QTableView subclass integrating AbstractItemModel with entity metadata helpers.
More...
#include <tableviewbase.h>
|
|
void | clear () |
| | Remove all rows from the view model.
|
| |
|
|
void | horizontalHeaderChanged () |
| | Emitted when the horizontal header is resized.
|
| |
|
void | verticalHeaderChanged () |
| | Emitted when the vertical header is resized.
|
| |
|
void | currentSelectionChanged () |
| | Emitted when the current selection changes.
|
| |
| void | currentIndexChanged (const QModelIndex ¤t, const QModelIndex &previous) |
| | Emitted when the current index changes.
|
| |
|
void | entityAdded (const EntityMetadata &metadata) |
| | Emitted when a row is to be added with the given metadata.
|
| |
|
void | entityDeleted (const EntityMetadata &metadata) |
| | Emitted when an entity row is deleted.
|
| |
|
void | entityUpdated (const EntityMetadata &metadata) |
| | Emitted when an entity row is updated.
|
| |
|
| | TableViewBase (QWidget *parent=nullptr) |
| | Construct with an optional parent widget.
|
| |
|
virtual | ~TableViewBase () |
| | Destructor.
|
| |
| virtual void | setModel (QAbstractItemModel *model) override |
| | Set the model, wrapping it in an internal sort/filter proxy.
|
| |
| int | entityTypeAtPos (const QPoint &pos) |
| | Return the entity type of the item at a view position.
|
| |
| EntityMetadata | currentMetadata () const |
| | Return the EntityMetadata of the currently selected item.
|
| |
| EntityMetadata | metadataAtPos (const QPoint &pos) const |
| | Return the EntityMetadata of the item at a view position.
|
| |
| AbstractItemModel * | sourceModel () const |
| | Return the underlying AbstractItemModel (without the proxy).
|
| |
| QSortFilterProxyModel * | proxyModel () const |
| | Return the internal sort/filter proxy model.
|
| |
| virtual void | deleteRow (const QModelIndex &index) |
| | Delete the row identified by the given model index.
|
| |
| virtual void | addRow (const EntityMetadata &metadata) |
| | Emit entityAdded() for the given metadata (override to customise).
|
| |
| int | rowCount () const |
| | Return the number of rows currently in the view.
|
| |
| QModelIndexList | allRows () const |
| | Return model indexes for all rows in the view.
|
| |
| QModelIndex | findFirstMatch (const QVariant &needle, int role) const |
| | Return the first model index where the given role matches a value.
|
| |
| virtual QModelIndex | firstIndexOfEntityUuid (const QUuid &uuid) const |
| | Return the first index whose item UUID matches.
|
| |
| void | setCurrentUuid (const QUuid &uuid, ScrollHint scrollHint=EnsureVisible) |
| | Select the item with the given UUID and optionally scroll to it.
|
| |
| bool | isIndexVisible (const QModelIndex &index) const |
| | Return whether the given model index is currently visible in the viewport.
|
| |
|
void | restoreHeaderStates () |
| | Restore both horizontal and vertical header states from settings.
|
| |
|
void | restoreHorizontalHeaderState () |
| | Restore horizontal header state (column widths/order) from settings.
|
| |
|
void | restoreVerticalHeaderState () |
| | Restore vertical header state (row heights) from settings.
|
| |
| void | setColumnDelegate (int type, QStyledItemDelegate *delegate) |
| | Assign a custom item delegate to the column of the given header type.
|
| |
|
|
virtual void | currentChanged (const QModelIndex ¤t, const QModelIndex &previous) override |
| | Internal override forwarding current-index changes to currentIndexChanged().
|
| |
QTableView subclass integrating AbstractItemModel with entity metadata helpers.
TableViewBase wraps the source model in a QSortFilterProxyModel and provides helpers for accessing EntityMetadata at positions, navigating by UUID, managing row delegates, and restoring column/row header states.
Definition at line 30 of file tableviewbase.h.
◆ TableViewBase()
| TableViewBase::TableViewBase |
( |
QWidget * |
parent = nullptr | ) |
|
|
explicit |
Construct with an optional parent widget.
- Parameters
-
| parent | Optional QWidget parent |
◆ addRow()
| virtual void TableViewBase::addRow |
( |
const EntityMetadata & |
metadata | ) |
|
|
inlinevirtual |
Emit entityAdded() for the given metadata (override to customise).
- Parameters
-
| metadata | Metadata describing the entity to add |
Definition at line 93 of file tableviewbase.h.
◆ allRows()
| QModelIndexList TableViewBase::allRows |
( |
| ) |
const |
Return model indexes for all rows in the view.
- Returns
- List of all row indexes (first column of each row)
◆ currentIndexChanged
| void TableViewBase::currentIndexChanged |
( |
const QModelIndex & |
current, |
|
|
const QModelIndex & |
previous |
|
) |
| |
|
signal |
Emitted when the current index changes.
- Parameters
-
| current | The newly current index |
| previous | The previously current index |
◆ currentMetadata()
| EntityMetadata TableViewBase::currentMetadata |
( |
| ) |
const |
Return the EntityMetadata of the currently selected item.
- Returns
- EntityMetadata for the current selection
◆ deleteRow()
| virtual void TableViewBase::deleteRow |
( |
const QModelIndex & |
index | ) |
|
|
virtual |
Delete the row identified by the given model index.
- Parameters
-
| index | Model index of the row to delete |
◆ entityTypeAtPos()
| int TableViewBase::entityTypeAtPos |
( |
const QPoint & |
pos | ) |
|
Return the entity type of the item at a view position.
- Parameters
-
- Returns
- Entity type integer, or -1 if no item at that position
◆ findFirstMatch()
| QModelIndex TableViewBase::findFirstMatch |
( |
const QVariant & |
needle, |
|
|
int |
role |
|
) |
| const |
Return the first model index where the given role matches a value.
- Parameters
-
| needle | Value to search for |
| role | Model role to compare |
- Returns
- First matching index, or invalid index if not found
◆ firstIndexOfEntityUuid()
| virtual QModelIndex TableViewBase::firstIndexOfEntityUuid |
( |
const QUuid & |
uuid | ) |
const |
|
virtual |
Return the first index whose item UUID matches.
- Parameters
-
- Returns
- First matching index, or invalid index if not found
◆ isIndexVisible()
| bool TableViewBase::isIndexVisible |
( |
const QModelIndex & |
index | ) |
const |
Return whether the given model index is currently visible in the viewport.
- Parameters
-
| index | Model index to check |
- Returns
- true if the index is within the visible area
◆ metadataAtPos()
| EntityMetadata TableViewBase::metadataAtPos |
( |
const QPoint & |
pos | ) |
const |
Return the EntityMetadata of the item at a view position.
- Parameters
-
- Returns
- EntityMetadata at that position
◆ proxyModel()
| QSortFilterProxyModel * TableViewBase::proxyModel |
( |
| ) |
const |
|
inline |
Return the internal sort/filter proxy model.
- Returns
- Pointer to the proxy model
Definition at line 81 of file tableviewbase.h.
◆ rowCount()
| int TableViewBase::rowCount |
( |
| ) |
const |
Return the number of rows currently in the view.
- Returns
- Row count
◆ setColumnDelegate()
| void TableViewBase::setColumnDelegate |
( |
int |
type, |
|
|
QStyledItemDelegate * |
delegate |
|
) |
| |
Assign a custom item delegate to the column of the given header type.
- Parameters
-
| type | Column header type identifier |
| delegate | Delegate to install |
◆ setCurrentUuid()
| void TableViewBase::setCurrentUuid |
( |
const QUuid & |
uuid, |
|
|
ScrollHint |
scrollHint = EnsureVisible |
|
) |
| |
Select the item with the given UUID and optionally scroll to it.
- Parameters
-
| uuid | UUID of the item to select |
| scrollHint | How to scroll to make the item visible |
◆ setModel()
| virtual void TableViewBase::setModel |
( |
QAbstractItemModel * |
model | ) |
|
|
overridevirtual |
Set the model, wrapping it in an internal sort/filter proxy.
- Parameters
-
◆ sourceModel()
The documentation for this class was generated from the following file: