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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Oct 2 18:31:46 UTC 2006


Revision: 791
          http://svn.sourceforge.net/rkward/?rev=791&view=rev
Author:   tfry
Date:     2006-10-02 11:31:37 -0700 (Mon, 02 Oct 2006)

Log Message:
-----------
deal with restored objects during update

Modified Paths:
--------------
    trunk/rkward/rkward/core/rcontainerobject.cpp
    trunk/rkward/rkward/core/rkmodificationtracker.cpp
    trunk/rkward/rkward/core/rkmodificationtracker.h

Modified: trunk/rkward/rkward/core/rcontainerobject.cpp
===================================================================
--- trunk/rkward/rkward/core/rcontainerobject.cpp	2006-10-02 18:18:15 UTC (rev 790)
+++ trunk/rkward/rkward/core/rcontainerobject.cpp	2006-10-02 18:31:37 UTC (rev 791)
@@ -55,15 +55,16 @@
 			RK_ASSERT (false);
 			return 0;
 		} else {
-qDebug (child->getFullName ().latin1());
-			RKGlobals::tracker ()->removeObject (child, 0, true);
-
-			RData *child_name_data = new_data->getStructureVector ()[0];
-			RK_ASSERT (child_name_data->getDataType () == RData::StringVector);
-			RK_ASSERT (child_name_data->getDataLength () >= 1);
-			QString child_name = child_name_data->getStringVector ()[0];
-
-			return (createChildFromStructure (new_data, child_name));
+			if (RKGlobals::tracker ()->removeObject (child, 0, true)) {
+				RData *child_name_data = new_data->getStructureVector ()[0];
+				RK_ASSERT (child_name_data->getDataType () == RData::StringVector);
+				RK_ASSERT (child_name_data->getDataLength () >= 1);
+				QString child_name = child_name_data->getStringVector ()[0];
+	
+				return (createChildFromStructure (new_data, child_name));
+			} else {
+				return child;		// it was restored in it's old shape
+			}
 		}
 	}
 }

Modified: trunk/rkward/rkward/core/rkmodificationtracker.cpp
===================================================================
--- trunk/rkward/rkward/core/rkmodificationtracker.cpp	2006-10-02 18:18:15 UTC (rev 790)
+++ trunk/rkward/rkward/core/rkmodificationtracker.cpp	2006-10-02 18:31:37 UTC (rev 791)
@@ -36,29 +36,30 @@
 	RK_TRACE (OBJECTS);
 }
 
-void RKModificationTracker::removeObject (RObject *object, RKEditor *editor, bool removed_in_workspace) {
+bool RKModificationTracker::removeObject (RObject *object, RKEditor *editor, bool removed_in_workspace) {
 	RK_TRACE (OBJECTS);
 // TODO: allow more than one editor per object
+#warning ! This does not work, if a sub-object is being edited!
 	RKEditor *ed = object->objectOpened ();
 	RK_ASSERT (!((editor) && (!ed)));
 	RK_ASSERT (!(removed_in_workspace && editor));
-	
+
 	if (removed_in_workspace) {
 		if (ed) {
-			if (KMessageBox::questionYesNo (0, i18n ("The object '%1' was removed from workspace, but is currently opened for editing. Do you want to restore it?").arg (object->getFullName ()), i18n ("Restore object?")) == KMessageBox::Yes) {
+			if (KMessageBox::questionYesNo (0, i18n ("The object '%1' was removed from workspace or changed to a different type of object, but is currently opened for editing. Do you want to restore it?").arg (object->getFullName ()), i18n ("Restore object?")) == KMessageBox::Yes) {
 				if (removed_in_workspace) ed->restoreObject (object);
-				return;
+				return false;
 			}
 		}
 	} else {
 		if (editor || ed) {
 			if (KMessageBox::questionYesNo (0, i18n ("Do you really want to remove the object '%1'? The object is currently opened for editing, it will be removed in the editor, too. There's no way to get it back.").arg (object->getFullName ()), i18n ("Remove object?")) != KMessageBox::Yes) {
-				return;
+				return false;
 			}
 		} else {
 			// TODO: check for other editors editing this object
 			if (KMessageBox::questionYesNo (0, i18n ("Do you really want to remove the object '%1'? There's no way to get it back.").arg (object->getFullName ()), i18n ("Remove object?")) != KMessageBox::Yes) {
-				return;
+				return false;
 			}
 		}
 	}
@@ -66,6 +67,8 @@
 	if (ed) ed->removeObject (object);
 	if (updates_locked <= 0) emit (objectRemoved (object));
 	object->remove (removed_in_workspace);
+
+	return true;
 }
 
 void RKModificationTracker::renameObject (RObject *object, const QString &new_name) {

Modified: trunk/rkward/rkward/core/rkmodificationtracker.h
===================================================================
--- trunk/rkward/rkward/core/rkmodificationtracker.h	2006-10-02 18:18:15 UTC (rev 790)
+++ trunk/rkward/rkward/core/rkmodificationtracker.h	2006-10-02 18:31:37 UTC (rev 791)
@@ -38,7 +38,7 @@
 	~RKModificationTracker ();
 	
 /** the given object should be removed (either it was removed in the R-workspace, or the user requests removal of the object in an editor or the RObjectList). First, if the object is being edited somewhere, the user will get a chance to object to the removal. If the user does no object, the RKModificationTracker will remove the object and notify all editors/objectlists that the object really was removed. When calling from the RObjectList, you will likely set removed_in_workspace to true, to signal that the object-data is already gone in the workspace. */
-	void removeObject (RObject *object, RKEditor *editor=0, bool removed_in_workspace=false);
+	bool removeObject (RObject *object, RKEditor *editor=0, bool removed_in_workspace=false);
 /** essentially like the above function, but requests a renaming of the object. Will also take care of finding out, whether the name is valid and promting for a different name otherwise. */
 	void renameObject (RObject *object, const QString &new_name);
 /** essentially like the above function(s). All objects editing a parent of the new objects are notified of the addition. */


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