Make QStringList an alias to QList<QString>

Fix our API, so that QStringList and QList<QString> are the
same thing.

This required a bit of refactoring in QList and moving the
indexOf(), lastIndexOf() and contains() method into
QListSpecialMethods. In addition, we need to ensure that
the QStringList(const QString&) constructor is still available
for compatibility with Qt 5.

Once those two are done, all methods in QStringList can be moved
into QListSpecialMethods<QString>.

Change-Id: Ib8afbf5b6d9df4d0d47051252233506f62335fa3
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Lars Knoll 2020-09-03 15:04:16 +02:00
parent ead02871cc
commit 652bd1efca
27 changed files with 115 additions and 268 deletions

View File

@ -61,7 +61,6 @@ class QPainterPath;
class QPoint; class QPoint;
class QRect; class QRect;
class QString; class QString;
class QStringList;
QT_END_NAMESPACE QT_END_NAMESPACE
//! [0] //! [0]

View File

@ -57,7 +57,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QLabel; class QLabel;
class QPushButton; class QPushButton;
class QStringList;
class QTreeWidget; class QTreeWidget;
class QTreeWidgetItem; class QTreeWidgetItem;
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -55,7 +55,6 @@
class QSignalMapper; class QSignalMapper;
class QString; class QString;
class QStringList;
//! [0] //! [0]
class ButtonWidget : public QWidget class ButtonWidget : public QWidget

View File

