[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sc/source sc/uiconfig
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jun 9 19:44:13 UTC 2020
sc/source/ui/dialogs/searchresults.cxx | 31 +++++++++++++++++++++++++++++++
sc/source/ui/inc/searchresults.hxx | 2 ++
sc/uiconfig/scalc/ui/searchresults.ui | 3 +++
3 files changed, 36 insertions(+)
New commits:
commit 79bf8179aaf7bdaef59b27e65bf0430db9aff168
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Jun 9 09:27:56 2020 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Jun 9 21:43:39 2020 +0200
Resolves: tdf#133780 allow sorting search result treeview columns
Change-Id: I7d5b1ffdaf99fd2e28dfd124db0fbbd4036e2dd6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95877
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sc/source/ui/dialogs/searchresults.cxx b/sc/source/ui/dialogs/searchresults.cxx
index 11e670fae161..b1b0e45aec5f 100644
--- a/sc/source/ui/dialogs/searchresults.cxx
+++ b/sc/source/ui/dialogs/searchresults.cxx
@@ -26,6 +26,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"))
@@ -37,6 +38,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()
@@ -176,6 +178,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 de48e1c9c4ac..cf48fb239ece 100644
--- a/sc/source/ui/inc/searchresults.hxx
+++ b/sc/source/ui/inc/searchresults.hxx
@@ -24,11 +24,13 @@ class SearchResultsDlg : public SfxDialogController
OUString aSkipped;
SfxBindings* 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>
More information about the Libreoffice-commits
mailing list