diff options
-rw-r--r-- | vcl/inc/qt5/QtInstanceComboBox.hxx | 4 | ||||
-rw-r--r-- | vcl/qt5/QtInstanceComboBox.cxx | 16 |
2 files changed, 18 insertions, 2 deletions
diff --git a/vcl/inc/qt5/QtInstanceComboBox.hxx b/vcl/inc/qt5/QtInstanceComboBox.hxx index cc5bd2523eb3..53d81bc9aadc 100644 --- a/vcl/inc/qt5/QtInstanceComboBox.hxx +++ b/vcl/inc/qt5/QtInstanceComboBox.hxx @@ -16,6 +16,7 @@ class QtInstanceComboBox : public QtInstanceWidget, public virtual weld::ComboBox { QComboBox* m_pComboBox; + bool m_bSorted; public: QtInstanceComboBox(QComboBox* pComboBox); @@ -79,6 +80,9 @@ public: virtual void set_mru_entries(const OUString& rEntries) override; virtual void set_max_drop_down_rows(int nRows) override; + +private: + void sortItems(); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 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: */ |