BornAgain  1.19.0
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/coregui/Views/CommonWidgets/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_COREGUI_VIEWS_COMMONWIDGETS_ITEMSTACKWIDGET_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_COMMONWIDGETS_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 = 0);
35 
36  void setModel(SessionModel* model);
37 
38  QSize sizeHint() const;
39  QSize minimumSizeHint() const;
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_COREGUI_VIEWS_COMMONWIDGETS_ITEMSTACKWIDGET_H
The ItemStackWidget class contains a stack of widgets presenting top level items of SessionModel.
class QStackedWidget * m_stackedWidget
ItemStackWidget(QWidget *parent=0)
void setModel(SessionModel *model)
QSize sizeHint() const
virtual void removeWidgets()=0
void setSizeHint(const QSize &size_hint)
virtual void onModelAboutToBeReset()
virtual void removeWidgetForItem(SessionItem *item)=0
QSize minimumSizeHint() const
void validateItem(SessionItem *item)
Checks if model was set correctly.
SessionModel * m_model
virtual void onRowsAboutToBeRemoved(const QModelIndex &parent, int first, int)