Public Slots | Signals | Public Member Functions | Private Attributes | List of all members
rviz::EnumProperty Class Reference

Enum property. More...

#include <enum_property.h>

Inheritance diagram for rviz::EnumProperty:
Inheritance graph
[legend]

Public Slots

virtual void setString (const QString &str)
 Set the value of this property to the given string. Does not force the value to be one of the list of options. More...
 
void setStringStd (const std::string &str)
 Set the value of this property to the given std::string. Does not force the value to be one of the list of options. More...
 
void sortOptions ()
 Sort the option strings. Does not change string/int associations. More...
 
- Public Slots inherited from rviz::StringProperty
bool setStdString (const std::string &std_str)
 
bool setString (const QString &str)
 

Signals

void requestOptions (EnumProperty *property_in_need_of_options)
 requestOptions() is emitted each time createEditor() is called. More...
 
- Signals inherited from rviz::Property
void aboutToChange ()
 Emitted by setValue() just before the value has changed. More...
 
void changed ()
 Emitted by setValue() just after the value has changed. More...
 
void childListChanged (Property *this_property)
 Emitted after insertions and deletions of child Properties. More...
 

Public Member Functions

virtual void addOption (const QString &option, int value=0)
 
void addOptionStd (const std::string &option, int value=0)
 
virtual void clearOptions ()
 Clear the list of options. More...
 
QWidget * createEditor (QWidget *parent, const QStyleOptionViewItem &option) override
 Create an editor widget to edit the value of this property. More...
 
 EnumProperty (const QString &name=QString(), const QString &default_value=QString(), const QString &description=QString(), Property *parent=nullptr, const char *changed_slot=nullptr, QObject *receiver=nullptr)
 
virtual int getOptionInt ()
 Return the int value of the currently-chosen option, or 0 if the current option string does not have an int value. More...
 
- Public Member Functions inherited from rviz::StringProperty
std::string getStdString ()
 
QString getString ()
 
 StringProperty (const QString &name=QString(), const QString &default_value=QString(), const QString &description=QString(), Property *parent=nullptr, const char *changed_slot=nullptr, QObject *receiver=nullptr)
 
- Public Member Functions inherited from rviz::Property
virtual void addChild (Property *child, int index=-1)
 Add a child property. More...
 
PropertychildAt (int index) const
 Return the child Property with the given index, or NULL if the index is out of bounds or if the child at that index is not a Property. More...
 
virtual PropertychildAtUnchecked (int index) const
 Return the child Property with the given index, without checking whether the index is within bounds. More...
 
virtual void collapse ()
 Collapse (hide the children of) this Property. More...
 
bool contains (Property *possible_child) const
 Return true if the list of children includes possible_child, false if not. More...
 
virtual void expand ()
 Expand (show the children of) this Property. More...
 
virtual QString getDescription () const
 Return the description. More...
 
virtual bool getDisableChildren ()
 If true, the children of this property should set their ItemIsEnabled flag to false. More...
 
virtual bool getHidden () const
 Return the hidden/shown state. True means hidden, false means visible. More...
 
virtual QIcon getIcon () const
 
PropertyTreeModelgetModel () const
 Return the model managing this Property and its childrent. More...
 
virtual QString getName () const
 Return the name of this Property as a QString. More...
 
std::string getNameStd () const
 Return the name of this Property as a std::string. More...
 
PropertygetParent () const
 Return the parent Property. More...
 
virtual bool getReadOnly ()
 Return the read-only-ness of this property. More...
 
virtual QVariant getValue () const
 Return the value of this Property as a QVariant. If the value has never been set, an invalid QVariant is returned. More...
 
virtual QVariant getViewData (int column, int role) const
 Return data appropriate for the given column (0 or 1) and role for this Property. More...
 
virtual Qt::ItemFlags getViewFlags (int column) const
 Return item flags appropriate for the given column (0 or 1) for this Property. More...
 
void hide ()
 Hide this Property in any PropertyTreeWidgets. More...
 
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. More...
 
virtual void load (const Config &config)
 Load the value of this property and/or its children from the given Config reference. More...
 
virtual void moveChild (int from_index, int to_index)
 Move the child at from_index to to_index. More...
 
virtual int numChildren () const
 Return the number of child objects (Property or otherwise). More...
 
virtual bool paint (QPainter *painter, const QStyleOptionViewItem &option) const
 Hook to provide custom painting of the value data (right-hand column) in a subclass. More...
 
 Property (const QString &name=QString(), const QVariant default_value=QVariant(), const QString &description=QString(), Property *parent=nullptr, const char *changed_slot=nullptr, QObject *receiver=nullptr)
 Constructor. More...
 
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. More...
 
int rowNumberInParent () const
 Return the row number of this property within its parent, or -1 if it has no parent. More...
 
virtual void save (Config config) const
 Write the value of this property and/or its children into the given Config reference. More...
 
virtual void setDescription (const QString &description)
 Set the description. More...
 
virtual void setHidden (bool hidden)
 Hide or show this property in any PropertyTreeWidget viewing its parent. More...
 
virtual void setIcon (const QIcon &icon)
 Set the icon to be displayed next to the property. More...
 
void setModel (PropertyTreeModel *model)
 Set the model managing this Property and all its child properties, recursively. More...
 
virtual void setName (const QString &name)
 Set the name. More...
 
void setParent (Property *new_parent)
 Set parent property, without telling the parent. More...
 
