summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.h49
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.mm57
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.pro5
-rw-r--r--src/corelib/global/qlogging.cpp3
-rw-r--r--src/corelib/itemmodels/qabstractproxymodel.cpp2
-rw-r--r--src/corelib/kernel/qabstractnativeeventfilter.cpp15
-rw-r--r--src/corelib/kernel/qobject.cpp2
-rw-r--r--src/corelib/kernel/qobjectdefs.h2
-rw-r--r--src/corelib/tools/qdatetime.cpp31
-rw-r--r--src/corelib/tools/qstring.h23
10 files changed, 160 insertions, 29 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.h b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.h
new file mode 100644
index 0000000000..6666bc56c5
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Samuel Gaist <samuel.gaist@edeltech.ch>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * 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.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+#include <QAbstractNativeEventFilter>
+
+class MyCocoaEventFilter : public QAbstractNativeEventFilter
+{
+public:
+ bool nativeEventFilter(const QByteArray &eventType, void *message, long *) Q_DECL_OVERRIDE;
+};
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.mm b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.mm
new file mode 100644
index 0000000000..8abd576259
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.mm
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Samuel Gaist <samuel.gaist@edeltech.ch>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * 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.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+#include "mycocoaeventfilter.h"
+
+#import <AppKit/AppKit.h>
+
+bool CocoaNativeEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *)
+{
+ if (eventType == "mac_generic_NSEvent") {
+ NSEvent *event = static_cast<NSEvent *>(message);
+ if ([event type] == NSKeyDown) {
+ // Handle key event
+ qDebug() << QString::fromNSString([event characters]);
+ }
+ }
+ return false;
+}
+//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.pro b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.pro
new file mode 100644
index 0000000000..8f447be514
--- /dev/null
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qabstractnativeeventfilter.pro
@@ -0,0 +1,5 @@
+#! [0]
+HEADERS += mycocoaeventfilter.h
+OBJECTIVE_SOURCES += mycocoaeventfilter.mm
+LIBS += -framework AppKit
+#! [0]
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index a6da9567c6..6c7cd9c5c6 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -1199,7 +1199,8 @@ void QMessagePattern::setPattern(const QString &pattern)
#if defined(QLOGGING_HAVE_BACKTRACE) && !defined(QT_BOOTSTRAPPED)
// make sure the function has "Message" in the name so the function is removed
-#if (defined(Q_CC_GNU) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) || QT_HAS_ATTRIBUTE(optimize)
+#if ((defined(Q_CC_GNU) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) || QT_HAS_ATTRIBUTE(optimize)) \
+ && !defined(Q_CC_INTEL)
// force skipping the frame pointer, to save the backtrace() function some work
__attribute__((optimize("omit-frame-pointer")))
#endif
diff --git a/src/corelib/itemmodels/qabstractproxymodel.cpp b/src/corelib/itemmodels/qabstractproxymodel.cpp
index 886b2d0d27..39bfdd7782 100644
--- a/src/corelib/itemmodels/qabstractproxymodel.cpp
+++ b/src/corelib/itemmodels/qabstractproxymodel.cpp
@@ -83,7 +83,7 @@ QT_BEGIN_NAMESPACE
/*!
\property QAbstractProxyModel::sourceModel
- \brief the source model this proxy model.
+ \brief the source model of this proxy model.
*/
//detects the deletion of the source model
diff --git a/src/corelib/kernel/qabstractnativeeventfilter.cpp b/src/corelib/kernel/qabstractnativeeventfilter.cpp
index 351657d42c..dcbb92f044 100644
--- a/src/corelib/kernel/qabstractnativeeventfilter.cpp
+++ b/src/corelib/kernel/qabstractnativeeventfilter.cpp
@@ -96,14 +96,25 @@ QAbstractNativeEventFilter::~QAbstractNativeEventFilter()
In both cases, the \a message can be casted to a MSG pointer.
The \a result pointer is only used on Windows, and corresponds to the LRESULT pointer.
- On Mac, \a eventType is set to "mac_generic_NSEvent", and the \a message can be casted to an EventRef.
+ On macOS, \a eventType is set to "mac_generic_NSEvent", and the \a message can be casted to an NSEvent pointer.
In your reimplementation of this function, if you want to filter
the \a message out, i.e. stop it being handled further, return
true; otherwise return false.
- Example:
+ \b {Linux example}
\snippet code/src_corelib_kernel_qabstractnativeeventfilter.cpp 0
+
+ \b {macOS example}
+
+ mycocoaeventfilter.h:
+ \snippet code/src_corelib_kernel_qabstractnativeeventfilter.h 0
+
+ mycocoaeventfilter.mm:
+ \snippet code/src_corelib_kernel_qabstractnativeeventfilter.mm 0
+
+ myapp.pro:
+ \snippet code/src_corelib_kernel_qabstractnativeeventfilter.pro 0
*/
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 4ca90b8acf..d7cc0bce46 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -222,7 +222,7 @@ QObjectPrivate::QObjectPrivate(int version)
blockSig = false; // not blocking signals
wasDeleted = false; // double-delete catcher
isDeletingChildren = false; // set by deleteChildren()
- sendChildEvents = true; // if we should send ChildInsert and ChildRemove events to parent
+ sendChildEvents = true; // if we should send ChildAdded and ChildRemoved events to parent
receiveChildEvents = true;
postedEvents = 0;
extraData = 0;
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index 7ed6088d3b..5cdbef443b 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -185,7 +185,7 @@ inline void qYouForgotTheQ_OBJECT_Macro(T1, T2) {}
#if defined(Q_CC_CLANG) && Q_CC_CLANG >= 306
# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_CLANG("-Winconsistent-missing-override")
-#elif defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 510
+#elif defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 501
# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_GCC("-Wsuggest-override")
#else
# define Q_OBJECT_NO_OVERRIDE_WARNING
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 6aae4ce871..ac8054ce82 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -845,7 +845,7 @@ static QString toStringIsoDate(qint64 jd)
range 0 to 9999. This restriction may apply to locale-aware
formats as well, depending on the locale settings.
- \sa shortDayName(), shortMonthName()
+ \sa fromString(), shortDayName(), shortMonthName(), QLocale::toString()
*/
QString QDate::toString(Qt::DateFormat format) const
{
@@ -921,7 +921,7 @@ QString QDate::toString(Qt::DateFormat format) const
If the datetime is invalid, an empty string will be returned.
- \sa QDateTime::toString(), QTime::toString(), QLocale::toString()
+ \sa fromString(), QDateTime::toString(), QTime::toString(), QLocale::toString()
*/
QString QDate::toString(const QString& format) const
@@ -1201,6 +1201,8 @@ qint64 QDate::daysTo(const QDate &d) const
Note for Qt::TextDate: It is recommended that you use the
English short month names (e.g. "Jan"). Although localized month
names can also be used, they depend on the user's locale settings.
+
+ \sa toString(), QLocale::toDate()
*/
QDate QDate::fromString(const QString& string, Qt::DateFormat format)
{
@@ -1319,8 +1321,8 @@ QDate QDate::fromString(const QString& string, Qt::DateFormat format)
\snippet code/src_corelib_tools_qdatetime.cpp 3
- \sa QDateTime::fromString(), QTime::fromString(), QDate::toString(),
- QDateTime::toString(), QTime::toString()
+ \sa toString(), QDateTime::fromString(), QTime::fromString(),
+ QLocale::toDate()
*/
QDate QDate::fromString(const QString &string, const QString &format)
@@ -1588,7 +1590,7 @@ int QTime::msec() const
If the time is invalid, an empty string will be returned.
- \sa QDate::toString(), QDateTime::toString()
+ \sa fromString(), QDate::toString(), QDateTime::toString(), QLocale::toString()
*/
QString QTime::toString(Qt::DateFormat format) const
@@ -1661,7 +1663,7 @@ QString QTime::toString(Qt::DateFormat format) const
If the time is invalid, an empty string will be returned.
If \a format is empty, the default format "hh:mm:ss" is used.
- \sa QDate::toString(), QDateTime::toString(), QLocale::toString()
+ \sa fromString(), QDate::toString(), QDateTime::toString(), QLocale::toString()
*/
QString QTime::toString(const QString& format) const
{
@@ -1933,6 +1935,8 @@ static QTime fromIsoTimeString(const QStringRef &string, Qt::DateFormat format,
this may result in two conversion attempts (if the conversion
fails for the default locale). This should be considered an
implementation detail.
+
+ \sa toString(), QLocale::toTime()
*/
QTime QTime::fromString(const QString& string, Qt::DateFormat format)
{
@@ -2006,8 +2010,8 @@ QTime QTime::fromString(const QString& string, Qt::DateFormat format)
\snippet code/src_corelib_tools_qdatetime.cpp 8
- \sa QDateTime::fromString(), QDate::fromString(), QDate::toString(),
- QDateTime::toString(), QTime::toString()
+ \sa toString(), QDateTime::fromString(), QDate::fromString(),
+ QLocale::toTime()
*/
QTime QTime::fromString(const QString &string, const QString &format)
@@ -3734,7 +3738,8 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC)
range 0 to 9999. This restriction may apply to locale-aware
formats as well, depending on the locale settings.
- \sa QDate::toString(), QTime::toString(), Qt::DateFormat
+ \sa fromString(), QDate::toString(), QTime::toString(),
+ QLocale::toString()
*/
QString QDateTime::toString(Qt::DateFormat format) const
@@ -3874,7 +3879,7 @@ QString QDateTime::toString(Qt::DateFormat format) const
If the datetime is invalid, an empty string will be returned.
- \sa QDate::toString(), QTime::toString(), QLocale::toString()
+ \sa fromString(), QDate::toString(), QTime::toString(), QLocale::toString()
*/
QString QDateTime::toString(const QString& format) const
{
@@ -4617,6 +4622,8 @@ int QDateTime::utcOffset() const
Note for Qt::TextDate: It is recommended that you use the
English short month names (e.g. "Jan"). Although localized month
names can also be used, they depend on the user's locale settings.
+
+ \sa toString(), QLocale::toDateTime()
*/
QDateTime QDateTime::fromString(const QString& string, Qt::DateFormat format)
{
@@ -4918,8 +4925,8 @@ QDateTime QDateTime::fromString(const QString& string, Qt::DateFormat format)
\snippet code/src_corelib_tools_qdatetime.cpp 14
- \sa QDate::fromString(), QTime::fromString(), QDate::toString(),
- QDateTime::toString(), QTime::toString()
+ \sa toString(), QDate::fromString(), QTime::fromString(),
+ QLocale::toDateTime()
*/
QDateTime QDateTime::fromString(const QString &string, const QString &format)
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 53a28d9278..b50b2ee4e5 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -976,6 +976,7 @@ inline QString QString::section(QChar asep, int astart, int aend, SectionFlags a
QT_WARNING_PUSH
QT_WARNING_DISABLE_MSVC(4127) // "conditional expression is constant"
+QT_WARNING_DISABLE_INTEL(111) // "statement is unreachable"
inline int QString::toWCharArray(wchar_t *array) const
{
@@ -1157,21 +1158,21 @@ inline bool operator!=(QString::Null, const QString &s) { return !s.isNull(); }
inline bool operator!=(const QString &s, QString::Null) { return !s.isNull(); }
inline bool operator==(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW
-{ return (s1.size() == s2.size() && !memcmp(s1.latin1(), s2.latin1(), s1.size())); }
+{ return s1.size() == s2.size() && (!s1.size() || !memcmp(s1.latin1(), s2.latin1(), s1.size())); }
inline bool operator!=(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW
-{ return (s1.size() != s2.size() || memcmp(s1.latin1(), s2.latin1(), s1.size())); }
+{ return !operator==(s1, s2); }
inline bool operator<(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW
-{ int r = memcmp(s1.latin1(), s2.latin1(), qMin(s1.size(), s2.size()));
- return (r < 0) || (r == 0 && s1.size() < s2.size()); }
-inline bool operator<=(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW
-{ int r = memcmp(s1.latin1(), s2.latin1(), qMin(s1.size(), s2.size()));
- return (r < 0) || (r == 0 && s1.size() <= s2.size()); }
+{
+ const int len = qMin(s1.size(), s2.size());
+ const int r = len ? memcmp(s1.latin1(), s2.latin1(), len) : 0;
+ return r < 0 || (r == 0 && s1.size() < s2.size());
+}
inline bool operator>(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW
-{ int r = memcmp(s1.latin1(), s2.latin1(), qMin(s1.size(), s2.size()));
- return (r > 0) || (r == 0 && s1.size() > s2.size()); }
+{ return operator<(s2, s1); }
+inline bool operator<=(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW
+{ return !operator>(s1, s2); }
inline bool operator>=(QLatin1String s1, QLatin1String s2) Q_DECL_NOTHROW
-{ int r = memcmp(s1.latin1(), s2.latin1(), qMin(s1.size(), s2.size()));
- return (r > 0) || (r == 0 && s1.size() >= s2.size()); }
+{ return !operator<(s1, s2); }
inline bool QLatin1String::operator==(const QString &s) const Q_DECL_NOTHROW
{ return s == *this; }