BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
FitParameterModel.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Model/FitParameterModel.h
6 //! @brief Defines class FitParameterModel
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_MODEL_MODEL_FITPARAMETERMODEL_H
16 #define BORNAGAIN_GUI_MODEL_MODEL_FITPARAMETERMODEL_H
17 
18 #include <QAbstractItemModel>
19 #include <QStringList>
20 
21 class SessionModel;
23 class SessionItem;
24 
25 //! Model to show items from FitParameterContainer in 5 column tree view.
26 class FitParameterModel : public QAbstractItemModel {
27  Q_OBJECT
28 
29 public:
30  explicit FitParameterModel(FitParameterContainerItem* fitParContainer,
31  QObject* parent = nullptr);
32 
33  ~FitParameterModel() override;
34 
36 
37  Qt::ItemFlags flags(const QModelIndex& index) const override;
38  QModelIndex index(int row, int column, const QModelIndex& parent) const override;
39  QModelIndex parent(const QModelIndex& child) const override;
40  int rowCount(const QModelIndex& parent) const override;
41  int columnCount(const QModelIndex& parent) const override;
42  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
43  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
44 
45  QStringList mimeTypes() const override;
46  Qt::DropActions supportedDragActions() const override;
47  Qt::DropActions supportedDropActions() const override;
48  QMimeData* mimeData(const QModelIndexList& indexes) const override;
49  bool canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
50  const QModelIndex& parent) const override;
51  bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
52  const QModelIndex& parent) override;
53 
54  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
55 
56  QModelIndex indexOfItem(SessionItem* item) const;
57  SessionItem* itemForIndex(const QModelIndex& index) const;
58 
59  SessionModel* sourceModel() const;
60 
61  bool isValidSourceItem(SessionItem* item) const;
62 
63 private slots:
64  void onSourceDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight,
65  const QVector<int>& roles);
66  void onSourceRowsRemoved(const QModelIndex& parent, int first, int last);
68 
69 private:
70  void connectModel(QAbstractItemModel* sourceModel, bool isConnect = true) const;
71  void addColumn(EColumn id, const QString& name, const QString& tooltip);
72 
74  QMap<int, QString> m_columnNames;
75  QMap<int, QString> m_columnToolTips;
76 };
77 
78 inline Qt::DropActions FitParameterModel::supportedDragActions() const
79 {
80  return Qt::MoveAction | Qt::CopyAction;
81 }
82 
83 inline Qt::DropActions FitParameterModel::supportedDropActions() const
84 {
85  return Qt::MoveAction | Qt::CopyAction;
86 }
87 
88 #endif // BORNAGAIN_GUI_MODEL_MODEL_FITPARAMETERMODEL_H
The FitParameterContainerItem class is a collection of all defined fit parameters in JobItem.
Model to show items from FitParameterContainer in 5 column tree view.
int columnCount(const QModelIndex &parent) const override
Qt::DropActions supportedDragActions() const override
Qt::ItemFlags flags(const QModelIndex &index) const override
int rowCount(const QModelIndex &parent) const override
QModelIndex indexOfItem(SessionItem *item) const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
void onSourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
SessionItem * itemForIndex(const QModelIndex &index) const
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
SessionModel * sourceModel() const
Qt::DropActions supportedDropActions() const override
FitParameterModel(FitParameterContainerItem *fitParContainer, QObject *parent=nullptr)
QMap< int, QString > m_columnToolTips
bool setData(const QModelIndex &index, const QVariant &value, int role) override
~FitParameterModel() override
QModelIndex parent(const QModelIndex &child) const override
QStringList mimeTypes() const override
QModelIndex index(int row, int column, const QModelIndex &parent) const override
void addColumn(EColumn id, const QString &name, const QString &tooltip)
FitParameterContainerItem * m_parameterContainer
void connectModel(QAbstractItemModel *sourceModel, bool isConnect=true) const
QMimeData * mimeData(const QModelIndexList &indexes) const override
void onSourceRowsRemoved(const QModelIndex &parent, int first, int last)
QMap< int, QString > m_columnNames
bool isValidSourceItem(SessionItem *item) const
Returns true if given item still exists in source model.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Base class for a GUI data item.
Definition: SessionItem.h:204
Base class for a GUI data collection. A collection is e.g. all real data (RealDataModel)....
Definition: SessionModel.h:42
QString const & name(EShape k)
Definition: particles.cpp:20