mirror of https://github.com/qt/qtbase.git
Use qsizetype in QList
The change creates a slight source incompatibility. The main things to take care of are * code using printf statements on list.size(). Using qsizetype in printf statements will always require a cast to work on both 32 and 64 bit. * A few places where overloads now get ambiguous. One example is QRandomGenerator::bounded() that has overloads for int, uint and double, but not int64. * Streaming list.size() to a QDataStream will change the format depending on the architecture. [ChangeLog][QtCore][QList] QList now uses qsizetype to index into elements. Change-Id: Iaff562a4d072b97f458417b670f95971bd47cbc6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
3711bf85ae
commit
df853fed66
|
@ -72,7 +72,7 @@ static QStringList colorPairs(int max)
|
|||
// randomize it
|
||||
colors.clear();
|
||||
while (combinedColors.count()) {
|
||||
int i = QRandomGenerator::global()->bounded(combinedColors.count());
|
||||
int i = QRandomGenerator::global()->bounded(int(combinedColors.count()));
|
||||
colors << combinedColors[i];
|
||||
combinedColors.removeAt(i);
|
||||
if (colors.count() == max)
|
||||
|
|
|
@ -145,7 +145,7 @@ void Server::sendFortune()
|
|||
QDataStream out(&block, QIODevice::WriteOnly);
|
||||
out.setVersion(QDataStream::Qt_5_10);
|
||||
|
||||
out << fortunes[QRandomGenerator::global()->bounded(fortunes.size())];
|
||||
out << fortunes[QRandomGenerator::global()->bounded(int(fortunes.size()))];
|
||||
//! [4] //! [7]
|
||||
|
||||
QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
|
||||
|
|
|
@ -72,7 +72,7 @@ FortuneServer::FortuneServer(QObject *parent)
|
|||
//! [1]
|
||||
void FortuneServer::incomingConnection(qintptr socketDescriptor)
|
||||
{
|
||||
QString fortune = fortunes.at(QRandomGenerator::global()->bounded(fortunes.size()));
|
||||
QString fortune = fortunes.at(QRandomGenerator::global()->bounded(int(fortunes.size())));
|
||||
FortuneThread *thread = new FortuneThread(socketDescriptor, fortune, this);
|
||||
connect(thread, &FortuneThread::finished, thread, &FortuneThread::deleteLater);
|
||||
thread->start();
|
||||
|
|
|
@ -700,7 +700,7 @@ void TorrentClient::connectToPeers()
|
|||
d->connections << client;
|
||||
|
||||
// Pick a random peer from the list of weighed peers.
|
||||
TorrentPeer *peer = weighedPeers.takeAt(QRandomGenerator::global()->bounded(weighedPeers.size()));
|
||||
TorrentPeer *peer = weighedPeers.takeAt(QRandomGenerator::global()->bounded(int(weighedPeers.size())));
|
||||
weighedPeers.removeAll(peer);
|
||||
peer->connectStart = QDateTime::currentSecsSinceEpoch();
|
||||
peer->lastVisited = peer->connectStart;
|
||||
|
@ -1130,7 +1130,7 @@ void TorrentClient::scheduleUploads()
|
|||
// random peer to allow it to compete for a position among the
|
||||
// downloaders. (This is known as an "optimistic unchoke".)
|
||||
if (!allClients.isEmpty()) {
|
||||
PeerWireClient *client = allClients[QRandomGenerator::global()->bounded(allClients.size())];
|
||||
PeerWireClient *client = allClients[QRandomGenerator::global()->bounded(int(allClients.size()))];
|
||||
if (client->peerWireState() & PeerWireClient::ChokingPeer)
|
||||
client->unchokePeer();
|
||||
}
|
||||
|
@ -1191,7 +1191,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
|
|||
piece = d->payloads.value(client);
|
||||
if (!piece) {
|
||||
QList<TorrentPiece *> values = d->pendingPieces.values();
|
||||
piece = values.value(QRandomGenerator::global()->bounded(values.size()));
|
||||
piece = values.value(QRandomGenerator::global()->bounded(int(values.size())));
|
||||
piece->inProgress = true;
|
||||
d->payloads.insert(client, piece);
|
||||
}
|
||||
|
@ -1248,7 +1248,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
|
|||
++it;
|
||||
}
|
||||
if (!partialPieces.isEmpty())
|
||||
piece = partialPieces.value(QRandomGenerator::global()->bounded(partialPieces.size()));
|
||||
piece = partialPieces.value(QRandomGenerator::global()->bounded(int(partialPieces.size())));
|
||||
|
||||
if (!piece) {
|
||||
// Pick a random piece 3 out of 4 times; otherwise, pick either
|
||||
|
@ -1295,7 +1295,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
|
|||
}
|
||||
|
||||
// Select one piece randomly
|
||||
pieceIndex = piecesReadyForDownload.at(QRandomGenerator::global()->bounded(piecesReadyForDownload.size()));
|
||||
pieceIndex = piecesReadyForDownload.at(QRandomGenerator::global()->bounded(int(piecesReadyForDownload.size())));
|
||||
delete [] occurrences;
|
||||
} else {
|
||||
// Make up a list of available piece indices, and pick
|
||||
|
@ -1306,7 +1306,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
|
|||
if (incompletePiecesAvailableToClient.testBit(i))
|
||||
values << i;
|
||||
}
|
||||
pieceIndex = values.at(QRandomGenerator::global()->bounded(values.size()));
|
||||
pieceIndex = values.at(QRandomGenerator::global()->bounded(int(values.size())));
|
||||
}
|
||||
|
||||
// Create a new TorrentPiece and fill in all initial
|
||||
|
@ -1398,8 +1398,8 @@ int TorrentClient::requestBlocks(PeerWireClient *client, TorrentPiece *piece, in
|
|||
// speedup comes from an increased chance of receiving
|
||||
// different blocks from the different peers.
|
||||
for (int i = 0; i < bits.size(); ++i) {
|
||||
int a = QRandomGenerator::global()->bounded(bits.size());
|
||||
int b = QRandomGenerator::global()->bounded(bits.size());
|
||||
int a = QRandomGenerator::global()->bounded(int(bits.size()));
|
||||
int b = QRandomGenerator::global()->bounded(int(bits.size()));
|
||||
int tmp = bits[a];
|
||||
bits[a] = bits[b];
|
||||
bits[b] = tmp;
|
||||
|
|
|
@ -264,7 +264,7 @@ void ToolBar::randomize()
|
|||
QList<QAction *> randomized;
|
||||
QList<QAction *> actions = this->actions();
|
||||
while (!actions.isEmpty()) {
|
||||
QAction *action = actions.takeAt(QRandomGenerator::global()->bounded(actions.size()));
|
||||
QAction *action = actions.takeAt(QRandomGenerator::global()->bounded(int(actions.size())));
|
||||
randomized.append(action);
|
||||
}
|
||||
clear();
|
||||
|
|
|
@ -267,7 +267,7 @@ void XmlOutput::closeTag()
|
|||
case Bare:
|
||||
if (tagStack.count())
|
||||
//warn_msg(WarnLogic, "<Root>: Cannot close tag in Bare state, %d tags on stack", tagStack.count());
|
||||
qDebug("<Root>: Cannot close tag in Bare state, %d tags on stack", tagStack.count());
|
||||
qDebug("<Root>: Cannot close tag in Bare state, %d tags on stack", int(tagStack.count()));
|
||||
else
|
||||
//warn_msg(WarnLogic, "<Root>: Cannot close tag, no tags on stack");
|
||||
qDebug("<Root>: Cannot close tag, no tags on stack");
|
||||
|
|
|
@ -1598,12 +1598,12 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const
|
|||
stream << QByteArray();
|
||||
|
||||
// Write the counts for each type of class member.
|
||||
stream << d->classInfoNames.size();
|
||||
stream << int(d->classInfoNames.size());
|
||||
stream << int(d->methods.size());
|
||||
stream << int(d->properties.size());
|
||||
stream << int(d->enumerators.size());
|
||||
stream << int(d->constructors.size());
|
||||
stream << d->relatedMetaObjects.size();
|
||||
stream << int(d->relatedMetaObjects.size());
|
||||
|
||||
// Write the items of class information.
|
||||
for (index = 0; index < d->classInfoNames.size(); ++index) {
|
||||
|
|
|
@ -718,7 +718,7 @@ bool QJsonObject::operator!=(const QJsonObject &other) const
|
|||
QJsonObject::iterator QJsonObject::erase(QJsonObject::iterator it)
|
||||
{
|
||||
if (it.o != this || it.i < 0 || it.i >= o->elements.length())
|
||||
return {this, o->elements.length()};
|
||||
return {this, int(o->elements.length())};
|
||||
|
||||
int index = it.i;
|
||||
|
||||
|
|
|
@ -314,7 +314,7 @@ QStringList QtPrivate::QStringList_filter(const QStringList *that, QStringView s
|
|||
{
|
||||
QStringMatcher matcher(str, cs);
|
||||
QStringList res;
|
||||
for (int i = 0; i < that->size(); ++i)
|
||||
for (qsizetype i = 0; i < that->size(); ++i)
|
||||
if (matcher.indexIn(that->at(i)) != -1)
|
||||
res << that->at(i);
|
||||
return res;
|
||||
|
@ -327,7 +327,7 @@ QStringList QtPrivate::QStringList_filter(const QStringList *that, const QString
|
|||
{
|
||||
QStringMatcher matcher(str, cs);
|
||||
QStringList res;
|
||||
for (int i = 0; i < that->size(); ++i)
|
||||
for (qsizetype i = 0; i < that->size(); ++i)
|
||||
if (matcher.indexIn(that->at(i)) != -1)
|
||||
res << that->at(i);
|
||||
return res;
|
||||
|
@ -399,7 +399,7 @@ bool QtPrivate::QStringList_contains(const QStringList *that, QLatin1String str,
|
|||
}
|
||||
|
||||
/*!
|
||||
\fn bool QStringList::indexOf(QStringView str, int from) const
|
||||
\fn bool QStringList::indexOf(QStringView str, qsizetype from) const
|
||||
\overload
|
||||
\since 5.13
|
||||
|
||||
|
@ -411,7 +411,7 @@ bool QtPrivate::QStringList_contains(const QStringList *that, QLatin1String str,
|
|||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QStringList::indexOf(QLatin1String str, int from) const
|
||||
\fn bool QStringList::indexOf(QLatin1String str, qsizetype from) const
|
||||
\overload
|
||||
\since 5.13
|
||||
|
||||
|
@ -423,7 +423,7 @@ bool QtPrivate::QStringList_contains(const QStringList *that, QLatin1String str,
|
|||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QStringList::lastIndexOf(QStringView str, int from) const
|
||||
\fn bool QStringList::lastIndexOf(QStringView str, qsizetype from) const
|
||||
\overload
|
||||
\since 5.13
|
||||
|
||||
|
@ -436,7 +436,7 @@ bool QtPrivate::QStringList_contains(const QStringList *that, QLatin1String str,
|
|||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QStringList::lastIndexOf(QLatin1String str, int from) const
|
||||
\fn bool QStringList::lastIndexOf(QLatin1String str, qsizetype from) const
|
||||
\overload
|
||||
\since 5.13
|
||||
|
||||
|
@ -460,7 +460,7 @@ bool QtPrivate::QStringList_contains(const QStringList *that, QLatin1String str,
|
|||
QStringList QtPrivate::QStringList_filter(const QStringList *that, const QRegularExpression &re)
|
||||
{
|
||||
QStringList res;
|
||||
for (int i = 0; i < that->size(); ++i) {
|
||||
for (qsizetype i = 0; i < that->size(); ++i) {
|
||||
if (that->at(i).contains(re))
|
||||
res << that->at(i);
|
||||
}
|
||||
|
@ -506,7 +506,7 @@ QStringList QtPrivate::QStringList_filter(const QStringList *that, const QRegula
|
|||
void QtPrivate::QStringList_replaceInStrings(QStringList *that, QStringView before,
|
||||
QStringView after, Qt::CaseSensitivity cs)
|
||||
{
|
||||
for (int i = 0; i < that->size(); ++i)
|
||||
for (qsizetype i = 0; i < that->size(); ++i)
|
||||
(*that)[i].replace(before.data(), before.length(), after.data(), after.length(), cs);
|
||||
}
|
||||
|
||||
|
@ -515,7 +515,7 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, QStringView befo
|
|||
void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QString &before,
|
||||
const QString &after, Qt::CaseSensitivity cs)
|
||||
{
|
||||
for (int i = 0; i < that->size(); ++i)
|
||||
for (qsizetype i = 0; i < that->size(); ++i)
|
||||
(*that)[i].replace(before, after, cs);
|
||||
}
|
||||
#endif
|
||||
|
@ -546,14 +546,14 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QString &b
|
|||
*/
|
||||
void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegularExpression &re, const QString &after)
|
||||
{
|
||||
for (int i = 0; i < that->size(); ++i)
|
||||
for (qsizetype i = 0; i < that->size(); ++i)
|
||||
(*that)[i].replace(re, after);
|
||||
}
|
||||
#endif // QT_CONFIG(regularexpression)
|
||||
|
||||
static int accumulatedSize(const QStringList &list, int seplen)
|
||||
static qsizetype accumulatedSize(const QStringList &list, qsizetype seplen)
|
||||
{
|
||||
int result = 0;
|
||||
qsizetype result = 0;
|
||||
if (!list.isEmpty()) {
|
||||
for (const auto &e : list)
|
||||
result += e.size() + seplen;
|
||||
|
@ -579,16 +579,16 @@ static int accumulatedSize(const QStringList &list, int seplen)
|
|||
\since 5.0
|
||||
\overload join()
|
||||
*/
|
||||
QString QtPrivate::QStringList_join(const QStringList *that, const QChar *sep, int seplen)
|
||||
QString QtPrivate::QStringList_join(const QStringList *that, const QChar *sep, qsizetype seplen)
|
||||
{
|
||||
const int totalLength = accumulatedSize(*that, seplen);
|
||||
const int size = that->size();
|
||||
const qsizetype totalLength = accumulatedSize(*that, seplen);
|
||||
const qsizetype size = that->size();
|
||||
|
||||
QString res;
|
||||
if (totalLength == 0)
|
||||
return res;
|
||||
res.reserve(totalLength);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
for (qsizetype i = 0; i < size; ++i) {
|
||||
if (i)
|
||||
res.append(sep, seplen);
|
||||
res += that->at(i);
|
||||
|
@ -666,7 +666,7 @@ QString QtPrivate::QStringList_join(const QStringList *that, QStringView sep)
|
|||
|
||||
#if QT_CONFIG(regularexpression)
|
||||
/*!
|
||||
\fn int QStringList::indexOf(const QRegularExpression &re, int from) const
|
||||
\fn qsizetype QStringList::indexOf(const QRegularExpression &re, qsizetype from) const
|
||||
\overload
|
||||
\since 5.0
|
||||
|
||||
|
@ -676,15 +676,15 @@ QString QtPrivate::QStringList_join(const QStringList *that, QStringView sep)
|
|||
|
||||
\sa lastIndexOf()
|
||||
*/
|
||||
int QtPrivate::QStringList_indexOf(const QStringList *that, const QRegularExpression &re, int from)
|
||||
qsizetype QtPrivate::QStringList_indexOf(const QStringList *that, const QRegularExpression &re, qsizetype from)
|
||||
{
|
||||
if (from < 0)
|
||||
from = qMax(from + that->size(), 0);
|
||||
from = qMax(from + that->size(), qsizetype(0));
|
||||
|
||||
QString exactPattern = QRegularExpression::anchoredPattern(re.pattern());
|
||||
QRegularExpression exactRe(exactPattern, re.patternOptions());
|
||||
|
||||
for (int i = from; i < that->size(); ++i) {
|
||||
for (qsizetype i = from; i < that->size(); ++i) {
|
||||
QRegularExpressionMatch m = exactRe.match(that->at(i));
|
||||
if (m.hasMatch())
|
||||
return i;
|
||||
|
@ -693,7 +693,7 @@ int QtPrivate::QStringList_indexOf(const QStringList *that, const QRegularExpres
|
|||
}
|
||||
|
||||
/*!
|
||||
\fn int QStringList::lastIndexOf(const QRegularExpression &re, int from) const
|
||||
\fn qsizetype QStringList::lastIndexOf(const QRegularExpression &re, qsizetype from) const
|
||||
\overload
|
||||
\since 5.0
|
||||
|
||||
|
@ -704,7 +704,7 @@ int QtPrivate::QStringList_indexOf(const QStringList *that, const QRegularExpres
|
|||
|
||||
\sa indexOf()
|
||||
*/
|
||||
int QtPrivate::QStringList_lastIndexOf(const QStringList *that, const QRegularExpression &re, int from)
|
||||
qsizetype QtPrivate::QStringList_lastIndexOf(const QStringList *that, const QRegularExpression &re, qsizetype from)
|
||||
{
|
||||
if (from < 0)
|
||||
from += that->size();
|
||||
|
@ -714,7 +714,7 @@ int QtPrivate::QStringList_lastIndexOf(const QStringList *that, const QRegularEx
|
|||
QString exactPattern = QRegularExpression::anchoredPattern(re.pattern());
|
||||
QRegularExpression exactRe(exactPattern, re.patternOptions());
|
||||
|
||||
for (int i = from; i >= 0; --i) {
|
||||
for (qsizetype i = from; i >= 0; --i) {
|
||||
QRegularExpressionMatch m = exactRe.match(that->at(i));
|
||||
if (m.hasMatch())
|
||||
return i;
|
||||
|
@ -724,7 +724,7 @@ int QtPrivate::QStringList_lastIndexOf(const QStringList *that, const QRegularEx
|
|||
#endif // QT_CONFIG(regularexpression)
|
||||
|
||||
/*!
|
||||
\fn int QStringList::removeDuplicates()
|
||||
\fn qsizetype QStringList::removeDuplicates()
|
||||
|
||||
\since 4.5
|
||||
|
||||
|
@ -734,14 +734,14 @@ int QtPrivate::QStringList_lastIndexOf(const QStringList *that, const QRegularEx
|
|||
|
||||
Returns the number of removed entries.
|
||||
*/
|
||||
int QtPrivate::QStringList_removeDuplicates(QStringList *that)
|
||||
qsizetype QtPrivate::QStringList_removeDuplicates(QStringList *that)
|
||||
{
|
||||
int n = that->size();
|
||||
int j = 0;
|
||||
qsizetype n = that->size();
|
||||
qsizetype j = 0;
|
||||
|
||||
QDuplicateTracker<QString> seen;
|
||||
seen.reserve(n);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
for (qsizetype i = 0; i < n; ++i) {
|
||||
const QString &s = that->at(i);
|
||||
if (seen.hasSeen(s))
|
||||
continue;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2020 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Intel Corporation.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
|
@ -71,7 +71,7 @@ protected:
|
|||
#endif
|
||||
public:
|
||||
inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive);
|
||||
inline int removeDuplicates();
|
||||
inline qsizetype removeDuplicates();
|
||||
|
||||
#if QT_STRINGVIEW_LEVEL < 2
|
||||
inline QString join(const QString &sep) const;
|
||||
|
@ -134,15 +134,15 @@ public:
|
|||
inline QStringList &operator<<(const QList<QString> &l)
|
||||
{ *this += l; return *this; }
|
||||
|
||||
inline int indexOf(QStringView str, int from = 0) const;
|
||||
inline int indexOf(QLatin1String str, int from = 0) const;
|
||||
inline qsizetype indexOf(QStringView str, qsizetype from = 0) const;
|
||||
inline qsizetype indexOf(QLatin1String str, qsizetype from = 0) const;
|
||||
|
||||
inline int lastIndexOf(QStringView str, int from = -1) const;
|
||||
inline int lastIndexOf(QLatin1String str, int from = -1) const;
|
||||
inline qsizetype lastIndexOf(QStringView str, qsizetype from = -1) const;
|
||||
inline qsizetype lastIndexOf(QLatin1String str, qsizetype from = -1) const;
|
||||
|
||||
#if QT_CONFIG(regularexpression)
|
||||
inline int indexOf(const QRegularExpression &re, int from = 0) const;
|
||||
inline int lastIndexOf(const QRegularExpression &re, int from = -1) const;
|
||||
inline qsizetype indexOf(const QRegularExpression &re, qsizetype from = 0) const;
|
||||
inline qsizetype lastIndexOf(const QRegularExpression &re, qsizetype from = -1) const;
|
||||
#endif // QT_CONFIG(regularexpression)
|
||||
|
||||
using QList<QString>::indexOf;
|
||||
|
@ -159,9 +159,9 @@ inline const QStringList *QListSpecialMethods<QString>::self() const
|
|||
|
||||
namespace QtPrivate {
|
||||
void Q_CORE_EXPORT QStringList_sort(QStringList *that, Qt::CaseSensitivity cs);
|
||||
int Q_CORE_EXPORT QStringList_removeDuplicates(QStringList *that);
|
||||
qsizetype Q_CORE_EXPORT QStringList_removeDuplicates(QStringList *that);
|
||||
QString Q_CORE_EXPORT QStringList_join(const QStringList *that, QStringView sep);
|
||||
QString Q_CORE_EXPORT QStringList_join(const QStringList *that, const QChar *sep, int seplen);
|
||||
QString Q_CORE_EXPORT QStringList_join(const QStringList *that, const QChar *sep, qsizetype seplen);
|
||||
Q_CORE_EXPORT QString QStringList_join(const QStringList &list, QLatin1String sep);
|
||||
QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, QStringView str,
|
||||
Qt::CaseSensitivity cs);
|
||||
|
@ -185,8 +185,8 @@ namespace QtPrivate {
|
|||
#if QT_CONFIG(regularexpression)
|
||||
void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, const QRegularExpression &rx, const QString &after);
|
||||
QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, const QRegularExpression &re);
|
||||
int Q_CORE_EXPORT QStringList_indexOf(const QStringList *that, const QRegularExpression &re, int from);
|
||||
int Q_CORE_EXPORT QStringList_lastIndexOf(const QStringList *that, const QRegularExpression &re, int from);
|
||||
qsizetype Q_CORE_EXPORT QStringList_indexOf(const QStringList *that, const QRegularExpression &re, qsizetype from);
|
||||
qsizetype Q_CORE_EXPORT QStringList_lastIndexOf(const QStringList *that, const QRegularExpression &re, qsizetype from);
|
||||
#endif // QT_CONFIG(regularexpression)
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ inline void QListSpecialMethods<QString>::sort(Qt::CaseSensitivity cs)
|
|||
QtPrivate::QStringList_sort(self(), cs);
|
||||
}
|
||||
|
||||
inline int QListSpecialMethods<QString>::removeDuplicates()
|
||||
inline qsizetype QListSpecialMethods<QString>::removeDuplicates()
|
||||
{
|
||||
return QtPrivate::QStringList_removeDuplicates(self());
|
||||
}
|
||||
|
@ -284,22 +284,22 @@ inline QStringList operator+(const QList<QString> &one, const QStringList &other
|
|||
return n;
|
||||
}
|
||||
|
||||
inline int QStringList::indexOf(QStringView string, int from) const
|
||||
inline qsizetype QStringList::indexOf(QStringView string, qsizetype from) const
|
||||
{
|
||||
return QtPrivate::indexOf<QString, QStringView>(*this, string, from);
|
||||
}
|
||||
|
||||
inline int QStringList::indexOf(QLatin1String string, int from) const
|
||||
inline qsizetype QStringList::indexOf(QLatin1String string, qsizetype from) const
|
||||
{
|
||||
return QtPrivate::indexOf<QString, QLatin1String>(*this, string, from);
|
||||
}
|
||||
|
||||
inline int QStringList::lastIndexOf(QStringView string, int from) const
|
||||
inline qsizetype QStringList::lastIndexOf(QStringView string, qsizetype from) const
|
||||
{
|
||||
return QtPrivate::lastIndexOf<QString, QStringView>(*this, string, from);
|
||||
}
|
||||
|
||||
inline int QStringList::lastIndexOf(QLatin1String string, int from) const
|
||||
inline qsizetype QStringList::lastIndexOf(QLatin1String string, qsizetype from) const
|
||||
{
|
||||
return QtPrivate::lastIndexOf<QString, QLatin1String>(*this, string, from);
|
||||
}
|
||||
|
@ -316,12 +316,12 @@ inline QStringList QListSpecialMethods<QString>::filter(const QRegularExpression
|
|||
return QtPrivate::QStringList_filter(self(), rx);
|
||||
}
|
||||
|
||||
inline int QStringList::indexOf(const QRegularExpression &rx, int from) const
|
||||
inline qsizetype QStringList::indexOf(const QRegularExpression &rx, qsizetype from) const
|
||||
{
|
||||
return QtPrivate::QStringList_indexOf(this, rx, from);
|
||||
}
|
||||
|
||||
inline int QStringList::lastIndexOf(const QRegularExpression &rx, int from) const
|
||||
inline qsizetype QStringList::lastIndexOf(const QRegularExpression &rx, qsizetype from) const
|
||||
{
|
||||
return QtPrivate::QStringList_lastIndexOf(this, rx, from);
|
||||
}
|
||||
|
|
|
@ -54,8 +54,8 @@
|
|||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QtPrivate {
|
||||
template <typename V, typename U> int indexOf(const QList<V> &list, const U &u, int from);
|
||||
template <typename V, typename U> int lastIndexOf(const QList<V> &list, const U &u, int from);
|
||||
template <typename V, typename U> qsizetype indexOf(const QList<V> &list, const U &u, qsizetype from);
|
||||
template <typename V, typename U> qsizetype lastIndexOf(const QList<V> &list, const U &u, qsizetype from);
|
||||
}
|
||||
|
||||
template <typename T> struct QListSpecialMethods
|
||||
|
@ -79,8 +79,8 @@ class QList
|
|||
|
||||
DataPointer d;
|
||||
|
||||
template <typename V, typename U> friend int QtPrivate::indexOf(const QList<V> &list, const U &u, int from);
|
||||
template <typename V, typename U> friend int QtPrivate::lastIndexOf(const QList<V> &list, const U &u, int from);
|
||||
template <typename V, typename U> friend qsizetype QtPrivate::indexOf(const QList<V> &list, const U &u, qsizetype from);
|
||||
template <typename V, typename U> friend qsizetype QtPrivate::lastIndexOf(const QList<V> &list, const U &u, qsizetype from);
|
||||
|
||||
public:
|
||||
typedef T Type;
|
||||
|
@ -89,7 +89,7 @@ public:
|
|||
typedef const value_type *const_pointer;
|
||||
typedef value_type &reference;
|
||||
typedef const value_type &const_reference;
|
||||
typedef int size_type;
|
||||
typedef qsizetype size_type;
|
||||
typedef qptrdiff difference_type;
|
||||
typedef typename Data::iterator iterator;
|
||||
typedef typename Data::const_iterator const_iterator;
|
||||
|
@ -101,7 +101,7 @@ public:
|
|||
using rvalue_ref = typename std::conditional<DataPointer::pass_parameter_by_value, DisableRValueRefs, T &&>::type;
|
||||
|
||||
private:
|
||||
void resize_internal(int i, Qt::Initialization);
|
||||
void resize_internal(qsizetype i, Qt::Initialization);
|
||||
bool isValidIterator(const_iterator i) const
|
||||
{
|
||||
const std::less<const T*> less = {};
|
||||
|
@ -115,13 +115,13 @@ public:
|
|||
|
||||
public:
|
||||
QList() = default;
|
||||
explicit QList(int size)
|
||||
explicit QList(qsizetype size)
|
||||
: d(Data::allocate(size))
|
||||
{
|
||||
if (size)
|
||||
d->appendInitialize(size);
|
||||
}
|
||||
QList(int size, const T &t)
|
||||
QList(qsizetype size, const T &t)
|
||||
: d(Data::allocate(size))
|
||||
{
|
||||
if (size)
|
||||
|
@ -177,27 +177,27 @@ public:
|
|||
return !(l == r);
|
||||
}
|
||||
|
||||
int size() const noexcept { return int(d->size); }
|
||||
int count() const noexcept { return size(); }
|
||||
int length() const noexcept { return size(); }
|
||||
qsizetype size() const noexcept { return d->size; }
|
||||
qsizetype count() const noexcept { return size(); }
|
||||
qsizetype length() const noexcept { return size(); }
|
||||
|
||||
inline bool isEmpty() const noexcept { return d->size == 0; }
|
||||
|
||||
void resize(int size)
|
||||
void resize(qsizetype size)
|
||||
{
|
||||
resize_internal(size, Qt::Uninitialized);
|
||||
if (size > this->size())
|
||||
d->appendInitialize(size);
|
||||
}
|
||||
void resize(int size, parameter_type c)
|
||||
void resize(qsizetype size, parameter_type c)
|
||||
{
|
||||
resize_internal(size, Qt::Uninitialized);
|
||||
if (size > this->size())
|
||||
d->copyAppend(size - this->size(), c);
|
||||
}
|
||||
|
||||
inline int capacity() const { return int(d->constAllocatedCapacity()); }
|
||||
void reserve(int size);
|
||||
inline qsizetype capacity() const { return qsizetype(d->constAllocatedCapacity()); }
|
||||
void reserve(qsizetype size);
|
||||
inline void squeeze();
|
||||
|
||||
void detach() { d.detach(); }
|
||||
|
@ -220,18 +220,18 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
const_reference at(int i) const noexcept
|
||||
const_reference at(qsizetype i) const noexcept
|
||||
{
|
||||
Q_ASSERT_X(size_t(i) < size_t(d->size), "QList::at", "index out of range");
|
||||
return data()[i];
|
||||
}
|
||||
reference operator[](int i)
|
||||
reference operator[](qsizetype i)
|
||||
{
|
||||
Q_ASSERT_X(size_t(i) < size_t(d->size), "QList::operator[]", "index out of range");
|
||||
detach();
|
||||
return data()[i];
|
||||
}
|
||||
const_reference operator[](int i) const noexcept { return at(i); }
|
||||
const_reference operator[](qsizetype i) const noexcept { return at(i); }
|
||||
void append(const_reference t)
|
||||
{ append(const_iterator(std::addressof(t)), const_iterator(std::addressof(t)) + 1); }
|
||||
void append(const_iterator i1, const_iterator i2);
|
||||
|
@ -243,15 +243,15 @@ public:
|
|||
template <typename ...Args>
|
||||
reference emplaceBack(Args&&... args) { return *emplace(count(), std::forward<Args>(args)...); }
|
||||
|
||||
iterator insert(int i, parameter_type t)
|
||||
iterator insert(qsizetype i, parameter_type t)
|
||||
{ return insert(i, 1, t); }
|
||||
iterator insert(int i, int n, parameter_type t);
|
||||
iterator insert(qsizetype i, qsizetype n, parameter_type t);
|
||||
iterator insert(const_iterator before, parameter_type t)
|
||||
{
|
||||
Q_ASSERT_X(isValidIterator(before), "QList::insert", "The specified iterator argument 'before' is invalid");
|
||||
return insert(before, 1, t);
|
||||
}
|
||||
iterator insert(const_iterator before, int n, parameter_type t)
|
||||
iterator insert(const_iterator before, qsizetype n, parameter_type t)
|
||||
{
|
||||
Q_ASSERT_X(isValidIterator(before), "QList::insert", "The specified iterator argument 'before' is invalid");
|
||||
return insert(std::distance(constBegin(), before), n, t);
|
||||
|
@ -261,7 +261,7 @@ public:
|
|||
Q_ASSERT_X(isValidIterator(before), "QList::insert", "The specified iterator argument 'before' is invalid");
|
||||
return insert(std::distance(constBegin(), before), std::move(t));
|
||||
}
|
||||
iterator insert(int i, rvalue_ref t) { return emplace(i, std::move(t)); }
|
||||
iterator insert(qsizetype i, rvalue_ref t) { return emplace(i, std::move(t)); }
|
||||
|
||||
template <typename ...Args>
|
||||
iterator emplace(const_iterator before, Args&&... args)
|
||||
|
@ -271,72 +271,72 @@ public:
|
|||
}
|
||||
|
||||
template <typename ...Args>
|
||||
iterator emplace(int i, Args&&... args);
|
||||
iterator emplace(qsizetype i, Args&&... args);
|
||||
#if 0
|
||||
template< class InputIt >
|
||||
iterator insert( const_iterator pos, InputIt first, InputIt last );
|
||||
iterator insert( const_iterator pos, std::initializer_list<T> ilist );
|
||||
#endif
|
||||
void replace(int i, const T &t)
|
||||
void replace(qsizetype i, const T &t)
|
||||
{
|
||||
Q_ASSERT_X(i >= 0 && i < d->size, "QList<T>::replace", "index out of range");
|
||||
const T copy(t);
|
||||
data()[i] = copy;
|
||||
}
|
||||
void replace(int i, rvalue_ref t)
|
||||
void replace(qsizetype i, rvalue_ref t)
|
||||
{
|
||||
Q_ASSERT_X(i >= 0 && i < d->size, "QList<T>::replace", "index out of range");
|
||||
const T copy(std::move(t));
|
||||
data()[i] = std::move(copy);
|
||||
}
|
||||
|
||||
void remove(int i, int n = 1);
|
||||
void remove(qsizetype i, qsizetype n = 1);
|
||||
void removeFirst() { Q_ASSERT(!isEmpty()); remove(0); }
|
||||
void removeLast() { Q_ASSERT(!isEmpty()); remove(size() - 1); }
|
||||
value_type takeFirst() { Q_ASSERT(!isEmpty()); value_type v = std::move(first()); remove(0); return v; }
|
||||
value_type takeLast() { Q_ASSERT(!isEmpty()); value_type v = std::move(last()); remove(size() - 1); return v; }
|
||||
|
||||
QList<T> &fill(parameter_type t, int size = -1);
|
||||
QList<T> &fill(parameter_type t, qsizetype size = -1);
|
||||
|
||||
int indexOf(const T &t, int from = 0) const noexcept;
|
||||
int lastIndexOf(const T &t, int from = -1) const noexcept;
|
||||
qsizetype indexOf(const T &t, qsizetype from = 0) const noexcept;
|
||||
qsizetype lastIndexOf(const T &t, qsizetype from = -1) const noexcept;
|
||||
bool contains(const T &t) const noexcept
|
||||
{
|
||||
return indexOf(t) != -1;
|
||||
}
|
||||
int count(const T &t) const noexcept
|
||||
qsizetype count(const T &t) const noexcept
|
||||
{
|
||||
return int(std::count(&*cbegin(), &*cend(), t));
|
||||
return qsizetype(std::count(&*cbegin(), &*cend(), t));
|
||||
}
|
||||
|
||||
// QList compatibility
|
||||
void removeAt(int i) { remove(i); }
|
||||
int removeAll(const T &t)
|
||||
void removeAt(qsizetype i) { remove(i); }
|
||||
qsizetype removeAll(const T &t)
|
||||
{
|
||||
const const_iterator ce = this->cend(), cit = std::find(this->cbegin(), ce, t);
|
||||
if (cit == ce)
|
||||
return 0;
|
||||
int index = cit - this->cbegin();
|
||||
qsizetype index = cit - this->cbegin();
|
||||
// next operation detaches, so ce, cit, t may become invalidated:
|
||||
const T tCopy = t;
|
||||
const iterator e = end(), it = std::remove(begin() + index, e, tCopy);
|
||||
const int result = std::distance(it, e);
|
||||
const qsizetype result = std::distance(it, e);
|
||||
erase(it, e);
|
||||
return result;
|
||||
}
|
||||
bool removeOne(const T &t)
|
||||
{
|
||||
const int i = indexOf(t);
|
||||
const qsizetype i = indexOf(t);
|
||||
if (i < 0)
|
||||
return false;
|
||||
remove(i);
|
||||
return true;
|
||||
}
|
||||
T takeAt(int i) { T t = std::move((*this)[i]); remove(i); return t; }
|
||||
void move(int from, int to)
|
||||
T takeAt(qsizetype i) { T t = std::move((*this)[i]); remove(i); return t; }
|
||||
void move(qsizetype from, qsizetype to)
|
||||
{
|
||||
Q_ASSERT_X(from >= 0 && from < size(), "QList::move(int,int)", "'from' is out-of-range");
|
||||
Q_ASSERT_X(to >= 0 && to < size(), "QList::move(int,int)", "'to' is out-of-range");
|
||||
Q_ASSERT_X(from >= 0 && from < size(), "QList::move(qsizetype, qsizetype)", "'from' is out-of-range");
|
||||
Q_ASSERT_X(to >= 0 && to < size(), "QList::move(qsizetype, qsizetype)", "'to' is out-of-range");
|
||||
if (from == to) // don't detach when no-op
|
||||
return;
|
||||
detach();
|
||||
|
@ -376,12 +376,12 @@ public:
|
|||
inline const T &constLast() const { Q_ASSERT(!isEmpty()); return *(end()-1); }
|
||||
inline bool startsWith(const T &t) const { return !isEmpty() && first() == t; }
|
||||
inline bool endsWith(const T &t) const { return !isEmpty() && last() == t; }
|
||||
QList<T> mid(int pos, int len = -1) const;
|
||||
QList<T> mid(qsizetype pos, qsizetype len = -1) const;
|
||||
|
||||
T value(int i) const { return value(i, T()); }
|
||||
T value(int i, const T &defaultValue) const;
|
||||
T value(qsizetype i) const { return value(i, T()); }
|
||||
T value(qsizetype i, const T &defaultValue) const;
|
||||
|
||||
void swapItemsAt(int i, int j) {
|
||||
void swapItemsAt(qsizetype i, qsizetype j) {
|
||||
Q_ASSERT_X(i >= 0 && i < size() && j >= 0 && j < size(),
|
||||
"QList<T>::swap", "index out of range");
|
||||
detach();
|
||||
|
@ -429,7 +429,7 @@ public:
|
|||
static inline QList<T> fromVector(const QList<T> &vector) { return vector; }
|
||||
inline QList<T> toVector() const { return *this; }
|
||||
|
||||
template<int N>
|
||||
template<qsizetype N>
|
||||
static QList<T> fromReadOnlyData(const T (&t)[N])
|
||||
{
|
||||
return QList<T>({ nullptr, const_cast<T *>(t), N });
|
||||
|
@ -444,7 +444,7 @@ QList(InputIterator, InputIterator) -> QList<ValueType>;
|
|||
#endif
|
||||
|
||||
template <typename T>
|
||||
inline void QList<T>::resize_internal(int newSize, Qt::Initialization)
|
||||
inline void QList<T>::resize_internal(qsizetype newSize, Qt::Initialization)
|
||||
{
|
||||
Q_ASSERT(newSize >= 0);
|
||||
|
||||
|
@ -463,7 +463,7 @@ inline void QList<T>::resize_internal(int newSize, Qt::Initialization)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void QList<T>::reserve(int asize)
|
||||
void QList<T>::reserve(qsizetype asize)
|
||||
{
|
||||
// capacity() == 0 for immutable data, so this will force a detaching below
|
||||
if (asize <= capacity()) {
|
||||
|
@ -496,7 +496,7 @@ inline void QList<T>::squeeze()
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
inline void QList<T>::remove(int i, int n)
|
||||
inline void QList<T>::remove(qsizetype i, qsizetype n)
|
||||
{
|
||||
Q_ASSERT_X(size_t(i) + size_t(n) <= size_t(d->size), "QList::remove", "index out of range");
|
||||
Q_ASSERT_X(n >= 0, "QList::remove", "invalid count");
|
||||
|
@ -531,7 +531,7 @@ void QList<T>::prepend(rvalue_ref t)
|
|||
{ insert(0, std::move(t)); }
|
||||
|
||||
template<typename T>
|
||||
inline T QList<T>::value(int i, const T &defaultValue) const
|
||||
inline T QList<T>::value(qsizetype i, const T &defaultValue) const
|
||||
{
|
||||
return size_t(i) < size_t(d->size) ? at(i) : defaultValue;
|
||||
}
|
||||
|
@ -556,7 +556,7 @@ inline void QList<T>::append(const_iterator i1, const_iterator i2)
|
|||
|
||||
template <typename T>
|
||||
inline typename QList<T>::iterator
|
||||
QList<T>::insert(int i, int n, parameter_type t)
|
||||
QList<T>::insert(qsizetype i, qsizetype n, parameter_type t)
|
||||
{
|
||||
Q_ASSERT_X(size_t(i) <= size_t(d->size), "QList<T>::insert", "index out of range");
|
||||
|
||||
|
@ -590,7 +590,7 @@ QList<T>::insert(int i, int n, parameter_type t)
|
|||
template <typename T>
|
||||
template <typename ...Args>
|
||||
typename QList<T>::iterator
|
||||
QList<T>::emplace(int i, Args&&... args)
|
||||
QList<T>::emplace(qsizetype i, Args&&... args)
|
||||
{
|
||||
Q_ASSERT_X(i >= 0 && i <= d->size, "QList<T>::insert", "index out of range");
|
||||
|
||||
|
@ -631,15 +631,15 @@ typename QList<T>::iterator QList<T>::erase(const_iterator abegin, const_iterato
|
|||
Q_ASSERT_X(isValidIterator(aend), "QList::erase", "The specified iterator argument 'aend' is invalid");
|
||||
Q_ASSERT(aend >= abegin);
|
||||
|
||||
int i = std::distance(d.constBegin(), abegin);
|
||||
int n = std::distance(abegin, aend);
|
||||
qsizetype i = std::distance(d.constBegin(), abegin);
|
||||
qsizetype n = std::distance(abegin, aend);
|
||||
remove(i, n);
|
||||
|
||||
return d.begin() + i;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline QList<T> &QList<T>::fill(parameter_type t, int newSize)
|
||||
inline QList<T> &QList<T>::fill(parameter_type t, qsizetype newSize)
|
||||
{
|
||||
if (newSize == -1)
|
||||
newSize = size();
|
||||
|
@ -661,22 +661,22 @@ inline QList<T> &QList<T>::fill(parameter_type t, int newSize)
|
|||
|
||||
namespace QtPrivate {
|
||||
template <typename T, typename U>
|
||||
int indexOf(const QList<T> &vector, const U &u, int from)
|
||||
qsizetype indexOf(const QList<T> &vector, const U &u, qsizetype from)
|
||||
{
|
||||
if (from < 0)
|
||||
from = qMax(from + vector.size(), 0);
|
||||
from = qMax(from + vector.size(), qsizetype(0));
|
||||
if (from < vector.size()) {
|
||||
auto n = vector.begin() + from - 1;
|
||||
auto e = vector.end();
|
||||
while (++n != e)
|
||||
if (*n == u)
|
||||
return int(n - vector.begin());
|
||||
return qsizetype(n - vector.begin());
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
int lastIndexOf(const QList<T> &vector, const U &u, int from)
|
||||
qsizetype lastIndexOf(const QList<T> &vector, const U &u, qsizetype from)
|
||||
{
|
||||
if (from < 0)
|
||||
from += vector.d->size;
|
||||
|
@ -687,7 +687,7 @@ int lastIndexOf(const QList<T> &vector, const U &u, int from)
|
|||
auto n = vector.begin() + from + 1;
|
||||
while (n != b) {
|
||||
if (*--n == u)
|
||||
return int(n - b);
|
||||
return qsizetype(n - b);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
@ -695,19 +695,19 @@ int lastIndexOf(const QList<T> &vector, const U &u, int from)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
int QList<T>::indexOf(const T &t, int from) const noexcept
|
||||
qsizetype QList<T>::indexOf(const T &t, qsizetype from) const noexcept
|
||||
{
|
||||
return QtPrivate::indexOf<T, T>(*this, t, from);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int QList<T>::lastIndexOf(const T &t, int from) const noexcept
|
||||
qsizetype QList<T>::lastIndexOf(const T &t, qsizetype from) const noexcept
|
||||
{
|
||||
return QtPrivate::lastIndexOf(*this, t, from);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline QList<T> QList<T>::mid(int pos, int len) const
|
||||
inline QList<T> QList<T>::mid(qsizetype pos, qsizetype len) const
|
||||
{
|
||||
qsizetype p = pos;
|
||||
qsizetype l = len;
|
||||
|
|
|
@ -3132,7 +3132,7 @@ QMimeData *QStandardItemModel::mimeData(const QModelIndexList &indexes) const
|
|||
if (itemsSet.contains(item)) //if the item is selection 'top-level', stream its position
|
||||
stream << item->row() << item->column();
|
||||
|
||||
stream << *item << item->columnCount() << item->d_ptr->children.count();
|
||||
stream << *item << item->columnCount() << int(item->d_ptr->children.count());
|
||||
stack += item->d_ptr->children;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ namespace QPdf {
|
|||
ByteStream &operator <<(const ByteStream &src);
|
||||
ByteStream &operator <<(qreal val);
|
||||
ByteStream &operator <<(int val);
|
||||
ByteStream &operator <<(qint64 val) { return (*this << int(val)); }
|
||||
ByteStream &operator <<(const QPointF &p);
|
||||
// Note that the stream may be invalidated by calls that insert data.
|
||||
QIODevice *stream();
|
||||
|
|
|
@ -505,7 +505,7 @@ bool QRhiVulkan::create(QRhi::Flags flags)
|
|||
for (const VkExtensionProperties &p : qAsConst(extProps))
|
||||
devExts.append({ p.extensionName, p.specVersion });
|
||||
}
|
||||
qCDebug(QRHI_LOG_INFO, "%d device extensions available", devExts.count());
|
||||
qCDebug(QRHI_LOG_INFO, "%d device extensions available", int(devExts.count()));
|
||||
|
||||
QVector<const char *> requestedDevExts;
|
||||
requestedDevExts.append("VK_KHR_swapchain");
|
||||
|
|
|
@ -877,7 +877,7 @@ bool QTextDocumentPrivate::unite(uint f)
|
|||
|
||||
int QTextDocumentPrivate::undoRedo(bool undo)
|
||||
{
|
||||
PMDEBUG("%s, undoState=%d, undoStack size=%d", undo ? "undo:" : "redo:", undoState, undoStack.size());
|
||||
PMDEBUG("%s, undoState=%d, undoStack size=%d", undo ? "undo:" : "redo:", undoState, int(undoStack.size()));
|
||||
if (!undoEnabled || (undo && undoState == 0) || (!undo && undoState == undoStack.size()))
|
||||
return -1;
|
||||
|
||||
|
|
|
@ -1830,7 +1830,7 @@ void QTextLine::layout_helper(int maxGlyphs)
|
|||
int newItem = eng->findItem(line.from);
|
||||
Q_ASSERT(newItem >= 0);
|
||||
|
||||
LB_DEBUG("from: %d: item=%d, total %d, width available %f", line.from, newItem, eng->layoutData->items.size(), line.width.toReal());
|
||||
LB_DEBUG("from: %d: item=%d, total %d, width available %f", line.from, newItem, int(eng->layoutData->items.size()), line.width.toReal());
|
||||
|
||||
Qt::Alignment alignment = eng->option.alignment();
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det)
|
|||
switch (blockType) {
|
||||
case MD_BLOCK_P:
|
||||
if (!m_listStack.isEmpty())
|
||||
qCDebug(lcMD, m_listItem ? "P of LI at level %d" : "P continuation inside LI at level %d", m_listStack.count());
|
||||
qCDebug(lcMD, m_listItem ? "P of LI at level %d" : "P continuation inside LI at level %d", int(m_listStack.count()));
|
||||
else
|
||||
qCDebug(lcMD, "P");
|
||||
m_needsInsertBlock = true;
|
||||
|
@ -243,7 +243,7 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det)
|
|||
m_listFormat.setStyle(QTextListFormat::ListDisc);
|
||||
break;
|
||||
}
|
||||
qCDebug(lcMD, "UL %c level %d", detail->mark, m_listStack.count() + 1);
|
||||
qCDebug(lcMD, "UL %c level %d", detail->mark, int(m_listStack.count()) + 1);
|
||||
} break;
|
||||
case MD_BLOCK_OL: {
|
||||
if (m_needsInsertList) // list nested in an empty list
|
||||
|
@ -255,7 +255,7 @@ int QTextMarkdownImporter::cbEnterBlock(int blockType, void *det)
|
|||
m_listFormat.setIndent(m_listStack.count() + 1);
|
||||
m_listFormat.setNumberSuffix(QChar::fromLatin1(detail->mark_delimiter));
|
||||
m_listFormat.setStyle(QTextListFormat::ListDecimal);
|
||||
qCDebug(lcMD, "OL xx%d level %d", detail->mark_delimiter, m_listStack.count() + 1);
|
||||
qCDebug(lcMD, "OL xx%d level %d", detail->mark_delimiter, int(m_listStack.count()) + 1);
|
||||
} break;
|
||||
case MD_BLOCK_TD: {
|
||||
MD_BLOCK_TD_DETAIL *detail = static_cast<MD_BLOCK_TD_DETAIL *>(det);
|
||||
|
@ -326,7 +326,7 @@ int QTextMarkdownImporter::cbLeaveBlock(int blockType, void *detail)
|
|||
if (Q_UNLIKELY(m_listStack.isEmpty())) {
|
||||
qCWarning(lcMD, "list ended unexpectedly");
|
||||
} else {
|
||||
qCDebug(lcMD, "list at level %d ended", m_listStack.count());
|
||||
qCDebug(lcMD, "list at level %d ended", int(m_listStack.count()));
|
||||
m_listStack.pop();
|
||||
}
|
||||
break;
|
||||
|
@ -363,7 +363,7 @@ int QTextMarkdownImporter::cbLeaveBlock(int blockType, void *detail)
|
|||
m_cursor->movePosition(QTextCursor::End);
|
||||
break;
|
||||
case MD_BLOCK_LI:
|
||||
qCDebug(lcMD, "LI at level %d ended", m_listStack.count());
|
||||
qCDebug(lcMD, "LI at level %d ended", int(m_listStack.count()));
|
||||
m_listItem = false;
|
||||
break;
|
||||
case MD_BLOCK_CODE: {
|
||||
|
|
|
@ -86,7 +86,7 @@ static void qt_qdnsmailexchangerecord_sort(QList<QDnsMailExchangeRecord> &record
|
|||
|
||||
// Randomize the slice of records.
|
||||
while (!slice.isEmpty()) {
|
||||
const unsigned int pos = QRandomGenerator::global()->bounded(slice.size());
|
||||
const unsigned int pos = QRandomGenerator::global()->bounded(int(slice.size()));
|
||||
records[i++] = slice.takeAt(pos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3782,7 +3782,7 @@ bool QOpenGLShaderProgramPrivate::linkBinary()
|
|||
const QByteArray cacheKey = binaryProgram.cacheKey();
|
||||
if (lcOpenGLProgramDiskCache().isEnabled(QtDebugMsg))
|
||||
qCDebug(lcOpenGLProgramDiskCache, "program with %d shaders, cache key %s",
|
||||
binaryProgram.shaders.count(), cacheKey.constData());
|
||||
int(binaryProgram.shaders.count()), cacheKey.constData());
|
||||
|
||||
bool needsCompile = true;
|
||||
if (binCache.load(cacheKey, q->programId())) {
|
||||
|
|
|
@ -471,7 +471,7 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
|
|||
}
|
||||
}
|
||||
qCDebug(qLcKmsDebug, "Output %s can use %d planes: %s",
|
||||
connectorName.constData(), output.available_planes.count(), qPrintable(planeListStr));
|
||||
connectorName.constData(), int(output.available_planes.count()), qPrintable(planeListStr));
|
||||
|
||||
// This is for the EGLDevice/EGLStream backend. On some of those devices one
|
||||
// may want to target a pre-configured plane. It is probably useless for
|
||||
|
|
|
@ -1173,7 +1173,7 @@ void QAndroidInputContext::focusObjectStartComposing()
|
|||
|
||||
QInputMethodEvent event(m_composingText, {
|
||||
{ QInputMethodEvent::Cursor, absoluteCursorPos - m_composingTextStart, 1 },
|
||||
{ QInputMethodEvent::TextFormat, 0, m_composingText.length(), underlined }
|
||||
{ QInputMethodEvent::TextFormat, 0, int(m_composingText.length()), underlined }
|
||||
});
|
||||
|
||||
event.setCommitString({}, m_composingTextStart - absoluteCursorPos, m_composingText.length());
|
||||
|
@ -1450,7 +1450,7 @@ jboolean QAndroidInputContext::setComposingText(const QString &text, jint newCur
|
|||
underlined.setFontUnderline(true);
|
||||
|
||||
event = QInputMethodEvent(m_composingText, {
|
||||
{ QInputMethodEvent::TextFormat, 0, m_composingText.length(), underlined },
|
||||
{ QInputMethodEvent::TextFormat, 0, int(m_composingText.length()), underlined },
|
||||
{ QInputMethodEvent::Cursor, m_composingCursor - m_composingTextStart, 1 }
|
||||
});
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ void Generator::generateCode()
|
|||
//
|
||||
const int constCharArraySizeLimit = 65535;
|
||||
fprintf(out, "struct qt_meta_stringdata_%s_t {\n", qualifiedClassNameIdentifier.constData());
|
||||
fprintf(out, " const uint offsetsAndSize[%d];\n", strings.size()*2);
|
||||
fprintf(out, " const uint offsetsAndSize[%d];\n", int(strings.size()*2));
|
||||
{
|
||||
int stringDataLength = 0;
|
||||
int stringDataCounter = 0;
|
||||
|
@ -352,7 +352,7 @@ void Generator::generateCode()
|
|||
fprintf(out, "\n // content:\n");
|
||||
fprintf(out, " %4d, // revision\n", int(QMetaObjectPrivate::OutputRevision));
|
||||
fprintf(out, " %4d, // classname\n", stridx(cdef->qualified));
|
||||
fprintf(out, " %4d, %4d, // classinfo\n", cdef->classInfoList.count(), cdef->classInfoList.count() ? index : 0);
|
||||
fprintf(out, " %4d, %4d, // classinfo\n", int(cdef->classInfoList.count()), int(cdef->classInfoList.count() ? index : 0));
|
||||
index += cdef->classInfoList.count() * 2;
|
||||
|
||||
int methodCount = cdef->signalList.count() + cdef->slotList.count() + cdef->methodList.count();
|
||||
|
@ -369,14 +369,14 @@ void Generator::generateCode()
|
|||
- methodCount // return "parameters" don't have names
|
||||
- cdef->constructorList.count(); // "this" parameters don't have names
|
||||
|
||||
fprintf(out, " %4d, %4d, // properties\n", cdef->propertyList.count(), cdef->propertyList.count() ? index : 0);
|
||||
fprintf(out, " %4d, %4d, // properties\n", int(cdef->propertyList.count()), int(cdef->propertyList.count() ? index : 0));
|
||||
index += cdef->propertyList.count() * QMetaObjectPrivate::IntsPerProperty;
|
||||
fprintf(out, " %4d, %4d, // enums/sets\n", cdef->enumList.count(), cdef->enumList.count() ? index : 0);
|
||||
fprintf(out, " %4d, %4d, // enums/sets\n", int(cdef->enumList.count()), cdef->enumList.count() ? index : 0);
|
||||
|
||||
int enumsIndex = index;
|
||||
for (int i = 0; i < cdef->enumList.count(); ++i)
|
||||
index += 5 + (cdef->enumList.at(i).values.count() * 2);
|
||||
fprintf(out, " %4d, %4d, // constructors\n", isConstructible ? cdef->constructorList.count() : 0,
|
||||
fprintf(out, " %4d, %4d, // constructors\n", isConstructible ? int(cdef->constructorList.count()) : 0,
|
||||
isConstructible ? index : 0);
|
||||
|
||||
int flags = 0;
|
||||
|
@ -386,7 +386,7 @@ void Generator::generateCode()
|
|||
flags |= PropertyAccessInStaticMetaCall;
|
||||
}
|
||||
fprintf(out, " %4d, // flags\n", flags);
|
||||
fprintf(out, " %4d, // signalCount\n", cdef->signalList.count());
|
||||
fprintf(out, " %4d, // signalCount\n", int(cdef->signalList.count()));
|
||||
|
||||
|
||||
//
|
||||
|
@ -943,7 +943,7 @@ void Generator::generateEnums(int index)
|
|||
stridx(e.name),
|
||||
e.enumName.isNull() ? stridx(e.name) : stridx(e.enumName),
|
||||
flags,
|
||||
e.values.count(),
|
||||
int(e.values.count()),
|
||||
index);
|
||||
index += e.values.count() * 2;
|
||||
}
|
||||
|
@ -994,18 +994,18 @@ void Generator::generateMetacall()
|
|||
if (methodList.size()) {
|
||||
needElse = true;
|
||||
fprintf(out, "if (_c == QMetaObject::InvokeMetaMethod) {\n");
|
||||
fprintf(out, " if (_id < %d)\n", methodList.size());
|
||||
fprintf(out, " if (_id < %d)\n", int(methodList.size()));
|
||||
fprintf(out, " qt_static_metacall(this, _c, _id, _a);\n");
|
||||
fprintf(out, " _id -= %d;\n }", methodList.size());
|
||||
fprintf(out, " _id -= %d;\n }", int(methodList.size()));
|
||||
|
||||
fprintf(out, " else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {\n");
|
||||
fprintf(out, " if (_id < %d)\n", methodList.size());
|
||||
fprintf(out, " if (_id < %d)\n", int(methodList.size()));
|
||||
|
||||
if (methodsWithAutomaticTypesHelper(methodList).isEmpty())
|
||||
fprintf(out, " *reinterpret_cast<int*>(_a[0]) = -1;\n");
|
||||
else
|
||||
fprintf(out, " qt_static_metacall(this, _c, _id, _a);\n");
|
||||
fprintf(out, " _id -= %d;\n }", methodList.size());
|
||||
fprintf(out, " _id -= %d;\n }", int(methodList.size()));
|
||||
|
||||
}
|
||||
|
||||
|
@ -1020,7 +1020,7 @@ void Generator::generateMetacall()
|
|||
" || _c == QMetaObject::RegisterQPropertyObserver\n"
|
||||
" || _c == QMetaObject::SetQPropertyBinding) {\n"
|
||||
" qt_static_metacall(this, _c, _id, _a);\n"
|
||||
" _id -= %d;\n }", cdef->propertyList.count());
|
||||
" _id -= %d;\n }", int(cdef->propertyList.count()));
|
||||
fprintf(out, "\n#endif // QT_NO_PROPERTIES");
|
||||
}
|
||||
if (methodList.size() || cdef->propertyList.size())
|
||||
|
|
|
@ -2119,7 +2119,7 @@ void QHeaderViewPrivate::_q_sectionsAboutToBeChanged(const QList<QPersistentMode
|
|||
return;
|
||||
|
||||
layoutChangePersistentSections.clear();
|
||||
layoutChangePersistentSections.reserve(std::min(10, sectionItems.count()));
|
||||
layoutChangePersistentSections.reserve(std::min(10, int(sectionItems.count())));
|
||||
// after layoutChanged another section can be last stretched section
|
||||
if (stretchLastSection && lastSectionLogicalIdx >= 0 && lastSectionLogicalIdx < sectionItems.count()) {
|
||||
const int visual = visualIndex(lastSectionLogicalIdx);
|
||||
|
|
|
@ -2171,7 +2171,7 @@ int QTreeView::verticalOffset() const
|
|||
// ### find a faster way to do this
|
||||
d->executePostedLayout();
|
||||
int offset = 0;
|
||||
const int cnt = std::min(d->viewItems.count(), verticalScrollBar()->value());
|
||||
const int cnt = qMin(d->viewItems.count(), verticalScrollBar()->value());
|
||||
for (int i = 0; i < cnt; ++i)
|
||||
offset += d->itemHeight(i);
|
||||
return offset;
|
||||
|
|
|
@ -1860,7 +1860,7 @@ int QDateTimeEditPrivate::closestSection(int pos, bool forward) const
|
|||
|
||||
const QString text = displayText();
|
||||
if (text.size() - pos < separators.last().size() + 1)
|
||||
return forward ? LastSectionIndex : sectionNodes.size() - 1;
|
||||
return forward ? LastSectionIndex : int(sectionNodes.size() - 1);
|
||||
|
||||
updateCache(value, text);
|
||||
for (int i=0; i<sectionNodes.size(); ++i) {
|
||||
|
@ -1892,7 +1892,7 @@ int QDateTimeEditPrivate::nextPrevSection(int current, bool forward) const
|
|||
|
||||
switch (current) {
|
||||
case FirstSectionIndex: return forward ? 0 : FirstSectionIndex;
|
||||
case LastSectionIndex: return (forward ? LastSectionIndex : sectionNodes.size() - 1);
|
||||
case LastSectionIndex: return (forward ? LastSectionIndex : int(sectionNodes.size() - 1));
|
||||
case NoSectionIndex: return FirstSectionIndex;
|
||||
default: break;
|
||||
}
|
||||
|
|
|
@ -1796,7 +1796,7 @@ void QDockAreaLayoutInfo::saveState(QDataStream &stream) const
|
|||
stream << (uchar) SequenceMarker;
|
||||
}
|
||||
|
||||
stream << (uchar) o << item_list.count();
|
||||
stream << (uchar) o << int(item_list.count());
|
||||
|
||||
for (int i = 0; i < item_list.count(); ++i) {
|
||||
const QDockAreaLayoutItem &item = item_list.at(i);
|
||||
|
|
|
@ -1267,7 +1267,7 @@ void QToolBarAreaLayout::saveState(QDataStream &stream) const
|
|||
for (int j = 0; j < dock.lines.count(); ++j) {
|
||||
const QToolBarAreaLayoutLine &line = dock.lines.at(j);
|
||||
|
||||
stream << i << line.toolBarItems.count();
|
||||
stream << i << int(line.toolBarItems.count());
|
||||
|
||||
for (int k = 0; k < line.toolBarItems.count(); ++k) {
|
||||
const QToolBarAreaLayoutItem &item = line.toolBarItems.at(k);
|
||||
|
|
|
@ -2022,8 +2022,8 @@ void tst_QCborValue::validation_data()
|
|||
QTest::addRow("very-large-array-overflow2") << raw("\x9b\0\0\0\1""\0\0\0\2" "\0\0") << 0 << CborErrorDataTooLarge;
|
||||
} else {
|
||||
// 64-bit Qt 6
|
||||
QTest::addRow("very-large-array-no-overflow") << raw("\x9b\x07\xff\xff\xff" "\xff\xff\xff\xff" "\0\0");
|
||||
QTest::addRow("very-large-array-overflow") << raw("\x9b\x40\0\0\0" "\0\0\0\0" "\0\0");
|
||||
QTest::addRow("very-large-array-no-overflow") << raw("\x9b\x07\xff\xff\xff" "\xff\xff\xff\xff" "\0\0") << 0 << CborErrorDataTooLarge;
|
||||
QTest::addRow("very-large-array-overflow") << raw("\x9b\x40\0\0\0" "\0\0\0\0" "\0\0") << 0 << CborErrorDataTooLarge;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -335,7 +335,7 @@ void tst_QRegion::emptyPolygonRegion()
|
|||
QTEST(int(std::distance(r.begin(), r.end())), "numRects");
|
||||
QList<QRect> rects;
|
||||
std::copy(r.begin(), r.end(), std::back_inserter(rects));
|
||||
QTEST(rects.size(), "numRects");
|
||||
QTEST(int(rects.size()), "numRects");
|
||||
QTEST(rects, "rects");
|
||||
}
|
||||
|
||||
|
|
|
@ -4817,8 +4817,8 @@ void tst_QNetworkReply::ioPostToHttpFromSocket()
|
|||
|
||||
QCOMPARE(reply->readAll().trimmed(), md5sum(data).toHex());
|
||||
|
||||
QTEST(authenticationRequiredSpy.count(), "authenticationRequiredCount");
|
||||
QTEST(proxyAuthenticationRequiredSpy.count(), "proxyAuthenticationRequiredCount");
|
||||
QTEST(int(authenticationRequiredSpy.count()), "authenticationRequiredCount");
|
||||
QTEST(int(proxyAuthenticationRequiredSpy.count()), "proxyAuthenticationRequiredCount");
|
||||
}
|
||||
|
||||
void tst_QNetworkReply::ioPostToHttpFromSocketSynchronous_data()
|
||||
|
|
|
@ -191,7 +191,7 @@ void tst_QDialogButtonBox::testConstructor3()
|
|||
|
||||
QDialogButtonBox buttonBox(buttons, (Qt::Orientation)orientation);
|
||||
QCOMPARE(int(buttonBox.orientation()), orientation);
|
||||
QTEST(buttonBox.buttons().count(), "buttonCount");
|
||||
QTEST(int(buttonBox.buttons().count()), "buttonCount");
|
||||
}
|
||||
|
||||
void tst_QDialogButtonBox::testConstructor4_data()
|
||||
|
@ -226,7 +226,7 @@ void tst_QDialogButtonBox::testConstructor4()
|
|||
|
||||
QDialogButtonBox buttonBox(buttons);
|
||||
QCOMPARE(buttonBox.orientation(), Qt::Horizontal);
|
||||
QTEST(buttonBox.buttons().count(), "buttonCount");
|
||||
QTEST(int(buttonBox.buttons().count()), "buttonCount");
|
||||
}
|
||||
|
||||
void tst_QDialogButtonBox::setOrientation_data()
|
||||
|
@ -292,9 +292,9 @@ void tst_QDialogButtonBox::addButton1()
|
|||
QCOMPARE(buttonBox.buttons().count(), 0);
|
||||
QPushButton *button = new QPushButton();
|
||||
buttonBox.addButton(button, role);
|
||||
QTEST(buttonBox.buttons().count(), "totalCount");
|
||||
QTEST(int(buttonBox.buttons().count()), "totalCount");
|
||||
QList<QAbstractButton *> children = buttonBox.findChildren<QAbstractButton *>();
|
||||
QTEST(children.count(), "totalCount");
|
||||
QTEST(int(children.count()), "totalCount");
|
||||
delete button;
|
||||
}
|
||||
|
||||
|
@ -319,9 +319,9 @@ void tst_QDialogButtonBox::addButton2()
|
|||
QDialogButtonBox buttonBox;
|
||||
QCOMPARE(buttonBox.buttons().count(), 0);
|
||||
buttonBox.addButton(text, role);
|
||||
QTEST(buttonBox.buttons().count(), "totalCount");
|
||||
QTEST(int(buttonBox.buttons().count()), "totalCount");
|
||||
QList<QAbstractButton *> children = buttonBox.findChildren<QAbstractButton *>();
|
||||
QTEST(children.count(), "totalCount");
|
||||
QTEST(int(children.count()), "totalCount");
|
||||
}
|
||||
|
||||
void tst_QDialogButtonBox::addButton3_data()
|
||||
|
@ -346,9 +346,9 @@ void tst_QDialogButtonBox::addButton3()
|
|||
QDialogButtonBox buttonBox;
|
||||
QCOMPARE(buttonBox.buttons().count(), 0);
|
||||
buttonBox.addButton(button);
|
||||
QTEST(buttonBox.buttons().count(), "totalCount");
|
||||
QTEST(int(buttonBox.buttons().count()), "totalCount");
|
||||
QList<QAbstractButton *> children = buttonBox.findChildren<QAbstractButton *>();
|
||||
QTEST(children.count(), "totalCount");
|
||||
QTEST(int(children.count()), "totalCount");
|
||||
}
|
||||
|
||||
void tst_QDialogButtonBox::clear_data()
|
||||
|
@ -389,7 +389,7 @@ void tst_QDialogButtonBox::removeButton()
|
|||
QCOMPARE(buttonBox.buttons().count(), 0);
|
||||
QPushButton *button = new QPushButton("RemoveButton test");
|
||||
buttonBox.addButton(button, roleToAdd);
|
||||
QTEST(buttonBox.buttons().count(), "expectedCount");
|
||||
QTEST(int(buttonBox.buttons().count()), "expectedCount");
|
||||
|
||||
buttonBox.removeButton(button);
|
||||
QCOMPARE(buttonBox.buttons().count(), 0);
|
||||
|
@ -622,9 +622,9 @@ void tst_QDialogButtonBox::testSignals()
|
|||
if (clicked2.count() > 0)
|
||||
QCOMPARE(qvariant_cast<QAbstractButton *>(clicked2.at(0).at(0)), clickMe);
|
||||
|
||||
QTEST(accept.count(), "acceptCount");
|
||||
QTEST(reject.count(), "rejectCount");
|
||||
QTEST(helpRequested.count(), "helpRequestedCount");
|
||||
QTEST(int(accept.count()), "acceptCount");
|
||||
QTEST(int(reject.count()), "rejectCount");
|
||||
QTEST(int(helpRequested.count()), "helpRequestedCount");
|
||||
}
|
||||
|
||||
void tst_QDialogButtonBox::testSignalOrder()
|
||||
|
|
|
@ -391,7 +391,7 @@ void tst_QGroupBox::clicked()
|
|||
else
|
||||
QTest::mouseClick(&testWidget, Qt::LeftButton);
|
||||
|
||||
QTEST(spy.count(), "clickedCount");
|
||||
QTEST(int(spy.count()), "clickedCount");
|
||||
if (spy.count() > 0)
|
||||
QTEST(spy.at(0).at(0).toBool(), "finalCheck");
|
||||
QTEST(testWidget.isChecked(), "finalCheck");
|
||||
|
|
|
@ -247,7 +247,7 @@ void tst_QTabBar::removeTab()
|
|||
tabbar.setCurrentIndex(currentIndex);
|
||||
QSignalSpy spy(&tabbar, SIGNAL(currentChanged(int)));
|
||||
tabbar.removeTab(deleteIndex);
|
||||
QTEST(spy.count(), "spyCount");
|
||||
QTEST(int(spy.count()), "spyCount");
|
||||
QTEST(tabbar.currentIndex(), "finalIndex");
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ void tst_QTabBar::hideTab()
|
|||
tabbar.setCurrentIndex(currentIndex);
|
||||
QSignalSpy spy(&tabbar, &QTabBar::currentChanged);
|
||||
tabbar.setTabVisible(hideIndex, false);
|
||||
QTEST(spy.count(), "spyCount");
|
||||
QTEST(int(spy.count()), "spyCount");
|
||||
QTEST(tabbar.currentIndex(), "finalIndex");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue