[rkward-cvs] SF.net SVN: rkward:[4460] trunk/rkward/rkward/plugin/rkcomponentproperties. cpp
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Tue Nov 27 15:10:47 UTC 2012
Revision: 4460
http://rkward.svn.sourceforge.net/rkward/?rev=4460&view=rev
Author: tfry
Date: 2012-11-27 15:10:47 +0000 (Tue, 27 Nov 2012)
Log Message:
-----------
Try harder to convert values to bool
Modified Paths:
--------------
trunk/rkward/rkward/plugin/rkcomponentproperties.cpp
Modified: trunk/rkward/rkward/plugin/rkcomponentproperties.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentproperties.cpp 2012-11-27 13:59:53 UTC (rev 4459)
+++ trunk/rkward/rkward/plugin/rkcomponentproperties.cpp 2012-11-27 15:10:47 UTC (rev 4460)
@@ -261,6 +261,20 @@
is_valid = true;
}
+bool RKComponentPropertyBool::stringToBool (const QString &value, bool *ok) {
+ if (ok) *ok = true;
+
+ bool _ok;
+ bool ret = value.toInt (&_ok);
+ if (_ok) return ret;
+
+ if (value == "true") return true;
+ if (value == "false") return false;
+
+ if (ok) *ok = false;
+ return false;
+}
+
void RKComponentPropertyBool::internalSetValue (const QString &new_value) {
RK_TRACE (PLUGIN);
@@ -270,7 +284,7 @@
} else if (new_value == value_false) {
internalSetValue (false);
} else {
- is_valid = false;
+ internalSetValue (stringToBool (new_value, &is_valid));
}
}
@@ -324,7 +338,7 @@
RK_TRACE (PLUGIN);
QVariant value = property->value (governor_modifier);
- if (value.type () == QVariant::String) { // Qt's conversion from string to bool does not meet our needs.
+ 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 ());
@@ -1195,7 +1209,9 @@
break;
} case And: {
bool ok;
- int val = source.property->value (source.modifier).toInt (&ok);
+ QVariant v = source.property->value (source.modifier);
+ bool val = (bool) v.toInt (&ok);
+ if (!ok) val = stringToBool (fetchStringValue(source.property, source.modifier), &ok);
if (ok) {
if (!val) {
setBoolValue (false);
@@ -1207,7 +1223,9 @@
break;
} case Or: {
bool ok;
- int val = source.property->value (source.modifier).toInt (&ok);
+ QVariant v = source.property->value (source.modifier);
+ bool val = (bool) v.toInt (&ok);
+ if (!ok) val = stringToBool (fetchStringValue(source.property, source.modifier), &ok);
if (ok) {
if (val) {
setBoolValue (true);
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