|
KanoopGuiQt 1.3.0
Qt GUI utility library
|
|
Base class for items managed by AbstractItemModel. More...
#include <abstractmodelitem.h>
Classes | |
| class | List |
| A list of AbstractModelItem pointers with UUID and entity-type search helpers. More... | |
Public Member Functions | |
| AbstractModelItem () | |
| Default constructor — creates an unowned, untyped item. | |
| AbstractModelItem (AbstractItemModel *model) | |
| Construct an item owned by a model with no metadata. | |
| AbstractModelItem (const EntityMetadata &entityMetadata, AbstractItemModel *model, const QUuid &uuid=QUuid()) | |
| Construct an item with metadata, a model, and an optional UUID. | |
| AbstractModelItem (const EntityMetadata &entityMetadata, const QUuid &uuid, AbstractItemModel *model) | |
| Construct an item with metadata, a UUID, and a model. | |
| virtual | ~AbstractModelItem () |
| Destructor — deletes all child items. | |
| virtual EntityMetadata | entityMetadata () const |
| Return the entity metadata for this item. | |
| virtual EntityMetadata & | entityMetadataRef () |
| Return a mutable reference to the entity metadata. | |
| virtual void | setEntityMetadata (const EntityMetadata &metadata) |
| Set the entity metadata for this item. | |
| virtual int | entityType () const |
| Return the entity type integer from this item's metadata. | |
| virtual QUuid | uuid () const |
| Return the UUID for this item. | |
| virtual QIcon | icon () const |
| Return the icon for this item. | |
| virtual QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
| Return display or decoration data for a model index. | |
| virtual void | updateFromMetadata (const EntityMetadata &metadata) |
| Update this item's data from new entity metadata. | |
| virtual void | updateFromVariant (int headerType, const QVariant &value) |
| Update a single cell from a raw variant value (no-op by default). | |
| int | row () const |
| Return the row index of this item within its parent's children. | |
| AbstractModelItem * | parent () const |
| Return this item's parent item, or nullptr if it is a root item. | |
| AbstractModelItem * | child (int row) const |
| Return the child item at the given row. | |
| List | children () const |
| Return the list of child items. | |
| List & | childrenRef () |
| Return a mutable reference to the child items list. | |
| List | siblings () const |
| Return the list of sibling items (all children of this item's parent). | |
| int | childCount (int entityType=0) const |
| Return the number of direct children, optionally filtered by entity type. | |
| int | childCountRecursive (int entityType=0) const |
| Return the total number of descendants, optionally filtered by entity type. | |
| AbstractModelItem * | insertChild (int index, AbstractModelItem *child) |
| Insert a child item at the given index. | |
| AbstractModelItem * | appendChild (AbstractModelItem *child) |
| Append a child item. | |
| void | deleteChild (AbstractModelItem *child) |
| Delete a specific child item. | |
| void | deleteAllChildren () |
| Delete and remove all child items. | |
| template<typename T > | |
| QList< T > | findChildren (bool recursive=false) const |
| Find all direct (or recursive) children castable to type T. | |
| template<typename T > | |
| T | firstChild () const |
| Return the first direct child castable to type T. | |
| AbstractItemModel * | model () const |
| Return the model that owns this item. | |
Protected Member Functions | |
| void | setIcon (const QIcon &value) |
| Set the icon for this item. | |
Base class for items managed by AbstractItemModel.
Each item holds an EntityMetadata descriptor, a UUID, an optional icon, and references to its parent model, parent item, and child items. Subclass this to attach domain-specific data and override data() to supply display values.
Definition at line 31 of file abstractmodelitem.h.
| AbstractModelItem::AbstractModelItem | ( | AbstractItemModel * | model | ) |
Construct an item owned by a model with no metadata.
| model | Model that owns this item |
| AbstractModelItem::AbstractModelItem | ( | const EntityMetadata & | entityMetadata, |
| AbstractItemModel * | model, | ||
| const QUuid & | uuid = QUuid() |
||
| ) |
Construct an item with metadata, a model, and an optional UUID.
| entityMetadata | Metadata describing the entity |
| model | Model that owns this item |
| uuid | Optional UUID for this item |
| AbstractModelItem::AbstractModelItem | ( | const EntityMetadata & | entityMetadata, |
| const QUuid & | uuid, | ||
| AbstractItemModel * | model | ||
| ) |
Construct an item with metadata, a UUID, and a model.
| entityMetadata | Metadata describing the entity |
| uuid | UUID for this item |
| model | Model that owns this item |
|
inlinevirtual |
Destructor — deletes all child items.
Definition at line 60 of file abstractmodelitem.h.
| AbstractModelItem * AbstractModelItem::appendChild | ( | AbstractModelItem * | child | ) |
Append a child item.
| child | Child item to append |
| AbstractModelItem * AbstractModelItem::child | ( | int | row | ) | const |
Return the child item at the given row.
| row | Row index |
| int AbstractModelItem::childCount | ( | int | entityType = 0 | ) | const |
Return the number of direct children, optionally filtered by entity type.
| entityType | Entity type filter (0 = count all types) |
| int AbstractModelItem::childCountRecursive | ( | int | entityType = 0 | ) | const |
Return the total number of descendants, optionally filtered by entity type.
| entityType | Entity type filter (0 = count all types) |
|
inline |
Return the list of child items.
Definition at line 212 of file abstractmodelitem.h.
|
inline |
Return a mutable reference to the child items list.
Definition at line 214 of file abstractmodelitem.h.
|
virtual |
Return display or decoration data for a model index.
| index | Model index being queried |
| role | Qt item data role |
| void AbstractModelItem::deleteChild | ( | AbstractModelItem * | child | ) |
Delete a specific child item.
| child | Child item to remove and delete |
|
inlinevirtual |
Return the entity metadata for this item.
Definition at line 66 of file abstractmodelitem.h.
|
inlinevirtual |
Return a mutable reference to the entity metadata.
Definition at line 68 of file abstractmodelitem.h.
|
inlinevirtual |
Return the entity type integer from this item's metadata.
Definition at line 75 of file abstractmodelitem.h.
Referenced by AbstractModelItem::List::firstIndexOfEntityType(), and AbstractModelItem::List::lastIndexOfEntityType().
|
inline |
Find all direct (or recursive) children castable to type T.
| T | Pointer type to find |
| recursive | Whether to recurse into grandchildren (default false) |
Definition at line 263 of file abstractmodelitem.h.
|
inline |
Return the first direct child castable to type T.
| T | Pointer type to find |
Definition at line 275 of file abstractmodelitem.h.
|
inlinevirtual |
Return the icon for this item.
Definition at line 79 of file abstractmodelitem.h.
| AbstractModelItem * AbstractModelItem::insertChild | ( | int | index, |
| AbstractModelItem * | child | ||
| ) |
Insert a child item at the given index.
| index | Position to insert at |
| child | Child item to insert |
|
inline |
Return the model that owns this item.
Definition at line 289 of file abstractmodelitem.h.
|
inline |
Return this item's parent item, or nullptr if it is a root item.
Definition at line 202 of file abstractmodelitem.h.
| int AbstractModelItem::row | ( | ) | const |
Return the row index of this item within its parent's children.
|
inlinevirtual |
Set the entity metadata for this item.
| metadata | New metadata |
Definition at line 73 of file abstractmodelitem.h.
|
inlineprotected |
Set the icon for this item.
| value | Icon to assign |
Definition at line 296 of file abstractmodelitem.h.
|
virtual |
Update this item's data from new entity metadata.
| metadata | New metadata to apply |
|
inlinevirtual |
Update a single cell from a raw variant value (no-op by default).
| headerType | Column header type |
| value | New cell value |
Definition at line 97 of file abstractmodelitem.h.
|
inlinevirtual |
Return the UUID for this item.
Definition at line 77 of file abstractmodelitem.h.
Referenced by AbstractModelItem::List::findByUuid(), and AbstractModelItem::List::indexOfUuid().