[rkward-cvs] SF.net SVN: rkward:[4259] trunk/rkward/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Tue May 22 07:44:11 UTC 2012
Revision: 4259
http://rkward.svn.sourceforge.net/rkward/?rev=4259&view=rev
Author: tfry
Date: 2012-05-22 07:44:11 +0000 (Tue, 22 May 2012)
Log Message:
-----------
Fix enabledness / disabledness of contents area
Modified Paths:
--------------
trunk/rkward/rkward/plugin/rkcomponent.cpp
trunk/rkward/rkward/plugin/rkcomponent.h
trunk/rkward/rkward/plugin/rkoptionset.cpp
trunk/rkward/rkward/plugins/testing/optionset.js
trunk/rkward/rkward/plugins/testing/optionset.xml
Modified: trunk/rkward/rkward/plugin/rkcomponent.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponent.cpp 2012-05-21 17:23:09 UTC (rev 4258)
+++ trunk/rkward/rkward/plugin/rkcomponent.cpp 2012-05-22 07:44:11 UTC (rev 4259)
@@ -2,7 +2,7 @@
rkcomponent - description
-------------------
begin : Tue Dec 13 2005
- copyright : (C) 2005, 2006, 2009, 2010, 2011 by Thomas Friedrichsmeier
+ copyright : (C) 2005, 2006, 2009, 2010, 2011, 2012 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -213,28 +213,26 @@
if (!isHidden ()) hide ();
}
} else if (property == enabledness_property) {
- updateEnablednessRecursive ();
+ updateEnablednessRecursive ((!parentComponent ()) || (parentComponent ()->isEnabled ()));
} else if (property == requiredness_property) {
required = requiredness_property->boolValue ();
changed ();
}
}
-void RKComponent::updateEnablednessRecursive () {
+void RKComponent::updateEnablednessRecursive (bool parent_enabled) {
RK_TRACE (PLUGIN);
- bool enabled;
- if (enabledness_property->boolValue ()) {
- enabled = ((!parentComponent ()) || (parentComponent ()->isEnabled ()));
- } else {
- enabled = false;
- }
+ bool enabled = (enabledness_property->boolValue () && parent_enabled);
+ bool changed = (enabled != isEnabled ());
- setEnabled (enabled); /* We do this, even if the state *seems* to be unchanged. This is needed, as isEnabled () also returns false, if the parent QWidget is not enabled. However, the parent QWidget may not always be the parent component. */
- if (enabled != isEnabled ()) {
+ setEnabled (enabled);
+ /* RKComponent hierarchy does not always correspond to QWidget hierarchy (although in _most_ cases, it does. For this reason,
+ * we need to update enabledness of all child components. */
+ if (changed) {
for (QHash<QString, RKComponentBase*>::const_iterator it = child_map.constBegin (); it != child_map.constEnd (); ++it) {
if (it.value ()->isComponent()) {
- static_cast<RKComponent*> (it.value ())->updateEnablednessRecursive ();
+ static_cast<RKComponent*> (it.value ())->updateEnablednessRecursive (enabled);
}
}
}
Modified: trunk/rkward/rkward/plugin/rkcomponent.h
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponent.h 2012-05-21 17:23:09 UTC (rev 4258)
+++ trunk/rkward/rkward/plugin/rkcomponent.h 2012-05-22 07:44:11 UTC (rev 4259)
@@ -2,7 +2,7 @@
rkcomponent - description
-------------------
begin : Tue Dec 13 2005
- copyright : (C) 2005, 2006, 2007, 2009, 2010, 2011 by Thomas Friedrichsmeier
+ copyright : (C) 2005, 2006, 2007, 2009, 2010, 2011, 2012 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -203,8 +203,8 @@
RKComponent *_parent;
/** usually happens during construction, so you don't need to call this - unless you're RKStandardComponent, and discard the children at some point of time */
void createDefaultProperties ();
-/** This function is needed internally, to set the Qt enabledness of this widget, and all child component widgets. Note that the enabledness as stored in the enabledness_property is not necessarily the same as the enabledness in the GUI (and is not affected by this call). In general, a component is enabled in the GUI, if and only if both it's enabledness_property is set to true, and the its parent widget is enabled in Qt. */
- void updateEnablednessRecursive ();
+/** This function is needed internally, to set the Qt enabledness of this widget, and all child component widgets. Note that the enabledness as stored in the enabledness_property is not necessarily the same as the enabledness in the GUI (and is not affected by this call). In general, a component is enabled in the GUI, if and only if a) it's enabledness_property is set to true, b) its parent widget is enabled in Qt, and c) it's parent component is also enabled. */
+ void updateEnablednessRecursive (bool parent_component_enabled);
};
#endif
Modified: trunk/rkward/rkward/plugin/rkoptionset.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkoptionset.cpp 2012-05-21 17:23:09 UTC (rev 4258)
+++ trunk/rkward/rkward/plugin/rkoptionset.cpp 2012-05-22 07:44:11 UTC (rev 4259)
@@ -61,12 +61,13 @@
display = 0; // will be created from the builder, on demand -> createDisplay ()
contents_container = new RKComponent (this, contents_box);
RKComponentBuilder *builder = new RKComponentBuilder (contents_container, QDomElement ());
- builder->buildElement (xml->getChildElement (element, "content", DL_ERROR), contents_box, false);
+ builder->buildElement (xml->getChildElement (element, "content", DL_ERROR), contents_box, 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->makeConnections ();
#warning TOOD: do we need this? or is the per-column default good enough?
#warning TOOD: should we wait until the (top level) plugin initial state has settled, before fetching the defaults?
// take a snapshot of the default state of the contents
contents_container->fetchPropertyValuesRecursive (&content_defaults);
+ addChild ("contents", contents_container);
// create columns
XMLChildList options = xml->getChildElements (element, "option", DL_WARNING);
@@ -156,6 +157,8 @@
connect (remove_button, SIGNAL (clicked()), this, SLOT (removeRow()));
}
}
+
+ update_timer.start ();
}
RKOptionSet::~RKOptionSet () {
@@ -388,6 +391,7 @@
row_count->setIntValue (count);
#warning TODO: why doesn't this have an effect?
contents_container->enablednessProperty ()->setBoolValue (row >= 0);
+// contents_container->setEnabled (false);
updateVisuals ();
changed (); // needed, for the unlikely case that no change notification was triggered above, since isValid() returns false while updating
Modified: trunk/rkward/rkward/plugins/testing/optionset.js
===================================================================
--- trunk/rkward/rkward/plugins/testing/optionset.js 2012-05-21 17:23:09 UTC (rev 4258)
+++ trunk/rkward/rkward/plugins/testing/optionset.js 2012-05-22 07:44:11 UTC (rev 4259)
@@ -2,7 +2,9 @@
echo ("## Manual set: ##\n")
echo ("row_count <- " + getValue ("mset.row_count") + "\n");
echo ("current_row <- " + getValue ("mset.current_row") + "\n");
+ echo ("mset.contents.enabled <- " + getValue ("mset.contents.enabled") + "\n");
echo ("## Driven set: ##\n")
echo ("row_count <- " + getValue ("set.row_count") + "\n");
echo ("current_row <- " + getValue ("set.current_row") + "\n");
+ echo ("set.contents.enabled <- " + getValue ("set.contents.enabled") + "\n");
}
Modified: trunk/rkward/rkward/plugins/testing/optionset.xml
===================================================================
--- trunk/rkward/rkward/plugins/testing/optionset.xml 2012-05-21 17:23:09 UTC (rev 4258)
+++ trunk/rkward/rkward/plugins/testing/optionset.xml 2012-05-22 07:44:11 UTC (rev 4259)
@@ -4,9 +4,11 @@
<code file="optionset.js"/>
<logic>
- <set id="set.dummyslot.enabled" to="false"/> <!-- TODO: does not work, yet -->
+ <set id="set.contents.dummyslot.enabled" to="false"/>
<connect governor="x.available" client="set.var" />
<connect governor="x.available.shortname" client="set.varname" />
+ <connect governor="mset.object" client="cset.object" />
+ <connect governor="mset.objshort" client="cset.objshort" />
</logic>
<dialog label="Testing Optionset">
@@ -22,7 +24,7 @@
<row>
<varselector id="vars"/>
<column>
- <varslot type="numeric" id="x" source="vars" required="false" label="Pick an object"/>
+ <varslot type="numeric" id="x" source="vars" required="true" label="Pick an object"/> <!-- NOTE: requiredness does not work, correctly, yet -->
<input id="summary" label="Enter a summary" size="large"/>
<stretch/>
</column>
@@ -34,6 +36,20 @@
<option id="summary" connect="summary.text" restorable="true"/>
</optionset>
</tab>
+ <tab label="Connected driven set">
+ <text>This option set is connected to the set on the first tab.</text>
+ <optionset id="cset" keycolumn="object">
+ <content>
+ <frame>
+ <optiondisplay index="true"/>
+ <input id="summary" label="Enter another summary" size="large"/>
+ </frame>
+ </content>
+ <option id="object" restorable="false"/>
+ <option id="objshort" label="Object" restorable="false"/>
+ <option id="summary" connect="summary.text" restorable="true"/>
+ </optionset>
+ </tab>
<tab label="Driven set">
<text>First, select some objects, here (it doesn't matter, what you pick).</text>
<row>
@@ -45,7 +61,7 @@
<optionset id="set" min_rows="1" keycolumn="var">
<content>
<frame>
- <optiondisplay index="true"/>
+ <optiondisplay index="false"/>
<varslot id="dummyslot"/>
<input id="commenta" label="Comment A"/>
<input id="commentb" label="Comment B"/>
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