Commit 3915c77210e491b5d0107f4ffd8ef17498cde3ca

Authored by Charles Otto
1 parent 6cdd5961

initial implementation of setPropertyRecursive

openbr/openbr_plugin.cpp
@@ -717,6 +717,16 @@ void Object::load(QDataStream &stream) @@ -717,6 +717,16 @@ void Object::load(QDataStream &stream)
717 init(); 717 init();
718 } 718 }
719 719
  720 +bool Object::setPropertyRecursive(const QString & name, QVariant value)
  721 +{
  722 + if (this->metaObject()->indexOfProperty(qPrintable(name)) == -1)
  723 + return false;
  724 +
  725 + qDebug() << "Class: " << metaObject()->className() << "took property" << name;
  726 + setProperty(name, value);
  727 + return true;
  728 +}
  729 +
720 void Object::setProperty(const QString &name, QVariant value) 730 void Object::setProperty(const QString &name, QVariant value)
721 { 731 {
722 QString type; 732 QString type;
openbr/openbr_plugin.h
@@ -597,6 +597,8 @@ public: @@ -597,6 +597,8 @@ public:
597 QString argument(int index) const; /*!< \brief A string value for the argument at the specified index. */ 597 QString argument(int index) const; /*!< \brief A string value for the argument at the specified index. */
598 QString description() const; /*!< \brief Returns a string description of the object. */ 598 QString description() const; /*!< \brief Returns a string description of the object. */
599 void setProperty(const QString &name, QVariant value); /*!< \brief Overload of QObject::setProperty to handle OpenBR data types. */ 599 void setProperty(const QString &name, QVariant value); /*!< \brief Overload of QObject::setProperty to handle OpenBR data types. */
  600 + virtual bool setPropertyRecursive(const QString & name, QVariant value); /*!< \brief Recursive version of setProperty, try to set the property on this object, or its children, returns true if successful. */
  601 +
600 static QStringList parse(const QString &string, char split = ','); /*!< \brief Splits the string while respecting lexical scoping of <tt>()</tt>, <tt>[]</tt>, <tt>\<\></tt>, and <tt>{}</tt>. */ 602 static QStringList parse(const QString &string, char split = ','); /*!< \brief Splits the string while respecting lexical scoping of <tt>()</tt>, <tt>[]</tt>, <tt>\<\></tt>, and <tt>{}</tt>. */
601 603
602 private: 604 private:
openbr/plugins/independent.cpp
@@ -126,6 +126,20 @@ class IndependentTransform : public MetaTransform @@ -126,6 +126,20 @@ class IndependentTransform : public MetaTransform
126 126
127 QList<Transform*> transforms; 127 QList<Transform*> transforms;
128 128
  129 +
  130 + bool setPropertyRecursive(const QString & name, QVariant value)
  131 + {
  132 + if (br::Object::setPropertyRecursive(name, value))
  133 + return true;
  134 +
  135 + if (!transform->setPropertyRecursive(name, value))
  136 + return false;
  137 +
  138 + for (int i=0;i < transforms.size();i++) {
  139 + transforms[i]->setPropertyRecursive(name, value);
  140 + }
  141 + }
  142 +
129 void init() 143 void init()
130 { 144 {
131 transforms.clear(); 145 transforms.clear();
openbr/plugins/meta.cpp
@@ -493,6 +493,12 @@ class LoadStoreTransform : public MetaTransform @@ -493,6 +493,12 @@ class LoadStoreTransform : public MetaTransform
493 public: 493 public:
494 LoadStoreTransform() : transform(NULL) {} 494 LoadStoreTransform() : transform(NULL) {}
495 495
  496 + bool setPropertyRecursive(const QString & name, QVariant value)
  497 + {
  498 + if (br::Object::setPropertyRecursive(name, value))
  499 + return true;
  500 + return transform->setPropertyRecursive(name, value);
  501 + }
496 private: 502 private:
497 void init() 503 void init()
498 { 504 {
openbr/plugins/openbr_internal.h
@@ -201,6 +201,13 @@ public: @@ -201,6 +201,13 @@ public:
201 this->trainable = transform->trainable; 201 this->trainable = transform->trainable;
202 } 202 }
203 203
  204 + bool setPropertyRecursive(const QString & name, QVariant value)
  205 + {
  206 + if (br::Object::setPropertyRecursive(name, value))
  207 + return true;
  208 +
  209 + return transform->setPropertyRecursive(name, value);
  210 + }
204 }; 211 };
205 212
206 /*! 213 /*!
@@ -293,6 +300,20 @@ public: @@ -293,6 +300,20 @@ public:
293 return output; 300 return output;
294 } 301 }
295 302
  303 + bool setPropertyRecursive(const QString & name, QVariant value)
  304 + {
  305 + if (br::Object::setPropertyRecursive(name, value))
  306 + return true;
  307 +
  308 + for (int i=0; i < this->transforms.size();i++)
  309 + {
  310 + if (transforms[i]->setPropertyRecursive(name, value))
  311 + return true;
  312 + }
  313 + return false;
  314 + }
  315 +
  316 +
296 protected: 317 protected:
297 bool isTimeVarying; 318 bool isTimeVarying;
298 319