[rkward-cvs] rkward/rkward/plugin Makefile.am,1.9,1.10 rkcomponent.h,1.6,1.7 rkcomponentproperties.cpp,1.11,1.12 rkformula.h,1.6,1.7 rkradio.cpp,1.7,1.8 rkradio.h,1.4,1.5 rkstandardcomponent.cpp,1.8,1.9 rkvarselector.h,1.8,1.9

Thomas Friedrichsmeier tfry at users.sourceforge.net
Fri Mar 17 00:02:33 UTC 2006


Update of /cvsroot/rkward/rkward/rkward/plugin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13942/plugin

Modified Files:
	Makefile.am rkcomponent.h rkcomponentproperties.cpp 
	rkformula.h rkradio.cpp rkradio.h rkstandardcomponent.cpp 
	rkvarselector.h 
Log Message:
Moved over RKRadio

Index: rkcomponent.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponent.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** rkcomponent.h	15 Mar 2006 20:31:28 -0000	1.6
--- rkcomponent.h	17 Mar 2006 00:02:27 -0000	1.7
***************
*** 43,46 ****
--- 43,48 ----
  		ComponentVarSelector = 2003,
  		ComponentVarSlot = 2003,
+ 		ComponentFormula = 2004,
+ 		ComponentRadio = 2005,
  		ComponentUser = 3000	/**< for user expansion */
  	};

Index: rkvarselector.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkvarselector.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** rkvarselector.h	15 Mar 2006 18:09:22 -0000	1.8
--- rkvarselector.h	17 Mar 2006 00:02:27 -0000	1.9
***************
*** 19,26 ****
  #define RKVARSELECTOR_H
  
! #include "rkstandardcomponent.h"
  #include "rkcomponentproperties.h"
  
  class RKObjectListView;
  
  /** This is an especially important RK-plugin-widget. It provides a list of variables
--- 19,27 ----
  #define RKVARSELECTOR_H
  
! #include "rkcomponent.h"
  #include "rkcomponentproperties.h"
  
  class RKObjectListView;
+ class QDomElement;
  
  /** This is an especially important RK-plugin-widget. It provides a list of variables
***************
*** 37,42 ****
     Q_OBJECT
  public: 
! 	RKVarSelector(const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget);
! 	~RKVarSelector();
  	int type () { return ComponentVarSelector; };
  public slots:
--- 38,43 ----
     Q_OBJECT
  public: 
! 	RKVarSelector (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget);
! 	~RKVarSelector ();
  	int type () { return ComponentVarSelector; };
  public slots:

Index: rkradio.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkradio.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** rkradio.cpp	2 Oct 2005 17:19:02 -0000	1.7
--- rkradio.cpp	17 Mar 2006 00:02:27 -0000	1.8
***************
*** 3,7 ****
                               -------------------
      begin                : Thu Nov 7 2002
!     copyright            : (C) 2002 by Thomas Friedrichsmeier
      email                : tfry at users.sourceforge.net
   ***************************************************************************/
--- 3,7 ----
                               -------------------
      begin                : Thu Nov 7 2002
!     copyright            : (C) 2002, 2006 by Thomas Friedrichsmeier
      email                : tfry at users.sourceforge.net
   ***************************************************************************/
***************
*** 24,38 ****
  #include <qradiobutton.h>
  
  #include "../rkglobals.h"
  #include "../debug.h"
  
! RKRadio::RKRadio(const QDomElement &element, QWidget *parent, RKPlugin *plugin) : RKPluginWidget (element, parent, plugin) {
  	RK_TRACE (PLUGIN);
  	QVBoxLayout *vbox = new QVBoxLayout (this, RKGlobals::spacingHint ());
  
  	// create label
! 	label = new QLabel (element.attribute ("label", "Select one:"), this);
  	vbox->addWidget (label);
- 	depend = element.attribute ("depend", QString::null);
  
  	// create ButtonGroup
--- 24,51 ----
  #include <qradiobutton.h>
  
+ #include <klocale.h>
+ 
  #include "../rkglobals.h"
+ #include "../misc/xmlhelper.h"
  #include "../debug.h"
  
! RKRadio::RKRadio (const QDomElement &element, 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 *)));
+ 
+ 	// get xml-helper
+ 	XMLHelper *xml = XMLHelper::getStaticHelper ();
+ 
+ 	// create layout
  	QVBoxLayout *vbox = new QVBoxLayout (this, RKGlobals::spacingHint ());
  
  	// create label
