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

tfry at users.sf.net tfry at users.sf.net
Thu May 9 06:24:54 UTC 2013


Revision: 4746
          http://sourceforge.net/p/rkward/code/4746
Author:   tfry
Date:     2013-05-09 06:24:52 +0000 (Thu, 09 May 2013)
Log Message:
-----------
Fix some first valueselector bugs.

Modified Paths:
--------------
    trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
    trunk/rkward/rkward/plugin/rkvalueselector.cpp
    trunk/rkward/rkward/plugins/under_development.pluginmap

Added Paths:
-----------
    trunk/rkward/rkward/plugins/testing/valueselect1.js
    trunk/rkward/rkward/plugins/testing/valueselect1.xml

Modified: trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2013-05-08 18:06:09 UTC (rev 4745)
+++ trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2013-05-09 06:24:52 UTC (rev 4746)
@@ -56,6 +56,7 @@
 #include "rktabpage.h"
 #include "rkpluginframe.h"
 #include "rkoptionset.h"
+#include "rkvalueselector.h"
 
 #include "../rkglobals.h"
 
@@ -617,6 +618,8 @@
 			QString source = xml->getStringAttribute (e, "source_property", QString (), DL_INFO);
 			if (source.isEmpty ()) source = xml->getStringAttribute (e, "source", "#noid#", DL_WARNING) + ".selected";
 			addConnection (id, "source", source, QString (), false, e);
+		} else if ((e.tagName () == QLatin1String ("valueselector")) || (e.tagName () == QLatin1String ("select"))) {
+			widget = new RKValueSelector (e, component (), parent_widget);
 		} else if (e.tagName () == QLatin1String ("formula")) {
 			widget = new RKFormula (e, component (), parent_widget);
 			addConnection (id, "dependent", xml->getStringAttribute (e, "dependent", "#noid#", DL_INFO), "available", false, e);

Modified: trunk/rkward/rkward/plugin/rkvalueselector.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkvalueselector.cpp	2013-05-08 18:06:09 UTC (rev 4745)
+++ trunk/rkward/rkward/plugin/rkvalueselector.cpp	2013-05-09 06:24:52 UTC (rev 4746)
@@ -55,9 +55,10 @@
 
 	list_view = new QTreeView (this);
 	list_view->setSelectionMode (QAbstractItemView::ExtendedSelection);
-	connect (list_view, SIGNAL (listSelectionChanged ()), this, SLOT (listSelectionChanged ()));
+	list_view->setRootIsDecorated (false);
 	model = new QStringListModel (this);
 	list_view->setModel (model);
+	connect (list_view->selectionModel (), SIGNAL (selectionChanged(QItemSelection,QItemSelection)), this, SLOT (listSelectionChanged ()));
 
 	vbox->addWidget (list_view);
 
@@ -68,9 +69,10 @@
 		QStringList selected_list;
 
 		for (int i = 0; i < options.size (); ++i) {
-			QString v = xml->getStringAttribute (element, "value", QString (), DL_WARNING);
-			QString l = xml->getStringAttribute (element, "label", v, DL_INFO);
-			if (xml->getBoolAttribute (element, "selected", false, DL_INFO)) selected_list.append (v);
+			const QDomElement &child = options[i];
+			QString v = xml->getStringAttribute (child, "value", QString (), DL_WARNING);
+			QString l = xml->getStringAttribute (child, "label", v, DL_INFO);
+			if (xml->getBoolAttribute (child, "selected", false, DL_INFO)) selected_list.append (v);
 			labels_list.append (l);
 			values_list.append (v);
 		}
@@ -108,6 +110,7 @@
 		purged_selected_indexes.clear ();
 	} else {
 		selectionPropertyChanged ();   // To update selected items
+		purged_selected_indexes.clear ();
 	}
 }
 
@@ -115,6 +118,7 @@
 	if (updating) return;
 	RK_TRACE (PLUGIN);
 
