summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2022-05-19 00:33:37 +0900
committerTomaž Vajngerl <quikee@gmail.com>2022-05-20 06:19:16 +0200
commit66d8951df3c11ead0b9415eb292c3ae88689edf1 (patch)
treeb7cabf8bde6aeb517d17d75eb9813b4d61af65a2 /sfx2
parent09822cf77cdbe32b03553cd05154100b5f2591d0 (diff)
sfx2: use natural string sort for sorting in object inspector
Use a natural string sort for all strings in the object inspector tree view. This is more useful for properties as those can have indices, which are shown as numbers, so having them in natural order makes the tree view easier to digest. Change-Id: I7d036cd755f6595fa302c7a28a005684897f2963 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134541 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/devtools/ObjectInspectorTreeHandler.cxx31
1 files changed, 30 insertions, 1 deletions
diff --git a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
index 79b69d612b79..18c4206e0730 100644
--- a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
+++ b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx
@@ -44,6 +44,9 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/extract.hxx>
+#include <vcl/settings.hxx>
+#include <i18nlangtag/languagetag.hxx>
+
using namespace css;
namespace
@@ -928,6 +931,7 @@ ObjectInspectorTreeHandler::ObjectInspectorTreeHandler(
std::unique_ptr<ObjectInspectorWidgets>& pObjectInspectorWidgets)
: mpObjectInspectorWidgets(pObjectInspectorWidgets)
, mxContext(comphelper::getProcessComponentContext())
+ , mxSorter(mxContext, Application::GetSettings().GetLanguageTag().getLocale())
{
mpObjectInspectorWidgets->mpInterfacesTreeView->connect_expanding(
LINK(this, ObjectInspectorTreeHandler, ExpandingHandlerInterfaces));
@@ -955,6 +959,11 @@ ObjectInspectorTreeHandler::ObjectInspectorTreeHandler(
mpObjectInspectorWidgets->mpPropertiesTreeView->make_sorted();
mpObjectInspectorWidgets->mpMethodsTreeView->make_sorted();
+ setSortFunction(mpObjectInspectorWidgets->mpInterfacesTreeView);
+ setSortFunction(mpObjectInspectorWidgets->mpServicesTreeView);
+ setSortFunction(mpObjectInspectorWidgets->mpPropertiesTreeView);
+ setSortFunction(mpObjectInspectorWidgets->mpMethodsTreeView);
+
mpObjectInspectorWidgets->mpInterfacesTreeView->connect_column_clicked(
LINK(this, ObjectInspectorTreeHandler, HeaderBarClick));
mpObjectInspectorWidgets->mpServicesTreeView->connect_column_clicked(
@@ -987,7 +996,27 @@ ObjectInspectorTreeHandler::ObjectInspectorTreeHandler(
static_cast<int>(nMethodsDigitWidth * 50) };
mpObjectInspectorWidgets->mpMethodsTreeView->set_column_fixed_widths(aMethodsWidths);
- pObjectInspectorWidgets->mpPaned->set_position(160);
+ mpObjectInspectorWidgets->mpPaned->set_position(160);
+}
+
+void ObjectInspectorTreeHandler::setSortFunction(std::unique_ptr<weld::TreeView>& pTreeView)
+{
+ pTreeView->set_sort_func(
+ [this, &pTreeView](const weld::TreeIter& rLeft, const weld::TreeIter& rRight) {
+ return compare(pTreeView, rLeft, rRight);
+ });
+}
+
+sal_Int32 ObjectInspectorTreeHandler::compare(std::unique_ptr<weld::TreeView>& pTreeView,
+ const weld::TreeIter& rLeft,
+ const weld::TreeIter& rRight)
+{
+ int nSortColumn = pTreeView->get_sort_column();
+
+ OUString sLeft = pTreeView->get_text(rLeft, nSortColumn);
+ OUString sRight = pTreeView->get_text(rRight, nSortColumn);
+ sal_Int32 nCompare = mxSorter.compare(sLeft, sRight);
+ return nCompare;
}
void ObjectInspectorTreeHandler::handleExpanding(std::unique_ptr<weld::TreeView>& pTreeView,