From a9d9dfea46c174e17078cc60b233e34d4087b087 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 24 Apr 2008 19:46:07 +0000 Subject: [PATCH] API reviews: the protected slots containmentDestroyed(QObject*) and syncConfig() are now private and in the private implementation svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=800755 --- corona.cpp | 50 ++++++++++++++++++++++++++------------------------ corona.h | 7 +++---- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/corona.cpp b/corona.cpp index 1c101f136..d10465e55 100644 --- a/corona.cpp +++ b/corona.cpp @@ -47,8 +47,9 @@ const int CONFIG_SYNC_TIMEOUT = 120000; class Corona::Private { public: - Private() - : immutability(NotImmutable), + Private(Corona *corona) + : q(corona), + immutability(NotImmutable), mimetype("text/x-plasmoidservicename"), config(0) { @@ -64,7 +65,7 @@ public: qDeleteAll(containments); } - void init(Corona* q) + void init() { configSyncTimer.setSingleShot(true); connect(&configSyncTimer, SIGNAL(timeout()), q, SLOT(syncConfig())); @@ -106,6 +107,26 @@ public: } } + void containmentDestroyed(QObject* obj) + { + // we do a static_cast here since it really isn't an Containment by this + // point anymore since we are in the qobject dtor. we don't actually + // try and do anything with it, we just need the value of the pointer + // so this unsafe looking code is actually just fine. + Containment* containment = static_cast(obj); + int index = containments.indexOf(containment); + + if (index > -1) { + containments.removeAt(index); + } + } + + void syncConfig() + { + q->config()->sync(); + } + + Corona *q; ImmutabilityType immutability; QString mimetype; QString configName; @@ -116,9 +137,9 @@ public: Corona::Corona(QObject *parent) : QGraphicsScene(parent), - d(new Private) + d(new Private(this)) { - d->init(this); + d->init(); //setViewport(new QGLWidget(QGLFormat(QGL::StencilBuffer | QGL::AlphaChannel))); } @@ -395,25 +416,6 @@ void Corona::dragMoveEvent(QGraphicsSceneDragDropEvent *event) //kDebug() << "Corona::dragMoveEvent(QDragMoveEvent* event)"; } -void Corona::containmentDestroyed(QObject* obj) -{ - // we do a static_cast here since it really isn't an Containment by this - // point anymore since we are in the qobject dtor. we don't actually - // try and do anything with it, we just need the value of the pointer - // so this unsafe looking code is actually just fine. - Containment* containment = static_cast(obj); - int index = d->containments.indexOf(containment); - - if (index > -1) { - d->containments.removeAt(index); - } -} - -void Corona::syncConfig() -{ - config()->sync(); -} - ImmutabilityType Corona::immutability() const { return d->immutability; diff --git a/corona.h b/corona.h index 94a773dbc..abb9af1ff 100644 --- a/corona.h +++ b/corona.h @@ -166,13 +166,12 @@ protected: void dragLeaveEvent(QGraphicsSceneDragDropEvent* event); void dragMoveEvent(QGraphicsSceneDragDropEvent* event); -protected Q_SLOTS: - void containmentDestroyed(QObject*); - void syncConfig(); - private: class Private; Private * const d; + + Q_PRIVATE_SLOT(d, void containmentDestroyed(QObject*)) + Q_PRIVATE_SLOT(d, void syncConfig()) }; } // namespace Plasma