BornAgain
1.19.79
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/View/Common/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_VIEW_COMMON_ITEMCOMBOWIDGET_H
16
#define BORNAGAIN_GUI_VIEW_COMMON_ITEMCOMBOWIDGET_H
17
18
#include "Base/Util/IFactory.h"
19
#include "
GUI/View/Common/SessionItemWidget.h
"
20
#include <QMap>
21
22
class
SessionItem
;
23
class
SessionItemWidget
;
24
class
ItemComboToolbar
;
25
class
QStackedWidget;
26
27
//! The ItemComboWidget class combines stack of widgets with QComboBox controller to switch between
28
//! widgets. It is used in the case when one SessionItem can be presented with different widgets.
29
30
//! For example, in JobDatafieldWidget the results of the job can be presented with either
31
//! IntensityDataWidget or FitDataWidget, depending from the JobView's activity type.
32
33
//! For the presentation the special value of an empty string can be used which results in an
34
//! empty widget being shown (with the toolbar hidden). In this case the current item can also
35
//! be \c nullptr and this presentation needs not to be listed in the (active)PresentationList
36
//! functions.
37
38
class
ItemComboWidget
:
public
SessionItemWidget
{
39
Q_OBJECT
40
41
public
:
42
using
factory_function_t
= std::function<
SessionItemWidget
*()>;
43
44
explicit
ItemComboWidget
(QWidget* parent =
nullptr
);
45
46
void
registerWidget
(
const
QString& presentationType,
factory_function_t
);
47
48
virtual
void
setPresentation
(
const
QString& presentationType);
49
50
void
setToolbarVisible
(
bool
value);
51
void
setItem
(
SessionItem
* item)
override
;
52
53
protected
:
54
virtual
QStringList
activePresentationList
(
SessionItem
* item);
55
virtual
QStringList
presentationList
(
SessionItem
* item);
56
virtual
QString
itemPresentation
()
const
;
57
QString
selectedPresentation
()
const
;
58
void
subscribeToItem
()
override
;
59
60
private
slots:
61
void
onComboChanged
(
const
QString&
name
);
62
63
private
:
64
void
setSizeToCurrentWidget
();
65
66
ItemComboToolbar
*
m_toolbar
;
67
QStackedWidget*
m_stackedWidget
;
68
IFactory<QString, SessionItemWidget>
m_widgetFactory
;
69
QMap<QString, SessionItemWidget*>
m_presentationTypeToWidget
;
70
QWidget*
m_blankWidget
;
71
};
72
73
#endif
// BORNAGAIN_GUI_VIEW_COMMON_ITEMCOMBOWIDGET_H
SessionItemWidget.h
Defines class ItemComboWidget.
ItemComboToolbar
The ItemComboToolbar class is a styled toolbar on top of ItemComboWidget. Contains ComboBox to switch...
Definition:
ItemComboToolbar.h:28
ItemComboWidget
The ItemComboWidget class combines stack of widgets with QComboBox controller to switch between widge...
Definition:
ItemComboWidget.h:38
ItemComboWidget::m_presentationTypeToWidget
QMap< QString, SessionItemWidget * > m_presentationTypeToWidget
Definition:
ItemComboWidget.h:69
ItemComboWidget::m_blankWidget
QWidget * m_blankWidget
Definition:
ItemComboWidget.h:70
ItemComboWidget::m_stackedWidget
QStackedWidget * m_stackedWidget
Definition:
ItemComboWidget.h:67
ItemComboWidget::ItemComboWidget
ItemComboWidget(QWidget *parent=nullptr)
Definition:
ItemComboWidget.cpp:21
ItemComboWidget::m_toolbar
ItemComboToolbar * m_toolbar
Definition:
ItemComboWidget.h:66
ItemComboWidget::factory_function_t
std::function< SessionItemWidget *()> factory_function_t
Definition:
ItemComboWidget.h:42
ItemComboWidget::setItem
void setItem(SessionItem *item) override
Definition:
ItemComboWidget.cpp:88
ItemComboWidget::selectedPresentation
QString selectedPresentation() const
Presentation selected in combo selector.
Definition:
ItemComboWidget.cpp:122
ItemComboWidget::setPresentation
virtual void setPresentation(const QString &presentationType)
Sets stack to show widget corresponding to given presentation.
Definition:
ItemComboWidget.cpp:50
ItemComboWidget::onComboChanged
void onComboChanged(const QString &name)
Definition:
ItemComboWidget.cpp:134
ItemComboWidget::activePresentationList
virtual QStringList activePresentationList(SessionItem *item)
Returns list of active presentations for given item. Active presentation is the one which is present ...
Definition:
ItemComboWidget.cpp:100
ItemComboWidget::presentationList
virtual QStringList presentationList(SessionItem *item)
Returns full list of presentations available for given item.
Definition:
ItemComboWidget.cpp:108
ItemComboWidget::subscribeToItem
void subscribeToItem() override
Definition:
ItemComboWidget.cpp:127
ItemComboWidget::m_widgetFactory
IFactory< QString, SessionItemWidget > m_widgetFactory
Definition:
ItemComboWidget.h:68
ItemComboWidget::itemPresentation
virtual QString itemPresentation() const
Presentation which should be shown for current item.
Definition:
ItemComboWidget.cpp:115
ItemComboWidget::registerWidget
void registerWidget(const QString &presentationType, factory_function_t)
Definition:
ItemComboWidget.cpp:44
ItemComboWidget::setSizeToCurrentWidget
void setSizeToCurrentWidget()
Resizes QStackedWidget to currently active page.
Definition:
ItemComboWidget.cpp:141
ItemComboWidget::setToolbarVisible
void setToolbarVisible(bool value)
Definition:
ItemComboWidget.cpp:83
SessionItemWidget
The SessionItemWidget class is a base for all widgets representing the content of SessionItem....
Definition:
SessionItemWidget.h:30
SessionItem
Base class for a GUI data item.
Definition:
SessionItem.h:204
GUI::RealSpace::Particles::name
QString const & name(EShape k)
Definition:
particles.cpp:20
GUI
View
Common
ItemComboWidget.h
Generated by
1.9.1