summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-11-28 23:21:47 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2024-11-29 12:03:59 +0100
commit32642136ad7ba0426f71d335730a3afe02524215 (patch)
tree8a99d0d594252ee64ca01a1153e930ab623a5080
parent1f41481fe987b3c183ac3edbd946ecff38721a79 (diff)
tdf#130857 qt weld: Implement QtInstanceTreeView::set_selection_mode
Change-Id: I1b41a57ccdda4cdbd8a3a8ab3dbde495a51df80e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177508 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
-rw-r--r--vcl/inc/qt5/QtInstanceTreeView.hxx3
-rw-r--r--vcl/qt5/QtInstanceTreeView.cxx24
2 files changed, 25 insertions, 2 deletions
diff --git a/vcl/inc/qt5/QtInstanceTreeView.hxx b/vcl/inc/qt5/QtInstanceTreeView.hxx
index 594168acc5bf..5cd107dc4862 100644
--- a/vcl/inc/qt5/QtInstanceTreeView.hxx
+++ b/vcl/inc/qt5/QtInstanceTreeView.hxx
@@ -180,6 +180,9 @@ public:
using QtInstanceWidget::set_sensitive;
using QtInstanceWidget::get_sensitive;
+
+private:
+ static QAbstractItemView::SelectionMode mapSelectionMode(SelectionMode eMode);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/qt5/QtInstanceTreeView.cxx b/vcl/qt5/QtInstanceTreeView.cxx
index d462def967f6..7cda3a3694ad 100644
--- a/vcl/qt5/QtInstanceTreeView.cxx
+++ b/vcl/qt5/QtInstanceTreeView.cxx
@@ -515,9 +515,11 @@ void QtInstanceTreeView::set_column_title(int, const OUString&)
assert(false && "Not implemented yet");
}
-void QtInstanceTreeView::set_selection_mode(SelectionMode)
+void QtInstanceTreeView::set_selection_mode(SelectionMode eMode)
{
- assert(false && "Not implemented yet");
+ SolarMutexGuard g;
+ GetQtInstance().RunInMainThread(
+ [&] { m_pTreeView->setSelectionMode(mapSelectionMode(eMode)); });
}
int QtInstanceTreeView::count_selected_rows() const
@@ -569,4 +571,22 @@ weld::TreeView* QtInstanceTreeView::get_drag_source() const
return nullptr;
}
+QAbstractItemView::SelectionMode QtInstanceTreeView::mapSelectionMode(SelectionMode eMode)
+{
+ switch (eMode)
+ {
+ case SelectionMode::NONE:
+ return QAbstractItemView::NoSelection;
+ case SelectionMode::Single:
+ return QAbstractItemView::SingleSelection;
+ case SelectionMode::Range:
+ return QAbstractItemView::ContiguousSelection;
+ case SelectionMode::Multiple:
+ return QAbstractItemView::ExtendedSelection;
+ default:
+ assert(false && "unhandled selection mode");
+ return QAbstractItemView::SingleSelection;
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */