BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
SampleListModel.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/SampleDesigner/SampleListModel.h
6 //! @brief Defines class SampleListModel
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_SAMPLEDESIGNER_SAMPLELISTMODEL_H
16 #define BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLELISTMODEL_H
17 
18 #include <QAbstractItemModel>
19 
20 class MultiLayerItems;
21 class MultiLayerItem;
22 
23 //! List model for sample selection (used in the left pane of the layer oriented sample editor)
24 class SampleListModel : public QAbstractListModel {
25 public:
26  SampleListModel(QObject* parent, MultiLayerItems* model);
27 
28  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
29  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
30  Qt::ItemFlags flags(const QModelIndex& index) const override;
31  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
32 
33  MultiLayerItem* itemForIndex(const QModelIndex& index) const;
34  QModelIndex indexForItem(MultiLayerItem* item) const;
35 
36  //! Remove the given sample. nullptr is allowed.
37  void removeSample(MultiLayerItem* item);
38 
39  //! Create a new sample (sample) and return the index of it.
40  QModelIndex createSample();
41 
42  //! Create sample from list of built-in examples.
43  //!
44  //! Returns invalid index if anything went wrong.
45  QModelIndex createSampleFromExamples(const QString& className, const QString& title,
46  const QString& description);
47 
48 #ifdef BORNAGAIN_PYTHON
49  //! Create sample from an imported python code.
50  //!
51  //! Returns invalid index if anything went wrong.
52  QModelIndex createSampleFromPython();
53 #endif
54 
55 private:
57 };
58 
59 #endif // BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLELISTMODEL_H
Main model to hold sample items.
List model for sample selection (used in the left pane of the layer oriented sample editor)
QModelIndex createSample()
Create a new sample (sample) and return the index of it.
Qt::ItemFlags flags(const QModelIndex &index) const override
SampleListModel(QObject *parent, MultiLayerItems *model)
QModelIndex createSampleFromPython()
Create sample from an imported python code.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
void removeSample(MultiLayerItem *item)
Remove the given sample. nullptr is allowed.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
MultiLayerItem * itemForIndex(const QModelIndex &index) const
bool setData(const QModelIndex &index, const QVariant &value, int role) override
MultiLayerItems * m_sampleItems
QModelIndex createSampleFromExamples(const QString &className, const QString &title, const QString &description)
Create sample from list of built-in examples.
QModelIndex indexForItem(MultiLayerItem *item) const