+	purged_selected_indexes.clear ();
 	QStringList sel_list;
 	QModelIndexList selected_rows = list_view->selectionModel ()->selectedRows ();
 	for (int i = 0; i < selected_rows.size (); ++i) {
@@ -149,8 +153,9 @@
 	foreach (const int row, selected_rows) {
 		list_view->selectionModel ()->select (model->index (row), QItemSelectionModel::Select | QItemSelectionModel::Rows);
 	}
+	updating = false;
 
-	updating = false;
+	changed ();
 }
 
 QVariant RKValueSelector::value (const QString& modifier) {
@@ -169,4 +174,4 @@
 	return selected->value (modifier);
 }
 
-#include "rkvarselector.moc"
+#include "rkvalueselector.moc"

Added: trunk/rkward/rkward/plugins/testing/valueselect1.js
===================================================================
--- trunk/rkward/rkward/plugins/testing/valueselect1.js	                        (rev 0)
+++ trunk/rkward/rkward/plugins/testing/valueselect1.js	2013-05-09 06:24:52 UTC (rev 4746)
@@ -0,0 +1,9 @@
+function calculate () {
+	echo (getList ("select").join ("\n"));
+	echo ("\n\n");
+	echo (getList ("valueselect.labelled").join ("\n"));
+	echo ("\n\n");
+	echo (getList ("valueselect.selected").join ("\n"));
+	echo ("\n\n");
+}
+

Added: trunk/rkward/rkward/plugins/testing/valueselect1.xml
===================================================================
--- trunk/rkward/rkward/plugins/testing/valueselect1.xml	                        (rev 0)
+++ trunk/rkward/rkward/plugins/testing/valueselect1.xml	2013-05-09 06:24:52 UTC (rev 4746)
@@ -0,0 +1,33 @@
+<!DOCTYPE rkplugin>
+
+<document>
+	<code file="valueselect1.js"/>
+
+	<dialog label="Testing valueselector/slot and select elements">
+		<text id="text">
+			This plugin is bogus! Do not use!
+		</text>
+		<tabbook>
+			<tab label="<select>">
+				<select id="select">
+					<option value="test1" label="first" selected="true"/>
+					<option value="test2" label="second"/>
+					<option value="test3" label="third" selected="true"/>
+				</select>
+				<stretch/>
+			</tab>
+			<tab label="valueselector/valueslot">
+				<row>
+					<valueselector id="valueselect">
+						<option value="test1" label="first"/>
+						<option value="test2" label="second"/>
+						<option value="test3" label="third"/>
+					</valueselector>
+					<valueslot id="valueslot" label="Select one or more" min_vars="1" multi="true" source="valueselect"/>
+					<stretch/>
+				</row>
+			</tab>
+		</tabbook>
+	</dialog>
+
+</document> 

Modified: trunk/rkward/rkward/plugins/under_development.pluginmap
===================================================================
--- trunk/rkward/rkward/plugins/under_development.pluginmap	2013-05-08 18:06:09 UTC (rev 4745)
+++ trunk/rkward/rkward/plugins/under_development.pluginmap	2013-05-09 06:24:52 UTC (rev 4746)
@@ -13,6 +13,7 @@
 		<component type="standard" id="qtscript_test2" file="testing/test2.xml" label="QtScript Test 2" />
 		<component type="standard" id="optionset_test" file="testing/optionset.xml" label="Optionset Test" />
 		<component type="standard" id="matrix_test1" file="testing/matrix1.xml" label="Input Matrix Test" />
+		<component type="standard" id="valueselect_test1" file="testing/valueselect1.xml" label="Valueselector/valueslot/select Test" />
 <!-- End -->
 
 		<component type="standard" id="import_xls" file="00saveload/import/import_xls.xml" label="Import MS EXCEL">
@@ -40,6 +41,7 @@
 			<entry component="qtscript_test1" index="1"/>
 			<entry component="optionset_test" index="1"/>
 			<entry component="matrix_test1" index="1"/>
+			<entry component="valueselect_test1" index="1"/>
 		</menu>
 		<menu id="plots" label="Plots" index="5">
 			<entry component="sieve_plot" />





More information about the rkward-tracker mailing list