Replace all QPair/qMakePair with std::pair in qtbase/widgets

As a drive-by replace QList::append and operator<< with emplace_back,
to avoid repeating value_type.

Task-number: QTBUG-115841
Pick-to: 6.8
Change-Id: I6fb790f959b41b0feb49e3a0f0b6b3631e24a232
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 71d114588d9312e89195a32357ec402fc22b062e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Isak Fyksen 2024-10-17 14:11:12 +02:00 committed by Qt Cherry-pick Bot
parent 562e74e3b4
commit 2b2271bea3
21 changed files with 134 additions and 131 deletions

View File

@ -252,10 +252,10 @@ static inline bool isAncestor(const QObject *obj, const QObject *child)
} }
/*! \reimp */ /*! \reimp */
QList<QPair<QAccessibleInterface *, QAccessible::Relation>> QList<std::pair<QAccessibleInterface *, QAccessible::Relation>>
QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRelations*/) const QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRelations*/) const
{ {
QList<QPair<QAccessibleInterface *, QAccessible::Relation>> rels; QList<std::pair<QAccessibleInterface *, QAccessible::Relation>> rels;
if (match & QAccessible::Label) { if (match & QAccessible::Label) {
const QAccessible::Relation rel = QAccessible::Label; const QAccessible::Relation rel = QAccessible::Label;
if (QWidget *parent = widget()->parentWidget()) { if (QWidget *parent = widget()->parentWidget()) {
@ -268,7 +268,7 @@ QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRel
if (QLabel *labelSibling = qobject_cast<QLabel*>(kid)) { if (QLabel *labelSibling = qobject_cast<QLabel*>(kid)) {
if (labelSibling->buddy() == widget()) { if (labelSibling->buddy() == widget()) {
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(labelSibling); QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(labelSibling);
rels.append(qMakePair(iface, rel)); rels.emplace_back(iface, rel);
} }
} }
} }
@ -277,7 +277,7 @@ QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRel
QGroupBox *groupbox = qobject_cast<QGroupBox*>(parent); QGroupBox *groupbox = qobject_cast<QGroupBox*>(parent);
if (groupbox && !groupbox->title().isEmpty()) { if (groupbox && !groupbox->title().isEmpty()) {
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(groupbox); QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(groupbox);
rels.append(qMakePair(iface, rel)); rels.emplace_back(iface, rel);
} }
#endif #endif
} }
@ -297,7 +297,7 @@ QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRel
const QAccessible::Relation rel = QAccessible::Controlled; const QAccessible::Relation rel = QAccessible::Controlled;
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(allReceivers.at(i)); QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(allReceivers.at(i));
if (iface) if (iface)
rels.append(qMakePair(iface, rel)); rels.emplace_back(iface, rel);
} }
} }

View File

@ -23,7 +23,7 @@ public:
QWindow *window() const override; QWindow *window() const override;
int childCount() const override; int childCount() const override;
int indexOfChild(const QAccessibleInterface *child) const override; int indexOfChild(const QAccessibleInterface *child) const override;
QList<QPair<QAccessibleInterface *, QAccessible::Relation>> QList<std::pair<QAccessibleInterface *, QAccessible::Relation>>
relations(QAccessible::Relation match = QAccessible::AllRelations) const override; relations(QAccessible::Relation match = QAccessible::AllRelations) const override;
QAccessibleInterface *focusChild() const override; QAccessibleInterface *focusChild() const override;

View File

@ -953,7 +953,7 @@ QString QAccessibleTextWidget::textBeforeOffset(int offset, QAccessible::TextBou
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
cursor.setPosition(offset); cursor.setPosition(offset);
QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); std::pair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType);
cursor.setPosition(boundaries.first - 1); cursor.setPosition(boundaries.first - 1);
boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType);
@ -972,7 +972,7 @@ QString QAccessibleTextWidget::textAfterOffset(int offset, QAccessible::TextBoun
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
cursor.setPosition(offset); cursor.setPosition(offset);
QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); std::pair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType);
cursor.setPosition(boundaries.second); cursor.setPosition(boundaries.second);
boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType);
@ -990,7 +990,7 @@ QString QAccessibleTextWidget::textAtOffset(int offset, QAccessible::TextBoundar
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
cursor.setPosition(offset); cursor.setPosition(offset);
QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); std::pair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType);
*startOffset = boundaries.first; *startOffset = boundaries.first;
*endOffset = boundaries.second; *endOffset = boundaries.second;

View File

