Go to the documentation of this file.
33 #include <QApplication>
60 const QVariant& default_value,
61 const QString& description,
65 , child_indexes_valid_(false)
69 , is_read_only_(false)
77 QMetaObject::Connection
83 return QObject::connect(
this, SIGNAL(
changed()), receiver, slot, type);
85 return QMetaObject::Connection();
96 for (
int i =
children_.size() - 1; i >= 0; i--)
119 for (
int i = start_index; i < start_index + count; i++)
182 for (
int i = 0; i < size; i++)
185 if (prop->
getName() == sub_name)
193 QString ancestry =
"";
196 ancestry =
"\"" + prop->
getName() +
"\"->" + ancestry;
198 printf(
"ERROR: Undefined property %s \"%s\" accessed.\n", qPrintable(ancestry), qPrintable(sub_name));
221 for (
int i = 0; i < num_children; i++)
244 return QApplication::palette().brush(QPalette::Disabled, QPalette::Text);
251 case Qt::DisplayRole:
254 case Qt::DecorationRole:
263 case Qt::DisplayRole:
265 return (
value_.type() == QVariant::Bool ? QVariant() :
getValue());
266 case Qt::CheckStateRole:
267 if (
value_.type() == QVariant::Bool)
268 return (
value_.toBool() ? Qt::Checked : Qt::Unchecked);
294 Qt::ItemFlags enabled_flag =
299 return enabled_flag | Qt::ItemIsSelectable;
303 if (
value_.type() == QVariant::Bool)
305 return Qt::ItemIsUserCheckable | enabled_flag | Qt::ItemIsSelectable;
307 return Qt::ItemIsEditable | enabled_flag | Qt::ItemIsSelectable;
309 return enabled_flag | Qt::ItemIsSelectable;
315 while (prop !=
nullptr && prop !=
this)
336 if (index < 0 || index >=
children_.size())
363 if (index < 0 || index > num_children)
365 index = num_children;
389 return element->getName() < child->getName();
403 for (
int i = 0; i < num_children; i++)
413 for (
int i = 0; i < num_children; i++)
455 int num_property_children =
children_.size();
456 for (
int i = 0; i < num_property_children; i++)
469 switch (
int(
value_.type()))
474 case QMetaType::Float:
475 case QVariant::Double:
478 case QVariant::String:
485 printf(
"Property::loadValue() TODO: error handling - unexpected QVariant type %d.\n",
506 for (
int i = 0; i < num_properties; i++)
541 switch (
int(
value_.type()))
545 QSpinBox* editor =
new QSpinBox(parent);
546 editor->setFrame(
false);
547 editor->setRange(INT_MIN, INT_MAX);
550 case QMetaType::Float:
551 case QVariant::Double:
556 case QVariant::String:
559 QLineEdit* editor =
new QLineEdit(parent);
560 editor->setFrame(
false);
void insertChildSorted(Property *child)
Insert a child property, sorted by name.
void emitPropertyHiddenChanged(const Property *property)
Emit the propertyHiddenChanged() signal for the given Property.
Property * childAt(int index) const
Return the child Property with the given index, or NULL if the index is out of bounds or if the child...
virtual void setHidden(bool hidden)
Hide or show this property in any PropertyTreeWidget viewing its parent.
virtual void setName(const QString &name)
Set the name.
static Property * failprop_
The property returned by subProp() when the requested name is not found.
void expandProperty(Property *property)
Expand (show the children of) the given Property.
virtual QVariant getViewData(int column, int role) const
Return data appropriate for the given column (0 or 1) and role for this Property.
virtual void addChild(Property *child, int index=-1)
Add a child property.
int row_number_within_parent_
virtual void collapse()
Collapse (hide the children of) this Property.
bool shouldBeSaved() const
Returns true if the property has data worth saving.
virtual Property * subProp(const QString &sub_name)
Return the first child Property with the given name, or the FailureProperty if no child has the name.
Property * subProp(const QString &) override
Return the first child Property with the given name, or the FailureProperty if no child has the name.
virtual int numChildren() const
Return the number of child objects (Property or otherwise).
bool contains(Property *possible_child) const
Return true if the list of children includes possible_child, false if not.
virtual QVariant getValue() const
Return the value of this Property as a QVariant. If the value has never been set, an invalid QVariant...
Property(const QString &name=QString(), const QVariant &default_value=QVariant(), const QString &description=QString(), Property *parent=nullptr)
Constructor.
void collapseProperty(Property *property)
Collapse (hide the children of) the given Property.
QMetaObject::Connection connect(const QObject *receiver, const char *slot, Qt::ConnectionType type=Qt::AutoConnection)
Connect changed() signal to given slot of receiver.
~Property() override
Destructor. Removes this property from its parent's list of children.
A single element of a property tree, with a name, value, description, and possibly children.
void emitDataChanged(Property *property, bool emit_config_changed=true)
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option)
Create an editor widget to edit the value of this property.
virtual void expand()
Expand (show the children of) this Property.
virtual bool setValue(const QVariant &new_value)
Set the new value for this property. Returns true if the new value is different from the old value,...
virtual Property * takeChildAt(int index)
Take a child out of the child list, but don't destroy it.
PropertyTreeModel * model_
Pointer to the PropertyTreeModel managing this property tree.
void childListChanged(Property *this_property)
Emitted after insertions and deletions of child Properties.
Property * getParent() const
Return the parent Property.
void beginInsert(Property *parent_property, int row_within_parent, int count=1)
bool child_indexes_valid_
True if row_number_within_parent_ of all children is valid, false if not.
int rowNumberInParent() const
Return the row number of this property within its parent, or -1 if it has no parent.
virtual void setDescription(const QString &description)
Set the description.
void beginRemove(Property *parent_property, int row_within_parent, int count=1)
virtual Qt::ItemFlags getViewFlags(int column) const
Return item flags appropriate for the given column (0 or 1) for this Property.
Type getType() const
Return the Type of the referenced Node, or Invalid if this Config does not refer to a Node at all.
virtual QString getName() const
Return the name of this Property as a QString.
virtual QString getDescription() const
Return the description.
bool isAncestorOf(Property *possible_child) const
Returns true if this is an ancestor of possible_child, meaning is the parent or parent of parent etc.
void setParent(Property *new_parent)
Set parent property, without telling the parent.
QList< Property * > children_
void changed()
Emitted by setValue() just after the value has changed.
virtual void save(Config config) const
Write the value of this property and/or its children into the given Config reference.
void loadValue(const Config &config)
Load the value of this property specifically, not including children.
void reindexChildren()
Set row_number_within_parent_ correctly for every child. Sets child_indexes_valid_ to true when done.
virtual void removeChildren(int start_index=0, int count=-1)
Remove and delete some or all child Properties. Does not change the value of this Property.
QVariant value_
This is the central property value. If you set it directly in a subclass, do so with care because man...
virtual Property * childAtUnchecked(int index) const
Return the child Property with the given index, without checking whether the index is within bounds.
void aboutToChange()
Emitted by setValue() just before the value has changed.
virtual bool getDisableChildren()
If true, the children of this property should set their ItemIsEnabled flag to false.
Property * takeChild(Property *child)
Remove a given child object and return a pointer to it.
virtual void load(const Config &config)
Load the value of this property and/or its children from the given Config reference.
Configuration data storage class.
virtual void moveChild(int from_index, int to_index)
Move the child at from_index to to_index.
void setModel(PropertyTreeModel *model)
Set the model managing this Property and all its child properties, recursively.
rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Aug 2 2024 08:43:10