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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Jun 16 18:59:46 UTC 2010


Revision: 2883
          http://rkward.svn.sourceforge.net/rkward/?rev=2883&view=rev
Author:   tfry
Date:     2010-06-16 18:59:46 +0000 (Wed, 16 Jun 2010)

Log Message:
-----------
Initialize rownames, and signal changes, properly

Modified Paths:
--------------
    trunk/rkward/rkward/core/rkrownames.cpp
    trunk/rkward/rkward/core/rkrownames.h

Modified: trunk/rkward/rkward/core/rkrownames.cpp
===================================================================
--- trunk/rkward/rkward/core/rkrownames.cpp	2010-06-15 20:30:39 UTC (rev 2882)
+++ trunk/rkward/rkward/core/rkrownames.cpp	2010-06-16 18:59:46 UTC (rev 2883)
@@ -44,6 +44,22 @@
 	RK_TRACE (OBJECTS);
 }
 
+void RKRowNames::beginEdit () {
+	RK_TRACE (OBJECTS);
+
+	bool just_initialized = (data == 0);
+	RKVariable::beginEdit ();
+
+	if (just_initialized) {
+		RK_ASSERT (data);
+		for (int i = 0; i < getLength (); ++i) {
+			data->cell_strings[i] = QString::number (i+1);
+			data->cell_states[i] = RKVarEditData::Valid;
+		}
+		is_sequential_up_to_row = getLength () - 1;
+	}
+}
+
 QString RKRowNames::getFullName () const {
 //	RK_TRACE (OBJECTS);
 
@@ -55,11 +71,6 @@
 
 	if (isSequential ()) {
 		RKGlobals::rInterface ()->issueCommand (getFullName () + " <- NULL", RCommand::App | RCommand::Sync, QString::null, 0,0, chain);
-
-		ChangeSet *set = new ChangeSet;
-		set->from_index = from_row;
-		set->to_index = to_row;
-		RKGlobals::tracker ()->objectDataChanged (this, set);
 	} else {
 		// unfortunately, we always need to write the whole data, as row.names<- does not support indexing.
 		QString data_string = "c (";
@@ -73,6 +84,11 @@
 		data_string.append (")");
 		RKGlobals::rInterface ()->issueCommand (getFullName () + " <- " + data_string, RCommand::App | RCommand::Sync, QString::null, 0, 0, chain);
 	}
+
+	ChangeSet *set = new ChangeSet;
+	set->from_index = from_row;
+	set->to_index = to_row;
+	RKGlobals::tracker ()->objectDataChanged (this, set);
 }
 
 void RKRowNames::setText (int row, const QString &text) {

Modified: trunk/rkward/rkward/core/rkrownames.h
===================================================================
--- trunk/rkward/rkward/core/rkrownames.h	2010-06-15 20:30:39 UTC (rev 2882)
+++ trunk/rkward/rkward/core/rkrownames.h	2010-06-16 18:59:46 UTC (rev 2883)
@@ -44,6 +44,8 @@
 protected:
 /** Reimplemented to disable duplicate checks during the setText() calls within */
 	void setCharacterFromR (int from_row, int to_row, QString *data);
+/** Reimplemented to assume sequential row number on initialization */
+	void beginEdit ();
 private:
 /** @returns: true if the text was already unique, false, if it had to be adjusted */
 	bool makeUnique (QString *text, bool non_sequentials_only);


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