Debian Codegraph @

avogadro/qtgui/multiviewwidget.h

raw
1 /******************************************************************************
2 This source file is part of the Avogadro project.
3 This source code is released under the 3-Clause BSD License, (see "LICENSE").
4 ******************************************************************************/
5
6 #ifndef AVOGADRO_QTGUI_MULTIVIEWWIDGET_H
7 #define AVOGADRO_QTGUI_MULTIVIEWWIDGET_H
8
9 #include "avogadroqtguiexport.h"
10
11 #include <QtWidgets/QWidget>
12
13 namespace Avogadro {
14 namespace QtGui {
15
16 class ContainerWidget;
17 class ViewFactory;
18 class ActiveWidgetFilter;
19
20 /**
21 * @class MultiViewWidget multiviewwidget.h <avogadro/qtgui/multiviewwidget.h>
22 * @brief A widget that contains other views, taking on responsibility for
23 * defining the active view, the layout of the subviews and ownership of the
24 * widgets.
25 * @author Marcus D. Hanwell
26 */
27
28 class AVOGADROQTGUI_EXPORT MultiViewWidget : public QWidget
29 {
30 Q_OBJECT
31
32 public:
33 explicit MultiViewWidget(QWidget* parent = nullptr,
34 Qt::WindowFlags f = Qt::WindowFlags());
35 ~MultiViewWidget() override;
36
37 void addWidget(QWidget* widget);
38
39 /**
40 * @brief Get the currently active widget.
41 * @return The active widget.
42 */
43 QWidget* activeWidget();
44 void setActiveWidget(QWidget* widget);
45
46 void setFactory(ViewFactory* factory) { m_factory = factory; }
47 void setDefaultView(const QString& viewName) { m_defaultView = viewName; }
48
49 signals:
50 void activeWidgetChanged(QWidget* widget);
51
52 public slots:
53 void splitHorizontal();
54 void splitVertical();
55 void createView();
56 void removeView();
57
58 private:
59 QList<ContainerWidget*> m_children;
60 ViewFactory* m_factory;
61 QString m_defaultView;
62 QWidget* m_activeWidget;
63 ActiveWidgetFilter* m_activeFilter;
64
65 ContainerWidget* createContainer(QWidget* widget = nullptr);
66
67 void splitView(Qt::Orientation orient, ContainerWidget* container);
68 };
69
70 } // namespace QtGui
71 } // namespace Avogadro
72
73 #endif // AVOGADRO_QTGUI_MULTIVIEWWIDGET_H