BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ItemStackWidget.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Common/ItemStackWidget.h
6 //! @brief Defines class ItemStackWidget
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_COMMON_ITEMSTACKWIDGET_H
16 #define BORNAGAIN_GUI_VIEW_COMMON_ITEMSTACKWIDGET_H
17 
18 #include <QWidget>
19 
20 class SessionModel;
21 class SessionItem;
22 
23 //! The ItemStackWidget class contains a stack of widgets presenting top level items
24 //! of SessionModel. Every item corresponds to its own widget.
25 
26 //! This is the base for ItemStackPresenter, which actually contains item
27 //! specific editor's logic. Used in InstrumentView, ImportDataView, JobView to show editors for
28 //! currently selected items.
29 
30 class ItemStackWidget : public QWidget {
31  Q_OBJECT
32 
33 public:
34  ItemStackWidget(QWidget* parent = nullptr);
35 
36  void setModel(SessionModel* model);
37 
38  QSize sizeHint() const override;
39  QSize minimumSizeHint() const override;
40 
41  void setSizeHint(const QSize& size_hint);
42 
43 public slots:
44  virtual void onModelAboutToBeReset();
45  virtual void onRowsAboutToBeRemoved(const QModelIndex& parent, int first, int);
46 
47 protected:
48  void connectModel();
49  void disconnectModel();
50  void validateItem(SessionItem* item);
51  virtual void removeWidgetForItem(SessionItem* item) = 0;
52  virtual void removeWidgets() = 0;
53 
54  class QStackedWidget* m_stackedWidget;
56  QSize m_size_hint;
57 };
58 
59 #endif // BORNAGAIN_GUI_VIEW_COMMON_ITEMSTACKWIDGET_H
The ItemStackWidget class contains a stack of widgets presenting top level items of SessionModel....
class QStackedWidget * m_stackedWidget
void setModel(SessionModel *model)
QSize minimumSizeHint() const override
virtual void removeWidgets()=0
void setSizeHint(const QSize &size_hint)
QSize sizeHint() const override
virtual void onModelAboutToBeReset()
virtual void removeWidgetForItem(SessionItem *item)=0
void validateItem(SessionItem *item)
Checks if model was set correctly.
ItemStackWidget(QWidget *parent=nullptr)
SessionModel * m_model
virtual void onRowsAboutToBeRemoved(const QModelIndex &parent, int first, int)
Base class for a GUI data item.
Definition: SessionItem.h:204
Base class for a GUI data collection. A collection is e.g. all real data (RealDataModel)....
Definition: SessionModel.h:42