A QTreeView that clears its selection, and emits emptyClicked(), when the user clicks empty space or an already-selected item.
More...
#include <deselectabletreeview.h>
|
| void | emptyClicked () |
| | Emitted after deselect() has cleared the selection because of a single click on empty space or on a selected row; MainWindow clears the password panel in response.
|
|
| | DeselectableTreeView (QWidget *parent) |
| | Construct the view and arm the single-shot deselect timer.
|
|
| ~DeselectableTreeView () override=default |
| | Default destructor.
|
|
| void | mousePressEvent (QMouseEvent *event) override |
| | Remember whether the pressed row was already selected and cancel any pending deselect from the previous click.
|
| void | mouseReleaseEvent (QMouseEvent *event) override |
| | Let QTreeView handle the release at once, then, if the press was on a selected row and the release is over empty space or a still selected row, start deselectTimer.
|
| void | deselect () |
| | Timer slot: clear the selection and current index and emit emptyClicked(), unless a double-click happened in the meantime.
|
| void | mouseDoubleClickEvent (QMouseEvent *event) override |
| | Cancel the pending deselect so the double-click opens the entry instead of clearing the selection.
|
A QTreeView that clears its selection, and emits emptyClicked(), when the user clicks empty space or an already-selected item.
The press records whether the row under the pointer was selected, the release handles selection immediately and arms a single-shot timer for the platform's double-click interval, and only when no double-click arrives in that time does deselect() clear the selection. Opening an entry by double-click therefore always wins over deselecting it.
Definition at line 29 of file deselectabletreeview.h.
◆ DeselectableTreeView()
| DeselectableTreeView::DeselectableTreeView |
( |
QWidget * | parent | ) |
|
|
inlineexplicit |
Construct the view and arm the single-shot deselect timer.
- Parameters
-
| parent | Parent widget forwarded to QTreeView. |
Definition at line 37 of file deselectabletreeview.h.
◆ deselect()
| void DeselectableTreeView::deselect |
( |
| ) |
|
|
inlineprivate |
◆ emptyClicked
| void DeselectableTreeView::emptyClicked |
( |
| ) |
|
|
signal |
Emitted after deselect() has cleared the selection because of a single click on empty space or on a selected row; MainWindow clears the password panel in response.
◆ mouseDoubleClickEvent()
| void DeselectableTreeView::mouseDoubleClickEvent |
( |
QMouseEvent * | event | ) |
|
|
inlineoverrideprivate |
Cancel the pending deselect so the double-click opens the entry instead of clearing the selection.
- Parameters
-
| event | The double-click; forwarded to QTreeView. |
Definition at line 133 of file deselectabletreeview.h.
◆ mousePressEvent()
| void DeselectableTreeView::mousePressEvent |
( |
QMouseEvent * | event | ) |
|
|
inlineoverrideprivate |
Remember whether the pressed row was already selected and cancel any pending deselect from the previous click.
- Parameters
-
| event | The mouse press; forwarded to QTreeView. |
Definition at line 77 of file deselectabletreeview.h.
◆ mouseReleaseEvent()
| void DeselectableTreeView::mouseReleaseEvent |
( |
QMouseEvent * | event | ) |
|
|
inlineoverrideprivate |
Let QTreeView handle the release at once, then, if the press was on a selected row and the release is over empty space or a still selected row, start deselectTimer.
- Parameters
-
| event | The mouse release; forwarded to QTreeView first. |
Definition at line 92 of file deselectabletreeview.h.
◆ clickSelected
| bool DeselectableTreeView::clickSelected = false |
|
private |
Whether the row under the last press was already selected; read and reset by the matching release.
Definition at line 65 of file deselectabletreeview.h.
◆ deselectTimer
| QTimer DeselectableTreeView::deselectTimer |
|
private |
◆ doubleClickHappened
| bool DeselectableTreeView::doubleClickHappened = false |
|
private |
The documentation for this class was generated from the following file: