summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-06-09 09:27:56 +0100
committerEike Rathke <erack@redhat.com>2020-06-16 17:58:52 +0200
commite8a4fae1cdc2373bfb1fd9e5f8ac55499f58f9a5 (patch)
tree532156ef2d0d10e8e51b7154fcc43806b0a503bd
parentc1638c1012593f6d6336a9d94c73fb074fed6a47 (diff)
Resolves: tdf#133780 allow sorting search result treeview columns
Change-Id: I7d5b1ffdaf99fd2e28dfd124db0fbbd4036e2dd6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95878 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/source/ui/dialogs/searchresults.cxx31
-rw-r--r--sc/source/ui/inc/searchresults.hxx2
-rw-r--r--sc/uiconfig/scalc/ui/searchresults.ui3
3 files changed, 36 insertions, 0 deletions
diff --git a/sc/source/ui/dialogs/searchresults.cxx b/sc/source/ui/dialogs/searchresults.cxx
index 8b896b466ab6..3604e1599a16 100644
--- a/sc/source/ui/dialogs/searchresults.cxx
+++ b/sc/source/ui/dialogs/searchresults.cxx
@@ -24,6 +24,7 @@ SearchResultsDlg::SearchResultsDlg(SfxBindings* _pBindings, weld::Window* pParen
, aSkipped(ScResId(SCSTR_SKIPPED))
, mpBindings(_pBindings)
, mpDoc(nullptr)
+ , mbSorted(false)
, mxList(m_xBuilder->weld_tree_view("results"))
, mxSearchResults(m_xBuilder->weld_label("lbSearchResults"))
, mxShowDialog(m_xBuilder->weld_check_button("cbShow"))
@@ -35,6 +36,7 @@ SearchResultsDlg::SearchResultsDlg(SfxBindings* _pBindings, weld::Window* pParen
aWidths.push_back(mxList->get_approximate_digit_width() * 10);
mxList->set_column_fixed_widths(aWidths);
mxList->connect_changed(LINK(this, SearchResultsDlg, ListSelectHdl));
+ mxList->connect_column_clicked(LINK(this, SearchResultsDlg, HeaderBarClick));
}
SearchResultsDlg::~SearchResultsDlg()
@@ -161,6 +163,35 @@ void SearchResultsDlg::Close()
SfxDialogController::Close();
}
+IMPL_LINK(SearchResultsDlg, HeaderBarClick, int, nColumn, void)
+{
+ if (!mbSorted)
+ {
+ mxList->make_sorted();
+ mbSorted = true;
+ }
+
+ bool bSortAtoZ = mxList->get_sort_order();
+
+ //set new arrow positions in headerbar
+ if (nColumn == mxList->get_sort_column())
+ {
+ bSortAtoZ = !bSortAtoZ;
+ mxList->set_sort_order(bSortAtoZ);
+ }
+ else
+ {
+ mxList->set_sort_indicator(TRISTATE_INDET, mxList->get_sort_column());
+ mxList->set_sort_column(nColumn);
+ }
+
+ if (nColumn != -1)
+ {
+ //sort lists
+ mxList->set_sort_indicator(bSortAtoZ ? TRISTATE_TRUE : TRISTATE_FALSE, nColumn);
+ }
+}
+
IMPL_LINK_NOARG( SearchResultsDlg, ListSelectHdl, weld::TreeView&, void )
{
if (!mpDoc)
diff --git a/sc/source/ui/inc/searchresults.hxx b/sc/source/ui/inc/searchresults.hxx
index 137b999d967c..a0ca894141d9 100644
--- a/sc/source/ui/inc/searchresults.hxx
+++ b/sc/source/ui/inc/searchresults.hxx
@@ -24,11 +24,13 @@ class SearchResultsDlg : public SfxDialogController
OUString const aSkipped;
SfxBindings* const mpBindings;
ScDocument* mpDoc;
+ bool mbSorted;
std::unique_ptr<weld::TreeView> mxList;
std::unique_ptr<weld::Label> mxSearchResults;
std::unique_ptr<weld::CheckButton> mxShowDialog;
DECL_LINK(ListSelectHdl, weld::TreeView&, void);
+ DECL_LINK(HeaderBarClick, int, void);
DECL_STATIC_LINK(SearchResultsDlg, OnShowToggled, weld::ToggleButton&, void);
public:
SearchResultsDlg(SfxBindings* _pBindings, weld::Window* pParent);
diff --git a/sc/uiconfig/scalc/ui/searchresults.ui b/sc/uiconfig/scalc/ui/searchresults.ui
index cb8fbaf44e7e..ca56a9950a7f 100644
--- a/sc/uiconfig/scalc/ui/searchresults.ui
+++ b/sc/uiconfig/scalc/ui/searchresults.ui
@@ -100,6 +100,7 @@
<property name="resizable">True</property>
<property name="spacing">6</property>
<property name="title" translatable="yes" context="searchresults|sheet">Sheet</property>
+ <property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderer1"/>
<attributes>
@@ -113,6 +114,7 @@
<property name="resizable">True</property>
<property name="spacing">6</property>
<property name="title" translatable="yes" context="searchresults|cell">Cell</property>
+ <property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderer2"/>
<attributes>
@@ -126,6 +128,7 @@
<property name="resizable">True</property>
<property name="spacing">6</property>
<property name="title" translatable="yes" context="searchresults|content">Content</property>
+ <property name="clickable">True</property>
<child>
<object class="GtkCellRendererText" id="cellrenderer3"/>
<attributes>