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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Nov 27 17:16:32 UTC 2006


Revision: 950
          http://svn.sourceforge.net/rkward/?rev=950&view=rev
Author:   tfry
Date:     2006-11-27 09:16:32 -0800 (Mon, 27 Nov 2006)

Log Message:
-----------
Allow to use plugins dedicated to X11 windows; small fix to setting icon of attached windows

Modified Paths:
--------------
    trunk/rkward/rkward/plugin/rkcomponentmap.cpp
    trunk/rkward/rkward/plugin/rkcomponentmap.h
    trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
    trunk/rkward/rkward/plugins/all.pluginmap
    trunk/rkward/rkward/rkglobals.cpp
    trunk/rkward/rkward/rkglobals.h
    trunk/rkward/rkward/rkward.cpp
    trunk/rkward/rkward/windows/rkcatchedx11windowpart.rc
    trunk/rkward/rkward/windows/rkwindowcatcher.cpp
    trunk/rkward/rkward/windows/rkwindowcatcher.h
    trunk/rkward/rkward/windows/rkworkplaceview.cpp

Added Paths:
-----------
    trunk/rkward/rkward/plugins/x11device/
    trunk/rkward/rkward/plugins/x11device/export.php
    trunk/rkward/rkward/plugins/x11device/export.xml
    trunk/rkward/rkward/plugins/x11device.pluginmap

Modified: trunk/rkward/rkward/plugin/rkcomponentmap.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentmap.cpp	2006-11-27 15:53:58 UTC (rev 949)
+++ trunk/rkward/rkward/plugin/rkcomponentmap.cpp	2006-11-27 17:16:32 UTC (rev 950)
@@ -26,6 +26,19 @@
 #include "../rkglobals.h"
 #include "../rkward.h"
 
+// static members
+RKComponentMap *RKComponentMap::regular_component_map = 0;
+RKComponentMap *RKComponentMap::x11_device_component_map = 0;;
+
+void RKComponentMap::initializeMaps () {
+	RK_TRACE (PLUGIN);
+
+	RK_ASSERT (regular_component_map == 0);
+	RK_ASSERT (x11_device_component_map == 0);
+	regular_component_map = new RKComponentMap ();
+	x11_device_component_map = new RKComponentMap ();
+}
+
 RKComponentMap::RKComponentMap () : KXMLGUIClient () {
 	RK_TRACE (PLUGIN);
 }
@@ -33,10 +46,10 @@
 RKComponentMap::~RKComponentMap () {
 	RK_TRACE (PLUGIN);
 
-	clear ();
+	clearLocal ();
 }
 
