]> vaikene.ee Git - evaf/blob - src/plugins/SdiWindow/sdiwindow.h
31b311d60454d8a4c4d04efa640f5fb88bf7b4b4
[evaf] / src / plugins / SdiWindow / sdiwindow.h
1 /**
2 * @file SdiWindow/sdiwindow.h
3 * @brief SdiWindow module's implementation
4 * @author Enar Vaikene
5 *
6 * Copyright (c) 2011 Enar Vaikene
7 *
8 * This file is part of the eVaf C++ cross-platform application development framework.
9 *
10 * This file can be used under the terms of the GNU General Public License
11 * version 3.0 as published by the Free Software Foundation and appearing in
12 * the file LICENSE included in the packaging of this file. Please review the
13 * the following information to ensure the GNU General Public License version
14 * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
15 *
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
18 */
19
20 #ifndef __SDIWINDOW_SDIWINDOW_H
21 # define __SDIWINDOW_SDIWINDOW_H
22
23 #include "isdiwindow.h"
24
25 #include <Plugins/iPlugin>
26
27 #include <QObject>
28 #include <QString>
29 #include <QWidget>
30 #include <QList>
31 #include <QPointer>
32
33 class QVBoxLayout;
34
35 namespace eVaf {
36 namespace SdiWindow {
37 namespace Internal {
38
39 /**
40 * Main window widget
41 */
42 class MainWindow : public QWidget
43 {
44 Q_OBJECT
45
46 public:
47
48 MainWindow(QWidget * parent = 0, Qt::WindowFlags flags = 0);
49
50 virtual ~MainWindow();
51
52 bool init();
53
54 void done();
55
56 void addWidget(QWidget * widget);
57
58 void addLayout(QLayout * layout);
59
60
61 private: // Methods
62
63 void setWindowSize();
64
65 void saveSettings();
66
67 void restoreSettings();
68
69
70 private: // Members
71
72 /// The layout of the window
73 QVBoxLayout * mLayout;
74
75 /// Widgets and layouts added to the main window
76 QList<QPointer<QObject> > mItemsAdded;
77
78 };
79
80 /**
81 * iSdiWindow interface implementation
82 */
83 class SdiWindowImpl : public iSdiWindow
84 {
85 Q_OBJECT
86
87 public:
88
89 SdiWindowImpl();
90
91 virtual ~SdiWindowImpl();
92
93 bool init(const QString & args);
94
95 void done();
96
97 bool isReady() const { return mReady; }
98
99 virtual void addWidget(QWidget * widget) { wWindow->addWidget(widget); }
100
101 virtual void addLayout(QLayout * layout) { wWindow->addLayout(layout); }
102
103
104 private: // Members
105
106 /// Ready flag
107 bool mReady;
108
109 /// The main window widget
110 MainWindow * wWindow;
111 };
112
113 /**
114 * SdiWindow module's implementation
115 */
116 class SdiWindowPlugin : public Plugins::iPlugin
117 {
118 Q_OBJECT
119
120 public:
121
122 SdiWindowPlugin();
123
124 virtual ~SdiWindowPlugin();
125
126 virtual bool init(const QString & args);
127
128 virtual void done();
129
130 virtual bool isReady() const { return mWindow != 0 && mWindow->isReady(); }
131
132
133 private:
134
135 /// iSdiWindow interface implementation
136 SdiWindowImpl * mWindow;
137 };
138
139 } // namespace eVaf::SdiWindow::Internal
140 } // namespace eVaf::SdiWindow
141 } // namespace eVaf
142
143 #endif // sdiwindow.h