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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Mar 21 16:09:13 UTC 2007


Revision: 1680
          http://svn.sourceforge.net/rkward/?rev=1680&view=rev
Author:   tfry
Date:     2007-03-21 09:09:13 -0700 (Wed, 21 Mar 2007)

Log Message:
-----------
When disabling a(n embedded) component, all it's child components become disabled as well

Modified Paths:
--------------
    trunk/rkward/rkward/plugin/rkcomponent.cpp
    trunk/rkward/rkward/plugin/rkcomponent.h
    trunk/rkward/rkward/plugins/plots/color_chooser.xml

Modified: trunk/rkward/rkward/plugin/rkcomponent.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponent.cpp	2007-03-21 12:29:41 UTC (rev 1679)
+++ trunk/rkward/rkward/plugin/rkcomponent.cpp	2007-03-21 16:09:13 UTC (rev 1680)
@@ -136,17 +136,35 @@
 			if (isShown ()) hide ();
 		}
 	} else if (property == enabledness_property) {
-		if (enabledness_property->boolValue ()) {
-			if (!isEnabled ()) setEnabled (true);
-		} else {
-			if (isEnabled ()) setEnabled (false);
-		}
+		updateEnablednessRecursive ();
 	} else if (property == requiredness_property) {
 		required = requiredness_property->boolValue ();
 		changed ();
 	}
 }
 
+void RKComponent::updateEnablednessRecursive () {
+	RK_TRACE (PLUGIN);
+
+	bool enabled;
+	if (enabledness_property->boolValue ()) {
+		enabled = ((!parentComponent ()) || (parentComponent ()->isEnabled ()));
+	} else {
+		enabled = false;
+	}
+
+	qDebug ("old %d, new %d", isEnabled (), enabled);
+
+	if (enabled != isEnabled ()) {
+		setEnabled (enabled);
+		for (QDictIterator<RKComponentBase> it (child_map); it.current (); ++it) {
+			if (it.current ()->isComponent()) {
+				static_cast<RKComponent*> (it.current ())->updateEnablednessRecursive ();
+			}
+		}
+	}
+}
+
 bool RKComponent::isValid () {
 	RK_TRACE (PLUGIN);
 

Modified: trunk/rkward/rkward/plugin/rkcomponent.h
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponent.h	2007-03-21 12:29:41 UTC (rev 1679)
+++ trunk/rkward/rkward/plugin/rkcomponent.h	2007-03-21 16:09:13 UTC (rev 1680)
@@ -73,6 +73,7 @@
 	virtual QString value (const QString &modifier=QString::null);
 /** returns true, if this is a property */
 	bool isProperty () { return (type () <= PropertyEnd); };
+	bool isComponent () { return (type () >= ComponentBase); };
 /** returns satisfaction state. see setRequired () */
 	virtual bool isSatisfied ();
 /** currently valid (i.e. satisfied, even if required)? default implementation always returns true */
@@ -161,6 +162,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 ();
 };
 
 #endif

Modified: trunk/rkward/rkward/plugins/plots/color_chooser.xml
===================================================================
--- trunk/rkward/rkward/plugins/plots/color_chooser.xml	2007-03-21 12:29:41 UTC (rev 1679)
+++ trunk/rkward/rkward/plugins/plots/color_chooser.xml	2007-03-21 16:09:13 UTC (rev 1680)
@@ -5,9 +5,6 @@
 	<logic>
 		<external id="argument" default=", col=" />
 		<external id="default_color" default="" />
-
-		<!-- This is just a dirty workaround. Actually, this should be solved at the C++ level, somehow -->
-		<connect client="color.enabled" governor="enabled"/>
 	</logic>
 	<dialog label="Choose color" >
 		<dropdown id="color" label="Color">


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