[rkward-cvs] SF.net SVN: rkward:[2602] trunk/rkward/rkward/misc
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Thu Aug 6 15:46:57 UTC 2009
Revision: 2602
http://rkward.svn.sourceforge.net/rkward/?rev=2602&view=rev
Author: tfry
Date: 2009-08-06 15:46:56 +0000 (Thu, 06 Aug 2009)
Log Message:
-----------
d-pointer-ify the rkxmlguisyncer for later submission to kdelibs.
Modified Paths:
--------------
trunk/rkward/rkward/misc/rkxmlguisyncer.cpp
trunk/rkward/rkward/misc/rkxmlguisyncer.h
Added Paths:
-----------
trunk/rkward/rkward/misc/rkxmlguisyncer_p.h
Modified: trunk/rkward/rkward/misc/rkxmlguisyncer.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkxmlguisyncer.cpp 2009-08-06 15:02:00 UTC (rev 2601)
+++ trunk/rkward/rkward/misc/rkxmlguisyncer.cpp 2009-08-06 15:46:56 UTC (rev 2602)
@@ -16,15 +16,8 @@
***************************************************************************/
#include "rkxmlguisyncer.h"
+#include "rkxmlguisyncer_p.h"
-#include <kxmlguiclient.h>
-#include <kxmlguifactory.h>
-#include <kactioncollection.h>
-#include <kdirwatch.h>
-#include <kapplication.h>
-
-#include <QDir>
-
#include "../debug.h"
RKXMLGUISyncer* RKXMLGUISyncer::syncer = 0;
@@ -37,18 +30,13 @@
return syncer;
}
-RKXMLGUISyncer::RKXMLGUISyncer () : QObject () {
+RKXMLGUISyncer::RKXMLGUISyncer () : d (new RKXMLGUISyncerPrivate) {
RK_TRACE (MISC);
-
- file_watcher = KDirWatch::self ();
- connect (file_watcher, SIGNAL (dirty(const QString&)), this, SLOT (uiRcFileChanged(const QString&)));
-
- connect (&rebuild_guis_timer, SIGNAL (timeout()), this, SLOT (rebuildGUIs()));
- rebuild_guis_timer.setSingleShot (true);
}
RKXMLGUISyncer::~RKXMLGUISyncer () {
RK_TRACE (MISC);
+ delete d;
}
void RKXMLGUISyncer::watchXMLGUIClientUIrc (KXMLGUIClient *client, bool recursive) {
@@ -61,13 +49,13 @@
if (ac && (!local_xml_file.isEmpty()) && (!QDir (local_xml_file).exists ())) {
RK_ASSERT (ac->parentGUIClient () == client);
- if (!client_map.contains (local_xml_file, ac)) {
- if (!client_map.contains (local_xml_file)) {
- file_watcher->addFile (local_xml_file);
+ if (!d->client_map.contains (local_xml_file, ac)) {
+ if (!d->client_map.contains (local_xml_file)) {
+ d->file_watcher->addFile (local_xml_file);
}
- client_map.insertMulti (local_xml_file, ac);
- connect (ac, SIGNAL (destroyed(QObject*)), this, SLOT (actionCollectionDestroyed(QObject*)));
+ d->client_map.insertMulti (local_xml_file, ac);
+ d->connect (ac, SIGNAL (destroyed(QObject*)), d, SLOT (actionCollectionDestroyed(QObject*)));
} // we simply ignore attempts to watch the same client twice
}
@@ -84,12 +72,14 @@
KActionCollection *ac = watched_client->actionCollection ();
RKXMLGUISyncerNotifier *notifier = new RKXMLGUISyncerNotifier (0);
- connect (notifier, SIGNAL (changed(KXMLGUIClient*)), receiver, method);
+ d->connect (notifier, SIGNAL (changed(KXMLGUIClient*)), receiver, method);
- notifier_map.insertMulti (ac, notifier);
+ d->notifier_map.insertMulti (ac, notifier);
}
-void RKXMLGUISyncer::uiRcFileChanged (const QString &path) {
+
+
+void RKXMLGUISyncerPrivate::uiRcFileChanged (const QString &path) {
RK_TRACE (MISC);
RK_ASSERT (client_map.contains (path));
@@ -123,7 +113,7 @@
rebuild_guis_timer.start (0);
}
-void RKXMLGUISyncer::rebuildGUIs () {
+void RKXMLGUISyncerPrivate::rebuildGUIs () {
RK_TRACE (MISC);
while (!affected_factories.isEmpty ()) {
@@ -142,7 +132,7 @@
}
}
-void RKXMLGUISyncer::actionCollectionDestroyed (QObject *object) {
+void RKXMLGUISyncerPrivate::actionCollectionDestroyed (QObject *object) {
RK_TRACE (MISC);
// warning: Do not call any methods on the ac. It is half-destroyed, already.
@@ -166,10 +156,10 @@
RK_DO (qDebug ("action collection destroyed. Still watch %d clients with %d notifiers", client_map.size (), notifier_map.size ()), MISC, DL_DEBUG);
}
-void RKXMLGUISyncer::guiFactoryDestroyed (QObject *object) {
+void RKXMLGUISyncerPrivate::guiFactoryDestroyed (QObject *object) {
RK_TRACE (MISC);
affected_factories.remove (static_cast<KXMLGUIFactory*>(object));
}
-#include "rkxmlguisyncer.moc"
+#include "rkxmlguisyncer_p.moc"
Modified: trunk/rkward/rkward/misc/rkxmlguisyncer.h
===================================================================
--- trunk/rkward/rkward/misc/rkxmlguisyncer.h 2009-08-06 15:02:00 UTC (rev 2601)
+++ trunk/rkward/rkward/misc/rkxmlguisyncer.h 2009-08-06 15:46:56 UTC (rev 2602)
@@ -18,31 +18,12 @@
#ifndef RKXMLGUISYNCER_H
#define RKXMLGUISYNCER_H
-#include <QObject>
-#include <QMultiHash>
-#include <QSet>
-#include <QTimer>
-
class KXMLGUIClient;
-class KActionCollection;
-class KDirWatch;
-class KXMLGUIFactory;
+class QObject;
+class RKXMLGUISyncerPrivate;
-/** For internal use by RKXMLGUISyncer, only */
-class RKXMLGUISyncerNotifier : public QObject {
-Q_OBJECT
-public:
- RKXMLGUISyncerNotifier (QObject *parent) : QObject (parent) {};
- ~RKXMLGUISyncerNotifier () {};
-
- void emitChangeSignal (KXMLGUIClient *client) { changed (client); };
-signals:
- void changed (KXMLGUIClient *client);
-};
-
/** This class listens for changes in the XMLGUI-configuration files of registered KXMLGUIClients. It then takes care of updating those KXMLGUIClients. */
-class RKXMLGUISyncer : public QObject {
-Q_OBJECT
+class RKXMLGUISyncer {
public:
/** Returns the single static instance of the syncer. If the instance did not exit, yet, it is created, now. */
static RKXMLGUISyncer *self ();
@@ -61,23 +42,11 @@
\endcode
*/
void registerChangeListener (KXMLGUIClient *watched_client, QObject *receiver, const char *method);
-private slots:
- void uiRcFileChanged (const QString &path);
- void actionCollectionDestroyed (QObject *object);
- void guiFactoryDestroyed (QObject *object);
- void rebuildGUIs ();
protected:
RKXMLGUISyncer ();
~RKXMLGUISyncer ();
private:
- /** Internally we store the actionCollection() of each KXMLGUIClient, instead of a pointer to the client, directly. This is because KXMLGUIClient is not a QObject, and so we cannot safely detect its destruction. */
- QMultiHash<QString, KActionCollection*> client_map;
- QMultiHash<KActionCollection*, RKXMLGUISyncerNotifier*> notifier_map;
-
- QSet<KXMLGUIFactory*> affected_factories;
- QTimer rebuild_guis_timer;
-
- KDirWatch *file_watcher;
+ RKXMLGUISyncerPrivate * const d;
static RKXMLGUISyncer *syncer;
};
Added: trunk/rkward/rkward/misc/rkxmlguisyncer_p.h
===================================================================
--- trunk/rkward/rkward/misc/rkxmlguisyncer_p.h (rev 0)
+++ trunk/rkward/rkward/misc/rkxmlguisyncer_p.h 2009-08-06 15:46:56 UTC (rev 2602)
@@ -0,0 +1,72 @@
+/***************************************************************************
+ rkxmlguisyncer_p.h - description
+ -------------------
+ begin : Wed Aug 5 2009
+ copyright : (C) 2009 by Thomas Friedrichsmeier
+ email : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef RKXMLGUISYNCER_P_H
+#define RKXMLGUISYNCER_P_H
+
+#include <kxmlguiclient.h>
+#include <kxmlguifactory.h>
+#include <kactioncollection.h>
+#include <kdirwatch.h>
+#include <kapplication.h>
+
+#include <QDir>
+#include <QMultiHash>
+#include <QSet>
+#include <QTimer>
+
+/** For internal use by RKXMLGUISyncer, only */
+class RKXMLGUISyncerNotifier : public QObject {
+Q_OBJECT
+public:
+ RKXMLGUISyncerNotifier (QObject *parent) : QObject (parent) {};
+ ~RKXMLGUISyncerNotifier () {};
+
+ void emitChangeSignal (KXMLGUIClient *client) { changed (client); };
+signals:
+ void changed (KXMLGUIClient *client);
+};
+
+class RKXMLGUISyncerPrivate : public QObject {
+Q_OBJECT
+public:
+ RKXMLGUISyncerPrivate () {
+ file_watcher = KDirWatch::self ();
+ connect (file_watcher, SIGNAL (dirty(const QString&)), this, SLOT (uiRcFileChanged(const QString&)));
+
+ connect (&rebuild_guis_timer, SIGNAL (timeout()), this, SLOT (rebuildGUIs()));
+ rebuild_guis_timer.setSingleShot (true);
+ }
+ ~RKXMLGUISyncerPrivate () {};
+
+ /** Internally we store the actionCollection() of each KXMLGUIClient, instead of a pointer to the client, itself. This is because KXMLGUIClient is not a QObject, and so we cannot safely detect its destruction. */
+ QMultiHash<QString, KActionCollection*> client_map;
+ QMultiHash<KActionCollection*, RKXMLGUISyncerNotifier*> notifier_map;
+
+ QSet<KXMLGUIFactory*> affected_factories;
+ QTimer rebuild_guis_timer;
+
+ KDirWatch *file_watcher;
+public slots:
+ void uiRcFileChanged (const QString &path);
+ void actionCollectionDestroyed (QObject *object);
+ void guiFactoryDestroyed (QObject *object);
+ void rebuildGUIs ();
+};
+
+#endif
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list