[rkward-cvs] rkward/rkward/plugin Makefile.am,1.11,1.12 rkcomponent.cpp,1.7,1.8 rkcomponent.h,1.8,1.9 rkcomponentproperties.cpp,1.13,1.14 rkcomponentproperties.h,1.14,1.15 rkpluginspinbox.cpp,1.8,1.9 rkpluginspinbox.h,1.4,1.5 rkstandardcomponent.cpp,1.10,1.11

Thomas Friedrichsmeier tfry at users.sourceforge.net
Fri Mar 17 15:18:40 UTC 2006


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

Modified Files:
	Makefile.am rkcomponent.cpp rkcomponent.h 
	rkcomponentproperties.cpp rkcomponentproperties.h 
	rkpluginspinbox.cpp rkpluginspinbox.h rkstandardcomponent.cpp 
Log Message:
Moved over RKPluginSpinBox

Index: rkcomponent.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponent.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** rkcomponent.h	17 Mar 2006 13:27:18 -0000	1.8
--- rkcomponent.h	17 Mar 2006 15:18:38 -0000	1.9
***************
*** 124,129 ****
  	RKComponent *_parent;
  private:
- /** Internal function to use when satisfaction state changes. Also notifies the parent, if applicable */
- 	void setSatisfied (bool satisfied);
  	void setReady (bool ready);
  };
--- 124,127 ----

Index: rkpluginspinbox.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkpluginspinbox.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** rkpluginspinbox.h	26 Mar 2005 10:32:17 -0000	1.4
--- rkpluginspinbox.h	17 Mar 2006 15:18:38 -0000	1.5
***************
*** 3,7 ****
                               -------------------
      begin                : Wed Aug 11 2004
!     copyright            : (C) 2004 by Thomas Friedrichsmeier
      email                : tfry at users.sourceforge.net
   ***************************************************************************/
--- 3,7 ----
                               -------------------
      begin                : Wed Aug 11 2004
!     copyright            : (C) 2004, 2006 by Thomas Friedrichsmeier
      email                : tfry at users.sourceforge.net
   ***************************************************************************/
***************
*** 17,50 ****
  #ifndef RKPLUGINSPINBOX_H
  #define RKPLUGINSPINBOX_H
- #define SPINBOX_WIDGET 3 // comme ma note d'interro
  
! #include <rkpluginwidget.h>
  
  class RKSpinBox;
! class QLabel ;
  
! /**
  @author Thomas Friedrichsmeier
  */
! class RKPluginSpinBox : public RKPluginWidget {
  	Q_OBJECT
  public:
! 	RKPluginSpinBox(const QDomElement &element, QWidget *parent, RKPlugin *plugin);
  
! 	~RKPluginSpinBox();
  	QString value (const QString &modifier);
!   	QLabel * label ;
!   	int type() {return SPINBOX_WIDGET ;} ;
!   	void setEnabled(bool);
! 	void adjust(int, int);
  public slots:
  	void valueChanged (int);
!   	void slotActive();
!   	void slotActive(bool);
!   
  private:
  	RKSpinBox *spinbox;
!   	QString depend;
! 	QString size;
  };
  
--- 17,50 ----
  #ifndef RKPLUGINSPINBOX_H
  #define RKPLUGINSPINBOX_H
  
! #include "rkcomponent.h"
! 
! #include "rkcomponentproperties.h"
  
  class RKSpinBox;
! class QDomElement;
  
! /** RKComponent for numeric input represented as a spinbox
! TODO: rename file and class to RKComponentSpinBox
  @author Thomas Friedrichsmeier
  */
! class RKPluginSpinBox : public RKComponent {
  	Q_OBJECT
  public:
! 	RKPluginSpinBox (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget);
  
! 	~RKPluginSpinBox ();
  	QString value (const QString &modifier);
! 	int type () { return ComponentSpinBox; };
! 
! 	RKComponentPropertyInt *intvalue;
! 	RKComponentPropertyDouble *realvalue;
  public slots:
  	void valueChanged (int);
! 	void valueChanged (RKComponentPropertyBase *property);
  private:
  	RKSpinBox *spinbox;
! 	bool intmode;
! 	bool updating;
  };
  

Index: rkcomponent.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponent.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** rkcomponent.cpp	17 Mar 2006 13:27:18 -0000	1.7
--- rkcomponent.cpp	17 Mar 2006 15:18:38 -0000	1.8
***************
*** 112,122 ****
  }
  
