[rkward-cvs] rkward/rkward/plugin rkcomponentproperties.cpp,1.4,1.5 rkcomponentproperties.h,1.4,1.5

Thomas Friedrichsmeier tfry at users.sourceforge.net
Wed Nov 30 22:08:41 UTC 2005


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

Modified Files:
	rkcomponentproperties.cpp rkcomponentproperties.h 
Log Message:
Some few more bits implemented

Index: rkcomponentproperties.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponentproperties.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** rkcomponentproperties.cpp	30 Nov 2005 15:22:16 -0000	1.4
--- rkcomponentproperties.cpp	30 Nov 2005 22:08:39 -0000	1.5
***************
*** 47,54 ****
--- 47,56 ----
  
  - 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?
  
  - Add something like RKComponentPropertySelect for a property that accepts one or more of a set of predefined strings (like e.g. for a radio-box)
+ 	- Maybe then, and in conjunction with sub-properties, the bool-property can be abstracted away (it would just be a select property, and an internal int-property could be used for bool purposes)?
  
  - Carefully check whether all API-elements are really needed once the implementation is complete
***************
*** 95,99 ****
  	connect (governor, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (governorValueChanged (RKComponentPropertyBase *)));
  	governor_modifier = modifier;
! 	// no need to reconcile any requirements, and the RKComponentPropertyBase does not have any requirements
  
  	// fetch current value
--- 97,101 ----
  	connect (governor, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (governorValueChanged (RKComponentPropertyBase *)));
  	governor_modifier = modifier;
! 	// no need to reconcile any requirements, as the RKComponentPropertyBase does not have any requirements
  
  	// fetch current value
***************
*** 551,553 ****
--- 553,723 ----
  }
  
