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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Feb 16 14:14:21 UTC 2007


Revision: 1403
          http://svn.sourceforge.net/rkward/?rev=1403&view=rev
Author:   tfry
Date:     2007-02-16 06:14:21 -0800 (Fri, 16 Feb 2007)

Log Message:
-----------
Make sure the object list is updated when an rk.edit() call gets run

Modified Paths:
--------------
    trunk/rkward/TODO
    trunk/rkward/rkward/agents/Makefile.am
    trunk/rkward/rkward/rbackend/rinterface.cpp
    trunk/rkward/rkward/rbackend/rthread.cpp
    trunk/rkward/rkward/rkward.cpp

Added Paths:
-----------
    trunk/rkward/rkward/agents/rkeditobjectagent.cpp
    trunk/rkward/rkward/agents/rkeditobjectagent.h

Modified: trunk/rkward/TODO
===================================================================
--- trunk/rkward/TODO	2007-02-16 12:21:01 UTC (rev 1402)
+++ trunk/rkward/TODO	2007-02-16 14:14:21 UTC (rev 1403)
@@ -167,9 +167,6 @@
 	- import plugins:
 		- standardized? checkbox to open imported object for editing
 			- would be nice, if this box could be affected (default) by a global setting
-	- multiple interfaces (dialog and wizard)
-		- create a new tag <copy id="..."/> to "copy" an entire element from <dialog> to <wizard> or vice versa. Perhaps additional arguments could be specified, and those would override the ones in the other definition (but maybe this isn't even needed).
-		- should make it much easier to keep the interfaces in sync
 	- Generalized preview:
 		- E.g. for data import plugins
 	- Ability to pre-select some default values with a single option

Modified: trunk/rkward/rkward/agents/Makefile.am
===================================================================
--- trunk/rkward/rkward/agents/Makefile.am	2007-02-16 12:21:01 UTC (rev 1402)
+++ trunk/rkward/rkward/agents/Makefile.am	2007-02-16 14:14:21 UTC (rev 1403)
@@ -1,5 +1,5 @@
 INCLUDES = $(all_includes)
 METASOURCES = AUTO
 noinst_LIBRARIES =  libagents.a
-noinst_HEADERS = rksaveagent.h rkloadagent.h showedittextfileagent.h rkquitagent.h
-libagents_a_SOURCES = rksaveagent.cpp rkloadagent.cpp showedittextfileagent.cpp rkquitagent.cpp
+noinst_HEADERS = rksaveagent.h rkloadagent.h showedittextfileagent.h rkquitagent.h rkeditobjectagent.h
+libagents_a_SOURCES = rksaveagent.cpp rkloadagent.cpp showedittextfileagent.cpp rkquitagent.cpp  rkeditobjectagent.cpp

Added: trunk/rkward/rkward/agents/rkeditobjectagent.cpp
===================================================================
--- trunk/rkward/rkward/agents/rkeditobjectagent.cpp	                        (rev 0)
+++ trunk/rkward/rkward/agents/rkeditobjectagent.cpp	2007-02-16 14:14:21 UTC (rev 1403)
@@ -0,0 +1,65 @@
+/***************************************************************************
+                          rkeditobjectagent  -  description
+                             -------------------
+    begin                : Fri Feb 16 2007
+    copyright            : (C) 2007 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.                                   *
+ *                                                                         *
+ ***************************************************************************/
+#include "rkeditobjectagent.h"
+
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "../rkglobals.h"
+#include "../core/robjectlist.h"
+#include "../rbackend/rinterface.h"
+#include "../rkward.h"
+#include "../windows/rkworkplace.h"
+
+#include "../debug.h"
+
+RKEditObjectAgent::RKEditObjectAgent (const QStringList &object_names, RCommandChain *chain) {
+	RK_TRACE (APP);
+
+	RKEditObjectAgent::object_names = object_names;
+
+	// first issue an empty command to trigger an update of the object list
+	RKGlobals::rInterface ()->issueCommand (new RCommand (QString::null, RCommand::EmptyCommand | RCommand::ObjectListUpdate, QString::null, this), chain);
+
+	// now add another empty command to find out, when the update is complete
+	RCommand *command = new RCommand (QString::null, RCommand::EmptyCommand, QString::null, this);
+	done_command_id = command->id ();
+	RKGlobals::rInterface ()->issueCommand (command, chain);
+}
+
+RKEditObjectAgent::~RKEditObjectAgent () {
+	RK_TRACE (APP);
+}
+
+void RKEditObjectAgent::rCommandDone (RCommand *command) {
+	RK_TRACE (APP);
+
+	if (command->id () == done_command_id) {	
+		for (QStringList::const_iterator it = object_names.constBegin (); it != object_names.constEnd (); ++it) {
+			QString object_name = *it;
+			RObject *obj = RObjectList::getObjectList ()->findObject (object_name);
+			if (!(obj && RKWorkplace::mainWorkplace()->editObject (obj, false))) {
+				KMessageBox::information (0, i18n ("The object '%1', could not be opened for editing. Either it does not exist, or RKWard does not support editing this type of object, yet.").arg (object_name), i18n ("Cannot edit '%1'").arg (object_name));
+			}
+		}
+		
+		// we're done
+		deleteLater ();
+	}
+}
+
+#include "rkeditobjectagent.moc"

Added: trunk/rkward/rkward/agents/rkeditobjectagent.h
===================================================================
--- trunk/rkward/rkward/agents/rkeditobjectagent.h	                        (rev 0)
+++ trunk/rkward/rkward/agents/rkeditobjectagent.h	2007-02-16 14:14:21 UTC (rev 1403)
@@ -0,0 +1,43 @@
+/***************************************************************************
+                          rkeditobjectagent  -  description
+                             -------------------
+    begin                : Fri Feb 16 2007
+    copyright            : (C) 2007 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 RKEDITOBJECTAGENT_H
+#define RKEDITOBJECTAGENT_H
+
+#include <qobject.h>
+#include "../rbackend/rcommandreceiver.h"
+
+#include <qstring.h>
+#include <qstringlist.h>
+
+/** This agent gets called, when an rk.edit() command was run in the backend. The purpose is to first update the structure information for the object(s), and then try to open it/them.
+
+ at author Thomas Friedrichsmeier
+*/
+class RKEditObjectAgent : public QObject, public RCommandReceiver {
+	Q_OBJECT
+public:
+	RKEditObjectAgent (const QStringList &object_names, RCommandChain *chain);
+
+	~RKEditObjectAgent ();
+protected:
+	void rCommandDone (RCommand *command);
+private:
+	QStringList object_names;
+	int done_command_id;
+};
+
+#endif

Modified: trunk/rkward/rkward/rbackend/rinterface.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.cpp	2007-02-16 12:21:01 UTC (rev 1402)
+++ trunk/rkward/rkward/rbackend/rinterface.cpp	2007-02-16 14:14:21 UTC (rev 1403)
@@ -28,6 +28,7 @@
 #include "../dialogs/rkloadlibsdialog.h"
 #include "../dialogs/rkreadlinedialog.h"
 #include "../agents/showedittextfileagent.h"
+#include "../agents/rkeditobjectagent.h"
 #include "../windows/rcontrolwindow.h"
 #include "../windows/rkworkplace.h"
 #include "../windows/rkcommandlog.h"
@@ -324,13 +325,11 @@
 	} else if (call == "edit") {
 		RK_ASSERT (request->call_length >= 2);
 
+		QStringList object_list;
 		for (int i = 1; i < request->call_length; ++i) {
-			QString object_name = request->call[i];
-			RObject *obj = RObjectList::getObjectList ()->findObject (object_name);
-			if (!(obj && RKWorkplace::mainWorkplace()->editObject (obj, false))) {
-				KMessageBox::information (0, i18n ("The object '%1', could not be opened for editing. Either it does not exist, or RKWard does not support editing this type of object, yet.").arg (object_name), i18n ("Cannot edit '%1'").arg (object_name));
-			}
+			object_list.append (request->call[i]);
 		}
+		new RKEditObjectAgent (object_list, request->in_chain);
 	} else if (call == "require") {
 		if (request->call_length >= 2) {
 			QString lib_name = request->call[1];

Modified: trunk/rkward/rkward/rbackend/rthread.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.cpp	2007-02-16 12:21:01 UTC (rev 1402)
+++ trunk/rkward/rkward/rbackend/rthread.cpp	2007-02-16 14:14:21 UTC (rev 1403)
@@ -362,7 +362,9 @@
 			
 			if (command) {
 				// mutex will be unlocked inside
+				bool object_update_forced = (command->type () & RCommand::ObjectListUpdate);
 				doCommand (command);
+				if (object_update_forced) checkObjectUpdatesNeeded (true);
 				processX11Events ();
 			}
 		}

Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp	2007-02-16 12:21:01 UTC (rev 1402)
+++ trunk/rkward/rkward/rkward.cpp	2007-02-16 14:14:21 UTC (rev 1403)
@@ -82,6 +82,7 @@
 #include "windows/detachedwindowcontainer.h"	// TODO: see below: needed purely for linking!
 #include "windows/qxembedcopy.h"	// TODO: see below: needed purely for linking!
 #include "dataeditor/rkeditordataframepart.h"	// TODO: see below: needed purely for linking!
+#include "agents/rkeditobjectagent.h"	// TODO: see below: needed purely for linking!
 
 // This nevers gets called. It's needed to trick ld into linking correctly. Nothing else.
 void bogusCalls () {
@@ -91,6 +92,7 @@
 	DetachedWindowContainer (0);
 	new RKWorkplaceView (0);
 	new QXEmbedCopy (0);
+	new RKEditObjectAgent (QStringList (), 0);
 }
 
 //static


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