Port from qAsConst() to std::as_const()

We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace, with manual
unstaging of the actual definition and documentation in dist/,
src/corelib/doc/ and src/corelib/global/.

Task-number: QTBUG-99313
Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
Marc Mutz 2022-10-06 11:08:21 +02:00
parent fd2685c2f0
commit aa37e67ef7
263 changed files with 670 additions and 670 deletions

View File

@ -703,7 +703,7 @@ int main(int argc, char *argv[])
QStringList files = parser.positionalArguments();
if (files.isEmpty())
files << "-";
for (const QString &file : qAsConst(files)) {
for (const QString &file : std::as_const(files)) {
QFile f(file);
if (file == "-" ? f.open(stdin, QIODevice::ReadOnly) : f.open(QIODevice::ReadOnly)) {
if (files.size() > 1)

View File

@ -31,7 +31,7 @@ int main(int argc, char *argv[])
QStringList inputFormats;
QStringList outputFormats;
for (Converter *conv : qAsConst(*availableConverters)) {
for (Converter *conv : std::as_const(*availableConverters)) {
auto direction = conv->directions();
QString name = conv->name();
if (direction & Converter::In)
@ -82,7 +82,7 @@ int main(int argc, char *argv[])
if (parser.isSet(formatOptionsOption)) {
QString format = parser.value(formatOptionsOption);
for (Converter *conv : qAsConst(*availableConverters)) {
for (Converter *conv : std::as_const(*availableConverters)) {
if (conv->name() == format) {
const char *help = conv->optionsHelp();
if (help)
@ -100,7 +100,7 @@ int main(int argc, char *argv[])
Converter *inconv = nullptr;
QString format = parser.value(inputFormatOption);
if (format != "auto") {
for (Converter *conv : qAsConst(*availableConverters)) {
for (Converter *conv : std::as_const(*availableConverters)) {
if (conv->name() == format) {
inconv = conv;
break;
@ -116,7 +116,7 @@ int main(int argc, char *argv[])
Converter *outconv = nullptr;
format = parser.value(outputFormatOption);
if (format != "auto") {
for (Converter *conv : qAsConst(*availableConverters)) {
for (Converter *conv : std::as_const(*availableConverters)) {
if (conv->name() == format) {
outconv = conv;
break;
@ -155,7 +155,7 @@ int main(int argc, char *argv[])
if (!inconv) {
// probe the input to find a file format
for (Converter *conv : qAsConst(*availableConverters)) {
for (Converter *conv : std::as_const(*availableConverters)) {
if (conv->directions() & Converter::In && conv->probeFile(&input)) {
inconv = conv;
break;
@ -170,7 +170,7 @@ int main(int argc, char *argv[])
if (!outconv) {
// probe the output to find a file format
for (Converter *conv : qAsConst(*availableConverters)) {
for (Converter *conv : std::as_const(*availableConverters)) {
if (conv->directions() & Converter::Out && conv->probeFile(&output)) {
outconv = conv;
break;

View File

@ -109,7 +109,7 @@ void DownloadManager::execute()
return;
}
for (const QString &arg : qAsConst(args)) {
for (const QString &arg : std::as_const(args)) {
QUrl url = QUrl::fromEncoded(arg.toLocal8Bit());
doDownload(url);
}

View File

@ -24,7 +24,7 @@ void Client::sendMessage(const QString &message)
if (message.isEmpty())
return;
for (Connection *connection : qAsConst(peers))
for (Connection *connection : std::as_const(peers))
connection->sendMessage(message);
}

View File

@ -78,7 +78,7 @@ void PeerManager::sendBroadcastDatagram()
}
bool validBroadcastAddresses = true;
for (const QHostAddress &address : qAsConst(broadcastAddresses)) {
for (const QHostAddress &address : std::as_const(broadcastAddresses)) {
if (broadcastSocket.writeDatagram(datagram, address,
broadcastPort) == -1)
validBroadcastAddresses = false;

View File

@ -30,7 +30,7 @@ FileManager::~FileManager()
cond.wakeOne();
wait();
for (QFile *file : qAsConst(files)) {
for (QFile *file : std::as_const(files)) {
file->close();
delete file;
}
@ -391,7 +391,7 @@ void FileManager::verifyFileContents()
}
// Verify all pending pieces
for (int index : qAsConst(newPendingVerificationRequests))
for (int index : std::as_const(newPendingVerificationRequests))
emit pieceVerified(index, verifySinglePiece(index));
}

View File

@ -311,7 +311,7 @@ bool MainWindow::addTorrent(const QString &fileName, const QString &destinationF
const QByteArray &resumeState)
{
// Check if the torrent is already being downloaded.
for (const Job &job : qAsConst(jobs)) {
for (const Job &job : std::as_const(jobs)) {
if (job.torrentFileName == fileName && job.destinationDirectory == destinationFolder) {
QMessageBox::warning(this, tr("Already downloading"),
tr("The torrent file %1 is "
@ -644,7 +644,7 @@ void MainWindow::closeEvent(QCloseEvent *)
// them to signal that they have stopped.
jobsToStop = 0;
jobsStopped = 0;
for (const Job &job : qAsConst(jobs)) {
for (const Job &job : std::as_const(jobs)) {
++jobsToStop;
TorrentClient *client = job.client;
client->disconnect();

View File

@ -33,7 +33,7 @@ void RateController::removeSocket(PeerWireClient *socket)
void RateController::setDownloadLimit(int bytesPerSecond)
{
downLimit = bytesPerSecond;
for (PeerWireClient *socket : qAsConst(sockets))
for (PeerWireClient *socket : std::as_const(sockets))
socket->setReadBufferSize(downLimit * 4);
}
@ -63,7 +63,7 @@ void RateController::transfer()
}
QSet<PeerWireClient *> pendingSockets;
for (PeerWireClient *client : qAsConst(sockets)) {
for (PeerWireClient *client : std::as_const(sockets)) {
if (client->canTransferMore())
pendingSockets << client;
}

View File

@ -416,7 +416,7 @@ void TorrentClient::stop()
}
// Abort all existing connections
for (PeerWireClient *client : qAsConst(d->connections)) {
for (PeerWireClient *client : std::as_const(d->connections)) {
RateController::instance()->removeSocket(client);
ConnectionManager::instance()->removeConnection(client);
client->abort();
@ -439,7 +439,7 @@ void TorrentClient::setPaused(bool paused)
// connections to 0. Keep the list of peers, so we can quickly
// resume later.
d->setState(Paused);
for (PeerWireClient *client : qAsConst(d->connections))
for (PeerWireClient *client : std::as_const(d->connections))
client->abort();
d->connections.clear();
TorrentServer::instance()->removeClient(this);
@ -574,7 +574,7 @@ void TorrentClient::pieceVerified(int pieceIndex, bool ok)
}
// Update the peer list so we know who's still interesting.
for (TorrentPeer *peer : qAsConst(d->peers)) {
for (TorrentPeer *peer : std::as_const(d->peers)) {
if (!peer->interesting)
continue;
bool interesting = false;
@ -594,7 +594,7 @@ void TorrentClient::pieceVerified(int pieceIndex, bool ok)
d->incompletePieces.clearBit(pieceIndex);
// Notify connected peers.
for (PeerWireClient *client : qAsConst(d->connections)) {
for (PeerWireClient *client : std::as_const(d->connections)) {
if (client->state() == QAbstractSocket::ConnectedState
&& !client->availablePieces().testBit(pieceIndex)) {
client->sendPieceNotification(pieceIndex);
@ -672,9 +672,9 @@ QList<TorrentPeer *> TorrentClient::weighedFreePeers() const
qint64 now = QDateTime::currentSecsSinceEpoch();
QList<TorrentPeer *> freePeers;
QMap<QString, int> connectionsPerPeer;
for (TorrentPeer *peer : qAsConst(d->peers)) {
for (TorrentPeer *peer : std::as_const(d->peers)) {
bool busy = false;
for (PeerWireClient *client : qAsConst(d->connections)) {
for (PeerWireClient *client : std::as_const(d->connections)) {
if (client->state() == PeerWireClient::ConnectedState
&& client->peerAddress() == peer->address
&& client->peerPort() == peer->port) {
@ -694,7 +694,7 @@ QList<TorrentPeer *> TorrentClient::weighedFreePeers() const
// Assign points based on connection speed and pieces available.
QList<QPair<int, TorrentPeer *> > points;
for (TorrentPeer *peer : qAsConst(freePeers)) {
for (TorrentPeer *peer : std::as_const(freePeers)) {
int tmp = 0;
if (peer->interesting) {
tmp += peer->numCompletedPieces;
@ -717,7 +717,7 @@ QList<TorrentPeer *> TorrentClient::weighedFreePeers() const
QMultiMap<int, TorrentPeer *> pointMap;
int lowestScore = 0;
int lastIndex = 0;
for (const PointPair &point : qAsConst(points)) {
for (const PointPair &point : std::as_const(points)) {
if (point.first > lowestScore) {
lowestScore = point.first;
++lastIndex;
@ -768,7 +768,7 @@ void TorrentClient::setupOutgoingConnection()
PeerWireClient *client = qobject_cast<PeerWireClient *>(sender());
// Update connection statistics.
for (TorrentPeer *peer : qAsConst(d->peers)) {
for (TorrentPeer *peer : std::as_const(d->peers)) {
if (peer->port == client->peerPort() && peer->address == client->peerAddress()) {
peer->connectTime = peer->lastVisited - peer->connectStart;
break;
@ -1040,7 +1040,7 @@ void TorrentClient::scheduleUploads()
// no use in unchoking them.
QList<PeerWireClient *> allClients = d->connections;
QList<QPair<qint64, PeerWireClient *>> transferSpeeds;
for (PeerWireClient *client : qAsConst(allClients)) {
for (PeerWireClient *client : std::as_const(allClients)) {
if (client->state() == QAbstractSocket::ConnectedState
&& client->availablePieces().count(true) != d->pieceCount) {
if (d->state == Seeding) {
@ -1098,7 +1098,7 @@ void TorrentClient::scheduleDownloads()
// Check what each client is doing, and assign payloads to those
// who are either idle or done.
for (PeerWireClient *client : qAsConst(d->connections))
for (PeerWireClient *client : std::as_const(d->connections))
schedulePieceForClient(client);
}
@ -1177,7 +1177,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
incompletePiecesAvailableToClient &= client->availablePieces();
// Remove all pieces that this client has already requested.
for (int i : qAsConst(currentPieces))
for (int i : std::as_const(currentPieces))
incompletePiecesAvailableToClient.clearBit(i);
// Only continue if more pieces can be scheduled. If no pieces
@ -1213,7 +1213,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
memset(occurrences, 0, d->pieceCount * sizeof(int));
// Count how many of each piece are available.
for (PeerWireClient *peer : qAsConst(d->connections)) {
for (PeerWireClient *peer : std::as_const(d->connections)) {
QBitArray peerPieces = peer->availablePieces();
int peerPiecesSize = peerPieces.size();
for (int i = 0; i < peerPiecesSize; ++i) {
@ -1311,7 +1311,7 @@ void TorrentClient::requestMore(PeerWireClient *client)
// Starting with the first piece that we're waiting for, request
// blocks until the quota is filled up.
for (TorrentPiece *piece : qAsConst(piecesInProgress)) {
for (TorrentPiece *piece : std::as_const(piecesInProgress)) {
numBlocksInProgress += requestBlocks(client, piece, maxInProgress - numBlocksInProgress);
if (numBlocksInProgress == maxInProgress)
break;
@ -1414,7 +1414,7 @@ void TorrentClient::addToPeerList(const QList<TorrentPeer> &peerList)
}
bool known = false;
for (const TorrentPeer *knownPeer : qAsConst(d->peers)) {
for (const TorrentPeer *knownPeer : std::as_const(d->peers)) {
if (knownPeer->port == peer.port
&& knownPeer->address == peer.address) {
known = true;
@ -1445,7 +1445,7 @@ void TorrentClient::addToPeerList(const QList<TorrentPeer> &peerList)
const auto firstNInactivePeers = [&tooMany, this] (TorrentPeer *peer) {
if (!tooMany)
return false;
for (const PeerWireClient *client : qAsConst(d->connections)) {
for (const PeerWireClient *client : std::as_const(d->connections)) {
if (client->peer() == peer && (client->downloadSpeed() + client->uploadSpeed()) > 1024)
return false;
}

View File

@ -55,7 +55,7 @@ void TorrentServer::removeClient()
void TorrentServer::processInfoHash(const QByteArray &infoHash)
{
PeerWireClient *peer = qobject_cast<PeerWireClient *>(sender());
for (TorrentClient *client : qAsConst(clients)) {
for (TorrentClient *client : std::as_const(clients)) {
if (client->state() >= TorrentClient::Searching && client->infoHash() == infoHash) {
peer->disconnect(peer, nullptr, this, nullptr);
client->setupIncomingConnection(peer);

View File

@ -345,7 +345,7 @@ void Widget::renderWindowReady()
QList<QByteArray> extensionList = context->extensions().values();
std::sort(extensionList.begin(), extensionList.end());
m_extensions->append(tr("Found %1 extensions:").arg(extensionList.count()));
for (const QByteArray &ext : qAsConst(extensionList))
for (const QByteArray &ext : std::as_const(extensionList))
m_extensions->append(QString::fromLatin1(ext));
m_output->moveCursor(QTextCursor::Start);

View File

@ -358,7 +358,7 @@ void GLWidget::paintGL()
painter.endNativePainting();
if (m_showBubbles) {
for (Bubble *bubble : qAsConst(m_bubbles))
for (Bubble *bubble : std::as_const(m_bubbles))
bubble->drawBubble(&painter);
}
@ -371,7 +371,7 @@ void GLWidget::paintGL()
painter.end();
for (Bubble *bubble : qAsConst(m_bubbles))
for (Bubble *bubble : std::as_const(m_bubbles))
bubble->move(rect());
if (!(m_frames % 100)) {

View File

@ -133,7 +133,7 @@ void MainWindow::timerUsageChanged(bool enabled)
m_timer->start();
} else {
m_timer->stop();
for (QOpenGLWidget *w : qAsConst(m_glWidgets))
for (QOpenGLWidget *w : std::as_const(m_glWidgets))
w->update();
}
}

View File

@ -52,7 +52,7 @@ void DialogOptionsWidget::addSpacer()
int DialogOptionsWidget::value() const
{
int result = 0;
for (const CheckBoxEntry &checkboxEntry : qAsConst(checkBoxEntries)) {
for (const CheckBoxEntry &checkboxEntry : std::as_const(checkBoxEntries)) {
if (checkboxEntry.first->isChecked())
result |= checkboxEntry.second;
}

View File

@ -105,7 +105,7 @@ void DiagramItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
QVariant DiagramItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemPositionChange) {
for (Arrow *arrow : qAsConst(arrows))
for (Arrow *arrow : std::as_const(arrows))
arrow->updatePosition();
}

View File

@ -87,7 +87,7 @@ void MainWindow::buttonGroupClicked(QAbstractButton *button)
void MainWindow::deleteItem()
{
QList<QGraphicsItem *> selectedItems = scene->selectedItems();
for (QGraphicsItem *item : qAsConst(selectedItems)) {
for (QGraphicsItem *item : std::as_const(selectedItems)) {
if (item->type() == Arrow::Type) {
scene->removeItem(item);
Arrow *arrow = qgraphicsitem_cast<Arrow *>(item);
@ -98,7 +98,7 @@ void MainWindow::deleteItem()
}
selectedItems = scene->selectedItems();
for (QGraphicsItem *item : qAsConst(selectedItems)) {
for (QGraphicsItem *item : std::as_const(selectedItems)) {
if (item->type() == DiagramItem::Type)
qgraphicsitem_cast<DiagramItem *>(item)->removeArrows();
scene->removeItem(item);

View File

@ -123,11 +123,11 @@ void GraphWidget::timerEvent(QTimerEvent *event)
nodes << node;
}
for (Node *node : qAsConst(nodes))
for (Node *node : std::as_const(nodes))
node->calculateForces();
bool itemsMoved = false;
for (Node *node : qAsConst(nodes)) {
for (Node *node : std::as_const(nodes)) {
if (node->advancePosition())
itemsMoved = true;
}

View File

@ -67,7 +67,7 @@ void Node::calculateForces()
//! [4]
// Now subtract all forces pulling items together
double weight = (edgeList.size() + 1) * 10;
for (const Edge *edge : qAsConst(edgeList)) {
for (const Edge *edge : std::as_const(edgeList)) {
QPointF vec;
if (edge->sourceNode() == this)
vec = mapToItem(edge->destNode(), 0, 0);
@ -148,7 +148,7 @@ QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
{
switch (change) {
case ItemPositionHasChanged:
for (Edge *edge : qAsConst(edgeList))
for (Edge *edge : std::as_const(edgeList))
edge->adjust();
graph->itemMoved();
break;

View File

@ -102,7 +102,7 @@ QSizeF FlowLayout::minSize(const QSizeF &constraint) const
} else if (constraint.height() >= 0) { // width for height?
// not supported
} else {
for (const QGraphicsLayoutItem *item : qAsConst(m_items))
for (const QGraphicsLayoutItem *item : std::as_const(m_items))
size = size.expandedTo(item->effectiveSizeHint(Qt::MinimumSize));
size += QSizeF(left + right, top + bottom);
}
@ -116,7 +116,7 @@ QSizeF FlowLayout::prefSize() const
qreal maxh = 0;
qreal totalWidth = 0;
for (const QGraphicsLayoutItem *item : qAsConst(m_items)) {
for (const QGraphicsLayoutItem *item : std::as_const(m_items)) {
if (totalWidth > 0)
totalWidth += spacing(Qt::Horizontal);
QSizeF pref = item->effectiveSizeHint(Qt::PreferredSize);
@ -135,7 +135,7 @@ QSizeF FlowLayout::maxSize() const
{
qreal totalWidth = 0;
qreal totalHeight = 0;
for (const QGraphicsLayoutItem *item : qAsConst(m_items)) {
for (const QGraphicsLayoutItem *item : std::as_const(m_items)) {
if (totalWidth > 0)
totalWidth += spacing(Qt::Horizontal);
if (totalHeight > 0)

View File

@ -164,7 +164,7 @@ void AddressWidget::readFromFile(const QString &fileName)
QMessageBox::information(this, tr("No contacts in file"),
tr("The file you are attempting to open contains no contacts."));
} else {
for (const auto &contact: qAsConst(contacts))
for (const auto &contact: std::as_const(contacts))
addEntry(contact.name, contact.address);
}
}

View File

@ -88,7 +88,7 @@ bool TreeItem::insertColumns(int position, int columns)
for (int column = 0; column < columns; ++column)
itemData.insert(position, QVariant());
for (TreeItem *child : qAsConst(childItems))
for (TreeItem *child : std::as_const(childItems))
child->insertColumns(position, columns);
return true;
@ -123,7 +123,7 @@ bool TreeItem::removeColumns(int position, int columns)
for (int column = 0; column < columns; ++column)
itemData.remove(position);
for (TreeItem *child : qAsConst(childItems))
for (TreeItem *child : std::as_const(childItems))
child->removeColumns(position, columns);
return true;

View File

@ -57,7 +57,7 @@ void Dialog::rotateWidgets()
{
Q_ASSERT(rotatableWidgets.count() % 2 == 0);
for (QWidget *widget : qAsConst(rotatableWidgets))
for (QWidget *widget : std::as_const(rotatableWidgets))
rotatableLayout->removeWidget(widget);
rotatableWidgets.enqueue(rotatableWidgets.dequeue());

View File

@ -108,7 +108,7 @@ QSize FlowLayout::sizeHint() const
QSize FlowLayout::minimumSize() const
{
QSize size;
for (const QLayoutItem *item : qAsConst(itemList))
for (const QLayoutItem *item : std::as_const(itemList))
size = size.expandedTo(item->minimumSize());
const QMargins margins = contentsMargins();
@ -129,7 +129,7 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
//! [9]
//! [10]
for (QLayoutItem *item : qAsConst(itemList)) {
for (QLayoutItem *item : std::as_const(itemList)) {
const QWidget *wid = item->widget();
int spaceX = horizontalSpacing();
if (spaceX == -1)

View File

@ -260,7 +260,7 @@ void MainWindow::printPage(int index, QPainter *painter, QPrinter *printer)
bool italic = item->data(0, Qt::UserRole + 1).toBool();
// Calculate the maximum width and total height of the text.
for (int size : qAsConst(sampleSizes)) {
for (int size : std::as_const(sampleSizes)) {
QFont font(family, size, weight, italic);
font.setStyleName(style);
font = QFont(font, painter->device());
@ -294,7 +294,7 @@ void MainWindow::printPage(int index, QPainter *painter, QPrinter *printer)
bool italic = item->data(0, Qt::UserRole + 1).toBool();
// Draw each line of text.
for (int size : qAsConst(sampleSizes)) {
for (int size : std::as_const(sampleSizes)) {
QFont font(family, size, weight, italic);
font.setStyleName(style);
font = QFont(font, painter->device());

View File

@ -534,7 +534,7 @@ void GradientRenderer::paint(QPainter *p)
g = QConicalGradient(pts.at(0), angle);
}
for (const auto &stop : qAsConst(m_stops))
for (const auto &stop : std::as_const(m_stops))
g.setColorAt(stop.first, stop.second);
g.setSpread(m_spread);

View File

@ -156,7 +156,7 @@ Window::Window()
connect(penColorComboBox, &QComboBox::activated,
this, &Window::penColorChanged);
for (RenderArea *area : qAsConst(renderAreas)) {
for (RenderArea *area : std::as_const(renderAreas)) {
connect(penWidthSpinBox, &QSpinBox::valueChanged,
area, &RenderArea::setPenWidth);
connect(rotationAngleSpinBox, &QSpinBox::valueChanged,
@ -167,7 +167,7 @@ Window::Window()
QGridLayout *topLayout = new QGridLayout;
int i = 0;
for (RenderArea *area : qAsConst(renderAreas)) {
for (RenderArea *area : std::as_const(renderAreas)) {
topLayout->addWidget(area, i / 3, i % 3);
++i;
}
@ -204,7 +204,7 @@ void Window::fillRuleChanged()
{
Qt::FillRule rule = (Qt::FillRule)currentItemData(fillRuleComboBox).toInt();
for (RenderArea *area : qAsConst(renderAreas))
for (RenderArea *area : std::as_const(renderAreas))
area->setFillRule(rule);
}
//! [19]
@ -215,7 +215,7 @@ void Window::fillGradientChanged()
QColor color1 = qvariant_cast<QColor>(currentItemData(fillColor1ComboBox));
QColor color2 = qvariant_cast<QColor>(currentItemData(fillColor2ComboBox));
for (RenderArea *area : qAsConst(renderAreas))
for (RenderArea *area : std::as_const(renderAreas))
area->setFillGradient(color1, color2);
}
//! [20]
@ -225,7 +225,7 @@ void Window::penColorChanged()
{
QColor color = qvariant_cast<QColor>(currentItemData(penColorComboBox));
for (RenderArea *area : qAsConst(renderAreas))
for (RenderArea *area : std::as_const(renderAreas))
area->setPenColor(color);
}
//! [21]

View File

@ -268,7 +268,7 @@ void HoverPoints::paintPoints()
p.setPen(m_pointPen);
p.setBrush(m_pointBrush);
for (const auto &point : qAsConst(m_points)) {
for (const auto &point : std::as_const(m_points)) {
QRectF bounds = pointBoundingRect(point);
if (m_shape == CircleShape)
p.drawEllipse(bounds);

View File

@ -72,7 +72,7 @@ Highlighter::Highlighter(QTextDocument *parent)
//! [7]
void Highlighter::highlightBlock(const QString &text)
{
for (const HighlightingRule &rule : qAsConst(highlightingRules)) {
for (const HighlightingRule &rule : std::as_const(highlightingRules)) {
QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text);
while (matchIterator.hasNext()) {
QRegularExpressionMatch match = matchIterator.next();

View File

@ -153,7 +153,7 @@ void MainWindow::createMenus()
//! [15] //! [16]
{
saveAsMenu = new QMenu(tr("&Save As"), this);
for (QAction *action : qAsConst(saveAsActs))
for (QAction *action : std::as_const(saveAsActs))
saveAsMenu->addAction(action);
fileMenu = new QMenu(tr("&File"), this);

View File

@ -97,7 +97,7 @@ void SortingBox::paintEvent(QPaintEvent * /* event */)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
for (const ShapeItem &shapeItem : qAsConst(shapeItems)) {
for (const ShapeItem &shapeItem : std::as_const(shapeItems)) {
//! [8] //! [9]
painter.translate(shapeItem.position());
//! [9] //! [10]

View File

@ -51,7 +51,7 @@ void parseHtmlFile(QTextStream &out, const QString &fileName)
while (links.size() > 5)
links.removeLast();
for (const QString &link : qAsConst(links))
for (const QString &link : std::as_const(links))
out << " " << link << Qt::endl;
out << Qt::endl << Qt::endl;
}

View File

@ -429,17 +429,17 @@ ProjectBuilderSources::files(QMakeProject *project) const
static QString xcodeFiletypeForFilename(const QString &filename)
{
for (const QString &ext : qAsConst(Option::cpp_ext)) {
for (const QString &ext : std::as_const(Option::cpp_ext)) {
if (filename.endsWith(ext))
return QStringLiteral("sourcecode.cpp.cpp");
}
for (const QString &ext : qAsConst(Option::c_ext)) {
for (const QString &ext : std::as_const(Option::c_ext)) {
if (filename.endsWith(ext))
return QStringLiteral("sourcecode.c.c");
}
for (const QString &ext : qAsConst(Option::h_ext)) {
for (const QString &ext : std::as_const(Option::h_ext)) {
if (filename.endsWith(ext))
return "sourcecode.c.h";
}
@ -1181,13 +1181,13 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
if (copyBundleResources && ((!osx && path.isEmpty())
|| (osx && path == QLatin1String("Contents/Resources")))) {
for (const ProString &s : qAsConst(bundle_files))
for (const ProString &s : std::as_const(bundle_files))
bundle_resources_files << s;
} else if (copyBundleResources && isEmbeddedFramework) {
for (const ProString &s : qAsConst(bundle_files))
for (const ProString &s : std::as_const(bundle_files))
embedded_frameworks << s;
} else if (copyBundleResources && isEmbeddedPlugin) {
for (const ProString &s : qAsConst(bundle_files)) {
for (const ProString &s : std::as_const(bundle_files)) {
ProString subpath = (path == pluginsPrefix) ? ProString() : path.mid(pluginsPrefix.size() + 1);
embedded_plugins[subpath] << s;
}

View File

@ -1031,7 +1031,7 @@ MakefileGenerator::writeProjectMakefile()
//install
t << "install: ";
for (SubTarget *s : qAsConst(targets))
for (SubTarget *s : std::as_const(targets))
t << s->target << '-';
t << "install " << Qt::endl;
@ -1961,7 +1961,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
if (raw_clean.isEmpty())
raw_clean << tmp_out;
QString tmp_clean;
for (const QString &rc : qAsConst(raw_clean))
for (const QString &rc : std::as_const(raw_clean))
tmp_clean += ' ' + escapeFilePath(Option::fixPathToTargetOS(rc));
QString tmp_clean_cmds = project->values(ProKey(*it + ".clean_commands")).join(' ');
if(!tmp_inputs.isEmpty())
@ -1986,7 +1986,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
for (ProStringList::ConstIterator input = tmp_inputs.cbegin(); input != tmp_inputs.cend(); ++input) {
QString tinp = (*input).toQString();
QString out = replaceExtraCompilerVariables(tmp_out, tinp, QString(), NoShell);
for (const QString &rc : qAsConst(raw_clean)) {
for (const QString &rc : std::as_const(raw_clean)) {
dels << ' ' + escapeFilePath(fileFixify(
replaceExtraCompilerVariables(rc, tinp, out, NoShell),
FileFixifyFromOutdir));
@ -1997,7 +1997,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
} else {
QString files;
const int commandlineLimit = 2047; // NT limit, expanded
for (const QString &file : qAsConst(dels)) {
for (const QString &file : std::as_const(dels)) {
if(del_statement.size() + files.size() +
qMax(fixEnvVariables(file).size(), file.size()) > commandlineLimit) {
cleans.append(files);
@ -2263,11 +2263,11 @@ QString MakefileGenerator::buildArgs(bool withExtra)
{
QString ret;
for (const QString &arg : qAsConst(Option::globals->qmake_args))
for (const QString &arg : std::as_const(Option::globals->qmake_args))
ret += " " + shellQuote(arg);
if (withExtra && !Option::globals->qmake_extra_args.isEmpty()) {
ret += " --";
for (const QString &arg : qAsConst(Option::globals->qmake_extra_args))
for (const QString &arg : std::as_const(Option::globals->qmake_extra_args))
ret += " " + shellQuote(arg);
}
return ret;

View File

@ -809,7 +809,7 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
}
}
if(!exists) { //path lookup
for (const QMakeLocalFileName &depdir : qAsConst(depdirs)) {
for (const QMakeLocalFileName &depdir : std::as_const(depdirs)) {
QMakeLocalFileName f(depdir.real() + Option::dir_sep + lfn.real());
QFileInfo fi(findFileInfo(f));
if(fi.exists() && !fi.isDir()) {

View File

@ -14,7 +14,7 @@ QT_BEGIN_NAMESPACE
ProStringList UnixMakefileGenerator::libdirToFlags(const ProKey &key)
{
ProStringList results;
for (const auto &libdir : qAsConst(project->values(key))) {
for (const auto &libdir : std::as_const(project->values(key))) {
if (!project->isEmpty("QMAKE_LFLAGS_RPATH") && project->isActiveConfig("rpath_libdirs"))
project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATH") + libdir;
results.append("-L" + escapeFilePath(libdir));
@ -299,7 +299,7 @@ QStringList
ProStringList pchArchs = project->values("QMAKE_PCH_ARCHS");
if (pchArchs.isEmpty())
pchArchs << ProString(); // normal single-arch PCH
for (const ProString &arch : qAsConst(pchArchs)) {
for (const ProString &arch : std::as_const(pchArchs)) {
auto pfx = header_prefix;
if (!arch.isEmpty())
pfx.replace(QLatin1String("${QMAKE_PCH_ARCH}"), arch.toQString());
@ -337,7 +337,7 @@ QStringList
ProStringList pchArchs = project->values("QMAKE_PCH_ARCHS");
if (pchArchs.isEmpty())
pchArchs << ProString(); // normal single-arch PCH
for (const ProString &arch : qAsConst(pchArchs)) {
for (const ProString &arch : std::as_const(pchArchs)) {
QString precompiledHeader = header_prefix + language + header_suffix;
if (!arch.isEmpty()) {
precompiledHeader.replace(QLatin1String("${QMAKE_PCH_ARCH}"),
@ -392,7 +392,7 @@ UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
libdirs.insert(libidx++, f);
} else if(opt.startsWith("-l")) {
QString lib = opt.mid(2);
for (const QMakeLocalFileName &libdir : qAsConst(libdirs)) {
for (const QMakeLocalFileName &libdir : std::as_const(libdirs)) {
QString libBase = libdir.local() + '/'
+ project->first("QMAKE_PREFIX_SHLIB") + lib;
if (linkPrl && processPrlFile(libBase, true))
@ -418,7 +418,7 @@ UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
frameworkName.truncate(suffixPosition);
opt.remove(suffixMarker); // Apply suffix by removing marker
}
for (const QMakeLocalFileName &dir : qAsConst(frameworkdirs)) {
for (const QMakeLocalFileName &dir : std::as_const(frameworkdirs)) {
auto processPrlIfFound = [&](QString directory) {
QString suffixedPrl = directory + opt;
if (processPrlFile(suffixedPrl, true))

View File

@ -805,7 +805,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
QString icon = fileFixify(var("ICON"));
t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
<< "@sed ";
for (const ProString &arg : qAsConst(commonSedArgs))
for (const ProString &arg : std::as_const(commonSedArgs))
t << arg;
const QString iconName = icon.section(Option::dir_sep, -1);
t << "-e \"s,@ICON@," << iconName << ",g\" "
@ -837,7 +837,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
symlinks[bundle_dir + "Resources"] = "Versions/Current/Resources";
t << "@$(DEL_FILE) " << info_plist_out << "\n\t"
<< "@sed ";
for (const ProString &arg : qAsConst(commonSedArgs))
for (const ProString &arg : std::as_const(commonSedArgs))
t << arg;
t << "-e \"s,@LIBRARY@," << lib_bundle_name << ",g\" "
<< "-e \"s,\\$${EXECUTABLE_NAME}," << lib_bundle_name << ",g\" "
@ -977,7 +977,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
ProStringList pchArchs = project->values("QMAKE_PCH_ARCHS");
if (pchArchs.isEmpty())
pchArchs << ProString(); // normal single-arch PCH
for (const ProString &arch : qAsConst(pchArchs)) {
for (const ProString &arch : std::as_const(pchArchs)) {
ProString pchOutput;
if (!project->isEmpty("PRECOMPILED_DIR"))
pchOutput = project->first("PRECOMPILED_DIR");
@ -1008,7 +1008,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
ProStringList pchArchs = project->values("QMAKE_PCH_ARCHS");
if (pchArchs.isEmpty())
pchArchs << ProString(); // normal single-arch PCH
for (const ProString &arch : qAsConst(pchArchs)) {
for (const ProString &arch : std::as_const(pchArchs)) {
QString file = precomph_out_dir + header_prefix + language + header_suffix;
if (!arch.isEmpty())
file.replace(QStringLiteral("${QMAKE_PCH_ARCH}"), arch.toQString());
@ -1106,7 +1106,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
}
pchFlags.replace(QLatin1String("${QMAKE_PCH_INPUT}"), escapeFilePath(pchInput))
.replace(QLatin1String("${QMAKE_PCH_OUTPUT_BASE}"), escapeFilePath(pchBaseName.toQString()));
for (const ProString &arch : qAsConst(pchArchs)) {
for (const ProString &arch : std::as_const(pchArchs)) {
auto pchArchOutput = pchOutput.toQString();
if (!arch.isEmpty())
pchArchOutput.replace(QStringLiteral("${QMAKE_PCH_ARCH}"), arch.toQString());

View File

@ -191,7 +191,7 @@ void MingwMakefileGenerator::writeIncPart(QTextStream &t)
return;
}
}
for (const ProString &incit: qAsConst(incs)) {
for (const ProString &incit: std::as_const(incs)) {
QString inc = incit.toQString();
inc.replace(QRegularExpression("\\\\$"), "");
inc.replace('\\', '/');

View File

@ -264,9 +264,9 @@ QStringList NmakeMakefileGenerator::sourceFilesForImplicitRulesFilter()
{
QStringList filter;
const QChar wildcard = QLatin1Char('*');
for (const QString &ext : qAsConst(Option::c_ext))
for (const QString &ext : std::as_const(Option::c_ext))
filter << wildcard + ext;
for (const QString &ext : qAsConst(Option::cpp_ext))
for (const QString &ext : std::as_const(Option::cpp_ext))
filter << wildcard + ext;
return filter;
}
@ -314,7 +314,7 @@ void NmakeMakefileGenerator::writeImplicitRulesPart(QTextStream &t)
const QStringList sourceFilesFilter = sourceFilesForImplicitRulesFilter();
QStringList fixifiedSourceDirs = fileFixify(QList<QString>(source_directories.constBegin(), source_directories.constEnd()), FileFixifyAbsolute);
fixifiedSourceDirs.removeDuplicates();
for (const QString &sourceDir : qAsConst(fixifiedSourceDirs)) {
for (const QString &sourceDir : std::as_const(fixifiedSourceDirs)) {
QDirIterator dit(sourceDir, sourceFilesFilter, QDir::Files | QDir::NoDotAndDotDot);
while (dit.hasNext()) {
const QFileInfo fi = dit.nextFileInfo();
@ -339,7 +339,7 @@ void NmakeMakefileGenerator::writeImplicitRulesPart(QTextStream &t)
project->variables().remove("QMAKE_RUN_CXX");
project->variables().remove("QMAKE_RUN_CC");
for (const QString &sourceDir : qAsConst(source_directories)) {
for (const QString &sourceDir : std::as_const(source_directories)) {
if (sourceDir.isEmpty())
continue;
QString objDir = var("OBJECTS_DIR");

View File

@ -2271,7 +2271,7 @@ void VCFilter::modifyPCHstage(QString str)
lines << "* WARNING: All changes made in this file will be lost.";
lines << "--------------------------------------------------------------------*/";
lines << "#include \"" + Project->precompHFilename + "\"";
for (const QString &line : qAsConst(lines))
for (const QString &line : std::as_const(lines))
CustomBuildTool.CommandLine += "echo " + line + ">>" + toFile;
return;
}
@ -2461,7 +2461,7 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info)
// Ensure that none of the output files are also dependencies. Or else, the custom buildstep
// will be rebuild every time, even if nothing has changed.
for (const QString &output : qAsConst(CustomBuildTool.Outputs))
for (const QString &output : std::as_const(CustomBuildTool.Outputs))
CustomBuildTool.AdditionalDependencies.removeAll(output);
useCustomBuildTool = !CustomBuildTool.CommandLine.isEmpty();

View File

@ -349,7 +349,7 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash<QSt
collectedSubdirs.append(qMakePair(tmpdir.toQString(), proj->values(ProKey(tmp_proj_subdirs.at(x) + ".depends"))));
projLookup.insert(tmp_proj_subdirs.at(x).toQString(), tmpdir.toQString());
}
for (const auto &subdir : qAsConst(collectedSubdirs)) {
for (const auto &subdir : std::as_const(collectedSubdirs)) {
QString profile = subdir.first;
QFileInfo fi(fileInfo(Option::normalizePath(profile)));
if (fi.exists()) {

View File

@ -546,7 +546,7 @@ void QMakeEvaluator::populateDeps(
if (depends.isEmpty()) {
rootSet.insert(first(ProKey(prefix + item + priosfx)).toInt(), item);
} else {
for (const ProString &dep : qAsConst(depends)) {
for (const ProString &dep : std::as_const(depends)) {
dset.insert(dep.toKey());
dependees[dep.toKey()] << item;
}
@ -703,7 +703,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
}
case E_NUM_ADD: {
qlonglong sum = 0;
for (const ProString &arg : qAsConst(args)) {
for (const ProString &arg : std::as_const(args)) {
if (arg.contains(QLatin1Char('.'))) {
evalError(fL1S("num_add(): floats are currently not supported."));
goto allfail;
@ -1103,7 +1103,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
rootSet.erase(it);
if ((func_t == E_RESOLVE_DEPENDS) || orgList.contains(item))
ret.prepend(item);
for (const ProString &dep : qAsConst(dependees[item.toKey()])) {
for (const ProString &dep : std::as_const(dependees[item.toKey()])) {
QSet<ProKey> &dset = dependencies[dep.toKey()];
dset.remove(item.toKey());
if (dset.isEmpty())
@ -1114,11 +1114,11 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
}
case E_ENUMERATE_VARS: {
QSet<ProString> keys;
for (const ProValueMap &vmap : qAsConst(m_valuemapStack))
for (const ProValueMap &vmap : std::as_const(m_valuemapStack))
for (ProValueMap::ConstIterator it = vmap.constBegin(); it != vmap.constEnd(); ++it)
keys.insert(it.key());
ret.reserve(keys.size());
for (const ProString &key : qAsConst(keys))
for (const ProString &key : std::as_const(keys))
ret << key;
break; }
case E_SHADOWED: {

View File

@ -1233,7 +1233,7 @@ bool QMakeEvaluator::loadSpec()
qmakespec = m_hostBuild ? QLatin1String("default-host") : QLatin1String("default");
#endif
if (IoUtils::isRelativePath(qmakespec)) {
for (const QString &root : qAsConst(m_mkspecPaths)) {
for (const QString &root : std::as_const(m_mkspecPaths)) {
QString mkspec = root + QLatin1Char('/') + qmakespec;
if (IoUtils::exists(mkspec)) {
qmakespec = mkspec;
@ -1475,7 +1475,7 @@ void QMakeEvaluator::updateMkspecPaths()
for (const QString &it : paths)
ret << it + concat;
for (const QString &it : qAsConst(m_qmakepath))
for (const QString &it : std::as_const(m_qmakepath))
ret << it + concat;
if (!m_buildRoot.isEmpty())
@ -1516,7 +1516,7 @@ void QMakeEvaluator::updateFeaturePaths()
for (const QString &item : items)
feature_bases << (item + mkspecs_concat);
for (const QString &item : qAsConst(m_qmakepath))
for (const QString &item : std::as_const(m_qmakepath))
feature_bases << (item + mkspecs_concat);
if (!m_qmakespec.isEmpty()) {
@ -1538,7 +1538,7 @@ void QMakeEvaluator::updateFeaturePaths()
feature_bases << (m_option->propertyValue(ProKey("QT_HOST_DATA/get")) + mkspecs_concat);
feature_bases << (m_option->propertyValue(ProKey("QT_HOST_DATA/src")) + mkspecs_concat);
for (const QString &fb : qAsConst(feature_bases)) {
for (const QString &fb : std::as_const(feature_bases)) {
const auto sfxs = values(ProKey("QMAKE_PLATFORM"));
for (const ProString &sfx : sfxs)
feature_roots << (fb + features_concat + sfx + QLatin1Char('/'));
@ -1552,7 +1552,7 @@ void QMakeEvaluator::updateFeaturePaths()
feature_roots.removeDuplicates();
QStringList ret;
for (const QString &root : qAsConst(feature_roots))
for (const QString &root : std::as_const(feature_roots))
if (IoUtils::exists(root))
ret << root;
m_featureRoots = new QMakeFeatureRoots(ret);

View File

@ -168,7 +168,7 @@ void QMakeGlobals::commitCommandLineArguments(QMakeCmdLineParserState &state)
{
if (!state.extraargs.isEmpty()) {
QString extra = fL1S("QMAKE_EXTRA_ARGS =");
for (const QString &ea : qAsConst(state.extraargs))
for (const QString &ea : std::as_const(state.extraargs))
extra += QLatin1Char(' ') + QMakeEvaluator::quoteValue(ProString(ea));
state.cmds[QMakeEvalBefore] << extra;
}

View File

@ -27,7 +27,7 @@ ProFileCache::ProFileCache()
ProFileCache::~ProFileCache()
{
for (const Entry &ent : qAsConst(parsed_files))
for (const Entry &ent : std::as_const(parsed_files))
if (ent.pro)
ent.pro->deref();
QMakeVfs::deref();

View File

@ -126,7 +126,7 @@ static int doSed(int argc, char **argv)
}
if (inFiles.isEmpty())
inFiles << "-";
for (const char *inFile : qAsConst(inFiles)) {
for (const char *inFile : std::as_const(inFiles)) {
FILE *f;
if (!strcmp(inFile, "-")) {
f = stdin;

View File

@ -138,7 +138,7 @@ void QMakeProject::dump() const
}
}
out.sort();
for (const QString &v : qAsConst(out))
for (const QString &v : std::as_const(out))
puts(qPrintable(v));
}

View File

@ -143,7 +143,7 @@ int QMakeProperty::queryProperty(const QStringList &optionProperties,
specialProps.append("QMAKE_VERSION");
#endif
specialProps.append("QT_VERSION");
for (const QString &prop : qAsConst(specialProps)) {
for (const QString &prop : std::as_const(specialProps)) {
ProString val = value(ProKey(prop));
ProString pval = value(ProKey(prop + "/raw"));
ProString gval = value(ProKey(prop + "/get"));

View File

@ -25,8 +25,8 @@ template <typename T>
class QForeachContainer {
Q_DISABLE_COPY_MOVE(QForeachContainer)
public:
QForeachContainer(const T &t) : c(t), i(qAsConst(c).begin()), e(qAsConst(c).end()) {}
QForeachContainer(T &&t) : c(std::move(t)), i(qAsConst(c).begin()), e(qAsConst(c).end()) {}
QForeachContainer(const T &t) : c(t), i(std::as_const(c).begin()), e(std::as_const(c).end()) {}
QForeachContainer(T &&t) : c(std::move(t)), i(std::as_const(c).begin()), e(std::as_const(c).end()) {}
T c;
typename T::const_iterator i, e;

View File

@ -54,9 +54,9 @@
\note Since Qt 5.7, the use of this macro is discouraged. It will
be removed in a future version of Qt. Please use C++11 range-for,
possibly with qAsConst(), as needed.
possibly with std::as_const(), as needed.
\sa qAsConst()
\sa std::as_const()
*/
/*!
@ -70,7 +70,7 @@
\note Since Qt 5.7, the use of this macro is discouraged. It will
be removed in a future version of Qt. Please use C++11 range-for,
possibly with qAsConst(), as needed.
possibly with std::as_const(), as needed.
\sa qAsConst()
\sa std::as_const()
*/

View File

@ -223,7 +223,7 @@ QInotifyFileSystemWatcherEngine::QInotifyFileSystemWatcherEngine(int fd, QObject
QInotifyFileSystemWatcherEngine::~QInotifyFileSystemWatcherEngine()
{
notifier.setEnabled(false);
for (int id : qAsConst(pathToID))
for (int id : std::as_const(pathToID))
inotify_rm_watch(inotifyFd, id < 0 ? -id : id);
::close(inotifyFd);

View File

@ -51,7 +51,7 @@ QKqueueFileSystemWatcherEngine::~QKqueueFileSystemWatcherEngine()
notifier.setEnabled(false);
close(kqfd);
for (int id : qAsConst(pathToID))
for (int id : std::as_const(pathToID))
::close(id < 0 ? -id : id);
}

View File

@ -317,9 +317,9 @@ QWindowsFileSystemWatcherEngine::QWindowsFileSystemWatcherEngine(QObject *parent
QWindowsFileSystemWatcherEngine::~QWindowsFileSystemWatcherEngine()
{
for (auto *thread : qAsConst(threads))
for (auto *thread : std::as_const(threads))
thread->stop();
for (auto *thread : qAsConst(threads))
for (auto *thread : std::as_const(threads))
thread->wait();
qDeleteAll(threads);
}
@ -433,7 +433,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths,
// now look for a thread to insert
bool found = false;
for (QWindowsFileSystemWatcherEngineThread *thread : qAsConst(threads)) {
for (QWindowsFileSystemWatcherEngineThread *thread : std::as_const(threads)) {
const auto locker = qt_scoped_lock(thread->mutex);
if (thread->handles.count() < MAXIMUM_WAIT_OBJECTS) {
DEBUG() << "Added handle" << handle.handle << "for" << absolutePath << "to watch" << fileInfo.absoluteFilePath()
@ -586,7 +586,7 @@ QWindowsFileSystemWatcherEngineThread::~QWindowsFileSystemWatcherEngineThread()
CloseHandle(handles.at(0));
handles[0] = INVALID_HANDLE_VALUE;
for (HANDLE h : qAsConst(handles)) {
for (HANDLE h : std::as_const(handles)) {
if (h == INVALID_HANDLE_VALUE)
continue;
FindCloseChangeNotification(h);

View File

@ -1081,16 +1081,16 @@ QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format format,
QStringList paths;
if (!application.isEmpty()) {
paths.reserve(dirs.size() * 2);
for (const auto &dir : qAsConst(dirs))
for (const auto &dir : std::as_const(dirs))
paths.append(dir + u'/' + appFile);
} else {
paths.reserve(dirs.size());
}
for (const auto &dir : qAsConst(dirs))
for (const auto &dir : std::as_const(dirs))
paths.append(dir + u'/' + orgFile);
// Note: No check for existence of files is done intentionally.
for (const auto &path : qAsConst(paths))
for (const auto &path : std::as_const(paths))
confFiles.append(QConfFile::fromName(path, false));
} else
#endif // Q_XDG_PLATFORM && !QT_NO_STANDARDPATHS
@ -1123,7 +1123,7 @@ QConfFileSettingsPrivate::~QConfFileSettingsPrivate()
ConfFileHash *usedHash = usedHashFunc();
ConfFileCache *unusedCache = unusedCacheFunc();
for (auto conf_file : qAsConst(confFiles)) {
for (auto conf_file : std::as_const(confFiles)) {
if (!conf_file->ref.deref()) {
if (conf_file->size == 0) {
delete conf_file;
@ -1197,7 +1197,7 @@ std::optional<QVariant> QConfFileSettingsPrivate::get(const QString &key) const
ParsedSettingsMap::const_iterator j;
bool found = false;
for (auto confFile : qAsConst(confFiles)) {
for (auto confFile : std::as_const(confFiles)) {
const auto locker = qt_scoped_lock(confFile->mutex);
if (!confFile->addedKeys.isEmpty()) {
@ -1226,7 +1226,7 @@ QStringList QConfFileSettingsPrivate::children(const QString &prefix, ChildSpec
QSettingsKey thePrefix(prefix, caseSensitivity);
qsizetype startPos = prefix.size();
for (auto confFile : qAsConst(confFiles)) {
for (auto confFile : std::as_const(confFiles)) {
const auto locker = qt_scoped_lock(confFile->mutex);
if (thePrefix.isEmpty())
@ -1277,7 +1277,7 @@ void QConfFileSettingsPrivate::sync()
// people probably won't be checking the status a whole lot, so in case of
// error we just try to go on and make the best of it
for (auto confFile : qAsConst(confFiles)) {
for (auto confFile : std::as_const(confFiles)) {
const auto locker = qt_scoped_lock(confFile->mutex);
syncConfFile(confFile);
}

View File

@ -713,7 +713,7 @@ QAbstractItemModel *QAbstractItemModelPrivate::staticEmptyModel()
void QAbstractItemModelPrivate::invalidatePersistentIndexes()
{
for (QPersistentModelIndexData *data : qAsConst(persistent.indexes))
for (QPersistentModelIndexData *data : std::as_const(persistent.indexes))
data->index = QModelIndex();
persistent.indexes.clear();
}
@ -861,7 +861,7 @@ void QAbstractItemModelPrivate::rowsAboutToBeInserted(const QModelIndex &parent,
Q_UNUSED(last);
QList<QPersistentModelIndexData *> persistent_moved;
if (first < q->rowCount(parent)) {
for (auto *data : qAsConst(persistent.indexes)) {
for (auto *data : std::as_const(persistent.indexes)) {
const QModelIndex &index = data->index;
if (index.row() >= first && index.isValid() && index.parent() == parent) {
persistent_moved.append(data);
@ -897,7 +897,7 @@ void QAbstractItemModelPrivate::itemsAboutToBeMoved(const QModelIndex &srcParent
const bool sameParent = (srcParent == destinationParent);
const bool movingUp = (srcFirst > destinationChild);
for (auto *data : qAsConst(persistent.indexes)) {
for (auto *data : std::as_const(persistent.indexes)) {
const QModelIndex &index = data->index;
const QModelIndex &parent = index.parent();
const bool isSourceIndex = (parent == srcParent);
@ -995,7 +995,7 @@ void QAbstractItemModelPrivate::rowsAboutToBeRemoved(const QModelIndex &parent,
QList<QPersistentModelIndexData *> persistent_invalidated;
// find the persistent indexes that are affected by the change, either by being in the removed subtree
// or by being on the same level and below the removed rows
for (auto *data : qAsConst(persistent.indexes)) {
for (auto *data : std::as_const(persistent.indexes)) {
bool level_changed = false;
QModelIndex current = data->index;
while (current.isValid()) {
@ -1047,7 +1047,7 @@ void QAbstractItemModelPrivate::columnsAboutToBeInserted(const QModelIndex &pare
Q_UNUSED(last);
QList<QPersistentModelIndexData *> persistent_moved;
if (first < q->columnCount(parent)) {
for (auto *data : qAsConst(persistent.indexes)) {
for (auto *data : std::as_const(persistent.indexes)) {
const QModelIndex &index = data->index;
if (index.column() >= first && index.isValid() && index.parent() == parent)
persistent_moved.append(data);
@ -1080,7 +1080,7 @@ void QAbstractItemModelPrivate::columnsAboutToBeRemoved(const QModelIndex &paren
QList<QPersistentModelIndexData *> persistent_invalidated;
// find the persistent indexes that are affected by the change, either by being in the removed subtree
// or by being on the same level and to the right of the removed columns
for (auto *data : qAsConst(persistent.indexes)) {
for (auto *data : std::as_const(persistent.indexes)) {
bool level_changed = false;
QModelIndex current = data->index;
while (current.isValid()) {
@ -3460,7 +3460,7 @@ void QAbstractItemModel::changePersistentIndexList(const QModelIndexList &from,
}
}
for (auto *data : qAsConst(toBeReinserted))
for (auto *data : std::as_const(toBeReinserted))
d->persistent.insertMultiAtEnd(data->index, data);
}
@ -3474,7 +3474,7 @@ QModelIndexList QAbstractItemModel::persistentIndexList() const
Q_D(const QAbstractItemModel);
QModelIndexList result;
result.reserve(d->persistent.indexes.size());
for (auto *data : qAsConst(d->persistent.indexes))
for (auto *data : std::as_const(d->persistent.indexes))
result.append(data->index);
return result;
}

View File

@ -1616,7 +1616,7 @@ bool QItemSelectionModel::rowIntersectsSelection(int row, const QModelIndex &par
QItemSelection sel = d->ranges;
sel.merge(d->currentSelection, d->currentCommand);
for (const QItemSelectionRange &range : qAsConst(sel)) {
for (const QItemSelectionRange &range : std::as_const(sel)) {
if (range.parent() != parent)
return false;
int top = range.top();
@ -1651,7 +1651,7 @@ bool QItemSelectionModel::columnIntersectsSelection(int column, const QModelInde
QItemSelection sel = d->ranges;
sel.merge(d->currentSelection, d->currentCommand);
for (const QItemSelectionRange &range : qAsConst(sel)) {
for (const QItemSelectionRange &range : std::as_const(sel)) {
if (range.parent() != parent)
return false;
int top = range.top();

View File

@ -450,7 +450,7 @@ bool QSortFilterProxyModelPrivate::recursiveChildAcceptsRow(int source_row, cons
void QSortFilterProxyModelPrivate::remove_from_mapping(const QModelIndex &source_parent)
{
if (Mapping *m = source_index_mapping.take(source_parent)) {
for (const QModelIndex &mappedIdx : qAsConst(m->mapped_children))
for (const QModelIndex &mappedIdx : std::as_const(m->mapped_children))
remove_from_mapping(mappedIdx);
delete m;
}
@ -1175,7 +1175,7 @@ void QSortFilterProxyModelPrivate::updateChildrenMapping(const QModelIndex &sour
}
// reinsert moved, mapped indexes
for (auto &pair : qAsConst(moved_source_index_mappings)) {
for (auto &pair : std::as_const(moved_source_index_mappings)) {
pair.second->source_parent = pair.first;
source_index_mapping.insert(pair.first, pair.second);
}
@ -1224,7 +1224,7 @@ QModelIndexPairList QSortFilterProxyModelPrivate::store_persistent_indexes() con
Q_Q(const QSortFilterProxyModel);
QModelIndexPairList source_indexes;
source_indexes.reserve(persistent.indexes.size());
for (const QPersistentModelIndexData *data : qAsConst(persistent.indexes)) {
for (const QPersistentModelIndexData *data : std::as_const(persistent.indexes)) {
const QModelIndex &proxy_index = data->index;
QModelIndex source_index = q->mapToSource(proxy_index);
source_indexes.append(qMakePair(proxy_index, QPersistentModelIndex(source_index)));

View File

@ -32,7 +32,7 @@ void QTransposeProxyModelPrivate::onLayoutChanged(const QList<QPersistentModelIn
Q_ASSERT(layoutChangeProxyIndexes.size() == layoutChangePersistentIndexes.size());
QModelIndexList toList;
toList.reserve(layoutChangePersistentIndexes.size());
for (const QPersistentModelIndex &persistIdx : qAsConst(layoutChangePersistentIndexes))
for (const QPersistentModelIndex &persistIdx : std::as_const(layoutChangePersistentIndexes))
toList << q->mapFromSource(persistIdx);
q->changePersistentIndexList(layoutChangeProxyIndexes, toList);
layoutChangeProxyIndexes.clear();
@ -172,7 +172,7 @@ void QTransposeProxyModel::setSourceModel(QAbstractItemModel* newSourceModel)
return;
beginResetModel();
if (d->model) {
for (const QMetaObject::Connection& discIter : qAsConst(d->sourceConnections))
for (const QMetaObject::Connection& discIter : std::as_const(d->sourceConnections))
disconnect(discIter);
}
d->sourceConnections.clear();

View File

@ -213,7 +213,7 @@ void QCFSocketNotifier::unregisterSocketNotifier(QSocketNotifier *notifier)
void QCFSocketNotifier::removeSocketNotifiers()
{
// Remove CFSockets from the runloop.
for (MacSocketInfo *socketInfo : qAsConst(macSockets)) {
for (MacSocketInfo *socketInfo : std::as_const(macSockets)) {
unregisterSocketInfo(socketInfo);
delete socketInfo;
}

View File

@ -302,7 +302,7 @@ void Q_CORE_EXPORT qt_call_post_routines()
if (list.isEmpty())
break;
for (QtCleanUpFunction f : qAsConst(list))
for (QtCleanUpFunction f : std::as_const(list))
f();
}
}

View File

@ -216,7 +216,7 @@ int QEventDispatcherUNIXPrivate::activateTimers()
void QEventDispatcherUNIXPrivate::markPendingSocketNotifiers()
{
for (const pollfd &pfd : qAsConst(pollfds)) {
for (const pollfd &pfd : std::as_const(pollfds)) {
if (pfd.fd < 0 || pfd.revents == 0)
continue;

View File

@ -764,7 +764,7 @@ QEventDispatcherWin32::registeredTimers(QObject *object) const
Q_D(const QEventDispatcherWin32);
QList<TimerInfo> list;
for (WinTimerInfo *t : qAsConst(d->timerDict)) {
for (WinTimerInfo *t : std::as_const(d->timerDict)) {
Q_ASSERT(t);
if (t->obj == object)
list << TimerInfo(t->timerId, t->interval, t->timerType);
@ -832,7 +832,7 @@ void QEventDispatcherWin32::closingDown()
Q_ASSERT(d->active_fd.isEmpty());
// clean up any timers
for (WinTimerInfo *t : qAsConst(d->timerDict))
for (WinTimerInfo *t : std::as_const(d->timerDict))
d->unregisterTimer(t);
d->timerDict.clear();

View File

@ -53,7 +53,7 @@ static jboolean dispatchGenericMotionEvent(JNIEnv *, jclass, jobject event)
{
jboolean ret = JNI_FALSE;
QMutexLocker locker(&g_genericMotionEventListeners()->mutex);
for (auto *listener : qAsConst(g_genericMotionEventListeners()->listeners))
for (auto *listener : std::as_const(g_genericMotionEventListeners()->listeners))
ret |= listener->handleGenericMotionEvent(event);
return ret;
}
@ -70,7 +70,7 @@ static jboolean dispatchKeyEvent(JNIEnv *, jclass, jobject event)
{
jboolean ret = JNI_FALSE;
QMutexLocker locker(&g_keyEventListeners()->mutex);
for (auto *listener : qAsConst(g_keyEventListeners()->listeners))
for (auto *listener : std::as_const(g_keyEventListeners()->listeners))
ret |= listener->handleKeyEvent(event);
return ret;
}

View File

@ -390,7 +390,7 @@ qint64 QTimerInfoList::timerRemainingTime(int timerId)
repairTimersIfNeeded();
timespec tm = {0, 0};
for (const auto *t : qAsConst(*this)) {
for (const auto *t : std::as_const(*this)) {
if (t->id == timerId) {
if (currentTime < t->timeout) {
// time to wait

View File

@ -635,7 +635,7 @@ static QString find_translation(const QLocale & locale,
languages.insert(i + 1, lowerLang);
}
for (QString localeName : qAsConst(languages)) {
for (QString localeName : std::as_const(languages)) {
localeName.replace(u'-', u'_');
// try the complete locale name first and progressively truncate from

View File

@ -386,7 +386,7 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
return candidateByData;
}
for (const QString &m : qAsConst(candidatesByName.m_allMatchingMimeTypes)) {
for (const QString &m : std::as_const(candidatesByName.m_allMatchingMimeTypes)) {
if (inherits(m, sniffedMime)) {
// We have magic + pattern pointing to this, so it's a pretty good match
return mimeTypeForName(m);

View File

@ -449,10 +449,10 @@ void QMimeBinaryProvider::addAllMimeTypes(QList<QMimeType> &result)
loadMimeTypeList();
if (result.isEmpty()) {
result.reserve(m_mimetypeNames.size());
for (const QString &name : qAsConst(m_mimetypeNames))
for (const QString &name : std::as_const(m_mimetypeNames))
result.append(mimeTypeForNameUnchecked(name));
} else {
for (const QString &name : qAsConst(m_mimetypeNames))
for (const QString &name : std::as_const(m_mimetypeNames))
if (std::find_if(result.constBegin(), result.constEnd(), [name](const QMimeType &mime) -> bool { return mime.name() == name; })
== result.constEnd())
result.append(mimeTypeForNameUnchecked(name));
@ -680,7 +680,7 @@ void QMimeXMLProvider::findByMagic(const QByteArray &data, int *accuracyPtr, QMi
{
QString candidateName;
bool foundOne = false;
for (const QMimeMagicRuleMatcher &matcher : qAsConst(m_magicMatchers)) {
for (const QMimeMagicRuleMatcher &matcher : std::as_const(m_magicMatchers)) {
if (matcher.matches(data)) {
const int priority = matcher.priority();
if (priority > *accuracyPtr) {
@ -716,7 +716,7 @@ void QMimeXMLProvider::ensureLoaded()
//qDebug() << "Loading" << m_allFiles;
for (const QString &file : qAsConst(allFiles))
for (const QString &file : std::as_const(allFiles))
load(file);
}

View File

@ -225,7 +225,7 @@ QString QMimeType::comment() const
languageList << QLocale().name();
languageList << QLocale().uiLanguages();
languageList << u"default"_s; // use the default locale if possible.
for (const QString &language : qAsConst(languageList)) {
for (const QString &language : std::as_const(languageList)) {
const QString lang = language == "C"_L1 ? u"en_US"_s : language;
const QString comm = d->localeComments.value(lang);
if (!comm.isEmpty())
@ -410,7 +410,7 @@ QStringList QMimeType::suffixes() const
QMimeDatabasePrivate::instance()->loadMimeTypePrivate(const_cast<QMimeTypePrivate&>(*d));
QStringList result;
for (const QString &pattern : qAsConst(d->globPatterns)) {
for (const QString &pattern : std::as_const(d->globPatterns)) {
// Not a simple suffix if it looks like: README or *. or *.* or *.JP*G or *.JP?
if (pattern.startsWith("*."_L1) &&
pattern.size() > 2 &&

View File

@ -132,7 +132,7 @@ Q_GLOBAL_STATIC(QFactoryLoaderGlobals, qt_factoryloader_global)
QFactoryLoaderPrivate::~QFactoryLoaderPrivate()
{
for (QLibraryPrivate *library : qAsConst(libraryList))
for (QLibraryPrivate *library : std::as_const(libraryList))
library->release();
}

View File

@ -357,7 +357,7 @@ inline void QLibraryStore::cleanup()
// dump all objects that remain
if (lcDebugLibrary().isDebugEnabled()) {
for (QLibraryPrivate *lib : qAsConst(data->libraryMap)) {
for (QLibraryPrivate *lib : std::as_const(data->libraryMap)) {
if (lib)
qDebug(lcDebugLibrary)
<< "On QtCore unload," << lib->fileName << "was leaked, with"

View File

@ -164,7 +164,7 @@ bool QLibraryPrivate::load_sys()
QStringList tmp;
qSwap(tmp, list);
list.reserve(tmp.size() * 2);
for (const QString &s : qAsConst(tmp)) {
for (const QString &s : std::as_const(tmp)) {
QString modifiedPath = s;
f(&modifiedPath);
list.append(modifiedPath);

View File

@ -59,7 +59,7 @@ bool QLibraryPrivate::load_sys()
locker.unlock();
Handle hnd = nullptr;
for (const QString &attempt : qAsConst(attempts)) {
for (const QString &attempt : std::as_const(attempts)) {
hnd = LoadLibrary(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(attempt).utf16()));
// If we have a handle or the last error is something other than "unable

View File

@ -246,9 +246,9 @@ static QString locatePlugin(const QString& fileName)
paths = QCoreApplication::libraryPaths();
}
for (const QString &path : qAsConst(paths)) {
for (const QString &prefix : qAsConst(prefixes)) {
for (const QString &suffix : qAsConst(suffixes)) {
for (const QString &path : std::as_const(paths)) {
for (const QString &prefix : std::as_const(prefixes)) {
for (const QString &suffix : std::as_const(suffixes)) {
#ifdef Q_OS_ANDROID
{
QString pluginPath = basePath + prefix + baseName + suffix;

View File

@ -970,7 +970,7 @@ QCborStreamReader::Type QCborStreamReader::parentContainerType() const
{
if (d->containerStack.isEmpty())
return Invalid;
return Type(cbor_value_get_type(&qAsConst(d->containerStack).top()));
return Type(cbor_value_get_type(&std::as_const(d->containerStack).top()));
}
/*!

View File

@ -944,7 +944,7 @@ QCborContainerPrivate *QCborContainerPrivate::clone(QCborContainerPrivate *d, qs
d = u.take();
d->ref.storeRelaxed(0);
for (auto &e : qAsConst(d->elements)) {
for (auto &e : std::as_const(d->elements)) {
if (e.flags & Element::IsContainer)
e.container->ref.ref();
}

View File

@ -545,13 +545,13 @@ public:
#if QT_CONFIG(cborstreamwriter)
using QCborValueConstRef::toCbor;
QByteArray toCbor(QCborValue::EncodingOptions opt = QCborValue::NoTransformation)
{ return qAsConst(*this).toCbor(opt); }
{ return std::as_const(*this).toCbor(opt); }
void toCbor(QCborStreamWriter &writer, QCborValue::EncodingOptions opt = QCborValue::NoTransformation);
#endif
using QCborValueConstRef::toDiagnosticNotation;
QString toDiagnosticNotation(QCborValue::DiagnosticNotationOptions opt = QCborValue::Compact)
{ return qAsConst(*this).toDiagnosticNotation(opt); }
{ return std::as_const(*this).toDiagnosticNotation(opt); }
private:
static QCborValue concrete(QCborValueRef that) noexcept;

View File

@ -4463,7 +4463,7 @@ QString &QString::replace(const QRegularExpression &re, const QString &after)
lastEnd = 0;
// add the after string, with replacements for the backreferences
for (const QStringCapture &backReference : qAsConst(backReferences)) {
for (const QStringCapture &backReference : std::as_const(backReferences)) {
// part of "after" before the backreference
len = backReference.pos - lastEnd;
if (len > 0) {
@ -4501,7 +4501,7 @@ QString &QString::replace(const QRegularExpression &re, const QString &after)
resize(newLength);
qsizetype i = 0;
QChar *uc = data();
for (const QStringView &chunk : qAsConst(chunks)) {
for (const QStringView &chunk : std::as_const(chunks)) {
qsizetype len = chunk.length();
memcpy(uc + i, chunk.constData(), len * sizeof(QChar));
i += len;

View File

@ -71,7 +71,7 @@ public:
template <typename T>
T *pointer()
{
const T *p = qAsConst(*this).pointer<T>();
const T *p = std::as_const(*this).pointer<T>();
return const_cast<T *>(p);
}

View File

@ -188,7 +188,7 @@ inline bool comparePriority(int priority, const QueuePage *p)
void QThreadPoolPrivate::enqueueTask(QRunnable *runnable, int priority)
{
Q_ASSERT(runnable != nullptr);
for (QueuePage *page : qAsConst(queue)) {
for (QueuePage *page : std::as_const(queue)) {
if (page->priority() == priority && !page->isFull()) {
page->push(runnable);
return;
@ -269,7 +269,7 @@ void QThreadPoolPrivate::reset()
mutex.unlock();
for (QThreadPoolThread *thread : qAsConst(allThreadsCopy)) {
for (QThreadPoolThread *thread : std::as_const(allThreadsCopy)) {
if (thread->isRunning()) {
thread->runnableReady.wakeAll();
thread->wait();
@ -348,7 +348,7 @@ bool QThreadPool::tryTake(QRunnable *runnable)
return false;
QMutexLocker locker(&d->mutex);
for (QueuePage *page : qAsConst(d->queue)) {
for (QueuePage *page : std::as_const(d->queue)) {
if (page->tryTake(runnable)) {
if (page->isFinished()) {
d->queue.removeOne(page);

View File

@ -178,7 +178,7 @@ void QWaitCondition::wakeOne()
{
// wake up the first waiting thread in the queue
QMutexLocker locker(&d->mtx);
for (QWaitConditionEvent *current : qAsConst(d->queue)) {
for (QWaitConditionEvent *current : std::as_const(d->queue)) {
if (current->wokenUp)
continue;
SetEvent(current->event);
@ -191,7 +191,7 @@ void QWaitCondition::wakeAll()
{
// wake up the all threads in the queue
QMutexLocker locker(&d->mtx);
for (QWaitConditionEvent *current : qAsConst(d->queue)) {
for (QWaitConditionEvent *current : std::as_const(d->queue)) {
SetEvent(current->event);
current->wokenUp = true;
}

View File

@ -826,7 +826,7 @@ QTzTimeZoneCacheEntry QTzTimeZoneCache::findEntry(const QByteArray &ianaId)
// Offsets are stored as total offset, want to know separate UTC and DST offsets
// so find the first non-dst transition to use as base UTC Offset
int utcOffset = ret.m_preZoneRule.stdOffset;
for (const QTzTransition &tran : qAsConst(tranList)) {
for (const QTzTransition &tran : std::as_const(tranList)) {
if (!typeList.at(tran.tz_typeind).tz_isdst) {
utcOffset = typeList.at(tran.tz_typeind).tz_gmtoff;
break;

View File

@ -793,7 +793,7 @@ bool QCommandLineParser::isSet(const QString &name) const
if (d->optionNames.contains(name))
return true;
const QStringList aliases = d->aliases(name);
for (const QString &optionName : qAsConst(d->optionNames)) {
for (const QString &optionName : std::as_const(d->optionNames)) {
if (aliases.contains(optionName))
return true;
}
@ -1110,7 +1110,7 @@ QString QCommandLineParserPrivate::helpText(bool includeQtOptions) const
QStringList optionNameList;
optionNameList.reserve(options.size());
int longestOptionNameString = 0;
for (const QCommandLineOption &option : qAsConst(options)) {
for (const QCommandLineOption &option : std::as_const(options)) {
if (option.flags() & QCommandLineOption::HiddenFromHelp)
continue;
const QStringList optionNames = option.names();
@ -1130,7 +1130,7 @@ QString QCommandLineParserPrivate::helpText(bool includeQtOptions) const
++longestOptionNameString;
const int optionNameMaxWidth = qMin(50, longestOptionNameString);
auto optionNameIterator = optionNameList.cbegin();
for (const QCommandLineOption &option : qAsConst(options)) {
for (const QCommandLineOption &option : std::as_const(options)) {
if (option.flags() & QCommandLineOption::HiddenFromHelp)
continue;
text += wrapText(*optionNameIterator, optionNameMaxWidth, option.description());

View File

@ -2121,7 +2121,7 @@ public:
{
const auto copy = isDetached() ? QMultiHash() : *this; // keep 'key' alive across the detach
detach();
auto pair = qAsConst(*this).equal_range(key);
auto pair = std::as_const(*this).equal_range(key);
return qMakePair(iterator(pair.first.i), iterator(pair.second.i));
}

View File

@ -244,7 +244,7 @@ Q_INLINE_TEMPLATE QSet<T> &QSet<T>::intersect(const QSet<T> &other)
copy2 = *this;
*this = copy1;
}
for (const auto &e : qAsConst(copy1)) {
for (const auto &e : std::as_const(copy1)) {
if (!copy2.contains(e))
remove(e);
}

View File

@ -415,9 +415,9 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
qsizetype data_size = idata.size() +
(header->methodCount * (QMetaObjectPrivate::IntsPerMethod+intsPerMethod)) + methodParametersDataSize +
(header->propertyCount * (QMetaObjectPrivate::IntsPerProperty+intsPerProperty));
for (const Method &mm : qAsConst(signals_))
for (const Method &mm : std::as_const(signals_))
data_size += 2 + mm.inputTypes.size() + mm.outputTypes.size();
for (const Method &mm : qAsConst(methods))
for (const Method &mm : std::as_const(methods))
data_size += 2 + mm.inputTypes.size() + mm.outputTypes.size();
idata.resize(data_size + 1);

View File

@ -81,7 +81,7 @@ QDBusServer::~QDBusServer()
QMutexLocker locker(managerMutex);
QWriteLocker writeLocker(&d->lock);
if (QDBusConnectionManager::instance()) {
for (const QString &name : qAsConst(d->serverConnectionNames))
for (const QString &name : std::as_const(d->serverConnectionNames))
QDBusConnectionManager::instance()->removeConnection(name);
d->serverConnectionNames.clear();
locker.unlock();

View File

@ -62,7 +62,7 @@ void QDBusServiceWatcherPrivate::setConnection(const QStringList &services,
{
if (connection.isConnected()) {
// remove older rules
for (const QString &s : qAsConst(watchedServicesData.value()))
for (const QString &s : std::as_const(watchedServicesData.value()))
removeService(s);
}
@ -72,7 +72,7 @@ void QDBusServiceWatcherPrivate::setConnection(const QStringList &services,
if (connection.isConnected()) {
// add new rules
for (const QString &s : qAsConst(watchedServicesData.value()))
for (const QString &s : std::as_const(watchedServicesData.value()))
addService(s);
}
}

View File

@ -451,7 +451,7 @@ void QPixmapIconEngine::addFile(const QString &fileName, const QSize &size, QIco
}
}
}
for (const QImage &i : qAsConst(icoImages))
for (const QImage &i : std::as_const(icoImages))
pixmaps += QPixmapIconEngineEntry(abs, i, mode, state);
if (icoImages.isEmpty() && !ignoreSize) // Add placeholder with the filename and empty pixmap for the size.
pixmaps += QPixmapIconEngineEntry(abs, size, mode, state);

View File

@ -282,9 +282,9 @@ void QFileInfoGatherer::run()
condition.wait(&mutex);
if (abort.loadRelaxed())
return;
const QString thisPath = qAsConst(path).front();
const QString thisPath = std::as_const(path).front();
path.pop_front();
const QStringList thisList = qAsConst(files).front();
const QStringList thisList = std::as_const(files).front();
files.pop_front();
locker.unlock();

View File

@ -1944,7 +1944,7 @@ void QFileSystemModelPrivate::_q_fileSystemChanged(const QString &path,
std::sort(rowsToUpdate.begin(), rowsToUpdate.end());
QString min;
QString max;
for (const QString &value : qAsConst(rowsToUpdate)) {
for (const QString &value : std::as_const(rowsToUpdate)) {
//##TODO is there a way to bundle signals with QString as the content of the list?
/*if (min.isEmpty()) {
min = value;

View File

@ -146,7 +146,7 @@ public:
void updateIcon(QAbstractFileIconProvider *iconProvider, const QString &path) {
if (info)
info->icon = iconProvider->icon(QFileInfo(path));
for (QFileSystemNode *child : qAsConst(children)) {
for (QFileSystemNode *child : std::as_const(children)) {
//On windows the root (My computer) has no path so we don't want to add a / for nothing (e.g. /C:/)
if (!path.isEmpty()) {
if (path.endsWith(u'/'))
@ -161,7 +161,7 @@ public:
void retranslateStrings(QAbstractFileIconProvider *iconProvider, const QString &path) {
if (info)
info->displayType = iconProvider->type(QFileInfo(path));
for (QFileSystemNode *child : qAsConst(children)) {
for (QFileSystemNode *child : std::as_const(children)) {
//On windows the root (My computer) has no path so we don't want to add a / for nothing (e.g. /C:/)
if (!path.isEmpty()) {
if (path.endsWith(u'/'))

View File

@ -840,7 +840,7 @@ QStandardItem &QStandardItem::operator=(const QStandardItem &other)
QStandardItem::~QStandardItem()
{
Q_D(QStandardItem);
for (QStandardItem *child : qAsConst(d->children)) {
for (QStandardItem *child : std::as_const(d->children)) {
if (child)
child->d_func()->setModel(nullptr);
delete child;
@ -3144,7 +3144,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const
}
stack.reserve(itemsSet.size());
for (QStandardItem *item : qAsConst(itemsSet))
for (QStandardItem *item : std::as_const(itemsSet))
stack.push(item);
//stream everything recursively

View File

@ -81,26 +81,26 @@ void QActionPrivate::sendDataChanged()
void QActionPrivate::redoGrab(QShortcutMap &map)
{
Q_Q(QAction);
for (int id : qAsConst(shortcutIds)) {
for (int id : std::as_const(shortcutIds)) {
if (id)
map.removeShortcut(id, q);
}
shortcutIds.clear();
for (const QKeySequence &shortcut : qAsConst(shortcuts)) {
for (const QKeySequence &shortcut : std::as_const(shortcuts)) {
if (!shortcut.isEmpty())
shortcutIds.append(map.addShortcut(q, shortcut, shortcutContext, contextMatcher()));
else
shortcutIds.append(0);
}
if (!enabled) {
for (int id : qAsConst(shortcutIds)) {
for (int id : std::as_const(shortcutIds)) {
if (id)
map.setShortcutEnabled(false, id, q);
}
}
if (!autorepeat) {
for (int id : qAsConst(shortcutIds)) {
for (int id : std::as_const(shortcutIds)) {
if (id)
map.setShortcutAutoRepeat(false, id, q);
}
@ -110,7 +110,7 @@ void QActionPrivate::redoGrab(QShortcutMap &map)
void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map)
{
Q_Q(QAction);
for (int id : qAsConst(shortcutIds)) {
for (int id : std::as_const(shortcutIds)) {
if (id)
map.setShortcutEnabled(enable, id, q);
}
@ -458,7 +458,7 @@ QAction::~QAction()
d->group->removeAction(this);
#if QT_CONFIG(shortcut)
if (qApp) {
for (int id : qAsConst(d->shortcutIds)) {
for (int id : std::as_const(d->shortcutIds)) {
if (id)
QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(id, this);
}
@ -1024,7 +1024,7 @@ bool QAction::event(QEvent *e)
{
Q_D(QAction);
if (e->type() == QEvent::ActionChanged) {
for (auto object : qAsConst(d->associatedObjects))
for (auto object : std::as_const(d->associatedObjects))
QCoreApplication::sendEvent(object, e);
}

View File

@ -277,7 +277,7 @@ void QActionGroup::setEnabled(bool b)
{
Q_D(QActionGroup);
d->enabled = b;
for (auto action : qAsConst(d->actions)) {
for (auto action : std::as_const(d->actions)) {
action->d_func()->setEnabled(b, true);
}
}
@ -311,7 +311,7 @@ void QActionGroup::setVisible(bool b)
{
Q_D(QActionGroup);
d->visible = b;
for (auto action : qAsConst(d->actions)) {
for (auto action : std::as_const(d->actions)) {
if (!action->d_func()->forceInvisible)
action->d_func()->setVisible(b);
}

View File

@ -837,7 +837,7 @@ void QGuiApplicationPrivate::showModalWindow(QWindow *modal)
}
}
for (QWindow *window : qAsConst(QGuiApplicationPrivate::window_list)) {
for (QWindow *window : std::as_const(QGuiApplicationPrivate::window_list)) {
if (needsWindowBlockedEvent(window) && !window->d_func()->blockedByModalWindow)
updateBlockedStatus(window);
}
@ -849,7 +849,7 @@ void QGuiApplicationPrivate::hideModalWindow(QWindow *window)
{
self->modalWindowList.removeAll(window);
for (QWindow *window : qAsConst(QGuiApplicationPrivate::window_list)) {
for (QWindow *window : std::as_const(QGuiApplicationPrivate::window_list)) {
if (needsWindowBlockedEvent(window) && window->d_func()->blockedByModalWindow)
updateBlockedStatus(window);
}
@ -1097,7 +1097,7 @@ qreal QGuiApplication::devicePixelRatio() const
return QGuiApplicationPrivate::m_maxDevicePixelRatio;
QGuiApplicationPrivate::m_maxDevicePixelRatio = 1.0; // make sure we never return 0.
for (QScreen *screen : qAsConst(QGuiApplicationPrivate::screen_list))
for (QScreen *screen : std::as_const(QGuiApplicationPrivate::screen_list))
QGuiApplicationPrivate::m_maxDevicePixelRatio = qMax(QGuiApplicationPrivate::m_maxDevicePixelRatio, screen->devicePixelRatio());
return QGuiApplicationPrivate::m_maxDevicePixelRatio;
@ -1245,7 +1245,7 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString
qCDebug(lcQpaTheme) << "Adding platform integration's theme names to list of theme names:" << platformIntegrationThemeNames;
themeNames += platformIntegrationThemeNames;
// 4) Look for a theme plugin.
for (const QString &themeName : qAsConst(themeNames)) {
for (const QString &themeName : std::as_const(themeNames)) {
qCDebug(lcQpaTheme) << "Attempting to create platform theme" << themeName << "via QPlatformThemeFactory::create";
QGuiApplicationPrivate::platform_theme = QPlatformThemeFactory::create(themeName, platformPluginPath);
if (QGuiApplicationPrivate::platform_theme) {
@ -1257,7 +1257,7 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString
// 5) If no theme plugin was found ask the platform integration to
// create a theme
if (!QGuiApplicationPrivate::platform_theme) {
for (const QString &themeName : qAsConst(themeNames)) {
for (const QString &themeName : std::as_const(themeNames)) {
qCDebug(lcQpaTheme) << "Attempting to create platform theme" << themeName << "via createPlatformTheme";
QGuiApplicationPrivate::platform_theme = QGuiApplicationPrivate::platform_integration->createPlatformTheme(themeName);
if (QGuiApplicationPrivate::platform_theme) {
@ -1278,7 +1278,7 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString
// boolean 'foo' or strings: 'foo=bar'
if (!platformArguments.isEmpty()) {
if (QObject *nativeInterface = QGuiApplicationPrivate::platform_integration->nativeInterface()) {
for (const QString &argument : qAsConst(platformArguments)) {
for (const QString &argument : std::as_const(platformArguments)) {
const int equalsPos = argument.indexOf(u'=');
const QByteArray name =
equalsPos != -1 ? argument.left(equalsPos).toUtf8() : argument.toUtf8();

View File

@ -127,14 +127,14 @@ void QShortcutPrivate::redoGrab(QShortcutMap &map)
return;
}
for (int id : qAsConst(sc_ids))
for (int id : std::as_const(sc_ids))
map.removeShortcut(id, q);
sc_ids.clear();
if (sc_sequences.isEmpty())
return;
sc_ids.reserve(sc_sequences.size());
for (const auto &keySequence : qAsConst(sc_sequences)) {
for (const auto &keySequence : std::as_const(sc_sequences)) {
if (keySequence.isEmpty())
continue;
int id = map.addShortcut(q, keySequence, sc_context, contextMatcher());
@ -337,7 +337,7 @@ QShortcut::~QShortcut()
{
Q_D(QShortcut);
if (qApp) {
for (int id : qAsConst(d->sc_ids))
for (int id : std::as_const(d->sc_ids))
QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(id, this);
}
}

View File

@ -621,7 +621,7 @@ void QShortcutMap::dispatchEvent(QKeyEvent *e)
if (lcShortcutMap().isDebugEnabled()) {
if (ambiguousShortcuts.size() > 1) {
qCDebug(lcShortcutMap) << "The following shortcuts are about to be activated ambiguously:";
for (const QShortcutEntry *entry : qAsConst(ambiguousShortcuts))
for (const QShortcutEntry *entry : std::as_const(ambiguousShortcuts))
qCDebug(lcShortcutMap).nospace() << "- " << entry->keyseq << " (belonging to " << entry->owner << ")";
}

View File

@ -309,7 +309,7 @@ static inline QPoint fromNativeGlobalPixels(const QPoint &point)
#ifndef QT_NO_HIGHDPISCALING
QPoint res = point;
if (QHighDpiScaling::isActive()) {
for (const QScreen *s : qAsConst(QGuiApplicationPrivate::screen_list)) {
for (const QScreen *s : std::as_const(QGuiApplicationPrivate::screen_list)) {
if (s->handle()->geometry().contains(point)) {
res = QHighDpi::fromNativePixels(point, s);
break;

View File

@ -132,7 +132,7 @@ QT_END_NAMESPACE
auto nsImage = [[[NSImage alloc] initWithSize:NSZeroSize] autorelease];
for (QSize size : qAsConst(availableSizes)) {
for (QSize size : std::as_const(availableSizes)) {
QImage image = icon.pixmap(size).toImage();
if (image.isNull())
continue;

View File

@ -381,7 +381,7 @@ void QPainterPrivate::draw_helper(const QPainterPath &originalPath, DrawOperatio
if (q->hasClipping()) {
bool hasPerspectiveTransform = false;
for (const QPainterClipInfo &info : qAsConst(state->clipInfo)) {
for (const QPainterClipInfo &info : std::as_const(state->clipInfo)) {
if (info.matrix.type() == QTransform::TxProject) {
hasPerspectiveTransform = true;
break;
@ -1616,7 +1616,7 @@ void QPainter::restore()
tmp->clipPath = QPainterPath();
d->engine->updateState(*tmp);
// replay the list of clip states,
for (const QPainterClipInfo &info : qAsConst(d->state->clipInfo)) {
for (const QPainterClipInfo &info : std::as_const(d->state->clipInfo)) {
tmp->matrix = info.matrix;
tmp->matrix *= d->state->redirectionMatrix;
tmp->clipOperation = info.operation;
@ -2478,7 +2478,7 @@ QRegion QPainter::clipRegion() const
const_cast<QPainter *>(this)->d_ptr->updateInvMatrix();
// ### Falcon: Use QPainterPath
for (const QPainterClipInfo &info : qAsConst(d->state->clipInfo)) {
for (const QPainterClipInfo &info : std::as_const(d->state->clipInfo)) {
switch (info.clipType) {
case QPainterClipInfo::RegionClip: {
@ -2645,7 +2645,7 @@ QRectF QPainter::clipBoundingRect() const
// fast.
QRectF bounds;
bool first = true;
for (const QPainterClipInfo &info : qAsConst(d->state->clipInfo)) {
for (const QPainterClipInfo &info : std::as_const(d->state->clipInfo)) {
QRectF r;
if (info.clipType == QPainterClipInfo::RectClip)

View File

@ -45,7 +45,7 @@ QXdgDBusImageVector iconToQXdgDBusImageVector(const QIcon &icon)
bool hasSmallIcon = false;
bool hasMediumIcon = false;
QList<QSize> toRemove;
for (const QSize &size : qAsConst(sizes)) {
for (const QSize &size : std::as_const(sizes)) {
int maxSize = qMax(size.width(), size.height());
if (maxSize <= IconNormalSmallSize)
hasSmallIcon = true;
@ -54,7 +54,7 @@ QXdgDBusImageVector iconToQXdgDBusImageVector(const QIcon &icon)
else if (maxSize > IconSizeLimit)
toRemove << size;
}
for (const QSize &size : qAsConst(toRemove))
for (const QSize &size : std::as_const(toRemove))
sizes.removeOne(size);
if (!hasSmallIcon)
sizes.append(QSize(IconNormalSmallSize, IconNormalSmallSize));
@ -62,7 +62,7 @@ QXdgDBusImageVector iconToQXdgDBusImageVector(const QIcon &icon)
sizes.append(QSize(IconNormalMediumSize, IconNormalMediumSize));
ret.reserve(sizes.size());
for (const QSize &size : qAsConst(sizes)) {
for (const QSize &size : std::as_const(sizes)) {
// Protocol specifies ARGB32 format in network byte order
QImage im = engine->pixmap(size, QIcon::Normal, QIcon::Off).toImage().convertToFormat(QImage::Format_ARGB32);
// letterbox if necessary to make it square

Some files were not shown because too many files have changed in this diff Show More