[rkward-cvs] rkward/rkward/plugin rkcheckbox.cpp,1.10,1.11 rkcomponent.cpp,1.11,1.12 rkcomponent.h,1.12,1.13 rkcomponentmap.cpp,1.7,1.8 rkcomponentmap.h,1.6,1.7 rkcomponentproperties.cpp,1.18,1.19 rkcomponentproperties.h,1.17,1.18 rkstandardcomponent.cpp,1.20,1.21 rkstandardcomponent.h,1.11,1.12

Thomas Friedrichsmeier tfry at users.sourceforge.net
Mon Mar 20 19:33:58 UTC 2006


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

Modified Files:
	rkcheckbox.cpp rkcomponent.cpp rkcomponent.h 
	rkcomponentmap.cpp rkcomponentmap.h rkcomponentproperties.cpp 
	rkcomponentproperties.h rkstandardcomponent.cpp 
	rkstandardcomponent.h 
Log Message:
Basic embedding or RKComponents works

Index: rkcomponent.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponent.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** rkcomponent.h	20 Mar 2006 12:41:43 -0000	1.12
--- rkcomponent.h	20 Mar 2006 19:33:55 -0000	1.13
***************
*** 111,114 ****
--- 111,116 ----
  specialized properties */
  	void propertyValueChanged (RKComponentPropertyBase *property);
+ /** If you add an outside property to a component, connect it to this slot, so the component will update itself. used in RKComponentBuilder::parseLogic () */
+ 	void outsideValueChanged (RKComponentPropertyBase *) { changed (); }
  public:
  /** standard property controlling visibility */
***************
*** 131,134 ****
--- 133,139 ----
  /** Is the component "ready"? I.e. it is up to date according to current settings. Does not imply it is also satisfied. Default implementation always returns true. */
  	virtual bool isReady () { return true; };
+ protected slots:
+ /** if a child component self-destructs, it should remove itself from its parent *before* destructing. Don't use in a regular destructor. Call only if the child dies unexpectedly */
+ 	void removeFromParent ();
  protected:
  	RKComponentPropertyBool *visibility_property;

Index: rkstandardcomponent.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkstandardcomponent.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** rkstandardcomponent.h	20 Mar 2006 14:03:43 -0000	1.11
--- rkstandardcomponent.h	20 Mar 2006 19:33:55 -0000	1.12
***************
*** 59,64 ****
  /** RTTI */
  	int type () { return ComponentStandard; };
- /** reimplemented from QWidget to hide the gui if applicable */
- 	void hide ();
  public slots:
  /** this gets called by the script-backend, when it's done. Might enable the
--- 59,62 ----
***************
*** 71,74 ****
--- 69,74 ----
  /** get a value for the backend */
  	void getValue (const QString &id);
+ /** reimplemented from QWidget to hide the gui if applicable */
+ 	void hide ();
  private:
  /** The property holding the generated code. Note that this member is tightly controlled by the ScriptBackend */

Index: rkcomponentmap.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponentmap.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** rkcomponentmap.h	15 Mar 2006 18:09:22 -0000	1.6
--- rkcomponentmap.h	20 Mar 2006 19:33:55 -0000	1.7
***************
*** 26,38 ****
  #include <qstring.h>
  
  /** This simple class keeps the most basic information about a component in RKWard. Most work is done in RKComponentMap.
- Note that standard components (i.e. components which can act as regular top-level dialogs) have an additional counterpart in RKPluginHandle
- 
- TODO: no! RKPluginHandle should inherit from RKComponentHandle!
- 
  
  @author Thomas Friedrichsmeier
  */
