+add_subdirectory(SdiWindow)
add_subdirectory(Test)
--- /dev/null
+# Name of the target
+set(TARGET SdiWindow)
+
+# Qt modules
+include(${QT_USE_FILE})
+
+# Needed for exporting/importing symbols
+add_definitions(-DSDIWINDOW_LIBRARY)
+
+# Include files
+include_directories(${eVaf_INCLUDE})
+
+# Required eVaf libraries
+set(eVaf_LIBRARIES CommonLib PluginsLib)
+
+# Source files
+set(SRCS
+ factory.cpp
+ sdiwindow.cpp
+)
+
+# Header files for the meta-object compiler
+set(MOC_HDRS
+ factory.h
+ isdiwindow.h
+ sdiwindow.h
+)
+
+# Version info resource file for Windows builds
+if(WIN32)
+ set(SRCS ${SRCS} version.rc)
+endif(WIN32)
+
+qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS})
+
+add_library(${TARGET} SHARED ${SRCS} ${MOC_SRCS})
+
+target_link_libraries(${TARGET} ${QT_LIBRARIES} ${eVaf_LIBRARIES})
+
+install(TARGETS ${TARGET} DESTINATION bin)
--- /dev/null
+/**
+ * @file SdiWindow/factory.cpp
+ * @brief SDI module's factory class
+ * @author Enar Vaikene
+ *
+ * Copyright (c) 2011 Enar Vaikene
+ *
+ * This file is part of the eVaf C++ cross-platform application development framework.
+ *
+ * This file can be used under the terms of the GNU General Public License
+ * version 3.0 as published by the Free Software Foundation and appearing in
+ * the file LICENSE included in the packaging of this file. Please review the
+ * the following information to ensure the GNU General Public License version
+ * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * Alternatively, this file may be used in accordance with the Commercial License
+ * Agreement provided with the Software.
+ */
+
+#include "factory.h"
+#include "sdiwindow.h"
+#include "version.h"
+
+#include <Common/iLogger>
+
+#include <QtCore>
+
+using namespace eVaf::SdiWindow;
+
+VER_EXPORT_VERSION_INFO()
+Q_EXPORT_PLUGIN2(VER_MODULE_NAME_STR, Factory)
+
+
+//-------------------------------------------------------------------
+
+Factory::Factory()
+ : Plugins::iPluginFactory()
+ , mPlugin(0)
+{
+ setObjectName(QString("%1-Factory").arg(VER_MODULE_NAME_STR));
+
+ EVAF_INFO("%s created", qPrintable(objectName()));
+}
+
+Factory::~Factory()
+{
+ if (mPlugin)
+ delete mPlugin;
+
+ EVAF_INFO("%s destroyed", qPrintable(objectName()));
+}
+
+QObject * Factory::create(QString const & name)
+{
+ Q_UNUSED(name);
+
+ if (mPlugin == 0)
+ mPlugin = new Internal::SdiWindowPlugin;
+ return mPlugin;
+}
--- /dev/null
+/**
+ * @file SdiWindow/factory.h
+ * @brief SDI module's factory class
+ * @author Enar Vaikene
+ *
+ * Copyright (c) 2011 Enar Vaikene
+ *
+ * This file is part of the eVaf C++ cross-platform application development framework.
+ *
+ * This file can be used under the terms of the GNU General Public License
+ * version 3.0 as published by the Free Software Foundation and appearing in
+ * the file LICENSE included in the packaging of this file. Please review the
+ * the following information to ensure the GNU General Public License version
+ * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * Alternatively, this file may be used in accordance with the Commercial License
+ * Agreement provided with the Software.
+ */
+
+#ifndef __SDIWINDOW_FACTORY_H
+# define __SDIWINDOW_FACTORY_H
+
+#include <Plugins/iPluginFactory>
+
+namespace eVaf {
+
+/**
+ * Module that implements the Single Document Interface.
+ *
+ * Use this module as the main window for SDI applications.
+ */
+namespace SdiWindow {
+
+/**
+ * Internal implementation of the module.
+ */
+namespace Internal {
+ class SdiWindowPlugin;
+} // namespace eVaf::SdiWindow::Internal
+
+
+/**
+ * Plugin factory class for the module
+ */
+class Factory : public Plugins::iPluginFactory
+{
+ Q_OBJECT
+
+public:
+
+ Factory();
+
+ virtual ~Factory();
+
+ virtual QObject * create(QString const & name);
+
+
+private: // Members
+
+ Internal::SdiWindowPlugin * mPlugin;
+
+};
+
+} // namespace eVaf::SdiWindow
+} // namespace eVaf
+
+#endif // factory.h
--- /dev/null
+#include "isdiwindow.h"
--- /dev/null
+/**
+ * @file SdiWindow/isdiwindow.h
+ * @brief eVaf SDI window interface
+ * @author Enar Vaikene
+ *
+ * Copyright (c) 2011 Enar Vaikene
+ *
+ * This file is part of the eVaf C++ cross-platform application development framework.
+ *
+ * This file can be used under the terms of the GNU General Public License
+ * version 3.0 as published by the Free Software Foundation and appearing in
+ * the file LICENSE included in the packaging of this file. Please review the
+ * the following information to ensure the GNU General Public License version
+ * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * Alternatively, this file may be used in accordance with the Commercial License
+ * Agreement provided with the Software.
+ */
+
+#ifndef __SDIWINDOW_ISDIWINDOW_H
+# define __SDIWINDOW_ISDIWINDOW_H
+
+#include "libsdiwindow.h"
+
+#include <QObject>
+#include <QString>
+
+namespace eVaf {
+namespace SdiWindow {
+
+/**
+ * Main window interface for eVaf applications implementing the Single Document Interface.
+ *
+ * The iSdiWindow interface provides access to the SDI main window. The SDI main window is
+ * an empty window that the application needs to fill with widgets.
+ */
+class SDIWINDOW_EXPORT iSdiWindow : public QObject
+{
+ 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
+ *
+ * This function returns the global iSdiWindow interface instance. Using this function
+ * is not mandatory and modules can use the iRegistry interface instead. Using the iRegistry
+ * interface has the advantage that modules do not need to link against this library.
+ */
+ static iSdiWindow * instance();
+
+ /**
+ * Returns the main window widget
+ * @return The main window widget
+ *
+ * This function provides access to the main window widget. The main window is an empty QWidget and
+ * needs to be filled with additional widgets in order to provide some functionality.
+ */
+ virtual QWidget * widget() const = 0;
+
+};
+
+} // namespace eVaf::SdiWindow
+} // namespace eVaf
+
+#endif // isdiwindow.h
--- /dev/null
+/**
+ * @file SdiWindow/libsdiwindow.h
+ * @author Enar Vaikene
+ *
+ * Copyright (c) 2011 Enar Vaikene
+ *
+ * This file is part of the eVaf C++ cross-platform application development framework.
+ *
+ * This file can be used under the terms of the GNU General Public License
+ * version 3.0 as published by the Free Software Foundation and appearing in
+ * the file LICENSE included in the packaging of this file. Please review the
+ * the following information to ensure the GNU General Public License version
+ * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * Alternatively, this file may be used in accordance with the Commercial License
+ * Agreement provided with the Software.
+ */
+
+#ifndef __SDIWINDOW_LIBSDIWINDOW_H
+# define __SDIWINDOW_LIBSDIWINDOW_H
+
+#include <QtCore/qglobal.h>
+
+#if defined(SDIWINDOW_LIBRARY)
+# define SDIWINDOW_EXPORT Q_DECL_EXPORT
+#else
+# define SDIWINDOW_EXPORT Q_DECL_IMPORT
+#endif
+
+#endif // libsdiwindow.h
--- /dev/null
+/**
+ * @file SdiWindow/sdiwindow.cpp
+ * @brief SdiWindow module's implementation
+ * @author Enar Vaikene
+ *
+ * Copyright (c) 2011 Enar Vaikene
+ *
+ * This file is part of the eVaf C++ cross-platform application development framework.
+ *
+ * This file can be used under the terms of the GNU General Public License
+ * version 3.0 as published by the Free Software Foundation and appearing in
+ * the file LICENSE included in the packaging of this file. Please review the
+ * the following information to ensure the GNU General Public License version
+ * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * Alternatively, this file may be used in accordance with the Commercial License
+ * Agreement provided with the Software.
+ */
+
+#include "sdiwindow.h"
+#include "version.h"
+
+#include <Common/iLogger>
+#include <Common/iRegistry>
+
+#include <QtGui>
+
+namespace eVaf {
+namespace SdiWindow {
+namespace Internal {
+ /// iSdiWindow interface instance singleton
+ static iSdiWindow * mSdiWindow = 0;
+} // namespace eVaf::SdiWindow::Internal
+} // namespace eVaf::SdiWindow
+} // namespace eVaf
+
+
+using namespace eVaf;
+
+//-------------------------------------------------------------------
+
+using namespace eVaf::SdiWindow;
+
+iSdiWindow * iSdiWindow::instance()
+{
+ return Internal::mSdiWindow;
+}
+
+
+//-------------------------------------------------------------------
+
+using namespace eVaf::SdiWindow::Internal;
+
+MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags)
+ : QWidget(parent, flags)
+{
+ setObjectName(QString("%1-%2").arg(VER_MODULE_NAME_STR).arg(__FUNCTION__));
+
+ // Restore geometry
+ restoreSettings();
+
+ // Apply the size specified in a) properties; or b) on the command line
+ setWindowSize();
+
+ EVAF_INFO("%s created", qPrintable(objectName()));
+}
+
+MainWindow::~MainWindow()
+{
+ // Save geometry
+ saveSettings();
+
+ EVAF_INFO("%s destroyed", qPrintable(objectName()));
+}
+
+bool MainWindow::init()
+{
+ show();
+
+ EVAF_INFO("%s initialized", qPrintable(objectName()));
+
+ return true;
+}
+
+void MainWindow::done()
+{
+ close();
+
+ EVAF_INFO("%s finalized", qPrintable(objectName()));
+}
+
+void MainWindow::saveSettings()
+{
+ static int ver[4] = {VER_FILE_VERSION};
+ QSettings settings(VER_COMPANY_NAME_STR, VER_PRODUCT_NAME_STR);
+ settings.setValue(QString("%1/version/major").arg(objectName()), ver[0]);
+ settings.setValue(QString("%1/version/minor").arg(objectName()), ver[1]);
+ settings.setValue(QString("%1/geometry").arg(objectName()), saveGeometry());
+}
+
+void MainWindow::restoreSettings()
+{
+ static int ver[4] = {VER_FILE_VERSION};
+ QSettings settings(VER_COMPANY_NAME_STR, VER_PRODUCT_NAME_STR);
+
+ // Ignore saved settings if the version number is not the same
+ // More intelligent checks can be implemented to allow upgrading from previous versions
+ QVariant v = settings.value(QString("%1/version/major").arg(objectName()));
+ if (!v.isValid() || v.toInt() != ver[0])
+ return;
+ v = settings.value(QString("%1/version/minor").arg(objectName()));
+ if (!v.isValid() || v.toInt() != ver[1])
+ return;
+
+ // Restore the geometry
+ restoreGeometry(settings.value(QString("%1/geometry").arg(objectName())).toByteArray());
+}
+
+void MainWindow::setWindowSize()
+{
+ // a) Get window size from properties
+ int w = 0;
+ int h = 0;
+
+ // b) Use command line arguments
+ QStringList args = QApplication::arguments();
+ for (int i = 1; i < args.size(); ++i) {
+ QStringList arg = args.at(i).simplified().split('=');
+ if (QRegExp("-[-]?w[idth]?").exactMatch(arg.at(0)) && arg.size() > 1) {
+ bool ok;
+ int v = arg.at(1).toInt(&ok);
+ if (ok)
+ w = v;
+ }
+ if (QRegExp("-[-]?h[eight]?").exactMatch(arg.at(0)) && arg.size() > 1) {
+ bool ok;
+ int v = arg.at(1).toInt(&ok);
+ if (ok)
+ h = v;
+ }
+ }
+
+ // Resize the window
+ if (w > 0 || h > 0) {
+ QSize sz = sizeHint();
+ if (w > 0)
+ sz.setWidth(w);
+ if (h > 0)
+ sz.setHeight(h);
+ resize(sz);
+ }
+}
+
+
+//-------------------------------------------------------------------
+
+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()
+ : Plugins::iPlugin()
+{
+ setObjectName(VER_MODULE_NAME_STR);
+
+ mWindow = new SdiWindowImpl;
+
+ EVAF_INFO("%s created", qPrintable(objectName()));
+}
+
+SdiWindowPlugin::~SdiWindowPlugin()
+{
+ delete mWindow;
+
+ EVAF_INFO("%s destroyed", qPrintable(objectName()));
+}
+
+bool SdiWindowPlugin::init(const QString & args)
+{
+ if (!mWindow->init(args))
+ return false;
+
+ EVAF_INFO("%s initialized", qPrintable(objectName()));
+
+ return true;
+}
+
+void SdiWindowPlugin::done()
+{
+ mWindow->done();
+
+ EVAF_INFO("%s finalized", qPrintable(objectName()));
+}
--- /dev/null
+/**
+ * @file SdiWindow/sdiwindow.h
+ * @brief SdiWindow module's implementation
+ * @author Enar Vaikene
+ *
+ * Copyright (c) 2011 Enar Vaikene
+ *
+ * This file is part of the eVaf C++ cross-platform application development framework.
+ *
+ * This file can be used under the terms of the GNU General Public License
+ * version 3.0 as published by the Free Software Foundation and appearing in
+ * the file LICENSE included in the packaging of this file. Please review the
+ * the following information to ensure the GNU General Public License version
+ * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * Alternatively, this file may be used in accordance with the Commercial License
+ * Agreement provided with the Software.
+ */
+
+#ifndef __SDIWINDOW_SDIWINDOW_H
+# define __SDIWINDOW_SDIWINDOW_H
+
+#include "isdiwindow.h"
+
+#include <Plugins/iPlugin>
+
+#include <QObject>
+#include <QString>
+#include <QWidget>
+
+namespace eVaf {
+namespace SdiWindow {
+namespace Internal {
+
+/**
+ * Main window widget
+ */
+class MainWindow : public QWidget
+{
+ Q_OBJECT
+
+public:
+
+ MainWindow(QWidget * parent = 0, Qt::WindowFlags flags = 0);
+
+ virtual ~MainWindow();
+
+ bool init();
+
+ void done();
+
+
+private: // Methods
+
+ void setWindowSize();
+
+ void saveSettings();
+
+ void restoreSettings();
+};
+
+/**
+ * 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 QWidget * widget() const { return wWindow; }
+
+
+private: // Members
+
+ /// Ready flag
+ bool mReady;
+
+ /// The main window widget
+ MainWindow * wWindow;
+};
+
+/**
+ * SdiWindow module's implementation
+ */
+class SdiWindowPlugin : public Plugins::iPlugin
+{
+ Q_OBJECT
+
+public:
+
+ SdiWindowPlugin();
+
+ virtual ~SdiWindowPlugin();
+
+ virtual bool init(const QString & args);
+
+ virtual void done();
+
+ virtual bool isReady() const { return mWindow != 0 && mWindow->isReady(); }
+
+
+private:
+
+ /// iSdiWindow interface implementation
+ SdiWindowImpl * mWindow;
+};
+
+} // namespace eVaf::SdiWindow::Internal
+} // namespace eVaf::SdiWindow
+} // namespace eVaf
+
+#endif // sdiwindow.h
--- /dev/null
+/**
+ * @file SdiWindow/version.h
+ * @brief Version information for eVaf modules
+ * @author Enar Vaikene
+ *
+ * Copyright (c) 2011 Enar Vaikene
+ *
+ * This file is part of the eVaf C++ cross-platform application development framework.
+ *
+ * This file can be used under the terms of the GNU General Public License
+ * version 3.0 as published by the Free Software Foundation and appearing in
+ * the file LICENSE included in the packaging of this file. Please review the
+ * the following information to ensure the GNU General Public License version
+ * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * Alternatively, this file may be used in accordance with the Commercial License
+ * Agreement provided with the Software.
+ */
+
+#ifndef __SDI_WINDOW_VERSION_H
+#define __SDI_WINDOW_VERSION_H
+
+#include <version_rc.h>
+
+/**
+ * Module/library version number in the form major,minor,release,build
+ */
+#define VER_FILE_VERSION 0,1,1,1
+
+/**
+ * Module/library version number in the string format (shall end with \0)
+ */
+#define VER_FILE_VERSION_STR "0.1.1.1\0"
+
+/**
+ * Module/library name (shall end with \0)
+ */
+#define VER_MODULE_NAME_STR "SdiWindow\0"
+
+/**
+ * Module type (see version_rc.h for all the types)
+ */
+#define VER_MODULE_TYPE MT_GENERIC
+
+/**
+ * Module type in the string format (see version_rc for all the types)
+ */
+#define VER_MODULE_TYPE_STR MT_GENERIC
+
+/**
+ * Original file name for windows (shall end with \0)
+ */
+#define VER_ORIGINAL_FILE_NAME_STR "SdiWindow.dll\0"
+
+/**
+ * Description of the module/library (shall end with \0)
+ */
+#define VER_FILE_DESCRIPTION_STR "Module that implements Single Document Interface for the eVaf application framework.\0"
+
+#endif // version.h
--- /dev/null
+/**
+ * @file plugins/Test/version.rc
+ * @brief Windows resource file with module/library version information.
+ * @author Enar Vaikene
+ *
+ * Copyright (c) 2011 Enar Vaikene
+ *
+ * This file is part of the eVaf C++ cross-platform application development framework.
+ *
+ * This file can be used under the terms of the GNU General Public License
+ * version 3.0 as published by the Free Software Foundation and appearing in
+ * the file LICENSE included in the packaging of this file. Please review the
+ * the following information to ensure the GNU General Public License version
+ * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
+ *
+ * Alternatively, this file may be used in accordance with the Commercial License
+ * Agreement provided with the Software.
+ */
+
+#include "version.h"
+#include <version_rc.h>
+#include <winver.h>
+
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION VER_FILE_VERSION
+ PRODUCTVERSION VER_PRODUCT_VERSION
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS VS_FF_DEBUG
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE 0x0L
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904B0"
+ BEGIN
+ VALUE "CompanyName", VER_COMPANY_NAME_STR
+ VALUE "FileDescription", VER_FILE_DESCRIPTION_STR
+ VALUE "FileVersion", VER_FILE_VERSION_STR
+ VALUE "LegalCopyright", VER_LEGAL_COPYRIGHT_STR
+ VALUE "OriginalFilename", VER_ORIGINAL_FILE_NAME_STR
+ VALUE "ProductName", VER_PRODUCT_NAME_STR
+ VALUE "ProductVersion", VER_PRODUCT_VERSION_STR
+ VALUE "Build Date", VER_PRODUCT_DATE_STR
+ VALUE "Module Name", VER_MODULE_NAME_STR
+ VALUE "Module Type", VER_MODULE_TYPE_STR
+ END
+ END
+ END