diff options
-rw-r--r-- | vcl/CustomTarget_qt5_moc.mk | 1 | ||||
-rw-r--r-- | vcl/CustomTarget_qt6_moc.mk | 1 | ||||
-rw-r--r-- | vcl/Library_vclplug_qt5.mk | 1 | ||||
-rw-r--r-- | vcl/Library_vclplug_qt6.mk | 1 | ||||
-rw-r--r-- | vcl/inc/qt5/QtInstanceBuilder.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/qt5/QtInstanceIconView.hxx | 76 | ||||
-rw-r--r-- | vcl/inc/qt6/QtInstanceIconView.hxx | 12 | ||||
-rw-r--r-- | vcl/qt5/QtBuilder.cxx | 8 | ||||
-rw-r--r-- | vcl/qt5/QtInstanceBuilder.cxx | 9 | ||||
-rw-r--r-- | vcl/qt5/QtInstanceIconView.cxx | 176 | ||||
-rw-r--r-- | vcl/qt6/QtInstanceIconView.cxx | 12 |
11 files changed, 296 insertions, 5 deletions
diff --git a/vcl/CustomTarget_qt5_moc.mk b/vcl/CustomTarget_qt5_moc.mk index 6e3d7dda89fd..f2b34a7a1c48 100644 --- a/vcl/CustomTarget_qt5_moc.mk +++ b/vcl/CustomTarget_qt5_moc.mk @@ -23,6 +23,7 @@ $(call gb_CustomTarget_get_target,vcl/qt5) : \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceDrawingArea.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceEntry.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceExpander.moc \ + $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceIconView.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceImage.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceLabel.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceLevelBar.moc \ diff --git a/vcl/CustomTarget_qt6_moc.mk b/vcl/CustomTarget_qt6_moc.mk index a45846b37ea5..319c60434421 100644 --- a/vcl/CustomTarget_qt6_moc.mk +++ b/vcl/CustomTarget_qt6_moc.mk @@ -23,6 +23,7 @@ $(call gb_CustomTarget_get_target,vcl/qt6) : \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceDrawingArea.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceEntry.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceExpander.moc \ + $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceIconView.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceImage.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceLabel.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceLevelBar.moc \ diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk index 402698303f2d..e1597fe99d20 100644 --- a/vcl/Library_vclplug_qt5.mk +++ b/vcl/Library_vclplug_qt5.mk @@ -109,6 +109,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\ vcl/qt5/QtInstanceEntry \ vcl/qt5/QtInstanceExpander \ vcl/qt5/QtInstanceFrame \ + vcl/qt5/QtInstanceIconView \ vcl/qt5/QtInstanceImage \ vcl/qt5/QtInstanceLabel \ vcl/qt5/QtInstanceLevelBar \ diff --git a/vcl/Library_vclplug_qt6.mk b/vcl/Library_vclplug_qt6.mk index 293ab41d87a9..5c5d49cdc5eb 100644 --- a/vcl/Library_vclplug_qt6.mk +++ b/vcl/Library_vclplug_qt6.mk @@ -108,6 +108,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt6,\ vcl/qt6/QtInstanceEntry \ vcl/qt6/QtInstanceExpander \ vcl/qt6/QtInstanceFrame \ + vcl/qt6/QtInstanceIconView \ vcl/qt6/QtInstanceImage \ vcl/qt6/QtInstanceLabel \ vcl/qt6/QtInstanceLevelBar \ diff --git a/vcl/inc/qt5/QtInstanceBuilder.hxx b/vcl/inc/qt5/QtInstanceBuilder.hxx index 547d7aec1b8e..0749eaee1e4c 100644 --- a/vcl/inc/qt5/QtInstanceBuilder.hxx +++ b/vcl/inc/qt5/QtInstanceBuilder.hxx @@ -65,8 +65,8 @@ public: virtual std::unique_ptr<weld::EntryTreeView> weld_entry_tree_view(const OUString&, const OUString&, const OUString&) override; virtual std::unique_ptr<weld::TreeView> weld_tree_view(const OUString& rId) override; - virtual std::unique_ptr<weld::IconView> weld_icon_view(const OUString&) override; - virtual std::unique_ptr<weld::Label> weld_label(const OUString&) override; + virtual std::unique_ptr<weld::IconView> weld_icon_view(const OUString& rId) override; + virtual std::unique_ptr<weld::Label> weld_label(const OUString& rId) override; virtual std::unique_ptr<weld::TextView> weld_text_view(const OUString& rId) override; virtual std::unique_ptr<weld::Expander> weld_expander(const OUString& rId) override; virtual std::unique_ptr<weld::DrawingArea> diff --git a/vcl/inc/qt5/QtInstanceIconView.hxx b/vcl/inc/qt5/QtInstanceIconView.hxx new file mode 100644 index 000000000000..e60f63ee946f --- /dev/null +++ b/vcl/inc/qt5/QtInstanceIconView.hxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include "QtInstanceWidget.hxx" + +#include <QtGui/QStandardItemModel> +#include <QtWidgets/QListView> + +class QtInstanceIconView : public QtInstanceWidget, public virtual weld::IconView +{ + Q_OBJECT + + QListView* m_pListView; + QStandardItemModel* m_pModel; + QItemSelectionModel* m_pSelectionModel; + +public: + QtInstanceIconView(QListView* pListView); + + virtual int get_item_width() const override; + virtual void set_item_width(int width) override; + + virtual void insert(int pos, const OUString* pStr, const OUString* pId, + const OUString* pIconName, weld::TreeIter* pRet) override; + + virtual void insert(int pos, const OUString* pStr, const OUString* pId, + const VirtualDevice* pIcon, weld::TreeIter* pRet) override; + + virtual void insert_separator(int pos, const OUString* pId) override; + + virtual OUString get_selected_id() const override; + + virtual void clear() override; + + virtual int count_selected_items() const override; + + virtual OUString get_selected_text() const override; + + virtual OUString get_id(int pos) const override; + virtual void select(int pos) override; + virtual void unselect(int pos) override; + virtual void set_image(int pos, VirtualDevice* pDevice) override; + virtual void set_text(int pos, const OUString& rText) override; + virtual void set_id(int pos, const OUString& rId) override; + virtual void remove(int pos) override; + virtual tools::Rectangle get_rect(int pos) const override; + + virtual std::unique_ptr<weld::TreeIter> make_iterator(const weld::TreeIter* pOrig + = nullptr) const override; + virtual bool get_selected(weld::TreeIter* pIter) const override; + virtual bool get_cursor(weld::TreeIter* pIter) const override; + virtual void set_cursor(const weld::TreeIter& rIter) override; + virtual bool get_iter_first(weld::TreeIter& rIter) const override; + virtual OUString get_id(const weld::TreeIter& rIter) const override; + virtual OUString get_text(const weld::TreeIter& rIter) const override; + virtual bool iter_next_sibling(weld::TreeIter& rIter) const override; + virtual void scroll_to_item(const weld::TreeIter& rIter) override; + + virtual void selected_foreach(const std::function<bool(weld::TreeIter&)>& func) override; + + virtual int n_children() const override; + +private Q_SLOTS: + void handleActivated(); + void handleSelectionChanged(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/inc/qt6/QtInstanceIconView.hxx b/vcl/inc/qt6/QtInstanceIconView.hxx new file mode 100644 index 000000000000..81bc2291d3b6 --- /dev/null +++ b/vcl/inc/qt6/QtInstanceIconView.hxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../qt5/QtInstanceIconView.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx index 95a27a2ec162..8ba77d82fbd5 100644 --- a/vcl/qt5/QtBuilder.cxx +++ b/vcl/qt5/QtBuilder.cxx @@ -27,6 +27,7 @@ #include <QtWidgets/QGroupBox> #include <QtWidgets/QLabel> #include <QtWidgets/QLineEdit> +#include <QtWidgets/QListView> #include <QtWidgets/QLayout> #include <QtWidgets/QPlainTextEdit> #include <QtWidgets/QProgressBar> @@ -225,6 +226,13 @@ QObject* QtBuilder::makeObject(QObject* pParent, std::u16string_view sName, std: pLayoutParentWidget = new QWidget(pParentWidget); pObject = new QGridLayout(pLayoutParentWidget); } + else if (sName == u"GtkIconView") + { + QListView* pListView = new QListView(pParentWidget); + pListView->setModel(new QStandardItemModel(pListView)); + pListView->setViewMode(QListView::IconMode); + pObject = pListView; + } else if (sName == u"GtkImage") { QLabel* pLabel = new QLabel(pParentWidget); diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx index 03b7d15701fe..17c5f20a943e 100644 --- a/vcl/qt5/QtInstanceBuilder.cxx +++ b/vcl/qt5/QtInstanceBuilder.cxx @@ -22,6 +22,7 @@ #include <QtInstanceLabel.hxx> #include <QtInstanceLevelBar.hxx> #include <QtInstanceLinkButton.hxx> +#include <QtInstanceIconView.hxx> #include <QtInstanceMessageDialog.hxx> #include <QtInstanceNotebook.hxx> #include <QtInstanceProgressBar.hxx> @@ -319,10 +320,12 @@ std::unique_ptr<weld::TreeView> QtInstanceBuilder::weld_tree_view(const OUString return xRet; } -std::unique_ptr<weld::IconView> QtInstanceBuilder::weld_icon_view(const OUString&) +std::unique_ptr<weld::IconView> QtInstanceBuilder::weld_icon_view(const OUString& rId) { - assert(false && "Not implemented yet"); - return nullptr; + QListView* pListView = m_xBuilder->get<QListView>(rId); + std::unique_ptr<weld::IconView> xRet(pListView ? std::make_unique<QtInstanceIconView>(pListView) + : nullptr); + return xRet; } std::unique_ptr<weld::Label> QtInstanceBuilder::weld_label(const OUString& rId) diff --git a/vcl/qt5/QtInstanceIconView.cxx b/vcl/qt5/QtInstanceIconView.cxx new file mode 100644 index 000000000000..9c3c9f25e7e2 --- /dev/null +++ b/vcl/qt5/QtInstanceIconView.cxx @@ -0,0 +1,176 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <QtInstanceIconView.hxx> +#include <QtInstanceIconView.moc> + +#include <vcl/qt/QtUtils.hxx> + +QtInstanceIconView::QtInstanceIconView(QListView* pListView) + : QtInstanceWidget(pListView) + , m_pListView(pListView) +{ + assert(m_pListView); + + m_pModel = qobject_cast<QStandardItemModel*>(m_pListView->model()); + assert(m_pModel && "list view doesn't have expected item model set"); + + m_pSelectionModel = m_pListView->selectionModel(); + assert(m_pSelectionModel); + + connect(m_pListView, &QListView::activated, this, &QtInstanceIconView::handleActivated); + connect(m_pSelectionModel, &QItemSelectionModel::selectionChanged, this, + &QtInstanceIconView::handleSelectionChanged); +} + +int QtInstanceIconView::get_item_width() const +{ + assert(false && "Not implemented yet"); + return 0; +} + +void QtInstanceIconView::set_item_width(int) { assert(false && "Not implemented yet"); } + +void QtInstanceIconView::insert(int, const OUString*, const OUString*, const OUString*, + weld::TreeIter*) +{ + assert(false && "Not implemented yet"); +} + +void QtInstanceIconView::insert(int, const OUString*, const OUString*, const VirtualDevice*, + weld::TreeIter*) +{ + assert(false && "Not implemented yet"); +} + +void QtInstanceIconView::insert_separator(int, const OUString*) +{ + assert(false && "Not implemented yet"); +} + +OUString QtInstanceIconView::get_selected_id() const +{ + assert(false && "Not implemented yet"); + return OUString(); +} + +void QtInstanceIconView::clear() { assert(false && "Not implemented yet"); } + +int QtInstanceIconView::count_selected_items() const +{ + assert(false && "Not implemented yet"); + return 0; +} + +OUString QtInstanceIconView::get_selected_text() const +{ + assert(false && "Not implemented yet"); + return OUString(); +} + +OUString QtInstanceIconView::get_id(int) const +{ + assert(false && "Not implemented yet"); + return OUString(); +} + +void QtInstanceIconView::select(int) { assert(false && "Not implemented yet"); } + +void QtInstanceIconView::unselect(int) { assert(false && "Not implemented yet"); } + +void QtInstanceIconView::set_image(int, VirtualDevice*) { assert(false && "Not implemented yet"); } + +void QtInstanceIconView::set_text(int, const OUString&) { assert(false && "Not implemented yet"); } + +void QtInstanceIconView::set_id(int, const OUString&) { assert(false && "Not implemented yet"); } + +void QtInstanceIconView::remove(int) { assert(false && "Not implemented yet"); } + +tools::Rectangle QtInstanceIconView::get_rect(int) const +{ + assert(false && "Not implemented yet"); + return tools::Rectangle(); +} + +std::unique_ptr<weld::TreeIter> QtInstanceIconView::make_iterator(const weld::TreeIter*) const +{ + assert(false && "Not implemented yet"); + return nullptr; +} + +bool QtInstanceIconView::get_selected(weld::TreeIter*) const +{ + assert(false && "Not implemented yet"); + return false; +} + +bool QtInstanceIconView::get_cursor(weld::TreeIter*) const +{ + assert(false && "Not implemented yet"); + return false; +} + +void QtInstanceIconView::set_cursor(const weld::TreeIter&) +{ + assert(false && "Not implemented yet"); +} + +bool QtInstanceIconView::get_iter_first(weld::TreeIter&) const +{ + assert(false && "Not implemented yet"); + return false; +} + +OUString QtInstanceIconView::get_id(const weld::TreeIter&) const +{ + assert(false && "Not implemented yet"); + return OUString(); +} + +OUString QtInstanceIconView::get_text(const weld::TreeIter&) const +{ + assert(false && "Not implemented yet"); + return OUString(); +} + +bool QtInstanceIconView::iter_next_sibling(weld::TreeIter&) const +{ + assert(false && "Not implemented yet"); + return false; +} + +void QtInstanceIconView::scroll_to_item(const weld::TreeIter&) +{ + assert(false && "Not implemented yet"); +} + +void QtInstanceIconView::selected_foreach(const std::function<bool(weld::TreeIter&)>&) +{ + assert(false && "Not implemented yet"); +} + +int QtInstanceIconView::n_children() const +{ + assert(false && "Not implemented yet"); + return 0; +} + +void QtInstanceIconView::handleActivated() +{ + SolarMutexGuard g; + signal_item_activated(); +} + +void QtInstanceIconView::handleSelectionChanged() +{ + SolarMutexGuard g; + signal_selection_changed(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/qt6/QtInstanceIconView.cxx b/vcl/qt6/QtInstanceIconView.cxx new file mode 100644 index 000000000000..d872d40d9f8f --- /dev/null +++ b/vcl/qt6/QtInstanceIconView.cxx @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "../qt5/QtInstanceIconView.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |