diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-10-24 01:25:23 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-10-24 09:10:44 +0200 |
commit | ff1543fcd2db91e10f3aa6c42ceb3251d8fa092b (patch) | |
tree | 829741625501f504b5d1f9f492960f3c1f2ac787 /vcl | |
parent | 6cc411801138f93b5b25b0822b1fdd723dc75869 (diff) |
tdf#130857 qt weld: Implement QtInstanceComboBox::insert_vector
Change-Id: I71b1e8c596ca1f6790e93bdd7d73a9e5c583c278
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175529
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qt5/QtInstanceComboBox.cxx | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/vcl/qt5/QtInstanceComboBox.cxx b/vcl/qt5/QtInstanceComboBox.cxx index 46c8e2ba9316..c623104c8a38 100644 --- a/vcl/qt5/QtInstanceComboBox.cxx +++ b/vcl/qt5/QtInstanceComboBox.cxx @@ -41,9 +41,29 @@ void QtInstanceComboBox::insert(int nPos, const OUString& rStr, const OUString* }); } -void QtInstanceComboBox::insert_vector(const std::vector<weld::ComboBoxEntry>&, bool) +void QtInstanceComboBox::insert_vector(const std::vector<weld::ComboBoxEntry>& rItems, + bool bKeepExisting) { - assert(false && "Not implemented yet"); + SolarMutexGuard g; + GetQtInstance().RunInMainThread([&] { + if (!bKeepExisting) + m_pComboBox->clear(); + + // if sorted, only sort once at the end + const bool bSorted = m_bSorted; + m_bSorted = false; + + for (const weld::ComboBoxEntry& rEntry : rItems) + { + const OUString* pId = rEntry.sId.isEmpty() ? nullptr : &rEntry.sId; + const OUString* pImage = rEntry.sImage.isEmpty() ? nullptr : &rEntry.sImage; + insert(m_pComboBox->count(), rEntry.sString, pId, pImage, nullptr); + } + + m_bSorted = bSorted; + if (m_bSorted) + sortItems(); + }); } void QtInstanceComboBox::insert_separator(int nPos, const OUString&) |