[rkward-cvs] SF.net SVN: rkward: [1200] trunk/rkward/rkward/plugin

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Jan 23 12:19:11 UTC 2007


Revision: 1200
          http://svn.sourceforge.net/rkward/?rev=1200&view=rev
Author:   tfry
Date:     2007-01-23 04:19:11 -0800 (Tue, 23 Jan 2007)

Log Message:
-----------
Merge RKStandardComponentHandle into RKComponentHandle. Components will never be quite as different to need separate classes.

Modified Paths:
--------------
    trunk/rkward/rkward/plugin/rkcomponentcontext.cpp
    trunk/rkward/rkward/plugin/rkcomponentcontext.h
    trunk/rkward/rkward/plugin/rkcomponentmap.cpp
    trunk/rkward/rkward/plugin/rkcomponentmap.h

Modified: trunk/rkward/rkward/plugin/rkcomponentcontext.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentcontext.cpp	2007-01-23 11:49:19 UTC (rev 1199)
+++ trunk/rkward/rkward/plugin/rkcomponentcontext.cpp	2007-01-23 12:19:11 UTC (rev 1200)
@@ -48,7 +48,7 @@
 	for (QStringList::const_iterator it = component_ids.constBegin (); it != component_ids.constEnd (); ++it) {
 		RKComponentHandle *handle = RKComponentMap::getComponentHandle (*it);
 		if (handle->isPlugin ()) {
-			handler->addAction (*it, static_cast<RKStandardComponentHandle *> (handle));
+			handler->addAction (*it, handle);
 		}
 	}
 	return handler;
@@ -77,7 +77,7 @@
 	RK_TRACE (PLUGIN);
 }
 
-void RKContextHandler::addAction (const QString &id, RKStandardComponentHandle *handle) {
+void RKContextHandler::addAction (const QString &id, RKComponentHandle *handle) {
 	RK_TRACE (PLUGIN);
 
 	action_map.insert (new KAction (handle->getLabel (), 0, this, SLOT (componentActionActivated ()), actionCollection (), id.latin1 ()), handle);
@@ -87,7 +87,7 @@
 	RK_TRACE (PLUGIN);
 
 	// find handle that triggered action
-	RKStandardComponentHandle *handle = 0;
+	RKComponentHandle *handle = 0;
 	const KAction *action = dynamic_cast<const KAction *> (sender ());
 	if (action_map.contains (action)) handle = action_map[action];
 	if (!handle) {

Modified: trunk/rkward/rkward/plugin/rkcomponentcontext.h
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentcontext.h	2007-01-23 11:49:19 UTC (rev 1199)
+++ trunk/rkward/rkward/plugin/rkcomponentcontext.h	2007-01-23 12:19:11 UTC (rev 1200)
@@ -69,12 +69,12 @@
 /** desctructor. Should be called automatically, as this is QObject */
 	~RKContextHandler ();
 /** add a KAction to the context. To be called from RKContext::makeContextHandler(). */
-	void addAction (const QString &id, RKStandardComponentHandle *handle);
+	void addAction (const QString &id, RKComponentHandle *handle);
 private slots:
 /** slot to handle plugin activation */
 	void componentActionActivated ();
 private:
-	typedef QMap<const KAction *, RKStandardComponentHandle *> ActionMap;
+	typedef QMap<const KAction *, RKComponentHandle *> ActionMap;
 	ActionMap action_map;
 };
 

Modified: trunk/rkward/rkward/plugin/rkcomponentmap.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentmap.cpp	2007-01-23 11:49:19 UTC (rev 1199)
+++ trunk/rkward/rkward/plugin/rkcomponentmap.cpp	2007-01-23 12:19:11 UTC (rev 1200)
@@ -252,7 +252,7 @@
 		} else if (!QFileInfo (filename).isReadable ()) {
 			RK_DO (qDebug ("Specified file '%s' for component id \"%s\" does not exist or is not readable. Ignoring.", filename.latin1 (), id.latin1 ()), PLUGIN, DL_ERROR);
 		} else {
-			components.insert (id, RKComponentHandle::createComponentHandle (filename, (RKComponentType) type, label));
+			components.insert (id, new RKComponentHandle (filename, label, (RKComponentType) type));
 		}
 	}
 
@@ -296,14 +296,16 @@
 	RK_TRACE (PLUGIN);
 
 	if (handle->isPlugin ()) {
-		new KAction (handle->getLabel (), 0, static_cast<RKStandardComponentHandle *>(handle), SLOT (activated ()), actionCollection (), id.latin1 ());
+		new KAction (handle->getLabel (), 0, handle, SLOT (activated ()), actionCollection (), id.latin1 ());
 	}
 }
 
 ///########################### END RKComponentMap ###############################
 ///########################### BEGIN RKComponentHandle ############################
 
