diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-10-23 21:59:55 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-10-24 09:09:26 +0200 |
commit | c8ff967c4996318d25bcc0642b14cbc5e6d981bb (patch) | |
tree | 3f2426a51fe483ba357a2679607f4fb9211b967a /vcl/qt5/QtInstanceComboBox.cxx | |
parent | f0a90a0d3f9c0a200603ee69a42fddf461068a22 (diff) |
tdf#130857 qt weld: Implement combobox entry sorting
Implement sorting for combobox entries by adding
a QtInstanceComboBox::m_bSorted member that gets
set to true when QtInstanceComboBox::make_sorted
gets called, and sort entries then and whenever
a new entry gets inserted afterwards.
This is in preparation for upcoming
Change-Id: I7806688102f690faa02fb5e712943d6ae216ff9a
Author: Michael Weghorn <m.weghorn@posteo.de>
tdf#130857 qt weld: Declare support for "Printer Settings" dialog
Change-Id: I54140db4310c7b288fe3be0e73000860410068fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175520
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/qt5/QtInstanceComboBox.cxx')
-rw-r--r-- | vcl/qt5/QtInstanceComboBox.cxx | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/vcl/qt5/QtInstanceComboBox.cxx b/vcl/qt5/QtInstanceComboBox.cxx index 1b12610aead0..e2284b33ef4a 100644 --- a/vcl/qt5/QtInstanceComboBox.cxx +++ b/vcl/qt5/QtInstanceComboBox.cxx @@ -12,6 +12,7 @@ QtInstanceComboBox::QtInstanceComboBox(QComboBox* pComboBox) : QtInstanceWidget(pComboBox) , m_pComboBox(pComboBox) + , m_bSorted(false) { assert(pComboBox); } @@ -23,7 +24,11 @@ void QtInstanceComboBox::insert(int nPos, const OUString& rStr, const OUString* assert(false && "Handling for these not implemented yet"); SolarMutexGuard g; - GetQtInstance().RunInMainThread([&] { m_pComboBox->insertItem(nPos, toQString(rStr)); }); + GetQtInstance().RunInMainThread([&] { + m_pComboBox->insertItem(nPos, toQString(rStr)); + if (m_bSorted) + sortItems(); + }); } void QtInstanceComboBox::insert_vector(const std::vector<weld::ComboBoxEntry>&, bool) @@ -44,7 +49,12 @@ int QtInstanceComboBox::get_count() const return nCount; } -void QtInstanceComboBox::make_sorted() { assert(false && "Not implemented yet"); } +void QtInstanceComboBox::make_sorted() +{ + SolarMutexGuard g; + m_bSorted = true; + GetQtInstance().RunInMainThread([&] { sortItems(); }); +} void QtInstanceComboBox::clear() { @@ -237,4 +247,6 @@ void QtInstanceComboBox::set_mru_entries(const OUString&) void QtInstanceComboBox::set_max_drop_down_rows(int) { assert(false && "Not implemented yet"); } +void QtInstanceComboBox::sortItems() { m_pComboBox->model()->sort(0, Qt::AscendingOrder); } + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |