|
QGroundControl
Ground Control Station for MAVLink Drones
|
#include <QmlObjectTreeModel.h>
Inheritance diagram for QmlObjectTreeModel:
Collaboration diagram for QmlObjectTreeModel:Public Member Functions | |
| QmlObjectTreeModel (QObject *parent=nullptr) | |
| ~QmlObjectTreeModel () override | |
| int | count () const override |
| void | setDirty (bool dirty) override |
| void | clear () override |
| QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const override |
| QModelIndex | parent (const QModelIndex &child) const override |
| int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
| int | columnCount (const QModelIndex &parent=QModelIndex()) const override |
| bool | hasChildren (const QModelIndex &parent=QModelIndex()) const override |
| QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
| bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override |
| bool | insertRows (int row, int count, const QModelIndex &parent=QModelIndex()) override |
| bool | removeRows (int row, int count, const QModelIndex &parent=QModelIndex()) override |
| QHash< int, QByteArray > | roleNames () const override |
| QObject * | getObject (const QModelIndex &index) const |
Returns the QObject* stored at index, or nullptr if invalid. | |
| QModelIndex | appendItem (QObject *object, const QModelIndex &parentIndex=QModelIndex()) |
Appends object as the last child of parentIndex (root if invalid). Returns the new item's index. | |
| QModelIndex | appendItem (QObject *object, const QModelIndex &parentIndex, const QString &nodeType) |
| Same as above but also sets a nodeType tag on the created tree node. | |
| QModelIndex | insertItem (int row, QObject *object, const QModelIndex &parentIndex=QModelIndex()) |
Inserts object at row under parentIndex. Returns the new item's index. | |
| QModelIndex | insertItem (int row, QObject *object, const QModelIndex &parentIndex, const QString &nodeType) |
| Same as above but also sets a nodeType tag on the created tree node. | |
| QObject * | removeItem (const QModelIndex &index) |
| int | childCount (const QModelIndex &parentIndex=QModelIndex()) const |
Number of direct children under parentIndex. | |
| QModelIndex | childIndex (int row, const QModelIndex &parentIndex=QModelIndex()) const |
Returns the QModelIndex for the child at row under parentIndex. | |
| QModelIndex | indexForObject (QObject *object) const |
Searches the entire tree for object and returns its QModelIndex (invalid if not found) | |
| QModelIndex | parentIndex (const QModelIndex &index) const |
| Convenience wrapper around parent() | |
| int | depth (const QModelIndex &index) const |
Returns the depth of index (0 = root-level item, -1 = invalid index) | |
| void | appendRootItem (QObject *object) |
| void | appendChild (const QModelIndex &parentIndex, QObject *object) |
| QObject * | removeAt (const QModelIndex &parentIndex, int row) |
| void | removeChildren (const QModelIndex &parentIndex) |
| Removes all children of parentIndex without removing the parent itself. | |
| void | clearAndDeleteContents () |
| Clears the tree and calls deleteLater on every QObject. | |
| bool | contains (QObject *object) const |
Public Member Functions inherited from ObjectItemModelBase | |
| ObjectItemModelBase (QObject *parent=nullptr) | |
| ~ObjectItemModelBase () override | |
| int count READ count NOTIFY | countChanged (bool dirty READ dirty WRITE setDirty NOTIFY dirtyChanged) bool dirty() const |
| void | beginResetModel () |
| Depth-counted beginResetModel — only the outermost call has effect. | |
| void | endResetModel () |
| Depth-counted endResetModel — only the outermost call has effect. | |
| virtual bool | isEmpty () const |
Static Public Attributes | |
| static constexpr int | NodeTypeRole = Qt::UserRole + 2 |
Additional Inherited Members | |
Signals inherited from ObjectItemModelBase | |
| void | countChanged (int count) |
| void | dirtyChanged (bool dirty) |
Protected Slots inherited from ObjectItemModelBase | |
| void | _childDirtyChanged (bool dirty) |
Protected Member Functions inherited from ObjectItemModelBase | |
| QHash< int, QByteArray > | roleNames () const override |
| void | _signalCountChangedIfNotNested () |
Protected Attributes inherited from ObjectItemModelBase | |
| bool | _dirty = false |
| uint | _resetModelNestingCount = 0 |
Static Protected Attributes inherited from ObjectItemModelBase | |
| static constexpr int | ObjectRole = Qt::UserRole |
| static constexpr int | TextRole = Qt::UserRole + 1 |
A tree model for QObject* items, usable from both C++ and QML. Works like QmlObjectListModel but supports hierarchical parent/child relationships. Compatible with Qt 6 TreeView.
Top-level items are children of an invisible root node. The root is represented by an invalid QModelIndex (the default).
Definition at line 25 of file QmlObjectTreeModel.h.
|
explicit |
Definition at line 60 of file QmlObjectTreeModel.cc.
|
override |
Definition at line 65 of file QmlObjectTreeModel.cc.
| void QmlObjectTreeModel::appendChild | ( | const QModelIndex & | parentIndex, |
| QObject * | object | ||
| ) |
Definition at line 358 of file QmlObjectTreeModel.cc.
References appendItem(), and parentIndex().
| QModelIndex QmlObjectTreeModel::appendItem | ( | QObject * | object, |
| const QModelIndex & | parentIndex, | ||
| const QString & | nodeType | ||
| ) |
Same as above but also sets a nodeType tag on the created tree node.
Definition at line 276 of file QmlObjectTreeModel.cc.
References index(), insertItem(), and parentIndex().
| QModelIndex QmlObjectTreeModel::appendItem | ( | QObject * | object, |
| const QModelIndex & | parentIndex = QModelIndex() |
||
| ) |
Appends object as the last child of parentIndex (root if invalid). Returns the new item's index.
Definition at line 221 of file QmlObjectTreeModel.cc.
References index(), insertItem(), and parentIndex().
Referenced by appendChild(), and appendRootItem().
| void QmlObjectTreeModel::appendRootItem | ( | QObject * | object | ) |
Definition at line 353 of file QmlObjectTreeModel.cc.
References appendItem().
|
inline |
Number of direct children under parentIndex.
Definition at line 74 of file QmlObjectTreeModel.h.
Referenced by removeChildren().
|
inline |
Returns the QModelIndex for the child at row under parentIndex.
Definition at line 77 of file QmlObjectTreeModel.h.
|
overridevirtual |
Implements ObjectItemModelBase.
Definition at line 402 of file QmlObjectTreeModel.cc.
References ObjectItemModelBase::beginResetModel(), and ObjectItemModelBase::endResetModel().
| void QmlObjectTreeModel::clearAndDeleteContents | ( | ) |
Clears the tree and calls deleteLater on every QObject.
Definition at line 415 of file QmlObjectTreeModel.cc.
References ObjectItemModelBase::beginResetModel(), and ObjectItemModelBase::endResetModel().
|
override |
Definition at line 110 of file QmlObjectTreeModel.cc.
| bool QmlObjectTreeModel::contains | ( | QObject * | object | ) | const |
Definition at line 428 of file QmlObjectTreeModel.cc.
|
overridevirtual |
Implements ObjectItemModelBase.
Definition at line 194 of file QmlObjectTreeModel.cc.
|
override |
Definition at line 122 of file QmlObjectTreeModel.cc.
References index(), NodeTypeRole, ObjectItemModelBase::ObjectRole, and ObjectItemModelBase::TextRole.
| int QmlObjectTreeModel::depth | ( | const QModelIndex & | index | ) | const |
Returns the depth of index (0 = root-level item, -1 = invalid index)
Definition at line 334 of file QmlObjectTreeModel.cc.
References index().
| QObject * QmlObjectTreeModel::getObject | ( | const QModelIndex & | index | ) | const |
Returns the QObject* stored at index, or nullptr if invalid.
Definition at line 211 of file QmlObjectTreeModel.cc.
References index().
|
override |
Definition at line 116 of file QmlObjectTreeModel.cc.
References parent().
|
override |
Definition at line 76 of file QmlObjectTreeModel.cc.
References index(), and parent().
Referenced by appendItem(), appendItem(), columnCount(), data(), depth(), getObject(), index(), indexForObject(), insertItem(), insertItem(), insertRows(), parent(), removeAt(), removeChildren(), removeItem(), removeRows(), roleNames(), setData(), and setDirty().
| QModelIndex QmlObjectTreeModel::indexForObject | ( | QObject * | object | ) | const |
Searches the entire tree for object and returns its QModelIndex (invalid if not found)
Definition at line 324 of file QmlObjectTreeModel.cc.
References index().
| QModelIndex QmlObjectTreeModel::insertItem | ( | int | row, |
| QObject * | object, | ||
| const QModelIndex & | parentIndex, | ||
| const QString & | nodeType | ||
| ) |
Same as above but also sets a nodeType tag on the created tree node.
Definition at line 237 of file QmlObjectTreeModel.cc.
References ObjectItemModelBase::_resetModelNestingCount, ObjectItemModelBase::_signalCountChangedIfNotNested(), index(), parentIndex(), and setDirty().
| QModelIndex QmlObjectTreeModel::insertItem | ( | int | row, |
| QObject * | object, | ||
| const QModelIndex & | parentIndex = QModelIndex() |
||
| ) |
Inserts object at row under parentIndex. Returns the new item's index.
Definition at line 232 of file QmlObjectTreeModel.cc.
References index(), insertItem(), and parentIndex().
Referenced by appendItem(), appendItem(), and insertItem().
|
override |
Definition at line 171 of file QmlObjectTreeModel.cc.
References index().
|
override |
Definition at line 90 of file QmlObjectTreeModel.cc.
References index().
Referenced by columnCount(), hasChildren(), index(), and rowCount().
|
inline |
Convenience wrapper around parent()
Definition at line 83 of file QmlObjectTreeModel.h.
Referenced by appendChild(), appendItem(), appendItem(), insertItem(), insertItem(), removeAt(), and removeChildren().
| QObject * QmlObjectTreeModel::removeAt | ( | const QModelIndex & | parentIndex, |
| int | row | ||
| ) |
Definition at line 363 of file QmlObjectTreeModel.cc.
References index(), parentIndex(), and removeItem().
| void QmlObjectTreeModel::removeChildren | ( | const QModelIndex & | parentIndex | ) |
Removes all children of parentIndex without removing the parent itself.
Definition at line 368 of file QmlObjectTreeModel.cc.
References ObjectItemModelBase::_resetModelNestingCount, ObjectItemModelBase::_signalCountChangedIfNotNested(), childCount(), index(), and parentIndex().
| QObject * QmlObjectTreeModel::removeItem | ( | const QModelIndex & | index | ) |
Removes the item (and its entire subtree) at index. Returns the removed QObject* (caller takes ownership). Child QObjects are NOT deleted; only the internal tree nodes are freed.
Definition at line 286 of file QmlObjectTreeModel.cc.
References ObjectItemModelBase::_signalCountChangedIfNotNested(), index(), and setDirty().
Referenced by removeAt().
|
override |
Definition at line 177 of file QmlObjectTreeModel.cc.
References index().
|
override |
Definition at line 183 of file QmlObjectTreeModel.cc.
References index(), NodeTypeRole, and ObjectItemModelBase::roleNames().
|
override |
Definition at line 104 of file QmlObjectTreeModel.cc.
References parent().
|
override |
Definition at line 145 of file QmlObjectTreeModel.cc.
References index(), and ObjectItemModelBase::ObjectRole.
Implements ObjectItemModelBase.
Definition at line 199 of file QmlObjectTreeModel.cc.
References ObjectItemModelBase::_dirty, ObjectItemModelBase::dirtyChanged(), and index().
Referenced by insertItem(), and removeItem().
Definition at line 96 of file QmlObjectTreeModel.h.
Referenced by data(), and roleNames().