BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
RealDataTreeModel.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Import/RealDataTreeModel.h
6 //! @brief Defines class RealDataTreeModel
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_IMPORT_REALDATATREEMODEL_H
16 #define BORNAGAIN_GUI_VIEW_IMPORT_REALDATATREEMODEL_H
17 
18 #include <QAbstractItemModel>
19 #include <QSet>
20 
21 class RealDataModel;
22 class RealDataItem;
23 
24 //! Tree model for real data item selection. Used for the tree in the import view.
25 class RealDataTreeModel : public QAbstractItemModel {
26 public:
27  explicit RealDataTreeModel(QObject* parent, RealDataModel* model);
28  void setVisibleRanks(QSet<int> visibleRanks);
29 
30  QModelIndex index(int row, int column,
31  const QModelIndex& parent = QModelIndex()) const override;
32 
33  QModelIndex parent(const QModelIndex& index) const override;
34  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
35  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
36  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
37  Qt::ItemFlags flags(const QModelIndex& index) const override;
38  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
39  RealDataItem* itemForIndex(const QModelIndex& index) const;
40  QModelIndex indexForItem(RealDataItem* item) const;
41 
43 
44  void removeItem(RealDataItem* item);
47  RealDataItem* insertDataItem(int rank);
48 
49  //! The topmost visible item. Can be null of course.
50  RealDataItem* topMostItem() const;
51 
52  QModelIndex indexOfHeadline(int rank) const;
53  bool isHeadline(const QModelIndex& index) const;
54 
55 private:
56  void updateSubscriptions();
58  void clear();
59 
60 private:
61  RealDataModel* m_model = nullptr;
62  QVector<RealDataItem*> m_items[2]; //< Items borrowed from realDataModel. Never delete the ptrs!
63  QSet<int> m_visibleRanks;
64 };
65 
66 #endif // BORNAGAIN_GUI_VIEW_IMPORT_REALDATATREEMODEL_H
Provides access to experimental data, for display and fitting. Owns an AbstractDataLoader.
Definition: RealDataItem.h:33
The RealDataModel class is a model to store all imported RealDataItem's.
Definition: RealDataModel.h:24
Tree model for real data item selection. Used for the tree in the import view.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QModelIndex parent(const QModelIndex &index) const override
QModelIndex indexForItem(RealDataItem *item) const
QSet< int > m_visibleRanks
Qt::ItemFlags flags(const QModelIndex &index) const override
bool setData(const QModelIndex &index, const QVariant &value, int role) override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
RealDataItem * insertIntensityDataItem()
bool isHeadline(const QModelIndex &index) const
RealDataModel * m_model
int columnCount(const QModelIndex &parent=QModelIndex()) const override
RealDataTreeModel(QObject *parent, RealDataModel *model)
RealDataItem * topMostItem() const
The topmost visible item. Can be null of course.
RealDataItem * insertSpecularDataItem()
RealDataItem * itemForIndex(const QModelIndex &index) const
QVector< RealDataItem * > m_items[2]
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
void onContentsProcessed(RealDataItem *item)
void removeItem(RealDataItem *item)
void setVisibleRanks(QSet< int > visibleRanks)
QModelIndex indexOfHeadline(int rank) const
RealDataItem * insertDataItem(int rank)