BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
InstrumentLibraryEditor.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Instrument/InstrumentLibraryEditor.h
6 //! @brief Defines class InstrumentLibraryEditor
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_INSTRUMENTLIBRARYEDITOR_H
16 #define BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLIBRARYEDITOR_H
17 
19 #include <QDialog>
20 
21 class InstrumentItem;
22 
23 namespace Ui {
24 
26 }
27 
28 class InstrumentLibraryEditor : public QDialog {
29  Q_OBJECT
30 
31 public:
32  InstrumentLibraryEditor(QWidget* parent);
33  ~InstrumentLibraryEditor() override;
34 
35  void setGisasEnabled(bool b);
36  void setOffspecEnabled(bool b);
37  void setSpecularEnabled(bool b);
38  void setDepthProbeEnabled(bool b);
39 
40  //! Execute the dialog for choosing an instrument from the library.
41  //! Returns nullptr if canceled
43 
44  //! Execute the dialog to add an instrument to the library.
45  void execAdd(const InstrumentItem& instrumentToAdd);
46 
47 private:
48  void onItemDoubleClickedForChoose(const QModelIndex& index);
50  QList<QAction*> getOverlayActions(const QModelIndex& index, bool asHover);
52 
53  void onInstrumentNameEdited(const QString& newName);
54  void onInstrumentDescriptionEdited(const QString& t);
56 
57 private:
58  //! A model extension for InstrumentsTreeModel which
59  //! * shows a "NEW" sign in the icon of a newly added instrument.
60  //! * creates a HTML text for the Display role
62  public:
63  TreeModel(QObject* parent, InstrumentCollection* model);
64 
65  //! Set the instrument which shall have a "NEW" sign in its icon
66  void setNewInstrument(InstrumentItem* addedInstrument);
67 
68  QVariant data(const QModelIndex& index, int role) const override;
69 
70  private:
72  };
73 
74  Ui::InstrumentLibraryEditor* m_ui;
77 };
78 
79 #endif // BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLIBRARYEDITOR_H
Defines class InstrumentsTreeModel.
Abstract base class for instrument-specific item classes.
A model extension for InstrumentsTreeModel which.
void setNewInstrument(InstrumentItem *addedInstrument)
Set the instrument which shall have a "NEW" sign in its icon.
TreeModel(QObject *parent, InstrumentCollection *model)
QVariant data(const QModelIndex &index, int role) const override
Ui::InstrumentLibraryEditor * m_ui
InstrumentLibraryEditor(QWidget *parent)
void onInstrumentDescriptionEdited(const QString &t)
InstrumentItem * execChoose()
Execute the dialog for choosing an instrument from the library. Returns nullptr if canceled.
void onItemDoubleClickedForChoose(const QModelIndex &index)
QList< QAction * > getOverlayActions(const QModelIndex &index, bool asHover)
void execAdd(const InstrumentItem &instrumentToAdd)
Execute the dialog to add an instrument to the library.
void onInstrumentNameEdited(const QString &newName)
Tree model for instrument item selection. Used e.g. for the instrument library.
QModelIndex parent(const QModelIndex &index) const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override