[rkward] rkward/plugin: Make varslot checks "soft". (This change is still subject to further discussion on the list.)

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Mon Nov 23 12:01:56 UTC 2015


Git commit 0ab7b858737091e8aa7eeb4c74aa9c92b7e850f4 by Thomas Friedrichsmeier.
Committed on 23/11/2015 at 12:01.
Pushed by tfry into branch 'master'.

Make varslot checks "soft". (This change is still subject to further discussion on the list.)

M  +9    -2    rkward/plugin/rkcomponentproperties.cpp
M  +2    -0    rkward/plugin/rkcomponentproperties.h
M  +4    -2    rkward/plugin/rkvarslot.cpp

http://commits.kde.org/rkward/0ab7b858737091e8aa7eeb4c74aa9c92b7e850f4

diff --git a/rkward/plugin/rkcomponentproperties.cpp b/rkward/plugin/rkcomponentproperties.cpp
index 3972255..00e3f5b 100644
--- a/rkward/plugin/rkcomponentproperties.cpp
+++ b/rkward/plugin/rkcomponentproperties.cpp
@@ -800,6 +800,7 @@ RKComponentPropertyRObjects::RKComponentPropertyRObjects (QObject *parent, bool
 
 // no initial requirements
 	dims = min_length = max_length;
+	problems_are_errors = true;
 	setStripDuplicates (true);      // legacy default
 
 	addNotificationType (RObjectListener::ObjectRemoved);
@@ -951,7 +952,7 @@ QString RKComponentPropertyRObjects::checkObjectProblems (RObject *object) const
 	if (!types.isEmpty ()) {
 		QString type = RObject::typeToText (object->getDataType ()).toLower ();
 		if (!types.contains (type)) {
-			probs.append (i18n ("This object's data type is <i>%1</i>, while allowed type(s) is/are <i>%2</i>.", type, types.join (", ")));
+			probs.append (i18n ("This object's data type is <i>%1</i>, while expected type(s) is/are <i>%2</i>.", type, types.join (", ")));
 		}
 	}
 
@@ -1162,10 +1163,16 @@ void RKComponentPropertyRObjects::updateValidity () {
 
 	is_valid = true;	// innocent until proven guilty
 
-	if (!problems.isEmpty ()) is_valid = false;
+	if (problems_are_errors && (!problems.isEmpty ())) is_valid = false;
 	else is_valid = checkListLength ();
 }
 
+void RKComponentPropertyRObjects::setObjectProblemsAreErrors (bool errors) {
+	RK_TRACE (PLUGIN);
+	problems_are_errors = errors;
+	updateValidity ();
+}
+
 /////////////////////////////////////////// Code ////////////////////////////////////////////////
 
 RKComponentPropertyCode::RKComponentPropertyCode (QObject *parent, bool required) : RKComponentPropertyBase (parent, required) {
diff --git a/rkward/plugin/rkcomponentproperties.h b/rkward/plugin/rkcomponentproperties.h
index aad9a94..2a9706a 100644
--- a/rkward/plugin/rkcomponentproperties.h
+++ b/rkward/plugin/rkcomponentproperties.h
@@ -334,6 +334,7 @@ public:
 	void removeAt (int index);
 	RObject* objectAt (int index) const { return object_list.value (index); };
 	int listLength () const { return (object_list.size ()); };
+	void setObjectProblemsAreErrors (bool errors);
 protected:
 /** remove an object value. reimplemented from RObjectListener::objectRemoved (). This is so we get notified if the object currently selected is removed TODO: is this effectively a duplication of setFromList? */
 	void objectRemoved (RObject *removed);
@@ -352,6 +353,7 @@ private:
 	QString checkObjectProblems (RObject *object) const;
 	RObject::ObjectList object_list;
 	QMap<RObject*, QString> problems;
+	bool problems_are_errors;
 	int dims;
 	int min_length;
 	int max_length;
diff --git a/rkward/plugin/rkvarslot.cpp b/rkward/plugin/rkvarslot.cpp
index 5d85d58..1e9f883 100644
--- a/rkward/plugin/rkvarslot.cpp
+++ b/rkward/plugin/rkvarslot.cpp
@@ -26,6 +26,7 @@
 #include <QVBoxLayout>
 
 #include <klocale.h>
+#include <kicon.h>
 
 #include "rkvarselector.h"
 #include "../core/robject.h"
@@ -110,6 +111,7 @@ RKVarSlot::RKVarSlot (const QDomElement &element, RKComponent *parent_component,
 		static_cast<RKComponentPropertyRObjects*> (available)->setClassFilter (xml->getStringAttribute (element, "classes", QString (), DL_INFO).split (' ', QString::SkipEmptyParts));
 		static_cast<RKComponentPropertyRObjects*> (available)->setTypeFilter (xml->getStringAttribute (element, "types", QString (), DL_INFO).split (' ', QString::SkipEmptyParts));
 		static_cast<RKComponentPropertyRObjects*> (available)->setDimensionFilter (xml->getIntAttribute (element, "num_dimensions", 0, DL_INFO), xml->getIntAttribute (element, "min_length", 0, DL_INFO), xml->getIntAttribute (element, "max_length", INT_MAX, DL_INFO));
+		static_cast<RKComponentPropertyRObjects*> (available)->setObjectProblemsAreErrors (false);
 	}
 	available->setStripDuplicates (!xml->getBoolAttribute (element, "allow_duplicates", false, DL_INFO));
 	setRequired (xml->getBoolAttribute (element, "required", false, DL_INFO));
@@ -163,8 +165,8 @@ void RKVarSlot::availablePropertyChanged (RKComponentPropertyBase *) {
 			new_item->setText (0, object->getShortName ());
 			QString probs = static_cast<RKComponentPropertyRObjects*> (available)->objectProblems (i);
 			if (!probs.isEmpty ()) {
-				new_item->setToolTip (0, i18n ("<p>This object is not allowed, here, for the following reason(s):</p>") + probs);
-				new_item->setIcon (0, RKStandardIcons::getIcon (RKStandardIcons::ActionDeleteVar));
+				new_item->setToolTip (0, i18n ("<p>Using this object, here may lead to failures or unexpected results, for the following reason(s):</p>") + probs);
+				new_item->setIcon (0, KIcon ("task-attention"));
 			}
 		}
 	}



More information about the rkward-tracker mailing list