sw/source/ui/index/cnttab.cxx | 25 +++++++++++++++++++++++++ sw/uiconfig/swriter/ui/assignstylesdialog.ui | 3 +-- 2 files changed, 26 insertions(+), 2 deletions(-)
New commits: commit 8525e8bd9bc90139c97251f5fb49cf37dc07dbdc Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Jul 21 09:06:19 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Jul 21 17:15:21 2022 +0200 Resolves: tdf#148743 TOC->Edit Index->Assign Styles; Styles aren't sorted Change-Id: I1ec804d315f487d7bd1138681ab8e8ae60f21a52 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137303 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 759dccc46721..f4baaa48a463 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -487,6 +487,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[]); @@ -510,6 +511,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<int> aWidths { @@ -581,11 +583,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 c87d3f40c9a5..71e377bbd041 100644 --- a/sw/uiconfig/swriter/ui/assignstylesdialog.ui +++ b/sw/uiconfig/swriter/ui/assignstylesdialog.ui @@ -267,11 +267,10 @@ </child> <child> <object class="GtkTreeViewColumn" id="treeviewcolumn1"> + <property name="clickable">True</property> <property name="resizable">True</property> <property name="spacing">6</property> <property name="title" translatable="yes" context="assignstylesdialog|stylecolumn">Style</property> - <property name="sort-indicator">True</property> - <property name="sort-column-id">0</property> <child> <object class="GtkCellRendererText" id="cellrenderer1"/> <attributes>