[rkward-cvs] rkward/rkward/plugin rkcomponentproperties.cpp,1.7,1.8

Thomas Friedrichsmeier tfry at users.sourceforge.net
Fri Dec 9 18:18:16 UTC 2005


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

Modified Files:
	rkcomponentproperties.cpp 
Log Message:
Done with basic (untested) implementation of RKComponentProperties.

Index: rkcomponentproperties.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponentproperties.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** rkcomponentproperties.cpp	9 Dec 2005 13:28:57 -0000	1.7
--- rkcomponentproperties.cpp	9 Dec 2005 18:18:13 -0000	1.8
***************
*** 641,704 ****
  }
  
- /** 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: this function could be made a lot more straightforward, if RObject would contain more information (via virtual functions). See TODO in RObject.
- 
  	// first check dimensionality
! 	if (dims >= 0) {
! 		if (object->isVariable ()) {
! 			RKVariable *var = static_cast<RKVariable *> (object);
! 			if (var->getLength ()) {
! 				if (dims != 1) return false;
! 			} else {
! 				if (dims != 0) return false;
! 			}
! 		} else if (object->isContainer ()) {
! 			RContainerObject *cont = static_cast<RContainerObject *> (object);
! 			if (cont->numDimensions () != dims) {
! 				return false;
! 			}
! 		} else {
! 			return false;
! 		}
! 	}
! 	if ((min_length > 0) || (max_length >= 0)) {
! 		// determine object length
! 		int olength;
! 		if (object->isVariable ()) {
! 			olength = static_cast<RKVariable *> (object)->getLength ();
! 		} else if (object->isContainer ()) {
! 			if (static_cast<RContainerObject *> (object)->numDimensions ()) {
! 				olength = static_cast<RContainerObject *> (object)->getDimension (0);
! 			} else {
! 				olength = 0;
! 			}
! 		}
! 
! 		// then check, whether length is valid
! 		if ((min_length > 0) && (olength < min_length)) return false;
! 		if ((max_length >= 0) && (olength > max_length)) return false;
  	}
  
  	// next, check classes
  	if (!classes.isEmpty ()) {
! 		
  	}
  
  	// finally, check type
  	if (!types.isEmpty ()) {
  	}
  
- 	// TODO
- /*
- 	int dims;
- 	int min_length;
- 	int max_length;
- 	QStringList classes;
- 	QStringList types;
- }; */
  	return true;
  }
--- 641,678 ----
  }
  
  bool RKComponentPropertyRObjects::isObjectValid (RObject *object) {
  	RK_TRACE (PLUGIN);
  
  	// first check dimensionality
! 	if (dims > 0) {
! 		if (object->numDimensions () != dims) return false;
  	}
+ 	int olength = object->getLength ();
+ 	if ((min_length > 0) && (olength < min_length)) return false;
+ 	if ((max_length >= 0) && (olength > max_length)) return false;
  
  	// next, check classes
  	if (!classes.isEmpty ()) {
! 		bool ok = false;
! 		QStringList::const_iterator it = classes.begin ();
! 		while ((!ok) && (it != classes.end ())) {
! 			if (object->inherits (*it)) {
! 				ok = true;
! 			}
! 			++it;
! 		}
! 		if (!ok) return false;
  	}
  
  	// finally, check type
  	if (!types.isEmpty ()) {
+ 		// TODO: this is not entirely correct, yet
+ 		if (object->isVariable ()) {
+ 			if (!types.contains (static_cast<RKVariable *> (object)->getVarTypeString ().lower ())) {
+ 				return false;
+ 			}
+ 		}
  	}
  
  	return true;
  }
***************
*** 787,792 ****
  
  			// reconcile dimensionality filter
! 			if (dims != -1) {
! 				if (ogov->dims == -1) {
  					ogov->dims = dims;
  				} else if (ogov->dims != dims) {
--- 761,766 ----
  
  			// reconcile dimensionality filter
! 			if (dims > 0) {
! 				if (ogov->dims <= 0) {
  					ogov->dims = dims;
  				} else if (ogov->dims != dims) {
***************
*** 797,801 ****
  				ogov->min_length = min_length;
  			}
! 			if (max_length != -1) {
  				if (ogov->max_length > max_length) {
  					ogov->max_length = max_length;
--- 771,775 ----
  				ogov->min_length = min_length;
  			}
! 			if (max_length > 0) {
  				if (ogov->max_length > max_length) {
  					ogov->max_length = max_length;





More information about the rkward-tracker mailing list