From 9b6b134b3e605236e90aca089867f08d659a6076 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 25 Nov 2019 13:31:22 +0000 Subject: tdf#126043 use bulk_insert_for_each MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I68b5a7805a2e0a76d1871448a011fdde7f7cdb1e Reviewed-on: https://gerrit.libreoffice.org/83685 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- cui/source/customize/SvxNotebookbarConfigPage.cxx | 52 ++++++++++------------- cui/source/inc/cfg.hxx | 4 +- 2 files changed, 26 insertions(+), 30 deletions(-) (limited to 'cui/source') 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 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 aEntries; std::vector 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, -- cgit