! 	QLabel *label = new QLabel (xml->getStringAttribute (element, "label", i18n ("Select one:"), DL_INFO), this);
  	vbox->addWidget (label);
  
  	// create ButtonGroup
***************
*** 46,71 ****
  
  	// create all the options
! 	QDomNodeList children = element.elementsByTagName("option");
! 	bool checked_one = false;	
! 	for (unsigned int i=0; i < children.count (); i++) {
! 		QDomElement child = children.item (i).toElement ();
! 
! 		QRadioButton *button = new QRadioButton (child.attribute ("label"), group);
! 		options.insert (button, child.attribute ("value"));
  		group_layout->addWidget (button);
  
! 		if (child.attribute ("checked") == "true") {
  			button->setChecked (true);
! 			checked_one = true;
  		}
  	}
! 	// if none was set to checked, check the first
! 	if (!checked_one) {
! 		group->setButton (0);
! 	}
  
  	connect (group, SIGNAL (clicked (int)), this, SLOT (buttonClicked (int)));
  
! 	vbox->addWidget (group);
  }
  
--- 59,85 ----
  
  	// 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);
  
! 		if (xml->getBoolAttribute (*it, "checked", false, DL_INFO)) {
  			button->setChecked (true);
! 			checked = i;
  		}
+ 
+ 		++i;
  	}
! 	number->setIntValue (checked);			// will also take care of checking the correct button
! 	number->setMin (0);
! 	number->setMax (i-1);
  
+ 	vbox->addWidget (group);
  	connect (group, SIGNAL (clicked (int)), this, SLOT (buttonClicked (int)));
  
! 	updating = false;
  }
  
***************
*** 74,140 ****
  }
  
! QString RKRadio::value (const QString &) {
  	RK_TRACE (PLUGIN);
- 	OptionsMap::Iterator it;
- 	for (it = options.begin(); it != options.end(); ++it) {
- 		if (it.key()->isChecked ()) {
- 			return (it.data ());
- 		}
- 	}
  
! 	return QString::null;
! }
  
! void RKRadio::buttonClicked (int) {
! 	RK_TRACE (PLUGIN);
! 	emit (changed ());
  }
  
! void RKRadio::setEnabled(bool checked){
  	RK_TRACE (PLUGIN);
-   group->setEnabled(checked);
-   label->setEnabled(checked);
-   }
- 
  
! void RKRadio::slotActive(){
! 	RK_TRACE (PLUGIN);
! bool isOk = group->isEnabled();
! group->setEnabled(! isOk) ;
! label->setEnabled(! isOk) ;
  }
  
! void RKRadio::slotActive(bool isOk){
  	RK_TRACE (PLUGIN);
- group->setEnabled(isOk) ;
- label->setEnabled(isOk) ;
- }
  
! QRadioButton * RKRadio::findLabel (QString lab) {
! 	RK_TRACE (PLUGIN);
!   QRadioButton * sol = 0 ;
!   OptionsMap::iterator findlab;
!       for (findlab = options.begin(); findlab != options.end(); ++findlab) {
!         if (findlab != options.end ()  ) { 
! //          qDebug ("looking  : %s", findlab.data().latin1 ()) ;
!         if ( findlab.data() == lab) { return findlab.key() ;};
!           };
!         };
!    return  sol ;
  }  
  
- bool RKRadio::isOk(QString val) {
- 	RK_TRACE (PLUGIN);
-   QString sol ;
-   OptionsMap::Iterator it;
- 	for (it = options.begin(); it != options.end(); ++it) {
- 		if (it.key()->isChecked ()) {
-          sol   = it.data() ;
- 		};
-     };
-     if (sol == val) return true ;
-     else return false;
- 
-  }
- 
  #include "rkradio.moc"
--- 88,125 ----
  }
  
! void RKRadio::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;
! 	group->setButton (new_id);
! 	updating = false;
  }
  
! void RKRadio::buttonClicked (int id) {
  	RK_TRACE (PLUGIN);
  
! 	string->setValue (options[id]);
! 	number->setIntValue (id);
  }
  
! int RKRadio::findOption (const QString &option_string) {
  	RK_TRACE (PLUGIN);
  
! 	for (OptionsMap::const_iterator it = options.begin(); it != options.end(); ++it) {
! 		if (it.data () == option_string) return (it.key ());
! 	}
! 	return -1;
  }  
  
  #include "rkradio.moc"

Index: rkformula.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkformula.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** rkformula.h	16 Mar 2006 22:31:08 -0000	1.6
--- rkformula.h	17 Mar 2006 00:02:27 -0000	1.7
***************
*** 93,96 ****
--- 93,99 ----
  
  	bool isSatisfied ();
