sw/source/ui/index/cnttab.cxx                |   25 +++++++++++++++++++++++++
 sw/uiconfig/swriter/ui/assignstylesdialog.ui |    3 +--
 2 files changed, 26 insertions(+), 2 deletions(-)

New commits:
commit 47e9c7d433e7f23019ea4ae68e08d82ae9c7e3e3
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Jul 21 09:06:19 2022 +0100
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Sat Jul 23 14:11:43 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/+/137192
    Tested-by: Jenkins
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx
index 1aac737639b9..f73c234784f0 100644
--- a/sw/source/ui/index/cnttab.cxx
+++ b/sw/source/ui/index/cnttab.cxx
@@ -485,6 +485,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[]);
@@ -508,6 +509,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
     {
@@ -579,11 +581,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 f3d53261511b..a5a412c35c86 100644
--- a/sw/uiconfig/swriter/ui/assignstylesdialog.ui
+++ b/sw/uiconfig/swriter/ui/assignstylesdialog.ui
@@ -266,11 +266,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>

Reply via email to