* The main window widget is no more accessable from other modules
* Modules should use addWidget() and addLayout() methods to add widgets
and layouts to the main window.
* Any widgets and layouts added to the main window are deleted in the done()
method.
Fixes the issue where the main window widget tried to delete its children and failed, because
modules that created them were already unloaded.
SdiWindow::iSdiWindow * win = evafQueryInterface<SdiWindow::iSdiWindow>("iSdiWindow");
EVAF_TEST_X(win, "No iSdiWindow interface");
SdiWindow::iSdiWindow * win = evafQueryInterface<SdiWindow::iSdiWindow>("iSdiWindow");
EVAF_TEST_X(win, "No iSdiWindow interface");
+ QWidget * masterWidget = new QWidget;
+ win->addWidget(masterWidget);
+
QVBoxLayout * v = new QVBoxLayout;
QVBoxLayout * v = new QVBoxLayout;
- win->widget()->setLayout(v);
+ masterWidget->setLayout(v);
QGridLayout * g = new QGridLayout;
v->addLayout(g);
QGridLayout * g = new QGridLayout;
v->addLayout(g);
}
connect(wName, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
g->addWidget(wName, 1, 1, 1, 2);
}
connect(wName, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
g->addWidget(wName, 1, 1, 1, 2);
- win->widget()->setFocusProxy(wName);
+ masterWidget->setFocusProxy(wName);
l = new QLabel(tr("&Length of the password:", VER_MODULE_NAME_STR));
l->setAlignment(Qt::AlignRight);
l = new QLabel(tr("&Length of the password:", VER_MODULE_NAME_STR));
l->setAlignment(Qt::AlignRight);
connect(wCopy, SIGNAL(clicked()), this, SLOT(copyClicked()));
h->addWidget(wCopy);
connect(wCopy, SIGNAL(clicked()), this, SLOT(copyClicked()));
h->addWidget(wCopy);
- QAction * a = new QAction(win->widget());
+ QAction * a = new QAction(masterWidget);
a->setShortcut(Qt::Key_Return);
connect(a, SIGNAL(triggered()), this, SLOT(generateClicked()));
a->setShortcut(Qt::Key_Return);
connect(a, SIGNAL(triggered()), this, SLOT(generateClicked()));
- win->widget()->addAction(a);
+ masterWidget->addAction(a);
- a = new QAction(win->widget());
+ a = new QAction(masterWidget);
a->setShortcut(Qt::Key_Escape);
connect(a, SIGNAL(triggered()), qApp, SLOT(quit()));
a->setShortcut(Qt::Key_Escape);
connect(a, SIGNAL(triggered()), qApp, SLOT(quit()));
- win->widget()->addAction(a);
+ masterWidget->addAction(a);
/**
* Module/library version number in the form major,minor,release,build
*/
/**
* Module/library version number in the form major,minor,release,build
*/
-#define VER_FILE_VERSION 0,1,2,3
+#define VER_FILE_VERSION 0,1,3,4
/**
* Module/library version number in the string format (shall end with \0)
*/
/**
* Module/library version number in the string format (shall end with \0)
*/
-#define VER_FILE_VERSION_STR "0.1.2.3\0"
+#define VER_FILE_VERSION_STR "0.1.3.4\0"
/**
* Module/library name (shall end with \0)
/**
* Module/library name (shall end with \0)
#include <QObject>
#include <QString>
#include <QObject>
#include <QString>
+class QWidget;
+class QLayout;
+
namespace eVaf {
namespace SdiWindow {
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
* 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.
+ * an empty window that the application can fill with widgets.
*/
class SDIWINDOW_EXPORT iSdiWindow : public QObject
{
*/
class SDIWINDOW_EXPORT iSdiWindow : public QObject
{
static iSdiWindow * instance();
/**
static iSdiWindow * instance();
/**
- * Returns the main window widget
- * @return The main window widget
+ * 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
- * 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.
+ * This function adds the new layout to the end of the main window layout.
- virtual QWidget * widget() const = 0;
+ virtual void addLayout(QLayout * layout) = 0;
// Apply the size specified in a) properties; or b) on the command line
setWindowSize();
// Apply the size specified in a) properties; or b) on the command line
setWindowSize();
+ // Create the default layout
+ mLayout = new QVBoxLayout;
+ setLayout(mLayout);
+
EVAF_INFO("%s created", qPrintable(objectName()));
}
EVAF_INFO("%s created", qPrintable(objectName()));
}
+ // Delete all the items added to the main window
+ while (mItemsAdded.count() > 0)
+ delete mItemsAdded.takeAt(0);
+
EVAF_INFO("%s finalized", qPrintable(objectName()));
}
EVAF_INFO("%s finalized", qPrintable(objectName()));
}
+void MainWindow::addWidget(QWidget * widget)
+{
+ mLayout->addWidget(widget);
+ mItemsAdded.append(widget);
+}
+
+void MainWindow::addLayout(QLayout * layout)
+{
+ mLayout->addLayout(layout);
+ mItemsAdded.append(layout);
+}
+
void MainWindow::saveSettings()
{
static int ver[4] = {VER_FILE_VERSION};
void MainWindow::saveSettings()
{
static int ver[4] = {VER_FILE_VERSION};
#include <QObject>
#include <QString>
#include <QWidget>
#include <QObject>
#include <QString>
#include <QWidget>
+#include <QList>
+
+class QVBoxLayout;
namespace eVaf {
namespace SdiWindow {
namespace eVaf {
namespace SdiWindow {
+ void addWidget(QWidget * widget);
+
+ void addLayout(QLayout * layout);
+
void saveSettings();
void restoreSettings();
void saveSettings();
void restoreSettings();
+
+
+private: // Members
+
+ /// The layout of the window
+ QVBoxLayout * mLayout;
+
+ /// Widgets and layouts added to the main window
+ QList<QObject *> mItemsAdded;
+
bool isReady() const { return mReady; }
bool isReady() const { return mReady; }
- virtual QWidget * widget() const { return wWindow; }
+ virtual void addWidget(QWidget * widget) { wWindow->addWidget(widget); }
+
+ virtual void addLayout(QLayout * layout) { wWindow->addLayout(layout); }
/**
* Module/library version number in the form major,minor,release,build
*/
/**
* Module/library version number in the form major,minor,release,build
*/
-#define VER_FILE_VERSION 0,1,1,1
+#define VER_FILE_VERSION 0,2,1,2
/**
* Module/library version number in the string format (shall end with \0)
*/
/**
* Module/library version number in the string format (shall end with \0)
*/
-#define VER_FILE_VERSION_STR "0.1.1.1\0"
+#define VER_FILE_VERSION_STR "0.2.1.2\0"
/**
* Module/library name (shall end with \0)
/**
* Module/library name (shall end with \0)