- 
  class RKComponentHandle {
  public:
--- 26,35 ----
  #include <qstring.h>
  
+ class RKComponent;
+ class QWidget;
  /** This simple class keeps the most basic information about a component in RKWard. Most work is done in RKComponentMap.
  
  @author Thomas Friedrichsmeier
  */
  class RKComponentHandle {
  public:
***************
*** 46,49 ****
--- 43,48 ----
  
  	static RKComponentHandle* createComponentHandle (const QString &filename, RKComponentType type, const QString& id, const QString& label);
+ /** invoke the component (standalone or embedded) */
+ 	virtual RKComponent *invoke (RKComponent *parent_component, QWidget *parent_widget) = 0;
  private:
  /** The filename of the description file for this component */
***************
*** 112,115 ****
--- 111,116 ----
  
  	~RKStandardComponentHandle ();
+ 
+ 	RKComponent *invoke (RKComponent *parent_component, QWidget *parent_widget);
  public slots:
  /** Slot called, when the menu-item for this widget is selected. Responsible for creating the GUI. */

Index: rkcomponentmap.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponentmap.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** rkcomponentmap.cpp	15 Mar 2006 18:09:22 -0000	1.7
--- rkcomponentmap.cpp	20 Mar 2006 19:33:55 -0000	1.8
***************
*** 222,228 ****
  }
  
  void RKStandardComponentHandle::activated () {
  	RK_TRACE (PLUGIN);
! 	new RKStandardComponent (0, 0, getFilename ());
  }
  
--- 222,235 ----
  }
  
+ RKComponent *RKStandardComponentHandle::invoke (RKComponent *parent_component, QWidget *parent_widget) {
+ 	RK_TRACE (PLUGIN);
+ 
+ 	return (new RKStandardComponent (parent_component, parent_widget, getFilename ()));
+ }
+ 
  void RKStandardComponentHandle::activated () {
  	RK_TRACE (PLUGIN);
! 
! 	invoke (0, 0);
  }
  

Index: rkcomponent.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponent.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** rkcomponent.cpp	20 Mar 2006 12:41:43 -0000	1.11
--- rkcomponent.cpp	20 Mar 2006 19:33:55 -0000	1.12
***************
*** 171,173 ****
--- 171,191 ----
  }
  
+ void RKComponent::removeFromParent () {
+ 	RK_TRACE (PLUGIN);
+ 
+ 	if (!parentComponent ()) return;
+ 	for (QDictIterator<RKComponentBase> it (parentComponent ()->child_map); it.current (); ++it) {
+ 		if (it.current () == this) {
+ 			QString key = it.currentKey ();
+ 	// unfortunately, several items might hvae the same key, and there seems to be no way to selectively remove the current item only.
+ 	// however, this function should only ever be called in cases of emergency and to prevent crashes. So we make extra sure to remove the child,
+ 	// even if we remove a little more than neccessary along the way.
+ 			while (parentComponent ()->child_map.remove (key));
+ 			return;
+ 		}
+ 	}
+ 
+ 	RK_ASSERT (false);
+ }
+ 
  #include "rkcomponent.moc"

