From 6344bb8b24d8250508f29457508f0daf479e5b4c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Caol=C3=A1n=20McNamara?= Date: Thu, 21 Jul 2022 09:06:19 +0100 Subject: [PATCH] Resolves: tdf#148743 TOC->Edit Index->Assign Styles; Styles aren't sorted Change-Id: I1ec804d315f487d7bd1138681ab8e8ae60f21a52 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137306 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos --- sw/source/ui/index/cnttab.cxx | 25 +++++++++++++++++++++++++ sw/uiconfig/swriter/ui/assignstylesdialog.ui | 3 +-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 25d1d33ceaab..dc31fdd5d156 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -484,6 +484,7 @@ class SwAddStylesDlg_Impl : public SfxDialogController DECL_LINK(KeyInput, const KeyEvent&, bool); DECL_LINK(TreeSizeAllocHdl, const Size&, void); DECL_LINK(RadioToggleOnHdl, const weld::TreeView::iter_col&, void); + DECL_LINK(HeaderBarClick, int, void); public: SwAddStylesDlg_Impl(weld::Window* pParent, SwWrtShell const & rWrtSh, OUString rStringArr[]); @@ -507,6 +508,7 @@ SwAddStylesDlg_Impl::SwAddStylesDlg_Impl(weld::Window* pParent, m_xHeaderTree->connect_size_allocate(LINK(this, SwAddStylesDlg_Impl, TreeSizeAllocHdl)); m_xHeaderTree->enable_toggle_buttons(weld::ColumnToggleType::Radio); m_xHeaderTree->connect_toggled(LINK(this, SwAddStylesDlg_Impl, RadioToggleOnHdl)); + m_xHeaderTree->connect_column_clicked(LINK(this, SwAddStylesDlg_Impl, HeaderBarClick)); std::vector aWidths { @@ -578,11 +580,34 @@ SwAddStylesDlg_Impl::SwAddStylesDlg_Impl(weld::Window* pParent, } } } + m_xHeaderTree->make_sorted(); + m_xHeaderTree->set_sort_column(0); + m_xHeaderTree->set_sort_order(true); + m_xHeaderTree->set_sort_indicator(TRISTATE_TRUE, 0); + m_xHeaderTree->select(0); m_xHeaderTree->connect_key_release(LINK(this, SwAddStylesDlg_Impl, KeyInput)); } +IMPL_LINK(SwAddStylesDlg_Impl, HeaderBarClick, int, nColumn, void) +{ + bool bSortAtoZ = m_xHeaderTree->get_sort_order(); + + //set new arrow positions in headerbar + if (nColumn == m_xHeaderTree->get_sort_column()) + { + bSortAtoZ = !bSortAtoZ; + m_xHeaderTree->set_sort_order(bSortAtoZ); + } + + if (nColumn != -1) + { + //sort lists + m_xHeaderTree->set_sort_indicator(bSortAtoZ ? TRISTATE_TRUE : TRISTATE_FALSE, nColumn); + } +} + IMPL_LINK(SwAddStylesDlg_Impl, TreeSizeAllocHdl, const Size&, rSize, void) { auto nWidth = rSize.Width() - Application::GetSettings().GetStyleSettings().GetScrollBarSize(); diff --git a/sw/uiconfig/swriter/ui/assignstylesdialog.ui b/sw/uiconfig/swriter/ui/assignstylesdialog.ui index 1ed5cbb56e65..1e9f52faf87f 100644 --- a/sw/uiconfig/swriter/ui/assignstylesdialog.ui +++ b/sw/uiconfig/swriter/ui/assignstylesdialog.ui @@ -266,11 +266,10 @@ + True True 6 Style - True - 0 -- 2.11.4.GIT