29 #ifndef PROPERTY_MODEL_H 30 #define PROPERTY_MODEL_H 32 #include <QAbstractItemModel> 59 QVariant
data(
const QModelIndex&
index,
int role)
const override;
61 headerData(
int section, Qt::Orientation orientation,
int role = Qt::DisplayRole)
const override;
63 QModelIndex
index(
int row,
int column,
const QModelIndex&
parent = QModelIndex())
const override;
64 QModelIndex
parent(
const QModelIndex& index)
const override;
71 int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
75 int columnCount(
const QModelIndex& = QModelIndex())
const override 81 Qt::ItemFlags
flags(
const QModelIndex& index)
const override;
82 bool setData(
const QModelIndex& index,
const QVariant& value,
int role = Qt::EditRole)
override;
86 return Qt::MoveAction;
95 QMimeData*
mimeData(
const QModelIndexList& indexes)
const override;
107 int destination_column,
108 const QModelIndex& destination_parent)
override;
157 void expand(
const QModelIndex& index);
160 void collapse(
const QModelIndex& index);
170 #endif // PROPERTY_MODEL_H QStringList mimeTypes() const override
Returns a list with just "application/x-rviz-" plus drag_drop_class_.
void propertyHiddenChanged(const Property *property)
Emitted when a property within the model is hidden or shown.
PropertyTreeModel(Property *root_property, QObject *parent=nullptr)
Constructor.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
QModelIndex parentIndex(const Property *child) const
Same as parent() but taking a Property pointer instead of an index.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Return the number of rows under the given parent index.
A single element of a property tree, with a name, value, description, and possibly children...
void printPersistentIndices()
For debugging only. Uses printf() to print the property names of current persistent indices...
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
void collapse(const QModelIndex &index)
Emitted when a Property wants to collapse (hide its children).
QModelIndex parent(const QModelIndex &index) const override
void expand(const QModelIndex &index)
Emitted when a Property wants to expand (display its children).
QMimeData * mimeData(const QModelIndexList &indexes) const override
Override from QAbstractItemModel. Returns a (non-standard) mime-encoded version of the given indexes...
void beginRemove(Property *parent_property, int row_within_parent, int count=1)
void expandProperty(Property *property)
Expand (show the children of) the given Property.
Property * getRoot() const
~PropertyTreeModel() override
Destructor. Deletes the root property (and thus the entire property tree).
Property * getProp(const QModelIndex &index) const
return the Property at the given index, or the root property if the index is invalid.
QVariant data(const QModelIndex &index, int role) const override
void configChanged()
Emitted when a Property which should be saved changes.
int columnCount(const QModelIndex &=QModelIndex()) const override
Return the number of columns under the given parent index, which is always 2 for this model...
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int destination_row, int destination_column, const QModelIndex &destination_parent) override
Override from QAbstractItemModel. Takes a (non-standard) mime-encoded version of an index list and dr...
QModelIndex indexOf(Property *property) const
void setDragDropClass(const QString &drag_drop_class)
Qt::DropActions supportedDropActions() const override
void collapseProperty(Property *property)
Collapse (hide the children of) the given Property.
void emitDataChanged(Property *property)
void beginInsert(Property *parent_property, int row_within_parent, int count=1)
Qt::ItemFlags flags(const QModelIndex &index) const override
void emitPropertyHiddenChanged(const Property *property)
Emit the propertyHiddenChanged() signal for the given Property.
Property * root_property_