|
KanoopGuiQt 1.3.0
Qt GUI utility library
|
|
QTreeView subclass integrating AbstractItemModel with rich navigation helpers. More...
#include <treeviewbase.h>
Inheritance diagram for TreeViewBase:
Collaboration diagram for TreeViewBase:Public Slots | |
| virtual void | refreshVisibleColumns (const QList< int > &columns) |
| Refresh the display of a set of columns. | |
| virtual void | refreshVisibleIndexes (const QModelIndexList &indexes) |
| Refresh the display of a set of source model indexes. | |
| virtual void | refreshIndex (const QModelIndex &sourceIndex) |
| Refresh a single source model index. | |
| virtual void | clear () |
| Remove all items from the view model. | |
Signals | |
| void | itemProgramaticallySelected (const QModelIndex &index) |
| Emitted when an item is selected programmatically. | |
| void | headerChanged () |
| Emitted when the header is resized or reordered. | |
| void | currentSelectionChanged () |
| Emitted when the current selection changes. | |
| void | currentIndexChanged (const QModelIndex &index) |
| Emitted when the current index changes. | |
| void | entityAdded (const EntityMetadata &metadata) |
| Emitted when an entity is added. | |
| void | entityDeleted (const EntityMetadata &metadata) |
| Emitted when an entity is deleted. | |
| void | entityUpdated (const EntityMetadata &metadata) |
| Emitted when an entity is updated. | |
Public Member Functions | |
| TreeViewBase (QWidget *parent=nullptr) | |
| Construct with an optional parent widget. | |
| int | entityTypeAtPos (const QPoint &pos) |
| Return the entity type of the item at a view position. | |
| virtual EntityMetadata | currentMetadata () const |
| Return the EntityMetadata of the currently selected item. | |
| virtual EntityMetadata | metadataAtPos (const QPoint &pos) const |
| Return the EntityMetadata of the item at a view position. | |
| virtual QModelIndex | firstIndexOfEntityUuid (const QUuid &uuid) const |
| Return the first index whose item UUID matches. | |
| virtual QModelIndexList | indexesOfUuid (const QUuid &uuid) const |
| Return all indexes whose item UUID matches. | |
| virtual void | setCurrentUuid (const QUuid &uuid, ScrollHint scrollHint=EnsureVisible) |
| Select the item with the given UUID and optionally scroll to it. | |
| virtual void | setCurrentIndex (const QModelIndex &index, ScrollHint scrollHint=EnsureVisible) |
| Set the current index and optionally scroll to it. | |
| virtual QModelIndex | findNextMatch (const QString &text, const QModelIndex &fromIndex) const |
| Find the next index whose display text matches, searching forward. | |
| virtual QModelIndex | findPreviousMatch (const QString &text, const QModelIndex &fromIndex) const |
| Find the previous index whose display text matches, searching backward. | |
| virtual QModelIndex | finalChildIndex (const QModelIndex &from) const |
| Return the deepest last child of the given index. | |
| virtual QModelIndex | nextIndex (const QModelIndex &from) const |
| Return the next index in display order after from. | |
| virtual QModelIndex | previousIndex (const QModelIndex &from) const |
| Return the previous index in display order before from. | |
| virtual QModelIndexList | matchBackwards (const QModelIndex &start, int role, const QVariant &value, int hits=1, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const |
| Search backward from start for indexes matching a role value. | |
| QModelIndex | currentSourceIndex () const |
| Return the current source model index (mapped through the proxy). | |
| QByteArray | saveState () const |
| Save the header and expansion state to a byte array. | |
| void | restoreState (const QByteArray &state) |
| Restore header and expansion state from a byte array. | |
| void | restoreHeaderStates () |
| Restore horizontal header state (column widths/order) from settings. | |
| virtual void | setModel (QAbstractItemModel *model) override |
| Set the model, wrapping it in an internal sort/filter proxy. | |
| virtual void | setSelectionModel (QItemSelectionModel *selectionModel) override |
| Set the selection model. | |
| AbstractItemModel * | sourceModel () const |
| Return the underlying AbstractItemModel (without the proxy). | |
| QSortFilterProxyModel * | proxyModel () const |
| Return the internal sort/filter proxy model. | |
| void | collapseRecursively (const QModelIndex &index, int depth=-1) |
| Recursively collapse index and all its descendants up to a depth limit. | |
| bool | isLeafExpanded (const QModelIndex &index, bool recursive=true) const |
| Return whether the deepest expanded leaf under index is expanded. | |
| bool | isIndexVisible (const QModelIndex &index) const |
| Return whether the given index is visible in the current viewport. | |
| void | setColumnDelegate (int type, QStyledItemDelegate *delegate) |
| Assign a custom item delegate to the column of the given header type. | |
| int | columnForHeaderType (int headerType) const |
| Return the column index for a given header type. | |
| void | setColumnTypesVisible (const QList< int > &headerTypes, bool visible, bool exclusive=false) |
| Show or hide columns identified by header types. | |
| void | setColumnsVisible (const QList< int > &columns, bool visible, bool exclusive=false) |
| Show or hide columns by column index. | |
Protected Member Functions | |
| EntityMetadata | findCurrentParent (int entityMetadataType) const |
| Walk ancestors of the current index to find one with the given entity type. | |
| EntityMetadata | findFirstParent (const QModelIndex &index, int entityMetadataType) const |
| Walk ancestors of index to find one with the given entity type. | |
| QModelIndexList | findParents (const QModelIndex &index) const |
| Return all ancestor indexes of index. | |
| QModelIndexList | mapToSource (const QModelIndexList &indexes) const |
| Map a list of view indexes to their source model equivalents. | |
| virtual void | addHeaderContextMenuItems (QMenu *menu, const QPoint &globalPos) |
| Override to add application-specific items to the header context menu. | |
QTreeView subclass integrating AbstractItemModel with rich navigation helpers.
TreeViewBase wraps its source model in a QSortFilterProxyModel and provides helpers for UUID-based navigation, text-based forward/backward search, recursive collapse, column visibility management, header state persistence, and delegate assignment.
Definition at line 31 of file treeviewbase.h.
| TreeViewBase::TreeViewBase | ( | QWidget * | parent = nullptr | ) |
Construct with an optional parent widget.
| parent | Optional QWidget parent |
|
inlineprotectedvirtual |
Override to add application-specific items to the header context menu.
| menu | Menu to populate |
| globalPos | Global cursor position when the menu was requested |
Definition at line 294 of file treeviewbase.h.
| void TreeViewBase::collapseRecursively | ( | const QModelIndex & | index, |
| int | depth = -1 |
||
| ) |
Recursively collapse index and all its descendants up to a depth limit.
| index | Root index to collapse from |
| depth | Maximum depth to collapse (-1 for unlimited) |
| int TreeViewBase::columnForHeaderType | ( | int | headerType | ) | const |
Return the column index for a given header type.
| headerType | Header type identifier |
|
signal |
Emitted when the current index changes.
| index | The newly current index |
|
virtual |
Return the EntityMetadata of the currently selected item.
| QModelIndex TreeViewBase::currentSourceIndex | ( | ) | const |
Return the current source model index (mapped through the proxy).
| int TreeViewBase::entityTypeAtPos | ( | const QPoint & | pos | ) |
Return the entity type of the item at a view position.
| pos | View-local position |
|
virtual |
Return the deepest last child of the given index.
| from | Starting index |
|
protected |
Walk ancestors of the current index to find one with the given entity type.
| entityMetadataType | Entity type to search for |
|
protected |
Walk ancestors of index to find one with the given entity type.
| index | Starting index |
| entityMetadataType | Entity type to search for |
|
virtual |
Find the next index whose display text matches, searching forward.
| text | Text to search for |
| fromIndex | Starting index for the search |
|
protected |
Return all ancestor indexes of index.
| index | Starting index |
|
virtual |
Find the previous index whose display text matches, searching backward.
| text | Text to search for |
| fromIndex | Starting index for the backward search |
|
virtual |
Return the first index whose item UUID matches.
| uuid | UUID to search for |
|
virtual |
Return all indexes whose item UUID matches.
| uuid | UUID to search for |
| bool TreeViewBase::isIndexVisible | ( | const QModelIndex & | index | ) | const |
Return whether the given index is visible in the current viewport.
| index | Index to check |
| bool TreeViewBase::isLeafExpanded | ( | const QModelIndex & | index, |
| bool | recursive = true |
||
| ) | const |
Return whether the deepest expanded leaf under index is expanded.
| index | Root index to check |
| recursive | Whether to check recursively |
|
protected |
Map a list of view indexes to their source model equivalents.
| indexes | Proxy model indexes to map |
|
virtual |
Search backward from start for indexes matching a role value.
| start | Index to begin searching from |
| role | Model role to compare |
| value | Value to match |
| hits | Maximum number of matches to return |
| flags | Match flags |
|
virtual |
Return the EntityMetadata of the item at a view position.
| pos | View-local position |
|
virtual |
Return the next index in display order after from.
| from | Reference index |
|
virtual |
Return the previous index in display order before from.
| from | Reference index |
|
inline |
Return the internal sort/filter proxy model.
Definition at line 183 of file treeviewbase.h.
|
virtualslot |
Refresh a single source model index.
| sourceIndex | Source model index to refresh |
|
virtualslot |
Refresh the display of a set of columns.
| columns | Column indexes to refresh |
|
virtualslot |
Refresh the display of a set of source model indexes.
| indexes | Source model indexes to refresh |
| void TreeViewBase::restoreState | ( | const QByteArray & | state | ) |
Restore header and expansion state from a byte array.
| state | Previously saved state |
| QByteArray TreeViewBase::saveState | ( | ) | const |
Save the header and expansion state to a byte array.
| void TreeViewBase::setColumnDelegate | ( | int | type, |
| QStyledItemDelegate * | delegate | ||
| ) |
Assign a custom item delegate to the column of the given header type.
| type | Column header type identifier |
| delegate | Delegate to install |
| void TreeViewBase::setColumnsVisible | ( | const QList< int > & | columns, |
| bool | visible, | ||
| bool | exclusive = false |
||
| ) |
Show or hide columns by column index.
| columns | List of column indexes |
| visible | true to show, false to hide |
| exclusive | If true, hide all other columns |
| void TreeViewBase::setColumnTypesVisible | ( | const QList< int > & | headerTypes, |
| bool | visible, | ||
| bool | exclusive = false |
||
| ) |
Show or hide columns identified by header types.
| headerTypes | List of header type identifiers |
| visible | true to show, false to hide |
| exclusive | If true, hide all other columns |
|
virtual |
Set the current index and optionally scroll to it.
| index | Index to make current |
| scrollHint | How to scroll to make the item visible |
|
virtual |
Select the item with the given UUID and optionally scroll to it.
| uuid | UUID of the item to select |
| scrollHint | How to scroll to make the item visible |
|
overridevirtual |
Set the model, wrapping it in an internal sort/filter proxy.
| model | Model to display (should derive from AbstractItemModel) |
|
overridevirtual |
Set the selection model.
| selectionModel | Selection model to use |
|
inline |
Return the underlying AbstractItemModel (without the proxy).
Definition at line 177 of file treeviewbase.h.