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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Nov 27 13:12:25 UTC 2012


Revision: 4455
          http://rkward.svn.sourceforge.net/rkward/?rev=4455&view=rev
Author:   tfry
Date:     2012-11-27 13:12:24 +0000 (Tue, 27 Nov 2012)
Log Message:
-----------
Fix initialization order of <convert> properties

Modified Paths:
--------------
    trunk/rkward/rkward/plugin/rkabstractoptionselector.cpp
    trunk/rkward/rkward/plugin/rkabstractoptionselector.h
    trunk/rkward/rkward/plugin/rkcheckbox.h
    trunk/rkward/rkward/plugin/rkcomponent.cpp
    trunk/rkward/rkward/plugin/rkcomponent.h
    trunk/rkward/rkward/plugin/rkcomponentproperties.cpp
    trunk/rkward/rkward/plugin/rkcomponentproperties.h
    trunk/rkward/rkward/plugin/rkformula.h
    trunk/rkward/rkward/plugin/rkinput.cpp
    trunk/rkward/rkward/plugin/rkinput.h
    trunk/rkward/rkward/plugin/rkmatrixinput.cpp
    trunk/rkward/rkward/plugin/rkmatrixinput.h
    trunk/rkward/rkward/plugin/rkoptionset.cpp
    trunk/rkward/rkward/plugin/rkpluginbrowser.cpp
    trunk/rkward/rkward/plugin/rkpluginbrowser.h
    trunk/rkward/rkward/plugin/rkpluginframe.cpp
    trunk/rkward/rkward/plugin/rkpluginframe.h
    trunk/rkward/rkward/plugin/rkpluginsaveobject.cpp
    trunk/rkward/rkward/plugin/rkpluginsaveobject.h
    trunk/rkward/rkward/plugin/rkpluginspinbox.cpp
    trunk/rkward/rkward/plugin/rkpluginspinbox.h
    trunk/rkward/rkward/plugin/rkpreviewbox.h
    trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
    trunk/rkward/rkward/plugin/rktext.cpp
    trunk/rkward/rkward/plugin/rktext.h
    trunk/rkward/rkward/plugin/rkvarselector.cpp
    trunk/rkward/rkward/plugin/rkvarslot.cpp
    trunk/rkward/rkward/plugin/rkvarslot.h

