diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-01-14 20:06:15 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-01-19 18:10:16 +0100 |
commit | 0c69660a8f67248edcf469391a2ac96a000f37d9 (patch) | |
tree | 5a017c3e281aa5c2af8c4816db4ce2ed27d40d1f | |
parent | 6e8e53757c684c30d9547bf7fb3f5ce0b7e3f0c8 (diff) | |
download | qtwebengine-0c69660a8f67248edcf469391a2ac96a000f37d9.tar.gz |
QtPdf: remove TableViewExtra
9e3c27595113dd07ad936e73696aee62db4c6f3f was a temporary solution to
work around missing TableView features in Qt 5.
Drive-by: remove import versions and use required property in
PdfMultiPageView, since we're touching it anyway.
Change-Id: I0b1f83b865671f6ea9f14bbf70d7e3972e20e354
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
-rw-r--r-- | src/pdfquick/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/pdfquick/plugin.cpp | 2 | ||||
-rw-r--r-- | src/pdfquick/qml/PdfMultiPageView.qml | 39 | ||||
-rw-r--r-- | src/pdfquick/qquicktableviewextra.cpp | 86 | ||||
-rw-r--r-- | src/pdfquick/qquicktableviewextra_p.h | 97 |
5 files changed, 17 insertions, 208 deletions
diff --git a/src/pdfquick/CMakeLists.txt b/src/pdfquick/CMakeLists.txt index 5bbe66959..e19199abc 100644 --- a/src/pdfquick/CMakeLists.txt +++ b/src/pdfquick/CMakeLists.txt @@ -26,7 +26,6 @@ qt_internal_add_qml_module(PdfQuick qquickpdfnavigationstack.cpp qquickpdfnavigationstack_p.h qquickpdfsearchmodel.cpp qquickpdfsearchmodel_p.h qquickpdfselection.cpp qquickpdfselection_p.h - qquicktableviewextra.cpp qquicktableviewextra_p.h qtpdfquickglobal_p.h INCLUDE_DIRECTORIES ../3rdparty/chromium diff --git a/src/pdfquick/plugin.cpp b/src/pdfquick/plugin.cpp index 20fcf6393..9ec5528f6 100644 --- a/src/pdfquick/plugin.cpp +++ b/src/pdfquick/plugin.cpp @@ -46,7 +46,6 @@ #include "qquickpdfnavigationstack_p.h" #include "qquickpdfsearchmodel_p.h" #include "qquickpdfselection_p.h" -#include "qquicktableviewextra_p.h" QT_BEGIN_NAMESPACE @@ -93,7 +92,6 @@ public: qmlRegisterType<QQuickPdfNavigationStack>(uri, 5, 15, "PdfNavigationStack"); qmlRegisterType<QQuickPdfSearchModel>(uri, 5, 15, "PdfSearchModel"); qmlRegisterType<QQuickPdfSelection>(uri, 5, 15, "PdfSelection"); - qmlRegisterType<QQuickTableViewExtra>(uri, 5, 15, "TableViewExtra"); } }; diff --git a/src/pdfquick/qml/PdfMultiPageView.qml b/src/pdfquick/qml/PdfMultiPageView.qml index 39f9831ea..9e841e1e2 100644 --- a/src/pdfquick/qml/PdfMultiPageView.qml +++ b/src/pdfquick/qml/PdfMultiPageView.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtPDF module of the Qt Toolkit. @@ -36,27 +36,26 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.14 -import QtQuick.Controls 2.14 -import QtQuick.Layouts 1.14 -import QtQuick.Pdf 5.15 -import QtQuick.Shapes 1.14 -import QtQuick.Window 2.14 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import QtQuick.Pdf +import QtQuick.Shapes +import QtQuick.Window Item { // public API - // TODO 5.15: required property - property var document: undefined + required property var document property bool debug: false property string selectedText function selectAll() { - var currentItem = tableHelper.itemAtCell(tableHelper.cellAtPos(root.width / 2, root.height / 2)) + var currentItem = tableView.itemAtCell(tableView.cellAtPos(root.width / 2, root.height / 2)) if (currentItem) currentItem.selection.selectAll() } function copySelectionToClipboard() { - var currentItem = tableHelper.itemAtCell(tableHelper.cellAtPos(root.width / 2, root.height / 2)) + var currentItem = tableView.itemAtCell(tableView.cellAtPos(root.width / 2, root.height / 2)) if (debug) console.log("currentItem", currentItem, "sel", currentItem.selection.text) if (currentItem) @@ -140,10 +139,6 @@ Item { (rot90 ? document.maxPageHeight : document.maxPageWidth) * root.renderScale) contentWidth: document === undefined ? 0 : pageHolderWidth + vscroll.width + 2 rowHeightProvider: function(row) { return (rot90 ? document.pagePointSize(row).width : document.pagePointSize(row).height) * root.renderScale } - TableViewExtra { - id: tableHelper - tableView: tableView - } delegate: Rectangle { id: pageHolder color: root.debug ? "beige" : "transparent" @@ -355,8 +350,8 @@ Item { property bool moved: false onPositionChanged: moved = true onActiveChanged: { - var cell = tableHelper.cellAtPos(root.width / 2, root.height / 2) - var currentItem = tableHelper.itemAtCell(cell) + var cell = tableView.cellAtPos(root.width / 2, root.height / 2) + var currentItem = tableView.itemAtCell(cell) var currentLocation = Qt.point(0, 0) if (currentItem) { // maybe the delegate wasn't loaded yet currentLocation = Qt.point((tableView.contentX - currentItem.x + jumpLocationMargin.x) / root.renderScale, @@ -380,8 +375,8 @@ Item { return // make TableView rebuild from scratch, because otherwise it doesn't know the delegates are changing size tableView.rebuild() - var cell = tableHelper.cellAtPos(root.width / 2, root.height / 2) - var currentItem = tableHelper.itemAtCell(cell) + var cell = tableView.cellAtPos(root.width / 2, root.height / 2) + var currentItem = tableView.itemAtCell(cell) if (currentItem) { var currentLocation = Qt.point((tableView.contentX - currentItem.x + jumpLocationMargin.x) / root.renderScale, (tableView.contentY - currentItem.y + jumpLocationMargin.y) / root.renderScale) @@ -399,10 +394,10 @@ Item { // invalid to indicate that a specific location was not needed, // so attempt to position the new page just as the current page is var currentYOffset = 0 - var previousPageDelegate = tableHelper.itemAtCell(0, previousPage) + var previousPageDelegate = tableView.itemAtCell(0, previousPage) if (previousPageDelegate) currentYOffset = tableView.contentY - previousPageDelegate.y - tableHelper.positionViewAtRow(page, Qt.AlignTop, currentYOffset) + tableView.positionViewAtRow(page, Qt.AlignTop, currentYOffset) if (root.debug) { console.log("going from page", previousPage, "to", page, "offset", currentYOffset, "ended up @", tableView.contentX.toFixed(1) + ", " + tableView.contentY.toFixed(1)) @@ -416,7 +411,7 @@ Item { var offset = Qt.point(Math.max(-xOffsetLimit, Math.min(xOffsetLimit, location.x * root.renderScale - jumpLocationMargin.x)), Math.max(0, location.y * root.renderScale - jumpLocationMargin.y)) - tableHelper.positionViewAtCell(0, page, Qt.AlignLeft | Qt.AlignTop, offset) + tableView.positionViewAtCell(0, page, Qt.AlignLeft | Qt.AlignTop, offset) if (root.debug) { console.log("going to zoom", zoom, "loc", location, "on page", page, "ended up @", tableView.contentX.toFixed(1) + ", " + tableView.contentY.toFixed(1)) diff --git a/src/pdfquick/qquicktableviewextra.cpp b/src/pdfquick/qquicktableviewextra.cpp deleted file mode 100644 index 9687150a5..000000000 --- a/src/pdfquick/qquicktableviewextra.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPDF module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquicktableviewextra_p.h" -#include <QtQml> -#include <QQmlContext> - -Q_LOGGING_CATEGORY(qLcTVE, "qt.pdf.tableextra") - -QT_BEGIN_NAMESPACE - -/*! - \internal - \qmltype TableViewExtra -//! \instantiates QQuickTableViewExtra - \inqmlmodule QtQuick.Pdf - \ingroup pdf - \brief A helper class with missing TableView functions - \since 5.15 - - TableViewExtra provides equivalents for some functions that will be added - to TableView in Qt 6. -*/ - -QQuickTableViewExtra::QQuickTableViewExtra(QObject *parent) : QObject(parent) -{ -} - -/*! - \internal -*/ -QQuickTableViewExtra::~QQuickTableViewExtra() = default; - -QPoint QQuickTableViewExtra::cellAtPos(qreal x, qreal y) const -{ - QPointF position(x, y); - return m_tableView->cellAtPos(position); -} - -QQuickItem *QQuickTableViewExtra::itemAtCell(const QPoint &cell) const -{ - return m_tableView->itemAtCell(cell); -} - -void QQuickTableViewExtra::positionViewAtCell(const QPoint &cell, Qt::Alignment alignment, const QPointF &offset) -{ - m_tableView->positionViewAtCell(cell, alignment, offset); -} - -QT_END_NAMESPACE diff --git a/src/pdfquick/qquicktableviewextra_p.h b/src/pdfquick/qquicktableviewextra_p.h deleted file mode 100644 index c1969e04c..000000000 --- a/src/pdfquick/qquicktableviewextra_p.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtPDF module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKTABLEVIEWEXTRA_P_H -#define QQUICKTABLEVIEWEXTRA_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtPdfQuick/private/qtpdfquickglobal_p.h> -#include <QtQuick/private/qquicktableview_p.h> -#include <QPointF> -#include <QPolygonF> -#include <QVariant> -#include <QtQml/qqml.h> -#include <QtQuick/qquickitem.h> - -QT_BEGIN_NAMESPACE - -class Q_PDFQUICK_EXPORT QQuickTableViewExtra : public QObject -{ - Q_OBJECT - Q_PROPERTY(QQuickTableView *tableView READ tableView WRITE setTableView) - -public: - explicit QQuickTableViewExtra(QObject *parent = nullptr); - ~QQuickTableViewExtra() override; - - QQuickTableView * tableView() const { return m_tableView; } - void setTableView(QQuickTableView * tableView) { m_tableView = tableView; } - - Q_INVOKABLE QPoint cellAtPos(qreal x, qreal y) const; - Q_INVOKABLE QQuickItem *itemAtCell(int column, int row) const { - return itemAtCell(QPoint(column, row)); - } - Q_INVOKABLE QQuickItem *itemAtCell(const QPoint &cell) const; - Q_INVOKABLE void positionViewAtCell(int column, int row, Qt::Alignment alignment, const QPointF &offset = QPointF()) { - positionViewAtCell(QPoint(column, row), alignment, offset); - } - Q_INVOKABLE void positionViewAtCell(const QPoint &cell, Qt::Alignment alignment, const QPointF &offset); - Q_INVOKABLE void positionViewAtRow(int row, Qt::Alignment alignment, qreal offset = 0) { - positionViewAtCell(QPoint(0, row), alignment & Qt::AlignVertical_Mask, QPointF(0, offset)); - } - -private: - QQuickTableView *m_tableView = nullptr; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickTableViewExtra) - -#endif // QQUICKTABLEVIEWEXTRA_P_H |