- /** also notifies the parent, if applicable */
- void RKComponent::setSatisfied (bool satisfied) {
- 	RK_TRACE (PLUGIN);
- 
- 	// TODO
- }
- 
  void RKComponent::setReady (bool ready) {
  	RK_TRACE (PLUGIN);
--- 112,115 ----

Index: rkpluginspinbox.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkpluginspinbox.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** rkpluginspinbox.cpp	2 Oct 2005 17:19:02 -0000	1.8
--- rkpluginspinbox.cpp	17 Mar 2006 15:18:38 -0000	1.9
***************
*** 3,7 ****
                               -------------------
      begin                : Wed Aug 11 2004
!     copyright            : (C) 2004 by Thomas Friedrichsmeier
      email                : tfry at users.sourceforge.net
   ***************************************************************************/
--- 3,7 ----
                               -------------------
      begin                : Wed Aug 11 2004
!     copyright            : (C) 2004, 2006 by Thomas Friedrichsmeier
      email                : tfry at users.sourceforge.net
   ***************************************************************************/
***************
*** 19,50 ****
  #include <qlayout.h>
  #include <qlabel.h>
! #include <qdom.h>
  
  #include "../misc/rkspinbox.h"
  #include "../rkglobals.h"
  #include "../debug.h"
- #include "rkplugin.h"
  
! RKPluginSpinBox::RKPluginSpinBox (const QDomElement &element, QWidget *parent, RKPlugin *plugin) : RKPluginWidget(element, parent, plugin) {
! 		RK_TRACE (PLUGIN);
  	QVBoxLayout *vbox = new QVBoxLayout (this, RKGlobals::spacingHint ());
! 	
! 	label = new QLabel (element.attribute ("label", "Enter value:"), this);
  	vbox->addWidget (label);
- 	depend = element.attribute ("depend", QString::null);
  
  	spinbox = new RKSpinBox (this);
! 	if (element.attribute ("type") != "integer") {
! 		spinbox->setRealMode (element.attribute ("min", "0").toFloat (), element.attribute ("max", "1").toFloat (), element.attribute ("initial", "0").toFloat (), element.attribute ("default_precision", "2").toInt (), element.attribute ("max_precision", "4").toInt ());
  	} else {
! 		spinbox->setIntMode (element.attribute ("min", "0").toInt (), element.attribute ("max", "100").toInt (), element.attribute ("initial", "0").toInt ());
  	}
  	connect (spinbox, SIGNAL (valueChanged (int)), this, SLOT (valueChanged (int)));
  	vbox->addWidget (spinbox);
! 	size = element.attribute ("size", "small");
! 	if (size=="small"){
! 	spinbox->setMaximumWidth(100);
! 	spinbox->setMinimumWidth(100);
  	}
  }
  
--- 19,88 ----
  #include <qlayout.h>
  #include <qlabel.h>
! 
! #include <klocale.h>
  
  #include "../misc/rkspinbox.h"
+ #include "../misc/xmlhelper.h"
  #include "../rkglobals.h"
  #include "../debug.h"
  
! RKPluginSpinBox::RKPluginSpinBox (const QDomElement &element, RKComponent *parent_component, QWidget *parent_widget) : RKComponent (parent_component, parent_widget) {
! 	RK_TRACE (PLUGIN);
! 	// get xml-helper
! 	XMLHelper *xml = XMLHelper::getStaticHelper ();
! 
! 	// first question: int or real
! 	intmode = (xml->getMultiChoiceAttribute (element, "type", "integer;real", 0, DL_INFO) == 0);
! 
! 	// create and add properties
! 	addChild ("int", intvalue = new RKComponentPropertyInt (this, intmode, 0));
! 	addChild ("real", realvalue = new RKComponentPropertyDouble (this, !intmode, 0));
! 
! 	// layout and label
  	QVBoxLayout *vbox = new QVBoxLayout (this, RKGlobals::spacingHint ());
! 	QLabel *label = new QLabel (xml->getStringAttribute (element, "label", i18n ("Enter value:"), DL_WARNING), this);
  	vbox->addWidget (label);
  
+ 	// create spinbox and read settings
  	spinbox = new RKSpinBox (this);
! 	if (!intmode) {
! 		double min = xml->getDoubleAttribute (element, "min", FLT_MIN, DL_INFO);
! 		double max = xml->getDoubleAttribute (element, "max", FLT_MAX, DL_INFO);
! 		double initial = xml->getDoubleAttribute (element, "initial", min, DL_INFO);
! 		int default_precision = xml->getIntAttribute (element, "default_precision", 2, DL_INFO);
! 		int max_precision = xml->getIntAttribute (element, "max_precision", 4, DL_INFO);
! 
! 		spinbox->setRealMode (min, max, initial, default_precision, max_precision);
! 
! 		realvalue->setMin (min);
! 		realvalue->setMax (max);
! 		realvalue->setPrecision (max_precision);
! 		intmode = false;
  	} else {
! 		int min = xml->getIntAttribute (element, "min", INT_MIN, DL_INFO);
! 		int max = xml->getIntAttribute (element, "max", INT_MAX, DL_INFO);
! 		int initial = xml->getIntAttribute (element, "initial", min, DL_INFO);
! 
! 		spinbox->setIntMode (min, max, initial);
! 
! 		intvalue->setMin (min);
! 		intvalue->setMax (max);
! 		intmode = true;
  	}
+ 
+ 	// connect
  	connect (spinbox, SIGNAL (valueChanged (int)), this, SLOT (valueChanged (int)));
+ 	connect (intvalue, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (valueChanged (RKComponentPropertyBase *)));
+ 	connect (realvalue, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (valueChanged (RKComponentPropertyBase *)));
+ 	updating = false;
+ 
+ 	// finish layout
  	vbox->addWidget (spinbox);
! 	if (xml->getStringAttribute (element, "size", "normal", DL_INFO) == "small") {
! 		spinbox->setFixedWidth (100);
  	}
+ 
+ 	// initialize
+ 	valueChanged (1);
  }
  
***************
*** 53,87 ****
  }
  
