From c951908bc201afa59402967d50fa926212845fae Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 23 Feb 2012 07:43:30 +0100 Subject: QString: add from{Ascii,Latin1,Utf8,Local8Bit() overloads for QByteArray One of the more frequent uses for QByteArray::operator const char*() is in passing a QByteArray to QString::fromLatin1(). But this is highly inefficient, since the bytearray already knows its size, but since its demoted to a const char* in passing to fromLatin1(), it forces the latter to call strlen() _again_. The solution, then, is to add overloads for QByteArray that pass the array's .size() as a second argument to the two-arg fromLatin1() version. Change-Id: I5ea1ad3c96d9e64167be53c0c418c7b7dba51f68 Reviewed-by: David Faure Reviewed-by: Lars Knoll --- src/corelib/tools/qstring.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index f1bad5c028..12a5acb689 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -417,6 +417,10 @@ public: { return fromLocal8Bit_helper(str, (str && size == -1) ? int(strlen(str)) : size); } + static inline QString fromAscii(const QByteArray &str) { return fromAscii(str.data(), str.size()); } + static inline QString fromLatin1(const QByteArray &str) { return fromLatin1(str.data(), str.size()); } + static inline QString fromUtf8(const QByteArray &str) { return fromUtf8(str.data(), str.size()); } + static inline QString fromLocal8Bit(const QByteArray &str) { return fromLocal8Bit(str.data(), str.size()); } static QString fromUtf16(const ushort *, int size = -1); static QString fromUcs4(const uint *, int size = -1); static QString fromRawData(const QChar *, int size); -- cgit v1.2.3 From 8397a44bedf542b53284674c87268819f4911d31 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 22 Feb 2012 16:17:30 +0100 Subject: QByteArray: deprecate QT_NO_CAST_FROM_BYTEARRAY-protected operators The QByteArray::operator const {char,void}*() implicit conversions are a source of subtle bugs, so they right- fully can be disabled with QT_NO_CAST_FROM_BYTEARRAY. const char *d = qstring.toLatin1(); // implicit conversion while ( d ) // oops: d points to freed memory // ... But almost no-one ever enabled this macros in the wild and many were bitten by these implicit conversions, so this patch deprecates them. I would have liked to remove them completely, but there are just too many occurrences even in Qt itself to hope to find all conditionally-compiled code that uses these. Also fixes all code that needs to compile under QT_NO_DEPRECATED (in qmake/, src/tools/). I984706452db7d0841620a0f64e179906123f3849 separately deals with the bulk of changes in src/ and examples/. Depends on I5ea1ad3c96d9e64167be53c0c418c7b7dba51f68. Change-Id: I8d47e6c293c80f61c6288c9f8d42fda41afe2267 Reviewed-by: David Faure Reviewed-by: Lars Knoll --- src/corelib/codecs/qtextcodec.cpp | 6 +++--- src/corelib/io/qfilesystemengine_unix.cpp | 18 +++++++++--------- src/corelib/io/qsettings.cpp | 6 +++--- src/corelib/kernel/qvariant.cpp | 2 +- src/corelib/tools/qbytearray.cpp | 6 ++++-- src/corelib/tools/qbytearray.h | 12 ++++-------- src/corelib/tools/qlocale_unix.cpp | 2 +- src/corelib/tools/qstring.cpp | 2 +- 8 files changed, 26 insertions(+), 28 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 82e5c9a1c3..e49ebfb844 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -111,7 +111,7 @@ static bool qisalnum(register char c) static bool nameMatch(const QByteArray &name, const QByteArray &test) { // if they're the same, return a perfect score - if (qstricmp(name, test) == 0) + if (qstricmp(name.constData(), test.constData()) == 0) return true; const char *n = name.constData(); @@ -510,7 +510,7 @@ static QTextCodec * ru_RU_hack(const char * i) { koi8r, latin5, i); } #if !defined(QT_NO_SETLOCALE) - setlocale(LC_CTYPE, origlocale); + setlocale(LC_CTYPE, origlocale.constData()); #endif return ru_RU_codec; @@ -648,7 +648,7 @@ static void setupLocaleMapper() else if (try_locale_list(pt_154locales, lang)) localeMapper = QTextCodec::codecForName("PT 154"); else if (try_locale_list(probably_koi8_rlocales, lang)) - localeMapper = ru_RU_hack(lang); + localeMapper = ru_RU_hack(lang.constData()); } } diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 5e466e480d..e8ff6107ce 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -476,12 +476,12 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea slash = dirName.length(); } if (slash) { - QByteArray chunk = QFile::encodeName(dirName.left(slash)); + const QByteArray chunk = QFile::encodeName(dirName.left(slash)); QT_STATBUF st; - if (QT_STAT(chunk, &st) != -1) { + if (QT_STAT(chunk.constData(), &st) != -1) { if ((st.st_mode & S_IFMT) != S_IFDIR) return false; - } else if (QT_MKDIR(chunk, 0777) != 0) { + } else if (QT_MKDIR(chunk.constData(), 0777) != 0) { return false; } } @@ -492,7 +492,7 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea if (dirName.endsWith(QLatin1Char('/'))) dirName.chop(1); #endif - return (QT_MKDIR(QFile::encodeName(dirName), 0777) == 0); + return (QT_MKDIR(QFile::encodeName(dirName).constData(), 0777) == 0); } //static @@ -501,12 +501,12 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo if (removeEmptyParents) { QString dirName = QDir::cleanPath(entry.filePath()); for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) { - QByteArray chunk = QFile::encodeName(dirName.left(slash)); + const QByteArray chunk = QFile::encodeName(dirName.left(slash)); QT_STATBUF st; - if (QT_STAT(chunk, &st) != -1) { + if (QT_STAT(chunk.constData(), &st) != -1) { if ((st.st_mode & S_IFMT) != S_IFDIR) return false; - if (::rmdir(chunk) != 0) + if (::rmdir(chunk.constData()) != 0) return oldslash != 0; } else { return false; @@ -515,7 +515,7 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo } return true; } - return rmdir(QFile::encodeName(entry.filePath())) == 0; + return rmdir(QFile::encodeName(entry.filePath()).constData()) == 0; } //static @@ -623,7 +623,7 @@ QString QFileSystemEngine::tempPath() bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &path) { int r; - r = QT_CHDIR(path.nativeFilePath()); + r = QT_CHDIR(path.nativeFilePath().constData()); return r >= 0; } diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 2021c42c4d..f743c592bd 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -1752,10 +1752,10 @@ bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data, iniSection = iniSection.trimmed(); - if (qstricmp(iniSection, "general") == 0) { + if (qstricmp(iniSection.constData(), "general") == 0) { currentSection.clear(); } else { - if (qstricmp(iniSection, "%general") == 0) { + if (qstricmp(iniSection.constData(), "%general") == 0) { currentSection = QLatin1String(iniSection.constData() + 1); } else { currentSection.clear(); @@ -1912,7 +1912,7 @@ bool QConfFileSettingsPrivate::writeIniFile(QIODevice &device, const ParsedSetti if (realSection.isEmpty()) { realSection = "[General]"; - } else if (qstricmp(realSection, "general") == 0) { + } else if (qstricmp(realSection.constData(), "general") == 0) { realSection = "[%General]"; } else { realSection.prepend('['); diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 4e7fd94141..2f67ae9287 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1698,7 +1698,7 @@ void QVariant::load(QDataStream &s) if (typeId == QVariant::UserType) { QByteArray name; s >> name; - typeId = QMetaType::type(name); + typeId = QMetaType::type(name.constData()); if (!typeId) { s.setStatus(QDataStream::ReadCorruptData); return; diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index c74c61999d..1d37f578b8 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -343,7 +343,7 @@ int qstrcmp(const QByteArray &str1, const QByteArray &str2) { int l1 = str1.length(); int l2 = str2.length(); - int ret = memcmp(str1, str2, qMin(l1, l2)); + int ret = memcmp(str1.constData(), str2.constData(), qMin(l1, l2)); if (ret != 0) return ret; @@ -995,6 +995,8 @@ QByteArray &QByteArray::operator=(const char *str) /*! \fn QByteArray::operator const char *() const \fn QByteArray::operator const void *() const + \obsolete Use constData() instead. + Returns a pointer to the data stored in the byte array. The pointer can be used to access the bytes that compose the array. The data is '\\0'-terminated. The pointer remains valid as long @@ -2751,7 +2753,7 @@ QDataStream &operator<<(QDataStream &out, const QByteArray &ba) out << (quint32)0xffffffff; return out; } - return out.writeBytes(ba, ba.size()); + return out.writeBytes(ba.constData(), ba.size()); } /*! \relates QByteArray diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 8202097da5..09c43988fd 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -207,8 +207,10 @@ public: void squeeze(); #ifndef QT_NO_CAST_FROM_BYTEARRAY - operator const char *() const; - operator const void *() const; +#if QT_DEPRECATED_SINCE(5, 0) + QT_DEPRECATED operator const char *() const { return constData(); } + QT_DEPRECATED operator const void *() const { return constData(); } +#endif #endif char *data(); const char *data() const; @@ -415,12 +417,6 @@ inline char QByteArray::operator[](uint i) const inline bool QByteArray::isEmpty() const { return d->size == 0; } -#ifndef QT_NO_CAST_FROM_BYTEARRAY -inline QByteArray::operator const char *() const -{ return d->data(); } -inline QByteArray::operator const void *() const -{ return d->data(); } -#endif inline char *QByteArray::data() { detach(); return d->data(); } inline const char *QByteArray::data() const diff --git a/src/corelib/tools/qlocale_unix.cpp b/src/corelib/tools/qlocale_unix.cpp index 6ace96f771..f2876912b4 100644 --- a/src/corelib/tools/qlocale_unix.cpp +++ b/src/corelib/tools/qlocale_unix.cpp @@ -98,7 +98,7 @@ QLocale QSystemLocale::fallbackLocale() const lang = qgetenv("LC_NUMERIC"); if (lang.isEmpty()) lang = qgetenv("LANG"); - return QLocale(QLatin1String(lang)); + return QLocale(QString::fromLatin1(lang)); } QVariant QSystemLocale::query(QueryType type, QVariant in) const diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 704545667c..14b8782dae 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -4761,7 +4761,7 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1, } // else fall through # endif // declared in - int delta = strcoll(toLocal8Bit_helper(data1, length1), toLocal8Bit_helper(data2, length2)); + int delta = strcoll(toLocal8Bit_helper(data1, length1).constData(), toLocal8Bit_helper(data2, length2).constData()); if (delta == 0) delta = ucstrcmp(data1, length1, data2, length2); return delta; -- cgit v1.2.3 From 3ec9aac6c9aa627eb41f8603c517c8cf71be0af0 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 23 Feb 2012 22:15:57 +0100 Subject: QXmlStream{Reader,Writer}: add explicit to constructors Change-Id: Ib70b7a8f15aaf2e59deddcb0b89eb7e976893280 Reviewed-by: Lars Knoll Reviewed-by: Olivier Goffart --- src/corelib/xml/qxmlstream.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/xml/qxmlstream.h b/src/corelib/xml/qxmlstream.h index 3a9ddfd990..90382c7fe5 100644 --- a/src/corelib/xml/qxmlstream.h +++ b/src/corelib/xml/qxmlstream.h @@ -248,10 +248,10 @@ public: QXmlStreamReader(); - QXmlStreamReader(QIODevice *device); - QXmlStreamReader(const QByteArray &data); - QXmlStreamReader(const QString &data); - QXmlStreamReader(const char * data); + explicit QXmlStreamReader(QIODevice *device); + explicit QXmlStreamReader(const QByteArray &data); + explicit QXmlStreamReader(const QString &data); + explicit QXmlStreamReader(const char * data); ~QXmlStreamReader(); void setDevice(QIODevice *device); @@ -361,9 +361,9 @@ class Q_CORE_EXPORT QXmlStreamWriter QDOC_PROPERTY(int autoFormattingIndent READ autoFormattingIndent WRITE setAutoFormattingIndent) public: QXmlStreamWriter(); - QXmlStreamWriter(QIODevice *device); - QXmlStreamWriter(QByteArray *array); - QXmlStreamWriter(QString *string); + explicit QXmlStreamWriter(QIODevice *device); + explicit QXmlStreamWriter(QByteArray *array); + explicit QXmlStreamWriter(QString *string); ~QXmlStreamWriter(); void setDevice(QIODevice *device); -- cgit v1.2.3 From 4550f0db210258338c8d6261640d9f192c0d3db6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 23 Feb 2012 22:39:20 +0100 Subject: QStringMatcher: make constructor explicit Change-Id: I3a8f37d2132eb84bef336afed60aff6e2350366d Reviewed-by: Lars Knoll Reviewed-by: Olivier Goffart --- src/corelib/tools/qstringmatcher.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qstringmatcher.h b/src/corelib/tools/qstringmatcher.h index a9b2a7c371..3f614f732c 100644 --- a/src/corelib/tools/qstringmatcher.h +++ b/src/corelib/tools/qstringmatcher.h @@ -55,7 +55,7 @@ class Q_CORE_EXPORT QStringMatcher { public: QStringMatcher(); - QStringMatcher(const QString &pattern, + explicit QStringMatcher(const QString &pattern, Qt::CaseSensitivity cs = Qt::CaseSensitive); QStringMatcher(const QChar *uc, int len, Qt::CaseSensitivity cs = Qt::CaseSensitive); -- cgit v1.2.3 From 5bb1408927b4eb5a03e8ab9f7cbc68f80d8a3962 Mon Sep 17 00:00:00 2001 From: Matthew Vogt Date: Thu, 23 Feb 2012 11:12:58 +1000 Subject: Allow moc to handle symbols that have been redefined. Allow moc to produce the desired identifiers when used with C++ symbol names that have been redefined, for example by -Dfoo=bar. Two changes are required: firstly, when encoding a type name, the components of the name must be checked for substitutions that have been defined for that token (note that this is not done here by correct pre-processing, but only by processing the resultant table of definitions). Secondly, the arguments to the SIGNAL, SLOT and METHOD macros must be allowed to be substituted during macro expansion rather than stringized directly. This is a temporary change to prevent breaking existing projects that depend on the declarative module. After clients have had an opportunity to update their code to the use the new interfaces, it can be removed. Task-number: QTBUG-23737 Change-Id: I39e6844cebf6ca7984af6028160b8a3797ac44a5 Reviewed-by: Martin Jones --- src/corelib/kernel/qobjectdefs.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 0b1fa8839f..45ef8ab3ca 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -208,16 +208,16 @@ Q_CORE_EXPORT const char *qFlagLocation(const char *method); #ifndef QT_NO_DEBUG # define QLOCATION "\0" __FILE__ ":" QTOSTRING(__LINE__) # ifndef QT_NO_KEYWORDS -# define METHOD(a) qFlagLocation("0"#a QLOCATION) +# define METHOD(a) qFlagLocation("0" QTOSTRING(a) QLOCATION) # endif -# define SLOT(a) qFlagLocation("1"#a QLOCATION) -# define SIGNAL(a) qFlagLocation("2"#a QLOCATION) +# define SLOT(a) qFlagLocation("1" QTOSTRING(a) QLOCATION) +# define SIGNAL(a) qFlagLocation("2" QTOSTRING(a) QLOCATION) #else # ifndef QT_NO_KEYWORDS -# define METHOD(a) "0"#a +# define METHOD(a) "0" QTOSTRING(a) # endif -# define SLOT(a) "1"#a -# define SIGNAL(a) "2"#a +# define SLOT(a) "1" QTOSTRING(a) +# define SIGNAL(a) "2" QTOSTRING(a) #endif #define QMETHOD_CODE 0 // member type codes -- cgit v1.2.3 From c06e932c7307530d23d218ef7ed86bc06583f2d1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 25 Feb 2012 17:00:15 +0100 Subject: Move the QString comparison operator as non member function The operator== and similar should not be member of the class. This ensure a symertry. Indeed, consider this code string == string1 + string2; string1 + string2 == string; The first line compile fine even if QStringBuilder is used, because QStringBuilder will be converted to QString implicitly. But the second line do not compile if the operator== is a member of QString, because the implicit conversion rules do not apply. For this reason, the symetric operators should not be declared as member. Change-Id: I3f7c11fab45a9133f7a424bdfcb894f97da9282b Reviewed-by: Thiago Macieira --- src/corelib/tools/qstring.cpp | 44 ++++++++++++++++++++++++------------------- src/corelib/tools/qstring.h | 12 ++++++------ 2 files changed, 31 insertions(+), 25 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 14b8782dae..d0c5506228 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -2139,7 +2139,8 @@ QString &QString::replace(QChar c, const QLatin1String &after, Qt::CaseSensitivi /*! - Returns true if string \a other is equal to this string; otherwise + \relates QString + Returns true if string \a s1 is equal to string \a s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values of @@ -2147,12 +2148,12 @@ QString &QString::replace(QChar c, const QLatin1String &after, Qt::CaseSensitivi expect. Consider sorting user-interface strings with localeAwareCompare(). */ -bool QString::operator==(const QString &other) const +bool operator==(const QString &s1, const QString &s2) { - if (d->size != other.d->size) + if (s1.d->size != s2.d->size) return false; - return qMemEquals(d->data(), other.d->data(), d->size); + return qMemEquals(s1.d->data(), s2.d->data(), s1.d->size); } /*! @@ -2207,17 +2208,18 @@ bool QString::operator==(const QLatin1String &other) const */ /*! - Returns true if this string is lexically less than string \a - other; otherwise returns false. + \relates QString + Returns true if string \a s1 is lexically less than string + \a s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values of the characters and is very fast, but is not what a human would expect. Consider sorting user-interface strings using the QString::localeAwareCompare() function. */ -bool QString::operator<(const QString &other) const +bool operator<(const QString &s1, const QString &s2) { - return ucstrcmp(constData(), length(), other.constData(), other.length()) < 0; + return ucstrcmp(s1.constData(), s1.length(), s2.constData(), s2.length()) < 0; } /*! @@ -2268,10 +2270,11 @@ bool QString::operator<(const QLatin1String &other) const go through QObject::tr(), for example. */ -/*! \fn bool QString::operator<=(const QString &other) const +/*! \fn bool operator<=(const QString &s1, const QString &s2) + \relates QString - Returns true if this string is lexically less than or equal to - string \a other; otherwise returns false. + Returns true if string \a s1 is lexically less than or equal to + string \a s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values of the characters and is very fast, but is not what a human would @@ -2311,10 +2314,11 @@ bool QString::operator<(const QLatin1String &other) const go through QObject::tr(), for example. */ -/*! \fn bool QString::operator>(const QString &other) const +/*! \fn bool operator>(const QString &s1, const QString &s2) + \relates QString - Returns true if this string is lexically greater than string \a - other; otherwise returns false. + Returns true if string \a s1 is lexically greater than string \a + s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values of the characters and is very fast, but is not what a human would @@ -2370,10 +2374,11 @@ bool QString::operator>(const QLatin1String &other) const for example. */ -/*! \fn bool QString::operator>=(const QString &other) const +/*! \fn bool operator>=(const QString &s1, const QString &s2) + \relates QString - Returns true if this string is lexically greater than or equal to - string \a other; otherwise returns false. + Returns true if string \a s1 is lexically greater than or equal to + string \a s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values of the characters and is very fast, but is not what a human would @@ -2413,9 +2418,10 @@ bool QString::operator>(const QLatin1String &other) const for example. */ -/*! \fn bool QString::operator!=(const QString &other) const +/*! \fn bool operator!=(const QString &s1, const QString &s2) + \relates QString - Returns true if this string is not equal to string \a other; + Returns true if string \a s1 is not equal to string \a s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 12a5acb689..bdadba8bd4 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -486,12 +486,12 @@ public: static QString number(qulonglong, int base=10); static QString number(double, char f='g', int prec=6); - bool operator==(const QString &s) const; - bool operator<(const QString &s) const; - inline bool operator>(const QString &s) const { return s < *this; } - inline bool operator!=(const QString &s) const { return !operator==(s); } - inline bool operator<=(const QString &s) const { return !operator>(s); } - inline bool operator>=(const QString &s) const { return !operator<(s); } + friend Q_CORE_EXPORT bool operator==(const QString &s1, const QString &s2); + friend Q_CORE_EXPORT bool operator<(const QString &s1, const QString &s2); + friend inline bool operator>(const QString &s1, const QString &s2) { return s2 < s1; } + friend inline bool operator!=(const QString &s1, const QString &s2) { return !(s1 == s2); } + friend inline bool operator<=(const QString &s1, const QString &s2) { return !(s1 > s2); } + friend inline bool operator>=(const QString &s1, const QString &s2) { return !(s1 < s2); } bool operator==(const QLatin1String &s) const; bool operator<(const QLatin1String &s) const; -- cgit v1.2.3 From f79768cd39a58529656b320bfaa9c096eccb191d Mon Sep 17 00:00:00 2001 From: Matthew Vogt Date: Fri, 24 Feb 2012 10:51:42 +1000 Subject: Remove Q_DECLARATIVE_EXPORT and Q_QTQUICK1_EXPORT Theses definitions are no longer required in qtbase. Task-number: QTBUG-23737 Change-Id: Ib11e5840086b44120adabe83a1b068c991920f2f Reviewed-by: Martin Jones Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 1fb5778f14..fb6eaeb452 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -610,16 +610,6 @@ class QDataStream; # else # define Q_SVG_EXPORT Q_DECL_IMPORT # endif -# if defined(QT_BUILD_QTQUICK1_LIB) -# define Q_QTQUICK1_EXPORT Q_DECL_EXPORT -# else -# define Q_QTQUICK1_EXPORT Q_DECL_IMPORT -# endif -# if defined(QT_BUILD_DECLARATIVE_LIB) -# define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT -# else -# define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT -# endif # if defined(QT_BUILD_OPENGL_LIB) # define Q_OPENGL_EXPORT Q_DECL_EXPORT # else @@ -680,8 +670,6 @@ class QDataStream; # define Q_SQL_EXPORT Q_DECL_IMPORT # define Q_NETWORK_EXPORT Q_DECL_IMPORT # define Q_SVG_EXPORT Q_DECL_IMPORT -# define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT -# define Q_QTQUICK1_EXPORT Q_DECL_IMPORT # define Q_CANVAS_EXPORT Q_DECL_IMPORT # define Q_OPENGL_EXPORT Q_DECL_IMPORT # define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT @@ -714,8 +702,6 @@ class QDataStream; # define Q_SQL_EXPORT Q_DECL_EXPORT # define Q_NETWORK_EXPORT Q_DECL_EXPORT # define Q_SVG_EXPORT Q_DECL_EXPORT -# define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT -# define Q_QTQUICK1_EXPORT Q_DECL_EXPORT # define Q_OPENGL_EXPORT Q_DECL_EXPORT # define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT # define Q_OPENVG_EXPORT Q_DECL_EXPORT @@ -734,8 +720,6 @@ class QDataStream; # define Q_SQL_EXPORT # define Q_NETWORK_EXPORT # define Q_SVG_EXPORT -# define Q_DECLARATIVE_EXPORT -# define Q_QTQUICK1_EXPORT # define Q_OPENGL_EXPORT # define Q_MULTIMEDIA_EXPORT # define Q_OPENVG_EXPORT -- cgit v1.2.3 From 4a82f78dea36c297b5a4a44853936cc733de8197 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 28 Feb 2012 22:06:36 +0100 Subject: QPair: remove user-defined copy assignment operator The compiler-generated copy assignment operator is fine, and the user-defined one prevents the compiler from synthesising a move assignment operator. Change-Id: I044104a2fd4d7522a910d5c2a68d11dabeca99c4 Reviewed-by: Olivier Goffart --- src/corelib/tools/qpair.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qpair.h b/src/corelib/tools/qpair.h index 501f2af3e6..064a75048c 100644 --- a/src/corelib/tools/qpair.h +++ b/src/corelib/tools/qpair.h @@ -57,9 +57,7 @@ struct QPair QPair() : first(T1()), second(T2()) {} QPair(const T1 &t1, const T2 &t2) : first(t1), second(t2) {} - - QPair &operator=(const QPair &other) - { first = other.first; second = other.second; return *this; } + // compiler-generated copy/move ctor/assignment operators are fine! T1 first; T2 second; -- cgit v1.2.3 From b72bcea864e6e38f14c8f0c94b7ea6019d7d8a01 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 28 Feb 2012 22:09:48 +0100 Subject: QPair: don't copy-initialise 'first'/'second' in the default ctor Why would we want copy-initialisation if we can have the default constructor? Change-Id: Id2de36d42ef9f63793ff4e3ec36202d3f2bf5f30 Reviewed-by: Olivier Goffart --- src/corelib/tools/qpair.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qpair.h b/src/corelib/tools/qpair.h index 064a75048c..5df33a4e9d 100644 --- a/src/corelib/tools/qpair.h +++ b/src/corelib/tools/qpair.h @@ -55,7 +55,7 @@ struct QPair typedef T1 first_type; typedef T2 second_type; - QPair() : first(T1()), second(T2()) {} + QPair() : first(), second() {} QPair(const T1 &t1, const T2 &t2) : first(t1), second(t2) {} // compiler-generated copy/move ctor/assignment operators are fine! -- cgit v1.2.3 From aac821c220662ec9d1acbf88ac82603bbda3cee8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 28 Feb 2012 22:52:41 +0100 Subject: QRingBuffer: make constructor explicit This is a private class, but it's so close to the classical Stack(int) example for explicit that I just have to make this ctor explicit, too: QRingBuffer rb = 0; // oops: meant '*rb' now no longer compiles. Change-Id: I7d58c1f08c1b14d14930426159c5c8db71b4cf4d Reviewed-by: Olivier Goffart --- src/corelib/tools/qringbuffer_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h index 46e505099a..c248477f2c 100644 --- a/src/corelib/tools/qringbuffer_p.h +++ b/src/corelib/tools/qringbuffer_p.h @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE class QRingBuffer { public: - inline QRingBuffer(int growth = 4096) : basicBlockSize(growth) { + explicit inline QRingBuffer(int growth = 4096) : basicBlockSize(growth) { buffers << QByteArray(); clear(); } -- cgit v1.2.3 From 6363672163a8d40c685c0120f76b261685ee34be Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 22 Feb 2012 16:36:52 +0100 Subject: Add support for QT_NO_SIGNALS_SLOTS_KEYWORDS QT_NO_KEYWORDS can be used for example to ensure that foreach can not be used, but Q_FOREACH must be, that slots must not be used but Q_SLOTS must be, etc. Typically they are used to avoid symbol conflict with other libraries that may use the same keywords (I think boost uses signals). For 3rd party libraries, it makes sense to use Q_SLOTS and Q_SIGNALS instead of slots and signals, so that downstreams can still choose to use QT_NO_KEYWORDS in their code. The most convenient way to enforce that currently is to define QT_NO_KEYWORDS when building the 3rd party library. However, that has the inconvenient side effect of making foreach, forever and emit not usable within the library implementation. This patch makes it possible for the 3rd party library to use QT_NO_SIGNALS_SLOTS_KEYWORDS to exclude signals and slots without affecting whether the other keywords can be used in the library implementation. Change-Id: If1e16a4fa384bd3a2ddd737143499f8b587bc4f8 Reviewed-by: Lars Knoll Reviewed-by: Richard J. Moore --- src/corelib/kernel/qobjectdefs.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index ec51251531..15daf223b9 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -65,8 +65,10 @@ class QString; # if defined(QT_NO_KEYWORDS) # define QT_NO_EMIT # else -# define slots -# define signals public +# ifndef QT_NO_SIGNALS_SLOTS_KEYWORDS +# define slots +# define signals public +# endif # endif # define Q_SLOTS # define Q_SIGNALS public -- cgit v1.2.3 From ec234625c0bde3eeb67cd4681cb66277bdf115b3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 29 Feb 2012 12:28:57 +0100 Subject: Remove include for no-longer-supported compiler. Change-Id: I162da3e373a0191f69e50e110114ef78c2d5fc66 Reviewed-by: Olivier Goffart --- src/corelib/tools/qstringbuilder.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 4c963185ad..0fd164c2e4 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -45,12 +45,6 @@ #include #include -#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) -# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ == 0) -# include -# endif -#endif - #include QT_BEGIN_HEADER -- cgit v1.2.3 From 8b33be0054517e7506f1ed4378232fa81e710df1 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 28 Feb 2012 22:27:48 +0100 Subject: QScopedValueRollback: make constructor explicit I'm not even sure whether you could implicitly convert a T& into a QScopedValueRollback, seeing as the constructor takes a non-const reference, but it looks wrong without explicit and QObject o = new QObject(parent); also won't compile even with implicit QObject(QObject*) under a conformant compiler because of the disabled copy constructor, and we still make QObject(QObject*) explicit, so add it here, too. Change-Id: I722a6e8431644e450fe2b401ccfb707a8e982380 Reviewed-by: Olivier Goffart Reviewed-by: Lars Knoll Reviewed-by: Shane Kearns --- src/corelib/tools/qscopedvaluerollback.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qscopedvaluerollback.h b/src/corelib/tools/qscopedvaluerollback.h index 23d2d9eda0..d53cabd315 100644 --- a/src/corelib/tools/qscopedvaluerollback.h +++ b/src/corelib/tools/qscopedvaluerollback.h @@ -51,7 +51,7 @@ template class QScopedValueRollback { public: - QScopedValueRollback(T &var) : + explicit QScopedValueRollback(T &var) : varRef(var) { oldValue = varRef; -- cgit v1.2.3 From 85e050b0b3f1eb36007abd6b12158ce3496a4dc4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 27 Feb 2012 22:06:54 +0100 Subject: Make qlocale.h not depend on qvariant.h. As a consequence, we have to add more explicit includes. Change-Id: Ib3137031f0554b846c7bbd08f1f7df10dfeb8e61 Reviewed-by: Olivier Goffart --- src/corelib/io/qstandardpaths_unix.cpp | 1 + src/corelib/json/qjsonarray.cpp | 1 + src/corelib/json/qjsondocument.cpp | 1 + src/corelib/json/qjsonobject.cpp | 1 + src/corelib/tools/qlocale.h | 1 - src/corelib/tools/qlocale_p.h | 2 +- 6 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp index 62c846738e..5499751751 100644 --- a/src/corelib/io/qstandardpaths_unix.cpp +++ b/src/corelib/io/qstandardpaths_unix.cpp @@ -42,6 +42,7 @@ #include "qstandardpaths.h" #include #include +#include #include #include #include diff --git a/src/corelib/json/qjsonarray.cpp b/src/corelib/json/qjsonarray.cpp index 0eb1974147..6ffb9639f7 100644 --- a/src/corelib/json/qjsonarray.cpp +++ b/src/corelib/json/qjsonarray.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include "qjsonwriter_p.h" diff --git a/src/corelib/json/qjsondocument.cpp b/src/corelib/json/qjsondocument.cpp index 8a7fa760ae..c2204bf696 100644 --- a/src/corelib/json/qjsondocument.cpp +++ b/src/corelib/json/qjsondocument.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include "qjsonwriter_p.h" #include "qjsonparser_p.h" diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp index b7af8c22cf..289a752c8b 100644 --- a/src/corelib/json/qjsonobject.cpp +++ b/src/corelib/json/qjsonobject.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include "qjson_p.h" #include "qjsonwriter_p.h" diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index c029f627b2..2ecd934100 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -42,7 +42,6 @@ #ifndef QLOCALE_H #define QLOCALE_H -#include #include #include diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index c6902ca206..ad7c9706c4 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -55,7 +55,7 @@ #include "QtCore/qstring.h" #include "QtCore/qvarlengtharray.h" -#include "QtCore/qmetatype.h" +#include "QtCore/qvariant.h" #include "qlocale.h" -- cgit v1.2.3 From 612152fad8f531e66ecda9ef72eae32061af7139 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 27 Feb 2012 21:57:12 +0100 Subject: Make qobject_p.h not need qvariant.h. Move definition of ExtraData to the implementation file. As a side effect, we need to include qhash.h in some other places. Change-Id: I8bb4ec0940ae51c7d6961c9a51adb80fd444e1e3 Reviewed-by: Olivier Goffart --- src/corelib/io/qfilesystemwatcher_polling_p.h | 1 + src/corelib/kernel/qeventdispatcher_win_p.h | 1 + src/corelib/kernel/qobject.cpp | 10 ++++++++++ src/corelib/kernel/qobject_p.h | 11 +---------- 4 files changed, 13 insertions(+), 10 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qfilesystemwatcher_polling_p.h b/src/corelib/io/qfilesystemwatcher_polling_p.h index 14f6345412..e50082c6d3 100644 --- a/src/corelib/io/qfilesystemwatcher_polling_p.h +++ b/src/corelib/io/qfilesystemwatcher_polling_p.h @@ -58,6 +58,7 @@ #include #include #include +#include #include "qfilesystemwatcher_p.h" diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h index c404967e6a..a831ad39e8 100644 --- a/src/corelib/kernel/qeventdispatcher_win_p.h +++ b/src/corelib/kernel/qeventdispatcher_win_p.h @@ -55,6 +55,7 @@ #include "QtCore/qabstracteventdispatcher.h" #include "QtCore/qt_windows.h" +#include "QtCore/qhash.h" #include "qabstracteventdispatcher_p.h" diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 8fa5dcdcff..2231518253 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -69,6 +69,16 @@ QT_BEGIN_NAMESPACE +struct QObjectPrivate::ExtraData +{ + ExtraData() {} +#ifndef QT_NO_USERDATA + QVector userData; +#endif + QList propertyNames; + QList propertyValues; +}; + static int DIRECT_CONNECTION_ONLY = 0; static int *queuedConnectionTypes(const QList &typeNames) diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index fa1aee8173..f75d4464b2 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -60,7 +60,6 @@ #include "QtCore/qlist.h" #include "QtCore/qvector.h" #include "QtCore/qreadwritelock.h" -#include "QtCore/qvariant.h" QT_BEGIN_NAMESPACE @@ -98,16 +97,8 @@ class Q_CORE_EXPORT QObjectPrivate : public QObjectData { Q_DECLARE_PUBLIC(QObject) + struct ExtraData; public: - struct ExtraData - { - ExtraData() {} -#ifndef QT_NO_USERDATA - QVector userData; -#endif - QList propertyNames; - QList propertyValues; - }; typedef void (*StaticMetaCallFunction)(QObject *, QMetaObject::Call, int, void **); struct Connection -- cgit v1.2.3 From e1cc0d6bbc2c65b10f23b2935a68a3a34b7c26a0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 29 Feb 2012 11:54:29 +0100 Subject: Allow QChar::SpecialCharacter with QStringBuilder. Change-Id: I3c91fd516bb13e5534aa6f26ee9df745c990dfb5 Reviewed-by: Olivier Goffart --- src/corelib/tools/qstringbuilder.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 0fd164c2e4..e34425be7e 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -167,6 +167,16 @@ template <> struct QConcatenable : private QAbstractConcatenable { *out++ = c; } }; +template <> struct QConcatenable : private QAbstractConcatenable +{ + typedef QChar::SpecialCharacter type; + typedef QString ConvertTo; + enum { ExactSize = true }; + static int size(const QChar::SpecialCharacter) { return 1; } + static inline void appendTo(const QChar::SpecialCharacter c, QChar *&out) + { *out++ = c; } +}; + template <> struct QConcatenable : private QAbstractConcatenable { typedef QCharRef type; -- cgit v1.2.3 From da08210494c132e8990ae3ba2ddb78983d266461 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 28 Feb 2012 09:54:53 +0100 Subject: remove pointless ifdefs configure always defines all of these constants. the exception is SettingsPath which is unix-only, so make the #ifdef explicit about that. Change-Id: I339d2d7cb9d188a8e74d79310c3a80b5d4dbb806 Reviewed-by: Thiago Macieira --- src/corelib/global/qlibraryinfo.cpp | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index c871675334..72db761e2d 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -226,66 +226,44 @@ QLibraryInfo::location(LibraryLocation loc) if(!QLibraryInfoPrivate::configuration()) { const char *path = 0; switch (loc) { -#ifdef QT_CONFIGURE_PREFIX_PATH case PrefixPath: path = QT_CONFIGURE_PREFIX_PATH; break; -#endif -#ifdef QT_CONFIGURE_DOCUMENTATION_PATH case DocumentationPath: path = QT_CONFIGURE_DOCUMENTATION_PATH; break; -#endif -#ifdef QT_CONFIGURE_HEADERS_PATH case HeadersPath: path = QT_CONFIGURE_HEADERS_PATH; break; -#endif -#ifdef QT_CONFIGURE_LIBRARIES_PATH case LibrariesPath: path = QT_CONFIGURE_LIBRARIES_PATH; break; -#endif -#ifdef QT_CONFIGURE_BINARIES_PATH case BinariesPath: path = QT_CONFIGURE_BINARIES_PATH; break; -#endif -#ifdef QT_CONFIGURE_PLUGINS_PATH case PluginsPath: path = QT_CONFIGURE_PLUGINS_PATH; break; -#endif -#ifdef QT_CONFIGURE_IMPORTS_PATH case ImportsPath: path = QT_CONFIGURE_IMPORTS_PATH; break; -#endif -#ifdef QT_CONFIGURE_DATA_PATH case DataPath: path = QT_CONFIGURE_DATA_PATH; break; -#endif -#ifdef QT_CONFIGURE_TRANSLATIONS_PATH case TranslationsPath: path = QT_CONFIGURE_TRANSLATIONS_PATH; break; -#endif -#ifdef QT_CONFIGURE_SETTINGS_PATH +#ifndef Q_OS_WIN // On Windows we use the registry case SettingsPath: path = QT_CONFIGURE_SETTINGS_PATH; break; #endif -#ifdef QT_CONFIGURE_EXAMPLES_PATH case ExamplesPath: path = QT_CONFIGURE_EXAMPLES_PATH; break; -#endif -#ifdef QT_CONFIGURE_TESTS_PATH case TestsPath: path = QT_CONFIGURE_TESTS_PATH; break; -#endif default: break; } -- cgit v1.2.3 From 486bde8372b30a2133e911268147704c699f8284 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 28 Feb 2012 11:01:52 +0100 Subject: make qlibraryinfo table-driven switch blocks are noisy. this is nicer. reshuffled the LibraryLocation enum to make table lookups possible and future-safe. using pointer-free tables to avoid adding data relocations. Change-Id: I70ec2c2142ce02a15e67284e4b285d754d930da3 Reviewed-by: Thiago Macieira --- src/corelib/global/qlibraryinfo.cpp | 120 +++++++++--------------------------- src/corelib/global/qlibraryinfo.h | 8 +-- 2 files changed, 34 insertions(+), 94 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 72db761e2d..ac99b80cb0 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -214,6 +214,22 @@ QLibraryInfo::isDebugBuild() return false; } +static const struct { + char key[14], value[13]; +} qtConfEntries[] = { + { "Prefix", "" }, + { "Documentation", "doc" }, + { "Headers", "include" }, + { "Libraries", "lib" }, + { "Binaries", "bin" }, + { "Plugins", "plugins" }, + { "Imports", "imports" }, + { "Data", "" }, + { "Translations", "translations" }, + { "Examples", "" }, + { "Tests", "tests" }, +}; + /*! Returns the location specified by \a loc. @@ -225,102 +241,26 @@ QLibraryInfo::location(LibraryLocation loc) QString ret; if(!QLibraryInfoPrivate::configuration()) { const char *path = 0; - switch (loc) { - case PrefixPath: - path = QT_CONFIGURE_PREFIX_PATH; - break; - case DocumentationPath: - path = QT_CONFIGURE_DOCUMENTATION_PATH; - break; - case HeadersPath: - path = QT_CONFIGURE_HEADERS_PATH; - break; - case LibrariesPath: - path = QT_CONFIGURE_LIBRARIES_PATH; - break; - case BinariesPath: - path = QT_CONFIGURE_BINARIES_PATH; - break; - case PluginsPath: - path = QT_CONFIGURE_PLUGINS_PATH; - break; - case ImportsPath: - path = QT_CONFIGURE_IMPORTS_PATH; - break; - case DataPath: - path = QT_CONFIGURE_DATA_PATH; - break; - case TranslationsPath: - path = QT_CONFIGURE_TRANSLATIONS_PATH; - break; + if (loc >= 0 && loc < sizeof(qt_configure_prefix_path_strs)/sizeof(qt_configure_prefix_path_strs[0])) + path = qt_configure_prefix_path_strs[loc] + 12; #ifndef Q_OS_WIN // On Windows we use the registry - case SettingsPath: + else if (loc == SettingsPath) path = QT_CONFIGURE_SETTINGS_PATH; - break; #endif - case ExamplesPath: - path = QT_CONFIGURE_EXAMPLES_PATH; - break; - case TestsPath: - path = QT_CONFIGURE_TESTS_PATH; - break; - default: - break; - } if (path) ret = QString::fromLocal8Bit(path); } else { QString key; QString defaultValue; - switch(loc) { - case PrefixPath: - key = QLatin1String("Prefix"); - break; - case DocumentationPath: - key = QLatin1String("Documentation"); - defaultValue = QLatin1String("doc"); - break; - case HeadersPath: - key = QLatin1String("Headers"); - defaultValue = QLatin1String("include"); - break; - case LibrariesPath: - key = QLatin1String("Libraries"); - defaultValue = QLatin1String("lib"); - break; - case BinariesPath: - key = QLatin1String("Binaries"); - defaultValue = QLatin1String("bin"); - break; - case PluginsPath: - key = QLatin1String("Plugins"); - defaultValue = QLatin1String("plugins"); - break; - case ImportsPath: - key = QLatin1String("Imports"); - defaultValue = QLatin1String("imports"); - break; - case DataPath: - key = QLatin1String("Data"); - break; - case TranslationsPath: - key = QLatin1String("Translations"); - defaultValue = QLatin1String("translations"); - break; - case SettingsPath: - key = QLatin1String("Settings"); - break; - case ExamplesPath: - key = QLatin1String("Examples"); - break; - case TestsPath: - key = QLatin1String("Tests"); - defaultValue = QLatin1String("tests"); - break; - default: - break; + if (loc >= 0 && loc < sizeof(qtConfEntries)/sizeof(qtConfEntries[0])) { + key = QLatin1String(qtConfEntries[loc].key); + defaultValue = QLatin1String(qtConfEntries[loc].value); } +#ifndef Q_OS_WIN // On Windows we use the registry + else if (loc == SettingsPath) + key = QLatin1String("Settings"); +#endif if(!key.isNull()) { QSettings *config = QLibraryInfoPrivate::configuration(); @@ -391,9 +331,9 @@ QLibraryInfo::location(LibraryLocation loc) \value ImportsPath The location of installed QML extensions to import. \value DataPath The location of general Qt data. \value TranslationsPath The location of translation information for Qt strings. - \value SettingsPath The location for Qt settings. \value ExamplesPath The location for examples upon install. \value TestsPath The location of installed Qt testcases. + \value SettingsPath The location for Qt settings. Not applicable on Windows. \sa location() */ @@ -421,9 +361,9 @@ void qt_core_boilerplate() "Library path: %s\n" "Include path: %s\n", qt_configure_installation + 12, - qt_configure_prefix_path_str + 12, - qt_configure_libraries_path_str + 12, - qt_configure_headers_path_str + 12); + qt_configure_prefix_path_strs[QT_PREPEND_NAMESPACE(QLibraryInfo)::PrefixPath] + 12, + qt_configure_prefix_path_strs[QT_PREPEND_NAMESPACE(QLibraryInfo)::LibrariesPath] + 12, + qt_configure_prefix_path_strs[QT_PREPEND_NAMESPACE(QLibraryInfo)::HeadersPath] + 12); QT_PREPEND_NAMESPACE(qDumpCPUFeatures)(); diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index 66f3d40792..f6234d1eb4 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -66,18 +66,18 @@ public: enum LibraryLocation { - PrefixPath, + PrefixPath = 0, DocumentationPath, HeadersPath, LibrariesPath, BinariesPath, PluginsPath, + ImportsPath, DataPath, TranslationsPath, - SettingsPath, ExamplesPath, - ImportsPath, - TestsPath + TestsPath, + SettingsPath = 100 }; static QString location(LibraryLocation); // ### Qt 5: consider renaming it to path() -- cgit v1.2.3 From 1ff1486d5372177798ea3c8785a4b80a1f6cbe1e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 28 Feb 2012 22:39:07 +0100 Subject: QCryptographicHash: make constructor explicit The copy constructor of QCH is disabled, so there's no point in providing an implicit conversion from the Algorithm enum anyway, so make the ctor explicit. Change-Id: I4ea74ffb0963b4f49415da17778c3e6050454a6b Reviewed-by: Olivier Goffart --- src/corelib/tools/qcryptographichash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qcryptographichash.h b/src/corelib/tools/qcryptographichash.h index 2bfc03373a..6ebe389faf 100644 --- a/src/corelib/tools/qcryptographichash.h +++ b/src/corelib/tools/qcryptographichash.h @@ -65,7 +65,7 @@ public: Sha512 }; - QCryptographicHash(Algorithm method); + explicit QCryptographicHash(Algorithm method); ~QCryptographicHash(); void reset(); -- cgit v1.2.3 From 76afa1556c9739f341adf15226b84bcc8cbaa032 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Mon, 27 Feb 2012 22:19:39 +0100 Subject: Make QJsonPrivate::String compile on big endian platforms. Was missing a variable declaration and an explicit cast. Change-Id: I4f0fb9c3d9b8472adf0d91036442adc1fe255c7e Reviewed-by: Lars Knoll --- src/corelib/json/qjson_p.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/json/qjson_p.h b/src/corelib/json/qjson_p.h index 55c37988e2..0742ced39b 100644 --- a/src/corelib/json/qjson_p.h +++ b/src/corelib/json/qjson_p.h @@ -309,6 +309,7 @@ public: { d->length = str.length(); #if Q_BYTE_ORDER == Q_BIG_ENDIAN + const qle_ushort *uc = (const qle_ushort *)str.unicode(); for (int i = 0; i < str.length(); ++i) d->utf16[i] = uc[i]; #else @@ -359,7 +360,7 @@ public: QString str(l, Qt::Uninitialized); QChar *ch = str.data(); for (int i = 0; i < l; ++i) - ch[i] = d->utf16[i]; + ch[i] = QChar(d->utf16[i]); return str; #endif } -- cgit v1.2.3 From 3f1a4be30263a676b7e188bf6cfa809c7788c87f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Feb 2012 15:46:01 +0100 Subject: Make loadAcquire const. Change-Id: Iad2d60d1abe363a3b85eaf152861d0979a997d81 Reviewed-by: Thiago Macieira --- src/corelib/arch/qatomic_gcc.h | 2 +- src/corelib/arch/qatomic_ia64.h | 4 ++-- src/corelib/thread/qbasicatomic.h | 4 ++-- src/corelib/thread/qgenericatomic.h | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/arch/qatomic_gcc.h b/src/corelib/arch/qatomic_gcc.h index 225a7809eb..9edb74fa73 100644 --- a/src/corelib/arch/qatomic_gcc.h +++ b/src/corelib/arch/qatomic_gcc.h @@ -84,7 +84,7 @@ template struct QAtomicOps: QGenericAtomicOps > typedef T Type; #ifndef __ia64__ - static T loadAcquire(T &_q_value) + static T loadAcquire(const T &_q_value) { T tmp = _q_value; __sync_synchronize(); diff --git a/src/corelib/arch/qatomic_ia64.h b/src/corelib/arch/qatomic_ia64.h index d82ad12223..5108751f2a 100644 --- a/src/corelib/arch/qatomic_ia64.h +++ b/src/corelib/arch/qatomic_ia64.h @@ -143,9 +143,9 @@ template struct QBasicAtomicOps: QGenericAtomicOps static inline - T loadAcquire(T &_q_value) + T loadAcquire(const T &_q_value) { - return *static_cast(&_q_value); + return *static_cast(&_q_value); } template static inline diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index 96338c62dc..01a69dbd8b 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -136,7 +136,7 @@ public: // Atomic API, implemented in qatomic_XXX.h - T loadAcquire() { return Ops::loadAcquire(_q_value); } + T loadAcquire() const { return Ops::loadAcquire(_q_value); } void storeRelease(T newValue) { Ops::storeRelease(_q_value, newValue); } static bool isReferenceCountingNative() { return Ops::isReferenceCountingNative(); } @@ -206,7 +206,7 @@ public: void store(Type newValue) { _q_value = newValue; } // Atomic API, implemented in qatomic_XXX.h - Type loadAcquire() { return Ops::loadAcquire(_q_value); } + Type loadAcquire() const { return Ops::loadAcquire(_q_value); } void storeRelease(Type newValue) { Ops::storeRelease(_q_value, newValue); } static bool isTestAndSetNative() { return Ops::isTestAndSetNative(); } diff --git a/src/corelib/thread/qgenericatomic.h b/src/corelib/thread/qgenericatomic.h index f4d5e2f8d9..34c040c39b 100644 --- a/src/corelib/thread/qgenericatomic.h +++ b/src/corelib/thread/qgenericatomic.h @@ -85,7 +85,7 @@ template struct QGenericAtomicOps static void orderedMemoryFence() { } template static inline always_inline - T load(T &_q_value) + T load(const T &_q_value) { return _q_value; } @@ -97,9 +97,9 @@ template struct QGenericAtomicOps } template static inline always_inline - T loadAcquire(T &_q_value) + T loadAcquire(const T &_q_value) { - T tmp = *static_cast(&_q_value); + T tmp = *static_cast(&_q_value); BaseClass::acquireMemoryFence(); return tmp; } -- cgit v1.2.3 From 0d68a5aabf4f93236df95da8836ecf62c4e92593 Mon Sep 17 00:00:00 2001 From: Morten Johan Sorvig Date: Tue, 28 Feb 2012 12:37:55 +0100 Subject: Remove Mac qDebug ifdefs. Make qDebug work again with the new logging framework. Change-Id: Ib88a83182429636b274d6284933d5ea00db7279c Reviewed-by: Bradley T. Hughes --- src/corelib/kernel/qcore_mac_p.h | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index 78cb0eff3b..048d746183 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -57,17 +57,6 @@ # define __IMAGECAPTURE__ #endif -#undef OLD_DEBUG -#ifdef DEBUG -# define OLD_DEBUG DEBUG -# undef DEBUG -#endif -#define DEBUG 0 -#ifdef qDebug -# define old_qDebug qDebug -# undef qDebug -#endif - #if defined(QT_BUILD_QMAKE) || defined(QT_BOOTSTRAPPED) #include #else @@ -82,18 +71,6 @@ #include #endif -#undef DEBUG -#ifdef OLD_DEBUG -# define DEBUG OLD_DEBUG -# undef OLD_DEBUG -#endif - -#ifdef old_qDebug -# undef qDebug -# define qDebug QT_NO_QDEBUG_MACRO -# undef old_qDebug -#endif - #include "qstring.h" QT_BEGIN_NAMESPACE -- cgit v1.2.3 From ff004175bcd5dc23f8c080cd390b04117c9f51df Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 26 Feb 2012 23:01:46 +0100 Subject: QFlags: mark as Q_PRIMITIVE_TYPE I originally tried to put Q_DECLARE_TYPEINFOs into Q_DECLARE_OPERATORS_FOR_FLAGS, to declare not only the flags type, but also the underlying enum as primitive, but too many users (arguably correctly) used Q_DECLARE_OPERATORS_FOR_FLAGS at (non-global) namespace scope where QTypeInfo would have been specialised in the wrong namespace. So specialise QTypeInfo for QFlags only. Change-Id: I4af6e29aefbd9460a3d2bc6405f03cdf6b1096bc Reviewed-by: Thiago Macieira Reviewed-by: Stephen Kelly Reviewed-by: Olivier Goffart --- src/corelib/global/qtypeinfo.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index 6297b35b9c..815be935f7 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -161,6 +161,10 @@ public: \ template<> \ Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS) +/* Specialize QTypeInfo for QFlags */ +template class QFlags; +template +Q_DECLARE_TYPEINFO_BODY(QFlags, Q_PRIMITIVE_TYPE); /* Specialize a shared type with: -- cgit v1.2.3 From f885a526acbb2d5fd15fe76478bf3faef1570aec Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 29 Feb 2012 01:01:01 +0100 Subject: SHA-2 code does not compile on FreeBSD The code fails to compile with the below error: qcryptographichash.cpp:55: error: conflicting declaration 'typedef quint64 uint64_t' /usr/include/sys/types.h:99: error: 'uint64_t' has a previous declaration as 'typedef __uint64_t uint64_t' FreeBSDs types.h defines the used defines. Maybe it would be less ugly to switch the code to quint*, or use a define to do so, or to have basic os detection for stdint.h, not to include sys/types.h. Change-Id: Ic62ae4b742c1123b4b7e17158d216374e609f59f Reviewed-by: Bradley T. Hughes --- src/corelib/tools/qcryptographichash.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index 31a0fdc5e6..3730a6c580 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -52,9 +52,18 @@ from from stdint.h, but since this header is not available on all platforms (MSVC 2008, for example), we need to define them ourselves. */ +#ifndef _UINT64_T_DECLARED typedef QT_PREPEND_NAMESPACE(quint64) uint64_t; +#endif + +#ifndef _UINT32_T_DECLARED typedef QT_PREPEND_NAMESPACE(quint32) uint32_t; +#endif + +#ifndef _UINT8_T_DECLARED typedef QT_PREPEND_NAMESPACE(quint8) uint8_t; +#endif + typedef QT_PREPEND_NAMESPACE(qint16) int_least16_t; // Header from rfc6234 with 1 modification: // sha1.h - commented out '#include ' on line 74 -- cgit v1.2.3 From eafc667136c28fdde28d5dbc775ad978f888aa71 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 29 Feb 2012 00:02:53 +0000 Subject: QRegExp: fix \i \I \c \C \p \P escape sequences Those escape sequences have a special meaning in the XML Schema 1.1 regular expressions, but not in Perl-compatible ones. An escape sequence that has no special meaning should match the escaped character itself; this patch fixes QRegExp's behaviour in that regard (previously, it added a character class matching nothing). Change-Id: I983f923baa7c2ec19938b96353f3a205e6c06d58 Reviewed-by: Andy Shaw Reviewed-by: Thiago Macieira --- src/corelib/tools/qregexp.cpp | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index d7bcd0edbc..e55144ec4c 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -3015,6 +3015,8 @@ int QRegExpEngine::getEscape() if (xmlSchemaExtensions) { yyCharClass->setNegative(!yyCharClass->negative()); // fall through + } else { + break; } case 'i': if (xmlSchemaExtensions) { @@ -3045,12 +3047,16 @@ int QRegExpEngine::getEscape() yyCharClass->addRange(0xf900, 0xfdcf); yyCharClass->addRange(0xfdf0, 0xfffd); yyCharClass->addRange((ushort)0x10000, (ushort)0xeffff); + return Tok_CharClass; + } else { + break; } - return Tok_CharClass; case 'C': if (xmlSchemaExtensions) { yyCharClass->setNegative(!yyCharClass->negative()); // fall through + } else { + break; } case 'c': if (xmlSchemaExtensions) { @@ -3087,12 +3093,16 @@ int QRegExpEngine::getEscape() yyCharClass->addRange((ushort)0x10000, (ushort)0xeffff); yyCharClass->addRange(0x0300, 0x036f); yyCharClass->addRange(0x203f, 0x2040); + return Tok_CharClass; + } else { + break; } - return Tok_CharClass; case 'P': if (xmlSchemaExtensions) { yyCharClass->setNegative(!yyCharClass->negative()); // fall through + } else { + break; } case 'p': if (xmlSchemaExtensions) { @@ -3246,8 +3256,10 @@ int QRegExpEngine::getEscape() } else { error(RXERR_CATEGORY); } + return Tok_CharClass; + } else { + break; } - return Tok_CharClass; #endif #ifndef QT_NO_REGEXP_ESCAPE case 'x': @@ -3265,20 +3277,21 @@ int QRegExpEngine::getEscape() return Tok_Char | val; #endif default: - if (prevCh >= '1' && prevCh <= '9') { + break; + } + if (prevCh >= '1' && prevCh <= '9') { #ifndef QT_NO_REGEXP_BACKREF - val = prevCh - '0'; - while (yyCh >= '0' && yyCh <= '9') { - val = (val * 10) + (yyCh - '0'); - yyCh = getChar(); - } - return Tok_BackRef | val; + val = prevCh - '0'; + while (yyCh >= '0' && yyCh <= '9') { + val = (val * 10) + (yyCh - '0'); + yyCh = getChar(); + } + return Tok_BackRef | val; #else - error(RXERR_DISABLED); + error(RXERR_DISABLED); #endif - } - return Tok_Char | prevCh; } + return Tok_Char | prevCh; } #ifndef QT_NO_REGEXP_INTERVAL -- cgit v1.2.3 From 1cd4d6b1819f67b70dd359c7fc43ab06182cc34b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 29 Feb 2012 00:00:27 +0100 Subject: QEvent (and subclasses): make ctors explicit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do this regardless of whether the event subclass is public API or only used in examples. Examples are examples, used by others as templates or even copied verbatim, so they should also follow sound engineering rules. Anyway, there's only one in examples/... Change-Id: I586ff16407a956c9e89288fdd4377eed73f45c0f Reviewed-by: Samuel Rødal --- src/corelib/kernel/qcoreevent.h | 6 +++--- src/corelib/kernel/qeventdispatcher_win_p.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h index 1f36f9c9c8..cac89f2b13 100644 --- a/src/corelib/kernel/qcoreevent.h +++ b/src/corelib/kernel/qcoreevent.h @@ -288,7 +288,7 @@ public: MaxUser = 65535 // last user event id }; - QEvent(Type type); + explicit QEvent(Type type); virtual ~QEvent(); inline Type type() const { return static_cast(t); } inline bool spontaneous() const { return spont; } @@ -330,7 +330,7 @@ private: class Q_CORE_EXPORT QTimerEvent : public QEvent { public: - QTimerEvent( int timerId ); + explicit QTimerEvent( int timerId ); ~QTimerEvent(); int timerId() const { return id; } protected: @@ -355,7 +355,7 @@ protected: class Q_CORE_EXPORT QDynamicPropertyChangeEvent : public QEvent { public: - QDynamicPropertyChangeEvent(const QByteArray &name); + explicit QDynamicPropertyChangeEvent(const QByteArray &name); ~QDynamicPropertyChangeEvent(); inline QByteArray propertyName() const { return n; } diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h index a831ad39e8..565f1ef4b3 100644 --- a/src/corelib/kernel/qeventdispatcher_win_p.h +++ b/src/corelib/kernel/qeventdispatcher_win_p.h @@ -131,7 +131,7 @@ struct WinTimerInfo { // internal timer info class QZeroTimerEvent : public QTimerEvent { public: - inline QZeroTimerEvent(int timerId) + explicit inline QZeroTimerEvent(int timerId) : QTimerEvent(timerId) { t = QEvent::ZeroTimerEvent; } }; -- cgit v1.2.3 From 4908cf2a556948599c40681208438e814ba7b83c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 1 Mar 2012 08:33:15 +0100 Subject: QBoolBlocker: make constructor explicit and disable copying Change-Id: If294eff3f84f837ed554c572527d46a89660de9c Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobject_p.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index fa1aee8173..710aa630d9 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -284,8 +284,9 @@ private: class QBoolBlocker { + Q_DISABLE_COPY(QBoolBlocker) public: - inline QBoolBlocker(bool &b, bool value=true):block(b), reset(b){block = value;} + explicit inline QBoolBlocker(bool &b, bool value=true):block(b), reset(b){block = value;} inline ~QBoolBlocker(){block = reset; } private: bool █ -- cgit v1.2.3 From 15c141511fab24233d42b3c8593f0781a4931c8a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 28 Feb 2012 19:54:46 +0100 Subject: QPair: specialise QTypeInfo based on the typeinfos of its arguments Specialise QTypeInfo> based on the properties of T1 and T2: - If either T1 or T2 is Q_COMPLEX_TYPE, so is QPair. - Otherwise, if either T1 or T2 is Q_MOVABLE_TYPE, so is QPair. - Otherwise, QPair is Q_PRIMITIVE_TYPE. Change-Id: I8aecbd37e3b7924f77f38967498deabf1a19ca24 Reviewed-by: Olivier Goffart Reviewed-by: Thiago Macieira Reviewed-by: Stephen Kelly --- src/corelib/tools/qpair.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/tools/qpair.h b/src/corelib/tools/qpair.h index 501f2af3e6..29eb58bd22 100644 --- a/src/corelib/tools/qpair.h +++ b/src/corelib/tools/qpair.h @@ -65,6 +65,22 @@ struct QPair T2 second; }; +// mark QPair as complex/movable/primitive depending on the +// typeinfos of the constituents: +template +class QTypeInfo< QPair > +{ +public: + enum { + isComplex = QTypeInfo::isComplex || QTypeInfo::isComplex, + isStatic = QTypeInfo::isStatic || QTypeInfo::isStatic, + isLarge = sizeof(QPair) > sizeof(void*), + isPointer = false, + isDummy = false, + sizeOf = sizeof(QPair) + }; +}; + template Q_INLINE_TEMPLATE bool operator==(const QPair &p1, const QPair &p2) { return p1.first == p2.first && p1.second == p2.second; } -- cgit v1.2.3 From d9649812521e9c67cebb2f9a932e853d5333b2b1 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 24 Feb 2012 01:52:11 -0800 Subject: Remove ARMFPA support and Q_DOUBLE_FORMAT detection Remove the -armfpa option the config.tests/unix/doubleformat* detection. The places where we used QT_ARMFPA and Q_DOUBLE_FORMAT has been removed as well. Rationale: ARM FPA with GCC does not work with EABI. Qt currently does not support compiling without EABI, making ARM FPA an impossibility. It is unknown whether other compilers provide ARM FPA support with EABI. Support for ARM FPA can be re-added in the future should the need arise, but since ARM VFP is available for ARMv5 and up, we should encourage implementors to instead use soft-floats or VFP. Change-Id: I3671aba575118ae3e3e6d769759301c8f2f496f5 Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- src/corelib/global/qnumeric_p.h | 42 ---------------------- src/corelib/io/qdatastream.cpp | 69 ------------------------------------- src/corelib/tools/qlocale_tools.cpp | 44 +++-------------------- src/corelib/tools/qlocale_tools_p.h | 4 --- 4 files changed, 4 insertions(+), 155 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index 6b5ecf73e1..851c18203d 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -61,63 +61,43 @@ QT_BEGIN_NAMESPACE static const union { unsigned char c[8]; double d; } qt_be_inf_bytes = { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } }; static const union { unsigned char c[8]; double d; } qt_le_inf_bytes = { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } }; -static const union { unsigned char c[8]; double d; } qt_armfpa_inf_bytes = { { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 } }; static inline double qt_inf() { -#ifdef QT_ARMFPA - return qt_armfpa_inf_bytes.d; -#else return (QSysInfo::ByteOrder == QSysInfo::BigEndian ? qt_be_inf_bytes.d : qt_le_inf_bytes.d); -#endif } // Signaling NAN static const union { unsigned char c[8]; double d; } qt_be_snan_bytes = { { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 } }; static const union { unsigned char c[8]; double d; } qt_le_snan_bytes = { { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f } }; -static const union { unsigned char c[8]; double d; } qt_armfpa_snan_bytes = { { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 } }; static inline double qt_snan() { -#ifdef QT_ARMFPA - return qt_armfpa_snan_bytes.d; -#else return (QSysInfo::ByteOrder == QSysInfo::BigEndian ? qt_be_snan_bytes.d : qt_le_snan_bytes.d); -#endif } // Quiet NAN static const union { unsigned char c[8]; double d; } qt_be_qnan_bytes = { { 0xff, 0xf8, 0, 0, 0, 0, 0, 0 } }; static const union { unsigned char c[8]; double d; } qt_le_qnan_bytes = { { 0, 0, 0, 0, 0, 0, 0xf8, 0xff } }; -static const union { unsigned char c[8]; double d; } qt_armfpa_qnan_bytes = { { 0, 0, 0xf8, 0xff, 0, 0, 0, 0 } }; static inline double qt_qnan() { -#ifdef QT_ARMFPA - return qt_armfpa_qnan_bytes.d; -#else return (QSysInfo::ByteOrder == QSysInfo::BigEndian ? qt_be_qnan_bytes.d : qt_le_qnan_bytes.d); -#endif } #else // Q_CC_MIPS static const unsigned char qt_be_inf_bytes[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 }; static const unsigned char qt_le_inf_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }; -static const unsigned char qt_armfpa_inf_bytes[] = { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 }; static inline double qt_inf() { const unsigned char *bytes; -#ifdef QT_ARMFPA - bytes = qt_armfpa_inf_bytes; -#else bytes = (QSysInfo::ByteOrder == QSysInfo::BigEndian ? qt_be_inf_bytes : qt_le_inf_bytes); -#endif union { unsigned char c[8]; double d; } returnValue; qMemCopy(returnValue.c, bytes, sizeof(returnValue.c)); @@ -127,17 +107,12 @@ static inline double qt_inf() // Signaling NAN static const unsigned char qt_be_snan_bytes[] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 }; static const unsigned char qt_le_snan_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }; -static const unsigned char qt_armfpa_snan_bytes[] = { 0, 0, 0xf8, 0x7f, 0, 0, 0, 0 }; static inline double qt_snan() { const unsigned char *bytes; -#ifdef QT_ARMFPA - bytes = qt_armfpa_snan_bytes; -#else bytes = (QSysInfo::ByteOrder == QSysInfo::BigEndian ? qt_be_snan_bytes : qt_le_snan_bytes); -#endif union { unsigned char c[8]; double d; } returnValue; qMemCopy(returnValue.c, bytes, sizeof(returnValue.c)); @@ -147,17 +122,12 @@ static inline double qt_snan() // Quiet NAN static const unsigned char qt_be_qnan_bytes[] = { 0xff, 0xf8, 0, 0, 0, 0, 0, 0 }; static const unsigned char qt_le_qnan_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0xff }; -static const unsigned char qt_armfpa_qnan_bytes[] = { 0, 0, 0xf8, 0xff, 0, 0, 0, 0 }; static inline double qt_qnan() { const unsigned char *bytes; -#ifdef QT_ARMFPA - bytes = qt_armfpa_qnan_bytes; -#else bytes = (QSysInfo::ByteOrder == QSysInfo::BigEndian ? qt_be_qnan_bytes : qt_le_qnan_bytes); -#endif union { unsigned char c[8]; double d; } returnValue; qMemCopy(returnValue.c, bytes, sizeof(returnValue.c)); @@ -169,43 +139,31 @@ static inline double qt_qnan() static inline bool qt_is_inf(double d) { uchar *ch = (uchar *)&d; -#ifdef QT_ARMFPA - return (ch[3] & 0x7f) == 0x7f && ch[2] == 0xf0; -#else if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { return (ch[0] & 0x7f) == 0x7f && ch[1] == 0xf0; } else { return (ch[7] & 0x7f) == 0x7f && ch[6] == 0xf0; } -#endif } static inline bool qt_is_nan(double d) { uchar *ch = (uchar *)&d; -#ifdef QT_ARMFPA - return (ch[3] & 0x7f) == 0x7f && ch[2] > 0xf0; -#else if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { return (ch[0] & 0x7f) == 0x7f && ch[1] > 0xf0; } else { return (ch[7] & 0x7f) == 0x7f && ch[6] > 0xf0; } -#endif } static inline bool qt_is_finite(double d) { uchar *ch = (uchar *)&d; -#ifdef QT_ARMFPA - return (ch[3] & 0x7f) != 0x7f || (ch[2] & 0xf0) != 0xf0; -#else if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { return (ch[0] & 0x7f) != 0x7f || (ch[1] & 0xf0) != 0xf0; } else { return (ch[7] & 0x7f) != 0x7f || (ch[6] & 0xf0) != 0xf0; } -#endif } static inline bool qt_is_inf(float d) diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp index 7920d881b4..f3fe91427a 100644 --- a/src/corelib/io/qdatastream.cpp +++ b/src/corelib/io/qdatastream.cpp @@ -771,10 +771,6 @@ QDataStream &QDataStream::operator>>(float &f) return *this; } -#if defined(Q_DOUBLE_FORMAT) -#define Q_DF(x) Q_DOUBLE_FORMAT[(x)] - '0' -#endif - /*! \overload @@ -797,7 +793,6 @@ QDataStream &QDataStream::operator>>(double &f) f = 0.0; CHECK_STREAM_PRECOND(*this) -#ifndef Q_DOUBLE_FORMAT if (dev->read((char *)&f, 8) != 8) { f = 0.0; setStatus(ReadPastEnd); @@ -811,39 +806,6 @@ QDataStream &QDataStream::operator>>(double &f) f = x.val1; } } -#else - //non-standard floating point format - union { - double val1; - char val2[8]; - } x; - char *p = x.val2; - char b[8]; - if (dev->read(b, 8) == 8) { - if (noswap) { - *p++ = b[Q_DF(0)]; - *p++ = b[Q_DF(1)]; - *p++ = b[Q_DF(2)]; - *p++ = b[Q_DF(3)]; - *p++ = b[Q_DF(4)]; - *p++ = b[Q_DF(5)]; - *p++ = b[Q_DF(6)]; - *p = b[Q_DF(7)]; - } else { - *p++ = b[Q_DF(7)]; - *p++ = b[Q_DF(6)]; - *p++ = b[Q_DF(5)]; - *p++ = b[Q_DF(4)]; - *p++ = b[Q_DF(3)]; - *p++ = b[Q_DF(2)]; - *p++ = b[Q_DF(1)]; - *p = b[Q_DF(0)]; - } - f = x.val1; - } else { - setStatus(ReadPastEnd); - } -#endif return *this; } @@ -1112,7 +1074,6 @@ QDataStream &QDataStream::operator<<(double f) } CHECK_STREAM_WRITE_PRECOND(*this) -#ifndef Q_DOUBLE_FORMAT if (noswap) { if (dev->write((char *)&f, sizeof(double)) != sizeof(double)) q_status = WriteFailed; @@ -1126,36 +1087,6 @@ QDataStream &QDataStream::operator<<(double f) if (dev->write((char *)&x.val2, sizeof(double)) != sizeof(double)) q_status = WriteFailed; } -#else - union { - double val1; - char val2[8]; - } x; - x.val1 = f; - char *p = x.val2; - char b[8]; - if (noswap) { - b[Q_DF(0)] = *p++; - b[Q_DF(1)] = *p++; - b[Q_DF(2)] = *p++; - b[Q_DF(3)] = *p++; - b[Q_DF(4)] = *p++; - b[Q_DF(5)] = *p++; - b[Q_DF(6)] = *p++; - b[Q_DF(7)] = *p; - } else { - b[Q_DF(7)] = *p++; - b[Q_DF(6)] = *p++; - b[Q_DF(5)] = *p++; - b[Q_DF(4)] = *p++; - b[Q_DF(3)] = *p++; - b[Q_DF(2)] = *p++; - b[Q_DF(1)] = *p++; - b[Q_DF(0)] = *p; - } - if (dev->write(b, 8) != 8) - q_status = WriteFailed; -#endif return *this; } diff --git a/src/corelib/tools/qlocale_tools.cpp b/src/corelib/tools/qlocale_tools.cpp index 31a29d7fe1..2d6b8047a6 100644 --- a/src/corelib/tools/qlocale_tools.cpp +++ b/src/corelib/tools/qlocale_tools.cpp @@ -601,7 +601,7 @@ QT_END_INCLUDE_NAMESPACE #error Exactly one of IEEE_BIG_OR_LITTLE_ENDIAN, VAX, or IBM should be defined. #endif -static inline ULong _getWord0(const NEEDS_VOLATILE double x) +static inline ULong getWord0(const NEEDS_VOLATILE double x) { const NEEDS_VOLATILE uchar *ptr = reinterpret_cast(&x); if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { @@ -611,7 +611,7 @@ static inline ULong _getWord0(const NEEDS_VOLATILE double x) } } -static inline void _setWord0(NEEDS_VOLATILE double *x, ULong l) +static inline void setWord0(NEEDS_VOLATILE double *x, ULong l) { NEEDS_VOLATILE uchar *ptr = reinterpret_cast(x); if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { @@ -627,7 +627,7 @@ static inline void _setWord0(NEEDS_VOLATILE double *x, ULong l) } } -static inline ULong _getWord1(const NEEDS_VOLATILE double x) +static inline ULong getWord1(const NEEDS_VOLATILE double x) { const NEEDS_VOLATILE uchar *ptr = reinterpret_cast(&x); if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { @@ -636,7 +636,7 @@ static inline ULong _getWord1(const NEEDS_VOLATILE double x) return (ptr[3]<<24) + (ptr[2]<<16) + (ptr[1]<<8) + ptr[0]; } } -static inline void _setWord1(NEEDS_VOLATILE double *x, ULong l) +static inline void setWord1(NEEDS_VOLATILE double *x, ULong l) { NEEDS_VOLATILE uchar *ptr = reinterpret_cast(x); if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { @@ -652,42 +652,6 @@ static inline void _setWord1(NEEDS_VOLATILE double *x, ULong l) } } -static inline ULong getWord0(const NEEDS_VOLATILE double x) -{ -#ifdef QT_ARMFPA - return _getWord1(x); -#else - return _getWord0(x); -#endif -} - -static inline void setWord0(NEEDS_VOLATILE double *x, ULong l) -{ -#ifdef QT_ARMFPA - _setWord1(x, l); -#else - _setWord0(x, l); -#endif -} - -static inline ULong getWord1(const NEEDS_VOLATILE double x) -{ -#ifdef QT_ARMFPA - return _getWord0(x); -#else - return _getWord1(x); -#endif -} - -static inline void setWord1(NEEDS_VOLATILE double *x, ULong l) -{ -#ifdef QT_ARMFPA - _setWord0(x, l); -#else - _setWord1(x, l); -#endif -} - static inline void Storeinc(ULong *&a, const ULong &b, const ULong &c) { diff --git a/src/corelib/tools/qlocale_tools_p.h b/src/corelib/tools/qlocale_tools_p.h index 2dc5c03a20..d920d41cb3 100644 --- a/src/corelib/tools/qlocale_tools_p.h +++ b/src/corelib/tools/qlocale_tools_p.h @@ -97,15 +97,11 @@ QString &exponentForm(QChar zero, QChar decimal, QChar exponential, inline bool isZero(double d) { uchar *ch = (uchar *)&d; -#ifdef QT_ARMFPA - return !(ch[3] & 0x7F || ch[2] || ch[1] || ch[0] || ch[7] || ch[6] || ch[5] || ch[4]); -#else if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { return !(ch[0] & 0x7F || ch[1] || ch[2] || ch[3] || ch[4] || ch[5] || ch[6] || ch[7]); } else { return !(ch[7] & 0x7F || ch[6] || ch[5] || ch[4] || ch[3] || ch[2] || ch[1] || ch[0]); } -#endif } // Removes thousand-group separators in "C" locale. -- cgit v1.2.3 From a1c75534a4bca417204725e77945e53059895726 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 24 Feb 2012 22:27:32 +0100 Subject: QtGlobal: remove qIsDetached() There's not a single in-tree user of this function, and the concept is a broken one in MT programs: By the time qIsDetached() returns, the result can already be different due to another thread taking a copy, or a copy in another thread being destroyed (note that this doesn't require mutex use by the user, since we promise (implicitly, if not explicitly) that you can copy from const objects without holding a lock). QTBUG-10813 talks about a use in QCache::trim(), but 677cf76340f88e0fe51c1f75aa512b6d835414ca removed it, so there's no reason to keep it anymore. Change-Id: I20380c12bdf00ac764b89d84392f0f34727b1971 Reviewed-by: Lars Knoll --- src/corelib/global/qtypeinfo.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index 815be935f7..1c08bbe1cf 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -49,15 +49,12 @@ QT_BEGIN_NAMESPACE /* QTypeInfo - type trait functionality - qIsDetached - data sharing functionality */ /* The catch-all template. */ -template inline bool qIsDetached(T &) { return true; } - template class QTypeInfo { @@ -188,7 +185,6 @@ QT_BEGIN_NAMESPACE #endif #define Q_DECLARE_SHARED(TYPE) \ -template <> inline bool qIsDetached(TYPE &t) { return t.isDetached(); } \ template <> inline void qSwap(TYPE &value1, TYPE &value2) \ { qSwap(value1.data_ptr(), value2.data_ptr()); } \ Q_DECLARE_SHARED_STL(TYPE) -- cgit v1.2.3 From 8c7aa37aa7d34860a9c062808416cef0118b36d6 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 28 Feb 2012 17:12:32 +0100 Subject: dispose of BOOTSTRAPPING define this is used only in qmake, not in other bootstrapped tools Change-Id: Ie2841e69dbd82c86d2297ddf51443ee75760766c Reviewed-by: Joerg Bornemann Reviewed-by: Marius Storm-Olsen --- src/corelib/global/qlibraryinfo.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index ac99b80cb0..ff1fd6bfdd 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -46,11 +46,7 @@ #include "qlibraryinfo.h" #include "qscopedpointer.h" -#if defined(QT_BUILD_QMAKE) || defined(QT_BOOTSTRAPPED) -# define BOOTSTRAPPING -#endif - -#ifdef BOOTSTRAPPING +#ifdef QT_BUILD_QMAKE QT_BEGIN_NAMESPACE extern QString qmake_libraryInfoFile(); QT_END_NAMESPACE @@ -97,7 +93,7 @@ public: QLibrarySettings::QLibrarySettings() : settings(QLibraryInfoPrivate::findConfiguration()) { -#ifndef BOOTSTRAPPING +#ifndef QT_BUILD_QMAKE qAddPostRoutine(QLibraryInfoPrivate::cleanup); #endif } @@ -105,7 +101,7 @@ QLibrarySettings::QLibrarySettings() QSettings *QLibraryInfoPrivate::findConfiguration() { QString qtconfig = QLatin1String(":/qt/etc/qt.conf"); -#ifdef BOOTSTRAPPING +#ifdef QT_BUILD_QMAKE if(!QFile::exists(qtconfig)) qtconfig = qmake_libraryInfoFile(); #else @@ -286,7 +282,7 @@ QLibraryInfo::location(LibraryLocation loc) QString baseDir; if (loc == PrefixPath) { // we make the prefix path absolute to the executable's directory -#ifdef BOOTSTRAPPING +#ifdef QT_BUILD_QMAKE baseDir = QFileInfo(qmake_libraryInfoFile()).absolutePath(); #else if (QCoreApplication::instance()) { -- cgit v1.2.3 From 6663b5ebac7f750a3fb53dc61fbfb466bebec931 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 28 Feb 2012 17:26:59 +0100 Subject: exclude some code from the qmake build Change-Id: Ic989a2cc5106496a2c5f13c863a0a87d5cd2d963 Reviewed-by: Joerg Bornemann Reviewed-by: Marius Storm-Olsen --- src/corelib/global/qlibraryinfo.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index ff1fd6bfdd..c7f0cd1c28 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -148,6 +148,8 @@ QSettings *QLibraryInfoPrivate::findConfiguration() \sa QSysInfo, {Using qt.conf} */ +#ifndef QT_BUILD_QMAKE + /*! \internal You cannot create a QLibraryInfo, instead only the static functions are available to query @@ -210,6 +212,8 @@ QLibraryInfo::isDebugBuild() return false; } +#endif // QT_BUILD_QMAKE + static const struct { char key[14], value[13]; } qtConfEntries[] = { -- cgit v1.2.3 From 012f799254eedc610e2e33842e62d2a184b14fcc Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 28 Feb 2012 20:57:38 +0100 Subject: revamp -sysroot and -hostprefix handling instead of being a variable added to the makespec (via qconfig.pri), QT_SYSROOT is now a property. the QT_INSTALL_... properties are now automatically prefixed with the sysroot; the raw values are available as QT_RAW_INSTALL_... - this is expected to cause the least migration effort for existing projects. -hostprefix and the new -hostbindir & -hostdatadir now feed the new QT_HOST_... properties. adapted the qmake feature files and the qtbase build system accordingly. Change-Id: Iaa9b65bc10d9fe9c4988d620c70a8ce72177f8d4 Reviewed-by: Marius Storm-Olsen --- src/corelib/global/qlibraryinfo.cpp | 44 +++++++++++++++++++++++++++++++++---- src/corelib/global/qlibraryinfo.h | 12 ++++++++++ 2 files changed, 52 insertions(+), 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index c7f0cd1c28..4caacece2d 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -228,16 +228,43 @@ static const struct { { "Translations", "translations" }, { "Examples", "" }, { "Tests", "tests" }, +#ifdef QT_BUILD_QMAKE + { "Sysroot", "" }, + { "HostPrefix", "" }, + { "HostBinaries", "bin" }, + { "HostData", "" }, +#endif }; /*! Returns the location specified by \a loc. */ - QString QLibraryInfo::location(LibraryLocation loc) { +#ifdef QT_BUILD_QMAKE + QString ret = rawLocation(loc); + + // Automatically prepend the sysroot to target paths + if (loc < SysrootPath || loc > LastHostPath) { + QString sysroot = rawLocation(SysrootPath); + if (!sysroot.isEmpty() && ret.length() > 2 && ret.at(1) == QLatin1Char(':') + && (ret.at(2) == QLatin1Char('/') || ret.at(2) == QLatin1Char('\\'))) + ret.replace(0, 2, sysroot); // Strip out the drive on Windows targets + else + ret.prepend(sysroot); + } + + return ret; +} + +QString +QLibraryInfo::rawLocation(LibraryLocation loc) +{ +#else +# define rawLocation location +#endif QString ret; if(!QLibraryInfoPrivate::configuration()) { const char *path = 0; @@ -284,11 +311,19 @@ QLibraryInfo::location(LibraryLocation loc) if (QDir::isRelativePath(ret)) { QString baseDir; - if (loc == PrefixPath) { - // we make the prefix path absolute to the executable's directory #ifdef QT_BUILD_QMAKE + if (loc == HostPrefixPath || loc == PrefixPath) { + // We make the prefix path absolute to the executable's directory. + // loc == PrefixPath while a sysroot is set would make no sense here. baseDir = QFileInfo(qmake_libraryInfoFile()).absolutePath(); + } else if (loc == SysrootPath) { + // The sysroot is bare + return ret; + } else if (loc > SysrootPath && loc <= LastHostPath) { + // We make any other host path absolute to the host prefix directory. + baseDir = rawLocation(HostPrefixPath); #else + if (loc == PrefixPath) { if (QCoreApplication::instance()) { #ifdef Q_OS_MAC CFBundleRef bundleRef = CFBundleGetMainBundle(); @@ -300,6 +335,7 @@ QLibraryInfo::location(LibraryLocation loc) } } #endif + // We make the prefix path absolute to the executable's directory. baseDir = QCoreApplication::applicationDirPath(); } else { baseDir = QDir::currentPath(); @@ -307,7 +343,7 @@ QLibraryInfo::location(LibraryLocation loc) #endif } else { // we make any other path absolute to the prefix directory - baseDir = location(PrefixPath); + baseDir = rawLocation(PrefixPath); } ret = QDir::cleanPath(baseDir + QLatin1Char('/') + ret); } diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index f6234d1eb4..d180e63198 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -77,9 +77,21 @@ public: TranslationsPath, ExamplesPath, TestsPath, + // Insert new values above this line +#ifdef QT_BUILD_QMAKE + // These are not subject to binary compatibility constraints + SysrootPath, + HostPrefixPath, + HostBinariesPath, + HostDataPath, + LastHostPath = HostDataPath, +#endif SettingsPath = 100 }; static QString location(LibraryLocation); // ### Qt 5: consider renaming it to path() +#ifdef QT_BUILD_QMAKE + static QString rawLocation(LibraryLocation); +#endif private: QLibraryInfo(); -- cgit v1.2.3 From fb8c95bac09910c4dfa476ab97c6206b2e94ee53 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 29 Feb 2012 15:07:12 +0100 Subject: Automatic metatype registration of two-template-argument types. This commit is complimentary to the commit which introduced a similar partial specialization for single template argument types: 6b4f8a68c8da1af7c5be7dc6075b688c9d6ca55f If T and U are available as metatypes, then QHash is too. Change-Id: I09097b954666418b424c8c23577032beb814343a Reviewed-by: Olivier Goffart --- src/corelib/kernel/qmetatype.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index beb7294abd..f969875455 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -565,6 +565,7 @@ template class QSet; template class QSharedPointer; template class QMap; template class QHash; +template struct QPair; typedef QList QVariantList; typedef QMap QVariantMap; typedef QHash QVariantHash; @@ -586,6 +587,23 @@ struct QMetaTypeId< SINGLE_ARG_TEMPLATE > \ } \ }; +#define Q_DECLARE_METATYPE_TEMPLATE_2ARG(DOUBLE_ARG_TEMPLATE) \ +template \ +struct QMetaTypeId< DOUBLE_ARG_TEMPLATE > \ +{ \ + enum { \ + Defined = QMetaTypeId2::Defined && QMetaTypeId2::Defined \ + }; \ + static int qt_metatype_id() \ + { \ + static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \ + if (!metatype_id.load()) \ + metatype_id.storeRelease(qRegisterMetaType< DOUBLE_ARG_TEMPLATE >( QByteArray(QByteArray(#DOUBLE_ARG_TEMPLATE "<") + QMetaType::typeName(qMetaTypeId()) + ", " + QMetaType::typeName(qMetaTypeId()) + ">").constData(), \ + reinterpret_cast< DOUBLE_ARG_TEMPLATE *>(quintptr(-1)))); \ + return metatype_id.loadAcquire(); \ + } \ +}; + Q_DECLARE_METATYPE_TEMPLATE_1ARG(QList) Q_DECLARE_METATYPE_TEMPLATE_1ARG(QVector) Q_DECLARE_METATYPE_TEMPLATE_1ARG(QQueue) @@ -594,6 +612,10 @@ Q_DECLARE_METATYPE_TEMPLATE_1ARG(QSet) Q_DECLARE_METATYPE_TEMPLATE_1ARG(QSharedPointer) Q_DECLARE_METATYPE_TEMPLATE_1ARG(QLinkedList) +Q_DECLARE_METATYPE_TEMPLATE_2ARG(QHash) +Q_DECLARE_METATYPE_TEMPLATE_2ARG(QMap) +Q_DECLARE_METATYPE_TEMPLATE_2ARG(QPair) + inline QMetaType::QMetaType(const ExtensionFlag extensionFlags, const QMetaTypeInterface *info, Creator creator, Deleter deleter, -- cgit v1.2.3 From 17ddce4692b31af4374b28cd40b9f25e8ed629cd Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 24 Feb 2012 11:11:02 +0100 Subject: Remove Q_BYTE_ORDER and -*-endian arguments from configures Do not write Q_BYTE_ORDER to qconfig.h in the configures. Instead, we #define Q_BYTE_ORDER in qprocessordetection.h, since many CPUs only support a single endian format. For bi-endian processors, we set Q_BYTE_ORDER depending on how the preprocessor sets __BYTE_ORDER__, __BIG_ENDIAN__, or __LITTLE_ENDIAN__ (instead of using a compile test to do so). For operating systems that only support a single byte order, we can check for Q_OS_* in addition to the preprocessor macros above. This is possible because qprocessordetection.h is included by qglobal.h after Q_OS_* and Q_CC_* detection has been done. Do this for Windows CE, which is always little- endian according to MSDN. Change-Id: I019a95e05252ef69895c4b38fbfa6ebfb6a943cd Reviewed-by: Oswald Buddenhagen --- src/corelib/global/qprocessordetection.h | 76 +++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h index fd02f0e4c5..4213d5830e 100644 --- a/src/corelib/global/qprocessordetection.h +++ b/src/corelib/global/qprocessordetection.h @@ -53,16 +53,39 @@ The first is always defined. Defines for the various revisions/variants are optional and usually dependent on how the compiler was invoked. Variants that are a superset of another should have a define for the superset. + + In addition to the procesor family, variants, and revisions, we also set + Q_BYTE_ORDER appropriately for the target processor. For bi-endian + processors, we try to auto-detect the byte order using the __BIG_ENDIAN__, + __LITTLE_ENDIAN__, or __BYTE_ORDER__ preprocessor macros. */ +/* Machine byte-order, reuse preprocessor provided macros when available */ +#if defined(__ORDER_BIG_ENDIAN__) +# define Q_BIG_ENDIAN __ORDER_BIG_ENDIAN__ +#else +# define Q_BIG_ENDIAN 4321 +#endif +#if defined(__ORDER_LITTLE_ENDIAN__) +# define Q_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ +#else +# define Q_LITTLE_ENDIAN 1234 +#endif + /* Alpha family, no revisions or variants + + Alpha is bi-endian, use endianness auto-detection described above. */ // #elif defined(__alpha__) || defined(_M_ALPHA) // # define Q_PROCESSOR_ALPHA +// Q_BYTE_ORDER not defined, use endianness auto-detection /* - ARM family, known revisions: V5, V6, and V7 + ARM family, known revisions: V5, V6, and V7 + + ARM is bi-endian, detect using __ARMEL__ or __ARMEB__, falling back to + auto-detection described above. */ #if defined(__arm__) || defined(__TARGET_ARCH_ARM) # define Q_PROCESSOR_ARM @@ -88,37 +111,59 @@ || (__TARGET_ARCH_ARM-0 >= 5) # define Q_PROCESSOR_ARM_V5 # endif +# if defined(__ARMEL__) +# define Q_BYTE_ORDER Q_LITTLE_ENDIAN +# elif defined(__ARMEB__) +# define Q_BYTE_ORDER Q_BIG_ENDIAN +# else +// Q_BYTE_ORDER not defined, use endianness auto-detection +#endif /* AVR32 family, no revisions or variants + + AVR32 is big-endian. */ // #elif defined(__avr32__) // # define Q_PROCESSOR_AVR32 +// # define Q_BYTE_ORDER Q_BIG_ENDIAN /* Blackfin family, no revisions or variants + + Blackfin is little-endian. */ // #elif defined(__bfin__) // # define Q_PROCESSOR_BLACKFIN +// # define Q_BYTE_ORDER Q_LITTLE_ENDIAN /* X86 family, known variants: 32- and 64-bit + + X86 is little-endian. */ #elif defined(__i386) || defined(__i386__) || defined(_M_IX86) # define Q_PROCESSOR_X86 # define Q_PROCESSOR_X86_32 +# define Q_BYTE_ORDER Q_LITTLE_ENDIAN #elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) # define Q_PROCESSOR_X86 # define Q_PROCESSOR_X86_64 +# define Q_BYTE_ORDER Q_LITTLE_ENDIAN /* Itanium (IA-64) family, no revisions or variants + + Itanium is bi-endian, use endianness auto-detection described above. */ #elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) # define Q_PROCESSOR_IA64 +// Q_BYTE_ORDER not defined, use endianness auto-detection /* MIPS family, known revisions: I, II, III, IV, 32, 64 + + MIPS is bi-endian, use endianness auto-detection described above. */ #elif defined(__mips) || defined(__mips__) || defined(_M_MRX000) # define Q_PROCESSOR_MIPS @@ -143,6 +188,7 @@ # if defined(_MIPS_ARCH_MIPS64) || defined(__mips64) # define Q_PROCESSOR_MIPS_64 # endif +// Q_BYTE_ORDER not defined, use endianness auto-detection /* Power family, known variants: 32- and 64-bit @@ -150,6 +196,8 @@ There are many more known variants/revisions that we do not handle/detect. See http://en.wikipedia.org/wiki/Power_Architecture and http://en.wikipedia.org/wiki/File:PowerISA-evolution.svg + + Power is bi-endian, use endianness auto-detection described above. */ #elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \ || defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \ @@ -160,34 +208,60 @@ # else # define Q_PROCESSOR_POWER_32 # endif +// Q_BYTE_ORDER not defined, use endianness auto-detection /* S390 family, known variant: S390X (64-bit) + + S390 is big-endian. */ // #elif defined(__s390__) // # define Q_PROCESSOR_S390 // # if defined(__s390x__) // # define Q_PROCESSOR_S390_X // # endif +// # define Q_BYTE_ORDER Q_BIG_ENDIAN /* SuperH family, optional revision: SH-4A + + SuperH is bi-endian, use endianness auto-detection descrived above. */ // #elif defined(__sh__) // # define Q_PROCESSOR_SH // # if defined(__sh4a__) // # define Q_PROCESSOR_SH_4A // # endif +// Q_BYTE_ORDER not defined, use endianness auto-detection /* SPARC family, optional revision: V9 + + SPARC is big-endian only prior to V9, while V9 is bi-endian with big-endian + as the default byte order. Assume all SPARC systems are big-endian. */ // #elif defined(__sparc__) // # define Q_PROCESSOR_SPARC // # if defined(__sparc_v9__) // # define Q_PROCESSOR_SPARC_V9 // # endif +// # define Q_BYTE_ORDER Q_BIG_ENDIAN + +#endif +// Some processors support either endian format, try to detect which we are using. +#if !defined(Q_BYTE_ORDER) +# if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == Q_BIG_ENDIAN || __BYTE_ORDER__ == Q_LITTLE_ENDIAN) +// Reuse __BYTE_ORDER__ as-is, since our Q_*_ENDIAN #defines match the preprocessor defaults +# define Q_BYTE_ORDER __BYTE_ORDER__ +# elif defined(__BIG_ENDIAN__) +# define Q_BYTE_ORDER Q_BIG_ENDIAN +# elif defined(__LITTLE_ENDIAN__) \ + || defined(Q_OS_WINCE) // Windows CE is always little-endian according to MSDN. +# define Q_BYTE_ORDER Q_LITTLE_ENDIAN +# else +# error "Unable to determine byte order!" +# endif #endif #endif // QPROCESSORDETECTION_H -- cgit v1.2.3 From 6c2e57e6884c1ef524bb22f0ed6a2be2c97cd46d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 1 Mar 2012 11:37:51 +0100 Subject: Make the CONFIG and QT_CONFIG contents available downstream. Change-Id: I62dbc5a695e41179de9f6acd11aa7bc592cac6f3 Reviewed-by: Clinton Stimpson Reviewed-by: Alexander Neundorf Reviewed-by: Stephen Kelly --- src/corelib/Qt5CoreConfigExtras.cmake.in | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in index 67598f4f70..5acc13c6f3 100644 --- a/src/corelib/Qt5CoreConfigExtras.cmake.in +++ b/src/corelib/Qt5CoreConfigExtras.cmake.in @@ -30,6 +30,9 @@ list(APPEND Qt5Core_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE) set(QT_LIBINFIX \"$${QT_LIBINFIX}\") !!ENDIF +set(QT_CONFIG \"$${CONFIG}\") +set(QT_QCONFIG \"$${QT_CONFIG}\") + !!IF !isEmpty(CMAKE_WINDOWS_BUILD) set(Qt5Core_QTMAIN_LIBRARIES Qt5::WinMain) -- cgit v1.2.3 From db5c28fa0e392a68836d9a97bb2add3a94ddb37c Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 2 Mar 2012 15:05:59 +0100 Subject: Use correct types in QResource. qHash() returns uint, not int, so change all interactions with hashing to use uint to match. This blocks the introduction of a new (better) hashing algorithm because it currently breaks numerous tests: rcc would (correctly) write a uint hash value to the qrc files, but QResource would attempt to mangle it around as an int. This wasn't a problem with the old hash, because it deliberately threw away data (h &= 0x0fffffff), possibly because of someone not being able to diagnose precisly this problem. Change-Id: I46fb42acc100fdd3bedd714f6dc91aeca91d0351 Reviewed-by: hjk --- src/corelib/io/qresource.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index e46ab260b0..fb3a24b940 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -114,7 +114,7 @@ class QResourceRoot }; const uchar *tree, *names, *payloads; inline int findOffset(int node) const { return node * 14; } //sizeof each tree element - int hash(int node) const; + uint hash(int node) const; QString name(int node) const; short flags(int node) const; public: @@ -594,7 +594,7 @@ QResource::searchPaths() return *resourceSearchPaths(); } -inline int QResourceRoot::hash(int node) const +inline uint QResourceRoot::hash(int node) const { if(!node) //root return 0; @@ -673,13 +673,13 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const qDebug() << " " << child+j << " :: " << name(child+j); } #endif - const int h = qHash(segment); + const uint h = qHash(segment); //do the binary search for the hash int l = 0, r = child_count-1; int sub_node = (l+r+1)/2; while(r != l) { - const int sub_node_hash = hash(child+sub_node); + const uint sub_node_hash = hash(child+sub_node); if(h == sub_node_hash) break; else if(h < sub_node_hash) -- cgit v1.2.3 From 95d83cb1b68cc4a415d5d80859b4e74472ad7112 Mon Sep 17 00:00:00 2001 From: Casper van Donderen Date: Thu, 1 Mar 2012 15:28:31 +0100 Subject: Remove the usage of deprecated qdoc macros. QDoc now has support for Doxygen style commands for italics, bold and list items. This change applies that change in QDoc to the actual documentation. Task-number: QTBUG-24578 Change-Id: I519bf9c29b14092e3ab6067612f42bf749eeedf5 Reviewed-by: Shane Kearns Reviewed-by: Lars Knoll --- src/corelib/animation/qvariantanimation.cpp | 24 +- src/corelib/codecs/codecs.qdoc | 56 ++-- src/corelib/codecs/qtextcodec.cpp | 86 ++--- src/corelib/global/qglobal.cpp | 14 +- src/corelib/global/qlogging.cpp | 2 +- src/corelib/global/qnamespace.qdoc | 52 +-- src/corelib/io/qdatastream.cpp | 28 +- src/corelib/io/qdir.cpp | 20 +- src/corelib/io/qfile.cpp | 8 +- src/corelib/io/qfileinfo.cpp | 6 +- src/corelib/io/qiodevice.cpp | 16 +- src/corelib/io/qprocess.cpp | 18 +- src/corelib/io/qsettings.cpp | 126 +++---- src/corelib/io/qtextstream.cpp | 68 ++-- src/corelib/io/qurl.cpp | 16 +- src/corelib/itemmodels/qabstractitemmodel.cpp | 82 ++--- src/corelib/itemmodels/qsortfilterproxymodel.cpp | 20 +- src/corelib/json/qjsonarray.cpp | 4 +- src/corelib/json/qjsonobject.cpp | 4 +- src/corelib/json/qjsonvalue.cpp | 32 +- src/corelib/kernel/qabstracteventdispatcher.cpp | 24 +- src/corelib/kernel/qcoreapplication.cpp | 10 +- src/corelib/kernel/qeventloop.cpp | 6 +- src/corelib/kernel/qmetaobject.cpp | 26 +- src/corelib/kernel/qmimedata.cpp | 18 +- src/corelib/kernel/qobject.cpp | 28 +- src/corelib/kernel/qpointer.cpp | 4 +- src/corelib/kernel/qsharedmemory.cpp | 6 +- src/corelib/kernel/qsocketnotifier.cpp | 16 +- src/corelib/kernel/qsystemsemaphore.cpp | 8 +- src/corelib/kernel/qtranslator.cpp | 56 ++-- src/corelib/kernel/qvariant.cpp | 44 +-- src/corelib/kernel/qwineventnotifier.cpp | 4 +- src/corelib/plugin/qlibrary.cpp | 12 +- src/corelib/plugin/qpluginloader.cpp | 4 +- src/corelib/plugin/quuid.cpp | 168 +++++----- src/corelib/thread/qatomic.cpp | 72 ++-- src/corelib/thread/qsemaphore.cpp | 4 +- src/corelib/thread/qthread.cpp | 4 +- src/corelib/thread/qthreadstorage.cpp | 4 +- src/corelib/thread/qwaitcondition.qdoc | 8 +- src/corelib/tools/qalgorithms.qdoc | 14 +- src/corelib/tools/qbytearray.cpp | 26 +- src/corelib/tools/qdatetime.cpp | 406 +++++++++++------------ src/corelib/tools/qhash.cpp | 6 +- src/corelib/tools/qline.cpp | 20 +- src/corelib/tools/qlinkedlist.cpp | 6 +- src/corelib/tools/qlist.cpp | 6 +- src/corelib/tools/qlocale.cpp | 22 +- src/corelib/tools/qlocale.qdoc | 12 +- src/corelib/tools/qmap.cpp | 6 +- src/corelib/tools/qrect.cpp | 48 +-- src/corelib/tools/qregexp.cpp | 372 ++++++++++----------- src/corelib/tools/qscopedpointer.cpp | 6 +- src/corelib/tools/qshareddata.cpp | 4 +- src/corelib/tools/qsize.cpp | 12 +- src/corelib/tools/qstring.cpp | 32 +- src/corelib/tools/qstringlist.cpp | 2 +- src/corelib/tools/qvarlengtharray.qdoc | 6 +- src/corelib/tools/qvector.cpp | 8 +- 60 files changed, 1111 insertions(+), 1111 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index 35a340836d..2262a3836e 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -98,18 +98,18 @@ QT_BEGIN_NAMESPACE supported QVariant types: \list - \o \l{QMetaType::}{Int} - \o \l{QMetaType::}{Double} - \o \l{QMetaType::}{Float} - \o \l{QMetaType::}{QLine} - \o \l{QMetaType::}{QLineF} - \o \l{QMetaType::}{QPoint} - \o \l{QMetaType::}{QPointF} - \o \l{QMetaType::}{QSize} - \o \l{QMetaType::}{QSizeF} - \o \l{QMetaType::}{QRect} - \o \l{QMetaType::}{QRectF} - \o \l{QMetaType::}{QColor} + \li \l{QMetaType::}{Int} + \li \l{QMetaType::}{Double} + \li \l{QMetaType::}{Float} + \li \l{QMetaType::}{QLine} + \li \l{QMetaType::}{QLineF} + \li \l{QMetaType::}{QPoint} + \li \l{QMetaType::}{QPointF} + \li \l{QMetaType::}{QSize} + \li \l{QMetaType::}{QSizeF} + \li \l{QMetaType::}{QRect} + \li \l{QMetaType::}{QRectF} + \li \l{QMetaType::}{QColor} \endlist If you need to interpolate other variant types, including custom diff --git a/src/corelib/codecs/codecs.qdoc b/src/corelib/codecs/codecs.qdoc index 2127a0a4cf..669072f789 100644 --- a/src/corelib/codecs/codecs.qdoc +++ b/src/corelib/codecs/codecs.qdoc @@ -77,9 +77,9 @@ are met: \list 1 - \o Redistributions of source code must retain the above copyright + \li Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - \o Redistributions in binary form must reproduce the above copyright + \li Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. \endlist @@ -126,9 +126,9 @@ Currently, the Big5-HKSCS tables are generated from the following sources, and with the Euro character added: \list 1 - \o \l{http://www.microsoft.com/typography/unicode/950.txt} - \o \l{http://www.info.gov.hk/digital21/chi/hkscs/download/big5-iso.txt} - \o \l{http://www.info.gov.hk/digital21/chi/hkscs/download/big5cmp.txt} + \li \l{http://www.microsoft.com/typography/unicode/950.txt} + \li \l{http://www.info.gov.hk/digital21/chi/hkscs/download/big5-iso.txt} + \li \l{http://www.info.gov.hk/digital21/chi/hkscs/download/big5cmp.txt} \endlist There may be more fine-tuning to the QBig5hkscsCodec to maximize its @@ -147,9 +147,9 @@ are met: \list 1 - \o Redistributions of source code must retain the above copyright + \li Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - \o Redistributions in binary form must reproduce the above copyright + \li Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. \endlist @@ -195,9 +195,9 @@ are met: \list 1 - \o Redistributions of source code must retain the above copyright + \li Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - \o Redistributions in binary form must reproduce the above copyright + \li Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. \endlist @@ -238,9 +238,9 @@ are met: \list 1 - \o Redistributions of source code must retain the above copyright + \li Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - \o Redistributions in binary form must reproduce the above copyright + \li Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. \endlist @@ -282,9 +282,9 @@ Some must-read documents are: \list - \o \l{ftp://ftp.oreilly.com/pub/examples/nutshell/cjkv/pdf/GB18030_Summary.pdf} - \o \l{http://oss.software.ibm.com/cvs/icu/~checkout~/charset/source/gb18030/gb18030.html} - \o \l{http://oss.software.ibm.com/cvs/icu/~checkout~/charset/data/xml/gb-18030-2000.xml} + \li \l{ftp://ftp.oreilly.com/pub/examples/nutshell/cjkv/pdf/GB18030_Summary.pdf} + \li \l{http://oss.software.ibm.com/cvs/icu/~checkout~/charset/source/gb18030/gb18030.html} + \li \l{http://oss.software.ibm.com/cvs/icu/~checkout~/charset/data/xml/gb-18030-2000.xml} \endlist The GBK codec was contributed to Qt by @@ -316,9 +316,9 @@ are met: \list 1 - \o Redistributions of source code must retain the above copyright + \li Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - \o Redistributions in binary form must reproduce the above copyright + \li Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. \endlist @@ -354,30 +354,30 @@ \list - \o "unicode-0.9" or "unicode-0201" for Unicode style. This assumes + \li "unicode-0.9" or "unicode-0201" for Unicode style. This assumes JISX0201 for 0x00-0x7f. (0.9 is a table version of jisx02xx mapping used for Unicode 1.1.) - \o "unicode-ascii" This assumes US-ASCII for 0x00-0x7f; some + \li "unicode-ascii" This assumes US-ASCII for 0x00-0x7f; some chars (JISX0208 0x2140 and JISX0212 0x2237) are different from Unicode 1.1 to avoid conflict. - \o "open-19970715-0201" ("open-0201" for convenience) or + \li "open-19970715-0201" ("open-0201" for convenience) or "jisx0221-1995" for JISX0221-JISX0201 style. JIS X 0221 is JIS version of Unicode, but a few chars (0x5c, 0x7e, 0x2140, 0x216f, 0x2131) are different from Unicode 1.1. This is used when 0x5c is treated as YEN SIGN. - \o "open-19970715-ascii" ("open-ascii" for convenience) for + \li "open-19970715-ascii" ("open-ascii" for convenience) for JISX0221-ASCII style. This is used when 0x5c is treated as REVERSE SOLIDUS. - \o "open-19970715-ms" ("open-ms" for convenience) or "cp932" for + \li "open-19970715-ms" ("open-ms" for convenience) or "cp932" for Microsoft Windows style. Windows Code Page 932. Some chars (0x2140, 0x2141, 0x2142, 0x215d, 0x2171, 0x2172) are different from Unicode 1.1. - \o "jdk1.1.7" for Sun's JDK style. Same as Unicode 1.1, except that + \li "jdk1.1.7" for Sun's JDK style. Same as Unicode 1.1, except that JIS 0x2140 is mapped to UFF3C. Either ASCII or JISX0201 can be used for 0x00-0x7f. @@ -405,9 +405,9 @@ are met: \list 1 - \o Redistributions of source code must retain the above copyright + \li Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - \o Redistributions in binary form must reproduce the above copyright + \li Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. \endlist @@ -454,9 +454,9 @@ are met: \list 1 - \o Redistributions of source code must retain the above copyright + \li Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - \o Redistributions in binary form must reproduce the above copyright + \li Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. \endlist @@ -510,9 +510,9 @@ are met: \list 1 - \o Redistributions of source code must retain the above copyright + \li Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - \o Redistributions in binary form must reproduce the above copyright + \li Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. \endlist diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 68866b9000..4cfdfe5966 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -789,38 +789,38 @@ QTextCodec::ConverterState::~ConverterState() The supported encodings are: \list - \o Apple Roman - \o \l{Big5 Text Codec}{Big5} - \o \l{Big5-HKSCS Text Codec}{Big5-HKSCS} - \o CP949 - \o \l{EUC-JP Text Codec}{EUC-JP} - \o \l{EUC-KR Text Codec}{EUC-KR} - \o \l{GBK Text Codec}{GB18030-0} - \o IBM 850 - \o IBM 866 - \o IBM 874 - \o \l{ISO 2022-JP (JIS) Text Codec}{ISO 2022-JP} - \o ISO 8859-1 to 10 - \o ISO 8859-13 to 16 - \o Iscii-Bng, Dev, Gjr, Knd, Mlm, Ori, Pnj, Tlg, and Tml - \o JIS X 0201 - \o JIS X 0208 - \o KOI8-R - \o KOI8-U - \o MuleLao-1 - \o ROMAN8 - \o \l{Shift-JIS Text Codec}{Shift-JIS} - \o TIS-620 - \o \l{TSCII Text Codec}{TSCII} - \o UTF-8 - \o UTF-16 - \o UTF-16BE - \o UTF-16LE - \o UTF-32 - \o UTF-32BE - \o UTF-32LE - \o Windows-1250 to 1258 - \o WINSAMI2 + \li Apple Roman + \li \l{Big5 Text Codec}{Big5} + \li \l{Big5-HKSCS Text Codec}{Big5-HKSCS} + \li CP949 + \li \l{EUC-JP Text Codec}{EUC-JP} + \li \l{EUC-KR Text Codec}{EUC-KR} + \li \l{GBK Text Codec}{GB18030-0} + \li IBM 850 + \li IBM 866 + \li IBM 874 + \li \l{ISO 2022-JP (JIS) Text Codec}{ISO 2022-JP} + \li ISO 8859-1 to 10 + \li ISO 8859-13 to 16 + \li Iscii-Bng, Dev, Gjr, Knd, Mlm, Ori, Pnj, Tlg, and Tml + \li JIS X 0201 + \li JIS X 0208 + \li KOI8-R + \li KOI8-U + \li MuleLao-1 + \li ROMAN8 + \li \l{Shift-JIS Text Codec}{Shift-JIS} + \li TIS-620 + \li \l{TSCII Text Codec}{TSCII} + \li UTF-8 + \li UTF-16 + \li UTF-16BE + \li UTF-16LE + \li UTF-32 + \li UTF-32BE + \li UTF-32LE + \li Windows-1250 to 1258 + \li WINSAMI2 \endlist QTextCodecs can be used as follows to convert some locally encoded @@ -871,29 +871,29 @@ QTextCodec::ConverterState::~ConverterState() QTextCodec and implement the functions listed in the table below. \table - \header \o Function \o Description + \header \li Function \li Description - \row \o name() - \o Returns the official name for the encoding. If the + \row \li name() + \li Returns the official name for the encoding. If the encoding is listed in the \l{IANA character-sets encoding file}, the name should be the preferred MIME name for the encoding. - \row \o aliases() - \o Returns a list of alternative names for the encoding. + \row \li aliases() + \li Returns a list of alternative names for the encoding. QTextCodec provides a default implementation that returns an empty list. For example, "ISO-8859-1" has "latin1", "CP819", "IBM819", and "iso-ir-100" as aliases. - \row \o mibEnum() - \o Return the MIB enum for the encoding if it is listed in + \row \li mibEnum() + \li Return the MIB enum for the encoding if it is listed in the \l{IANA character-sets encoding file}. - \row \o convertToUnicode() - \o Converts an 8-bit character string to Unicode. + \row \li convertToUnicode() + \li Converts an 8-bit character string to Unicode. - \row \o convertFromUnicode() - \o Converts a Unicode string to an 8-bit character string. + \row \li convertFromUnicode() + \li Converts a Unicode string to an 8-bit character string. \endtable \sa QTextStream, QTextDecoder, QTextEncoder, {Codecs Example} diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 6257376b62..a30250df81 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -892,13 +892,13 @@ bool qSharedBuild() \brief The QSysInfo class provides information about the system. \list - \o \l WordSize specifies the size of a pointer for the platform + \li \l WordSize specifies the size of a pointer for the platform on which the application is compiled. - \o \l ByteOrder specifies whether the platform is big-endian or + \li \l ByteOrder specifies whether the platform is big-endian or little-endian. - \o \l WindowsVersion specifies the version of the Windows operating + \li \l WindowsVersion specifies the version of the Windows operating system on which the application is run (Windows only) - \o \l MacintoshVersion specifies the version of the Macintosh + \li \l MacintoshVersion specifies the version of the Macintosh operating system on which the application is run (Mac only). \endlist @@ -2462,12 +2462,12 @@ int qrand() \a Flags can be one of the following: \list - \o \c Q_PRIMITIVE_TYPE specifies that \a Type is a POD (plain old + \li \c Q_PRIMITIVE_TYPE specifies that \a Type is a POD (plain old data) type with no constructor or destructor. - \o \c Q_MOVABLE_TYPE specifies that \a Type has a constructor + \li \c Q_MOVABLE_TYPE specifies that \a Type has a constructor and/or a destructor but can be moved in memory using \c memcpy(). - \o \c Q_COMPLEX_TYPE (the default) specifies that \a Type has + \li \c Q_COMPLEX_TYPE (the default) specifies that \a Type has constructors and/or a destructor and that it may not be moved in memory. \endlist diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index badccc947d..8cbd4528dc 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -309,7 +309,7 @@ QDebug QMessageLogger::critical() message handler has been installed, the message is printed to stderr. Under Windows, the message is sent to the debugger. - If you are using the \bold{default message handler} this function will + If you are using the \b{default message handler} this function will abort on Unix systems to create a core dump. On Windows, for debug builds, this function will report a _CRT_ERROR enabling you to connect a debugger to the application. diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 895feb7f53..7d5eec4271 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -266,7 +266,7 @@ This enum provides shorter names for the keyboard modifier keys supported by Qt. - \bold{Note:} On Mac OS X, the \c CTRL value corresponds to + \b{Note:} On Mac OS X, the \c CTRL value corresponds to the Command keys on the Macintosh keyboard, and the \c META value corresponds to the Control keys. @@ -319,21 +319,21 @@ \table \row - \o \inlineimage qpen-solid.png - \o \inlineimage qpen-dash.png - \o \inlineimage qpen-dot.png + \li \inlineimage qpen-solid.png + \li \inlineimage qpen-dash.png + \li \inlineimage qpen-dot.png \row - \o Qt::SolidLine - \o Qt::DashLine - \o Qt::DotLine + \li Qt::SolidLine + \li Qt::DashLine + \li Qt::DotLine \row - \o \inlineimage qpen-dashdot.png - \o \inlineimage qpen-dashdotdot.png - \o \inlineimage qpen-custom.png + \li \inlineimage qpen-dashdot.png + \li \inlineimage qpen-dashdotdot.png + \li \inlineimage qpen-custom.png \row - \o Qt::DashDotLine - \o Qt::DashDotDotLine - \o Qt::CustomDashLine + \li Qt::DashDotLine + \li Qt::DashDotDotLine + \li Qt::CustomDashLine \endtable \value NoPen no line at all. For example, QPainter::drawRect() @@ -360,13 +360,13 @@ \table \row - \o \inlineimage qpen-square.png - \o \inlineimage qpen-flat.png - \o \inlineimage qpen-roundcap.png + \li \inlineimage qpen-square.png + \li \inlineimage qpen-flat.png + \li \inlineimage qpen-roundcap.png \row - \o Qt::SquareCap - \o Qt::FlatCap - \o Qt::RoundCap + \li Qt::SquareCap + \li Qt::FlatCap + \li Qt::RoundCap \endtable \value FlatCap a square line end that does not cover the end @@ -388,13 +388,13 @@ \table \row - \o \inlineimage qpen-bevel.png - \o \inlineimage qpen-miter.png - \o \inlineimage qpen-roundjoin.png + \li \inlineimage qpen-bevel.png + \li \inlineimage qpen-miter.png + \li \inlineimage qpen-roundjoin.png \row - \o Qt::BevelJoin - \o Qt::MiterJoin - \o Qt::RoundJoin + \li Qt::BevelJoin + \li Qt::MiterJoin + \li Qt::RoundJoin \endtable \value MiterJoin The outer edges of the lines are extended to @@ -968,7 +968,7 @@ \value WA_NoSystemBackground Indicates that the widget has no background, i.e. when the widget receives paint events, the background is not automatically repainted. \note Unlike WA_OpaquePaintEvent, newly exposed - areas are \bold never filled with the background (e.g., after showing a + areas are \b never filled with the background (e.g., after showing a window for the first time the user can see "through" it until the application processes the paint events). This flag is set or cleared by the widget's author. diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp index f3fe91427a..1fe2a793a6 100644 --- a/src/corelib/io/qdatastream.cpp +++ b/src/corelib/io/qdatastream.cpp @@ -184,7 +184,7 @@ QT_BEGIN_NAMESPACE \endcode To see if your favorite Qt class has similar stream operators - defined, check the \bold {Related Non-Members} section of the + defined, check the \b {Related Non-Members} section of the class's documentation page. \sa QTextStream QVariant @@ -571,19 +571,19 @@ void QDataStream::setByteOrder(ByteOrder bo) serialization format used by QDataStream. \table - \header \i Qt Version \i QDataStream Version - \row \i Qt 4.6 \i 12 - \row \i Qt 4.5 \i 11 - \row \i Qt 4.4 \i 10 - \row \i Qt 4.3 \i 9 - \row \i Qt 4.2 \i 8 - \row \i Qt 4.0, 4.1 \i 7 - \row \i Qt 3.3 \i 6 - \row \i Qt 3.1, 3.2 \i 5 - \row \i Qt 3.0 \i 4 - \row \i Qt 2.1, 2.2, 2.3 \i 3 - \row \i Qt 2.0 \i 2 - \row \i Qt 1.x \i 1 + \header \li Qt Version \li QDataStream Version + \row \li Qt 4.6 \li 12 + \row \li Qt 4.5 \li 11 + \row \li Qt 4.4 \li 10 + \row \li Qt 4.3 \li 9 + \row \li Qt 4.2 \li 8 + \row \li Qt 4.0, 4.1 \li 7 + \row \li Qt 3.3 \li 6 + \row \li Qt 3.1, 3.2 \li 5 + \row \li Qt 3.0 \li 4 + \row \li Qt 2.1, 2.2, 2.3 \li 3 + \row \li Qt 2.0 \li 2 + \row \li Qt 1.x \li 1 \endtable The \l Version enum provides symbolic constants for the different diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index afd402d019..1dedc7c5c8 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -451,11 +451,11 @@ inline void QDirPrivate::initFileEngine() for these that return strings: \table - \header \o QDir \o QString \o Return Value - \row \o current() \o currentPath() \o The application's working directory - \row \o home() \o homePath() \o The user's home directory - \row \o root() \o rootPath() \o The root directory - \row \o temp() \o tempPath() \o The system's temporary directory + \header \li QDir \li QString \li Return Value + \row \li current() \li currentPath() \li The application's working directory + \row \li home() \li homePath() \li The user's home directory + \row \li root() \li rootPath() \li The root directory + \row \li temp() \li tempPath() \li The system's temporary directory \endtable The setCurrent() static function can also be used to set the application's @@ -1878,13 +1878,13 @@ QString QDir::currentPath() the given order) until an existing and available path is found: \list 1 - \o The path specified by the \c USERPROFILE environment variable. - \o The path formed by concatenating the \c HOMEDRIVE and \c HOMEPATH + \li The path specified by the \c USERPROFILE environment variable. + \li The path formed by concatenating the \c HOMEDRIVE and \c HOMEPATH environment variables. - \o The path specified by the \c HOME environment variable. - \o The path returned by the rootPath() function (which uses the \c SystemDrive + \li The path specified by the \c HOME environment variable. + \li The path returned by the rootPath() function (which uses the \c SystemDrive environment variable) - \o The \c{C:/} directory. + \li The \c{C:/} directory. \endlist Under non-Windows operating systems the \c HOME environment diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index fc0c90cf69..6640dca70b 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -1034,13 +1034,13 @@ bool QFile::open(OpenMode mode) then calling close() closes the adopted handle. Otherwise, close() does not actually close the file, but only flushes it. - \bold{Warning:} + \b{Warning:} \list 1 - \o If \a fh does not refer to a regular file, e.g., it is \c stdin, + \li If \a fh does not refer to a regular file, e.g., it is \c stdin, \c stdout, or \c stderr, you may not be able to seek(). size() returns \c 0 in those cases. See QIODevice::isSequential() for more information. - \o Since this function opens the file without specifying the file name, + \li Since this function opens the file without specifying the file name, you cannot use this QFile with a QFileInfo. \endlist @@ -1048,7 +1048,7 @@ bool QFile::open(OpenMode mode) \sa close(), {qmake Variable Reference#CONFIG}{qmake Variable Reference} - \bold{Note for the Windows Platform} + \b{Note for the Windows Platform} \a fh must be opened in binary mode (i.e., the mode string must contain 'b', as in "rb" or "wb") when accessing files and other random-access diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index a7fb0fb6c7..044c71d00a 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -812,7 +812,7 @@ QString QFileInfo::suffix() const /*! Returns the path of the object's parent directory as a QDir object. - \bold{Note:} The QDir returned always corresponds to the object's + \b{Note:} The QDir returned always corresponds to the object's parent directory, even if the QFileInfo represents a directory. For each of the following, dir() returns a QDir for @@ -901,7 +901,7 @@ bool QFileInfo::isExecutable() const /*! Returns true if this is a `hidden' file; otherwise returns false. - \bold{Note:} This function returns true for the special entries + \b{Note:} This function returns true for the special entries "." and ".." on Unix, even though QDir::entryList threats them as shown. */ bool QFileInfo::isHidden() const @@ -923,7 +923,7 @@ bool QFileInfo::isHidden() const Returns false if the file is otherwise supported by a virtual file system inside Qt, such as \l{the Qt Resource System}. - \bold{Note:} Native paths may still require conversion of path separators + \b{Note:} Native paths may still require conversion of path separators and character encoding, depending on platform and input requirements of the native API. diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index 3d9391ebaa..1cdfc61627 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -163,12 +163,12 @@ QIODevicePrivate::~QIODevicePrivate() random-access devices and sequential devices. \list - \o Random-access devices support seeking to arbitrary + \li Random-access devices support seeking to arbitrary positions using seek(). The current position in the file is available by calling pos(). QFile and QBuffer are examples of random-access devices. - \o Sequential devices don't support seeking to arbitrary + \li Sequential devices don't support seeking to arbitrary positions. The data must be read in one pass. The functions pos() and size() don't work for sequential devices. QTcpSocket and QProcess are examples of sequential devices. @@ -199,14 +199,14 @@ QIODevicePrivate::~QIODevicePrivate() a separate thread: \list - \o waitForReadyRead() - This function suspends operation in the + \li waitForReadyRead() - This function suspends operation in the calling thread until new data is available for reading. - \o waitForBytesWritten() - This function suspends operation in the + \li waitForBytesWritten() - This function suspends operation in the calling thread until one payload of data has been written to the device. - \o waitFor....() - Subclasses of QIODevice implement blocking + \li waitFor....() - Subclasses of QIODevice implement blocking functions for device-specific operations. For example, QProcess has a function called waitForStarted() which suspends operation in the calling thread until the process has started. @@ -1038,9 +1038,9 @@ QByteArray QIODevice::readAll() Data is read until either of the following conditions are met: \list - \o The first '\n' character is read. - \o \a maxSize - 1 bytes are read. - \o The end of the device data is detected. + \li The first '\n' character is read. + \li \a maxSize - 1 bytes are read. + \li The end of the device data is detected. \endlist For example, the following code reads a line of characters from a diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 7a81313fa0..640704ec86 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -532,15 +532,15 @@ void QProcessPrivate::Channel::clear() certain signals are emitted: \list - \o waitForStarted() blocks until the process has started. + \li waitForStarted() blocks until the process has started. - \o waitForReadyRead() blocks until new data is + \li waitForReadyRead() blocks until new data is available for reading on the current read channel. - \o waitForBytesWritten() blocks until one payload of + \li waitForBytesWritten() blocks until one payload of data has been written to the process. - \o waitForFinished() blocks until the process has finished. + \li waitForFinished() blocks until the process has finished. \endlist Calling these functions from the main thread (the thread that @@ -1910,7 +1910,7 @@ QByteArray QProcess::readAllStandardError() \note No further splitting of the arguments is performed. - \bold{Windows:} Arguments that contain spaces are wrapped in quotes. + \b{Windows:} Arguments that contain spaces are wrapped in quotes. \sa pid(), started(), waitForStarted() */ @@ -2149,10 +2149,10 @@ int QProcess::execute(const QString &program) Note that arguments that contain spaces are not passed to the process as separate arguments. - \bold{Unix:} The started process will run in its own session and act + \b{Unix:} The started process will run in its own session and act like a daemon. - \bold{Windows:} Arguments that contain spaces are wrapped in quotes. + \b{Windows:} Arguments that contain spaces are wrapped in quotes. The started process will run as a regular standalone process. The process will be started in the directory \a workingDirectory. @@ -2183,10 +2183,10 @@ bool QProcess::startDetached(const QString &program, \note Arguments that contain spaces are not passed to the process as separate arguments. - \bold{Unix:} The started process will run in its own session and act + \b{Unix:} The started process will run in its own session and act like a daemon. - \bold{Windows:} Arguments that contain spaces are wrapped in quotes. + \b{Windows:} Arguments that contain spaces are wrapped in quotes. The started process will run as a regular standalone process. */ bool QProcess::startDetached(const QString &program, diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 2021c42c4d..e4d90e000a 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -2112,15 +2112,15 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, avoid portability problems, follow these simple rules: \list 1 - \o Always refer to the same key using the same case. For example, + \li Always refer to the same key using the same case. For example, if you refer to a key as "text fonts" in one place in your code, don't refer to it as "Text Fonts" somewhere else. - \o Avoid key names that are identical except for the case. For + \li Avoid key names that are identical except for the case. For example, if you have a key called "MainWindow", don't try to save another key as "mainwindow". - \o Do not use slashes ('/' and '\\') in section or key names; the + \li Do not use slashes ('/' and '\\') in section or key names; the backslash character is used to separate sub keys (see below). On windows '\\' are converted by QSettings to '/', which makes them identical. @@ -2156,10 +2156,10 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, that order: \list 1 - \o a user-specific location for the Star Runner application - \o a user-specific location for all applications by MySoft - \o a system-wide location for the Star Runner application - \o a system-wide location for all applications by MySoft + \li a user-specific location for the Star Runner application + \li a user-specific location for all applications by MySoft + \li a system-wide location for the Star Runner application + \li a system-wide location for all applications by MySoft \endlist (See \l{Platform-Specific Notes} below for information on what @@ -2184,17 +2184,17 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, \snippet doc/src/snippets/settings/settings.cpp 14 The table below summarizes which QSettings objects access - which location. "\bold{X}" means that the location is the main + which location. "\b{X}" means that the location is the main location associated to the QSettings object and is used both for reading and for writing; "o" means that the location is used as a fallback when reading. \table - \header \o Locations \o \c{obj1} \o \c{obj2} \o \c{obj3} \o \c{obj4} - \row \o 1. User, Application \o \bold{X} \o \o \o - \row \o 2. User, Organization \o o \o \bold{X} \o \o - \row \o 3. System, Application \o o \o \o \bold{X} \o - \row \o 4. System, Organization \o o \o o \o o \o \bold{X} + \header \li Locations \li \c{obj1} \li \c{obj2} \li \c{obj3} \li \c{obj4} + \row \li 1. User, Application \li \b{X} \li \li \li + \row \li 2. User, Organization \li o \li \b{X} \li \li + \row \li 3. System, Application \li o \li \li \b{X} \li + \row \li 4. System, Organization \li o \li o \li o \li \b{X} \endtable The beauty of this mechanism is that it works on all platforms @@ -2276,30 +2276,30 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, following files are used by default: \list 1 - \o \c{$HOME/.config/MySoft/Star Runner.conf} (Qt for Embedded Linux: \c{$HOME/Settings/MySoft/Star Runner.conf}) - \o \c{$HOME/.config/MySoft.conf} (Qt for Embedded Linux: \c{$HOME/Settings/MySoft.conf}) - \o \c{/etc/xdg/MySoft/Star Runner.conf} - \o \c{/etc/xdg/MySoft.conf} + \li \c{$HOME/.config/MySoft/Star Runner.conf} (Qt for Embedded Linux: \c{$HOME/Settings/MySoft/Star Runner.conf}) + \li \c{$HOME/.config/MySoft.conf} (Qt for Embedded Linux: \c{$HOME/Settings/MySoft.conf}) + \li \c{/etc/xdg/MySoft/Star Runner.conf} + \li \c{/etc/xdg/MySoft.conf} \endlist On Mac OS X versions 10.2 and 10.3, these files are used by default: \list 1 - \o \c{$HOME/Library/Preferences/com.MySoft.Star Runner.plist} - \o \c{$HOME/Library/Preferences/com.MySoft.plist} - \o \c{/Library/Preferences/com.MySoft.Star Runner.plist} - \o \c{/Library/Preferences/com.MySoft.plist} + \li \c{$HOME/Library/Preferences/com.MySoft.Star Runner.plist} + \li \c{$HOME/Library/Preferences/com.MySoft.plist} + \li \c{/Library/Preferences/com.MySoft.Star Runner.plist} + \li \c{/Library/Preferences/com.MySoft.plist} \endlist On Windows, NativeFormat settings are stored in the following registry paths: \list 1 - \o \c{HKEY_CURRENT_USER\Software\MySoft\Star Runner} - \o \c{HKEY_CURRENT_USER\Software\MySoft} - \o \c{HKEY_LOCAL_MACHINE\Software\MySoft\Star Runner} - \o \c{HKEY_LOCAL_MACHINE\Software\MySoft} + \li \c{HKEY_CURRENT_USER\Software\MySoft\Star Runner} + \li \c{HKEY_CURRENT_USER\Software\MySoft} + \li \c{HKEY_LOCAL_MACHINE\Software\MySoft\Star Runner} + \li \c{HKEY_LOCAL_MACHINE\Software\MySoft} \endlist \note On Windows, for 32-bit programs running in WOW64 mode, settings are @@ -2310,19 +2310,19 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, used on Unix and Mac OS X: \list 1 - \o \c{$HOME/.config/MySoft/Star Runner.ini} (Qt for Embedded Linux: \c{$HOME/Settings/MySoft/Star Runner.ini}) - \o \c{$HOME/.config/MySoft.ini} (Qt for Embedded Linux: \c{$HOME/Settings/MySoft.ini}) - \o \c{/etc/xdg/MySoft/Star Runner.ini} - \o \c{/etc/xdg/MySoft.ini} + \li \c{$HOME/.config/MySoft/Star Runner.ini} (Qt for Embedded Linux: \c{$HOME/Settings/MySoft/Star Runner.ini}) + \li \c{$HOME/.config/MySoft.ini} (Qt for Embedded Linux: \c{$HOME/Settings/MySoft.ini}) + \li \c{/etc/xdg/MySoft/Star Runner.ini} + \li \c{/etc/xdg/MySoft.ini} \endlist On Windows, the following files are used: \list 1 - \o \c{%APPDATA%\MySoft\Star Runner.ini} - \o \c{%APPDATA%\MySoft.ini} - \o \c{%COMMON_APPDATA%\MySoft\Star Runner.ini} - \o \c{%COMMON_APPDATA%\MySoft.ini} + \li \c{%APPDATA%\MySoft\Star Runner.ini} + \li \c{%APPDATA%\MySoft.ini} + \li \c{%COMMON_APPDATA%\MySoft\Star Runner.ini} + \li \c{%COMMON_APPDATA%\MySoft.ini} \endlist The \c %APPDATA% path is usually \tt{C:\\Documents and @@ -2395,20 +2395,20 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, application: \list - \o The Windows system registry has the following limitations: A + \li The Windows system registry has the following limitations: A subkey may not exceed 255 characters, an entry's value may not exceed 16,383 characters, and all the values of a key may not exceed 65,535 characters. One way to work around these limitations is to store the settings using the IniFormat instead of the NativeFormat. - \o On Mac OS X, allKeys() will return some extra keys for global + \li On Mac OS X, allKeys() will return some extra keys for global settings that apply to all applications. These keys can be read using value() but cannot be changed, only shadowed. Calling setFallbacksEnabled(false) will hide these global settings. - \o On Mac OS X, the CFPreferences API used by QSettings expects + \li On Mac OS X, the CFPreferences API used by QSettings expects Internet domain names rather than organization names. To provide a uniform API, QSettings derives a fake domain name from the organization name (unless the organization name @@ -2425,7 +2425,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 7 - \o On Unix and Mac OS X systems, the advisory file locking is disabled + \li On Unix and Mac OS X systems, the advisory file locking is disabled if NFS (or AutoFS or CacheFS) is detected to work around a bug in the NFS fcntl() implementation, which hangs forever if statd or lockd aren't running. Also, the locking isn't performed when accessing \c .plist @@ -2485,7 +2485,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, follow what Microsoft does, with the following exceptions: \list - \o If you store types that QVariant can't convert to QString + \li If you store types that QVariant can't convert to QString (e.g., QPoint, QRect, and QSize), Qt uses an \c{@}-based syntax to encode the type. For example: @@ -2496,7 +2496,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, followed by a Qt type (\c Point, \c Rect, \c Size, etc.) is treated as a normal character. - \o Although backslash is a special character in INI files, most + \li Although backslash is a special character in INI files, most Windows applications don't escape backslashes (\c{\}) in file paths: @@ -2505,7 +2505,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, QSettings always treats backslash as a special character and provides no API for reading or writing such entries. - \o The INI file format has severe restrictions on the syntax of + \li The INI file format has severe restrictions on the syntax of a key. Qt works around this by using \c % as an escape character in keys. In addition, if you save a top-level setting (a key with no slashes in it, e.g., "someKey"), it @@ -2514,7 +2514,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, such as "General/someKey", the key will be located in the "%General" section, \e not in the "General" section. - \o Following the philosophy that we should be liberal in what + \li Following the philosophy that we should be liberal in what we accept and conservative in what we generate, QSettings will accept Latin-1 encoded INI files, but generate pure ASCII files, where non-ASCII values are encoded using standard @@ -2632,10 +2632,10 @@ QSettings::QSettings(Format format, Scope scope, const QString &organization, be aware of the following limitations: \list - \o QSettings provides no way of reading INI "path" entries, i.e., entries + \li QSettings provides no way of reading INI "path" entries, i.e., entries with unescaped slash characters. (This is because these entries are ambiguous and cannot be resolved automatically.) - \o In INI files, QSettings uses the \c @ character as a metacharacter in some + \li In INI files, QSettings uses the \c @ character as a metacharacter in some contexts, to encode Qt-specific data types (e.g., \c @Rect), and might therefore misinterpret it when it occurs in pure INI files. \endlist @@ -2933,9 +2933,9 @@ QSettings::Status QSettings::status() const This will set the value of three settings: \list - \o \c mainwindow/size - \o \c mainwindow/fullScreen - \o \c outputpanel/visible + \li \c mainwindow/size + \li \c mainwindow/fullScreen + \li \c outputpanel/visible \endlist Call endGroup() to reset the current group to what it was before @@ -3021,14 +3021,14 @@ int QSettings::beginReadArray(const QString &prefix) The generated keys will have the form \list - \o \c logins/size - \o \c logins/1/userName - \o \c logins/1/password - \o \c logins/2/userName - \o \c logins/2/password - \o \c logins/3/userName - \o \c logins/3/password - \o ... + \li \c logins/size + \li \c logins/1/userName + \li \c logins/1/password + \li \c logins/2/userName + \li \c logins/2/password + \li \c logins/3/userName + \li \c logins/3/password + \li ... \endlist To read back an array, use beginReadArray(). @@ -3412,15 +3412,15 @@ void QSettings::setUserIniPath(const QString &dir) The table below summarizes the default values: \table - \header \o Platform \o Format \o Scope \o Path - \row \o{1,2} Windows \o{1,2} IniFormat \o UserScope \o \c %APPDATA% - \row \o SystemScope \o \c %COMMON_APPDATA% - \row \o{1,2} Unix \o{1,2} NativeFormat, IniFormat \o UserScope \o \c $HOME/.config - \row \o SystemScope \o \c /etc/xdg - \row \o{1,2} Qt for Embedded Linux \o{1,2} NativeFormat, IniFormat \o UserScope \o \c $HOME/Settings - \row \o SystemScope \o \c /etc/xdg - \row \o{1,2} Mac OS X \o{1,2} IniFormat \o UserScope \o \c $HOME/.config - \row \o SystemScope \o \c /etc/xdg + \header \li Platform \li Format \li Scope \li Path + \row \li{1,2} Windows \li{1,2} IniFormat \li UserScope \li \c %APPDATA% + \row \li SystemScope \li \c %COMMON_APPDATA% + \row \li{1,2} Unix \li{1,2} NativeFormat, IniFormat \li UserScope \li \c $HOME/.config + \row \li SystemScope \li \c /etc/xdg + \row \li{1,2} Qt for Embedded Linux \li{1,2} NativeFormat, IniFormat \li UserScope \li \c $HOME/Settings + \row \li SystemScope \li \c /etc/xdg + \row \li{1,2} Mac OS X \li{1,2} IniFormat \li UserScope \li \c $HOME/.config + \row \li SystemScope \li \c /etc/xdg \endtable The default UserScope paths on Unix and Mac OS X (\c diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index dd0ab85119..cb703df8c6 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -90,13 +90,13 @@ static const int QTEXTSTREAM_BUFFERSIZE = 16384; \list - \o Chunk by chunk, by calling readLine() or readAll(). + \li Chunk by chunk, by calling readLine() or readAll(). - \o Word by word. QTextStream supports streaming into QStrings, + \li Word by word. QTextStream supports streaming into QStrings, QByteArrays and char* buffers. Words are delimited by space, and leading white space is automatically skipped. - \o Character by character, by streaming into QChar or char types. + \li Character by character, by streaming into QChar or char types. This method is often used for convenient input handling when parsing files, independent of character encoding and end-of-line semantics. To skip white space, call skipWhiteSpace(). @@ -134,31 +134,31 @@ static const int QTEXTSTREAM_BUFFERSIZE = 16384; defines several global manipulator functions: \table - \header \o Manipulator \o Description - \row \o \c bin \o Same as setIntegerBase(2). - \row \o \c oct \o Same as setIntegerBase(8). - \row \o \c dec \o Same as setIntegerBase(10). - \row \o \c hex \o Same as setIntegerBase(16). - \row \o \c showbase \o Same as setNumberFlags(numberFlags() | ShowBase). - \row \o \c forcesign \o Same as setNumberFlags(numberFlags() | ForceSign). - \row \o \c forcepoint \o Same as setNumberFlags(numberFlags() | ForcePoint). - \row \o \c noshowbase \o Same as setNumberFlags(numberFlags() & ~ShowBase). - \row \o \c noforcesign \o Same as setNumberFlags(numberFlags() & ~ForceSign). - \row \o \c noforcepoint \o Same as setNumberFlags(numberFlags() & ~ForcePoint). - \row \o \c uppercasebase \o Same as setNumberFlags(numberFlags() | UppercaseBase). - \row \o \c uppercasedigits \o Same as setNumberFlags(numberFlags() | UppercaseDigits). - \row \o \c lowercasebase \o Same as setNumberFlags(numberFlags() & ~UppercaseBase). - \row \o \c lowercasedigits \o Same as setNumberFlags(numberFlags() & ~UppercaseDigits). - \row \o \c fixed \o Same as setRealNumberNotation(FixedNotation). - \row \o \c scientific \o Same as setRealNumberNotation(ScientificNotation). - \row \o \c left \o Same as setFieldAlignment(AlignLeft). - \row \o \c right \o Same as setFieldAlignment(AlignRight). - \row \o \c center \o Same as setFieldAlignment(AlignCenter). - \row \o \c endl \o Same as operator<<('\n') and flush(). - \row \o \c flush \o Same as flush(). - \row \o \c reset \o Same as reset(). - \row \o \c ws \o Same as skipWhiteSpace(). - \row \o \c bom \o Same as setGenerateByteOrderMark(true). + \header \li Manipulator \li Description + \row \li \c bin \li Same as setIntegerBase(2). + \row \li \c oct \li Same as setIntegerBase(8). + \row \li \c dec \li Same as setIntegerBase(10). + \row \li \c hex \li Same as setIntegerBase(16). + \row \li \c showbase \li Same as setNumberFlags(numberFlags() | ShowBase). + \row \li \c forcesign \li Same as setNumberFlags(numberFlags() | ForceSign). + \row \li \c forcepoint \li Same as setNumberFlags(numberFlags() | ForcePoint). + \row \li \c noshowbase \li Same as setNumberFlags(numberFlags() & ~ShowBase). + \row \li \c noforcesign \li Same as setNumberFlags(numberFlags() & ~ForceSign). + \row \li \c noforcepoint \li Same as setNumberFlags(numberFlags() & ~ForcePoint). + \row \li \c uppercasebase \li Same as setNumberFlags(numberFlags() | UppercaseBase). + \row \li \c uppercasedigits \li Same as setNumberFlags(numberFlags() | UppercaseDigits). + \row \li \c lowercasebase \li Same as setNumberFlags(numberFlags() & ~UppercaseBase). + \row \li \c lowercasedigits \li Same as setNumberFlags(numberFlags() & ~UppercaseDigits). + \row \li \c fixed \li Same as setRealNumberNotation(FixedNotation). + \row \li \c scientific \li Same as setRealNumberNotation(ScientificNotation). + \row \li \c left \li Same as setFieldAlignment(AlignLeft). + \row \li \c right \li Same as setFieldAlignment(AlignRight). + \row \li \c center \li Same as setFieldAlignment(AlignCenter). + \row \li \c endl \li Same as operator<<('\n') and flush(). + \row \li \c flush \li Same as flush(). + \row \li \c reset \li Same as reset(). + \row \li \c ws \li Same as skipWhiteSpace(). + \row \li \c bom \li Same as setGenerateByteOrderMark(true). \endtable In addition, Qt provides three global manipulators that take a @@ -2065,12 +2065,12 @@ QTextStream &QTextStream::operator>>(char &c) number using the following rules: \table - \header \o Prefix \o Base - \row \o "0b" or "0B" \o 2 (binary) - \row \o "0" followed by "0-7" \o 8 (octal) - \row \o "0" otherwise \o 10 (decimal) - \row \o "0x" or "0X" \o 16 (hexadecimal) - \row \o "1" to "9" \o 10 (decimal) + \header \li Prefix \li Base + \row \li "0b" or "0B" \li 2 (binary) + \row \li "0" followed by "0-7" \li 8 (octal) + \row \li "0" otherwise \li 10 (decimal) + \row \li "0x" or "0X" \li 16 (hexadecimal) + \row \li "1" to "9" \li 10 (decimal) \endtable By calling setIntegerBase(), you can specify the integer base diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index eeeca1bf77..0659053937 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -112,7 +112,7 @@ dealing with URLs and strings: \list - \o When creating an QString to contain a URL from a QByteArray or a + \li When creating an QString to contain a URL from a QByteArray or a char*, always use QString::fromUtf8(). \endlist @@ -135,15 +135,15 @@ \list - \o Spaces and "%20": If an encoded URL contains a space, this will be + \li Spaces and "%20": If an encoded URL contains a space, this will be replaced with "%20". If a decoded URL contains "%20", this will be replaced with a single space before the URL is parsed. - \o Single "%" characters: Any occurrences of a percent character "%" not + \li Single "%" characters: Any occurrences of a percent character "%" not followed by exactly two hexadecimal characters (e.g., "13% coverage.html") will be replaced by "%25". - \o Reserved and unreserved characters: An encoded URL should only + \li Reserved and unreserved characters: An encoded URL should only contain a few characters as literals; all other characters should be percent-encoded. In TolerantMode, these characters will be automatically percent-encoded where they are not allowed: @@ -6335,10 +6335,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \section1 Examples: \list - \o qt.nokia.com becomes http://qt.nokia.com - \o ftp.qt.nokia.com becomes ftp://ftp.qt.nokia.com - \o hostname becomes http://hostname - \o /home/user/test.html becomes file:///home/user/test.html + \li qt.nokia.com becomes http://qt.nokia.com + \li ftp.qt.nokia.com becomes ftp://ftp.qt.nokia.com + \li hostname becomes http://hostname + \li /home/user/test.html becomes file:///home/user/test.html \endlist */ QUrl QUrl::fromUserInput(const QString &userInput) diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index a8c3921f45..7a1357959e 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -1161,16 +1161,16 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, \e before and \e after they occur: \list - \o An insertRows() implementation must call beginInsertRows() \e before + \li An insertRows() implementation must call beginInsertRows() \e before inserting new rows into the data structure, and endInsertRows() \e{immediately afterwards}. - \o An insertColumns() implementation must call beginInsertColumns() + \li An insertColumns() implementation must call beginInsertColumns() \e before inserting new columns into the data structure, and endInsertColumns() \e{immediately afterwards}. - \o A removeRows() implementation must call beginRemoveRows() \e before + \li A removeRows() implementation must call beginRemoveRows() \e before the rows are removed from the data structure, and endRemoveRows() \e{immediately afterwards}. - \o A removeColumns() implementation must call beginRemoveColumns() + \li A removeColumns() implementation must call beginRemoveColumns() \e before the columns are removed from the data structure, and endRemoveColumns() \e{immediately afterwards}. \endlist @@ -1179,7 +1179,7 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, the chance to take action before any data becomes unavailable. The encapsulation of the insert and remove operations with these begin and end functions also enables the model to manage \l{QPersistentModelIndex} - {persistent model indexes} correctly. \bold{If you want selections to be + {persistent model indexes} correctly. \b{If you want selections to be handled properly, you must ensure that you call these functions.} If you insert or remove an item with children, you do not need to call these functions for the child items. In other words, the parent item will take @@ -1338,11 +1338,11 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, layoutChanged(). In other words, when the structure changes: \list - \o emit layoutAboutToBeChanged - \o Remember the QModelIndex that will change - \o Update your internal data - \o Call changePersistentIndex() - \o emit layoutChanged + \li emit layoutAboutToBeChanged + \li Remember the QModelIndex that will change + \li Update your internal data + \li Call changePersistentIndex() + \li emit layoutChanged \endlist \sa layoutAboutToBeChanged(), dataChanged(), headerDataChanged(), modelReset(), @@ -1500,7 +1500,7 @@ QAbstractItemModel::~QAbstractItemModel() inclusive, under the given \a sourceParent item have been moved to \a destinationParent starting at the row \a destinationRow. - \bold{Note:} Components connected to this signal use it to adapt to changes + \b{Note:} Components connected to this signal use it to adapt to changes in the model's dimensions. It can only be emitted by the QAbstractItemModel implementation, and cannot be explicitly emitted in subclass code. @@ -1516,7 +1516,7 @@ QAbstractItemModel::~QAbstractItemModel() inclusive, under the given \a sourceParent item. They will be moved to \a destinationParent starting at the row \a destinationRow. - \bold{Note:} Components connected to this signal use it to adapt to changes + \b{Note:} Components connected to this signal use it to adapt to changes in the model's dimensions. It can only be emitted by the QAbstractItemModel implementation, and cannot be explicitly emitted in subclass code. @@ -1532,7 +1532,7 @@ QAbstractItemModel::~QAbstractItemModel() inclusive, under the given \a sourceParent item have been moved to \a destinationParent starting at the column \a destinationColumn. - \bold{Note:} Components connected to this signal use it to adapt to changes + \b{Note:} Components connected to this signal use it to adapt to changes in the model's dimensions. It can only be emitted by the QAbstractItemModel implementation, and cannot be explicitly emitted in subclass code. @@ -1548,7 +1548,7 @@ QAbstractItemModel::~QAbstractItemModel() inclusive, under the given \a sourceParent item. They will be moved to \a destinationParent starting at the column \a destinationColumn. - \bold{Note:} Components connected to this signal use it to adapt to changes + \b{Note:} Components connected to this signal use it to adapt to changes in the model's dimensions. It can only be emitted by the QAbstractItemModel implementation, and cannot be explicitly emitted in subclass code. @@ -1683,7 +1683,7 @@ bool QAbstractItemModel::setData(const QModelIndex &index, const QVariant &value Returns the data stored under the given \a role for the item referred to by the \a index. - \note If you do not have a value to return, return an \bold invalid + \note If you do not have a value to return, return an \b invalid QVariant instead of returning 0. \sa Qt::ItemDataRole, setData(), headerData() @@ -2437,8 +2437,8 @@ bool QAbstractItemModel::decodeData(int row, int column, const QModelIndex &pare \table 80% \row - \o \inlineimage modelview-begin-insert-rows.png Inserting rows - \o Specify the first and last row numbers for the span of rows you + \li \inlineimage modelview-begin-insert-rows.png Inserting rows + \li Specify the first and last row numbers for the span of rows you want to insert into an item in a model. For example, as shown in the diagram, we insert three rows before @@ -2448,8 +2448,8 @@ bool QAbstractItemModel::decodeData(int row, int column, const QModelIndex &pare This inserts the three new rows as rows 2, 3, and 4. \row - \o \inlineimage modelview-begin-append-rows.png Appending rows - \o To append rows, insert them after the last row. + \li \inlineimage modelview-begin-append-rows.png Appending rows + \li To append rows, insert them after the last row. For example, as shown in the diagram, we append two rows to a collection of 4 existing rows (ending in row 3), so \a first is 4 @@ -2503,8 +2503,8 @@ void QAbstractItemModel::endInsertRows() \table 80% \row - \o \inlineimage modelview-begin-remove-rows.png Removing rows - \o Specify the first and last row numbers for the span of rows you + \li \inlineimage modelview-begin-remove-rows.png Removing rows + \li Specify the first and last row numbers for the span of rows you want to remove from an item in a model. For example, as shown in the diagram, we remove the two rows from @@ -2616,8 +2616,8 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star \table 80% \row - \o \inlineimage modelview-move-rows-1.png Moving rows to another parent - \o Specify the first and last row numbers for the span of rows in + \li \inlineimage modelview-move-rows-1.png Moving rows to another parent + \li Specify the first and last row numbers for the span of rows in the source parent you want to move in the model. Also specify the row in the destination parent to move the span to. @@ -2630,8 +2630,8 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star This moves the three rows rows 2, 3, and 4 in the source to become 2, 3 and 4 in the destination. Other affected siblings are displaced accordingly. \row - \o \inlineimage modelview-move-rows-2.png Moving rows to append to another parent - \o To append rows to another parent, move them to after the last row. + \li \inlineimage modelview-move-rows-2.png Moving rows to append to another parent + \li To append rows to another parent, move them to after the last row. For example, as shown in the diagram, we move three rows to a collection of 6 existing rows (ending in row 5), so \a destinationChild is 6: @@ -2640,8 +2640,8 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star This moves the target rows to the end of the target parent as 6, 7 and 8. \row - \o \inlineimage modelview-move-rows-3.png Moving rows in the same parent up - \o To move rows within the same parent, specify the row to move them to. + \li \inlineimage modelview-move-rows-3.png Moving rows in the same parent up + \li To move rows within the same parent, specify the row to move them to. For example, as shown in the diagram, we move one item from row 2 to row 0, so \a sourceFirst and \a sourceLast are 2 and \a destinationChild is 0. @@ -2655,8 +2655,8 @@ bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int star it is already) \row - \o \inlineimage modelview-move-rows-4.png Moving rows in the same parent down - \o To move rows within the same parent, specify the row to move them to. + \li \inlineimage modelview-move-rows-4.png Moving rows in the same parent down + \li To move rows within the same parent, specify the row to move them to. For example, as shown in the diagram, we move one item from row 2 to row 4, so \a sourceFirst and \a sourceLast are 2 and \a destinationChild is 4. @@ -2737,8 +2737,8 @@ void QAbstractItemModel::endMoveRows() \table 80% \row - \o \inlineimage modelview-begin-insert-columns.png Inserting columns - \o Specify the first and last column numbers for the span of columns + \li \inlineimage modelview-begin-insert-columns.png Inserting columns + \li Specify the first and last column numbers for the span of columns you want to insert into an item in a model. For example, as shown in the diagram, we insert three columns @@ -2748,8 +2748,8 @@ void QAbstractItemModel::endMoveRows() This inserts the three new columns as columns 4, 5, and 6. \row - \o \inlineimage modelview-begin-append-columns.png Appending columns - \o To append columns, insert them after the last column. + \li \inlineimage modelview-begin-append-columns.png Appending columns + \li To append columns, insert them after the last column. For example, as shown in the diagram, we append three columns to a collection of six existing columns (ending in column 5), so @@ -2805,8 +2805,8 @@ void QAbstractItemModel::endInsertColumns() \table 80% \row - \o \inlineimage modelview-begin-remove-columns.png Removing columns - \o Specify the first and last column numbers for the span of columns + \li \inlineimage modelview-begin-remove-columns.png Removing columns + \li Specify the first and last column numbers for the span of columns you want to remove from an item in a model. For example, as shown in the diagram, we remove the three columns @@ -3135,16 +3135,16 @@ QModelIndexList QAbstractItemModel::persistentIndexList() const are aware of any changes: \list - \o An insertRows() implementation must call beginInsertRows() + \li An insertRows() implementation must call beginInsertRows() \e before inserting new rows into the data structure, and it must call endInsertRows() \e{immediately afterwards}. - \o An insertColumns() implementation must call beginInsertColumns() + \li An insertColumns() implementation must call beginInsertColumns() \e before inserting new columns into the data structure, and it must call endInsertColumns() \e{immediately afterwards}. - \o A removeRows() implementation must call beginRemoveRows() + \li A removeRows() implementation must call beginRemoveRows() \e before the rows are removed from the data structure, and it must call endRemoveRows() \e{immediately afterwards}. - \o A removeColumns() implementation must call beginRemoveColumns() + \li A removeColumns() implementation must call beginRemoveColumns() \e before the columns are removed from the data structure, and it must call endRemoveColumns() \e{immediately afterwards}. \endlist @@ -3271,10 +3271,10 @@ bool QAbstractTableModel::hasChildren(const QModelIndex &parent) const functions so that all connected views are aware of any changes: \list - \o An insertRows() implementation must call beginInsertRows() + \li An insertRows() implementation must call beginInsertRows() \e before inserting new rows into the data structure, and it must call endInsertRows() \e{immediately afterwards}. - \o A removeRows() implementation must call beginRemoveRows() + \li A removeRows() implementation must call beginRemoveRows() \e before the rows are removed from the data structure, and it must call endRemoveRows() \e{immediately afterwards}. \endlist diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index b7ef69423f..ae9affb862 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -2531,16 +2531,16 @@ void QSortFilterProxyModel::invalidateFilter() the following QVariant types: \list - \o QVariant::Int - \o QVariant::UInt - \o QVariant::LongLong - \o QVariant::ULongLong - \o QVariant::Double - \o QVariant::Char - \o QVariant::Date - \o QVariant::Time - \o QVariant::DateTime - \o QVariant::String + \li QVariant::Int + \li QVariant::UInt + \li QVariant::LongLong + \li QVariant::ULongLong + \li QVariant::Double + \li QVariant::Char + \li QVariant::Date + \li QVariant::Time + \li QVariant::DateTime + \li QVariant::String \endlist Any other type will be converted to a QString using diff --git a/src/corelib/json/qjsonarray.cpp b/src/corelib/json/qjsonarray.cpp index 0eb1974147..cdf9192b27 100644 --- a/src/corelib/json/qjsonarray.cpp +++ b/src/corelib/json/qjsonarray.cpp @@ -559,7 +559,7 @@ bool QJsonArray::operator!=(const QJsonArray &other) const /*! \typedef QJsonArray::iterator::iterator_category - A synonym for \i {std::random_access_iterator_tag} indicating + A synonym for \e {std::random_access_iterator_tag} indicating this iterator is a random access iterator. */ @@ -793,7 +793,7 @@ bool QJsonArray::operator!=(const QJsonArray &other) const /*! \typedef QJsonArray::const_iterator::iterator_category - A synonym for \i {std::random_access_iterator_tag} indicating + A synonym for \e {std::random_access_iterator_tag} indicating this iterator is a random access iterator. */ diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp index b7af8c22cf..a854f73c7e 100644 --- a/src/corelib/json/qjsonobject.cpp +++ b/src/corelib/json/qjsonobject.cpp @@ -568,7 +568,7 @@ QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const /*! \typedef QJsonObject::iterator::iterator_category - A synonym for \i {std::bidirectional_iterator_tag} indicating + A synonym for \e {std::bidirectional_iterator_tag} indicating this iterator is a bidirectional iterator. */ @@ -757,7 +757,7 @@ QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const /*! \typedef QJsonObject::const_iterator::iterator_category - A synonym for \i {std::bidirectional_iterator_tag} indicating + A synonym for \e {std::bidirectional_iterator_tag} indicating this iterator is a bidirectional iterator. */ diff --git a/src/corelib/json/qjsonvalue.cpp b/src/corelib/json/qjsonvalue.cpp index 603cba8897..b4a689da60 100644 --- a/src/corelib/json/qjsonvalue.cpp +++ b/src/corelib/json/qjsonvalue.cpp @@ -64,12 +64,12 @@ QT_BEGIN_NAMESPACE JSON is a format to store structured data. It has 6 basic data types: \list - \o bool QJsonValue::Bool - \o double QJsonValue::Double - \o string QJsonValue::String - \o array QJsonValue::Array - \o object QJsonValue::Object - \o null QJsonValue::Null + \li bool QJsonValue::Bool + \li double QJsonValue::Double + \li string QJsonValue::String + \li array QJsonValue::Array + \li object QJsonValue::Object + \li null QJsonValue::Null \endlist A value can represent any of the above data types. In addition, QJsonValue has one special @@ -260,16 +260,16 @@ QJsonValue &QJsonValue::operator =(const QJsonValue &other) The conversion will convert QVariant types as follows: \list - \o QVariant::Bool to Bool - \o QVariant::Int - \o QVariant::Double - \o QVariant::LongLong - \o QVariant::ULongLong - \o QVariant::UInt to Double - \o QVariant::String to String - \o QVariant::StringList - \o QVariant::VariantList to Array - \o QVariant::VariantMap to Object + \li QVariant::Bool to Bool + \li QVariant::Int + \li QVariant::Double + \li QVariant::LongLong + \li QVariant::ULongLong + \li QVariant::UInt to Double + \li QVariant::String to String + \li QVariant::StringList + \li QVariant::VariantList to Array + \li QVariant::VariantMap to Object \endlist For all other QVariant types a conversion to a QString will be attempted. If the returned string diff --git a/src/corelib/kernel/qabstracteventdispatcher.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp index 3075eab753..b98f3f4a30 100644 --- a/src/corelib/kernel/qabstracteventdispatcher.cpp +++ b/src/corelib/kernel/qabstracteventdispatcher.cpp @@ -167,7 +167,7 @@ QAbstractEventDispatcher::~QAbstractEventDispatcher() event dispatcher exists for the specified thread, this function returns 0. - \bold{Note:} If Qt is built without thread support, the \a thread + \b{Note:} If Qt is built without thread support, the \a thread argument is ignored. */ QAbstractEventDispatcher *QAbstractEventDispatcher::instance(QThread *thread) @@ -192,10 +192,10 @@ QAbstractEventDispatcher *QAbstractEventDispatcher::instance(QThread *thread) \list - \i If events are available, this function returns after processing + \li If events are available, this function returns after processing them. - \i If no events are available, this function will wait until more + \li If no events are available, this function will wait until more are available and return after processing newly available events. \endlist @@ -204,7 +204,7 @@ QAbstractEventDispatcher *QAbstractEventDispatcher::instance(QThread *thread) and no events are available, this function will return immediately. - \bold{Note:} This function does not process events continuously; it + \b{Note:} This function does not process events continuously; it returns after all available events are processed. \sa hasPendingEvents() @@ -349,17 +349,17 @@ void QAbstractEventDispatcher::closingDown() \table \header - \o Platform - \o type + \li Platform + \li type \row - \o Windows - \o MSG + \li Windows + \li MSG \row - \o X11 - \o XEvent + \li X11 + \li XEvent \row - \o Mac - \o NSEvent + \li Mac + \li NSEvent \endtable diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 2d49b271ce..515732bc68 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -715,13 +715,13 @@ bool QCoreApplication::notifyInternal(QObject *receiver, QEvent *event) reimplementing this virtual function is just one of them. All five approaches are listed below: \list 1 - \i Reimplementing paintEvent(), mousePressEvent() and so + \li Reimplementing paintEvent(), mousePressEvent() and so on. This is the commonest, easiest and least powerful way. - \i Reimplementing this function. This is very powerful, providing + \li Reimplementing this function. This is very powerful, providing complete control; but only one subclass can be active at a time. - \i Installing an event filter on QCoreApplication::instance(). Such + \li Installing an event filter on QCoreApplication::instance(). Such an event filter is able to process all events for all widgets, so it's just as powerful as reimplementing notify(); furthermore, it's possible to have more than one application-global event filter. @@ -730,11 +730,11 @@ bool QCoreApplication::notifyInternal(QObject *receiver, QEvent *event) event filters are only called for objects that live in the main thread. - \i Reimplementing QObject::event() (as QWidget does). If you do + \li Reimplementing QObject::event() (as QWidget does). If you do this you get Tab key presses, and you get to see the events before any widget-specific event filters. - \i Installing an event filter on the object. Such an event filter gets all + \li Installing an event filter on the object. Such an event filter gets all the events, including Tab and Shift+Tab key press events, as long as they do not change the focus widget. \endlist diff --git a/src/corelib/kernel/qeventloop.cpp b/src/corelib/kernel/qeventloop.cpp index dfdd178c35..58e2c5cd2f 100644 --- a/src/corelib/kernel/qeventloop.cpp +++ b/src/corelib/kernel/qeventloop.cpp @@ -222,11 +222,11 @@ int QEventLoop::exec(ProcessEventsFlags flags) operation and want to show its progress without allowing user input, i.e. by using the \l ExcludeUserInputEvents flag. - \bold{Notes:} + \b{Notes:} \list - \o This function does not process events continuously; it + \li This function does not process events continuously; it returns after all available events are processed. - \o Specifying the \l WaitForMoreEvents flag makes no sense + \li Specifying the \l WaitForMoreEvents flag makes no sense and will be ignored. \endlist */ diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index d53ba707f7..f962fb7831 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -86,16 +86,16 @@ QT_BEGIN_NAMESPACE The functions you are most likely to find useful are these: \list - \o className() returns the name of a class. - \o superClass() returns the superclass's meta-object. - \o method() and methodCount() provide information + \li className() returns the name of a class. + \li superClass() returns the superclass's meta-object. + \li method() and methodCount() provide information about a class's meta-methods (signals, slots and other \l{Q_INVOKABLE}{invokable} member functions). - \o enumerator() and enumeratorCount() and provide information about + \li enumerator() and enumeratorCount() and provide information about a class's enumerators. - \o propertyCount() and property() provide information about a + \li propertyCount() and property() provide information about a class's properties. - \o constructor() and constructorCount() provide information + \li constructor() and constructorCount() provide information about a class's meta-constructors. \endlist @@ -1051,18 +1051,18 @@ enum { MaximumParamCount = 11 }; // up to 10 arguments + 1 return value depending on \a type: \list - \o If \a type is Qt::DirectConnection, the member will be invoked immediately. + \li If \a type is Qt::DirectConnection, the member will be invoked immediately. - \o If \a type is Qt::QueuedConnection, + \li If \a type is Qt::QueuedConnection, a QEvent will be sent and the member is invoked as soon as the application enters the main event loop. - \o If \a type is Qt::BlockingQueuedConnection, the method will be invoked in + \li If \a type is Qt::BlockingQueuedConnection, the method will be invoked in the same way as for Qt::QueuedConnection, except that the current thread will block until the event is delivered. Using this connection type to communicate between objects in the same thread will lead to deadlocks. - \o If \a type is Qt::AutoConnection, the member is invoked + \li If \a type is Qt::AutoConnection, the member is invoked synchronously if \a obj lives in the same thread as the caller; otherwise it will invoke the member asynchronously. \endlist @@ -1456,13 +1456,13 @@ QMetaMethod::MethodType QMetaMethod::methodType() const \a connectionType: \list - \o If \a connectionType is Qt::DirectConnection, the member will be invoked immediately. + \li If \a connectionType is Qt::DirectConnection, the member will be invoked immediately. - \o If \a connectionType is Qt::QueuedConnection, + \li If \a connectionType is Qt::QueuedConnection, a QEvent will be posted and the member is invoked as soon as the application enters the main event loop. - \o If \a connectionType is Qt::AutoConnection, the member is invoked + \li If \a connectionType is Qt::AutoConnection, the member is invoked synchronously if \a object lives in the same thread as the caller; otherwise it will invoke the member asynchronously. \endlist diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp index cfe985da26..3a3464e43e 100644 --- a/src/corelib/kernel/qmimedata.cpp +++ b/src/corelib/kernel/qmimedata.cpp @@ -246,12 +246,12 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty functions to access the data: \table - \header \o Tester \o Getter \o Setter \o MIME Types - \row \o hasText() \o text() \o setText() \o \c text/plain - \row \o hasHtml() \o html() \o setHtml() \o \c text/html - \row \o hasUrls() \o urls() \o setUrls() \o \c text/uri-list - \row \o hasImage() \o imageData() \o setImageData() \o \c image/ * - \row \o hasColor() \o colorData() \o setColorData() \o \c application/x-color + \header \li Tester \li Getter \li Setter \li MIME Types + \row \li hasText() \li text() \li setText() \li \c text/plain + \row \li hasHtml() \li html() \li setHtml() \li \c text/html + \row \li hasUrls() \li urls() \li setUrls() \li \c text/uri-list + \row \li hasImage() \li imageData() \li setImageData() \li \c image/ * + \row \li hasColor() \li colorData() \li setColorData() \li \c application/x-color \endtable For example, if your write a widget that accepts URL drags, you @@ -263,15 +263,15 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty object: \list 1 - \o Custom data can be stored directly in a QMimeData object as a + \li Custom data can be stored directly in a QMimeData object as a QByteArray using setData(). For example: \snippet doc/src/snippets/code/src_corelib_kernel_qmimedata.cpp 1 - \o We can subclass QMimeData and reimplement hasFormat(), + \li We can subclass QMimeData and reimplement hasFormat(), formats(), and retrieveData(). - \o If the drag and drop operation occurs within a single + \li If the drag and drop operation occurs within a single application, we can subclass QMimeData and add extra data in it, and use a qobject_cast() in the receiver's drop event handler. For example: diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 8fa5dcdcff..530ddb3f13 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1805,7 +1805,7 @@ void QObject::removeEventFilter(QObject *obj) deleted, the control must return to the event loop from which deleteLater() was called. - \bold{Note:} It is safe to call this function more than once; when the + \b{Note:} It is safe to call this function more than once; when the first deferred deletion event is delivered, any pending events for the object are removed from the event queue. @@ -2123,9 +2123,9 @@ int QObject::receivers(const char *signal) const member in the specified class. \list - \o If member.mobj is 0 then both signalIndex and methodIndex are set to -1. + \li If member.mobj is 0 then both signalIndex and methodIndex are set to -1. - \o If specified member is not a member of obj instance class (or one of + \li If specified member is not a member of obj instance class (or one of its parent classes) then both signalIndex and methodIndex are set to -1. \endlist @@ -2505,7 +2505,7 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho disconnect() is typically used in three ways, as the following examples demonstrate. \list 1 - \i Disconnect everything connected to an object's signals: + \li Disconnect everything connected to an object's signals: \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 26 @@ -2513,7 +2513,7 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 27 - \i Disconnect everything connected to a specific signal: + \li Disconnect everything connected to a specific signal: \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 28 @@ -2521,7 +2521,7 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 29 - \i Disconnect a specific receiver: + \li Disconnect a specific receiver: \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 30 @@ -2663,11 +2663,11 @@ bool QObject::disconnect(const QObject *sender, const char *signal, if: \list 1 - \i \a signal is not a member of sender class or one of its parent classes. + \li \a signal is not a member of sender class or one of its parent classes. - \i \a method is not a member of receiver class or one of its parent classes. + \li \a method is not a member of receiver class or one of its parent classes. - \i \a signal instance represents not a signal. + \li \a signal instance represents not a signal. \endlist @@ -3339,7 +3339,7 @@ int QObjectPrivate::signalIndex(const char *signalName) const Changing the value of a dynamic property causes a QDynamicPropertyChangeEvent to be sent to the object. - \bold{Note:} Dynamic properties starting with "_q_" are reserved for internal + \b{Note:} Dynamic properties starting with "_q_" are reserved for internal purposes. \sa property(), metaObject(), dynamicPropertyNames() @@ -4091,19 +4091,19 @@ bool QObject::disconnect(const QMetaObject::Connection &connection) disconnect() is typically used in three ways, as the following examples demonstrate. \list 1 - \i Disconnect everything connected to an object's signals: + \li Disconnect everything connected to an object's signals: \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 26 - \i Disconnect everything connected to a specific signal: + \li Disconnect everything connected to a specific signal: \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 47 - \i Disconnect a specific receiver: + \li Disconnect a specific receiver: \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 30 - \i Disconnect a connection from one specific signal to a specific slot: + \li Disconnect a connection from one specific signal to a specific slot: \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 48 diff --git a/src/corelib/kernel/qpointer.cpp b/src/corelib/kernel/qpointer.cpp index 936a933d2d..b983bef5fe 100644 --- a/src/corelib/kernel/qpointer.cpp +++ b/src/corelib/kernel/qpointer.cpp @@ -61,13 +61,13 @@ \list - \i When using QPointer on a QWidget (or a subclass of QWidget), previously + \li When using QPointer on a QWidget (or a subclass of QWidget), previously the QPointer would be cleared by the QWidget destructor. Now, the QPointer is cleared by the QObject destructor (since this is when QWeakPointers are cleared). Any QPointers tracking a widget will \b NOT be cleared before the QWidget destructor destroys the children for the widget being tracked. - \i When constructing a QSharedPointer to take ownership of an object after a + \li When constructing a QSharedPointer to take ownership of an object after a QPointer is already tracking the object. Previously, the shared pointer construction would not be affected by the QPointer, but now that QPointer is implemented using QWeakPoiner, constructing the QSharedPointer will diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp index 640dfc0f94..d8578a8059 100644 --- a/src/corelib/kernel/qsharedmemory.cpp +++ b/src/corelib/kernel/qsharedmemory.cpp @@ -100,13 +100,13 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key, \list - \o Windows: QSharedMemory does not "own" the shared memory segment. + \li Windows: QSharedMemory does not "own" the shared memory segment. When all threads or processes that have an instance of QSharedMemory attached to a particular shared memory segment have either destroyed their instance of QSharedMemory or exited, the Windows kernel releases the shared memory segment automatically. - \o Unix: QSharedMemory "owns" the shared memory segment. When the + \li Unix: QSharedMemory "owns" the shared memory segment. When the last thread or process that has an instance of QSharedMemory attached to a particular shared memory segment detaches from the segment by destroying its instance of QSharedMemory, the Unix kernel @@ -114,7 +114,7 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key, process crashes without running the QSharedMemory destructor, the shared memory segment survives the crash. - \o HP-UX: Only one attach to a shared memory segment is allowed per + \li HP-UX: Only one attach to a shared memory segment is allowed per process. This means that QSharedMemory should not be used across multiple threads in the same process in HP-UX. diff --git a/src/corelib/kernel/qsocketnotifier.cpp b/src/corelib/kernel/qsocketnotifier.cpp index d7689bb7b1..0a2a66b6b2 100644 --- a/src/corelib/kernel/qsocketnotifier.cpp +++ b/src/corelib/kernel/qsocketnotifier.cpp @@ -111,9 +111,9 @@ QT_BEGIN_NAMESPACE follow these steps when you receive a notification: \list 1 - \o Disable the notifier. - \o Read data from the socket. - \o Re-enable the notifier if you are interested in more data (such as after + \li Disable the notifier. + \li Read data from the socket. + \li Re-enable the notifier if you are interested in more data (such as after having written a new command to a remote server). \endlist @@ -121,12 +121,12 @@ QT_BEGIN_NAMESPACE follow these steps when you receive a notification: \list 1 - \o Disable the notifier. - \o Write as much data as you can (before \c EWOULDBLOCK is returned). - \o Re-enable notifier if you have more data to write. + \li Disable the notifier. + \li Write as much data as you can (before \c EWOULDBLOCK is returned). + \li Re-enable notifier if you have more data to write. \endlist - \bold{Further information:} + \b{Further information:} On Windows, Qt always disables the notifier after getting a notification, and only re-enables it if more data is expected. For example, if data is read from the socket and it can be used to read more, or if reading or @@ -162,7 +162,7 @@ QT_BEGIN_NAMESPACE It is generally advisable to explicitly enable or disable the socket notifier, especially for write notifiers. - \bold{Note for Windows users:} The socket passed to QSocketNotifier + \b{Note for Windows users:} The socket passed to QSocketNotifier will become non-blocking, even if it was created as a blocking socket. \sa setEnabled(), isEnabled() diff --git a/src/corelib/kernel/qsystemsemaphore.cpp b/src/corelib/kernel/qsystemsemaphore.cpp index d0a67834dd..0558f3cb59 100644 --- a/src/corelib/kernel/qsystemsemaphore.cpp +++ b/src/corelib/kernel/qsystemsemaphore.cpp @@ -90,16 +90,16 @@ QT_BEGIN_NAMESPACE When using this class, be aware of the following platform differences: - \bold{Windows:} QSystemSemaphore does not own its underlying system + \b{Windows:} QSystemSemaphore does not own its underlying system semaphore. Windows owns it. This means that when all instances of QSystemSemaphore for a particular key have been destroyed, either by having their destructors called, or because one or more processes crash, Windows removes the underlying system semaphore. - \bold{Unix:} + \b{Unix:} \list - \o QSystemSemaphore owns the underlying system semaphore + \li QSystemSemaphore owns the underlying system semaphore in Unix systems. This means that the last process having an instance of QSystemSemaphore for a particular key must remove the underlying system semaphore in its destructor. If the last process crashes @@ -117,7 +117,7 @@ QT_BEGIN_NAMESPACE {QSystemSemaphore::} {Create}, which will force Unix to reset the resource count in the underlying system semaphore. - \o When a process using QSystemSemaphore terminates for + \li When a process using QSystemSemaphore terminates for any reason, Unix automatically reverses the effect of all acquire operations that were not released. Thus if the process acquires a resource and then exits without releasing it, Unix will release that diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index a11bcb26c9..dad3318870 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -279,9 +279,9 @@ public: up to three parameters: \list - \o The \e context - usually the class name for the tr() caller. - \o The \e {source text} - usually the argument to tr(). - \o The \e disambiguation - an optional string that helps disambiguate + \li The \e context - usually the class name for the tr() caller. + \li The \e {source text} - usually the argument to tr(). + \li The \e disambiguation - an optional string that helps disambiguate different uses of the same text in the same context. \endlist @@ -361,12 +361,12 @@ QTranslator::~QTranslator() in the following order: \list 1 - \o File name without \a suffix appended. - \o File name with text after a character in \a search_delimiters + \li File name without \a suffix appended. + \li File name with text after a character in \a search_delimiters stripped ("_." is the default for \a search_delimiters if it is an empty string) and \a suffix. - \o File name stripped without \a suffix appended. - \o File name stripped further, etc. + \li File name stripped without \a suffix appended. + \li File name stripped further, etc. \endlist For example, an application running in the fr_CA locale @@ -375,12 +375,12 @@ QTranslator::~QTranslator() readable file from this list: \list 1 - \o \c /opt/foolib/foo.fr_ca.qm - \o \c /opt/foolib/foo.fr_ca - \o \c /opt/foolib/foo.fr.qm - \o \c /opt/foolib/foo.fr - \o \c /opt/foolib/foo.qm - \o \c /opt/foolib/foo + \li \c /opt/foolib/foo.fr_ca.qm + \li \c /opt/foolib/foo.fr_ca + \li \c /opt/foolib/foo.fr.qm + \li \c /opt/foolib/foo.fr + \li \c /opt/foolib/foo.qm + \li \c /opt/foolib/foo \endlist */ @@ -599,10 +599,10 @@ static QString find_translation(const QLocale & locale, in the following order: \list 1 - \o File name without \a suffix appended. - \o File name with ui language part after a "_" character stripped and \a suffix. - \o File name with ui language part stripped without \a suffix appended. - \o File name with ui language part stripped further, etc. + \li File name without \a suffix appended. + \li File name with ui language part after a "_" character stripped and \a suffix. + \li File name with ui language part stripped without \a suffix appended. + \li File name with ui language part stripped further, etc. \endlist For example, an application running in the locale with the following @@ -612,17 +612,17 @@ static QString find_translation(const QLocale & locale, open the first existing readable file from this list: \list 1 - \o \c /opt/foolib/foo.es.qm - \o \c /opt/foolib/foo.es - \o \c /opt/foolib/foo.fr_CA.qm - \o \c /opt/foolib/foo.fr_CA - \o \c /opt/foolib/foo.de.qm - \o \c /opt/foolib/foo.de - \o \c /opt/foolib/foo.fr.qm - \o \c /opt/foolib/foo.fr - \o \c /opt/foolib/foo.qm - \o \c /opt/foolib/foo. - \o \c /opt/foolib/foo + \li \c /opt/foolib/foo.es.qm + \li \c /opt/foolib/foo.es + \li \c /opt/foolib/foo.fr_CA.qm + \li \c /opt/foolib/foo.fr_CA + \li \c /opt/foolib/foo.de.qm + \li \c /opt/foolib/foo.de + \li \c /opt/foolib/foo.fr.qm + \li \c /opt/foolib/foo.fr + \li \c /opt/foolib/foo.qm + \li \c /opt/foolib/foo. + \li \c /opt/foolib/foo \endlist On operating systems where file system is case sensitive, QTranslator also diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 1c18883fde..4f3e4f8b4e 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -2174,7 +2174,7 @@ inline T qNumVariantToHelper(const QVariant::Private &d, If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be converted to an int; otherwise \c{*}\a{ok} is set to false. - \bold{Warning:} If the value is convertible to a \l LongLong but is too + \b{Warning:} If the value is convertible to a \l LongLong but is too large to be represented in an int, the resulting arithmetic overflow will not be reflected in \a ok. A simple workaround is to use QString::toInt(). Fixing this bug has been postponed to Qt 5 in order to avoid breaking existing code. @@ -2194,7 +2194,7 @@ int QVariant::toInt(bool *ok) const If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be converted to an unsigned int; otherwise \c{*}\a{ok} is set to false. - \bold{Warning:} If the value is convertible to a \l ULongLong but is too + \b{Warning:} If the value is convertible to a \l ULongLong but is too large to be represented in an unsigned int, the resulting arithmetic overflow will not be reflected in \a ok. A simple workaround is to use QString::toUInt(). Fixing this bug has been postponed to Qt 5 in order to avoid breaking existing code. @@ -2411,28 +2411,28 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = The following casts are done automatically: \table - \header \o Type \o Automatically Cast To - \row \o \l Bool \o \l Char, \l Double, \l Int, \l LongLong, \l String, \l UInt, \l ULongLong - \row \o \l ByteArray \o \l Double, \l Int, \l LongLong, \l String, \l UInt, \l ULongLong - \row \o \l Char \o \l Bool, \l Int, \l UInt, \l LongLong, \l ULongLong - \row \o \l Color \o \l String - \row \o \l Date \o \l DateTime, \l String - \row \o \l DateTime \o \l Date, \l String, \l Time - \row \o \l Double \o \l Bool, \l Int, \l LongLong, \l String, \l UInt, \l ULongLong - \row \o \l Font \o \l String - \row \o \l Int \o \l Bool, \l Char, \l Double, \l LongLong, \l String, \l UInt, \l ULongLong - \row \o \l KeySequence \o \l Int, \l String - \row \o \l List \o \l StringList (if the list's items can be converted to strings) - \row \o \l LongLong \o \l Bool, \l ByteArray, \l Char, \l Double, \l Int, \l String, \l UInt, \l ULongLong - \row \o \l Point \o PointF - \row \o \l Rect \o RectF - \row \o \l String \o \l Bool, \l ByteArray, \l Char, \l Color, \l Date, \l DateTime, \l Double, + \header \li Type \li Automatically Cast To + \row \li \l Bool \li \l Char, \l Double, \l Int, \l LongLong, \l String, \l UInt, \l ULongLong + \row \li \l ByteArray \li \l Double, \l Int, \l LongLong, \l String, \l UInt, \l ULongLong + \row \li \l Char \li \l Bool, \l Int, \l UInt, \l LongLong, \l ULongLong + \row \li \l Color \li \l String + \row \li \l Date \li \l DateTime, \l String + \row \li \l DateTime \li \l Date, \l String, \l Time + \row \li \l Double \li \l Bool, \l Int, \l LongLong, \l String, \l UInt, \l ULongLong + \row \li \l Font \li \l String + \row \li \l Int \li \l Bool, \l Char, \l Double, \l LongLong, \l String, \l UInt, \l ULongLong + \row \li \l KeySequence \li \l Int, \l String + \row \li \l List \li \l StringList (if the list's items can be converted to strings) + \row \li \l LongLong \li \l Bool, \l ByteArray, \l Char, \l Double, \l Int, \l String, \l UInt, \l ULongLong + \row \li \l Point \li PointF + \row \li \l Rect \li RectF + \row \li \l String \li \l Bool, \l ByteArray, \l Char, \l Color, \l Date, \l DateTime, \l Double, \l Font, \l Int, \l KeySequence, \l LongLong, \l StringList, \l Time, \l UInt, \l ULongLong - \row \o \l StringList \o \l List, \l String (if the list contains exactly one item) - \row \o \l Time \o \l String - \row \o \l UInt \o \l Bool, \l Char, \l Double, \l Int, \l LongLong, \l String, \l ULongLong - \row \o \l ULongLong \o \l Bool, \l Char, \l Double, \l Int, \l LongLong, \l String, \l UInt + \row \li \l StringList \li \l List, \l String (if the list contains exactly one item) + \row \li \l Time \li \l String + \row \li \l UInt \li \l Bool, \l Char, \l Double, \l Int, \l LongLong, \l String, \l ULongLong + \row \li \l ULongLong \li \l Bool, \l Char, \l Double, \l Int, \l LongLong, \l String, \l UInt \endtable \sa convert() diff --git a/src/corelib/kernel/qwineventnotifier.cpp b/src/corelib/kernel/qwineventnotifier.cpp index 11a2dc83f5..58ca046d9d 100644 --- a/src/corelib/kernel/qwineventnotifier.cpp +++ b/src/corelib/kernel/qwineventnotifier.cpp @@ -75,7 +75,7 @@ QT_BEGIN_NAMESPACE Finally, you can use the setHandle() function to register a new event object, and the handle() function to retrieve the event handle. - \bold{Further information:} + \b{Further information:} Although the class is called QWinEventNotifier, it can be used for certain other objects which are so-called synchronization objects, such as Processes, Threads, Waitable timers. @@ -140,7 +140,7 @@ QWinEventNotifier::~QWinEventNotifier() Register the HANDLE \a hEvent. The old HANDLE will be automatically unregistered. - \bold Note: The notifier will be disabled as a side effect and needs + \b Note: The notifier will be disabled as a side effect and needs to be re-enabled. \sa handle(), setEnabled() diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index b171577184..216e6e1e7c 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -596,12 +596,12 @@ bool QLibraryPrivate::loadPlugin() library; otherwise returns false. \table - \header \i Platform \i Valid suffixes - \row \i Windows \i \c .dll, \c .DLL - \row \i Unix/Linux \i \c .so - \row \i AIX \i \c .a - \row \i HP-UX \i \c .sl, \c .so (HP-UXi) - \row \i Mac OS X \i \c .dylib, \c .bundle, \c .so + \header \li Platform \li Valid suffixes + \row \li Windows \li \c .dll, \c .DLL + \row \li Unix/Linux \li \c .so + \row \li AIX \li \c .a + \row \li HP-UX \li \c .sl, \c .so (HP-UXi) + \row \li Mac OS X \li \c .dylib, \c .bundle, \c .so \endtable Trailing versioning numbers on Unix are ignored. diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index d652b251f1..f198f108da 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -66,9 +66,9 @@ QT_BEGIN_NAMESPACE using QLibrary: \list - \o QPluginLoader checks that a plugin is linked against the same + \li QPluginLoader checks that a plugin is linked against the same version of Qt as the application. - \o QPluginLoader provides direct access to a root component object + \li QPluginLoader provides direct access to a root component object (instance()), instead of forcing you to resolve a C function manually. \endlist diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 3d7988a8fc..26032323e0 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -190,34 +190,34 @@ static QUuid createFromName(const QUuid &ns, const QByteArray &baseData, QCrypto \table \header - \o msb0 - \o msb1 - \o msb2 - \o Variant + \li msb0 + \li msb1 + \li msb2 + \li Variant \row - \o 0 - \o x - \o x - \o NCS (Network Computing System) + \li 0 + \li x + \li x + \li NCS (Network Computing System) \row - \o 1 - \o 0 - \o x - \o DCE (Distributed Computing Environment) + \li 1 + \li 0 + \li x + \li DCE (Distributed Computing Environment) \row - \o 1 - \o 1 - \o 0 - \o Microsoft (GUID) + \li 1 + \li 1 + \li 0 + \li Microsoft (GUID) \row - \o 1 - \o 1 - \o 1 - \o Reserved for future expansion + \li 1 + \li 1 + \li 1 + \li Reserved for future expansion \endtable @@ -234,46 +234,46 @@ static QUuid createFromName(const QUuid &ns, const QByteArray &baseData, QCrypto \table \header - \o msb0 - \o msb1 - \o msb2 - \o msb3 - \o Version + \li msb0 + \li msb1 + \li msb2 + \li msb3 + \li Version \row - \o 0 - \o 0 - \o 0 - \o 1 - \o Time + \li 0 + \li 0 + \li 0 + \li 1 + \li Time \row - \o 0 - \o 0 - \o 1 - \o 0 - \o Embedded POSIX + \li 0 + \li 0 + \li 1 + \li 0 + \li Embedded POSIX \row - \o 0 - \o 0 - \o 1 - \o 1 - \o Md5(Name) + \li 0 + \li 0 + \li 1 + \li 1 + \li Md5(Name) \row - \o 0 - \o 1 - \o 0 - \o 0 - \o Random + \li 0 + \li 1 + \li 0 + \li 0 + \li Random \row - \o 0 - \o 1 - \o 0 - \o 1 - \o Sha1 + \li 0 + \li 1 + \li 0 + \li 1 + \li Sha1 \endtable @@ -516,28 +516,28 @@ QUuid QUuid::fromRfc4122(const QByteArray &bytes) \table \header - \o Field # - \o Source + \li Field # + \li Source \row - \o 1 - \o data1 + \li 1 + \li data1 \row - \o 2 - \o data2 + \li 2 + \li data2 \row - \o 3 - \o data3 + \li 3 + \li data3 \row - \o 4 - \o data4[0] .. data4[1] + \li 4 + \li data4[0] .. data4[1] \row - \o 5 - \o data4[2] .. data4[7] + \li 5 + \li data4[2] .. data4[7] \endtable */ @@ -560,28 +560,28 @@ QString QUuid::toString() const \table \header - \o Field # - \o Source + \li Field # + \li Source \row - \o 1 - \o data1 + \li 1 + \li data1 \row - \o 2 - \o data2 + \li 2 + \li data2 \row - \o 3 - \o data3 + \li 3 + \li data3 \row - \o 4 - \o data4[0] .. data4[1] + \li 4 + \li data4[0] .. data4[1] \row - \o 5 - \o data4[2] .. data4[7] + \li 5 + \li data4[2] .. data4[7] \endtable @@ -607,24 +607,24 @@ QByteArray QUuid::toByteArray() const \table \header - \o Field # - \o Source + \li Field # + \li Source \row - \o 1 - \o data1 + \li 1 + \li data1 \row - \o 2 - \o data2 + \li 2 + \li data2 \row - \o 3 - \o data3 + \li 3 + \li data3 \row - \o 4 - \o data4[0] .. data4[7] + \li 4 + \li data4[0] .. data4[7] \endtable diff --git a/src/corelib/thread/qatomic.cpp b/src/corelib/thread/qatomic.cpp index 5443d6e1b6..2e3029f3fa 100644 --- a/src/corelib/thread/qatomic.cpp +++ b/src/corelib/thread/qatomic.cpp @@ -83,16 +83,16 @@ \list - \o Relaxed - memory ordering is unspecified, leaving the compiler + \li Relaxed - memory ordering is unspecified, leaving the compiler and processor to freely reorder memory accesses. - \o Acquire - memory access following the atomic operation (in + \li Acquire - memory access following the atomic operation (in program order) may not be re-ordered before the atomic operation. - \o Release - memory access before the atomic operation (in program + \li Release - memory access before the atomic operation (in program order) may not be re-ordered after the atomic operation. - \o Ordered - the same Acquire and Release semantics combined. + \li Ordered - the same Acquire and Release semantics combined. \endlist @@ -180,25 +180,25 @@ \list - \o Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE - \o Q_ATOMIC_INT_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE - \o Q_ATOMIC_INT_REFERENCE_COUNTING_IS_NOT_NATIVE - \o Q_ATOMIC_INT_REFERENCE_COUNTING_IS_WAIT_FREE + \li Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE + \li Q_ATOMIC_INT_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE + \li Q_ATOMIC_INT_REFERENCE_COUNTING_IS_NOT_NATIVE + \li Q_ATOMIC_INT_REFERENCE_COUNTING_IS_WAIT_FREE - \o Q_ATOMIC_INT_TEST_AND_SET_IS_ALWAYS_NATIVE - \o Q_ATOMIC_INT_TEST_AND_SET_IS_SOMETIMES_NATIVE - \o Q_ATOMIC_INT_TEST_AND_SET_IS_NOT_NATIVE - \o Q_ATOMIC_INT_TEST_AND_SET_IS_WAIT_FREE + \li Q_ATOMIC_INT_TEST_AND_SET_IS_ALWAYS_NATIVE + \li Q_ATOMIC_INT_TEST_AND_SET_IS_SOMETIMES_NATIVE + \li Q_ATOMIC_INT_TEST_AND_SET_IS_NOT_NATIVE + \li Q_ATOMIC_INT_TEST_AND_SET_IS_WAIT_FREE - \o Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE - \o Q_ATOMIC_INT_FETCH_AND_STORE_IS_SOMETIMES_NATIVE - \o Q_ATOMIC_INT_FETCH_AND_STORE_IS_NOT_NATIVE - \o Q_ATOMIC_INT_FETCH_AND_STORE_IS_WAIT_FREE + \li Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE + \li Q_ATOMIC_INT_FETCH_AND_STORE_IS_SOMETIMES_NATIVE + \li Q_ATOMIC_INT_FETCH_AND_STORE_IS_NOT_NATIVE + \li Q_ATOMIC_INT_FETCH_AND_STORE_IS_WAIT_FREE - \o Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE - \o Q_ATOMIC_INT_FETCH_AND_ADD_IS_SOMETIMES_NATIVE - \o Q_ATOMIC_INT_FETCH_AND_ADD_IS_NOT_NATIVE - \o Q_ATOMIC_INT_FETCH_AND_ADD_IS_WAIT_FREE + \li Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE + \li Q_ATOMIC_INT_FETCH_AND_ADD_IS_SOMETIMES_NATIVE + \li Q_ATOMIC_INT_FETCH_AND_ADD_IS_NOT_NATIVE + \li Q_ATOMIC_INT_FETCH_AND_ADD_IS_WAIT_FREE \endlist @@ -658,16 +658,16 @@ \list - \o Relaxed - memory ordering is unspecified, leaving the compiler + \li Relaxed - memory ordering is unspecified, leaving the compiler and processor to freely reorder memory accesses. - \o Acquire - memory access following the atomic operation (in + \li Acquire - memory access following the atomic operation (in program order) may not be re-ordered before the atomic operation. - \o Release - memory access before the atomic operation (in program + \li Release - memory access before the atomic operation (in program order) may not be re-ordered after the atomic operation. - \o Ordered - the same Acquire and Release semantics combined. + \li Ordered - the same Acquire and Release semantics combined. \endlist @@ -753,20 +753,20 @@ \list - \o Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE - \o Q_ATOMIC_POINTER_TEST_AND_SET_IS_SOMETIMES_NATIVE - \o Q_ATOMIC_POINTER_TEST_AND_SET_IS_NOT_NATIVE - \o Q_ATOMIC_POINTER_TEST_AND_SET_IS_WAIT_FREE + \li Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE + \li Q_ATOMIC_POINTER_TEST_AND_SET_IS_SOMETIMES_NATIVE + \li Q_ATOMIC_POINTER_TEST_AND_SET_IS_NOT_NATIVE + \li Q_ATOMIC_POINTER_TEST_AND_SET_IS_WAIT_FREE - \o Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE - \o Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_SOMETIMES_NATIVE - \o Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_NOT_NATIVE - \o Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_WAIT_FREE + \li Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE + \li Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_SOMETIMES_NATIVE + \li Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_NOT_NATIVE + \li Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_WAIT_FREE - \o Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE - \o Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_SOMETIMES_NATIVE - \o Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_NOT_NATIVE - \o Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_WAIT_FREE + \li Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE + \li Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_SOMETIMES_NATIVE + \li Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_NOT_NATIVE + \li Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_WAIT_FREE \endlist diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp index 52f5a1d699..08952eeaa3 100644 --- a/src/corelib/thread/qsemaphore.cpp +++ b/src/corelib/thread/qsemaphore.cpp @@ -66,10 +66,10 @@ QT_BEGIN_NAMESPACE release(): \list - \o acquire(\e{n}) tries to acquire \e n resources. If there aren't + \li acquire(\e{n}) tries to acquire \e n resources. If there aren't that many resources available, the call will block until this is the case. - \o release(\e{n}) releases \e n resources. + \li release(\e{n}) releases \e n resources. \endlist There's also a tryAcquire() function that returns immediately if diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index a071463178..64fd8776ce 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -658,11 +658,11 @@ QThread::Priority QThread::priority() const Blocks the thread until either of these conditions is met: \list - \o The thread associated with this QThread object has finished + \li The thread associated with this QThread object has finished execution (i.e. when it returns from \l{run()}). This function will return true if the thread has finished. It also returns true if the thread has not been started yet. - \o \a time milliseconds has elapsed. If \a time is ULONG_MAX (the + \li \a time milliseconds has elapsed. If \a time is ULONG_MAX (the default), then the wait will never timeout (the thread must return from \l{run()}). This function will return false if the wait timed out. diff --git a/src/corelib/thread/qthreadstorage.cpp b/src/corelib/thread/qthreadstorage.cpp index 1dfa3305bc..68db8fe261 100644 --- a/src/corelib/thread/qthreadstorage.cpp +++ b/src/corelib/thread/qthreadstorage.cpp @@ -246,11 +246,11 @@ void QThreadStorageData::finish(void **p) \list - \o The QThreadStorage destructor does not delete per-thread data. + \li The QThreadStorage destructor does not delete per-thread data. QThreadStorage only deletes per-thread data when the thread exits or when setLocalData() is called multiple times. - \o QThreadStorage can be used to store data for the \c main() + \li QThreadStorage can be used to store data for the \c main() thread. QThreadStorage deletes all data set for the \c main() thread when QApplication is destroyed, regardless of whether or not the \c main() thread has actually finished. diff --git a/src/corelib/thread/qwaitcondition.qdoc b/src/corelib/thread/qwaitcondition.qdoc index 7b861f8f7a..8c93bd167d 100644 --- a/src/corelib/thread/qwaitcondition.qdoc +++ b/src/corelib/thread/qwaitcondition.qdoc @@ -129,9 +129,9 @@ calling thread will block until either of these conditions is met: \list - \o Another thread signals it using wakeOne() or wakeAll(). This + \li Another thread signals it using wakeOne() or wakeAll(). This function will return true in this case. - \o \a time milliseconds has elapsed. If \a time is \c ULONG_MAX + \li \a time milliseconds has elapsed. If \a time is \c ULONG_MAX (the default), then the wait will never timeout (the event must be signalled). This function will return false if the wait timed out. @@ -157,9 +157,9 @@ calling thread will block until either of these conditions is met: \list - \o Another thread signals it using wakeOne() or wakeAll(). This + \li Another thread signals it using wakeOne() or wakeAll(). This function will return true in this case. - \o \a time milliseconds has elapsed. If \a time is \c ULONG_MAX + \li \a time milliseconds has elapsed. If \a time is \c ULONG_MAX (the default), then the wait will never timeout (the event must be signalled). This function will return false if the wait timed out. diff --git a/src/corelib/tools/qalgorithms.qdoc b/src/corelib/tools/qalgorithms.qdoc index a16ed8b3dc..5a4a278ad0 100644 --- a/src/corelib/tools/qalgorithms.qdoc +++ b/src/corelib/tools/qalgorithms.qdoc @@ -159,14 +159,14 @@ bidirectional iterator, and supports the following operations: \table - \row \i \c{i += n} \i advances iterator \c i by \c n positions - \row \i \c{i -= n} \i moves iterator \c i back by \c n positions - \row \i \c{i + n} or \c{n + i} \i returns the iterator for the item \c + \row \li \c{i += n} \li advances iterator \c i by \c n positions + \row \li \c{i -= n} \li moves iterator \c i back by \c n positions + \row \li \c{i + n} or \c{n + i} \li returns the iterator for the item \c n positions ahead of iterator \c i - \row \i \c{i - n} \i returns the iterator for the item \c n positions behind of iterator \c i - \row \i \c{i - j} \i returns the number of items between iterators \c i and \c j - \row \i \c{i[n]} \i same as \c{*(i + n)} - \row \i \c{i < j} \i returns true if iterator \c j comes after iterator \c i + \row \li \c{i - n} \li returns the iterator for the item \c n positions behind of iterator \c i + \row \li \c{i - j} \li returns the number of items between iterators \c i and \c j + \row \li \c{i[n]} \li same as \c{*(i + n)} + \row \li \c{i < j} \li returns true if iterator \c j comes after iterator \c i \endtable QList and QVector's non-const iterator types are random access iterators. diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index c74c61999d..445fe5cd81 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -505,7 +505,7 @@ QByteArray qCompress(const uchar* data, int nbytes, int compressionLevel) from this and any earlier Qt version, back to Qt 3.1 when this feature was added. - \bold{Note:} If you want to use this function to uncompress external + \b{Note:} If you want to use this function to uncompress external data that was compressed using zlib, you first need to prepend a four byte header to the byte array containing the data. The header must contain the expected length (in bytes) of the uncompressed data, @@ -3687,12 +3687,12 @@ QByteArray &QByteArray::setNum(qulonglong n, int base) The format \a f can be any of the following: \table - \header \i Format \i Meaning - \row \i \c e \i format as [-]9.9e[+|-]999 - \row \i \c E \i format as [-]9.9E[+|-]999 - \row \i \c f \i format as [-]9.9 - \row \i \c g \i use \c e or \c f format, whichever is the most concise - \row \i \c G \i use \c E or \c f format, whichever is the most concise + \header \li Format \li Meaning + \row \li \c e \li format as [-]9.9e[+|-]999 + \row \li \c E \li format as [-]9.9E[+|-]999 + \row \li \c f \li format as [-]9.9 + \row \li \c g \li use \c e or \c f format, whichever is the most concise + \row \li \c G \li use \c E or \c f format, whichever is the most concise \endtable With 'e', 'E', and 'f', \a prec is the number of digits after the @@ -3816,12 +3816,12 @@ QByteArray QByteArray::number(qulonglong n, int base) which is \c g by default, and can be any of the following: \table - \header \i Format \i Meaning - \row \i \c e \i format as [-]9.9e[+|-]999 - \row \i \c E \i format as [-]9.9E[+|-]999 - \row \i \c f \i format as [-]9.9 - \row \i \c g \i use \c e or \c f format, whichever is the most concise - \row \i \c G \i use \c E or \c f format, whichever is the most concise + \header \li Format \li Meaning + \row \li \c e \li format as [-]9.9e[+|-]999 + \row \li \c E \li format as [-]9.9E[+|-]999 + \row \li \c f \li format as [-]9.9 + \row \li \c g \li use \c e or \c f format, whichever is the most concise + \row \li \c G \li use \c E or \c f format, whichever is the most concise \endtable With 'e', 'E', and 'f', \a prec is the number of digits after the diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 70efb5db22..64ad3121d0 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -306,18 +306,18 @@ int QDate::year() const the following convention: \list - \i 1 = "January" - \i 2 = "February" - \i 3 = "March" - \i 4 = "April" - \i 5 = "May" - \i 6 = "June" - \i 7 = "July" - \i 8 = "August" - \i 9 = "September" - \i 10 = "October" - \i 11 = "November" - \i 12 = "December" + \li 1 = "January" + \li 2 = "February" + \li 3 = "March" + \li 4 = "April" + \li 5 = "May" + \li 6 = "June" + \li 7 = "July" + \li 8 = "August" + \li 9 = "September" + \li 10 = "October" + \li 11 = "November" + \li 12 = "December" \endlist Returns 0 if the date is invalid. @@ -521,18 +521,18 @@ int QDate::weekNumber(int *yearNumber) const The months are enumerated using the following convention: \list - \i 1 = "Jan" - \i 2 = "Feb" - \i 3 = "Mar" - \i 4 = "Apr" - \i 5 = "May" - \i 6 = "Jun" - \i 7 = "Jul" - \i 8 = "Aug" - \i 9 = "Sep" - \i 10 = "Oct" - \i 11 = "Nov" - \i 12 = "Dec" + \li 1 = "Jan" + \li 2 = "Feb" + \li 3 = "Mar" + \li 4 = "Apr" + \li 5 = "May" + \li 6 = "Jun" + \li 7 = "Jul" + \li 8 = "Aug" + \li 9 = "Sep" + \li 10 = "Oct" + \li 11 = "Nov" + \li 12 = "Dec" \endlist The month names will be localized according to the system's locale @@ -568,18 +568,18 @@ QString QDate::shortMonthName(int month, QDate::MonthNameType type) The months are enumerated using the following convention: \list - \i 1 = "January" - \i 2 = "February" - \i 3 = "March" - \i 4 = "April" - \i 5 = "May" - \i 6 = "June" - \i 7 = "July" - \i 8 = "August" - \i 9 = "September" - \i 10 = "October" - \i 11 = "November" - \i 12 = "December" + \li 1 = "January" + \li 2 = "February" + \li 3 = "March" + \li 4 = "April" + \li 5 = "May" + \li 6 = "June" + \li 7 = "July" + \li 8 = "August" + \li 9 = "September" + \li 10 = "October" + \li 11 = "November" + \li 12 = "December" \endlist The month names will be localized according to the system's locale @@ -615,13 +615,13 @@ QString QDate::longMonthName(int month, MonthNameType type) The days are enumerated using the following convention: \list - \i 1 = "Mon" - \i 2 = "Tue" - \i 3 = "Wed" - \i 4 = "Thu" - \i 5 = "Fri" - \i 6 = "Sat" - \i 7 = "Sun" + \li 1 = "Mon" + \li 2 = "Tue" + \li 3 = "Wed" + \li 4 = "Thu" + \li 5 = "Fri" + \li 6 = "Sat" + \li 7 = "Sun" \endlist The day names will be localized according to the system's locale @@ -657,13 +657,13 @@ QString QDate::shortDayName(int weekday, MonthNameType type) The days are enumerated using the following convention: \list - \i 1 = "Monday" - \i 2 = "Tuesday" - \i 3 = "Wednesday" - \i 4 = "Thursday" - \i 5 = "Friday" - \i 6 = "Saturday" - \i 7 = "Sunday" + \li 1 = "Monday" + \li 2 = "Tuesday" + \li 3 = "Wednesday" + \li 4 = "Thursday" + \li 5 = "Friday" + \li 6 = "Saturday" + \li 7 = "Sunday" \endlist The day names will be localized according to the system's locale @@ -781,25 +781,25 @@ QString QDate::toString(Qt::DateFormat f) const These expressions may be used: \table - \header \i Expression \i Output - \row \i d \i the day as number without a leading zero (1 to 31) - \row \i dd \i the day as number with a leading zero (01 to 31) - \row \i ddd - \i the abbreviated localized day name (e.g. 'Mon' to 'Sun'). + \header \li Expression \li Output + \row \li d \li the day as number without a leading zero (1 to 31) + \row \li dd \li the day as number with a leading zero (01 to 31) + \row \li ddd + \li the abbreviated localized day name (e.g. 'Mon' to 'Sun'). Uses QDate::shortDayName(). - \row \i dddd - \i the long localized day name (e.g. 'Monday' to 'Sunday'). + \row \li dddd + \li the long localized day name (e.g. 'Monday' to 'Sunday'). Uses QDate::longDayName(). - \row \i M \i the month as number without a leading zero (1 to 12) - \row \i MM \i the month as number with a leading zero (01 to 12) - \row \i MMM - \i the abbreviated localized month name (e.g. 'Jan' to 'Dec'). + \row \li M \li the month as number without a leading zero (1 to 12) + \row \li MM \li the month as number with a leading zero (01 to 12) + \row \li MMM + \li the abbreviated localized month name (e.g. 'Jan' to 'Dec'). Uses QDate::shortMonthName(). - \row \i MMMM - \i the long localized month name (e.g. 'January' to 'December'). + \row \li MMMM + \li the long localized month name (e.g. 'January' to 'December'). Uses QDate::longMonthName(). - \row \i yy \i the year as two digit number (00 to 99) - \row \i yyyy \i the year as four digit number. If the year is negative, + \row \li yy \li the year as two digit number (00 to 99) + \row \li yyyy \li the year as four digit number. If the year is negative, a minus sign is prepended in addition. \endtable @@ -812,10 +812,10 @@ QString QDate::toString(Qt::DateFormat f) const 1969): \table - \header \o Format \o Result - \row \o dd.MM.yyyy \o 20.07.1969 - \row \o ddd MMMM d yy \o Sun July 20 69 - \row \o 'The day is' dddd \o The day is Sunday + \header \li Format \li Result + \row \li dd.MM.yyyy \li 20.07.1969 + \row \li ddd MMMM d yy \li Sun July 20 69 + \row \li 'The day is' dddd \li The day is Sunday \endtable If the datetime is invalid, an empty string will be returned. @@ -1191,25 +1191,25 @@ QDate QDate::fromString(const QString& s, Qt::DateFormat f) These expressions may be used for the format: \table - \header \i Expression \i Output - \row \i d \i The day as a number without a leading zero (1 to 31) - \row \i dd \i The day as a number with a leading zero (01 to 31) - \row \i ddd - \i The abbreviated localized day name (e.g. 'Mon' to 'Sun'). + \header \li Expression \li Output + \row \li d \li The day as a number without a leading zero (1 to 31) + \row \li dd \li The day as a number with a leading zero (01 to 31) + \row \li ddd + \li The abbreviated localized day name (e.g. 'Mon' to 'Sun'). Uses QDate::shortDayName(). - \row \i dddd - \i The long localized day name (e.g. 'Monday' to 'Sunday'). + \row \li dddd + \li The long localized day name (e.g. 'Monday' to 'Sunday'). Uses QDate::longDayName(). - \row \i M \i The month as a number without a leading zero (1 to 12) - \row \i MM \i The month as a number with a leading zero (01 to 12) - \row \i MMM - \i The abbreviated localized month name (e.g. 'Jan' to 'Dec'). + \row \li M \li The month as a number without a leading zero (1 to 12) + \row \li MM \li The month as a number with a leading zero (01 to 12) + \row \li MMM + \li The abbreviated localized month name (e.g. 'Jan' to 'Dec'). Uses QDate::shortMonthName(). - \row \i MMMM - \i The long localized month name (e.g. 'January' to 'December'). + \row \li MMMM + \li The long localized month name (e.g. 'January' to 'December'). Uses QDate::longMonthName(). - \row \i yy \i The year as two digit number (00 to 99) - \row \i yyyy \i The year as four digit number. If the year is negative, + \row \li yy \li The year as two digit number (00 to 99) + \row \li yyyy \li The year as four digit number. If the year is negative, a minus sign is prepended in addition. \endtable @@ -1233,10 +1233,10 @@ QDate QDate::fromString(const QString& s, Qt::DateFormat f) defaults are used: \table - \header \i Field \i Default value - \row \i Year \i 1900 - \row \i Month \i 1 - \row \i Day \i 1 + \header \li Field \li Default value + \row \li Year \li 1900 + \row \li Month \li 1 + \row \li Day \li 1 \endtable The following examples demonstrate the default values: @@ -1543,26 +1543,26 @@ QString QTime::toString(Qt::DateFormat format) const These expressions may be used: \table - \header \i Expression \i Output - \row \i h - \i the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) - \row \i hh - \i the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) - \row \i H - \i the hour without a leading zero (0 to 23, even with AM/PM display) - \row \i HH - \i the hour with a leading zero (00 to 23, even with AM/PM display) - \row \i m \i the minute without a leading zero (0 to 59) - \row \i mm \i the minute with a leading zero (00 to 59) - \row \i s \i the second without a leading zero (0 to 59) - \row \i ss \i the second with a leading zero (00 to 59) - \row \i z \i the milliseconds without leading zeroes (0 to 999) - \row \i zzz \i the milliseconds with leading zeroes (000 to 999) - \row \i AP or A - \i use AM/PM display. \e AP will be replaced by either "AM" or "PM". - \row \i ap or a - \i use am/pm display. \e ap will be replaced by either "am" or "pm". - \row \i t \i the timezone (for example "CEST") + \header \li Expression \li Output + \row \li h + \li the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) + \row \li hh + \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) + \row \li H + \li the hour without a leading zero (0 to 23, even with AM/PM display) + \row \li HH + \li the hour with a leading zero (00 to 23, even with AM/PM display) + \row \li m \li the minute without a leading zero (0 to 59) + \row \li mm \li the minute with a leading zero (00 to 59) + \row \li s \li the second without a leading zero (0 to 59) + \row \li ss \li the second with a leading zero (00 to 59) + \row \li z \li the milliseconds without leading zeroes (0 to 999) + \row \li zzz \li the milliseconds with leading zeroes (000 to 999) + \row \li AP or A + \li use AM/PM display. \e AP will be replaced by either "AM" or "PM". + \row \li ap or a + \li use am/pm display. \e ap will be replaced by either "am" or "pm". + \row \li t \li the timezone (for example "CEST") \endtable All other input characters will be ignored. Any sequence of characters that @@ -1573,10 +1573,10 @@ QString QTime::toString(Qt::DateFormat format) const Example format strings (assuming that the QTime is 14:13:09.042) \table - \header \i Format \i Result - \row \i hh:mm:ss.zzz \i 14:13:09.042 - \row \i h:m:s ap \i 2:13:9 pm - \row \i H:m:s a \i 14:13:9 pm + \header \li Format \li Result + \row \li hh:mm:ss.zzz \li 14:13:09.042 + \row \li h:m:s ap \li 2:13:9 pm + \row \li H:m:s a \li 14:13:9 pm \endtable If the datetime is invalid, an empty string will be returned. @@ -1824,21 +1824,21 @@ QTime QTime::fromString(const QString& s, Qt::DateFormat f) These expressions may be used for the format: \table - \header \i Expression \i Output - \row \i h - \i the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) - \row \i hh - \i the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) - \row \i m \i the minute without a leading zero (0 to 59) - \row \i mm \i the minute with a leading zero (00 to 59) - \row \i s \i the second without a leading zero (0 to 59) - \row \i ss \i the second with a leading zero (00 to 59) - \row \i z \i the milliseconds without leading zeroes (0 to 999) - \row \i zzz \i the milliseconds with leading zeroes (000 to 999) - \row \i AP - \i interpret as an AM/PM time. \e AP must be either "AM" or "PM". - \row \i ap - \i Interpret as an AM/PM time. \e ap must be either "am" or "pm". + \header \li Expression \li Output + \row \li h + \li the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) + \row \li hh + \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) + \row \li m \li the minute without a leading zero (0 to 59) + \row \li mm \li the minute with a leading zero (00 to 59) + \row \li s \li the second without a leading zero (0 to 59) + \row \li ss \li the second with a leading zero (00 to 59) + \row \li z \li the milliseconds without leading zeroes (0 to 999) + \row \li zzz \li the milliseconds with leading zeroes (000 to 999) + \row \li AP + \li interpret as an AM/PM time. \e AP must be either "AM" or "PM". + \row \li ap + \li Interpret as an AM/PM time. \e ap must be either "am" or "pm". \endtable All other input characters will be treated as text. Any sequence @@ -2515,45 +2515,45 @@ QString QDateTime::toString(Qt::DateFormat f) const These expressions may be used for the date: \table - \header \i Expression \i Output - \row \i d \i the day as number without a leading zero (1 to 31) - \row \i dd \i the day as number with a leading zero (01 to 31) - \row \i ddd - \i the abbreviated localized day name (e.g. 'Mon' to 'Sun'). + \header \li Expression \li Output + \row \li d \li the day as number without a leading zero (1 to 31) + \row \li dd \li the day as number with a leading zero (01 to 31) + \row \li ddd + \li the abbreviated localized day name (e.g. 'Mon' to 'Sun'). Uses QDate::shortDayName(). - \row \i dddd - \i the long localized day name (e.g. 'Monday' to 'Qt::Sunday'). + \row \li dddd + \li the long localized day name (e.g. 'Monday' to 'Qt::Sunday'). Uses QDate::longDayName(). - \row \i M \i the month as number without a leading zero (1-12) - \row \i MM \i the month as number with a leading zero (01-12) - \row \i MMM - \i the abbreviated localized month name (e.g. 'Jan' to 'Dec'). + \row \li M \li the month as number without a leading zero (1-12) + \row \li MM \li the month as number with a leading zero (01-12) + \row \li MMM + \li the abbreviated localized month name (e.g. 'Jan' to 'Dec'). Uses QDate::shortMonthName(). - \row \i MMMM - \i the long localized month name (e.g. 'January' to 'December'). + \row \li MMMM + \li the long localized month name (e.g. 'January' to 'December'). Uses QDate::longMonthName(). - \row \i yy \i the year as two digit number (00-99) - \row \i yyyy \i the year as four digit number + \row \li yy \li the year as two digit number (00-99) + \row \li yyyy \li the year as four digit number \endtable These expressions may be used for the time: \table - \header \i Expression \i Output - \row \i h - \i the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) - \row \i hh - \i the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) - \row \i m \i the minute without a leading zero (0 to 59) - \row \i mm \i the minute with a leading zero (00 to 59) - \row \i s \i the second without a leading zero (0 to 59) - \row \i ss \i the second with a leading zero (00 to 59) - \row \i z \i the milliseconds without leading zeroes (0 to 999) - \row \i zzz \i the milliseconds with leading zeroes (000 to 999) - \row \i AP - \i use AM/PM display. \e AP will be replaced by either "AM" or "PM". - \row \i ap - \i use am/pm display. \e ap will be replaced by either "am" or "pm". + \header \li Expression \li Output + \row \li h + \li the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) + \row \li hh + \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) + \row \li m \li the minute without a leading zero (0 to 59) + \row \li mm \li the minute with a leading zero (00 to 59) + \row \li s \li the second without a leading zero (0 to 59) + \row \li ss \li the second with a leading zero (00 to 59) + \row \li z \li the milliseconds without leading zeroes (0 to 999) + \row \li zzz \li the milliseconds with leading zeroes (000 to 999) + \row \li AP + \li use AM/PM display. \e AP will be replaced by either "AM" or "PM". + \row \li ap + \li use am/pm display. \e ap will be replaced by either "am" or "pm". \endtable All other input characters will be ignored. Any sequence of characters that @@ -2565,11 +2565,11 @@ QString QDateTime::toString(Qt::DateFormat f) const 14:13:09): \table - \header \i Format \i Result - \row \i dd.MM.yyyy \i 21.05.2001 - \row \i ddd MMMM d yy \i Tue May 21 01 - \row \i hh:mm:ss.zzz \i 14:13:09.042 - \row \i h:m:s ap \i 2:13:9 pm + \header \li Format \li Result + \row \li dd.MM.yyyy \li 21.05.2001 + \row \li ddd MMMM d yy \li Tue May 21 01 + \row \li hh:mm:ss.zzz \li 14:13:09.042 + \row \li h:m:s ap \li 2:13:9 pm \endtable If the datetime is invalid, an empty string will be returned. @@ -3367,25 +3367,25 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f) These expressions may be used for the date part of the format string: \table - \header \i Expression \i Output - \row \i d \i the day as number without a leading zero (1 to 31) - \row \i dd \i the day as number with a leading zero (01 to 31) - \row \i ddd - \i the abbreviated localized day name (e.g. 'Mon' to 'Sun'). + \header \li Expression \li Output + \row \li d \li the day as number without a leading zero (1 to 31) + \row \li dd \li the day as number with a leading zero (01 to 31) + \row \li ddd + \li the abbreviated localized day name (e.g. 'Mon' to 'Sun'). Uses QDate::shortDayName(). - \row \i dddd - \i the long localized day name (e.g. 'Monday' to 'Sunday'). + \row \li dddd + \li the long localized day name (e.g. 'Monday' to 'Sunday'). Uses QDate::longDayName(). - \row \i M \i the month as number without a leading zero (1-12) - \row \i MM \i the month as number with a leading zero (01-12) - \row \i MMM - \i the abbreviated localized month name (e.g. 'Jan' to 'Dec'). + \row \li M \li the month as number without a leading zero (1-12) + \row \li MM \li the month as number with a leading zero (01-12) + \row \li MMM + \li the abbreviated localized month name (e.g. 'Jan' to 'Dec'). Uses QDate::shortMonthName(). - \row \i MMMM - \i the long localized month name (e.g. 'January' to 'December'). + \row \li MMMM + \li the long localized month name (e.g. 'January' to 'December'). Uses QDate::longMonthName(). - \row \i yy \i the year as two digit number (00-99) - \row \i yyyy \i the year as four digit number + \row \li yy \li the year as two digit number (00-99) + \row \li yyyy \li the year as four digit number \endtable \note Unlike the other version of this function, day and month names must @@ -3395,25 +3395,25 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f) These expressions may be used for the time part of the format string: \table - \header \i Expression \i Output - \row \i h - \i the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) - \row \i hh - \i the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) - \row \i H - \i the hour without a leading zero (0 to 23, even with AM/PM display) - \row \i HH - \i the hour with a leading zero (00 to 23, even with AM/PM display) - \row \i m \i the minute without a leading zero (0 to 59) - \row \i mm \i the minute with a leading zero (00 to 59) - \row \i s \i the second without a leading zero (0 to 59) - \row \i ss \i the second with a leading zero (00 to 59) - \row \i z \i the milliseconds without leading zeroes (0 to 999) - \row \i zzz \i the milliseconds with leading zeroes (000 to 999) - \row \i AP or A - \i interpret as an AM/PM time. \e AP must be either "AM" or "PM". - \row \i ap or a - \i Interpret as an AM/PM time. \e ap must be either "am" or "pm". + \header \li Expression \li Output + \row \li h + \li the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display) + \row \li hh + \li the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display) + \row \li H + \li the hour without a leading zero (0 to 23, even with AM/PM display) + \row \li HH + \li the hour with a leading zero (00 to 23, even with AM/PM display) + \row \li m \li the minute without a leading zero (0 to 59) + \row \li mm \li the minute with a leading zero (00 to 59) + \row \li s \li the second without a leading zero (0 to 59) + \row \li ss \li the second with a leading zero (00 to 59) + \row \li z \li the milliseconds without leading zeroes (0 to 999) + \row \li zzz \li the milliseconds with leading zeroes (000 to 999) + \row \li AP or A + \li interpret as an AM/PM time. \e AP must be either "AM" or "PM". + \row \li ap or a + \li Interpret as an AM/PM time. \e ap must be either "am" or "pm". \endtable All other input characters will be treated as text. Any sequence @@ -3437,13 +3437,13 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f) defaults are used: \table - \header \i Field \i Default value - \row \i Year \i 1900 - \row \i Month \i 1 (January) - \row \i Day \i 1 - \row \i Hour \i 0 - \row \i Minute \i 0 - \row \i Second \i 0 + \header \li Field \li Default value + \row \li Year \li 1900 + \row \li Month \li 1 (January) + \row \li Day \li 1 + \row \li Hour \li 0 + \row \li Minute \li 0 + \row \li Second \li 0 \endtable For example: diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 36497c59ff..d5703e8b2a 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -547,11 +547,11 @@ void QHashData::checkSanity() differences are: \list - \i QHash provides faster lookups than QMap. (See \l{Algorithmic + \li QHash provides faster lookups than QMap. (See \l{Algorithmic Complexity} for details.) - \i When iterating over a QMap, the items are always sorted by + \li When iterating over a QMap, the items are always sorted by key. With QHash, the items are arbitrarily ordered. - \i The key type of a QMap must provide operator<(). The key + \li The key type of a QMap must provide operator<(). The key type of a QHash must provide operator==() and a global hash function called qHash() (see the related non-member functions). diff --git a/src/corelib/tools/qline.cpp b/src/corelib/tools/qline.cpp index 78f1c44263..39ec0ed97c 100644 --- a/src/corelib/tools/qline.cpp +++ b/src/corelib/tools/qline.cpp @@ -61,8 +61,8 @@ QT_BEGIN_NAMESPACE \table \row - \o \inlineimage qline-point.png - \o \inlineimage qline-coordinates.png + \li \inlineimage qline-point.png + \li \inlineimage qline-coordinates.png \endtable The positions of the line's start and end points can be retrieved @@ -322,8 +322,8 @@ QDataStream &operator>>(QDataStream &stream, QLine &line) \table \row - \o \inlineimage qline-point.png - \o \inlineimage qline-coordinates.png + \li \inlineimage qline-point.png + \li \inlineimage qline-coordinates.png \endtable The positions of the line's start and end points can be retrieved @@ -360,11 +360,11 @@ QDataStream &operator>>(QDataStream &stream, QLine &line) \table \row - \o \inlineimage qlinef-unbounded.png - \o \inlineimage qlinef-bounded.png + \li \inlineimage qlinef-unbounded.png + \li \inlineimage qlinef-bounded.png \row - \o QLineF::UnboundedIntersection - \o QLineF::BoundedIntersection + \li QLineF::UnboundedIntersection + \li QLineF::BoundedIntersection \endtable \value NoIntersection Indicates that the lines do not intersect; @@ -795,8 +795,8 @@ qreal QLineF::angleTo(const QLineF &l) const \table \row - \o \inlineimage qlinef-angle-identicaldirection.png - \o \inlineimage qlinef-angle-oppositedirection.png + \li \inlineimage qlinef-angle-identicaldirection.png + \li \inlineimage qlinef-angle-oppositedirection.png \endtable When the lines are parallel, this function returns 0 if they have diff --git a/src/corelib/tools/qlinkedlist.cpp b/src/corelib/tools/qlinkedlist.cpp index e2efaa3639..b31ef3e5e9 100644 --- a/src/corelib/tools/qlinkedlist.cpp +++ b/src/corelib/tools/qlinkedlist.cpp @@ -65,16 +65,16 @@ const QLinkedListData QLinkedListData::shared_null = { functionality. Here's an overview: \list - \i For most purposes, QList is the right class to use. Its + \li For most purposes, QList is the right class to use. Its index-based API is more convenient than QLinkedList's iterator-based API, and it is usually faster than QVector because of the way it stores its items in memory (see \l{Algorithmic Complexity} for details). It also expands to less code in your executable. - \i If you need a real linked list, with guarantees of \l{constant + \li If you need a real linked list, with guarantees of \l{constant time} insertions in the middle of the list and iterators to items rather than indexes, use QLinkedList. - \i If you want the items to occupy adjacent memory positions, + \li If you want the items to occupy adjacent memory positions, use QVector. \endlist diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp index b8c938e216..263045a25d 100644 --- a/src/corelib/tools/qlist.cpp +++ b/src/corelib/tools/qlist.cpp @@ -340,15 +340,15 @@ void **QListData::erase(void **xi) functionality. Here's an overview: \list - \i For most purposes, QList is the right class to use. Its + \li For most purposes, QList is the right class to use. Its index-based API is more convenient than QLinkedList's iterator-based API, and it is usually faster than QVector because of the way it stores its items in memory. It also expands to less code in your executable. - \i If you need a real linked list, with guarantees of \l{constant + \li If you need a real linked list, with guarantees of \l{constant time} insertions in the middle of the list and iterators to items rather than indexes, use QLinkedList. - \i If you want the items to occupy adjacent memory positions, + \li If you want the items to occupy adjacent memory positions, use QVector. \endlist diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 31f776dc2e..086ca7bd38 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -621,10 +621,10 @@ static quint16 localePrivateIndex(const QLocalePrivate *p) "language[_script][_country][.codeset][@modifier]" or "C", where: \list - \i language is a lowercase, two-letter, ISO 639 language code, - \i script is a titlecase, four-letter, ISO 15924 script code, - \i country is an uppercase, two- or three-letter, ISO 3166 country code (also "419" as defined by United Nations), - \i and codeset and modifier are ignored. + \li language is a lowercase, two-letter, ISO 639 language code, + \li script is a titlecase, four-letter, ISO 15924 script code, + \li country is an uppercase, two- or three-letter, ISO 3166 country code (also "419" as defined by United Nations), + \li and codeset and modifier are ignored. \endlist The separator can be either underscore or a minus sign. @@ -671,11 +671,11 @@ QLocale::QLocale() country. \list - \i If the language/country pair is found in the database, it is used. - \i If the language is found but the country is not, or if the country + \li If the language/country pair is found in the database, it is used. + \li If the language is found but the country is not, or if the country is \c AnyCountry, the language is used with the most appropriate available country (for example, Germany for German), - \i If neither the language nor the country are found, QLocale + \li If neither the language nor the country are found, QLocale defaults to the default locale (see setDefault()). \endlist @@ -707,14 +707,14 @@ QLocale::QLocale(Language language, Country country) \a country. \list - \i If the language/script/country is found in the database, it is used. - \i If both \a script is AnyScript and \a country is AnyCountry, the + \li If the language/script/country is found in the database, it is used. + \li If both \a script is AnyScript and \a country is AnyCountry, the language is used with the most appropriate available script and country (for example, Germany for German), - \i If either \a script is AnyScript or \a country is AnyCountry, the + \li If either \a script is AnyScript or \a country is AnyCountry, the language is used with the first locale that matches the given \a script and \a country. - \i If neither the language nor the country are found, QLocale + \li If neither the language nor the country are found, QLocale defaults to the default locale (see setDefault()). \endlist diff --git a/src/corelib/tools/qlocale.qdoc b/src/corelib/tools/qlocale.qdoc index 3a386c17d6..8e90d7d94e 100644 --- a/src/corelib/tools/qlocale.qdoc +++ b/src/corelib/tools/qlocale.qdoc @@ -51,12 +51,12 @@ following effects: \list - \i If a QLocale object is constructed with the default constructor, + \li If a QLocale object is constructed with the default constructor, it will use the default locale's settings. - \i QString::toInt(), QString::toDouble(), etc., interpret the + \li QString::toInt(), QString::toDouble(), etc., interpret the string according to the default locale. If this fails, it falls back on the "C" locale. - \i QString::arg() uses the default locale to format a number when + \li QString::arg() uses the default locale to format a number when its position specifier in the format string contains an 'L', e.g. "%L1". \endlist @@ -69,11 +69,11 @@ of three things can happen: \list - \i If the language/country pair is found in the database, it is used. - \i If the language is found but the country is not, or if the country + \li If the language/country pair is found in the database, it is used. + \li If the language is found but the country is not, or if the country is \c AnyCountry, the language is used with the most appropriate available country (for example, Germany for German), - \i If neither the language nor the country are found, QLocale + \li If neither the language nor the country are found, QLocale defaults to the default locale (see setDefault()). \endlist diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp index 37d705b3e0..103d074941 100644 --- a/src/corelib/tools/qmap.cpp +++ b/src/corelib/tools/qmap.cpp @@ -232,11 +232,11 @@ void QMapData::dump() differences are: \list - \i QHash provides faster lookups than QMap. (See \l{Algorithmic + \li QHash provides faster lookups than QMap. (See \l{Algorithmic Complexity} for details.) - \i When iterating over a QHash, the items are arbitrarily ordered. + \li When iterating over a QHash, the items are arbitrarily ordered. With QMap, the items are always sorted by key. - \i The key type of a QHash must provide operator==() and a global + \li The key type of a QHash must provide operator==() and a global qHash(Key) function. The key type of a QMap must provide operator<() specifying a total order. \endlist diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index 7ff883a99a..aeab97803d 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -99,11 +99,11 @@ QT_BEGIN_NAMESPACE \table \row - \o \inlineimage qrect-intersect.png - \o \inlineimage qrect-unite.png + \li \inlineimage qrect-intersect.png + \li \inlineimage qrect-unite.png \row - \o intersected() - \o united() + \li intersected() + \li united() \endtable The isEmpty() function returns true if left() > right() or top() > @@ -139,17 +139,17 @@ QT_BEGIN_NAMESPACE \table \row - \o \inlineimage qrect-diagram-zero.png - \o \inlineimage qrect-diagram-one.png + \li \inlineimage qrect-diagram-zero.png + \li \inlineimage qrect-diagram-one.png \row - \o Logical representation - \o One pixel wide pen + \li Logical representation + \li One pixel wide pen \row - \o \inlineimage qrect-diagram-two.png - \o \inlineimage qrect-diagram-three.png + \li \inlineimage qrect-diagram-two.png + \li \inlineimage qrect-diagram-three.png \row - \o Two pixel wide pen - \o Three pixel wide pen + \li Two pixel wide pen + \li Three pixel wide pen \endtable \section1 Coordinates @@ -1278,11 +1278,11 @@ QDebug operator<<(QDebug dbg, const QRect &r) { \table \row - \o \inlineimage qrect-intersect.png - \o \inlineimage qrect-unite.png + \li \inlineimage qrect-intersect.png + \li \inlineimage qrect-unite.png \row - \o intersected() - \o united() + \li intersected() + \li united() \endtable The isEmpty() function returns true if the rectangle's width or @@ -1318,17 +1318,17 @@ QDebug operator<<(QDebug dbg, const QRect &r) { \table \row - \o \inlineimage qrect-diagram-zero.png - \o \inlineimage qrectf-diagram-one.png + \li \inlineimage qrect-diagram-zero.png + \li \inlineimage qrectf-diagram-one.png \row - \o Logical representation - \o One pixel wide pen + \li Logical representation + \li One pixel wide pen \row - \o \inlineimage qrectf-diagram-two.png - \o \inlineimage qrectf-diagram-three.png + \li \inlineimage qrectf-diagram-two.png + \li \inlineimage qrectf-diagram-three.png \row - \o Two pixel wide pen - \o Three pixel wide pen + \li Two pixel wide pen + \li Three pixel wide pen \endtable \section1 Coordinates diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index e55144ec4c..29b3424315 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -90,21 +90,21 @@ int qFindString(const QChar *haystack, int haystackLen, int from, substrings in a text. This is useful in many contexts, e.g., \table - \row \i Validation - \i A regexp can test whether a substring meets some criteria, + \row \li Validation + \li A regexp can test whether a substring meets some criteria, e.g. is an integer or contains no whitespace. - \row \i Searching - \i A regexp provides more powerful pattern matching than + \row \li Searching + \li A regexp provides more powerful pattern matching than simple substring matching, e.g., match one of the words \e{mail}, \e{letter} or \e{correspondence}, but none of the words \e{email}, \e{mailman}, \e{mailer}, \e{letterbox}, etc. - \row \i Search and Replace - \i A regexp can replace all occurrences of a substring with a + \row \li Search and Replace + \li A regexp can replace all occurrences of a substring with a different substring, e.g., replace all occurrences of \e{&} with \e{\&} except where the \e{&} is already followed by an \e{amp;}. - \row \i String Splitting - \i A regexp can be used to identify where a string should be + \row \li String Splitting + \li A regexp can be used to identify where a string should be split apart, e.g. splitting tab-delimited strings. \endtable @@ -127,18 +127,18 @@ int qFindString(const QChar *haystack, int haystackLen, int from, \section1 Introduction Regexps are built up from expressions, quantifiers, and - assertions. The simplest expression is a character, e.g. \bold{x} - or \bold{5}. An expression can also be a set of characters - enclosed in square brackets. \bold{[ABCD]} will match an \bold{A} - or a \bold{B} or a \bold{C} or a \bold{D}. We can write this same - expression as \bold{[A-D]}, and an experession to match any + assertions. The simplest expression is a character, e.g. \b{x} + or \b{5}. An expression can also be a set of characters + enclosed in square brackets. \b{[ABCD]} will match an \b{A} + or a \b{B} or a \b{C} or a \b{D}. We can write this same + expression as \b{[A-D]}, and an experession to match any captital letter in the English alphabet is written as - \bold{[A-Z]}. + \b{[A-Z]}. A quantifier specifies the number of occurrences of an expression - that must be matched. \bold{x{1,1}} means match one and only one - \bold{x}. \bold{x{1,5}} means match a sequence of \bold{x} - characters that contains at least one \bold{x} but no more than + that must be matched. \b{x{1,1}} means match one and only one + \b{x}. \b{x{1,5}} means match a sequence of \b{x} + characters that contains at least one \b{x} but no more than five. Note that in general regexps cannot be used to check for balanced @@ -156,35 +156,35 @@ int qFindString(const QChar *haystack, int haystackLen, int from, Suppose we want a regexp to match integers in the range 0 to 99. At least one digit is required, so we start with the expression - \bold{[0-9]{1,1}}, which matches a single digit exactly once. This + \b{[0-9]{1,1}}, which matches a single digit exactly once. This regexp matches integers in the range 0 to 9. To match integers up to 99, increase the maximum number of occurrences to 2, so the - regexp becomes \bold{[0-9]{1,2}}. This regexp satisfies the + regexp becomes \b{[0-9]{1,2}}. This regexp satisfies the original requirement to match integers from 0 to 99, but it will also match integers that occur in the middle of strings. If we want the matched integer to be the whole string, we must use the - anchor assertions, \bold{^} (caret) and \bold{$} (dollar). When - \bold{^} is the first character in a regexp, it means the regexp - must match from the beginning of the string. When \bold{$} is the + anchor assertions, \b{^} (caret) and \b{$} (dollar). When + \b{^} is the first character in a regexp, it means the regexp + must match from the beginning of the string. When \b{$} is the last character of the regexp, it means the regexp must match to - the end of the string. The regexp becomes \bold{^[0-9]{1,2}$}. - Note that assertions, e.g. \bold{^} and \bold{$}, do not match + the end of the string. The regexp becomes \b{^[0-9]{1,2}$}. + Note that assertions, e.g. \b{^} and \b{$}, do not match characters but locations in the string. If you have seen regexps described elsewhere, they may have looked different from the ones shown here. This is because some sets of characters and some quantifiers are so common that they have been - given special symbols to represent them. \bold{[0-9]} can be - replaced with the symbol \bold{\\d}. The quantifier to match - exactly one occurrence, \bold{{1,1}}, can be replaced with the - expression itself, i.e. \bold{x{1,1}} is the same as \bold{x}. So - our 0 to 99 matcher could be written as \bold{^\\d{1,2}$}. It can - also be written \bold{^\\d\\d{0,1}$}, i.e. \e{From the start of + given special symbols to represent them. \b{[0-9]} can be + replaced with the symbol \b{\\d}. The quantifier to match + exactly one occurrence, \b{{1,1}}, can be replaced with the + expression itself, i.e. \b{x{1,1}} is the same as \b{x}. So + our 0 to 99 matcher could be written as \b{^\\d{1,2}$}. It can + also be written \b{^\\d\\d{0,1}$}, i.e. \e{From the start of the string, match a digit, followed immediately by 0 or 1 digits}. - In practice, it would be written as \bold{^\\d\\d?$}. The \bold{?} - is shorthand for the quantifier \bold{{0,1}}, i.e. 0 or 1 - occurrences. \bold{?} makes an expression optional. The regexp - \bold{^\\d\\d?$} means \e{From the beginning of the string, match + In practice, it would be written as \b{^\\d\\d?$}. The \b{?} + is shorthand for the quantifier \b{{0,1}}, i.e. 0 or 1 + occurrences. \b{?} makes an expression optional. The regexp + \b{^\\d\\d?$} means \e{From the beginning of the string, match one digit, followed immediately by 0 or 1 more digit, followed immediately by end of string}. @@ -192,45 +192,45 @@ int qFindString(const QChar *haystack, int haystackLen, int from, 'letter' \e or 'correspondence' but does not match words that contain these words, e.g., 'email', 'mailman', 'mailer', and 'letterbox', start with a regexp that matches 'mail'. Expressed - fully, the regexp is \bold{m{1,1}a{1,1}i{1,1}l{1,1}}, but because + fully, the regexp is \b{m{1,1}a{1,1}i{1,1}l{1,1}}, but because a character expression is automatically quantified by - \bold{{1,1}}, we can simplify the regexp to \bold{mail}, i.e., an + \b{{1,1}}, we can simplify the regexp to \b{mail}, i.e., an 'm' followed by an 'a' followed by an 'i' followed by an 'l'. Now - we can use the vertical bar \bold{|}, which means \bold{or}, to + we can use the vertical bar \b{|}, which means \b{or}, to include the other two words, so our regexp for matching any of the - three words becomes \bold{mail|letter|correspondence}. Match - 'mail' \bold{or} 'letter' \bold{or} 'correspondence'. While this + three words becomes \b{mail|letter|correspondence}. Match + 'mail' \b{or} 'letter' \b{or} 'correspondence'. While this regexp will match one of the three words we want to match, it will also match words we don't want to match, e.g., 'email'. To prevent the regexp from matching unwanted words, we must tell it to begin and end the match at word boundaries. First we enclose - our regexp in parentheses, \bold{(mail|letter|correspondence)}. + our regexp in parentheses, \b{(mail|letter|correspondence)}. Parentheses group expressions together, and they identify a part of the regexp that we wish to \l{capturing text}{capture}. Enclosing the expression in parentheses allows us to use it as a component in more complex regexps. It also allows us to examine which of the three words was actually matched. To force the match to begin and end on word boundaries, we enclose the regexp in - \bold{\\b} \e{word boundary} assertions: - \bold{\\b(mail|letter|correspondence)\\b}. Now the regexp means: + \b{\\b} \e{word boundary} assertions: + \b{\\b(mail|letter|correspondence)\\b}. Now the regexp means: \e{Match a word boundary, followed by the regexp in parentheses, - followed by a word boundary}. The \bold{\\b} assertion matches a + followed by a word boundary}. The \b{\\b} assertion matches a \e position in the regexp, not a \e character. A word boundary is any non-word character, e.g., a space, newline, or the beginning or ending of a string. If we want to replace ampersand characters with the HTML entity - \bold{\&}, the regexp to match is simply \bold{\&}. But this + \b{\&}, the regexp to match is simply \b{\&}. But this regexp will also match ampersands that have already been converted to HTML entities. We want to replace only ampersands that are not - already followed by \bold{amp;}. For this, we need the negative - lookahead assertion, \bold{(?!}__\bold{)}. The regexp can then be - written as \bold{\&(?!amp;)}, i.e. \e{Match an ampersand that is} - \bold{not} \e{followed by} \bold{amp;}. + already followed by \b{amp;}. For this, we need the negative + lookahead assertion, \b{(?!}__\b{)}. The regexp can then be + written as \b{\&(?!amp;)}, i.e. \e{Match an ampersand that is} + \b{not} \e{followed by} \b{amp;}. If we want to count all the occurrences of 'Eric' and 'Eirik' in a - string, two valid solutions are \bold{\\b(Eric|Eirik)\\b} and - \bold{\\bEi?ri[ck]\\b}. The word boundary assertion '\\b' is + string, two valid solutions are \b{\\b(Eric|Eirik)\\b} and + \b{\\bEi?ri[ck]\\b}. The word boundary assertion '\\b' is required to avoid matching words that contain either name, e.g. 'Ericsson'. Note that the second regexp matches more spellings than we want: 'Eric', 'Erik', 'Eiric' and 'Eirik'. @@ -242,52 +242,52 @@ int qFindString(const QChar *haystack, int haystackLen, int from, \section1 Characters and Abbreviations for Sets of Characters \table - \header \i Element \i Meaning - \row \i \bold{c} - \i A character represents itself unless it has a special - regexp meaning. e.g. \bold{c} matches the character \e c. - \row \i \bold{\\c} - \i A character that follows a backslash matches the character + \header \li Element \li Meaning + \row \li \b{c} + \li A character represents itself unless it has a special + regexp meaning. e.g. \b{c} matches the character \e c. + \row \li \b{\\c} + \li A character that follows a backslash matches the character itself, except as specified below. e.g., To match a literal - caret at the beginning of a string, write \bold{\\^}. - \row \i \bold{\\a} - \i Matches the ASCII bell (BEL, 0x07). - \row \i \bold{\\f} - \i Matches the ASCII form feed (FF, 0x0C). - \row \i \bold{\\n} - \i Matches the ASCII line feed (LF, 0x0A, Unix newline). - \row \i \bold{\\r} - \i Matches the ASCII carriage return (CR, 0x0D). - \row \i \bold{\\t} - \i Matches the ASCII horizontal tab (HT, 0x09). - \row \i \bold{\\v} - \i Matches the ASCII vertical tab (VT, 0x0B). - \row \i \bold{\\x\e{hhhh}} - \i Matches the Unicode character corresponding to the + caret at the beginning of a string, write \b{\\^}. + \row \li \b{\\a} + \li Matches the ASCII bell (BEL, 0x07). + \row \li \b{\\f} + \li Matches the ASCII form feed (FF, 0x0C). + \row \li \b{\\n} + \li Matches the ASCII line feed (LF, 0x0A, Unix newline). + \row \li \b{\\r} + \li Matches the ASCII carriage return (CR, 0x0D). + \row \li \b{\\t} + \li Matches the ASCII horizontal tab (HT, 0x09). + \row \li \b{\\v} + \li Matches the ASCII vertical tab (VT, 0x0B). + \row \li \b{\\x\e{hhhh}} + \li Matches the Unicode character corresponding to the hexadecimal number \e{hhhh} (between 0x0000 and 0xFFFF). - \row \i \bold{\\0\e{ooo}} (i.e., \\zero \e{ooo}) - \i matches the ASCII/Latin1 character for the octal number + \row \li \b{\\0\e{ooo}} (i.e., \\zero \e{ooo}) + \li matches the ASCII/Latin1 character for the octal number \e{ooo} (between 0 and 0377). - \row \i \bold{. (dot)} - \i Matches any character (including newline). - \row \i \bold{\\d} - \i Matches a digit (QChar::isDigit()). - \row \i \bold{\\D} - \i Matches a non-digit. - \row \i \bold{\\s} - \i Matches a whitespace character (QChar::isSpace()). - \row \i \bold{\\S} - \i Matches a non-whitespace character. - \row \i \bold{\\w} - \i Matches a word character (QChar::isLetterOrNumber(), QChar::isMark(), or '_'). - \row \i \bold{\\W} - \i Matches a non-word character. - \row \i \bold{\\\e{n}} - \i The \e{n}-th \l backreference, e.g. \\1, \\2, etc. + \row \li \b{. (dot)} + \li Matches any character (including newline). + \row \li \b{\\d} + \li Matches a digit (QChar::isDigit()). + \row \li \b{\\D} + \li Matches a non-digit. + \row \li \b{\\s} + \li Matches a whitespace character (QChar::isSpace()). + \row \li \b{\\S} + \li Matches a non-whitespace character. + \row \li \b{\\w} + \li Matches a word character (QChar::isLetterOrNumber(), QChar::isMark(), or '_'). + \row \li \b{\\W} + \li Matches a non-word character. + \row \li \b{\\\e{n}} + \li The \e{n}-th \l backreference, e.g. \\1, \\2, etc. \endtable - \bold{Note:} The C++ compiler transforms backslashes in strings. - To include a \bold{\\} in a regexp, enter it twice, i.e. \c{\\}. + \b{Note:} The C++ compiler transforms backslashes in strings. + To include a \b{\\} in a regexp, enter it twice, i.e. \c{\\}. To match the backslash character itself, enter it four times, i.e. \c{\\\\}. @@ -301,24 +301,24 @@ int qFindString(const QChar *haystack, int haystackLen, int from, characters do not have special meanings in square brackets. \table - \row \i \bold{^} + \row \li \b{^} - \i The caret negates the character set if it occurs as the + \li The caret negates the character set if it occurs as the first character (i.e. immediately after the opening square - bracket). \bold{[abc]} matches 'a' or 'b' or 'c', but - \bold{[^abc]} matches anything \e but 'a' or 'b' or 'c'. + bracket). \b{[abc]} matches 'a' or 'b' or 'c', but + \b{[^abc]} matches anything \e but 'a' or 'b' or 'c'. - \row \i \bold{-} + \row \li \b{-} - \i The dash indicates a range of characters. \bold{[W-Z]} + \li The dash indicates a range of characters. \b{[W-Z]} matches 'W' or 'X' or 'Y' or 'Z'. \endtable Using the predefined character set abbreviations is more portable than using character ranges across platforms and languages. For - example, \bold{[0-9]} matches a digit in Western alphabets but - \bold{\\d} matches a digit in \e any alphabet. + example, \b{[0-9]} matches a digit in Western alphabets but + \b{\\d} matches a digit in \e any alphabet. Note: In other regexp documentation, sets of characters are often called "character classes". @@ -327,64 +327,64 @@ int qFindString(const QChar *haystack, int haystackLen, int from, \section1 Quantifiers By default, an expression is automatically quantified by - \bold{{1,1}}, i.e. it should occur exactly once. In the following - list, \bold{\e {E}} stands for expression. An expression is a + \b{{1,1}}, i.e. it should occur exactly once. In the following + list, \b{\e {E}} stands for expression. An expression is a character, or an abbreviation for a set of characters, or a set of characters in square brackets, or an expression in parentheses. \table - \row \i \bold{\e {E}?} + \row \li \b{\e {E}?} - \i Matches zero or one occurrences of \e E. This quantifier + \li Matches zero or one occurrences of \e E. This quantifier means \e{The previous expression is optional}, because it - will match whether or not the expression is found. \bold{\e - {E}?} is the same as \bold{\e {E}{0,1}}. e.g., \bold{dents?} + will match whether or not the expression is found. \b{\e + {E}?} is the same as \b{\e {E}{0,1}}. e.g., \b{dents?} matches 'dent' or 'dents'. - \row \i \bold{\e {E}+} + \row \li \b{\e {E}+} - \i Matches one or more occurrences of \e E. \bold{\e {E}+} is - the same as \bold{\e {E}{1,}}. e.g., \bold{0+} matches '0', + \li Matches one or more occurrences of \e E. \b{\e {E}+} is + the same as \b{\e {E}{1,}}. e.g., \b{0+} matches '0', '00', '000', etc. - \row \i \bold{\e {E}*} + \row \li \b{\e {E}*} - \i Matches zero or more occurrences of \e E. It is the same - as \bold{\e {E}{0,}}. The \bold{*} quantifier is often used - in error where \bold{+} should be used. For example, if - \bold{\\s*$} is used in an expression to match strings that + \li Matches zero or more occurrences of \e E. It is the same + as \b{\e {E}{0,}}. The \b{*} quantifier is often used + in error where \b{+} should be used. For example, if + \b{\\s*$} is used in an expression to match strings that end in whitespace, it will match every string because - \bold{\\s*$} means \e{Match zero or more whitespaces followed + \b{\\s*$} means \e{Match zero or more whitespaces followed by end of string}. The correct regexp to match strings that have at least one trailing whitespace character is - \bold{\\s+$}. + \b{\\s+$}. - \row \i \bold{\e {E}{n}} + \row \li \b{\e {E}{n}} - \i Matches exactly \e n occurrences of \e E. \bold{\e {E}{n}} + \li Matches exactly \e n occurrences of \e E. \b{\e {E}{n}} is the same as repeating \e E \e n times. For example, - \bold{x{5}} is the same as \bold{xxxxx}. It is also the same - as \bold{\e {E}{n,n}}, e.g. \bold{x{5,5}}. + \b{x{5}} is the same as \b{xxxxx}. It is also the same + as \b{\e {E}{n,n}}, e.g. \b{x{5,5}}. - \row \i \bold{\e {E}{n,}} - \i Matches at least \e n occurrences of \e E. + \row \li \b{\e {E}{n,}} + \li Matches at least \e n occurrences of \e E. - \row \i \bold{\e {E}{,m}} - \i Matches at most \e m occurrences of \e E. \bold{\e {E}{,m}} - is the same as \bold{\e {E}{0,m}}. + \row \li \b{\e {E}{,m}} + \li Matches at most \e m occurrences of \e E. \b{\e {E}{,m}} + is the same as \b{\e {E}{0,m}}. - \row \i \bold{\e {E}{n,m}} - \i Matches at least \e n and at most \e m occurrences of \e E. + \row \li \b{\e {E}{n,m}} + \li Matches at least \e n and at most \e m occurrences of \e E. \endtable To apply a quantifier to more than just the preceding character, use parentheses to group characters together in an expression. For - example, \bold{tag+} matches a 't' followed by an 'a' followed by - at least one 'g', whereas \bold{(tag)+} matches at least one + example, \b{tag+} matches a 't' followed by an 'a' followed by + at least one 'g', whereas \b{(tag)+} matches at least one occurrence of 'tag'. Note: Quantifiers are normally "greedy". They always match as much - text as they can. For example, \bold{0+} matches the first zero it + text as they can. For example, \b{0+} matches the first zero it finds and all the consecutive zeros after the first zero. Applied to '20005', it matches'2\underline{000}5'. Quantifiers can be made non-greedy, see setMinimal(). @@ -395,10 +395,10 @@ int qFindString(const QChar *haystack, int haystackLen, int from, Parentheses allow us to group elements together so that we can quantify and capture them. For example if we have the expression - \bold{mail|letter|correspondence} that matches a string we know + \b{mail|letter|correspondence} that matches a string we know that \e one of the words matched but not which one. Using parentheses allows us to "capture" whatever is matched within - their bounds, so if we used \bold{(mail|letter|correspondence)} + their bounds, so if we used \b{(mail|letter|correspondence)} and matched this regexp against the string "I sent you some email" we can use the cap() or capturedTexts() functions to extract the matched characters, in this case 'mail'. @@ -406,14 +406,14 @@ int qFindString(const QChar *haystack, int haystackLen, int from, We can use captured text within the regexp itself. To refer to the captured text we use \e backreferences which are indexed from 1, the same as for cap(). For example we could search for duplicate - words in a string using \bold{\\b(\\w+)\\W+\\1\\b} which means match a + words in a string using \b{\\b(\\w+)\\W+\\1\\b} which means match a word boundary followed by one or more word characters followed by one or more non-word characters followed by the same text as the first parenthesized expression followed by a word boundary. If we want to use parentheses purely for grouping and not for capturing we can use the non-capturing syntax, e.g. - \bold{(?:green|blue)}. Non-capturing parentheses begin '(?:' and + \b{(?:green|blue)}. Non-capturing parentheses begin '(?:' and end ')'. In this example we match either 'green' or 'blue' but we do not capture the match so we only know whether or not we matched but not which color we actually found. Using non-capturing @@ -424,9 +424,9 @@ int qFindString(const QChar *haystack, int haystackLen, int from, \target greedy quantifiers - For historical reasons, quantifiers (e.g. \bold{*}) that apply to + For historical reasons, quantifiers (e.g. \b{*}) that apply to capturing parentheses are more "greedy" than other quantifiers. - For example, \bold{a*(a*)} will match "aaa" with cap(1) == "aaa". + For example, \b{a*(a*)} will match "aaa" with cap(1) == "aaa". This behavior is different from what other regexp engines do (notably, Perl). To obtain a more intuitive capturing behavior, specify QRegExp::RegExp2 to the QRegExp constructor or call @@ -444,54 +444,54 @@ int qFindString(const QChar *haystack, int haystackLen, int from, Assertions make some statement about the text at the point where they occur in the regexp but they do not match any characters. In - the following list \bold{\e {E}} stands for any expression. + the following list \b{\e {E}} stands for any expression. \table - \row \i \bold{^} - \i The caret signifies the beginning of the string. If you + \row \li \b{^} + \li The caret signifies the beginning of the string. If you wish to match a literal \c{^} you must escape it by - writing \c{\\^}. For example, \bold{^#include} will only + writing \c{\\^}. For example, \b{^#include} will only match strings which \e begin with the characters '#include'. (When the caret is the first character of a character set it has a special meaning, see \link #sets-of-characters Sets of Characters \endlink.) - \row \i \bold{$} - \i The dollar signifies the end of the string. For example - \bold{\\d\\s*$} will match strings which end with a digit + \row \li \b{$} + \li The dollar signifies the end of the string. For example + \b{\\d\\s*$} will match strings which end with a digit optionally followed by whitespace. If you wish to match a literal \c{$} you must escape it by writing \c{\\$}. - \row \i \bold{\\b} - \i A word boundary. For example the regexp - \bold{\\bOK\\b} means match immediately after a word + \row \li \b{\\b} + \li A word boundary. For example the regexp + \b{\\bOK\\b} means match immediately after a word boundary (e.g. start of string or whitespace) the letter 'O' then the letter 'K' immediately before another word boundary (e.g. end of string or whitespace). But note that the assertion does not actually match any whitespace so if we - write \bold{(\\bOK\\b)} and we have a match it will only + write \b{(\\bOK\\b)} and we have a match it will only contain 'OK' even if the string is "It's \underline{OK} now". - \row \i \bold{\\B} - \i A non-word boundary. This assertion is true wherever - \bold{\\b} is false. For example if we searched for - \bold{\\Bon\\B} in "Left on" the match would fail (space + \row \li \b{\\B} + \li A non-word boundary. This assertion is true wherever + \b{\\b} is false. For example if we searched for + \b{\\Bon\\B} in "Left on" the match would fail (space and end of string aren't non-word boundaries), but it would match in "t\underline{on}ne". - \row \i \bold{(?=\e E)} - \i Positive lookahead. This assertion is true if the + \row \li \b{(?=\e E)} + \li Positive lookahead. This assertion is true if the expression matches at this point in the regexp. For example, - \bold{const(?=\\s+char)} matches 'const' whenever it is + \b{const(?=\\s+char)} matches 'const' whenever it is followed by 'char', as in 'static \underline{const} char *'. - (Compare with \bold{const\\s+char}, which matches 'static + (Compare with \b{const\\s+char}, which matches 'static \underline{const char} *'.) - \row \i \bold{(?!\e E)} - \i Negative lookahead. This assertion is true if the + \row \li \b{(?!\e E)} + \li Negative lookahead. This assertion is true if the expression does not match at this point in the regexp. For - example, \bold{const(?!\\s+char)} matches 'const' \e except + example, \b{const(?!\\s+char)} matches 'const' \e except when it is followed by 'char'. \endtable @@ -505,17 +505,17 @@ int qFindString(const QChar *haystack, int haystackLen, int from, simpler than full regexps and has only four features: \table - \row \i \bold{c} - \i Any character represents itself apart from those mentioned - below. Thus \bold{c} matches the character \e c. - \row \i \bold{?} - \i Matches any single character. It is the same as - \bold{.} in full regexps. - \row \i \bold{*} - \i Matches zero or more of any characters. It is the - same as \bold{.*} in full regexps. - \row \i \bold{[...]} - \i Sets of characters can be represented in square brackets, + \row \li \b{c} + \li Any character represents itself apart from those mentioned + below. Thus \b{c} matches the character \e c. + \row \li \b{?} + \li Matches any single character. It is the same as + \b{.} in full regexps. + \row \li \b{*} + \li Matches zero or more of any characters. It is the + same as \b{.*} in full regexps. + \row \li \b{[...]} + \li Sets of characters can be represented in square brackets, similar to full regexps. Within the character class, like outside, backslash has no special meaning. \endtable @@ -525,7 +525,7 @@ int qFindString(const QChar *haystack, int haystackLen, int from, wildcard. For example if we are in wildcard mode and have strings which - contain filenames we could identify HTML files with \bold{*.html}. + contain filenames we could identify HTML files with \b{*.html}. This will match zero or more characters followed by a dot followed by 'h', 't', 'm' and 'l'. @@ -553,7 +553,7 @@ int qFindString(const QChar *haystack, int haystackLen, int from, (but see the \l{greedy quantifiers}{note above}). Non-greedy matching cannot be applied to individual quantifiers, but can be applied to all the quantifiers in the pattern. For example, to - match the Perl regexp \bold{ro+?m} requires: + match the Perl regexp \b{ro+?m} requires: \snippet doc/src/snippets/code/src_corelib_tools_qregexp.cpp 2 @@ -562,7 +562,7 @@ int qFindString(const QChar *haystack, int haystackLen, int from, Perl's \c{/g} option can be emulated using a \l{#cap_in_a_loop}{loop}. - In QRegExp \bold{.} matches any character, therefore all QRegExp + In QRegExp \b{.} matches any character, therefore all QRegExp regexps have the equivalent of Perl's \c{/s} option. QRegExp does not have an equivalent to Perl's \c{/m} option, but this can be emulated in various ways for example by splitting the input @@ -598,7 +598,7 @@ int qFindString(const QChar *haystack, int haystackLen, int from, to Perl's split and join functions. Note: because C++ transforms \\'s they must be written \e twice in - code, e.g. \bold{\\b} must be written \bold{\\\\b}. + code, e.g. \b{\\b} must be written \b{\\\\b}. \target code-examples \section1 Code Examples @@ -670,10 +670,10 @@ int qFindString(const QChar *haystack, int haystackLen, int from, Wildcard matching can be convenient because of its simplicity, but any wildcard regexp can be defined using full regexps, e.g. - \bold{.*\\.html$}. Notice that we can't match both \c .html and \c - .htm files with a wildcard unless we use \bold{*.htm*} which will + \b{.*\\.html$}. Notice that we can't match both \c .html and \c + .htm files with a wildcard unless we use \b{*.htm*} which will also match 'test.html.bak'. A full regexp gives us the precision - we need, \bold{.*\\.html?$}. + we need, \b{.*\\.html?$}. QRegExp can match case insensitively using setCaseSensitivity(), and can use non-greedy matching, see setMinimal(). By @@ -3898,7 +3898,7 @@ static void invalidateEngine(QRegExpPrivate *priv) \enum QRegExp::CaretMode The CaretMode enum defines the different meanings of the caret - (\bold{^}) in a regular expression. The possible values are: + (\b{^}) in a regular expression. The possible values are: \value CaretAtZero The caret corresponds to index 0 in the searched string. @@ -4065,11 +4065,11 @@ bool QRegExp::isEmpty() const Returns true if the regular expression is valid; otherwise returns false. An invalid regular expression never matches. - The pattern \bold{[a-z} is an example of an invalid pattern, since + The pattern \b{[a-z} is an example of an invalid pattern, since it lacks a closing square bracket. Note that the validity of a regexp may also depend on the setting - of the wildcard flag, for example \bold{*.html} is a valid + of the wildcard flag, for example \b{*.html} is a valid wildcard regexp but an invalid full regexp. \sa errorString() @@ -4124,7 +4124,7 @@ Qt::CaseSensitivity QRegExp::caseSensitivity() const /*! Sets case sensitive matching to \a cs. - If \a cs is Qt::CaseSensitive, \bold{\\.txt$} matches + If \a cs is Qt::CaseSensitive, \b{\\.txt$} matches \c{readme.txt} but not \c{README.TXT}. \sa setPatternSyntax(), setPattern(), setMinimal() @@ -4153,7 +4153,7 @@ QRegExp::PatternSyntax QRegExp::patternSyntax() const QRegExp::RegExp. Setting \a syntax to QRegExp::Wildcard enables simple shell-like - \l{wildcard matching}. For example, \bold{r*.txt} matches the + \l{wildcard matching}. For example, \b{r*.txt} matches the string \c{readme.txt} in wildcard mode, but does not match \c{readme}. @@ -4188,13 +4188,13 @@ bool QRegExp::isMinimal() const For example, suppose we have the input string "We must be bold, very bold!" and the pattern - \bold{.*}. With the default greedy (maximal) matching, + \b{.*}. With the default greedy (maximal) matching, the match is "We must be \underline{bold, very bold}!". But with minimal (non-greedy) matching, the first match is: "We must be \underline{bold}, very bold!" and the second match is "We must be bold, very \underline{bold}!". In practice we might use the pattern - \bold{[^<]*\} instead, although this will still fail for + \b{[^<]*\} instead, although this will still fail for nested tags. \sa setCaseSensitivity() @@ -4215,7 +4215,7 @@ void QRegExp::setMinimal(bool minimal) in the start of string and end of string anchors, except that it sets matchedLength() differently. - For example, if the regular expression is \bold{blue}, then + For example, if the regular expression is \b{blue}, then exactMatch() returns true only for input \c blue. For inputs \c bluebell, \c blutak and \c lightblue, exactMatch() returns false and matchedLength() will return 4, 3 and 0 respectively. @@ -4247,7 +4247,7 @@ bool QRegExp::exactMatch(const QString &str) const Returns the position of the first match, or -1 if there was no match. - The \a caretMode parameter can be used to instruct whether \bold{^} + The \a caretMode parameter can be used to instruct whether \b{^} should match at index 0 or at \a offset. You might prefer to use QString::indexOf(), QString::contains(), @@ -4286,7 +4286,7 @@ int QRegExp::indexIn(const QString &str, int offset, CaretMode caretMode) const Returns the position of the first match, or -1 if there was no match. - The \a caretMode parameter can be used to instruct whether \bold{^} + The \a caretMode parameter can be used to instruct whether \b{^} should match at index 0 or at \a offset. Although const, this function sets matchedLength(), @@ -4371,7 +4371,7 @@ int QRegExp::captureCount() const Some regexps can match an indeterminate number of times. For example if the input string is "Offsets: 12 14 99 231 7" and the - regexp, \c{rx}, is \bold{(\\d+)+}, we would hope to get a list of + regexp, \c{rx}, is \b{(\\d+)+}, we would hope to get a list of all the numbers matched. However, after calling \c{rx.indexIn(str)}, capturedTexts() will return the list ("12", "12"), i.e. the entire match was "12" and the first subexpression diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp index b6bf525fb9..5ecca89229 100644 --- a/src/corelib/tools/qscopedpointer.cpp +++ b/src/corelib/tools/qscopedpointer.cpp @@ -89,10 +89,10 @@ QT_BEGIN_NAMESPACE The following custom cleanup handlers exist: \list - \i QScopedPointerDeleter - the default, deletes the pointer using \c delete - \i QScopedPointerArrayDeleter - deletes the pointer using \c{delete []}. Use + \li QScopedPointerDeleter - the default, deletes the pointer using \c delete + \li QScopedPointerArrayDeleter - deletes the pointer using \c{delete []}. Use this handler for pointers that were allocated with \c{new []}. - \i QScopedPointerPodDeleter - deletes the pointer using \c{free()}. Use this + \li QScopedPointerPodDeleter - deletes the pointer using \c{free()}. Use this handler for pointers that were allocated with \c{malloc()}. \endlist diff --git a/src/corelib/tools/qshareddata.cpp b/src/corelib/tools/qshareddata.cpp index 6250745400..ffc8ac601d 100644 --- a/src/corelib/tools/qshareddata.cpp +++ b/src/corelib/tools/qshareddata.cpp @@ -86,10 +86,10 @@ QT_BEGIN_NAMESPACE \list - \o Define the class \c Employee to have a single data member of + \li Define the class \c Employee to have a single data member of type \c {QSharedDataPointer}. - \o Define the \c EmployeeData class derived from \l QSharedData to + \li Define the \c EmployeeData class derived from \l QSharedData to contain all the data members you would normally have put in the \c Employee class. diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp index 4c94f899e7..b276d2d2e0 100644 --- a/src/corelib/tools/qsize.cpp +++ b/src/corelib/tools/qsize.cpp @@ -186,10 +186,10 @@ void QSize::transpose() height, according to the specified \a mode: \list - \i If \a mode is Qt::IgnoreAspectRatio, the size is set to (\a width, \a height). - \i If \a mode is Qt::KeepAspectRatio, the current size is scaled to a rectangle + \li If \a mode is Qt::IgnoreAspectRatio, the size is set to (\a width, \a height). + \li If \a mode is Qt::KeepAspectRatio, the current size is scaled to a rectangle as large as possible inside (\a width, \a height), preserving the aspect ratio. - \i If \a mode is Qt::KeepAspectRatioByExpanding, the current size is scaled to a rectangle + \li If \a mode is Qt::KeepAspectRatioByExpanding, the current size is scaled to a rectangle as small as possible outside (\a width, \a height), preserving the aspect ratio. \endlist @@ -614,10 +614,10 @@ void QSizeF::transpose() height, according to the specified \a mode. \list - \i If \a mode is Qt::IgnoreAspectRatio, the size is set to (\a width, \a height). - \i If \a mode is Qt::KeepAspectRatio, the current size is scaled to a rectangle + \li If \a mode is Qt::IgnoreAspectRatio, the size is set to (\a width, \a height). + \li If \a mode is Qt::KeepAspectRatio, the current size is scaled to a rectangle as large as possible inside (\a width, \a height), preserving the aspect ratio. - \i If \a mode is Qt::KeepAspectRatioByExpanding, the current size is scaled to a rectangle + \li If \a mode is Qt::KeepAspectRatioByExpanding, the current size is scaled to a rectangle as small as possible outside (\a width, \a height), preserving the aspect ratio. \endlist diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index bf50159de2..45ccfb8aea 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -606,12 +606,12 @@ const QString::Null QString::null = { }; toLatin1(), toUtf8(), and toLocal8Bit(). \list - \o toAscii() returns a Latin-1 (ISO 8859-1) encoded 8-bit string. - \o toLatin1() returns a Latin-1 (ISO 8859-1) encoded 8-bit string. - \o toUtf8() returns a UTF-8 encoded 8-bit string. UTF-8 is a + \li toAscii() returns a Latin-1 (ISO 8859-1) encoded 8-bit string. + \li toLatin1() returns a Latin-1 (ISO 8859-1) encoded 8-bit string. + \li toUtf8() returns a UTF-8 encoded 8-bit string. UTF-8 is a superset of US-ASCII (ANSI X3.4-1986) that supports the entire Unicode character set through multibyte sequences. - \o toLocal8Bit() returns an 8-bit string using the system's local + \li toLocal8Bit() returns an 8-bit string using the system's local encoding. \endlist @@ -629,9 +629,9 @@ const QString::Null QString::null = { }; conversions by defining the following two preprocessor symbols: \list - \o \c QT_NO_CAST_FROM_ASCII disables automatic conversions from + \li \c QT_NO_CAST_FROM_ASCII disables automatic conversions from C string literals and pointers to Unicode. - \o \c QT_NO_CAST_TO_ASCII disables automatic conversion from QString + \li \c QT_NO_CAST_TO_ASCII disables automatic conversion from QString to C strings. \endlist @@ -655,10 +655,10 @@ const QString::Null QString::null = { }; \table 100 % \header - \o Note for C Programmers + \li Note for C Programmers \row - \o + \li Due to C++'s type system and the fact that QString is \l{implicitly shared}, QStrings may be treated like \c{int}s or other basic types. For example: @@ -697,12 +697,12 @@ const QString::Null QString::null = { }; following: \table - \header \o Format \o Meaning - \row \o \c e \o format as [-]9.9e[+|-]999 - \row \o \c E \o format as [-]9.9E[+|-]999 - \row \o \c f \o format as [-]9.9 - \row \o \c g \o use \c e or \c f format, whichever is the most concise - \row \o \c G \o use \c E or \c f format, whichever is the most concise + \header \li Format \li Meaning + \row \li \c e \li format as [-]9.9e[+|-]999 + \row \li \c E \li format as [-]9.9E[+|-]999 + \row \li \c f \li format as [-]9.9 + \row \li \c g \li use \c e or \c f format, whichever is the most concise + \row \li \c G \li use \c E or \c f format, whichever is the most concise \endtable A \e precision is also specified with the argument \e format. For @@ -2789,7 +2789,7 @@ struct QStringCapture \snippet doc/src/snippets/qstring/main.cpp 42 For regular expressions containing \l{capturing parentheses}, - occurrences of \bold{\\1}, \bold{\\2}, ..., in \a after are replaced + occurrences of \b{\\1}, \b{\\2}, ..., in \a after are replaced with \a{rx}.cap(1), cap(2), ... \snippet doc/src/snippets/qstring/main.cpp 43 @@ -6059,7 +6059,7 @@ QStringList QString::split(QChar sep, SplitBehavior behavior, Qt::CaseSensitivit \snippet doc/src/snippets/qstring/main.cpp 60 Here's a third example where we use a zero-length assertion, - \bold{\\b} (word boundary), to split the string into an + \b{\\b} (word boundary), to split the string into an alternating sequence of non-word and word tokens: \snippet doc/src/snippets/qstring/main.cpp 61 diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index a352045a7d..b4ec0c6498 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -342,7 +342,7 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QString &b \snippet doc/src/snippets/qstringlist/main.cpp 14 For regular expressions that contain \l{capturing parentheses}, - occurrences of \bold{\\1}, \bold{\\2}, ..., in \a after are + occurrences of \b{\\1}, \b{\\2}, ..., in \a after are replaced with \a{rx}.cap(1), \a{rx}.cap(2), ... For example: diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc index 1a0579a077..e1dc2bee9a 100644 --- a/src/corelib/tools/qvarlengtharray.qdoc +++ b/src/corelib/tools/qvarlengtharray.qdoc @@ -69,13 +69,13 @@ structure. The main differences between the two classes are: \list - \o QVarLengthArray's API is much more low-level. It provides no + \li QVarLengthArray's API is much more low-level. It provides no iterators and lacks much of QVector's functionality. - \o QVarLengthArray doesn't initialize the memory if the value is + \li QVarLengthArray doesn't initialize the memory if the value is a basic type. (QVector always does.) - \o QVector uses \l{implicit sharing} as a memory optimization. + \li QVector uses \l{implicit sharing} as a memory optimization. QVarLengthArray doesn't provide that feature; however, it usually produces slightly better performance due to reduced overhead, especially in tight loops. diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp index 3efe695559..75c219bbc9 100644 --- a/src/corelib/tools/qvector.cpp +++ b/src/corelib/tools/qvector.cpp @@ -108,21 +108,21 @@ int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive similar functionality. Here's an overview: \list - \i For most purposes, QList is the right class to use. Operations + \li For most purposes, QList is the right class to use. Operations like prepend() and insert() are usually faster than with QVector because of the way QList stores its items in memory (see \l{Algorithmic Complexity} for details), and its index-based API is more convenient than QLinkedList's iterator-based API. It also expands to less code in your executable. - \i If you need a real linked list, with guarantees of \l{constant + \li If you need a real linked list, with guarantees of \l{constant time} insertions in the middle of the list and iterators to items rather than indexes, use QLinkedList. - \i If you want the items to occupy adjacent memory positions, or + \li If you want the items to occupy adjacent memory positions, or if your items are larger than a pointer and you want to avoid the overhead of allocating them on the heap individually at insertion time, then use QVector. - \i If you want a low-level variable-size array, QVarLengthArray + \li If you want a low-level variable-size array, QVarLengthArray may be sufficient. \endlist -- cgit v1.2.3 From db1abf9f760ebc40b1f7f0f3e88698cea8aebbd7 Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Fri, 2 Mar 2012 11:04:01 +0100 Subject: Change bugreports.qt.nokia.com -> bugreports.qt-project.org Change-Id: Ia795098f24cf358b15067f54cd08dff0bd792bc5 Reviewed-by: Thiago Macieira --- src/corelib/global/qnamespace.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 7d5eec4271..1df36f42e6 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2653,7 +2653,7 @@ \value ElideNone Ellipsis should NOT appear in the text. Qt::ElideMiddle is normally the most appropriate choice for URLs (e.g., - "\l{http://bugreports.qt.nokia.com/browse/QTWEBSITE-13}{http://bugreports.qt.../QTWEBSITE-13/}"), + "\l{http://bugreports.qt-project.org/browse/QTWEBSITE-13}{http://bugreports.qt.../QTWEBSITE-13/}"), whereas Qt::ElideRight is appropriate for other strings (e.g., "\l{http://qt.nokia.com/doc/qq/qq09-mac-deployment.html}{Deploying Applications on Ma...}"). -- cgit v1.2.3 From 8db8a34f07a2f8cbd06dc0b593886a13d52ae4b1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 3 Mar 2012 12:53:45 +0100 Subject: Fix documentation of the new connect functions. Make sure that qdoc can find the same function signature in the header than in the \fn tags in qobject.cpp Change-Id: Iccf2ba4e8f6384e9c3bfc878a446120f03e8a813 Reviewed-by: Casper van Donderen --- src/corelib/kernel/qobject.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 5f43b52939..9f09617071 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -198,6 +198,10 @@ public: inline QMetaObject::Connection connect(const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type = Qt::AutoConnection) const; +#ifdef Q_QDOC + QMetaObject::Connection QObject::connect(const QObject *sender, (T::*signal)(...), const QObject *receiver, (T::*method)(...), Qt::ConnectionType type) + QMetaObject::Connection QObject::connect(const QObject *sender, (T::*signal)(...), Functor functor) +#else //Connect a signal to a pointer to qobject member function template static inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer::Object *sender, Func1 signal, @@ -261,6 +265,7 @@ public: new QFunctorSlotObject(slot), Qt::DirectConnection, 0, &SignalType::Object::staticMetaObject); } +#endif //Q_QDOC static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member); @@ -273,6 +278,9 @@ public: { return disconnect(this, 0, receiver, member); } static bool disconnect(const QMetaObject::Connection &); +#ifdef Q_QDOC + bool QObject::disconnect(const QObject *sender, (T::*signal)(...), const Qbject *receiver, (T::*method)(...)) +#else template static inline bool disconnect(const typename QtPrivate::FunctionPointer::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer::Object *receiver, Func2 slot) @@ -300,6 +308,7 @@ public: return disconnectImpl(sender, reinterpret_cast(&signal), receiver, zero, &SignalType::Object::staticMetaObject); } +#endif //Q_QDOC void dumpObjectTree(); -- cgit v1.2.3 From e8b46d6f69c80e1e041403b1d45d548b2c3e5add Mon Sep 17 00:00:00 2001 From: Leonard Lee Date: Mon, 5 Mar 2012 12:01:45 +0100 Subject: Enable name of threads in release mode. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Naming threads is very useful for release builds. Enabling only on Linux/Mac for now. The Windows port is using debugger specific API for setting thread names, so it has to remain debug mode only. Change-Id: I179521f65f215ff038e8230f958f6aa728ea4cbe Reviewed-by: Lars Knoll Reviewed-by: João Abecasis --- src/corelib/thread/qthread_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index d458ee9472..a0913e5dbc 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -287,7 +287,7 @@ void *QThreadPrivate::start(void *arg) else createEventDispatcher(data); -#if !defined(QT_NO_DEBUG) && (defined(Q_OS_LINUX) || defined(Q_OS_MAC)) +#if (defined(Q_OS_LINUX) || defined(Q_OS_MAC)) // sets the name of the current thread. QByteArray objectName = thr->objectName().toLocal8Bit(); -- cgit v1.2.3 From f449cefc27fc321f96aadbcb0f0a46e6f7a2b0b4 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Sun, 12 Feb 2012 12:35:12 +0100 Subject: Remove AccessibilityPrepare event. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This event was completely unused. In addition it leads to crashes on linux when sending the Destroy accessibility update. The Destroy event on linux would still query an accessible interface. That in turn would trigger the event to be sent. Change-Id: I8915527de067b8b70ba41b1361e3ef5d12866d7d Reviewed-by: Frederik Gladhorn Reviewed-by: Jan-Arve Sæther --- src/corelib/kernel/qcoreevent.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h index cac89f2b13..1d54b32dfa 100644 --- a/src/corelib/kernel/qcoreevent.h +++ b/src/corelib/kernel/qcoreevent.h @@ -127,7 +127,6 @@ public: DeactivateControl = 81, // ActiveX deactivation ContextMenu = 82, // context popup menu InputMethod = 83, // input method - AccessibilityPrepare = 86, // accessibility information is requested TabletMove = 87, // Wacom tablet event LocaleChange = 88, // the system locale changed LanguageChange = 89, // the application language changed -- cgit v1.2.3 From eb150a51cd1e439fd719fe3cd3f30c53f9a1348a Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Mon, 5 Mar 2012 22:11:05 +0100 Subject: Remove unused QThreadPoolPrivate::startFrontRunnable(). Change-Id: Ie079aea3412a53cf9dccaa770fa64ff5b6b7b3b1 Reviewed-by: Stephen Kelly --- src/corelib/thread/qthreadpool.cpp | 25 ------------------------- src/corelib/thread/qthreadpool_p.h | 1 - 2 files changed, 26 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index af8c99197e..b7021817c5 100644 --- a/src/corelib/thread/qthreadpool.cpp +++ b/src/corelib/thread/qthreadpool.cpp @@ -307,31 +307,6 @@ bool QThreadPoolPrivate::waitForDone(int msecs) return queue.isEmpty() && activeThreads == 0; } -/*! \internal - Pulls a runnable from the front queue and runs it in the current thread. Blocks - until the runnable has completed. Returns true if a runnable was found. -*/ -bool QThreadPoolPrivate::startFrontRunnable() -{ - QMutexLocker locker(&mutex); - if (queue.isEmpty()) - return false; - - QRunnable *runnable = queue.takeFirst().first; - const bool autoDelete = runnable->autoDelete(); - bool del = autoDelete && !--runnable->ref; - - locker.unlock(); - runnable->run(); - locker.relock(); - - if (del) { - delete runnable; - } - - return true; -} - /*! \internal Seaches for \a runnable in the queue, removes it from the queue and runs it if found. This functon does not return until the runnable diff --git a/src/corelib/thread/qthreadpool_p.h b/src/corelib/thread/qthreadpool_p.h index 9a7c09695f..910e0b0714 100644 --- a/src/corelib/thread/qthreadpool_p.h +++ b/src/corelib/thread/qthreadpool_p.h @@ -83,7 +83,6 @@ public: void startThread(QRunnable *runnable = 0); void reset(); bool waitForDone(int msecs = -1); - bool startFrontRunnable(); void stealRunnable(QRunnable *); mutable QMutex mutex; -- cgit v1.2.3 From 95550c8f1292c93ea42d59283394fc4f4d63bf2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Mon, 5 Mar 2012 15:27:40 +0100 Subject: Mark QMetaType constructor as explicit. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implicit conversion from an int would look strange in this case. Change-Id: I2222a045c293595d7b83a2fb75ca646f5cf79bca Reviewed-by: Stephen Kelly Reviewed-by: João Abecasis --- src/corelib/kernel/qmetatype.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index f969875455..7f6eaf2230 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -255,7 +255,7 @@ public: static bool load(QDataStream &stream, int type, void *data); #endif - QMetaType(const int type); + explicit QMetaType(const int type); inline ~QMetaType(); inline bool isValid() const; -- cgit v1.2.3 From 9c75d0a91327868b2131d11caea2cd0ccd437711 Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Mon, 5 Mar 2012 18:16:58 +1000 Subject: Support new-style plugins without a "Keys" json property As per discussion with Lars, intent here was to allow plugins without a "Keys" property to still function correctly, but this particular if statement was blocking any such plugins from being detected. Change-Id: Icb343ca8bd95a508d62565cd816fe2a57a4f82bd Reviewed-by: Lars Knoll --- src/corelib/plugin/qfactoryloader.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 566ece77c9..cdc72cf35d 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -128,6 +128,7 @@ void QFactoryLoader::update() QLibraryPrivate *library = 0; for (int j = 0; j < plugins.count(); ++j) { QString fileName = QDir::cleanPath(path + QLatin1Char('/') + plugins.at(j)); + if (qt_debug_component()) { qDebug() << "QFactoryLoader::QFactoryLoader() looking at" << fileName; } @@ -140,7 +141,9 @@ void QFactoryLoader::update() library->release(); continue; } + QStringList keys; + bool metaDataOk = false; if (library->compatPlugin) { qWarning("Qt plugin loader: Compatibility plugin '%s', need to load for accessing meta data.", qPrintable(QDir::toNativeSeparators(fileName))); @@ -164,10 +167,17 @@ void QFactoryLoader::update() QFactoryInterface *factory = qobject_cast(instance); if (instance && factory && instance->qt_metacast(d->iid)) keys = factory->keys(); + + if (!keys.isEmpty()) + metaDataOk = true; + } else { QString iid = library->metaData.value(QLatin1String("IID")).toString(); if (iid == QLatin1String(d->iid.constData(), d->iid.size())) { QJsonObject object = library->metaData.value(QLatin1String("MetaData")).toObject(); + if (!object.isEmpty()) + metaDataOk = true; + QJsonArray k = object.value(QLatin1String("Keys")).toArray(); for (int i = 0; i < k.size(); ++i) { QString s = k.at(i).toString(); @@ -178,11 +188,12 @@ void QFactoryLoader::update() qDebug() << "Got keys from plugin meta data" << keys; } - if (keys.isEmpty()) { + if (!metaDataOk) { library->unload(); library->release(); continue; } + d->libraryList += library; for (int k = 0; k < keys.count(); ++k) { // first come first serve, unless the first -- cgit v1.2.3 From 95fa88abe7441f49b64a0b398e16b04b3b6bdbc9 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Wed, 1 Feb 2012 00:33:30 +0200 Subject: Remove codecForTr(). Similarly to change id I2f429fa7ef93bd75bb93a7f64c56db15b7283388, the capability to arbitrarily alter the encoding of literals is very destructive, especially in a world with libraries and plugins. Change-Id: If0d4cd8dcf89792e39c1984cbde6b036cebfc02f Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- src/corelib/codecs/qtextcodec.cpp | 37 --------------------------------- src/corelib/codecs/qtextcodec.h | 7 ------- src/corelib/global/qglobal.cpp | 4 +--- src/corelib/kernel/qcoreapplication.cpp | 14 +++++-------- src/corelib/kernel/qcoreapplication.h | 6 +++--- src/corelib/kernel/qmetaobject.cpp | 2 +- src/corelib/kernel/qobject.cpp | 7 +------ 7 files changed, 11 insertions(+), 66 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index f6f0cd8699..13f0ec8ce5 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -145,8 +145,6 @@ static bool destroying_is_ok = false; #endif static QTextCodec *localeMapper = 0; -QTextCodec *QTextCodec::cftr = 0; - class QTextCodecCleanup { @@ -1463,41 +1461,6 @@ QString QTextDecoder::toUnicode(const QByteArray &ba) return c->toUnicode(ba.constData(), ba.length(), &state); } - -/*! - \fn QTextCodec* QTextCodec::codecForTr() - - Returns the codec used by QObject::tr() on its argument. If this - function returns 0 (the default), tr() assumes Latin-1. - - \sa setCodecForTr() -*/ - -/*! - \fn void QTextCodec::setCodecForTr(QTextCodec *c) - \nonreentrant - - Sets the codec used by QObject::tr() on its argument to \a c. If - \a c is 0 (the default), tr() assumes Latin-1. - - If the literal quoted text in the program is not in the Latin-1 - encoding, this function can be used to set the appropriate - encoding. For example, software developed by Korean programmers - might use eucKR for all the text in the program, in which case the - main() function might look like this: - - \snippet doc/src/snippets/code/src_corelib_codecs_qtextcodec.cpp 3 - - Note that this is not the way to select the encoding that the \e - user has chosen. For example, to convert an application containing - literal English strings to Korean, all that is needed is for the - English strings to be passed through tr() and for translation - files to be loaded. For details of internationalization, see - \l{Internationalization with Qt}. - - \sa codecForTr() -*/ - /*! \since 4.4 diff --git a/src/corelib/codecs/qtextcodec.h b/src/corelib/codecs/qtextcodec.h index ad37005e92..b4b170f7d7 100644 --- a/src/corelib/codecs/qtextcodec.h +++ b/src/corelib/codecs/qtextcodec.h @@ -72,9 +72,6 @@ public: static QTextCodec* codecForLocale(); static void setCodecForLocale(QTextCodec *c); - static QTextCodec* codecForTr(); - static void setCodecForTr(QTextCodec *c); - static QTextCodec *codecForHtml(const QByteArray &ba); static QTextCodec *codecForHtml(const QByteArray &ba, QTextCodec *defaultCodec); @@ -129,14 +126,10 @@ protected: private: friend class QTextCodecCleanup; - static QTextCodec *cftr; static bool validCodecs(); }; Q_DECLARE_OPERATORS_FOR_FLAGS(QTextCodec::ConversionFlags) - inline QTextCodec* QTextCodec::codecForTr() { return validCodecs() ? cftr : 0; } -inline void QTextCodec::setCodecForTr(QTextCodec *c) { cftr = c; } - class Q_CORE_EXPORT QTextEncoder { Q_DISABLE_COPY(QTextEncoder) public: diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index a30250df81..09d178639d 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2233,9 +2233,7 @@ int qrand() The macro QT_TR_NOOP_UTF8() is identical except that it tells lupdate that the source string is encoded in UTF-8. Corresponding variants - exist in the QT_TRANSLATE_NOOP() family of macros, too. Note that - using these macros is not required if \c CODECFORTR is already set to - UTF-8 in the qmake project file. + exist in the QT_TRANSLATE_NOOP() family of macros, too. \sa QT_TRANSLATE_NOOP(), {Internationalization with Qt} */ diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 515732bc68..184743e865 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1438,11 +1438,9 @@ bool QCoreApplication::event(QEvent *e) This enum type defines the 8-bit encoding of character string arguments to translate(): - \value CodecForTr The encoding specified by - QTextCodec::codecForTr() (Latin-1 if none has - been set). - \value UnicodeUTF8 UTF-8. - \value DefaultCodec (Obsolete) Use CodecForTr instead. + \value UnicodeUTF8 UTF-8. + \value Latin1 Latin-1. + \value DefaultCodec Latin-1. \sa QObject::tr(), QObject::trUtf8(), QString::fromUtf8() */ @@ -1617,7 +1615,7 @@ static void replacePercentN(QString *result, int n) If none of the translation files contain a translation for \a sourceText in \a context, this function returns a QString equivalent of \a sourceText. The encoding of \a sourceText is - specified by \e encoding; it defaults to CodecForTr. + specified by \e encoding; it defaults to DefaultCodec. This function is not virtual. You can use alternative translation techniques by subclassing \l QTranslator. @@ -1628,7 +1626,7 @@ static void replacePercentN(QString *result, int n) so will most likely result in crashes or other undesirable behavior. - \sa QObject::tr() installTranslator() QTextCodec::codecForTr() + \sa QObject::tr() installTranslator() */ @@ -1657,8 +1655,6 @@ QString QCoreApplication::translate(const char *context, const char *sourceText, #else if (encoding == UnicodeUTF8) result = QString::fromUtf8(sourceText); - else if (QTextCodec::codecForTr() != 0) - result = QTextCodec::codecForTr()->toUnicode(sourceText); else #endif result = QString::fromLatin1(sourceText); diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index 18266a9a2c..0a5181a508 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -137,11 +137,11 @@ public: static void installTranslator(QTranslator * messageFile); static void removeTranslator(QTranslator * messageFile); #endif - enum Encoding { CodecForTr, UnicodeUTF8, DefaultCodec = CodecForTr }; + enum Encoding { UnicodeUTF8, Latin1, DefaultCodec = Latin1 }; static QString translate(const char * context, const char * key, const char * disambiguation = 0, - Encoding encoding = CodecForTr, + Encoding encoding = DefaultCodec, int n = -1); static void flush(); @@ -240,7 +240,7 @@ inline QString QCoreApplication::translate(const char *, const char *sourceText, public: \ static inline QString tr(const char *sourceText, const char *disambiguation = 0, int n = -1) \ { return QCoreApplication::translate(#context, sourceText, disambiguation, \ - QCoreApplication::CodecForTr, n); } \ + QCoreApplication::DefaultCodec, n); } \ static inline QString trUtf8(const char *sourceText, const char *disambiguation = 0, int n = -1) \ { return QCoreApplication::translate(#context, sourceText, disambiguation, \ QCoreApplication::UnicodeUTF8, n); } \ diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index f962fb7831..cacd999869 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -307,7 +307,7 @@ const QObject *QMetaObject::cast(const QObject *obj) const */ QString QMetaObject::tr(const char *s, const char *c, int n) const { - return QCoreApplication::translate(d.stringdata, s, c, QCoreApplication::CodecForTr, n); + return QCoreApplication::translate(d.stringdata, s, c, QCoreApplication::DefaultCodec, n); } /*! diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 19440e9368..3a4d1da592 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1859,7 +1859,7 @@ void QObject::deleteLater() translators while performing translations is not supported. Doing so will probably result in crashes or other undesirable behavior. - \sa trUtf8(), QApplication::translate(), QTextCodec::setCodecForTr(), {Internationalization with Qt} + \sa trUtf8(), QApplication::translate(), {Internationalization with Qt} */ /*! @@ -1871,11 +1871,6 @@ void QObject::deleteLater() version. It is otherwise identical to tr(\a sourceText, \a disambiguation, \a n). - Note that using the Utf8 variants of the translation functions - is not required if \c CODECFORTR is already set to UTF-8 in the - qmake project file and QTextCodec::setCodecForTr("UTF-8") is - used. - \warning This method is reentrant only if all translators are installed \e before calling this method. Installing or removing translators while performing translations is not supported. Doing -- cgit v1.2.3 From dc75c20397e7322ba87578e766e0cd86ece90f93 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 26 Feb 2012 10:05:39 +0100 Subject: Split up base class QFileDevice for open-file operations (read/write) This will be used later on as a base class for QTemporaryFile and QSaveFile. Change-Id: Ic2e1d232f95dc29b8e2f75e24a881ab459d3f037 Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll --- src/corelib/io/io.pri | 3 + src/corelib/io/qfile.cpp | 635 +---------------------------------- src/corelib/io/qfile.h | 62 +--- src/corelib/io/qfile_p.h | 20 +- src/corelib/io/qfiledevice.cpp | 736 +++++++++++++++++++++++++++++++++++++++++ src/corelib/io/qfiledevice.h | 147 ++++++++ src/corelib/io/qfiledevice_p.h | 104 ++++++ 7 files changed, 1012 insertions(+), 695 deletions(-) create mode 100644 src/corelib/io/qfiledevice.cpp create mode 100644 src/corelib/io/qfiledevice.h create mode 100644 src/corelib/io/qfiledevice_p.h (limited to 'src/corelib') diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 29599295ad..9c117abe03 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -11,6 +11,8 @@ HEADERS += \ io/qdir_p.h \ io/qdiriterator.h \ io/qfile.h \ + io/qfiledevice.h \ + io/qfiledevice_p.h \ io/qfileinfo.h \ io/qfileinfo_p.h \ io/qiodevice.h \ @@ -49,6 +51,7 @@ SOURCES += \ io/qdir.cpp \ io/qdiriterator.cpp \ io/qfile.cpp \ + io/qfiledevice.cpp \ io/qfileinfo.cpp \ io/qiodevice.cpp \ io/qnoncontiguousbytedevice.cpp \ diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 6640dca70b..433d4493e5 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -59,8 +59,6 @@ QT_BEGIN_NAMESPACE -static const int QFILE_WRITEBUFFER_SIZE = 16384; - static QByteArray locale_encode(const QString &f) { #if defined(Q_OS_DARWIN) @@ -86,16 +84,11 @@ QFile::EncoderFn QFilePrivate::encoder = locale_encode; QFile::DecoderFn QFilePrivate::decoder = locale_decode; QFilePrivate::QFilePrivate() - : fileEngine(0), lastWasWrite(false), - writeBuffer(QFILE_WRITEBUFFER_SIZE), error(QFile::NoError), - cachedSize(0) { } QFilePrivate::~QFilePrivate() { - delete fileEngine; - fileEngine = 0; } bool @@ -137,39 +130,6 @@ QAbstractFileEngine *QFilePrivate::engine() const return fileEngine; } -inline bool QFilePrivate::ensureFlushed() const -{ - // This function ensures that the write buffer has been flushed (const - // because certain const functions need to call it. - if (lastWasWrite) { - const_cast(this)->lastWasWrite = false; - if (!const_cast(q_func())->flush()) - return false; - } - return true; -} - -void -QFilePrivate::setError(QFile::FileError err) -{ - error = err; - errorString.clear(); -} - -void -QFilePrivate::setError(QFile::FileError err, const QString &errStr) -{ - error = err; - errorString = errStr; -} - -void -QFilePrivate::setError(QFile::FileError err, int errNum) -{ - error = err; - errorString = qt_error_string(errNum); -} - //************* QFile /*! @@ -278,98 +238,18 @@ QFilePrivate::setError(QFile::FileError err, int errNum) \sa QTextStream, QDataStream, QFileInfo, QDir, {The Qt Resource System} */ -/*! - \enum QFile::FileError - - This enum describes the errors that may be returned by the error() - function. - - \value NoError No error occurred. - \value ReadError An error occurred when reading from the file. - \value WriteError An error occurred when writing to the file. - \value FatalError A fatal error occurred. - \value ResourceError - \value OpenError The file could not be opened. - \value AbortError The operation was aborted. - \value TimeOutError A timeout occurred. - \value UnspecifiedError An unspecified error occurred. - \value RemoveError The file could not be removed. - \value RenameError The file could not be renamed. - \value PositionError The position in the file could not be changed. - \value ResizeError The file could not be resized. - \value PermissionsError The file could not be accessed. - \value CopyError The file could not be copied. - - \omitvalue ConnectError -*/ - -/*! - \enum QFile::Permission - - This enum is used by the permission() function to report the - permissions and ownership of a file. The values may be OR-ed - together to test multiple permissions and ownership values. - - \value ReadOwner The file is readable by the owner of the file. - \value WriteOwner The file is writable by the owner of the file. - \value ExeOwner The file is executable by the owner of the file. - \value ReadUser The file is readable by the user. - \value WriteUser The file is writable by the user. - \value ExeUser The file is executable by the user. - \value ReadGroup The file is readable by the group. - \value WriteGroup The file is writable by the group. - \value ExeGroup The file is executable by the group. - \value ReadOther The file is readable by anyone. - \value WriteOther The file is writable by anyone. - \value ExeOther The file is executable by anyone. - - \warning Because of differences in the platforms supported by Qt, - the semantics of ReadUser, WriteUser and ExeUser are - platform-dependent: On Unix, the rights of the owner of the file - are returned and on Windows the rights of the current user are - returned. This behavior might change in a future Qt version. - - Note that Qt does not by default check for permissions on NTFS - file systems, as this may decrease the performance of file - handling considerably. It is possible to force permission checking - on NTFS by including the following code in your source: - - \snippet doc/src/snippets/ntfsp.cpp 0 - - Permission checking is then turned on and off by incrementing and - decrementing \c qt_ntfs_permission_lookup by 1. - - \snippet doc/src/snippets/ntfsp.cpp 1 -*/ - -/*! - \enum QFile::FileHandleFlag - - This enum is used when opening a file to specify additional - options which only apply to files and not to a generic - QIODevice. - - \value AutoCloseHandle The file handle passed into open() should be - closed by close(), the default behavior is that close just flushes - the file and the application is responsible for closing the file handle. - When opening a file by name, this flag is ignored as Qt always owns the - file handle and must close it. - \value DontCloseHandle If not explicitly closed, the underlying file - handle is left open when the QFile object is destroyed. - */ - #ifdef QT_NO_QOBJECT QFile::QFile() - : QIODevice(*new QFilePrivate) + : QFileDevice(*new QFilePrivate) { } QFile::QFile(const QString &name) - : QIODevice(*new QFilePrivate) + : QFileDevice(*new QFilePrivate) { d_func()->fileName = name; } QFile::QFile(QFilePrivate &dd) - : QIODevice(dd) + : QFileDevice(dd) { } #else @@ -377,21 +257,21 @@ QFile::QFile(QFilePrivate &dd) \internal */ QFile::QFile() - : QIODevice(*new QFilePrivate, 0) + : QFileDevice(*new QFilePrivate, 0) { } /*! Constructs a new file object with the given \a parent. */ QFile::QFile(QObject *parent) - : QIODevice(*new QFilePrivate, parent) + : QFileDevice(*new QFilePrivate, parent) { } /*! Constructs a new file object to represent the file with the given \a name. */ QFile::QFile(const QString &name) - : QIODevice(*new QFilePrivate, 0) + : QFileDevice(*new QFilePrivate, 0) { Q_D(QFile); d->fileName = name; @@ -401,7 +281,7 @@ QFile::QFile(const QString &name) file with the specified \a name. */ QFile::QFile(const QString &name, QObject *parent) - : QIODevice(*new QFilePrivate, parent) + : QFileDevice(*new QFilePrivate, parent) { Q_D(QFile); d->fileName = name; @@ -410,7 +290,7 @@ QFile::QFile(const QString &name, QObject *parent) \internal */ QFile::QFile(QFilePrivate &dd, QObject *parent) - : QIODevice(dd, parent) + : QFileDevice(dd, parent) { } #endif @@ -420,7 +300,6 @@ QFile::QFile(QFilePrivate &dd, QObject *parent) */ QFile::~QFile() { - close(); } /*! @@ -961,20 +840,6 @@ QFile::copy(const QString &fileName, const QString &newName) return QFile(fileName).copy(newName); } -/*! - Returns true if the file can only be manipulated sequentially; - otherwise returns false. - - Most files support random-access, but some special files may not. - - \sa QIODevice::isSequential() -*/ -bool QFile::isSequential() const -{ - Q_D(const QFile); - return d->fileEngine && d->fileEngine->isSequential(); -} - /*! Opens the file using OpenMode \a mode, returning true if successful; otherwise false. @@ -1149,119 +1014,11 @@ bool QFile::open(int fd, OpenMode mode, FileHandleFlags handleFlags) } /*! - Returns the file handle of the file. - - This is a small positive integer, suitable for use with C library - functions such as fdopen() and fcntl(). On systems that use file - descriptors for sockets (i.e. Unix systems, but not Windows) the handle - can be used with QSocketNotifier as well. - - If the file is not open, or there is an error, handle() returns -1. - - This function is not supported on Windows CE. - - \sa QSocketNotifier -*/ - -int -QFile::handle() const -{ - Q_D(const QFile); - if (!isOpen() || !d->fileEngine) - return -1; - - return d->fileEngine->handle(); -} - -/*! - \enum QFile::MemoryMapFlags - \since 4.4 - - This enum describes special options that may be used by the map() - function. - - \value NoOptions No options. -*/ - -/*! - \since 4.4 - Maps \a size bytes of the file into memory starting at \a offset. A file - should be open for a map to succeed but the file does not need to stay - open after the memory has been mapped. When the QFile is destroyed - or a new file is opened with this object, any maps that have not been - unmapped will automatically be unmapped. - - Any mapping options can be passed through \a flags. - - Returns a pointer to the memory or 0 if there is an error. - - \note On Windows CE 5.0 the file will be closed before mapping occurs. - - \sa unmap() - */ -uchar *QFile::map(qint64 offset, qint64 size, MemoryMapFlags flags) -{ - Q_D(QFile); - if (d->engine() - && d->fileEngine->supportsExtension(QAbstractFileEngine::MapExtension)) { - unsetError(); - uchar *address = d->fileEngine->map(offset, size, flags); - if (address == 0) - d->setError(d->fileEngine->error(), d->fileEngine->errorString()); - return address; - } - return 0; -} - -/*! - \since 4.4 - Unmaps the memory \a address. - - Returns true if the unmap succeeds; false otherwise. - - \sa map() - */ -bool QFile::unmap(uchar *address) -{ - Q_D(QFile); - if (d->engine() - && d->fileEngine->supportsExtension(QAbstractFileEngine::UnMapExtension)) { - unsetError(); - bool success = d->fileEngine->unmap(address); - if (!success) - d->setError(d->fileEngine->error(), d->fileEngine->errorString()); - return success; - } - d->setError(PermissionsError, tr("No file engine available or engine does not support UnMapExtension")); - return false; -} - -/*! - Sets the file size (in bytes) \a sz. Returns true if the file if the - resize succeeds; false otherwise. If \a sz is larger than the file - currently is the new bytes will be set to 0, if \a sz is smaller the - file is simply truncated. - - \sa size(), setFileName() + \reimp */ - -bool -QFile::resize(qint64 sz) +bool QFile::resize(qint64 sz) { - Q_D(QFile); - if (!d->ensureFlushed()) - return false; - d->engine(); - if (isOpen() && d->fileEngine->pos() > sz) - seek(sz); - if(d->fileEngine->setSize(sz)) { - unsetError(); - d->cachedSize = sz; - return true; - } - d->cachedSize = 0; - d->setError(QFile::ResizeError, d->fileEngine->errorString()); - return false; + return QFileDevice::resize(sz); // for now } /*! @@ -1282,18 +1039,11 @@ QFile::resize(const QString &fileName, qint64 sz) } /*! - Returns the complete OR-ed together combination of - QFile::Permission for the file. - - \sa setPermissions(), setFileName() + \reimp */ - -QFile::Permissions -QFile::permissions() const +QFile::Permissions QFile::permissions() const { - Q_D(const QFile); - QAbstractFileEngine::FileFlags perms = d->engine()->fileFlags(QAbstractFileEngine::PermsMask) & QAbstractFileEngine::PermsMask; - return QFile::Permissions((int)perms); //ewww + return QFileDevice::permissions(); // for now } /*! @@ -1317,16 +1067,9 @@ QFile::permissions(const QString &fileName) \sa permissions(), setFileName() */ -bool -QFile::setPermissions(Permissions permissions) +bool QFile::setPermissions(Permissions permissions) { - Q_D(QFile); - if (d->engine()->setPermissions(permissions)) { - unsetError(); - return true; - } - d->setError(QFile::PermissionsError, d->fileEngine->errorString()); - return false; + return QFileDevice::setPermissions(permissions); // for now } /*! @@ -1341,354 +1084,12 @@ QFile::setPermissions(const QString &fileName, Permissions permissions) return QFile(fileName).setPermissions(permissions); } -static inline qint64 _qfile_writeData(QAbstractFileEngine *engine, QRingBuffer *buffer) -{ - qint64 ret = engine->write(buffer->readPointer(), buffer->nextDataBlockSize()); - if (ret > 0) - buffer->free(ret); - return ret; -} - -/*! - Flushes any buffered data to the file. Returns true if successful; - otherwise returns false. -*/ - -bool -QFile::flush() -{ - Q_D(QFile); - if (!d->fileEngine) { - qWarning("QFile::flush: No file engine. Is IODevice open?"); - return false; - } - - if (!d->writeBuffer.isEmpty()) { - qint64 size = d->writeBuffer.size(); - if (_qfile_writeData(d->fileEngine, &d->writeBuffer) != size) { - QFile::FileError err = d->fileEngine->error(); - if(err == QFile::UnspecifiedError) - err = QFile::WriteError; - d->setError(err, d->fileEngine->errorString()); - return false; - } - } - - if (!d->fileEngine->flush()) { - QFile::FileError err = d->fileEngine->error(); - if(err == QFile::UnspecifiedError) - err = QFile::WriteError; - d->setError(err, d->fileEngine->errorString()); - return false; - } - return true; -} - -/*! - Calls QFile::flush() and closes the file. Errors from flush are ignored. - - \sa QIODevice::close() -*/ -void -QFile::close() -{ - Q_D(QFile); - if(!isOpen()) - return; - bool flushed = flush(); - QIODevice::close(); - - // reset write buffer - d->lastWasWrite = false; - d->writeBuffer.clear(); - - // keep earlier error from flush - if (d->fileEngine->close() && flushed) - unsetError(); - else if (flushed) - d->setError(d->fileEngine->error(), d->fileEngine->errorString()); -} - -/*! - Returns the size of the file. - - For regular empty files on Unix (e.g. those in \c /proc), this function - returns 0; the contents of such a file are generated on demand in response - to you calling read(). -*/ - -qint64 QFile::size() const -{ - Q_D(const QFile); - if (!d->ensureFlushed()) - return 0; - d->cachedSize = d->engine()->size(); - return d->cachedSize; -} - -/*! - \reimp -*/ - -qint64 QFile::pos() const -{ - return QIODevice::pos(); -} - -/*! - Returns true if the end of the file has been reached; otherwise returns - false. - - For regular empty files on Unix (e.g. those in \c /proc), this function - returns true, since the file system reports that the size of such a file is - 0. Therefore, you should not depend on atEnd() when reading data from such a - file, but rather call read() until no more data can be read. -*/ - -bool QFile::atEnd() const -{ - Q_D(const QFile); - - // If there's buffered data left, we're not at the end. - if (!d->buffer.isEmpty()) - return false; - - if (!isOpen()) - return true; - - if (!d->ensureFlushed()) - return false; - - // If the file engine knows best, say what it says. - if (d->fileEngine->supportsExtension(QAbstractFileEngine::AtEndExtension)) { - // Check if the file engine supports AtEndExtension, and if it does, - // check if the file engine claims to be at the end. - return d->fileEngine->atEnd(); - } - - // if it looks like we are at the end, or if size is not cached, - // fall through to bytesAvailable() to make sure. - if (pos() < d->cachedSize) - return false; - - // Fall back to checking how much is available (will stat files). - return bytesAvailable() == 0; -} - -/*! - \fn bool QFile::seek(qint64 pos) - - For random-access devices, this function sets the current position - to \a pos, returning true on success, or false if an error occurred. - For sequential devices, the default behavior is to do nothing and - return false. - - Seeking beyond the end of a file: - If the position is beyond the end of a file, then seek() shall not - immediately extend the file. If a write is performed at this position, - then the file shall be extended. The content of the file between the - previous end of file and the newly written data is UNDEFINED and - varies between platforms and file systems. -*/ - -bool QFile::seek(qint64 off) -{ - Q_D(QFile); - if (!isOpen()) { - qWarning("QFile::seek: IODevice is not open"); - return false; - } - - if (!d->ensureFlushed()) - return false; - - if (!d->fileEngine->seek(off) || !QIODevice::seek(off)) { - QFile::FileError err = d->fileEngine->error(); - if(err == QFile::UnspecifiedError) - err = QFile::PositionError; - d->setError(err, d->fileEngine->errorString()); - return false; - } - unsetError(); - return true; -} - -/*! - \reimp -*/ -qint64 QFile::readLineData(char *data, qint64 maxlen) -{ - Q_D(QFile); - if (!d->ensureFlushed()) - return -1; - - qint64 read; - if (d->fileEngine->supportsExtension(QAbstractFileEngine::FastReadLineExtension)) { - read = d->fileEngine->readLine(data, maxlen); - } else { - // Fall back to QIODevice's readLine implementation if the engine - // cannot do it faster. - read = QIODevice::readLineData(data, maxlen); - } - - if (read < maxlen) { - // failed to read all requested, may be at the end of file, stop caching size so that it's rechecked - d->cachedSize = 0; - } - - return read; -} - -/*! - \reimp -*/ - -qint64 QFile::readData(char *data, qint64 len) -{ - Q_D(QFile); - unsetError(); - if (!d->ensureFlushed()) - return -1; - - qint64 read = d->fileEngine->read(data, len); - if(read < 0) { - QFile::FileError err = d->fileEngine->error(); - if(err == QFile::UnspecifiedError) - err = QFile::ReadError; - d->setError(err, d->fileEngine->errorString()); - } - - if (read < len) { - // failed to read all requested, may be at the end of file, stop caching size so that it's rechecked - d->cachedSize = 0; - } - - return read; -} - -/*! - \internal -*/ -bool QFilePrivate::putCharHelper(char c) -{ -#ifdef QT_NO_QOBJECT - return QIODevicePrivate::putCharHelper(c); -#else - - // Cutoff for code that doesn't only touch the buffer. - int writeBufferSize = writeBuffer.size(); - if ((openMode & QIODevice::Unbuffered) || writeBufferSize + 1 >= QFILE_WRITEBUFFER_SIZE -#ifdef Q_OS_WIN - || ((openMode & QIODevice::Text) && c == '\n' && writeBufferSize + 2 >= QFILE_WRITEBUFFER_SIZE) -#endif - ) { - return QIODevicePrivate::putCharHelper(c); - } - - if (!(openMode & QIODevice::WriteOnly)) { - if (openMode == QIODevice::NotOpen) - qWarning("QIODevice::putChar: Closed device"); - else - qWarning("QIODevice::putChar: ReadOnly device"); - return false; - } - - // Make sure the device is positioned correctly. - const bool sequential = isSequential(); - if (pos != devicePos && !sequential && !q_func()->seek(pos)) - return false; - - lastWasWrite = true; - - int len = 1; -#ifdef Q_OS_WIN - if ((openMode & QIODevice::Text) && c == '\n') { - ++len; - *writeBuffer.reserve(1) = '\r'; - } -#endif - - // Write to buffer. - *writeBuffer.reserve(1) = c; - - if (!sequential) { - pos += len; - devicePos += len; - if (!buffer.isEmpty()) - buffer.skip(len); - } - - return true; -#endif -} - /*! \reimp */ - -qint64 -QFile::writeData(const char *data, qint64 len) -{ - Q_D(QFile); - unsetError(); - d->lastWasWrite = true; - bool buffered = !(d->openMode & Unbuffered); - - // Flush buffered data if this read will overflow. - if (buffered && (d->writeBuffer.size() + len) > QFILE_WRITEBUFFER_SIZE) { - if (!flush()) - return -1; - } - - // Write directly to the engine if the block size is larger than - // the write buffer size. - if (!buffered || len > QFILE_WRITEBUFFER_SIZE) { - qint64 ret = d->fileEngine->write(data, len); - if(ret < 0) { - QFile::FileError err = d->fileEngine->error(); - if(err == QFile::UnspecifiedError) - err = QFile::WriteError; - d->setError(err, d->fileEngine->errorString()); - } - return ret; - } - - // Write to the buffer. - char *writePointer = d->writeBuffer.reserve(len); - if (len == 1) - *writePointer = *data; - else - ::memcpy(writePointer, data, len); - return len; -} - -/*! - Returns the file error status. - - The I/O device status returns an error code. For example, if open() - returns false, or a read/write operation returns -1, this function can - be called to find out the reason why the operation failed. - - \sa unsetError() -*/ - -QFile::FileError -QFile::error() const -{ - Q_D(const QFile); - return d->error; -} - -/*! - Sets the file's error to QFile::NoError. - - \sa error() -*/ -void -QFile::unsetError() +qint64 QFile::size() const { - Q_D(QFile); - d->setError(QFile::NoError); + return QFileDevice::size(); // for now } QT_END_NAMESPACE diff --git a/src/corelib/io/qfile.h b/src/corelib/io/qfile.h index 7f370d4214..0ee8f39d95 100644 --- a/src/corelib/io/qfile.h +++ b/src/corelib/io/qfile.h @@ -42,7 +42,7 @@ #ifndef QFILE_H #define QFILE_H -#include +#include #include #include @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE class QTemporaryFile; class QFilePrivate; -class Q_CORE_EXPORT QFile : public QIODevice +class Q_CORE_EXPORT QFile : public QFileDevice { #ifndef QT_NO_QOBJECT Q_OBJECT @@ -65,39 +65,6 @@ class Q_CORE_EXPORT QFile : public QIODevice Q_DECLARE_PRIVATE(QFile) public: - - enum FileError { - NoError = 0, - ReadError = 1, - WriteError = 2, - FatalError = 3, - ResourceError = 4, - OpenError = 5, - AbortError = 6, - TimeOutError = 7, - UnspecifiedError = 8, - RemoveError = 9, - RenameError = 10, - PositionError = 11, - ResizeError = 12, - PermissionsError = 13, - CopyError = 14 - }; - - enum Permission { - ReadOwner = 0x4000, WriteOwner = 0x2000, ExeOwner = 0x1000, - ReadUser = 0x0400, WriteUser = 0x0200, ExeUser = 0x0100, - ReadGroup = 0x0040, WriteGroup = 0x0020, ExeGroup = 0x0010, - ReadOther = 0x0004, WriteOther = 0x0002, ExeOther = 0x0001 - }; - Q_DECLARE_FLAGS(Permissions, Permission) - - enum FileHandleFlag { - AutoCloseHandle = 0x0001, - DontCloseHandle = 0 - }; - Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag) - QFile(); QFile(const QString &name); #ifndef QT_NO_QOBJECT @@ -106,9 +73,6 @@ public: #endif ~QFile(); - FileError error() const; - void unsetError(); - QString fileName() const; void setFileName(const QString &name); @@ -141,18 +105,11 @@ public: bool copy(const QString &newName); static bool copy(const QString &fileName, const QString &newName); - bool isSequential() const; - bool open(OpenMode flags); bool open(FILE *f, OpenMode ioFlags, FileHandleFlags handleFlags=DontCloseHandle); bool open(int fd, OpenMode ioFlags, FileHandleFlags handleFlags=DontCloseHandle); - virtual void close(); qint64 size() const; - qint64 pos() const; - bool seek(qint64 offset); - bool atEnd() const; - bool flush(); bool resize(qint64 sz); static bool resize(const QString &filename, qint64 sz); @@ -162,15 +119,6 @@ public: bool setPermissions(Permissions permissionSpec); static bool setPermissions(const QString &filename, Permissions permissionSpec); - int handle() const; - - enum MemoryMapFlags { - NoOptions = 0 - }; - - uchar *map(qint64 offset, qint64 size, MemoryMapFlags flags = NoOptions); - bool unmap(uchar *address); - protected: #ifdef QT_NO_QOBJECT QFile(QFilePrivate &dd); @@ -178,17 +126,11 @@ protected: QFile(QFilePrivate &dd, QObject *parent = 0); #endif - qint64 readData(char *data, qint64 maxlen); - qint64 writeData(const char *data, qint64 len); - qint64 readLineData(char *data, qint64 maxlen); - private: friend class QTemporaryFile; Q_DISABLE_COPY(QFile) }; -Q_DECLARE_OPERATORS_FOR_FLAGS(QFile::Permissions) - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/corelib/io/qfile_p.h b/src/corelib/io/qfile_p.h index 3d2d3d678b..575d7d14b9 100644 --- a/src/corelib/io/qfile_p.h +++ b/src/corelib/io/qfile_p.h @@ -53,15 +53,13 @@ // We mean it. // -#include "private/qabstractfileengine_p.h" -#include "private/qiodevice_p.h" -#include "private/qringbuffer_p.h" +#include "private/qfiledevice_p.h" QT_BEGIN_NAMESPACE class QTemporaryFile; -class QFilePrivate : public QIODevicePrivate +class QFilePrivate : public QFileDevicePrivate { Q_DECLARE_PUBLIC(QFile) friend class QTemporaryFile; @@ -76,20 +74,6 @@ protected: virtual QAbstractFileEngine *engine() const; QString fileName; - mutable QAbstractFileEngine *fileEngine; - - bool lastWasWrite; - QRingBuffer writeBuffer; - inline bool ensureFlushed() const; - - bool putCharHelper(char c); - - QFile::FileError error; - void setError(QFile::FileError err); - void setError(QFile::FileError err, const QString &errorString); - void setError(QFile::FileError err, int errNum); - - mutable qint64 cachedSize; private: static QFile::EncoderFn encoder; diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp new file mode 100644 index 0000000000..17eedb0bdd --- /dev/null +++ b/src/corelib/io/qfiledevice.cpp @@ -0,0 +1,736 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qplatformdefs.h" +#include "qfiledevice.h" +#include "qfiledevice_p.h" +#include "qfsfileengine_p.h" + +#ifdef QT_NO_QOBJECT +#define tr(X) QString::fromLatin1(X) +#endif + +QT_BEGIN_NAMESPACE + +static const int QFILE_WRITEBUFFER_SIZE = 16384; + +QFileDevicePrivate::QFileDevicePrivate() + : fileEngine(0), lastWasWrite(false), + writeBuffer(QFILE_WRITEBUFFER_SIZE), error(QFile::NoError), + cachedSize(0) +{ +} + +QFileDevicePrivate::~QFileDevicePrivate() +{ + delete fileEngine; + fileEngine = 0; +} + +QAbstractFileEngine * QFileDevicePrivate::engine() const +{ + if (!fileEngine) + fileEngine = new QFSFileEngine; + return fileEngine; +} + +void QFileDevicePrivate::setError(QFileDevice::FileError err) +{ + error = err; + errorString.clear(); +} + +void QFileDevicePrivate::setError(QFileDevice::FileError err, const QString &errStr) +{ + error = err; + errorString = errStr; +} + +void QFileDevicePrivate::setError(QFileDevice::FileError err, int errNum) +{ + error = err; + errorString = qt_error_string(errNum); +} + +/*! + \enum QFileDevice::FileError + + This enum describes the errors that may be returned by the error() + function. + + \value NoError No error occurred. + \value ReadError An error occurred when reading from the file. + \value WriteError An error occurred when writing to the file. + \value FatalError A fatal error occurred. + \value ResourceError + \value OpenError The file could not be opened. + \value AbortError The operation was aborted. + \value TimeOutError A timeout occurred. + \value UnspecifiedError An unspecified error occurred. + \value RemoveError The file could not be removed. + \value RenameError The file could not be renamed. + \value PositionError The position in the file could not be changed. + \value ResizeError The file could not be resized. + \value PermissionsError The file could not be accessed. + \value CopyError The file could not be copied. + + \omitvalue ConnectError +*/ + +/*! + \enum QFileDevice::Permission + + This enum is used by the permission() function to report the + permissions and ownership of a file. The values may be OR-ed + together to test multiple permissions and ownership values. + + \value ReadOwner The file is readable by the owner of the file. + \value WriteOwner The file is writable by the owner of the file. + \value ExeOwner The file is executable by the owner of the file. + \value ReadUser The file is readable by the user. + \value WriteUser The file is writable by the user. + \value ExeUser The file is executable by the user. + \value ReadGroup The file is readable by the group. + \value WriteGroup The file is writable by the group. + \value ExeGroup The file is executable by the group. + \value ReadOther The file is readable by anyone. + \value WriteOther The file is writable by anyone. + \value ExeOther The file is executable by anyone. + + \warning Because of differences in the platforms supported by Qt, + the semantics of ReadUser, WriteUser and ExeUser are + platform-dependent: On Unix, the rights of the owner of the file + are returned and on Windows the rights of the current user are + returned. This behavior might change in a future Qt version. + + Note that Qt does not by default check for permissions on NTFS + file systems, as this may decrease the performance of file + handling considerably. It is possible to force permission checking + on NTFS by including the following code in your source: + + \snippet doc/src/snippets/ntfsp.cpp 0 + + Permission checking is then turned on and off by incrementing and + decrementing \c qt_ntfs_permission_lookup by 1. + + \snippet doc/src/snippets/ntfsp.cpp 1 +*/ + +//************* QFileDevice + +/*! + \class QFileDevice + \since 5.0 + + \brief The QFileDevice class provides an interface for reading from and writing to open files. + + \ingroup io + + \reentrant + + QFileDevice is the base class for I/O devices that can read and write text and binary files + and \l{The Qt Resource System}{resources}. QFile offers the main functionality, + QFileDevice serves as a base class for sharing functionality with other file devices such + as QTemporaryFile, by providing all the operations that can be done on files that have + been opened by QFile or QTemporaryFile. + + \sa QFile, QTemporaryFile +*/ + +/*! + \enum QFileDevice::FileHandleFlag + + This enum is used when opening a file to specify additional + options which only apply to files and not to a generic + QIODevice. + + \value AutoCloseHandle The file handle passed into open() should be + closed by close(), the default behavior is that close just flushes + the file and the application is responsible for closing the file handle. + When opening a file by name, this flag is ignored as Qt always owns the + file handle and must close it. + \value DontCloseHandle If not explicitly closed, the underlying file + handle is left open when the QFile object is destroyed. + */ + +#ifdef QT_NO_QOBJECT +QFileDevice::QFileDevice() + : QIODevice(*new QFileDevicePrivate) +{ +} +QFileDevice::QFileDevice(QFileDevicePrivate &dd) + : QIODevice(dd) +{ +} +#else +/*! + \internal +*/ +QFileDevice::QFileDevice() + : QIODevice(*new QFileDevicePrivate, 0) +{ +} +/*! + \internal +*/ +QFileDevice::QFileDevice(QObject *parent) + : QIODevice(*new QFileDevicePrivate, parent) +{ +} +/*! + \internal +*/ +QFileDevice::QFileDevice(QFileDevicePrivate &dd, QObject *parent) + : QIODevice(dd, parent) +{ +} +#endif + +/*! + Destroys the file device, closing it if necessary. +*/ +QFileDevice::~QFileDevice() +{ + close(); +} + +/*! + Returns true if the file can only be manipulated sequentially; + otherwise returns false. + + Most files support random-access, but some special files may not. + + \sa QIODevice::isSequential() +*/ +bool QFileDevice::isSequential() const +{ + Q_D(const QFileDevice); + return d->fileEngine && d->fileEngine->isSequential(); +} + +/*! + Returns the file handle of the file. + + This is a small positive integer, suitable for use with C library + functions such as fdopen() and fcntl(). On systems that use file + descriptors for sockets (i.e. Unix systems, but not Windows) the handle + can be used with QSocketNotifier as well. + + If the file is not open, or there is an error, handle() returns -1. + + This function is not supported on Windows CE. + + \sa QSocketNotifier +*/ +int QFileDevice::handle() const +{ + Q_D(const QFileDevice); + if (!isOpen() || !d->fileEngine) + return -1; + + return d->fileEngine->handle(); +} + +/*! + Returns the name of the file. + The default implementation in QFileDevice returns QString(). +*/ +QString QFileDevice::fileName() const +{ + return QString(); +} + +static inline qint64 _qfile_writeData(QAbstractFileEngine *engine, QRingBuffer *buffer) +{ + qint64 ret = engine->write(buffer->readPointer(), buffer->nextDataBlockSize()); + if (ret > 0) + buffer->free(ret); + return ret; +} + +/*! + Flushes any buffered data to the file. Returns true if successful; + otherwise returns false. +*/ +bool QFileDevice::flush() +{ + Q_D(QFileDevice); + if (!d->fileEngine) { + qWarning("QFileDevice::flush: No file engine. Is IODevice open?"); + return false; + } + + if (!d->writeBuffer.isEmpty()) { + qint64 size = d->writeBuffer.size(); + if (_qfile_writeData(d->fileEngine, &d->writeBuffer) != size) { + QFileDevice::FileError err = d->fileEngine->error(); + if (err == QFileDevice::UnspecifiedError) + err = QFileDevice::WriteError; + d->setError(err, d->fileEngine->errorString()); + return false; + } + } + + if (!d->fileEngine->flush()) { + QFileDevice::FileError err = d->fileEngine->error(); + if (err == QFileDevice::UnspecifiedError) + err = QFileDevice::WriteError; + d->setError(err, d->fileEngine->errorString()); + return false; + } + return true; +} + +/*! + Calls QFileDevice::flush() and closes the file. Errors from flush are ignored. + + \sa QIODevice::close() +*/ +void QFileDevice::close() +{ + Q_D(QFileDevice); + if (!isOpen()) + return; + bool flushed = flush(); + QIODevice::close(); + + // reset write buffer + d->lastWasWrite = false; + d->writeBuffer.clear(); + + // keep earlier error from flush + if (d->fileEngine->close() && flushed) + unsetError(); + else if (flushed) + d->setError(d->fileEngine->error(), d->fileEngine->errorString()); +} + +/*! + \reimp +*/ +qint64 QFileDevice::pos() const +{ + return QIODevice::pos(); +} + +/*! + Returns true if the end of the file has been reached; otherwise returns + false. + + For regular empty files on Unix (e.g. those in \c /proc), this function + returns true, since the file system reports that the size of such a file is + 0. Therefore, you should not depend on atEnd() when reading data from such a + file, but rather call read() until no more data can be read. +*/ +bool QFileDevice::atEnd() const +{ + Q_D(const QFileDevice); + + // If there's buffered data left, we're not at the end. + if (!d->buffer.isEmpty()) + return false; + + if (!isOpen()) + return true; + + if (!d->ensureFlushed()) + return false; + + // If the file engine knows best, say what it says. + if (d->fileEngine->supportsExtension(QAbstractFileEngine::AtEndExtension)) { + // Check if the file engine supports AtEndExtension, and if it does, + // check if the file engine claims to be at the end. + return d->fileEngine->atEnd(); + } + + // if it looks like we are at the end, or if size is not cached, + // fall through to bytesAvailable() to make sure. + if (pos() < d->cachedSize) + return false; + + // Fall back to checking how much is available (will stat files). + return bytesAvailable() == 0; +} + +/*! + \fn bool QFileDevice::seek(qint64 pos) + + For random-access devices, this function sets the current position + to \a pos, returning true on success, or false if an error occurred. + For sequential devices, the default behavior is to do nothing and + return false. + + Seeking beyond the end of a file: + If the position is beyond the end of a file, then seek() shall not + immediately extend the file. If a write is performed at this position, + then the file shall be extended. The content of the file between the + previous end of file and the newly written data is UNDEFINED and + varies between platforms and file systems. +*/ +bool QFileDevice::seek(qint64 off) +{ + Q_D(QFileDevice); + if (!isOpen()) { + qWarning("QFileDevice::seek: IODevice is not open"); + return false; + } + + if (!d->ensureFlushed()) + return false; + + if (!d->fileEngine->seek(off) || !QIODevice::seek(off)) { + QFileDevice::FileError err = d->fileEngine->error(); + if (err == QFileDevice::UnspecifiedError) + err = QFileDevice::PositionError; + d->setError(err, d->fileEngine->errorString()); + return false; + } + unsetError(); + return true; +} + +/*! + \reimp +*/ +qint64 QFileDevice::readLineData(char *data, qint64 maxlen) +{ + Q_D(QFileDevice); + if (!d->ensureFlushed()) + return -1; + + qint64 read; + if (d->fileEngine->supportsExtension(QAbstractFileEngine::FastReadLineExtension)) { + read = d->fileEngine->readLine(data, maxlen); + } else { + // Fall back to QIODevice's readLine implementation if the engine + // cannot do it faster. + read = QIODevice::readLineData(data, maxlen); + } + + if (read < maxlen) { + // failed to read all requested, may be at the end of file, stop caching size so that it's rechecked + d->cachedSize = 0; + } + + return read; +} + +/*! + \reimp +*/ +qint64 QFileDevice::readData(char *data, qint64 len) +{ + Q_D(QFileDevice); + unsetError(); + if (!d->ensureFlushed()) + return -1; + + const qint64 read = d->fileEngine->read(data, len); + if (read < 0) { + QFileDevice::FileError err = d->fileEngine->error(); + if (err == QFileDevice::UnspecifiedError) + err = QFileDevice::ReadError; + d->setError(err, d->fileEngine->errorString()); + } + + if (read < len) { + // failed to read all requested, may be at the end of file, stop caching size so that it's rechecked + d->cachedSize = 0; + } + + return read; +} + +/*! + \internal +*/ +bool QFileDevicePrivate::putCharHelper(char c) +{ +#ifdef QT_NO_QOBJECT + return QIODevicePrivate::putCharHelper(c); +#else + + // Cutoff for code that doesn't only touch the buffer. + int writeBufferSize = writeBuffer.size(); + if ((openMode & QIODevice::Unbuffered) || writeBufferSize + 1 >= QFILE_WRITEBUFFER_SIZE +#ifdef Q_OS_WIN + || ((openMode & QIODevice::Text) && c == '\n' && writeBufferSize + 2 >= QFILE_WRITEBUFFER_SIZE) +#endif + ) { + return QIODevicePrivate::putCharHelper(c); + } + + if (!(openMode & QIODevice::WriteOnly)) { + if (openMode == QIODevice::NotOpen) + qWarning("QIODevice::putChar: Closed device"); + else + qWarning("QIODevice::putChar: ReadOnly device"); + return false; + } + + // Make sure the device is positioned correctly. + const bool sequential = isSequential(); + if (pos != devicePos && !sequential && !q_func()->seek(pos)) + return false; + + lastWasWrite = true; + + int len = 1; +#ifdef Q_OS_WIN + if ((openMode & QIODevice::Text) && c == '\n') { + ++len; + *writeBuffer.reserve(1) = '\r'; + } +#endif + + // Write to buffer. + *writeBuffer.reserve(1) = c; + + if (!sequential) { + pos += len; + devicePos += len; + if (!buffer.isEmpty()) + buffer.skip(len); + } + + return true; +#endif +} + +/*! + \reimp +*/ +qint64 QFileDevice::writeData(const char *data, qint64 len) +{ + Q_D(QFileDevice); + unsetError(); + d->lastWasWrite = true; + bool buffered = !(d->openMode & Unbuffered); + + // Flush buffered data if this read will overflow. + if (buffered && (d->writeBuffer.size() + len) > QFILE_WRITEBUFFER_SIZE) { + if (!flush()) + return -1; + } + + // Write directly to the engine if the block size is larger than + // the write buffer size. + if (!buffered || len > QFILE_WRITEBUFFER_SIZE) { + const qint64 ret = d->fileEngine->write(data, len); + if (ret < 0) { + QFileDevice::FileError err = d->fileEngine->error(); + if (err == QFileDevice::UnspecifiedError) + err = QFileDevice::WriteError; + d->setError(err, d->fileEngine->errorString()); + } + return ret; + } + + // Write to the buffer. + char *writePointer = d->writeBuffer.reserve(len); + if (len == 1) + *writePointer = *data; + else + ::memcpy(writePointer, data, len); + return len; +} + +/*! + Returns the file error status. + + The I/O device status returns an error code. For example, if open() + returns false, or a read/write operation returns -1, this function can + be called to find out the reason why the operation failed. + + \sa unsetError() +*/ +QFileDevice::FileError QFileDevice::error() const +{ + Q_D(const QFileDevice); + return d->error; +} + +/*! + Sets the file's error to QFileDevice::NoError. + + \sa error() +*/ +void QFileDevice::unsetError() +{ + Q_D(QFileDevice); + d->setError(QFileDevice::NoError); +} + +/*! + Returns the size of the file. + + For regular empty files on Unix (e.g. those in \c /proc), this function + returns 0; the contents of such a file are generated on demand in response + to you calling read(). +*/ +qint64 QFileDevice::size() const +{ + Q_D(const QFileDevice); + if (!d->ensureFlushed()) + return 0; + d->cachedSize = d->engine()->size(); + return d->cachedSize; +} + +/*! + Sets the file size (in bytes) \a sz. Returns true if the file if the + resize succeeds; false otherwise. If \a sz is larger than the file + currently is the new bytes will be set to 0, if \a sz is smaller the + file is simply truncated. + + \sa size() +*/ +bool QFileDevice::resize(qint64 sz) +{ + Q_D(QFileDevice); + if (!d->ensureFlushed()) + return false; + d->engine(); + if (isOpen() && d->fileEngine->pos() > sz) + seek(sz); + if (d->fileEngine->setSize(sz)) { + unsetError(); + d->cachedSize = sz; + return true; + } + d->cachedSize = 0; + d->setError(QFile::ResizeError, d->fileEngine->errorString()); + return false; +} + +/*! + Returns the complete OR-ed together combination of + QFile::Permission for the file. + + \sa setPermissions() +*/ +QFile::Permissions QFileDevice::permissions() const +{ + Q_D(const QFileDevice); + QAbstractFileEngine::FileFlags perms = d->engine()->fileFlags(QAbstractFileEngine::PermsMask) & QAbstractFileEngine::PermsMask; + return QFile::Permissions((int)perms); //ewww +} + +/*! + Sets the permissions for the file to the \a permissions specified. + Returns true if successful, or false if the permissions cannot be + modified. + + \sa permissions() +*/ +bool QFileDevice::setPermissions(Permissions permissions) +{ + Q_D(QFileDevice); + if (d->engine()->setPermissions(permissions)) { + unsetError(); + return true; + } + d->setError(QFile::PermissionsError, d->fileEngine->errorString()); + return false; +} + +/*! + \enum QFileDevice::MemoryMapFlags + \since 4.4 + + This enum describes special options that may be used by the map() + function. + + \value NoOptions No options. +*/ + +/*! + Maps \a size bytes of the file into memory starting at \a offset. A file + should be open for a map to succeed but the file does not need to stay + open after the memory has been mapped. When the QFile is destroyed + or a new file is opened with this object, any maps that have not been + unmapped will automatically be unmapped. + + Any mapping options can be passed through \a flags. + + Returns a pointer to the memory or 0 if there is an error. + + \note On Windows CE 5.0 the file will be closed before mapping occurs. + + \sa unmap() + */ +uchar *QFileDevice::map(qint64 offset, qint64 size, MemoryMapFlags flags) +{ + Q_D(QFileDevice); + if (d->engine() + && d->fileEngine->supportsExtension(QAbstractFileEngine::MapExtension)) { + unsetError(); + uchar *address = d->fileEngine->map(offset, size, flags); + if (address == 0) + d->setError(d->fileEngine->error(), d->fileEngine->errorString()); + return address; + } + return 0; +} + +/*! + Unmaps the memory \a address. + + Returns true if the unmap succeeds; false otherwise. + + \sa map() + */ +bool QFileDevice::unmap(uchar *address) +{ + Q_D(QFileDevice); + if (d->engine() + && d->fileEngine->supportsExtension(QAbstractFileEngine::UnMapExtension)) { + unsetError(); + bool success = d->fileEngine->unmap(address); + if (!success) + d->setError(d->fileEngine->error(), d->fileEngine->errorString()); + return success; + } + d->setError(PermissionsError, tr("No file engine available or engine does not support UnMapExtension")); + return false; +} + +QT_END_NAMESPACE diff --git a/src/corelib/io/qfiledevice.h b/src/corelib/io/qfiledevice.h new file mode 100644 index 0000000000..bbde91842c --- /dev/null +++ b/src/corelib/io/qfiledevice.h @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFILEDEVICE_H +#define QFILEDEVICE_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QFileDevicePrivate; + +class Q_CORE_EXPORT QFileDevice : public QIODevice +{ +#ifndef QT_NO_QOBJECT + Q_OBJECT +#endif + Q_DECLARE_PRIVATE(QFileDevice) + +public: + enum FileError { + NoError = 0, + ReadError = 1, + WriteError = 2, + FatalError = 3, + ResourceError = 4, + OpenError = 5, + AbortError = 6, + TimeOutError = 7, + UnspecifiedError = 8, + RemoveError = 9, + RenameError = 10, + PositionError = 11, + ResizeError = 12, + PermissionsError = 13, + CopyError = 14 + }; + + enum Permission { + ReadOwner = 0x4000, WriteOwner = 0x2000, ExeOwner = 0x1000, + ReadUser = 0x0400, WriteUser = 0x0200, ExeUser = 0x0100, + ReadGroup = 0x0040, WriteGroup = 0x0020, ExeGroup = 0x0010, + ReadOther = 0x0004, WriteOther = 0x0002, ExeOther = 0x0001 + }; + Q_DECLARE_FLAGS(Permissions, Permission) + + enum FileHandleFlag { + AutoCloseHandle = 0x0001, + DontCloseHandle = 0 + }; + Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag) + + ~QFileDevice(); + + FileError error() const; + void unsetError(); + + virtual void close(); + + bool isSequential() const; + + int handle() const; + virtual QString fileName() const; + + qint64 pos() const; + bool seek(qint64 offset); + bool atEnd() const; + bool flush(); + + qint64 size() const; + + virtual bool resize(qint64 sz); + virtual Permissions permissions() const; + virtual bool setPermissions(Permissions permissionSpec); + + enum MemoryMapFlags { + NoOptions = 0 + }; + + uchar *map(qint64 offset, qint64 size, MemoryMapFlags flags = NoOptions); + bool unmap(uchar *address); + +protected: + QFileDevice(); +#ifdef QT_NO_QOBJECT + QFileDevice(QFileDevicePrivate &dd); +#else + explicit QFileDevice(QObject *parent); + QFileDevice(QFileDevicePrivate &dd, QObject *parent = 0); +#endif + + qint64 readData(char *data, qint64 maxlen); + qint64 writeData(const char *data, qint64 len); + qint64 readLineData(char *data, qint64 maxlen); + +private: + Q_DISABLE_COPY(QFileDevice) +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QFileDevice::Permissions) + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QFILEDEVICE_H diff --git a/src/corelib/io/qfiledevice_p.h b/src/corelib/io/qfiledevice_p.h new file mode 100644 index 0000000000..2550cd73a2 --- /dev/null +++ b/src/corelib/io/qfiledevice_p.h @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFILEDEVICE_P_H +#define QFILEDEVICE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "private/qiodevice_p.h" +#include "private/qringbuffer_p.h" + +QT_BEGIN_NAMESPACE + +class QAbstractFileEngine; +class QFSFileEngine; + +class QFileDevicePrivate : public QIODevicePrivate +{ + Q_DECLARE_PUBLIC(QFileDevice) +protected: + QFileDevicePrivate(); + ~QFileDevicePrivate(); + + virtual QAbstractFileEngine *engine() const; + + QFileDevice::FileHandleFlags handleFlags; + + mutable QAbstractFileEngine *fileEngine; + bool lastWasWrite; + QRingBuffer writeBuffer; + inline bool ensureFlushed() const; + + bool putCharHelper(char c); + + QFileDevice::FileError error; + void setError(QFileDevice::FileError err); + void setError(QFileDevice::FileError err, const QString &errorString); + void setError(QFileDevice::FileError err, int errNum); + + mutable qint64 cachedSize; +}; + +inline bool QFileDevicePrivate::ensureFlushed() const +{ + // This function ensures that the write buffer has been flushed (const + // because certain const functions need to call it. + if (lastWasWrite) { + const_cast(this)->lastWasWrite = false; + if (!const_cast(q_func())->flush()) + return false; + } + return true; +} + +QT_END_NAMESPACE + +#endif // QFILEDEVICE_P_H -- cgit v1.2.3 From c78957766a5adba45289a0f7afe22949a183b34b Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 2 Mar 2012 20:33:55 +0100 Subject: QMimeDatabase: Fix crash on empty filename This is due to the search in the suffix tree starting at position fileName.length() - 1. Change-Id: I98501c1724c7dde2626351ace8ba19faa0d2e1e1 Reviewed-by: Ivan Komissarov Reviewed-by: Wolf-Michael Bolle --- src/corelib/mimetypes/qmimeprovider.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp index 8ef0ee8881..0c2f25a1f9 100644 --- a/src/corelib/mimetypes/qmimeprovider.cpp +++ b/src/corelib/mimetypes/qmimeprovider.cpp @@ -283,6 +283,8 @@ QMimeType QMimeBinaryProvider::mimeTypeForName(const QString &name) QStringList QMimeBinaryProvider::findByFileName(const QString &fileName, QString *foundSuffix) { checkCache(); + if (fileName.isEmpty()) + return QStringList(); const QString lowerFileName = fileName.toLower(); QMimeGlobMatchResult result; // TODO this parses in the order (local, global). Check that it handles "NOGLOBS" correctly. -- cgit v1.2.3 From e5dabe8338cb3dacf24079e315e07f2705fd0a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Mon, 5 Mar 2012 15:40:03 +0100 Subject: Improve safeness of QMetaType::registerType. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This internal function is abused by some modules to create dynamic types in metatype system. In Qt5 more non-optional arguments were added to the function and to keep temporary source compatibility an overload was created. QMetaType code assumes that every known type has properly defined basic operations like creation and destruction. Setting a helper function pointer to null value is asking for a crash, because the code doesn't check for that value, the null pointer may be called. Change-Id: I5ca7454a70c308e01de26fab23481b3c94c22371 Reviewed-by: João Abecasis --- src/corelib/kernel/qmetatype.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 003ad1c32d..410a5cc712 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -456,7 +456,7 @@ static int qMetaTypeCustomType_unlocked(const char *typeName, int length) int QMetaType::registerType(const char *typeName, Deleter deleter, Creator creator) { - return registerType(typeName, deleter, creator, 0, 0, 0, TypeFlags()); + return registerType(typeName, deleter, creator, qMetaTypeDestructHelper, qMetaTypeConstructHelper, 0, TypeFlags()); } /*! \internal @@ -474,7 +474,7 @@ int QMetaType::registerType(const char *typeName, Deleter deleter, int size, TypeFlags flags) { QVector *ct = customTypes(); - if (!ct || !typeName || !deleter || !creator) + if (!ct || !typeName || !deleter || !creator || !destructor || !constructor) return -1; #ifdef QT_NO_QOBJECT @@ -1331,6 +1331,7 @@ private: return; deleter = ct->at(type - QMetaType::User).deleter; } + Q_ASSERT_X(deleter, "void QMetaType::destroy(int type, void *data)", "The type was not properly registered"); deleter(where); } @@ -1393,6 +1394,7 @@ private: return 0; ctor = ct->at(type - QMetaType::User).constructor; } + Q_ASSERT_X(ctor, "void *QMetaType::construct(int type, void *where, const void *copy)", "The type was not properly registered"); return ctor(where, copy); } @@ -1481,6 +1483,7 @@ private: return; dtor = ct->at(type - QMetaType::User).destructor; } + Q_ASSERT_X(dtor, "void QMetaType::destruct(int type, void *where)", "The type was not properly registered"); dtor(where); } -- cgit v1.2.3 From 9f13a7d020749e936dfe0b4c0a1d46f4dbee810f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 2 Mar 2012 16:20:55 +0100 Subject: Make cache of opentype tables in Harfbuzz face lazy The mechanism in fontconfig which determines if a certain character is available (FcCharSetHasChar()) may give false positives, in which case we would load and unload those fonts per every char for which FC gave us a false positive. This was a major performance regression. Specifically the false positives happened when looking at e.g. italic variants of certain multilingual fonts, since we only check the charset of the font family as a whole and not of the specific variant, which may only support a subset of the chars. To optimize this, we remove the deletion of the font engines after loading them, but also wait with loading the opentype tables until they are actually needed. This means that for the false positives, we will load the font, but the cached data for each unused font will be much smaller. Change-Id: Idfc794401a2080da5946bf65204eb947aeb635ed Reviewed-by: Lars Knoll --- src/corelib/tools/qharfbuzz.cpp | 7 ++++++- src/corelib/tools/qharfbuzz_p.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qharfbuzz.cpp b/src/corelib/tools/qharfbuzz.cpp index 7d08547ab8..11126b814d 100644 --- a/src/corelib/tools/qharfbuzz.cpp +++ b/src/corelib/tools/qharfbuzz.cpp @@ -122,7 +122,12 @@ HB_Bool qShapeItem(HB_ShaperItem *item) HB_Face qHBNewFace(void *font, HB_GetFontTableFunc tableFunc) { - return HB_NewFace(font, tableFunc); + return HB_AllocFace(font, tableFunc); +} + +HB_Face qHBLoadFace(HB_Face face) +{ + return HB_LoadFace(face); } void qHBFreeFace(HB_Face face) diff --git a/src/corelib/tools/qharfbuzz_p.h b/src/corelib/tools/qharfbuzz_p.h index cc575ddffa..3cef3a55dd 100644 --- a/src/corelib/tools/qharfbuzz_p.h +++ b/src/corelib/tools/qharfbuzz_p.h @@ -68,6 +68,7 @@ Q_CORE_EXPORT HB_Bool qShapeItem(HB_ShaperItem *item); // ### temporary Q_CORE_EXPORT HB_Face qHBNewFace(void *font, HB_GetFontTableFunc tableFunc); Q_CORE_EXPORT void qHBFreeFace(HB_Face); +Q_CORE_EXPORT HB_Face qHBLoadFace(HB_Face face); Q_DECLARE_TYPEINFO(HB_GlyphAttributes, Q_PRIMITIVE_TYPE); Q_DECLARE_TYPEINFO(HB_FixedPoint, Q_PRIMITIVE_TYPE); -- cgit v1.2.3 From 9a5c728e4664cdd22ab999a9c7c15b7ed4965ce1 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 1 Mar 2012 08:42:54 +0100 Subject: QStateMachine: make ctor explicit Change-Id: I727129b52daeb0d54685d530f034d41896d1da0f Reviewed-by: Stephen Kelly --- src/corelib/statemachine/qstatemachine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h index c9c60976d1..b3aeb41016 100644 --- a/src/corelib/statemachine/qstatemachine.h +++ b/src/corelib/statemachine/qstatemachine.h @@ -119,7 +119,7 @@ public: NoCommonAncestorForTransitionError }; - QStateMachine(QObject *parent = 0); + explicit QStateMachine(QObject *parent = 0); ~QStateMachine(); void addState(QAbstractState *state); -- cgit v1.2.3 From eb24dfcccb304c84a147f0eafd3b3fc3df3ef4f3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 2 Mar 2012 14:48:09 +0100 Subject: Add template specialization of QMetaType for QObject derived pointers. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes it possible to do things like QVariant::fromValue(new SomeObject); without first using Q_DECLARE_METATYPE(Something*) This functionality was originally part of http://codereview.qt-project.org/#change,11710 but was rejected because the functionality was based on specialization of QVariant::fromValue which could be dangerous. This new implementation doesn't have such danger. Change-Id: I83fe941b6984be54469bc6b9191f6eacaceaa036 Reviewed-by: JÄ™drzej Nowacki Reviewed-by: Olivier Goffart --- src/corelib/kernel/qmetatype.h | 75 ++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 24 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index f969875455..06ada136a6 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -364,33 +364,11 @@ void qMetaTypeLoadHelper(QDataStream &stream, void *t) template <> inline void qMetaTypeLoadHelper(QDataStream &, void *) {} #endif // QT_NO_DATASTREAM -template -struct QMetaTypeId -{ - enum { Defined = 0 }; -}; - -template -struct QMetaTypeId2 -{ - enum { Defined = QMetaTypeId::Defined }; - static inline int qt_metatype_id() { return QMetaTypeId::qt_metatype_id(); } -}; - class QObject; class QWidget; -namespace QtPrivate { - template ::Defined> - struct QMetaTypeIdHelper { - static inline int qt_metatype_id() - { return QMetaTypeId2::qt_metatype_id(); } - }; - template struct QMetaTypeIdHelper { - static inline int qt_metatype_id() - { return -1; } - }; - +namespace QtPrivate +{ template struct IsPointerToTypeDerivedFromQObject { @@ -427,6 +405,38 @@ namespace QtPrivate { Q_STATIC_ASSERT_X(sizeof(T), "Type argument of Q_DECLARE_METATYPE(T*) must be fully defined"); enum { Value = sizeof(checkType(static_cast(0))) == sizeof(yes_type) }; }; +} + +template ::Value> +struct QMetaTypeIdQObject +{ + enum { + Defined = 0 + }; +}; + +template +struct QMetaTypeId : public QMetaTypeIdQObject +{ +}; + +template +struct QMetaTypeId2 +{ + enum { Defined = QMetaTypeId::Defined }; + static inline int qt_metatype_id() { return QMetaTypeId::qt_metatype_id(); } +}; + +namespace QtPrivate { + template ::Defined> + struct QMetaTypeIdHelper { + static inline int qt_metatype_id() + { return QMetaTypeId2::qt_metatype_id(); } + }; + template struct QMetaTypeIdHelper { + static inline int qt_metatype_id() + { return -1; } + }; // Function pointers don't derive from QObject template struct IsPointerToTypeDerivedFromQObject { enum { Value = false }; }; @@ -501,6 +511,23 @@ inline int qRegisterMetaType( #endif } +template +struct QMetaTypeIdQObject +{ + enum { + Defined = 1 + }; + + static int qt_metatype_id() + { + static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); + if (!metatype_id.load()) + metatype_id.storeRelease(qRegisterMetaType(QByteArray(T::staticMetaObject.className() + QByteArrayLiteral("*")).constData(), + reinterpret_cast(quintptr(-1)))); + return metatype_id.loadAcquire(); + } +}; + #ifndef QT_NO_DATASTREAM template inline int qRegisterMetaTypeStreamOperators() -- cgit v1.2.3 From 38d566f7131c3f7a1016ab5fe768e6e9a5c8e54e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 2 Mar 2012 15:56:19 +0100 Subject: Cleanup QThread::initialize and QThread::cleanup The qt_global_mutexpool was private API deprecated long time ago. And there is no reason to call qt_create_tls because it is called in QThreadData::current that is called from the QObject constructor, even before QCoreApplication::init can be called. Change-Id: Idf3576d8591377811b727b12edc43dc898570ba4 Reviewed-by: Bradley T. Hughes --- src/corelib/kernel/qcoreapplication.cpp | 5 ----- src/corelib/thread/qmutexpool.cpp | 3 --- src/corelib/thread/qmutexpool_p.h | 2 -- src/corelib/thread/qthread.cpp | 28 ---------------------------- src/corelib/thread/qthread.h | 3 --- 5 files changed, 41 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 184743e865..967ed447d5 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -543,10 +543,6 @@ void QCoreApplication::init() Q_ASSERT_X(!self, "QCoreApplication", "there should be only one application object"); QCoreApplication::self = this; -#ifndef QT_NO_THREAD - QThread::initialize(); -#endif - // use the event dispatcher created by the app programmer (if any) if (!QCoreApplicationPrivate::eventDispatcher) QCoreApplicationPrivate::eventDispatcher = d->threadData->eventDispatcher; @@ -602,7 +598,6 @@ QCoreApplication::~QCoreApplication() } if (globalThreadPool) globalThreadPool->waitForDone(); - QThread::cleanup(); #endif d_func()->threadData->eventDispatcher = 0; diff --git a/src/corelib/thread/qmutexpool.cpp b/src/corelib/thread/qmutexpool.cpp index b102770d23..6b6674ccdf 100644 --- a/src/corelib/thread/qmutexpool.cpp +++ b/src/corelib/thread/qmutexpool.cpp @@ -46,9 +46,6 @@ QT_BEGIN_NAMESPACE -// qt_global_mutexpool is here for backwards compatibility only, -// use QMutexpool::instance() in new clode. -Q_CORE_EXPORT QMutexPool *qt_global_mutexpool = 0; Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (QMutex::Recursive)) /*! diff --git a/src/corelib/thread/qmutexpool_p.h b/src/corelib/thread/qmutexpool_p.h index ce55a40bb8..f5428bed52 100644 --- a/src/corelib/thread/qmutexpool_p.h +++ b/src/corelib/thread/qmutexpool_p.h @@ -84,8 +84,6 @@ private: QMutex::RecursionMode recursionMode; }; -extern Q_CORE_EXPORT QMutexPool *qt_global_mutexpool; - QT_END_NAMESPACE #endif // QT_NO_THREAD diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 64fd8776ce..ea6760a1b9 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -42,7 +42,6 @@ #include "qthread.h" #include "qthreadstorage.h" #include "qmutex.h" -#include "qmutexpool_p.h" #include "qreadwritelock.h" #include "qabstracteventdispatcher.h" @@ -537,33 +536,6 @@ void QThread::run() (void) exec(); } -/*! \internal - Initializes the QThread system. -*/ -#if defined (Q_OS_WIN) -void qt_create_tls(); -#endif - -void QThread::initialize() -{ - if (qt_global_mutexpool) - return; - qt_global_mutexpool = QMutexPool::instance(); - -#if defined (Q_OS_WIN) - qt_create_tls(); -#endif -} - - -/*! \internal - Cleans up the QThread system. -*/ -void QThread::cleanup() -{ - qt_global_mutexpool = 0; -} - /*! \fn void QThread::setPriority(Priority priority) \since 4.1 diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index ba119afb5d..953632c6fc 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -128,9 +128,6 @@ private: Q_OBJECT Q_DECLARE_PRIVATE(QThread) - static void initialize(); - static void cleanup(); - friend class QCoreApplication; friend class QThreadData; }; -- cgit v1.2.3 From 1e6514a714c1f55b9cb57d2b8b65bc2305c2e2c6 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 2 Mar 2012 16:18:52 +0100 Subject: Don't use QMutexPool from the animation framework Use a plain QBasicMutex instead Change-Id: I1abd35b4fe4e9f0401e73c7c3f503b00bba2baa9 Reviewed-by: Bradley T. Hughes --- src/corelib/animation/qpropertyanimation.cpp | 5 +++-- src/corelib/animation/qvariantanimation.cpp | 22 ++++++++++------------ 2 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index fc51a20a15..83ae7bafaa 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -92,7 +92,7 @@ #include "qanimationgroup.h" #include "qpropertyanimation_p.h" -#include +#include #ifndef QT_NO_ANIMATION @@ -268,7 +268,8 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State newState, QPropertyAnimation *animToStop = 0; { #ifndef QT_NO_THREAD - QMutexLocker locker(QMutexPool::globalInstanceGet(&staticMetaObject)); + static QBasicMutex mutex; + QMutexLocker locker(&mutex); #endif typedef QPair QPropertyAnimationPair; typedef QHash QPropertyAnimationHash; diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index 2262a3836e..59b2d6abf3 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -45,7 +45,6 @@ #include #include #include -#include #ifndef QT_NO_ANIMATION @@ -399,6 +398,7 @@ void QVariantAnimation::setEasingCurve(const QEasingCurve &easing) typedef QVector QInterpolatorVector; Q_GLOBAL_STATIC(QInterpolatorVector, registeredInterpolators) +static QBasicMutex registeredInterpolatorsMutex; /*! \fn void qRegisterAnimationInterpolator(QVariant (*func)(const T &from, const T &to, qreal progress)) @@ -435,9 +435,7 @@ void QVariantAnimation::registerInterpolator(QVariantAnimation::Interpolator fun // in such an order that we get here with interpolators == NULL, // to continue causes the app to crash on exit with a SEGV if (interpolators) { -#ifndef QT_NO_THREAD - QMutexLocker locker(QMutexPool::globalInstanceGet(interpolators)); -#endif + QMutexLocker locker(®isteredInterpolatorsMutex); if (int(interpolationType) >= interpolators->count()) interpolators->resize(int(interpolationType) + 1); interpolators->replace(interpolationType, func); @@ -452,14 +450,14 @@ template static inline QVariantAnimation::Interpolator castToInterpo QVariantAnimation::Interpolator QVariantAnimationPrivate::getInterpolator(int interpolationType) { - QInterpolatorVector *interpolators = registeredInterpolators(); -#ifndef QT_NO_THREAD - QMutexLocker locker(QMutexPool::globalInstanceGet(interpolators)); -#endif - QVariantAnimation::Interpolator ret = 0; - if (interpolationType < interpolators->count()) { - ret = interpolators->at(interpolationType); - if (ret) return ret; + { + QInterpolatorVector *interpolators = registeredInterpolators(); + QMutexLocker locker(®isteredInterpolatorsMutex); + QVariantAnimation::Interpolator ret = 0; + if (interpolationType < interpolators->count()) { + ret = interpolators->at(interpolationType); + if (ret) return ret; + } } switch(interpolationType) -- cgit v1.2.3 From 8bf6d6a6caadd4db36bb36d7de7ccb76dd031452 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 2 Mar 2012 15:39:50 +0100 Subject: Don't use QMutexPool in QEventDispatcher Use a QBasicMutex, there is no extra cost of having a mutex for this. Change-Id: Ib5b01338649002c0c21f018b2c931a8cc68027f6 Reviewed-by: Bradley T. Hughes --- src/corelib/kernel/qeventdispatcher_glib.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp index 4adcb7678c..3f272a2512 100644 --- a/src/corelib/kernel/qeventdispatcher_glib.cpp +++ b/src/corelib/kernel/qeventdispatcher_glib.cpp @@ -42,7 +42,6 @@ #include "qeventdispatcher_glib_p.h" #include "qeventdispatcher_unix_p.h" -#include #include #include "qcoreapplication.h" @@ -295,8 +294,8 @@ QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(GMainContext *context) : mainContext(context) { if (qgetenv("QT_NO_THREADED_GLIB").isEmpty()) { - static int dummyValue = 0; // only used for its address - QMutexLocker locker(QMutexPool::instance()->get(&dummyValue)); + static QBasicMutex mutex; + QMutexLocker locker(&mutex); if (!g_thread_supported()) g_thread_init(NULL); } -- cgit v1.2.3 From 3ff7bc086b9ae3d7288e6a4e1f96974b77105ae0 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 6 Mar 2012 10:18:14 +0100 Subject: QProcess/Win: pointless Sleep call removed Change-Id: I634c62d3a0f96bc074e815dfd4106b6187f4ba85 Reviewed-by: Friedemann Kleint Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess_win.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index a52fd46c97..f7c2f965d5 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -530,8 +530,6 @@ void QProcessPrivate::startProcess() notifier->start(NOTIFYTIMEOUT); } - // give the process a chance to start ... - Sleep(SLEEPMIN * 2); _q_startupNotification(); } -- cgit v1.2.3 From 092a270afde4fade3dbe36fde7156e5a462a13cb Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 5 Mar 2012 21:03:09 +0100 Subject: fix relative default examples path copy&pasto ... Change-Id: I73ab90f31f2a2250abe1ec9aeea975122ff319cb Reviewed-by: Joerg Bornemann Reviewed-by: Mark Brand --- src/corelib/global/qlibraryinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 4caacece2d..cb4e0e753f 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -226,7 +226,7 @@ static const struct { { "Imports", "imports" }, { "Data", "" }, { "Translations", "translations" }, - { "Examples", "" }, + { "Examples", "examples" }, { "Tests", "tests" }, #ifdef QT_BUILD_QMAKE { "Sysroot", "" }, -- cgit v1.2.3 From c7cb455a47c42e8e658e3433defee613f8643cd2 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 23 Jan 2012 22:47:59 +0000 Subject: QRegularExpression: add QRegularExpression* set of classes Added QRegularExpression, QRegularExpressionMatch and QRegularExpressionMatchIterator as PCRE-enabled, regexp classes. Documentation is included, as well as a first round of autotests. Task-number: QTBUG-23489 Change-Id: Id47031b80602c913ccd2fd740070e3024ea06abc Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- src/corelib/tools/qregularexpression.cpp | 2022 ++++++++++++++++++++++++++++++ src/corelib/tools/qregularexpression.h | 245 ++++ src/corelib/tools/tools.pri | 8 + 3 files changed, 2275 insertions(+) create mode 100644 src/corelib/tools/qregularexpression.cpp create mode 100644 src/corelib/tools/qregularexpression.h (limited to 'src/corelib') diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp new file mode 100644 index 0000000000..488a454aaa --- /dev/null +++ b/src/corelib/tools/qregularexpression.cpp @@ -0,0 +1,2022 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Giuseppe D'Angelo . +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qregularexpression.h" + +#include +#include +#include +#include +#include + +#include + +// after how many usages we optimize the regexp +static const unsigned int OPTIMIZE_AFTER_USE_COUNT = 10; + +QT_BEGIN_NAMESPACE + +/*! + \class QRegularExpression + \reentrant + + \brief The QRegularExpression class provides pattern matching using regular + expressions. + + \since 5.0 + + \ingroup tools + \ingroup shared + + \keyword regular expression + + Regular expressions, or \e{regexps}, are a very powerful tool to handle + strings and texts. This is useful in many contexts, e.g., + + \table + \row \i Validation + \i A regexp can test whether a substring meets some criteria, + e.g. is an integer or contains no whitespace. + \row \i Searching + \i A regexp provides more powerful pattern matching than + simple substring matching, e.g., match one of the words + \e{mail}, \e{letter} or \e{correspondence}, but none of the + words \e{email}, \e{mailman}, \e{mailer}, \e{letterbox}, etc. + \row \i Search and Replace + \i A regexp can replace all occurrences of a substring with a + different substring, e.g., replace all occurrences of \e{&} + with \e{\&} except where the \e{&} is already followed by + an \e{amp;}. + \row \i String Splitting + \i A regexp can be used to identify where a string should be + split apart, e.g. splitting tab-delimited strings. + \endtable + + This document is by no means a complete reference to pattern matching using + regular expressions, and the following parts will require the reader to + have some basic knowledge about Perl-like regular expressions and their + pattern syntax. + + Good references about regular expressions include: + + \list + \o \e {Mastering Regular Expressions} (Third Edition) by Jeffrey E. F. + Friedl, ISBN 0-596-52812-4; + \o the \l{http://pcre.org/pcre.txt} {pcrepattern(3)} man page, describing + the pattern syntax supported by PCRE (the reference implementation of + Perl-compatible regular expressions); + \o the \l{http://perldoc.perl.org/perlre.html} {Perl's regular expression + documentation} and the \l{http://perldoc.perl.org/perlretut.html} {Perl's + regular expression tutorial}. + \endlist + + \tableofcontents + + \section1 Introduction + + QRegularExpression implements Perl-compatible regular expressions. It fully + supports Unicode. For an overview of the regular expression syntax + supported by QRegularExpression, please refer to the aforementioned + pcrepattern(3) man page. A regular expression is made up of two things: a + \bold{pattern string} and a set of \bold{pattern options} that change the + meaning of the pattern string. + + You can set the pattern string by passing a string to the QRegularExpression + constructor: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 0 + + This sets the pattern string to \c{a pattern}. You can also use the + setPattern() function to set a pattern on an existing QRegularExpression + object: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 1 + + Note that due to C++ literal strings rules, you must escape all backslashes + inside the pattern string with another backslash: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 2 + + The pattern() function returns the pattern that it's currently set for a + QRegularExpression object: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 3 + + \section1 Pattern options + + The meaning of the pattern string can be modified by setting one or more + \e{pattern options}. For instance, it is possible to set a pattern to match + case insensitively by setting the QRegularExpression::CaseInsensitiveOption. + + You can set the options by passing them to the QRegularExpression + constructor, as in: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 4 + + Alternatively, you can use the setPatternOptions() function on an existing + QRegularExpressionObject: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 5 + + It is possible to get the pattern options currently set on a + QRegularExpression object by using the patternOptions() function: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 6 + + Please refer to the QRegularExpression::PatternOption enum documentation for + more information about each pattern option. + + \section1 Match type and match options + + The last two arguments of the match() and the globalMatch() functions set + the match type and the match options. The match type is a value of the + QRegularExpression::MatchType enum; the "traditional" matching algorithm is + chosen by using the NormalMatch match type (the default). It is also + possible to enable partial matching of the regular expression against a + subject string: see the \l{partial matching} section for more details. + + The match options are a set of one or more QRegularExpression::MatchOption + values. They change the way a specific match of a regular expression + against a subject string is done. Please refer to the + QRegularExpression::MatchOption enum documentation for more details. + + \target normal matching + \section1 Normal matching + + In order to perform a match you can simply invoke the match() function + passing a string to match against. We refer to this string as the + \e{subject string}. The result of the match() function is a + QRegularExpressionMatch object that can be used to inspect the results of + the match. For instance: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 7 + + If a match is successful, the (implicit) capturing group number 0 can be + used to retrieve the substring matched by the entire pattern (see also the + section about \l{extracting captured substrings}): + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 8 + + It's also possible to start a match at an arbitrary offset inside the + subject string by passing the offset as an argument of the + match() function. In the following example \c{"12 abc"} + is not matched because the match is started at offset 1: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 9 + + \target extracting captured substrings + \section2 Extracting captured substrings + + The QRegularExpressionMatch object contains also information about the + substrings captured by the capturing groups in the pattern string. The + \l{QRegularExpressionMatch::}{captured()} function will return the string + captured by the n-th capturing group: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 10 + + Capturing groups in the pattern are numbered starting from 1, and the + implicit capturing group 0 is used to capture the substring that matched + the entire pattern. + + It's also possible to retrieve the starting and the ending offsets (inside + the subject string) of each captured substring, by using the + \l{QRegularExpressionMatch::}{capturedStart()} and the + \l{QRegularExpressionMatch::}{capturedEnd()} functions: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 11 + + All of these functions have an overload taking a QString as a parameter + in order to extract \e{named} captured substrings. For instance: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 12 + + \target global matching + \section1 Global matching + + \e{Global matching} is useful to find all the occurrences of a given + regular expression inside a subject string. Suppose that we want to extract + all the words from a given string, where a word is a substring matching + the pattern \c{\w+}. + + QRegularExpression::globalMatch returns a QRegularExpressionMatchIterator, + which is a Java-like forward iterator that can be used to iterate over the + results. For instance: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 13 + + Since it's a Java-like iterator, the QRegularExpressionMatchIterator will + point immediately before the first result. Every result is returned as a + QRegularExpressionMatch object. The + \l{QRegularExpressionMatchIterator::}{hasNext()} function will return true + if there's at least one more result, and + \l{QRegularExpressionMatchIterator::}{next()} will return the next result + and advance the iterator. Continuing from the previous example: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 14 + + You can also use \l{QRegularExpressionMatchIterator::}{peekNext()} to get + the next result without advancing the iterator. + + It is possible to pass a starting offset and one or more match options to + the globalMatch() function, exactly like normal matching with match(). + + \target partial matching + \section1 Partial matching + + A \e{partial match} is obtained when the end of the subject string is + reached, but more characters are needed to successfully complete the match. + Note that a partial match is usually much more inefficient than a normal + match because many optimizations of the matching algorithm cannot be + employed. + + A partial match must be explicitly requested by specifying a match type of + PartialPreferCompleteMatch or PartialPreferFirstMatch when calling + QRegularExpression::match or QRegularExpression::globalMatch. If a partial + match is found, then calling the \l{QRegularExpressionMatch::}{hasMatch()} + function on the QRegularExpressionMatch object returned by match() will + return \c{false}, but \l{QRegularExpressionMatch::}{hasPartialMatch()} will return + \c{true}. + + When a partial match is found, no captured substrings are returned, and the + (implicit) capturing group 0 corresponding to the whole match captures the + partially matched substring of the subject string. + + Note that asking for a partial match can still lead to a complete match, if + one is found; in this case, \l{QRegularExpressionMatch::}{hasMatch()} will + return \c{true} and \l{QRegularExpressionMatch::}{hasPartialMatch()} + \c{false}. It never happens that a QRegularExpressionMatch reports both a + partial and a complete match. + + Partial matching is mainly useful in two scenarios: validating user input + in real time and incremental/multi-segment matching. + + \target + \section2 Validating user input + + Suppose that we would like the user to input a date in a specific + format, for instance "MMM dd, yyyy". We can check the input validity with + a pattern like: + + \c{^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d\d?, \d\d\d\d$} + + (This pattern doesn't catch invalid days, but let's keep it for the + example's purposes). + + We would like to validate the input with this regular expression \e{while} + the user is typing it, so that we can report an error in the input as soon + as it is committed (for instance, the user typed the wrong key). In order + to do so we must distinguish three cases: + + \list + \o the input cannot possibly match the regular expression; + \o the input does match the regular expression; + \o the input does not match the regular expression right now, + but it will if more charaters will be added to it. + \endlist + + Note that these three cases represent exactly the possible states of a + QValidator (see the QValidator::State enum). + + In particular, in the last case we want the regular expression engine to + report a partial match: we are successfully matching the pattern against + the subject string but the matching cannot continue because the end of the + subject is encountered. Notice, however, that the matching algorithm should + continue and try all possibilities, and in case a complete (non-partial) + match is found, then this one should be reported, and the input string + accepted as fully valid. + + This behaviour is implemented by the PartialPreferCompleteMatch match type. + For instance: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 15 + + If matching the same regular expression against the subject string leads to + a complete match, it is reported as usual: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 16 + + Another example with a different pattern, showing the behaviour of + preferring a complete match over a partial one: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 17 + + In this case, the subpattern \c{abc\\w+X} partially matches the subject + string; however, the subpattern \c{def} matches the subject string + completely, and therefore a complete match is reported. + + In case multiple partial matches are found when matching (but no complete + match), then the QRegularExpressionMatch will report the first one that it + is found. For instance: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 18 + + \section2 Incremental/multi-segment matching + + Incremental matching is another use case of partial matching. Suppose that + we want to find the occurrences of a regular expression inside a large text + (that is, substrings matching the regular expression). In order to do so we + would like to "feed" the large text to the regular expression engines in + smaller chunks. The obvious problem is what happens if the substring that + matches the regular expression spans across two or more chunks. + + In this case, the regular expression engine should report a partial match, + so that we can match again adding new data and (eventually) get a complete + match. This implies that the regular expression engine may assume that + there are other characters \e{beyond the end} of the subject string. This + is not to be taken literally -- the engine will never try to access + any character after the last one in the subject. + + QRegularExpression implements this behaviour when using the + PartialPreferFirstMatch match type. This match type reports a partial match + as soon as it is found, and other match alternatives are not tried + (even if they could lead to a complete match). For instance: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 19 + + This happens because when matching the first branch of the alternation + operator a partial match is found, and therefore matching stops, without + trying the second branch. Another example: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 20 + + This shows what could seem a counterintuitve behaviour of quantifiers: + since \c{?} is greedy, then the engine tries first to continue the match + after having matched \c{"abc"}; but then the matching reaches the end of the + subject string, and therefore a partial match is reported. This is + even more surprising in the following example: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 21 + + It's easy to understand this behaviour if we remember that the engine + expects the subject string to be only a substring of the whole text we're + looking for a match into (that is, how we said before, that the engine + assumes that there are other characters beyond the end of the subject + string). + + Since the \c{*} quantifier is greedy, then reporting a complete match could + be an error, because after the current subject \c{"abc"} there may be other + occurrences of \c{"abc"}. For instance, the complete text could have been + "abcabcX", and therefore the \e{right} match to report (in the complete + text) would have been \c{"abcabc"}; by matching only against the leading + \c{"abc"} we instead get a partial match. + + \section1 Error handling + + It is possible for a QRegularExpression object to be invalid because of + syntax errors in the pattern string. The isValid() function will return + true if the regular expression is valid, or false otherwise: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 22 + + You can get more information about the specific error by calling the + errorString() function; moreover, the patternErrorOffset() function + will return the offset inside the pattern string + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 23 + + If a match is attempted with an invalid QRegularExpression, then the + returned QRegularExpressionMatch object will be invalid as well (that is, + its \l{QRegularExpressionMatch::}{isValid()} function will return false). + The same applies for attempting a global match. + + \section1 Unsupported Perl-compatible regular expressions features + + QRegularExpression does not support all the features available in + Perl-compatible regular expressions. The most notable one is the fact that + duplicated names for capturing groups are not supported, and using them can + lead to undefined behaviour. + + This may change in a future version of Qt. + + \section1 Notes for QRegExp users + + The QRegularExpression class introduced in Qt 5 is a big improvement upon + QRegExp, in terms of APIs offered, supported pattern syntax and speed of + execution. The biggest difference is that QRegularExpression simply holds a + regular expression, and it's \e{not} modified when a match is requested. + Instead, a QRegularExpressionMatch object is returned, in order to check + the result of a match and extract the captured substring. The same applies + with global matching and QRegularExpressionMatchIterator. + + Other differences are outlined below. + + \section2 Exact matching + + QRegExp::exactMatch in Qt 4 served for two purposes: it exactly matched + a regular expression against a subject string, and it implemented partial + matching. In fact, if an exact match was not found, one could still find + out how much of the subject string was matched by the regular expression + by calling QRegExp::matchedLength(). If the returned length was equal + to the subject string's length, then one could desume that a partial match + was found. + + QRegularExpression supports partial matching explicitly by means of the + appropriate MatchType. If instead you simply want to be sure that the + subject string matches the regular expression exactly, you can wrap the + pattern between a couple of anchoring expressions. Simply + putting the pattern between the \c{^} and the \c{$} anchors is enough + in most cases: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 24 + + However, remember that the \c{$} anchor not only matches at the end of the + string, but also at a newline character right before the end of the string; + that is, the previous pattern matches against the string "this pattern must + match exactly\n". Also, the behaviour of both the \c{^} and the \c{$} + anchors changes if the MultiLineOption is set either explicitely (as a + pattern option) or implicitly (as a directive inside the pattern string). + + Therefore, in the most general case, you should wrap the pattern between + the \c{\A} and the \c{\z} anchors: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 25 + + Note the usage of the non-capturing group in order to preserve the meaning + of the branch operator inside the pattern. + + \section2 Global matching + + Due to limitations of the QRegExp API it was impossible to implement global + matching correctly (that is, like Perl does). In particular, patterns that + can match 0 characters (like \c{"a*"}) are problematic. + + QRegularExpression::globalMatch implements Perl global match correctly, and + the returned iterator can be used to examine each result. + + \section2 Wildcard matching + + There is no equivalent of wildcard matching in QRegularExpression. + Nevertheless, rewriting a regular expression in wildcard syntax to a + Perl-compatible regular expression is a very easy task, given the fact + that wildcard syntax supported by QRegExp is very simple. + + \section2 Other pattern syntaxes + + QRegularExpression supports only Perl-compatible regular expressions. + + \section2 Minimal matching + + QRegExp::setMinimal implemented minimal matching by simply reversing the + greediness of the quantifiers (QRegExp did not support lazy quantifiers, + like \c{*?}, \c{+?}, etc.). QRegularExpression instead does support greedy, + lazy and possessive quantifiers. The InvertedGreedinessOption + pattern option can be useful to emulate the effects of QRegExp::setMinimal: + if enabled, it inverts the greediness of quantifiers (greedy ones become + lazy and vice versa). + + \section2 Caret modes + + The AnchoredMatchOption match option can be used to emulate the + QRegExp::CaretAtOffset behaviour. There is no equivalent for the other + QRegExp::CaretMode modes. + + \sa QRegularExpressionMatch, QRegularExpressionMatchIterator +*/ + +/*! + \class QRegularExpressionMatch + \reentrant + + \brief The QRegularExpressionMatch class provides the results of a matching + a QRegularExpression against a string. + + \since 5.0 + + \ingroup tools + \ingroup shared + + \keyword regular expression match + + A QRegularExpressionMatch object can be obtained by calling the + QRegularExpression::match() function, or as a single result of a global + match from a QRegularExpressionMatchIterator. + + The success or the failure of a match attempt can be inspected by calling + the hasMatch() function. QRegularExpressionMatch also reports a successful + partial match through the hasPartialMatch() function. + + In addition, QRegularExpressionMatch returns the substrings captured by the + capturing groups in the pattern string. The implicit capturing group with + index 0 captures the result of the whole match. The captured() function + returns each substring captured, either by the capturing group's index or + by its name: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 29 + + For each captured substring it is possible to query its starting and ending + offsets in the subject string by calling the capturedStart() and the + capturedEnd() function, respectively. The length of each captured + substring is available using the capturedLength() function. + + The convenience function capturedTexts() will return \e{all} the captured + substrings at once (including the substring matched by the entire pattern) + in the order they have been captured by captring groups; that is, + \c{captured(i) == capturedTexts().at(i)}. + + You can retrieve the QRegularExpression object the subject string was + matched against by calling the regularExpression() function; the + match type and the match options are available as well by calling + the matchType() and the matchOptions() respectively. + + Please refer to the QRegularExpression documentation for more information + about the Qt regular expression classes. + + \sa QRegularExpression +*/ + +/*! + \class QRegularExpressionMatchIterator + \reentrant + + \brief The QRegularExpressionMatchIterator class provides an iterator on + the results of a global match of a QRegularExpression object against a string. + + \since 5.0 + + \ingroup tools + \ingroup shared + + \keyword regular expression iterator + + A QRegularExpressionMatchIterator object is a forward only Java-like + iterator; it can be obtained by calling the + QRegularExpression::globalMatch() function. A new + QRegularExpressionMatchIterator will be positioned before the first result. + You can then call the hasNext() function to check if there are more + results available; if so, the next() function will return the next + result and advance the iterator. + + Each result is a QRegularExpressionMatch object holding all the information + for that result (including captured substrings). + + For instance: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 30 + + Moreover, QRegularExpressionMatchIterator offers a peekNext() function + to get the next result \e{without} advancing the iterator. + + You can retrieve the QRegularExpression object the subject string was + matched against by calling the regularExpression() function; the + match type and the match options are available as well by calling + the matchType() and the matchOptions() respectively. + + Please refer to the QRegularExpression documentation for more information + about the Qt regular expression classes. + + \sa QRegularExpression, QRegularExpressionMatch +*/ + + +/*! + \enum QRegularExpression::PatternOption + + The PatternOption enum defines modifiers to the way the pattern string + should be interpreted, and therefore the way the pattern matches against a + subject string. + + \value NoPatternOption + No pattern options are set. + + \value CaseInsensitiveOption + The pattern should match against the subject string in a case + insensitive way. This option corresponds to the /i modifier in Perl + regular expressions. + + \value DotMatchesEverythingOption + The dot metacharacter (\c{.}) in the pattern string is allowed to match + any character in the subject string, including newlines (normally, the + dot does not match newlines). This option corresponds to the \c{/s} + modifier in Perl regular expressions. + + \value MultilineOption + The caret (\c{^}) and the dollar (\c{$}) metacharacters in the pattern + string are allowed to match, respectively, immediately after and + immediately before any newline in the subject string, as well as at the + very beginning and at the very end of the subject string. This option + corresponds to the \c{/m} modifier in Perl regular expressions. + + \value ExtendedPatternSyntaxOption + Any whitespace in the pattern string which is not escaped and outside a + character class is ignored. Moreover, an unescaped sharp (\bold{#}) + outside a character class causes all the following characters, until + the first newline (included), to be ignored. This can be used to + increase the readability of a pattern string as well as put comments + inside regular expressions; this is particulary useful if the pattern + string is loaded from a file or written by the user, because in C++ + code it is always possible to use the rules for string literals to put + comments outside the pattern string. This option corresponds to the \c{/x} + modifier in Perl regular expressions. + + \value InvertedGreedinessOption + The greediness of the quantifiers is inverted: \c{*}, \c{+}, \c{?}, + \c{{m,n}}, etc. become lazy, while their lazy versions (\c{*?}, + \c{+?}, \c{??}, \c{{m,n}?}, etc.) become greedy. There is no equivalent + for this option in Perl regular expressions. + + \value DontCaptureOption + The non-named capturing groups do not capture substrings; named + capturing groups still work as intended, as well as the implicit + capturing group number 0 corresponding to the entire match. There is no + equivalent for this option in Perl regular expressions. + + \value UseUnicodePropertiesOption + The meaning of the \c{\w}, \c{\d}, etc., character types, as well as + the meaning of their counterparts (\c{\W}, \c{\D}, etc.), is changed + from matching ASCII charaters only to matching any character with the + corresponding Unicode property. For instance, \c{\d} is changed to + match any character with the Unicode Nd (decimal digit) property; + \c{\w} to match any character with either the Unicode L (letter) or N + (digit) property, plus underscore, and so on. This option corresponds + to the \c{/u} modifier in Perl regular expressions. +*/ + +/*! + \enum QRegularExpression::MatchType + + The MatchType enum defines the type of the match that should be attempted + against the subject string. + + \value NormalMatch + A normal match is done. + + \value PartialPreferCompleteMatch + The pattern string is matched partially against the subject string. If + a partial match is found, then it is recorded, and other matching + alternatives are tried as usual. If a complete match is then found, + then it's preferred to the partial match; in this case only the + complete match is reported. If instead no complete match is found (but + only the partial one), then the partial one is reported. + + \value PartialPreferFirstMatch + The pattern string is matched partially against the subject string. If + a partial match is found, then matching stops and the partial match is + reported. In this case, other matching alternatives (potentially + leading to a complete match) are not tried. Moreover, this match type + assumes that the subject string only a substring of a larger text, and + that (in this text) there are other characters beyond the end of the + subject string. This can lead to surprising results; see the discussion + in the \l{partial matching} section for more details. +*/ + +/*! + \enum QRegularExpression::MatchOption + + \value NoMatchOption + No match options are set. + + \value AnchoredMatchOption + The match is constrained to start exactly at the offset passed to + match() in order to be successful, even if the pattern string does not + contain any metacharacter that anchors the match at that point. +*/ + +/*! + \internal +*/ +static int convertToPcreOptions(QRegularExpression::PatternOptions patternOptions) +{ + int options = 0; + + if (patternOptions & QRegularExpression::CaseInsensitiveOption) + options |= PCRE_CASELESS; + if (patternOptions & QRegularExpression::DotMatchesEverythingOption) + options |= PCRE_DOTALL; + if (patternOptions & QRegularExpression::MultilineOption) + options |= PCRE_MULTILINE; + if (patternOptions & QRegularExpression::ExtendedPatternSyntaxOption) + options |= PCRE_EXTENDED; + if (patternOptions & QRegularExpression::InvertedGreedinessOption) + options |= PCRE_UNGREEDY; + if (patternOptions & QRegularExpression::DontCaptureOption) + options |= PCRE_NO_AUTO_CAPTURE; + if (patternOptions & QRegularExpression::UseUnicodePropertiesOption) + options |= PCRE_UCP; + + return options; +} + +/*! + \internal +*/ +static int convertToPcreOptions(QRegularExpression::MatchOptions matchOptions) +{ + int options = 0; + + if (matchOptions & QRegularExpression::AnchoredMatchOption) + options |= PCRE_ANCHORED; + + return options; +} + +struct QRegularExpressionPrivate : QSharedData +{ + QRegularExpressionPrivate(); + ~QRegularExpressionPrivate(); + QRegularExpressionPrivate(const QRegularExpressionPrivate &other); + + void cleanCompiledPattern(); + void compilePattern(); + void getPatternInfo(); + void optimizePattern(); + + QRegularExpressionMatchPrivate *doMatch(const QString &subject, + int offset, + QRegularExpression::MatchType matchType, + QRegularExpression::MatchOptions matchOptions, + const QRegularExpressionMatchPrivate *previous = 0) const; + + int captureIndexForName(const QString &name) const; + + QString pattern; + QRegularExpression::PatternOptions patternOptions; + + // *All* of the following members are set managed while holding this mutex, + // except for isDirty which is set to true by QRegularExpression setters + // (right after a detach happened). + // On the other hand, after the compilation and studying, + // it's safe to *use* (i.e. read) them from multiple threads at the same time. + // Therefore, doMatch doesn't need to lock this mutex. + QMutex mutex; + + // The PCRE pointers are reference-counted by the QRegularExpressionPrivate + // objects themselves; when the private is copied (i.e. a detach happened) + // they are set to 0 + pcre16 *compiledPattern; + pcre16_extra *studyData; + const char *errorString; + int errorOffset; + int capturingCount; + unsigned int usedCount; + bool usingCrLfNewlines; + bool isDirty; +}; + +struct QRegularExpressionMatchPrivate : QSharedData +{ + QRegularExpressionMatchPrivate(const QRegularExpression &re, + const QString &subject, + QRegularExpression::MatchType matchType, + QRegularExpression::MatchOptions matchOptions, + int capturingCount); + + QRegularExpressionMatch nextMatch() const; + + QRegularExpression regularExpression; + QString subject; + // the capturedOffsets vector contains pairs of (start, end) positions + // for each captured substring + QVector capturedOffsets; + + QRegularExpression::MatchType matchType; + QRegularExpression::MatchOptions matchOptions; + + int capturedCount; + + bool hasMatch; + bool hasPartialMatch; + bool isValid; +}; + +struct QRegularExpressionMatchIteratorPrivate : QSharedData +{ + QRegularExpressionMatchIteratorPrivate(const QRegularExpression re, + QRegularExpression::MatchType matchType, + QRegularExpression::MatchOptions matchOptions, + const QRegularExpressionMatch &next); + + bool hasNext() const; + QRegularExpressionMatch next; + QRegularExpression regularExpression; + QRegularExpression::MatchType matchType; + QRegularExpression::MatchOptions matchOptions; +}; + +/*! + \internal +*/ +QRegularExpression::QRegularExpression(QRegularExpressionPrivate &dd) + : d(&dd) +{ +} + +/*! + \internal +*/ +QRegularExpressionPrivate::QRegularExpressionPrivate() + : pattern(), patternOptions(0), + mutex(), + compiledPattern(0), studyData(0), + errorString(0), errorOffset(-1), + capturingCount(0), + usedCount(0), + usingCrLfNewlines(false), + isDirty(true) +{ +} + +/*! + \internal +*/ +QRegularExpressionPrivate::~QRegularExpressionPrivate() +{ + cleanCompiledPattern(); +} + +/*! + \internal + + Copies the private, which means copying only the pattern and the pattern + options. The compiledPattern and the studyData pointers are NOT copied (we + do not own them any more), and in general all the members set when + compiling a pattern are set to default values. isDirty is set back to true + so that the pattern has to be recompiled again. +*/ +QRegularExpressionPrivate::QRegularExpressionPrivate(const QRegularExpressionPrivate &other) + : QSharedData(other), + pattern(other.pattern), patternOptions(other.patternOptions), + mutex(), + compiledPattern(0), studyData(0), + errorString(0), + errorOffset(-1), capturingCount(0), + usedCount(0), + usingCrLfNewlines(false), isDirty(true) +{ +} + +/*! + \internal +*/ +void QRegularExpressionPrivate::cleanCompiledPattern() +{ + pcre16_free(compiledPattern); + pcre16_free_study(studyData); + usedCount = 0; + compiledPattern = 0; + studyData = 0; + usingCrLfNewlines = false; + errorOffset = -1; + capturingCount = 0; +} + +/*! + \internal +*/ +void QRegularExpressionPrivate::compilePattern() +{ + QMutexLocker lock(&mutex); + + if (!isDirty) + return; + + isDirty = false; + cleanCompiledPattern(); + + int options = convertToPcreOptions(patternOptions); + options |= PCRE_UTF16; + + int errorCode; + compiledPattern = pcre16_compile2(pattern.utf16(), options, + &errorCode, &errorString, &errorOffset, 0); + + if (!compiledPattern) + return; + + Q_ASSERT(errorCode == 0); + Q_ASSERT(studyData == 0); // studying (=>optimizing) is always done later + errorOffset = -1; + + getPatternInfo(); +} + +/*! + \internal +*/ +void QRegularExpressionPrivate::getPatternInfo() +{ + Q_ASSERT(compiledPattern); + + pcre16_fullinfo(compiledPattern, 0, PCRE_INFO_CAPTURECOUNT, &capturingCount); + + // detect the settings for the newline + int patternNewlineSetting; + pcre16_fullinfo(compiledPattern, studyData, PCRE_INFO_OPTIONS, &patternNewlineSetting); + patternNewlineSetting &= PCRE_NEWLINE_CR | PCRE_NEWLINE_LF | PCRE_NEWLINE_CRLF + | PCRE_NEWLINE_ANY | PCRE_NEWLINE_ANYCRLF; + if (patternNewlineSetting == 0) { + // no option was specified in the regexp, grab PCRE build defaults + int pcreNewlineSetting; + pcre16_config(PCRE_CONFIG_NEWLINE, &pcreNewlineSetting); + switch (pcreNewlineSetting) { + case 13: + patternNewlineSetting = PCRE_NEWLINE_CR; break; + case 10: + patternNewlineSetting = PCRE_NEWLINE_LF; break; + case 3338: // (13<<8 | 10) + patternNewlineSetting = PCRE_NEWLINE_CRLF; break; + case -2: + patternNewlineSetting = PCRE_NEWLINE_ANYCRLF; break; + case -1: + patternNewlineSetting = PCRE_NEWLINE_ANY; break; + default: + qWarning("QRegularExpressionPrivate::compilePattern(): " + "PCRE_CONFIG_NEWLINE returned an unknown newline"); + break; + } + } + + usingCrLfNewlines = (patternNewlineSetting == PCRE_NEWLINE_CRLF) || + (patternNewlineSetting == PCRE_NEWLINE_ANY) || + (patternNewlineSetting == PCRE_NEWLINE_ANYCRLF); +} + +/*! + \internal +*/ +void QRegularExpressionPrivate::optimizePattern() +{ + Q_ASSERT(compiledPattern); + + QMutexLocker lock(&mutex); + + if (studyData || (++usedCount != OPTIMIZE_AFTER_USE_COUNT)) + return; + + int studyOptions = PCRE_STUDY_JIT_COMPILE; + const char *err; + studyData = pcre16_study(compiledPattern, studyOptions, &err); + + if (!studyData && err) + qWarning("QRegularExpressionPrivate::optimizePattern(): pcre_study failed: %s", err); +} + +/*! + \internal + + Returns the capturing group number for the given name. Duplicated names for + capturing groups are not supported. +*/ +int QRegularExpressionPrivate::captureIndexForName(const QString &name) const +{ + Q_ASSERT(!name.isEmpty()); + + int index = pcre16_get_stringnumber(compiledPattern, name.utf16()); + if (index >= 0) + return index; + + return -1; +} + +/*! + \internal + + Performs a match of type \a matchType on the given \a subject string with + options \a matchOptions and returns the QRegularExpressionMatchPrivate of + the result. It also advances a match if a previous result is given as \a + previous. + + Advancing a match is a tricky algorithm. If the previous match matched a + non-empty string, we just do an ordinary match at the offset position. + + If the previous match matched an empty string, then an anchored, non-empty + match is attempted at the offset position. If that succeeds, then we got + the next match and we can return it. Otherwise, we advance by 1 position + (which can be one or two code units in UTF-16!) and reattempt a "normal" + match. We also have the problem of detecting the current newline format: if + the new advanced offset is pointing to the beginning of a CRLF sequence, we + must advance over it. +*/ +QRegularExpressionMatchPrivate *QRegularExpressionPrivate::doMatch(const QString &subject, + int offset, + QRegularExpression::MatchType matchType, + QRegularExpression::MatchOptions matchOptions, + const QRegularExpressionMatchPrivate *previous) const +{ + if (offset < 0) + offset += subject.length(); + + QRegularExpression re(*const_cast(this)); + + if (offset < 0 || offset > subject.length()) + return new QRegularExpressionMatchPrivate(re, subject, matchType, matchOptions, 0); + + if (!compiledPattern) { + qWarning("QRegularExpressionPrivate::doMatch(): called on an invalid QRegularExpression object"); + return new QRegularExpressionMatchPrivate(re, subject, matchType, matchOptions, 0); + } + + QRegularExpressionMatchPrivate *priv = new QRegularExpressionMatchPrivate(re, subject, + matchType, matchOptions, + capturingCount); + + // this is mutex protected + const_cast(this)->optimizePattern(); + + int pcreOptions = convertToPcreOptions(matchOptions); + + if (matchType == QRegularExpression::PartialPreferCompleteMatch) + pcreOptions |= PCRE_PARTIAL_SOFT; + else if (matchType == QRegularExpression::PartialPreferFirstMatch) + pcreOptions |= PCRE_PARTIAL_HARD; + + bool previousMatchWasEmpty = false; + if (previous && previous->hasMatch && + (previous->capturedOffsets.at(0) == previous->capturedOffsets.at(1))) { + previousMatchWasEmpty = true; + } + + int * const captureOffsets = priv->capturedOffsets.data(); + const int captureOffsetsCount = priv->capturedOffsets.size(); + + const unsigned short * const subjectUtf16 = subject.utf16(); + const int subjectLength = subject.length(); + + int result; + + if (!previousMatchWasEmpty) { + result = pcre16_exec(compiledPattern, studyData, + subjectUtf16, subjectLength, + offset, pcreOptions, + captureOffsets, captureOffsetsCount); + } else { + result = pcre16_exec(compiledPattern, studyData, + subjectUtf16, subjectLength, + offset, pcreOptions | PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED, + captureOffsets, captureOffsetsCount); + + if (result == PCRE_ERROR_NOMATCH) { + ++offset; + + if (usingCrLfNewlines + && offset < subjectLength + && subjectUtf16[offset - 1] == QLatin1Char('\r') + && subjectUtf16[offset] == QLatin1Char('\n')) { + ++offset; + } else if (offset < subjectLength + && QChar::isLowSurrogate(subjectUtf16[offset])) { + ++offset; + } + + result = pcre16_exec(compiledPattern, studyData, + subjectUtf16, subjectLength, + offset, pcreOptions, + captureOffsets, captureOffsetsCount); + } + } + +#ifdef QREGULAREXPRESSION_DEBUG + qDebug() << "Matching" << pattern << "against" << subject + << offset << matchType << matchOptions << previousMatchWasEmpty + << "result" << result; +#endif + + // result == 0 means not enough space in captureOffsets; should never happen + Q_ASSERT(result != 0); + + if (result > 0) { + // full match + priv->isValid = true; + priv->hasMatch = true; + priv->capturedCount = result; + priv->capturedOffsets.resize(result * 2); + } else { + // no match, partial match or error + priv->hasPartialMatch = (result == PCRE_ERROR_PARTIAL); + priv->isValid = (result == PCRE_ERROR_NOMATCH || result == PCRE_ERROR_PARTIAL); + + if (result == PCRE_ERROR_PARTIAL) { + // partial match: + // leave the start and end capture offsets (i.e. cap(0)) + priv->capturedCount = 1; + priv->capturedOffsets.resize(2); + } else { + // no match or error + priv->capturedCount = 0; + priv->capturedOffsets.clear(); + } + } + + return priv; +} + +/*! + \internal +*/ +QRegularExpressionMatchPrivate::QRegularExpressionMatchPrivate(const QRegularExpression &re, + const QString &subject, + QRegularExpression::MatchType matchType, + QRegularExpression::MatchOptions matchOptions, + int capturingCount) + : regularExpression(re), subject(subject), + matchType(matchType), matchOptions(matchOptions), + capturedCount(0), + hasMatch(false), hasPartialMatch(false), isValid(false) +{ + Q_ASSERT(capturingCount >= 0); + const int captureOffsetsCount = (capturingCount + 1) * 3; + capturedOffsets.resize(captureOffsetsCount); +} + + +/*! + \internal +*/ +QRegularExpressionMatch QRegularExpressionMatchPrivate::nextMatch() const +{ + Q_ASSERT(isValid); + Q_ASSERT(hasMatch || hasPartialMatch); + + QRegularExpressionMatchPrivate *nextPrivate = regularExpression.d->doMatch(subject, + capturedOffsets.at(1), + matchType, + matchOptions, + this); + return QRegularExpressionMatch(*nextPrivate); +} + +/*! + \internal +*/ +QRegularExpressionMatchIteratorPrivate::QRegularExpressionMatchIteratorPrivate(const QRegularExpression re, + QRegularExpression::MatchType matchType, + QRegularExpression::MatchOptions matchOptions, + const QRegularExpressionMatch &next) + : next(next), + regularExpression(re), + matchType(matchType), matchOptions(matchOptions) +{ +} + +/*! + \internal +*/ +bool QRegularExpressionMatchIteratorPrivate::hasNext() const +{ + return next.isValid() && (next.hasMatch() || next.hasPartialMatch()); +} + +// PUBLIC API + +/*! + Constructs a QRegularExpression object with an empty pattern and no pattern + options. + + \sa setPattern(), setPatternOptions() +*/ +QRegularExpression::QRegularExpression() + : d(new QRegularExpressionPrivate) +{ +} + +/*! + Constructs a QRegularExpression object using the given \a pattern as + pattern and the \a options as the pattern options. + + \sa setPattern(), setPatternOptions() +*/ +QRegularExpression::QRegularExpression(const QString &pattern, PatternOptions options) + : d(new QRegularExpressionPrivate) +{ + d->pattern = pattern; + d->patternOptions = options; +} + +/*! + Constructs a QRegularExpression object as a copy of \a re. + + \sa operator=() +*/ +QRegularExpression::QRegularExpression(const QRegularExpression &re) + : d(re.d) +{ +} + +/*! + Destroys the QRegularExpression object. +*/ +QRegularExpression::~QRegularExpression() +{ +} + +/*! + Assigns the regular expression \a re to this object, and returns a reference + to the copy. Both the pattern and the pattern options are copied. +*/ +QRegularExpression &QRegularExpression::operator=(const QRegularExpression &re) +{ + d = re.d; + return *this; +} + +/*! + \fn void QRegularExpression::swap(QRegularExpression &other) + + Swaps the regular expression \a other with this regular expression. This + operation is very fast and never fails. +*/ + +/*! + Returns the pattern string of the regular expression. + + \sa setPattern(), patternOptions() +*/ +QString QRegularExpression::pattern() const +{ + return d->pattern; +} + +/*! + Sets the pattern string of the regular expression to \a pattern. The + pattern options are left unchanged. + + \sa pattern(), setPatternOptions() +*/ +void QRegularExpression::setPattern(const QString &pattern) +{ + d.detach(); + d->isDirty = true; + d->pattern = pattern; +} + +/*! + Returns the pattern options for the regular expression. + + \sa setPatternOptions(), pattern() +*/ +QRegularExpression::PatternOptions QRegularExpression::patternOptions() const +{ + return d->patternOptions; +} + +/*! + Sets the given \a options as the pattern options of the regular expression. + The pattern string is left unchanged. + + \sa patternOptions(), setPattern() +*/ +void QRegularExpression::setPatternOptions(PatternOptions options) +{ + d.detach(); + d->isDirty = true; + d->patternOptions = options; +} + +/*! + Returns true if the regular expression is a valid regular expression (that + is, it contains no syntax errors, etc.), or false otherwise. Use + errorString() to obtain a textual description of the error. + + \sa errorString(), patternErrorOffset() +*/ +bool QRegularExpression::isValid() const +{ + d.data()->compilePattern(); + return d->compiledPattern; +} + +/*! + Returns a textual description of the error found when checking the validity + of the regular expression, or "no error" if no error was found. + + \sa isValid(), patternErrorOffset() +*/ +QString QRegularExpression::errorString() const +{ + d.data()->compilePattern(); + if (d->errorString) + return QCoreApplication::translate("QRegularExpression", d->errorString, 0, QCoreApplication::UnicodeUTF8); + return QCoreApplication::translate("QRegularExpression", "no error", 0, QCoreApplication::UnicodeUTF8); +} + +/*! + Returns the offset, inside the pattern string, at which an error was found + when checking the validity of the regular expression. If no error was + found, then -1 is returned. + + \sa pattern(), isValid(), errorString() +*/ +int QRegularExpression::patternErrorOffset() const +{ + d.data()->compilePattern(); + return d->errorOffset; +} + +/*! + Attempts to match the regular expression against the given \a subject + string, starting at the position \a offset inside the subject, using a + match of type \a matchType and honoring the given \a matchOptions. + + The returned QRegularExpressionMatch object contains the results of the + match. + + \sa QRegularExpressionMatch, {normal matching} +*/ +QRegularExpressionMatch QRegularExpression::match(const QString &subject, + int offset, + MatchType matchType, + MatchOptions matchOptions) const +{ + d.data()->compilePattern(); + + QRegularExpressionMatchPrivate *priv = d->doMatch(subject, offset, matchType, matchOptions); + return QRegularExpressionMatch(*priv); +} + +/*! + Attempts to perform a global match of the regular expression against the + given \a subject string, starting at the position \a offset inside the + subject, using a match of type \a matchType and honoring the given \a + matchOptions. + + The returned QRegularExpressionMatchIterator is positioned before the + first match result (if any). + + \sa QRegularExpressionMatchIterator, {global matching} +*/ +QRegularExpressionMatchIterator QRegularExpression::globalMatch(const QString &subject, + int offset, + MatchType matchType, + MatchOptions matchOptions) const +{ + QRegularExpressionMatchIteratorPrivate *priv = + new QRegularExpressionMatchIteratorPrivate(*this, + matchType, + matchOptions, + match(subject, offset, matchType, matchOptions)); + + return QRegularExpressionMatchIterator(*priv); +} + +/*! + Returns true if the regular expression is equal to \a re, or false + otherwise. Two QRegularExpression objects are equal if they have + the same pattern string and the same pattern options. + + \sa operator!=() +*/ +bool QRegularExpression::operator==(const QRegularExpression &re) const +{ + return (pattern() == re.pattern() && patternOptions() == re.patternOptions()); +} + +/*! + \fn bool QRegularExpression::operator!=(const QRegularExpression &re) const + + Returns true if the regular expression is different from \a re, or + false otherwise. + + \sa operator==() +*/ + +/*! + Escapes all characters of \a str so that they no longer have any special + meaning when used as a regular expression pattern string, and returns + the escaped string. For instance: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 26 + + This is very convenient in order to build patterns from arbitrary strings: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 27 + + \note This function implements Perl's quotemeta algorithm and escapes with + a backslash all characters in \a str, except for the characters in the + \c{[A-Z]}, \c{[a-z]} and \c{[0-9]} ranges, as well as the underscore + (\c{_}) character. The only difference with Perl is that a literal NUL + inside \a str is escaped with the sequence \c{"\\\\0"} (backslash + + \c{'0'}), instead of \c{"\\\\\\0"} (backslash + \c{NUL}). +*/ +QString QRegularExpression::escape(const QString &str) +{ + QString result; + const int count = str.size(); + result.reserve(count * 2); + + // everything but [a-zA-Z0-9_] gets escaped, + // cf. perldoc -f quotemeta + for (int i = 0; i < count; ++i) { + const QChar current = str.at(i); + + if (current == QChar::Null) { + // unlike Perl, a literal NUL must be escaped with + // "\\0" (backslash + 0) and not "\\\0" (backslash + NUL), + // because pcre16_compile uses a NUL-terminated string + result.append(QLatin1Char('\\')); + result.append(QLatin1Char('0')); + } else if ( (current < QLatin1Char('a') || current > QLatin1Char('z')) && + (current < QLatin1Char('A') || current > QLatin1Char('Z')) && + (current < QLatin1Char('0') || current > QLatin1Char('9')) && + current != QLatin1Char('_') ) + { + result.append(QLatin1Char('\\')); + result.append(current); + if (current.isHighSurrogate() && i < (count - 1)) + result.append(str.at(++i)); + } else { + result.append(current); + } + } + + result.squeeze(); + return result; +} + +/*! + Destroys the match result. +*/ +QRegularExpressionMatch::~QRegularExpressionMatch() +{ +} + +/*! + Constructs a match result by copying the result of the given \a match. + + \sa operator=() +*/ +QRegularExpressionMatch::QRegularExpressionMatch(const QRegularExpressionMatch &match) + : d(match.d) +{ +} + +/*! + Assigns the match result \a match to this object, and returns a reference + to the copy. +*/ +QRegularExpressionMatch &QRegularExpressionMatch::operator=(const QRegularExpressionMatch &match) +{ + d = match.d; + return *this; +} + +/*! + \fn void QRegularExpressionMatch::swap(QRegularExpressionMatch &other) + + Swaps the match result \a other with this match result. This + operation is very fast and never fails. +*/ + +/*! + \internal +*/ +QRegularExpressionMatch::QRegularExpressionMatch(QRegularExpressionMatchPrivate &dd) + : d(&dd) +{ +} + +/*! + Returns the QRegularExpression object whose match() function returned this + object. + + \sa QRegularExpression::match(), matchType(), matchOptions() +*/ +QRegularExpression QRegularExpressionMatch::regularExpression() const +{ + return d->regularExpression; +} + + +/*! + Returns the match type that was used to get this QRegularExpressionMatch + object, that is, the match type that was passed to + QRegularExpression::match() or QRegularExpression::globalMatch(). + + \sa QRegularExpression::match(), regularExpression(), matchOptions() +*/ +QRegularExpression::MatchType QRegularExpressionMatch::matchType() const +{ + return d->matchType; +} + +/*! + Returns the match options that were used to get this + QRegularExpressionMatch object, that is, the match options that were passed + to QRegularExpression::match() or QRegularExpression::globalMatch(). + + \sa QRegularExpression::match(), regularExpression(), matchType() +*/ +QRegularExpression::MatchOptions QRegularExpressionMatch::matchOptions() const +{ + return d->matchOptions; +} + +/*! + Returns the index of the last capturing group that captured something, + including the implicit capturing group 0. This can be used to extract all + the substrings that were captured: + + \snippet doc/src/snippets/code/src_corelib_tools_qregularexpression.cpp 28 + + Note that some of the capturing groups with an index less than + lastCapturedIndex() could have not matched, and therefore captured nothing. + + If the regular expression did not match, this function returns -1. + + \sa captured(), capturedStart(), capturedEnd(), capturedLength() +*/ +int QRegularExpressionMatch::lastCapturedIndex() const +{ + return d->capturedCount - 1; +} + +/*! + Returns the substring captured by the \a nth capturing group. If the \a nth + capturing group did not capture a string or doesn't exist, returns a null + QString. + + \sa capturedRef(), lastCapturedIndex(), capturedStart(), capturedEnd(), + capturedLength(), QString::isNull() +*/ +QString QRegularExpressionMatch::captured(int nth) const +{ + if (nth < 0 || nth > lastCapturedIndex()) + return QString(); + + int start = capturedStart(nth); + + if (start == -1) // didn't capture + return QString(); + + return d->subject.mid(start, capturedLength(nth)); +} + +/*! + Returns a reference to the substring captured by the \a nth capturing group. + If the \a nth capturing group did not capture a string or doesn't exist, + returns a null QStringRef. + + \sa captured(), lastCapturedIndex(), capturedStart(), capturedEnd(), + capturedLength(), QStringRef::isNull() +*/ +QStringRef QRegularExpressionMatch::capturedRef(int nth) const +{ + if (nth < 0 || nth > lastCapturedIndex()) + return QStringRef(); + + int start = capturedStart(nth); + + if (start == -1) // didn't capture + return QStringRef(); + + return d->subject.midRef(start, capturedLength(nth)); +} + +/*! + Returns the substring captured by the capturing group named \a name. If the + capturing group named \a name did not capture a string or doesn't exist, + returns a null QString. + + \sa capturedRef(), capturedStart(), capturedEnd(), capturedLength(), + QString::isNull() +*/ +QString QRegularExpressionMatch::captured(const QString &name) const +{ + if (name.isEmpty()) { + qWarning("QRegularExpressionMatch::captured: empty capturing group name passed"); + return QString(); + } + int nth = d->regularExpression.d->captureIndexForName(name); + if (nth == -1) + return QString(); + return captured(nth); +} + +/*! + Returns a reference to the string captured by the capturing group named \a + name. If the capturing group named \a name did not capture a string or + doesn't exist, returns a null QStringRef. + + \sa captured(), capturedStart(), capturedEnd(), capturedLength(), + QStringRef::isNull() +*/ +QStringRef QRegularExpressionMatch::capturedRef(const QString &name) const +{ + if (name.isEmpty()) { + qWarning("QRegularExpressionMatch::capturedRef: empty capturing group name passed"); + return QStringRef(); + } + int nth = d->regularExpression.d->captureIndexForName(name); + if (nth == -1) + return QStringRef(); + return capturedRef(nth); +} + +/*! + Returns a list of all strings captured by capturing groups, in the order + the groups themselves appear in the pattern string. +*/ +QStringList QRegularExpressionMatch::capturedTexts() const +{ + QStringList texts; + for (int i = 0; i <= lastCapturedIndex(); ++i) + texts << captured(i); + return texts; +} + +/*! + Returns the offset inside the subject string corresponding to the + starting position of the substring captured by the \a nth capturing group. + If the \a nth capturing group did not capture a string or doesn't exist, + returns -1. + + \sa capturedEnd(), capturedLength(), captured() +*/ +int QRegularExpressionMatch::capturedStart(int nth) const +{ + if (nth < 0 || nth > lastCapturedIndex()) + return -1; + + return d->capturedOffsets.at(nth * 2); +} + +/*! + Returns the length of the substring captured by the \a nth capturing group. + + \note This function returns 0 if the \a nth capturing group did not capture + a string or doesn't exist. + + \sa capturedStart(), capturedEnd(), captured() +*/ +int QRegularExpressionMatch::capturedLength(int nth) const +{ + // bound checking performed by these two functions + return capturedEnd(nth) - capturedStart(nth); +} + +/*! + Returns the offset inside the subject string immediately after the ending + position of the substring captured by the \a nth capturing group. If the \a + nth capturing group did not capture a string or doesn't exist, returns -1. + + \sa capturedStart(), capturedLength(), captured() +*/ +int QRegularExpressionMatch::capturedEnd(int nth) const +{ + if (nth < 0 || nth > lastCapturedIndex()) + return -1; + + return d->capturedOffsets.at(nth * 2 + 1); +} + +/*! + Returns the offset inside the subject string corresponding to the starting + position of the substring captured by the capturing group named \a name. + If the capturing group named \a name did not capture a string or doesn't + exist, returns -1. + + \sa capturedEnd(), capturedLength(), captured() +*/ +int QRegularExpressionMatch::capturedStart(const QString &name) const +{ + if (name.isEmpty()) { + qWarning("QRegularExpressionMatch::capturedStart: empty capturing group name passed"); + return -1; + } + int nth = d->regularExpression.d->captureIndexForName(name); + if (nth == -1) + return -1; + return capturedStart(nth); +} + +/*! + Returns the offset inside the subject string corresponding to the starting + position of the substring captured by the capturing group named \a name. + + \note This function returns 0 if the capturing group named \a name did not + capture a string or doesn't exist. + + \sa capturedStart(), capturedEnd(), captured() +*/ +int QRegularExpressionMatch::capturedLength(const QString &name) const +{ + if (name.isEmpty()) { + qWarning("QRegularExpressionMatch::capturedLength: empty capturing group name passed"); + return 0; + } + int nth = d->regularExpression.d->captureIndexForName(name); + if (nth == -1) + return 0; + return capturedLength(nth); +} + +/*! + Returns the offset inside the subject string immediately after the ending + position of the substring captured by the capturing group named \a name. If + the capturing group named \a name did not capture a string or doesn't + exist, returns -1. + + \sa capturedStart(), capturedLength(), captured() +*/ +int QRegularExpressionMatch::capturedEnd(const QString &name) const +{ + if (name.isEmpty()) { + qWarning("QRegularExpressionMatch::capturedEnd: empty capturing group name passed"); + return -1; + } + int nth = d->regularExpression.d->captureIndexForName(name); + if (nth == -1) + return -1; + return capturedEnd(nth); +} + +/*! + Returns true if the regular expression matched against the subject string, + or false otherwise. + + \sa QRegularExpression::match(), hasPartialMatch() +*/ +bool QRegularExpressionMatch::hasMatch() const +{ + return d->hasMatch; +} + +/*! + Returns true if the regular expression partially matched against the + subject string, or false otherwise. + + \note Only a match that explicitely used the one of the partial match types + can yield a partial match. Still, if such a match succeeds totally, this + function will return false, while hasMatch() will return true. + + \sa QRegularExpression::match(), QRegularExpression::MatchType, hasMatch() +*/ +bool QRegularExpressionMatch::hasPartialMatch() const +{ + return d->hasPartialMatch; +} + +/*! + Returns true if the match object was obtained as a result from the + QRegularExpression::match() function invoked on a valid QRegularExpression + object; returns false if the QRegularExpression was invalid. + + \sa QRegularExpression::match(), QRegularExpression::isValid() +*/ +bool QRegularExpressionMatch::isValid() const +{ + return d->isValid; +} + +/*! + \internal +*/ +QRegularExpressionMatchIterator::QRegularExpressionMatchIterator(QRegularExpressionMatchIteratorPrivate &dd) + : d(&dd) +{ +} + +/*! + Destroys the QRegularExpressionMatchIterator object. +*/ +QRegularExpressionMatchIterator::~QRegularExpressionMatchIterator() +{ +} + +/*! + Constructs a QRegularExpressionMatchIterator object as a copy of \a + iterator. + + \sa operator=() +*/ +QRegularExpressionMatchIterator::QRegularExpressionMatchIterator(const QRegularExpressionMatchIterator &iterator) + : d(iterator.d) +{ +} + +/*! + Assigns the iterator \a iterator to this object, and returns a reference to + the copy. +*/ +QRegularExpressionMatchIterator &QRegularExpressionMatchIterator::operator=(const QRegularExpressionMatchIterator &iterator) +{ + d = iterator.d; + return *this; +} + +/*! + \fn void QRegularExpressionMatchIterator::swap(QRegularExpressionMatchIterator &other) + + Swaps the iterator \a other with this iterator object. This operation is + very fast and never fails. +*/ + +/*! + Returns true if the iterator object was obtained as a result from the + QRegularExpression::globalMatch() function invoked on a valid + QRegularExpression object; returns false if the QRegularExpression was + invalid. + + \sa QRegularExpression::globalMatch(), QRegularExpression::isValid() +*/ +bool QRegularExpressionMatchIterator::isValid() const +{ + return d->next.isValid(); +} + +/*! + Returns true if there is at least one match result ahead of the iterator; + otherwise it returns false. + + \sa next() +*/ +bool QRegularExpressionMatchIterator::hasNext() const +{ + return d->hasNext(); +} + +/*! + Returns the next match result without moving the iterator. + + \note Calling this function when the iterator is at the end of the result + set leads to undefined results. +*/ +QRegularExpressionMatch QRegularExpressionMatchIterator::peekNext() const +{ + if (!hasNext()) + qWarning("QRegularExpressionMatchIterator::peekNext() called on an iterator already at end"); + + return d->next; +} + +/*! + Returns the next match result and advances the iterator by one position. + + \note Calling this function when the iterator is at the end of the result + set leads to undefined results. +*/ +QRegularExpressionMatch QRegularExpressionMatchIterator::next() +{ + if (!hasNext()) { + qWarning("QRegularExpressionMatchIterator::next() called on an iterator already at end"); + return d->next; + } + + QRegularExpressionMatch current = d->next; + d->next = d->next.d.constData()->nextMatch(); + return current; +} + +/*! + Returns the QRegularExpression object whose globalMatch() function returned + this object. + + \sa QRegularExpression::globalMatch(), matchType(), matchOptions() +*/ +QRegularExpression QRegularExpressionMatchIterator::regularExpression() const +{ + return d->regularExpression; +} + +/*! + Returns the match type that was used to get this + QRegularExpressionMatchIterator object, that is, the match type that was + passed to QRegularExpression::globalMatch(). + + \sa QRegularExpression::globalMatch(), regularExpression(), matchOptions() +*/ +QRegularExpression::MatchType QRegularExpressionMatchIterator::matchType() const +{ + return d->matchType; +} + +/*! + Returns the match options that were used to get this + QRegularExpressionMatchIterator object, that is, the match options that + were passed to QRegularExpression::globalMatch(). + + \sa QRegularExpression::globalMatch(), regularExpression(), matchType() +*/ +QRegularExpression::MatchOptions QRegularExpressionMatchIterator::matchOptions() const +{ + return d->matchOptions; +} + +#ifndef QT_NO_DATASTREAM +/*! + \relates QRegularExpression + + Writes the regular expression \a re to stream \a out. + + \sa {Serializing Qt Data Types} +*/ +QDataStream &operator<<(QDataStream &out, const QRegularExpression &re) +{ + out << re.pattern() << quint32(re.patternOptions()); + return out; +} + +/*! + \relates QRegularExpression + + Reads a regular expression from stream \a in into \a re. + + \sa {Serializing Qt Data Types} +*/ +QDataStream &operator>>(QDataStream &in, QRegularExpression &re) +{ + QString pattern; + quint32 patternOptions; + in >> pattern >> patternOptions; + re.setPattern(pattern); + re.setPatternOptions(QRegularExpression::PatternOptions(patternOptions)); + return in; +} +#endif + +#ifndef QT_NO_DEBUG_STREAM +/*! + \relates QRegularExpression + + Writes the regular expression \a re into the debug object \a debug for + debugging purposes. + + \sa {Debugging Techniques} +*/ +QDebug operator<<(QDebug debug, const QRegularExpression &re) +{ + debug.nospace() << "QRegularExpression(" << re.pattern() << ", " << re.patternOptions() << ")"; + return debug.space(); +} + +/*! + \relates QRegularExpressionMatch + + Writes the match object \a match into the debug object \a debug for + debugging purposes. + + \sa {Debugging Techniques} +*/ +QDebug operator<<(QDebug debug, const QRegularExpressionMatch &match) +{ + debug.nospace() << "QRegularExpressionMatch("; + + if (!match.isValid()) { + debug << "Invalid)"; + return debug.space(); + } + + debug << "Valid"; + + if (match.hasMatch()) { + debug << ", has match: "; + for (int i = 0; i <= match.lastCapturedIndex(); ++i) { + debug << i + << ":(" << match.capturedStart(i) << ", " << match.capturedEnd(i) + << ", " << match.captured(i) << ")"; + if (i < match.lastCapturedIndex()) + debug << ", "; + } + } else if (match.hasPartialMatch()) { + debug << ", has partial match: (" + << match.capturedStart(0) << ", " + << match.capturedEnd(0) << ", " + << match.captured(0) << ")"; + } else { + debug << ", no match"; + } + + debug << ")"; + + return debug.space(); +} +#endif + +QT_END_NAMESPACE diff --git a/src/corelib/tools/qregularexpression.h b/src/corelib/tools/qregularexpression.h new file mode 100644 index 0000000000..c9bcb1e7ba --- /dev/null +++ b/src/corelib/tools/qregularexpression.h @@ -0,0 +1,245 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Giuseppe D'Angelo . +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QREGULAREXPRESSION_H +#define QREGULAREXPRESSION_H + +#ifndef QT_NO_REGEXP + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QRegularExpressionMatch; +class QRegularExpressionMatchIterator; +struct QRegularExpressionPrivate; + +class Q_CORE_EXPORT QRegularExpression +{ +public: + enum PatternOption { + NoPatternOption = 0x0000, + CaseInsensitiveOption = 0x0001, + DotMatchesEverythingOption = 0x0002, + MultilineOption = 0x0004, + ExtendedPatternSyntaxOption = 0x0008, + InvertedGreedinessOption = 0x0010, + DontCaptureOption = 0x0020, + UseUnicodePropertiesOption = 0x0040 + }; + Q_DECLARE_FLAGS(PatternOptions, PatternOption) + + PatternOptions patternOptions() const; + void setPatternOptions(PatternOptions options); + + QRegularExpression(); + explicit QRegularExpression(const QString &pattern, PatternOptions options = NoPatternOption); + QRegularExpression(const QRegularExpression &re); + ~QRegularExpression(); + QRegularExpression &operator=(const QRegularExpression &re); + +#ifdef Q_COMPILER_RVALUE_REFS + inline QRegularExpression &operator=(QRegularExpression &&re) + { d.swap(re.d); return *this; } +#endif + + inline void swap(QRegularExpression &re) { d.swap(re.d); } + + QString pattern() const; + void setPattern(const QString &pattern); + + bool isValid() const; + int patternErrorOffset() const; + QString errorString() const; + + enum MatchType { + NormalMatch = 0, + PartialPreferCompleteMatch, + PartialPreferFirstMatch + }; + + enum MatchOption { + NoMatchOption = 0x0000, + AnchoredMatchOption = 0x0001 + }; + Q_DECLARE_FLAGS(MatchOptions, MatchOption) + + QRegularExpressionMatch match(const QString &subject, + int offset = 0, + MatchType matchType = NormalMatch, + MatchOptions matchOptions = NoMatchOption) const; + + QRegularExpressionMatchIterator globalMatch(const QString &subject, + int offset = 0, + MatchType matchType = NormalMatch, + MatchOptions matchOptions = NoMatchOption) const; + + static QString escape(const QString &str); + + bool operator==(const QRegularExpression &re) const; + inline bool operator!=(const QRegularExpression &re) const { return !operator==(re); } + +private: + friend struct QRegularExpressionPrivate; + friend class QRegularExpressionMatch; + friend struct QRegularExpressionMatchPrivate; + friend class QRegularExpressionMatchIterator; + + QRegularExpression(QRegularExpressionPrivate &dd); + QExplicitlySharedDataPointer d; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QRegularExpression::PatternOptions) +Q_DECLARE_OPERATORS_FOR_FLAGS(QRegularExpression::MatchOptions) +Q_DECLARE_TYPEINFO(QRegularExpression, Q_MOVABLE_TYPE); + +#ifndef QT_NO_DATASTREAM +Q_CORE_EXPORT QDataStream &operator<<(QDataStream &out, const QRegularExpression &re); +Q_CORE_EXPORT QDataStream &operator>>(QDataStream &in, QRegularExpression &re); +#endif + +#ifndef QT_NO_DEBUG_STREAM +Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QRegularExpression &re); +#endif + +struct QRegularExpressionMatchPrivate; + +class Q_CORE_EXPORT QRegularExpressionMatch +{ +public: + ~QRegularExpressionMatch(); + QRegularExpressionMatch(const QRegularExpressionMatch &match); + QRegularExpressionMatch &operator=(const QRegularExpressionMatch &match); + +#ifdef Q_COMPILER_RVALUE_REFS + inline QRegularExpressionMatch &operator=(QRegularExpressionMatch &&match) + { d.swap(match.d); return *this; } +#endif + inline void swap(QRegularExpressionMatch &match) { d.swap(match.d); } + + QRegularExpression regularExpression() const; + QRegularExpression::MatchType matchType() const; + QRegularExpression::MatchOptions matchOptions() const; + + bool hasMatch() const; + bool hasPartialMatch() const; + + bool isValid() const; + + int lastCapturedIndex() const; + + QString captured(int nth = 0) const; + QStringRef capturedRef(int nth = 0) const; + + QString captured(const QString &name) const; + QStringRef capturedRef(const QString &name) const; + + QStringList capturedTexts() const; + + int capturedStart(int nth = 0) const; + int capturedLength(int nth = 0) const; + int capturedEnd(int nth = 0) const; + + int capturedStart(const QString &name) const; + int capturedLength(const QString &name) const; + int capturedEnd(const QString &name) const; + +private: + friend class QRegularExpression; + friend struct QRegularExpressionMatchPrivate; + friend class QRegularExpressionMatchIterator; + + QRegularExpressionMatch(QRegularExpressionMatchPrivate &dd); + QSharedDataPointer d; +}; + +Q_DECLARE_TYPEINFO(QRegularExpressionMatch, Q_MOVABLE_TYPE); + +#ifndef QT_NO_DEBUG_STREAM +Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QRegularExpressionMatch &match); +#endif + +struct QRegularExpressionMatchIteratorPrivate; + +class Q_CORE_EXPORT QRegularExpressionMatchIterator +{ +public: + ~QRegularExpressionMatchIterator(); + QRegularExpressionMatchIterator(const QRegularExpressionMatchIterator &iterator); + QRegularExpressionMatchIterator &operator=(const QRegularExpressionMatchIterator &iterator); +#ifdef Q_COMPILER_RVALUE_REFS + inline QRegularExpressionMatchIterator &operator=(QRegularExpressionMatchIterator &&iterator) + { d.swap(iterator.d); return *this; } +#endif + void swap(QRegularExpressionMatchIterator &iterator) { d.swap(iterator.d); } + + bool isValid() const; + + bool hasNext() const; + QRegularExpressionMatch next(); + QRegularExpressionMatch peekNext() const; + + QRegularExpression regularExpression() const; + QRegularExpression::MatchType matchType() const; + QRegularExpression::MatchOptions matchOptions() const; + +private: + friend class QRegularExpression; + + QRegularExpressionMatchIterator(QRegularExpressionMatchIteratorPrivate &dd); + QSharedDataPointer d; +}; + +Q_DECLARE_TYPEINFO(QRegularExpressionMatchIterator, Q_MOVABLE_TYPE); + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QRegularExpression) + +QT_END_HEADER + +#endif // QT_NO_REGEXP + +#endif // QREGULAREXPRESSION_H diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index 3740975b12..250789a969 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -30,6 +30,7 @@ HEADERS += \ tools/qqueue.h \ tools/qrect.h \ tools/qregexp.h \ + tools/qregularexpression.h \ tools/qringbuffer_p.h \ tools/qrefcount.h \ tools/qscopedpointer.h \ @@ -75,6 +76,7 @@ SOURCES += \ tools/qcontiguouscache.cpp \ tools/qrect.cpp \ tools/qregexp.cpp \ + tools/qregularexpression.cpp \ tools/qrefcount.cpp \ tools/qshareddata.cpp \ tools/qsharedpointer.cpp \ @@ -105,6 +107,12 @@ contains(QT_CONFIG,icu) { DEFINES += QT_USE_ICU } +pcre { + include($$PWD/../../3rdparty/pcre.pri) +} else { + LIBS_PRIVATE += -lpcre16 +} + DEFINES += HB_EXPORT=Q_CORE_EXPORT INCLUDEPATH += ../3rdparty/harfbuzz/src HEADERS += ../3rdparty/harfbuzz/src/harfbuzz.h -- cgit v1.2.3 From aea65cbaa4fd889129d7945600dad3277f9c6d9b Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 7 Feb 2012 23:56:40 +0000 Subject: QRegularExpression: QDebug support for pattern options Added the proper QDebug operator to debug the QRegularExpression::PatternOptions flags. Change-Id: Icd00e93a0c6cc4345db528d494fc176624f7b7a2 Reviewed-by: hjk Reviewed-by: Lars Knoll --- src/corelib/tools/qregularexpression.cpp | 37 ++++++++++++++++++++++++++++++++ src/corelib/tools/qregularexpression.h | 1 + 2 files changed, 38 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index 488a454aaa..7fbbfaa9ef 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -1976,6 +1976,43 @@ QDebug operator<<(QDebug debug, const QRegularExpression &re) return debug.space(); } +/*! + \relates QRegularExpression + + Writes the pattern options \a patternOptions into the debug object \a debug + for debugging purposes. + + \sa {Debugging Techniques} +*/ +QDebug operator<<(QDebug debug, QRegularExpression::PatternOptions patternOptions) +{ + QStringList flags; + + if (patternOptions == QRegularExpression::NoPatternOption) { + flags << QLatin1String("NoPatternOption"); + } else { + if (patternOptions & QRegularExpression::CaseInsensitiveOption) + flags << QLatin1String("CaseInsensitiveOption"); + if (patternOptions & QRegularExpression::DotMatchesEverythingOption) + flags << QLatin1String("DotMatchesEverythingOption"); + if (patternOptions & QRegularExpression::MultilineOption) + flags << QLatin1String("MultilineOption"); + if (patternOptions & QRegularExpression::ExtendedPatternSyntaxOption) + flags << QLatin1String("ExtendedPatternSyntaxOption"); + if (patternOptions & QRegularExpression::InvertedGreedinessOption) + flags << QLatin1String("InvertedGreedinessOption"); + if (patternOptions & QRegularExpression::DontCaptureOption) + flags << QLatin1String("DontCaptureOption"); + if (patternOptions & QRegularExpression::UseUnicodePropertiesOption) + flags << QLatin1String("UseUnicodePropertiesOption"); + } + + debug.nospace() << "QRegularExpression::PatternOptions(" + << qPrintable(flags.join(QLatin1String("|"))) + << ")"; + + return debug.space(); +} /*! \relates QRegularExpressionMatch diff --git a/src/corelib/tools/qregularexpression.h b/src/corelib/tools/qregularexpression.h index c9bcb1e7ba..13c7de7cab 100644 --- a/src/corelib/tools/qregularexpression.h +++ b/src/corelib/tools/qregularexpression.h @@ -142,6 +142,7 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &in, QRegularExpression &re); #ifndef QT_NO_DEBUG_STREAM Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QRegularExpression &re); +Q_CORE_EXPORT QDebug operator<<(QDebug debug, QRegularExpression::PatternOptions patternOptions); #endif struct QRegularExpressionMatchPrivate; -- cgit v1.2.3 From bd30234b59c1a0cef81b8ce43f2fefac1f28b318 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 8 Feb 2012 18:53:22 +0000 Subject: QRegularExpression: improve operator==, add dedicated autotest Trivial change: compare dpointers first, then the data. Added test function for operator==. Change-Id: I33ac64a59db4ccad56c30be17622187e42415f38 Reviewed-by: Lars Knoll --- src/corelib/tools/qregularexpression.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index 7fbbfaa9ef..b7a5c3de8e 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -1395,7 +1395,8 @@ QRegularExpressionMatchIterator QRegularExpression::globalMatch(const QString &s */ bool QRegularExpression::operator==(const QRegularExpression &re) const { - return (pattern() == re.pattern() && patternOptions() == re.patternOptions()); + return (d == re.d) || + (d->pattern == re.d->pattern && d->patternOptions == re.d->patternOptions); } /*! -- cgit v1.2.3 From 1899861858eb262df7826eb32d1274233a35536e Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 8 Feb 2012 19:28:14 +0000 Subject: QRegularExpression: do not use JIT in debug builds PCRE's JIT uses self-modifying code extensively, requiring full SMC checks enabled by tools like valgrind, which slow down the execution considerably; not enabling SMC checks lead to crashes. Therefore, JIT is now disabled by default in debug builds of Qt. Its usage (both in debug and release builds) can be controlled by setting the QT_ENABLE_REGEXP_JIT environment variable. Change-Id: Ib38952400e4219582942ce65ab9edcd89c432f3e Reviewed-by: Lars Knoll --- src/corelib/tools/qregularexpression.cpp | 42 +++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index b7a5c3de8e..17988bdb31 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -509,6 +509,22 @@ QT_BEGIN_NAMESPACE QRegExp::CaretAtOffset behaviour. There is no equivalent for the other QRegExp::CaretMode modes. + \section1 Debugging code that uses QRegularExpression + + QRegularExpression internally uses a just in time compiler (JIT) to + optimize the execution of the matching algorithm. The JIT makes extensive + usage of self-modifying code, which can lead debugging tools such as + Valgrind to crash. You must enable all checks for self-modifying code if + you want to debug programs using QRegularExpression (f.i., see Valgrind's + \c{--smc-check} command line option). The downside of enabling such checks + is that your program will run considerably slower. + + To avoid that, the JIT is disabled by default if you compile Qt in debug + mode. It is possible to override the default and enable or disable the JIT + usage (both in debug or release mode) by setting the + \c{QT_ENABLE_REGEXP_JIT} environment variable to a non-zero or zero value + respectively. + \sa QRegularExpressionMatch, QRegularExpressionMatchIterator */ @@ -969,6 +985,25 @@ void QRegularExpressionPrivate::getPatternInfo() (patternNewlineSetting == PCRE_NEWLINE_ANYCRLF); } +/*! + \internal +*/ +static bool isJitEnabled() +{ + QByteArray jitEnvironment = qgetenv("QT_ENABLE_REGEXP_JIT"); + if (!jitEnvironment.isEmpty()) { + bool ok; + int enableJit = jitEnvironment.toInt(&ok); + return ok ? (enableJit != 0) : true; + } + +#ifdef QT_DEBUG + return false; +#else + return true; +#endif +} + /*! \internal */ @@ -981,7 +1016,12 @@ void QRegularExpressionPrivate::optimizePattern() if (studyData || (++usedCount != OPTIMIZE_AFTER_USE_COUNT)) return; - int studyOptions = PCRE_STUDY_JIT_COMPILE; + static const bool enableJit = isJitEnabled(); + + int studyOptions = 0; + if (enableJit) + studyOptions |= PCRE_STUDY_JIT_COMPILE; + const char *err; studyData = pcre16_study(compiledPattern, studyOptions, &err); -- cgit v1.2.3 From efcd4d9470781e3a0331afeab49cd00cee24399f Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 19 Feb 2012 23:56:50 +0100 Subject: QRegularExpression: add captureCount() QRegularExpression::captureCount() returns the number of capturing groups inside the regular expression pattern. Change-Id: Ib90ce67c67d06ab2966f0c98bd91da21defc156d Reviewed-by: Thiago Macieira --- src/corelib/tools/qregularexpression.cpp | 13 +++++++++++++ src/corelib/tools/qregularexpression.h | 2 ++ 2 files changed, 15 insertions(+) (limited to 'src/corelib') diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index 17988bdb31..7bbac0144b 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -1340,6 +1340,19 @@ void QRegularExpression::setPatternOptions(PatternOptions options) d->patternOptions = options; } +/*! + Returns the number of capturing groups inside the pattern string, + or -1 if the regular expression is not valid. + + \sa isValid() +*/ +int QRegularExpression::captureCount() const +{ + if (!isValid()) // will compile the pattern + return -1; + return d->capturingCount; +} + /*! Returns true if the regular expression is a valid regular expression (that is, it contains no syntax errors, etc.), or false otherwise. Use diff --git a/src/corelib/tools/qregularexpression.h b/src/corelib/tools/qregularexpression.h index 13c7de7cab..3ca83c9e27 100644 --- a/src/corelib/tools/qregularexpression.h +++ b/src/corelib/tools/qregularexpression.h @@ -94,6 +94,8 @@ public: int patternErrorOffset() const; QString errorString() const; + int captureCount() const; + enum MatchType { NormalMatch = 0, PartialPreferCompleteMatch, -- cgit v1.2.3 From d7b720dd3ee7a095abe7e283d1bed881268b0f5e Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 19 Feb 2012 23:58:04 +0100 Subject: QRegularExpression: const correctness fixes Adding some const qualifiers to members which are never written. Change-Id: Ibb8953764c7b7790a419a5d48f2956751d5fc1f9 Reviewed-by: Thiago Macieira --- src/corelib/tools/qregularexpression.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index 7bbac0144b..40b6b5a08e 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -817,14 +817,14 @@ struct QRegularExpressionMatchPrivate : QSharedData QRegularExpressionMatch nextMatch() const; - QRegularExpression regularExpression; - QString subject; + const QRegularExpression regularExpression; + const QString subject; // the capturedOffsets vector contains pairs of (start, end) positions // for each captured substring QVector capturedOffsets; - QRegularExpression::MatchType matchType; - QRegularExpression::MatchOptions matchOptions; + const QRegularExpression::MatchType matchType; + const QRegularExpression::MatchOptions matchOptions; int capturedCount; @@ -835,16 +835,16 @@ struct QRegularExpressionMatchPrivate : QSharedData struct QRegularExpressionMatchIteratorPrivate : QSharedData { - QRegularExpressionMatchIteratorPrivate(const QRegularExpression re, + QRegularExpressionMatchIteratorPrivate(const QRegularExpression &re, QRegularExpression::MatchType matchType, QRegularExpression::MatchOptions matchOptions, const QRegularExpressionMatch &next); bool hasNext() const; QRegularExpressionMatch next; - QRegularExpression regularExpression; - QRegularExpression::MatchType matchType; - QRegularExpression::MatchOptions matchOptions; + const QRegularExpression regularExpression; + const QRegularExpression::MatchType matchType; + const QRegularExpression::MatchOptions matchOptions; }; /*! @@ -1216,7 +1216,7 @@ QRegularExpressionMatch QRegularExpressionMatchPrivate::nextMatch() const /*! \internal */ -QRegularExpressionMatchIteratorPrivate::QRegularExpressionMatchIteratorPrivate(const QRegularExpression re, +QRegularExpressionMatchIteratorPrivate::QRegularExpressionMatchIteratorPrivate(const QRegularExpression &re, QRegularExpression::MatchType matchType, QRegularExpression::MatchOptions matchOptions, const QRegularExpressionMatch &next) -- cgit v1.2.3 From ebb94587f69207d02269d7c20dd963e59629cfc4 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 2 Mar 2012 08:07:23 +0100 Subject: Use #define before including SHA-2 3rdparty code Using typedef causes errors due to re-definition, so #define the types needed by the SHA-2 code to the q[u]int* equivalents instead. Change-Id: I6fc29788dd05aeee28723820f511527d482d31f2 Reviewed-by: Oliver Wolff --- src/corelib/tools/qcryptographichash.cpp | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index 3730a6c580..be124c94f7 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -48,23 +48,16 @@ #include "../../3rdparty/sha1/sha1.cpp" /* - These typedefs are needed by the RFC6234 code. Normally they would come - from from stdint.h, but since this header is not available on all platforms - (MSVC 2008, for example), we need to define them ourselves. + These #defines replace the typedefs needed by the RFC6234 code. Normally + the typedefs would come from from stdint.h, but since this header is not + available on all platforms (MSVC 2008, for example), we #define them to the + Qt equivalents. */ -#ifndef _UINT64_T_DECLARED -typedef QT_PREPEND_NAMESPACE(quint64) uint64_t; -#endif +#define uint64_t QT_PREPEND_NAMESPACE(quint64) +#define uint32_t QT_PREPEND_NAMESPACE(quint32) +#define uint8_t QT_PREPEND_NAMESPACE(quint8) +#define int_least16_t QT_PREPEND_NAMESPACE(qint16) -#ifndef _UINT32_T_DECLARED -typedef QT_PREPEND_NAMESPACE(quint32) uint32_t; -#endif - -#ifndef _UINT8_T_DECLARED -typedef QT_PREPEND_NAMESPACE(quint8) uint8_t; -#endif - -typedef QT_PREPEND_NAMESPACE(qint16) int_least16_t; // Header from rfc6234 with 1 modification: // sha1.h - commented out '#include ' on line 74 #include "../../3rdparty/rfc6234/sha.h" @@ -90,16 +83,21 @@ static int SHA384_512AddLength(SHA512Context *context, unsigned int length); // sha384-512.c - appended 'M' to the SHA224_256AddLength macro on line 304 #include "../../3rdparty/rfc6234/sha384-512.c" +#undef uint64_t +#undef uint32_t +#undef uint68_t +#undef int_least16_t + #include static inline int SHA224_256AddLength(SHA256Context *context, unsigned int length) { - uint32_t addTemp; + QT_PREPEND_NAMESPACE(quint32) addTemp; return SHA224_256AddLengthM(context, length); } static inline int SHA384_512AddLength(SHA512Context *context, unsigned int length) { - uint64_t addTemp; + QT_PREPEND_NAMESPACE(quint64) addTemp; return SHA384_512AddLengthM(context, length); } -- cgit v1.2.3 From c74bc26605f2337b13f366c2600fff4822d88ffe Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Tue, 6 Mar 2012 11:17:07 +1000 Subject: Support legacy QDataStream serialization of QDate. Commit 8327fa7c11f6c84ccc66be4365ee282a76288788 changed the type of the Julian day member of QDate from quint32 to qint64. This changed the QDataStream format. Keep the old behavior, with the limited date range, if the stream version is less than Qt_5_0. Change-Id: I800448979a1891581069f39de7f9ab9c634e4f0e Reviewed-by: John Layt Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetime.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 64ad3121d0..fa5eed4f86 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -3511,7 +3511,10 @@ void QDateTime::detach() QDataStream &operator<<(QDataStream &out, const QDate &date) { - return out << (qint64)(date.jd); + if (out.version() < QDataStream::Qt_5_0) + return out << quint32(date.jd); + else + return out << qint64(date.jd); } /*! @@ -3524,9 +3527,16 @@ QDataStream &operator<<(QDataStream &out, const QDate &date) QDataStream &operator>>(QDataStream &in, QDate &date) { - qint64 jd; - in >> jd; - date.jd = jd; + if (in.version() < QDataStream::Qt_5_0) { + quint32 jd; + in >> jd; + date.jd = jd; + } else { + qint64 jd; + in >> jd; + date.jd = jd; + } + return in; } -- cgit v1.2.3 From 7ae6a6e744f92db2626b7c9b38175dc4140a4eaf Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 6 Mar 2012 17:55:14 +1000 Subject: Fixed warning from gcc with -Wundef for some values of WCHAR_MAX Certain versions of system headers will declare WCHAR_MAX like: #define __WCHAR_MAX ( (wchar_t) - 1 ) #define WCHAR_MAX __WCHAR_MAX In particular on ARM (see e.g. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=598937 ) In this case, defined(WCHAR_MAX) is true, but attempting to use the value of WCHAR_MAX in a preprocessor expression will not give the desired results - "wchar_t" is unknown to the preprocessor, so WCHAR_MAX silently (without -Wundef) evaluates to ( (0) - 1 ) == -1. A simple workaround is to avoid looking at WCHAR_MAX when the superior __SIZEOF_WCHAR_T__ is defined. Change-Id: I439b166cffb93416737ee19025fb6e8d51c27876 Reviewed-by: Bradley T. Hughes Reviewed-by: Thiago Macieira --- src/corelib/tools/qstring.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 6fc86fc04b..4d02fbe66d 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -98,7 +98,9 @@ template struct QConstStringData #define QT_UNICODE_LITERAL_II(str) u"" str -#elif defined(Q_OS_WIN) || (defined(__SIZEOF_WCHAR_T__) && __SIZEOF_WCHAR_T__ == 2) || defined(WCHAR_MAX) && (WCHAR_MAX - 0 < 65536) +#elif defined(Q_OS_WIN) \ + || (defined(__SIZEOF_WCHAR_T__) && __SIZEOF_WCHAR_T__ == 2) \ + || (!defined(__SIZEOF_WCHAR_T__) && defined(WCHAR_MAX) && (WCHAR_MAX - 0 < 65536)) // wchar_t is 2 bytes template struct QConstStringData { -- cgit v1.2.3 From 53bbea232830af3f056cd8253c4ff4dd33f525c7 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 6 Mar 2012 13:05:09 +0100 Subject: Fix parsing of unicode escape sequences Change-Id: I63a7cd3a571fb47c97157bcb2ca29c4239c600ba Reviewed-by: Thiago Macieira --- src/corelib/json/qjsonparser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/json/qjsonparser.cpp b/src/corelib/json/qjsonparser.cpp index 16eedadf1a..a83685da22 100644 --- a/src/corelib/json/qjsonparser.cpp +++ b/src/corelib/json/qjsonparser.cpp @@ -584,9 +584,9 @@ static inline bool addHexDigit(char digit, uint *result) if (digit >= '0' && digit <= '9') *result |= (digit - '0'); else if (digit >= 'a' && digit <= 'f') - *result |= (digit - 'a'); + *result |= (digit - 'a') + 10; else if (digit >= 'A' && digit <= 'F') - *result |= (digit - 'A'); + *result |= (digit - 'A') + 10; else return false; return true; -- cgit v1.2.3 From 76d0df1b0ad9de56b7ca2e86c254f61d6e5ea702 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 6 Mar 2012 17:50:05 +1000 Subject: Fixed warnings from arm builds with -Wundef Do not use the value of a macro before verifying that the macro is defined. Change-Id: I36bebe37da5f4e5e7af1e423b7f2b18091e35707 Reviewed-by: Oswald Buddenhagen Reviewed-by: Bradley T. Hughes --- src/corelib/global/qprocessordetection.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h index 4213d5830e..1f16f090a9 100644 --- a/src/corelib/global/qprocessordetection.h +++ b/src/corelib/global/qprocessordetection.h @@ -93,7 +93,7 @@ || defined(__ARM_ARCH_7A__) \ || defined(__ARM_ARCH_7R__) \ || defined(__ARM_ARCH_7M__) \ - || (__TARGET_ARCH_ARM-0 >= 7) + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7) # define Q_PROCESSOR_ARM_V7 # define Q_PROCESSOR_ARM_V6 # define Q_PROCESSOR_ARM_V5 @@ -104,11 +104,11 @@ || defined(__ARM_ARCH_6K__) \ || defined(__ARM_ARCH_6ZK__) \ || defined(__ARM_ARCH_6M__) \ - || (__TARGET_ARCH_ARM-0 >= 6) + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6) # define Q_PROCESSOR_ARM_V6 # define Q_PROCESSOR_ARM_V5 # elif defined(__ARM_ARCH_5TEJ__) \ - || (__TARGET_ARCH_ARM-0 >= 5) + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5) # define Q_PROCESSOR_ARM_V5 # endif # if defined(__ARMEL__) -- cgit v1.2.3 From 02d947524d887e3ff6cb24065ccdbf3311ea81a8 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sat, 3 Mar 2012 12:41:13 +0000 Subject: QRegularExpression: fix documentation due to qdoc changes Removes the usage of various qdoc macros which are now deprecated. Change-Id: I74fa70f8d2a2a1bff57cdb2bcc14a31a7198dea0 Reviewed-by: Casper van Donderen --- src/corelib/tools/qregularexpression.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index 40b6b5a08e..7faa907e35 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -73,21 +73,21 @@ QT_BEGIN_NAMESPACE strings and texts. This is useful in many contexts, e.g., \table - \row \i Validation - \i A regexp can test whether a substring meets some criteria, + \row \li Validation + \li A regexp can test whether a substring meets some criteria, e.g. is an integer or contains no whitespace. - \row \i Searching - \i A regexp provides more powerful pattern matching than + \row \li Searching + \li A regexp provides more powerful pattern matching than simple substring matching, e.g., match one of the words \e{mail}, \e{letter} or \e{correspondence}, but none of the words \e{email}, \e{mailman}, \e{mailer}, \e{letterbox}, etc. - \row \i Search and Replace - \i A regexp can replace all occurrences of a substring with a + \row \li Search and Replace + \li A regexp can replace all occurrences of a substring with a different substring, e.g., replace all occurrences of \e{&} with \e{\&} except where the \e{&} is already followed by an \e{amp;}. - \row \i String Splitting - \i A regexp can be used to identify where a string should be + \row \li String Splitting + \li A regexp can be used to identify where a string should be split apart, e.g. splitting tab-delimited strings. \endtable @@ -99,12 +99,12 @@ QT_BEGIN_NAMESPACE Good references about regular expressions include: \list - \o \e {Mastering Regular Expressions} (Third Edition) by Jeffrey E. F. + \li \e {Mastering Regular Expressions} (Third Edition) by Jeffrey E. F. Friedl, ISBN 0-596-52812-4; - \o the \l{http://pcre.org/pcre.txt} {pcrepattern(3)} man page, describing + \li the \l{http://pcre.org/pcre.txt} {pcrepattern(3)} man page, describing the pattern syntax supported by PCRE (the reference implementation of Perl-compatible regular expressions); - \o the \l{http://perldoc.perl.org/perlre.html} {Perl's regular expression + \li the \l{http://perldoc.perl.org/perlre.html} {Perl's regular expression documentation} and the \l{http://perldoc.perl.org/perlretut.html} {Perl's regular expression tutorial}. \endlist @@ -117,7 +117,7 @@ QT_BEGIN_NAMESPACE supports Unicode. For an overview of the regular expression syntax supported by QRegularExpression, please refer to the aforementioned pcrepattern(3) man page. A regular expression is made up of two things: a - \bold{pattern string} and a set of \bold{pattern options} that change the + \b{pattern string} and a set of \b{pattern options} that change the meaning of the pattern string. You can set the pattern string by passing a string to the QRegularExpression @@ -307,9 +307,9 @@ QT_BEGIN_NAMESPACE to do so we must distinguish three cases: \list - \o the input cannot possibly match the regular expression; - \o the input does match the regular expression; - \o the input does not match the regular expression right now, + \li the input cannot possibly match the regular expression; + \li the input does match the regular expression; + \li the input does not match the regular expression right now, but it will if more charaters will be added to it. \endlist @@ -653,7 +653,7 @@ QT_BEGIN_NAMESPACE \value ExtendedPatternSyntaxOption Any whitespace in the pattern string which is not escaped and outside a - character class is ignored. Moreover, an unescaped sharp (\bold{#}) + character class is ignored. Moreover, an unescaped sharp (\b{#}) outside a character class causes all the following characters, until the first newline (included), to be ignored. This can be used to increase the readability of a pattern string as well as put comments -- cgit v1.2.3 From a47d974e19512ae5a445f64fbd2b1703201f781d Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 16 Feb 2012 23:49:27 +0100 Subject: QRegularExpression: fix optimizePattern, document the issue The studyData pointer is atomically set by the pointer assignment, but another processor running a different thread might see the new studyData value but not the memory it points to. Therefore, the current studyData is returned from optimizePattern and used by that thread. Docs were added to optimizePattern to explain what's going on. Change-Id: I4502c336077bb98a1751011aa93ffd4f585ed101 Reviewed-by: Thiago Macieira --- src/corelib/tools/qregularexpression.cpp | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index 7faa907e35..0252a30c89 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -773,7 +773,7 @@ struct QRegularExpressionPrivate : QSharedData void cleanCompiledPattern(); void compilePattern(); void getPatternInfo(); - void optimizePattern(); + pcre16_extra *optimizePattern(); QRegularExpressionMatchPrivate *doMatch(const QString &subject, int offset, @@ -1006,15 +1006,30 @@ static bool isJitEnabled() /*! \internal + + The purpose of the function is to call pcre16_study (which allows some + optimizations to be performed, including JIT-compiling the pattern), and + setting the studyData member variable to the result of the study. It gets + called by doMatch() every time a match is performed. As of now, the + optimizations on the pattern are performed after a certain number of usages + (i.e. the OPTIMIZE_AFTER_USE_COUNT constant). + + Notice that although the method is protected by a mutex, one thread may + invoke this function and return immediately (i.e. not study the pattern, + leaving studyData to NULL); but before calling pcre16_exec to perform the + match, another thread performs the studying and sets studyData to something + else. Although the assignment to studyData is itself atomic, the release of + the memory pointed by studyData isn't. Therefore, the current studyData + value is returned and used by doMatch. */ -void QRegularExpressionPrivate::optimizePattern() +pcre16_extra *QRegularExpressionPrivate::optimizePattern() { Q_ASSERT(compiledPattern); QMutexLocker lock(&mutex); if (studyData || (++usedCount != OPTIMIZE_AFTER_USE_COUNT)) - return; + return studyData; static const bool enableJit = isJitEnabled(); @@ -1027,6 +1042,8 @@ void QRegularExpressionPrivate::optimizePattern() if (!studyData && err) qWarning("QRegularExpressionPrivate::optimizePattern(): pcre_study failed: %s", err); + + return studyData; } /*! @@ -1089,7 +1106,7 @@ QRegularExpressionMatchPrivate *QRegularExpressionPrivate::doMatch(const QString capturingCount); // this is mutex protected - const_cast(this)->optimizePattern(); + const pcre16_extra *currentStudyData = const_cast(this)->optimizePattern(); int pcreOptions = convertToPcreOptions(matchOptions); @@ -1113,12 +1130,12 @@ QRegularExpressionMatchPrivate *QRegularExpressionPrivate::doMatch(const QString int result; if (!previousMatchWasEmpty) { - result = pcre16_exec(compiledPattern, studyData, + result = pcre16_exec(compiledPattern, currentStudyData, subjectUtf16, subjectLength, offset, pcreOptions, captureOffsets, captureOffsetsCount); } else { - result = pcre16_exec(compiledPattern, studyData, + result = pcre16_exec(compiledPattern, currentStudyData, subjectUtf16, subjectLength, offset, pcreOptions | PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED, captureOffsets, captureOffsetsCount); @@ -1136,7 +1153,7 @@ QRegularExpressionMatchPrivate *QRegularExpressionPrivate::doMatch(const QString ++offset; } - result = pcre16_exec(compiledPattern, studyData, + result = pcre16_exec(compiledPattern, currentStudyData, subjectUtf16, subjectLength, offset, pcreOptions, captureOffsets, captureOffsetsCount); -- cgit v1.2.3 From e1b2755083c8b30d2062108ea490f9c49729cf3b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 6 Mar 2012 22:06:30 +0100 Subject: itemview/itemmodels: make some constructors explicit This is a semi-automatic search, so I'm reasonably sure that all the exported ones have been caught. Change-Id: I38d7978f1fcf7513e802ed0042aa7a57a95b0060 Reviewed-by: Stephen Kelly --- src/corelib/itemmodels/qabstractproxymodel.h | 2 +- src/corelib/itemmodels/qsortfilterproxymodel.h | 2 +- src/corelib/itemmodels/qstringlistmodel.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/itemmodels/qabstractproxymodel.h b/src/corelib/itemmodels/qabstractproxymodel.h index 3c82199038..d80fcb683c 100644 --- a/src/corelib/itemmodels/qabstractproxymodel.h +++ b/src/corelib/itemmodels/qabstractproxymodel.h @@ -59,7 +59,7 @@ class Q_CORE_EXPORT QAbstractProxyModel : public QAbstractItemModel Q_OBJECT public: - QAbstractProxyModel(QObject *parent = 0); + explicit QAbstractProxyModel(QObject *parent = 0); ~QAbstractProxyModel(); virtual void setSourceModel(QAbstractItemModel *sourceModel); diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.h b/src/corelib/itemmodels/qsortfilterproxymodel.h index 8c7433d307..f18b1fccb1 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.h +++ b/src/corelib/itemmodels/qsortfilterproxymodel.h @@ -73,7 +73,7 @@ class Q_CORE_EXPORT QSortFilterProxyModel : public QAbstractProxyModel Q_PROPERTY(int filterRole READ filterRole WRITE setFilterRole) public: - QSortFilterProxyModel(QObject *parent = 0); + explicit QSortFilterProxyModel(QObject *parent = 0); ~QSortFilterProxyModel(); void setSourceModel(QAbstractItemModel *sourceModel); diff --git a/src/corelib/itemmodels/qstringlistmodel.h b/src/corelib/itemmodels/qstringlistmodel.h index d8b3f87f4a..a6bc4e7bd3 100644 --- a/src/corelib/itemmodels/qstringlistmodel.h +++ b/src/corelib/itemmodels/qstringlistmodel.h @@ -57,7 +57,7 @@ class Q_CORE_EXPORT QStringListModel : public QAbstractListModel Q_OBJECT public: explicit QStringListModel(QObject *parent = 0); - QStringListModel(const QStringList &strings, QObject *parent = 0); + explicit QStringListModel(const QStringList &strings, QObject *parent = 0); int rowCount(const QModelIndex &parent = QModelIndex()) const; -- cgit v1.2.3 From 7439fb47cd7c5731dd1aadeaf10c46b58aa59798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Tue, 6 Mar 2012 15:12:06 +0100 Subject: Add nicer error message in qMetaTypeId function. The function can be used only with a registered type and it would fail to compile for other types. By adding the static assert we can print an almost user friendly compilation error message. Change-Id: I59ab148cabf32afe0baef186b82cb03303b57780 Reviewed-by: Stephen Kelly Reviewed-by: Olivier Goffart --- src/corelib/kernel/qmetatype.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 7f6eaf2230..eacb8403dc 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -484,6 +484,7 @@ inline int qMetaTypeId( #endif ) { + Q_STATIC_ASSERT_X(QMetaTypeId2::Defined, "Type is not registered, please use Q_DECLARE_METATYPE macro to make it know to Qt's meta-object system"); return QMetaTypeId2::qt_metatype_id(); } -- cgit v1.2.3 From 5713dde8a1e6a35483134ffe9d986db66b208cf5 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 7 Mar 2012 12:24:30 +0100 Subject: Fix deadlock in QPropertyAnimation Commit 1e6514a714c1f55b9cb57d2b8b65bc2305c2e2c6 changed the mutex from recursive to non-recursive, which could introduce dead lock if the animation starts other animation (This is the case in QMainWindow layouts) Change-Id: I1b149b78a802748eb24b5700fffeca0b8555f005 Reviewed-by: Friedemann Kleint --- src/corelib/animation/qpropertyanimation.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/corelib') diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index 83ae7bafaa..f7ba49c3cd 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -281,6 +281,7 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State newState, d->updateMetaProperty(); animToStop = hash.value(key, 0); hash.insert(key, this); + locker.unlock(); // update the default start value if (oldState == Stopped) { d->setDefaultStartEndValue(d->targetValue->property(d->propertyName.constData())); -- cgit v1.2.3 From a6a7cabcd3b38dbd65570a23a800d7e3800a78d0 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 2 Mar 2012 15:41:51 +0100 Subject: Add QUrl formatting option "PreferLocalFile". For the readonly case (e.g. progress dialogs), where local file paths look much nicer to end users than file:/// URLs. Change-Id: I899fed27cfb73ebf565389cfd489d2d2fcbeac7c Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- src/corelib/io/qurl.cpp | 31 ++++++++++++++++++++++++------- src/corelib/io/qurl.h | 1 + 2 files changed, 25 insertions(+), 7 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 0659053937..9b15c1fd98 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -170,6 +170,8 @@ \value RemoveQuery The query part of the URL (following a '?' character) is removed. \value RemoveFragment + \value PreferLocalFile If the URL is a local file according to isLocalFile() + and contains no query or fragment, a local file path is returned. \value StripTrailingSlash The trailing slash is removed if one is present. Note that the case folding rules in \l{RFC 3491}{Nameprep}, which QUrl @@ -331,6 +333,7 @@ public: void clear(); QByteArray toEncoded(QUrl::FormattingOptions options = QUrl::None) const; + bool isLocalFile() const; QAtomicInt ref; @@ -3953,6 +3956,9 @@ QByteArray QUrlPrivate::toEncoded(QUrl::FormattingOptions options) const if (options==0x100) // private - see qHash(QUrl) return normalized(); + if ((options & QUrl::PreferLocalFile) && isLocalFile() && !hasQuery && !hasFragment) + return encodedPath; + QByteArray url; if (!(options & QUrl::RemoveScheme) && !scheme.isEmpty()) { @@ -5695,9 +5701,12 @@ QString QUrl::toString(FormattingOptions options) const QString url; + const QString ourPath = path(); + if ((options & QUrl::PreferLocalFile) && isLocalFile() && !d->hasQuery && !d->hasFragment) + return ourPath; + if (!(options & QUrl::RemoveScheme) && !d->scheme.isEmpty()) url += d->scheme + QLatin1Char(':'); - QString ourPath = path(); if ((options & QUrl::RemoveAuthority) != QUrl::RemoveAuthority) { bool doFileScheme = d->scheme == QLatin1String("file") && ourPath.startsWith(QLatin1Char('/')); QString tmp = d->authority(options); @@ -5733,6 +5742,7 @@ QString QUrl::toString(FormattingOptions options) const } /*! + \since 5.0 Returns a string representation of the URL. The output can be customized by passing flags with \a options. @@ -5748,13 +5758,16 @@ QString QUrl::url(FormattingOptions options) const } /*! + \since 5.0 + Returns a human-displayable string representation of the URL. The output can be customized by passing flags with \a options. The option RemovePassword is always enabled, since passwords should never be shown back to users. - The resulting QString can be passed back to a QUrl later on, - but any password that was present initially will be lost. + With the default options, the resulting QString can be passed back + to a QUrl later on, but any password that was present initially will + be lost. \sa FormattingOptions, toEncoded(), toString() */ @@ -6171,6 +6184,13 @@ QString QUrl::toLocalFile() const return tmp; } +bool QUrlPrivate::isLocalFile() const +{ + if (scheme.compare(QLatin1String("file"), Qt::CaseInsensitive) != 0) + return false; // not file + return true; +} + /*! \since 4.7 Returns true if this URL is pointing to a local file path. A URL is a @@ -6186,10 +6206,7 @@ bool QUrl::isLocalFile() const { if (!d) return false; if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); - - if (d->scheme.compare(QLatin1String("file"), Qt::CaseInsensitive) != 0) - return false; // not file - return true; + return d->isLocalFile(); } /*! diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index 3e5c62cd7c..fc49231594 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -76,6 +76,7 @@ public: RemoveQuery = 0x40, RemoveFragment = 0x80, // 0x100: private: normalized + PreferLocalFile = 0x200, StripTrailingSlash = 0x10000 }; -- cgit v1.2.3 From eb709333989a7e3d8eb662a0e167ac81ca19d882 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 22 Feb 2012 03:33:00 +0000 Subject: QRegularExpression: add optimizations autotest Exporting the counter that controls the optimization of a compiled pattern lets us to forcibly optimize all patterns. Therefore, two tests are now run: one with default optimization values and another one which always optimizes the pattern. The counter itself was renamed with a qt_ prefix and put inside the Qt compilation namespace (thanks to rohanpm for pointing it out). Change-Id: I56602433d37adc127772b2d0d2cdaf2e49d43c71 Reviewed-by: Rohan McGovern Reviewed-by: Thiago Macieira --- src/corelib/tools/qregularexpression.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp index 0252a30c89..0fa7d6459e 100644 --- a/src/corelib/tools/qregularexpression.cpp +++ b/src/corelib/tools/qregularexpression.cpp @@ -50,9 +50,6 @@ #include -// after how many usages we optimize the regexp -static const unsigned int OPTIMIZE_AFTER_USE_COUNT = 10; - QT_BEGIN_NAMESPACE /*! @@ -726,6 +723,13 @@ QT_BEGIN_NAMESPACE contain any metacharacter that anchors the match at that point. */ +// after how many usages we optimize the regexp +#ifdef QT_BUILD_INTERNAL +Q_AUTOTEST_EXPORT unsigned int qt_qregularexpression_optimize_after_use_count = 10; +#else +static const unsigned int qt_qregularexpression_optimize_after_use_count = 10; +#endif // QT_BUILD_INTERNAL + /*! \internal */ @@ -1012,7 +1016,7 @@ static bool isJitEnabled() setting the studyData member variable to the result of the study. It gets called by doMatch() every time a match is performed. As of now, the optimizations on the pattern are performed after a certain number of usages - (i.e. the OPTIMIZE_AFTER_USE_COUNT constant). + (i.e. the qt_qregularexpression_optimize_after_use_count constant). Notice that although the method is protected by a mutex, one thread may invoke this function and return immediately (i.e. not study the pattern, @@ -1028,7 +1032,7 @@ pcre16_extra *QRegularExpressionPrivate::optimizePattern() QMutexLocker lock(&mutex); - if (studyData || (++usedCount != OPTIMIZE_AFTER_USE_COUNT)) + if (studyData || (++usedCount != qt_qregularexpression_optimize_after_use_count)) return studyData; static const bool enableJit = isJitEnabled(); -- cgit v1.2.3