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
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>
(cherry picked from commit 2b2271bea3f94a72adf73aa04395a6b20c404f0e)
This commit is contained in:
Isak Fyksen 2024-10-17 14:11:12 +02:00 committed by Qt Cherry-pick Bot
parent 92b47c2743
commit 626d129aa9
21 changed files with 134 additions and 131 deletions

View File

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

View File

@ -23,7 +23,7 @@ public:
QWindow *window() const override;
int childCount() 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;
QAccessibleInterface *focusChild() const override;

View File

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

View File

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

View File

@ -83,7 +83,7 @@ public:
QAccessible::Role role() 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;
void *interface_cast(QAccessible::InterfaceType t) override;
@ -103,7 +103,7 @@ public:
QAccessible::Role role() 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;
//QAccessibleActionInterface

View File

@ -179,15 +179,15 @@ public:
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) {
Vertex *from = it.from();
Vertex *to = it.to();
// do not return (from,to) *and* (to,from)
if (std::less<Vertex*>()(from, to))
conns.append(qMakePair(from, to));
conns.emplace_back(from, to);
}
return conns;
}

View File

@ -378,9 +378,9 @@ bool ParallelAnchorData::calculateSizeHints()
0 is at Preferred
1 is at Maximum
*/
static QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> getFactor(qreal value, qreal min,
qreal minPref, qreal pref,
qreal maxPref, qreal max)
static std::pair<QGraphicsAnchorLayoutPrivate::Interval, qreal> getFactor(qreal value, qreal min,
qreal minPref, qreal pref,
qreal maxPref, qreal max)
{
QGraphicsAnchorLayoutPrivate::Interval interval;
qreal lower;
@ -411,10 +411,10 @@ static QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> getFactor(qreal valu
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 lower = 0;
@ -447,11 +447,11 @@ void SequentialAnchorData::updateChildrenSizes()
// Band here refers if the value is in the Minimum To Preferred
// 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);
const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> prefFactor =
const std::pair<QGraphicsAnchorLayoutPrivate::Interval, qreal> prefFactor =
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);
// 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];
QSet<AnchorVertex *> visited;
QStack<QPair<AnchorVertex *, AnchorVertex *> > stack;
stack.push(qMakePair(static_cast<AnchorVertex *>(nullptr), layoutFirstVertex[orientation]));
QStack<std::pair<AnchorVertex *, AnchorVertex *> > stack;
stack.push(std::pair(static_cast<AnchorVertex *>(nullptr), layoutFirstVertex[orientation]));
QList<AnchorVertex *> candidates;
// Walk depth-first, in the stack we store start of the candidate sequence (beforeSequence)
// and the vertex to be visited.
while (!stack.isEmpty()) {
QPair<AnchorVertex *, AnchorVertex *> pair = stack.pop();
std::pair<AnchorVertex *, AnchorVertex *> pair = stack.pop();
AnchorVertex *beforeSequence = pair.first;
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,
// since we are keeping the candidates list.
if (endOfSequence)
stack.push(qMakePair(v, next));
stack.push(std::pair(v, next));
else
stack.push(qMakePair(beforeSequence, next));
stack.push(std::pair(beforeSequence, next));
}
visited.insert(v);
@ -1212,7 +1212,7 @@ void QGraphicsAnchorLayoutPrivate::restoreSimplifiedGraph(Qt::Orientation orient
// Restore anchor simplification
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) {
AnchorVertex *v1 = connections.at(i).first;
AnchorVertex *v2 = connections.at(i).second;
@ -1764,12 +1764,12 @@ void QGraphicsAnchorLayoutPrivate::removeAnchor(AnchorVertex *firstVertex,
bool keepFirstItem = false;
bool keepSecondItem = false;
QPair<AnchorVertex *, int> v;
std::pair<AnchorVertex *, int> v;
int refcount = -1;
if (firstItem != q) {
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 (i == Qt::AnchorHorizontalCenter || i == Qt::AnchorVerticalCenter)
refcount = 2;
@ -1787,7 +1787,7 @@ void QGraphicsAnchorLayoutPrivate::removeAnchor(AnchorVertex *firstVertex,
if (secondItem != q) {
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 (i == Qt::AnchorHorizontalCenter || i == Qt::AnchorVerticalCenter)
refcount = 2;
@ -1835,8 +1835,8 @@ void QGraphicsAnchorLayoutPrivate::removeAnchor_helper(AnchorVertex *v1, AnchorV
AnchorVertex *QGraphicsAnchorLayoutPrivate::addInternalVertex(QGraphicsLayoutItem *item,
Qt::AnchorPoint edge)
{
QPair<QGraphicsLayoutItem *, Qt::AnchorPoint> pair(item, edge);
QPair<AnchorVertex *, int> v = m_vertexList.value(pair);
std::pair<QGraphicsLayoutItem *, Qt::AnchorPoint> pair(item, edge);
std::pair<AnchorVertex *, int> v = m_vertexList.value(pair);
if (!v.first) {
Q_ASSERT(v.second == 0);
@ -1856,8 +1856,8 @@ AnchorVertex *QGraphicsAnchorLayoutPrivate::addInternalVertex(QGraphicsLayoutIte
void QGraphicsAnchorLayoutPrivate::removeInternalVertex(QGraphicsLayoutItem *item,
Qt::AnchorPoint edge)
{
QPair<QGraphicsLayoutItem *, Qt::AnchorPoint> pair(item, edge);
QPair<AnchorVertex *, int> v = m_vertexList.value(pair);
std::pair<QGraphicsLayoutItem *, Qt::AnchorPoint> pair(item, edge);
std::pair<AnchorVertex *, int> v = m_vertexList.value(pair);
if (!v.first) {
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)
{
Graph<AnchorVertex, AnchorData> &g = graph[orientation];
QList<QPair<AnchorVertex *, AnchorVertex *>> vertices = g.connections();
QList<std::pair<AnchorVertex *, AnchorVertex *>> vertices = g.connections();
QLayoutStyleInfo styleInf = styleInfo();
for (int i = 0; i < vertices.size(); ++i) {
@ -2255,7 +2255,7 @@ void QGraphicsAnchorLayoutPrivate::refreshAllSizeHints(Qt::Orientation orientati
*/
void QGraphicsAnchorLayoutPrivate::findPaths(Qt::Orientation orientation)
{
QQueue<QPair<AnchorVertex *, AnchorVertex *> > queue;
QQueue<std::pair<AnchorVertex *, AnchorVertex *> > queue;
QSet<AnchorData *> visited;
@ -2265,10 +2265,10 @@ void QGraphicsAnchorLayoutPrivate::findPaths(Qt::Orientation orientation)
const auto adjacentVertices = graph[orientation].adjacentVertices(root);
for (AnchorVertex *v : adjacentVertices)
queue.enqueue(qMakePair(root, v));
queue.enqueue(std::pair(root, v));
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);
if (visited.contains(edge))
@ -2286,7 +2286,7 @@ void QGraphicsAnchorLayoutPrivate::findPaths(Qt::Orientation orientation)
const auto adjacentVertices = graph[orientation].adjacentVertices(pair.second);
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.
@ -2327,7 +2327,7 @@ void QGraphicsAnchorLayoutPrivate::constraintsFromPaths(Qt::Orientation orientat
void QGraphicsAnchorLayoutPrivate::updateAnchorSizes(Qt::Orientation 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) {
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)
{
QQueue<QPair<AnchorVertex *, AnchorVertex *> > queue;
QQueue<std::pair<AnchorVertex *, AnchorVertex *> > queue;
QSet<AnchorVertex *> visited;
// Get root vertex
@ -2634,14 +2634,14 @@ void QGraphicsAnchorLayoutPrivate::calculateVertexPositions(Qt::Orientation orie
// Add initial edges to the queue
const auto adjacentVertices = graph[orientation].adjacentVertices(root);
for (AnchorVertex *v : adjacentVertices)
queue.enqueue(qMakePair(root, v));
queue.enqueue(std::pair(root, v));
// Do initial calculation required by "interpolateEdge()"
setupEdgesInterpolation(orientation);
// Traverse the graph and calculate vertex positions
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);
if (visited.contains(pair.second))
@ -2653,7 +2653,7 @@ void QGraphicsAnchorLayoutPrivate::calculateVertexPositions(Qt::Orientation orie
QList<AnchorVertex *> adjacents = graph[orientation].adjacentVertices(pair.second);
for (int i = 0; i < adjacents.size(); ++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;
current = (orientation == Qt::Horizontal) ? q->contentsRect().width() : q->contentsRect().height();
QPair<Interval, qreal> result;
std::pair<Interval, qreal> result;
result = getFactor(current,
sizeHints[orientation][Qt::MinimumSize],
sizeHints[orientation][Qt::PreferredSize],
@ -2703,8 +2703,8 @@ void QGraphicsAnchorLayoutPrivate::setupEdgesInterpolation(
void QGraphicsAnchorLayoutPrivate::interpolateEdge(AnchorVertex *base, AnchorData *edge)
{
const Qt::Orientation orientation = edge->isVertical ? Qt::Vertical : Qt::Horizontal;
const QPair<Interval, qreal> factor(interpolationInterval[orientation],
interpolationProgress[orientation]);
const std::pair<Interval, qreal> factor(interpolationInterval[orientation],
interpolationProgress[orientation]);
qreal edgeDistance = interpolate(factor, edge->sizeAtMinimum, edge->sizeAtPreferred,
edge->sizeAtPreferred, edge->sizeAtPreferred,
@ -2761,7 +2761,7 @@ bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList<QSimplexConstraint *>
}
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)
{
QSimplexVariable *slack = new QSimplexVariable;
@ -2772,7 +2772,7 @@ static QPair<QSimplexVariable *, QSimplexConstraint *> createSlack(QSimplexConst
limit->ratio = QSimplexConstraint::LessOrEqual;
limit->constant = interval;
return qMakePair(slack, limit);
return std::pair(slack, limit);
}
bool QGraphicsAnchorLayoutPrivate::solvePreferred(const QList<QSimplexConstraint *> &constraints,
@ -2815,7 +2815,7 @@ bool QGraphicsAnchorLayoutPrivate::solvePreferred(const QList<QSimplexConstraint
sizeConstraint->constant = ad->prefSize + g_offset;
// Can easily shrink
QPair<QSimplexVariable *, QSimplexConstraint *> slack;
std::pair<QSimplexVariable *, QSimplexConstraint *> slack;
const qreal softShrinkInterval = ad->prefSize - ad->minPrefSize;
if (softShrinkInterval) {
slack = createSlack(sizeConstraint, softShrinkInterval, Shrinker);

View File

@ -475,14 +475,14 @@ public:
void identifyFloatItems(const QSet<AnchorData *> &visited, Qt::Orientation orientation);
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;
}
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)
@ -528,7 +528,7 @@ public:
// Mapping between high level anchorage points (Item, Edge) to low level
// 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
QHVContainer<Graph<AnchorVertex, AnchorData>> graph;

View File

@ -50,7 +50,6 @@
#include <QtCore/qtimeline.h>
#include <QtCore/qpoint.h>
#include <QtCore/qpointer.h>
#include <QtCore/qpair.h>
#include <algorithm>
@ -248,13 +247,14 @@ void QGraphicsItemAnimation::setPosAt(qreal step, const QPointF &pos)
\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();
list.reserve(xPosCount);
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;
}
@ -306,13 +306,13 @@ void QGraphicsItemAnimation::setRotationAt(qreal step, qreal angle)
\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();
list.reserve(numRotations);
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;
}
@ -356,13 +356,14 @@ void QGraphicsItemAnimation::setTranslationAt(qreal step, qreal dx, qreal dy)
\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();
list.reserve(numTranslations);
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;
}
@ -407,13 +408,15 @@ void QGraphicsItemAnimation::setScaleAt(qreal step, qreal sx, qreal sy)
\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();
list.reserve(numScales);
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;
}
@ -457,13 +460,15 @@ void QGraphicsItemAnimation::setShearAt(qreal step, qreal sh, qreal sv)
\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();
list.reserve(numShears);
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;
}

View File

@ -31,28 +31,28 @@ public:
void setTimeLine(QTimeLine *timeLine);
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);
QTransform transformAt(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);
qreal xTranslationAt(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);
qreal verticalScaleAt(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);
qreal verticalShearAt(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 clear();

View File

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

View File

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

View File

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

View File

@ -77,10 +77,10 @@ public:
void sort(int column, Qt::SortOrder order) override;
void ensureSorted(int column, Qt::SortOrder order, int start, int end);
static bool itemLessThan(const QPair<QListWidgetItem*,int> &left,
const QPair<QListWidgetItem*,int> &right);
static bool itemGreaterThan(const QPair<QListWidgetItem*,int> &left,
const QPair<QListWidgetItem*,int> &right);
static bool itemLessThan(const std::pair<QListWidgetItem*,int> &left,
const std::pair<QListWidgetItem*,int> &right);
static bool itemGreaterThan(const std::pair<QListWidgetItem*,int> &left,
const std::pair<QListWidgetItem*,int> &right);
static QList<QListWidgetItem*>::iterator sortedInsertionIterator(
const QList<QListWidgetItem*>::iterator &begin,
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)
{
QList<QPair<QTableWidgetItem *, int>> sortable;
QList<std::pair<QTableWidgetItem *, int>> sortable;
QList<int> unsortable;
const int numRows = rowCount();
@ -505,7 +505,7 @@ void QTableModel::sort(int column, Qt::SortOrder order)
for (int row = 0; row < numRows; ++row) {
if (QTableWidgetItem *itm = item(row, column))
sortable.append(QPair<QTableWidgetItem*,int>(itm, row));
sortable.emplace_back(itm, row);
else
unsortable.append(row);
}
@ -549,7 +549,7 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order,
int start, int end)
{
int count = end - start + 1;
QList<QPair<QTableWidgetItem *, int>> sorting;
QList<std::pair<QTableWidgetItem *, int>> sorting;
sorting.reserve(count);
for (int row = start; row <= end; ++row) {
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)
break;
}
sorting.append(QPair<QTableWidgetItem*,int>(itm, row));
sorting.emplace_back(itm, row);
}
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());
}
bool QTableModel::itemLessThan(const QPair<QTableWidgetItem*,int> &left,
const QPair<QTableWidgetItem*,int> &right)
bool QTableModel::itemLessThan(const std::pair<QTableWidgetItem*,int> &left,
const std::pair<QTableWidgetItem*,int> &right)
{
return *(left.first) < *(right.first);
}
bool QTableModel::itemGreaterThan(const QPair<QTableWidgetItem*,int> &left,
const QPair<QTableWidgetItem*,int> &right)
bool QTableModel::itemGreaterThan(const std::pair<QTableWidgetItem*,int> &left,
const std::pair<QTableWidgetItem*,int> &right)
{
return (*(right.first) < *(left .first));
}

View File

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

View File

@ -2778,10 +2778,10 @@ void QTreeView::expandRecursively(const QModelIndex &index, int depth)
expand(index);
if (depth == 0)
return;
QStack<QPair<QModelIndex, int>> parents;
QStack<std::pair<QModelIndex, int>> parents;
parents.push({index, 0});
while (!parents.isEmpty()) {
const QPair<QModelIndex, int> elem = parents.pop();
const std::pair<QModelIndex, int> elem = parents.pop();
const QModelIndex &parent = elem.first;
const int curDepth = elem.second;
const int rowCount = d->model->rowCount(parent);
@ -3933,8 +3933,8 @@ QRect QTreeViewPrivate::itemDecorationRect(const QModelIndex &index) const
return q->style()->subElementRect(QStyle::SE_TreeViewDisclosureItem, &opt, q);
}
QList<QPair<int, int>> QTreeViewPrivate::columnRanges(const QModelIndex &topIndex,
const QModelIndex &bottomIndex) const
QList<std::pair<int, int>> QTreeViewPrivate::columnRanges(const QModelIndex &topIndex,
const QModelIndex &bottomIndex) const
{
const int topVisual = header->visualIndex(topIndex.column()),
bottomVisual = header->visualIndex(bottomIndex.column());
@ -3954,8 +3954,8 @@ QList<QPair<int, int>> QTreeViewPrivate::columnRanges(const QModelIndex &topInde
//let's sort the list
std::sort(logicalIndexes.begin(), logicalIndexes.end());
QList<QPair<int, int>> ret;
QPair<int, int> current;
QList<std::pair<int, int>> ret;
std::pair<int, int> current;
current.first = -2; // -1 is not enough because -1+1 = 0
current.second = -2;
for(int i = 0; i < logicalIndexes.size(); ++i) {
@ -3988,8 +3988,8 @@ void QTreeViewPrivate::select(const QModelIndex &topIndex, const QModelIndex &bo
const int top = viewIndex(topIndex),
bottom = viewIndex(bottomIndex);
const QList<QPair<int, int>> colRanges = columnRanges(topIndex, bottomIndex);
QList<QPair<int, int>>::const_iterator it;
const QList<std::pair<int, int>> colRanges = columnRanges(topIndex, bottomIndex);
QList<std::pair<int, int>>::const_iterator it;
for (it = colRanges.begin(); it != colRanges.end(); ++it) {
const int left = (*it).first,
right = (*it).second;
@ -4040,7 +4040,7 @@ void QTreeViewPrivate::select(const QModelIndex &topIndex, const QModelIndex &bo
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);
int start = header->visualIndexAt(rect.left());
@ -4052,7 +4052,7 @@ QPair<int,int> QTreeViewPrivate::startAndEndColumns(const QRect &rect) const
start = (start == -1 ? 0 : start);
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

View File

@ -137,11 +137,11 @@ public:
int itemDecorationAt(const QPoint &pos) 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;
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);
@ -183,7 +183,7 @@ public:
bool customIndent;
// used for drawing
mutable QPair<int,int> leftAndRight;
mutable std::pair<int,int> leftAndRight;
mutable int current;
mutable bool spanning;

View File

@ -581,7 +581,7 @@ void QTreeModel::ensureSorted(int column, Qt::SortOrder order,
QList<QTreeWidgetItem*> lst = itm->children;
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) {
sorting[i].first = lst.at(start + i);
sorting[i].second = start + i;
@ -661,8 +661,8 @@ void QTreeModel::ensureSorted(int column, Qt::SortOrder order,
Used by the sorting functions.
*/
bool QTreeModel::itemLessThan(const QPair<QTreeWidgetItem*,int> &left,
const QPair<QTreeWidgetItem*,int> &right)
bool QTreeModel::itemLessThan(const std::pair<QTreeWidgetItem*,int> &left,
const std::pair<QTreeWidgetItem*,int> &right)
{
return *(left.first) < *(right.first);
}
@ -676,8 +676,8 @@ bool QTreeModel::itemLessThan(const QPair<QTreeWidgetItem*,int> &left,
Used by the sorting functions.
*/
bool QTreeModel::itemGreaterThan(const QPair<QTreeWidgetItem*,int> &left,
const QPair<QTreeWidgetItem*,int> &right)
bool QTreeModel::itemGreaterThan(const std::pair<QTreeWidgetItem*,int> &left,
const std::pair<QTreeWidgetItem*,int> &right)
{
return *(right.first) < *(left.first);
}
@ -826,7 +826,7 @@ void QTreeModel::sortItems(QList<QTreeWidgetItem*> *items, int column, Qt::SortO
return;
// 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) {
sorting[i].first = items->at(i);
sorting[i].second = i;

View File

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

View File

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