-RKComponentHandle::RKComponentHandle (const QString &filename, const QString &label, RKComponentType type) {
+#include "rkstandardcomponent.h"
+
+RKComponentHandle::RKComponentHandle (const QString &filename, const QString &label, RKComponentType type) : QObject (RKWardMainWindow::getMain ()) {
 	RK_TRACE (PLUGIN);
 
 	RKComponentHandle::type = type;
@@ -315,20 +317,6 @@
 	RK_TRACE (PLUGIN);
 }
 
-//static 
-RKComponentHandle* RKComponentHandle::createComponentHandle (const QString &filename, RKComponentType type, const QString& label) {
-	if (type == (int) Standard) {
-		RKStandardComponentHandle *ret = new RKStandardComponentHandle (filename, label, type);
-		return (ret);
-	}
-	// TODO: create an RKPluginHandle instead!
-
-	// TODO: more ifs, special handling for sepcial components
-
-	RK_ASSERT (false);
-	return 0;
-}
-
 bool RKComponentHandle::isPlugin () {
 	if (type != Standard) {
 		return false;
@@ -336,30 +324,19 @@
 	return true;
 }
 
-
-///########################### END RKComponentHandle ###############################
-///########################### BEGIN RKStandardComponentHandle ############################
-
-#include "rkstandardcomponent.h"
-
-RKStandardComponentHandle::RKStandardComponentHandle (const QString &filename, const QString &label, RKComponentType type) : QObject (RKWardMainWindow::getMain ()), RKComponentHandle (filename, label, type) {
+RKComponent *RKComponentHandle::invoke (RKComponent *parent_component, QWidget *parent_widget) {
 	RK_TRACE (PLUGIN);
-}
+	RK_ASSERT (isPlugin ());
 
-RKStandardComponentHandle::~RKStandardComponentHandle () {
-	RK_TRACE (PLUGIN);
-}
-
-RKComponent *RKStandardComponentHandle::invoke (RKComponent *parent_component, QWidget *parent_widget) {
-	RK_TRACE (PLUGIN);
-
 	return (new RKStandardComponent (parent_component, parent_widget, getFilename (), this));
 }
 
-void RKStandardComponentHandle::activated () {
+void RKComponentHandle::activated () {
 	RK_TRACE (PLUGIN);
 
 	invoke (0, 0);
 }
 
+///########################### END RKComponentHandle ###############################
+
 #include "rkcomponentmap.moc"

Modified: trunk/rkward/rkward/plugin/rkcomponentmap.h
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentmap.h	2007-01-23 11:49:19 UTC (rev 1199)
+++ trunk/rkward/rkward/plugin/rkcomponentmap.h	2007-01-23 12:19:11 UTC (rev 1200)
@@ -24,6 +24,7 @@
 };
 
 #include <qstring.h>
+#include <qobject.h>
 
 class RKComponent;
 class RKComponentMap;
@@ -33,7 +34,8 @@
 
 @author Thomas Friedrichsmeier
 */
-class RKComponentHandle {
+class RKComponentHandle : public QObject {
+	Q_OBJECT
 public:
 	RKComponentHandle (const QString &filename, const QString &label, RKComponentType type);
 
@@ -44,9 +46,10 @@
 	RKComponentType getType () { return type; };
 	bool isPlugin ();
 
-	static RKComponentHandle* createComponentHandle (const QString &filename, RKComponentType type, const QString& label);
-/** invoke the component (standalone or embedded) */
-	virtual RKComponent *invoke (RKComponent *parent_component, QWidget *parent_widget) = 0;
+	RKComponent *invoke (RKComponent *parent_component, QWidget *parent_widget);
+public slots:
+/** Slot called, when the menu-item for this component is selected. Responsible for creating the GUI. */
+	void activated ();
 protected:
 /** The filename of the description file for this component */
 	QString filename;
@@ -153,22 +156,4 @@
 	void addedEntry (const QString &id, RKComponentHandle *handle);
 };
 
-#include <qobject.h>
-
-/**
- at author Thomas Friedrichsmeier
-*/
-class RKStandardComponentHandle : public QObject, public RKComponentHandle {
-	Q_OBJECT
-public:
-	RKStandardComponentHandle (const QString &filename, const QString &label, RKComponentType type);
-
-	~RKStandardComponentHandle ();
-
-	RKComponent *invoke (RKComponent *parent_component, QWidget *parent_widget);
-public slots:
-/** Slot called, when the menu-item for this component is selected. Responsible for creating the GUI. */
-	void activated ();
-};
-
 #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