BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ItemComboWidget.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/ItemComboWidget.h
6 //! @brief Defines class ItemComboWidget
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_ITEMCOMBOWIDGET_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_COMMONWIDGETS_ITEMCOMBOWIDGET_H
17 
18 #include "Base/Utils/IFactory.h"
20 #include <QMap>
21 #include <QString>
22 #include <QWidget>
23 
24 class SessionItem;
25 class SessionItemWidget;
26 class ItemComboToolBar;
27 class QStackedWidget;
28 
29 //! The ItemComboWidget class combines stack of widgets with QComboBox controller to switch between
30 //! widgets. It is used in the case when one SessionItem can be presented with different widgets.
31 
32 //! For example, in JobOutputDataWidget the results of the job can be presented with either
33 //! IntensityDataWidget or FitDataWidget, depending from the JobView's activity type.
34 
36  Q_OBJECT
37 
38 public:
39  using factory_function_t = std::function<SessionItemWidget*()>;
40 
41  explicit ItemComboWidget(QWidget* parent = 0);
42 
43  void registerWidget(const QString& presentationType, factory_function_t);
44 
45  virtual void setPresentation(const QString& presentationType);
46 
47  void setToolBarVisible(bool value);
48 
49 protected:
50  virtual QStringList activePresentationList(SessionItem* item);
51  virtual QStringList presentationList(SessionItem* item);
52  virtual QString itemPresentation() const;
53  QString selectedPresentation() const;
54  // SessionItem* currentItem();
55  // const SessionItem* currentItem() const;
56  void subscribeToItem();
57 
58 private slots:
59  void onComboChanged(const QString& name);
60 
61 private:
63 
65  QStackedWidget* m_stackedWidget;
66  // SessionItem* m_currentItem;
68  QMap<QString, SessionItemWidget*> m_presentationTypeToWidget;
69 };
70 
71 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_COMMONWIDGETS_ITEMCOMBOWIDGET_H
Defines interface class IFactory.
Defines class ItemComboWidget.
The ItemComboToolBar class is a styled toolbar on top of ItemComboWidget.
The ItemComboWidget class combines stack of widgets with QComboBox controller to switch between widge...
QMap< QString, SessionItemWidget * > m_presentationTypeToWidget
QStackedWidget * m_stackedWidget
void setToolBarVisible(bool value)
std::function< SessionItemWidget *()> factory_function_t
QString selectedPresentation() const
Presentation selected in combo selector.
virtual void setPresentation(const QString &presentationType)
Sets stack to show widget corresponding to given presentation.
ItemComboToolBar * m_toolBar
void onComboChanged(const QString &name)
virtual QStringList activePresentationList(SessionItem *item)
Returns list of active presentations for given item.
virtual QStringList presentationList(SessionItem *item)
Returns full list of presentations available for given item.
IFactory< QString, SessionItemWidget > m_widgetFactory
virtual QString itemPresentation() const
Presentation which should be shown for current item.
ItemComboWidget(QWidget *parent=0)
void registerWidget(const QString &presentationType, factory_function_t)
void setSizeToCurrentWidget()
Resizes QStackedWidget to currently active page.
The SessionItemWidget class is a base for all widgets representing the content of SessionItem.
QString const & name(EShape k)
Definition: particles.cpp:21