From: Enar Väikene Date: Wed, 19 Oct 2011 10:08:01 +0000 (+0300) Subject: Changed the SdiWindow::iSdiWindow interface to be not derived from QObject. X-Git-Url: https://vaikene.ee/gitweb/gitweb.cgi?p=evaf;a=commitdiff_plain;h=ad70660919cd7b0e821e35548b6d1f5efa181c4c Changed the SdiWindow::iSdiWindow interface to be not derived from QObject. * No plans to use signals in this interface * Simplifies the implementation as we can now have one single class derived both from Widget and iSdiWindow * No need to link against the SdiWindow library as long as the iSdiWindow::instance() method is not used. --- diff --git a/src/apps/PswGen/GUI/CMakeLists.txt b/src/apps/PswGen/GUI/CMakeLists.txt index 060625b..329cd17 100644 --- a/src/apps/PswGen/GUI/CMakeLists.txt +++ b/src/apps/PswGen/GUI/CMakeLists.txt @@ -8,7 +8,7 @@ include(${QT_USE_FILE}) include_directories(${eVaf_INCLUDE}) # Required eVaf libraries -set(eVaf_LIBRARIES CommonLib PluginsLib SdiWindow) +set(eVaf_LIBRARIES CommonLib PluginsLib) # Source files set(SRCS diff --git a/src/plugins/SdiWindow/CMakeLists.txt b/src/plugins/SdiWindow/CMakeLists.txt index 9edf476..b1a9c79 100644 --- a/src/plugins/SdiWindow/CMakeLists.txt +++ b/src/plugins/SdiWindow/CMakeLists.txt @@ -22,7 +22,6 @@ set(SRCS # Header files for the meta-object compiler set(MOC_HDRS factory.h - isdiwindow.h sdiwindow.h ) diff --git a/src/plugins/SdiWindow/isdiwindow.h b/src/plugins/SdiWindow/isdiwindow.h index 8cd4343..28e774d 100644 --- a/src/plugins/SdiWindow/isdiwindow.h +++ b/src/plugins/SdiWindow/isdiwindow.h @@ -22,8 +22,8 @@ #include "libsdiwindow.h" -#include #include +#include class QWidget; class QLayout; @@ -37,18 +37,8 @@ namespace SdiWindow { * 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. */ -class SDIWINDOW_EXPORT iSdiWindow : public QObject +struct SDIWINDOW_EXPORT iSdiWindow { - Q_OBJECT - -public: - - /// Interface constructor - iSdiWindow() : QObject() {} - - /// Empty virtual destructor - virtual ~iSdiWindow() {} - /** * Returns the iSdiWindow interface instance * @return The iSdiWindow interface or zero if not available @@ -80,4 +70,6 @@ public: } // namespace eVaf::SdiWindow } // namespace eVaf +Q_DECLARE_INTERFACE(eVaf::SdiWindow::iSdiWindow, "eVaf.SdiWindow.iSdiWindow/1.0") + #endif // isdiwindow.h diff --git a/src/plugins/SdiWindow/sdiwindow.cpp b/src/plugins/SdiWindow/sdiwindow.cpp index 02de43a..aba9ce2 100644 --- a/src/plugins/SdiWindow/sdiwindow.cpp +++ b/src/plugins/SdiWindow/sdiwindow.cpp @@ -54,6 +54,7 @@ using namespace eVaf::SdiWindow::Internal; MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags) : QWidget(parent, flags) + , mReady(false) { setObjectName(QString("%1-%2").arg(VER_MODULE_NAME_STR).arg(__FUNCTION__)); @@ -67,23 +68,33 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags) mLayout = new QVBoxLayout; setLayout(mLayout); + mSdiWindow = this; + EVAF_INFO("%s created", qPrintable(objectName())); } MainWindow::~MainWindow() { + mSdiWindow = 0; + // Save geometry saveSettings(); EVAF_INFO("%s destroyed", qPrintable(objectName())); } -bool MainWindow::init() +bool MainWindow::init(QString const & args) { + Q_UNUSED(args); + + Common::iRegistry::instance()->registerInterface("iSdiWindow", this); + setWindowTitle(Common::iApp::instance()->name()); show(); + mReady = true; + EVAF_INFO("%s initialized", qPrintable(objectName())); return true; @@ -91,6 +102,8 @@ bool MainWindow::init() void MainWindow::done() { + mReady = false; + close(); // Delete all the items added to the main window @@ -178,56 +191,6 @@ void MainWindow::setWindowSize() } -//------------------------------------------------------------------- - -SdiWindowImpl::SdiWindowImpl() - : iSdiWindow() - , mReady(false) -{ - setObjectName(QString("%1.iSdiWindow").arg(VER_MODULE_NAME_STR)); - - mSdiWindow = this; - - wWindow = new MainWindow; - - Common::iRegistry::instance()->registerInterface("iSdiWindow", this); - - EVAF_INFO("%s created", qPrintable(objectName())); -} - -SdiWindowImpl::~SdiWindowImpl() -{ - delete wWindow; - - mSdiWindow = 0; - - EVAF_INFO("%s destroyed", qPrintable(objectName())); -} - -bool SdiWindowImpl::init(const QString & args) -{ - Q_UNUSED(args); - - if (!wWindow->init()) - return false; - - mReady = true; - - EVAF_INFO("%s initialized", qPrintable(objectName())); - - return true; -} - -void SdiWindowImpl::done() -{ - mReady = false; - - wWindow->done(); - - EVAF_INFO("%s finalized", qPrintable(objectName())); -} - - //------------------------------------------------------------------- SdiWindowPlugin::SdiWindowPlugin() @@ -235,7 +198,7 @@ SdiWindowPlugin::SdiWindowPlugin() { setObjectName(VER_MODULE_NAME_STR); - mWindow = new SdiWindowImpl; + mWindow = new MainWindow; EVAF_INFO("%s created", qPrintable(objectName())); } diff --git a/src/plugins/SdiWindow/sdiwindow.h b/src/plugins/SdiWindow/sdiwindow.h index 0032bc6..a73f2ee 100644 --- a/src/plugins/SdiWindow/sdiwindow.h +++ b/src/plugins/SdiWindow/sdiwindow.h @@ -37,11 +37,12 @@ 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: @@ -49,13 +50,15 @@ public: virtual ~MainWindow(); - bool init(); + virtual bool init(QString const & args); - void done(); + virtual void done(); + + virtual bool isReady() { return mReady; } - void addWidget(QWidget * widget); + virtual void addWidget(QWidget * widget); - void addLayout(QLayout * layout); + virtual void addLayout(QLayout * layout); private: // Methods @@ -69,6 +72,9 @@ private: // Methods private: // Members + /// Ready flag + bool mReady; + /// The layout of the window QVBoxLayout * mLayout; @@ -77,39 +83,6 @@ private: // Members }; -/** - * iSdiWindow interface implementation - */ -class SdiWindowImpl : public iSdiWindow -{ - Q_OBJECT - -public: - - SdiWindowImpl(); - - virtual ~SdiWindowImpl(); - - bool init(const QString & args); - - void done(); - - bool isReady() const { return mReady; } - - virtual void addWidget(QWidget * widget) { wWindow->addWidget(widget); } - - virtual void addLayout(QLayout * layout) { wWindow->addLayout(layout); } - - -private: // Members - - /// Ready flag - bool mReady; - - /// The main window widget - MainWindow * wWindow; -}; - /** * SdiWindow module's implementation */ @@ -133,7 +106,7 @@ public: private: /// iSdiWindow interface implementation - SdiWindowImpl * mWindow; + MainWindow * mWindow; }; } // namespace eVaf::SdiWindow::Internal diff --git a/src/plugins/SdiWindow/version.h b/src/plugins/SdiWindow/version.h index 6df80cf..9671900 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,3,4 +#define VER_FILE_VERSION 0,2,4,5 /** * Module/library version number in the string format (shall end with \0) */ -#define VER_FILE_VERSION_STR "0.2.3.4\0" +#define VER_FILE_VERSION_STR "0.2.4.5\0" /** * Module/library name (shall end with \0)