]> vaikene.ee Git - evaf/blobdiff - src/plugins/SdiWindow/sdiwindow.h
Warning fixes and copyright update.
[evaf] / src / plugins / SdiWindow / sdiwindow.h
index 31b311d60454d8a4c4d04efa640f5fb88bf7b4b4..08bfcd90e5be8b09cf0afcf2979dd988a3cbb7ef 100644 (file)
@@ -3,7 +3,7 @@
  * @brief SdiWindow module's implementation
  * @author Enar Vaikene
  *
- * Copyright (c) 2011 Enar Vaikene
+ * Copyright (c) 2011-2019 Enar Vaikene
  *
  * This file is part of the eVaf C++ cross-platform application development framework.
  *
 #include "isdiwindow.h"
 
 #include <Plugins/iPlugin>
+#include <Gui/Panel>
 
 #include <QObject>
 #include <QString>
 #include <QWidget>
 #include <QList>
-#include <QPointer>
+#include <QVector>
+#include <QHash>
+#include <QScopedPointer>
 
 class QVBoxLayout;
 
@@ -37,25 +40,37 @@ namespace SdiWindow {
 namespace Internal {
 
 /**
- * Main window widget
+ * Main window widget implementing the iSdiWindow interface
  */
-class MainWindow : public QWidget
+class MainWindow : public QWidget, public iSdiWindow
 {
     Q_OBJECT
+    Q_INTERFACES(eVaf::SdiWindow::iSdiWindow)
 
 public:
 
-    MainWindow(QWidget * parent = 0, Qt::WindowFlags flags = 0);
+    MainWindow(QWidget * parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
 
     virtual ~MainWindow();
 
-    bool init();
+    virtual bool init(QString const & args);
 
-    void done();
+    virtual void done();
+
+    virtual bool isReady() { return mReady; }
+
+    virtual void addPanel(QString const & name, Gui::Panel * panel);
+
+    virtual Gui::Panel * panel(QString const & name) const;
+
+    virtual bool showPanel(QString const & name);
+
+    virtual void changeEvent(QEvent * e);
 
-    void addWidget(QWidget * widget);
+    virtual void closeEvent(QCloseEvent * e);
 
-    void addLayout(QLayout * layout);
+
+protected: // Methods
 
 
 private: // Methods
@@ -69,45 +84,40 @@ private: // Methods
 
 private: // Members
 
-    /// The layout of the window
-    QVBoxLayout * mLayout;
-
-    /// Widgets and layouts added to the main window
-    QList<QPointer<QObject> > mItemsAdded;
-
-};
+    /// Ready flag
+    bool mReady;
 
-/**
- * iSdiWindow interface implementation
- */
-class SdiWindowImpl : public iSdiWindow
-{
-    Q_OBJECT
+    /// The layout of the main window
+    QVBoxLayout * mLayout;
 
-public:
+    /// Name of the main panel that becomes part of this window
+    QString mMainPanelName;
 
-    SdiWindowImpl();
+    /// List of GUI::Panel objects added to the manager
+    QList<Gui::Panel *> mPanels;
 
-    virtual ~SdiWindowImpl();
+    /// List of minimized GUI::Panel objects
+    QVector<Gui::Panel *> mMinimizedPanels;
 
-    bool init(const QString & args);
+    /// Hash with panel names
+    QHash<QString, Gui::Panel *> mPanelNames;
 
-    void done();
+    /// Current main panel added to this window
+    Gui::Panel * mMainPanel;
 
-    bool isReady() const { return mReady; }
 
-    virtual void addWidget(QWidget * widget) { wWindow->addWidget(widget); }
+private: // Methods
 
-    virtual void addLayout(QLayout * layout) { wWindow->addLayout(layout); }
+    /// Gets the main panel name from module attributes
+    QString getMainPanelName(QString const & args) const;
 
 
-private: // Members
+private slots:
 
-    /// Ready flag
-    bool mReady;
+    /// Panel destroyed signal. We need to remove the panel from all the
+    /// lists.
+    void panelDestroyed(QObject * obj = nullptr);
 
-    /// The main window widget
-    MainWindow * wWindow;
 };
 
 /**
@@ -116,6 +126,7 @@ private: // Members
 class SdiWindowPlugin : public Plugins::iPlugin
 {
     Q_OBJECT
+    Q_INTERFACES(eVaf::Plugins::iPlugin)
 
 public:
 
@@ -127,13 +138,13 @@ public:
 
     virtual void done();
 
-    virtual bool isReady() const { return mWindow != 0 && mWindow->isReady(); }
+    virtual bool isReady() const { return mWindow != nullptr && mWindow->isReady(); }
 
 
 private:
 
     /// iSdiWindow interface implementation
-    SdiWindowImpl * mWindow;
+    QScopedPointer<MainWindow> mWindow;
 };
 
 } // namespace eVaf::SdiWindow::Internal