: QTreeView subclass that add ParaView specific customizations.
pqTreeView adds ParaView specific customizations to the QTreeView. These include the following:
- Auto-resize: Oftentimes we want the view to as compact as possible, but if has up to a certain number of items, it should grow to fit those items so that the vertical scroll bars don't show up. This is supported using the
MaximumRowCountBeforeScrolling
property. The pqTreeView will grown in size vertically to fit the number of items indicated.
- Avoid grabbing scroll focus: Wheel events are not handled by the widget unless the widget has focus. Together with change in focus policy to Qt::StrongFocus instead of the default Qt::WheelFocus, we improve the widget scroll behavior when nested in other scrollable panels.
- Avoid changing selection state on check-state toggles: Disables updating selection when user toggle check state of any item (see paraview/paraview#18157 for details).
- **Toggle check-state for selected items: If user selected multiple items, and toggles check-state for one of the selected item, the check-state for all selected items is changed match the toggled item (see paraview/paraview#18157 for details).
Definition at line 34 of file pqTreeView.h.
QItemSelectionModel::SelectionFlags pqTreeView::selectionCommand |
( |
const QModelIndex & |
index, |
|
|
const QEvent * |
event = nullptr |
|
) |
| const |
|
overrideprotected |
We need to change two things about how Qt manages toggling check state of a selected item (see paraview/paraview#18150).
These two overrides help use do that.
First, by overriding selectionCommand
, we tell QAbstractItemView to not update selection state in mouse-release. This stops the current selection state being changed when user edits (e.g. toggles check state) of any item.
Second, by override edit
, if the edit was triggered because user clicked on a selected item and then toggled its check state, we look at all currently selected checkable items and then set their checkstate to match that of the trigger item.
bool pqTreeView::edit |
( |
const QModelIndex & |
index, |
|
|
EditTrigger |
trigger, |
|
|
QEvent * |
event |
|
) |
| |
|
overrideprotected |
We need to change two things about how Qt manages toggling check state of a selected item (see paraview/paraview#18150).
These two overrides help use do that.
First, by overriding selectionCommand
, we tell QAbstractItemView to not update selection state in mouse-release. This stops the current selection state being changed when user edits (e.g. toggles check state) of any item.
Second, by override edit
, if the edit was triggered because user clicked on a selected item and then toggled its check state, we look at all currently selected checkable items and then set their checkstate to match that of the trigger item.