-void RKComponentMap::clear () {
+void RKComponentMap::clearLocal () {
 	RK_TRACE (PLUGIN);
 
 	actionCollection ()->clear ();
@@ -52,12 +65,32 @@
 	setXMLGUIBuildDocument (doc);
 }
 
+void RKComponentMap::clearAll () {
+	RK_TRACE (PLUGIN);
+
+	getRegularMap ()->clearLocal ();
+	getX11DeviceMap ()->clearLocal ();
+}
+
 RKComponentHandle* RKComponentMap::getComponentHandle (const QString &id) {
 	RK_TRACE (PLUGIN);
 
-	return (components[id]);
+	RKComponentHandle *handle = getRegularMap ()->getComponentHandleLocal (id);
+	if (handle) return handle;
+	handle = getX11DeviceMap ()->getComponentHandleLocal (id);
+	if (handle) return handle;
+
+	RK_DO (qDebug ("no such component %s", id.latin1 ()), PLUGIN, DL_WARNING);
+	return (0);
 }
 
+RKComponentHandle* RKComponentMap::getComponentHandleLocal (const QString &id) {
+	RK_TRACE (PLUGIN);
+
+	if (components.contains (id)) return (components[id]);
+	return 0;
+}
+
 //static
 QDomElement RKComponentMap::findOrCreateElement (QDomElement& parent, const QString& tagname, const QString& name, const QString& label, int index) {
 	RK_TRACE (PLUGIN);
@@ -133,6 +166,18 @@
 	QDomElement document_element = xml->openXMLFile (plugin_map_file, DL_ERROR);
 	if (xml->highestError () >= DL_ERROR) return (0);
 
+	int type = xml->getMultiChoiceAttribute (document_element, "type", "regular;x11", 0, DL_INFO);
+	if (type == 0) return getRegularMap()->addPluginMapLocal (plugin_map_file, document_element);
+	else return getX11DeviceMap()->addPluginMapLocal (plugin_map_file, document_element);
+}
+
+int RKComponentMap::addPluginMapLocal (const QString& plugin_map_file, const QDomElement &document_element) {
+	RK_TRACE (PLUGIN);
+
+	XMLHelper* xml = XMLHelper::getStaticHelper ();
+	QDomElement element;
+	XMLChildList list;	
+
 	QString prefix = QFileInfo (plugin_map_file).dirPath (true) + "/" + xml->getStringAttribute (document_element, "base_prefix", QString::null, DL_INFO);
 	QString cnamespace = xml->getStringAttribute (document_element, "namespace", "rkward", DL_INFO) + "::";
 
@@ -151,7 +196,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, id, label));
+			components.insert (id, RKComponentHandle::createComponentHandle (filename, (RKComponentType) type, id, label, this));
 		}
 	}
 
@@ -198,10 +243,10 @@
 }
 
 //static 