! void RKPluginSpinBox::setEnabled(bool checked){
  	RK_TRACE (PLUGIN);
-   spinbox->setEnabled(checked);
-   label->setEnabled(checked);
-   }
  
! QString RKPluginSpinBox::value (const QString &) {
! 	RK_TRACE (PLUGIN);
! 	return (spinbox->text ());
  }
  
  void RKPluginSpinBox::valueChanged (int) {
  	RK_TRACE (PLUGIN);
- 	plugin ()->changed ();
- }
  
! void RKPluginSpinBox::slotActive(){
! 	RK_TRACE (PLUGIN);
! bool isOk = spinbox->isEnabled();
! spinbox->setEnabled(! isOk) ;
! label->setEnabled(! isOk);
! }
  
! void RKPluginSpinBox::slotActive(bool isOk){
! 	RK_TRACE (PLUGIN);
! spinbox->setEnabled( isOk) ;
! label->setEnabled(isOk);
! }
! void RKPluginSpinBox::adjust(int longueur, int largeur){
! 	RK_TRACE (PLUGIN);
! spinbox->resize(longueur, largeur);
  }
  
--- 91,128 ----
  }
  
! void RKPluginSpinBox::valueChanged (RKComponentPropertyBase *property) {
  	RK_TRACE (PLUGIN);
  
! 	if (updating) return;
! 	updating = true;
! 
! 	// sync the two properties
! 	if (property == intvalue) {
! 		realvalue->setDoubleValue ((double) intvalue->intValue ());
! 	} else {
! 		intvalue->setIntValue ((int) realvalue->doubleValue ());
! 	}
! 
! 	// update GUI
! 	if (intmode) {
! 		spinbox->setValue (intvalue->intValue ());
! 	} else {
! 		spinbox->setRealValue (realvalue->doubleValue ());
! 	}
! 
! 	updating = false;
  }
  
  void RKPluginSpinBox::valueChanged (int) {
  	RK_TRACE (PLUGIN);
  
! 	if (intmode) {
! 		intvalue->setIntValue (spinbox->value ());
! 	} else {
! 		// this may be ugly, but we have to set via text to make sure we get the exact same display
! 		realvalue->setValue (spinbox->text ());
! 	}
  
! 	changed ();
  }
  

Index: Makefile.am
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/Makefile.am,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Makefile.am	17 Mar 2006 13:27:18 -0000	1.11
--- Makefile.am	17 Mar 2006 15:18:38 -0000	1.12
***************
*** 4,17 ****
  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 
  
--- 4,17 ----
  libplugin_a_SOURCES = rkcomponentmap.cpp rkcomponentproperties.cpp rkcomponent.cpp \
  	rkstandardcomponent.cpp rkvarselector.cpp rkvarslot.cpp rkformula.cpp rkradio.cpp \
! 	rkcheckbox.cpp rkpluginspinbox.cpp
  # rkplugin.cpp \
! #	rkpluginhandle.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 rkpluginspinbox.h
  # rkplugin.h rkpluginhandle.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.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** rkstandardcomponent.cpp	17 Mar 2006 13:27:18 -0000	1.10
--- rkstandardcomponent.cpp	17 Mar 2006 15:18:38 -0000	1.11
***************
*** 56,61 ****
  #include "rkradio.h"
  #include "rkcheckbox.h"
