diff options
Diffstat (limited to 'src/widgets/graphicsview')
53 files changed, 535 insertions, 2559 deletions
diff --git a/src/widgets/graphicsview/qgraph_p.h b/src/widgets/graphicsview/qgraph_p.h index ce04b16265..10c742d42e 100644 --- a/src/widgets/graphicsview/qgraph_p.h +++ b/src/widgets/graphicsview/qgraph_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPH_P_H #define QGRAPH_P_H @@ -56,6 +20,7 @@ #include <QtCore/QQueue> #include <QtCore/QString> #include <QtCore/QDebug> +#include <QtCore/QSet> #include <functional> // for std::less diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout.cpp index 6ed86bf942..4cb7165f37 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout.cpp +++ b/src/widgets/graphicsview/qgraphicsanchorlayout.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only /*! \class QGraphicsAnchorLayout diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout.h b/src/widgets/graphicsview/qgraphicsanchorlayout.h index 9bea43dd8e..5ddbd83e13 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout.h +++ b/src/widgets/graphicsview/qgraphicsanchorlayout.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSANCHORLAYOUT_H #define QGRAPHICSANCHORLAYOUT_H diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp index 232599c561..8a5280d44c 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qgraphicsanchorlayout_p.h" @@ -51,6 +15,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // To ensure that all variables inside the simplex solver are non-negative, // we limit the size of anchors in the interval [-limit, limit]. Then before // sending them to the simplex solver we add "limit" as an offset, so that @@ -493,9 +459,7 @@ void SequentialAnchorData::updateChildrenSizes() // "from" or "to", that _contains_ one of them. AnchorVertex *prev = from; - for (int i = 0; i < m_edges.count(); ++i) { - AnchorData *e = m_edges.at(i); - + for (AnchorData *e : m_edges) { const bool edgeIsForward = (e->from == prev); if (edgeIsForward) { e->sizeAtMinimum = interpolate(minFactor, e->minSize, e->minPrefSize, @@ -530,9 +494,7 @@ void SequentialAnchorData::calculateSizeHints() AnchorVertex *prev = from; - for (int i = 0; i < m_edges.count(); ++i) { - AnchorData *edge = m_edges.at(i); - + for (AnchorData *edge : m_edges) { const bool edgeIsForward = (edge->from == prev); if (edgeIsForward) { minSize += edge->minSize; @@ -566,12 +528,10 @@ void AnchorData::dump(int indent) { p->firstEdge->dump(indent+2); p->secondEdge->dump(indent+2); } else if (type == Sequential) { - SequentialAnchorData *s = static_cast<SequentialAnchorData *>(this); - int kids = s->m_edges.count(); - qDebug("%*s type: sequential(%d):", indent, "", kids); - for (int i = 0; i < kids; ++i) { - s->m_edges.at(i)->dump(indent+2); - } + const auto *s = static_cast<SequentialAnchorData *>(this); + qDebug("%*s type: sequential(%lld):", indent, "", qint64(s->m_edges.size())); + for (AnchorData *e : s->m_edges) + e->dump(indent + 2); } else { qDebug("%*s type: Normal:", indent, ""); } @@ -609,7 +569,9 @@ QSimplexConstraint *GraphPath::constraint(const GraphPath &path) const #ifdef QT_DEBUG QString GraphPath::toString() const { - QString string(QLatin1String("Path: ")); + QString string; + string += "Path: "_L1; + for (AnchorData *edge : positives) string += QString::fromLatin1(" (+++) %1").arg(edge->toString()); @@ -698,7 +660,7 @@ AnchorData *QGraphicsAnchorLayoutPrivate::addAnchorMaybeParallel(AnchorData *new parallel->isCenterAnchor = true; - for (int j = 0; j < constraints.count(); ++j) { + for (int j = 0; j < constraints.size(); ++j) { QSimplexConstraint *c = constraints[j]; if (c->variables.contains(child)) { childConstraints->append(c); @@ -744,9 +706,9 @@ static AnchorData *createSequence(Graph<AnchorVertex, AnchorData> *graph, Anchor AnchorVertex *prev = before; QList<AnchorData *> edges; - edges.reserve(vertices.count() + 1); + edges.reserve(vertices.size() + 1); - const int numVertices = vertices.count(); + const int numVertices = vertices.size(); edges.reserve(numVertices + 1); // Take from the graph, the edges that will be simplificated for (int i = 0; i < numVertices; ++i) { @@ -872,7 +834,7 @@ bool QGraphicsAnchorLayoutPrivate::replaceVertex(Qt::Orientation orientation, An Graph<AnchorVertex, AnchorData> &g = graph[orientation]; bool feasible = true; - for (int i = 0; i < edges.count(); ++i) { + for (int i = 0; i < edges.size(); ++i) { AnchorData *ad = edges[i]; AnchorVertex *otherV = replaceVertex_helper(ad, oldV, newV); @@ -920,7 +882,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyVertices(Qt::Orientation orientation) QList<AnchorVertex *> adjacents = g.adjacentVertices(v); int index = 0; - while (index < adjacents.count()) { + while (index < adjacents.size()) { AnchorVertex *next = adjacents.at(index); index++; @@ -940,7 +902,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyVertices(Qt::Orientation orientation) const QList<AnchorVertex *> &vAdjacents = g.adjacentVertices(v); const QList<AnchorVertex *> &nextAdjacents = g.adjacentVertices(next); - for (int i = 0; i < vAdjacents.count(); ++i) { + for (int i = 0; i < vAdjacents.size(); ++i) { AnchorVertex *adjacent = vAdjacents.at(i); if (adjacent != next) { AnchorData *ad = g.edgeData(v, adjacent); @@ -948,7 +910,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyVertices(Qt::Orientation orientation) } } - for (int i = 0; i < nextAdjacents.count(); ++i) { + for (int i = 0; i < nextAdjacents.size(); ++i) { AnchorVertex *adjacent = nextAdjacents.at(i); if (adjacent != v) { AnchorData *ad = g.edgeData(next, adjacent); @@ -1051,7 +1013,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(Qt::Orientation orient // // Identifies cases (a) and (b) - endOfSequence = isLayoutVertex || adjacents.count() != 2; + endOfSequence = isLayoutVertex || adjacents.size() != 2; if (!endOfSequence) { // This is a tricky part. We peek at the next vertex to find out whether @@ -1093,7 +1055,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(Qt::Orientation orient // // Add next non-visited vertices to the stack. // - for (int i = 0; i < adjacents.count(); ++i) { + for (int i = 0; i < adjacents.size(); ++i) { AnchorVertex *next = adjacents.at(i); if (visited.contains(next)) continue; @@ -1132,7 +1094,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(Qt::Orientation orient const AnchorData *lastAnchor = g.edgeData(candidates.constLast(), afterSequence); if (lastAnchor->isCenterAnchor) { afterSequence = candidates.constLast(); - candidates.remove(candidates.count() - 1); + candidates.remove(candidates.size() - 1); if (candidates.isEmpty()) continue; @@ -1185,12 +1147,10 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedAnchor(AnchorData *edge) g.createEdge(edge->from, edge->to, edge); } else if (edge->type == AnchorData::Sequential) { - SequentialAnchorData *sequence = static_cast<SequentialAnchorData *>(edge); + const auto *sequence = static_cast<SequentialAnchorData *>(edge); - for (int i = 0; i < sequence->m_edges.count(); ++i) { - AnchorData *data = sequence->m_edges.at(i); + for (AnchorData *data : sequence->m_edges) restoreSimplifiedAnchor(data); - } delete sequence; @@ -1222,7 +1182,7 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints(ParallelAnchorDa if (!parallel->isCenterAnchor) return; - for (int i = 0; i < parallel->m_firstConstraints.count(); ++i) { + for (int i = 0; i < parallel->m_firstConstraints.size(); ++i) { QSimplexConstraint *c = parallel->m_firstConstraints.at(i); qreal v = c->variables[parallel]; c->variables.remove(parallel); @@ -1233,7 +1193,7 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints(ParallelAnchorDa // addAnchorMaybeParallel(). const bool needsReverse = !parallel->secondForward(); - for (int i = 0; i < parallel->m_secondConstraints.count(); ++i) { + for (int i = 0; i < parallel->m_secondConstraints.size(); ++i) { QSimplexConstraint *c = parallel->m_secondConstraints.at(i); qreal v = c->variables[parallel]; if (needsReverse) @@ -1253,7 +1213,7 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedGraph(Qt::Orientation orient // Restore anchor simplification Graph<AnchorVertex, AnchorData> &g = graph[orientation]; QList<QPair<AnchorVertex *, AnchorVertex *>> connections = g.connections(); - for (int i = 0; i < connections.count(); ++i) { + for (int i = 0; i < connections.size(); ++i) { AnchorVertex *v1 = connections.at(i).first; AnchorVertex *v2 = connections.at(i).second; AnchorData *edge = g.edgeData(v1, v2); @@ -1289,14 +1249,14 @@ void QGraphicsAnchorLayoutPrivate::restoreVertices(Qt::Orientation orientation) // In the next step, we'll change the anchors vertices so that would not be possible anymore. QList<AnchorData *> ¶llelAnchors = anchorsFromSimplifiedVertices[orientation]; - for (int i = parallelAnchors.count() - 1; i >= 0; --i) { + for (int i = parallelAnchors.size() - 1; i >= 0; --i) { ParallelAnchorData *parallel = static_cast<ParallelAnchorData *>(parallelAnchors.at(i)); restoreSimplifiedConstraints(parallel); } // Then, we will restore the vertices in the inverse order of creation, this way we ensure that // the vertex being restored was not wrapped by another simplification. - for (int i = toRestore.count() - 1; i >= 0; --i) { + for (int i = toRestore.size() - 1; i >= 0; --i) { AnchorVertexPair *pair = toRestore.at(i); QList<AnchorVertex *> adjacents = g.adjacentVertices(pair); @@ -1307,7 +1267,7 @@ void QGraphicsAnchorLayoutPrivate::restoreVertices(Qt::Orientation orientation) g.createEdge(first, second, pair->m_removedAnchor); // Restore the anchors for the first child vertex - for (int j = 0; j < pair->m_firstAnchors.count(); ++j) { + for (int j = 0; j < pair->m_firstAnchors.size(); ++j) { AnchorData *ad = pair->m_firstAnchors.at(j); Q_ASSERT(ad->from == pair || ad->to == pair); @@ -1316,7 +1276,7 @@ void QGraphicsAnchorLayoutPrivate::restoreVertices(Qt::Orientation orientation) } // Restore the anchors for the second child vertex - for (int j = 0; j < pair->m_secondAnchors.count(); ++j) { + for (int j = 0; j < pair->m_secondAnchors.size(); ++j) { AnchorData *ad = pair->m_secondAnchors.at(j); Q_ASSERT(ad->from == pair || ad->to == pair); @@ -1324,7 +1284,7 @@ void QGraphicsAnchorLayoutPrivate::restoreVertices(Qt::Orientation orientation) g.createEdge(ad->from, ad->to, ad); } - for (int j = 0; j < adjacents.count(); ++j) { + for (int j = 0; j < adjacents.size(); ++j) { g.takeEdge(pair, adjacents.at(j)); } @@ -1534,7 +1494,7 @@ void QGraphicsAnchorLayoutPrivate::removeCenterAnchors( AnchorData *oldData = g.edgeData(first, center); // Remove center constraint - for (int i = itemCenterConstraints[orientation].count() - 1; i >= 0; --i) { + for (int i = itemCenterConstraints[orientation].size() - 1; i >= 0; --i) { if (itemCenterConstraints[orientation].at(i)->variables.contains(oldData)) { delete itemCenterConstraints[orientation].takeAt(i); break; @@ -1555,7 +1515,7 @@ void QGraphicsAnchorLayoutPrivate::removeCenterAnchors( // this is only called from removeAnchors() // first, remove all non-internal anchors QList<AnchorVertex*> adjacents = g.adjacentVertices(center); - for (int i = 0; i < adjacents.count(); ++i) { + for (int i = 0; i < adjacents.size(); ++i) { AnchorVertex *v = adjacents.at(i); if (v->m_item != item) { removeAnchor_helper(center, internalVertex(v->m_item, v->m_edge)); @@ -2048,7 +2008,7 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs() QList<AnchorData *> getVariables(const QList<QSimplexConstraint *> &constraints) { QSet<AnchorData *> variableSet; - for (int i = 0; i < constraints.count(); ++i) { + for (int i = 0; i < constraints.size(); ++i) { const QSimplexConstraint *c = constraints.at(i); for (auto it = c->variables.cbegin(), end = c->variables.cend(); it != end; ++it) variableSet.insert(static_cast<AnchorData *>(it.key())); @@ -2163,7 +2123,7 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs(Qt::Orientation orientation) */ static void shiftConstraints(const QList<QSimplexConstraint *> &constraints, qreal amount) { - for (int i = 0; i < constraints.count(); ++i) { + for (int i = 0; i < constraints.size(); ++i) { QSimplexConstraint *c = constraints.at(i); const qreal multiplier = std::accumulate(c->variables.cbegin(), c->variables.cend(), qreal(0)); c->constant += multiplier * amount; @@ -2221,8 +2181,8 @@ bool QGraphicsAnchorLayoutPrivate::calculateTrunk(Qt::Orientation orientation, c } else { // No Simplex is necessary because the path was simplified all the way to a single // anchor. - Q_ASSERT(path.positives.count() == 1); - Q_ASSERT(path.negatives.count() == 0); + Q_ASSERT(path.positives.size() == 1); + Q_ASSERT(path.negatives.size() == 0); AnchorData *ad = *path.positives.cbegin(); ad->sizeAtMinimum = ad->minSize; @@ -2253,7 +2213,7 @@ bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk(const QList<QSimplexConstra if (feasible) { // Propagate size at preferred to other sizes. Semi-floats always will be // in their sizeAtPreferred. - for (int j = 0; j < variables.count(); ++j) { + for (int j = 0; j < variables.size(); ++j) { AnchorData *ad = variables.at(j); Q_ASSERT(ad); ad->sizeAtMinimum = ad->sizeAtPreferred; @@ -2277,7 +2237,7 @@ void QGraphicsAnchorLayoutPrivate::refreshAllSizeHints(Qt::Orientation orientati QList<QPair<AnchorVertex *, AnchorVertex *>> vertices = g.connections(); QLayoutStyleInfo styleInf = styleInfo(); - for (int i = 0; i < vertices.count(); ++i) { + for (int i = 0; i < vertices.size(); ++i) { AnchorData *data = g.edgeData(vertices.at(i).first, vertices.at(i).second); data->refreshSizeHints(&styleInf); } @@ -2369,7 +2329,7 @@ void QGraphicsAnchorLayoutPrivate::updateAnchorSizes(Qt::Orientation orientation Graph<AnchorVertex, AnchorData> &g = graph[orientation]; const QList<QPair<AnchorVertex *, AnchorVertex *>> &vertices = g.connections(); - for (int i = 0; i < vertices.count(); ++i) { + for (int i = 0; i < vertices.size(); ++i) { AnchorData *ad = g.edgeData(vertices.at(i).first, vertices.at(i).second); ad->updateChildrenSizes(); } @@ -2512,7 +2472,7 @@ QGraphicsAnchorLayoutPrivate::getGraphParts(Qt::Orientation orientation) // Check if this constraint have some overlap with current // trunk variables... - for (QSimplexVariable *ad : qAsConst(trunkVariables)) { + for (QSimplexVariable *ad : std::as_const(trunkVariables)) { if (c->variables.contains(ad)) { match = true; break; @@ -2561,7 +2521,7 @@ void QGraphicsAnchorLayoutPrivate::identifyFloatItems(const QSet<AnchorData *> & identifyNonFloatItems_helper(ad, &nonFloating); QSet<QGraphicsLayoutItem *> floatItems; - for (QGraphicsLayoutItem *item : qAsConst(items)) { + for (QGraphicsLayoutItem *item : std::as_const(items)) { if (!nonFloating.contains(item)) floatItems.insert(item); } @@ -2586,7 +2546,7 @@ void QGraphicsAnchorLayoutPrivate::identifyNonFloatItems_helper(const AnchorData nonFloatingItemsIdentifiedSoFar->insert(ad->item); break; case AnchorData::Sequential: - foreach (const AnchorData *d, static_cast<const SequentialAnchorData *>(ad)->m_edges) + for (const AnchorData *d : static_cast<const SequentialAnchorData *>(ad)->m_edges) identifyNonFloatItems_helper(d, nonFloatingItemsIdentifiedSoFar); break; case AnchorData::Parallel: @@ -2620,7 +2580,7 @@ void QGraphicsAnchorLayoutPrivate::setItemsGeometries(const QRectF &geom) top += geom.top(); right = geom.right() - right; - for (QGraphicsLayoutItem *item : qAsConst(items)) { + for (QGraphicsLayoutItem *item : std::as_const(items)) { QRectF newGeom; QSizeF itemPreferredSize = item->effectiveSizeHint(Qt::PreferredSize); if (m_floatItems[Qt::Horizontal].contains(item)) { @@ -2691,7 +2651,7 @@ void QGraphicsAnchorLayoutPrivate::calculateVertexPositions(Qt::Orientation orie interpolateEdge(pair.first, edge); QList<AnchorVertex *> adjacents = graph[orientation].adjacentVertices(pair.second); - for (int i = 0; i < adjacents.count(); ++i) { + for (int i = 0; i < adjacents.size(); ++i) { if (!visited.contains(adjacents.at(i))) queue.enqueue(qMakePair(pair.second, adjacents.at(i))); } @@ -2775,7 +2735,7 @@ bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList<QSimplexConstraint *> for (iter = path.negatives.constBegin(); iter != path.negatives.constEnd(); ++iter) objective.variables.insert(*iter, -1.0); - const qreal objectiveOffset = (path.positives.count() - path.negatives.count()) * g_offset; + const qreal objectiveOffset = (path.positives.size() - path.negatives.size()) * g_offset; simplex.setObjective(&objective); // Calculate minimum values diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h index 9fa14a3f90..880e262d34 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSANCHORLAYOUT_P_H #define QGRAPHICSANCHORLAYOUT_P_H @@ -191,20 +155,21 @@ inline QString AnchorData::toString() const struct SequentialAnchorData : public AnchorData { SequentialAnchorData(const QList<AnchorVertex *> &vertices, const QList<AnchorData *> &edges) - : AnchorData(), m_children(vertices), m_edges(edges) + : AnchorData(), m_edges(edges) { type = AnchorData::Sequential; isVertical = m_edges.at(0)->isVertical; #ifdef QT_DEBUG name = QString::fromLatin1("%1 -- %2").arg(vertices.first()->toString(), vertices.last()->toString()); +#else + Q_UNUSED(vertices); #endif } virtual void updateChildrenSizes() override; void calculateSizeHints(); - QList<AnchorVertex *> m_children; // list of vertices in the sequence - QList<AnchorData *> m_edges; // keep the list of edges too. + const QList<AnchorData *> m_edges; // keep the list of edges too. }; struct ParallelAnchorData : public AnchorData @@ -269,42 +234,44 @@ struct AnchorVertexPair : public AnchorVertex { #ifdef QT_DEBUG inline QString AnchorVertex::toString() const { + using namespace Qt::StringLiterals; + if (!m_item) return QString::fromLatin1("NULL_%1").arg(quintptr(this)); QString edge; switch (m_edge) { case Qt::AnchorLeft: - edge = QLatin1String("Left"); + edge = "Left"_L1; break; case Qt::AnchorHorizontalCenter: - edge = QLatin1String("HorizontalCenter"); + edge = "HorizontalCenter"_L1; break; case Qt::AnchorRight: - edge = QLatin1String("Right"); + edge = "Right"_L1; break; case Qt::AnchorTop: - edge = QLatin1String("Top"); + edge = "Top"_L1; break; case Qt::AnchorVerticalCenter: - edge = QLatin1String("VerticalCenter"); + edge = "VerticalCenter"_L1; break; case Qt::AnchorBottom: - edge = QLatin1String("Bottom"); + edge = "Bottom"_L1; break; default: - edge = QLatin1String("None"); + edge = "None"_L1; break; } QString itemName; if (m_item->isLayout()) { - itemName = QLatin1String("layout"); + itemName = "layout"_L1; } else { if (QGraphicsItem *item = m_item->graphicsItem()) { itemName = item->data(0).toString(); } } - edge.insert(0, QLatin1String("%1_")); + edge.insert(0, "%1_"_L1); return edge.arg(itemName); } #endif diff --git a/src/widgets/graphicsview/qgraphicsgridlayout.cpp b/src/widgets/graphicsview/qgraphicsgridlayout.cpp index 79cba74a93..e4599d20bb 100644 --- a/src/widgets/graphicsview/qgraphicsgridlayout.cpp +++ b/src/widgets/graphicsview/qgraphicsgridlayout.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only /*! \class QGraphicsGridLayout @@ -47,13 +11,16 @@ \inmodule QtWidgets The most common way to use QGraphicsGridLayout is to construct an object - on the heap with no parent, add widgets and layouts by calling addItem(), - and finally assign the layout to a widget by calling - QGraphicsWidget::setLayout(). QGraphicsGridLayout automatically computes + on the heap, passing a parent widget to the constructor, then add widgets + and layouts by calling addItem(). QGraphicsGridLayout automatically computes the dimensions of the grid as you add items. \snippet code/src_gui_graphicsview_qgraphicsgridlayout.cpp 0 + Alternatively, if you do not pass a parent widget to the layout's constructor, + you will need to call QGraphicsWidget::setLayout() to set this layout as the + top-level layout for that widget, the widget will take ownership of the layout. + The layout takes ownership of the items. In some cases when the layout item also inherits from QGraphicsItem (such as QGraphicsWidget) there will be a ambiguity in ownership because the layout item belongs to two ownership hierarchies. @@ -179,7 +146,7 @@ void QGraphicsGridLayout::addItem(QGraphicsLayoutItem *item, int row, int column } /*! - \fn QGraphicsGridLayout::addItem(QGraphicsLayoutItem *item, int row, int column, Qt::Alignment alignment = 0) + \fn QGraphicsGridLayout::addItem(QGraphicsLayoutItem *item, int row, int column, Qt::Alignment alignment) Adds \a item to the grid on \a row and \a column. You can specify an optional \a alignment for \a item. diff --git a/src/widgets/graphicsview/qgraphicsgridlayout.h b/src/widgets/graphicsview/qgraphicsgridlayout.h index 4c0a1b4527..bf2cf383d8 100644 --- a/src/widgets/graphicsview/qgraphicsgridlayout.h +++ b/src/widgets/graphicsview/qgraphicsgridlayout.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSGRIDLAYOUT_H #define QGRAPHICSGRIDLAYOUT_H diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp b/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp index 3dd1b1652a..db0818d93e 100644 --- a/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp +++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qgraphicsgridlayoutengine_p.h" diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h index a3e42c7b77..f3b2ec3731 100644 --- a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h +++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSGRIDLAYOUTENGINE_P_H #define QGRAPHICSGRIDLAYOUTENGINE_P_H @@ -119,7 +83,7 @@ public: int indexOf(QGraphicsLayoutItem *item) const { - for (int i = 0; i < q_items.count(); ++i) { + for (int i = 0; i < q_items.size(); ++i) { if (item == static_cast<QGraphicsGridLayoutEngineItem*>(q_items.at(i))->layoutItem()) return i; } diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 606244dd3c..17ea830cab 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only /*! \class QGraphicsItem @@ -132,7 +96,6 @@ \image graphicsview-parentchild.png - \target Transformations \section1 Transformations QGraphicsItem supports projective transformations in addition to its base @@ -829,6 +792,8 @@ QT_BEGIN_NAMESPACE +QT_IMPL_METATYPE_EXTERN_TAGGED(QGraphicsItem*, QGraphicsItem_ptr) + static inline void _q_adjustRect(QRect *rect) { Q_ASSERT(rect); @@ -939,7 +904,6 @@ QGraphicsItemPrivate::QGraphicsItemPrivate() scenePosDescendants(false), pendingPolish(false), mayHaveChildWithGraphicsEffect(false), - isDeclarativeItem(false), sendParentChangeNotification(false), dirtyChildrenBoundingRect(true), globalStackingOrder(-1), @@ -1071,7 +1035,7 @@ void QGraphicsItemPrivate::setIsMemberOfGroup(bool enabled) Q_Q(QGraphicsItem); isMemberOfGroup = enabled; if (!qgraphicsitem_cast<QGraphicsItemGroup *>(q)) { - for (QGraphicsItem *child : qAsConst(children)) + for (QGraphicsItem *child : std::as_const(children)) child->d_func()->setIsMemberOfGroup(enabled); } } @@ -2210,7 +2174,7 @@ bool QGraphicsItem::isBlockedByModalPanel(QGraphicsItem **blockingPanel) const if (!scene_d->popupWidgets.isEmpty() && scene_d->popupWidgets.first() == this) return false; - for (int i = 0; i < scene_d->modalPanels.count(); ++i) { + for (int i = 0; i < scene_d->modalPanels.size(); ++i) { QGraphicsItem *modalPanel = scene_d->modalPanels.at(i); if (modalPanel->panelModality() == QGraphicsItem::SceneModal) { // Scene modal panels block all non-descendents. @@ -2493,7 +2457,7 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, const bool updateChildren = update && !((flags & QGraphicsItem::ItemClipsChildrenToShape || flags & QGraphicsItem::ItemContainsChildrenInShape) && !(flags & QGraphicsItem::ItemHasNoContents)); - for (QGraphicsItem *child : qAsConst(children)) { + for (QGraphicsItem *child : std::as_const(children)) { if (!newVisible || !child->d_ptr->explicitlyHidden) child->d_ptr->setVisibleHelper(newVisible, false, updateChildren, hiddenByPanel); } @@ -2685,7 +2649,7 @@ void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bo if (update) q_ptr->update(); - for (QGraphicsItem *child : qAsConst(children)) { + for (QGraphicsItem *child : std::as_const(children)) { if (!newEnabled || !child->d_ptr->explicitlyDisabled) child->d_ptr->setEnabledHelper(newEnabled, /* explicitly = */ false); } @@ -3126,7 +3090,7 @@ Qt::MouseButtons QGraphicsItem::acceptedMouseButtons() const mouse events to the first item beneath it that does. To disable mouse events for an item (i.e., make it transparent for mouse - events), call setAcceptedMouseButtons(0). + events), call setAcceptedMouseButtons(Qt::NoButton). \sa acceptedMouseButtons(), mousePressEvent() */ @@ -3248,7 +3212,7 @@ bool QGraphicsItem::filtersChildEvents() const \since 4.6 If \a enabled is true, this item is set to filter all events for - all its children (i.e., all events intented for any of its + all its children (i.e., all events intended for any of its children are instead sent to this item); otherwise, if \a enabled is false, this item will only handle its own events. The default value is false. @@ -3290,7 +3254,7 @@ bool QGraphicsItem::handlesChildEvents() const \deprecated If \a enabled is true, this item is set to handle all events for - all its children (i.e., all events intented for any of its + all its children (i.e., all events intended for any of its children are instead sent to this item); otherwise, if \a enabled is false, this item will only handle its own events. The default value is false. @@ -3952,7 +3916,7 @@ void QGraphicsItem::ensureVisible(const QRectF &rect, int xmargin, int ymargin) sceneRect = sceneTransform().mapRect(rect); else sceneRect = sceneBoundingRect(); - for (QGraphicsView *view : qAsConst(d_ptr->scene->d_func()->views)) + for (QGraphicsView *view : std::as_const(d_ptr->scene->d_func()->views)) view->ensureVisible(sceneRect, xmargin, ymargin); } } @@ -4662,7 +4626,7 @@ inline void QGraphicsItemPrivate::sendScenePosChange() if (flags & QGraphicsItem::ItemSendsScenePositionChanges) q->itemChange(QGraphicsItem::ItemScenePositionHasChanged, q->scenePos()); if (scenePosDescendants) { - for (QGraphicsItem *item : qAsConst(scene->d_func()->scenePosItems)) { + for (QGraphicsItem *item : std::as_const(scene->d_func()->scenePosItems)) { if (q->isAncestorOf(item)) item->itemChange(QGraphicsItem::ItemScenePositionHasChanged, item->scenePos()); } @@ -6537,7 +6501,7 @@ void QGraphicsItem::setData(int key, const QVariant &value) } /*! - \fn T qgraphicsitem_cast(QGraphicsItem *item) + \fn template <class T> qgraphicsitem_cast(QGraphicsItem *item) \relates QGraphicsItem \since 4.2 @@ -7118,7 +7082,7 @@ void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) selectedItems = d_ptr->scene->selectedItems(); initialPositions = d_ptr->scene->d_func()->movingItemsInitialPositions; if (initialPositions.isEmpty()) { - for (QGraphicsItem *item : qAsConst(selectedItems)) + for (QGraphicsItem *item : std::as_const(selectedItems)) initialPositions[item] = item->pos(); initialPositions[this] = pos(); } @@ -7227,7 +7191,7 @@ void QGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) // temporarily removing this item from the selection list. if (d_ptr->selected) { scene->d_func()->selectedItems.remove(this); - for (QGraphicsItem *item : qAsConst(scene->d_func()->selectedItems)) { + for (QGraphicsItem *item : std::as_const(scene->d_func()->selectedItems)) { if (item->isSelected()) { selectionChanged = true; break; @@ -7685,66 +7649,6 @@ void QGraphicsObject::updateMicroFocus() QGraphicsItem::updateMicroFocus(); } -void QGraphicsItemPrivate::children_append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item) -{ - if (item) { - QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(list->object); - if (QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification) { - item->setParentItem(graphicsObject); - } else { - QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, nullptr, nullptr); - } - } -} - -int QGraphicsItemPrivate::children_count(QDeclarativeListProperty<QGraphicsObject> *list) -{ - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); - return d->children.count(); -} - -QGraphicsObject *QGraphicsItemPrivate::children_at(QDeclarativeListProperty<QGraphicsObject> *list, int index) -{ - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); - if (index >= 0 && index < d->children.count()) - return d->children.at(index)->toGraphicsObject(); - else - return nullptr; -} - -void QGraphicsItemPrivate::children_clear(QDeclarativeListProperty<QGraphicsObject> *list) -{ - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); - int childCount = d->children.count(); - if (d->sendParentChangeNotification) { - for (int index = 0; index < childCount; index++) - d->children.at(0)->setParentItem(nullptr); - } else { - for (int index = 0; index < childCount; index++) - QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(nullptr, nullptr, nullptr); - } -} - -/*! - Returns a list of this item's children. - - The items are sorted by stacking order. This takes into account both the - items' insertion order and their Z-values. - -*/ -QDeclarativeListProperty<QGraphicsObject> QGraphicsItemPrivate::childrenList() -{ - Q_Q(QGraphicsItem); - if (isObject) { - QGraphicsObject *that = static_cast<QGraphicsObject *>(q); - return QDeclarativeListProperty<QGraphicsObject>(that, &children, children_append, - children_count, children_at, children_clear); - } else { - //QGraphicsItem is not supported for this property - return QDeclarativeListProperty<QGraphicsObject>(); - } -} - /*! \internal Returns the width of the item @@ -10309,7 +10213,9 @@ void QGraphicsTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) QVariant QGraphicsTextItem::inputMethodQuery(Qt::InputMethodQuery query) const { QVariant v; - if (query == Qt::ImHints) + if (query == Qt::ImEnabled) + return isEnabled(); + else if (query == Qt::ImHints) v = int(inputMethodHints()); else if (dd->control) v = dd->control->inputMethodQuery(query, QVariant()); @@ -10397,16 +10303,16 @@ QWidgetTextControl *QGraphicsTextItemPrivate::textControl() const control = new QWidgetTextControl(that); control->setTextInteractionFlags(Qt::NoTextInteraction); - QObject::connect(control, SIGNAL(updateRequest(QRectF)), - qq, SLOT(_q_update(QRectF))); - QObject::connect(control, SIGNAL(documentSizeChanged(QSizeF)), - qq, SLOT(_q_updateBoundingRect(QSizeF))); - QObject::connect(control, SIGNAL(visibilityRequest(QRectF)), - qq, SLOT(_q_ensureVisible(QRectF))); - QObject::connect(control, SIGNAL(linkActivated(QString)), - qq, SIGNAL(linkActivated(QString))); - QObject::connect(control, SIGNAL(linkHovered(QString)), - qq, SIGNAL(linkHovered(QString))); + QObject::connect(control, &QWidgetTextControl::updateRequest, qq, + [dd = that->dd](const QRectF &rect) { dd->_q_update(rect); }); + QObject::connect(control, &QWidgetTextControl::documentSizeChanged, qq, + [dd = that->dd](QSizeF size) { dd->_q_updateBoundingRect(size); }); + QObject::connect(control, &QWidgetTextControl::visibilityRequest, qq, + [dd = that->dd](const QRectF &rect) { dd->_q_ensureVisible(rect); }); + QObject::connect(control, &QWidgetTextControl::linkActivated, qq, + &QGraphicsTextItem::linkActivated); + QObject::connect(control, &QWidgetTextControl::linkHovered, qq, + &QGraphicsTextItem::linkHovered); const QSizeF pgSize = control->document()->pageSize(); if (pgSize.height() != -1) { @@ -10609,7 +10515,7 @@ void QGraphicsSimpleTextItemPrivate::updateBoundingRect() br = QRectF(); } else { QString tmp = text; - tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); + tmp.replace(u'\n', QChar::LineSeparator); QStackTextEngine engine(tmp, font); QTextLayout layout(&engine); br = setupTextLayout(&layout); @@ -10770,7 +10676,7 @@ void QGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphic painter->setFont(d->font); QString tmp = d->text; - tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); + tmp.replace(u'\n', QChar::LineSeparator); QStackTextEngine engine(tmp, d->font); QTextLayout layout(&engine); @@ -10782,7 +10688,7 @@ void QGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphic } else { QTextLayout::FormatRange range; range.start = 0; - range.length = layout.text().length(); + range.length = layout.text().size(); range.format.setTextOutline(d->pen); layout.setFormats(QList<QTextLayout::FormatRange>(1, range)); } diff --git a/src/widgets/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h index 18d92c62aa..f82c600b3a 100644 --- a/src/widgets/graphicsview/qgraphicsitem.h +++ b/src/widgets/graphicsview/qgraphicsitem.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSITEM_H #define QGRAPHICSITEM_H @@ -468,7 +432,7 @@ private: }; Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsItem::GraphicsItemFlags) -#ifndef Q_CLANG_QDOC +#ifndef Q_QDOC Q_DECLARE_INTERFACE(QGraphicsItem, "org.qt-project.Qt.QGraphicsItem") #endif @@ -536,13 +500,10 @@ class Q_WIDGETS_EXPORT QGraphicsObject : public QObject, public QGraphicsItem #if QT_CONFIG(graphicseffect) Q_PROPERTY(QGraphicsEffect *effect READ graphicsEffect WRITE setGraphicsEffect) #endif - Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), QDeclarativeListProperty<QGraphicsObject> children - READ childrenList DESIGNABLE false NOTIFY childrenChanged) Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), qreal width READ width WRITE setWidth NOTIFY widthChanged RESET resetWidth FINAL) Q_PRIVATE_PROPERTY(QGraphicsItem::d_func(), qreal height READ height WRITE setHeight NOTIFY heightChanged RESET resetHeight FINAL) - Q_CLASSINFO("DefaultProperty", "children") Q_INTERFACES(QGraphicsItem) public: explicit QGraphicsObject(QGraphicsItem *parent = nullptr); @@ -941,9 +902,6 @@ protected: private: Q_DISABLE_COPY(QGraphicsTextItem) - Q_PRIVATE_SLOT(dd, void _q_updateBoundingRect(const QSizeF &)) - Q_PRIVATE_SLOT(dd, void _q_update(QRectF)) - Q_PRIVATE_SLOT(dd, void _q_ensureVisible(QRectF)) QGraphicsTextItemPrivate *dd; friend class QGraphicsTextItemPrivate; }; @@ -1012,14 +970,14 @@ template <class T> inline T qgraphicsitem_cast(QGraphicsItem *item) { typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Item; return int(Item::Type) == int(QGraphicsItem::Type) - || (item && int(Item::Type) == item->type()) ? static_cast<T>(item) : 0; + || (item && int(Item::Type) == item->type()) ? static_cast<T>(item) : nullptr; } template <class T> inline T qgraphicsitem_cast(const QGraphicsItem *item) { typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type Item; return int(Item::Type) == int(QGraphicsItem::Type) - || (item && int(Item::Type) == item->type()) ? static_cast<T>(item) : 0; + || (item && int(Item::Type) == item->type()) ? static_cast<T>(item) : nullptr; } #ifndef QT_NO_DEBUG_STREAM @@ -1032,10 +990,6 @@ Q_WIDGETS_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag QT_END_NAMESPACE -Q_DECLARE_METATYPE(QGraphicsItem *) - -QT_BEGIN_NAMESPACE - -QT_END_NAMESPACE +QT_DECL_METATYPE_EXTERN_TAGGED(QGraphicsItem*, QGraphicsItem_ptr, Q_WIDGETS_EXPORT) #endif // QGRAPHICSITEM_H diff --git a/src/widgets/graphicsview/qgraphicsitem_p.h b/src/widgets/graphicsview/qgraphicsitem_p.h index 3827bc965e..bf6ebb96a2 100644 --- a/src/widgets/graphicsview/qgraphicsitem_p.h +++ b/src/widgets/graphicsview/qgraphicsitem_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSITEM_P_H #define QGRAPHICSITEM_P_H @@ -67,63 +31,6 @@ QT_BEGIN_NAMESPACE class QGraphicsItemPrivate; -#ifndef QDECLARATIVELISTPROPERTY -#define QDECLARATIVELISTPROPERTY -template<typename T> -class QDeclarativeListProperty { -public: - typedef void (*AppendFunction)(QDeclarativeListProperty<T> *, T*); - typedef int (*CountFunction)(QDeclarativeListProperty<T> *); - typedef T *(*AtFunction)(QDeclarativeListProperty<T> *, int); - typedef void (*ClearFunction)(QDeclarativeListProperty<T> *); - - QDeclarativeListProperty() - : object(nullptr), data(nullptr), append(nullptr), count(nullptr), at(nullptr), clear(nullptr), dummy1(nullptr), dummy2(nullptr) {} - QDeclarativeListProperty(QObject *o, QList<T *> &list) - : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at), - clear(qlist_clear), dummy1(nullptr), dummy2(nullptr) {} - QDeclarativeListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = nullptr, AtFunction t = nullptr, - ClearFunction r = nullptr) - : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(nullptr), dummy2(nullptr) {} - - bool operator==(const QDeclarativeListProperty &o) const { - return object == o.object && - data == o.data && - append == o.append && - count == o.count && - at == o.at && - clear == o.clear; - } - - QObject *object; - void *data; - - AppendFunction append; - - CountFunction count; - AtFunction at; - - ClearFunction clear; - - void *dummy1; - void *dummy2; - -private: - static void qlist_append(QDeclarativeListProperty *p, T *v) { - ((QList<T *> *)p->data)->append(v); - } - static int qlist_count(QDeclarativeListProperty *p) { - return ((QList<T *> *)p->data)->count(); - } - static T *qlist_at(QDeclarativeListProperty *p, int idx) { - return ((QList<T *> *)p->data)->at(idx); - } - static void qlist_clear(QDeclarativeListProperty *p) { - return ((QList<T *> *)p->data)->clear(); - } -}; -#endif - class QGraphicsItemCache { public: @@ -226,7 +133,6 @@ public: void resolveDepth(); void addChild(QGraphicsItem *child); void removeChild(QGraphicsItem *child); - QDeclarativeListProperty<QGraphicsObject> childrenList(); void setParentItemHelper(QGraphicsItem *parent, const QVariant *newParentVariant, const QVariant *thisPointerVariant); void childrenBoundingRectHelper(QTransform *x, QRectF *rect, QGraphicsItem *topMostEffectItem); @@ -414,11 +320,6 @@ public: virtual void subFocusItemChange(); virtual void focusScopeItemChange(bool isSubFocusItem); - static void children_append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item); - static int children_count(QDeclarativeListProperty<QGraphicsObject> *list); - static QGraphicsObject *children_at(QDeclarativeListProperty<QGraphicsObject> *list, int); - static void children_clear(QDeclarativeListProperty<QGraphicsObject> *list); - inline QTransform transformToParent() const; inline void ensureSortedChildren(); static inline bool insertionOrder(QGraphicsItem *a, QGraphicsItem *b); @@ -514,10 +415,9 @@ public: quint32 scenePosDescendants : 1; quint32 pendingPolish : 1; quint32 mayHaveChildWithGraphicsEffect : 1; - quint32 isDeclarativeItem : 1; quint32 sendParentChangeNotification : 1; quint32 dirtyChildrenBoundingRect : 1; - quint32 padding : 19; + quint32 padding : 20; // Optional stacking order int globalStackingOrder; @@ -624,7 +524,6 @@ public: return item->type() == QGraphicsPixmapItem::Type && !(item->flags() & QGraphicsItem::ItemIsSelectable) && item->d_ptr->children.size() == 0; - //|| (item->d_ptr->isObject && qobject_cast<QDeclarativeImage *>(q_func())); } const QStyleOption *styleOption() const override diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.cpp b/src/widgets/graphicsview/qgraphicsitemanimation.cpp index e0b881c18e..23dd9fcc7d 100644 --- a/src/widgets/graphicsview/qgraphicsitemanimation.cpp +++ b/src/widgets/graphicsview/qgraphicsitemanimation.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only /*! \class QGraphicsItemAnimation diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.h b/src/widgets/graphicsview/qgraphicsitemanimation.h index 8165532366..5fb6484c74 100644 --- a/src/widgets/graphicsview/qgraphicsitemanimation.h +++ b/src/widgets/graphicsview/qgraphicsitemanimation.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSITEMANIMATION_H #define QGRAPHICSITEMANIMATION_H diff --git a/src/widgets/graphicsview/qgraphicslayout.cpp b/src/widgets/graphicsview/qgraphicslayout.cpp index f7987cdd23..672f78afb8 100644 --- a/src/widgets/graphicsview/qgraphicslayout.cpp +++ b/src/widgets/graphicsview/qgraphicslayout.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qapplication.h" diff --git a/src/widgets/graphicsview/qgraphicslayout.h b/src/widgets/graphicsview/qgraphicslayout.h index efcafa5e6a..b95a6b839f 100644 --- a/src/widgets/graphicsview/qgraphicslayout.h +++ b/src/widgets/graphicsview/qgraphicslayout.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSLAYOUT_H #define QGRAPHICSLAYOUT_H @@ -83,7 +47,7 @@ private: friend class QGraphicsWidget; }; -#ifndef Q_CLANG_QDOC +#ifndef Q_QDOC Q_DECLARE_INTERFACE(QGraphicsLayout, "org.qt-project.Qt.QGraphicsLayout") #endif diff --git a/src/widgets/graphicsview/qgraphicslayout_p.cpp b/src/widgets/graphicsview/qgraphicslayout_p.cpp index c10763d065..e902ed8612 100644 --- a/src/widgets/graphicsview/qgraphicslayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicslayout_p.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qglobal.h" diff --git a/src/widgets/graphicsview/qgraphicslayout_p.h b/src/widgets/graphicsview/qgraphicslayout_p.h index d6edfec751..06eab2ba50 100644 --- a/src/widgets/graphicsview/qgraphicslayout_p.h +++ b/src/widgets/graphicsview/qgraphicslayout_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSLAYOUT_P_H #define QGRAPHICSLAYOUT_P_H @@ -87,8 +51,8 @@ public: Q_ASSERT(style); if (widget) //### m_styleOption.initFrom(widget); - m_defaultSpacing[0] = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing, &m_styleOption); - m_defaultSpacing[1] = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing, &m_styleOption); + m_defaultSpacing[0] = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing, &m_styleOption, widget); + m_defaultSpacing[1] = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing, &m_styleOption, widget); } inline void invalidate() { m_valid = false; m_style = nullptr; m_widget = nullptr; } diff --git a/src/widgets/graphicsview/qgraphicslayoutitem.cpp b/src/widgets/graphicsview/qgraphicslayoutitem.cpp index 67eefc14ad..f6aad09810 100644 --- a/src/widgets/graphicsview/qgraphicslayoutitem.cpp +++ b/src/widgets/graphicsview/qgraphicslayoutitem.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qglobal.h" diff --git a/src/widgets/graphicsview/qgraphicslayoutitem.h b/src/widgets/graphicsview/qgraphicslayoutitem.h index 04905c7654..43194ee729 100644 --- a/src/widgets/graphicsview/qgraphicslayoutitem.h +++ b/src/widgets/graphicsview/qgraphicslayoutitem.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSLAYOUTITEM_H #define QGRAPHICSLAYOUTITEM_H @@ -117,7 +81,7 @@ private: friend class QGraphicsLayout; }; -#ifndef Q_CLANG_QDOC +#ifndef Q_QDOC Q_DECLARE_INTERFACE(QGraphicsLayoutItem, "org.qt-project.Qt.QGraphicsLayoutItem") #endif diff --git a/src/widgets/graphicsview/qgraphicslayoutitem_p.h b/src/widgets/graphicsview/qgraphicslayoutitem_p.h index 6aaa85381e..70fb82c78c 100644 --- a/src/widgets/graphicsview/qgraphicslayoutitem_p.h +++ b/src/widgets/graphicsview/qgraphicslayoutitem_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSLAYOUTITEM_P_H #define QGRAPHICSLAYOUTITEM_P_H diff --git a/src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp b/src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp index 58b9f8bb9d..6bd57470f3 100644 --- a/src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp +++ b/src/widgets/graphicsview/qgraphicslayoutstyleinfo.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qgraphicslayoutstyleinfo_p.h" @@ -82,7 +46,7 @@ qreal QGraphicsLayoutStyleInfo::spacing(Qt::Orientation orientation) const Q_ASSERT(style()); return style()->pixelMetric(orientation == Qt::Horizontal ? QStyle::PM_LayoutHorizontalSpacing : QStyle::PM_LayoutVerticalSpacing, - &m_styleOption); + &m_styleOption, widget()); } qreal QGraphicsLayoutStyleInfo::windowMargin(Qt::Orientation orientation) const diff --git a/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h b/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h index 9807efb26e..a3c0c22606 100644 --- a/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h +++ b/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSLAYOUTSTYLEINFO_P_H #define QGRAPHICSLAYOUTSTYLEINFO_P_H diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.cpp b/src/widgets/graphicsview/qgraphicslinearlayout.cpp index f76cc61586..04693734d2 100644 --- a/src/widgets/graphicsview/qgraphicslinearlayout.cpp +++ b/src/widgets/graphicsview/qgraphicslinearlayout.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only /*! \class QGraphicsLinearLayout @@ -50,12 +14,16 @@ passing Qt::Vertical to QGraphicsLinearLayout's constructor. The most common way to use QGraphicsLinearLayout is to construct an object - on the heap with no parent, add widgets and layouts by calling addItem(), - and finally assign the layout to a widget by calling - QGraphicsWidget::setLayout(). + on the heap, passing a parent widget to the constructor, then add widgets + and layouts by calling addItem(). \snippet code/src_gui_graphicsview_qgraphicslinearlayout.cpp 0 + Alternatively, if you do not pass a parent widget to the layout's constructor, + you will need to call QGraphicsWidget::setLayout() to set this layout as the + top-level layout for that widget, the widget will take ownership of + the layout. + You can add widgets, layouts, stretches (addStretch(), insertStretch() or setStretchFactor()), and spacings (setItemSpacing()) to a linear layout. The layout takes ownership of the items. In some cases when the layout diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.h b/src/widgets/graphicsview/qgraphicslinearlayout.h index d27191adb3..d71c64aa5f 100644 --- a/src/widgets/graphicsview/qgraphicslinearlayout.h +++ b/src/widgets/graphicsview/qgraphicslinearlayout.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSLINEARLAYOUT_H #define QGRAPHICSLINEARLAYOUT_H diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index 7b381367c3..1ff4814142 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qglobal.h" @@ -376,10 +340,10 @@ QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) // Run around the focus chain until we find a widget that can take tab focus. if (!child) { - child = next ? (QWidget *)widget : widget->d_func()->focus_prev; + child = next ? widget.data() : widget->previousInFocusChain(); } else { - child = next ? child->d_func()->focus_next : child->d_func()->focus_prev; - if ((next && child == widget) || (!next && child == widget->d_func()->focus_prev)) { + child = next ? child->nextInFocusChain() : child->previousInFocusChain(); + if ((next && child == widget) || (!next && child == widget->previousInFocusChain())) { return nullptr; } } @@ -396,8 +360,8 @@ QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) && !(child->d_func()->extra && child->d_func()->extra->focus_proxy)) { return child; } - child = next ? child->d_func()->focus_next : child->d_func()->focus_prev; - } while (child != oldChild && !(next && child == widget) && !(!next && child == widget->d_func()->focus_prev)); + child = next ? child->nextInFocusChain() : child->previousInFocusChain(); + } while (child != oldChild && !(next && child == widget) && !(!next && child == widget->previousInFocusChain())); return nullptr; } @@ -497,7 +461,7 @@ void QGraphicsProxyWidgetPrivate::embedSubWindow(QWidget *subWin) */ void QGraphicsProxyWidgetPrivate::unembedSubWindow(QWidget *subWin) { - for (QGraphicsItem *child : qAsConst(children)) { + for (QGraphicsItem *child : std::as_const(children)) { if (child->isWidget()) { if (QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(static_cast<QGraphicsWidget *>(child))) { if (proxy->widget() == subWin) { @@ -558,7 +522,7 @@ QGraphicsProxyWidget::~QGraphicsProxyWidget() /*! Embeds \a widget into this proxy widget. The embedded widget must reside exclusively either inside or outside of Graphics View. You cannot embed a - widget as long as it is is visible elsewhere in the UI, at the same time. + widget as long as it is visible elsewhere in the UI, at the same time. \a widget must be a top-level widget whose parent is \nullptr. @@ -1437,7 +1401,7 @@ void QGraphicsProxyWidget::focusOutEvent(QFocusEvent *event) if (QWidget *focusWidget = d->widget->focusWidget()) { // QTBUG-88016 proxyWidget set QTextEdit(QLineEdit etc.) when input preview text, // inputMethod should be reset when proxyWidget lost focus - if (focusWidget && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) + if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) QApplication::inputMethod()->reset(); d->removeSubFocusHelper(focusWidget, event->reason()); diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.h b/src/widgets/graphicsview/qgraphicsproxywidget.h index aa51500ecb..7149f5701a 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.h +++ b/src/widgets/graphicsview/qgraphicsproxywidget.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSPROXYWIDGET_H #define QGRAPHICSPROXYWIDGET_H diff --git a/src/widgets/graphicsview/qgraphicsproxywidget_p.h b/src/widgets/graphicsview/qgraphicsproxywidget_p.h index 593b686e0e..328faad0be 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget_p.h +++ b/src/widgets/graphicsview/qgraphicsproxywidget_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSPROXYWIDGET_P_H #define QGRAPHICSPROXYWIDGET_P_H @@ -55,6 +19,8 @@ #include "qgraphicsproxywidget.h" #include "private/qgraphicswidget_p.h" +#include <QtCore/qpointer.h> + QT_REQUIRE_CONFIG(graphicsview); QT_BEGIN_NAMESPACE diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 0eceaeacb2..c022af6fc0 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only /*! \class QGraphicsScene @@ -244,6 +208,7 @@ #include <QtGui/qinputmethod.h> #include <private/qapplication_p.h> #include <private/qevent_p.h> +#include <QtGui/private/qeventpoint_p.h> #include <private/qobject_p.h> #if QT_CONFIG(graphicseffect) #include <private/qgraphicseffect_p.h> @@ -251,6 +216,8 @@ #include <private/qgesturemanager_p.h> #include <private/qpathclipper_p.h> +#include <QtCore/qpointer.h> + // #define GESTURE_DEBUG #ifndef GESTURE_DEBUG # define DEBUG if (0) qDebug @@ -365,7 +332,7 @@ void QGraphicsScenePrivate::_q_emitUpdated() // needs to happen in order to keep compatibility with the behavior from // Qt 4.4 and backward. if (isSignalConnected(changedSignalIndex)) { - for (auto view : qAsConst(views)) { + for (auto view : std::as_const(views)) { if (!view->d_func()->connectedToScene) { view->d_func()->connectedToScene = true; q->connect(q, SIGNAL(changed(QList<QRectF>)), @@ -377,10 +344,10 @@ void QGraphicsScenePrivate::_q_emitUpdated() updateAll = false; return; } - for (auto view : qAsConst(views)) + for (auto view : std::as_const(views)) view->d_func()->processPendingUpdates(); // It's important that we update all views before we dispatch, hence two for-loops. - for (auto view : qAsConst(views)) + for (auto view : std::as_const(views)) view->d_func()->dispatchPendingUpdateRequests(); return; } @@ -446,7 +413,7 @@ void QGraphicsScenePrivate::_q_polishItems() const QVariant booleanTrueVariant(true); QGraphicsItem *item = nullptr; QGraphicsItemPrivate *itemd = nullptr; - const int oldUnpolishedCount = unpolishedItems.count(); + const int oldUnpolishedCount = unpolishedItems.size(); for (int i = 0; i < oldUnpolishedCount; ++i) { item = unpolishedItems.at(i); @@ -464,7 +431,7 @@ void QGraphicsScenePrivate::_q_polishItems() } } - if (unpolishedItems.count() == oldUnpolishedCount) { + if (unpolishedItems.size() == oldUnpolishedCount) { // No new items were added to the vector. unpolishedItems.clear(); } else { @@ -483,7 +450,7 @@ void QGraphicsScenePrivate::_q_processDirtyItems() Q_ASSERT(calledEmitUpdated); // No need for further processing (except resetting the dirty states). // The growingItemsBoundingRect is updated in _q_emitUpdated. - for (auto topLevelItem : qAsConst(topLevelItems)) + for (auto topLevelItem : std::as_const(topLevelItems)) resetDirtyItem(topLevelItem, /*recursive=*/true); return; } @@ -492,7 +459,7 @@ void QGraphicsScenePrivate::_q_processDirtyItems() const QRectF oldGrowingItemsBoundingRect = growingItemsBoundingRect; // Process items recursively. - for (auto topLevelItem : qAsConst(topLevelItems)) + for (auto topLevelItem : std::as_const(topLevelItems)) processDirtyItemsRecursive(topLevelItem); dirtyGrowingItemsBoundingRect = false; @@ -502,7 +469,7 @@ void QGraphicsScenePrivate::_q_processDirtyItems() if (wasPendingSceneUpdate) return; - for (auto view : qAsConst(views)) + for (auto view : std::as_const(views)) view->d_func()->processPendingUpdates(); if (calledEmitUpdated) { @@ -513,7 +480,7 @@ void QGraphicsScenePrivate::_q_processDirtyItems() } // Immediately dispatch all pending update requests on the views. - for (auto view : qAsConst(views)) + for (auto view : std::as_const(views)) view->d_func()->dispatchPendingUpdateRequests(); } @@ -556,7 +523,7 @@ void QGraphicsScenePrivate::unregisterScenePosItem(QGraphicsItem *item) */ void QGraphicsScenePrivate::_q_updateScenePosDescendants() { - for (QGraphicsItem *item : qAsConst(scenePosItems)) { + for (QGraphicsItem *item : std::as_const(scenePosItems)) { QGraphicsItem *p = item->d_ptr->parent; while (p) { p->d_ptr->scenePosDescendants = 1; @@ -609,7 +576,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) //attributes (e.g. sceneTransform). if (!item->d_ptr->inDestructor) { // Remove all children recursively - for (auto child : qAsConst(item->d_ptr->children)) + for (auto child : std::as_const(item->d_ptr->children)) q->removeItem(child); } @@ -1039,7 +1006,7 @@ void QGraphicsScenePrivate::ungrabMouse(QGraphicsItem *item, bool itemIsDying) void QGraphicsScenePrivate::clearMouseGrabber() { if (!mouseGrabberItems.isEmpty()) - mouseGrabberItems.first()->ungrabMouse(); + mouseGrabberItems.constFirst()->ungrabMouse(); lastMouseGrabberItem = nullptr; } @@ -1115,7 +1082,7 @@ void QGraphicsScenePrivate::clearKeyboardGrabber() void QGraphicsScenePrivate::enableMouseTrackingOnViews() { - for (QGraphicsView *view : qAsConst(views)) + for (QGraphicsView *view : std::as_const(views)) view->viewport()->setMouseTracking(true); } @@ -1378,7 +1345,7 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou // Set focus on the topmost enabled item that can take focus. bool setFocus = false; - for (QGraphicsItem *item : qAsConst(cachedItemsUnderMouse)) { + for (QGraphicsItem *item : std::as_const(cachedItemsUnderMouse)) { if (item->isBlockedByModalPanel() || (item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling)) { // Make sure we don't clear focus. @@ -1401,7 +1368,7 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou // Check for scene modality. bool sceneModality = false; - for (auto modalPanel : qAsConst(modalPanels)) { + for (auto modalPanel : std::as_const(modalPanels)) { if (modalPanel->panelModality() == QGraphicsItem::SceneModal) { sceneModality = true; break; @@ -1420,7 +1387,7 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou // candidates one at a time, until the event is accepted. It's accepted by // default, so the receiver has to explicitly ignore it for it to pass // through. - for (QGraphicsItem *item : qAsConst(cachedItemsUnderMouse)) { + for (QGraphicsItem *item : std::as_const(cachedItemsUnderMouse)) { if (!(item->acceptedMouseButtons() & mouseEvent->button())) { // Skip items that don't accept the event's mouse button. continue; @@ -1696,7 +1663,7 @@ QGraphicsScene::~QGraphicsScene() // Remove this scene from all associated views. // Note: d->views is modified by QGraphicsView::setScene, so must make a copy const auto views = d->views; - for (auto view : qAsConst(views)) + for (auto view : std::as_const(views)) view->setScene(nullptr); } @@ -1815,8 +1782,8 @@ void QGraphicsScene::render(QPainter *painter, const QRectF &target, const QRect // in reverse order). QList<QGraphicsItem *> itemList = items(sourceRect, Qt::IntersectsItemBoundingRect); QGraphicsItem **itemArray = new QGraphicsItem *[itemList.size()]; - const int numItems = itemList.size(); - for (int i = 0; i < numItems; ++i) + const qsizetype numItems = itemList.size(); + for (qsizetype i = 0; i < numItems; ++i) itemArray[numItems - i - 1] = itemList.at(i); itemList.clear(); @@ -1833,7 +1800,7 @@ void QGraphicsScene::render(QPainter *painter, const QRectF &target, const QRect // Generate the style options QStyleOptionGraphicsItem *styleOptionArray = new QStyleOptionGraphicsItem[numItems]; - for (int i = 0; i < numItems; ++i) + for (qsizetype i = 0; i < numItems; ++i) itemArray[i]->d_ptr->initStyleOption(&styleOptionArray[i], painterTransform, targetRect.toRect()); // Render the scene. @@ -2167,7 +2134,7 @@ QList<QGraphicsItem *> QGraphicsScene::selectedItems() const // Optimization: Lazily removes items that are not selected. QGraphicsScene *that = const_cast<QGraphicsScene *>(this); QSet<QGraphicsItem *> actuallySelectedSet; - for (QGraphicsItem *item : qAsConst(that->d_func()->selectedItems)) { + for (QGraphicsItem *item : std::as_const(that->d_func()->selectedItems)) { if (item->isSelected()) actuallySelectedSet << item; } @@ -2257,7 +2224,7 @@ void QGraphicsScene::setSelectionArea(const QPainterPath &path, switch (selectionOperation) { case Qt::ReplaceSelection: // Deselect all items outside path. - for (QGraphicsItem *item : qAsConst(unselectItems)) { + for (QGraphicsItem *item : std::as_const(unselectItems)) { item->setSelected(false); changed = true; } @@ -2284,11 +2251,18 @@ void QGraphicsScene::clearSelection() // Disable emitting selectionChanged ++d->selectionChanging; - bool changed = !d->selectedItems.isEmpty(); + // iterate over a copy, as clearing selection might invalidate selectedItems + const auto selectedItems = d->selectedItems; + QSet<QGraphicsItem *> stillSelectedSet; - for (QGraphicsItem *item : qAsConst(d->selectedItems)) + for (QGraphicsItem *item : selectedItems) { item->setSelected(false); - d->selectedItems.clear(); + // items might override itemChange to prevent deselection + if (item->isSelected()) + stillSelectedSet << item; + } + const bool changed = stillSelectedSet != selectedItems; + d->selectedItems = stillSelectedSet; // Re-enable emitting selectionChanged() for individual items. --d->selectionChanging; @@ -2445,16 +2419,12 @@ void QGraphicsScene::addItem(QGraphicsItem *item) return; } - // QDeclarativeItems do not rely on initial itemChanged message, as the componentComplete - // function allows far more opportunity for delayed-construction optimization. - if (!item->d_ptr->isDeclarativeItem) { - if (d->unpolishedItems.isEmpty()) { - QMetaMethod method = metaObject()->method(d->polishItemsIndex); - method.invoke(this, Qt::QueuedConnection); - } - d->unpolishedItems.append(item); - item->d_ptr->pendingPolish = true; + if (d->unpolishedItems.isEmpty()) { + QMetaMethod method = metaObject()->method(d->polishItemsIndex); + method.invoke(this, Qt::QueuedConnection); } + d->unpolishedItems.append(item); + item->d_ptr->pendingPolish = true; // Detach this item from its parent if the parent's scene is different // from this scene. @@ -2544,7 +2514,7 @@ void QGraphicsScene::addItem(QGraphicsItem *item) // Add all children recursively item->d_ptr->ensureSortedChildren(); - for (auto child : qAsConst(item->d_ptr->children)) + for (auto child : std::as_const(item->d_ptr->children)) addItem(child); // Resolve font and palette. @@ -2916,7 +2886,7 @@ void QGraphicsScene::setFocusItem(QGraphicsItem *item, Qt::FocusReason focusReas /*! Returns \c true if the scene has focus; otherwise returns \c false. If the scene - has focus, it will will forward key events from QKeyEvent to any item that + has focus, it will forward key events from QKeyEvent to any item that has focus. \sa setFocus(), setFocusItem() @@ -3047,7 +3017,7 @@ void QGraphicsScene::setBackgroundBrush(const QBrush &brush) { Q_D(QGraphicsScene); d->backgroundBrush = brush; - for (QGraphicsView *view : qAsConst(d->views)) { + for (QGraphicsView *view : std::as_const(d->views)) { view->resetCachedContent(); view->viewport()->update(); } @@ -3136,13 +3106,13 @@ void QGraphicsScene::update(const QRectF &rect) d->updatedRects.clear(); if (directUpdates) { // Update all views. - for (auto view : qAsConst(d->views)) + for (auto view : std::as_const(d->views)) view->d_func()->fullUpdatePending = true; } } else { if (directUpdates) { // Update all views. - for (auto view : qAsConst(d->views)) { + for (auto view : std::as_const(d->views)) { if (view->isTransformed()) view->d_func()->updateRectF(view->viewportTransform().mapRect(rect)); else @@ -3283,6 +3253,7 @@ bool QGraphicsScene::event(QEvent *event) // ### this should only be cleared if we received a new mouse move event, // which relies on us fixing the replay mechanism in QGraphicsView. d->cachedItemsUnderMouse.clear(); + break; default: break; } @@ -3803,7 +3774,7 @@ bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEv } QGraphicsItem *item = nullptr; - for (auto tmp : qAsConst(cachedItemsUnderMouse)) { + for (auto tmp : std::as_const(cachedItemsUnderMouse)) { if (itemAcceptsHoverEvents_helper(tmp)) { item = tmp; break; @@ -4426,7 +4397,7 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte QRegion pixmapExposed; QRectF exposedRect; if (!itemCache->allExposed) { - for (const auto &rect : qAsConst(itemCache->exposed)) { + for (const auto &rect : std::as_const(itemCache->exposed)) { exposedRect |= rect; pixmapExposed += itemToPixmap.mapRect(rect).toAlignedRect(); } @@ -4586,7 +4557,7 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte // Map the item's logical expose to pixmap coordinates. QRegion pixmapExposed = scrollExposure; if (!itemCache->allExposed) { - for (const auto &rect : qAsConst(itemCache->exposed)) + for (const auto &rect : std::as_const(itemCache->exposed)) pixmapExposed += itemToPixmap.mapRect(rect).toRect().adjusted(-1, -1, 1, 1); } @@ -4595,10 +4566,10 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte if (itemCache->allExposed) { br = item->boundingRect(); } else { - for (const auto &rect : qAsConst(itemCache->exposed)) + for (const auto &rect : std::as_const(itemCache->exposed)) br |= rect; QTransform pixmapToItem = itemToPixmap.inverted(); - for (const QRect &r : qAsConst(scrollExposure)) + for (const QRect &r : std::as_const(scrollExposure)) br |= pixmapToItem.mapRect(r); } styleOptionTmp = *option; @@ -5005,7 +4976,7 @@ void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, b return; } - for (auto view : qAsConst(views)) { + for (auto view : std::as_const(views)) { QGraphicsViewPrivate *viewPrivate = view->d_func(); QRect rect = item->d_ptr->paintedViewBoundingRects.value(viewPrivate->viewport); rect.translate(viewPrivate->dirtyScrollOffset); @@ -5161,7 +5132,7 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool QRectF dirtyRect; bool uninitializedDirtyRect = true; - for (auto view : qAsConst(views)) { + for (auto view : std::as_const(views)) { QGraphicsViewPrivate *viewPrivate = view->d_func(); QRect &paintedViewBoundingRect = item->d_ptr->paintedViewBoundingRects[viewPrivate->viewport]; if (viewPrivate->fullUpdatePending @@ -5219,7 +5190,7 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool const bool bypassUpdateClip = !itemHasContents && wasDirtyParentViewBoundingRects; if (itemClipsChildrenToShape && !bypassUpdateClip) { // Make sure child updates are clipped to the item's bounding rect. - for (auto view : qAsConst(views)) + for (auto view : std::as_const(views)) view->d_func()->setUpdateClip(item); } if (!dirtyAncestorContainsChildren) { @@ -5229,7 +5200,7 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool const bool allChildrenDirty = item->d_ptr->allChildrenDirty; const bool parentIgnoresVisible = item->d_ptr->ignoreVisible; const bool parentIgnoresOpacity = item->d_ptr->ignoreOpacity; - for (auto child : qAsConst(item->d_ptr->children)) { + for (auto child : std::as_const(item->d_ptr->children)) { if (wasDirtyParentSceneTransform) child->d_ptr->dirtySceneTransform = 1; if (wasDirtyParentViewBoundingRects) @@ -5249,7 +5220,7 @@ void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool if (itemClipsChildrenToShape) { // Reset updateClip. - for (auto view : qAsConst(views)) + for (auto view : std::as_const(views)) view->d_func()->setUpdateClip(nullptr); } } else if (wasDirtyParentSceneTransform) { @@ -5330,7 +5301,7 @@ void QGraphicsScene::drawItems(QPainter *painter, d->rectAdjust = oldRectAdjust; // Reset discovery bits. - for (auto topLevelItem : qAsConst(topLevelItems)) + for (auto topLevelItem : std::as_const(topLevelItems)) topLevelItem->d_ptr->itemDiscovered = 0; painter->setWorldTransform(viewTransform); @@ -5840,8 +5811,8 @@ void QGraphicsScenePrivate::updateTouchPointsForItem(QGraphicsItem *item, QTouch item->d_ptr->genericMapFromSceneTransform(static_cast<const QWidget *>(touchEvent->target())); for (int i = 0; i < touchEvent->pointCount(); ++i) { - auto &pt = QMutableEventPoint::from(touchEvent->point(i)); - QMutableEventPoint::from(pt).setPosition(mapFromScene.map(pt.scenePosition())); + auto &pt = touchEvent->point(i); + QMutableEventPoint::setPosition(pt, mapFromScene.map(pt.scenePosition())); } } @@ -5849,7 +5820,7 @@ int QGraphicsScenePrivate::findClosestTouchPointId(const QPointF &scenePos) { int closestTouchPointId = -1; qreal closestDistance = qreal(0.); - for (const QEventPoint &touchPoint : qAsConst(sceneCurrentTouchPoints)) { + for (const QEventPoint &touchPoint : std::as_const(sceneCurrentTouchPoints)) { qreal distance = QLineF(scenePos, touchPoint.scenePosition()).length(); if (closestTouchPointId == -1|| distance < closestDistance) { closestTouchPointId = touchPoint.id(); @@ -5999,7 +5970,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve // Set focus on the topmost enabled item that can take focus. bool setFocus = false; - for (QGraphicsItem *item : qAsConst(cachedItemsUnderMouse)) { + for (QGraphicsItem *item : std::as_const(cachedItemsUnderMouse)) { if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) { if (!item->isWidget() || ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus) { setFocus = true; @@ -6026,7 +5997,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve bool res = false; bool eventAccepted = touchEvent->isAccepted(); - for (QGraphicsItem *item : qAsConst(cachedItemsUnderMouse)) { + for (QGraphicsItem *item : std::as_const(cachedItemsUnderMouse)) { // first, try to deliver the touch event updateTouchPointsForItem(item, touchEvent); bool acceptTouchEvents = item->acceptTouchEvents(); @@ -6058,13 +6029,13 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve void QGraphicsScenePrivate::enableTouchEventsOnViews() { - for (QGraphicsView *view : qAsConst(views)) + for (QGraphicsView *view : std::as_const(views)) view->viewport()->setAttribute(Qt::WA_AcceptTouchEvents, true); } void QGraphicsScenePrivate::updateInputMethodSensitivityInViews() { - for (auto view : qAsConst(views)) + for (auto view : std::as_const(views)) view->d_func()->updateInputMethodSensitivity(); } @@ -6430,7 +6401,7 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) } } - for (QGesture *g : qAsConst(startedGestures)) { + for (QGesture *g : std::as_const(startedGestures)) { if (g->gestureCancelPolicy() == QGesture::CancelAllInContext) { DEBUG() << "lets try to cancel some"; // find gestures in context in Qt::GestureStarted or Qt::GestureUpdated state and cancel them @@ -6543,7 +6514,7 @@ void QGraphicsScenePrivate::grabGesture(QGraphicsItem *, Qt::GestureType gesture { (void)QGestureManager::instance(); // create a gesture manager if (!grabbedGestures[gesture]++) { - for (QGraphicsView *view : qAsConst(views)) + for (QGraphicsView *view : std::as_const(views)) view->viewport()->grabGesture(gesture); } } @@ -6555,7 +6526,7 @@ void QGraphicsScenePrivate::ungrabGesture(QGraphicsItem *item, Qt::GestureType g QGraphicsObject *obj = static_cast<QGraphicsObject *>(item); QGestureManager::instance()->cleanupCachedGestures(obj, gesture); if (!--grabbedGestures[gesture]) { - for (QGraphicsView *view : qAsConst(views)) + for (QGraphicsView *view : std::as_const(views)) view->viewport()->ungrabGesture(gesture); } } diff --git a/src/widgets/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h index 0a08acf0f9..33fb747277 100644 --- a/src/widgets/graphicsview/qgraphicsscene.h +++ b/src/widgets/graphicsview/qgraphicsscene.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSSCENE_H #define QGRAPHICSSCENE_H diff --git a/src/widgets/graphicsview/qgraphicsscene_bsp.cpp b/src/widgets/graphicsview/qgraphicsscene_bsp.cpp index 437d413284..1ba6fe787a 100644 --- a/src/widgets/graphicsview/qgraphicsscene_bsp.cpp +++ b/src/widgets/graphicsview/qgraphicsscene_bsp.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qgraphicsscene_bsp_p.h" @@ -44,57 +8,14 @@ QT_BEGIN_NAMESPACE -class QGraphicsSceneInsertItemBspTreeVisitor : public QGraphicsSceneBspTreeVisitor -{ -public: - QGraphicsItem *item; - - void visit(QList<QGraphicsItem *> *items) override - { items->prepend(item); } -}; - -class QGraphicsSceneRemoveItemBspTreeVisitor : public QGraphicsSceneBspTreeVisitor -{ -public: - QGraphicsItem *item; - - void visit(QList<QGraphicsItem *> *items) override - { items->removeAll(item); } -}; - -class QGraphicsSceneFindItemBspTreeVisitor : public QGraphicsSceneBspTreeVisitor -{ -public: - QList<QGraphicsItem *> *foundItems; - bool onlyTopLevelItems; - - void visit(QList<QGraphicsItem *> *items) override - { - for (int i = 0; i < items->size(); ++i) { - QGraphicsItem *item = items->at(i); - if (onlyTopLevelItems && item->d_ptr->parent) - item = item->topLevelItem(); - if (!item->d_func()->itemDiscovered && item->d_ptr->visible) { - item->d_func()->itemDiscovered = 1; - foundItems->prepend(item); - } - } - } -}; QGraphicsSceneBspTree::QGraphicsSceneBspTree() : leafCnt(0) { - insertVisitor = new QGraphicsSceneInsertItemBspTreeVisitor; - removeVisitor = new QGraphicsSceneRemoveItemBspTreeVisitor; - findVisitor = new QGraphicsSceneFindItemBspTreeVisitor; } QGraphicsSceneBspTree::~QGraphicsSceneBspTree() { - delete insertVisitor; - delete removeVisitor; - delete findVisitor; } void QGraphicsSceneBspTree::initialize(const QRectF &rect, int depth) @@ -118,14 +39,16 @@ void QGraphicsSceneBspTree::clear() void QGraphicsSceneBspTree::insertItem(QGraphicsItem *item, const QRectF &rect) { - insertVisitor->item = item; - climbTree(insertVisitor, rect); + climbTree([item](QList<QGraphicsItem *> *items){ + items->prepend(item); + }, rect); } void QGraphicsSceneBspTree::removeItem(QGraphicsItem *item, const QRectF &rect) { - removeVisitor->item = item; - climbTree(removeVisitor, rect); + climbTree([item](QList<QGraphicsItem *> *items){ + items->removeAll(item); + }, rect); } void QGraphicsSceneBspTree::removeItems(const QSet<QGraphicsItem *> &items) @@ -144,14 +67,22 @@ void QGraphicsSceneBspTree::removeItems(const QSet<QGraphicsItem *> &items) QList<QGraphicsItem *> QGraphicsSceneBspTree::items(const QRectF &rect, bool onlyTopLevelItems) const { - QList<QGraphicsItem *> tmp; - findVisitor->foundItems = &tmp; - findVisitor->onlyTopLevelItems = onlyTopLevelItems; - climbTree(findVisitor, rect); + QList<QGraphicsItem *> foundItems; + climbTree([&foundItems, onlyTopLevelItems](QList<QGraphicsItem *> *items) { + for (int i = 0; i < items->size(); ++i) { + QGraphicsItem *item = items->at(i); + if (onlyTopLevelItems && item->d_ptr->parent) + item = item->topLevelItem(); + if (!item->d_func()->itemDiscovered && item->d_ptr->visible) { + item->d_func()->itemDiscovered = 1; + foundItems.prepend(item); + } + } + }, rect); // Reset discovery bits. - for (int i = 0; i < tmp.size(); ++i) - tmp.at(i)->d_ptr->itemDiscovered = 0; - return tmp; + for (const auto &foundItem : std::as_const(foundItems)) + foundItem->d_ptr->itemDiscovered = 0; + return foundItems; } int QGraphicsSceneBspTree::leafCount() const @@ -230,7 +161,8 @@ void QGraphicsSceneBspTree::initialize(const QRectF &rect, int depth, int index) } } -void QGraphicsSceneBspTree::climbTree(QGraphicsSceneBspTreeVisitor *visitor, const QRectF &rect, int index) const +template<typename Visitor> +void QGraphicsSceneBspTree::climbTree(Visitor &&visitor, const QRectF &rect, int index) const { if (nodes.isEmpty()) return; @@ -240,7 +172,7 @@ void QGraphicsSceneBspTree::climbTree(QGraphicsSceneBspTreeVisitor *visitor, con switch (node.type) { case Node::Leaf: { - visitor->visit(const_cast<QList<QGraphicsItem*>*>(&leaves[node.leafIndex])); + visitor(const_cast<QList<QGraphicsItem*>*>(&leaves[node.leafIndex])); break; } case Node::Vertical: diff --git a/src/widgets/graphicsview/qgraphicsscene_bsp_p.h b/src/widgets/graphicsview/qgraphicsscene_bsp_p.h index d81c0776ed..9e0fa919b7 100644 --- a/src/widgets/graphicsview/qgraphicsscene_bsp_p.h +++ b/src/widgets/graphicsview/qgraphicsscene_bsp_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSSCENEBSPTREE_P_H #define QGRAPHICSSCENEBSPTREE_P_H @@ -61,10 +25,6 @@ QT_REQUIRE_CONFIG(graphicsview); QT_BEGIN_NAMESPACE class QGraphicsItem; -class QGraphicsSceneBspTreeVisitor; -class QGraphicsSceneInsertItemBspTreeVisitor; -class QGraphicsSceneRemoveItemBspTreeVisitor; -class QGraphicsSceneFindItemBspTreeVisitor; class QGraphicsSceneBspTree { @@ -102,24 +62,14 @@ public: private: void initialize(const QRectF &rect, int depth, int index); - void climbTree(QGraphicsSceneBspTreeVisitor *visitor, const QRectF &rect, int index = 0) const; + template<typename Visitor> + void climbTree(Visitor &&visitor, const QRectF &rect, int index = 0) const; QRectF rectForIndex(int index) const; QList<Node> nodes; QList<QList<QGraphicsItem *>> leaves; int leafCnt; QRectF rect; - - QGraphicsSceneInsertItemBspTreeVisitor *insertVisitor; - QGraphicsSceneRemoveItemBspTreeVisitor *removeVisitor; - QGraphicsSceneFindItemBspTreeVisitor *findVisitor; -}; - -class QGraphicsSceneBspTreeVisitor -{ -public: - virtual ~QGraphicsSceneBspTreeVisitor() { } - virtual void visit(QList<QGraphicsItem *> *items) = 0; }; QT_END_NAMESPACE diff --git a/src/widgets/graphicsview/qgraphicsscene_p.h b/src/widgets/graphicsview/qgraphicsscene_p.h index 0cb8cd3c57..c4b8b4e867 100644 --- a/src/widgets/graphicsview/qgraphicsscene_p.h +++ b/src/widgets/graphicsview/qgraphicsscene_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSSCENE_P_H #define QGRAPHICSSCENE_P_H diff --git a/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp b/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp index 69ddf54bc7..8a11489308 100644 --- a/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp +++ b/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only /*! \class QGraphicsSceneBspTreeIndex diff --git a/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h b/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h index 7e0e525a6b..bd9894d5fe 100644 --- a/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h +++ b/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only // // W A R N I N G diff --git a/src/widgets/graphicsview/qgraphicssceneevent.cpp b/src/widgets/graphicsview/qgraphicssceneevent.cpp index 2608d2d5f1..0ace03b553 100644 --- a/src/widgets/graphicsview/qgraphicssceneevent.cpp +++ b/src/widgets/graphicsview/qgraphicssceneevent.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only /*! \class QGraphicsSceneEvent diff --git a/src/widgets/graphicsview/qgraphicssceneevent.h b/src/widgets/graphicsview/qgraphicssceneevent.h index f9de1d148b..ca9dd639a3 100644 --- a/src/widgets/graphicsview/qgraphicssceneevent.h +++ b/src/widgets/graphicsview/qgraphicssceneevent.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSSCENEEVENT_H #define QGRAPHICSSCENEEVENT_H diff --git a/src/widgets/graphicsview/qgraphicssceneindex.cpp b/src/widgets/graphicsview/qgraphicssceneindex.cpp index aab9068374..7c54bfe179 100644 --- a/src/widgets/graphicsview/qgraphicssceneindex.cpp +++ b/src/widgets/graphicsview/qgraphicssceneindex.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only /*! \class QGraphicsSceneIndex \brief The QGraphicsSceneIndex class provides a base class to implement @@ -581,7 +545,7 @@ void QGraphicsSceneIndex::clear() /*! This method is called when an \a item has been deleted. - The default implementation call removeItem. Be carefull, + The default implementation calls removeItem. Be careful, if your implementation of removeItem use pure virtual method of QGraphicsItem like boundingRect(), then you should reimplement this method. diff --git a/src/widgets/graphicsview/qgraphicssceneindex_p.h b/src/widgets/graphicsview/qgraphicssceneindex_p.h index e13c2a3cd3..8bd2ef4854 100644 --- a/src/widgets/graphicsview/qgraphicssceneindex_p.h +++ b/src/widgets/graphicsview/qgraphicssceneindex_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSSCENEINDEX_H #define QGRAPHICSSCENEINDEX_H diff --git a/src/widgets/graphicsview/qgraphicsscenelinearindex.cpp b/src/widgets/graphicsview/qgraphicsscenelinearindex.cpp index 85e524096c..c014783438 100644 --- a/src/widgets/graphicsview/qgraphicsscenelinearindex.cpp +++ b/src/widgets/graphicsview/qgraphicsscenelinearindex.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only /*! \class QGraphicsSceneLinearIndex diff --git a/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h b/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h index ead52c1fb0..e0a038a927 100644 --- a/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h +++ b/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSSCENELINEARINDEX_H #define QGRAPHICSSCENELINEARINDEX_H diff --git a/src/widgets/graphicsview/qgraphicstransform.cpp b/src/widgets/graphicsview/qgraphicstransform.cpp index fa763de05d..172bdff081 100644 --- a/src/widgets/graphicsview/qgraphicstransform.cpp +++ b/src/widgets/graphicsview/qgraphicstransform.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtDeclarative 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only /*! \class QGraphicsTransform @@ -593,6 +557,6 @@ void QGraphicsRotation::applyTo(QMatrix4x4 *matrix) const \sa QGraphicsRotation::axis */ -#include "moc_qgraphicstransform.cpp" - QT_END_NAMESPACE + +#include "moc_qgraphicstransform.cpp" diff --git a/src/widgets/graphicsview/qgraphicstransform.h b/src/widgets/graphicsview/qgraphicstransform.h index b8455781c5..903320cb62 100644 --- a/src/widgets/graphicsview/qgraphicstransform.h +++ b/src/widgets/graphicsview/qgraphicstransform.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSTRANSFORM_H #define QGRAPHICSTRANSFORM_H diff --git a/src/widgets/graphicsview/qgraphicstransform_p.h b/src/widgets/graphicsview/qgraphicstransform_p.h index 3b028db315..4c08c1c106 100644 --- a/src/widgets/graphicsview/qgraphicstransform_p.h +++ b/src/widgets/graphicsview/qgraphicstransform_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSTRANSFORM_P_H #define QGRAPHICSTRANSFORM_P_H diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index f4b9228e51..9505e2529a 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only static const int QGRAPHICSVIEW_REGION_RECT_THRESHOLD = 50; @@ -121,6 +85,16 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime < view coordinates and scene coordinates, and to find items on the scene using view coordinates. + When using a QOpenGLWidget as a viewport, stereoscopic rendering is + supported. This is done using the same pattern as QOpenGLWidget::paintGL. + To enable it, enable the QSurfaceFormat::StereoBuffers flag. Because of + how the flag is handled internally, set QSurfaceFormat::StereoBuffers flag + globally before the window is created using QSurfaceFormat::setDefaultFormat(). + If the flag is enabled and there is hardware support for stereoscopic + rendering, then drawBackground() and drawForeground() will be triggered twice + each frame. Call QOpenGLWidget::currentTargetBuffer() to query which buffer + is currently being drawn to. + \image graphicsview-view.png \note Using an OpenGL viewport limits the ability to use QGraphicsProxyWidget. @@ -294,6 +268,7 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime < #include <QtWidgets/qstyleoption.h> #include <private/qevent_p.h> +#include <QtGui/private/qeventpoint_p.h> QT_BEGIN_NAMESPACE @@ -314,7 +289,7 @@ void QGraphicsViewPrivate::translateTouchEvent(QGraphicsViewPrivate *d, QTouchEv auto &pt = touchEvent->point(i); // the scene will set the item local pos, startPos, lastPos, and rect before delivering to // an item, but for now those functions are returning the view's local coordinates - QMutableEventPoint::from(pt).setScenePosition(d->mapToScene(pt.position())); + QMutableEventPoint::setScenePosition(pt, d->mapToScene(pt.position())); // screenPos, startScreenPos, and lastScreenPos are already set } } @@ -370,10 +345,10 @@ void QGraphicsViewPrivate::recalculateContentSize() { Q_Q(QGraphicsView); - QSize maxSize = q->maximumViewportSize(); + const QSize maxSize = q->maximumViewportSize(); int width = maxSize.width(); int height = maxSize.height(); - QRectF viewRect = matrix.mapRect(q->sceneRect()); + const QRectF viewRect = matrix.mapRect(q->sceneRect()); bool frameOnlyAround = (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, nullptr, q)); if (frameOnlyAround) { @@ -385,9 +360,8 @@ void QGraphicsViewPrivate::recalculateContentSize() // Adjust the maximum width and height of the viewport based on the width // of visible scroll bars. - int scrollBarExtent = q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, nullptr, q); - if (frameOnlyAround) - scrollBarExtent += frameWidth * 2; + const int scrollBarExtent = q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, nullptr, q) + + (frameOnlyAround ? frameWidth * 2 : 0); // We do not need to subtract the width scrollbars whose policy is // Qt::ScrollBarAlwaysOn, this was already done by maximumViewportSize(). @@ -409,62 +383,70 @@ void QGraphicsViewPrivate::recalculateContentSize() // Setting the ranges of these scroll bars can/will cause the values to // change, and scrollContentsBy() will be called correspondingly. This // will reset the last center point. - QPointF savedLastCenterPoint = lastCenterPoint; + const QPointF savedLastCenterPoint = lastCenterPoint; // Remember the former indent settings - qreal oldLeftIndent = leftIndent; - qreal oldTopIndent = topIndent; + const qreal oldLeftIndent = leftIndent; + const qreal oldTopIndent = topIndent; // If the whole scene fits horizontally, we center the scene horizontally, // and ignore the horizontal scroll bars. - int left = q_round_bound(viewRect.left()); - int right = q_round_bound(viewRect.right() - width); + const int left = q_round_bound(viewRect.left()); + const int right = q_round_bound(viewRect.right() - width); if (left >= right) { - hbar->setRange(0, 0); - switch (alignment & Qt::AlignHorizontal_Mask) { case Qt::AlignLeft: leftIndent = -viewRect.left(); break; case Qt::AlignRight: - leftIndent = width - viewRect.width() - viewRect.left() - 1; + leftIndent = maxSize.width() - viewRect.width() - viewRect.left() - 1; break; case Qt::AlignHCenter: default: - leftIndent = width / 2 - (viewRect.left() + viewRect.right()) / 2; + leftIndent = maxSize.width() / 2 - (viewRect.left() + viewRect.right()) / 2; break; } + + hbar->setRange(0, 0); } else { + leftIndent = 0; + hbar->setRange(left, right); hbar->setPageStep(width); hbar->setSingleStep(width / 20); - leftIndent = 0; + + if (oldLeftIndent != 0) + hbar->setValue(-oldLeftIndent); } // If the whole scene fits vertically, we center the scene vertically, and // ignore the vertical scroll bars. - int top = q_round_bound(viewRect.top()); - int bottom = q_round_bound(viewRect.bottom() - height); + const int top = q_round_bound(viewRect.top()); + const int bottom = q_round_bound(viewRect.bottom() - height); if (top >= bottom) { - vbar->setRange(0, 0); - switch (alignment & Qt::AlignVertical_Mask) { case Qt::AlignTop: topIndent = -viewRect.top(); break; case Qt::AlignBottom: - topIndent = height - viewRect.height() - viewRect.top() - 1; + topIndent = maxSize.height() - viewRect.height() - viewRect.top() - 1; break; case Qt::AlignVCenter: default: - topIndent = height / 2 - (viewRect.top() + viewRect.bottom()) / 2; + topIndent = maxSize.height() / 2 - (viewRect.top() + viewRect.bottom()) / 2; break; } + + vbar->setRange(0, 0); } else { + topIndent = 0; + vbar->setRange(top, bottom); vbar->setPageStep(height); vbar->setSingleStep(height / 20); - topIndent = 0; + + if (oldTopIndent != 0) + vbar->setValue(-oldTopIndent); } // Restorethe center point from before the ranges changed. @@ -501,8 +483,8 @@ void QGraphicsViewPrivate::centerView(QGraphicsView::ViewportAnchor anchor) if (q->underMouse()) { // Last scene pos: lastMouseMoveScenePoint // Current mouse pos: - QPointF transformationDiff = q->mapToScene(viewport->rect().center()) - - q->mapToScene(viewport->mapFromGlobal(QCursor::pos())); + QPointF transformationDiff = mapToScene(viewport->rect().toRectF().center()) + - mapToScene(viewport->mapFromGlobal(QCursor::pos().toPointF())); q->centerOn(lastMouseMoveScenePoint + transformationDiff); } else { q->centerOn(lastCenterPoint); @@ -522,8 +504,7 @@ void QGraphicsViewPrivate::centerView(QGraphicsView::ViewportAnchor anchor) */ void QGraphicsViewPrivate::updateLastCenterPoint() { - Q_Q(QGraphicsView); - lastCenterPoint = q->mapToScene(viewport->rect().center()); + lastCenterPoint = mapToScene(viewport->rect().toRectF().center()); } /*! @@ -701,7 +682,7 @@ void QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent *event) mouseEvent.widget()); } // Find the topmost item under the mouse with a cursor. - for (QGraphicsItem *item : qAsConst(scene->d_func()->cachedItemsUnderMouse)) { + for (QGraphicsItem *item : std::as_const(scene->d_func()->cachedItemsUnderMouse)) { if (item->isEnabled() && item->hasCursor()) { _q_setViewportCursor(item->cursor()); return; @@ -731,7 +712,7 @@ QRegion QGraphicsViewPrivate::rubberBandRegion(const QWidget *widget, const QRec option.shape = QRubberBand::Rectangle; QRegion tmp; - tmp += rect; + tmp += rect.adjusted(-1, -1, 1, 1); if (widget->style()->styleHint(QStyle::SH_RubberBand_Mask, &option, widget, &mask)) tmp &= mask.region; return tmp; @@ -1577,7 +1558,7 @@ void QGraphicsView::setRubberBandSelectionMode(Qt::ItemSelectionMode mode) is currently doing an itemselection with rubber band. When the user is not using the rubber band this functions returns (a null) QRectF(). - Notice that part of this QRect can be outise the visual viewport. It can e.g + Notice that part of this QRect can be outside the visual viewport. It can e.g contain negative values. \sa rubberBandSelectionMode, rubberBandChanged() @@ -1910,14 +1891,14 @@ void QGraphicsView::centerOn(const QPointF &pos) qint64 horizontal = 0; horizontal += horizontalScrollBar()->minimum(); horizontal += horizontalScrollBar()->maximum(); - horizontal -= int(viewPoint.x() - width / 2.0); + horizontal -= qRound(viewPoint.x() - width / 2.0); horizontalScrollBar()->setValue(horizontal); } else { - horizontalScrollBar()->setValue(int(viewPoint.x() - width / 2.0)); + horizontalScrollBar()->setValue(qRound(viewPoint.x() - width / 2.0)); } } if (!d->topIndent) - verticalScrollBar()->setValue(int(viewPoint.y() - height / 2.0)); + verticalScrollBar()->setValue(qRound(viewPoint.y() - height / 2.0)); d->lastCenterPoint = oldCenterPoint; } @@ -2361,7 +2342,7 @@ QGraphicsItem *QGraphicsView::itemAt(const QPoint &pos) const if (!d->scene) return nullptr; const QList<QGraphicsItem *> itemsAtPos = items(pos); - return itemsAtPos.isEmpty() ? 0 : itemsAtPos.first(); + return itemsAtPos.isEmpty() ? nullptr : itemsAtPos.first(); } /*! @@ -2448,7 +2429,7 @@ QPolygonF QGraphicsView::mapToScene(const QRect &rect) const QPolygonF QGraphicsView::mapToScene(const QPolygon &polygon) const { QPolygonF poly; - poly.reserve(polygon.count()); + poly.reserve(polygon.size()); for (const QPoint &point : polygon) poly << mapToScene(point); return poly; @@ -2544,7 +2525,7 @@ QPolygon QGraphicsView::mapFromScene(const QRectF &rect) const QPolygon QGraphicsView::mapFromScene(const QPolygonF &polygon) const { QPolygon poly; - poly.reserve(polygon.count()); + poly.reserve(polygon.size()); for (const QPointF &point : polygon) poly << mapFromScene(point); return poly; @@ -2658,7 +2639,7 @@ void QGraphicsView::updateScene(const QList<QRectF> &rects) // Extract and reset dirty scene rect info. QList<QRect> dirtyViewportRects; - dirtyViewportRects.reserve(d->dirtyRegion.rectCount() + rects.count()); + dirtyViewportRects.reserve(d->dirtyRegion.rectCount() + rects.size()); for (const QRect &dirtyRect : d->dirtyRegion) dirtyViewportRects += dirtyRect; d->dirtyRegion = QRegion(); @@ -2687,7 +2668,7 @@ void QGraphicsView::updateScene(const QList<QRectF> &rects) dirtyViewportRects << xrect; } - for (const QRect &rect : qAsConst(dirtyViewportRects)) { + for (const QRect &rect : std::as_const(dirtyViewportRects)) { // Add the exposed rect to the update region. In rect update // mode, we only count the bounding rect of items. if (!boundingRectUpdate) { @@ -2752,6 +2733,9 @@ void QGraphicsView::setupViewport(QWidget *widget) widget->setFocusPolicy(Qt::StrongFocus); + if (isGLWidget) + d->stereoEnabled = QWidgetPrivate::get(widget)->isStereoEnabled(); + if (!isGLWidget) { // autoFillBackground enables scroll acceleration. widget->setAutoFillBackground(true); @@ -3453,132 +3437,146 @@ void QGraphicsView::paintEvent(QPaintEvent *event) painter.setWorldTransform(viewportTransform()); const QTransform viewTransform = painter.worldTransform(); - // Draw background - if (d->cacheMode & CacheBackground) { - // Recreate the background pixmap, and flag the whole background as - // exposed. - if (d->mustResizeBackgroundPixmap) { - const qreal dpr = d->viewport->devicePixelRatio(); - d->backgroundPixmap = QPixmap(viewport()->size() * dpr); - d->backgroundPixmap.setDevicePixelRatio(dpr); - QBrush bgBrush = viewport()->palette().brush(viewport()->backgroundRole()); - if (!bgBrush.isOpaque()) - d->backgroundPixmap.fill(Qt::transparent); - QPainter p(&d->backgroundPixmap); - p.fillRect(0, 0, d->backgroundPixmap.width(), d->backgroundPixmap.height(), bgBrush); - d->backgroundPixmapExposed = QRegion(viewport()->rect()); - d->mustResizeBackgroundPixmap = false; - } + const auto actuallyDraw = [&]() { + // Draw background + if (d->cacheMode & CacheBackground) { + // Recreate the background pixmap, and flag the whole background as + // exposed. + if (d->mustResizeBackgroundPixmap) { + const qreal dpr = d->viewport->devicePixelRatio(); + d->backgroundPixmap = QPixmap(viewport()->size() * dpr); + d->backgroundPixmap.setDevicePixelRatio(dpr); + QBrush bgBrush = viewport()->palette().brush(viewport()->backgroundRole()); + if (!bgBrush.isOpaque()) + d->backgroundPixmap.fill(Qt::transparent); + QPainter p(&d->backgroundPixmap); + p.fillRect(0, 0, d->backgroundPixmap.width(), d->backgroundPixmap.height(), bgBrush); + d->backgroundPixmapExposed = QRegion(viewport()->rect()); + d->mustResizeBackgroundPixmap = false; + } - // Redraw exposed areas - if (!d->backgroundPixmapExposed.isEmpty()) { - QPainter backgroundPainter(&d->backgroundPixmap); - backgroundPainter.setClipRegion(d->backgroundPixmapExposed, Qt::ReplaceClip); - if (viewTransformed) - backgroundPainter.setTransform(viewTransform); - QRectF backgroundExposedSceneRect = mapToScene(d->backgroundPixmapExposed.boundingRect()).boundingRect(); - drawBackground(&backgroundPainter, backgroundExposedSceneRect); - d->backgroundPixmapExposed = QRegion(); - } + // Redraw exposed areas + if (!d->backgroundPixmapExposed.isEmpty()) { + QPainter backgroundPainter(&d->backgroundPixmap); + backgroundPainter.setClipRegion(d->backgroundPixmapExposed, Qt::ReplaceClip); + if (viewTransformed) + backgroundPainter.setTransform(viewTransform); + QRectF backgroundExposedSceneRect = mapToScene(d->backgroundPixmapExposed.boundingRect()).boundingRect(); + drawBackground(&backgroundPainter, backgroundExposedSceneRect); + d->backgroundPixmapExposed = QRegion(); + } - // Blit the background from the background pixmap - if (viewTransformed) { - painter.setWorldTransform(QTransform()); - painter.drawPixmap(QPoint(), d->backgroundPixmap); - painter.setWorldTransform(viewTransform); + // Blit the background from the background pixmap + if (viewTransformed) { + painter.setWorldTransform(QTransform()); + painter.drawPixmap(QPoint(), d->backgroundPixmap); + painter.setWorldTransform(viewTransform); + } else { + painter.drawPixmap(QPoint(), d->backgroundPixmap); + } } else { - painter.drawPixmap(QPoint(), d->backgroundPixmap); + if (!(d->optimizationFlags & DontSavePainterState)) + painter.save(); + + drawBackground(&painter, exposedSceneRect); + if (!(d->optimizationFlags & DontSavePainterState)) + painter.restore(); } - } else { - if (!(d->optimizationFlags & DontSavePainterState)) - painter.save(); - drawBackground(&painter, exposedSceneRect); - if (!(d->optimizationFlags & DontSavePainterState)) - painter.restore(); - } - // Items - if (!(d->optimizationFlags & IndirectPainting)) { - const quint32 oldRectAdjust = d->scene->d_func()->rectAdjust; - if (d->optimizationFlags & QGraphicsView::DontAdjustForAntialiasing) - d->scene->d_func()->rectAdjust = 1; - else - d->scene->d_func()->rectAdjust = 2; - d->scene->d_func()->drawItems(&painter, viewTransformed ? &viewTransform : nullptr, - &d->exposedRegion, viewport()); - d->scene->d_func()->rectAdjust = oldRectAdjust; - // Make sure the painter's world transform is restored correctly when - // drawing without painter state protection (DontSavePainterState). - // We only change the worldTransform() so there's no need to do a full-blown - // save() and restore(). Also note that we don't have to do this in case of - // IndirectPainting (the else branch), because in that case we always save() - // and restore() in QGraphicsScene::drawItems(). - if (!d->scene->d_func()->painterStateProtection) - painter.setOpacity(1.0); - painter.setWorldTransform(viewTransform); - } else { - // Make sure we don't have unpolished items before we draw - if (!d->scene->d_func()->unpolishedItems.isEmpty()) - d->scene->d_func()->_q_polishItems(); - // We reset updateAll here (after we've issued polish events) - // so that we can discard update requests coming from polishEvent(). - d->scene->d_func()->updateAll = false; - - // Find all exposed items - bool allItems = false; - QList<QGraphicsItem *> itemList = d->findItems(d->exposedRegion, &allItems, viewTransform); - if (!itemList.isEmpty()) { - // Generate the style options. - const int numItems = itemList.size(); - QGraphicsItem **itemArray = &itemList[0]; // Relies on QList internals, but is perfectly valid. - QStyleOptionGraphicsItem *styleOptionArray = d->allocStyleOptionsArray(numItems); - QTransform transform(Qt::Uninitialized); - for (int i = 0; i < numItems; ++i) { - QGraphicsItem *item = itemArray[i]; - QGraphicsItemPrivate *itemd = item->d_ptr.data(); - itemd->initStyleOption(&styleOptionArray[i], viewTransform, d->exposedRegion, allItems); - // Cache the item's area in view coordinates. - // Note that we have to do this here in case the base class implementation - // (QGraphicsScene::drawItems) is not called. If it is, we'll do this - // operation twice, but that's the price one has to pay for using indirect - // painting :-/. - const QRectF brect = adjustedItemEffectiveBoundingRect(item); - if (!itemd->itemIsUntransformable()) { - transform = item->sceneTransform(); - if (viewTransformed) - transform *= viewTransform; - } else { - transform = item->deviceTransform(viewTransform); + // Items + if (!(d->optimizationFlags & IndirectPainting)) { + const quint32 oldRectAdjust = d->scene->d_func()->rectAdjust; + if (d->optimizationFlags & QGraphicsView::DontAdjustForAntialiasing) + d->scene->d_func()->rectAdjust = 1; + else + d->scene->d_func()->rectAdjust = 2; + d->scene->d_func()->drawItems(&painter, viewTransformed ? &viewTransform : nullptr, + &d->exposedRegion, viewport()); + d->scene->d_func()->rectAdjust = oldRectAdjust; + // Make sure the painter's world transform is restored correctly when + // drawing without painter state protection (DontSavePainterState). + // We only change the worldTransform() so there's no need to do a full-blown + // save() and restore(). Also note that we don't have to do this in case of + // IndirectPainting (the else branch), because in that case we always save() + // and restore() in QGraphicsScene::drawItems(). + if (!d->scene->d_func()->painterStateProtection) + painter.setOpacity(1.0); + painter.setWorldTransform(viewTransform); + } else { + // Make sure we don't have unpolished items before we draw + if (!d->scene->d_func()->unpolishedItems.isEmpty()) + d->scene->d_func()->_q_polishItems(); + // We reset updateAll here (after we've issued polish events) + // so that we can discard update requests coming from polishEvent(). + d->scene->d_func()->updateAll = false; + + // Find all exposed items + bool allItems = false; + QList<QGraphicsItem *> itemList = d->findItems(d->exposedRegion, &allItems, viewTransform); + if (!itemList.isEmpty()) { + // Generate the style options. + const int numItems = itemList.size(); + QGraphicsItem **itemArray = &itemList[0]; // Relies on QList internals, but is perfectly valid. + QStyleOptionGraphicsItem *styleOptionArray = d->allocStyleOptionsArray(numItems); + QTransform transform(Qt::Uninitialized); + for (int i = 0; i < numItems; ++i) { + QGraphicsItem *item = itemArray[i]; + QGraphicsItemPrivate *itemd = item->d_ptr.data(); + itemd->initStyleOption(&styleOptionArray[i], viewTransform, d->exposedRegion, allItems); + // Cache the item's area in view coordinates. + // Note that we have to do this here in case the base class implementation + // (QGraphicsScene::drawItems) is not called. If it is, we'll do this + // operation twice, but that's the price one has to pay for using indirect + // painting :-/. + const QRectF brect = adjustedItemEffectiveBoundingRect(item); + if (!itemd->itemIsUntransformable()) { + transform = item->sceneTransform(); + if (viewTransformed) + transform *= viewTransform; + } else { + transform = item->deviceTransform(viewTransform); + } + itemd->paintedViewBoundingRects.insert(d->viewport, transform.mapRect(brect).toRect()); } - itemd->paintedViewBoundingRects.insert(d->viewport, transform.mapRect(brect).toRect()); + // Draw the items. + drawItems(&painter, numItems, itemArray, styleOptionArray); + d->freeStyleOptionsArray(styleOptionArray); } - // Draw the items. - drawItems(&painter, numItems, itemArray, styleOptionArray); - d->freeStyleOptionsArray(styleOptionArray); } - } - // Foreground - drawForeground(&painter, exposedSceneRect); + // Foreground + drawForeground(&painter, exposedSceneRect); -#if QT_CONFIG(rubberband) - // Rubberband - if (d->rubberBanding && !d->rubberBandRect.isEmpty()) { - painter.restore(); - QStyleOptionRubberBand option; - option.initFrom(viewport()); - option.rect = d->rubberBandRect; - option.shape = QRubberBand::Rectangle; - - QStyleHintReturnMask mask; - if (viewport()->style()->styleHint(QStyle::SH_RubberBand_Mask, &option, viewport(), &mask)) { - // painter clipping for masked rubberbands - painter.setClipRegion(mask.region, Qt::IntersectClip); + #if QT_CONFIG(rubberband) + // Rubberband + if (d->rubberBanding && !d->rubberBandRect.isEmpty()) { + painter.restore(); + QStyleOptionRubberBand option; + option.initFrom(viewport()); + option.rect = d->rubberBandRect; + option.shape = QRubberBand::Rectangle; + + QStyleHintReturnMask mask; + if (viewport()->style()->styleHint(QStyle::SH_RubberBand_Mask, &option, viewport(), &mask)) { + // painter clipping for masked rubberbands + painter.setClipRegion(mask.region, Qt::IntersectClip); + } + + viewport()->style()->drawControl(QStyle::CE_RubberBand, &option, &painter, viewport()); } + #endif + }; + + actuallyDraw(); - viewport()->style()->drawControl(QStyle::CE_RubberBand, &option, &painter, viewport()); + // For stereo we want to draw everything twice, once to each buffer + if (d->stereoEnabled) { + QWidgetPrivate* w = QWidgetPrivate::get(viewport()); + if (w->toggleStereoTargetBuffer()) { + actuallyDraw(); + w->toggleStereoTargetBuffer(); + } } -#endif painter.end(); @@ -3719,7 +3717,12 @@ void QGraphicsView::drawBackground(QPainter *painter, const QRectF &rect) return; } + const bool wasAa = painter->testRenderHint(QPainter::Antialiasing); + if (wasAa) + painter->setRenderHints(QPainter::Antialiasing, false); painter->fillRect(rect, d->backgroundBrush); + if (wasAa) + painter->setRenderHints(QPainter::Antialiasing, true); } /*! @@ -3834,13 +3837,13 @@ bool QGraphicsView::isTransformed() const \snippet code/src_gui_graphicsview_qgraphicsview.cpp 7 - To simplify interation with items using a transformed view, QGraphicsView + To simplify interaction with items using a transformed view, QGraphicsView provides mapTo... and mapFrom... functions that can translate between scene and view coordinates. For example, you can call mapToScene() to map a view coordinate to a floating point scene coordinate, or mapFromScene() to map from floating point scene coordinates to view coordinates. - \sa transform(), rotate(), scale(), shear(), translate() + \sa transform(), resetTransform(), rotate(), scale(), shear(), translate() */ void QGraphicsView::setTransform(const QTransform &matrix, bool combine ) { diff --git a/src/widgets/graphicsview/qgraphicsview.h b/src/widgets/graphicsview/qgraphicsview.h index 719f11d4b2..554c5a4b4e 100644 --- a/src/widgets/graphicsview/qgraphicsview.h +++ b/src/widgets/graphicsview/qgraphicsview.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSVIEW_H #define QGRAPHICSVIEW_H diff --git a/src/widgets/graphicsview/qgraphicsview_p.h b/src/widgets/graphicsview/qgraphicsview_p.h index 0b137e91dc..7f1682beca 100644 --- a/src/widgets/graphicsview/qgraphicsview_p.h +++ b/src/widgets/graphicsview/qgraphicsview_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSVIEW_P_H #define QGRAPHICSVIEW_P_H @@ -61,6 +25,8 @@ #include <private/qabstractscrollarea_p.h> #include <private/qapplication_p.h> +#include <QtCore/qpointer.h> + QT_REQUIRE_CONFIG(graphicsview); QT_BEGIN_NAMESPACE @@ -136,6 +102,8 @@ public: QGraphicsView::ViewportUpdateMode viewportUpdateMode; QGraphicsView::OptimizationFlags optimizationFlags; + bool stereoEnabled = false; // Set in setupViewport() + QPointer<QGraphicsScene> scene; #if QT_CONFIG(rubberband) QRect rubberBandRect; diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index c857d5dc5a..3679723bc4 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qglobal.h" @@ -67,6 +31,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + /*! \class QGraphicsWidget \brief The QGraphicsWidget class is the base class for all widget @@ -233,7 +199,7 @@ QGraphicsWidget::~QGraphicsWidget() Q_D(QGraphicsWidget); #ifndef QT_NO_ACTION // Remove all actions from this widget - for (auto action : qAsConst(d->actions)) { + for (auto action : std::as_const(d->actions)) { QActionPrivate *apriv = action->d_func(); apriv->associatedObjects.removeAll(this); } @@ -2002,7 +1968,7 @@ void QGraphicsWidget::addAction(QAction *action) */ void QGraphicsWidget::addActions(const QList<QAction *> &actions) { - for (int i = 0; i < actions.count(); ++i) + for (int i = 0; i < actions.size(); ++i) insertAction(nullptr, actions.at(i)); } @@ -2059,7 +2025,7 @@ void QGraphicsWidget::insertAction(QAction *before, QAction *action) */ void QGraphicsWidget::insertActions(QAction *before, const QList<QAction *> &actions) { - for (int i = 0; i < actions.count(); ++i) + for (int i = 0; i < actions.size(); ++i) insertAction(before, actions.at(i)); } @@ -2401,7 +2367,7 @@ void QGraphicsWidget::dumpFocusChain() qWarning("Found a focus chain that is not circular, (next == 0)"); break; } - qDebug() << i++ << QString::number(uint(next), 16) << next->className() << next->data(0) << QString::fromLatin1("focusItem:%1").arg(next->hasFocus() ? '1' : '0') << QLatin1String("next:") << next->d_func()->focusNext->data(0) << QLatin1String("prev:") << next->d_func()->focusPrev->data(0); + qDebug() << i++ << QString::number(uint(next), 16) << next->className() << next->data(0) << QString::fromLatin1("focusItem:%1").arg(next->hasFocus() ? '1' : '0') << "next:"_L1 << next->d_func()->focusNext->data(0) << "prev:"_L1 << next->d_func()->focusPrev->data(0); if (visited.contains(next)) { qWarning("Already visited this node. However, I expected to dump until I found myself."); break; diff --git a/src/widgets/graphicsview/qgraphicswidget.h b/src/widgets/graphicsview/qgraphicswidget.h index 08ebb3de2a..3e2c93b6cc 100644 --- a/src/widgets/graphicsview/qgraphicswidget.h +++ b/src/widgets/graphicsview/qgraphicswidget.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSWIDGET_H #define QGRAPHICSWIDGET_H diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp index d989455596..6c12dc7754 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.cpp +++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qglobal.h" diff --git a/src/widgets/graphicsview/qgraphicswidget_p.h b/src/widgets/graphicsview/qgraphicswidget_p.h index e4cc2c3016..868969cc94 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.h +++ b/src/widgets/graphicsview/qgraphicswidget_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRAPHICSWIDGET_P_H #define QGRAPHICSWIDGET_P_H diff --git a/src/widgets/graphicsview/qsimplex_p.cpp b/src/widgets/graphicsview/qsimplex_p.cpp index b9f7275d00..948437bf68 100644 --- a/src/widgets/graphicsview/qsimplex_p.cpp +++ b/src/widgets/graphicsview/qsimplex_p.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qsimplex_p.h" @@ -46,6 +10,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + /*! \internal \class QSimplex @@ -354,7 +320,7 @@ void QSimplex::dumpMatrix() { qDebug("---- Simplex Matrix ----\n"); - QString str(QLatin1String(" ")); + QString str(" "_L1); for (int j = 0; j < columns; ++j) str += QString::fromLatin1(" <%1 >").arg(j, 2); qDebug("%s", qPrintable(str)); @@ -614,7 +580,7 @@ bool QSimplex::simplifyConstraints(QList<QSimplexConstraint *> *constraints) QList<QSimplexConstraint *>::iterator iter = constraints->begin(); while (iter != constraints->end()) { QSimplexConstraint *c = *iter; - if ((c->ratio == QSimplexConstraint::Equal) && (c->variables.count() == 1)) { + if ((c->ratio == QSimplexConstraint::Equal) && (c->variables.size() == 1)) { // Check whether this is a constraint of type Var == K // If so, save its value to "results". QSimplexVariable *variable = c->variables.constBegin().key(); diff --git a/src/widgets/graphicsview/qsimplex_p.h b/src/widgets/graphicsview/qsimplex_p.h index a69cef6115..800c8fe934 100644 --- a/src/widgets/graphicsview/qsimplex_p.h +++ b/src/widgets/graphicsview/qsimplex_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QSIMPLEX_P_H #define QSIMPLEX_P_H |