-RKComponentHandle* RKComponentHandle::createComponentHandle (const QString &filename, RKComponentType type, const QString& id, const QString& label) {
+RKComponentHandle* RKComponentHandle::createComponentHandle (const QString &filename, RKComponentType type, const QString& id, const QString& label, RKComponentMap *map) {
 	if (type == (int) Standard) {
 		RKStandardComponentHandle *ret = new RKStandardComponentHandle (filename, type);
-		new KAction (label, 0, ret, SLOT (activated ()), RKGlobals::componentMap ()->actionCollection (), id.latin1 ());
+		new KAction (label, 0, ret, SLOT (activated ()), map->actionCollection (), id.latin1 ());
 		return (ret);
 	}
 	// TODO: create an RKPluginHandle instead!

Modified: trunk/rkward/rkward/plugin/rkcomponentmap.h
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentmap.h	2006-11-27 15:53:58 UTC (rev 949)
+++ trunk/rkward/rkward/plugin/rkcomponentmap.h	2006-11-27 17:16:32 UTC (rev 950)
@@ -26,6 +26,7 @@
 #include <qstring.h>
 
 class RKComponent;
+class RKComponentMap;
 class QWidget;
 /** This simple class keeps the most basic information about a component in RKWard. Most work is done in RKComponentMap.
 
@@ -41,7 +42,7 @@
 	RKComponentType getType () { return type; };
 	bool isPlugin ();
 
-	static RKComponentHandle* createComponentHandle (const QString &filename, RKComponentType type, const QString& id, const QString& label);
+	static RKComponentHandle* createComponentHandle (const QString &filename, RKComponentType type, const QString& id, const QString& label, RKComponentMap *map);
 /** invoke the component (standalone or embedded) */
 	virtual RKComponent *invoke (RKComponent *parent_component, QWidget *parent_widget) = 0;
 private:
@@ -72,12 +73,16 @@
 
 /** adds all Plugins / components in a .pluginmap-file. Also takes care of creating the menu-items, etc.
 @returns number of plugins (i.e. stand-alone components/menu-entries) added successfully */
-	int addPluginMap (const QString& plugin_map_file);
+	static int addPluginMap (const QString& plugin_map_file);
+
 /** clears out (and deletes) all components / plugins */
-	void clear ();
+	static void clearAll ();
 
 /** returns the component identified by id */
-	RKComponentHandle* getComponentHandle (const QString &id);
+	static RKComponentHandle* getComponentHandle (const QString &id);
+	static RKComponentMap *getRegularMap () { return regular_component_map; };
+	static RKComponentMap *getX11DeviceMap () { return x11_device_component_map; };
+	static void initializeMaps ();
 private:
 /** recurse into a lower menu-level 
 @param parent the parent menu (in the KXMLGUI)
@@ -97,6 +102,14 @@
 	typedef QMap<QString, RKComponentHandle*> ComponentMap;
 /** the actual map of components */
 	ComponentMap components;
+
+	RKComponentHandle* getComponentHandleLocal (const QString &id);
+	int addPluginMapLocal (const QString& plugin_map_file, const QDomElement &document_element);
+
+	void clearLocal ();
+
+	static RKComponentMap *regular_component_map;
+	static RKComponentMap *x11_device_component_map;
 };
 
 #include <qobject.h>

Modified: trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2006-11-27 15:53:58 UTC (rev 949)
+++ trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2006-11-27 17:16:32 UTC (rev 950)
@@ -493,7 +493,7 @@
 			widget = new RKText (e, component (), parent_widget);
 		} else if (e.tagName () == "embed") {
 			QString component_id = xml->getStringAttribute (e, "component", QString::null, DL_ERROR);
-			RKComponentHandle *handle = RKGlobals::componentMap ()->getComponentHandle (component_id);
+			RKComponentHandle *handle = RKComponentMap::getComponentHandle (component_id);
 			if (handle) {
 				if (xml->getBoolAttribute (e, "as_button", false, DL_INFO)) {
 					widget = handle->invoke (component (), 0);

Modified: trunk/rkward/rkward/plugins/all.pluginmap
===================================================================
--- trunk/rkward/rkward/plugins/all.pluginmap	2006-11-27 15:53:58 UTC (rev 949)
+++ trunk/rkward/rkward/plugins/all.pluginmap	2006-11-27 17:16:32 UTC (rev 950)
@@ -1,6 +1,6 @@
 <!DOCTYPE rkpluginmap>
 
-<document base_prefix="" namespace="rkward">
+<document base_prefix="" namespace="rkward" type="regular">
 	<components>
 		<component type="standard" id="independent_samples_t_test" file="00means/00ttests/00independent_samples/description.xml" label="Independent Samples" />
 
@@ -55,5 +55,6 @@
 
 	<include file="distributions.pluginmap"/>
 	<include file="plots.pluginmap"/>
+	<include file="x11device.pluginmap"/>
 </document>
  

Added: trunk/rkward/rkward/plugins/x11device/export.php
===================================================================

Added: trunk/rkward/rkward/plugins/x11device/export.xml
===================================================================

Added: trunk/rkward/rkward/plugins/x11device.pluginmap
===================================================================
--- trunk/rkward/rkward/plugins/x11device.pluginmap	                        (rev 0)
+++ trunk/rkward/rkward/plugins/x11device.pluginmap	2006-11-27 17:16:32 UTC (rev 950)
@@ -0,0 +1,13 @@
+<!DOCTYPE rkpluginmap>
+
+<document base_prefix="x11device/" namespace="rkward" type="x11">
+	<components>
+		<component type="standard" id="export_x11_device" file="export.xml" label="Export..." />
+	</components>
+
+	<hierarchy>
+		<menu id="device" label="Device" index="1">
+			<entry component="export_x11_device" />
+		</menu>
+	</hierarchy>
+</document>

Modified: trunk/rkward/rkward/rkglobals.cpp
===================================================================
--- trunk/rkward/rkward/rkglobals.cpp	2006-11-27 15:53:58 UTC (rev 949)
+++ trunk/rkward/rkward/rkglobals.cpp	2006-11-27 17:16:32 UTC (rev 950)
@@ -20,7 +20,6 @@
 
 RInterface *RKGlobals::rinter;
 RKModificationTracker *RKGlobals::mtracker;
-RKComponentMap *RKGlobals::cmap;
 KHelpDlg *RKGlobals::helpdlg;
 RControlWindow *RKGlobals::rcontrol;
 

Modified: trunk/rkward/rkward/rkglobals.h
===================================================================
--- trunk/rkward/rkward/rkglobals.h	2006-11-27 15:53:58 UTC (rev 949)
+++ trunk/rkward/rkward/rkglobals.h	2006-11-27 17:16:32 UTC (rev 950)
@@ -21,7 +21,6 @@
 class RInterface;
 class RObjectList;
 class RKModificationTracker;
-class RKComponentMap;
 class KHelpDlg;
 class RControlWindow;
 class QString;
@@ -44,8 +43,6 @@
 	static RInterface *rInterface () { return rinter; };
 /// static pointer to the RKModificationTracker
 	static RKModificationTracker *tracker () { return mtracker; };
-/// static pointer to the RKComponentMap
-	static RKComponentMap *componentMap () { return cmap; };
 /// static pointer to the RKHelpDlg
 	static KHelpDlg *helpDialog () { return helpdlg; };
 /// static pointer to the RControlWindow
@@ -65,7 +62,6 @@
 	friend class RKWardMainWindow;
 	static RInterface *rinter;
 	static RKModificationTracker *mtracker;
-	static RKComponentMap *cmap;
 	static KHelpDlg *helpdlg;
 	static RControlWindow *rcontrol;
 };

Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp	2006-11-27 15:53:58 UTC (rev 949)
+++ trunk/rkward/rkward/rkward.cpp	2006-11-27 17:16:32 UTC (rev 950)
@@ -124,7 +124,7 @@
 	connect (this, SIGNAL (childWindowCloseRequest (KMdiChildView *)), this, SLOT (slotChildWindowCloseRequest (KMdiChildView *)));
 
 	RKGlobals::mtracker = new RKModificationTracker (this);
-	RKGlobals::cmap = new RKComponentMap ();
+	RKComponentMap::initializeMaps ();
 
 	initial_url = load_url;
 
@@ -225,20 +225,20 @@
 	RK_TRACE (APP);
 	slotSetStatusBarText(i18n("Setting up plugins..."));
 	
-	factory ()->removeClient (RKGlobals::componentMap ());
-	RKGlobals::componentMap ()->clear ();
+	factory ()->removeClient (RKComponentMap::getRegularMap ());
+	RKComponentMap::clearAll ();
 
 	QStringList list = RKSettingsModulePlugins::pluginMaps ();
 	int counter = 0;
 	for (QStringList::const_iterator it = RKSettingsModulePlugins::pluginMaps ().begin (); it != RKSettingsModulePlugins::pluginMaps ().end (); ++it) {
-		counter += RKGlobals::componentMap ()->addPluginMap ((*it));
+		counter += RKComponentMap::addPluginMap ((*it));
 	}
 
 	if (counter < 1) {
 		KMessageBox::information (0, i18n ("Plugins are needed: you may manage these through \"Settings->Configure RKWard\".\n"), i18n ("No (valid) plugins found"));
 	}
 
-	factory ()->addClient (RKGlobals::componentMap ());
+	factory ()->addClient (RKComponentMap::getRegularMap ());
 
 	slotSetStatusReady ();
 }

Modified: trunk/rkward/rkward/windows/rkcatchedx11windowpart.rc
===================================================================
--- trunk/rkward/rkward/windows/rkcatchedx11windowpart.rc	2006-11-27 15:53:58 UTC (rev 949)
+++ trunk/rkward/rkward/windows/rkcatchedx11windowpart.rc	2006-11-27 17:16:32 UTC (rev 950)
@@ -1,14 +1,13 @@
 <!DOCTYPE kpartgui>
 <kpartgui name="rkward" version="0.4.2">
 	<MenuBar>
-		<Menu name="plot"><text>&Device</text>
+		<Menu name="device"><text>&Device</text>
 			<Action name="device_activate"/>
 			<Action name="device_duplicate"/>
 			<Separator/>
 			<Action name="device_print"/>
 			<Action name="device_copy_to_output"/>
 			<Action name="device_copy_to_r_object"/>
-			<Action name="device_copy_to_file"/>
 			<Merge/>
 		</Menu>
 		<Menu name="view"><text>&View</text>

Modified: trunk/rkward/rkward/windows/rkwindowcatcher.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.cpp	2006-11-27 15:53:58 UTC (rev 949)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.cpp	2006-11-27 17:16:32 UTC (rev 950)
@@ -257,14 +257,6 @@
 	delete dialog;
 }
 
