summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/Qt5CoreConfigExtras.cmake.in3
-rw-r--r--src/corelib/animation/qpropertyanimation.cpp6
-rw-r--r--src/corelib/animation/qvariantanimation.cpp46
-rw-r--r--src/corelib/arch/qatomic_gcc.h2
-rw-r--r--src/corelib/arch/qatomic_ia64.h4
-rw-r--r--src/corelib/codecs/codecs.qdoc56
-rw-r--r--src/corelib/codecs/qtextcodec.cpp129
-rw-r--r--src/corelib/codecs/qtextcodec.h7
-rw-r--r--src/corelib/global/qglobal.cpp18
-rw-r--r--src/corelib/global/qglobal.h16
-rw-r--r--src/corelib/global/qlibraryinfo.cpp204
-rw-r--r--src/corelib/global/qlibraryinfo.h20
-rw-r--r--src/corelib/global/qlogging.cpp2
-rw-r--r--src/corelib/global/qnamespace.qdoc54
-rw-r--r--src/corelib/global/qnumeric_p.h42
-rw-r--r--src/corelib/global/qprocessordetection.h82
-rw-r--r--src/corelib/global/qtypeinfo.h8
-rw-r--r--src/corelib/io/io.pri3
-rw-r--r--src/corelib/io/qdatastream.cpp97
-rw-r--r--src/corelib/io/qdir.cpp20
-rw-r--r--src/corelib/io/qfile.cpp643
-rw-r--r--src/corelib/io/qfile.h62
-rw-r--r--src/corelib/io/qfile_p.h20
-rw-r--r--src/corelib/io/qfiledevice.cpp736
-rw-r--r--src/corelib/io/qfiledevice.h147
-rw-r--r--src/corelib/io/qfiledevice_p.h104
-rw-r--r--src/corelib/io/qfileinfo.cpp6
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp18
-rw-r--r--src/corelib/io/qfilesystemwatcher_polling_p.h1
-rw-r--r--src/corelib/io/qiodevice.cpp16
-rw-r--r--src/corelib/io/qprocess.cpp18
-rw-r--r--src/corelib/io/qprocess_win.cpp2
-rw-r--r--src/corelib/io/qresource.cpp8
-rw-r--r--src/corelib/io/qsettings.cpp132
-rw-r--r--src/corelib/io/qstandardpaths_unix.cpp1
-rw-r--r--src/corelib/io/qtextstream.cpp68
-rw-r--r--src/corelib/io/qurl.cpp47
-rw-r--r--src/corelib/io/qurl.h1
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp82
-rw-r--r--src/corelib/itemmodels/qabstractproxymodel.h2
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.cpp20
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.h2
-rw-r--r--src/corelib/itemmodels/qstringlistmodel.h2
-rw-r--r--src/corelib/json/qjson_p.h3
-rw-r--r--src/corelib/json/qjsonarray.cpp5
-rw-r--r--src/corelib/json/qjsondocument.cpp1
-rw-r--r--src/corelib/json/qjsonobject.cpp5
-rw-r--r--src/corelib/json/qjsonparser.cpp4
-rw-r--r--src/corelib/json/qjsonvalue.cpp32
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.cpp24
-rw-r--r--src/corelib/kernel/qcore_mac_p.h23
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp29
-rw-r--r--src/corelib/kernel/qcoreapplication.h6
-rw-r--r--src/corelib/kernel/qcoreevent.h7
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib.cpp5
-rw-r--r--src/corelib/kernel/qeventdispatcher_win_p.h3
-rw-r--r--src/corelib/kernel/qeventloop.cpp6
-rw-r--r--src/corelib/kernel/qmetaobject.cpp28
-rw-r--r--src/corelib/kernel/qmetatype.cpp7
-rw-r--r--src/corelib/kernel/qmetatype.h100
-rw-r--r--src/corelib/kernel/qmimedata.cpp18
-rw-r--r--src/corelib/kernel/qobject.cpp45
-rw-r--r--src/corelib/kernel/qobject.h9
-rw-r--r--src/corelib/kernel/qobject_p.h14
-rw-r--r--src/corelib/kernel/qobjectdefs.h18
-rw-r--r--src/corelib/kernel/qpointer.cpp4
-rw-r--r--src/corelib/kernel/qsharedmemory.cpp6
-rw-r--r--src/corelib/kernel/qsocketnotifier.cpp16
-rw-r--r--src/corelib/kernel/qsystemsemaphore.cpp8
-rw-r--r--src/corelib/kernel/qtranslator.cpp56
-rw-r--r--src/corelib/kernel/qvariant.cpp46
-rw-r--r--src/corelib/kernel/qwineventnotifier.cpp4
-rw-r--r--src/corelib/mimetypes/qmimeprovider.cpp2
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp13
-rw-r--r--src/corelib/plugin/qlibrary.cpp12
-rw-r--r--src/corelib/plugin/qpluginloader.cpp4
-rw-r--r--src/corelib/plugin/quuid.cpp168
-rw-r--r--src/corelib/statemachine/qstatemachine.h2
-rw-r--r--src/corelib/thread/qatomic.cpp72
-rw-r--r--src/corelib/thread/qbasicatomic.h4
-rw-r--r--src/corelib/thread/qgenericatomic.h6
-rw-r--r--src/corelib/thread/qmutexpool.cpp3
-rw-r--r--src/corelib/thread/qmutexpool_p.h2
-rw-r--r--src/corelib/thread/qsemaphore.cpp4
-rw-r--r--src/corelib/thread/qthread.cpp32
-rw-r--r--src/corelib/thread/qthread.h3
-rw-r--r--src/corelib/thread/qthread_unix.cpp2
-rw-r--r--src/corelib/thread/qthreadpool.cpp25
-rw-r--r--src/corelib/thread/qthreadpool_p.h1
-rw-r--r--src/corelib/thread/qthreadstorage.cpp4
-rw-r--r--src/corelib/thread/qwaitcondition.qdoc8
-rw-r--r--src/corelib/tools/qalgorithms.qdoc14
-rw-r--r--src/corelib/tools/qbytearray.cpp32
-rw-r--r--src/corelib/tools/qbytearray.h12
-rw-r--r--src/corelib/tools/qcryptographichash.cpp25
-rw-r--r--src/corelib/tools/qcryptographichash.h2
-rw-r--r--src/corelib/tools/qdatetime.cpp424
-rw-r--r--src/corelib/tools/qharfbuzz.cpp7
-rw-r--r--src/corelib/tools/qharfbuzz_p.h1
-rw-r--r--src/corelib/tools/qhash.cpp6
-rw-r--r--src/corelib/tools/qline.cpp20
-rw-r--r--src/corelib/tools/qlinkedlist.cpp6
-rw-r--r--src/corelib/tools/qlist.cpp6
-rw-r--r--src/corelib/tools/qlocale.cpp22
-rw-r--r--src/corelib/tools/qlocale.h1
-rw-r--r--src/corelib/tools/qlocale.qdoc12
-rw-r--r--src/corelib/tools/qlocale_p.h2
-rw-r--r--src/corelib/tools/qlocale_tools.cpp44
-rw-r--r--src/corelib/tools/qlocale_tools_p.h4
-rw-r--r--src/corelib/tools/qlocale_unix.cpp2
-rw-r--r--src/corelib/tools/qmap.cpp6
-rw-r--r--src/corelib/tools/qpair.h22
-rw-r--r--src/corelib/tools/qrect.cpp48
-rw-r--r--src/corelib/tools/qregexp.cpp411
-rw-r--r--src/corelib/tools/qregularexpression.cpp2134
-rw-r--r--src/corelib/tools/qregularexpression.h248
-rw-r--r--src/corelib/tools/qringbuffer_p.h2
-rw-r--r--src/corelib/tools/qscopedpointer.cpp6
-rw-r--r--src/corelib/tools/qscopedvaluerollback.h2
-rw-r--r--src/corelib/tools/qshareddata.cpp4
-rw-r--r--src/corelib/tools/qsize.cpp12
-rw-r--r--src/corelib/tools/qstring.cpp78
-rw-r--r--src/corelib/tools/qstring.h20
-rw-r--r--src/corelib/tools/qstringbuilder.h16
-rw-r--r--src/corelib/tools/qstringlist.cpp2
-rw-r--r--src/corelib/tools/qstringmatcher.h2
-rw-r--r--src/corelib/tools/qvarlengtharray.qdoc6
-rw-r--r--src/corelib/tools/qvector.cpp8
-rw-r--r--src/corelib/tools/tools.pri8
-rw-r--r--src/corelib/xml/qxmlstream.h14
130 files changed, 5074 insertions, 2473 deletions
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)
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp
index fc51a20a15..f7ba49c3cd 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 <private/qmutexpool_p.h>
+#include <QtCore/QMutex>
#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<QObject *, QByteArray> QPropertyAnimationPair;
typedef QHash<QPropertyAnimationPair, QPropertyAnimation*> QPropertyAnimationHash;
@@ -280,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()));
diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp
index 35a340836d..59b2d6abf3 100644
--- a/src/corelib/animation/qvariantanimation.cpp
+++ b/src/corelib/animation/qvariantanimation.cpp
@@ -45,7 +45,6 @@
#include <QtCore/qrect.h>
#include <QtCore/qline.h>
#include <QtCore/qmutex.h>
-#include <private/qmutexpool_p.h>
#ifndef QT_NO_ANIMATION
@@ -98,18 +97,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
@@ -399,6 +398,7 @@ void QVariantAnimation::setEasingCurve(const QEasingCurve &easing)
typedef QVector<QVariantAnimation::Interpolator> 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(&registeredInterpolatorsMutex);
if (int(interpolationType) >= interpolators->count())
interpolators->resize(int(interpolationType) + 1);
interpolators->replace(interpolationType, func);
@@ -452,14 +450,14 @@ template<typename T> 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(&registeredInterpolatorsMutex);
+ QVariantAnimation::Interpolator ret = 0;
+ if (interpolationType < interpolators->count()) {
+ ret = interpolators->at(interpolationType);
+ if (ret) return ret;
+ }
}
switch(interpolationType)
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 <typename T> struct QAtomicOps: QGenericAtomicOps<QAtomicOps<T> >
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 <int size> struct QBasicAtomicOps: QGenericAtomicOps<QBasicAtomicOps<si
static void orderedMemoryFence();
template <typename T> static inline
- T loadAcquire(T &_q_value)
+ T loadAcquire(const T &_q_value)
{
- return *static_cast<volatile T *>(&_q_value);
+ return *static_cast<const volatile T *>(&_q_value);
}
template <typename T> static inline
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..13f0ec8ce5 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();
@@ -145,8 +145,6 @@ static bool destroying_is_ok = false;
#endif
static QTextCodec *localeMapper = 0;
-QTextCodec *QTextCodec::cftr = 0;
-
class QTextCodecCleanup
{
@@ -510,7 +508,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 +646,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());
}
}
@@ -789,38 +787,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 +869,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}
@@ -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 6257376b62..09d178639d 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
@@ -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}
*/
@@ -2462,12 +2460,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/qglobal.h b/src/corelib/global/qglobal.h
index 5fbc8cdd19..99328d52ac 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -578,16 +578,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
@@ -648,8 +638,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
@@ -682,8 +670,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
@@ -702,8 +688,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
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index c871675334..cb4e0e753f 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
@@ -152,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
@@ -214,135 +212,82 @@ QLibraryInfo::isDebugBuild()
return false;
}
+#endif // QT_BUILD_QMAKE
+
+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", "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;
- 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
- case SettingsPath:
+ 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
+ else if (loc == 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;
- }
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();
@@ -366,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 BOOTSTRAPPING
+#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();
@@ -382,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();
@@ -389,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);
}
@@ -413,9 +367,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()
*/
@@ -443,9 +397,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..d180e63198 100644
--- a/src/corelib/global/qlibraryinfo.h
+++ b/src/corelib/global/qlibraryinfo.h
@@ -66,20 +66,32 @@ public:
enum LibraryLocation
{
- PrefixPath,
+ PrefixPath = 0,
DocumentationPath,
HeadersPath,
LibrariesPath,
BinariesPath,
PluginsPath,
+ ImportsPath,
DataPath,
TranslationsPath,
- SettingsPath,
ExamplesPath,
- ImportsPath,
- TestsPath
+ 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();
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..1df36f42e6 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.
@@ -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...}").
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/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h
index fd02f0e4c5..1f16f090a9 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
@@ -70,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
@@ -81,44 +104,66 @@
|| 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__)
+# 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
diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h
index 6297b35b9c..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 <typename T> inline bool qIsDetached(T &) { return true; }
-
template <typename T>
class QTypeInfo
{
@@ -161,6 +158,10 @@ public: \
template<> \
Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS)
+/* Specialize QTypeInfo for QFlags<T> */
+template<typename T> class QFlags;
+template<typename T>
+Q_DECLARE_TYPEINFO_BODY(QFlags<T>, Q_PRIMITIVE_TYPE);
/*
Specialize a shared type with:
@@ -184,7 +185,6 @@ QT_BEGIN_NAMESPACE
#endif
#define Q_DECLARE_SHARED(TYPE) \
-template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \
template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \
{ qSwap(value1.data_ptr(), value2.data_ptr()); } \
Q_DECLARE_SHARED_STL(TYPE)
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/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index 7920d881b4..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
@@ -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/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..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<QFilePrivate *>(this)->lastWasWrite = false;
- if (!const_cast<QFile *>(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();
}
/*!
@@ -962,20 +841,6 @@ QFile::copy(const QString &fileName, const QString &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.
@@ -1034,13 +899,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 +913,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
@@ -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 <QtCore/qiodevice.h>
+#include <QtCore/qfiledevice.h>
#include <QtCore/qstring.h>
#include <stdio.h>
@@ -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 <QtCore/qiodevice.h>
+#include <QtCore/qstring.h>
+
+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<QFileDevicePrivate *>(this)->lastWasWrite = false;
+ if (!const_cast<QFileDevice *>(q_func())->flush())
+ return false;
+ }
+ return true;
+}
+
+QT_END_NAMESPACE
+
+#endif // QFILEDEVICE_P_H
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/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/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 <QtCore/qdatetime.h>
#include <QtCore/qdir.h>
#include <QtCore/qtimer.h>
+#include <QtCore/qhash.h>
#include "qfilesystemwatcher_p.h"
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/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();
}
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)
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 2021c42c4d..1ec0390235 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('[');
@@ -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/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 <qdir.h>
#include <qfile.h>
+#include <qhash.h>
#include <qtextstream.h>
#include <qcoreapplication.h>
#include <private/qfilesystemengine_p.h>
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..9b15c1fd98 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:
@@ -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();
}
/*!
@@ -6335,10 +6352,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/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
};
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/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.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/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;
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
}
diff --git a/src/corelib/json/qjsonarray.cpp b/src/corelib/json/qjsonarray.cpp
index 0eb1974147..433a68105d 100644
--- a/src/corelib/json/qjsonarray.cpp
+++ b/src/corelib/json/qjsonarray.cpp
@@ -44,6 +44,7 @@
#include <qjsonarray.h>
#include <qjsonvalue.h>
#include <qstringlist.h>
+#include <qvariant.h>
#include <qdebug.h>
#include "qjsonwriter_p.h"
@@ -559,7 +560,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 +794,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/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 <qjsonvalue.h>
#include <qjsonarray.h>
#include <qstringlist.h>
+#include <qvariant.h>
#include <qdebug.h>
#include "qjsonwriter_p.h"
#include "qjsonparser_p.h"
diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp
index b7af8c22cf..cfe71e8959 100644
--- a/src/corelib/json/qjsonobject.cpp
+++ b/src/corelib/json/qjsonobject.cpp
@@ -44,6 +44,7 @@
#include <qjsonarray.h>
#include <qstringlist.h>
#include <qdebug.h>
+#include <qvariant.h>
#include "qjson_p.h"
#include "qjsonwriter_p.h"
@@ -568,7 +569,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 +758,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/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;
diff --git a/src/corelib/json/qjsonvalue.cpp b/src/corelib/json/qjsonvalue.cpp
index ec63db79f5..2eedef67ce 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/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 <ApplicationServices/ApplicationServices.h>
#else
@@ -82,18 +71,6 @@
#include <Foundation/Foundation.h>
#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
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 2d49b271ce..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;
@@ -715,13 +710,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 +725,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
@@ -1438,11 +1433,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 +1610,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 +1621,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 +1650,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/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index 1f36f9c9c8..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
@@ -288,7 +287,7 @@ public:
MaxUser = 65535 // last user event id
};
- QEvent(Type type);
+ explicit QEvent(Type type);
virtual ~QEvent();
inline Type type() const { return static_cast<Type>(t); }
inline bool spontaneous() const { return spont; }
@@ -330,7 +329,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 +354,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_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 <private/qmutexpool_p.h>
#include <private/qthread_p.h>
#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);
}
diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h
index c404967e6a..565f1ef4b3 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"
@@ -130,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; }
};
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 e446d8b6ba..a8c21657cb 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
@@ -393,7 +393,7 @@ const QObject *QMetaObject::cast(const QObject *obj) const
*/
QString QMetaObject::tr(const char *s, const char *c, int n) const
{
- return QCoreApplication::translate(rawStringData(this, 0), s, c, QCoreApplication::CodecForTr, n);
+ return QCoreApplication::translate(rawStringData(this, 0), s, c, QCoreApplication::DefaultCodec, n);
}
/*!
@@ -1414,18 +1414,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
@@ -2034,13 +2034,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/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 6d5973a7d0..a5dc179113 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -454,7 +454,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<void>, qMetaTypeConstructHelper<void>, 0, TypeFlags());
}
/*! \internal
@@ -472,7 +472,7 @@ int QMetaType::registerType(const char *typeName, Deleter deleter,
int size, TypeFlags flags)
{
QVector<QCustomTypeInfo> *ct = customTypes();
- if (!ct || !typeName || !deleter || !creator)
+ if (!ct || !typeName || !deleter || !creator || !destructor || !constructor)
return -1;
#ifdef QT_NO_QOBJECT
@@ -1337,6 +1337,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);
}
@@ -1400,6 +1401,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);
}
@@ -1489,6 +1491,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);
}
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 0f069dc45c..fb2bce7d7b 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -256,7 +256,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;
@@ -365,33 +365,11 @@ void qMetaTypeLoadHelper(QDataStream &stream, void *t)
template <> inline void qMetaTypeLoadHelper<void>(QDataStream &, void *) {}
#endif // QT_NO_DATASTREAM
-template <typename T>
-struct QMetaTypeId
-{
- enum { Defined = 0 };
-};
-
-template <typename T>
-struct QMetaTypeId2
-{
- enum { Defined = QMetaTypeId<T>::Defined };
- static inline int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
-};
-
class QObject;
class QWidget;
-namespace QtPrivate {
- template <typename T, bool Defined = QMetaTypeId2<T>::Defined>
- struct QMetaTypeIdHelper {
- static inline int qt_metatype_id()
- { return QMetaTypeId2<T>::qt_metatype_id(); }
- };
- template <typename T> struct QMetaTypeIdHelper<T, false> {
- static inline int qt_metatype_id()
- { return -1; }
- };
-
+namespace QtPrivate
+{
template<typename T>
struct IsPointerToTypeDerivedFromQObject
{
@@ -428,6 +406,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<T*>(0))) == sizeof(yes_type) };
};
+}
+
+template <typename T, bool = QtPrivate::IsPointerToTypeDerivedFromQObject<T>::Value>
+struct QMetaTypeIdQObject
+{
+ enum {
+ Defined = 0
+ };
+};
+
+template <typename T>
+struct QMetaTypeId : public QMetaTypeIdQObject<T>
+{
+};
+
+template <typename T>
+struct QMetaTypeId2
+{
+ enum { Defined = QMetaTypeId<T>::Defined };
+ static inline int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
+};
+
+namespace QtPrivate {
+ template <typename T, bool Defined = QMetaTypeId2<T>::Defined>
+ struct QMetaTypeIdHelper {
+ static inline int qt_metatype_id()
+ { return QMetaTypeId2<T>::qt_metatype_id(); }
+ };
+ template <typename T> struct QMetaTypeIdHelper<T, false> {
+ static inline int qt_metatype_id()
+ { return -1; }
+ };
// Function pointers don't derive from QObject
template <class Result> struct IsPointerToTypeDerivedFromQObject<Result(*)()> { enum { Value = false }; };
@@ -485,6 +495,7 @@ inline int qMetaTypeId(
#endif
)
{
+ Q_STATIC_ASSERT_X(QMetaTypeId2<T>::Defined, "Type is not registered, please use Q_DECLARE_METATYPE macro to make it know to Qt's meta-object system");
return QMetaTypeId2<T>::qt_metatype_id();
}
@@ -502,6 +513,23 @@ inline int qRegisterMetaType(
#endif
}
+template <typename T>
+struct QMetaTypeIdQObject<T*, /* isPointerToTypeDerivedFromQObject */ true>
+{
+ 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<T*>(QByteArray(T::staticMetaObject.className() + QByteArrayLiteral("*")).constData(),
+ reinterpret_cast<T**>(quintptr(-1))));
+ return metatype_id.loadAcquire();
+ }
+};
+
#ifndef QT_NO_DATASTREAM
template <typename T>
inline int qRegisterMetaTypeStreamOperators()
@@ -566,6 +594,7 @@ template <class T> class QSet;
template <class T> class QSharedPointer;
template <class T1, class T2> class QMap;
template <class T1, class T2> class QHash;
+template <class T1, class T2> struct QPair;
typedef QList<QVariant> QVariantList;
typedef QMap<QString, QVariant> QVariantMap;
typedef QHash<QString, QVariant> QVariantHash;
@@ -587,6 +616,23 @@ struct QMetaTypeId< SINGLE_ARG_TEMPLATE<T> > \
} \
};
+#define Q_DECLARE_METATYPE_TEMPLATE_2ARG(DOUBLE_ARG_TEMPLATE) \
+template<typename T, typename U> \
+struct QMetaTypeId< DOUBLE_ARG_TEMPLATE<T, U> > \
+{ \
+ enum { \
+ Defined = QMetaTypeId2<T>::Defined && QMetaTypeId2<U>::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<T, U> >( QByteArray(QByteArray(#DOUBLE_ARG_TEMPLATE "<") + QMetaType::typeName(qMetaTypeId<T>()) + ", " + QMetaType::typeName(qMetaTypeId<U>()) + ">").constData(), \
+ reinterpret_cast< DOUBLE_ARG_TEMPLATE<T, U> *>(quintptr(-1)))); \
+ return metatype_id.loadAcquire(); \
+ } \
+};
+
Q_DECLARE_METATYPE_TEMPLATE_1ARG(QList)
Q_DECLARE_METATYPE_TEMPLATE_1ARG(QVector)
Q_DECLARE_METATYPE_TEMPLATE_1ARG(QQueue)
@@ -595,6 +641,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,
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 9977f96f99..edbb84a657 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<QObjectUserData *> userData;
+#endif
+ QList<QByteArray> propertyNames;
+ QList<QVariant> propertyValues;
+};
+
static int DIRECT_CONNECTION_ONLY = 0;
static int *queuedConnectionTypes(const QList<QByteArray> &typeNames)
@@ -1829,7 +1839,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.
@@ -1873,7 +1883,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}
*/
/*!
@@ -1885,11 +1895,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
@@ -2147,9 +2152,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
@@ -2598,7 +2603,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
@@ -2606,7 +2611,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
@@ -2614,7 +2619,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
@@ -2775,11 +2780,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
@@ -3460,7 +3465,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()
@@ -4219,19 +4224,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/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 <typename Func1, typename Func2>
static inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
@@ -261,6 +265,7 @@ public:
new QFunctorSlotObject<Func2, SignalType::ArgumentCount, typename SignalType::Arguments, typename SignalType::ReturnType>(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 <typename Func1, typename Func2>
static inline bool disconnect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal,
const typename QtPrivate::FunctionPointer<Func2>::Object *receiver, Func2 slot)
@@ -300,6 +308,7 @@ public:
return disconnectImpl(sender, reinterpret_cast<void **>(&signal), receiver, zero,
&SignalType::Object::staticMetaObject);
}
+#endif //Q_QDOC
void dumpObjectTree();
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index fa1aee8173..c8edadce9d 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<QObjectUserData *> userData;
-#endif
- QList<QByteArray> propertyNames;
- QList<QVariant> propertyValues;
- };
typedef void (*StaticMetaCallFunction)(QObject *, QMetaObject::Call, int, void **);
struct Connection
@@ -284,8 +275,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 &block;
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index 8751d0f5a1..4c98bad0f9 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -66,8 +66,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
@@ -209,16 +211,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
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 ae51764c0a..39e8b4360f 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -1696,7 +1696,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 == QMetaType::UnknownType) {
s.setStatus(QDataStream::ReadCorruptData);
return;
@@ -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/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.
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<QFactoryInterface*>(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
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/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);
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/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 <typename BaseClass> struct QGenericAtomicOps
static void orderedMemoryFence() { }
template <typename T> static inline always_inline
- T load(T &_q_value)
+ T load(const T &_q_value)
{
return _q_value;
}
@@ -97,9 +97,9 @@ template <typename BaseClass> struct QGenericAtomicOps
}
template <typename T> static inline always_inline
- T loadAcquire(T &_q_value)
+ T loadAcquire(const T &_q_value)
{
- T tmp = *static_cast<volatile T *>(&_q_value);
+ T tmp = *static_cast<const volatile T *>(&_q_value);
BaseClass::acquireMemoryFence();
return tmp;
}
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/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..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
@@ -658,11 +630,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/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;
};
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();
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
@@ -308,31 +308,6 @@ bool QThreadPoolPrivate::waitForDone(int msecs)
}
/*! \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
has completed.
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;
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 0d5c0f59ba..ac936b1d0a 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -344,7 +344,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;
@@ -506,7 +506,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,
@@ -996,6 +996,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
@@ -2734,7 +2736,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
@@ -3670,12 +3672,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
@@ -3799,12 +3801,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/qbytearray.h b/src/corelib/tools/qbytearray.h
index bd3a4a8444..e65a9201c2 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -205,8 +205,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;
@@ -413,12 +415,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/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp
index 31a0fdc5e6..be124c94f7 100644
--- a/src/corelib/tools/qcryptographichash.cpp
+++ b/src/corelib/tools/qcryptographichash.cpp
@@ -48,14 +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.
*/
-typedef QT_PREPEND_NAMESPACE(quint64) uint64_t;
-typedef QT_PREPEND_NAMESPACE(quint32) uint32_t;
-typedef QT_PREPEND_NAMESPACE(quint8) uint8_t;
-typedef QT_PREPEND_NAMESPACE(qint16) int_least16_t;
+#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)
+
// Header from rfc6234 with 1 modification:
// sha1.h - commented out '#include <stdint.h>' on line 74
#include "../../3rdparty/rfc6234/sha.h"
@@ -81,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 <qiodevice.h>
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);
}
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();
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 70efb5db22..fa5eed4f86 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:
@@ -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;
}
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);
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index e0cd068158..897de77f2e 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 db5404e429..6e66f804c0 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 1b6610a724..9ee4c0a797 100644
--- a/src/corelib/tools/qlist.cpp
+++ b/src/corelib/tools/qlist.cpp
@@ -338,15 +338,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.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 <QtCore/qvariant.h>
#include <QtCore/qstring.h>
#include <QtCore/qobjectdefs.h>
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/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"
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<const NEEDS_VOLATILE uchar *>(&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<NEEDS_VOLATILE uchar *>(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<const NEEDS_VOLATILE uchar *>(&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<uchar NEEDS_VOLATILE *>(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.
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/qmap.cpp b/src/corelib/tools/qmap.cpp
index 474e9cb59d..c922d7aab0 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/qpair.h b/src/corelib/tools/qpair.h
index 501f2af3e6..4dc28f2d26 100644
--- a/src/corelib/tools/qpair.h
+++ b/src/corelib/tools/qpair.h
@@ -55,16 +55,30 @@ 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) {}
-
- QPair<T1, T2> &operator=(const QPair<T1, T2> &other)
- { first = other.first; second = other.second; return *this; }
+ // compiler-generated copy/move ctor/assignment operators are fine!
T1 first;
T2 second;
};
+// mark QPair<T1,T2> as complex/movable/primitive depending on the
+// typeinfos of the constituents:
+template<class T1, class T2>
+class QTypeInfo< QPair<T1, T2> >
+{
+public:
+ enum {
+ isComplex = QTypeInfo<T1>::isComplex || QTypeInfo<T2>::isComplex,
+ isStatic = QTypeInfo<T1>::isStatic || QTypeInfo<T2>::isStatic,
+ isLarge = sizeof(QPair<T1, T2>) > sizeof(void*),
+ isPointer = false,
+ isDummy = false,
+ sizeOf = sizeof(QPair<T1, T2>)
+ };
+};
+
template <class T1, class T2>
Q_INLINE_TEMPLATE bool operator==(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
{ return p1.first == p2.first && p1.second == p2.second; }
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 d7bcd0edbc..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{\&amp;} 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{\&amp;}, the regexp to match is simply \bold{\&}. But this
+ \b{\&amp;}, 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
@@ -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
@@ -3885,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.
@@ -4052,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()
@@ -4111,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()
@@ -4140,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}.
@@ -4175,13 +4188,13 @@ bool QRegExp::isMinimal() const
For example, suppose we have the input string "We must be
<b>bold</b>, very <b>bold</b>!" and the pattern
- \bold{<b>.*</b>}. With the default greedy (maximal) matching,
+ \b{<b>.*</b>}. With the default greedy (maximal) matching,
the match is "We must be \underline{<b>bold</b>, very
<b>bold</b>}!". But with minimal (non-greedy) matching, the
first match is: "We must be \underline{<b>bold</b>}, very
<b>bold</b>!" and the second match is "We must be <b>bold</b>,
very \underline{<b>bold</b>}!". In practice we might use the pattern
- \bold{<b>[^<]*\</b>} instead, although this will still fail for
+ \b{<b>[^<]*\</b>} instead, although this will still fail for
nested tags.
\sa setCaseSensitivity()
@@ -4202,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.
@@ -4234,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(),
@@ -4273,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(),
@@ -4358,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/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
new file mode 100644
index 0000000000..0fa7d6459e
--- /dev/null
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -0,0 +1,2134 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Giuseppe D'Angelo <dangelog@gmail.com>.
+** 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 <QtCore/qcoreapplication.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qvector.h>
+#include <QtCore/qstringlist.h>
+#include <QtCore/qdebug.h>
+
+#include <pcre.h>
+
+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 \li Validation
+ \li A regexp can test whether a substring meets some criteria,
+ e.g. is an integer or contains no whitespace.
+ \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 \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{\&amp;} except where the \e{&} is already followed by
+ an \e{amp;}.
+ \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
+
+ 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
+ \li \e {Mastering Regular Expressions} (Third Edition) by Jeffrey E. F.
+ Friedl, ISBN 0-596-52812-4;
+ \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);
+ \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
+
+ \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
+ \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
+ 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
+ \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
+
+ 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.
+
+ \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
+*/
+
+/*!
+ \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 (\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
+ 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.
+*/
+
+// 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
+*/
+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();
+ pcre16_extra *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;
+
+ const QRegularExpression regularExpression;
+ const QString subject;
+ // the capturedOffsets vector contains pairs of (start, end) positions
+ // for each captured substring
+ QVector<int> capturedOffsets;
+
+ const QRegularExpression::MatchType matchType;
+ const 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;
+ const QRegularExpression regularExpression;
+ const QRegularExpression::MatchType matchType;
+ const 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
+*/
+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
+
+ 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 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,
+ 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.
+*/
+pcre16_extra *QRegularExpressionPrivate::optimizePattern()
+{
+ Q_ASSERT(compiledPattern);
+
+ QMutexLocker lock(&mutex);
+
+ if (studyData || (++usedCount != qt_qregularexpression_optimize_after_use_count))
+ return studyData;
+
+ static const bool enableJit = isJitEnabled();
+
+ int studyOptions = 0;
+ if (enableJit)
+ 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);
+
+ return studyData;
+}
+
+/*!
+ \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<QRegularExpressionPrivate *>(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 pcre16_extra *currentStudyData = const_cast<QRegularExpressionPrivate *>(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, currentStudyData,
+ subjectUtf16, subjectLength,
+ offset, pcreOptions,
+ captureOffsets, captureOffsetsCount);
+ } else {
+ result = pcre16_exec(compiledPattern, currentStudyData,
+ 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, currentStudyData,
+ 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 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
+ 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 (d == re.d) ||
+ (d->pattern == re.d->pattern && d->patternOptions == re.d->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 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
+
+ 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..3ca83c9e27
--- /dev/null
+++ b/src/corelib/tools/qregularexpression.h
@@ -0,0 +1,248 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Giuseppe D'Angelo <dangelog@gmail.com>.
+** 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 <QtCore/qstring.h>
+#include <QtCore/qshareddata.h>
+#include <QtCore/qvariant.h>
+
+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;
+
+ int captureCount() 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<QRegularExpressionPrivate> 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);
+Q_CORE_EXPORT QDebug operator<<(QDebug debug, QRegularExpression::PatternOptions patternOptions);
+#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<QRegularExpressionMatchPrivate> 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<QRegularExpressionMatchIteratorPrivate> 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/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();
}
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/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 <typename T>
class QScopedValueRollback
{
public:
- QScopedValueRollback(T &var) :
+ explicit QScopedValueRollback(T &var) :
varRef(var)
{
oldValue = varRef;
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<EmployeeData>}.
- \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 d0c2dd7148..58eb711168 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -608,12 +608,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
@@ -631,9 +631,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
@@ -657,10 +657,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:
@@ -699,12 +699,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
@@ -2115,7 +2115,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
@@ -2123,12 +2124,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);
}
/*!
@@ -2183,17 +2184,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;
}
/*!
@@ -2244,10 +2246,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
@@ -2287,10 +2290,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
@@ -2346,10 +2350,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
@@ -2389,9 +2394,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
@@ -2772,7 +2778,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
@@ -4706,7 +4712,7 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1,
} // else fall through
# endif
// declared in <string.h>
- 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;
@@ -6038,7 +6044,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/qstring.h b/src/corelib/tools/qstring.h
index ba68ab022b..26959d81f3 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -97,7 +97,9 @@ template<int N> struct QStaticStringData
#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<int N> struct QStaticStringData
{
@@ -415,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);
@@ -480,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;
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index c19d733243..0eb8aa8903 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -45,12 +45,6 @@
#include <QtCore/qstring.h>
#include <QtCore/qbytearray.h>
-#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL)
-# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ == 0)
-# include <QtCore/qmap.h>
-# endif
-#endif
-
#include <string.h>
QT_BEGIN_HEADER
@@ -173,6 +167,16 @@ template <> struct QConcatenable<QChar> : private QAbstractConcatenable
{ *out++ = c; }
};
+template <> struct QConcatenable<QChar::SpecialCharacter> : 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<QCharRef> : private QAbstractConcatenable
{
typedef QCharRef type;
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/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);
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 b70436f907..1a746dc061 100644
--- a/src/corelib/tools/qvector.cpp
+++ b/src/corelib/tools/qvector.cpp
@@ -98,21 +98,21 @@ int QVectorData::grow(int sizeOfHeader, int size, int sizeOfT)
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
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index 0342e53261..ac347404fd 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -33,6 +33,7 @@ HEADERS += \
tools/qqueue.h \
tools/qrect.h \
tools/qregexp.h \
+ tools/qregularexpression.h \
tools/qringbuffer_p.h \
tools/qrefcount.h \
tools/qscopedpointer.h \
@@ -79,6 +80,7 @@ SOURCES += \
tools/qcontiguouscache.cpp \
tools/qrect.cpp \
tools/qregexp.cpp \
+ tools/qregularexpression.cpp \
tools/qrefcount.cpp \
tools/qshareddata.cpp \
tools/qsharedpointer.cpp \
@@ -109,6 +111,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
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);