BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
InstrumentListModel.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Instrument/InstrumentListModel.h
6 //! @brief Defines class InstrumentListModel
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLISTMODEL_H
16 #define BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLISTMODEL_H
17 
18 #include <QAbstractListModel>
19 #include <QIcon>
20 
21 class InstrumentItem;
24 
25 //! List model for instruments.
26 //!
27 //! Used e.g. to present the instrument list in the instrument view.
28 class InstrumentListModel : public QAbstractListModel {
29  Q_OBJECT
30 
31 public:
32  InstrumentListModel(QObject* parent, InstrumentsEditController* ec);
33 
34  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
35 
36  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
37 
38  InstrumentItem* instrumentForIndex(const QModelIndex& index) const;
39 
40  QModelIndex addNewGISASInstrument();
41  QModelIndex addNewOffspecInstrument();
42  QModelIndex addNewSpecularInstrument();
43  QModelIndex addNewDepthProbeInstrument();
44 
45  void removeInstrument(const QModelIndex& index);
46 
47  QModelIndex copyInstrument(const QModelIndex& source);
48  QModelIndex copyInstrument(const InstrumentItem* source);
49 
50 private:
51  template <class Instrument>
52  QModelIndex addNewInstrument();
53  void onInstrumentNameChanged(const InstrumentItem* instrument);
54 
55 private:
57  QIcon m_gisasIcon;
61 };
62 
63 #endif // BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLISTMODEL_H
Abstract base class for instrument-specific item classes.
List model for instruments.
QModelIndex copyInstrument(const QModelIndex &source)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
InstrumentListModel(QObject *parent, InstrumentsEditController *ec)
QModelIndex addNewSpecularInstrument()
int rowCount(const QModelIndex &parent=QModelIndex()) const override
InstrumentsEditController * m_ec
QModelIndex addNewOffspecInstrument()
void removeInstrument(const QModelIndex &index)
void onInstrumentNameChanged(const InstrumentItem *instrument)
QModelIndex addNewGISASInstrument()
InstrumentItem * instrumentForIndex(const QModelIndex &index) const
QModelIndex addNewDepthProbeInstrument()
Class to modify the instruments list or a single instrument and provide the necessary signaling withi...