From 54f282ee6797c05e60993632218875092362bdf7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enar=20V=C3=A4ikene?= Date: Tue, 29 Nov 2011 15:05:41 +0200 Subject: [PATCH] Changed the SdiWindow::iSdiWindow interface. The SdiWindow module is now a simple window manager that manages Gui::Window objects. Adding individual widgets and layouts is no more supported. The idea is that the same Gui::Window object could be added to many different window managers, not only the SdiWindow. --- src/plugins/SdiWindow/CMakeLists.txt | 2 +- src/plugins/SdiWindow/isdiwindow.h | 28 ++++++++++++---------------- src/plugins/SdiWindow/sdiwindow.cpp | 24 +++++++++--------------- src/plugins/SdiWindow/sdiwindow.h | 11 +++++------ src/plugins/SdiWindow/version.h | 4 ++-- 5 files changed, 29 insertions(+), 40 deletions(-) diff --git a/src/plugins/SdiWindow/CMakeLists.txt b/src/plugins/SdiWindow/CMakeLists.txt index b1a9c79..c87eed6 100644 --- a/src/plugins/SdiWindow/CMakeLists.txt +++ b/src/plugins/SdiWindow/CMakeLists.txt @@ -11,7 +11,7 @@ add_definitions(-DSDIWINDOW_LIBRARY) include_directories(${eVaf_INCLUDE}) # Required eVaf libraries -set(eVaf_LIBRARIES CommonLib PluginsLib) +set(eVaf_LIBRARIES CommonLib PluginsLib GuiLib) # Source files set(SRCS diff --git a/src/plugins/SdiWindow/isdiwindow.h b/src/plugins/SdiWindow/isdiwindow.h index 28e774d..13b9903 100644 --- a/src/plugins/SdiWindow/isdiwindow.h +++ b/src/plugins/SdiWindow/isdiwindow.h @@ -29,13 +29,17 @@ class QWidget; class QLayout; namespace eVaf { + +namespace Gui { + class Window; +} // namespace eVaf::Gui + namespace SdiWindow { /** - * Main window interface for eVaf applications implementing the Single Document Interface. + * Single Document Interface window manager for eVaf applications. * - * The iSdiWindow interface provides access to the SDI main window. The SDI main window is - * an empty window that the application can fill with widgets. + * The iSdiWindow interface implements an SDI window manager. */ struct SDIWINDOW_EXPORT iSdiWindow { @@ -50,26 +54,18 @@ struct SDIWINDOW_EXPORT iSdiWindow static iSdiWindow * instance(); /** - * Adds the widget to the end of the main window layout - * @param widget The widget - * - * This function adds the widget to the end of the main window layout. - */ - virtual void addWidget(QWidget * widget) = 0; - - /** - * Adds the layout to the end of the main window layout - * @param layout The layout + * Adds the window to the main SDI window + * @param window The window * - * This function adds the new layout to the end of the main window layout. + * This function adds a window to the main SDI layout. */ - virtual void addLayout(QLayout * layout) = 0; + virtual void addWindow(Gui::Window * window) = 0; }; } // namespace eVaf::SdiWindow } // namespace eVaf -Q_DECLARE_INTERFACE(eVaf::SdiWindow::iSdiWindow, "eVaf.SdiWindow.iSdiWindow/1.0") +Q_DECLARE_INTERFACE(eVaf::SdiWindow::iSdiWindow, "eVaf.SdiWindow.iSdiWindow/1.1") #endif // isdiwindow.h diff --git a/src/plugins/SdiWindow/sdiwindow.cpp b/src/plugins/SdiWindow/sdiwindow.cpp index aba9ce2..aa264de 100644 --- a/src/plugins/SdiWindow/sdiwindow.cpp +++ b/src/plugins/SdiWindow/sdiwindow.cpp @@ -106,26 +106,20 @@ void MainWindow::done() close(); - // Delete all the items added to the main window - while (mItemsAdded.count() > 0) { - QWeakPointer item = mItemsAdded.takeAt(0); - if (!item.isNull()) - delete item.data(); - } + // Delete the window + if (mWindow) + delete mWindow.data(); EVAF_INFO("%s finalized", qPrintable(objectName())); } -void MainWindow::addWidget(QWidget * widget) -{ - mLayout->addWidget(widget); - mItemsAdded.append(widget); -} - -void MainWindow::addLayout(QLayout * layout) +void MainWindow::addWindow(Gui::Window * window) { - mLayout->addLayout(layout); - mItemsAdded.append(layout); + // Delete the existing window + if (mWindow) + delete mWindow.data(); + mLayout->addWidget(window); + mWindow = window; } void MainWindow::saveSettings() diff --git a/src/plugins/SdiWindow/sdiwindow.h b/src/plugins/SdiWindow/sdiwindow.h index f0cfe6f..f884255 100644 --- a/src/plugins/SdiWindow/sdiwindow.h +++ b/src/plugins/SdiWindow/sdiwindow.h @@ -23,6 +23,7 @@ #include "isdiwindow.h" #include +#include #include #include @@ -56,9 +57,7 @@ public: virtual bool isReady() { return mReady; } - virtual void addWidget(QWidget * widget); - - virtual void addLayout(QLayout * layout); + virtual void addWindow(Gui::Window * window); private: // Methods @@ -75,11 +74,11 @@ private: // Members /// Ready flag bool mReady; - /// The layout of the window + /// The layout of the main window QVBoxLayout * mLayout; - /// Widgets and layouts added to the main window - QList > mItemsAdded; + /// eVaf GUI window implementing the main window + QWeakPointer mWindow; }; diff --git a/src/plugins/SdiWindow/version.h b/src/plugins/SdiWindow/version.h index 9671900..f3fedec 100644 --- a/src/plugins/SdiWindow/version.h +++ b/src/plugins/SdiWindow/version.h @@ -25,12 +25,12 @@ /** * Module/library version number in the form major,minor,release,build */ -#define VER_FILE_VERSION 0,2,4,5 +#define VER_FILE_VERSION 0,3,1,6 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.2.4.5\0" +#define VER_FILE_VERSION_STR "0.3.1.6\0" /** * Module/library name (shall end with \0) -- 2.47.0