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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Mar 20 12:17:41 UTC 2007


Revision: 1655
          http://svn.sourceforge.net/rkward/?rev=1655&view=rev
Author:   tfry
Date:     2007-03-20 05:17:40 -0700 (Tue, 20 Mar 2007)

Log Message:
-----------
Use a common base for RKRadio and RKDropDown. Single options can be enabled disabled

Modified Paths:
--------------
    trunk/rkward/rkward/plugin/Makefile.am
    trunk/rkward/rkward/plugin/rkdropdown.cpp
    trunk/rkward/rkward/plugin/rkdropdown.h
    trunk/rkward/rkward/plugin/rkradio.cpp
    trunk/rkward/rkward/plugin/rkradio.h

Added Paths:
-----------
    trunk/rkward/rkward/plugin/rkabstractoptionselector.cpp
    trunk/rkward/rkward/plugin/rkabstractoptionselector.h

Modified: trunk/rkward/rkward/plugin/Makefile.am
===================================================================
--- trunk/rkward/rkward/plugin/Makefile.am	2007-03-20 00:22:54 UTC (rev 1654)
+++ trunk/rkward/rkward/plugin/Makefile.am	2007-03-20 12:17:40 UTC (rev 1655)
@@ -5,12 +5,12 @@
 	rkstandardcomponent.cpp rkvarselector.cpp rkvarslot.cpp rkformula.cpp rkradio.cpp \
 	rkcheckbox.cpp rkpluginspinbox.cpp rkinput.cpp rkpluginbrowser.cpp rktext.cpp \
 	rktabpage.cpp rkstandardcomponentgui.cpp rkdropdown.cpp rkcomponentcontext.cpp \
-	rkpreviewbox.cpp rkpluginsaveobject.cpp
+	rkpreviewbox.cpp rkpluginsaveobject.cpp rkabstractoptionselector.cpp
 
 noinst_HEADERS = rkcomponentmap.h rkcomponentproperties.h rkcomponent.h \
 	rkstandardcomponent.h rkvarselector.h rkvarslot.h rkformula.h rkradio.h \
 	rkcheckbox.h rkpluginspinbox.h rkinput.h rkpluginbrowser.h rktext.h \
 	rktabpage.h rkstandardcomponentgui.h rkdropdown.h rkcomponentcontext.h \
-	rkpreviewbox.h rkpluginsaveobject.h
+	rkpreviewbox.h rkpluginsaveobject.h rkabstractoptionselector.h
 
 