Index: rkstandardcomponent.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkstandardcomponent.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** rkstandardcomponent.cpp	20 Mar 2006 14:03:43 -0000	1.20
--- rkstandardcomponent.cpp	20 Mar 2006 19:33:55 -0000	1.21
***************
*** 68,71 ****
--- 68,72 ----
  	if (xml->highestError () >= DL_ERROR) {
  		KMessageBox::error (this, i18n ("There has been an error while trying to parse the description of this pluign ('%1'). Please refer to stdout for details.").arg (filename), i18n("Could not create plugin"));
+ 		removeFromParent ();
  		deleteLater ();
  		return;
***************
*** 84,87 ****
--- 85,89 ----
  //	connect (backend, SIGNAL (requestRVector (const QString&)), this, SLOT (getRVector (const QString&)));
  	connect (backend, SIGNAL (haveError ()), this, SLOT (hide ()));
+ 	connect (backend, SIGNAL (haveError ()), this, SLOT (removeFromParent ()));
  	connect (backend, SIGNAL (haveError ()), this, SLOT (deleteLater ()));
  	if (!backend->initialize (dummy, code)) return;
***************
*** 107,111 ****
  			}
  		} else {
! 			QDomElement gui_element = xml->getChildElement (doc_element, "dialog", DL_WARNING);
  			if (gui_element.isNull ()) {
  				xml->displayError (&doc_element, "Cannot embed a wizard into a dialog, and no dialog definition available", DL_ERROR);
--- 109,113 ----
  			}
  		} else {
! 			gui_element = xml->getChildElement (doc_element, "dialog", DL_WARNING);
  			if (gui_element.isNull ()) {
  				xml->displayError (&doc_element, "Cannot embed a wizard into a dialog, and no dialog definition available", DL_ERROR);
***************
*** 339,342 ****
--- 341,345 ----
  /////////////////////////////////////// RKComponentBuilder /////////////////////////////////////////
  
+ #include "rkcomponentmap.h"
  
  RKComponentBuilder::RKComponentBuilder (RKStandardComponent *parent_component) {
***************
*** 422,425 ****
--- 425,436 ----
  		} else if (e.tagName () == "text") {
  			widget = new RKText (e, component (), parent_widget);
+ 		} else if (e.tagName () == "embed") {
+ 			QString component_id = xml->getStringAttribute (e, "component", QString::null, DL_ERROR);
+ 			RKComponentHandle *handle = RKGlobals::componentMap ()->getComponentHandle (component_id);
+ 			if (handle) {
+ 				widget = handle->invoke (component (), parent_widget);
+ 			} else {
+ 				xml->displayError (&e, QString ("Could not embed component '%1'. Not found").arg (component_id), DL_ERROR);
+ 			}
  		} else {
  			xml->displayError (&e, QString ("Invalid tagname '%1'").arg (e.tagName ()), DL_ERROR);
***************
*** 432,439 ****
  }
  
- /**
-  * 
-  * @param element 
-  */
  void RKComponentBuilder::parseLogic (const QDomElement &element) {
  	RK_TRACE (PLUGIN);
--- 443,446 ----
***************
*** 450,453 ****
--- 457,469 ----
  	}
  
+ 	// find outside elements
+ 	children = xml->getChildElements (element, "outside", DL_INFO);
+ 	for (it = children.constBegin (); it != children.constEnd (); ++it) {
+ 		RKComponentPropertyBase *prop = new RKComponentPropertyBase (component (), xml->getBoolAttribute (*it, "required", false, DL_INFO));
+ 		component ()->addChild (xml->getStringAttribute (*it, "id", "#noid#", DL_WARNING), prop);
+ 		component ()->connect (prop, SIGNAL (valueChanged (RKComponentPropertyBase *)), component (), SLOT (outsideValueChanged (RKComponentPropertyBase *)));
+ 		// TODO add more options
+ 	}
+ 
  	// find convert elements
  	children = xml->getChildElements (element, "convert", DL_INFO);
***************
*** 459,463 ****
  		convert->setMode ((RKComponentPropertyConvert::ConvertMode) mode);
  		convert->setSources (sources);
! 		if (mode == RKComponentPropertyConvert::Equals) {
  			convert->setStandard (xml->getStringAttribute (*it, "standard", QString::null, DL_WARNING));
  		} else if (mode == RKComponentPropertyConvert::Range) {
--- 475,479 ----
  		convert->setMode ((RKComponentPropertyConvert::ConvertMode) mode);
  		convert->setSources (sources);
! 		if ((mode == RKComponentPropertyConvert::Equals) || (mode == RKComponentPropertyConvert::NotEquals)) {
  			convert->setStandard (xml->getStringAttribute (*it, "standard", QString::null, DL_WARNING));
  		} else if (mode == RKComponentPropertyConvert::Range) {

Index: rkcomponentproperties.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponentproperties.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** rkcomponentproperties.cpp	20 Mar 2006 14:03:43 -0000	1.18
--- rkcomponentproperties.cpp	20 Mar 2006 19:33:55 -0000	1.19
***************
*** 972,976 ****
--- 972,986 ----
  }
  
+ QString RKComponentPropertyCode::value (const QString &modifier) {
+ 	RK_TRACE (PLUGIN);
  
+ 	if (modifier == "preprocess") return preprocess ();
+ 	if (modifier == "calculate") return calculate ();
+ 	if (modifier == "printout") return printout ();
+ 	if (modifier == "cleanup") return cleanup ();
+ 	if (!modifier.isEmpty ()) warnModifierNotRecognized (modifier);
+ 
+ 	return (preprocess () + calculate () + printout () + cleanup ());
+ }
  
  /////////////////////////////////////////// Convert ////////////////////////////////////////////////
***************
*** 1050,1053 ****
--- 1060,1069 ----
  				}
  				break;
+ 			} case NotEquals: {
+ 				if (source.property->value (source.modifier) == standard) {
+ 					setBoolValue (false);
+ 					return;
+ 				}
+ 				break;
  			} case Range: {
  				double val;
***************
*** 1093,1096 ****
--- 1109,1113 ----
  	switch (_mode) {
  		case Equals:
+ 		case NotEquals:
  		case Range:
  		case And: { setBoolValue (true); break; }

Index: rkcomponentproperties.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponentproperties.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** rkcomponentproperties.h	20 Mar 2006 12:41:43 -0000	1.17
--- rkcomponentproperties.h	20 Mar 2006 19:33:55 -0000	1.18
***************
*** 312,316 ****
  	QString cleanup () { return cleanup_code; };
  
! 	QString value () { return (preprocess () + calculate () + printout () + cleanup ()); };
  
  /** set the preprocess code.
--- 312,316 ----
  	QString cleanup () { return cleanup_code; };
  
! 	QString value (const QString &modifier=QString::null);
  
  /** set the preprocess code.
***************
*** 349,355 ****
  	enum ConvertMode {
  		Equals = 0,		/** < Check, whether some property has exactly the given string value (see setSources (), setStandard ()) */
! 		Range = 1,		/** < Check, whether some *numeric* property is in the given range (see setSources (), setRange ()) */
! 		And = 2,			/** < Check, whether several *boolean* properties are all true at once (see setSources ()) */
! 		Or = 3				/** < Check, whether one of several *boolean* properties is true (see setSources ()) */
  	};
  
--- 349,356 ----
  	enum ConvertMode {
  		Equals = 0,		/** < Check, whether some property has exactly the given string value (see setSources (), setStandard ()) */
! 		NotEquals = 1,		/** < Opposite of ConvertMode::Equals */
! 		Range = 2,		/** < Check, whether some *numeric* property is in the given range (see setSources (), setRange ()) */
! 		And = 3,			/** < Check, whether several *boolean* properties are all true at once (see setSources ()) */
! 		Or = 4				/** < Check, whether one of several *boolean* properties is true (see setSources ()) */
  	};
  
***************
*** 369,373 ****
  
  /** string represenation of the options in ConvertMode. For use in XMLHelper::getMultiChoiceAttribute */
! 	static QString convertModeOptionString () { return ("equals;range;and;or;require"); };
  public slots:
  /** unfortuntely, as the parent component likely does not know about us, we have to notify it manually of any changes. That's done from this slot */
--- 370,374 ----
  
  /** string represenation of the options in ConvertMode. For use in XMLHelper::getMultiChoiceAttribute */
! 	static QString convertModeOptionString () { return ("equals;notequals;range;and;or;require"); };
  public slots:
  /** unfortuntely, as the parent component likely does not know about us, we have to notify it manually of any changes. That's done from this slot */

Index: rkcheckbox.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcheckbox.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** rkcheckbox.cpp	20 Mar 2006 12:41:43 -0000	1.10
--- rkcheckbox.cpp	20 Mar 2006 19:33:55 -0000	1.11
***************
*** 31,35 ****
  
  	// create and add property
! 	addChild ("state", state = new RKComponentPropertyBool (this, true, xml->getBoolAttribute (element, "checked", false, DL_INFO), xml->getStringAttribute (element, "value", "1", DL_WARNING), xml->getStringAttribute (element, "value_unchecked", QString::null, DL_INFO)));
  	connect (state, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (changedState (RKComponentPropertyBase *)));
  
--- 31,35 ----
  
  	// create and add property
! 	addChild ("state", state = new RKComponentPropertyBool (this, true, xml->getBoolAttribute (element, "checked", false, DL_INFO), xml->getStringAttribute (element, "value", "1", DL_INFO), xml->getStringAttribute (element, "value_unchecked", QString::null, DL_INFO)));
  	connect (state, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (changedState (RKComponentPropertyBase *)));
  
***************
*** 38,41 ****
--- 38,42 ----
  	checkbox = new QCheckBox (xml->getStringAttribute (element, "label", QString::null, DL_WARNING), this);
  	vbox->addWidget (checkbox);
+ 	checkbox->setChecked (xml->getBoolAttribute (element, "checked", false, DL_INFO));
  	connect (checkbox, SIGNAL (stateChanged (int)), this, SLOT (changedState (int)));
  





More information about the rkward-tracker mailing list