[rkward-cvs] [rkward] Make it very easy to create a header line from plugin most plugin elements.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Mon Nov 17 19:21:39 UTC 2014


NOTE: This is a manual resend of a commit notification that was missing due to 
commit hooks not yet activated.

---

commit 2fcf55dc53d0f06c9f12381c2cead1b0b4c8c980
Commit:     Thomas Friedrichsmeier <thomas.friedrichsmeier at ruhr-uni-bochum.de>
CommitDate: Mon Nov 17 10:31:18 2014 +0100

    Make it very easy to create a header line from plugin most plugin 
elements.
    Makes i18n() much easier in some cases.

diff --git a/ChangeLog b/ChangeLog
index cc7f0a5..33bf727 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+- Support automatically generating a printable header parameter from most 
plugin elements
 - New Object based convience method for printing headers from plugins
 - Implement polyPath()-drawing in RK() device
 - Pre-compile the common js code included in every plugin (only when compiled 
with Qt >= 4.7)
diff --git a/doc/rkwardplugins/index.docbook b/doc/rkwardplugins/index.docbook
index 56c59bf..96eae9a 100644
--- a/doc/rkwardplugins/index.docbook
+++ b/doc/rkwardplugins/index.docbook
@@ -556,10 +556,11 @@ function printout () {
 		<programlisting>
 function printout () {
 	new Header (i18n ("Two Variable t-Test"))
-	          .add (i18n ("Assume equal variances"), getBoolean 
("varequal.state") ? i18n ("yes") : i18n ("no"))
-	          .add (i18n ("Confidence level"), getString ("conflevel"))
+	          .addFromUI ("varequal")
+	          .add (i18n ("Confidence level"), getString ("conflevel"))  // 
Note: written like this for illustration purposes. More automatic:
+	//        .addFromUI ("conflevel")
 	          .print ();
-	echo ('rk.print (res)\n');
+echo ('rk.print (res)\n');
 }
 		</programlisting>
 		<para>
diff --git a/rkward/plugin/rkabstractoptionselector.cpp 
b/rkward/plugin/rkabstractoptionselector.cpp
index b45e1a6..474de64 100644
--- a/rkward/plugin/rkabstractoptionselector.cpp
+++ b/rkward/plugin/rkabstractoptionselector.cpp
@@ -2,7 +2,7 @@
                           rkabstractoptionselector  -  description
                              -------------------
     begin                : Tue Mar 20 2007
-    copyright            : (C) 2007, 2009, 2012 by Thomas Friedrichsmeier
+    copyright            : (C) 2007, 2009, 2012, 2014 by Thomas 
Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
diff --git a/rkward/plugin/rkabstractoptionselector.h 
b/rkward/plugin/rkabstractoptionselector.h
index 0fcef9b..79c157e 100644
--- a/rkward/plugin/rkabstractoptionselector.h
+++ b/rkward/plugin/rkabstractoptionselector.h
@@ -2,7 +2,7 @@
                           rkabstractoptionselector  -  description
                              -------------------
     begin                : Tue Mar 20 2007
-    copyright            : (C) 2007, 2012 by Thomas Friedrichsmeier
+    copyright            : (C) 2007, 2012, 2014 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
diff --git a/rkward/plugin/rkcheckbox.cpp b/rkward/plugin/rkcheckbox.cpp
index b3e246e..0f2efdc 100644
--- a/rkward/plugin/rkcheckbox.cpp
+++ b/rkward/plugin/rkcheckbox.cpp
@@ -2,7 +2,7 @@
                           rkcheckbox  -  description
                              -------------------
     begin                : Fri Jul 30 2004
-    copyright            : (C) 2004, 2006 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2014 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -18,6 +18,7 @@
 
 #include <qcheckbox.h>
 #include <QVBoxLayout>
+#include <klocale.h>
 
 #include "../rkglobals.h"
 #include "../misc/xmlhelper.h"
@@ -67,4 +68,12 @@ void RKCheckBox::changedState (int) {
 	state->setBoolValue (checkbox->isChecked ());
 }
 
+QStringList RKCheckBox::getUiLabelPair () const {
+	RK_TRACE (PLUGIN);
+
+	QStringList ret (stripAccelerators (checkbox->text ()));
+	ret.append (checkbox->isChecked () ? i18n ("yes") : i18n ("no"));
+	return ret;
+}
+
 #include "rkcheckbox.moc"
diff --git a/rkward/plugin/rkcheckbox.h b/rkward/plugin/rkcheckbox.h
index e041837..7ff6525 100644
--- a/rkward/plugin/rkcheckbox.h
+++ b/rkward/plugin/rkcheckbox.h
@@ -2,7 +2,7 @@
                           rkcheckbox  -  description
                              -------------------
     begin                : Fri Jul 30 2004
-    copyright            : (C) 2004, 2006, 2012 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2012, 2014 by Thomas 
Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -41,6 +41,7 @@ public:
 		if (modifier.isEmpty ()) return state->value ("labeled");
 		return (state->value (modifier));
 	};