Added: trunk/rkward/rkward/plugin/rkabstractoptionselector.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkabstractoptionselector.cpp	                        (rev 0)
+++ trunk/rkward/rkward/plugin/rkabstractoptionselector.cpp	2007-03-20 12:17:40 UTC (rev 1655)
@@ -0,0 +1,189 @@
+/***************************************************************************
+                          rkabstractoptionselector  -  description
+                             -------------------
+    begin                : Tue Mar 20 2007
+    copyright            : (C) 2007 by Thomas Friedrichsmeier
+    email                : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "rkabstractoptionselector.h"
+
+#include <qdom.h>
+
+#include "../misc/xmlhelper.h"
+#include "../debug.h"
+
+RKAbstractOptionSelector::RKAbstractOptionSelector (RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
+	RK_TRACE (PLUGIN);
+
+	// create and register properties
+	addChild ("string", string = new RKComponentPropertyBase (this, false));
+	connect (string, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (propertyChanged (RKComponentPropertyBase *)));
+	addChild ("number", number = new RKComponentPropertyInt (this, true, -1));
+	connect (number, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (propertyChanged (RKComponentPropertyBase *)));
+}
+
+RKAbstractOptionSelector::~RKAbstractOptionSelector(){
+	RK_TRACE (PLUGIN);
+
+	for (OptionsMap::const_iterator it = options.begin(); it != options.end(); ++it) {
+		delete (it.data ());
+	}
+}
+
+void RKAbstractOptionSelector::addOptionsAndInit (const QDomElement &element) {
+	RK_TRACE (PLUGIN);
+
+	// get xml-helper
+	XMLHelper *xml = XMLHelper::getStaticHelper ();
+
+	// create all the options
+	XMLChildList option_elements = xml->getChildElements (element, "option", DL_ERROR);	
+	int selected = 0;
+	int i = 0;
+	for (XMLChildList::const_iterator it = option_elements.begin (); it != option_elements.end (); ++it) {
+		QString label = xml->getStringAttribute (*it, "label", QString::null, DL_ERROR);
+		QString value = xml->getStringAttribute (*it, "value", QString::null, DL_WARNING);
+		QString name = xml->getStringAttribute (*it, "id", QString::null, DL_INFO);
+
+		Option *opt = new Option;
+		opt->value = value;
+		opt->enabledness_prop = 0;
+
+		options.insert (i, opt);
+		if (!name.isNull ()) named_options.insert (name, opt);
+
+		addOptionToGUI (label, i);
+
+		if (xml->getBoolAttribute (*it, "checked", false, DL_INFO)) {
+			selected = i;
+		}
+
+		++i;
+	}
+
+	updating = false;
+	number->setIntValue (selected);		// will also take care of activating the correct item
+	number->setMin (0);
+	number->setMax (i-1);
+}
+
+RKComponentBase* RKAbstractOptionSelector::lookupComponent (const QString &identifier, QString *remainder) {
+	RK_TRACE (PLUGIN);
+
+	if (identifier.isEmpty ()) return this;
+
+	QString name = identifier.section (".", 0, 0);
+	if (named_options.contains (name)) {
+		Option *opt = named_options[name];
+
+		QString mod = identifier.section (".", 1);
+		if (mod != "enabled") {
+			RK_DO (qDebug ("options do not have property '%s'", mod.latin1()), PLUGIN, DL_DEBUG);
+			return this;
+		}
+
+		if (!(opt->enabledness_prop)) {		// requested for the first time
+			opt->enabledness_prop = new RKComponentPropertyBool (this, false);
+			connect (opt->enabledness_prop, SIGNAL (valueChanged(RKComponentPropertyBase*)), this, SLOT (ItemPropertyChanged(RKComponentPropertyBase*)));
+		}
+
+		return (opt->enabledness_prop);
+	}
+
+	return RKComponent::lookupComponent (identifier, remainder);
+}
+
+void RKAbstractOptionSelector::propertyChanged (RKComponentPropertyBase *property) {
+	RK_TRACE (PLUGIN);
+
+	if (updating) return;
+
+	int new_id = -1;
+	if (property == string) {
+		new_id = findOption (string->value ());
+	} else if (property == number) {
+		new_id = number->intValue ();
+	} else {
+		RK_ASSERT (false);
+	}
+
+	updating = true;
+	setItemInGUI (new_id);
+	itemSelected (new_id);		// slot not called automatically on programmed changes!
+	updating = false;
+
+	changed ();
+}
+
+void RKAbstractOptionSelector::ItemPropertyChanged (RKComponentPropertyBase *property) {
+	RK_TRACE (PLUGIN);
+
+	Option *opt = 0;
+	int id = -1;
+	for (OptionsMap::const_iterator it = options.begin(); it != options.end(); ++it) {
+		RK_ASSERT (it.data ());
+		if (it.data ()->enabledness_prop == property) {
+			opt = it.data ();
+			id = it.key ();
+			break;
+		}
+	}
+
+	if ((!opt) || (id < 0)) {
+		RK_ASSERT (false);
+		return;
+	}
+
+	RK_ASSERT (property->type () == RKComponent::PropertyBool);
+	bool enabled = static_cast<RKComponentPropertyBool*> (property)->boolValue ();
+
+	if (!enabled) {
+		if (id == number->intValue ()) {	// current item was disabled
+			int settable_opt = -1;
+			for (OptionsMap::const_iterator it = options.begin(); it != options.end(); ++it) {
+				RK_ASSERT (it.data ());
+
+				if ((!(it.data ()->enabledness_prop)) || (it.data ()->enabledness_prop->boolValue ())) {
+					settable_opt = it.key();
+					break;
+				}
+			}
+			if (settable_opt >= 0) itemSelected (settable_opt);
+			else RK_DO (qDebug ("No option left enabled. Disable the entire component, instead!"), PLUGIN, DL_ERROR);
+		}
+	}
+
+	setItemEnabledInGUI (id, enabled);
+}
+
+void RKAbstractOptionSelector::itemSelected (int id) {
+	RK_TRACE (PLUGIN);
+
+	Option *opt = options[id];
+	RK_ASSERT (opt);
+
+	string->setValue (opt->value);
+	number->setIntValue (id);
+}
+
+int RKAbstractOptionSelector::findOption (const QString &option_string) {
+	RK_TRACE (PLUGIN);
+
+	for (OptionsMap::const_iterator it = options.begin(); it != options.end(); ++it) {
+		RK_ASSERT (it.data ());
+		if (it.data ()->value == option_string) return (it.key ());
+	}
+	return -1;
+}
+
+#include "rkabstractoptionselector.moc"

Added: trunk/rkward/rkward/plugin/rkabstractoptionselector.h
===================================================================
--- trunk/rkward/rkward/plugin/rkabstractoptionselector.h	                        (rev 0)
+++ trunk/rkward/rkward/plugin/rkabstractoptionselector.h	2007-03-20 12:17:40 UTC (rev 1655)
@@ -0,0 +1,69 @@
+/***************************************************************************
+                          rkabstractoptionselector  -  description
+                             -------------------
+    begin                : Tue Mar 20 2007
+    copyright            : (C) 2007 by Thomas Friedrichsmeier
+    email                : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#ifndef RKABSTRACTOPTIONSELECTOR
+#define RKABSTRACTOPTIONSELECTOR
+
+#include "rkcomponent.h"
+#include "rkcomponentproperties.h"
+
+#include <qmap.h>
+
+class QComboBox;
+class QDomElement;
+
+/** Base class for option selection plugin widgets, like RKRadio and RKDropDown. This can not be used directly, due to pure virtual functions.
+ at author Thomas Friedrichsmeier
+*/
+class RKAbstractOptionSelector : public RKComponent {
+	Q_OBJECT
+public: 
+	RKAbstractOptionSelector (RKComponent *parent_component, QWidget *parent_widget);
+	~RKAbstractOptionSelector ();
+/** Find the option number with the corresponding string. If not found, returns -1
+ at param option_string the option string to search for
+ at returns the id (0, 1, 2...) of the corresponding option, or -1 if not found */
+	int findOption (const QString &option_string);
+	QString value (const QString &modifier) { return (string->value (modifier)); };
+/** reimplemented from RKComponent to add enabledness properties for the options, dynamically, if requested */
+	RKComponentBase* lookupComponent (const QString &identifier, QString *remainder);
+public slots:
+	void itemSelected (int id);
+	void propertyChanged (RKComponentPropertyBase *property);
+	void ItemPropertyChanged (RKComponentPropertyBase *property);
+protected:
+	virtual void setItemInGUI (int id) = 0;
+	virtual void addOptionToGUI (const QString &label, int id) = 0;
+	virtual void setItemEnabledInGUI (int id, bool enabled)= 0;
+	void addOptionsAndInit (const QDomElement &element);
+private:
+	RKComponentPropertyBase *string;
+	RKComponentPropertyInt *number;
+
+	struct Option {
+		QString value;
+		RKComponentPropertyBool *enabledness_prop;
+	};
+
+	bool updating;		// prevent recursion
+	typedef QMap<int, Option*> OptionsMap;
+	typedef QMap<QString, Option*> OptionsLookup;
+	OptionsMap options;
+	OptionsLookup named_options;
+};
+
+#endif

