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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Dec 6 09:20:31 UTC 2012


Revision: 4481
          http://rkward.svn.sourceforge.net/rkward/?rev=4481&view=rev
Author:   tfry
Date:     2012-12-06 09:20:31 +0000 (Thu, 06 Dec 2012)
Log Message:
-----------
Allow definition of separate <logic> section inside <optionset>s. This obsoletes the <property> child element.
Also, add missing reference entry for the <script> element.

Modified Paths:
--------------
    trunk/rkward/doc/rkwardplugins/index.docbook
    trunk/rkward/rkward/plugin/rkoptionset.cpp
    trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
    trunk/rkward/rkward/plugin/rkstandardcomponent.h
    trunk/rkward/rkward/plugins/data/sort.xml
    trunk/rkward/rkward/plugins/testing/optionset.xml

Modified: trunk/rkward/doc/rkwardplugins/index.docbook
===================================================================
--- trunk/rkward/doc/rkwardplugins/index.docbook	2012-12-05 17:02:54 UTC (rev 4480)
+++ trunk/rkward/doc/rkwardplugins/index.docbook	2012-12-06 09:20:31 UTC (rev 4481)
@@ -1551,10 +1551,8 @@
 </dialog>
 		</programlisting>
 	<para>
-		Of course you can also use <link linkend="logic">UI logic</link> inside an optionset. You do so by making connection (or scripting)
-		in the <command><logic></command> section of your plugin, as usual. However, you will access the UI elements in the contents
-		region as (e.g.) "set.contents.firstname.XYZ". Note the prefix "set" (the <parameter>id</parameter> you have assigned to the set
-		and "contents".
+		Of course you can also use <link linkend="logic">UI logic</link> inside an optionset. There are two options for doing this: You can do so	by making connection (or scripting) in the main <command><logic></command> section of your plugin, as usual. However, you will access the UI elements in the contents region as (e.g.) "set.contents.firstname.XYZ". Note the prefix "set" (the <parameter>id</parameter> you have assigned to the set and "contents". Alternatively, you can add a separate <command><logic></command> section as a child element of your <command><optionset></command>. In this case, <parameter>id</parameter>s will be addressed relative to the contents region, e.g. "firstname.XYZ". Only the <command><script></command>-element is not allowed in the logic section of an optionset. If you want to use scripting,
+		you will have to utilize the plugin's main <command><logic></command> section.
 	</para>
 	<note>
 		<para>
@@ -2708,7 +2706,7 @@
 	</para></listitem></varlistentry>
 	<varlistentry>
 	<term><content></term>
-	<listitem><para>Declare the content / UI of the set. No attributes. All usual active, passive, and layout elements are allowed as childname elements. In addition, the following special child-elements are allowed:
+	<listitem><para>Declare the content / UI of the set. No attributes. All usual active, passive, and layout elements are allowed as childname elements. In addition, the following special child-element is allowed:
 		<variablelist>
 			<varlistentry><term><optiondisplay></term>
 			<listitem><para>Creates a display for showing / selecting / adding / removing items in an optionset. Allowed only inside the contents are of an optionset, and only once. Attributes:
@@ -2717,16 +2715,12 @@
 				<listitem><para>Whether to show a column with a numberic index (1...n) in the optiondisplay. (optional, boolean, defaults to "true")</para></listitem></varlistentry>
 			</variablelist>
 			</para></listitem></varlistentry>
-			<varlistentry><term><property></term>
-			<listitem><para>In the rare case that you want to connect two or more properties inside the contents region to an (external)
-			<optioncolumn>, you can create an auxiliary property using this element. Attributes:
-			<variablelist>
-				<varlistentry><term><parameter>id</parameter></term>
-				<listitem><para>Id of the property (relative to "setid.contents") (required, string).</para></listitem></varlistentry>
-			</variablelist>
-			</para></listitem></varlistentry>
 		</variablelist>
 	</para></listitem></varlistentry>
+	<varlistentry>
+	<term><logic></term>
+	<listitem><para>Optional specification of UI logic to apply <emphasis>inside</emphasis> the contents region the optionset. See <link linkend="logicelements">the reference on <logic></link>
+	</para></listitem></varlistentry>
 	</variablelist>
 </para></listitem>
 </varlistentry>
@@ -2875,7 +2869,7 @@
 <variablelist>
 <varlistentry>
 <term><logic></term>
-<listitem><para>The containing element for the logic section. All elements below are allowed only inside the <logic> element. Only one <logic> element is allowed per document, as a direct child of the <document> element. The logic section applies to both <dialog> and <wizard> GUIs in the same way.</para></listitem>
+<listitem><para>The containing element for the logic section. All elements below are allowed only inside the <logic> element. The <logic> element is allowed only as a direct child of the <document> element (at most once per document), or of <optionset> elements (at most once per optionset). The document's logic section applies to both <dialog> and <wizard> GUIs in the same way.</para></listitem>
 </varlistentry>
 
 <varlistentry>
@@ -2962,6 +2956,18 @@
 	</varlistentry>
 	</variablelist></para></listitem>
 </varlistentry>
+
+<varlistentry>
+<term><script></term>
+<listitem><para>Define script code to control UI logic. See <link linkend="logic_scripted">the section on scripted GUJI logic</link> for details. The script code to run can be given either using the <parameter>"file"</parameter> attribute, or as a (commented) text of the element. The <command><script></command> element is not allowed in the <command><logic></command> section of an optionset. Attributes:
+	<variablelist>
+	<varlistentry>
+	<term><parameter>file</parameter></term>
+	<listitem><para>File name of the script file. (required)</para></listitem>
+	</varlistentry>
+	</variablelist></para></listitem>
+</varlistentry>
+
 </variablelist>
 </sect2>
 

Modified: trunk/rkward/rkward/plugin/rkoptionset.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkoptionset.cpp	2012-12-05 17:02:54 UTC (rev 4480)
+++ trunk/rkward/rkward/plugin/rkoptionset.cpp	2012-12-06 09:20:31 UTC (rev 4481)
@@ -81,6 +81,7 @@
 	QDomElement content_element = xml->getChildElement (element, "content", DL_ERROR);
 	RKComponentBuilder *builder = new RKComponentBuilder (contents_container, content_element);
 	builder->buildElement (content_element, user_area, false);	// NOTE that parent widget != parent component, here, by intention. The point is that the display should not be disabled along with the contents
+	builder->parseLogic (xml->getChildElement (element, "logic", DL_INFO), false);
 	builder->makeConnections ();
 	addChild ("contents", contents_container);
 	connect (standardComponent (), SIGNAL (standardInitializationComplete()), this, SLOT (fetchDefaults()));
@@ -164,20 +165,6 @@
 		}
 	}
 
-	// helper properties
-	XMLChildList properties = xml->getChildElements (content_element, "property", DL_WARNING);
-	for (int i = 0; i < properties.size (); ++i) {
-		const QDomElement &e = properties.at (i);
-		QString id = xml->getStringAttribute (e, "id", QString (), DL_ERROR);
-		if (contents_container->child_map.contains (id)) {
-			RK_DEBUG (PLUGIN, DL_WARNING, "Id %s already in use. Skipping property declaration", qPrintable (id));
-			continue;
-		}
-		RKComponentPropertyBase *prop = new RKComponentPropertyBase (contents_container, false);
-		prop->setInternal (true);
-		contents_container->addChild (id, prop);
-	}
-
 	if (display) {		// may or may not have been created
 		model->column_labels = visible_column_labels;
 		display->setItemsExpandable (false);

Modified: trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2012-12-05 17:02:54 UTC (rev 4480)
+++ trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2012-12-06 09:20:31 UTC (rev 4481)
@@ -684,7 +684,7 @@
 	}
 }
 
-void RKComponentBuilder::parseLogic (const QDomElement &element) {
+void RKComponentBuilder::parseLogic (const QDomElement &element, bool allow_script_tag) {
 	RK_TRACE (PLUGIN);
 
 	if (element.isNull ()) return;
@@ -740,10 +740,12 @@
 	}
 
 	QDomElement e = xml->getChildElement (element, "script", DL_INFO);
-	if (!e.isNull ()) {
+	if (!e.isNull () && allow_script_tag) {
 		QString file = xml->getStringAttribute (e, "file", QString (), DL_INFO);
 		QString inline_command = e.text ();
 		parent->standardComponent ()->scriptingProxy ()->initialize (file, inline_command);
+	} else if (!e.isNull ()) {
+		xml->displayError (&e, "<script> element is not allowed inside this <logic> section.", DL_ERROR);
 	}
 }
 

Modified: trunk/rkward/rkward/plugin/rkstandardcomponent.h
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponent.h	2012-12-05 17:02:54 UTC (rev 4480)
+++ trunk/rkward/rkward/plugin/rkstandardcomponent.h	2012-12-06 09:20:31 UTC (rev 4481)
@@ -143,7 +143,7 @@
 	RKComponentBuilder (RKComponent *parent_component, const QDomElement &document_element);
 	~RKComponentBuilder ();
 	void buildElement (const QDomElement &element, QWidget *parent_widget, bool allow_pages);
-	void parseLogic (const QDomElement &element);
+	void parseLogic (const QDomElement &element, bool allow_script_tag=true);
 	void makeConnections ();
 	RKComponent *component () const { return parent; };
 private:

Modified: trunk/rkward/rkward/plugins/data/sort.xml
===================================================================
--- trunk/rkward/rkward/plugins/data/sort.xml	2012-12-05 17:02:54 UTC (rev 4480)
+++ trunk/rkward/rkward/plugins/data/sort.xml	2012-12-06 09:20:31 UTC (rev 4481)
@@ -16,8 +16,6 @@
 
 		<convert id="custom_conversion" mode="equals" sources="conversion.string" standard="custom"/>
 		<connect governor="custom_conversion" client="conversion_custom.enabled"/>
-		<convert id="custom_conversion_multi" mode="equals" sources="multi_sortby.contents.conversion.string" standard="custom"/>
-		<connect governor="custom_conversion_multi" client="multi_sortby.contents.conversion_custom.enabled"/>
 		<script><![CDATA[
 			// the top-level block is called only once
 			gui.addChangeCommand ("object.available", "objectChanged ()");
@@ -76,6 +74,10 @@
 				</row>
 
 				<optionset id="multi_sortby" keycolumn="object">
+					<logic>
+						<convert id="custom_conversion" mode="equals" sources="conversion.string" standard="custom"/>
+						<connect governor="custom_conversion" client="conversion_custom.enabled"/>
+					</logic>
 					<content>
 						<optiondisplay index="true"/>
 						<checkbox id="reverse" label="Reverse sort order" checked="false" value="Reversed" value_unchecked=""/>

Modified: trunk/rkward/rkward/plugins/testing/optionset.xml
===================================================================
--- trunk/rkward/rkward/plugins/testing/optionset.xml	2012-12-05 17:02:54 UTC (rev 4480)
+++ trunk/rkward/rkward/plugins/testing/optionset.xml	2012-12-06 09:20:31 UTC (rev 4481)
@@ -62,7 +62,6 @@
 				<row>
 					<optionset id="set" min_rows="1" keycolumn="var">
 						<content>
-							<!--							<property id="x"/> -->
 							<frame>
 								<optiondisplay index="false"/>
 								<checkbox id="dummybox" label="This dummy option is always disabled"/>

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