-void RKCatchedX11Window::copyDeviceToFile () {
-	RK_TRACE (MISC);
-
-	KMessageBox::information (0, i18n ("Not yet implemented"), i18n ("Not yet implemented"));
-
-	#warning implement or deactivate action
-}
-
 void RKCatchedX11Window::duplicateDevice () {
 	RK_TRACE (MISC);
 
@@ -276,6 +268,7 @@
 /**************************************************************************************/
 //////////////////////////////// BEGIN RKCatchedX11WindowPart //////////////////////////
 
+#include "../plugin/rkcomponentmap.h"
 
 RKCatchedX11WindowPart::RKCatchedX11WindowPart (RKCatchedX11Window *window) : KParts::Part (0) {
 	RK_TRACE (MISC);
@@ -299,8 +292,9 @@
 	new KAction (i18n ("Copy to output"), 0, window, SLOT (copyDeviceToOutput ()), actionCollection (), "device_copy_to_output");
 	new KAction (i18n ("Print"), 0, window, SLOT (printDevice ()), actionCollection (), "device_print");
 	new KAction (i18n ("Store as R object..."), 0, window, SLOT (copyDeviceToRObject ()), actionCollection (), "device_copy_to_r_object");
-	new KAction (i18n ("Export..."), 0, window, SLOT (copyDeviceToFile ()), actionCollection (), "device_copy_to_file");
 	new KAction (i18n ("Duplicate"), 0, window, SLOT (duplicateDevice ()), actionCollection (), "device_duplicate");
+
+	insertChildClient (RKComponentMap::getX11DeviceMap ());
 }
 
 RKCatchedX11WindowPart::~RKCatchedX11WindowPart () {

Modified: trunk/rkward/rkward/windows/rkwindowcatcher.h
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.h	2006-11-27 15:53:58 UTC (rev 949)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.h	2006-11-27 17:16:32 UTC (rev 950)
@@ -119,7 +119,6 @@
 	void copyDeviceToOutput ();
 	void printDevice ();
 	void copyDeviceToRObject ();
-	void copyDeviceToFile ();
 	void duplicateDevice ();
 private:
 	friend class RKCatchedX11WindowPart;	// needs access to the actions

Modified: trunk/rkward/rkward/windows/rkworkplaceview.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkworkplaceview.cpp	2006-11-27 15:53:58 UTC (rev 949)
+++ trunk/rkward/rkward/windows/rkworkplaceview.cpp	2006-11-27 17:16:32 UTC (rev 950)
@@ -53,7 +53,15 @@
 	RK_TRACE (APP);
 
 	widgets->addWidget (widget);
-	int id = tabs->addTab (new QTab (*(widget->icon ()), widget->shortCaption ()));
+	int id;
+	if (widget->icon ()) {
+		id = tabs->addTab (new QTab (*(widget->icon ()), widget->shortCaption ()));
+	} else if (widget->topLevelWidget ()->icon ()) {
+		id = tabs->addTab (new QTab (*(widget->topLevelWidget ()->icon ()), widget->shortCaption ()));
+	} else {
+		RK_ASSERT (false);
+		id = tabs->addTab (new QTab (widget->shortCaption ()));
+	}
 	pages.insert (id, widget);
 	connect (widget, SIGNAL (captionChanged (RKMDIWindow *)), this, SLOT (childCaptionChanged (RKMDIWindow *)));
 	widget->show ();


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