[rkward-cvs] [rkward] rkward/plugin: Handle action signals from RKComponentMap, instead of RKComponentHandle's.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Fri Nov 28 19:10:07 UTC 2014


Git commit 13a4a2ea590489ce985c42dfe4e558452af3072e by Thomas Friedrichsmeier.
Committed on 28/11/2014 at 18:54.
Pushed by tfry into branch 'master'.

Handle action signals from RKComponentMap, instead of RKComponentHandle's.
- No need to have create QObject for every single handle.
- Will allow better handling of conflicting components (such as resolving to the latest available version on activation).

M  +0    -1    rkward/plugin/rkcomponent.cpp
M  +18   -9    rkward/plugin/rkcomponentmap.cpp
M  +6    -7    rkward/plugin/rkcomponentmap.h

http://commits.kde.org/rkward/13a4a2ea590489ce985c42dfe4e558452af3072e

diff --git a/rkward/plugin/rkcomponent.cpp b/rkward/plugin/rkcomponent.cpp
index a779180..eda0dcd 100644
--- a/rkward/plugin/rkcomponent.cpp
+++ b/rkward/plugin/rkcomponent.cpp
@@ -213,7 +213,6 @@ QVariant RKComponentBase::fetchValue (const QString &id, const int hint) {
 			if (ret.isEmpty ()) {
 				ret << "-" << "-";
 			}
-			RK_DEBUG (PLUGIN, DL_WARNING, "Labels for %s: %s", qPrintable (id), qPrintable (ret.join (":")));
 			return QVariant (ret);
 		}
 		QVariant val = prop->value (mod);
diff --git a/rkward/plugin/rkcomponentmap.cpp b/rkward/plugin/rkcomponentmap.cpp
index e377b6e..71531e6 100644
--- a/rkward/plugin/rkcomponentmap.cpp
+++ b/rkward/plugin/rkcomponentmap.cpp
@@ -223,7 +223,7 @@ void RKComponentMap::initialize () {
 	component_map = new RKComponentMap ();
 }
 
-RKComponentMap::RKComponentMap () : RKComponentGUIXML (), KXMLGUIClient () {
+RKComponentMap::RKComponentMap () : QObject (), RKComponentGUIXML (), KXMLGUIClient () {
 	RK_TRACE (PLUGIN);
 
 	setComponentData (KGlobal::mainComponent ());
@@ -558,12 +558,27 @@ RKPluginMapParseResult RKComponentMap::addPluginMapLocal (const QString& plugin_
 	return ret;
 }
 
+void RKComponentMap::activateComponent () {
+	RK_TRACE (PLUGIN);
+
+	if (!sender ()) {
+		RK_ASSERT (sender ());
+		return;
+	}
+	RKComponentHandle *handle = getComponentHandleLocal (sender ()->objectName ());
+	if (!handle) {
+		RK_ASSERT (handle);
+		return;
+	}
+	handle->invoke (0, 0);
+}
+
 void RKComponentMap::addedEntry (const QString &id, RKComponentHandle *handle) {
 	RK_TRACE (PLUGIN);
 
 	if (handle->isPlugin ()) {
 		handle->setAccessible (true);
-		KAction *action = actionCollection ()->addAction (id, handle, SLOT (activated()));
+		KAction *action = actionCollection ()->addAction (id, this, SLOT (activateComponent()));
 		action->setText (handle->getLabel ());
 		action->setShortcutConfigurable (true);
 	}
@@ -574,7 +589,7 @@ void RKComponentMap::addedEntry (const QString &id, RKComponentHandle *handle) {
 
 #include "rkstandardcomponent.h"
 
-RKComponentHandle::RKComponentHandle (RKPluginMapFile *pluginmap, const QString &rel_filename, const QString &label, RKComponentType type) : QObject (RKWardMainWindow::getMain ()) {
+RKComponentHandle::RKComponentHandle (RKPluginMapFile *pluginmap, const QString &rel_filename, const QString &label, RKComponentType type) {
 	RK_TRACE (PLUGIN);
 
 	RKComponentHandle::type = type;
@@ -603,12 +618,6 @@ RKStandardComponent *RKComponentHandle::invoke (RKComponent *parent_component, Q
 	return (new RKStandardComponent (parent_component, parent_widget, getFilename (), this));
 }
 
-void RKComponentHandle::activated () {
-	RK_TRACE (PLUGIN);
-
-	invoke (0, 0);
-}
-
 QString RKComponentHandle::getAttributeValue (const QString &attribute_id) {
 	RK_TRACE (PLUGIN);
 
diff --git a/rkward/plugin/rkcomponentmap.h b/rkward/plugin/rkcomponentmap.h
index 64abc80..79181d7 100644
--- a/rkward/plugin/rkcomponentmap.h
+++ b/rkward/plugin/rkcomponentmap.h
@@ -63,8 +63,7 @@ class KActionCollection;
 
 @author Thomas Friedrichsmeier
 */
-class RKComponentHandle : public QObject {
-	Q_OBJECT
+class RKComponentHandle {
 public:
 	RKComponentHandle (RKPluginMapFile *pluginmap, const QString &rel_filename, const QString &label, RKComponentType type);
 	virtual ~RKComponentHandle ();
@@ -89,9 +88,6 @@ public:
 /** Returns whether this component is accessible from the menu, somewhere (else it might be in a context) */
 	bool isAccessible () const { return is_accessible; };
 	const RKMessageCatalog *messageCatalog () const { return plugin_map->messageCatalog (); };
-public slots:
-/** Slot called, when the menu-item for this component is selected. Responsible for creating the GUI. */
-	void activated ();
 protected:
 /** The plugin map where this component was declared */
 	RKPluginMapFile *plugin_map;
@@ -175,10 +171,10 @@ The RKComponentMap provides convenience functions for adding or removing a .plug
 
 @author Thomas Friedrichsmeier
 */
-class RKComponentMap : public RKComponentGUIXML, public KXMLGUIClient {
+class RKComponentMap : public QObject, public RKComponentGUIXML, public KXMLGUIClient {
+	Q_OBJECT
 public:
 	RKComponentMap ();
-
 	~RKComponentMap ();
 
 /** adds all Plugins / components in a .pluginmap-file. Also takes care of creating the menu-items, etc.
@@ -209,6 +205,9 @@ public:
 /** @returns a list of all currently registered component ids */
 	QStringList allComponentIds () { return components.keys(); };
 	bool isPluginMapLoaded (const QString& abs_filename) { return pluginmapfiles.contains (abs_filename); };
+public slots:
+/** Slot called, when a menu-item for a component is selected. Responsible for creating the GUI. */
+	void activateComponent ();
 private:
 /** typedef for easy reference to iterator */
 	typedef QMap<QString, RKComponentHandle*> ComponentMap;





More information about the rkward-tracker mailing list