+ ///////////////////////////////////////////////// RObjects ////////////////////////////////////////////////////////
+ 
+ RKComponentPropertyRObjects::RKComponentPropertyRObjects (QObject *parent, bool required) {
+ 	RK_TRACE (PLUGIN);
+ 
+ // no initial requirements
+ 	int dims = min_length = max_length = min_num_objects = min_num_objects_if_any = max_num_objects = -1;
+ }
+ 
+ RKComponentPropertyRObjects::~RKComponentPropertyRObjects () {
+ 	RK_TRACE (PLUGIN);
+ }
+ 
+ void RKComponentPropertyRObjects::setListLength (int min_num_objects, int min_num_objects_if_any, int max_num_objects) {
+ 	RK_TRACE (PLUGIN);
+ 
+ 	RKComponentPropertyRObjects::min_num_objects = min_num_objects;
+ 	RKComponentPropertyRObjects::min_num_objects_if_any = min_num_objects_if_any;
+ 	RKComponentPropertyRObjects::max_num_objects = max_num_objects;
+ 
+ 	validizeAll ();
+ }
+ 
+ bool RKComponentPropertyRObjects::addObjectValue (RObject *object) {
+ 	RK_TRACE (PLUGIN);
+ 
+ 	if (isObjectValid (object)) {
+ 		if (!object_list->contains (object)) {
+ 			object_list->append (object);
+ 			checkListLengthValid ();
+ 			emit (valueChanged (this));
+ 		}
+ 	}
+ }
+ 
+ void RKComponentPropertyRObjects::removeObjectValue (RObject *object) {
+ 	RK_TRACE (PLUGIN);
+ 
+ 	object_list->remove (object);
+ 	checkListLengthValid ();
+ 	emit (valueChanged (this));
+ }
+ 
+ void RKComponentPropertyRObjects::setClassFilter (const QStringList &classes) {
+ 	RK_TRACE (PLUGIN);
+ 
+ 	RKComponentPropertyRObjects::classes = classes;
+ 	validizeAll ();
+ }
+ 
+ void RKComponentPropertyRObjects::setTypeFilter (const QStringList &types) {
+ 	RK_TRACE (PLUGIN);
+ 
+ 	RKComponentPropertyRObjects::types = types;
+ 	validizeAll ();
+ }
+ 
+ void RKComponentPropertyRObjects::setDimensionFilter (int dimensionality, int min_length, int max_length) {
+ 	RK_TRACE (PLUGIN);
+ 
+ 	dims = dimensionality;
+ 	RKComponentPropertyRObjects::min_length = min_length;
+ 	RKComponentPropertyRObjects::max_length = max_length;
+ }
+ 
+ bool RKComponentPropertyRObjects::setObjectValue (RObject *object) {
+ 	RK_TRACE (PLUGIN);
+ 
+ 	object_list->clear ();
+ 	return (addObjectValue (object));
+ }
+ 
+ /** Check whether an object is valid for this property.
+ @returns false if the object does not qualify as a valid selection according to current settings (class/type/dimensions), true otherwise */
+ bool RKComponentPropertyRObjects::isObjectValid (RObject *object) {
+ 	RK_TRACE (PLUGIN);
+ 
+ 	// TODO
+ }
+ 
+ RObject *RKComponentPropertyRObjects::objectValue () {
+ 	RK_TRACE (PLUGIN);
+ 
+ 	return (object_list->first ());
+ }
+ 
+ QValueList<RObject *> RKComponentPropertyRObjects::objectList () {
+ 	RK_TRACE (PLUGIN);
+ 
+ 	return (object_list);
+ }
+ 
+ /** reimplemented from RKComponentPropertyBase. Modifier "label" returns label. Modifier "shortname" returns short name. Modifier QString::null returns full name. If no object is set, returns an empty string */
+ QString RKComponentPropertyRObjects::value (const QString &modifier) {
+ 	RK_TRACE (PLUGIN);
+ 
+ //TODO!
+ 	QString ret;
+ 	if (modifier.isEmpty ()) {
+ 	} else if (modifier == "shortname") {
+ 	} else if (modifier == "label") {
+ 	} else {
+ 		warnModifierNotRecognized (modifier);
+ 	}
+ 	return ret;
+ }
+ 
+ /** reimplemented from RKComponentPropertyBase to convert to RObject with current constraints
+ @returns 0 if no such object could be found or the object is invalid */
+ bool RKComponentPropertyRObjects::setValue (const QString &value) {
+ 	RK_TRACE (PLUGIN);
+ 
+ 
+ }
+ 
+ /** reimplemented from RKComponentPropertyBase to test whether conversion to RObject, is possible with current constraints */
+ bool RKComponentPropertyRObjects::isStringValid (const QString &value) {
+ 	RK_TRACE (PLUGIN);
+ 
+ 
+ }
+ 
+ /** reimplemented from RKComponentPropertyBase to actually reconcile requirements with other object properties */
+ void RKComponentPropertyRObjects::connectToGovernor (RKComponentPropertyBase *governor, const QString &modifier, bool reconcile_requirements) {
+ 	RK_TRACE (PLUGIN);
+ 
+ 
+ }
+ 
+ /** reimplemented from RKComponentPropertyBase to use special handling for object properties */
+ void RKComponentPropertyRObjects::governorValueChanged (RKComponentPropertyBase *property) {
+ 	RK_TRACE (PLUGIN);
+ 
+ 
+ }
+ 
+ /** to be connected to RKModificationTracker::objectRemoved (). This is so we get notified if the object currently selected is removed */
+ void RKComponentPropertyRObjects::objectRemoved (RObject *object) {
+ 	RK_TRACE (PLUGIN);
+ 
+ 
+ }
+ 
+ /** to be connected to RKModificationTracker::objectPropertiesChanged (). This is so we get notified if the object currently selected is changed */
+ void RKComponentPropertyRObjects::objectPropertiesChanged (RObject *object) {
+ 	RK_TRACE (PLUGIN);
+ 
+ 
+ }
+ 
+ void RKComponentPropertyRObjects::validizeAll () {
+ 	RK_TRACE (PLUGIN);
+ 
+ 
+ }
+ 
+ /*
+ 	QValueList<RObject *> object_list;
+ 	int dims;
+ 	int min_length;
+ 	int max_length;
+ 	int min_num_objects;
+ 	int min_num_objects_if_any;
+ 	int max_num_objects;
+ 	QStringList classes;
+ 	QStringList types;
+ }; */
+ 
  #include "rkcomponentproperties.moc"

Index: rkcomponentproperties.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponentproperties.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** rkcomponentproperties.h	30 Nov 2005 15:22:16 -0000	1.4
--- rkcomponentproperties.h	30 Nov 2005 22:08:39 -0000	1.5
***************
*** 209,222 ****
  };
  
! ///////////////////////////////////////////////// RObject ////////////////////////////////////////////////////////
  class RObject;
  #include <qstringlist.h>
  #include <qvaluelist.h>
  
