vcl/inc/qt5/QtInstanceComboBox.hxx | 4 ++++ vcl/qt5/QtInstanceComboBox.cxx | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-)
New commits: commit c8ff967c4996318d25bcc0642b14cbc5e6d981bb Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Oct 23 21:59:55 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Oct 24 09:09:26 2024 +0200 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.wegh...@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.wegh...@posteo.de> 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: */ commit f0a90a0d3f9c0a200603ee69a42fddf461068a22 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Oct 23 21:46:42 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Oct 24 09:09:18 2024 +0200 tdf#130857 qt weld: Fix condition for not implemented combobox case The case where `pImageSurface` is non-null needs special handling, and that isn't implemented yet. (The assert would be triggered for the "File" -> "Printer Settings" dialog otherwise once declared as supported in an upcoming commit.) Change-Id: I1a7d352e24de13417aac28d1d4b514709a8e97d1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175519 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtInstanceComboBox.cxx b/vcl/qt5/QtInstanceComboBox.cxx index c1146cb35621..1b12610aead0 100644 --- a/vcl/qt5/QtInstanceComboBox.cxx +++ b/vcl/qt5/QtInstanceComboBox.cxx @@ -19,7 +19,7 @@ QtInstanceComboBox::QtInstanceComboBox(QComboBox* pComboBox) void QtInstanceComboBox::insert(int nPos, const OUString& rStr, const OUString* pId, const OUString* pIconName, VirtualDevice* pImageSurface) { - if (pId || pIconName || !pImageSurface) + if (pId || pIconName || pImageSurface) assert(false && "Handling for these not implemented yet"); SolarMutexGuard g;