@ -46,8 +46,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QStringList;
class Q_CORE_EXPORT QLibraryInfo class Q_CORE_EXPORT QLibraryInfo
{ {
public: public:

View File

@ -62,7 +62,6 @@ QT_BEGIN_NAMESPACE
class QCoreApplicationPrivate; class QCoreApplicationPrivate;
class QTranslator; class QTranslator;
class QPostEventList; class QPostEventList;
class QStringList;
class QAbstractEventDispatcher; class QAbstractEventDispatcher;
class QAbstractNativeEventFilter; class QAbstractNativeEventFilter;

View File

@ -60,7 +60,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QRunnable; class QRunnable;
class QStringList;
namespace QtAndroidPrivate namespace QtAndroidPrivate
{ {

View File

@ -125,7 +125,6 @@ inline constexpr int qMetaTypeId();
#define QT_FOR_EACH_STATIC_CORE_CLASS(F)\ #define QT_FOR_EACH_STATIC_CORE_CLASS(F)\
F(QChar, 7, QChar) \ F(QChar, 7, QChar) \
F(QString, 10, QString) \ F(QString, 10, QString) \
F(QStringList, 11, QStringList) \
F(QByteArray, 12, QByteArray) \ F(QByteArray, 12, QByteArray) \
F(QBitArray, 13, QBitArray) \ F(QBitArray, 13, QBitArray) \
F(QDate, 14, QDate) \ F(QDate, 14, QDate) \
@ -163,6 +162,7 @@ inline constexpr int qMetaTypeId();
F(QVariantHash, 28, QVariantHash) \ F(QVariantHash, 28, QVariantHash) \
F(QVariantPair, 58, QVariantPair) \ F(QVariantPair, 58, QVariantPair) \
F(QByteArrayList, 49, QByteArrayList) \ F(QByteArrayList, 49, QByteArrayList) \
F(QStringList, 11, QStringList) \
#if QT_CONFIG(shortcut) #if QT_CONFIG(shortcut)
#define QT_FOR_EACH_STATIC_KEYSEQUENCE_CLASS(F)\ #define QT_FOR_EACH_STATIC_KEYSEQUENCE_CLASS(F)\
@ -221,6 +221,7 @@ inline constexpr int qMetaTypeId();
F(QVariantHash, -1, QVariantHash, "QHash<QString,QVariant>") \ F(QVariantHash, -1, QVariantHash, "QHash<QString,QVariant>") \
F(QVariantPair, -1, QVariantPair, "QPair<QVariant,QVariant>") \ F(QVariantPair, -1, QVariantPair, "QPair<QVariant,QVariant>") \
F(QByteArrayList, -1, QByteArrayList, "QList<QByteArray>") \ F(QByteArrayList, -1, QByteArrayList, "QList<QByteArray>") \
F(QStringList, -1, QStringList, "QList<QString>") \
#define QT_FOR_EACH_STATIC_TYPE(F)\ #define QT_FOR_EACH_STATIC_TYPE(F)\
QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(F)\ QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(F)\

View File

@ -74,7 +74,6 @@ class QLine;
class QLineF; class QLineF;
class QLocale; class QLocale;
class QTransform; class QTransform;
class QStringList;
class QTime; class QTime;
class QPoint; class QPoint;
class QPointF; class QPointF;

View File

@ -48,7 +48,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QDebug; class QDebug;
class QStringList;
typedef QList<QVariant> QVariantList; typedef QList<QVariant> QVariantList;
class Q_CORE_EXPORT QJsonArray class Q_CORE_EXPORT QJsonArray

View File

@ -54,7 +54,6 @@ typedef QMutableListIterator<QByteArray> QMutableByteArrayListIterator;
#endif #endif
#ifndef Q_CLANG_QDOC #ifndef Q_CLANG_QDOC
typedef QList<QByteArray> QByteArrayList;
namespace QtPrivate { namespace QtPrivate {
QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, const char *separator, int separatorLength); QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, const char *separator, int separatorLength);
@ -73,6 +72,13 @@ protected:
~QListSpecialMethods() = default; ~QListSpecialMethods() = default;
#endif #endif
public: public:
qsizetype indexOf(const QByteArray &ba, qsizetype from = 0) const noexcept
{ return QtPrivate::indexOf(*self(), ba, from); }
qsizetype lastIndexOf(const QByteArray &ba, qsizetype from = -1) const noexcept
{ return QtPrivate::lastIndexOf(*self(), ba, from); }
bool contains(const QByteArray &ba) const noexcept
{ return indexOf(ba) != -1; }
inline QByteArray join() const inline QByteArray join() const
{ return QtPrivate::QByteArrayList_join(self(), nullptr, 0); } { return QtPrivate::QByteArrayList_join(self(), nullptr, 0); }
inline QByteArray join(const QByteArray &sep) const inline QByteArray join(const QByteArray &sep) const

View File

@ -51,7 +51,6 @@ QT_REQUIRE_CONFIG(regularexpression);
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QStringList;
class QLatin1String; class QLatin1String;
class QRegularExpressionMatch; class QRegularExpressionMatch;

View File

@ -75,7 +75,6 @@ QT_BEGIN_NAMESPACE
class QRegularExpression; class QRegularExpression;
class QRegularExpressionMatch; class QRegularExpressionMatch;
class QString; class QString;
class QStringList;
namespace QtPrivate { namespace QtPrivate {
template <bool...B> class BoolList; template <bool...B> class BoolList;

View File

@ -57,101 +57,6 @@ using QStringListIterator = QListIterator<QString>;
using QMutableStringListIterator = QMutableListIterator<QString>; using QMutableStringListIterator = QMutableListIterator<QString>;
#endif #endif
class QStringList;
#ifdef Q_QDOC
class QStringList : public QList<QString>
#else
template <> struct QListSpecialMethods<QString>
#endif
{
#ifndef Q_QDOC
protected:
~QListSpecialMethods() = default;
#endif
public:
inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive);
inline qsizetype removeDuplicates();
#if QT_STRINGVIEW_LEVEL < 2
inline QString join(const QString &sep) const;
#endif
inline QString join(QStringView sep) const;
inline QString join(QLatin1String sep) const;
inline QString join(QChar sep) const;
inline QStringList filter(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
inline QStringList &replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
#if QT_STRINGVIEW_LEVEL < 2
inline QStringList filter(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
inline QStringList &replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
inline QStringList &replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
inline QStringList &replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
#endif
#if QT_CONFIG(regularexpression)
inline QStringList filter(const QRegularExpression &re) const;
inline QStringList &replaceInStrings(const QRegularExpression &re, const QString &after);
#endif // QT_CONFIG(regularexpression)
#ifndef Q_QDOC
private:
inline QStringList *self();
inline const QStringList *self() const;
};
// ### Qt6: check if there's a better way
class QStringList : public QList<QString>
{
#endif
public:
using QList<QString>::QList;
inline explicit QStringList(const QString &i) { append(i); }
inline QStringList(const QList<QString> &l) : QList<QString>(l) { }
inline QStringList(QList<QString> &&l) noexcept : QList<QString>(std::move(l)) { }
QStringList &operator=(const QList<QString> &other)
{ QList<QString>::operator=(other); return *this; }
QStringList &operator=(QList<QString> &&other) noexcept
{ QList<QString>::operator=(std::move(other)); return *this; }
#if QT_STRINGVIEW_LEVEL < 2
inline bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
#endif
inline bool contains(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
inline bool contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
inline QStringList operator+(const QStringList &other) const
{ QStringList n = *this; n += other; return n; }
inline QStringList &operator<<(const QString &str)
{ append(str); return *this; }
inline QStringList &operator<<(const QStringList &l)
{ *this += l; return *this; }
inline QStringList &operator<<(const QList<QString> &l)
{ *this += l; return *this; }
inline qsizetype indexOf(QStringView str, qsizetype from = 0) const;
inline qsizetype indexOf(QLatin1String str, qsizetype from = 0) const;
inline qsizetype lastIndexOf(QStringView str, qsizetype from = -1) const;
inline qsizetype lastIndexOf(QLatin1String str, qsizetype from = -1) const;
#if QT_CONFIG(regularexpression)
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;
using QList<QString>::lastIndexOf;
};
Q_DECLARE_TYPEINFO(QStringList, Q_MOVABLE_TYPE);
#ifndef Q_QDOC
inline QStringList *QListSpecialMethods<QString>::self()
{ return static_cast<QStringList *>(this); }
inline const QStringList *QListSpecialMethods<QString>::self() const
{ return static_cast<const QStringList *>(this); }
namespace QtPrivate { namespace QtPrivate {
void Q_CORE_EXPORT QStringList_sort(QStringList *that, Qt::CaseSensitivity cs); void Q_CORE_EXPORT QStringList_sort(QStringList *that, Qt::CaseSensitivity cs);
@ -174,143 +79,98 @@ namespace QtPrivate {
#endif // QT_CONFIG(regularexpression) #endif // QT_CONFIG(regularexpression)
} }
inline void QListSpecialMethods<QString>::sort(Qt::CaseSensitivity cs) #ifdef Q_QDOC
class QStringList : public QList<QString>
#else
template <> struct QListSpecialMethods<QString>
#endif
{ {
QtPrivate::QStringList_sort(self(), cs); inline QStringList *self()
} { return static_cast<QStringList *>(this); }
inline const QStringList *self() const
{ return static_cast<const QStringList *>(this); }
inline qsizetype QListSpecialMethods<QString>::removeDuplicates() public:
{ inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive)
return QtPrivate::QStringList_removeDuplicates(self()); { QtPrivate::QStringList_sort(self(), cs); }
} inline qsizetype removeDuplicates()
{ return QtPrivate::QStringList_removeDuplicates(self()); }
inline QString join(QStringView sep) const
{ return QtPrivate::QStringList_join(self(), sep); }
inline QString join(QLatin1String sep) const
{ return QtPrivate::QStringList_join(*self(), sep); }
inline QString join(QChar sep) const
{ return QtPrivate::QStringList_join(self(), &sep, 1); }
inline QStringList filter(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
{ return QtPrivate::QStringList_filter(self(), str, cs); }
inline QStringList &replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
{
QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
return *self();
}
#if QT_STRINGVIEW_LEVEL < 2 #if QT_STRINGVIEW_LEVEL < 2
inline QString QListSpecialMethods<QString>::join(const QString &sep) const inline QString join(const QString &sep) const
{ { return QtPrivate::QStringList_join(self(), sep.constData(), sep.length()); }
return QtPrivate::QStringList_join(self(), sep.constData(), sep.length()); inline QStringList filter(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
} { return QtPrivate::QStringList_filter(self(), str, cs); }
inline QStringList &replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
{
QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
return *self();
}
inline QStringList &replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
{
QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
return *self();
}
inline QStringList &replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
{
QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
return *self();
}
#endif #endif
inline QString QListSpecialMethods<QString>::join(QStringView sep) const inline bool contains(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ { return QtPrivate::QStringList_contains(self(), str, cs); }
return QtPrivate::QStringList_join(self(), sep); inline bool contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
} { return QtPrivate::QStringList_contains(self(), str, cs); }
QString QListSpecialMethods<QString>::join(QLatin1String sep) const inline qsizetype indexOf(QStringView str, qsizetype from = 0) const noexcept
{ { return QtPrivate::indexOf<QString, QStringView>(*self(), str, from); }
return QtPrivate::QStringList_join(*self(), sep); inline qsizetype indexOf(QLatin1String str, qsizetype from = 0) const noexcept
} { return QtPrivate::indexOf<QString, QLatin1String>(*self(), str, from); }
inline QString QListSpecialMethods<QString>::join(QChar sep) const inline qsizetype lastIndexOf(QStringView str, qsizetype from = -1) const noexcept
{ { return QtPrivate::lastIndexOf<QString, QStringView>(*self(), str, from); }
return QtPrivate::QStringList_join(self(), &sep, 1); inline qsizetype lastIndexOf(QLatin1String str, qsizetype from = -1) const noexcept
} { return QtPrivate::lastIndexOf<QString, QLatin1String>(*self(), str, from); }
inline QStringList QListSpecialMethods<QString>::filter(QStringView str, Qt::CaseSensitivity cs) const
{
return QtPrivate::QStringList_filter(self(), str, cs);
}
#if QT_STRINGVIEW_LEVEL < 2 #if QT_STRINGVIEW_LEVEL < 2
inline QStringList QListSpecialMethods<QString>::filter(const QString &str, Qt::CaseSensitivity cs) const inline bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ { return QtPrivate::QStringList_contains(self(), str, cs); }
return QtPrivate::QStringList_filter(self(), str, cs); qsizetype indexOf(const QString &str, qsizetype from = 0) const noexcept
} { return indexOf(QStringView(str), from); }
qsizetype lastIndexOf(const QString &str, qsizetype from = -1) const noexcept
{ return lastIndexOf(QStringView(str), from); }
#endif #endif
#if QT_STRINGVIEW_LEVEL < 2
inline bool QStringList::contains(const QString &str, Qt::CaseSensitivity cs) const
{
return QtPrivate::QStringList_contains(this, str, cs);
}
#endif
inline bool QStringList::contains(QLatin1String str, Qt::CaseSensitivity cs) const
{
return QtPrivate::QStringList_contains(this, str, cs);
}
inline bool QStringList::contains(QStringView str, Qt::CaseSensitivity cs) const
{
return QtPrivate::QStringList_contains(this, str, cs);
}
inline QStringList &QListSpecialMethods<QString>::replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs)
{
QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
return *self();
}
#if QT_STRINGVIEW_LEVEL < 2
inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs)
{
QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
return *self();
}
inline QStringList &QListSpecialMethods<QString>::replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs)
{
QtPrivate::QStringList_replaceInStrings(self(), before, qToStringViewIgnoringNull(after), cs);
return *self();
}
inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs)
{
QtPrivate::QStringList_replaceInStrings(self(), QStringView(before), after, cs);
return *self();
}
#endif
inline QStringList operator+(const QList<QString> &one, const QStringList &other)
{
QStringList n = one;
n += other;
return n;
}
inline qsizetype QStringList::indexOf(QStringView string, qsizetype from) const
{
return QtPrivate::indexOf<QString, QStringView>(*this, string, from);
}
inline qsizetype QStringList::indexOf(QLatin1String string, qsizetype from) const
{
return QtPrivate::indexOf<QString, QLatin1String>(*this, string, from);
}
inline qsizetype QStringList::lastIndexOf(QStringView string, qsizetype from) const
{
return QtPrivate::lastIndexOf<QString, QStringView>(*this, string, from);
}
inline qsizetype QStringList::lastIndexOf(QLatin1String string, qsizetype from) const
{
return QtPrivate::lastIndexOf<QString, QLatin1String>(*this, string, from);
}
#if QT_CONFIG(regularexpression) #if QT_CONFIG(regularexpression)
inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QRegularExpression &rx, const QString &after) inline QStringList filter(const QRegularExpression &re) const
{ { return QtPrivate::QStringList_filter(self(), re); }
QtPrivate::QStringList_replaceInStrings(self(), rx, after); inline QStringList &replaceInStrings(const QRegularExpression &re, const QString &after)
return *self(); {
} QtPrivate::QStringList_replaceInStrings(self(), re, after);
return *self();
inline QStringList QListSpecialMethods<QString>::filter(const QRegularExpression &rx) const }
{ inline qsizetype indexOf(const QRegularExpression &re, qsizetype from = 0) const
return QtPrivate::QStringList_filter(self(), rx); { return QtPrivate::QStringList_indexOf(self(), re, from); }
} inline qsizetype lastIndexOf(const QRegularExpression &re, qsizetype from = -1) const
{ return QtPrivate::QStringList_lastIndexOf(self(), re, from); }
inline qsizetype QStringList::indexOf(const QRegularExpression &rx, qsizetype from) const
{
return QtPrivate::QStringList_indexOf(this, rx, from);
}
inline qsizetype QStringList::lastIndexOf(const QRegularExpression &rx, qsizetype from) const
{
return QtPrivate::QStringList_lastIndexOf(this, rx, from);
}
#endif // QT_CONFIG(regularexpression) #endif // QT_CONFIG(regularexpression)
#endif // Q_QDOC };
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -61,7 +61,7 @@ template <class T> class QStack;
template<class T, qsizetype Prealloc = 256> class QVarLengthArray; template<class T, qsizetype Prealloc = 256> class QVarLengthArray;
template <class T> class QList; template <class T> class QList;
template<typename T> using QVector = QList<T>; template<typename T> using QVector = QList<T>;
class QStringList; using QStringList = QList<QString>;
using QByteArrayList = QList<QByteArray>; using QByteArrayList = QList<QByteArray>;
class QMetaType; class QMetaType;
class QVariant; class QVariant;

View File

@ -54,14 +54,22 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace QtPrivate { namespace QtPrivate {
template <typename V, typename U> qsizetype indexOf(const QList<V> &list, const U &u, qsizetype from); template <typename V, typename U> qsizetype indexOf(const QList<V> &list, const U &u, qsizetype from) noexcept;
template <typename V, typename U> qsizetype lastIndexOf(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) noexcept;
} }
template <typename T> struct QListSpecialMethods template <typename T> struct QListSpecialMethods
{ {
protected: protected:
~QListSpecialMethods() = default; ~QListSpecialMethods() = default;
public:
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;
}
}; };
template <> struct QListSpecialMethods<QByteArray>; template <> struct QListSpecialMethods<QByteArray>;
template <> struct QListSpecialMethods<QString>; template <> struct QListSpecialMethods<QString>;
@ -79,8 +87,8 @@ class QList
DataPointer d; DataPointer d;
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::indexOf(const QList<V> &list, const U &u, qsizetype from) noexcept;
template <typename V, typename U> friend qsizetype QtPrivate::lastIndexOf(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) noexcept;
public: public:
typedef T Type; typedef T Type;
@ -158,6 +166,11 @@ public:
std::copy(i1, i2, std::back_inserter(*this)); std::copy(i1, i2, std::back_inserter(*this));
} }
// This constructor is here for compatibility with QStringList in Qt 5, that has a QStringList(const QString &) constructor
template<typename String, typename = std::enable_if_t<std::is_same_v<T, QString> && std::is_convertible_v<String, QString>>>
inline explicit QList(const String &str)
{ append(str); }
// compiler-generated special member functions are fine! // compiler-generated special member functions are fine!
void swap(QList<T> &other) noexcept { qSwap(d, other.d); } void swap(QList<T> &other) noexcept { qSwap(d, other.d); }
@ -289,12 +302,10 @@ public:
QList<T> &fill(parameter_type t, qsizetype size = -1); QList<T> &fill(parameter_type t, qsizetype size = -1);
qsizetype indexOf(const T &t, qsizetype from = 0) const noexcept; using QListSpecialMethods<T>::contains;
qsizetype lastIndexOf(const T &t, qsizetype from = -1) const noexcept; using QListSpecialMethods<T>::indexOf;
bool contains(const T &t) const noexcept using QListSpecialMethods<T>::lastIndexOf;
{
return indexOf(t) != -1;
}
qsizetype count(const T &t) const noexcept qsizetype count(const T &t) const noexcept
{ {
return qsizetype(std::count(&*cbegin(), &*cend(), t)); return qsizetype(std::count(&*cbegin(), &*cend(), t));
@ -705,7 +716,7 @@ inline QList<T> &QList<T>::fill(parameter_type t, qsizetype newSize)
namespace QtPrivate { namespace QtPrivate {
template <typename T, typename U> template <typename T, typename U>
qsizetype indexOf(const QList<T> &vector, const U &u, qsizetype from) qsizetype indexOf(const QList<T> &vector, const U &u, qsizetype from) noexcept
{ {
if (from < 0) if (from < 0)
from = qMax(from + vector.size(), qsizetype(0)); from = qMax(from + vector.size(), qsizetype(0));
@ -720,7 +731,7 @@ qsizetype indexOf(const QList<T> &vector, const U &u, qsizetype from)
} }
template <typename T, typename U> template <typename T, typename U>
qsizetype lastIndexOf(const QList<T> &vector, const U &u, qsizetype from) qsizetype lastIndexOf(const QList<T> &vector, const U &u, qsizetype from) noexcept
{ {
if (from < 0) if (from < 0)
from += vector.d->size; from += vector.d->size;
@ -739,15 +750,15 @@ qsizetype lastIndexOf(const QList<T> &vector, const U &u, qsizetype from)
} }
template <typename T> template <typename T>
qsizetype QList<T>::indexOf(const T &t, qsizetype from) const noexcept qsizetype QListSpecialMethods<T>::indexOf(const T &t, qsizetype from) const noexcept
{ {
return QtPrivate::indexOf<T, T>(*this, t, from); return QtPrivate::indexOf(*static_cast<const QList<T> *>(this), t, from);
} }
template <typename T> template <typename T>
qsizetype QList<T>::lastIndexOf(const T &t, qsizetype from) const noexcept qsizetype QListSpecialMethods<T>::lastIndexOf(const T &t, qsizetype from) const noexcept
{ {
return QtPrivate::lastIndexOf(*this, t, from); return QtPrivate::lastIndexOf(*static_cast<const QList<T> *>(this), t, from);
} }
template <typename T> template <typename T>

View File

@ -49,7 +49,6 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_ACCESSIBILITY #ifndef QT_NO_ACCESSIBILITY
class QStringList;
class QAccessibleInterface; class QAccessibleInterface;
#define QAccessibleFactoryInterface_iid "org.qt-project.Qt.QAccessibleFactoryInterface" #define QAccessibleFactoryInterface_iid "org.qt-project.Qt.QAccessibleFactoryInterface"

View File

@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
class QColorSpace; class QColorSpace;
class QColorTransform; class QColorTransform;
class QIODevice; class QIODevice;
class QStringList;
class QTransform; class QTransform;
class QVariant; class QVariant;

View File

@ -53,7 +53,6 @@ class QColor;
class QIODevice; class QIODevice;
class QRect; class QRect;
class QSize; class QSize;
class QStringList;
class QImageReaderPrivate; class QImageReaderPrivate;
class Q_GUI_EXPORT QImageReader class Q_GUI_EXPORT QImageReader

View File

@ -50,7 +50,6 @@ QT_BEGIN_NAMESPACE
class QFontPrivate; /* don't touch */ class QFontPrivate; /* don't touch */
class QStringList;
class QVariant; class QVariant;
class Q_GUI_EXPORT QFont class Q_GUI_EXPORT QFont

View File

@ -48,7 +48,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QStringList;
struct QFontDef; struct QFontDef;
class QFontEngine; class QFontEngine;

View File

@ -48,7 +48,6 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_DESKTOPSERVICES #ifndef QT_NO_DESKTOPSERVICES
class QStringList;
class QUrl; class QUrl;
class QObject; class QObject;

View File

@ -61,7 +61,6 @@ class QIODevice;
class QSslError; class QSslError;
class QSslKey; class QSslKey;
class QSslCertificateExtension; class QSslCertificateExtension;
class QStringList;
class QSslCertificate; class QSslCertificate;
// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)

View File

@ -68,8 +68,6 @@
#include <CoreFoundation/CFNumber.h> #include <CoreFoundation/CFNumber.h>
QT_FORWARD_DECLARE_CLASS(QString)
QT_FORWARD_DECLARE_CLASS(QStringList)
QT_FORWARD_DECLARE_CLASS(QFileInfo) QT_FORWARD_DECLARE_CLASS(QFileInfo)
QT_FORWARD_DECLARE_CLASS(QWindow) QT_FORWARD_DECLARE_CLASS(QWindow)
QT_USE_NAMESPACE QT_USE_NAMESPACE

View File

@ -47,7 +47,6 @@ QT_BEGIN_NAMESPACE
class QSqlField; class QSqlField;
class QStringList;
class QVariant; class QVariant;
class QSqlRecordPrivate; class QSqlRecordPrivate;

View File

@ -56,8 +56,6 @@
#include <QtCore/qmap.h> #include <QtCore/qmap.h>
#include <QtCore/qstring.h> #include <QtCore/qstring.h>
class QStringList;
QT_REQUIRE_CONFIG(valgrind); QT_REQUIRE_CONFIG(valgrind);
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View File

@ -499,13 +499,6 @@ bool qCompare(QList<T> const &t1, const T (& t2)[N],
actual, expected, file, line); actual, expected, file, line);
} }
template <>
inline bool qCompare(QStringList const &t1, QStringList const &t2, const char *actual, const char *expected,
const char *file, int line)
{
return qCompare<QString>(t1, t2, actual, expected, file, line);
}
template <typename T> template <typename T>
inline bool qCompare(QFlags<T> const &t1, T const &t2, const char *actual, const char *expected, inline bool qCompare(QFlags<T> const &t1, T const &t2, const char *actual, const char *expected,
const char *file, int line) const char *file, int line)

View File

@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE
// We mean it. // We mean it.
// //
class QStringList;
class QTextOption; class QTextOption;
// Private class // Private class