@ -486,17 +486,17 @@ QString QAccessibleDisplay::text(QAccessible::Text t) const
} }
/*! \reimp */ /*! \reimp */
QList<QPair<QAccessibleInterface *, QAccessible::Relation>> QList<std::pair<QAccessibleInterface *, QAccessible::Relation>>
QAccessibleDisplay::relations(QAccessible::Relation match /* = QAccessible::AllRelations */) const QAccessibleDisplay::relations(QAccessible::Relation match /* = QAccessible::AllRelations */) const
{ {
QList<QPair<QAccessibleInterface *, QAccessible::Relation>> rels = QList<std::pair<QAccessibleInterface *, QAccessible::Relation>> rels =
QAccessibleWidget::relations(match); QAccessibleWidget::relations(match);
# if QT_CONFIG(shortcut) && QT_CONFIG(label) # if QT_CONFIG(shortcut) && QT_CONFIG(label)
if (match & QAccessible::Labelled) { if (match & QAccessible::Labelled) {
if (QLabel *label = qobject_cast<QLabel*>(object())) { if (QLabel *label = qobject_cast<QLabel*>(object())) {
const QAccessible::Relation rel = QAccessible::Labelled; const QAccessible::Relation rel = QAccessible::Labelled;
if (QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(label->buddy())) if (QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(label->buddy()))
rels.append(qMakePair(iface, rel)); rels.emplace_back(iface, rel);
} }
} }
#endif #endif
@ -598,10 +598,10 @@ QAccessible::Role QAccessibleGroupBox::role() const
return groupBox()->isCheckable() ? QAccessible::CheckBox : QAccessible::Grouping; return groupBox()->isCheckable() ? QAccessible::CheckBox : QAccessible::Grouping;
} }
QList<QPair<QAccessibleInterface *, QAccessible::Relation>> QList<std::pair<QAccessibleInterface *, QAccessible::Relation>>
QAccessibleGroupBox::relations(QAccessible::Relation match /* = QAccessible::AllRelations */) const QAccessibleGroupBox::relations(QAccessible::Relation match /* = QAccessible::AllRelations */) const
{ {
QList<QPair<QAccessibleInterface *, QAccessible::Relation>> rels = QList<std::pair<QAccessibleInterface *, QAccessible::Relation>> rels =
QAccessibleWidget::relations(match); QAccessibleWidget::relations(match);
if ((match & QAccessible::Labelled) && (!groupBox()->title().isEmpty())) { if ((match & QAccessible::Labelled) && (!groupBox()->title().isEmpty())) {
@ -609,7 +609,7 @@ QAccessibleGroupBox::relations(QAccessible::Relation match /* = QAccessible::All
for (QWidget *kid : kids) { for (QWidget *kid : kids) {
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(kid); QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(kid);
if (iface) if (iface)
rels.append(qMakePair(iface, QAccessible::Relation(QAccessible::Labelled))); rels.emplace_back(iface, QAccessible::Relation(QAccessible::Labelled));
} }
} }
return rels; return rels;

View File

@ -83,7 +83,7 @@ public:
QAccessible::Role role() const override; QAccessible::Role role() const override;
QAccessible::State state() const override; QAccessible::State state() const override;
QList<QPair<QAccessibleInterface *, QAccessible::Relation>> QList<std::pair<QAccessibleInterface *, QAccessible::Relation>>
relations(QAccessible::Relation match = QAccessible::AllRelations) const override; relations(QAccessible::Relation match = QAccessible::AllRelations) const override;
void *interface_cast(QAccessible::InterfaceType t) override; void *interface_cast(QAccessible::InterfaceType t) override;
@ -103,7 +103,7 @@ public:
QAccessible::Role role() const override; QAccessible::Role role() const override;
QString text(QAccessible::Text t) const override; QString text(QAccessible::Text t) const override;
QList<QPair<QAccessibleInterface *, QAccessible::Relation>> QList<std::pair<QAccessibleInterface *, QAccessible::Relation>>
relations(QAccessible::Relation match = QAccessible::AllRelations) const override; relations(QAccessible::Relation match = QAccessible::AllRelations) const override;
//QAccessibleActionInterface //QAccessibleActionInterface

View File

@ -179,15 +179,15 @@ public:
return setOfVertices; return setOfVertices;
} }
QList<QPair<Vertex *, Vertex *>> connections() const QList<std::pair<Vertex *, Vertex *>> connections() const
{ {
QList<QPair<Vertex *, Vertex *>> conns; QList<std::pair<Vertex *, Vertex *>> conns;
for (const_iterator it = constBegin(); it != constEnd(); ++it) { for (const_iterator it = constBegin(); it != constEnd(); ++it) {
Vertex *from = it.from(); Vertex *from = it.from();
Vertex *to = it.to(); Vertex *to = it.to();
// do not return (from,to) *and* (to,from) // do not return (from,to) *and* (to,from)
if (std::less<Vertex*>()(from, to)) if (std::less<Vertex*>()(from, to))
conns.append(qMakePair(from, to)); conns.emplace_back(from, to);
} }
return conns; return conns;
} }

View File

@ -378,7 +378,7 @@ bool ParallelAnchorData::calculateSizeHints()
0 is at Preferred 0 is at Preferred
1 is at Maximum 1 is at Maximum
*/ */
static QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> getFactor(qreal value, qreal min, static std::pair<QGraphicsAnchorLayoutPrivate::Interval, qreal> getFactor(qreal value, qreal min,
qreal minPref, qreal pref, qreal minPref, qreal pref,
qreal maxPref, qreal max) qreal maxPref, qreal max)
{ {
@ -411,10 +411,10 @@ static QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> getFactor(qreal valu
progress = (value - lower) / (upper - lower); progress = (value - lower) / (upper - lower);
} }
return qMakePair(interval, progress); return std::pair(interval, progress);
} }
static qreal interpolate(const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> &factor, static qreal interpolate(const std::pair<QGraphicsAnchorLayoutPrivate::Interval, qreal> &factor,
qreal min, qreal minPref, qreal pref, qreal maxPref, qreal max) qreal min, qreal minPref, qreal pref, qreal maxPref, qreal max)
{ {
qreal lower = 0; qreal lower = 0;
@ -447,11 +447,11 @@ void SequentialAnchorData::updateChildrenSizes()
// Band here refers if the value is in the Minimum To Preferred // Band here refers if the value is in the Minimum To Preferred
// band (the lower band) or the Preferred To Maximum (the upper band). // band (the lower band) or the Preferred To Maximum (the upper band).
const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> minFactor = const std::pair<QGraphicsAnchorLayoutPrivate::Interval, qreal> minFactor =
getFactor(sizeAtMinimum, minSize, minPrefSize, prefSize, maxPrefSize, maxSize); getFactor(sizeAtMinimum, minSize, minPrefSize, prefSize, maxPrefSize, maxSize);
const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> prefFactor = const std::pair<QGraphicsAnchorLayoutPrivate::Interval, qreal> prefFactor =
getFactor(sizeAtPreferred, minSize, minPrefSize, prefSize, maxPrefSize, maxSize); getFactor(sizeAtPreferred, minSize, minPrefSize, prefSize, maxPrefSize, maxSize);
const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> maxFactor = const std::pair<QGraphicsAnchorLayoutPrivate::Interval, qreal> maxFactor =
getFactor(sizeAtMaximum, minSize, minPrefSize, prefSize, maxPrefSize, maxSize); getFactor(sizeAtMaximum, minSize, minPrefSize, prefSize, maxPrefSize, maxSize);
// XXX This is not safe if Vertex simplification takes place after the sequential // XXX This is not safe if Vertex simplification takes place after the sequential
@ -982,14 +982,14 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(Qt::Orientation orient
Graph<AnchorVertex, AnchorData> &g = graph[orientation]; Graph<AnchorVertex, AnchorData> &g = graph[orientation];
QSet<AnchorVertex *> visited; QSet<AnchorVertex *> visited;
QStack<QPair<AnchorVertex *, AnchorVertex *> > stack; QStack<std::pair<AnchorVertex *, AnchorVertex *> > stack;
stack.push(qMakePair(static_cast<AnchorVertex *>(nullptr), layoutFirstVertex[orientation])); stack.push(std::pair(static_cast<AnchorVertex *>(nullptr), layoutFirstVertex[orientation]));
QList<AnchorVertex *> candidates; QList<AnchorVertex *> candidates;
// Walk depth-first, in the stack we store start of the candidate sequence (beforeSequence) // Walk depth-first, in the stack we store start of the candidate sequence (beforeSequence)
// and the vertex to be visited. // and the vertex to be visited.
while (!stack.isEmpty()) { while (!stack.isEmpty()) {
QPair<AnchorVertex *, AnchorVertex *> pair = stack.pop(); std::pair<AnchorVertex *, AnchorVertex *> pair = stack.pop();
AnchorVertex *beforeSequence = pair.first; AnchorVertex *beforeSequence = pair.first;
AnchorVertex *v = pair.second; AnchorVertex *v = pair.second;
@ -1065,9 +1065,9 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(Qt::Orientation orient
// vertex. If it's not an end of sequence, we keep the original 'before' vertex, // vertex. If it's not an end of sequence, we keep the original 'before' vertex,
// since we are keeping the candidates list. // since we are keeping the candidates list.
if (endOfSequence) if (endOfSequence)
stack.push(qMakePair(v, next)); stack.push(std::pair(v, next));
else else
stack.push(qMakePair(beforeSequence, next)); stack.push(std::pair(beforeSequence, next));
} }
visited.insert(v); visited.insert(v);
@ -1212,7 +1212,7 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedGraph(Qt::Orientation orient
// Restore anchor simplification // Restore anchor simplification
Graph<AnchorVertex, AnchorData> &g = graph[orientation]; Graph<AnchorVertex, AnchorData> &g = graph[orientation];
QList<QPair<AnchorVertex *, AnchorVertex *>> connections = g.connections(); QList<std::pair<AnchorVertex *, AnchorVertex *>> connections = g.connections();
for (int i = 0; i < connections.size(); ++i) { for (int i = 0; i < connections.size(); ++i) {
AnchorVertex *v1 = connections.at(i).first; AnchorVertex *v1 = connections.at(i).first;
AnchorVertex *v2 = connections.at(i).second; AnchorVertex *v2 = connections.at(i).second;
@ -1764,12 +1764,12 @@ void QGraphicsAnchorLayoutPrivate::removeAnchor(AnchorVertex *firstVertex,
bool keepFirstItem = false; bool keepFirstItem = false;
bool keepSecondItem = false; bool keepSecondItem = false;
QPair<AnchorVertex *, int> v; std::pair<AnchorVertex *, int> v;
int refcount = -1; int refcount = -1;
if (firstItem != q) { if (firstItem != q) {
for (int i = Qt::AnchorLeft; i <= Qt::AnchorBottom; ++i) { for (int i = Qt::AnchorLeft; i <= Qt::AnchorBottom; ++i) {
v = m_vertexList.value(qMakePair(firstItem, static_cast<Qt::AnchorPoint>(i))); v = m_vertexList.value(std::pair(firstItem, static_cast<Qt::AnchorPoint>(i)));
if (v.first) { if (v.first) {
if (i == Qt::AnchorHorizontalCenter || i == Qt::AnchorVerticalCenter) if (i == Qt::AnchorHorizontalCenter || i == Qt::AnchorVerticalCenter)
refcount = 2; refcount = 2;
@ -1787,7 +1787,7 @@ void QGraphicsAnchorLayoutPrivate::removeAnchor(AnchorVertex *firstVertex,
if (secondItem != q) { if (secondItem != q) {
for (int i = Qt::AnchorLeft; i <= Qt::AnchorBottom; ++i) { for (int i = Qt::AnchorLeft; i <= Qt::AnchorBottom; ++i) {
v = m_vertexList.value(qMakePair(secondItem, static_cast<Qt::AnchorPoint>(i))); v = m_vertexList.value(std::pair(secondItem, static_cast<Qt::AnchorPoint>(i)));
if (v.first) { if (v.first) {
if (i == Qt::AnchorHorizontalCenter || i == Qt::AnchorVerticalCenter) if (i == Qt::AnchorHorizontalCenter || i == Qt::AnchorVerticalCenter)
refcount = 2; refcount = 2;
@ -1835,8 +1835,8 @@ void QGraphicsAnchorLayoutPrivate::removeAnchor_helper(AnchorVertex *v1, AnchorV
AnchorVertex *QGraphicsAnchorLayoutPrivate::addInternalVertex(QGraphicsLayoutItem *item, AnchorVertex *QGraphicsAnchorLayoutPrivate::addInternalVertex(QGraphicsLayoutItem *item,
Qt::AnchorPoint edge) Qt::AnchorPoint edge)
{ {
QPair<QGraphicsLayoutItem *, Qt::AnchorPoint> pair(item, edge); std::pair<QGraphicsLayoutItem *, Qt::AnchorPoint> pair(item, edge);
QPair<AnchorVertex *, int> v = m_vertexList.value(pair); std::pair<AnchorVertex *, int> v = m_vertexList.value(pair);
if (!v.first) { if (!v.first) {
Q_ASSERT(v.second == 0); Q_ASSERT(v.second == 0);
@ -1856,8 +1856,8 @@ AnchorVertex *QGraphicsAnchorLayoutPrivate::addInternalVertex(QGraphicsLayoutIte
void QGraphicsAnchorLayoutPrivate::removeInternalVertex(QGraphicsLayoutItem *item, void QGraphicsAnchorLayoutPrivate::removeInternalVertex(QGraphicsLayoutItem *item,
Qt::AnchorPoint edge) Qt::AnchorPoint edge)
{ {
QPair<QGraphicsLayoutItem *, Qt::AnchorPoint> pair(item, edge); std::pair<QGraphicsLayoutItem *, Qt::AnchorPoint> pair(item, edge);
QPair<AnchorVertex *, int> v = m_vertexList.value(pair); std::pair<AnchorVertex *, int> v = m_vertexList.value(pair);
if (!v.first) { if (!v.first) {
qWarning("This item with this edge is not in the graph"); qWarning("This item with this edge is not in the graph");
@ -2234,7 +2234,7 @@ bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk(const QList<QSimplexConstra
void QGraphicsAnchorLayoutPrivate::refreshAllSizeHints(Qt::Orientation orientation) void QGraphicsAnchorLayoutPrivate::refreshAllSizeHints(Qt::Orientation orientation)
{ {
Graph<AnchorVertex, AnchorData> &g = graph[orientation]; Graph<AnchorVertex, AnchorData> &g = graph[orientation];
QList<QPair<AnchorVertex *, AnchorVertex *>> vertices = g.connections(); QList<std::pair<AnchorVertex *, AnchorVertex *>> vertices = g.connections();
QLayoutStyleInfo styleInf = styleInfo(); QLayoutStyleInfo styleInf = styleInfo();
for (int i = 0; i < vertices.size(); ++i) { for (int i = 0; i < vertices.size(); ++i) {
@ -2255,7 +2255,7 @@ void QGraphicsAnchorLayoutPrivate::refreshAllSizeHints(Qt::Orientation orientati
*/ */
void QGraphicsAnchorLayoutPrivate::findPaths(Qt::Orientation orientation) void QGraphicsAnchorLayoutPrivate::findPaths(Qt::Orientation orientation)
{ {
QQueue<QPair<AnchorVertex *, AnchorVertex *> > queue; QQueue<std::pair<AnchorVertex *, AnchorVertex *> > queue;
QSet<AnchorData *> visited; QSet<AnchorData *> visited;
@ -2265,10 +2265,10 @@ void QGraphicsAnchorLayoutPrivate::findPaths(Qt::Orientation orientation)
const auto adjacentVertices = graph[orientation].adjacentVertices(root); const auto adjacentVertices = graph[orientation].adjacentVertices(root);
for (AnchorVertex *v : adjacentVertices) for (AnchorVertex *v : adjacentVertices)
queue.enqueue(qMakePair(root, v)); queue.enqueue(std::pair(root, v));
while(!queue.isEmpty()) { while(!queue.isEmpty()) {
QPair<AnchorVertex *, AnchorVertex *> pair = queue.dequeue(); std::pair<AnchorVertex *, AnchorVertex *> pair = queue.dequeue();
AnchorData *edge = graph[orientation].edgeData(pair.first, pair.second); AnchorData *edge = graph[orientation].edgeData(pair.first, pair.second);
if (visited.contains(edge)) if (visited.contains(edge))
@ -2286,7 +2286,7 @@ void QGraphicsAnchorLayoutPrivate::findPaths(Qt::Orientation orientation)
const auto adjacentVertices = graph[orientation].adjacentVertices(pair.second); const auto adjacentVertices = graph[orientation].adjacentVertices(pair.second);
for (AnchorVertex *v : adjacentVertices) for (AnchorVertex *v : adjacentVertices)
queue.enqueue(qMakePair(pair.second, v)); queue.enqueue(std::pair(pair.second, v));
} }
// We will walk through every reachable items (non-float) store them in a temporary set. // We will walk through every reachable items (non-float) store them in a temporary set.
@ -2327,7 +2327,7 @@ void QGraphicsAnchorLayoutPrivate::constraintsFromPaths(Qt::Orientation orientat
void QGraphicsAnchorLayoutPrivate::updateAnchorSizes(Qt::Orientation orientation) void QGraphicsAnchorLayoutPrivate::updateAnchorSizes(Qt::Orientation orientation)
{ {
Graph<AnchorVertex, AnchorData> &g = graph[orientation]; Graph<AnchorVertex, AnchorData> &g = graph[orientation];
const QList<QPair<AnchorVertex *, AnchorVertex *>> &vertices = g.connections(); const QList<std::pair<AnchorVertex *, AnchorVertex *>> &vertices = g.connections();
for (int i = 0; i < vertices.size(); ++i) { for (int i = 0; i < vertices.size(); ++i) {
AnchorData *ad = g.edgeData(vertices.at(i).first, vertices.at(i).second); AnchorData *ad = g.edgeData(vertices.at(i).first, vertices.at(i).second);
@ -2622,7 +2622,7 @@ void QGraphicsAnchorLayoutPrivate::setItemsGeometries(const QRectF &geom)
*/ */
void QGraphicsAnchorLayoutPrivate::calculateVertexPositions(Qt::Orientation orientation) void QGraphicsAnchorLayoutPrivate::calculateVertexPositions(Qt::Orientation orientation)
{ {
QQueue<QPair<AnchorVertex *, AnchorVertex *> > queue; QQueue<std::pair<AnchorVertex *, AnchorVertex *> > queue;
QSet<AnchorVertex *> visited; QSet<AnchorVertex *> visited;
// Get root vertex // Get root vertex
@ -2634,14 +2634,14 @@ void QGraphicsAnchorLayoutPrivate::calculateVertexPositions(Qt::Orientation orie
// Add initial edges to the queue // Add initial edges to the queue
const auto adjacentVertices = graph[orientation].adjacentVertices(root); const auto adjacentVertices = graph[orientation].adjacentVertices(root);
for (AnchorVertex *v : adjacentVertices) for (AnchorVertex *v : adjacentVertices)
queue.enqueue(qMakePair(root, v)); queue.enqueue(std::pair(root, v));
// Do initial calculation required by "interpolateEdge()" // Do initial calculation required by "interpolateEdge()"
setupEdgesInterpolation(orientation); setupEdgesInterpolation(orientation);
// Traverse the graph and calculate vertex positions // Traverse the graph and calculate vertex positions
while (!queue.isEmpty()) { while (!queue.isEmpty()) {
QPair<AnchorVertex *, AnchorVertex *> pair = queue.dequeue(); std::pair<AnchorVertex *, AnchorVertex *> pair = queue.dequeue();
AnchorData *edge = graph[orientation].edgeData(pair.first, pair.second); AnchorData *edge = graph[orientation].edgeData(pair.first, pair.second);
if (visited.contains(pair.second)) if (visited.contains(pair.second))
@ -2653,7 +2653,7 @@ void QGraphicsAnchorLayoutPrivate::calculateVertexPositions(Qt::Orientation orie
QList<AnchorVertex *> adjacents = graph[orientation].adjacentVertices(pair.second); QList<AnchorVertex *> adjacents = graph[orientation].adjacentVertices(pair.second);
for (int i = 0; i < adjacents.size(); ++i) { for (int i = 0; i < adjacents.size(); ++i) {
if (!visited.contains(adjacents.at(i))) if (!visited.contains(adjacents.at(i)))
queue.enqueue(qMakePair(pair.second, adjacents.at(i))); queue.enqueue(std::pair(pair.second, adjacents.at(i)));
} }
} }
} }
@ -2673,7 +2673,7 @@ void QGraphicsAnchorLayoutPrivate::setupEdgesInterpolation(
qreal current; qreal current;
current = (orientation == Qt::Horizontal) ? q->contentsRect().width() : q->contentsRect().height(); current = (orientation == Qt::Horizontal) ? q->contentsRect().width() : q->contentsRect().height();
QPair<Interval, qreal> result; std::pair<Interval, qreal> result;
result = getFactor(current, result = getFactor(current,
sizeHints[orientation][Qt::MinimumSize], sizeHints[orientation][Qt::MinimumSize],
sizeHints[orientation][Qt::PreferredSize], sizeHints[orientation][Qt::PreferredSize],
@ -2703,7 +2703,7 @@ void QGraphicsAnchorLayoutPrivate::setupEdgesInterpolation(
void QGraphicsAnchorLayoutPrivate::interpolateEdge(AnchorVertex *base, AnchorData *edge) void QGraphicsAnchorLayoutPrivate::interpolateEdge(AnchorVertex *base, AnchorData *edge)
{ {
const Qt::Orientation orientation = edge->isVertical ? Qt::Vertical : Qt::Horizontal; const Qt::Orientation orientation = edge->isVertical ? Qt::Vertical : Qt::Horizontal;
const QPair<Interval, qreal> factor(interpolationInterval[orientation], const std::pair<Interval, qreal> factor(interpolationInterval[orientation],
interpolationProgress[orientation]); interpolationProgress[orientation]);
qreal edgeDistance = interpolate(factor, edge->sizeAtMinimum, edge->sizeAtPreferred, qreal edgeDistance = interpolate(factor, edge->sizeAtMinimum, edge->sizeAtPreferred,
@ -2761,7 +2761,7 @@ bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList<QSimplexConstraint *>
} }
enum slackType { Grower = -1, Shrinker = 1 }; enum slackType { Grower = -1, Shrinker = 1 };
static QPair<QSimplexVariable *, QSimplexConstraint *> createSlack(QSimplexConstraint *sizeConstraint, static std::pair<QSimplexVariable *, QSimplexConstraint *> createSlack(QSimplexConstraint *sizeConstraint,
qreal interval, slackType type) qreal interval, slackType type)
{ {
QSimplexVariable *slack = new QSimplexVariable; QSimplexVariable *slack = new QSimplexVariable;
@ -2772,7 +2772,7 @@ static QPair<QSimplexVariable *, QSimplexConstraint *> createSlack(QSimplexConst
limit->ratio = QSimplexConstraint::LessOrEqual; limit->ratio = QSimplexConstraint::LessOrEqual;
limit->constant = interval; limit->constant = interval;
return qMakePair(slack, limit); return std::pair(slack, limit);
} }
bool QGraphicsAnchorLayoutPrivate::solvePreferred(const QList<QSimplexConstraint *> &constraints, bool QGraphicsAnchorLayoutPrivate::solvePreferred(const QList<QSimplexConstraint *> &constraints,
@ -2815,7 +2815,7 @@ bool QGraphicsAnchorLayoutPrivate::solvePreferred(const QList<QSimplexConstraint
sizeConstraint->constant = ad->prefSize + g_offset; sizeConstraint->constant = ad->prefSize + g_offset;
// Can easily shrink // Can easily shrink
QPair<QSimplexVariable *, QSimplexConstraint *> slack; std::pair<QSimplexVariable *, QSimplexConstraint *> slack;
const qreal softShrinkInterval = ad->prefSize - ad->minPrefSize; const qreal softShrinkInterval = ad->prefSize - ad->minPrefSize;
if (softShrinkInterval) { if (softShrinkInterval) {
slack = createSlack(sizeConstraint, softShrinkInterval, Shrinker); slack = createSlack(sizeConstraint, softShrinkInterval, Shrinker);

View File

@ -475,14 +475,14 @@ public:
void identifyFloatItems(const QSet<AnchorData *> &visited, Qt::Orientation orientation); void identifyFloatItems(const QSet<AnchorData *> &visited, Qt::Orientation orientation);
void identifyNonFloatItems_helper(const AnchorData *ad, QSet<QGraphicsLayoutItem *> *nonFloatingItemsIdentifiedSoFar); void identifyNonFloatItems_helper(const AnchorData *ad, QSet<QGraphicsLayoutItem *> *nonFloatingItemsIdentifiedSoFar);
inline AnchorVertex *internalVertex(const QPair<QGraphicsLayoutItem*, Qt::AnchorPoint> &itemEdge) const inline AnchorVertex *internalVertex(const std::pair<QGraphicsLayoutItem*, Qt::AnchorPoint> &itemEdge) const
{ {
return m_vertexList.value(itemEdge).first; return m_vertexList.value(itemEdge).first;
} }
inline AnchorVertex *internalVertex(const QGraphicsLayoutItem *item, Qt::AnchorPoint edge) const inline AnchorVertex *internalVertex(const QGraphicsLayoutItem *item, Qt::AnchorPoint edge) const
{ {
return internalVertex(qMakePair(const_cast<QGraphicsLayoutItem *>(item), edge)); return internalVertex(std::pair(const_cast<QGraphicsLayoutItem *>(item), edge));
} }
inline void changeLayoutVertex(Qt::Orientation orientation, AnchorVertex *oldV, AnchorVertex *newV) inline void changeLayoutVertex(Qt::Orientation orientation, AnchorVertex *oldV, AnchorVertex *newV)
@ -528,7 +528,7 @@ public:
// Mapping between high level anchorage points (Item, Edge) to low level // Mapping between high level anchorage points (Item, Edge) to low level
// ones (Graph Vertices) // ones (Graph Vertices)
QHash<QPair<QGraphicsLayoutItem*, Qt::AnchorPoint>, QPair<AnchorVertex *, int> > m_vertexList; QHash<std::pair<QGraphicsLayoutItem*, Qt::AnchorPoint>, std::pair<AnchorVertex *, int> > m_vertexList;
// Internal graph of anchorage points and anchors, for both orientations // Internal graph of anchorage points and anchors, for both orientations
QHVContainer<Graph<AnchorVertex, AnchorData>> graph; QHVContainer<Graph<AnchorVertex, AnchorData>> graph;

View File

@ -50,7 +50,6 @@
#include <QtCore/qtimeline.h> #include <QtCore/qtimeline.h>
#include <QtCore/qpoint.h> #include <QtCore/qpoint.h>
#include <QtCore/qpointer.h> #include <QtCore/qpointer.h>
#include <QtCore/qpair.h>
#include <algorithm> #include <algorithm>
@ -248,13 +247,14 @@ void QGraphicsItemAnimation::setPosAt(qreal step, const QPointF &pos)
\sa posAt(), setPosAt() \sa posAt(), setPosAt()
*/ */
QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::posList() const QList<std::pair<qreal, QPointF> > QGraphicsItemAnimation::posList() const
{ {
QList<QPair<qreal, QPointF> > list; QList<std::pair<qreal, QPointF>> list;
const int xPosCount = d->xPosition.size(); const int xPosCount = d->xPosition.size();
list.reserve(xPosCount); list.reserve(xPosCount);
for (int i = 0; i < xPosCount; ++i) for (int i = 0; i < xPosCount; ++i)
list << QPair<qreal, QPointF>(d->xPosition.at(i).step, QPointF(d->xPosition.at(i).value, d->yPosition.at(i).value)); list.emplace_back(d->xPosition.at(i).step,
QPointF(d->xPosition.at(i).value, d->yPosition.at(i).value));
return list; return list;
} }
@ -306,13 +306,13 @@ void QGraphicsItemAnimation::setRotationAt(qreal step, qreal angle)
\sa rotationAt(), setRotationAt() \sa rotationAt(), setRotationAt()
*/ */
QList<QPair<qreal, qreal> > QGraphicsItemAnimation::rotationList() const QList<std::pair<qreal, qreal> > QGraphicsItemAnimation::rotationList() const
{ {
QList<QPair<qreal, qreal> > list; QList<std::pair<qreal, qreal>> list;
const int numRotations = d->rotation.size(); const int numRotations = d->rotation.size();
list.reserve(numRotations); list.reserve(numRotations);
for (int i = 0; i < numRotations; ++i) for (int i = 0; i < numRotations; ++i)
list << QPair<qreal, qreal>(d->rotation.at(i).step, d->rotation.at(i).value); list.emplace_back(d->rotation.at(i).step, d->rotation.at(i).value);
return list; return list;
} }
@ -356,13 +356,14 @@ void QGraphicsItemAnimation::setTranslationAt(qreal step, qreal dx, qreal dy)
\sa xTranslationAt(), yTranslationAt(), setTranslationAt() \sa xTranslationAt(), yTranslationAt(), setTranslationAt()
*/ */
QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::translationList() const QList<std::pair<qreal, QPointF> > QGraphicsItemAnimation::translationList() const
{ {
QList<QPair<qreal, QPointF> > list; QList<std::pair<qreal, QPointF>> list;
const int numTranslations = d->xTranslation.size(); const int numTranslations = d->xTranslation.size();
list.reserve(numTranslations); list.reserve(numTranslations);
for (int i = 0; i < numTranslations; ++i) for (int i = 0; i < numTranslations; ++i)
list << QPair<qreal, QPointF>(d->xTranslation.at(i).step, QPointF(d->xTranslation.at(i).value, d->yTranslation.at(i).value)); list.emplace_back(d->xTranslation.at(i).step,
QPointF(d->xTranslation.at(i).value, d->yTranslation.at(i).value));
return list; return list;
} }
@ -407,13 +408,15 @@ void QGraphicsItemAnimation::setScaleAt(qreal step, qreal sx, qreal sy)
\sa verticalScaleAt(), horizontalScaleAt(), setScaleAt() \sa verticalScaleAt(), horizontalScaleAt(), setScaleAt()
*/ */
QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::scaleList() const QList<std::pair<qreal, QPointF> > QGraphicsItemAnimation::scaleList() const
{ {
QList<QPair<qreal, QPointF> > list; QList<std::pair<qreal, QPointF>> list;
const int numScales = d->horizontalScale.size(); const int numScales = d->horizontalScale.size();
list.reserve(numScales); list.reserve(numScales);
for (int i = 0; i < numScales; ++i) for (int i = 0; i < numScales; ++i)
list << QPair<qreal, QPointF>(d->horizontalScale.at(i).step, QPointF(d->horizontalScale.at(i).value, d->verticalScale.at(i).value)); list.emplace_back(d->horizontalScale.at(i).step,
QPointF(d->horizontalScale.at(i).value,
d->verticalScale.at(i).value));
return list; return list;
} }
@ -457,13 +460,15 @@ void QGraphicsItemAnimation::setShearAt(qreal step, qreal sh, qreal sv)
\sa verticalShearAt(), horizontalShearAt(), setShearAt() \sa verticalShearAt(), horizontalShearAt(), setShearAt()
*/ */
QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::shearList() const QList<std::pair<qreal, QPointF> > QGraphicsItemAnimation::shearList() const
{ {
QList<QPair<qreal, QPointF> > list; QList<std::pair<qreal, QPointF>> list;
const int numShears = d->horizontalShear.size(); const int numShears = d->horizontalShear.size();
list.reserve(numShears); list.reserve(numShears);
for (int i = 0; i < numShears; ++i) for (int i = 0; i < numShears; ++i)
list << QPair<qreal, QPointF>(d->horizontalShear.at(i).step, QPointF(d->horizontalShear.at(i).value, d->verticalShear.at(i).value)); list.emplace_back(d->horizontalShear.at(i).step,
QPointF(d->horizontalShear.at(i).value,
d->verticalShear.at(i).value));
return list; return list;
} }

View File

@ -31,28 +31,28 @@ public:
void setTimeLine(QTimeLine *timeLine); void setTimeLine(QTimeLine *timeLine);
QPointF posAt(qreal step) const; QPointF posAt(qreal step) const;
QList<QPair<qreal, QPointF> > posList() const; QList<std::pair<qreal, QPointF> > posList() const;
void setPosAt(qreal step, const QPointF &pos); void setPosAt(qreal step, const QPointF &pos);
QTransform transformAt(qreal step) const; QTransform transformAt(qreal step) const;
qreal rotationAt(qreal step) const; qreal rotationAt(qreal step) const;
QList<QPair<qreal, qreal> > rotationList() const; QList<std::pair<qreal, qreal> > rotationList() const;
void setRotationAt(qreal step, qreal angle); void setRotationAt(qreal step, qreal angle);
qreal xTranslationAt(qreal step) const; qreal xTranslationAt(qreal step) const;
qreal yTranslationAt(qreal step) const; qreal yTranslationAt(qreal step) const;
QList<QPair<qreal, QPointF> > translationList() const; QList<std::pair<qreal, QPointF> > translationList() const;
void setTranslationAt(qreal step, qreal dx, qreal dy); void setTranslationAt(qreal step, qreal dx, qreal dy);
qreal verticalScaleAt(qreal step) const; qreal verticalScaleAt(qreal step) const;
qreal horizontalScaleAt(qreal step) const; qreal horizontalScaleAt(qreal step) const;
QList<QPair<qreal, QPointF> > scaleList() const; QList<std::pair<qreal, QPointF> > scaleList() const;
void setScaleAt(qreal step, qreal sx, qreal sy); void setScaleAt(qreal step, qreal sx, qreal sy);
qreal verticalShearAt(qreal step) const; qreal verticalShearAt(qreal step) const;
qreal horizontalShearAt(qreal step) const; qreal horizontalShearAt(qreal step) const;
QList<QPair<qreal, QPointF> > shearList() const; QList<std::pair<qreal, QPointF> > shearList() const;
void setShearAt(qreal step, qreal sh, qreal sv); void setShearAt(qreal step, qreal sh, qreal sv);
void clear(); void clear();

View File

@ -5831,7 +5831,7 @@ int QGraphicsScenePrivate::findClosestTouchPointId(const QPointF &scenePos)
void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent) void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent)
{ {
typedef QPair<QEventPoint::States, QList<QEventPoint> > StatesAndTouchPoints; typedef std::pair<QEventPoint::States, QList<QEventPoint> > StatesAndTouchPoints;
QHash<QGraphicsItem *, StatesAndTouchPoints> itemsNeedingEvents; QHash<QGraphicsItem *, StatesAndTouchPoints> itemsNeedingEvents;
const auto &touchPoints = sceneTouchEvent->points(); const auto &touchPoints = sceneTouchEvent->points();

View File

@ -17,7 +17,6 @@
#include <QtWidgets/private/qtwidgetsglobal_p.h> #include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtCore/qhash.h> #include <QtCore/qhash.h>
#include <QtCore/qpair.h>
#include <QtCore/qstring.h> #include <QtCore/qstring.h>
QT_REQUIRE_CONFIG(graphicsview); QT_REQUIRE_CONFIG(graphicsview);
@ -58,7 +57,7 @@ struct QSimplexConstraint
qreal constant; qreal constant;
Ratio ratio; Ratio ratio;
QPair<QSimplexVariable *, qreal> helper; std::pair<QSimplexVariable *, qreal> helper;
QSimplexVariable * artificial; QSimplexVariable * artificial;
void invert(); void invert();

View File

@ -299,7 +299,7 @@ void QListModel::sort(int column, Qt::SortOrder order)
emit layoutAboutToBeChanged({}, QAbstractItemModel::VerticalSortHint); emit layoutAboutToBeChanged({}, QAbstractItemModel::VerticalSortHint);
QList<QPair<QListWidgetItem *, int>> sorting(items.size()); QList<std::pair<QListWidgetItem *, int>> sorting(items.size());
for (int i = 0; i < items.size(); ++i) { for (int i = 0; i < items.size(); ++i) {
QListWidgetItem *item = items.at(i); QListWidgetItem *item = items.at(i);
sorting[i].first = item; sorting[i].first = item;
@ -357,14 +357,14 @@ void QListModel::ensureSorted(int column, Qt::SortOrder order, int start, int en
sort(column, order); sort(column, order);
} }
bool QListModel::itemLessThan(const QPair<QListWidgetItem*,int> &left, bool QListModel::itemLessThan(const std::pair<QListWidgetItem*,int> &left,
const QPair<QListWidgetItem*,int> &right) const std::pair<QListWidgetItem*,int> &right)
{ {
return (*left.first) < (*right.first); return (*left.first) < (*right.first);
} }
bool QListModel::itemGreaterThan(const QPair<QListWidgetItem*,int> &left, bool QListModel::itemGreaterThan(const std::pair<QListWidgetItem*,int> &left,
const QPair<QListWidgetItem*,int> &right) const std::pair<QListWidgetItem*,int> &right)
{ {
return (*right.first) < (*left.first); return (*right.first) < (*left.first);
} }

View File

@ -77,10 +77,10 @@ public:
void sort(int column, Qt::SortOrder order) override; void sort(int column, Qt::SortOrder order) override;
void ensureSorted(int column, Qt::SortOrder order, int start, int end); void ensureSorted(int column, Qt::SortOrder order, int start, int end);
static bool itemLessThan(const QPair<QListWidgetItem*,int> &left, static bool itemLessThan(const std::pair<QListWidgetItem*,int> &left,
const QPair<QListWidgetItem*,int> &right); const std::pair<QListWidgetItem*,int> &right);
static bool itemGreaterThan(const QPair<QListWidgetItem*,int> &left, static bool itemGreaterThan(const std::pair<QListWidgetItem*,int> &left,
const QPair<QListWidgetItem*,int> &right); const std::pair<QListWidgetItem*,int> &right);
static QList<QListWidgetItem*>::iterator sortedInsertionIterator( static QList<QListWidgetItem*>::iterator sortedInsertionIterator(
const QList<QListWidgetItem*>::iterator &begin, const QList<QListWidgetItem*>::iterator &begin,
const QList<QListWidgetItem*>::iterator &end, const QList<QListWidgetItem*>::iterator &end,

View File

@ -496,7 +496,7 @@ Qt::ItemFlags QTableModel::flags(const QModelIndex &index) const
void QTableModel::sort(int column, Qt::SortOrder order) void QTableModel::sort(int column, Qt::SortOrder order)
{ {
QList<QPair<QTableWidgetItem *, int>> sortable; QList<std::pair<QTableWidgetItem *, int>> sortable;
QList<int> unsortable; QList<int> unsortable;
const int numRows = rowCount(); const int numRows = rowCount();
@ -505,7 +505,7 @@ void QTableModel::sort(int column, Qt::SortOrder order)
for (int row = 0; row < numRows; ++row) { for (int row = 0; row < numRows; ++row) {
if (QTableWidgetItem *itm = item(row, column)) if (QTableWidgetItem *itm = item(row, column))
sortable.append(QPair<QTableWidgetItem*,int>(itm, row)); sortable.emplace_back(itm, row);
else else
unsortable.append(row); unsortable.append(row);
} }
@ -549,7 +549,7 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order,
int start, int end) int start, int end)
{ {
int count = end - start + 1; int count = end - start + 1;
QList<QPair<QTableWidgetItem *, int>> sorting; QList<std::pair<QTableWidgetItem *, int>> sorting;
sorting.reserve(count); sorting.reserve(count);
for (int row = start; row <= end; ++row) { for (int row = start; row <= end; ++row) {
QTableWidgetItem *itm = item(row, column); QTableWidgetItem *itm = item(row, column);
@ -558,7 +558,7 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order,
// at the end of the table when it is sorted) // at the end of the table when it is sorted)
break; break;
} }
sorting.append(QPair<QTableWidgetItem*,int>(itm, row)); sorting.emplace_back(itm, row);
} }
const auto compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan); const auto compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan);
@ -686,14 +686,14 @@ QTableModel::sortedInsertionIterator(const QList<QTableWidgetItem *>::iterator &
return std::lower_bound(begin, end, item, QTableModelGreaterThan()); return std::lower_bound(begin, end, item, QTableModelGreaterThan());
} }
bool QTableModel::itemLessThan(const QPair<QTableWidgetItem*,int> &left, bool QTableModel::itemLessThan(const std::pair<QTableWidgetItem*,int> &left,
const QPair<QTableWidgetItem*,int> &right) const std::pair<QTableWidgetItem*,int> &right)
{ {
return *(left.first) < *(right.first); return *(left.first) < *(right.first);
} }
bool QTableModel::itemGreaterThan(const QPair<QTableWidgetItem*,int> &left, bool QTableModel::itemGreaterThan(const std::pair<QTableWidgetItem*,int> &left,
const QPair<QTableWidgetItem*,int> &right) const std::pair<QTableWidgetItem*,int> &right)
{ {
return (*(right.first) < *(left .first)); return (*(right.first) < *(left .first));
} }

View File

@ -103,10 +103,10 @@ public:
Qt::ItemFlags flags(const QModelIndex &index) const override; Qt::ItemFlags flags(const QModelIndex &index) const override;
void sort(int column, Qt::SortOrder order) override; void sort(int column, Qt::SortOrder order) override;
static bool itemLessThan(const QPair<QTableWidgetItem*,int> &left, static bool itemLessThan(const std::pair<QTableWidgetItem*,int> &left,
const QPair<QTableWidgetItem*,int> &right); const std::pair<QTableWidgetItem*,int> &right);
static bool itemGreaterThan(const QPair<QTableWidgetItem*,int> &left, static bool itemGreaterThan(const std::pair<QTableWidgetItem*,int> &left,
const QPair<QTableWidgetItem*,int> &right); const std::pair<QTableWidgetItem*,int> &right);
void ensureSorted(int column, Qt::SortOrder order, int start, int end); void ensureSorted(int column, Qt::SortOrder order, int start, int end);
QList<QTableWidgetItem *> columnItems(int column) const; QList<QTableWidgetItem *> columnItems(int column) const;

View File

@ -2760,10 +2760,10 @@ void QTreeView::expandRecursively(const QModelIndex &index, int depth)
expand(index); expand(index);
if (depth == 0) if (depth == 0)
return; return;
QStack<QPair<QModelIndex, int>> parents; QStack<std::pair<QModelIndex, int>> parents;
parents.push({index, 0}); parents.push({index, 0});
while (!parents.isEmpty()) { while (!parents.isEmpty()) {
const QPair<QModelIndex, int> elem = parents.pop(); const std::pair<QModelIndex, int> elem = parents.pop();
const QModelIndex &parent = elem.first; const QModelIndex &parent = elem.first;
const int curDepth = elem.second; const int curDepth = elem.second;
const int rowCount = d->model->rowCount(parent); const int rowCount = d->model->rowCount(parent);
@ -3911,7 +3911,7 @@ QRect QTreeViewPrivate::itemDecorationRect(const QModelIndex &index) const
return q->style()->subElementRect(QStyle::SE_TreeViewDisclosureItem, &opt, q); return q->style()->subElementRect(QStyle::SE_TreeViewDisclosureItem, &opt, q);
} }
QList<QPair<int, int>> QTreeViewPrivate::columnRanges(const QModelIndex &topIndex, QList<std::pair<int, int>> QTreeViewPrivate::columnRanges(const QModelIndex &topIndex,
const QModelIndex &bottomIndex) const const QModelIndex &bottomIndex) const
{ {
const int topVisual = header->visualIndex(topIndex.column()), const int topVisual = header->visualIndex(topIndex.column()),
@ -3932,8 +3932,8 @@ QList<QPair<int, int>> QTreeViewPrivate::columnRanges(const QModelIndex &topInde
//let's sort the list //let's sort the list
std::sort(logicalIndexes.begin(), logicalIndexes.end()); std::sort(logicalIndexes.begin(), logicalIndexes.end());
QList<QPair<int, int>> ret; QList<std::pair<int, int>> ret;
QPair<int, int> current; std::pair<int, int> current;
current.first = -2; // -1 is not enough because -1+1 = 0 current.first = -2; // -1 is not enough because -1+1 = 0
current.second = -2; current.second = -2;
for(int i = 0; i < logicalIndexes.size(); ++i) { for(int i = 0; i < logicalIndexes.size(); ++i) {
@ -3966,8 +3966,8 @@ void QTreeViewPrivate::select(const QModelIndex &topIndex, const QModelIndex &bo
const int top = viewIndex(topIndex), const int top = viewIndex(topIndex),
bottom = viewIndex(bottomIndex); bottom = viewIndex(bottomIndex);
const QList<QPair<int, int>> colRanges = columnRanges(topIndex, bottomIndex); const QList<std::pair<int, int>> colRanges = columnRanges(topIndex, bottomIndex);
QList<QPair<int, int>>::const_iterator it; QList<std::pair<int, int>>::const_iterator it;
for (it = colRanges.begin(); it != colRanges.end(); ++it) { for (it = colRanges.begin(); it != colRanges.end(); ++it) {
const int left = (*it).first, const int left = (*it).first,
right = (*it).second; right = (*it).second;
@ -4018,7 +4018,7 @@ void QTreeViewPrivate::select(const QModelIndex &topIndex, const QModelIndex &bo
q->selectionModel()->select(selection, command); q->selectionModel()->select(selection, command);
} }
QPair<int,int> QTreeViewPrivate::startAndEndColumns(const QRect &rect) const std::pair<int,int> QTreeViewPrivate::startAndEndColumns(const QRect &rect) const
{ {
Q_Q(const QTreeView); Q_Q(const QTreeView);
int start = header->visualIndexAt(rect.left()); int start = header->visualIndexAt(rect.left());
@ -4030,7 +4030,7 @@ QPair<int,int> QTreeViewPrivate::startAndEndColumns(const QRect &rect) const
start = (start == -1 ? 0 : start); start = (start == -1 ? 0 : start);
end = (end == -1 ? header->count() - 1 : end); end = (end == -1 ? header->count() - 1 : end);
} }
return qMakePair(qMin(start, end), qMax(start, end)); return std::pair(qMin(start, end), qMax(start, end));
} }
bool QTreeViewPrivate::hasVisibleChildren(const QModelIndex& parent) const bool QTreeViewPrivate::hasVisibleChildren(const QModelIndex& parent) const

View File

@ -139,11 +139,11 @@ public:
int itemDecorationAt(const QPoint &pos) const; int itemDecorationAt(const QPoint &pos) const;
QRect itemDecorationRect(const QModelIndex &index) const; QRect itemDecorationRect(const QModelIndex &index) const;
QList<QPair<int, int>> columnRanges(const QModelIndex &topIndex, QList<std::pair<int, int>> columnRanges(const QModelIndex &topIndex,
const QModelIndex &bottomIndex) const; const QModelIndex &bottomIndex) const;
void select(const QModelIndex &start, const QModelIndex &stop, QItemSelectionModel::SelectionFlags command); void select(const QModelIndex &start, const QModelIndex &stop, QItemSelectionModel::SelectionFlags command);
QPair<int,int> startAndEndColumns(const QRect &rect) const; std::pair<int,int> startAndEndColumns(const QRect &rect) const;
void updateChildCount(const int parentItem, const int delta); void updateChildCount(const int parentItem, const int delta);
@ -185,7 +185,7 @@ public:
bool customIndent; bool customIndent;
// used for drawing // used for drawing
mutable QPair<int,int> leftAndRight; mutable std::pair<int,int> leftAndRight;
mutable int current; mutable int current;
mutable bool spanning; mutable bool spanning;

View File

@ -578,7 +578,7 @@ void QTreeModel::ensureSorted(int column, Qt::SortOrder order,
QList<QTreeWidgetItem*> lst = itm->children; QList<QTreeWidgetItem*> lst = itm->children;
int count = end - start + 1; int count = end - start + 1;
QList<QPair<QTreeWidgetItem *, int>> sorting(count); QList<std::pair<QTreeWidgetItem *, int>> sorting(count);
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
sorting[i].first = lst.at(start + i); sorting[i].first = lst.at(start + i);
sorting[i].second = start + i; sorting[i].second = start + i;
@ -658,8 +658,8 @@ void QTreeModel::ensureSorted(int column, Qt::SortOrder order,
Used by the sorting functions. Used by the sorting functions.
*/ */
bool QTreeModel::itemLessThan(const QPair<QTreeWidgetItem*,int> &left, bool QTreeModel::itemLessThan(const std::pair<QTreeWidgetItem*,int> &left,
const QPair<QTreeWidgetItem*,int> &right) const std::pair<QTreeWidgetItem*,int> &right)
{ {
return *(left.first) < *(right.first); return *(left.first) < *(right.first);
} }
@ -673,8 +673,8 @@ bool QTreeModel::itemLessThan(const QPair<QTreeWidgetItem*,int> &left,
Used by the sorting functions. Used by the sorting functions.
*/ */
bool QTreeModel::itemGreaterThan(const QPair<QTreeWidgetItem*,int> &left, bool QTreeModel::itemGreaterThan(const std::pair<QTreeWidgetItem*,int> &left,
const QPair<QTreeWidgetItem*,int> &right) const std::pair<QTreeWidgetItem*,int> &right)
{ {
return *(right.first) < *(left.first); return *(right.first) < *(left.first);
} }
@ -825,7 +825,7 @@ void QTreeModel::sortItems(QList<QTreeWidgetItem*> *items, int column, Qt::SortO
return; return;
// store the original order of indexes // store the original order of indexes
QList<QPair<QTreeWidgetItem *, int>> sorting(items->size()); QList<std::pair<QTreeWidgetItem *, int>> sorting(items->size());
for (int i = 0; i < sorting.size(); ++i) { for (int i = 0; i < sorting.size(); ++i) {
sorting[i].first = items->at(i); sorting[i].first = items->at(i);
sorting[i].second = i; sorting[i].second = i;

View File

@ -17,7 +17,6 @@
#include <QtWidgets/private/qtwidgetsglobal_p.h> #include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtCore/qabstractitemmodel.h> #include <QtCore/qabstractitemmodel.h>
#include <private/qabstractitemmodel_p.h> #include <private/qabstractitemmodel_p.h>
#include <QtCore/qpair.h>
#include <QtCore/qbasictimer.h> #include <QtCore/qbasictimer.h>
#include <QtWidgets/qtreewidget.h> #include <QtWidgets/qtreewidget.h>
#include <private/qtreeview_p.h> #include <private/qtreeview_p.h>
@ -77,10 +76,10 @@ public:
void sort(int column, Qt::SortOrder order) override; void sort(int column, Qt::SortOrder order) override;
void ensureSorted(int column, Qt::SortOrder order, void ensureSorted(int column, Qt::SortOrder order,
int start, int end, const QModelIndex &parent); int start, int end, const QModelIndex &parent);
static bool itemLessThan(const QPair<QTreeWidgetItem*,int> &left, static bool itemLessThan(const std::pair<QTreeWidgetItem*,int> &left,
const QPair<QTreeWidgetItem*,int> &right); const std::pair<QTreeWidgetItem*,int> &right);
static bool itemGreaterThan(const QPair<QTreeWidgetItem*,int> &left, static bool itemGreaterThan(const std::pair<QTreeWidgetItem*,int> &left,
const QPair<QTreeWidgetItem*,int> &right); const std::pair<QTreeWidgetItem*,int> &right);
static QList<QTreeWidgetItem*>::iterator sortedInsertionIterator( static QList<QTreeWidgetItem*>::iterator sortedInsertionIterator(
const QList<QTreeWidgetItem*>::iterator &begin, const QList<QTreeWidgetItem*>::iterator &begin,
const QList<QTreeWidgetItem*>::iterator &end, const QList<QTreeWidgetItem*>::iterator &end,

View File

@ -3803,8 +3803,8 @@ void QApplicationPrivate::activateImplicitTouchGrab(QWidget *widget, QTouchEvent
bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, const QTouchEvent *te) bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, const QTouchEvent *te)
{ {
QApplicationPrivate *d = self; QApplicationPrivate *d = self;
// TODO get rid of this QPair // TODO get rid of this std::pair
typedef QPair<QEventPoint::State, QList<QEventPoint> > StatesAndTouchPoints; typedef std::pair<QEventPoint::State, QList<QEventPoint> > StatesAndTouchPoints;
QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents; QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents;
const auto *device = te->pointingDevice(); const auto *device = te->pointingDevice();