virtual void setReadOnly (bool read_only)
 Prevent or allow users to edit this property from a PropertyTreeWidget. More...
 
void setShouldBeSaved (bool save)
 If save is true and getReadOnly() is false, shouldBeSaved will return true; otherwise false. Default is true. More...
 
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, false if same. More...
 
bool shouldBeSaved () const
 Returns true if the property is not read-only AND has data worth saving. More...
 
void show ()
 Show this Property in any PropertyTreeWidgets. More...
 
virtual PropertysubProp (const QString &sub_name)
 Return the first child Property with the given name, or the FailureProperty if no child has the name. More...
 
PropertytakeChild (Property *child)
 Remove a given child object and return a pointer to it. More...
 
virtual PropertytakeChildAt (int index)
 Take a child out of the child list, but don't destroy it. More...
 
 ~Property () override
 Destructor. Removes this property from its parent's list of children. More...
 

Private Attributes

QHash< QString, int > ints_
 
QStringList strings_
 

Additional Inherited Members

- Protected Member Functions inherited from rviz::Property
void loadValue (const Config &config)
 Load the value of this property specifically, not including children. More...
 
- Protected Attributes inherited from rviz::Property
bool child_indexes_valid_
 True if row_number_within_parent_ of all children is valid, false if not. More...
 
QIcon icon_
 
PropertyTreeModelmodel_
 Pointer to the PropertyTreeModel managing this property tree. More...
 
QVariant value_
 This is the central property value. If you set it directly in a subclass, do so with care because many things depend on the aboutToChange() and changed() events emitted by setValue(). More...
 

Detailed Description

Enum property.

An enum property works like a string property all the way through the system property system, except when you get a changed() signal you can call getOptionInt() to get the integer value of the current option. The integer returned will be that passed to addOption() for with the string that is currently selected.

Definition at line 46 of file enum_property.h.

Constructor & Destructor Documentation

◆ EnumProperty()

rviz::EnumProperty::EnumProperty ( const QString &  name = QString(),
const QString &  default_value = QString(),
const QString &  description = QString(),
Property parent = nullptr,
const char *  changed_slot = nullptr,
QObject *  receiver = nullptr 
)

Definition at line 36 of file enum_property.cpp.

Member Function Documentation

◆ addOption()

void rviz::EnumProperty::addOption ( const QString &  option,
int  value = 0 
)
virtual

Definition at line 52 of file enum_property.cpp.

◆ addOptionStd()

void rviz::EnumProperty::addOptionStd ( const std::string &  option,
int  value = 0 
)
inline

Definition at line 62 of file enum_property.h.

◆ clearOptions()

void rviz::EnumProperty::clearOptions ( )
virtual

Clear the list of options.

Does not change the current value of the property.

Definition at line 46 of file enum_property.cpp.

◆ createEditor()

QWidget * rviz::EnumProperty::createEditor ( QWidget *  parent,
const QStyleOptionViewItem &  option 
)
overridevirtual

Create an editor widget to edit the value of this property.

Parameters
parentThe QWidget to set as the parent of the returned QWidget.
optionA QStyleOptionViewItem with parameters of the editor widget, like the rectangle, alignments, etc.
Returns
the newly-created editor widget. The default implementation creates a QSpinBox for integer values, a FloatEdit for float or double values, or a QLineEdit for anything else.

If this function returns NULL, a QStyledItemDelegate will make an editor widget.

The widget returned by createEditor() must have one Q_PROPERTY with USER set to true. The PropertyTreeDelegate finds it, sets it with the results of PropertyTreeModel::data() after creation, and after editing is finished it reads it and calls PropertyTreeModel::setData() with the contents.

Reimplemented from rviz::Property.

Definition at line 69 of file enum_property.cpp.

◆ getOptionInt()

int rviz::EnumProperty::getOptionInt ( )
virtual

Return the int value of the currently-chosen option, or 0 if the current option string does not have an int value.

Definition at line 58 of file enum_property.cpp.

◆ requestOptions

void rviz::EnumProperty::requestOptions ( EnumProperty property_in_need_of_options)
signal

requestOptions() is emitted each time createEditor() is called.

A connection to this signal should never be made with a queued connection, because then the "emit" would return before the changes to the options in the EnumProperty were made.

A connected slot should make calls to clearOptions() and/or addOption() as needed. The option list in the EnumProperty will not be cleared before the signal is emitted.

◆ setString

void rviz::EnumProperty::setString ( const QString &  str)
virtualslot

Set the value of this property to the given string. Does not force the value to be one of the list of options.

Definition at line 84 of file enum_property.cpp.

◆ setStringStd

void rviz::EnumProperty::setStringStd ( const std::string &  str)
inlineslot

Set the value of this property to the given std::string. Does not force the value to be one of the list of options.

Definition at line 80 of file enum_property.h.

◆ sortOptions

void rviz::EnumProperty::sortOptions ( )
inlineslot

Sort the option strings. Does not change string/int associations.

Definition at line 86 of file enum_property.h.

Member Data Documentation

◆ ints_

QHash<QString, int> rviz::EnumProperty::ints_
private

Definition at line 106 of file enum_property.h.

◆ strings_

QStringList rviz::EnumProperty::strings_
private

Definition at line 105 of file enum_property.h.


The documentation for this class was generated from the following files:


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Mon Aug 15 2022 02:05:17