summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/arch/qatomic_armv6.h2
-rw-r--r--src/corelib/global/qnamespace.h6
-rw-r--r--src/corelib/global/qnamespace.qdoc7
-rw-r--r--src/corelib/io/qfileinfo.cpp36
-rw-r--r--src/corelib/io/qfileinfo.h2
-rw-r--r--src/corelib/kernel/qobject.cpp50
-rw-r--r--src/corelib/kernel/qobject.h16
-rw-r--r--src/corelib/thread/qthread.h8
-rw-r--r--src/corelib/tools/qmap.h4
9 files changed, 77 insertions, 54 deletions
diff --git a/src/corelib/arch/qatomic_armv6.h b/src/corelib/arch/qatomic_armv6.h
index 96b561e742..dd465db18b 100644
--- a/src/corelib/arch/qatomic_armv6.h
+++ b/src/corelib/arch/qatomic_armv6.h
@@ -152,6 +152,7 @@ inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
asm volatile("0:\n"
"ldrex %[result], [%[_q_value]]\n"
"eors %[result], %[result], %[expectedValue]\n"
+ "itt eq\n"
"strexeq %[result], %[newValue], [%[_q_value]]\n"
"teqeq %[result], #1\n"
"beq 0b\n"
@@ -210,6 +211,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValu
asm volatile("0:\n"
"ldrex %[result], [%[_q_value]]\n"
"eors %[result], %[result], %[expectedValue]\n"
+ "itt eq\n"
"strexeq %[result], %[newValue], [%[_q_value]]\n"
"teqeq %[result], #1\n"
"beq 0b\n"
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 44e59e6cf8..2fc82c55ca 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1288,7 +1288,11 @@ public:
AnchorBottom
};
-
+ enum FindChildOption {
+ FindDirectChildrenOnly = 0x0,
+ FindChildrenRecursively = 0x1
+ };
+ Q_DECLARE_FLAGS(FindChildOptions, FindChildOption)
enum DropAction {
CopyAction = 0x1,
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 9dd7cda24f..08df79af28 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -2111,6 +2111,13 @@
*/
/*!
+ \enum Qt::FindChildOption
+
+ \value FindDirectChildrenOnly Looks only at the direct children of the object.
+ \value FindChildrenRecursively Looks at all children of the object (recursive search).
+*/
+
+/*!
\enum Qt::DropAction
\value CopyAction Copy the data to the target.
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index f54818e0a6..c83c39195a 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -366,7 +366,7 @@ QFileInfo::~QFileInfo()
}
/*!
- \fn bool QFileInfo::operator!=(const QFileInfo &fileinfo)
+ \fn bool QFileInfo::operator!=(const QFileInfo &fileinfo) const
Returns true if this QFileInfo object refers to a different file
than the one specified by \a fileinfo; otherwise returns false.
@@ -380,7 +380,19 @@ QFileInfo::~QFileInfo()
*/
/*!
- \overload
+ Returns true if this QFileInfo object refers to a file in the same
+ location as \a fileinfo; otherwise returns false.
+
+ Note that the result of comparing two empty QFileInfo objects,
+ containing no file references, is undefined.
+
+ \warning This will not compare two different symbolic links
+ pointing to the same file.
+
+ \warning Long and short file names that refer to the same file on Windows
+ are treated as if they referred to different files.
+
+ \sa operator!=()
*/
bool QFileInfo::operator==(const QFileInfo &fileinfo) const
{
@@ -410,26 +422,6 @@ bool QFileInfo::operator==(const QFileInfo &fileinfo) const
}
/*!
- Returns true if this QFileInfo object refers to a file in the same
- location as \a fileinfo; otherwise returns false.
-
- Note that the result of comparing two empty QFileInfo objects,
- containing no file references, is undefined.
-
- \warning This will not compare two different symbolic links
- pointing to the same file.
-
- \warning Long and short file names that refer to the same file on Windows
- are treated as if they referred to different files.
-
- \sa operator!=()
-*/
-bool QFileInfo::operator==(const QFileInfo &fileinfo)
-{
- return const_cast<const QFileInfo *>(this)->operator==(fileinfo);
-}
-
-/*!
Makes a copy of the given \a fileinfo and assigns it to this QFileInfo.
*/
QFileInfo &QFileInfo::operator=(const QFileInfo &fileinfo)
diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h
index 6ca0ae79e0..ab3d2dc847 100644
--- a/src/corelib/io/qfileinfo.h
+++ b/src/corelib/io/qfileinfo.h
@@ -75,9 +75,7 @@ public:
inline QFileInfo&operator=(QFileInfo &&other)
{ qSwap(d_ptr, other.d_ptr); return *this; }
#endif
- bool operator==(const QFileInfo &fileinfo); // 5.0 - remove me
bool operator==(const QFileInfo &fileinfo) const;
- inline bool operator!=(const QFileInfo &fileinfo) { return !(operator==(fileinfo)); } // 5.0 - remove me
inline bool operator!=(const QFileInfo &fileinfo) const { return !(operator==(fileinfo)); }
void setFile(const QString &file);
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 7652ec4871..2d280f14f7 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -1029,8 +1029,8 @@ QObjectPrivate::Connection::~Connection()
\brief the name of this object
- You can find an object by name (and type) using findChild(). You can
- find a set of objects with findChildren().
+ You can find an object by name (and type) using findChild().
+ You can find a set of objects with findChildren().
\snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 5
@@ -1546,12 +1546,13 @@ void QObject::killTimer(int id)
/*!
- \fn T *QObject::findChild(const QString &name) const
+ \fn T *QObject::findChild(const QString &name, Qt::FindChildOptions options) const
Returns the child of this object that can be cast into type T and
that is called \a name, or 0 if there is no such object.
Omitting the \a name argument causes all object names to be matched.
- The search is performed recursively.
+ The search is performed recursively, unless \a options specifies the
+ option FindDirectChildrenOnly.
If there is more than one child matching the search, the most
direct ancestor is returned. If there are several direct
@@ -1559,7 +1560,8 @@ void QObject::killTimer(int id)
case, findChildren() should be used.
This example returns a child \l{QPushButton} of \c{parentWidget}
- named \c{"button1"}:
+ named \c{"button1"}, even if the button isn't a direct child of
+ the parent:
\snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 10
@@ -1567,16 +1569,27 @@ void QObject::killTimer(int id)
\snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 11
+ This example returns a child \l{QPushButton} of \c{parentWidget}
+ (its direct parent) named \c{"button1"}:
+
+ \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 41
+
+ This example returns a \l{QListWidget} child of \c{parentWidget},
+ its direct parent:
+
+ \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 42
+
\sa findChildren()
*/
/*!
- \fn QList<T> QObject::findChildren(const QString &name) const
+ \fn QList<T> QObject::findChildren(const QString &name, Qt::FindChildOptions options) const
Returns all children of this object with the given \a name that can be
cast to type T, or an empty list if there are no such objects.
Omitting the \a name argument causes all object names to be matched.
- The search is performed recursively.
+ The search is performed recursively, unless \a options specifies the
+ option FindDirectChildrenOnly.
The following example shows how to find a list of child \l{QWidget}s of
the specified \c{parentWidget} named \c{widgetname}:
@@ -1587,11 +1600,15 @@ void QObject::killTimer(int id)
\snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 13
+ This example returns all \c{QPushButton}s that are immediate children of \c{parentWidget}:
+
+ \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 43
+
\sa findChild()
*/
/*!
- \fn QList<T> QObject::findChildren(const QRegExp &regExp) const
+ \fn QList<T> QObject::findChildren(const QRegExp &regExp, Qt::FindChildOptions options) const
\overload findChildren()
Returns the children of this object that can be cast to type T
@@ -1651,7 +1668,7 @@ void QObject::killTimer(int id)
\internal
*/
void qt_qFindChildren_helper(const QObject *parent, const QString &name, const QRegExp *re,
- const QMetaObject &mo, QList<void*> *list)
+ const QMetaObject &mo, QList<void*> *list, Qt::FindChildOptions options)
{
if (!parent || !list)
return;
@@ -1668,13 +1685,14 @@ void qt_qFindChildren_helper(const QObject *parent, const QString &name, const Q
list->append(obj);
}
}
- qt_qFindChildren_helper(obj, name, re, mo, list);
+ if (options & Qt::FindChildrenRecursively)
+ qt_qFindChildren_helper(obj, name, re, mo, list, options);
}
}
/*! \internal
*/
-QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo)
+QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo, Qt::FindChildOptions options)
{
if (!parent)
return 0;
@@ -1686,10 +1704,12 @@ QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const
if (mo.cast(obj) && (name.isNull() || obj->objectName() == name))
return obj;
}
- for (i = 0; i < children.size(); ++i) {
- obj = qt_qFindChild_helper(children.at(i), name, mo);
- if (obj)
- return obj;
+ if (options & Qt::FindChildrenRecursively) {
+ for (i = 0; i < children.size(); ++i) {
+ obj = qt_qFindChild_helper(children.at(i), name, mo, options);
+ if (obj)
+ return obj;
+ }
}
return 0;
}
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 1c367eb8d1..591c5c88bf 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -78,8 +78,8 @@ class QObjectUserData;
typedef QList<QObject*> QObjectList;
Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QString &name, const QRegExp *re,
- const QMetaObject &mo, QList<void *> *list);
-Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo);
+ const QMetaObject &mo, QList<void *> *list, Qt::FindChildOptions options);
+Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo, Qt::FindChildOptions options);
class
#if defined(__INTEL_COMPILER) && defined(Q_OS_WIN)
@@ -157,11 +157,11 @@ public:
void killTimer(int id);
template<typename T>
- inline T findChild(const QString &aName = QString()) const
- { return static_cast<T>(qt_qFindChild_helper(this, aName, reinterpret_cast<T>(0)->staticMetaObject)); }
+ inline T findChild(const QString &aName = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
+ { return static_cast<T>(qt_qFindChild_helper(this, aName, reinterpret_cast<T>(0)->staticMetaObject, options)); }
template<typename T>
- inline QList<T> findChildren(const QString &aName = QString()) const
+ inline QList<T> findChildren(const QString &aName = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
{
QList<T> list;
union {
@@ -169,13 +169,13 @@ public:
QList<void *> *voidList;
} u;
u.typedList = &list;
- qt_qFindChildren_helper(this, aName, 0, reinterpret_cast<T>(0)->staticMetaObject, u.voidList);
+ qt_qFindChildren_helper(this, aName, 0, reinterpret_cast<T>(0)->staticMetaObject, u.voidList, options);
return list;
}
#ifndef QT_NO_REGEXP
template<typename T>
- inline QList<T> findChildren(const QRegExp &re) const
+ inline QList<T> findChildren(const QRegExp &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const
{
QList<T> list;
union {
@@ -183,7 +183,7 @@ public:
QList<void *> *voidList;
} u;
u.typedList = &list;
- qt_qFindChildren_helper(this, QString(), &re, reinterpret_cast<T>(0)->staticMetaObject, u.voidList);
+ qt_qFindChildren_helper(this, QString(), &re, reinterpret_cast<T>(0)->staticMetaObject, u.voidList, options);
return list;
}
#endif
diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h
index bc529fd53b..89a3ad8b1f 100644
--- a/src/corelib/thread/qthread.h
+++ b/src/corelib/thread/qthread.h
@@ -101,6 +101,10 @@ public:
// default argument causes thread to block indefinately
bool wait(unsigned long time = ULONG_MAX);
+ static void sleep(unsigned long);
+ static void msleep(unsigned long);
+ static void usleep(unsigned long);
+
Q_SIGNALS:
void started();
void finished();
@@ -112,10 +116,6 @@ protected:
static void setTerminationEnabled(bool enabled = true);
- static void sleep(unsigned long);
- static void msleep(unsigned long);
- static void usleep(unsigned long);
-
protected:
QThread(QThreadPrivate &dd, QObject *parent = 0);
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index 36d8eefbdb..771959a3bf 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -352,8 +352,8 @@ public:
// ### Qt 5: not sure this is necessary anymore
#ifdef QT_STRICT_ITERATORS
private:
- inline bool operator==(const iterator &o) { return operator==(const_iterator(o)); }
- inline bool operator!=(const iterator &o) { return operator!=(const_iterator(o)); }
+ inline bool operator==(const iterator &o) const { return operator==(const_iterator(o)); }
+ inline bool operator!=(const iterator &o) const { return operator!=(const_iterator(o)); }
#endif
private: