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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Nov 27 13:59:53 UTC 2012


Revision: 4459
          http://rkward.svn.sourceforge.net/rkward/?rev=4459&view=rev
Author:   tfry
Date:     2012-11-27 13:59:53 +0000 (Tue, 27 Nov 2012)
Log Message:
-----------
This is the remainder of r4455. Actually, r4455 was meant to be a very small fix, not all the QVariant work. But I wasn't paying attention...

So what was r4455 all about? I changed RKComponentPropertyBase::value () to support different data types, not just string.
This will allow to provide more intelligent getters in the .js-files. In particular, I will add getList() to fetch string/object lists as arrays, rather than
concatenated strings. This is partially for convenience, but also important, when dealing with strings that may contain new line characters (and thus are not
trivially splittable).

While at it, boolean properties now return a bool (actually 0 or 1) value, by default. Calling getValue() on a checkbox, will continue to return the labeled
value, however, for backwards compatibility.

Revision Links:
--------------
    http://rkward.svn.sourceforge.net/rkward/?rev=4455&view=rev
    http://rkward.svn.sourceforge.net/rkward/?rev=4455&view=rev
    http://rkward.svn.sourceforge.net/rkward/?rev=4455&view=rev

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/doc/rkwardplugins/index.docbook
    trunk/rkward/rkward/plugin/rkcomponentproperties.cpp

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2012-11-27 13:47:12 UTC (rev 4458)
+++ trunk/rkward/ChangeLog	2012-11-27 13:59:53 UTC (rev 4459)
@@ -1,3 +1,5 @@
+- Boolean properties now return a numeric, not labelled representation of their value, by default. <checkbox>es should be unaffected.
+- Added GUI element for entering a set of options for an arbitrary number of items		TODO: document
 - Reduce CPU usage of pluings while idle
 - Fix conversion from Numeric to Factor in the data editor
 - In the data.frame editor, columns containing invalid values are now highlighted in red

Modified: trunk/rkward/doc/rkwardplugins/index.docbook
===================================================================
--- trunk/rkward/doc/rkwardplugins/index.docbook	2012-11-27 13:47:12 UTC (rev 4458)
+++ trunk/rkward/doc/rkwardplugins/index.docbook	2012-11-27 13:59:53 UTC (rev 4459)
@@ -1995,9 +1995,13 @@
 	<variablelist>
 	<varlistentry>
 	<term>No modifier ("")</term>
-	<listitem><para>By default the property will return the string "TRUE", if it is true, and "FALSE" otherwise. Boolean properties attached to a checkbox behave slightly differently, and return the strings you specified in the "value" and "value_unchecked" attributes.</para></listitem>
+	<listitem><para>By default the property will return 1 if it is true, and 0 otherwise.</para></listitem>
 	</varlistentry>
 	<varlistentry>
+	<term>"labeled"</term>
+	<listitem><para>Returns the string "true" when true, "false", when false, or whichever custom strings have been specified (typically in a <checkbox>).</para></listitem>
+	</varlistentry>
+	<varlistentry>
 	<term>"true"</term>
 	<listitem><para>Return the string as if the property was true, even if it is false</para></listitem>
 	</varlistentry>
@@ -2011,7 +2015,7 @@
 	</varlistentry>
 	<varlistentry>
 	<term>"numeric"</term>
-	<listitem><para>Return the string "1" if the property is true, or "0" if it is false</para></listitem>
+	<listitem><para>Obsolete, provided for backwards compatibility. Same as no modifier "". Return "1" if the property is true, or "0" if it is false.</para></listitem>
 	</varlistentry>
 	</variablelist></para></listitem>
 </varlistentry>
@@ -2021,11 +2025,21 @@
 </varlistentry>
 <varlistentry>
 <term>Real number properties</term>
-<listitem><para>A property designed to hold a real number value (but of course it still returns a numeric character string to the JS-template). It does not accept any modifiers. Used in <spinbox>es (see below)</para></listitem>
+<listitem><para>A property designed to hold a real number value (but of course it still returns a numeric character string to the JS-template). Used in <spinbox>es (see below)
+	<variablelist>
+	<varlistentry>
+	<term>No modifier ("")</term>
+	<listitem><para>For getValue() / getString(), this returns the same as "formatted". In future versions, it will be possible to obtain a numeric represenation, instead.</para></listitem>
+	</varlistentry>
+	<varlistentry>
+	<term>"formatted"</term>
+	<listitem><para>Returns the formatted number (as a string).</para></listitem>
+	</varlistentry>
+	</variablelist></para></listitem>
 </varlistentry>
 <varlistentry>
 <term>RObject properties</term>
-<listitem><para>A property designed a selection of one or more &r; objects. Used most prominently in varselectors and varslots.  The following values will be returned according to the given modifier:
+<listitem><para>A property designed a selection of one or more &r; objects. Used most prominently in varselectors and varslots. The following values will be returned according to the given modifier:
 	<variablelist>
 	<varlistentry>
 	<term>No modifier ("")</term>
@@ -2042,6 +2056,20 @@
 	</variablelist></para></listitem>
 </varlistentry>
 <varlistentry>
+<term>String list properties</term>
+<listitem><para>This property holds a list of strings.
+	<variablelist>
+	<varlistentry>
+	<term>No modifier ("")</term>
+	<listitem><para>For <function>getValue()</function>, this returns all strings separated by "\n". Any "\n" characters in each item are escaped as literal "\n". However, the recommended usage is to fetch the value with <function>getList()</function>, instead, which will return an array of strings.</para></listitem>
+	</varlistentry>
+	<varlistentry>
+	<term>"joined"</term>
+	<listitem><para>Returns the list as a single string, with items joined by "\n". In contrast to no modifier (""), the individual strings are _not_ esacped.</para></listitem>
+	</varlistentry>
+	</variablelist></para></listitem>
+</varlistentry>
+<varlistentry>
 <term>Code properties</term>
 <listitem><para>A property held by plugins that generated code. This is important for embedding plugins, in order to embed the code generated by the embedded plugin into the code generated by the embedding (top-level) plugin. The following values will be returned according to the given modifier:
 	<variablelist>
@@ -2822,11 +2850,11 @@
 
 <varlistentry>
 <term><checkbox></term>
-<listitem><para>Default property is "state"
+<listitem><para>Default property is "state.labeled"
 	<variablelist>
 	<varlistentry>
 	<term>state</term>
-	<listitem><para>State of the checkbox (on or off). Note that useful modifiers of this property (as of all boolean properties) are "not" and "numeric" (see <link linkend="propertytypes">types of properties</link>). (boolean)</para></listitem>
+	<listitem><para>State of the checkbox (on or off). Note that useful modifiers of this property (as of all boolean properties) are "not" and "labeled" (see <link linkend="propertytypes">types of properties</link>). However, often it is most useful to connect to the property with no modifier, i.e. "<emphasis>checkbox_id</emphasis>.state", which will return the state of the checkbox in a format suitable for use in an if statement (0 or 1). (boolean)</para></listitem>
 	</varlistentry>
 	</variablelist></para></listitem>
 </varlistentry>
@@ -2871,7 +2899,7 @@
 		</varlistentry>
 		<varlistentry>
 			<term>0,1,2...</term>
-			<listitem><para>The data from a single column (0 for leftmost column), separated by tabulator characters (string; read-only).</para></listitem>
+			<listitem><para>The data from a single column (0 for leftmost column). <function>getValue()</function>/<function>getString()</function> returns this as a single string, separated by "\n". However, the recommended way to get this is using <function>getList()</function>, which returns this column as an array of strings.</para></listitem>
 		</varlistentry>
 		<varlistentry>
 			<term>cbind</term>
@@ -2916,7 +2944,7 @@
 
 <varlistentry>
 <term><spinbox></term>
-<listitem><para>Default property is either "int" or "real" depending on the spinbox's mode
+<listitem><para>Default property is either "int" or "real.formatted" depending on the spinbox's mode
 	<variablelist>
 	<varlistentry>
 	<term>int</term>

Modified: trunk/rkward/rkward/plugin/rkcomponentproperties.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentproperties.cpp	2012-11-27 13:47:12 UTC (rev 4458)
+++ trunk/rkward/rkward/plugin/rkcomponentproperties.cpp	2012-11-27 13:59:53 UTC (rev 4459)
@@ -1194,8 +1194,10 @@
 				}
 				break;
 			} case And: {
-				if ((source.property->type () == PropertyBool) || (source.property->type () == PropertyLogic)) {
-					if (!(static_cast<RKComponentPropertyBool *>(source.property)->boolValue ())) {
+				bool ok;
+				int val = source.property->value (source.modifier).toInt (&ok);
+				if (ok) {
+					if (!val) {
 						setBoolValue (false);
 						return;
 					}
@@ -1204,8 +1206,10 @@
 				}
 				break;
 			} case Or: {
-				if ((source.property->type () == PropertyBool) || (source.property->type () == PropertyLogic)) {
-					if (static_cast<RKComponentPropertyBool *>(source.property)->boolValue ()) {
+				bool ok;
+				int val = source.property->value (source.modifier).toInt (&ok);
+				if (ok) {
+					if (val) {
 						setBoolValue (true);
 						return;
 					}

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