- /*#include "rktext.h"
  #include "rkpluginspinbox.h"
  #include "rknote.h"
  #include "rkinput.h"
--- 56,61 ----
  #include "rkradio.h"
  #include "rkcheckbox.h"
  #include "rkpluginspinbox.h"
+ /*#include "rktext.h"
  #include "rknote.h"
  #include "rkinput.h"
***************
*** 207,215 ****
  		} else if (e.tagName () == "checkbox") {
  			widget = new RKCheckBox (e, component (), parent_widget);
! /*		} else if (e.tagName () == "spinbox") {
  			widget = new RKPluginSpinBox (e, component (), parent_widget);
  //		} else if (e.tagName () == "note") {		//TODO: remove corresponding class
  //			widget = new RKNote (e, parent_widget, this);
! 		} else if (e.tagName () == "browser") {
  			widget = new RKPluginBrowser (e, component (), parent_widget);
  		} else if (e.tagName () == "input") {
--- 207,215 ----
  		} else if (e.tagName () == "checkbox") {
  			widget = new RKCheckBox (e, component (), parent_widget);
! 		} else if (e.tagName () == "spinbox") {
  			widget = new RKPluginSpinBox (e, component (), parent_widget);
  //		} else if (e.tagName () == "note") {		//TODO: remove corresponding class
  //			widget = new RKNote (e, parent_widget, this);
! /*		} else if (e.tagName () == "browser") {
  			widget = new RKPluginBrowser (e, component (), parent_widget);
  		} else if (e.tagName () == "input") {

Index: rkcomponentproperties.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponentproperties.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** rkcomponentproperties.cpp	17 Mar 2006 13:27:18 -0000	1.13
--- rkcomponentproperties.cpp	17 Mar 2006 15:18:38 -0000	1.14
***************
*** 46,52 ****
  the specialized properties (e.g. RKComponentPropertyInt::intValue () always returns something valid). Does this really make sense?
  
- - Maybe some properties could hold sub-properties of a different type to make flexibly and meaningfully connecting different properties easier (e.g. an RKComponentPropertyRObject might make dimensionality of the selected object available as an RKComponentPropertyInt). This might be a future extension to consider. Properties containing sub-properties would parse the modifier to pass down requests, if applicable.
- 	- make sure sub-properties are never connected to governors (only vice versa)
- 
  - Maybe Int and Double properties could be joined to a numeric property?
  
--- 46,49 ----
***************
*** 385,388 ****
--- 382,386 ----
  	validator = new QDoubleValidator (this);		// accepts all ints initially
  	RKComponentPropertyDouble::default_value = default_value;
+ 	precision = 6;
  	internalSetValue (default_value);
  }
***************
*** 526,531 ****
  
  void RKComponentPropertyDouble::internalSetValue (double new_value) {
  	current_value = new_value;
! 	_value = QString::number (current_value);
  	is_valid = ((new_value >= validator->bottom ()) && (new_value <= validator->top ()));
  	if (!is_valid) current_value = default_value;
--- 524,531 ----
  
  void RKComponentPropertyDouble::internalSetValue (double new_value) {
+ 	RK_TRACE (PLUGIN);
+ 
  	current_value = new_value;
! 	_value = QString::number (current_value, 'g', precision);
  	is_valid = ((new_value >= validator->bottom ()) && (new_value <= validator->top ()));
  	if (!is_valid) current_value = default_value;
***************
*** 533,536 ****
--- 533,538 ----
  
  void RKComponentPropertyDouble::internalSetValue (QString new_value) {
+ 	RK_TRACE (PLUGIN);
+ 
  	current_value = new_value.toDouble (&is_valid);
  	if (!is_valid) {

Index: rkcomponentproperties.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponentproperties.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** rkcomponentproperties.h	17 Mar 2006 13:27:18 -0000	1.14
--- rkcomponentproperties.h	17 Mar 2006 15:18:38 -0000	1.15
***************
*** 170,173 ****
--- 170,175 ----
  /** set upper boundary. Default parameter will effectively remove the boundary. You should call this *before* connecting to any other properties, so limits can be reconciled */
  	void setMax (double upper=FLT_MAX);
+ /** set text precision (default = 6) */
+ 	void setPrecision (int digits) { precision = digits; };
  /** return current min value */
  	double minValue ();
***************
*** 197,200 ****
--- 199,203 ----
  /** we could do without the validator, and create the logic on our own. Using Qt's validator, however, a) saves some typing b) allows to provide a validator object in use in lineedits, etc. (see getValidator ()) */
  	QDoubleValidator *validator;
+ 	int precision;
  };
  





More information about the rkward-tracker mailing list