Modified: trunk/rkward/rkward/plugin/rkabstractoptionselector.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkabstractoptionselector.cpp	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkabstractoptionselector.cpp	2012-11-27 13:12:24 UTC (rev 4455)
@@ -111,7 +111,7 @@
 
 	int new_id = -1;
 	if (property == string) {
-		new_id = findOption (string->value ());
+		new_id = findOption (fetchStringValue (string));
 	} else if (property == number) {
 		new_id = number->intValue ();
 	} else {
@@ -120,7 +120,7 @@
 	if (new_id < 0) {
 		RK_DO (qDebug ("option selector '%s' has no such option:", qPrintable (getIdInParent ())), PLUGIN, DL_ERROR);
 		if (property == string) {
-			RK_DO (qDebug ("'%s'", qPrintable (string->value ())), PLUGIN, DL_ERROR);
+			RK_DO (qDebug ("'%s'", qPrintable (fetchStringValue (string))), PLUGIN, DL_ERROR);
 		} else {
 			RK_DO (qDebug ("index %d", number->intValue ()), PLUGIN, DL_ERROR);
 		}

Modified: trunk/rkward/rkward/plugin/rkabstractoptionselector.h
===================================================================
--- trunk/rkward/rkward/plugin/rkabstractoptionselector.h	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkabstractoptionselector.h	2012-11-27 13:12:24 UTC (rev 4455)
@@ -38,7 +38,7 @@
 @param option_string the option string to search for
 @returns the id (0, 1, 2...) of the corresponding option, or -1 if not found */
 	int findOption (const QString &option_string);
-	QString value (const QString &modifier) { return (string->value (modifier)); };
+	QVariant value (const QString &modifier=QString ()) { return (string->value (modifier)); };
 /** reimplemented from RKComponent to add enabledness properties for the options, dynamically, if requested */
 	RKComponentBase* lookupComponent (const QString &identifier, QString *remainder);
 public slots:

Modified: trunk/rkward/rkward/plugin/rkcheckbox.h
===================================================================
--- trunk/rkward/rkward/plugin/rkcheckbox.h	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkcheckbox.h	2012-11-27 13:12:24 UTC (rev 4455)
@@ -37,7 +37,10 @@
 	~RKCheckBox ();
 	int type () { return ComponentCheckBox; };
 	RKComponentPropertyBool *state;
-	QString value (const QString &modifier) { return (state->value (modifier)); };
+	QVariant value (const QString &modifier=QString ()) {
+		if (modifier.isEmpty ()) return state->value ("labeled");
+		return (state->value (modifier));
+	};
 public slots:
 	void changedState (int);
 	void changedState (RKComponentPropertyBase *);

Modified: trunk/rkward/rkward/plugin/rkcomponent.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponent.cpp	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkcomponent.cpp	2012-11-27 13:12:24 UTC (rev 4455)
@@ -55,7 +55,7 @@
 
 		if (it.value ()->isProperty ()) {
 			if (include_top_level) {
-				list->insert (prefix + it.key (), static_cast<RKComponentPropertyBase*> (it.value ())->value ());
+				list->insert (prefix + it.key (), fetchStringValue (it.value ()));
 			}
 		} else {
 			RK_ASSERT (it.value ()->isComponent ());
@@ -123,13 +123,16 @@
 			QString dummy;
 			RKComponentBase *prop = lookupComponent (it.key (), &dummy);
 			if (dummy.isEmpty () && prop) {
-				// COMPAT: In RKWard 0.5.1, the formatting of real numbers was different. Hence we compare the numeric values, instead
 				if ((prop->type () == PropertyDouble) && static_cast<RKComponentPropertyDouble*> (prop)->doubleValue () == it.value ().toDouble ()) {
+					// COMPAT: In RKWard 0.5.1, the formatting of real numbers was different. Hence we compare the numeric values, instead
 					continue;
-				} else if (prop->value () == it.value ()) {
+				} else if ((prop->type () == PropertyBool) && (it.value () == prop->value ("labeled").toString ())) {
+					// COMPAT: In RKWard 0.6.0, bool properties returned the labelled string, by default. Hence we also compare on the labelled value
 					continue;
+				} else if (fetchStringValue (prop) == it.value ()) {
+					continue;
 				} else {
-					if (current_value.isEmpty () && !prop->value ().isEmpty ()) current_value = prop->value ();
+					if (current_value.isEmpty ()) current_value = fetchStringValue (prop);	// TODO: Hm, what did I have in mind, here?
 					probs.append (QString ("Tried to apply 'value %1' to property %2, but got '%3', instead").arg (it.value (), it.key (), current_value));
 				}
 			} else {
@@ -141,20 +144,37 @@
 	return probs;
 }
 
+QString RKComponentBase::fetchStringValue (RKComponentBase* prop, const QString &modifier) {
+	// not tracing this simple helper
+// TODO: we need a bit of special casing, here. Probably, instead, we should add new virutal functions serialize() and unserialize(QString()), which properties can re-implement, if needed.
+
+	if (prop->type () == PropertyDouble) {
+		if (modifier.isEmpty ()) return (prop->value ("formatted").toString ());
+	} else if (prop->type () == PropertyStringList) {
+		if (modifier.isEmpty ()) return (prop->value ("joined").toString ());
+	} else if (prop->type () == PropertyRObjects) {
+		return (prop->value (modifier).toStringList ().join ("\n"));
+	}
+	QVariant value = prop->value (modifier);
+	if (value.type () == QVariant::StringList) {
+		return value.toStringList ().join ("\n");
+	}
+	return (value.toString ());
+}
+
 QString RKComponentBase::fetchStringValue (const QString &identifier) {
 	RK_TRACE (PLUGIN);
 
 	QString mod;
 	RKComponentBase *prop = lookupComponent (identifier, &mod);
-
-	return prop->value (mod);
+	return fetchStringValue (prop, mod);
 }
 
-QString RKComponentBase::value (const QString &modifier) {
+QVariant RKComponentBase::value (const QString &modifier) {
 	RK_TRACE (PLUGIN);
 
 	RK_DO (qDebug ("Component type %d does not have a value. Remaining modifier is: '%s'", type (), modifier.toLatin1 ().data ()), PLUGIN, DL_WARNING);
-	return QString ();
+	return QVariant ();
 }
 
 RKComponentBase::ComponentStatus RKComponentBase::recursiveStatus () {

Modified: trunk/rkward/rkward/plugin/rkcomponent.h
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponent.h	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkcomponent.h	2012-11-27 13:12:24 UTC (rev 4455)
@@ -87,8 +87,9 @@
 	virtual RKComponentBase* lookupComponent (const QString &identifier, QString *remainder);
 /** Locate the component.subcomponent.property.value described by identifier and return its value as a string. Especially useful as a callback in code templates! Recursively walks subcomponents/properties until the requested value is found. @See RKComponentBase::lookupComponent */
 	QString fetchStringValue (const QString &identifier);
-/** returns the "value" of this component or property as a string. Properties generally return their value, components typically return the value of their "most important" property. Default implementation returns QString::null, and writes a debug message */
-	virtual QString value (const QString &modifier=QString::null);
+	static QString fetchStringValue (RKComponentBase* prop, const QString &modifier=QString ());
+/** returns the "value" of this component or property. Properties generally return their value, components typically return the value of their "most important" property. Default implementation returns QString::null, and writes a debug message */
+	virtual QVariant value (const QString &modifier=QString ());
 /** returns true, if this is a property */
 	bool isProperty () { return (type () <= PropertyEnd); };
 	bool isComponent () { return (type () >= ComponentBase); };
@@ -212,3 +213,4 @@
 };
 
 #endif
+

Modified: trunk/rkward/rkward/plugin/rkcomponentproperties.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentproperties.cpp	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkcomponentproperties.cpp	2012-11-27 13:12:24 UTC (rev 4455)
@@ -2,7 +2,7 @@
                           rkcomponentproperties  -  description
                              -------------------
     begin                : Fri Nov 25 2005
-    copyright            : (C) 2005, 2006, 2007, 2008, 2009, 2011 by Thomas Friedrichsmeier
+    copyright            : (C) 2005, 2006, 2007, 2008, 2009, 2011, 2012 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -93,6 +93,8 @@
 
 #include "rkcomponentproperties.h"
 
+#include "../misc/rkcommonfunctions.h"
+
 #include <klocale.h>
 
 #include "../debug.h"
@@ -109,7 +111,7 @@
 	RK_TRACE (PLUGIN);
 }
 
-QString RKComponentPropertyBase::value (const QString &modifier) {
+QVariant RKComponentPropertyBase::value (const QString &modifier) {
 	RK_TRACE (PLUGIN);
 	if (!modifier.isEmpty ()) {
 		warnModifierNotRecognized (modifier);
@@ -140,8 +142,8 @@
 
 void RKComponentPropertyBase::governorValueChanged (RKComponentPropertyBase *property) {
 	RK_TRACE (PLUGIN);
-
-	setValue (property->value (governor_modifier));
+#warning TOOD: connected value should be stored as qvariant
+	setValue (property->value (governor_modifier).toString ());
 }
 
 void RKComponentPropertyBase::warnModifierNotRecognized (const QString &modifier) {
@@ -161,20 +163,35 @@
 	RK_TRACE (PLUGIN);
 }
 
-QString RKComponentPropertyStringList::value (const QString &modifier) {
+QVariant RKComponentPropertyStringList::value (const QString &modifier) {
 	RK_TRACE (PLUGIN);
 
-	if (!modifier.isEmpty ()) {
-		warnModifierNotRecognized (modifier);
-		return QString ();
+	if (modifier.isEmpty ()) {
+		return storage;
+	} else if (modifier == "joined") {
+		if (_value.isNull ()) {
+			for (int i = 0; i < storage.size (); ++i) {
+				if (!_value.isEmpty ()) _value.append (sep);
+				_value.append (RKCommonFunctions::escape (storage[i]));	// _value acts as a cache for joined string
+			}
+		}
+		return _value;
 	}
-	if (_value.isNull ()) _value = storage.join (sep);	// _value acts as a cache
-	return _value;
+
+	warnModifierNotRecognized (modifier);
+	return QString ();
 }
 
 bool RKComponentPropertyStringList::setValue (const QString &string) {
-	if (string.isNull ()) setValues (QStringList ());
-	else setValues (string.split (sep));
+	if (string.isNull ()) {
+		setValues (QStringList ());
+	} else {
+		QStringList list = string.split (sep);
+		for (int i = 0; i < list.size (); ++i) {
+			list[i] = RKCommonFunctions::unescape (list[i]);
+		}
+		setValues (list);
+	}
 	return true;
 }
 
@@ -186,6 +203,15 @@
 	doChange ();
 }
 
+void RKComponentPropertyStringList::governorValueChanged (RKComponentPropertyBase *property) {
+	QVariant value = property->value (governor_modifier);
+	if (value.type () == QVariant::StringList) {
+		setValues (value.toStringList ());
+	} else {
+		setValue (value.toString ());
+	}
+}
+
 ///////////////////////////////////////////// Bool //////////////////////////////////////////
 
 RKComponentPropertyBool::RKComponentPropertyBool (QObject *parent, bool required, bool default_state, const QString &value_true, const QString &value_false) : RKComponentPropertyBase (parent, required) {
@@ -261,19 +287,20 @@
 	return current_value;
 }
 
-QString RKComponentPropertyBool::value (const QString &modifier) {
+QVariant RKComponentPropertyBool::value (const QString &modifier) {
 	RK_TRACE (PLUGIN);
 
-	if (modifier.isEmpty ()) return _value;
+	if (modifier.isEmpty () || (modifier == "numeric")) {
+		return (int) (current_value ? 1 : 0);
+	}
+	if (modifier == "labeled") {
+		return current_value ? value_true : value_false;
+	}
 	if (modifier == "true") return value_true;
 	if (modifier == "false") return value_false;
-	if (modifier == "numeric") {
-		if (current_value) return "1";
-		else return "0";
-	}
 
 	warnModifierNotRecognized (modifier);
-	return QString ();
+	return QVariant ();
 }
 
 bool RKComponentPropertyBool::setValue (const QString &string) {
@@ -296,16 +323,13 @@
 void RKComponentPropertyBool::governorValueChanged (RKComponentPropertyBase *property) {
 	RK_TRACE (PLUGIN);
 
-	if (governor_modifier.isEmpty ()) {
-		if (property->type () == PropertyBool) {
-			internalSetValue (static_cast<RKComponentPropertyBool *>(property)->boolValue ());
-		} else if (property->type () == PropertyInt) {
-			internalSetValue (static_cast<RKComponentPropertyInt *>(property)->intValue () != 0);
-		} else {
-			internalSetValue (property->value (QString::null));
-		}
-	} else {
-		internalSetValue (property->value (governor_modifier));
+	QVariant value = property->value (governor_modifier);
+	if (value.type () == QVariant::String) {	// Qt's conversion from string to bool does not meet our needs.
+		internalSetValue (value.toString ());
+	} else if (value.canConvert (QVariant::Bool)) {
+		internalSetValue (value.toBool ());
+	} else {	// fallback for lists, and other stuff that really should not have been connected to a bool property, in the first place
+		internalSetValue (value.toString ());
 	}
 	emit (valueChanged (this));
 }
@@ -384,14 +408,14 @@
 	return current_value;
 }
 
-QString RKComponentPropertyInt::value (const QString &modifier) {
+QVariant RKComponentPropertyInt::value (const QString &modifier) {
 	RK_TRACE (PLUGIN);
 
 	if (!modifier.isEmpty ()) {
 		warnModifierNotRecognized (modifier);
 		return QString ();
 	}
-	return _value;
+	return current_value;
 }
 
 bool RKComponentPropertyInt::isStringValid (const QString &string) {
@@ -437,17 +461,11 @@
 void RKComponentPropertyInt::governorValueChanged (RKComponentPropertyBase *property) {
 	RK_TRACE (PLUGIN);
 
-	if (governor_modifier.isEmpty ()) {
-		if (property->type () == PropertyInt) {
-			internalSetValue (static_cast<RKComponentPropertyInt *>(property)->intValue ());
-		} else if (property->type () == PropertyDouble) {
-			internalSetValue ((int) (static_cast<RKComponentPropertyDouble *>(property)->doubleValue ()));
-		} else {
-			internalSetValue (property->value (QString::null));
-		}
-	} else {
-		internalSetValue (property->value (governor_modifier));
-	}
+	QVariant value = property->value (governor_modifier);
+	double val = value.toDouble (&is_valid);	// QVariant's toInt() does not document rounding behavior. So we rather use a defined behavior, here.
+	if (isValid ()) internalSetValue ((int) val);
+	else internalSetValue (value.toString ());
+
 	emit (valueChanged (this));
 }
 
@@ -549,14 +567,14 @@
 	return current_value;
 }
 
-QString RKComponentPropertyDouble::value (const QString &modifier) {
+QVariant RKComponentPropertyDouble::value (const QString &modifier) {
 	RK_TRACE (PLUGIN);
 
-	if (!modifier.isEmpty ()) {
-		warnModifierNotRecognized (modifier);
-		return QString ();
-	}
-	return _value;
+	if (modifier.isEmpty ()) return current_value;
+	else if (modifier == "formatted") return _value;
+
+	warnModifierNotRecognized (modifier);
+	return QString ();
 }
 
 bool RKComponentPropertyDouble::isStringValid (const QString &string) {
@@ -602,17 +620,11 @@
 void RKComponentPropertyDouble::governorValueChanged (RKComponentPropertyBase *property) {
 	RK_TRACE (PLUGIN);
 
-	if (governor_modifier.isEmpty ()) {
-		if (property->type () == PropertyInt) {
-			internalSetValue ((double) (static_cast<RKComponentPropertyInt *>(property)->intValue ()));
-		} else if (property->type () == PropertyDouble) {
-			internalSetValue (static_cast<RKComponentPropertyDouble *>(property)->doubleValue ());
-		} else {
-			internalSetValue (property->value (QString::null));
-		}
-	} else {
-		internalSetValue (property->value (governor_modifier));
-	}
+	QVariant value = property->value (governor_modifier);
+	double val = value.toDouble (&is_valid);
+	if (is_valid) internalSetValue (val);
+	else internalSetValue (value.toString ());
+
 	emit (valueChanged (this));
 }
 
@@ -839,7 +851,7 @@
 	return (object_list);
 }
 
-QString RKComponentPropertyRObjects::value (const QString &modifier) {
+QVariant RKComponentPropertyRObjects::value (const QString &modifier) {
 	RK_TRACE (PLUGIN);
 
 	QStringList ret;
@@ -858,19 +870,17 @@
 	} else {
 		warnModifierNotRecognized (modifier);
 	}
-	return ret.join (separator);
+	return ret;
 }
 
-bool RKComponentPropertyRObjects::setValue (const QString &value) {
+bool RKComponentPropertyRObjects::setValue (const QStringList& values) {
 	RK_TRACE (PLUGIN);
 
 	setObjectValue (0);
 
 	bool ok = true;
-	QStringList slist = value.split (separator, QString::SkipEmptyParts);
-
-	for (QStringList::const_iterator it = slist.begin (); it != slist.end (); ++it) {
-		RObject *obj = RObjectList::getObjectList ()->findObject (*it);
+	for (int i = 0; i < values.size (); ++i) {
+		RObject *obj = RObjectList::getObjectList ()->findObject (values[i]);
 		ok = ok && appendObject (obj);
 	}
 
@@ -879,6 +889,12 @@
 	return (isValid () && ok);
 }
 
+bool RKComponentPropertyRObjects::setValue (const QString &value) {
+	RK_TRACE (PLUGIN);
+
+	return setValue (value.split (separator, QString::SkipEmptyParts));
+}
+
 bool RKComponentPropertyRObjects::isStringValid (const QString &value) {
 	RK_TRACE (PLUGIN);
 
@@ -989,7 +1005,12 @@
 	if ((property->type () == PropertyRObjects) && governor_modifier.isEmpty ()) {
 		setObjectList (static_cast <RKComponentPropertyRObjects *> (property)->objectList ());
 	} else {
-		setValue (property->value (governor_modifier));
+		QVariant value = property->value ();
+		if (value.type () == QVariant::StringList) {
+			setValue (value.toStringList ());
+		} else {
+			setValue (value.toString ());
+		}
 	}
 }
 
@@ -1066,7 +1087,7 @@
 	RK_TRACE (PLUGIN);
 }
 
-QString RKComponentPropertyCode::value (const QString &modifier) {
+QVariant RKComponentPropertyCode::value (const QString &modifier) {
 	RK_TRACE (PLUGIN);
 
 	if (modifier == "preprocess") return preprocess ();
@@ -1148,24 +1169,21 @@
 		Source source = sources[i];		// easier typing
 		switch (_mode) {
 			case Equals: {
-				if (source.property->value (source.modifier) != standard) {
+				if (fetchStringValue (source.property, source.modifier) != standard) {
 					setBoolValue (false);
 					return;
 				}
 				break;
 			} case NotEquals: {
-				if (source.property->value (source.modifier) == standard) {
+				if (fetchStringValue (source.property, source.modifier) == standard) {
 					setBoolValue (false);
 					return;
 				}
 				break;
 			} case Range: {
-				double val;
-				if (source.property->type () == PropertyInt) {
-					val = (double) static_cast<RKComponentPropertyInt *>(source.property)->intValue ();
-				} else if (source.property->type () == PropertyDouble) {
-					val = (double) static_cast<RKComponentPropertyDouble *>(source.property)->doubleValue ();
-				} else {
+				bool ok;
+				double val = source.property->value (source.modifier).toDouble (&ok);
+				if (!ok) {
 					val = min;
 					RK_DO (qDebug ("Non-numeric property in convert sources, cannot check range"), PLUGIN, DL_WARNING);
 				}

Modified: trunk/rkward/rkward/plugin/rkcomponentproperties.h
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentproperties.h	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkcomponentproperties.h	2012-11-27 13:12:24 UTC (rev 4455)
@@ -2,7 +2,7 @@
                           rkcomponentproperties  -  description
                              -------------------
     begin                : Fri Nov 25 2005
-    copyright            : (C) 2005, 2006, 2007, 2009, 2011 by Thomas Friedrichsmeier
+    copyright            : (C) 2005, 2006, 2007, 2009, 2011, 2012 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -28,6 +28,8 @@
 #include "rkcomponent.h"
 
 /** Base class for all RKComponentProperties. The base class can handle only a string-property. See derived classes for special types of properties.
+ * 
+ * TODO: Internal storage of value (_value) should be a QVariant
 
 see \ref RKComponentProperties
 */
@@ -39,7 +41,7 @@
 /** destructor */
 	virtual ~RKComponentPropertyBase ();
 /** supplies the current value. Since more than one value may be supplied, modifier can be used to select a value. Default implementation only has  a single string, however. Reimplemented from RKComponentBase */
-	QString value (const QString &modifier=QString::null);
+	QVariant value (const QString &modifier=QString ());
 /** set the value in string form.
 @returns false if the value is illegal (in the base class, all strings are legal) */
 	virtual bool setValue (const QString &string);
@@ -78,10 +80,8 @@
 	~RKComponentPropertyStringList ();
 /** for RTTI. see RKComponentBase::RKComponentTypes */
 	int type () { return PropertyStringList; };
-/** change separator string when concatenating strings for value (). Default separator string is "\n" */
-	void setSeparator (const QString &separator) { sep = separator; doChange (); };
-/** reimplemented to return all current strings joined by current separator (setSeparator) */
-	QString value (const QString &modifier=QString::null);
+/** reimplemented to return all current strings */
+	QVariant value (const QString &modifier=QString ());
 /** return the string at the given index */
 	const QString valueAt (int index) const { return storage.value (index); };
 /** set the values in string form (values will be split by the current separator)
@@ -93,9 +93,11 @@
 	const QStringList& values () const { return storage; };
 /** set current strings as a QStringList */
 	void setValues (const QStringList &new_values) { storage = new_values; doChange (); };
+/** reimplemented from RKComponentPropertyBase to use special handling for list properties */
+	void governorValueChanged (RKComponentPropertyBase *property);
 private:
 	void doChange () { _value.clear (); emit (valueChanged (this)); };
-	QString sep;
+	QString sep;	// always "\n". TODO: remove
 	QStringList storage;
 };
 
@@ -116,8 +118,8 @@
 	void setBoolValue (bool new_value);
 /** current value as bool */
 	bool boolValue ();
-/** reimplemented from RKComponentPropertyBase. Modifier "true" returns value if true. Modifier "false" returns value if false. Modifier QString::null returns current value. */
-	QString value (const QString &modifier=QString::null);
+/** reimplemented from RKComponentPropertyBase. Modifier "true" returns value if true. Modifier "false" returns value if false. Modifier QString () returns current value as bool, modifier "labelled" returns the labelled value. */
+	QVariant value (const QString &modifier=QString ());
 /** reimplemented from RKComponentPropertyBase to convert to bool value according to current settings */
 	bool setValue (const QString &string);
 /** reimplemented from RKComponentPropertyBase to test whether conversion to bool value is possible according to current settings */
@@ -162,8 +164,8 @@
 	int maxValue ();
 /** current value as int */
 	int intValue ();
-/** reimplemented from RKComponentPropertyBase. Return current value as a string. In the future, modifier might be used for format. */
-	QString value (const QString &modifier=QString::null);
+/** reimplemented from RKComponentPropertyBase. Return current value. */
+	QVariant value (const QString &modifier=QString ());
 /** reimplemented from RKComponentPropertyBase to convert to int value according to current settings */
 	bool setValue (const QString &string);
 /** reimplemented from RKComponentPropertyBase to test whether conversion to int value is possible according to current settings (is a number, and within limits min and max) */
@@ -213,8 +215,8 @@
 	double maxValue ();
 /** current value as double */
 	double doubleValue ();
-/** reimplemented from RKComponentPropertyBase. Return current value as a string. In the future, modifier might be used for format. */
-	QString value (const QString &modifier=QString::null);
+/** reimplemented from RKComponentPropertyBase. Return current value as a string. */
+	QVariant value (const QString &modifier=QString ());
 /** reimplemented from RKComponentPropertyBase to test whether conversion to int value is possible according to current settings (is a number, and within limits min and max) */
 	bool isStringValid (const QString &string);
 /** reimplemented from RKComponentPropertyBase to actually reconcile requirements with other numeric slots */
@@ -283,13 +285,14 @@
 /** Get current list of objects. Do not modify this list! It is the very same list, the property uses internally!
 @returns an empty list if no valid object is selected */
 	RObject::ObjectList objectList ();
-/** set separator (used to concatenate object names/labels, etc. if more than one object is selected) */
-	void setSeparator (const QString &sep) { separator = sep; emit (valueChanged (this)); };
-/** reimplemented from RKComponentPropertyBase. Modifier "label" returns label. Modifier "shortname" returns short name. Modifier QString::null returns full name. If no object is set, returns an empty string */
-	QString value (const QString &modifier=QString::null);
+/** reimplemented from RKComponentPropertyBase. Modifier "label" returns label(s). Modifier "shortname" returns short name(s). Modifier QString::null returns full name. If no object is set, returns an empty string / variant */
+	QVariant value (const QString &modifier=QString ());
 /** reimplemented from RKComponentPropertyBase to convert to RObject with current constraints
 @returns false if no such object(s) could be found or the object(s) are invalid */
 	bool setValue (const QString &value);
+/** overload of setValue() which accepts a list of names of RObjects
+ at returns false if no such object(s) could be found or the object(s) are invalid */
+	bool setValue (const QStringList &values);
 /** reimplemented from RKComponentPropertyBase to test whether conversion to RObject is possible with current constraints */
 	bool isStringValid (const QString &value);
 /** RTTI */
@@ -327,7 +330,7 @@
 	QStringList classes;
 /** TODO: use a list of enums instead for internal purposes! */
 	QStringList types;
-	QString separator;
+	QString separator;	// always "\n". TODO: remove
 };
 
 ///////////////////////////////////////////////// Code ////////////////////////////////////////////////////////
@@ -349,7 +352,7 @@
 /** the preview code */
 	QString preview () { return preview_code; };
 
-	QString value (const QString &modifier=QString::null);
+	QVariant value (const QString &modifier=QString ());
 
 /** set the preprocess code.
 @param code The code to set. If this is QString::null, the property is seen to lack preprocess code and hence is not valid (see isValid ()). In contrast, empty strings are seen as valid */

Modified: trunk/rkward/rkward/plugin/rkformula.h
===================================================================
--- trunk/rkward/rkward/plugin/rkformula.h	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkformula.h	2012-11-27 13:12:24 UTC (rev 4455)
@@ -40,7 +40,7 @@
 	RKFormula (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget);
 	~RKFormula ();
 
-	QString value (const QString &modifier) { return model->value (modifier); };
+	QVariant value (const QString &modifier=QString ()) { return model->value (modifier); };
 	bool isValid ();
 
 /** RTTI */

Modified: trunk/rkward/rkward/plugin/rkinput.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkinput.cpp	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkinput.cpp	2012-11-27 13:12:24 UTC (rev 4455)
@@ -119,8 +119,8 @@
 	updating = true;
 
 	RK_ASSERT (textedit || lineedit);
-	if (textedit) textedit->setText (text->value ());
-	else lineedit->setText (text->value ());
+	if (textedit) textedit->setText (fetchStringValue (text));
+	else lineedit->setText (fetchStringValue (text));
 
 	updateColor ();
 
@@ -150,7 +150,7 @@
 bool RKInput::isValid () {
 	RK_TRACE (PLUGIN);
 
-	return (!(text->value ().isEmpty ()));
+	return (!(fetchStringValue (text).isEmpty ()));
 }
 
 #include "rkinput.moc"

Modified: trunk/rkward/rkward/plugin/rkinput.h
===================================================================
--- trunk/rkward/rkward/plugin/rkinput.h	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkinput.h	2012-11-27 13:12:24 UTC (rev 4455)
@@ -37,7 +37,7 @@
 	~RKInput ();
 
 	RKComponentPropertyBase *text;
-	QString value (const QString &modifier) { return (text->value (modifier)); };
+	QVariant value (const QString &modifier=QString ()) { return (text->value (modifier)); };
 	int type () { return ComponentInput; };
 	bool isValid ();
 public slots:

Modified: trunk/rkward/rkward/plugin/rkmatrixinput.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkmatrixinput.cpp	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkmatrixinput.cpp	2012-11-27 13:12:24 UTC (rev 4455)
@@ -114,7 +114,7 @@
 	RK_TRACE (PLUGIN);
 }
 
-QString RKMatrixInput::value (const QString& modifier) {
+QVariant RKMatrixInput::value (const QString& modifier) {
 	if (modifier.isEmpty () || (modifier == "cbind")) {
 		QStringList ret;
 		for (int i = 0; i < column_count->intValue (); ++i) {
@@ -125,7 +125,15 @@
 
 	bool ok;
 	int col = modifier.toInt (&ok);
-	if ((col >= 0) && ok) return makeColumnString (col, "\t", false);
+	if ((col >= 0) && ok) {
+		QStringList l;
+		if (col < columns.size ()) l = columns[col].storage;
+		while (l.size () < row_count->intValue ()) {
+			l.append (QString ());
+		}
+		if (l.size () > row_count->intValue ()) l = l.mid (0, row_count->intValue ());
+		return l;
+	}
 	return ("Modifier '" + modifier + "' not recognized\n"); 
 }
 
@@ -308,7 +316,7 @@
 	RK_TRACE (PLUGIN);
 
 	columns.clear ();
-	QStringList coldata = tsv_data->value ().split ('\n', QString::KeepEmptyParts);
+	QStringList coldata = fetchStringValue (tsv_data).split ('\n', QString::KeepEmptyParts);
 	for (int i = 0; i < coldata.size (); ++i) {
 		setColumnValue (i, coldata[i]);
 	}

Modified: trunk/rkward/rkward/plugin/rkmatrixinput.h
===================================================================
--- trunk/rkward/rkward/plugin/rkmatrixinput.h	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkmatrixinput.h	2012-11-27 13:12:24 UTC (rev 4455)
@@ -38,7 +38,7 @@
 	~RKMatrixInput ();
 	int type () { return ComponentMatrixInput; };
 	bool isValid () { return is_valid; };
-	QString value (const QString &modifier);
+	QVariant value (const QString &modifier=QString ());
 public slots:
 	void cut ();
 	void copy ();

Modified: trunk/rkward/rkward/plugin/rkoptionset.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkoptionset.cpp	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkoptionset.cpp	2012-11-27 13:12:24 UTC (rev 4455)
@@ -326,7 +326,7 @@
 
 	QList<RowInfo> new_rows;
 	int row = 0;
-	QStringList items = property->value ().split ("\n");
+	QStringList items = fetchStringValue (property).split ("\n");
 	bool keys_missing = (keycolumn != 0);
 	for (int i = 0; i < items.size (); ++i) {
 		const QString &item = items[i];
@@ -552,7 +552,7 @@
 	for (int i = 0; i < cols.size (); ++i) {
 		RKComponentPropertyStringList *target = cols.at (i);
 		ColumnInfo &inf = column_map[target];
-		QString value = property->value (inf.governor_modifier);
+		QString value = fetchStringValue (property, inf.governor_modifier);
 		target->setValueAt (row, value);
 
 		if (model && (inf.display_index >= 0)) {

Modified: trunk/rkward/rkward/plugin/rkpluginbrowser.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginbrowser.cpp	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkpluginbrowser.cpp	2012-11-27 13:12:24 UTC (rev 4455)
@@ -75,7 +75,7 @@
 	if (updating) return;
 	updating = true;
 
-	selector->setLocation (selection->value ());
+	selector->setLocation (fetchStringValue (selection));
 	updateColor ();
 
 	updating = false;
@@ -89,7 +89,7 @@
 }
 
 bool RKPluginBrowser::isValid () {
-	return (!(selection->value ().isEmpty ()));
+	return (!(fetchStringValue (selection).isEmpty ()));
 }
 
 void RKPluginBrowser::requirednessChanged (RKComponentPropertyBase *) {

Modified: trunk/rkward/rkward/plugin/rkpluginbrowser.h
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginbrowser.h	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkpluginbrowser.h	2012-11-27 13:12:24 UTC (rev 4455)
@@ -40,7 +40,7 @@
 	~RKPluginBrowser ();
 
 	RKComponentPropertyBase *selection;
-	QString value (const QString &modifier) { return (selection->value (modifier)); };
+	QVariant value (const QString &modifier=QString ()) { return (selection->value (modifier)); };
 	int type () { return ComponentBrowser; };
 	bool isValid ();
 public slots:

Modified: trunk/rkward/rkward/plugin/rkpluginframe.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginframe.cpp	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkpluginframe.cpp	2012-11-27 13:12:24 UTC (rev 4455)
@@ -70,7 +70,7 @@
 	return RKComponentBase::lookupComponent(identifier, remainder);
 }
 
-QString RKPluginFrame::value (const QString &modifier) {
+QVariant RKPluginFrame::value (const QString &modifier) {
 	if (!frame->isCheckable ()) return RKComponent::value (modifier);
 	if (!checked) initCheckedProperty();
 	return checked->value (modifier);

Modified: trunk/rkward/rkward/plugin/rkpluginframe.h
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginframe.h	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkpluginframe.h	2012-11-27 13:12:24 UTC (rev 4455)
@@ -38,7 +38,7 @@
 	KVBox *getPage () { return page; };
 	int type () { return ComponentFrame; };
 /** reimplemented to return the value of the checked property by default */
-	QString value (const QString &modifier);
+	QVariant value (const QString &modifier=QString ());
 
 /** re-implemented to create "checked" property on demand. */
 	RKComponentBase* lookupComponent (const QString &identifier, QString *remainder);

Modified: trunk/rkward/rkward/plugin/rkpluginsaveobject.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginsaveobject.cpp	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkpluginsaveobject.cpp	2012-11-27 13:12:24 UTC (rev 4455)
@@ -93,7 +93,7 @@
 	if (updating) return;
 
 	// NOTE: the selection-property is read-only!
-	selector->setBaseName (objectname->value ());
+	selector->setBaseName (fetchStringValue (objectname));
 	selector->setRootObject (parent->objectValue ());
 	if (groupbox->isCheckable ()) {
 		groupbox->setChecked (active->boolValue ());
@@ -125,7 +125,7 @@
 	return (RKComponent::isValid () && selector->isOk ());
 }
 
-QString RKPluginSaveObject::value (const QString& modifier) {
+QVariant RKPluginSaveObject::value (const QString& modifier) {
 //	RK_TRACE (PLUGIN);
 
 	return (selection->value (modifier));

Modified: trunk/rkward/rkward/plugin/rkpluginsaveobject.h
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginsaveobject.h	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkpluginsaveobject.h	2012-11-27 13:12:24 UTC (rev 4455)
@@ -37,7 +37,7 @@
 	RKPluginSaveObject (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget);
 	~RKPluginSaveObject ();
 
-	QString value (const QString &modifier);
+	QVariant value (const QString &modifier=QString ());
 	int type () { return ComponentSaveObject; };
 	bool isValid ();
 public slots:

Modified: trunk/rkward/rkward/plugin/rkpluginspinbox.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginspinbox.cpp	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkpluginspinbox.cpp	2012-11-27 13:12:24 UTC (rev 4455)
@@ -127,12 +127,13 @@
 	changed ();
 }
 
-QString RKPluginSpinBox::value (const QString &modifier) {
+QVariant RKPluginSpinBox::value (const QString &modifier) {
 	RK_TRACE (PLUGIN);
 
 	if (intmode) {
 		return intvalue->value (modifier);
 	} else {
+		if (modifier.isEmpty ()) return realvalue->value ("formatted");
 		return realvalue->value (modifier);
 	}
 }

Modified: trunk/rkward/rkward/plugin/rkpluginspinbox.h
===================================================================
--- trunk/rkward/rkward/plugin/rkpluginspinbox.h	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkpluginspinbox.h	2012-11-27 13:12:24 UTC (rev 4455)
@@ -34,7 +34,7 @@
 	RKPluginSpinBox (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget);
 
 	~RKPluginSpinBox ();
-	QString value (const QString &modifier);
+	QVariant value (const QString &modifier=QString ());
 	int type () { return ComponentSpinBox; };
 
 	RKComponentPropertyInt *intvalue;

Modified: trunk/rkward/rkward/plugin/rkpreviewbox.h
===================================================================
--- trunk/rkward/rkward/plugin/rkpreviewbox.h	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkpreviewbox.h	2012-11-27 13:12:24 UTC (rev 4455)
@@ -41,7 +41,7 @@
 	~RKPreviewBox ();
 	int type () { return ComponentPreviewBox; };
 	RKComponentPropertyBool *state;
-	QString value (const QString &modifier) { return (state->value (modifier)); };
+	QVariant value (const QString &modifier=QString ()) { return (state->value (modifier)); };
 public slots:
 	void changedState (int);
 	void changedState (RKComponentPropertyBase *);

Modified: trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2012-11-27 13:12:24 UTC (rev 4455)
@@ -724,14 +724,14 @@
 		convert->setInternal (true);
 		QString id = xml->getStringAttribute (*it, "id", "#noid#", DL_WARNING);
 		int mode = xml->getMultiChoiceAttribute (*it, "mode", convert->convertModeOptionString (), 0, DL_WARNING);
-		QString sources = xml->getStringAttribute (*it, "sources", QString::null, DL_WARNING);
 		convert->setMode ((RKComponentPropertyConvert::ConvertMode) mode);
-		convert->setSources (sources);
 		if ((mode == RKComponentPropertyConvert::Equals) || (mode == RKComponentPropertyConvert::NotEquals)) {
 			convert->setStandard (xml->getStringAttribute (*it, "standard", QString::null, DL_WARNING));
 		} else if (mode == RKComponentPropertyConvert::Range) {
 			convert->setRange (xml->getDoubleAttribute (*it, "min", -FLT_MAX, DL_INFO), xml->getDoubleAttribute (*it, "max", FLT_MAX, DL_INFO));
 		}
+		QString sources = xml->getStringAttribute (*it, "sources", QString::null, DL_WARNING);
+		convert->setSources (sources);
 		convert->setRequireTrue (xml->getBoolAttribute (*it, "require_true", false, DL_INFO));
 		component ()->addChild (id, convert);
 	}

Modified: trunk/rkward/rkward/plugin/rktext.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rktext.cpp	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rktext.cpp	2012-11-27 13:12:24 UTC (rev 4455)
@@ -79,7 +79,7 @@
 void RKText::textChanged (RKComponentPropertyBase *) {
 	RK_TRACE (PLUGIN);
 
-	label->setText (text->value ());
+	label->setText (fetchStringValue (text));
 	changed ();
 }
 

Modified: trunk/rkward/rkward/plugin/rktext.h
===================================================================
--- trunk/rkward/rkward/plugin/rktext.h	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rktext.h	2012-11-27 13:12:24 UTC (rev 4455)
@@ -36,7 +36,7 @@
 	~RKText ();
 
 	RKComponentPropertyBase *text;
-	QString value (const QString &modifier) { return (text->value (modifier)); };
+	QVariant value (const QString &modifier=QString ()) { return (text->value (modifier)); };
 	int type () { return ComponentText; };
 public slots:
 	void textChanged (RKComponentPropertyBase *);

Modified: trunk/rkward/rkward/plugin/rkvarselector.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkvarselector.cpp	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkvarselector.cpp	2012-11-27 13:12:24 UTC (rev 4455)
@@ -69,7 +69,7 @@
 	RK_TRACE (PLUGIN);
 
 	selected->setObjectList (list_view->selectedObjects ());
-	RK_DO (qDebug ("selected in varselector: %s", selected->value ().toLatin1 ().data ()), PLUGIN, DL_DEBUG);
+	RK_DO (qDebug ("selected in varselector: %s", qPrintable (fetchStringValue (selected))), PLUGIN, DL_DEBUG);
 }
 
 #include "rkvarselector.moc"

Modified: trunk/rkward/rkward/plugin/rkvarslot.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkvarslot.cpp	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkvarslot.cpp	2012-11-27 13:12:24 UTC (rev 4455)
@@ -128,7 +128,7 @@
 	list->clear ();
 	item_map.clear ();
 
-	RK_DO (qDebug ("contained in varslot: %s", available->value ().toLatin1 ().data ()), PLUGIN, DL_DEBUG);
+	RK_DO (qDebug ("contained in varslot: %s", qPrintable (fetchStringValue (available))), PLUGIN, DL_DEBUG);
 
 	RObject::ObjectList objlist = available->objectList ();
 	for (int i = 0; i < objlist.count (); ++i) {
@@ -171,7 +171,7 @@
 void RKVarSlot::selectPressed () {
 	RK_TRACE (PLUGIN);
 
-	RK_DO (qDebug ("select press in varslot: mode %d, source %s, selected %s", add_mode, source->value ().toLatin1 ().data (), selected->value ().toLatin1 ().data ()), PLUGIN, DL_DEBUG);
+	RK_DO (qDebug ("select press in varslot: mode %d, source %s, selected %s", add_mode, qPrintable (fetchStringValue (source)), qPrintable (fetchStringValue (selected))), PLUGIN, DL_DEBUG);
 
 	// first update the properties
 	if (add_mode) {

Modified: trunk/rkward/rkward/plugin/rkvarslot.h
===================================================================
--- trunk/rkward/rkward/plugin/rkvarslot.h	2012-11-27 13:06:47 UTC (rev 4454)
+++ trunk/rkward/rkward/plugin/rkvarslot.h	2012-11-27 13:12:24 UTC (rev 4455)
@@ -41,7 +41,7 @@
 	RKVarSlot (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget);
 	~RKVarSlot ();
 	int type () {return ComponentVarSlot; };
-	QString value (const QString &modifier) { return (available->value (modifier)); };
+	QVariant value (const QString &modifier=QString ()) { return (available->value (modifier)); };
 /** reimplemented to call updateLook (), in case enabledness changed */
 	void changed () { updateLook (); RKComponent::changed (); };
 	void updateLook ();

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