cui/source/customize/SvxNotebookbarConfigPage.cxx |   52 +++++++++-------------
 cui/source/inc/cfg.hxx                            |    4 +
 2 files changed, 26 insertions(+), 30 deletions(-)

New commits:
commit 9b6b134b3e605236e90aca089867f08d659a6076
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Mon Nov 25 13:31:22 2019 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Tue Nov 26 15:34:48 2019 +0100

    tdf#126043 use bulk_insert_for_each
    
    Change-Id: I68b5a7805a2e0a76d1871448a011fdde7f7cdb1e
    Reviewed-on: https://gerrit.libreoffice.org/83685
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/cui/source/customize/SvxNotebookbarConfigPage.cxx 
b/cui/source/customize/SvxNotebookbarConfigPage.cxx
index b74353a95758..c8270b941385 100644
--- a/cui/source/customize/SvxNotebookbarConfigPage.cxx
+++ b/cui/source/customize/SvxNotebookbarConfigPage.cxx
@@ -217,8 +217,9 @@ short SvxNotebookbarConfigPage::QueryReset()
 
 void SvxConfigPage::InsertEntryIntoNotebookbarTabUI(const OUString& sClassId,
                                                     const OUString& sUIItemId,
-                                                    const OUString& 
sUIItemCommand, int nPos,
-                                                    int nStartCol)
+                                                    const OUString& 
sUIItemCommand,
+                                                    weld::TreeView& rTreeView,
+                                                    weld::TreeIter& rIter, int 
nStartCol)
 {
     css::uno::Reference<css::container::XNameAccess> m_xCommandToLabelMap,
         m_xGlobalCommandToLabelMap;
@@ -264,7 +265,7 @@ void SvxConfigPage::InsertEntryIntoNotebookbarTabUI(const 
OUString& sClassId,
     if (sClassId == "GtkSeparatorMenuItem" || sClassId == "GtkSeparator")
     {
         OUString sDataInTree = "--------------------------------------------";
-        m_xContentsListBox->set_text(nPos, sDataInTree, nStartCol + 1);
+        rTreeView.set_text(rIter, sDataInTree, nStartCol + 1);
     }
     else
     {
@@ -272,9 +273,9 @@ void SvxConfigPage::InsertEntryIntoNotebookbarTabUI(const 
OUString& sClassId,
             aName = sUIItemId;
         auto xImage = GetSaveInData()->GetImage(sUIItemCommand);
         if (xImage.is())
-            m_xContentsListBox->set_image(nPos, xImage, nStartCol);
-        m_xContentsListBox->set_text(nPos, aName, nStartCol + 1);
-        m_xContentsListBox->set_id(nPos, sUIItemId);
+            rTreeView.set_image(rIter, xImage, nStartCol);
+        rTreeView.set_text(rIter, aName, nStartCol + 1);
+        rTreeView.set_id(rIter, sUIItemId);
     }
 }
 
@@ -434,7 +435,6 @@ void SvxNotebookbarConfigPage::SelectElement()
     xmlDocPtr pDoc = xmlParseFile(sUIFileUIPath.getStr());
     xmlNodePtr pNodePtr = xmlDocGetRootElement(pDoc);
 
-    m_xContentsListBox->clear();
     std::vector<NotebookbarEntries> aEntries;
     std::vector<CategoriesEntries> aCategoryList;
     OUString sActiveCategory = m_xTopLevelListBox->get_active_id();
@@ -473,30 +473,24 @@ void SvxNotebookbarConfigPage::SelectElement()
     aTempEntries.clear();
 
     weld::TreeView& rTreeView = m_xContentsListBox->get_widget();
-    rTreeView.freeze();
-
-    sal_Int64 nId = 0;
-    for (std::size_t nIdx = 0; nIdx < aEntries.size(); nIdx++)
-    {
-        OUString sId(OUString::number(nId));
-        m_xContentsListBox->insert(nIdx, sId);
-        if (aEntries[nIdx].sActionName != "Null")
-        {
-            if (aEntries[nIdx].sVisibleValue == "True")
+    rTreeView.bulk_insert_for_each(
+        aEntries.size(), [this, &rTreeView, &aEntries](weld::TreeIter& rIter, 
int nIdx) {
+            OUString sId(OUString::number(nIdx));
+            rTreeView.set_id(rIter, sId);
+            if (aEntries[nIdx].sActionName != "Null")
             {
-                m_xContentsListBox->set_toggle(nIdx, TRISTATE_TRUE, 0);
-            }
-            else
-            {
-                m_xContentsListBox->set_toggle(nIdx, TRISTATE_FALSE, 0);
+                if (aEntries[nIdx].sVisibleValue == "True")
+                {
+                    rTreeView.set_toggle(rIter, TRISTATE_TRUE, 0);
+                }
+                else
+                {
+                    rTreeView.set_toggle(rIter, TRISTATE_FALSE, 0);
+                }
             }
-        }
-        InsertEntryIntoNotebookbarTabUI(aEntries[nIdx].sClassId, 
aEntries[nIdx].sDisplayName,
-                                        aEntries[nIdx].sActionName, nIdx, 1);
-        ++nId;
-    }
-
-    rTreeView.thaw();
+            InsertEntryIntoNotebookbarTabUI(aEntries[nIdx].sClassId, 
aEntries[nIdx].sDisplayName,
+                                            aEntries[nIdx].sActionName, 
rTreeView, rIter, 1);
+        });
 
     aEntries.clear();
 
diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx
index 80b0e29d009b..d5410a6ce667 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -452,7 +452,9 @@ protected:
 
     void                InsertEntryIntoUI(SvxConfigEntry* pNewEntryData,
                                           int nPos, int nStartCol);
-    void InsertEntryIntoNotebookbarTabUI(const OUString& sClassId, const 
OUString& sUIItemId, const OUString& sUIItemCommand, int nPos,
+    void InsertEntryIntoNotebookbarTabUI(const OUString& sClassId, const 
OUString& sUIItemId,
+                                         const OUString& sUIItemCommand,
+                                         weld::TreeView& rTreeView, 
weld::TreeIter& rIter,
                                          int nStartCol);
 
     SvxEntries*     FindParentForChild( SvxEntries* pParentEntries,
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to