+ 
+ /** RTTI */
+ 	int type () { return ComponentFormula; };
  };
  

Index: Makefile.am
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/Makefile.am,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Makefile.am	16 Mar 2006 22:31:08 -0000	1.9
--- Makefile.am	17 Mar 2006 00:02:27 -0000	1.10
***************
*** 3,15 ****
  noinst_LIBRARIES =  libplugin.a
  libplugin_a_SOURCES = rkcomponentmap.cpp rkcomponentproperties.cpp rkcomponent.cpp \
! 	rkstandardcomponent.cpp rkvarselector.cpp rkvarslot.cpp rkformula.cpp
  # rkcheckbox.cpp rkplugin.cpp \
! #	rkpluginhandle.cpp rkpluginspinbox.cpp rkpluginwidget.cpp rkradio.cpp rktext.cpp \
  #	 rkinput.cpp rknote.cpp \
  #	rkpluginbrowser.cpp 
  noinst_HEADERS = rkcomponentmap.h rkcomponentproperties.h rkcomponent.h \
! 	rkstandardcomponent.h rkvarselector.h rkvarslot.h rkformula.h
  # rkcheckbox.h rkplugin.h rkpluginhandle.h \
! #	rkpluginspinbox.h rkpluginwidget.h rkradio.h rktext.h  \
  #	rkpluginbrowser.h rkinput.h rknote.h 
  
--- 3,15 ----
  noinst_LIBRARIES =  libplugin.a
  libplugin_a_SOURCES = rkcomponentmap.cpp rkcomponentproperties.cpp rkcomponent.cpp \
! 	rkstandardcomponent.cpp rkvarselector.cpp rkvarslot.cpp rkformula.cpp rkradio.cpp
  # rkcheckbox.cpp rkplugin.cpp \
! #	rkpluginhandle.cpp rkpluginspinbox.cpp rkpluginwidget.cpp rktext.cpp \
  #	 rkinput.cpp rknote.cpp \
  #	rkpluginbrowser.cpp 
  noinst_HEADERS = rkcomponentmap.h rkcomponentproperties.h rkcomponent.h \
! 	rkstandardcomponent.h rkvarselector.h rkvarslot.h rkformula.h rkradio.h
  # rkcheckbox.h rkplugin.h rkpluginhandle.h \
! #	rkpluginspinbox.h rkpluginwidget.h rktext.h  \
  #	rkpluginbrowser.h rkinput.h rknote.h 
  

Index: rkstandardcomponent.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkstandardcomponent.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** rkstandardcomponent.cpp	16 Mar 2006 22:31:08 -0000	1.8
--- rkstandardcomponent.cpp	17 Mar 2006 00:02:27 -0000	1.9
***************
*** 54,59 ****
  #include "rkvarslot.h"
  #include "rkformula.h"