! /** special type of RKComponentProperty, that prepresents an RObject
! //TODO: this property should auto-connect to RKModificationTracker, to be safe when the object gets deleted/changed */
  class RKComponentPropertyRObjects : public RKComponentPropertyBase {
  	Q_OBJECT
  public:
  /** how many objects can this property hold? Use default values (-1) to remove constraints
  @param min_num_objects Minimum number of objects for this property to be valid
--- 209,225 ----
  };
  
! ///////////////////////////////////////////////// RObjects ////////////////////////////////////////////////////////
  class RObject;
  #include <qstringlist.h>
  #include <qvaluelist.h>
  
! /** special type of RKComponentProperty, that prepresents one or more RObject (s) */
  class RKComponentPropertyRObjects : public RKComponentPropertyBase {
  	Q_OBJECT
  public:
+ /** constructor */
+ 	RKComponentPropertyRObjects (QObject *parent, bool required);
+ /** destructor */
+ 	~RKComponentPropertyRObjects ();
  /** how many objects can this property hold? Use default values (-1) to remove constraints
  @param min_num_objects Minimum number of objects for this property to be valid
***************
*** 237,241 ****
  @param max_length Maximum length of first dimension. -1 will accept objects of all lengths */
  	void setDimensionFilter (int dimensionality=-1, int min_length=-1, int max_length=-1);
! /** Directly set an RObject.
  @returns false if the object does not qualify as a valid selection according to current settings (class/type/dimensions), true otherwise */
  	bool setObjectValue (RObject *object);
--- 240,244 ----
  @param max_length Maximum length of first dimension. -1 will accept objects of all lengths */
  	void setDimensionFilter (int dimensionality=-1, int min_length=-1, int max_length=-1);
! /** Directly set an RObject. Warning: This sets the list to contain only exactly this one item. Generally you do not want to use this, unless your list is in single mode. Use addObjectValue () instead, if the property can hold more than one object
  @returns false if the object does not qualify as a valid selection according to current settings (class/type/dimensions), true otherwise */
  	bool setObjectValue (RObject *object);
***************
*** 246,258 ****
  @returns 0 if no valid object is selected */
  	RObject *objectValue ();
! /** Get current list of objects.
  @returns an empty list if no valid object is selected */
  	QValueList<RObject *> objectList ();
  /** reimplemented from RKComponentPropertyBase. Modifier "label" returns label. Modifier "shortname" returns short name. Modifier QString::null returns full name. If no object is set, returns an empty string */
  	QString value (const QString &modifier=QString::null);
  /** reimplemented from RKComponentPropertyBase to convert to RObject with current constraints
! @returns 0 if no such object could be found or the object is invalid */
  	bool setValue (const QString &value);
! /** reimplemented from RKComponentPropertyBase to test whether conversion to RObject, is possible with current constraints */
  	bool isStringValid (const QString &value);
  /** RTTI */
--- 249,263 ----
  @returns 0 if no valid object is selected */
  	RObject *objectValue ();
! /** Get current list of objects. Do not modify this list! It is the very same list, the property uses internally!
  @returns an empty list if no valid object is selected */
  	QValueList<RObject *> objectList ();
+ /** set separator (used to concatenate object names/labels, etc. if more than one object is selected) */
+ 	void setSeparator (const QString &sep) { separator = sep; emit (valueChanged (this)); };
  /** reimplemented from RKComponentPropertyBase. Modifier "label" returns label. Modifier "shortname" returns short name. Modifier QString::null returns full name. If no object is set, returns an empty string */
  	QString value (const QString &modifier=QString::null);
  /** reimplemented from RKComponentPropertyBase to convert to RObject with current constraints
! @returns false if no such object(s) could be found or the object(s) are invalid */
  	bool setValue (const QString &value);
! /** reimplemented from RKComponentPropertyBase to test whether conversion to RObject is possible with current constraints */
  	bool isStringValid (const QString &value);
  /** RTTI */
***************
*** 267,271 ****
  /** to be connected to RKModificationTracker::objectPropertiesChanged (). This is so we get notified if the object currently selected is changed */
  	void objectPropertiesChanged (RObject *object);
! protected:
  	QValueList<RObject *> object_list;
  	int dims;
--- 272,280 ----
  /** to be connected to RKModificationTracker::objectPropertiesChanged (). This is so we get notified if the object currently selected is changed */
  	void objectPropertiesChanged (RObject *object);
! private:
! /** check all objects currently in the list for validity. Remove invalid objects. Determine validity state depending on how many (valid) objects remain in the list. If the list was changed during validation, a valueChanged () signal is emitted */
! 	void validizeAll ();
! /** simple helper function: Check whether the number of objects currently selected (and only that!), and set the valid state accordingly */
! 	void checkListLengthValid ();
  	QValueList<RObject *> object_list;
  	int dims;
***************
*** 277,280 ****
--- 286,290 ----
  	QStringList classes;
  	QStringList types;
+ 	QString separator;
  };
  





More information about the rkward-tracker mailing list