Modified: trunk/rkward/rkward/plugin/rkdropdown.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkdropdown.cpp	2007-03-20 00:22:54 UTC (rev 1654)
+++ trunk/rkward/rkward/plugin/rkdropdown.cpp	2007-03-20 12:17:40 UTC (rev 1655)
@@ -21,6 +21,7 @@
 #include <qlabel.h>
 #include <qlayout.h>
 #include <qcombobox.h>
+#include <qlistbox.h>
 
 #include <klocale.h>
 
@@ -28,15 +29,9 @@
 #include "../misc/xmlhelper.h"
 #include "../debug.h"
 
-RKDropDown::RKDropDown (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
+RKDropDown::RKDropDown (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKAbstractOptionSelector (parent_component, parent_widget) {
 	RK_TRACE (PLUGIN);
 
-	// create and register properties
-	addChild ("string", string = new RKComponentPropertyBase (this, false));
-	connect (string, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (propertyChanged (RKComponentPropertyBase *)));
-	addChild ("number", number = new RKComponentPropertyInt (this, true, -1));
-	connect (number, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (propertyChanged (RKComponentPropertyBase *)));
-
 	// get xml-helper
 	XMLHelper *xml = XMLHelper::getStaticHelper ();
 
@@ -48,26 +43,12 @@
 
 	// create ComboBox
 	box = new QComboBox (false, this);
-
-	// create all the options
-	XMLChildList option_elements = xml->getChildElements (element, "option", DL_ERROR);	
-	int selected = 0;
-	int i = 0;
-	for (XMLChildList::const_iterator it = option_elements.begin (); it != option_elements.end (); ++it) {
-		box->insertItem (xml->getStringAttribute (*it, "label", QString::null, DL_ERROR));
-		options.insert (i, xml->getStringAttribute (*it, "value", QString::null, DL_WARNING));
-
-		if (xml->getBoolAttribute (*it, "checked", false, DL_INFO)) {
-			selected = i;
-		}
-
-		++i;
+	if (!(box->listBox ())) {
+		// make sure the combo box uses a list box internally
+		box->setListBox (new QListBox (this));
 	}
 
-	updating = false;
-	number->setIntValue (selected);			// will also take care of activating the corret item
-	number->setMin (0);
-	number->setMax (i-1);
+	addOptionsAndInit (element);
 
 	vbox->addWidget (box);
 	connect (box, SIGNAL (activated (int)), this, SLOT (itemSelected (int)));
@@ -77,42 +58,25 @@
 	RK_TRACE (PLUGIN);
 }
 
-void RKDropDown::propertyChanged (RKComponentPropertyBase *property) {
+void RKDropDown::setItemInGUI (int id) {
 	RK_TRACE (PLUGIN);
 
-	if (updating) return;
-
-	int new_id = -1;
-	if (property == string) {
-		new_id = findOption (string->value ());
-	} else if (property == number) {
-		new_id = number->intValue ();
-	} else {
-		RK_ASSERT (false);
-	}
-
-	updating = true;
-	box->setCurrentItem (new_id);
-	itemSelected (new_id);		// slot not called automatically on programmed changes!
-	updating = false;
-
-	changed ();
+	box->setCurrentItem (id);
 }
 
-void RKDropDown::itemSelected (int id) {
+void RKDropDown::addOptionToGUI (const QString &label, int id) {
 	RK_TRACE (PLUGIN);
 
-	string->setValue (options[id]);
-	number->setIntValue (id);
+	box->insertItem (label, id);
 }
 
-int RKDropDown::findOption (const QString &option_string) {
+void RKDropDown::setItemEnabledInGUI (int id, bool enabled) {
 	RK_TRACE (PLUGIN);
 
-	for (OptionsMap::const_iterator it = options.begin(); it != options.end(); ++it) {
-		if (it.data () == option_string) return (it.key ());
-	}
-	return -1;
-}  
+	QListBoxItem *item = box->listBox ()->item (id);
+	RK_ASSERT (item);
 
+	item->setSelectable (enabled);
+}
+
 #include "rkdropdown.moc"

Modified: trunk/rkward/rkward/plugin/rkdropdown.h
===================================================================
--- trunk/rkward/rkward/plugin/rkdropdown.h	2007-03-20 00:22:54 UTC (rev 1654)
+++ trunk/rkward/rkward/plugin/rkdropdown.h	2007-03-20 12:17:40 UTC (rev 1655)
@@ -18,40 +18,26 @@
 #ifndef RKDROPDOWN_H
 #define RKDROPDOWN_H
 
-#include "rkcomponent.h"
-#include "rkcomponentproperties.h"
+#include "rkabstractoptionselector.h"
 
-#include <qmap.h>
-
 class QComboBox;
-class QDomElement;
 
 /** This RKPluginWidget provides a group of radio-buttons.
   *@author Thomas Friedrichsmeier
   */
 
-class RKDropDown : public RKComponent {
+class RKDropDown : public RKAbstractOptionSelector {
 	Q_OBJECT
 public: 
 	RKDropDown (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget);
 	~RKDropDown ();
 	int type () { return ComponentDropDown; };
-/** Find the option number with the corresponding string. If not found, returns -1
- at param option_string the option string to search for
- at returns the id (0, 1, 2...) of the corresponding option, or -1 if not found */
-	int findOption (const QString &option_string);
-	QString value (const QString &modifier) { return (string->value (modifier)); };
-public slots:
-	void itemSelected (int id);
-	void propertyChanged (RKComponentPropertyBase *property);
+protected:
+	void setItemInGUI (int id);
+	void addOptionToGUI (const QString &label, int id);
+	void setItemEnabledInGUI (int id, bool enabled);
 private:
-	RKComponentPropertyBase *string;
-	RKComponentPropertyInt *number;
-
-	bool updating;		// prevent recursion
 	QComboBox *box;
-	typedef QMap<int, QString> OptionsMap;
-	OptionsMap options;
 };
 
 #endif

Modified: trunk/rkward/rkward/plugin/rkradio.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkradio.cpp	2007-03-20 00:22:54 UTC (rev 1654)
+++ trunk/rkward/rkward/plugin/rkradio.cpp	2007-03-20 12:17:40 UTC (rev 1655)
@@ -20,7 +20,7 @@
 #include <qdom.h>
 #include <qlabel.h>
 #include <qlayout.h>
-#include <qbuttongroup.h>
+#include <qvbuttongroup.h>
 #include <qradiobutton.h>
 
 #include <klocale.h>
@@ -29,15 +29,9 @@
 #include "../misc/xmlhelper.h"
 #include "../debug.h"
 
-RKRadio::RKRadio (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
+RKRadio::RKRadio (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKAbstractOptionSelector (parent_component, parent_widget) {
 	RK_TRACE (PLUGIN);
 
-	// create and register properties
-	addChild ("string", string = new RKComponentPropertyBase (this, false));
-	connect (string, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (propertyChanged (RKComponentPropertyBase *)));
-	addChild ("number", number = new RKComponentPropertyInt (this, true, -1));
-	connect (number, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (propertyChanged (RKComponentPropertyBase *)));
-
 	// get xml-helper
 	XMLHelper *xml = XMLHelper::getStaticHelper ();
 
@@ -45,80 +39,42 @@
 	QVBoxLayout *vbox = new QVBoxLayout (this, RKGlobals::spacingHint ());
 
 	// create ButtonGroup
-	group = new QButtonGroup (xml->getStringAttribute (element, "label", i18n ("Select one:"), DL_INFO), this);
+	group = new QVButtonGroup (xml->getStringAttribute (element, "label", i18n ("Select one:"), DL_INFO), this);
 
-	// create internal layout for the buttons in the ButtonGroup
-	group->setColumnLayout (0, Qt::Vertical);
+	// adjust internal layout for the buttons in the ButtonGroup
+	RK_ASSERT (group->layout ());
 	group->layout()->setSpacing (RKGlobals::spacingHint ());
 	group->layout()->setMargin (RKGlobals::marginHint ());
-	QVBoxLayout *group_layout = new QVBoxLayout (group->layout(), RKGlobals::spacingHint ());
 
-	// create all the options
-	XMLChildList option_elements = xml->getChildElements (element, "option", DL_ERROR);	
-	int checked = 0;
-	int i = 0;
-	for (XMLChildList::const_iterator it = option_elements.begin (); it != option_elements.end (); ++it) {
-		QRadioButton *button = new QRadioButton (xml->getStringAttribute (*it, "label", QString::null, DL_ERROR), group);
-		options.insert (i, xml->getStringAttribute (*it, "value", QString::null, DL_WARNING));
-		group_layout->addWidget (button);
+	addOptionsAndInit (element);
 
-		if (xml->getBoolAttribute (*it, "checked", false, DL_INFO)) {
-			button->setChecked (true);
-			checked = i;
-		}
-
-		++i;
-	}
-
 	vbox->addWidget (group);
-	connect (group, SIGNAL (clicked (int)), this, SLOT (buttonClicked (int)));
-
-	updating = false;
-	number->setIntValue (checked);			// will also take care of checking the correct button
-	number->setMin (0);
-	number->setMax (i-1);
+	connect (group, SIGNAL (clicked (int)), this, SLOT (itemSelected (int)));
 }
 
 RKRadio::~RKRadio(){
 	RK_TRACE (PLUGIN);
 }
 
-void RKRadio::propertyChanged (RKComponentPropertyBase *property) {
+void RKRadio::setItemInGUI (int id) {
 	RK_TRACE (PLUGIN);
 
-	if (updating) return;
-
-	int new_id = -1;
-	if (property == string) {
-		new_id = findOption (string->value ());
-	} else if (property == number) {
-		new_id = number->intValue ();
-	} else {
-		RK_ASSERT (false);
-	}
-
-	updating = true;
-	group->setButton (new_id);
-	buttonClicked (new_id);		// unfortunately, this slot is not called when the option is changed programatically!
-	updating = false;
-
-	changed ();
+	group->setButton (id);
 }
 
-void RKRadio::buttonClicked (int id) {
+void RKRadio::addOptionToGUI (const QString &label, int id) {
 	RK_TRACE (PLUGIN);
 
-	string->setValue (options[id]);
-	number->setIntValue (id);
+	QRadioButton *button = new QRadioButton (label, group);
+	group->insert (button, id);
 }
 
-int RKRadio::findOption (const QString &option_string) {
+void RKRadio::setItemEnabledInGUI (int id, bool enabled) {
 	RK_TRACE (PLUGIN);
 
-	for (OptionsMap::const_iterator it = options.begin(); it != options.end(); ++it) {
-		if (it.data () == option_string) return (it.key ());
-	}
-	return -1;
-}  
+	QButton *button = group->find (id);
+	RK_ASSERT (button);
+	button->setEnabled (enabled);
+}
 
 #include "rkradio.moc"

Modified: trunk/rkward/rkward/plugin/rkradio.h
===================================================================
--- trunk/rkward/rkward/plugin/rkradio.h	2007-03-20 00:22:54 UTC (rev 1654)
+++ trunk/rkward/rkward/plugin/rkradio.h	2007-03-20 12:17:40 UTC (rev 1655)
@@ -18,41 +18,25 @@
 #ifndef RKRADIO_H
 #define RKRADIO_H
 
-#include "rkcomponent.h"
-#include "rkcomponentproperties.h"
+#include "rkabstractoptionselector.h"
 
-#include <qmap.h>
-
 class QButtonGroup;
-class QRadioButton;
-class QDomElement;
 
-/** This RKPluginWidget provides a group of radio-buttons.
-  *@author Thomas Friedrichsmeier
-  */
-
-class RKRadio : public RKComponent {
+/** This RKPluginWidget provides a group of radio-buttons for use in plugins.
+ at author Thomas Friedrichsmeier
+*/
+class RKRadio : public RKAbstractOptionSelector {
 	Q_OBJECT
 public: 
 	RKRadio (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget);
 	~RKRadio ();
 	int type () { return ComponentRadio; };
-/** Find the option number with the corresponding string. If not found, returns -1
- at param option_string the option string to search for
- at returns the id (0, 1, 2...) of the corresponding option, or -1 if not found */
-	int findOption (const QString &option_string);
-	QString value (const QString &modifier) { return (string->value (modifier)); };
-public slots:
-	void buttonClicked (int id);
-	void propertyChanged (RKComponentPropertyBase *property);
+protected:
+	void setItemInGUI (int id);
+	void addOptionToGUI (const QString &label, int id);
+	void setItemEnabledInGUI (int id, bool enabled);
 private:
-	RKComponentPropertyBase *string;
-	RKComponentPropertyInt *number;
-
-	bool updating;		// prevent recursion
 	QButtonGroup *group;
-	typedef QMap<int, QString> OptionsMap;
-	OptionsMap options;
 };
 
 #endif


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