|
KanoopGuiQt 1.3.0
Qt GUI utility library
|
|
Extended QAbstractItemModel providing EntityMetadata-based item lookup and header management. More...
#include <abstractitemmodel.h>
Inheritance diagram for AbstractItemModel:
Collaboration diagram for AbstractItemModel:Public Slots | |
| virtual void | clear () |
| Remove all root items from the model. | |
| virtual void | addEntity (const EntityMetadata &metadata) |
| Handle an entity-added event (no-op by default). | |
| virtual void | deleteEntity (const EntityMetadata &metadata) |
| Handle an entity-deleted event (no-op by default). | |
| virtual void | updateEntity (const EntityMetadata &metadata) |
| Handle an entity-updated event (no-op by default). | |
Public Member Functions | |
| AbstractItemModel (QObject *parent=nullptr) | |
| Construct with an optional parent. | |
| AbstractItemModel (const QString &loggingCategory, QObject *parent=nullptr) | |
| Construct with a logging category and optional parent. | |
| virtual | ~AbstractItemModel () |
| Destructor — deletes all root items. | |
| virtual QModelIndexList | indexesOfEntityType (int type) const |
| Return all indexes whose item has the given entity type. | |
| virtual QModelIndexList | indexesOfEntity (int type, const QVariant &data, int role=Qt::DisplayRole) const |
| Return all indexes matching entity type and a role value. | |
| virtual QModelIndexList | indexesOfEntityUuid (const QUuid &uuid) const |
| Return all indexes whose item UUID matches. | |
| virtual QModelIndex | firstIndexOfEntityType (int type) const |
| Return the first index whose item has the given entity type. | |
| virtual QModelIndex | firstIndexOfEntity (int type, const QVariant &data, int role=Qt::DisplayRole) const |
| Return the first index matching entity type and a role value. | |
| virtual QModelIndex | firstIndexOfEntityUuid (const QUuid &uuid) const |
| Return the first index whose item UUID matches. | |
| virtual QModelIndex | firstIndexOfChildEntityType (const QModelIndex &parent, int type, bool recursive=true) const |
| Return the first child index under parent with the given entity type. | |
| virtual QModelIndex | firstIndexOfChildEntityUuid (const QModelIndex &parent, const QUuid &uuid, bool recursive=true) const |
| Return the first child index under parent whose UUID matches. | |
| virtual QModelIndex | firstMatch (const QModelIndex &startSearchIndex, int role, const QVariant &value, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const |
| Return the first match starting from startSearchIndex. | |
| virtual QModelIndex | firstMatch (int role, const QVariant &value, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const |
| Return the first match anywhere in the model. | |
| virtual QModelIndexList | childIndexes (const QModelIndex &parent, int type=-1, bool recursive=true) const |
| Return child indexes under parent, optionally filtered by entity type. | |
| TableHeader::List | columnHeaders () const |
| Return all column headers as a sorted list. | |
| TableHeader | columnHeader (int section) const |
| Return the column header for a given section. | |
| TableHeader | rowHeader (int row) const |
| Return the row header for a given row. | |
| int | columnForHeader (int type) const |
| Return the column index for a header type. | |
| QModelIndexList | getPersistentIndexes () const |
| Return all persistent model indexes. | |
| virtual void | refresh (const QModelIndex &topLeft, const QModelIndex &bottomRight) |
| Emit dataChanged for the rectangular region from topLeft to bottomRight. | |
| virtual QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const override |
| Return the model index for the item at row/column under parent. | |
| virtual QModelIndex | parent (const QModelIndex &child) const override |
| Return the parent index of a child index. | |
| virtual int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
| Return the number of rows under parent. | |
| virtual int | columnCount (const QModelIndex &parent=QModelIndex()) const override |
| Return the number of columns under parent. | |
| virtual QVariant | data (const QModelIndex &index, int role) const override |
| Return the data for the given index and role. | |
| virtual QVariant | headerData (int section, Qt::Orientation orientation, int role) const override |
| Return header data for the given section, orientation, and role. | |
| virtual bool | removeRows (int row, int count, const QModelIndex &parentIndex) override |
| Remove count rows starting at row under parentIndex. | |
| virtual bool | hasChildren (const QModelIndex &parent) const override |
| Return true if parent has child items. | |
| virtual bool | setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role) override |
| Set header data for the given section, orientation, and role. | |
| void | setColumnHeaderVisible (int type, bool visible) |
| Show or hide the column whose header has the given type. | |
Static Public Member Functions | |
| static QString | indexToString (const QModelIndex &index, bool includeText=false) |
| Format a QModelIndex as a debug string. | |
| static QString | toString (const QModelIndex &index, bool includeText=false) |
| Format a QModelIndex as a debug string (static alias). | |
Protected Member Functions | |
| AbstractModelItem::List | rootItems () const |
| Return the list of root items. | |
| AbstractModelItem::List & | rootItemsRef () |
| Return a mutable reference to the root items list. | |
| const AbstractModelItem::List | rootItemsConst () const |
| Return a const copy of the root items list. | |
| int | rootItemCount () const |
| Return the number of root items. | |
| AbstractModelItem * | insertRootItem (int row, AbstractModelItem *item) |
| Insert an item at the given row among root items. | |
| AbstractModelItem * | appendRootItem (AbstractModelItem *item) |
| Append an item to the root items list. | |
| void | appendRootItems (QList< AbstractModelItem * > items) |
| Append multiple items to the root items list. | |
| void | appendColumnHeader (int type, const QString &text) |
| Append a column header with the given type and display text. | |
| void | appendColumnHeader (int type, const QColor &columnTextColor, const QString &text) |
| Append a column header with a custom text color. | |
| void | insertColumnHeader (int type, int index, const QString &text) |
| Insert a column header at the given index. | |
| void | appendAdHocColumnHeader (int type, const QString &value) |
| Append a column header (ad-hoc alias for appendColumnHeader). | |
| void | insertAdHocColumnHeader (int type, int index, const QString &value) |
| Insert a column header at the given index (ad-hoc alias for insertColumnHeader). | |
| void | deleteColumnHeader (int section) |
| Delete the column header at the given section. | |
| void | appendRowHeader (int type, const QString &value=QString()) |
| Append a row header with optional display text. | |
| void | appendAdHocRowHeader (int type, const QString &value) |
| Append a row header (ad-hoc alias for appendRowHeader). | |
| void | setColumnHeaderText (int section, const QString &text) |
| Change the display text of a column header. | |
| void | setColumnHeaderEntityMetadata (int type, const EntityMetadata &metadata) |
| Associate an EntityMetadata with a column header type. | |
| EntityMetadata | columnEntityMetadata (int type) const |
| Retrieve the EntityMetadata for a column header type. | |
| void | setColumnTextColor (int type, const QColor &color) |
| Set the text color for all cells in the column of the given type. | |
| void | deleteRootItem (AbstractModelItem *item) |
| Delete a root item from the model. | |
| void | deleteRootItems (const QUuid &uuid) |
| Delete all root items with the given UUID. | |
| void | deleteRootItems (const EntityMetadata &metadata) |
| Delete all root items matching the given EntityMetadata. | |
| void | deleteItem (const QUuid &uuid) |
| Delete any item (at any level) with the given UUID. | |
| void | updateItemAtIndex (const QModelIndex &itemIndex, const EntityMetadata &metadata) |
| Update the item at itemIndex with new metadata and emit dataChanged. | |
| void | updateItemsAtIndexes (const QModelIndexList &indexes, const EntityMetadata &metadata) |
| Update items at multiple indexes with new metadata. | |
| void | refreshAll () |
| Emit dataChanged for the entire model. | |
| template<typename T > | |
| QList< T > | findItems () const |
| Find all items of type T in the model (root and their children). | |
| QModelIndex | findFirstDirectChild (const QModelIndex &parentIndex, const QVariant &value, int role) const |
| Find the first direct child of parentIndex matching a role/value pair. | |
| TableHeader::IntMap | columnHeadersIntMap () const |
| Return the column headers as an int-keyed map. | |
| TableHeader::IntMap | rowHeadersIntMap () const |
| Return the row headers as an int-keyed map. | |
| void | emitRowChanged (const QModelIndex &rowIndex) |
| Emit dataChanged for all columns of the given row index. | |
Friends | |
| class | AbstractModelItem |
Extended QAbstractItemModel providing EntityMetadata-based item lookup and header management.
Subclass this together with AbstractModelItem to build tree, table, or list models. Column and row headers are managed internally; entity lookup helpers search by type or UUID.
Definition at line 32 of file abstractitemmodel.h.
| AbstractItemModel::AbstractItemModel | ( | const QString & | loggingCategory, |
| QObject * | parent = nullptr |
||
| ) |
Construct with a logging category and optional parent.
| loggingCategory | Category name used for log output |
| parent | Optional QObject parent |
|
inlinevirtual |
Destructor — deletes all root items.
Definition at line 48 of file abstractitemmodel.h.
|
inlinevirtualslot |
Handle an entity-added event (no-op by default).
Definition at line 439 of file abstractitemmodel.h.
|
inlineprotected |
Append a column header (ad-hoc alias for appendColumnHeader).
Definition at line 278 of file abstractitemmodel.h.
|
inlineprotected |
Append a row header (ad-hoc alias for appendRowHeader).
Definition at line 297 of file abstractitemmodel.h.
|
protected |
Append a column header with a custom text color.
| type | Column type identifier |
| columnTextColor | Text color for cells in this column |
| text | Header display text |
|
protected |
Append a column header with the given type and display text.
| type | Column type identifier |
| text | Header display text |
|
protected |
Append an item to the root items list.
| item | Item to append |
|
protected |
Append multiple items to the root items list.
| items | Items to append |
|
protected |
Append a row header with optional display text.
| type | Row type identifier |
| value | Optional display text |
|
virtual |
Return child indexes under parent, optionally filtered by entity type.
| parent | Parent index |
| type | Entity type filter (-1 to return all types) |
| recursive | Whether to search recursively (default true) |
|
overridevirtual |
Return the number of columns under parent.
Reimplemented in AbstractTableModel.
|
protected |
Retrieve the EntityMetadata for a column header type.
| type | Column type identifier |
| int AbstractItemModel::columnForHeader | ( | int | type | ) | const |
Return the column index for a header type.
| type | Header type identifier |
|
inline |
Return the column header for a given section.
| section | Column section index |
Definition at line 156 of file abstractitemmodel.h.
| TableHeader::List AbstractItemModel::columnHeaders | ( | ) | const |
Return all column headers as a sorted list.
|
inlineprotected |
Return the column headers as an int-keyed map.
Definition at line 397 of file abstractitemmodel.h.
|
overridevirtual |
Return the data for the given index and role.
Reimplemented in AbstractListModel, and AbstractTableModel.
|
protected |
Delete the column header at the given section.
| section | Section index to remove |
|
inlinevirtualslot |
Handle an entity-deleted event (no-op by default).
Definition at line 441 of file abstractitemmodel.h.
|
protected |
Delete any item (at any level) with the given UUID.
| uuid | UUID to match |
|
protected |
Delete a root item from the model.
| item | Root item to delete |
|
protected |
Delete all root items matching the given EntityMetadata.
| metadata | Metadata to match |
|
protected |
Delete all root items with the given UUID.
| uuid | UUID to match |
|
protected |
Emit dataChanged for all columns of the given row index.
| rowIndex | Row index whose data changed |
|
protected |
Find the first direct child of parentIndex matching a role/value pair.
| parentIndex | Parent index to search under |
| value | Value to match |
| role | Role to compare |
|
inlineprotected |
Find all items of type T in the model (root and their children).
| T | Pointer type of items to find (must derive from AbstractModelItem) |
Definition at line 374 of file abstractitemmodel.h.
|
virtual |
Return the first child index under parent with the given entity type.
| parent | Parent index to search under |
| type | Entity type to search for |
| recursive | Whether to search recursively (default true) |
|
virtual |
Return the first child index under parent whose UUID matches.
| parent | Parent index to search under |
| uuid | UUID to search for |
| recursive | Whether to search recursively (default true) |
|
virtual |
Return the first index matching entity type and a role value.
| type | Entity type to search for |
| data | Value to match against the given role |
| role | Model role to compare (default Qt::DisplayRole) |
|
virtual |
Return the first index whose item has the given entity type.
| type | Entity type to search for |
|
virtual |
Return the first index whose item UUID matches.
| uuid | UUID to search for |
|
virtual |
Return the first match starting from startSearchIndex.
| startSearchIndex | Index to begin searching from |
| role | Model role to compare |
| value | Value to match |
| flags | Match flags |
|
virtual |
Return the first match anywhere in the model.
| role | Model role to compare |
| value | Value to match |
| flags | Match flags |
| QModelIndexList AbstractItemModel::getPersistentIndexes | ( | ) | const |
Return all persistent model indexes.
|
virtual |
Return all indexes matching entity type and a role value.
| type | Entity type to search for |
| data | Value to match against the given role |
| role | Model role to compare (default Qt::DisplayRole) |
|
virtual |
Return all indexes whose item has the given entity type.
| type | Entity type to search for |
|
virtual |
Return all indexes whose item UUID matches.
| uuid | UUID to search for |
|
static |
Format a QModelIndex as a debug string.
| index | Index to format |
| includeText | Whether to include display text (default false) |
|
inlineprotected |
Insert a column header at the given index (ad-hoc alias for insertColumnHeader).
Definition at line 281 of file abstractitemmodel.h.
|
protected |
Insert a column header at the given index.
| type | Column type identifier |
| index | Position to insert at |
| text | Header display text |
|
protected |
Insert an item at the given row among root items.
| row | Insertion row index |
| item | Item to insert |
|
virtual |
Emit dataChanged for the rectangular region from topLeft to bottomRight.
| topLeft | Top-left corner of the changed region |
| bottomRight | Bottom-right corner of the changed region |
|
inlineprotected |
Return the number of root items.
Definition at line 231 of file abstractitemmodel.h.
|
inlineprotected |
Return the list of root items.
Definition at line 225 of file abstractitemmodel.h.
|
inlineprotected |
Return a const copy of the root items list.
Definition at line 229 of file abstractitemmodel.h.
|
inlineprotected |
Return a mutable reference to the root items list.
Definition at line 227 of file abstractitemmodel.h.
|
inline |
Return the row header for a given row.
| row | Row index |
Definition at line 163 of file abstractitemmodel.h.
|
inlineprotected |
Return the row headers as an int-keyed map.
Definition at line 399 of file abstractitemmodel.h.
|
protected |
Associate an EntityMetadata with a column header type.
| type | Column type identifier |
| metadata | Metadata to associate |
|
protected |
Change the display text of a column header.
| section | Section index to update |
| text | New display text |
| void AbstractItemModel::setColumnHeaderVisible | ( | int | type, |
| bool | visible | ||
| ) |
Show or hide the column whose header has the given type.
| type | Column header type identifier |
| visible | Whether to make the column visible |
|
protected |
Set the text color for all cells in the column of the given type.
| type | Column type identifier |
| color | Text color to apply |
|
static |
Format a QModelIndex as a debug string (static alias).
| index | Index to format |
| includeText | Whether to include display text |
|
inlinevirtualslot |
Handle an entity-updated event (no-op by default).
Definition at line 443 of file abstractitemmodel.h.
|
protected |
Update the item at itemIndex with new metadata and emit dataChanged.
| itemIndex | Index of the item to update |
| metadata | New metadata to apply |
|
protected |
Update items at multiple indexes with new metadata.
| indexes | Indexes of items to update |
| metadata | New metadata to apply |
|
friend |
Definition at line 425 of file abstractitemmodel.h.