diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-07 19:47:31 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-10 10:27:30 +0100 |
| commit | 5765439c7cff4e314a0c5732432bdb7b20e91efd (patch) | |
| tree | f4cc8bcf32876b4850b69c6ec1929061676c5979 /src/modlistview.cpp | |
| parent | 183440d6949578c2c626022d42ee412919a19552 (diff) | |
Alt+Click select/deselect the rows below from a separator.
Diffstat (limited to 'src/modlistview.cpp')
| -rw-r--r-- | src/modlistview.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/modlistview.cpp b/src/modlistview.cpp index 7c67c599..7c770709 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -1311,6 +1311,30 @@ void ModListView::timerEvent(QTimerEvent* event) }
}
+void ModListView::mousePressEvent(QMouseEvent* event)
+{
+ // we call the parent class first so that we can use the actual
+ // selection state of the item after
+ QTreeView::mousePressEvent(event);
+
+ const auto index = indexAt(event->pos());
+
+ if (event->isAccepted()
+ && hasCollapsibleSeparators()
+ && index.isValid() && model()->hasChildren(indexAt(event->pos()))
+ && (event->modifiers() & Qt::AltModifier)) {
+
+ const auto flag = selectionModel()->isSelected(index) ?
+ QItemSelectionModel::Select : QItemSelectionModel::Deselect;
+ const bool expanded = isExpanded(index);
+ const QItemSelection selection(
+ model()->index(0, index.column(), index),
+ model()->index(model()->rowCount(index) - 1, index.column(), index));
+ selectionModel()->select(selection, flag | QItemSelectionModel::Rows);
+ setExpanded(index, expanded);
+ }
+}
+
bool ModListView::event(QEvent* event)
{
if (event->type() == QEvent::KeyPress
|
