X-Git-Url: https://vaikene.ee/gitweb/pswgen09.html?a=blobdiff_plain;ds=inline;f=src%2Fplugins%2FSdiWindow%2Fsdiwindow.cpp;h=eb1a449ab3f84dc6884972f3da38e0a82481da4f;hb=a81a943bee20df3c7eb34bafb3e3fe878facfe4e;hp=c0e3587711afa35e00cbab88a421d4c38b634e47;hpb=5dd5f367dfcecab75077c3cb4ca1f01113fc1561;p=evaf
diff --git a/src/plugins/SdiWindow/sdiwindow.cpp b/src/plugins/SdiWindow/sdiwindow.cpp
index c0e3587..eb1a449 100644
--- a/src/plugins/SdiWindow/sdiwindow.cpp
+++ b/src/plugins/SdiWindow/sdiwindow.cpp
@@ -25,7 +25,7 @@
#include
#include
-#include
+#include
#include
namespace eVaf {
@@ -53,7 +53,6 @@ SdiWindow::iSdiWindow * SdiWindow::iSdiWindow::instance()
SdiWindow::Internal::MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags)
: QWidget(parent, flags)
, mReady(false)
- , mTimerId(0)
{
setObjectName(QString("%1-%2").arg(VER_MODULE_NAME_STR).arg(__FUNCTION__));
@@ -103,9 +102,6 @@ bool SdiWindow::Internal::MainWindow::init(QString const & args)
setWindowTitle(Common::iApp::instance()->name());
- // Start the garbage collector timer
- mTimerId = startTimer(60 * 1000);
-
show();
mReady = true;
@@ -121,21 +117,15 @@ void SdiWindow::Internal::MainWindow::done()
close();
- if (mTimerId) {
- killTimer(mTimerId);
- mTimerId = 0;
- }
-
// Delete all the panels
for (int i = mPanels.size() - 1; i >= 0; --i) {
- QWeakPointer p = mPanels.at(i);
- if (p)
- delete p.data();
+ disconnect(mPanels.at(i), SIGNAL(destroyed(QObject *)), this, SLOT(panelDestroyed(QObject *)));
+ delete mPanels.at(i);
}
mPanels.clear();
mMinimizedPanels.clear();
mPanelNames.clear();
- mMainPanel.clear();
+ mMainPanel = 0;
mMainPanelName.clear();
EVAF_INFO("%s finalized", qPrintable(objectName()));
@@ -143,6 +133,7 @@ void SdiWindow::Internal::MainWindow::done()
void SdiWindow::Internal::MainWindow::addPanel(QString const & name, Gui::Panel * panel)
{
+ connect(panel, SIGNAL(destroyed(QObject *)), this, SLOT(panelDestroyed(QObject*)));
mPanels.append(panel);
mPanelNames.insert(name, panel);
@@ -165,9 +156,9 @@ void SdiWindow::Internal::MainWindow::addPanel(QString const & name, Gui::Panel
Gui::Panel * SdiWindow::Internal::MainWindow::panel(QString const & name) const
{
- QHash >::const_iterator it = mPanelNames.constFind(name);
+ QHash::const_iterator it = mPanelNames.constFind(name);
if (it != mPanelNames.constEnd())
- return it.value().data();
+ return it.value();
return 0;
}
@@ -246,12 +237,10 @@ void SdiWindow::Internal::MainWindow::setWindowSize()
void SdiWindow::Internal::MainWindow::closeEvent(QCloseEvent * e)
{
// Try to close all the managed panels; ignore the event if one of the managed panels refuses to close
- foreach (QWeakPointer p, mPanels) {
- if (p) {
- if (!p.data()->close()) {
- e->ignore();
- return;
- }
+ foreach (Gui::Panel * p, mPanels) {
+ if (!p->close()) {
+ e->ignore();
+ return;
}
}
@@ -266,9 +255,9 @@ void SdiWindow::Internal::MainWindow::changeEvent(QEvent * e)
if (windowState() == Qt::WindowNoState && wse->oldState() == Qt::WindowMinimized) {
// Restore all the managed panels that were previously minimized
- foreach (QWeakPointer p, mMinimizedPanels) {
- if (p && p.data()->isVisible())
- p.data()->showNormal();
+ foreach (Gui::Panel * p, mMinimizedPanels) {
+ if (p->isVisible())
+ p->showNormal();
}
mMinimizedPanels.clear();
}
@@ -277,13 +266,10 @@ void SdiWindow::Internal::MainWindow::changeEvent(QEvent * e)
// Minimize all the managed panels that are not minimized yet
mMinimizedPanels.clear();
- foreach (QWeakPointer p, mPanels) {
- if (!p)
- continue;
-
- if (p.data()->windowState() != Qt::WindowMinimized && p.data()->isVisible()) {
+ foreach (Gui::Panel * p, mPanels) {
+ if (p->windowState() != Qt::WindowMinimized && p->isVisible()) {
mMinimizedPanels.append(p);
- p.data()->showMinimized();
+ p->showMinimized();
}
}
}
@@ -291,36 +277,37 @@ void SdiWindow::Internal::MainWindow::changeEvent(QEvent * e)
QWidget::changeEvent(e);
}
-void SdiWindow::Internal::MainWindow::timerEvent(QTimerEvent * e)
+void SdiWindow::Internal::MainWindow::panelDestroyed(QObject * obj)
{
- if (e->timerId() == mTimerId) {
-
- // Remove panels that are deleted
- {
- QList >::iterator it = mPanels.begin();
- while (it != mPanels.end()) {
- QWeakPointer p = *it;
- if (!p)
- it = mPanels.erase(it);
- else
- ++it;
+ // Remove panels that are deleted
+ {
+ QList::iterator it = mPanels.begin();
+ while (it != mPanels.end()) {
+ if (*it == obj) {
+ it = mPanels.erase(it);
+ }
+ else {
+ ++it;
}
}
+ }
- // Do the same with panel names
- {
- QHash >::iterator it = mPanelNames.begin();
- while (it != mPanelNames.end()) {
- QWeakPointer p = it.value();
- if (!p)
- it = mPanelNames.erase(it);
- else
- ++it;
+ // Do the same with panel names
+ {
+ QHash::iterator it = mPanelNames.begin();
+ while (it != mPanelNames.end()) {
+ if (it.value() == obj) {
+ it = mPanelNames.erase(it);
+ }
+ else {
+ ++it;
}
}
}
- else
- QWidget::timerEvent(e);
+
+ if (mMainPanel == obj) {
+ mMainPanel = 0;
+ }
}