+	QStringList getUiLabelPair () const;
 public slots:
 	void changedState (int);
 	void changedState (RKComponentPropertyBase *);
diff --git a/rkward/plugin/rkcomponent.cpp b/rkward/plugin/rkcomponent.cpp
index a4b376b..b2f0e50 100644
--- a/rkward/plugin/rkcomponent.cpp
+++ b/rkward/plugin/rkcomponent.cpp
@@ -199,6 +199,23 @@ QVariant RKComponentBase::fetchValue (const QString &id, 
const int hint) {
 	} else {
 		QString mod;
 		RKComponentBase *prop = lookupComponent (id, &mod);
+		if (hint == UiLabelPair) {
+			QStringList ret;
+			if (prop->isComponent ()) {
+				ret = static_cast<const RKComponent*> (prop)->getUiLabelPair 
();
+				if (ret.isEmpty ()) {
+					RK_DEBUG (PLUGIN, DL_WARNING, "Component id %s does not 
support getting ui labels.", qPrintable (id));
+				}
+				RK_ASSERT (!(ret.size () % 2));
+			} else {
+				RK_DEBUG (PLUGIN, DL_WARNING, "Getting ui labels is not 
supported for properties, only for components. Failed id was: %s", qPrintable 
(id));
+			}
+			if (ret.isEmpty ()) {
+				ret << "-" << "-";
+			}
+			RK_DEBUG (PLUGIN, DL_WARNING, "Labels for %s: %s", qPrintable 
(id), qPrintable (ret.join (":")));
+			return QVariant (ret);
+		}
 		QVariant val = prop->value (mod);
 		if (hint == BooleanValue) {
 			bool ok;
@@ -420,4 +437,19 @@ QString RKComponent::getIdInParent () const {
 	return (parentComponent ()->child_map.key (const_cast<RKComponent*> 
(this)));
 }
 
+// static
+QString RKComponent::stripAccelerators (const QString& in) {
+	QString ret;
+	ret.reserve (in.size ());
+	for (int i = 0; i < in.size (); ++i) {
+		QChar c = in[i];
+		if (c == QLatin1Char ('&')) {
+			if (++i < in.size ()) ret.append (in[i]);
+		} else {
+			ret.append (c);
+		}
+	}
+	return ret;
+}
+
 #include "rkcomponent.moc"
diff --git a/rkward/plugin/rkcomponent.h b/rkward/plugin/rkcomponent.h
index 8a27c9d..3496081 100644
--- a/rkward/plugin/rkcomponent.h
+++ b/rkward/plugin/rkcomponent.h
@@ -100,9 +100,11 @@ public:
 		BooleanValue,
 		StringValue,
 		StringlistValue,
-		NumericValue
+		NumericValue,
+		UiLabelPair
 	};
 	QVariant fetchValue (const QString &identifier, const int type_hint);
+	virtual QStringList getUiLabelPair () const { return QStringList (); };
 /** returns true, if this is a property */
 	bool isProperty () { return (type () <= PropertyEnd); };
 	bool isComponent () { return (type () >= ComponentBase); };
@@ -227,6 +229,8 @@ protected:
 	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 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);
+/** Helper for getUiLabelPair(): Strips accelator key markup ("&") from 
strings */
+	static QString stripAccelerators (const QString &in);
 };
 
 #endif
diff --git a/rkward/plugin/rkdropdown.cpp b/rkward/plugin/rkdropdown.cpp
index b1bf5d3..8b2a7b9 100644
--- a/rkward/plugin/rkdropdown.cpp
+++ b/rkward/plugin/rkdropdown.cpp
@@ -2,7 +2,7 @@
                           rkdropdown.h  -  description
                              -------------------
     begin                : Fri Jan 12 2007
