File: ItemComboWidget.h

package info (click to toggle)
bornagain 1.18.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 118,800 kB
  • sloc: cpp: 469,684; python: 38,920; xml: 805; awk: 630; sh: 286; ansic: 37; makefile: 25
file content (72 lines) | stat: -rw-r--r-- 2,490 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// ************************************************************************** //
//
//  BornAgain: simulate and fit scattering at grazing incidence
//
//! @file      GUI/coregui/Views/CommonWidgets/ItemComboWidget.h
//! @brief     Defines class ItemComboWidget
//!
//! @homepage  http://www.bornagainproject.org
//! @license   GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************** //

#ifndef BORNAGAIN_GUI_COREGUI_VIEWS_COMMONWIDGETS_ITEMCOMBOWIDGET_H
#define BORNAGAIN_GUI_COREGUI_VIEWS_COMMONWIDGETS_ITEMCOMBOWIDGET_H

#include "Fit/TestEngine/IFactory.h"
#include "GUI/coregui/Views/CommonWidgets/SessionItemWidget.h"
#include <QMap>
#include <QString>
#include <QWidget>

class SessionItem;
class SessionItemWidget;
class ItemComboToolBar;
class QStackedWidget;

//! The ItemComboWidget class combines stack of widgets with QComboBox controller to switch between
//! widgets. It is used in the case when one SessionItem can be presented with different widgets.

//! For example, in JobOutputDataWidget the results of the job can be presented with either
//! IntensityDataWidget or FitDataWidget, depending from the JobView's activity type.

class ItemComboWidget : public SessionItemWidget
{
    Q_OBJECT

public:
    using factory_function_t = std::function<SessionItemWidget*()>;

    explicit ItemComboWidget(QWidget* parent = 0);

    void registerWidget(const QString& presentationType, factory_function_t);

    virtual void setPresentation(const QString& presentationType);

    void setToolBarVisible(bool value);

protected:
    virtual QStringList activePresentationList(SessionItem* item);
    virtual QStringList presentationList(SessionItem* item);
    virtual QString itemPresentation() const;
    QString selectedPresentation() const;
    //    SessionItem* currentItem();
    //    const SessionItem* currentItem() const;
    void subscribeToItem();

private slots:
    void onComboChanged(const QString& name);

private:
    void setSizeToCurrentWidget();

    ItemComboToolBar* m_toolBar;
    QStackedWidget* m_stackedWidget;
    //    SessionItem* m_currentItem;
    IFactory<QString, SessionItemWidget> m_widgetFactory;
    QMap<QString, SessionItemWidget*> m_presentationTypeToWidget;
};

#endif // BORNAGAIN_GUI_COREGUI_VIEWS_COMMONWIDGETS_ITEMCOMBOWIDGET_H