BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
InstrumentViewActions.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/InstrumentWidgets/InstrumentViewActions.h
6 //! @brief Defines class InstrumentViewActions
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_COREGUI_VIEWS_INSTRUMENTWIDGETS_INSTRUMENTVIEWACTIONS_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_INSTRUMENTWIDGETS_INSTRUMENTVIEWACTIONS_H
17 
18 #include <QMap>
19 #include <QObject>
20 
21 class QAction;
22 class SessionModel;
23 class QItemSelectionModel;
24 class QModelIndex;
25 class QMenu;
26 
27 //! Collection of actions to add/remove/clone instrument.
28 
29 class InstrumentViewActions : public QObject {
30  Q_OBJECT
31 
32 public:
33  explicit InstrumentViewActions(QWidget* parent = nullptr);
35 
36  void setModel(SessionModel* model);
37  void setSelectionModel(QItemSelectionModel* selectionModel);
38 
39  QMenu* instrumentMenu();
40 
41 public slots:
42  void onRemoveInstrument();
43  void onCloneInstrument();
44  void onContextMenuRequest(const QPoint& point, const QModelIndex& indexAtPoint);
45 
46 private:
47  void setAllActionsEnabled(bool value);
48  void updateSelection();
49  QString suggestInstrumentName(const QString& currentName);
50  QMap<QString, int> mapOfNames();
51  void initAddInstrumentMenu();
52 
57  QItemSelectionModel* m_selectionModel;
58 };
59 
60 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_INSTRUMENTWIDGETS_INSTRUMENTVIEWACTIONS_H
Collection of actions to add/remove/clone instrument.
void setAllActionsEnabled(bool value)
void onRemoveInstrument()
Removes currently selected instrument.
void onContextMenuRequest(const QPoint &point, const QModelIndex &indexAtPoint)
void onCloneInstrument()
Clones currently selected instrument.
void setModel(SessionModel *model)
void setSelectionModel(QItemSelectionModel *selectionModel)
QMap< QString, int > mapOfNames()
void initAddInstrumentMenu()
Constructs menu to add instruments of various types.
InstrumentViewActions(QWidget *parent=nullptr)
QItemSelectionModel * m_selectionModel
QMenu * instrumentMenu()
Returns menu to create one of available instrument types.
QString suggestInstrumentName(const QString &currentName)