-    copyright            : (C) 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2007, 2014 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -39,7 +39,7 @@ RKDropDown::RKDropDown (const QDomElement &element, 
RKComponent *parent_componen
 	QVBoxLayout *vbox = new QVBoxLayout (this);
 	vbox->setContentsMargins (0, 0, 0, 0);
 
-	QLabel *label = new QLabel (xml->i18nStringAttribute (element, "label", 
i18n ("Select one:"), DL_INFO), this);
+	label = new QLabel (xml->i18nStringAttribute (element, "label", i18n 
("Select one:"), DL_INFO), this);
 	vbox->addWidget (label);
 
 	// create ComboBox
@@ -88,4 +88,12 @@ void RKDropDown::setItemEnabledInGUI (int id, bool enabled) 
{
 	item->setFlags ((Qt::ItemFlags) flags);
 }
 
+QStringList RKDropDown::getUiLabelPair () const {
+	RK_TRACE (PLUGIN);
+
+	QStringList ret (stripAccelerators (label->text ()));
+	ret.append (stripAccelerators (box->currentText ()));
+	return ret;
+}
+
 #include "rkdropdown.moc"
diff --git a/rkward/plugin/rkdropdown.h b/rkward/plugin/rkdropdown.h
index 9e67127..fcfb82f 100644
--- a/rkward/plugin/rkdropdown.h
+++ b/rkward/plugin/rkdropdown.h
@@ -2,7 +2,7 @@
                           rkdropdown.h  -  description
                              -------------------
     begin                : Fri Jan 12 2007
-    copyright            : (C) 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2007, 2014 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -22,6 +22,7 @@
 
 class QComboBox;
 class QListWidget;
+class QLabel;
 
 /** This RKPluginWidget provides a drop down list of options for use in 
plugins
 @author Thomas Friedrichsmeier
@@ -39,9 +40,11 @@ protected:
 	void setItemInGUI (int id);
 	void addOptionToGUI (const QString &label, int id);
 	void setItemEnabledInGUI (int id, bool enabled);
+	QStringList getUiLabelPair () const;
 private:
 	QComboBox *box;
 	QListWidget *listwidget;
+	QLabel *label;
 };
 
 #endif
diff --git a/rkward/plugin/rkformula.cpp b/rkward/plugin/rkformula.cpp
index 8d5e72a..aa5a658 100644
--- a/rkward/plugin/rkformula.cpp
+++ b/rkward/plugin/rkformula.cpp
@@ -2,7 +2,7 @@
                           rkformula  -  description
                              -------------------
     begin                : Thu Aug 12 2004
-    copyright            : (C) 2004, 2006, 2007, 2009, 2011 by Thomas 
Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2009, 2011, 2014 by Thomas 
Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -65,7 +65,8 @@ RKFormula::RKFormula (const QDomElement &element, 
RKComponent *parent_component,
 	QVBoxLayout *vbox = new QVBoxLayout (this);
 	vbox->setContentsMargins (0, 0, 0, 0);
 
-	vbox->addWidget (new QLabel (xml->i18nStringAttribute (element, "label", 
i18n ("Specify model"), DL_INFO), this));
+	label_string = xml->i18nStringAttribute (element, "label", i18n ("Specify 
model"), DL_INFO);
+	vbox->addWidget (new QLabel (label_string, this));
 
 	type_selector = new QButtonGroup (this);
 	QRadioButton* button;
@@ -406,4 +407,14 @@ bool RKFormula::isValid () {
 	return (model_ok);
 }
 
+QStringList RKFormula::getUiLabelPair () const {
+	RK_TRACE (PLUGIN);
+
+	QStringList ret (label_string);
+	QString m = stripAccelerators (type_selector->checkedButton ()->text ());
+	if (model_type == Custom) m.append (" " + model->value ().toString ());
+	ret.append (m);
+	return ret;
+}
+
 #include "rkformula.moc"
diff --git a/rkward/plugin/rkformula.h b/rkward/plugin/rkformula.h
index 1b128ab..3fb7f63 100644
--- a/rkward/plugin/rkformula.h
+++ b/rkward/plugin/rkformula.h
@@ -2,7 +2,7 @@
                           rkformula  -  description
                              -------------------
     begin                : Thu Aug 12 2004
-    copyright            : (C) 2004, 2006, 2007, 2012 by Thomas 
Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2012, 2014 by Thomas 
Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -41,6 +41,7 @@ public:
 	~RKFormula ();
 
 	QVariant value (const QString &modifier=QString ()) { return model->value 
(modifier); };
+	QStringList getUiLabelPair () const;
 	bool isValid ();
 
 /** RTTI */
@@ -73,6 +74,7 @@ private:
 	QPushButton *add_button;
 	QPushButton *remove_button;
 	QSpinBox *level_box;
+	QString label_string;
 	
 	void checkCustomModel ();
 	void makeModelString ();
diff --git a/rkward/plugin/rkinput.cpp b/rkward/plugin/rkinput.cpp
index 53ec7ae..c58c377 100644
--- a/rkward/plugin/rkinput.cpp
+++ b/rkward/plugin/rkinput.cpp
@@ -47,7 +47,7 @@ RKInput::RKInput (const QDomElement &element, RKComponent 
*parent_component, QWi
 	// do all the layouting
 	QVBoxLayout *vbox = new QVBoxLayout (this);
 	vbox->setContentsMargins (0, 0, 0, 0);
-	QString label_string = xml->i18nStringAttribute (element, "label", i18n 
("Enter text"), DL_INFO);
+	label_string = xml->i18nStringAttribute (element, "label", i18n ("Enter 
text"), DL_INFO);
 	if (!label_string.isEmpty ()) {
 		QLabel *label = new QLabel (label_string, this);
 		vbox->addWidget (label);
@@ -156,4 +156,12 @@ bool RKInput::isValid () {
 	return (!(fetchStringValue (text).isEmpty ()));
 }
 
+QStringList RKInput::getUiLabelPair () const {
+	RK_TRACE (PLUGIN);
+
+	QStringList ret (label_string);
+	ret.append (text->value ().toString ());
+	return ret;
+}
+
 #include "rkinput.moc"
diff --git a/rkward/plugin/rkinput.h b/rkward/plugin/rkinput.h
index 9b5db44..30caeaf 100644
--- a/rkward/plugin/rkinput.h
+++ b/rkward/plugin/rkinput.h
@@ -2,7 +2,7 @@
                           rkinput  -  description
                              -------------------
     begin                : Sat Mar 10 2005
-    copyright            : (C) 2005, 2006, 2007, 2012 by Thomas 
Friedrichsmeier
+    copyright            : (C) 2005, 2006, 2007, 2012, 2014 by Thomas 
Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -38,6 +38,7 @@ public:
 
 	RKComponentPropertyBase *text;
 	QVariant value (const QString &modifier=QString ()) { return (text->value 
(modifier)); };
+	QStringList getUiLabelPair () const;
 	int type () { return ComponentInput; };
 	bool isValid ();
 public slots:
@@ -53,6 +54,7 @@ private:
 	bool updating;
 	QTextEdit *textedit;
 	QLineEdit *lineedit;
+	QString label_string;
 };
 
 #endif
diff --git a/rkward/plugin/rkpluginbrowser.cpp 
b/rkward/plugin/rkpluginbrowser.cpp
index 11cfc2d..d3547a2 100644
--- a/rkward/plugin/rkpluginbrowser.cpp
+++ b/rkward/plugin/rkpluginbrowser.cpp
@@ -2,7 +2,7 @@
                           rkpluginbrowser  -  description
                              -------------------
     begin                : Sat Mar 10 2005
-    copyright            : (C) 2005, 2006, 2007, 2009, 2010, 2012 by Thomas 
Friedrichsmeier
+    copyright            : (C) 2005, 2006, 2007, 2009, 2010, 2012, 2014 by 
Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -50,7 +50,8 @@ RKPluginBrowser::RKPluginBrowser (const QDomElement 
&element, RKComponent *paren
 
 	bool only_local = !xml->getBoolAttribute (element, "allow_urls", false, 
DL_INFO);
 
-	selector = new GetFileNameWidget (this, mode, only_local, xml-
>i18nStringAttribute (element, "label", i18n ("Enter filename"), DL_INFO), 
i18n ("Select"), xml->getStringAttribute (element, "initial", QString (), 
DL_INFO));
+	label_string = xml->i18nStringAttribute (element, "label", i18n ("Enter 
filename"), DL_INFO);
+	selector = new GetFileNameWidget (this, mode, only_local, label_string, 
i18n ("Select"), xml->getStringAttribute (element, "initial", QString (), 
DL_INFO));
 	QString filter = xml->getStringAttribute (element, "filter", QString (), 
DL_INFO);
 	if (!filter.isEmpty ()) {
 		filter.append ("\n*|All files");
@@ -112,4 +113,12 @@ void RKPluginBrowser::updateColor () {
 	}
 }
 
+QStringList RKPluginBrowser::getUiLabelPair () const {
+	RK_TRACE (PLUGIN);
+
+	QStringList ret (label_string);
+	ret.append (selection->value ().toString ());
+	return ret;
+}
+
 #include "rkpluginbrowser.moc"
diff --git a/rkward/plugin/rkpluginbrowser.h b/rkward/plugin/rkpluginbrowser.h
index 6c98c02..48b70ef 100644
--- a/rkward/plugin/rkpluginbrowser.h
+++ b/rkward/plugin/rkpluginbrowser.h
@@ -2,7 +2,7 @@
                           rkpluginbrowser  -  description
                              -------------------
     begin                : Sat Mar 10 2005
-    copyright            : (C) 2005, 2006, 2007, 2012 by Thomas 
Friedrichsmeier
+    copyright            : (C) 2005, 2006, 2007, 2012, 2014 by Thomas 
Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -41,6 +41,7 @@ public:
 
 	RKComponentPropertyBase *selection;
 	QVariant value (const QString &modifier=QString ()) { return (selection-
>value (modifier)); };
+	QStringList getUiLabelPair () const;
 	int type () { return ComponentBrowser; };
 	bool isValid ();
 public slots:
@@ -51,6 +52,7 @@ private:
 	void updateColor ();
 	GetFileNameWidget *selector;
 	bool updating;
+	QString label_string;
 };
 
 #endif
diff --git a/rkward/plugin/rkpluginsaveobject.cpp 
b/rkward/plugin/rkpluginsaveobject.cpp
index 271b087..0291044 100644
--- a/rkward/plugin/rkpluginsaveobject.cpp
+++ b/rkward/plugin/rkpluginsaveobject.cpp
@@ -2,7 +2,7 @@
                           rkpluginsaveobject  -  description
                              -------------------
     begin                : Tue Jan 30 2007
-    copyright            : (C) 2007, 2010, 2012 by Thomas Friedrichsmeier
+    copyright            : (C) 2007, 2010, 2012, 2014 by Thomas 
Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -131,4 +131,12 @@ QVariant RKPluginSaveObject::value (const QString& 
modifier) {
 	return (selection->value (modifier));
 }
 
+QStringList RKPluginSaveObject::getUiLabelPair () const {
+	RK_TRACE (PLUGIN);
+
+	QStringList ret (stripAccelerators (groupbox->title ()));
+	ret.append (selection->value ().toString ());
+	return ret;
+}
+
 #include "rkpluginsaveobject.moc"
diff --git a/rkward/plugin/rkpluginsaveobject.h 
b/rkward/plugin/rkpluginsaveobject.h
index f1a0b0d..5ecb079 100644
--- a/rkward/plugin/rkpluginsaveobject.h
+++ b/rkward/plugin/rkpluginsaveobject.h
@@ -2,7 +2,7 @@
                           rkpluginsaveobject  -  description
                              -------------------
     begin                : Tue Jan 30 2007
-    copyright            : (C) 2007, 2010, 2012 by Thomas Friedrichsmeier
+    copyright            : (C) 2007, 2010, 2012, 2014 by Thomas 
Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -38,6 +38,7 @@ public:
 	~RKPluginSaveObject ();
 
 	QVariant value (const QString &modifier=QString ());
+	QStringList getUiLabelPair () const;
 	int type () { return ComponentSaveObject; };
 	bool isValid ();
 public slots:
diff --git a/rkward/plugin/rkpluginspinbox.cpp 
b/rkward/plugin/rkpluginspinbox.cpp
index 4fbe9fa..5fbab2f 100644
--- a/rkward/plugin/rkpluginspinbox.cpp
+++ b/rkward/plugin/rkpluginspinbox.cpp
@@ -2,7 +2,7 @@
                           rkpluginspinbox  -  description
                              -------------------
     begin                : Wed Aug 11 2004
-    copyright            : (C) 2004, 2006, 2009, 2012 by Thomas 
Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2009, 2012, 2014 by Thomas 
Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -42,7 +42,7 @@ RKPluginSpinBox::RKPluginSpinBox (const QDomElement 
&element, RKComponent *paren
 	// layout and label
 	QVBoxLayout *vbox = new QVBoxLayout (this);
 	vbox->setContentsMargins (0, 0, 0, 0);
-	QLabel *label = new QLabel (xml->i18nStringAttribute (element, "label", 
i18n ("Enter value:"), DL_WARNING), this);
+	label = new QLabel (xml->i18nStringAttribute (element, "label", i18n 
("Enter value:"), DL_WARNING), this);
 	vbox->addWidget (label);
 
 	// create spinbox and read settings
@@ -138,4 +138,12 @@ QVariant RKPluginSpinBox::value (const QString &modifier) 
{
 	}
 }
 
+QStringList RKPluginSpinBox::getUiLabelPair () const {
+	RK_TRACE (PLUGIN);
+
+	QStringList ret (stripAccelerators (label->text ()));
+	ret.append (const_cast<RKPluginSpinBox *> (this)->value ().toString ());
+	return ret;
+}
+
 #include "rkpluginspinbox.moc"
diff --git a/rkward/plugin/rkpluginspinbox.h b/rkward/plugin/rkpluginspinbox.h
index e84bad6..6653816 100644
--- a/rkward/plugin/rkpluginspinbox.h
+++ b/rkward/plugin/rkpluginspinbox.h
@@ -2,7 +2,7 @@
                           rkpluginspinbox  -  description
                              -------------------
     begin                : Wed Aug 11 2004
-    copyright            : (C) 2004, 2006, 2012 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2012, 2014 by Thomas 
Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -23,6 +23,7 @@
 
 class RKSpinBox;
 class QDomElement;
+class QLabel;
 
 /** RKComponent for numeric input represented as a spinbox
 TODO: rename file and class to RKComponentSpinBox
@@ -35,6 +36,7 @@ public:
 
 	~RKPluginSpinBox ();
 	QVariant value (const QString &modifier=QString ());
+	QStringList getUiLabelPair () const;
 	int type () { return ComponentSpinBox; };
 
 	RKComponentPropertyInt *intvalue;
@@ -44,6 +46,7 @@ public slots:
 	void valueChanged (RKComponentPropertyBase *property);
 private:
 	RKSpinBox *spinbox;
+	QLabel *label;
 	bool intmode;
 	bool updating;
 };
diff --git a/rkward/plugin/rkradio.cpp b/rkward/plugin/rkradio.cpp
index f362b77..ba614f1 100644
--- a/rkward/plugin/rkradio.cpp
+++ b/rkward/plugin/rkradio.cpp
@@ -2,7 +2,7 @@
                           rkradio.cpp  -  description
                              -------------------
     begin                : Thu Nov 7 2002
-    copyright            : (C) 2002, 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2002, 2006, 2007, 2014 by Thomas 
Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -78,4 +78,12 @@ void RKRadio::setItemEnabledInGUI (int id, bool enabled) {
 	button->setEnabled (enabled);
 }
 
+QStringList RKRadio::getUiLabelPair () const {
+	RK_TRACE (PLUGIN);
+
+	QStringList ret (stripAccelerators (group_box->title ()));
+	ret.append (stripAccelerators (group->checkedButton ()->text ()));
+	return ret;
+}
+
 #include "rkradio.moc"
diff --git a/rkward/plugin/rkradio.h b/rkward/plugin/rkradio.h
index 197ade6..8f839aa 100644
--- a/rkward/plugin/rkradio.h
+++ b/rkward/plugin/rkradio.h
@@ -2,7 +2,7 @@
                           rkradio.h  -  description
                              -------------------
     begin                : Thu Nov 7 2002
-    copyright            : (C) 2002, 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2002, 2006, 2007, 2014 by Thomas 
Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -36,6 +36,7 @@ protected:
 	void setItemInGUI (int id);
 	void addOptionToGUI (const QString &label, int id);
 	void setItemEnabledInGUI (int id, bool enabled);
+	QStringList getUiLabelPair () const;
 private:
 	QButtonGroup* group;
 	QGroupBox* group_box;
diff --git a/rkward/plugin/rkvalueselector.cpp 
b/rkward/plugin/rkvalueselector.cpp
index 32d6839..f820995 100644
--- a/rkward/plugin/rkvalueselector.cpp
+++ b/rkward/plugin/rkvalueselector.cpp
@@ -47,9 +47,9 @@ RKValueSelector::RKValueSelector (const QDomElement 
&element, RKComponent *paren
 	QVBoxLayout *vbox = new QVBoxLayout (this);
 	vbox->setContentsMargins (0, 0, 0, 0);
 
-	QString lab = xml->i18nStringAttribute (element, "label", QString (), 
DL_INFO);
-	if (!lab.isNull ()) {
-		QLabel *label = new QLabel (lab, this);
+	label_string = xml->i18nStringAttribute (element, "label", QString (), 
DL_INFO);
+	if (!label_string.isNull ()) {
+		QLabel *label = new QLabel (label_string, this);
 		vbox->addWidget (label);
 	}
 
@@ -186,4 +186,12 @@ QVariant RKValueSelector::value (const QString& modifier) 
{
 	return selected->value (modifier);
 }
 
+QStringList RKValueSelector::getUiLabelPair () const {
+	RK_TRACE (PLUGIN);
+
+	QStringList ret (label_string);
+	ret.append (const_cast<RKValueSelector *> (this)->value 
("labeled").toStringList ().join ("; "));
+	return ret;
+}
+
 #include "rkvalueselector.moc"
diff --git a/rkward/plugin/rkvalueselector.h b/rkward/plugin/rkvalueselector.h
index 22b8cee..12071d1 100644
--- a/rkward/plugin/rkvalueselector.h
+++ b/rkward/plugin/rkvalueselector.h
@@ -2,7 +2,7 @@
                           rkvalueselector  -  description
                              -------------------
     begin                : Weg May 8 2013
-    copyright            : (C) 2013 by Thomas Friedrichsmeier
+    copyright            : (C) 2013-2014 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -36,6 +36,7 @@ public:
 	~RKValueSelector ();
 	int type () { return ComponentValueSelector; };
 	QVariant value (const QString &modifier=QString ());
+	QStringList getUiLabelPair () const;
 private slots:
 	void selectionPropertyChanged ();
 	void listSelectionChanged ();
@@ -50,6 +51,7 @@ private:
 	RKComponentPropertyStringList *labels;
 	RKComponentPropertyStringList *available;
 	QStringList purged_selected_indexes;
+	QString label_string;
 };
 
 #endif
diff --git a/rkward/plugin/rkvarslot.cpp b/rkward/plugin/rkvarslot.cpp
index e7f8bdb..c479fd4 100644
--- a/rkward/plugin/rkvarslot.cpp
+++ b/rkward/plugin/rkvarslot.cpp
@@ -42,7 +42,7 @@ RKVarSlot::RKVarSlot (const QDomElement &element, 
RKComponent *parent_component,
 	// basic layout
 	QGridLayout *g_layout = new QGridLayout (this);
 
-	QString label_string = xml->i18nStringAttribute (element, "label", i18n 
("Variable:"), DL_INFO);
+	label_string = xml->i18nStringAttribute (element, "label", i18n 
("Variable:"), DL_INFO);
 	if (!label_string.isEmpty ()) {
 		QLabel *label = new QLabel (label_string, this);
 		g_layout->addWidget (label, 0, 2);
@@ -226,4 +226,12 @@ void RKVarSlot::selectPressed () {
 	availablePropertyChanged (available);
 }
 
+QStringList RKVarSlot::getUiLabelPair () const {
+	RK_TRACE (PLUGIN);
+
+	QStringList ret (label_string);
+	ret.append (available->value ().toString ());
+	return ret;
+}
+
 #include "rkvarslot.moc"
diff --git a/rkward/plugin/rkvarslot.h b/rkward/plugin/rkvarslot.h
index 3f691f4..09ec022 100644
--- a/rkward/plugin/rkvarslot.h
+++ b/rkward/plugin/rkvarslot.h
@@ -2,7 +2,7 @@
                           rkvarslot.h  -  description
                              -------------------
     begin                : Thu Nov 7 2002
-    copyright            : (C) 2002 - 2013 by Thomas Friedrichsmeier
+    copyright            : (C) 2002 - 2014 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -42,6 +42,7 @@ public:
 	~RKVarSlot ();
 	int type () {return ComponentVarSlot; };
 	QVariant value (const QString &modifier=QString ()) { return (available-
>value (modifier)); };
+	QStringList getUiLabelPair () const;
 /** reimplemented to call updateLook (), in case enabledness changed */
 	void changed () { updateLook (); RKComponent::changed (); };
 	void updateLook ();
@@ -64,6 +65,7 @@ private:
 	bool add_mode;
 	bool multi;
 	bool updating;
+	QString label_string;
 
 /** the available objects (typically a copy of the property of the 
varselector) */
 	RKComponentPropertyAbstractList *source;
diff --git a/rkward/plugins/analysis/corr_matrix.js 
b/rkward/plugins/analysis/corr_matrix.js
index 5168561..de98d71 100644
--- a/rkward/plugins/analysis/corr_matrix.js
+++ b/rkward/plugins/analysis/corr_matrix.js
@@ -120,7 +120,7 @@ function calculate () {
 
 function printout () {
 	// TODO: Printing of method and use is a poor solution, esp. when 
translated. We should support getting the <radio>'s option labels, and print 
those, instead.
-	new Header (i18n ("Correlation Matrix")).add (i18n ("Method"), noquote 
(method)).add (i18n ("Exclusion"), noquote (use)).print ();
+	new Header (i18n ("Correlation Matrix")).add (i18n ("Method"), getString 
("method.label")).add (i18n ("Exclusion"), getString ("use.label")).print ();
 	echo ('rk.results (data.frame (result, check.names=FALSE), titles=c (' + 
i18n ("Coefficient") + ', names (data)))\n');
 	if (do_p) {
 		if (polyCorr) {
diff --git a/rkward/plugins/analysis/wilcoxon/wilcoxon_tests.js 
b/rkward/plugins/analysis/wilcoxon/wilcoxon_tests.js
index 278b8ab..630dec9 100644
--- a/rkward/plugins/analysis/wilcoxon/wilcoxon_tests.js
+++ b/rkward/plugins/analysis/wilcoxon/wilcoxon_tests.js
@@ -67,40 +67,25 @@ function calculate(){
 function printout(){
 	// printout the results
 
-
+	var y = getValue("y");
 	var confintChecked = getValue("confint.checked");
 	var correct = getValue("correct");
-	var exact = getValue("exact");
-	var paired = getValue("paired");
 	var mu = getValue("mu");
-	echo("rk.header (wcox.result$method,\n" + "\tparameters=list 
(\"Comparing\", paste (names, collapse=\" against \"),\n" + "\t\"H1\", 
rk.describe.alternative (wcox.result),\n" + "\t\"Continuity correction in 
normal approximation for p-value\", ");
-	if(correct) {
-		echo("\"TRUE\",\n");
-	} else {
-		echo("\"FALSE\",\n");
-	}
-	echo("\t\"Compute exact p-value\", \"" + exact + "\",\n");
-	echo("\t\"Paired test\", ");
-	if(paired) {
-		echo("\"TRUE\",\n");
-	} else {
-		echo("\"FALSE\",\n");
-	}
-	echo("\t\"mu\", \"" + mu + "\"))\n\n");
-	echo("rk.results (list (\n" + "\t\"Variable Names\"=names,\n" + 
"\t\"Statistic\"=wcox.result$statistic,\n" + "\t\"Location 
Shift\"=wcox.result$null.value,\n" + 
"\t\"Hypothesis\"=wcox.result$alternative,\n" + "\tp=wcox.result$p.value");
+	var header = new Header (noquote ('wcox.result$method')).add (i18n 
("Comparing"), noquote ('names[1]'));
+	if (y) header.add (i18nc ("compare against", "against"), noquote 
('names[2]'));
+	header.add ("H1", noquote ('rk.describe.alternative (wcox.result)'));
+	header.add (i18n ("Continuity correction in normal approximation for p-
value"), correct ? "TRUE" : "FALSE");
+	header.addFromUI ("exact");
+	if (y) header.addFromUI ("paired");
+	header.addFromUI ("mu");
+	header.print ();
+	echo("rk.results (list (\n\t" + i18n ("Variable Names") + "=names,\n\t" + 
i18nc ("a statistic indicator", "Statistic") + "=wcox.result$statistic,\n\t" + 
i18n ("Location Shift") + "=wcox.result$null.value,\n\t" + i18n ("Hypothesis") 
+ "=wcox.result$alternative,\n" + "\tp=wcox.result$p.value");
 	if(confintChecked) {
-		echo(",\n\t\"Confidence interval percent\"=(100 * 
attr(wcox.result$conf.int, \"conf.level\")),\n" + "\t\"Confidence interval of 
difference\"=wcox.result$conf.int,\n" + "\t\"Difference in 
Location\"=wcox.result$estimate");
+		echo(",\n\t" + i18n ("Confidence interval percent") + "=(100 * 
attr(wcox.result$conf.int, \"conf.level\")),\n\t" + i18n ("Confidence interval 
of difference") + "=wcox.result$conf.int,\n\t" + i18n ("Difference in 
Location") + "=wcox.result$estimate");
 	} else {}
 	echo("))\n");
-	//// save result object
-	// read in saveobject variables
-	var svbSvrsltst = getValue("svb_Svrsltst");
-	var svbSvrsltstActive = getValue("svb_Svrsltst.active");
-	var svbSvrsltstParent = getValue("svb_Svrsltst.parent");
-	// assign object to chosen environment
-	if(svbSvrsltstActive) {
-		echo("assign(\"" + svbSvrsltst + "\", wcox.result, envir=" + 
svbSvrsltstParent + ")\n");
-	} else {}
-
+	// save result, if requested
+	if(getBoolean("svb_Svrsltst.active")) {
+		echo("\n\t.GlobalEnv$" + getString("svb_Svrsltst") + " <- 
wcox.result\n");
+	}
 }
-
diff --git a/rkward/scriptbackends/common.js b/rkward/scriptbackends/common.js
index 3d97161..4f50373 100644
--- a/rkward/scriptbackends/common.js
+++ b/rkward/scriptbackends/common.js
@@ -93,7 +93,7 @@ comment = function (message, indentation) {
 	printIndented (indentation + "# ", message + "\n");
 }
 
-makeHeaderCode = function (title, parameters, level) {
+makeHeaderCode = function (title, parameters, level, indentation) {
 	if (typeof (indentation) == 'undefined') indentation = "";
 	echo (indentation + "rk.header (" + quote (title));
 	if (parameters.length) {
@@ -116,8 +116,11 @@ Header = function (title, level) {
 		this.parameters.push (caption, value);
 		return this;
 	}
+	this.addFromUI = function (elementid) {
+		this.parameters = this.parameters.concat (_RK_backend.getUiLabelPair 
(elementid));
+	}
 	this.print = function (indentation) {
-		makeHeaderCode (this.title, this.parameters, this.level, 
this.indentation);
+		makeHeaderCode (this.title, this.parameters, this.level, indentation);
 	}
 }
 
diff --git a/rkward/scriptbackends/qtscriptbackend.cpp 
b/rkward/scriptbackends/qtscriptbackend.cpp
index ff755b9..ab1eae1 100644
--- a/rkward/scriptbackends/qtscriptbackend.cpp
+++ b/rkward/scriptbackends/qtscriptbackend.cpp
@@ -2,7 +2,7 @@
                           qtscriptbackend  -  description
                              -------------------
     begin                : Mon Sep 28 2009
-    copyright            : (C) 2009, 2010, 2012 by Thomas Friedrichsmeier
+    copyright            : (C) 2009, 2010, 2012, 2014 by Thomas 
Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -231,6 +231,10 @@ QVariant QtScriptBackendThread::getBoolean (const QString 
&identifier) {
 	return getValue (identifier, RKStandardComponent::BooleanValue);
 }
 
+QVariant QtScriptBackendThread::getUiLabelPair (const QString &identifier) {
+	return getValue (identifier, RKStandardComponent::UiLabelPair);
+}
+
 bool QtScriptBackendThread::scriptError () {
 	RK_TRACE (PHP);
 
diff --git a/rkward/scriptbackends/qtscriptbackend.h 
b/rkward/scriptbackends/qtscriptbackend.h
index 91905b9..ca6e1ad 100644
--- a/rkward/scriptbackends/qtscriptbackend.h
+++ b/rkward/scriptbackends/qtscriptbackend.h
@@ -80,6 +80,7 @@ protected slots:
 	QVariant getList (const QString &identifier);
 	QVariant getString (const QString &identifier);
 	QVariant getBoolean (const QString &identifier);
+	QVariant getUiLabelPair (const QString &identifier);
 	bool includeFile (const QString &filename);
 protected:
 	void run ();




More information about the rkward-tracker mailing list