BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
FitParameterDelegate.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Fit/FitParameterDelegate.h
6 //! @brief Defines class FitParameterDelegate
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2021
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_VIEW_FIT_FITPARAMETERDELEGATE_H
16 #define BORNAGAIN_GUI_VIEW_FIT_FITPARAMETERDELEGATE_H
17 
18 #include <QStyledItemDelegate>
19 
20 //! The FitParameterDelegate class presents the content of SessionModel items in
21 //! standard QTreeView. Extents base QItemDelegate with possibility to show/edit
22 //! our custom QVariant's.
23 
24 class FitParameterDelegate : public QStyledItemDelegate {
25  Q_OBJECT
26 public:
27  FitParameterDelegate(QObject* parent);
28 
29  void paint(QPainter* painter, const QStyleOptionViewItem& option,
30  const QModelIndex& index) const override;
31 
32  QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
33  const QModelIndex& index) const override;
34 
35  void setModelData(QWidget* editor, QAbstractItemModel* model,
36  const QModelIndex& index) const override;
37 
38  void setEditorData(QWidget* editor, const QModelIndex& index) const override;
39 
40  QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
41 
42  void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option,
43  const QModelIndex& index) const override;
44 
45 protected:
46  virtual QWidget* createEditorFromIndex(const QModelIndex& index, QWidget* parent) const;
47 
48 public slots:
49  void onCustomEditorDataChanged(const QVariant&);
50 
51 private:
52  void paintCustomLabel(QPainter* painter, const QStyleOptionViewItem& option,
53  const QModelIndex& index, const QString& text) const;
54 };
55 
56 #endif // BORNAGAIN_GUI_VIEW_FIT_FITPARAMETERDELEGATE_H
The FitParameterDelegate class presents the content of SessionModel items in standard QTreeView....
void setEditorData(QWidget *editor, const QModelIndex &index) const override
Propagates the data change from the model to the editor (if it is still opened).
void paintCustomLabel(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index, const QString &text) const
Paints custom text in a a place corresponding given index.
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Makes an editor occupying whole available space in a cell. If cell contains an icon as a decoration (...
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
Increases height of the row by 20% wrt the default.
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
FitParameterDelegate(QObject *parent)
void onCustomEditorDataChanged(const QVariant &)
Notifies everyone that the editor has completed editing the data.
virtual QWidget * createEditorFromIndex(const QModelIndex &index, QWidget *parent) const
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
Propagates changed data from the editor to the model.
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override