- /*#include "rktext.h"
  #include "rkradio.h"
  #include "rkcheckbox.h"
  #include "rkpluginspinbox.h"
--- 54,59 ----
  #include "rkvarslot.h"
  #include "rkformula.h"
  #include "rkradio.h"
+ /*#include "rktext.h"
  #include "rkcheckbox.h"
  #include "rkpluginspinbox.h"
***************
*** 203,209 ****
  			addConnection (id, "dependent", xml->getStringAttribute (e, "dependent", "#noid#", DL_INFO), "available", false, e);
  			addConnection (id, "fixed_factors", xml->getStringAttribute (e, "fixed_factors", "#noid#", DL_INFO), "available", false, e);
! /*		} else if (e.tagName () == "radio") {
! 			widget = new RKRadio (e, parent_component, parent_widget);
! 		} else if (e.tagName () == "checkbox") {
  			widget = new RKCheckBox (e, parent_component, parent_widget);
  		} else if (e.tagName () == "spinbox") {
--- 203,209 ----
  			addConnection (id, "dependent", xml->getStringAttribute (e, "dependent", "#noid#", DL_INFO), "available", false, e);
  			addConnection (id, "fixed_factors", xml->getStringAttribute (e, "fixed_factors", "#noid#", DL_INFO), "available", false, e);
! 		} else if (e.tagName () == "radio") {
! 			widget = new RKRadio (e, component (), parent_widget);
! /*		} else if (e.tagName () == "checkbox") {
  			widget = new RKCheckBox (e, parent_component, parent_widget);
  		} else if (e.tagName () == "spinbox") {

Index: rkcomponentproperties.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponentproperties.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** rkcomponentproperties.cpp	15 Mar 2006 20:31:28 -0000	1.11
--- rkcomponentproperties.cpp	17 Mar 2006 00:02:27 -0000	1.12
***************
*** 256,260 ****
  	validator->setBottom (lower);
  	if (default_value < lower) {
! 		RK_DO (qDebug ("default value in integer property is lower than lower boundary"), PLUGIN, DL_WARNING);
  		default_value = lower;
  	}
--- 256,260 ----
  	validator->setBottom (lower);
  	if (default_value < lower) {
! 		RK_DO (qDebug ("default value in integer property is lower than lower boundary"), PLUGIN, DL_DEBUG);	// actually this is ok. In this case the default is simply "invalid"
  		default_value = lower;
  	}
***************
*** 269,273 ****
  	validator->setTop (upper);
  	if (default_value > upper) {
! 		RK_DO (qDebug ("default value in integer property is larger than upper boundary"), PLUGIN, DL_WARNING);
  		default_value = upper;
  	}
--- 269,273 ----
  	validator->setTop (upper);
  	if (default_value > upper) {
! 		RK_DO (qDebug ("default value in integer property is larger than upper boundary"), PLUGIN, DL_DEBUG);	// see above
  		default_value = upper;
  	}
***************
*** 952,956 ****
  	RK_TRACE (PLUGIN);
  
! 	if (max_num_objects && (object_list.count () >= max_num_objects)) return true;
  	return false;
  }
--- 952,957 ----
  	RK_TRACE (PLUGIN);
  
! 	int len = object_list.count ();
! 	if (max_num_objects && (len >= max_num_objects)) return true;
  	return false;
  }

Index: rkradio.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkradio.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** rkradio.h	26 Mar 2005 10:32:17 -0000	1.4
--- rkradio.h	17 Mar 2006 00:02:27 -0000	1.5
***************
*** 3,7 ****
                               -------------------
      begin                : Thu Nov 7 2002
!     copyright            : (C) 2002 by Thomas Friedrichsmeier
      email                : tfry at users.sourceforge.net
   ***************************************************************************/
--- 3,7 ----
                               -------------------
      begin                : Thu Nov 7 2002
!     copyright            : (C) 2002, 2006 by Thomas Friedrichsmeier
      email                : tfry at users.sourceforge.net
   ***************************************************************************/
***************
*** 19,23 ****
  #define RKRADIO_H
  
! #include "rkpluginwidget.h"
  
  #include <qmap.h>
--- 19,24 ----
  #define RKRADIO_H
  
! #include "rkcomponent.h"
! #include "rkcomponentproperties.h"
  
  #include <qmap.h>
***************
*** 25,32 ****
  class QButtonGroup;
  class QRadioButton;
! class QLabel ;
! 
! #define RADIO_WIDGET 666 // comme la radio pirate de caen
! 
  
  /** This RKPluginWidget provides a group of radio-buttons.
--- 26,30 ----
  class QButtonGroup;
  class QRadioButton;
! class QDomElement;
  
  /** This RKPluginWidget provides a group of radio-buttons.
***************
*** 34,60 ****
    */
  
! class RKRadio : public RKPluginWidget  {
  	Q_OBJECT
  public: 
! 	RKRadio(const QDomElement &element, QWidget *parent, RKPlugin *plugin);
! 	~RKRadio();
!   void setEnabled(bool);
! 	int type() {return RADIO_WIDGET ; };
!   QRadioButton * findLabel(QString);
!   bool isOk (QString) ;
!   public slots:
  	void buttonClicked (int id);
!   void slotActive();
!   void slotActive(bool);
!   
  private:
  	QButtonGroup *group;
! 	typedef QMap<QRadioButton *, QString> OptionsMap;
  	OptionsMap options;
-   QString depend;
-   QLabel * label ;
- protected:
- /** Returns the value of the currently selected option. */
- 	QString value (const QString &modifier);
  };
  
--- 32,56 ----
    */
  
! class RKRadio : public RKComponent {
  	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
! @param option_string the option string to search for
! @returns the id (0, 1, 2...) of the corresponding option, or -1 if not found */
! 	int findOption (const QString &option_string);
! public slots:
  	void buttonClicked (int id);
! 	void propertyChanged (RKComponentPropertyBase *property);
  private:
+ 	RKComponentPropertyBase *string;
+ 	RKComponentPropertyInt *number;
+ 
+ 	bool updating;		// prevent recursion
  	QButtonGroup *group;
! 	typedef QMap<int, QString> OptionsMap;
  	OptionsMap options;
  };
  





More information about the rkward-tracker mailing list