summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/codecs/qtextcodec.cpp58
-rw-r--r--src/corelib/codecs/qtextcodec.h14
-rw-r--r--src/corelib/global/qglobal.cpp53
-rw-r--r--src/corelib/global/qglobal.h122
-rw-r--r--src/corelib/global/qnamespace.h258
-rw-r--r--src/corelib/global/qnamespace.qdoc46
-rw-r--r--src/corelib/io/qdatastream.cpp41
-rw-r--r--src/corelib/io/qdatastream.h15
-rw-r--r--src/corelib/io/qdir.cpp155
-rw-r--r--src/corelib/io/qdir.h45
-rw-r--r--src/corelib/io/qdir_p.h5
-rw-r--r--src/corelib/io/qfile.cpp16
-rw-r--r--src/corelib/io/qfile.h11
-rw-r--r--src/corelib/io/qfileinfo.cpp13
-rw-r--r--src/corelib/io/qfileinfo.h41
-rw-r--r--src/corelib/io/qiodevice.cpp25
-rw-r--r--src/corelib/io/qiodevice.h71
-rw-r--r--src/corelib/io/qnoncontiguousbytedevice.cpp8
-rw-r--r--src/corelib/io/qprocess_win.cpp18
-rw-r--r--src/corelib/io/qsettings.cpp272
-rw-r--r--src/corelib/io/qsettings.h110
-rw-r--r--src/corelib/io/qtextstream.cpp298
-rw-r--r--src/corelib/io/qtextstream.h88
-rw-r--r--src/corelib/io/qurl.cpp33
-rw-r--r--src/corelib/io/qurl.h50
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp149
-rw-r--r--src/corelib/kernel/qcoreapplication.h20
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h3
-rw-r--r--src/corelib/kernel/qcoreevent.cpp59
-rw-r--r--src/corelib/kernel/qcoreevent.h33
-rw-r--r--src/corelib/kernel/qeventloop.h4
-rw-r--r--src/corelib/kernel/qmetaobject.cpp6
-rw-r--r--src/corelib/kernel/qmetatype.cpp6
-rw-r--r--src/corelib/kernel/qmetatype.h7
-rw-r--r--src/corelib/kernel/qobject.cpp210
-rw-r--r--src/corelib/kernel/qobject.h67
-rw-r--r--src/corelib/kernel/qobject_p.h12
-rw-r--r--src/corelib/kernel/qobjectdefs.h21
-rw-r--r--src/corelib/kernel/qsignalmapper.cpp12
-rw-r--r--src/corelib/kernel/qsignalmapper.h5
-rw-r--r--src/corelib/kernel/qsocketnotifier.cpp34
-rw-r--r--src/corelib/kernel/qsocketnotifier.h3
-rw-r--r--src/corelib/kernel/qtimer.cpp30
-rw-r--r--src/corelib/kernel/qtimer.h8
-rw-r--r--src/corelib/kernel/qtranslator.cpp12
-rw-r--r--src/corelib/kernel/qtranslator.h8
-rw-r--r--src/corelib/kernel/qvariant.cpp15
-rw-r--r--src/corelib/kernel/qvariant.h80
-rw-r--r--src/corelib/plugin/qlibrary.h4
-rw-r--r--src/corelib/thread/qmutex.h18
-rw-r--r--src/corelib/thread/qthread.h6
-rw-r--r--src/corelib/thread/qthread_p.h21
-rw-r--r--src/corelib/tools/qbytearray.h47
-rw-r--r--src/corelib/tools/qcache.h9
-rw-r--r--src/corelib/tools/qchar.h27
-rw-r--r--src/corelib/tools/qdatetime.h48
-rw-r--r--src/corelib/tools/qlinkedlist.h15
-rw-r--r--src/corelib/tools/qlist.h14
-rw-r--r--src/corelib/tools/qmap.h36
-rw-r--r--src/corelib/tools/qrect.h30
-rw-r--r--src/corelib/tools/qregexp.h33
-rw-r--r--src/corelib/tools/qscopedpointer.h4
-rw-r--r--src/corelib/tools/qstring.cpp94
-rw-r--r--src/corelib/tools/qstring.h131
-rw-r--r--src/corelib/tools/qstringbuilder.cpp2
-rw-r--r--src/corelib/tools/qstringbuilder.h2
-rw-r--r--src/corelib/tools/qstringlist.cpp36
-rw-r--r--src/corelib/tools/qstringlist.h51
-rw-r--r--src/dbus/dbus.pro2
-rw-r--r--src/gui/kernel/qevent.cpp144
-rw-r--r--src/gui/kernel/qevent.h77
-rw-r--r--src/gui/kernel/qevent_p.h25
-rw-r--r--src/gui/painting/qbrush.cpp14
-rw-r--r--src/gui/painting/qcosmeticstroker.cpp25
-rw-r--r--src/gui/painting/qmatrix.cpp2
-rw-r--r--src/gui/painting/qoutlinemapper.cpp9
-rw-r--r--src/gui/painting/qoutlinemapper_p.h8
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp248
-rw-r--r--src/gui/painting/qpaintengine_raster_p.h5
-rw-r--r--src/gui/painting/qpainter.cpp47
-rw-r--r--src/gui/painting/qpainterpath.cpp8
-rw-r--r--src/gui/painting/qpen.cpp6
-rw-r--r--src/gui/painting/qrasterizer.cpp4
-rw-r--r--src/gui/painting/qtransform.cpp4
-rw-r--r--src/gui/text/qfont.cpp5
-rw-r--r--src/gui/text/qfont_p.h2
-rw-r--r--src/gui/text/qfontdatabase.cpp42
-rw-r--r--src/gui/text/qfontenginedirectwrite.cpp146
-rw-r--r--src/gui/text/qfontenginedirectwrite_p.h6
-rw-r--r--src/gui/text/qglyphrun.cpp3
-rw-r--r--src/gui/text/qharfbuzz_copy_p.h7
-rw-r--r--src/gui/text/qplatformfontdatabase_qpa.cpp37
-rw-r--r--src/gui/text/qrawfont.cpp27
-rw-r--r--src/gui/text/qrawfont.h3
-rw-r--r--src/gui/text/qstatictext.cpp10
-rw-r--r--src/gui/text/qtextlayout.cpp210
-rw-r--r--src/network/access/qftp.cpp30
-rw-r--r--src/network/access/qftp.h9
-rw-r--r--src/network/access/qhttp.h4
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp178
-rw-r--r--src/network/access/qhttpnetworkconnection_p.h16
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp31
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel_p.h2
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp6
-rw-r--r--src/network/access/qnetworkrequest.cpp25
-rw-r--r--src/network/kernel/qhostaddress.cpp18
-rw-r--r--src/network/kernel/qhostaddress.h9
-rw-r--r--src/network/kernel/qhostinfo_unix.cpp6
-rw-r--r--src/network/kernel/qnetworkinterface_unix.cpp3
-rw-r--r--src/network/kernel/qnetworkproxy.cpp7
-rw-r--r--src/network/socket/qabstractsocket.cpp111
-rw-r--r--src/network/socket/qabstractsocket.h37
-rw-r--r--src/network/socket/qabstractsocket_p.h2
-rw-r--r--src/network/socket/qnativesocketengine.cpp23
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp43
-rw-r--r--src/network/socket/qnativesocketengine_win.cpp38
-rw-r--r--src/network/socket/qudpsocket.cpp9
-rw-r--r--src/network/ssl/qsslcertificate.cpp24
-rw-r--r--src/network/ssl/qsslcertificate.h13
-rw-r--r--src/network/ssl/qsslsocket.cpp11
-rw-r--r--src/network/ssl/qsslsocket.h4
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp33
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols.cpp4
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols_p.h4
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp37
-rw-r--r--src/opengl/qgl.h6
-rw-r--r--src/opengl/qpaintengine_opengl.cpp5
-rw-r--r--src/plugins/generic/touchscreen/70-qtouchscreen.rules1
-rw-r--r--src/plugins/generic/touchscreen/README45
-rw-r--r--src/plugins/generic/touchscreen/main.cpp80
-rw-r--r--src/plugins/generic/touchscreen/qtoucheventsenderqpa.cpp113
-rw-r--r--src/plugins/generic/touchscreen/qtoucheventsenderqpa.h68
-rw-r--r--src/plugins/generic/touchscreen/qtouchscreen.cpp324
-rw-r--r--src/plugins/generic/touchscreen/qtouchscreen.h106
-rw-r--r--src/plugins/generic/touchscreen/touchscreen.pro18
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.cpp2
-rw-r--r--src/plugins/platforms/wayland/qwaylandinputdevice.cpp169
-rw-r--r--src/plugins/platforms/wayland/qwaylandinputdevice.h31
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.cpp4
-rw-r--r--src/plugins/platforms/wayland/wayland_sha1.txt2
-rw-r--r--src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h68
-rw-r--r--src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp33
-rw-r--r--src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h5
-rw-r--r--src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c16
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.cpp11
-rw-r--r--src/widgets/kernel/qapplication.cpp12
-rw-r--r--src/widgets/platforms/mac/qfontdatabase_mac.cpp2
-rw-r--r--src/widgets/platforms/mac/qpaintengine_mac.cpp5
-rw-r--r--src/widgets/platforms/win/qprintengine_win.cpp3
-rw-r--r--src/widgets/platforms/x11/qfontdatabase_x11.cpp6
-rw-r--r--src/widgets/platforms/x11/qpaintengine_x11.cpp5
-rw-r--r--src/widgets/widgets/qmaccocoaviewcontainer_mac.mm2
152 files changed, 2220 insertions, 4083 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 985f5153ea..0f919fb401 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -1427,48 +1427,6 @@ bool QTextCodec::canEncode(const QString& s) const
return (state.invalidChars == 0);
}
-#ifdef QT3_SUPPORT
-/*!
- Returns a string representing the current language and
- sublanguage, e.g. "pt" for Portuguese, or "pt_br" for Portuguese/Brazil.
-
- \sa QLocale
-*/
-const char *QTextCodec::locale()
-{
- static char locale[6];
- QByteArray l = QLocale::system().name().toLatin1();
- int len = qMin(l.length(), 5);
- memcpy(locale, l.constData(), len);
- locale[len] = '\0';
-
- return locale;
-}
-
-/*!
- \overload
-*/
-
-QByteArray QTextCodec::fromUnicode(const QString& uc, int& lenInOut) const
-{
- QByteArray result = convertFromUnicode(uc.constData(), lenInOut, 0);
- lenInOut = result.length();
- return result;
-}
-
-/*!
- \overload
-
- \a a contains the source characters; \a len contains the number of
- characters in \a a to use.
-*/
-QString QTextCodec::toUnicode(const QByteArray& a, int len) const
-{
- len = qMin(a.size(), len);
- return convertToUnicode(a.constData(), len, 0);
-}
-#endif
-
/*!
\overload
@@ -1552,22 +1510,6 @@ QByteArray QTextEncoder::fromUnicode(const QChar *uc, int len)
return result;
}
-#ifdef QT3_SUPPORT
-/*!
- \overload
-
- Converts \a lenInOut characters (not bytes) from \a uc, and returns the
- result in a QByteArray. The number of characters read is returned in
- the \a lenInOut parameter.
-*/
-QByteArray QTextEncoder::fromUnicode(const QString& uc, int& lenInOut)
-{
- QByteArray result = c->fromUnicode(uc.constData(), lenInOut, &state);
- lenInOut = result.length();
- return result;
-}
-#endif
-
/*!
\class QTextDecoder
\brief The QTextDecoder class provides a state-based decoder.
diff --git a/src/corelib/codecs/qtextcodec.h b/src/corelib/codecs/qtextcodec.h
index 270e96aaf7..015c0941f2 100644
--- a/src/corelib/codecs/qtextcodec.h
+++ b/src/corelib/codecs/qtextcodec.h
@@ -134,17 +134,6 @@ protected:
QTextCodec();
virtual ~QTextCodec();
-public:
-#ifdef QT3_SUPPORT
- static QT3_SUPPORT QTextCodec* codecForContent(const char*, int) { return 0; }
- static QT3_SUPPORT const char* locale();
- static QT3_SUPPORT QTextCodec* codecForName(const char* hint, int) { return codecForName(QByteArray(hint)); }
- QT3_SUPPORT QByteArray fromUnicode(const QString& uc, int& lenInOut) const;
- QT3_SUPPORT QString toUnicode(const QByteArray&, int len) const;
- QT3_SUPPORT QByteArray mimeName() const { return name(); }
- static QT3_SUPPORT QTextCodec *codecForIndex(int i) { return codecForName(availableCodecs().value(i)); }
-#endif
-
private:
friend class QTextCodecCleanup;
static QTextCodec *cftr;
@@ -165,9 +154,6 @@ public:
~QTextEncoder();
QByteArray fromUnicode(const QString& str);
QByteArray fromUnicode(const QChar *uc, int len);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT QByteArray fromUnicode(const QString& uc, int& lenInOut);
-#endif
bool hasFailure() const;
private:
const QTextCodec *c;
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index e5626b4632..ca8b30fc00 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -2471,11 +2471,6 @@ void qCritical(const char *msg, ...)
va_end(ap);
}
-#ifdef QT3_SUPPORT
-void qSystemWarning(const char *msg, int code)
- { qCritical("%s (%s)", msg, qt_error_string(code).toLocal8Bit().constData()); }
-#endif // QT3_SUPPORT
-
void qErrnoWarning(const char *msg, ...)
{
// qt_error_string() will allocate anyway, so we don't have
@@ -3031,54 +3026,6 @@ int qrand()
with meaningful parameter names in their signatures.
*/
-#if defined(QT3_SUPPORT) && !defined(QT_NO_SETTINGS)
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <qlibraryinfo.h>
-QT_END_INCLUDE_NAMESPACE
-
-static const char *qInstallLocation(QLibraryInfo::LibraryLocation loc)
-{
- static QByteArray ret;
- ret = QLibraryInfo::location(loc).toLatin1();
- return ret.constData();
-}
-const char *qInstallPath()
-{
- return qInstallLocation(QLibraryInfo::PrefixPath);
-}
-const char *qInstallPathDocs()
-{
- return qInstallLocation(QLibraryInfo::DocumentationPath);
-}
-const char *qInstallPathHeaders()
-{
- return qInstallLocation(QLibraryInfo::HeadersPath);
-}
-const char *qInstallPathLibs()
-{
- return qInstallLocation(QLibraryInfo::LibrariesPath);
-}
-const char *qInstallPathBins()
-{
- return qInstallLocation(QLibraryInfo::BinariesPath);
-}
-const char *qInstallPathPlugins()
-{
- return qInstallLocation(QLibraryInfo::PluginsPath);
-}
-const char *qInstallPathData()
-{
- return qInstallLocation(QLibraryInfo::DataPath);
-}
-const char *qInstallPathTranslations()
-{
- return qInstallLocation(QLibraryInfo::TranslationsPath);
-}
-const char *qInstallPathSysconf()
-{
- return qInstallLocation(QLibraryInfo::SettingsPath);
-}
-#endif
struct QInternal_CallBackTable {
QVector<QList<qInternalCallback> > callbacks;
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 4fa6a9954b..af9d86c2ca 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1031,18 +1031,10 @@ redefine to built-in booleans to make autotests work properly */
#endif
#if defined(QT_NO_DEPRECATED)
-/* disable Qt3 support as well */
-# undef QT3_SUPPORT_WARNINGS
-# undef QT3_SUPPORT
# undef QT_DEPRECATED
# undef QT_DEPRECATED_VARIABLE
# undef QT_DEPRECATED_CONSTRUCTOR
#elif defined(QT_DEPRECATED_WARNINGS)
-# ifdef QT3_SUPPORT
-/* enable Qt3 support warnings as well */
-# undef QT3_SUPPORT_WARNINGS
-# define QT3_SUPPORT_WARNINGS
-# endif
# undef QT_DEPRECATED
# define QT_DEPRECATED Q_DECL_DEPRECATED
# undef QT_DEPRECATED_VARIABLE
@@ -1058,28 +1050,6 @@ redefine to built-in booleans to make autotests work properly */
# define QT_DEPRECATED_CONSTRUCTOR
#endif
-#if defined(QT3_SUPPORT_WARNINGS)
-# if !defined(QT_COMPAT_WARNINGS) /* also enable compat */
-# define QT_COMPAT_WARNINGS
-# endif
-# undef QT3_SUPPORT
-# define QT3_SUPPORT Q_DECL_DEPRECATED
-# undef QT3_SUPPORT_VARIABLE
-# define QT3_SUPPORT_VARIABLE Q_DECL_VARIABLE_DEPRECATED
-# undef QT3_SUPPORT_CONSTRUCTOR
-# define QT3_SUPPORT_CONSTRUCTOR explicit Q_DECL_CONSTRUCTOR_DEPRECATED
-#elif defined(QT3_SUPPORT) /* define back to nothing */
-# if !defined(QT_COMPAT) /* also enable qt3 support */
-# define QT_COMPAT
-# endif
-# undef QT3_SUPPORT
-# define QT3_SUPPORT
-# undef QT3_SUPPORT_VARIABLE
-# define QT3_SUPPORT_VARIABLE
-# undef QT3_SUPPORT_CONSTRUCTOR
-# define QT3_SUPPORT_CONSTRUCTOR explicit
-#endif
-
/* moc compats (signals/slots) */
#ifndef QT_MOC_COMPAT
# if defined(QT3_SUPPORT)
@@ -1173,31 +1143,6 @@ template <typename T>
inline const T &qBound(const T &min, const T &val, const T &max)
{ return qMax(min, qMin(max, val)); }
-#ifdef QT3_SUPPORT
-typedef qint8 Q_INT8;
-typedef quint8 Q_UINT8;
-typedef qint16 Q_INT16;
-typedef quint16 Q_UINT16;
-typedef qint32 Q_INT32;
-typedef quint32 Q_UINT32;
-typedef qint64 Q_INT64;
-typedef quint64 Q_UINT64;
-
-typedef qint64 Q_LLONG;
-typedef quint64 Q_ULLONG;
-#if defined(Q_OS_WIN64)
-typedef __int64 Q_LONG; /* word up to 64 bit signed */
-typedef unsigned __int64 Q_ULONG; /* word up to 64 bit unsigned */
-#else
-typedef long Q_LONG; /* word up to 64 bit signed */
-typedef unsigned long Q_ULONG; /* word up to 64 bit unsigned */
-#endif
-
-# define QABS(a) qAbs(a)
-# define QMAX(a, b) qMax((a), (b))
-# define QMIN(a, b) qMin((a), (b))
-#endif
-
/*
Data stream functions are provided by many classes (defined in qdatastream.h)
*/
@@ -1659,27 +1604,6 @@ Q_CORE_EXPORT bool qSharedBuild();
inline int qMacVersion() { return QSysInfo::MacintoshVersion; }
#endif
-#ifdef QT3_SUPPORT
-inline QT3_SUPPORT bool qSysInfo(int *wordSize, bool *bigEndian)
-{
- *wordSize = QSysInfo::WordSize;
- *bigEndian = (QSysInfo::ByteOrder == QSysInfo::BigEndian);
- return true;
-}
-#endif
-
-#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
-#if defined(QT3_SUPPORT)
-inline QT3_SUPPORT bool qt_winUnicode() { return true; }
-inline QT3_SUPPORT int qWinVersion() { return QSysInfo::WindowsVersion; }
-#endif
-
-// ### Qt 5: remove Win9x support macros QT_WA and QT_WA_INLINE.
-#define QT_WA(unicode, ansi) unicode
-#define QT_WA_INLINE(unicode, ansi) (unicode)
-
-#endif /* Q_OS_WIN */
-
#ifndef Q_OUTOFLINE_TEMPLATE
# define Q_OUTOFLINE_TEMPLATE
#endif
@@ -1749,9 +1673,6 @@ Q_CORE_EXPORT void qFatal(const char *, ...) /* print fatal message and exit */
#endif
;
-#ifdef QT3_SUPPORT
-Q_CORE_EXPORT QT3_SUPPORT void qSystemWarning(const char *msg, int code = -1);
-#endif /* QT3_SUPPORT */
Q_CORE_EXPORT void qErrnoWarning(int code, const char *msg, ...);
Q_CORE_EXPORT void qErrnoWarning(const char *msg, ...);
@@ -1853,11 +1774,6 @@ Q_CORE_EXPORT void qt_message_output(QtMsgType, const char *buf);
typedef void (*QtMsgHandler)(QtMsgType, const char *);
Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler);
-#ifdef QT3_SUPPORT
-inline QT3_SUPPORT void qSuppressObsoleteWarnings(bool = true) {}
-inline QT3_SUPPORT void qObsolete(const char *, const char * = 0, const char * = 0) {}
-#endif
-
#if !defined(Q_UNIMPLEMENTED)
# define Q_UNIMPLEMENTED() qWarning("%s:%d: %s: Unimplemented code.", __FILE__, __LINE__, Q_FUNC_INFO)
#endif
@@ -2491,9 +2407,15 @@ Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
classes contains a private copy constructor and assignment
operator to disable copying (the compiler gives an error message).
*/
+#ifdef Q_COMPILER_DEFAULT_DELETE_MEMBERS
+#define Q_DISABLE_COPY(Class) \
+ Class(const Class &) = delete;\
+ Class &operator=(const Class &) = delete;
+#else
#define Q_DISABLE_COPY(Class) \
Class(const Class &); \
Class &operator=(const Class &);
+#endif
class QByteArray;
Q_CORE_EXPORT QByteArray qgetenv(const char *varName);
@@ -2508,27 +2430,6 @@ inline int qIntCast(float f) { return int(f); }
Q_CORE_EXPORT void qsrand(uint seed);
Q_CORE_EXPORT int qrand();
-/*
- Compat functions that were generated by configure
-*/
-#ifdef QT3_SUPPORT
-#ifndef QT_PRODUCT_LICENSEE
-# define QT_PRODUCT_LICENSEE QLibraryInfo::licensee()
-#endif
-#ifndef QT_PRODUCT_LICENSE
-# define QT_PRODUCT_LICENSE QLibraryInfo::licensedProducts()
-#endif
-QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPath();
-QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathDocs();
-QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathHeaders();
-QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathLibs();
-QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathBins();
-QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathPlugins();
-QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathData();
-QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathTranslations();
-QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf();
-#endif
-
#if defined(Q_OS_SYMBIAN)
#ifdef SYMBIAN_BUILD_GCE
@@ -2612,8 +2513,6 @@ Q_CORE_EXPORT int qt_symbian_exception2Error(const std::exception& ex);
#define QT_MODULE_OPENGL 0x000008
#define QT_MODULE_SQL 0x000010
#define QT_MODULE_XML 0x000020
-#define QT_MODULE_QT3SUPPORTLIGHT 0x000040
-#define QT_MODULE_QT3SUPPORT 0x000080
#define QT_MODULE_SVG 0x000100
#define QT_MODULE_ACTIVEQT 0x000200
#define QT_MODULE_GRAPHICSVIEW 0x000400
@@ -2641,7 +2540,6 @@ Q_CORE_EXPORT int qt_symbian_exception2Error(const std::exception& ex);
| QT_MODULE_DBUS)
#define QT_EDITION_DESKTOPLIGHT (QT_MODULE_CORE \
| QT_MODULE_GUI \
- | QT_MODULE_QT3SUPPORTLIGHT \
| QT_MODULE_TEST \
| QT_MODULE_DBUS)
#define QT_EDITION_OPENSOURCE (QT_MODULE_CORE \
@@ -2655,8 +2553,6 @@ Q_CORE_EXPORT int qt_symbian_exception2Error(const std::exception& ex);
| QT_MODULE_XMLPATTERNS \
| QT_MODULE_SCRIPT \
| QT_MODULE_SCRIPTTOOLS \
- | QT_MODULE_QT3SUPPORTLIGHT \
- | QT_MODULE_QT3SUPPORT \
| QT_MODULE_SVG \
| QT_MODULE_DECLARATIVE \
| QT_MODULE_GRAPHICSVIEW \
@@ -2723,12 +2619,6 @@ QT_LICENSED_MODULE(Script)
#if (QT_EDITION & QT_MODULE_SCRIPTTOOLS)
QT_LICENSED_MODULE(ScriptTools)
#endif
-#if (QT_EDITION & QT_MODULE_QT3SUPPORTLIGHT)
-QT_LICENSED_MODULE(Qt3SupportLight)
-#endif
-#if (QT_EDITION & QT_MODULE_QT3SUPPORT)
-QT_LICENSED_MODULE(Qt3Support)
-#endif
#if (QT_EDITION & QT_MODULE_SVG)
QT_LICENSED_MODULE(Svg)
#endif
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 38d4a85b89..44e59e6cf8 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -66,7 +66,6 @@ Qt {
Q_ENUMS(ScrollBarPolicy FocusPolicy ContextMenuPolicy)
Q_ENUMS(ArrowType ToolButtonStyle PenStyle PenCapStyle PenJoinStyle BrushStyle)
Q_ENUMS(FillRule MaskMode BGMode ClipOperation SizeMode)
- Q_ENUMS(BackgroundMode) // Qt3
Q_ENUMS(Axis Corner LayoutDirection SizeHint Orientation DropAction)
Q_FLAGS(Alignment Orientations DropActions)
Q_FLAGS(DockWidgetAreas ToolBarAreas)
@@ -159,18 +158,6 @@ public:
};
Q_DECLARE_FLAGS(MouseButtons, MouseButton)
-#ifdef QT3_SUPPORT
- enum ButtonState_enum {
- ShiftButton = Qt::ShiftModifier,
- ControlButton = Qt::ControlModifier,
- AltButton = Qt::AltModifier,
- MetaButton = Qt::MetaModifier,
- Keypad = Qt::KeypadModifier,
- KeyButtonMask = Qt::KeyboardModifierMask
- };
- typedef int ButtonState;
-#endif
-
enum Orientation {
Horizontal = 0x1,
Vertical = 0x2
@@ -189,10 +176,6 @@ public:
enum SortOrder {
AscendingOrder,
DescendingOrder
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- ,Ascending = AscendingOrder,
- Descending = DescendingOrder
-#endif
};
enum TileRule {
@@ -221,9 +204,6 @@ public:
AlignVertical_Mask = AlignTop | AlignBottom | AlignVCenter,
AlignCenter = AlignVCenter | AlignHCenter
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- , AlignAuto = AlignLeft
-#endif
};
Q_DECLARE_FLAGS(Alignment, AlignmentFlag)
@@ -243,22 +223,7 @@ public:
TextForceRightToLeft = 0x40000,
TextLongestVariant = 0x80000,
TextBypassShaping = 0x100000
-
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- ,SingleLine = TextSingleLine,
- DontClip = TextDontClip,
- ExpandTabs = TextExpandTabs,
- ShowPrefix = TextShowMnemonic,
- WordBreak = TextWordWrap,
- BreakAnywhere = TextWrapAnywhere,
- DontPrint = TextDontPrint,
- IncludeTrailingSpaces = TextIncludeTrailingSpaces,
- NoAccel = TextHideMnemonic
-#endif
};
-#ifdef QT3_SUPPORT
- typedef TextFlag TextFlags;
-#endif
enum TextElideMode {
ElideLeft,
@@ -533,36 +498,11 @@ public:
OpaqueMode
};
-#ifdef QT3_SUPPORT
- enum PaintUnit { // paint unit
- PixelUnit,
- LoMetricUnit, // obsolete
- HiMetricUnit, // obsolete
- LoEnglishUnit, // obsolete
- HiEnglishUnit, // obsolete
- TwipsUnit // obsolete
- };
-
- enum GUIStyle {
- MacStyle,
- WindowsStyle,
- Win3Style,
- PMStyle,
- MotifStyle
- };
-#endif
-
enum Key {
Key_Escape = 0x01000000, // misc keys
Key_Tab = 0x01000001,
Key_Backtab = 0x01000002,
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- Key_BackTab = Key_Backtab,
-#endif
Key_Backspace = 0x01000003,
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- Key_BackSpace = Key_Backspace,
-#endif
Key_Return = 0x01000004,
Key_Enter = 0x01000005,
Key_Insert = 0x01000006,
@@ -578,13 +518,7 @@ public:
Key_Right = 0x01000014,
Key_Down = 0x01000015,
Key_PageUp = 0x01000016,
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- Key_Prior = Key_PageUp,
-#endif
Key_PageDown = 0x01000017,
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- Key_Next = Key_PageDown,
-#endif
Key_Shift = 0x01000020, // modifiers
Key_Control = 0x01000021,
Key_Meta = 0x01000022,
@@ -770,41 +704,7 @@ public:
Key_Yacute = 0x0dd,
Key_THORN = 0x0de,
Key_ssharp = 0x0df,
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- Key_agrave = Key_Agrave,
- Key_aacute = Key_Aacute,
- Key_acircumflex = Key_Acircumflex,
- Key_atilde = Key_Atilde,
- Key_adiaeresis = Key_Adiaeresis,
- Key_aring = Key_Aring,
- Key_ae = Key_AE,
- Key_ccedilla = Key_Ccedilla,
- Key_egrave = Key_Egrave,
- Key_eacute = Key_Eacute,
- Key_ecircumflex = Key_Ecircumflex,
- Key_ediaeresis = Key_Ediaeresis,
- Key_igrave = Key_Igrave,
- Key_iacute = Key_Iacute,
- Key_icircumflex = Key_Icircumflex,
- Key_idiaeresis = Key_Idiaeresis,
- Key_eth = Key_ETH,
- Key_ntilde = Key_Ntilde,
- Key_ograve = Key_Ograve,
- Key_oacute = Key_Oacute,
- Key_ocircumflex = Key_Ocircumflex,
- Key_otilde = Key_Otilde,
- Key_odiaeresis = Key_Odiaeresis,
-#endif
Key_division = 0x0f7,
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- Key_oslash = Key_Ooblique,
- Key_ugrave = Key_Ugrave,
- Key_uacute = Key_Uacute,
- Key_ucircumflex = Key_Ucircumflex,
- Key_udiaeresis = Key_Udiaeresis,
- Key_yacute = Key_Yacute,
- Key_thorn = Key_THORN,
-#endif
Key_ydiaeresis = 0x0ff,
// International input method support (X keycode - 0xEE00, the
@@ -904,9 +804,6 @@ public:
Key_MediaPlay = 0x01000080,
Key_MediaStop = 0x01000081,
Key_MediaPrevious = 0x01000082,
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- Key_MediaPrev = Key_MediaPrevious,
-#endif
Key_MediaNext = 0x01000083,
Key_MediaRecord = 0x01000084,
Key_MediaPause = 0x1000085,
@@ -1122,9 +1019,6 @@ public:
RadialGradientPattern,
ConicalGradientPattern,
TexturePattern = 24
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- , CustomPattern = TexturePattern
-#endif
};
enum SizeMode {
@@ -1132,66 +1026,6 @@ public:
RelativeSize
};
-#if defined(QT3_SUPPORT)
-#if defined(Q_OS_MAC)
-#ifndef qdoc
- typedef int MacintoshVersion;
-
- enum
-#else
- enum MacintoshVersion
-#endif
- {
- //Unknown
- MV_Unknown = 0x0000,
-
- //Version numbers
- MV_9 = QSysInfo::MV_9,
- MV_10_DOT_0 = QSysInfo::MV_10_0,
- MV_10_DOT_1 = QSysInfo::MV_10_1,
- MV_10_DOT_2 = QSysInfo::MV_10_2,
- MV_10_DOT_3 = QSysInfo::MV_10_3,
- MV_10_DOT_4 = QSysInfo::MV_10_4,
-
- //Code names
- MV_CHEETAH = QSysInfo::MV_CHEETAH,
- MV_PUMA = QSysInfo::MV_PUMA,
- MV_JAGUAR = QSysInfo::MV_JAGUAR,
- MV_PANTHER = QSysInfo::MV_PANTHER,
- MV_TIGER = QSysInfo::MV_TIGER
- };
-#endif // Q_OS_MAC
-
-#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
-#ifndef qdoc
- typedef int WindowsVersion;
-
- enum
-#else
- enum WindowsVersion
-#endif
- {
- WV_32s = QSysInfo::WV_32s,
- WV_95 = QSysInfo::WV_95,
- WV_98 = QSysInfo::WV_98,
- WV_Me = QSysInfo::WV_Me,
- WV_DOS_based= QSysInfo::WV_DOS_based,
-
- WV_NT = QSysInfo::WV_NT,
- WV_2000 = QSysInfo::WV_2000,
- WV_XP = QSysInfo::WV_XP,
- WV_2003 = QSysInfo::WV_2003,
- WV_NT_based = QSysInfo::WV_NT_based,
-
- WV_CE = QSysInfo::WV_CE,
- WV_CENET = QSysInfo::WV_CENET,
- WV_CE_5 = QSysInfo::WV_CE_5,
- WV_CE_6 = QSysInfo::WV_CE_6,
- WV_CE_based = QSysInfo::WV_CE_based
- };
-#endif // Q_OS_WIN
-#endif // QT3_SUPPORT
-
enum UIEffect {
UI_General,
UI_AnimateMenu,
@@ -1228,26 +1062,6 @@ public:
LastCursor = DragLinkCursor,
BitmapCursor = 24,
CustomCursor = 25
-
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- ,
- arrowCursor = ArrowCursor,
- upArrowCursor = UpArrowCursor,
- crossCursor = CrossCursor,
- waitCursor = WaitCursor,
- ibeamCursor = IBeamCursor,
- sizeVerCursor = SizeVerCursor,
- sizeHorCursor = SizeHorCursor,
- sizeBDiagCursor = SizeBDiagCursor,
- sizeFDiagCursor = SizeFDiagCursor,
- sizeAllCursor = SizeAllCursor,
- blankCursor = BlankCursor,
- splitVCursor = SplitVCursor,
- splitHCursor = SplitHCursor,
- pointingHandCursor = PointingHandCursor,
- forbiddenCursor = ForbiddenCursor,
- whatsThisCursor = WhatsThisCursor
-#endif
};
enum TextFormat {
@@ -1261,15 +1075,7 @@ public:
IgnoreAspectRatio,
KeepAspectRatio,
KeepAspectRatioByExpanding
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- , ScaleFree = IgnoreAspectRatio,
- ScaleMin = KeepAspectRatio,
- ScaleMax = KeepAspectRatioByExpanding
-#endif
};
-#ifdef QT3_SUPPORT
- typedef AspectRatioMode ScaleMode;
-#endif
// This is for Q3TextEdit only, actually.
enum AnchorAttribute {
@@ -1310,28 +1116,6 @@ public:
Q_DECLARE_FLAGS(ToolBarAreas, ToolBarArea)
-#ifdef QT3_SUPPORT
- enum Dock {
- DockUnmanaged,
- DockTornOff,
- DockTop,
- DockBottom,
- DockRight,
- DockLeft,
- DockMinimized
- ,
- Unmanaged = DockUnmanaged,
- TornOff = DockTornOff,
- Top = DockTop,
- Bottom = DockBottom,
- Right = DockRight,
- Left = DockLeft,
- Minimized = DockMinimized
- };
- // compatibility
- typedef Dock ToolBarDock;
-#endif
-
enum DateFormat {
TextDate, // default Qt
ISODate, // ISO 8601
@@ -1366,31 +1150,6 @@ public:
ScrollBarAlwaysOn
};
-#ifdef QT3_SUPPORT
- enum BackgroundMode {
- FixedColor,
- FixedPixmap,
- NoBackground,
- PaletteForeground,
- PaletteButton,
- PaletteLight,
- PaletteMidlight,
- PaletteDark,
- PaletteMid,
- PaletteText,
- PaletteBrightText,
- PaletteBase,
- PaletteBackground,
- PaletteShadow,
- PaletteHighlight,
- PaletteHighlightedText,
- PaletteButtonText,
- PaletteLink,
- PaletteLinkVisited,
- X11ParentRelative
- };
-#endif
-
enum CaseSensitivity {
CaseInsensitive,
CaseSensitive
@@ -1401,12 +1160,6 @@ public:
TopRightCorner = 0x00001,
BottomLeftCorner = 0x00002,
BottomRightCorner = 0x00003
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- ,TopLeft = TopLeftCorner,
- TopRight = TopRightCorner,
- BottomLeft = BottomLeftCorner,
- BottomRight = BottomRightCorner
-#endif
};
enum ConnectionType {
@@ -1438,8 +1191,7 @@ public:
enum ClipOperation {
NoClip,
ReplaceClip,
- IntersectClip,
- UniteClip
+ IntersectClip
};
// Shape = 0x1, BoundingRect = 0x2
@@ -1818,14 +1570,6 @@ public:
static bool callFunction(InternalFunction func, void **);
};
-#ifdef QT3_SUPPORT
-typedef qint32 QCOORD; // coordinate type
-enum {
- QCOORD_MAX = 2147483647,
- QCOORD_MIN = -QCOORD_MAX - 1
-};
-#endif
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 09611e67f4..2d102e7ba1 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -2201,52 +2201,6 @@
TargetMoveAction is not used on the Mac.
*/
-#if defined(Q_OS_WIN) && defined(QT3_SUPPORT)
-/*!
- \enum Qt::WindowsVersion
- \compat
-
- \value WV_32s
- \value WV_95
- \value WV_98
- \value WV_Me
- \value WV_DOS_based
- \value WV_NT
- \value WV_2000
- \value WV_XP
- \value WV_2003
- \value WV_NT_based
- \value WV_CE
- \value WV_CENET
- \value WV_CE_based
- \value WV_CE_5
- \value WV_CE_6
-*/
-#endif
-
-#if defined(Q_OS_MAC) && defined(QT3_SUPPORT)
-/*!
- \enum Qt::MacintoshVersion
- \compat
-
- \value MV_Unknown Use QSysInfo::MV_Unknown instead.
- \value MV_9 Use QSysInfo::MV_9 instead.
- \value MV_10_DOT_0 Use QSysInfo::MV_10_0 instead.
- \value MV_10_DOT_1 Use QSysInfo::MV_10_1 instead.
- \value MV_10_DOT_2 Use QSysInfo::MV_10_2 instead.
- \value MV_10_DOT_3 Use QSysInfo::MV_10_3 instead.
- \value MV_10_DOT_4 Use QSysInfo::MV_10_4 instead.
-
- \value MV_CHEETAH Use QSysInfo::MV_10_0 instead.
- \value MV_PUMA Use QSysInfo::MV_10_1 instead.
- \value MV_JAGUAR Use QSysInfo::MV_10_2 instead.
- \value MV_PANTHER Use QSysInfo::MV_10_3 instead.
- \value MV_TIGER Use QSysInfo::MV_10_4 instead.
-
- \sa QSysInfo::MacVersion
-*/
-#endif
-
/*! \typedef Qt::ToolBarDock
\compat
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index b397c1a29c..af4ec3bc60 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -294,31 +294,6 @@ QDataStream::QDataStream(QIODevice *d)
q_status = Ok;
}
-#ifdef QT3_SUPPORT
-/*!
- \fn QDataStream::QDataStream(QByteArray *array, int mode)
- \compat
-
- Constructs a data stream that operates on the given \a array. The
- \a mode specifies how the byte array is to be used, and is
- usually either QIODevice::ReadOnly or QIODevice::WriteOnly.
-*/
-QDataStream::QDataStream(QByteArray *a, int mode)
-{
- QBuffer *buf = new QBuffer(a);
-#ifndef QT_NO_QOBJECT
- buf->blockSignals(true);
-#endif
- buf->open(QIODevice::OpenMode(mode));
- dev = buf;
- owndev = true;
- byteorder = BigEndian;
- ver = DefaultStreamVersion;
- noswap = QSysInfo::ByteOrder == QSysInfo::BigEndian;
- q_status = Ok;
-}
-#endif
-
/*!
\fn QDataStream::QDataStream(QByteArray *a, QIODevice::OpenMode mode)
@@ -587,6 +562,8 @@ void QDataStream::setByteOrder(ByteOrder bo)
\value Qt_4_6 Version 12 (Qt 4.6, Qt 4.7, Qt 4.8)
\value Qt_4_7 Same as Qt_4_6.
\value Qt_4_8 Same as Qt_4_6.
+ \value Qt_4_9 Same as Qt_4_6.
+ \value Qt_5_0 Same as Qt_4_6.
\sa setVersion(), version()
*/
@@ -1307,20 +1284,6 @@ int QDataStream::skipRawData(int len)
}
}
-#ifdef QT3_SUPPORT
-/*!
- \fn QDataStream &QDataStream::readRawBytes(char *str, uint len)
-
- Use readRawData() instead.
-*/
-
-/*!
- \fn QDataStream &QDataStream::writeRawBytes(const char *str, uint len)
-
- Use writeRawData() instead.
-*/
-#endif
-
QT_END_NAMESPACE
#endif // QT_NO_DATASTREAM
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index 57d68e2f39..1ae0573f6c 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -113,9 +113,6 @@ public:
QDataStream();
explicit QDataStream(QIODevice *);
-#ifdef QT3_SUPPORT
- QDataStream(QByteArray *, int mode);
-#endif
QDataStream(QByteArray *, QIODevice::OpenMode flags);
QDataStream(const QByteArray &);
virtual ~QDataStream();
@@ -125,9 +122,6 @@ public:
void unsetDevice();
bool atEnd() const;
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT bool eof() const { return atEnd(); }
-#endif
Status status() const;
void setStatus(Status status);
@@ -177,15 +171,6 @@ public:
int skipRawData(int len);
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT QDataStream &readRawBytes(char *str, uint len)
- { readRawData(str, static_cast<int>(len)); return *this; }
- inline QT3_SUPPORT QDataStream &writeRawBytes(const char *str, uint len)
- { writeRawData(str, static_cast<int>(len)); return *this; }
- inline QT3_SUPPORT bool isPrintableData() const { return false; }
- inline QT3_SUPPORT void setPrintableData(bool) {}
-#endif
-
private:
Q_DISABLE_COPY(QDataStream)
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 9426618875..3621deea28 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -91,10 +91,6 @@ QDirPrivate::QDirPrivate(const QString &path, const QStringList &nameFilters_, Q
, nameFilters(nameFilters_)
, sort(sort_)
, filters(filters_)
-#ifdef QT3_SUPPORT
- , filterSepChar(0)
- , matchAllDirs(false)
-#endif
, fileListsInitialized(false)
{
setPath(path.isEmpty() ? QString::fromLatin1(".") : path);
@@ -118,10 +114,6 @@ QDirPrivate::QDirPrivate(const QDirPrivate &copy)
, nameFilters(copy.nameFilters)
, sort(copy.sort)
, filters(copy.filters)
-#ifdef QT3_SUPPORT
- , filterSepChar(copy.filterSepChar)
- , matchAllDirs(copy.matchAllDirs)
-#endif
, fileListsInitialized(false)
, dirEntry(copy.dirEntry)
, metaData(copy.metaData)
@@ -1288,10 +1280,6 @@ QStringList QDir::entryList(const QStringList &nameFilters, Filters filters,
if (filters == NoFilter)
filters = d->filters;
-#ifdef QT3_SUPPORT
- if (d->matchAllDirs)
- filters |= AllDirs;
-#endif
if (sort == NoSort)
sort = d->sort;
@@ -1334,10 +1322,6 @@ QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filter
if (filters == NoFilter)
filters = d->filters;
-#ifdef QT3_SUPPORT
- if (d->matchAllDirs)
- filters |= AllDirs;
-#endif
if (sort == NoSort)
sort = d->sort;
@@ -2177,145 +2161,6 @@ QStringList QDir::nameFiltersFromString(const QString &nameFilter)
\sa Q_INIT_RESOURCE(), {The Qt Resource System}
*/
-#ifdef QT3_SUPPORT
-
-/*!
- \fn bool QDir::matchAllDirs() const
-
- Use filter() & AllDirs instead.
-*/
-bool QDir::matchAllDirs() const
-{
- const QDirPrivate* d = d_ptr.constData();
- return d->matchAllDirs;
-}
-
-
-/*!
- \fn void QDir::setMatchAllDirs(bool on)
-
- Use setFilter() instead.
-*/
-void QDir::setMatchAllDirs(bool on)
-{
- QDirPrivate* d = d_ptr.data();
- d->initFileEngine();
- d->clearFileLists();
-
- d->matchAllDirs = on;
-}
-
-/*!
- Use nameFilters() instead.
-*/
-QString QDir::nameFilter() const
-{
- const QDirPrivate* d = d_ptr.constData();
- return nameFilters().join(QString(d->filterSepChar));
-}
-
-/*!
- Use setNameFilters() instead.
-
- The \a nameFilter is a wildcard (globbing) filter that understands
- "*" and "?" wildcards. (See \l{QRegExp wildcard matching}.) You may
- specify several filter entries, each separated by spaces or by
- semicolons.
-
- For example, if you want entryList() and entryInfoList() to list
- all files ending with either ".cpp" or ".h", you would use either
- dir.setNameFilters("*.cpp *.h") or dir.setNameFilters("*.cpp;*.h").
-
- \oldcode
- QString filter = "*.cpp *.cxx *.cc";
- dir.setNameFilter(filter);
- \newcode
- QString filter = "*.cpp *.cxx *.cc";
- dir.setNameFilters(filter.split(' '));
- \endcode
-*/
-void QDir::setNameFilter(const QString &nameFilter)
-{
- QDirPrivate* d = d_ptr.data();
- d->initFileEngine();
- d->clearFileLists();
-
- d->filterSepChar = QDirPrivate::getFilterSepChar(nameFilter);
- d->nameFilters = QDirPrivate::splitFilters(nameFilter, d->filterSepChar);
-}
-
-/*!
- \fn QString QDir::absPath() const
-
- Use absolutePath() instead.
-*/
-
-/*!
- \fn QString QDir::absFilePath(const QString &fileName, bool acceptAbsPath) const
-
- Use absoluteFilePath(\a fileName) instead.
-
- The \a acceptAbsPath parameter is ignored.
-*/
-
-/*!
- \fn bool QDir::mkdir(const QString &dirName, bool acceptAbsPath) const
-
- Use mkdir(\a dirName) instead.
-
- The \a acceptAbsPath parameter is ignored.
-*/
-
-/*!
- \fn bool QDir::rmdir(const QString &dirName, bool acceptAbsPath) const
-
- Use rmdir(\a dirName) instead.
-
- The \a acceptAbsPath parameter is ignored.
-*/
-
-/*!
- \fn QStringList QDir::entryList(const QString &nameFilter, Filters filters,
- SortFlags sort) const
- \overload
-
- Use the overload that takes a name filter string list as first
- argument instead of a combination of attribute filter flags.
-*/
-
-/*!
- \fn QFileInfoList QDir::entryInfoList(const QString &nameFilter, Filters filters,
- SortFlags sort) const
- \overload
-
- Use the overload that takes a name filter string list as first
- argument instead of a combination of attribute filter flags.
-*/
-
-/*!
- \fn void QDir::convertToAbs()
-
- Use makeAbsolute() instead.
-*/
-
-/*!
- \fn QString QDir::cleanDirPath(const QString &name)
-
- Use cleanPath() instead.
-*/
-
-/*!
- \typedef QDir::FilterSpec
-
- Use QDir::Filters instead.
-*/
-
-/*!
- \typedef QDir::SortSpec
-
- Use QDir::SortFlags instead.
-*/
-#endif // QT3_SUPPORT
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug debug, QDir::Filters filters)
diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h
index e2f43f06b6..de5fb1bf00 100644
--- a/src/corelib/io/qdir.h
+++ b/src/corelib/io/qdir.h
@@ -67,17 +67,11 @@ public:
NoSymLinks = 0x008,
AllEntries = Dirs | Files | Drives,
TypeMask = 0x00f,
-#ifdef QT3_SUPPORT
- All = AllEntries,
-#endif
Readable = 0x010,
Writable = 0x020,
Executable = 0x040,
PermissionMask = 0x070,
-#ifdef QT3_SUPPORT
- RWEMask = 0x070,
-#endif
Modified = 0x080,
Hidden = 0x100,
@@ -92,14 +86,8 @@ public:
NoDotDot = 0x4000,
NoFilter = -1
-#ifdef QT3_SUPPORT
- ,DefaultFilter = NoFilter
-#endif
};
Q_DECLARE_FLAGS(Filters, Filter)
-#ifdef QT3_SUPPORT
- typedef Filters FilterSpec;
-#endif
enum SortFlag { Name = 0x00,
Time = 0x01,
@@ -114,9 +102,6 @@ public:
LocaleAware = 0x40,
Type = 0x80,
NoSort = -1
-#ifdef QT3_SUPPORT
- ,DefaultSort = NoSort
-#endif
};
Q_DECLARE_FLAGS(SortFlags, SortFlag)
@@ -223,36 +208,6 @@ public:
static QString cleanPath(const QString &path);
void refresh() const;
-
-#ifdef QT3_SUPPORT
- typedef SortFlags SortSpec;
- inline QT3_SUPPORT QString absPath() const { return absolutePath(); }
- inline QT3_SUPPORT QString absFilePath(const QString &fileName, bool acceptAbsPath = true) const
- { Q_UNUSED(acceptAbsPath); return absoluteFilePath(fileName); }
- QT3_SUPPORT bool matchAllDirs() const;
- QT3_SUPPORT void setMatchAllDirs(bool on);
- inline QT3_SUPPORT QStringList entryList(const QString &nameFilter, Filters filters = NoFilter,
- SortFlags sort = NoSort) const
- { return entryList(nameFiltersFromString(nameFilter), filters, sort); }
- inline QT3_SUPPORT QFileInfoList entryInfoList(const QString &nameFilter,
- Filters filters = NoFilter,
- SortFlags sort = NoSort) const
- { return entryInfoList(nameFiltersFromString(nameFilter), filters, sort); }
-
- QT3_SUPPORT QString nameFilter() const;
- QT3_SUPPORT void setNameFilter(const QString &nameFilter);
-
- inline QT3_SUPPORT bool mkdir(const QString &dirName, bool acceptAbsPath) const
- { Q_UNUSED(acceptAbsPath); return mkdir(dirName); }
- inline QT3_SUPPORT bool rmdir(const QString &dirName, bool acceptAbsPath) const
- { Q_UNUSED(acceptAbsPath); return rmdir(dirName); }
-
- inline QT3_SUPPORT void convertToAbs() { makeAbsolute(); }
- inline QT3_SUPPORT static QString currentDirPath() { return currentPath(); }
- inline QT3_SUPPORT static QString homeDirPath() { return homePath(); }
- inline QT3_SUPPORT static QString rootDirPath() { return rootPath(); }
- inline QT3_SUPPORT static QString cleanDirPath(const QString &name) { return cleanPath(name); }
-#endif // QT3_SUPPORT
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QDir::Filters)
diff --git a/src/corelib/io/qdir_p.h b/src/corelib/io/qdir_p.h
index 3e00529070..7644a0391e 100644
--- a/src/corelib/io/qdir_p.h
+++ b/src/corelib/io/qdir_p.h
@@ -77,11 +77,6 @@ public:
QDir::SortFlags sort;
QDir::Filters filters;
-#ifdef QT3_SUPPORT
- QChar filterSepChar;
- bool matchAllDirs;
-#endif
-
QScopedPointer<QAbstractFileEngine> fileEngine;
mutable bool fileListsInitialized;
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index 66edf58214..47f57f7fdb 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -364,20 +364,14 @@ QFilePrivate::setError(QFile::FileError err, int errNum)
QIODevice.
\value AutoCloseHandle The file handle passed into open() should be
- closed by close(), the default behaviour is that close just flushes
- the file and the app is responsible for closing the file handle. When
- opening a file by name, this flag is ignored as Qt always "owns" the
+ 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 QT3_SUPPORT
-/*!
- \typedef QFile::PermissionSpec
-
- Use QFile::Permission instead.
-*/
-#endif
-
#ifdef QT_NO_QOBJECT
QFile::QFile()
: QIODevice(*new QFilePrivate)
diff --git a/src/corelib/io/qfile.h b/src/corelib/io/qfile.h
index e4a74859db..554b2954e1 100644
--- a/src/corelib/io/qfile.h
+++ b/src/corelib/io/qfile.h
@@ -87,9 +87,6 @@ public:
ResizeError = 12,
PermissionsError = 13,
CopyError = 14
-#ifdef QT3_SUPPORT
- , ConnectError = 30
-#endif
};
enum Permission {
@@ -186,14 +183,6 @@ public:
virtual QAbstractFileEngine *fileEngine() const;
-#ifdef QT3_SUPPORT
- typedef Permission PermissionSpec;
- inline QT3_SUPPORT QString name() const { return fileName(); }
- inline QT3_SUPPORT void setName(const QString &aName) { setFileName(aName); }
- inline QT3_SUPPORT bool open(OpenMode aFlags, FILE *f) { return open(f, aFlags); }
- inline QT3_SUPPORT bool open(OpenMode aFlags, int fd) { return open(fd, aFlags); }
-#endif
-
protected:
#ifdef QT_NO_QOBJECT
QFile(QFilePrivate &dd);
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index ca42c87454..ee40c589a2 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -851,19 +851,6 @@ QDir QFileInfo::absoluteDir() const
return QDir(absolutePath());
}
-#ifdef QT3_SUPPORT
-/*!
- Use absoluteDir() or the dir() overload that takes no parameters
- instead.
-*/
-QDir QFileInfo::dir(bool absPath) const
-{
- if (absPath)
- return absoluteDir();
- return dir();
-}
-#endif //QT3_SUPPORT
-
/*!
Returns true if the user can read the file; otherwise returns false.
diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h
index 5b1b48b7d5..6ca0ae79e0 100644
--- a/src/corelib/io/qfileinfo.h
+++ b/src/corelib/io/qfileinfo.h
@@ -139,40 +139,6 @@ public:
bool caching() const;
void setCaching(bool on);
-#ifdef QT3_SUPPORT
- enum Permission {
- ReadOwner = QFile::ReadOwner, WriteOwner = QFile::WriteOwner, ExeOwner = QFile::ExeOwner,
- ReadUser = QFile::ReadUser, WriteUser = QFile::WriteUser, ExeUser = QFile::ExeUser,
- ReadGroup = QFile::ReadGroup, WriteGroup = QFile::WriteGroup, ExeGroup = QFile::ExeGroup,
- ReadOther = QFile::ReadOther, WriteOther = QFile::WriteOther, ExeOther = QFile::ExeOther
- };
- Q_DECLARE_FLAGS(PermissionSpec, Permission)
-
- inline QT3_SUPPORT QString baseName(bool complete) {
- if(complete)
- return completeBaseName();
- return baseName();
- }
- inline QT3_SUPPORT QString extension(bool complete = true) const {
- if(complete)
- return completeSuffix();
- return suffix();
- }
- inline QT3_SUPPORT QString absFilePath() const { return absoluteFilePath(); }
-
- inline QT3_SUPPORT QString dirPath(bool absPath = false) const {
- if(absPath)
- return absolutePath();
- return path();
- }
- QT3_SUPPORT QDir dir(bool absPath) const;
- inline QT3_SUPPORT bool convertToAbs() { return makeAbsolute(); }
-#if !defined(Q_NO_TYPESAFE_FLAGS)
- inline QT3_SUPPORT bool permission(PermissionSpec permissions) const
- { return permission(QFile::Permissions(static_cast<int>(permissions))); }
-#endif
-#endif
-
protected:
QSharedDataPointer<QFileInfoPrivate> d_ptr;
private:
@@ -190,14 +156,7 @@ private:
Q_DECLARE_TYPEINFO(QFileInfo, Q_MOVABLE_TYPE);
-#ifdef QT3_SUPPORT
-Q_DECLARE_OPERATORS_FOR_FLAGS(QFileInfo::PermissionSpec)
-#endif
-
typedef QList<QFileInfo> QFileInfoList;
-#ifdef QT3_SUPPORT
-typedef QList<QFileInfo>::Iterator QFileInfoListIterator;
-#endif
QT_END_NAMESPACE
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index ea00cb4a1f..4371d9cbef 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -1790,31 +1790,6 @@ QString QIODevice::errorString() const
Use write(\a data) instead.
*/
-#if defined QT3_SUPPORT
-QIODevice::Status QIODevice::status() const
-{
-#if !defined(QT_NO_QOBJECT)
- const QFile *f = qobject_cast<const QFile *>(this);
- if (f) return (int) f->error();
-#endif
- return isOpen() ? 0 /* IO_Ok */ : 8 /* IO_UnspecifiedError */;
-}
-
-/*!
- For device specific error handling, please refer to the
- individual device documentation.
-
- \sa qobject_cast()
-*/
-void QIODevice::resetStatus()
-{
-#if !defined(QT_NO_QOBJECT)
- QFile *f = qobject_cast<QFile *>(this);
- if (f) f->unsetError();
-#endif
-}
-#endif
-
#if !defined(QT_NO_DEBUG_STREAM)
QDebug operator<<(QDebug debug, QIODevice::OpenMode modes)
{
diff --git a/src/corelib/io/qiodevice.h b/src/corelib/io/qiodevice.h
index 328e329401..7d4afca850 100644
--- a/src/corelib/io/qiodevice.h
+++ b/src/corelib/io/qiodevice.h
@@ -167,81 +167,10 @@ protected:
private:
Q_DECLARE_PRIVATE(QIODevice)
Q_DISABLE_COPY(QIODevice)
-
-#ifdef QT3_SUPPORT
-public:
- typedef qint64 Offset;
-
- inline QT3_SUPPORT int flags() const { return static_cast<int>(openMode()); }
- inline QT3_SUPPORT int mode() const { return static_cast<int>(openMode()); }
- inline QT3_SUPPORT int state() const;
-
- inline QT3_SUPPORT bool isDirectAccess() const { return !isSequential(); }
- inline QT3_SUPPORT bool isSequentialAccess() const { return isSequential(); }
- inline QT3_SUPPORT bool isCombinedAccess() const { return false; }
- inline QT3_SUPPORT bool isBuffered() const { return true; }
- inline QT3_SUPPORT bool isRaw() const { return false; }
- inline QT3_SUPPORT bool isSynchronous() const { return true; }
- inline QT3_SUPPORT bool isAsynchronous() const { return false; }
- inline QT3_SUPPORT bool isTranslated() const { return (openMode() & Text) != 0; }
- inline QT3_SUPPORT bool isInactive() const { return !isOpen(); }
-
- typedef int Status;
- QT3_SUPPORT Status status() const;
- QT3_SUPPORT void resetStatus();
-
- inline QT3_SUPPORT Offset at() const { return pos(); }
- inline QT3_SUPPORT bool at(Offset offset) { return seek(offset); }
-
- inline QT3_SUPPORT qint64 readBlock(char *data, quint64 maxlen) { return read(data, maxlen); }
- inline QT3_SUPPORT qint64 writeBlock(const char *data, quint64 len) { return write(data, len); }
- inline QT3_SUPPORT qint64 writeBlock(const QByteArray &data) { return write(data); }
-
- inline QT3_SUPPORT int getch() { char c; return getChar(&c) ? int(uchar(c)) : -1; }
- inline QT3_SUPPORT int putch(int c) { return putChar(char(c)) ? int(uchar(c)) : -1; }
- inline QT3_SUPPORT int ungetch(int c) { ungetChar(uchar(c)); return c; }
-#endif
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QIODevice::OpenMode)
-#ifdef QT3_SUPPORT
-static QT3_SUPPORT_VARIABLE const uint IO_Direct = 0x0100;
-static QT3_SUPPORT_VARIABLE const uint IO_Sequential = 0x0200;
-static QT3_SUPPORT_VARIABLE const uint IO_Combined = 0x0300;
-static QT3_SUPPORT_VARIABLE const uint IO_TypeMask = 0x0300;
-
-static QT3_SUPPORT_VARIABLE const uint IO_Raw = 0x0000;
-static QT3_SUPPORT_VARIABLE const uint IO_Async = 0x0000;
-
-#define IO_ReadOnly QIODevice::ReadOnly
-#define IO_WriteOnly QIODevice::WriteOnly
-#define IO_ReadWrite QIODevice::ReadWrite
-#define IO_Append QIODevice::Append
-#define IO_Truncate QIODevice::Truncate
-#define IO_Translate QIODevice::Text
-#define IO_ModeMask 0x00ff
-
-static QT3_SUPPORT_VARIABLE const uint IO_Open = 0x1000;
-static QT3_SUPPORT_VARIABLE const uint IO_StateMask = 0xf000;
-
-static QT3_SUPPORT_VARIABLE const uint IO_Ok = 0;
-static QT3_SUPPORT_VARIABLE const uint IO_ReadError = 1;
-static QT3_SUPPORT_VARIABLE const uint IO_WriteError = 2;
-static QT3_SUPPORT_VARIABLE const uint IO_FatalError = 3;
-static QT3_SUPPORT_VARIABLE const uint IO_ResourceError = 4;
-static QT3_SUPPORT_VARIABLE const uint IO_OpenError = 5;
-static QT3_SUPPORT_VARIABLE const uint IO_ConnectError = 5;
-static QT3_SUPPORT_VARIABLE const uint IO_AbortError = 6;
-static QT3_SUPPORT_VARIABLE const uint IO_TimeOutError = 7;
-static QT3_SUPPORT_VARIABLE const uint IO_UnspecifiedError = 8;
-
-inline QT3_SUPPORT int QIODevice::state() const
-{
- return isOpen() ? 0x1000 : 0;
-}
-#endif
-
#if !defined(QT_NO_DEBUG_STREAM)
class QDebug;
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QIODevice::OpenMode modes);
diff --git a/src/corelib/io/qnoncontiguousbytedevice.cpp b/src/corelib/io/qnoncontiguousbytedevice.cpp
index 5568920061..113ba4b4bb 100644
--- a/src/corelib/io/qnoncontiguousbytedevice.cpp
+++ b/src/corelib/io/qnoncontiguousbytedevice.cpp
@@ -479,7 +479,7 @@ qint64 QByteDeviceWrappingIoDevice::writeData( const char* data, qint64 maxSize)
*/
/*!
- \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QIODevice *device);
+ \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QIODevice *device)
Create a QNonContiguousByteDevice out of a QIODevice.
For QFile, QBuffer and all other QIoDevice, sequential or not.
@@ -501,7 +501,7 @@ QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QIODevice *dev
}
/*!
- \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QRingBuffer *ringBuffer);
+ \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QSharedPointer<QRingBuffer> ringBuffer)
Create a QNonContiguousByteDevice out of a QRingBuffer.
@@ -513,7 +513,7 @@ QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QSharedPointer
}
/*!
- \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QByteArray *byteArray);
+ \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QByteArray *byteArray)
Create a QNonContiguousByteDevice out of a QByteArray.
@@ -525,7 +525,7 @@ QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QByteArray *by
}
/*!
- \fn static QIODevice* QNonContiguousByteDeviceFactory::wrap(QNonContiguousByteDevice* byteDevice);
+ \fn static QIODevice* QNonContiguousByteDeviceFactory::wrap(QNonContiguousByteDevice* byteDevice)
Wrap the \a byteDevice (possibly again) into a QIODevice.
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 1761c0edee..510f72312e 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -46,6 +46,7 @@
#include <qdatetime.h>
#include <qdir.h>
#include <qfileinfo.h>
+#include <qregexp.h>
#include <qtimer.h>
#include <qthread.h>
#include <qmutex.h>
@@ -256,24 +257,19 @@ static QString qt_create_commandline(const QString &program, const QStringList &
for (int i=0; i<arguments.size(); ++i) {
QString tmp = arguments.at(i);
- // in the case of \" already being in the string the \ must also be escaped
- tmp.replace( QLatin1String("\\\""), QLatin1String("\\\\\"") );
- // escape a single " because the arguments will be parsed
- tmp.replace( QLatin1Char('\"'), QLatin1String("\\\"") );
+ // Quotes are escaped and their preceding backslashes are doubled.
+ tmp.replace(QRegExp(QLatin1String("(\\\\*)\"")), QLatin1String("\\1\\1\\\""));
if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) {
// The argument must not end with a \ since this would be interpreted
// as escaping the quote -- rather put the \ behind the quote: e.g.
// rather use "foo"\ than "foo\"
- QString endQuote(QLatin1Char('\"'));
int i = tmp.length();
- while (i>0 && tmp.at(i-1) == QLatin1Char('\\')) {
+ while (i > 0 && tmp.at(i - 1) == QLatin1Char('\\'))
--i;
- endQuote += QLatin1Char('\\');
- }
- args += QLatin1String(" \"") + tmp.left(i) + endQuote;
- } else {
- args += QLatin1Char(' ') + tmp;
+ tmp.insert(i, QLatin1Char('"'));
+ tmp.prepend(QLatin1Char('"'));
}
+ args += QLatin1Char(' ') + tmp;
}
return args;
}
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 79b2728f58..7e40e5f73b 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -3547,278 +3547,6 @@ QSettings::Format QSettings::registerFormat(const QString &extension, ReadFunc r
return QSettings::Format((int)QSettings::CustomFormat1 + index);
}
-#ifdef QT3_SUPPORT
-void QSettings::setPath_helper(Scope scope, const QString &organization, const QString &application)
-{
- Q_D(QSettings);
- if (d->pendingChanges)
- d->flush();
- QSettingsPrivate *oldPriv = d;
- QSettingsPrivate *newPriv = QSettingsPrivate::create(oldPriv->format, scope, organization, application);
- static_cast<QObjectPrivate &>(*newPriv) = static_cast<QObjectPrivate &>(*oldPriv); // copy the QObject stuff over (hack)
- d_ptr.reset(newPriv);
-}
-
-/*! \fn bool QSettings::writeEntry(const QString &key, bool value)
-
- Sets the value of setting \a key to \a value.
-
- Use setValue() instead.
-*/
-
-/*! \fn bool QSettings::writeEntry(const QString &key, double value)
-
- \overload
-*/
-
-/*! \fn bool QSettings::writeEntry(const QString &key, int value)
-
- \overload
-*/
-
-/*! \fn bool QSettings::writeEntry(const QString &key, const char *value)
-
- \overload
-*/
-
-/*! \fn bool QSettings::writeEntry(const QString &key, const QString &value)
-
- \overload
-*/
-
-/*! \fn bool QSettings::writeEntry(const QString &key, const QStringList &value)
-
- \overload
-*/
-
-/*! \fn bool QSettings::writeEntry(const QString &key, const QStringList &value, QChar separator)
-
- \overload
-
- Use setValue(\a key, \a value) instead. You don't need \a separator.
-*/
-
-/*! \fn QStringList QSettings::readListEntry(const QString &key, bool *ok = 0)
-
- Returns the value of setting \a key converted to a QStringList.
-
- If \a ok is not 0, *\a{ok} is set to true if the key exists,
- otherwise *\a{ok} is set to false.
-
- Use value() instead.
-
- \oldcode
- bool ok;
- QStringList list = settings.readListEntry("recentFiles", &ok);
- \newcode
- bool ok = settings.contains("recentFiles");
- QStringList list = settings.value("recentFiles").toStringList();
- \endcode
-*/
-
-/*! \fn QStringList QSettings::readListEntry(const QString &key, QChar separator, bool *ok)
-
- Returns the value of setting \a key converted to a QStringList.
- \a separator is ignored.
-
- If \a ok is not 0, *\a{ok} is set to true if the key exists,
- otherwise *\a{ok} is set to false.
-
- Use value() instead.
-
- \oldcode
- bool ok;
- QStringList list = settings.readListEntry("recentFiles", ":", &ok);
- \newcode
- bool ok = settings.contains("recentFiles");
- QStringList list = settings.value("recentFiles").toStringList();
- \endcode
-*/
-
-/*! \fn QString QSettings::readEntry(const QString &key, const QString &defaultValue, bool *ok)
-
- Returns the value for setting \a key converted to a QString. If
- the setting doesn't exist, returns \a defaultValue.
-
- If \a ok is not 0, *\a{ok} is set to true if the key exists,
- otherwise *\a{ok} is set to false.
-
- Use value() instead.
-
- \oldcode
- bool ok;
- QString str = settings.readEntry("userName", "administrator", &ok);
- \newcode
- bool ok = settings.contains("userName");
- QString str = settings.value("userName", "administrator").toString();
- \endcode
-*/
-
-/*! \fn int QSettings::readNumEntry(const QString &key, int defaultValue, bool *ok)
-
- Returns the value for setting \a key converted to an \c int. If
- the setting doesn't exist, returns \a defaultValue.
-
- If \a ok is not 0, *\a{ok} is set to true if the key exists,
- otherwise *\a{ok} is set to false.
-
- Use value() instead.
-
- \oldcode
- bool ok;
- int max = settings.readNumEntry("maxConnections", 30, &ok);
- \newcode
- bool ok = settings.contains("maxConnections");
- int max = settings.value("maxConnections", 30).toInt();
- \endcode
-*/
-
-/*! \fn double QSettings::readDoubleEntry(const QString &key, double defaultValue, bool *ok)
-
- Returns the value for setting \a key converted to a \c double. If
- the setting doesn't exist, returns \a defaultValue.
-
- If \a ok is not 0, *\a{ok} is set to true if the key exists,
- otherwise *\a{ok} is set to false.
-
- Use value() instead.
-
- \oldcode
- bool ok;
- double pi = settings.readDoubleEntry("pi", 3.141592, &ok);
- \newcode
- bool ok = settings.contains("pi");
- double pi = settings.value("pi", 3.141592).toDouble();
- \endcode
-*/
-
-/*! \fn bool QSettings::readBoolEntry(const QString &key, bool defaultValue, bool *ok)
-
- Returns the value for setting \a key converted to a \c bool. If
- the setting doesn't exist, returns \a defaultValue.
-
- If \a ok is not 0, *\a{ok} is set to true if the key exists,
- otherwise *\a{ok} is set to false.
-
- Use value() instead.
-
- \oldcode
- bool ok;
- bool grid = settings.readBoolEntry("showGrid", true, &ok);
- \newcode
- bool ok = settings.contains("showGrid");
- bool grid = settings.value("showGrid", true).toBool();
- \endcode
-*/
-
-/*! \fn bool QSettings::removeEntry(const QString &key)
-
- Use remove() instead.
-*/
-
-/*! \enum QSettings::System
- \compat
-
- \value Unix Unix systems (X11 and Embedded Linux)
- \value Windows Microsoft Windows systems
- \value Mac Mac OS X systems
-
- \sa insertSearchPath(), removeSearchPath()
-*/
-
-/*! \fn void QSettings::insertSearchPath(System system, const QString &path)
-
- This function is implemented as a no-op. It is provided for
- source compatibility with Qt 3. The new QSettings class has no
- concept of "search path".
-*/
-
-/*! \fn void QSettings::removeSearchPath(System system, const QString &path)
-
- This function is implemented as a no-op. It is provided for
- source compatibility with Qt 3. The new QSettings class has no
- concept of "search path".
-*/
-
-/*! \fn void QSettings::setPath(const QString &organization, const QString &application, \
- Scope scope)
-
- Specifies the \a organization, \a application, and \a scope to
- use by the QSettings object.
-
- Use the appropriate constructor instead, with QSettings::UserScope
- instead of QSettings::User and QSettings::SystemScope instead of
- QSettings::Global.
-
- \oldcode
- QSettings settings;
- settings.setPath("twikimaster.com", "Kanooth", QSettings::Global);
- \newcode
- QSettings settings(QSettings::SystemScope, "twikimaster.com", "Kanooth");
- \endcode
-*/
-
-/*! \fn void QSettings::resetGroup()
-
- Sets the current group to be the empty string.
-
- Use endGroup() instead (possibly multiple times).
-
- \oldcode
- QSettings settings;
- settings.beginGroup("mainWindow");
- settings.beginGroup("leftPanel");
- ...
- settings.resetGroup();
- \newcode
- QSettings settings;
- settings.beginGroup("mainWindow");
- settings.beginGroup("leftPanel");
- ...
- settings.endGroup();
- settings.endGroup();
- \endcode
-*/
-
-/*! \fn QStringList QSettings::entryList(const QString &key) const
-
- Returns a list of all sub-keys of \a key.
-
- Use childKeys() instead.
-
- \oldcode
- QSettings settings;
- QStringList keys = settings.entryList("cities");
- ...
- \newcode
- QSettings settings;
- settings.beginGroup("cities");
- QStringList keys = settings.childKeys();
- ...
- settings.endGroup();
- \endcode
-*/
-
-/*! \fn QStringList QSettings::subkeyList(const QString &key) const
-
- Returns a list of all sub-keys of \a key.
-
- Use childGroups() instead.
-
- \oldcode
- QSettings settings;
- QStringList groups = settings.entryList("cities");
- ...
- \newcode
- QSettings settings;
- settings.beginGroup("cities");
- QStringList groups = settings.childKeys();
- ...
- settings.endGroup();
- \endcode
-*/
-#endif
-
QT_END_NAMESPACE
#endif // QT_NO_SETTINGS
diff --git a/src/corelib/io/qsettings.h b/src/corelib/io/qsettings.h
index 155e5c14a6..b144a9af4c 100644
--- a/src/corelib/io/qsettings.h
+++ b/src/corelib/io/qsettings.h
@@ -54,10 +54,6 @@ QT_END_NAMESPACE
#ifndef QT_NO_SETTINGS
-#ifdef QT3_SUPPORT
-#include <QtCore/qstringlist.h>
-#endif
-
#include <ctype.h>
QT_BEGIN_NAMESPACE
@@ -115,11 +111,6 @@ public:
enum Scope {
UserScope,
SystemScope
-#ifdef QT3_SUPPORT
- ,
- User = UserScope,
- Global = SystemScope
-#endif
};
#ifndef QT_NO_QOBJECT
@@ -194,113 +185,12 @@ public:
static Format registerFormat(const QString &extension, ReadFunc readFunc, WriteFunc writeFunc,
Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive);
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT bool writeEntry(const QString &key, bool value)
- { setValue(key, value); return isWritable(); }
- inline QT3_SUPPORT bool writeEntry(const QString &key, double value)
- { setValue(key, value); return isWritable(); }
- inline QT3_SUPPORT bool writeEntry(const QString &key, int value)
- { setValue(key, value); return isWritable(); }
- inline QT3_SUPPORT bool writeEntry(const QString &key, const char *value)
- { setValue(key, QString::fromAscii(value)); return isWritable(); }
- inline QT3_SUPPORT bool writeEntry(const QString &key, const QString &value)
- { setValue(key, value); return isWritable(); }
- inline QT3_SUPPORT bool writeEntry(const QString &key, const QStringList &value)
- { setValue(key, value); return isWritable(); }
- inline QT3_SUPPORT bool writeEntry(const QString &key, const QStringList &value, QChar separator)
- { setValue(key, value.join(QString(separator))); return isWritable(); }
- inline QT3_SUPPORT QStringList readListEntry(const QString &key, bool *ok = 0)
- {
- if (ok)
- *ok = contains(key);
- return value(key).toStringList();
- }
- inline QT3_SUPPORT QStringList readListEntry(const QString &key, QChar separator, bool *ok = 0)
- {
- if (ok)
- *ok = contains(key);
- QString str = value(key).toString();
- if (str.isEmpty())
- return QStringList();
- return str.split(separator);
- }
- inline QT3_SUPPORT QString readEntry(const QString &key, const QString &defaultValue = QString(),
- bool *ok = 0)
- {
- if (ok)
- *ok = contains(key);
- return value(key, defaultValue).toString();
- }
- inline QT3_SUPPORT int readNumEntry(const QString &key, int defaultValue = 0, bool *ok = 0)
- {
- if (ok)
- *ok = contains(key);
- return value(key, defaultValue).toInt();
- }
- inline QT3_SUPPORT double readDoubleEntry(const QString &key, double defaultValue = 0,
- bool *ok = 0)
- {
- if (ok)
- *ok = contains(key);
- return value(key, defaultValue).toDouble();
- }
- inline QT3_SUPPORT bool readBoolEntry(const QString &key, bool defaultValue = false,
- bool *ok = 0)
- {
- if (ok)
- *ok = contains(key);
- return value(key, defaultValue).toBool();
- }
- inline QT3_SUPPORT bool removeEntry(const QString &key)
- { remove(key); return true; }
-
- enum System { Unix, Windows, Mac };
- inline QT3_SUPPORT void insertSearchPath(System, const QString &) {}
- inline QT3_SUPPORT void removeSearchPath(System, const QString &) {}
-
- inline QT3_SUPPORT void setPath(const QString &organization, const QString &application,
- Scope scope = Global)
- {
- setPath_helper(scope == Global ? QSettings::SystemScope : QSettings::UserScope,
- organization, application);
- }
- inline QT3_SUPPORT void resetGroup()
- {
- while (!group().isEmpty())
- endGroup();
- }
- inline QT3_SUPPORT QStringList entryList(const QString &key) const
- {
- QSettings *that = const_cast<QSettings *>(this);
- QStringList result;
-
- that->beginGroup(key);
- result = that->childKeys();
- that->endGroup();
- return result;
- }
- inline QT3_SUPPORT QStringList subkeyList(const QString &key) const
- {
- QSettings *that = const_cast<QSettings *>(this);
- QStringList result;
-
- that->beginGroup(key);
- result = that->childGroups();
- that->endGroup();
- return result;
- }
-#endif
-
protected:
#ifndef QT_NO_QOBJECT
bool event(QEvent *event);
#endif
private:
-#ifdef QT3_SUPPORT
- void setPath_helper(Scope scope, const QString &organization, const QString &application);
-#endif
-
Q_DISABLE_COPY(QSettings)
};
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 7289bb6c03..177f73def3 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -3107,304 +3107,6 @@ QLocale QTextStream::locale() const
return d->locale;
}
-#ifdef QT3_SUPPORT
-/*!
- \class QTextIStream
- \brief The QTextIStream class is a convenience class for input streams.
-
- \compat
- \reentrant
-
- Use QTextStream instead.
-*/
-
-/*!
- \fn QTextIStream::QTextIStream(const QString *string)
-
- Use QTextStream(&\a{string}, QIODevice::ReadOnly) instead.
-*/
-/*!
- \fn QTextIStream::QTextIStream(QByteArray *byteArray)
-
- Use QTextStream(&\a{byteArray}, QIODevice::ReadOnly) instead.
-*/
-/*!
- \fn QTextIStream::QTextIStream(FILE *file)
-
- Use QTextStream(\a{file}, QIODevice::ReadOnly) instead.
-*/
-
-/*!
- \class QTextOStream
- \brief The QTextOStream class is a convenience class for output streams.
-
- \compat
- \reentrant
-
- Use QTextStream instead.
-*/
-
-/*!
- \fn QTextOStream::QTextOStream(QString *string)
-
- Use QTextStream(&\a{string}, QIODevice::WriteOnly) instead.
-*/
-/*!
- \fn QTextOStream::QTextOStream(QByteArray *byteArray)
-
- Use QTextStream(&\a{byteArray}, QIODevice::WriteOnly) instead.
-*/
-/*!
- \fn QTextOStream::QTextOStream(FILE *file)
-
- Use QTextStream(\a{file}, QIODevice::WriteOnly) instead.
-*/
-
-/*! \internal
-*/
-int QTextStream::flagsInternal() const
-{
- Q_D(const QTextStream);
-
- int f = 0;
- switch (d->fieldAlignment) {
- case AlignLeft: f |= left; break;
- case AlignRight: f |= right; break;
- case AlignCenter: f |= internal; break;
- default:
- break;
- }
- switch (d->integerBase) {
- case 2: f |= bin; break;
- case 8: f |= oct; break;
- case 10: f |= dec; break;
- case 16: f |= hex; break;
- default:
- break;
- }
- switch (d->realNumberNotation) {
- case FixedNotation: f |= fixed; break;
- case ScientificNotation: f |= scientific; break;
- default:
- break;
- }
- if (d->numberFlags & ShowBase)
- f |= showbase;
- if (d->numberFlags & ForcePoint)
- f |= showpoint;
- if (d->numberFlags & ForceSign)
- f |= showpos;
- if (d->numberFlags & UppercaseBase)
- f |= uppercase;
- return f;
-}
-
-/*! \internal
-*/
-int QTextStream::flagsInternal(int newFlags)
-{
- int oldFlags = flagsInternal();
-
- if (newFlags & left)
- setFieldAlignment(AlignLeft);
- else if (newFlags & right)
- setFieldAlignment(AlignRight);
- else if (newFlags & internal)
- setFieldAlignment(AlignCenter);
-
- if (newFlags & bin)
- setIntegerBase(2);
- else if (newFlags & oct)
- setIntegerBase(8);
- else if (newFlags & dec)
- setIntegerBase(10);
- else if (newFlags & hex)
- setIntegerBase(16);
-
- if (newFlags & showbase)
- setNumberFlags(numberFlags() | ShowBase);
- if (newFlags & showpos)
- setNumberFlags(numberFlags() | ForceSign);
- if (newFlags & showpoint)
- setNumberFlags(numberFlags() | ForcePoint);
- if (newFlags & uppercase)
- setNumberFlags(numberFlags() | UppercaseBase);
-
- if (newFlags & fixed)
- setRealNumberNotation(FixedNotation);
- else if (newFlags & scientific)
- setRealNumberNotation(ScientificNotation);
-
- return oldFlags;
-}
-
-#ifndef QT_NO_TEXTCODEC
-/*!
- Use setCodec() and setAutoDetectUnicode() instead.
-*/
-void QTextStream::setEncoding(Encoding encoding)
-{
- Q_D(QTextStream);
- resetCodecConverterStateHelper(&d->readConverterState);
- resetCodecConverterStateHelper(&d->writeConverterState);
-
- switch (encoding) {
- case Locale:
- d->writeConverterState.flags |= QTextCodec::IgnoreHeader;
- setCodec(QTextCodec::codecForLocale());
- d->autoDetectUnicode = true;
- break;
- case Latin1:
- d->readConverterState.flags |= QTextCodec::IgnoreHeader;
- d->writeConverterState.flags |= QTextCodec::IgnoreHeader;
- setCodec(QTextCodec::codecForName("ISO-8859-1"));
- d->autoDetectUnicode = false;
- break;
- case Unicode:
- setCodec(QTextCodec::codecForName("UTF-16"));
- d->autoDetectUnicode = false;
- break;
- case RawUnicode:
- d->readConverterState.flags |= QTextCodec::IgnoreHeader;
- d->writeConverterState.flags |= QTextCodec::IgnoreHeader;
- setCodec(QTextCodec::codecForName("UTF-16"));
- d->autoDetectUnicode = false;
- break;
- case UnicodeNetworkOrder:
- d->readConverterState.flags |= QTextCodec::IgnoreHeader;
- d->writeConverterState.flags |= QTextCodec::IgnoreHeader;
- setCodec(QTextCodec::codecForName("UTF-16BE"));
- d->autoDetectUnicode = false;
- break;
- case UnicodeReverse:
- d->readConverterState.flags |= QTextCodec::IgnoreHeader;
- d->writeConverterState.flags |= QTextCodec::IgnoreHeader;
- setCodec(QTextCodec::codecForName("UTF-16LE"));
- d->autoDetectUnicode = false;
- break;
- case UnicodeUTF8:
- d->writeConverterState.flags |= QTextCodec::IgnoreHeader;
- setCodec(QTextCodec::codecForName("UTF-8"));
- d->autoDetectUnicode = true;
- break;
- }
-}
-#endif
-
-/*!
- \enum QTextStream::Encoding
- \compat
-
- \value Latin1 Use setCodec(QTextCodec::codecForName("ISO-8859-1")) instead.
- \value Locale Use setCodec(QTextCodec::codecForLocale()) instead.
- \value RawUnicode Use setCodec(QTextCodec::codecForName("UTF-16")) instead.
- \value Unicode Use setCodec(QTextCodec::codecForName("UTF-16")) instead.
- \value UnicodeNetworkOrder Use setCodec(QTextCodec::codecForName("UTF-16BE")) instead.
- \value UnicodeReverse Use setCodec(QTextCodec::codecForName("UTF-16LE")) instead.
- \value UnicodeUTF8 Use setCodec(QTextCodec::codecForName("UTF-8")) instead.
-
- Also, for all encodings except QTextStream::Latin1 and
- QTextStream::UTF8, you need to call setAutoDetectUnicode(false)
- to obtain the Qt 3 behavior in addition to the setCodec() call.
-
- \sa setCodec(), setAutoDetectUnicode()
-*/
-
-/*!
- \fn int QTextStream::flags() const
-
- Use fieldAlignment(), padChar(), fieldWidth(), numberFlags(),
- integerBase(), realNumberNotation(), and realNumberNotation
- instead.
-*/
-
-/*!
- \fn int QTextStream::flags(int)
-
- Use setFieldAlignment(), setPadChar(), setFieldWidth(),
- setNumberFlags(), setIntegerBase(), setRealNumberNotation(), and
- setRealNumberNotation instead.
-*/
-
-/*!
- \fn int QTextStream::setf(int)
-
- Use setFieldAlignment(), setPadChar(), setFieldWidth(),
- setNumberFlags(), setIntegerBase(), setRealNumberNotation(), and
- setRealNumberNotation instead.
-*/
-
-/*!
- \fn int QTextStream::setf(int, int)
-
- Use setFieldAlignment(), setPadChar(), setFieldWidth(),
- setNumberFlags(), setIntegerBase(), setRealNumberNotation(), and
- setRealNumberNotation instead.
-*/
-
-/*!
- \fn int QTextStream::unsetf(int)
-
- Use setFieldAlignment(), setPadChar(), setFieldWidth(),
- setNumberFlags(), setIntegerBase(), setRealNumberNotation(), and
- setRealNumberNotation instead.
-*/
-
-/*!
- \fn int QTextStream::width(int)
-
- Use setFieldWidth() instead.
-*/
-
-/*!
- \fn int QTextStream::fill(int)
-
- Use setPadChar() instead.
-*/
-
-/*!
- \fn int QTextStream::precision(int)
-
- Use setRealNumberPrecision() instead.
-*/
-
-/*!
- \fn int QTextStream::read()
-
- Use readAll() or readLine() instead.
-*/
-
-/*!
- \fn int QTextStream::unsetDevice()
-
- Use setDevice(0) instead.
-*/
-
-/*!
- \variable QTextStream::skipws
- \variable QTextStream::left
- \variable QTextStream::right
- \variable QTextStream::internal
- \variable QTextStream::bin
- \variable QTextStream::oct
- \variable QTextStream::dec
- \variable QTextStream::hex
- \variable QTextStream::showbase
- \variable QTextStream::showpoint
- \variable QTextStream::uppercase
- \variable QTextStream::showpos
- \variable QTextStream::scientific
- \variable QTextStream::fixed
- \variable QTextStream::basefield
- \variable QTextStream::adjustfield
- \variable QTextStream::floatfield
- \compat
-
- Use the new \l{QTextStream manipulators} instead.
-*/
-
-#endif
-
QT_END_NAMESPACE
#ifndef QT_NO_QOBJECT
diff --git a/src/corelib/io/qtextstream.h b/src/corelib/io/qtextstream.h
index 3747fab6f6..db038855a8 100644
--- a/src/corelib/io/qtextstream.h
+++ b/src/corelib/io/qtextstream.h
@@ -48,12 +48,6 @@
#include <QtCore/qlocale.h>
#include <QtCore/qscopedpointer.h>
-#ifndef QT_NO_TEXTCODEC
-# ifdef QT3_SUPPORT
-# include <QtCore/qtextcodec.h>
-# endif
-#endif
-
#include <stdio.h>
#ifdef Status
@@ -199,63 +193,7 @@ public:
QTextStream &operator<<(const char *c);
QTextStream &operator<<(const void *ptr);
-#ifdef QT3_SUPPORT
- // not marked as QT3_SUPPORT to avoid double compiler warnings, as
- // they are used in the QT3_SUPPORT functions below.
- inline QT3_SUPPORT int flags() const { return flagsInternal(); }
- inline QT3_SUPPORT int flags(int f) { return flagsInternal(f); }
-
- inline QT3_SUPPORT int setf(int bits)
- { int old = flagsInternal(); flagsInternal(flagsInternal() | bits); return old; }
- inline QT3_SUPPORT int setf(int bits, int mask)
- { int old = flagsInternal(); flagsInternal(flagsInternal() | (bits & mask)); return old; }
- inline QT3_SUPPORT int unsetf(int bits)
- { int old = flagsInternal(); flagsInternal(flagsInternal() & ~bits); return old; }
-
- inline QT3_SUPPORT int width(int w)
- { int old = fieldWidth(); setFieldWidth(w); return old; }
- inline QT3_SUPPORT int fill(int f)
- { QChar ch = padChar(); setPadChar(QChar(f)); return ch.unicode(); }
- inline QT3_SUPPORT int precision(int p)
- { int old = realNumberPrecision(); setRealNumberPrecision(p); return old; }
-
- enum {
- skipws = 0x0001, // skip whitespace on input
- left = 0x0002, // left-adjust output
- right = 0x0004, // right-adjust output
- internal = 0x0008, // pad after sign
- bin = 0x0010, // binary format integer
- oct = 0x0020, // octal format integer
- dec = 0x0040, // decimal format integer
- hex = 0x0080, // hex format integer
- showbase = 0x0100, // show base indicator
- showpoint = 0x0200, // force decimal point (float)
- uppercase = 0x0400, // upper-case hex output
- showpos = 0x0800, // add '+' to positive integers
- scientific = 0x1000, // scientific float output
- fixed = 0x2000 // fixed float output
- };
- enum {
- basefield = bin | oct | dec | hex,
- adjustfield = left | right | internal,
- floatfield = scientific | fixed
- };
-
-#ifndef QT_NO_TEXTCODEC
- enum Encoding { Locale, Latin1, Unicode, UnicodeNetworkOrder,
- UnicodeReverse, RawUnicode, UnicodeUTF8 };
- QT3_SUPPORT void setEncoding(Encoding encoding);
-#endif
- inline QT3_SUPPORT QString read() { return readAll(); }
- inline QT3_SUPPORT void unsetDevice() { setDevice(0); }
-#endif
-
private:
-#ifdef QT3_SUPPORT
- int flagsInternal() const;
- int flagsInternal(int flags);
-#endif
-
Q_DISABLE_COPY(QTextStream)
QScopedPointer<QTextStreamPrivate> d_ptr;
@@ -344,32 +282,6 @@ inline QTextStreamManipulator qSetRealNumberPrecision(int precision)
return QTextStreamManipulator(func, precision);
}
-#ifdef QT3_SUPPORT
-typedef QTextStream QTS;
-
-class Q_CORE_EXPORT QTextIStream : public QTextStream
-{
-public:
- inline explicit QTextIStream(const QString *s) : QTextStream(const_cast<QString *>(s), QIODevice::ReadOnly) {}
- inline explicit QTextIStream(QByteArray *a) : QTextStream(a, QIODevice::ReadOnly) {}
- inline QTextIStream(FILE *f) : QTextStream(f, QIODevice::ReadOnly) {}
-
-private:
- Q_DISABLE_COPY(QTextIStream)
-};
-
-class Q_CORE_EXPORT QTextOStream : public QTextStream
-{
-public:
- inline explicit QTextOStream(QString *s) : QTextStream(s, QIODevice::WriteOnly) {}
- inline explicit QTextOStream(QByteArray *a) : QTextStream(a, QIODevice::WriteOnly) {}
- inline QTextOStream(FILE *f) : QTextStream(f, QIODevice::WriteOnly) {}
-
-private:
- Q_DISABLE_COPY(QTextOStream)
-};
-#endif
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 881365678f..b948a43080 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -189,9 +189,6 @@
#include "qstack.h"
#include "qvarlengtharray.h"
#include "qdebug.h"
-#if defined QT3_SUPPORT
-#include "qfileinfo.h"
-#endif
#ifndef QT_BOOTSTRAPPED
#include "qtldurl_p.h"
#endif
@@ -5466,6 +5463,7 @@ void QUrl::removeAllEncodedQueryItems(const QByteArray &key)
if (end < d->query.size())
++end; // remove additional '%'
d->query.remove(pos, end - pos);
+ query = d->query.constData(); //required if remove detach;
} else {
pos = end + 1;
}
@@ -6362,35 +6360,6 @@ bool QUrl::isParentOf(const QUrl &childUrl) const
Use QFileInfo(path()).absolutePath() or QFileInfo(path()) instead.
*/
-#ifdef QT3_SUPPORT
-void QUrl::setFileName(const QString &txt)
-{
- QFileInfo fileInfo(path());
- fileInfo.setFile(txt);
- setPath(fileInfo.filePath());
-}
-
-QString QUrl::fileName() const
-{
- QFileInfo fileInfo(path());
- return fileInfo.fileName();
-}
-
-QString QUrl::dirPath() const
-{
- QFileInfo fileInfo(path());
- if (fileInfo.isAbsolute()) {
- QString absPath = fileInfo.absolutePath();
-#ifdef Q_OS_WIN
- if (absPath.size() > 1 && absPath.at(1) == QLatin1Char(':'))
- absPath = absPath.mid(2);
-#endif
- return absPath;
- }
- return fileInfo.path();
-}
-#endif
-
#ifndef QT_NO_DATASTREAM
/*! \relates QUrl
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index d57a0c77df..e62cd0a85b 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -221,58 +221,8 @@ public:
static QStringList idnWhitelist();
static void setIdnWhitelist(const QStringList &);
-#if defined QT3_SUPPORT
- inline QT3_SUPPORT QString protocol() const { return scheme(); }
- inline QT3_SUPPORT void setProtocol(const QString &s) { setScheme(s); }
- inline QT3_SUPPORT void setUser(const QString &s) { setUserName(s); }
- inline QT3_SUPPORT QString user() const { return userName(); }
- inline QT3_SUPPORT bool hasUser() const { return !userName().isEmpty(); }
- inline QT3_SUPPORT bool hasPassword() const { return !password().isEmpty(); }
- inline QT3_SUPPORT bool hasHost() const { return !host().isEmpty(); }
- inline QT3_SUPPORT bool hasPort() const { return port() != -1; }
- inline QT3_SUPPORT bool hasPath() const { return !path().isEmpty(); }
- inline QT3_SUPPORT void setQuery(const QString &txt)
- {
- setEncodedQuery(txt.toLatin1());
- }
- inline QT3_SUPPORT QString query() const
- {
- return QString::fromLatin1(encodedQuery().constData());
- }
- inline QT3_SUPPORT QString ref() const { return fragment(); }
- inline QT3_SUPPORT void setRef(const QString &txt) { setFragment(txt); }
- inline QT3_SUPPORT bool hasRef() const { return !fragment().isEmpty(); }
- inline QT3_SUPPORT void addPath(const QString &p) { setPath(path() + QLatin1Char('/') + p); }
- QT3_SUPPORT void setFileName(const QString &txt);
- QT3_SUPPORT QString fileName() const;
- QT3_SUPPORT QString dirPath() const;
- static inline QT3_SUPPORT void decode(QString &url)
- {
- url = QUrl::fromPercentEncoding(url.toLatin1());
- }
- static inline QT3_SUPPORT void encode(QString &url)
- {
- url = QString::fromLatin1(QUrl::toPercentEncoding(url).constData());
- }
- inline QT3_SUPPORT operator QString() const { return toString(); }
- inline QT3_SUPPORT bool cdUp()
- {
- *this = resolved(QUrl(QLatin1String("..")));
- return true;
- }
- static inline QT3_SUPPORT bool isRelativeUrl(const QString &url)
- {
- return QUrl(url).isRelative();
- }
-#endif
-
QString errorString() const;
-protected:
-#if defined (QT3_SUPPORT)
- inline QT3_SUPPORT void reset() { clear(); }
-#endif
-
private:
QUrlPrivate *d;
public:
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index e00db5e01a..c134881f31 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -176,9 +176,6 @@ extern QString qAppFileName();
#endif
int QCoreApplicationPrivate::app_compile_version = 0x040000; //we don't know exactly, but it's at least 4.0.0
-#if defined(QT3_SUPPORT)
-bool QCoreApplicationPrivate::useQt3Support = true;
-#endif
#if !defined(Q_OS_WIN)
#ifdef Q_OS_MAC
@@ -337,9 +334,6 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint
in_exec(false), aboutToQuitEmitted(false), threadData_clean(false)
{
app_compile_version = flags & 0xffffff;
-#if defined(QT3_SUPPORT)
- useQt3Support = !(flags & 0x01000000);
-#endif
static const char *const empty = "";
if (argc == 0 || argv == 0) {
argc = 0;
@@ -1261,20 +1255,7 @@ void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority)
// delete the event on exceptions to protect against memory leaks till the event is
// properly owned in the postEventList
QScopedPointer<QEvent> eventDeleter(event);
- if (data->postEventList.isEmpty() || data->postEventList.last().priority >= priority) {
- // optimization: we can simply append if the last event in
- // the queue has higher or equal priority
- data->postEventList.append(QPostEvent(receiver, event, priority));
- } else {
- // insert event in descending priority order, using upper
- // bound for a given priority (to ensure proper ordering
- // of events with the same priority)
- QPostEventList::iterator begin = data->postEventList.begin()
- + data->postEventList.insertionOffset,
- end = data->postEventList.end();
- QPostEventList::iterator at = qUpperBound(begin, end, priority);
- data->postEventList.insert(at, QPostEvent(receiver, event, priority));
- }
+ data->postEventList.addEvent(QPostEvent(receiver, event, priority));
eventDeleter.take();
event->posted = true;
++receiver->d_func()->postedEvents;
@@ -1372,20 +1353,6 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type
++data->postEventList.recursion;
-#ifdef QT3_SUPPORT
- if (event_type == QEvent::ChildInserted) {
- if (receiver) {
- // optimize sendPostedEvents(w, QEvent::ChildInserted) calls away
- receiver->d_func()->sendPendingChildInsertedEvents();
- --data->postEventList.recursion;
- return;
- }
-
- // ChildInserted events are sent in response to *Request
- event_type = QEvent::ChildInsertedRequest;
- }
-#endif
-
QMutexLocker locker(&data->postEventList.mutex);
// by default, we assume that the event dispatcher can go to sleep after
@@ -1434,7 +1401,7 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type
// cannot send deferred delete
if (!event_type && !receiver) {
// don't lose the event
- data->postEventList.append(pe);
+ data->postEventList.addEvent(pe);
const_cast<QPostEvent &>(pe).event = 0;
}
continue;
@@ -1536,11 +1503,6 @@ void QCoreApplication::removePostedEvents(QObject *receiver)
void QCoreApplication::removePostedEvents(QObject *receiver, int eventType)
{
-#ifdef QT3_SUPPORT
- if (eventType == QEvent::ChildInserted)
- eventType = QEvent::ChildInsertedRequest;
-#endif
-
QThreadData *data = receiver ? receiver->d_func()->threadData : QThreadData::current();
QMutexLocker locker(&data->postEventList.mutex);
@@ -1563,10 +1525,6 @@ void QCoreApplication::removePostedEvents(QObject *receiver, int eventType)
if ((!receiver || pe.receiver == receiver)
&& (pe.event && (eventType == 0 || pe.event->type() == eventType))) {
--pe.receiver->d_func()->postedEvents;
-#ifdef QT3_SUPPORT
- if (pe.event->type() == QEvent::ChildInsertedRequest)
- pe.receiver->d_func()->pendingChildInsertedEvents.clear();
-#endif
pe.event->posted = false;
events.append(pe.event);
const_cast<QPostEvent &>(pe).event = 0;
@@ -2558,109 +2516,6 @@ bool QCoreApplication::hasPendingEvents()
return false;
}
-#ifdef QT3_SUPPORT
-/*! \fn void QCoreApplication::lock()
-
- In Qt 3, this function locked the Qt library mutex, allowing
- non-GUI threads to perform basic printing operations using
- QPainter.
-
- In Qt 4, this is no longer supported, since painting is only
- supported from within a paint event handler. This function does
- nothing.
-
- \sa QWidget::paintEvent()
-*/
-
-/*! \fn void QCoreApplication::unlock(bool wakeUpGui)
-
- In Qt 3, this function unlocked the Qt library mutex. The mutex
- allowed non-GUI threads to perform basic printing operations
- using QPainter.
-
- In Qt 4, this is no longer supported, since painting is only
- supported from within a paint event handler. This function does
- nothing.
-*/
-
-/*! \fn bool QCoreApplication::locked()
-
- This function does nothing. It is there to keep old code working.
- It always returns false.
-
- See lock() for details.
-*/
-
-/*! \fn bool QCoreApplication::tryLock()
-
- This function does nothing. It is there to keep old code working.
- It always returns false.
-
- See lock() for details.
-*/
-
-/*! \fn void QCoreApplication::processOneEvent()
- \obsolete
-
- Waits for an event to occur, processes it, then returns.
-
- This function is useful for adapting Qt to situations where the
- event processing must be grafted onto existing program loops.
-
- Using this function in new applications may be an indication of design
- problems.
-
- \sa processEvents(), exec(), QTimer
-*/
-
-/*! \obsolete
-
- This function enters the main event loop (recursively). Do not call
- it unless you really know what you are doing.
-*/
-int QCoreApplication::enter_loop()
-{
- if (!QCoreApplicationPrivate::checkInstance("enter_loop"))
- return -1;
- if (QThreadData::current() != self->d_func()->threadData) {
- qWarning("QCoreApplication::enter_loop: Must be called from the main thread");
- return -1;
- }
- QEventLoop eventLoop;
- int returnCode = eventLoop.exec();
- return returnCode;
-}
-
-/*! \obsolete
-
- This function exits from a recursive call to the main event loop.
- Do not call it unless you are an expert.
-*/
-void QCoreApplication::exit_loop()
-{
- if (!QCoreApplicationPrivate::checkInstance("exit_loop"))
- return;
- QThreadData *data = QThreadData::current();
- if (data != self->d_func()->threadData) {
- qWarning("QCoreApplication::exit_loop: Must be called from the main thread");
- return;
- }
- if (!data->eventLoops.isEmpty())
- data->eventLoops.top()->exit();
-}
-
-/*! \obsolete
-
- Returns the current loop level.
-*/
-int QCoreApplication::loopLevel()
-{
- if (!QCoreApplicationPrivate::checkInstance("loopLevel"))
- return -1;
- return self->d_func()->threadData->eventLoops.size();
-}
-#endif
-
/*
\fn void QCoreApplication::watchUnixSignal(int signal, bool watch)
\internal
diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h
index c3d174d878..04d538d1b3 100644
--- a/src/corelib/kernel/qcoreapplication.h
+++ b/src/corelib/kernel/qcoreapplication.h
@@ -46,10 +46,6 @@
#include <QtCore/qcoreevent.h>
#include <QtCore/qeventloop.h>
-#ifdef QT_INCLUDE_COMPAT
-#include <QtCore/qstringlist.h>
-#endif
-
#if defined(Q_OS_WIN) && !defined(tagMSG)
typedef struct tagMSG MSG;
#endif
@@ -79,9 +75,6 @@ class Q_CORE_EXPORT QCoreApplication : public QObject
Q_DECLARE_PRIVATE(QCoreApplication)
public:
enum { ApplicationFlags = QT_VERSION
-#if !defined(QT3_SUPPORT)
- | 0x01000000
-#endif
};
QCoreApplication(int &argc, char **argv, int = ApplicationFlags);
@@ -155,19 +148,6 @@ public:
static void flush();
-#if defined(QT3_SUPPORT)
- inline QT3_SUPPORT void lock() {}
- inline QT3_SUPPORT void unlock(bool = true) {}
- inline QT3_SUPPORT bool locked() { return false; }
- inline QT3_SUPPORT bool tryLock() { return false; }
-
- static inline QT3_SUPPORT void processOneEvent()
- { processEvents(QEventLoop::WaitForMoreEvents); }
- static QT3_SUPPORT int enter_loop();
- static QT3_SUPPORT void exit_loop();
- static QT3_SUPPORT int loopLevel();
-#endif
-
#if defined(Q_OS_WIN)
virtual bool winEventFilter(MSG *message, long *result);
#endif
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index 22585a1ce9..62026141a1 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -141,9 +141,6 @@ public:
static uint attribs;
static inline bool testAttribute(uint flag) { return attribs & (1 << flag); }
static int app_compile_version;
-#if defined(QT3_SUPPORT)
- static bool useQt3Support;
-#endif
static QSettings *trolltechConf();
};
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp
index 49c6da42c6..0c3a3b8777 100644
--- a/src/corelib/kernel/qcoreevent.cpp
+++ b/src/corelib/kernel/qcoreevent.cpp
@@ -505,65 +505,6 @@ QChildEvent::~QChildEvent()
false.
*/
-/*!
- \class QCustomEvent
- \brief The QCustomEvent class provides support for custom events.
-
- \compat
-
- QCustomEvent has a \c{void *} that can be used to store custom
- data.
-
- In Qt 3, QObject::customEvent() took a QCustomEvent pointer. We
- found out that this approach was unsatisfactory, because
- there was often no safe way of deleting the data held in the
- \c{void *}.
-
- In Qt 4, QObject::customEvent() takes a plain QEvent pointer.
- You can add custom data by subclassing.
-
- \sa QObject::customEvent(), QCoreApplication::notify()
-*/
-
-/*!
- \fn QCustomEvent::QCustomEvent(int type, void *data)
-
- Constructs a custom event object with the event \a type and a
- pointer to \a data. The value of \a type must be at least as
- large as QEvent::User. By default, the data pointer is set to 0.
-*/
-#ifdef QT3_SUPPORT
-QCustomEvent::QCustomEvent(int type, void *data)
- : QEvent(static_cast<Type>(type))
-{
- d = reinterpret_cast<QEventPrivate *>(data);
-}
-
-/*! \internal
-*/
-QCustomEvent::~QCustomEvent()
-{
-}
-#endif
-/*!
- \fn void QCustomEvent::setData(void *data)
-
- \compat
-
- Sets the generic data pointer to \a data.
-
- \sa data()
-*/
-
-/*!
- \fn void *QCustomEvent::data() const
-
- \compat
-
- Returns a pointer to the generic event data.
-
- \sa setData()
-*/
/*!
\fn bool QChildEvent::inserted() const
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index 791b207dea..831a403975 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -89,9 +89,6 @@ public:
Quit = 20, // request to quit application
ParentChange = 21, // widget has been reparented
ParentAboutToChange = 131, // sent just before the parent change is done
-#ifdef QT3_SUPPORT
- Reparent = ParentChange,
-#endif
ThreadChange = 22, // object has changed threads
WindowActivate = 24, // window was activated
WindowDeactivate = 25, // window was deactivated
@@ -118,11 +115,6 @@ public:
DragResponse = 64, // drag accepted/rejected
ChildAdded = 68, // new child widget
ChildPolished = 69, // polished child widget
-#ifdef QT3_SUPPORT
- ChildInsertedRequest = 67, // send ChildInserted compatibility events to receiver
- ChildInserted = 70, // compatibility child inserted
- LayoutHint = 72, // compatibility relayout request
-#endif
ChildRemoved = 71, // deleted child widget
ShowWindowRequest = 73, // widget's window should be mapped
PolishRequest = 74, // widget should be polished
@@ -174,18 +166,8 @@ public:
Shortcut = 117, // shortcut triggered
ShortcutOverride = 51, // shortcut override request
-#ifdef QT3_SUPPORT
- Accel = 30, // accelerator event
- AccelAvailable = 32, // accelerator available event
- AccelOverride = ShortcutOverride, // accelerator override event
-#endif
-
WhatsThisClicked = 118,
-#ifdef QT3_SUPPORT
- CaptionChange = WindowTitleChange,
- IconChange = WindowIconChange,
-#endif
ToolBarChange = 120, // toolbar visibility toggled
ApplicationActivate = 121, // application has been changed to active
@@ -297,6 +279,7 @@ public:
Expose = 208,
InputMethodQuery = 209,
+ OrientationChange = 210, // Screen orientation has changed
// 512 reserved for Qt Jambi's MetaCall event
// 513 reserved for Qt Jambi's DeleteOnMainThread event
@@ -364,26 +347,12 @@ public:
~QChildEvent();
QObject *child() const { return c; }
bool added() const { return type() == ChildAdded; }
-#ifdef QT3_SUPPORT
- QT3_SUPPORT bool inserted() const { return type() == ChildInserted; }
-#endif
bool polished() const { return type() == ChildPolished; }
bool removed() const { return type() == ChildRemoved; }
protected:
QObject *c;
};
-#ifdef QT3_SUPPORT
-class Q_CORE_EXPORT QCustomEvent : public QEvent
-{
-public:
- QT3_SUPPORT_CONSTRUCTOR QCustomEvent(int type, void *data = 0);
- ~QCustomEvent();
- QT3_SUPPORT void *data() const { return d; }
- QT3_SUPPORT void setData(void* aData) { d = reinterpret_cast<QEventPrivate *>(aData); }
-};
-#endif
-
class Q_CORE_EXPORT QDynamicPropertyChangeEvent : public QEvent
{
public:
diff --git a/src/corelib/kernel/qeventloop.h b/src/corelib/kernel/qeventloop.h
index 46ee118ce5..5bd4146352 100644
--- a/src/corelib/kernel/qeventloop.h
+++ b/src/corelib/kernel/qeventloop.h
@@ -66,10 +66,6 @@ public:
ExcludeUserInputEvents = 0x01,
ExcludeSocketNotifiers = 0x02,
WaitForMoreEvents = 0x04,
-#ifdef QT3_SUPPORT
- ExcludeUserInput = ExcludeUserInputEvents,
- WaitForMore = WaitForMoreEvents,
-#endif
X11ExcludeTimers = 0x08
#ifdef QT_DEPRECATED
, DeferredDeletion = 0x10
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index b4c37f4778..c8ac15c1fa 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -2283,11 +2283,7 @@ bool QMetaProperty::write(QObject *object, const QVariant &value) const
QVariant v = value;
uint t = QVariant::Invalid;
if (isEnumType()) {
- if (v.type() == QVariant::String
-#ifdef QT3_SUPPORT
- || v.type() == QVariant::CString
-#endif
- ) {
+ if (v.type() == QVariant::String) {
if (isFlagType())
v = QVariant(menum.keysToValue(value.toByteArray()));
else
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index e5ef021ed1..c97f9d260e 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -765,9 +765,6 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
stream << *static_cast<const NS(QEasingCurve)*>(data);
break;
#endif
-#ifdef QT3_SUPPORT
- case QMetaType::QColorGroup:
-#endif
case QMetaType::QFont:
case QMetaType::QPixmap:
case QMetaType::QBrush:
@@ -974,9 +971,6 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
stream >> *static_cast< NS(QEasingCurve)*>(data);
break;
#endif
-#ifdef QT3_SUPPORT
- case QMetaType::QColorGroup:
-#endif
case QMetaType::QFont:
case QMetaType::QPixmap:
case QMetaType::QBrush:
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index da59a8fa2b..5df7658a13 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -72,6 +72,7 @@ public:
QVariantHash = 28, QEasingCurve = 29, LastCoreType = QEasingCurve,
FirstGuiType = 64 /* QFont */,
+
QFont = 64, QPixmap = 65, QBrush = 66, QColor = 67, QPalette = 68,
QImage = 69, QPolygon = 70, QRegion = 71, QBitmap = 72,
QCursor = 73, QKeySequence = 74, QPen = 75,
@@ -314,9 +315,6 @@ class QEasingCurve;
class QWidget;
class QObject;
-#ifdef QT3_SUPPORT
-class QColorGroup;
-#endif
class QFont;
class QPixmap;
class QBrush;
@@ -384,9 +382,6 @@ Q_DECLARE_BUILTIN_METATYPE(QRegExp, QRegExp)
#endif
Q_DECLARE_BUILTIN_METATYPE(QEasingCurve, QEasingCurve)
-#ifdef QT3_SUPPORT
-Q_DECLARE_BUILTIN_METATYPE(QColorGroup, QColorGroup)
-#endif
Q_DECLARE_BUILTIN_METATYPE(QFont, QFont)
Q_DECLARE_BUILTIN_METATYPE(QPixmap, QPixmap)
Q_DECLARE_BUILTIN_METATYPE(QBrush, QBrush)
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index a958efd64f..d573741654 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -203,22 +203,6 @@ void QObjectPrivate::resetDeleteWatch(QObjectPrivate *d, int *oldWatch, int dele
}
#endif
-#ifdef QT3_SUPPORT
-void QObjectPrivate::sendPendingChildInsertedEvents()
-{
- Q_Q(QObject);
- for (int i = 0; i < pendingChildInsertedEvents.size(); ++i) {
- QObject *c = pendingChildInsertedEvents.at(i).data();
- if (!c || c->parent() != q)
- continue;
- QChildEvent childEvent(QEvent::ChildInserted, c);
- QCoreApplication::sendEvent(q, &childEvent);
- }
- pendingChildInsertedEvents.clear();
-}
-
-#endif
-
/*!\internal
For a given metaobject, compute the signal offset, and the method offset (including signals)
@@ -737,29 +721,6 @@ QObject::QObject(QObject *parent)
qt_addObject(this);
}
-#ifdef QT3_SUPPORT
-/*!
- \overload QObject()
- \obsolete
-
- Creates a new QObject with the given \a parent and object \a name.
- */
-QObject::QObject(QObject *parent, const char *name)
- : d_ptr(new QObjectPrivate)
-{
- Q_D(QObject);
- qt_addObject(d_ptr->q_ptr = this);
- d->threadData = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current();
- d->threadData->ref();
- if (parent) {
- if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData))
- parent = 0;
- setParent(parent);
- }
- setObjectName(QString::fromAscii(name));
-}
-#endif
-
/*! \internal
*/
QObject::QObject(QObjectPrivate &dd, QObject *parent)
@@ -1079,56 +1040,6 @@ void QObject::setObjectName(const QString &name)
d->declarativeData->objectNameChanged(d->declarativeData, this);
}
-
-#ifdef QT3_SUPPORT
-/*! \internal
- QObject::child is compat but needs to call itself recursively,
- that's why we need this helper.
-*/
-static QObject *qChildHelper(const char *objName, const char *inheritsClass,
- bool recursiveSearch, const QObjectList &children)
-{
- if (children.isEmpty())
- return 0;
-
- bool onlyWidgets = (inheritsClass && qstrcmp(inheritsClass, "QWidget") == 0);
- const QLatin1String oName(objName);
- for (int i = 0; i < children.size(); ++i) {
- QObject *obj = children.at(i);
- if (onlyWidgets) {
- if (obj->isWidgetType() && (!objName || obj->objectName() == oName))
- return obj;
- } else if ((!inheritsClass || obj->inherits(inheritsClass))
- && (!objName || obj->objectName() == oName))
- return obj;
- if (recursiveSearch && (obj = qChildHelper(objName, inheritsClass,
- recursiveSearch, obj->children())))
- return obj;
- }
- return 0;
-}
-
-
-/*!
- Searches the children and optionally grandchildren of this object,
- and returns a child that is called \a objName that inherits \a
- inheritsClass. If \a inheritsClass is 0 (the default), any class
- matches.
-
- If \a recursiveSearch is true (the default), child() performs a
- depth-first search of the object's children.
-
- If there is no such object, this function returns 0. If there are
- more than one, the first one found is returned.
-*/
-QObject* QObject::child(const char *objName, const char *inheritsClass,
- bool recursiveSearch) const
-{
- Q_D(const QObject);
- return qChildHelper(objName, inheritsClass, recursiveSearch, d->children);
-}
-#endif
-
/*!
\fn bool QObject::isWidgetType() const
@@ -1157,17 +1068,8 @@ bool QObject::event(QEvent *e)
timerEvent((QTimerEvent*)e);
break;
-#ifdef QT3_SUPPORT
- case QEvent::ChildInsertedRequest:
- d_func()->sendPendingChildInsertedEvents();
- break;
-#endif
-
case QEvent::ChildAdded:
case QEvent::ChildPolished:
-#ifdef QT3_SUPPORT
- case QEvent::ChildInserted:
-#endif
case QEvent::ChildRemoved:
childEvent((QChildEvent*)e);
break;
@@ -1483,7 +1385,7 @@ void QObjectPrivate::setThreadData_helper(QThreadData *currentData, QThreadData
continue;
if (pe.receiver == q) {
// move this post event to the targetList
- targetData->postEventList.append(pe);
+ targetData->postEventList.addEvent(pe);
const_cast<QPostEvent &>(pe).event = 0;
++eventsMoved;
}
@@ -1636,102 +1538,6 @@ void QObject::killTimer(int id)
\sa findChild(), findChildren(), parent(), setParent()
*/
-#ifdef QT3_SUPPORT
-static void objSearch(QObjectList &result,
- const QObjectList &list,
- const char *inheritsClass,
- bool onlyWidgets,
- const char *objName,
- QRegExp *rx,
- bool recurse)
-{
- for (int i = 0; i < list.size(); ++i) {
- QObject *obj = list.at(i);
- if (!obj)
- continue;
- bool ok = true;
- if (onlyWidgets)
- ok = obj->isWidgetType();
- else if (inheritsClass && !obj->inherits(inheritsClass))
- ok = false;
- if (ok) {
- if (objName)
- ok = (obj->objectName() == QLatin1String(objName));
-#ifndef QT_NO_REGEXP
- else if (rx)
- ok = (rx->indexIn(obj->objectName()) != -1);
-#endif
- }
- if (ok) // match!
- result.append(obj);
- if (recurse) {
- QObjectList clist = obj->children();
- if (!clist.isEmpty())
- objSearch(result, clist, inheritsClass,
- onlyWidgets, objName, rx, recurse);
- }
- }
-}
-
-/*!
- \internal
-
- Searches the children and optionally grandchildren of this object,
- and returns a list of those objects that are named or that match
- \a objName and inherit \a inheritsClass. If \a inheritsClass is 0
- (the default), all classes match. If \a objName is 0 (the
- default), all object names match.
-
- If \a regexpMatch is true (the default), \a objName is a regular
- expression that the objects's names must match. The syntax is that
- of a QRegExp. If \a regexpMatch is false, \a objName is a string
- and object names must match it exactly.
-
- Note that \a inheritsClass uses single inheritance from QObject,
- the way inherits() does. According to inherits(), QWidget
- inherits QObject but not QPaintDevice. This does not quite match
- reality, but is the best that can be done on the wide variety of
- compilers Qt supports.
-
- Finally, if \a recursiveSearch is true (the default), queryList()
- searches \e{n}th-generation as well as first-generation children.
-
- If all this seems a bit complex for your needs, the simpler
- child() function may be what you want.
-
- This somewhat contrived example disables all the buttons in this
- window:
-
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 9
-
- \warning Delete the list as soon you have finished using it. The
- list contains pointers that may become invalid at almost any time
- without notice (as soon as the user closes a window you may have
- dangling pointers, for example).
-
- \sa child() children(), parent(), inherits(), objectName(), QRegExp
-*/
-
-QObjectList QObject::queryList(const char *inheritsClass,
- const char *objName,
- bool regexpMatch,
- bool recursiveSearch) const
-{
- Q_D(const QObject);
- QObjectList list;
- bool onlyWidgets = (inheritsClass && qstrcmp(inheritsClass, "QWidget") == 0);
-#ifndef QT_NO_REGEXP
- if (regexpMatch && objName) { // regexp matching
- QRegExp rx(QString::fromLatin1(objName));
- objSearch(list, d->children, inheritsClass, onlyWidgets, 0, &rx, recursiveSearch);
- } else
-#endif
- {
- objSearch(list, d->children, inheritsClass, onlyWidgets, objName, 0, recursiveSearch);
- }
- return list;
-}
-#endif
/*!
\fn T *QObject::findChild(const QString &name) const
@@ -1949,16 +1755,6 @@ void QObjectPrivate::setParent_helper(QObject *o)
if (!isWidget) {
QChildEvent e(QEvent::ChildAdded, q);
QCoreApplication::sendEvent(parent, &e);
-#ifdef QT3_SUPPORT
- if (QCoreApplicationPrivate::useQt3Support) {
- if (parent->d_func()->pendingChildInsertedEvents.isEmpty()) {
- QCoreApplication::postEvent(parent,
- new QEvent(QEvent::ChildInsertedRequest),
- Qt::HighEventPriority);
- }
- parent->d_func()->pendingChildInsertedEvents.append(q);
- }
-#endif
}
}
}
@@ -2940,7 +2736,7 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
\a receiver. Returns true if the connection is successfully broken;
otherwise returns false.
- This function provides the same posibilities like
+ This function provides the same possibilities like
disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
but uses QMetaMethod to represent the signal and the method to be disconnected.
@@ -2958,7 +2754,7 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
QMetaMethod() may be used as wildcard in the meaning "any signal" or "any slot in receiving object".
In the same way 0 can be used for \a receiver in the meaning "any receiving object". In this case
- method shoud also be QMetaMethod(). \a sender parameter should be never 0.
+ method should also be QMetaMethod(). \a sender parameter should be never 0.
\sa disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
*/
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 0fa28c0e63..1c367eb8d1 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -188,14 +188,6 @@ public:
}
#endif
-#ifdef QT3_SUPPORT
- QT3_SUPPORT QObject *child(const char *objName, const char *inheritsClass = 0,
- bool recursiveSearch = true) const;
- QT3_SUPPORT QObjectList queryList(const char *inheritsClass = 0,
- const char *objName = 0,
- bool regexpMatch = true,
- bool recursiveSearch = true) const;
-#endif
inline const QObjectList &children() const { return d_ptr->children; }
void setParent(QObject *);
@@ -204,44 +196,14 @@ public:
static bool connect(const QObject *sender, const char *signal,
- const QObject *receiver, const char *member, Qt::ConnectionType =
-#ifdef qdoc
- Qt::AutoConnection
-#else
-#ifdef QT3_SUPPORT
- Qt::AutoCompatConnection
-#else
- Qt::AutoConnection
-#endif
-#endif
- );
+ const QObject *receiver, const char *member, Qt::ConnectionType = Qt::AutoConnection);
static bool connect(const QObject *sender, const QMetaMethod &signal,
const QObject *receiver, const QMetaMethod &method,
- Qt::ConnectionType type =
-#ifdef qdoc
- Qt::AutoConnection
-#else
-#ifdef QT3_SUPPORT
- Qt::AutoCompatConnection
-#else
- Qt::AutoConnection
-#endif
-#endif
- );
+ Qt::ConnectionType type = Qt::AutoConnection);
inline bool connect(const QObject *sender, const char *signal,
- const char *member, Qt::ConnectionType type =
-#ifdef qdoc
- Qt::AutoConnection
-#else
-#ifdef QT3_SUPPORT
- Qt::AutoCompatConnection
-#else
- Qt::AutoConnection
-#endif
-#endif
- ) const;
+ const char *member, Qt::ConnectionType type = Qt::AutoConnection) const;
static bool disconnect(const QObject *sender, const char *signal,
const QObject *receiver, const char *member);
@@ -292,29 +254,6 @@ protected:
virtual void connectNotify(const char *signal);
virtual void disconnectNotify(const char *signal);
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QObject(QObject *parent, const char *name);
- inline QT3_SUPPORT void insertChild(QObject *o)
- { if (o) o->setParent(this); }
- inline QT3_SUPPORT void removeChild(QObject *o)
- { if (o) o->setParent(0); }
- inline QT3_SUPPORT bool isA(const char *classname) const
- { return qstrcmp(classname, metaObject()->className()) == 0; }
- inline QT3_SUPPORT const char *className() const { return metaObject()->className(); }
- inline QT3_SUPPORT const char *name() const { return objectName().latin1_helper(); }
- inline QT3_SUPPORT const char *name(const char *defaultName) const
- { QString s = objectName(); return s.isEmpty()?defaultName:s.latin1_helper(); }
- inline QT3_SUPPORT void setName(const char *aName) { setObjectName(QLatin1String(aName)); }
-protected:
- inline QT3_SUPPORT bool checkConnectArgs(const char *signal,
- const QObject *,
- const char *member)
- { return QMetaObject::checkConnectArgs(signal, member); }
- static inline QT3_SUPPORT QByteArray normalizeSignalSlot(const char *signalSlot)
- { return QMetaObject::normalizedSignature(signalSlot); }
-#endif
-
protected:
QObject(QObjectPrivate &dd, QObject *parent = 0);
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 3968a31bb8..9151e8eb7b 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -157,10 +157,6 @@ public:
void addConnection(int signal, Connection *c);
void cleanConnectionLists();
-#ifdef QT3_SUPPORT
- void sendPendingChildInsertedEvents();
-#endif
-
static inline Sender *setCurrentSender(QObject *receiver,
Sender *sender);
static inline void resetCurrentSender(QObject *receiver,
@@ -190,14 +186,6 @@ public:
Sender *currentSender; // object currently activating the object
mutable quint32 connectedSignals[2];
-#ifdef QT3_SUPPORT
- QVector< QWeakPointer<QObject> > pendingChildInsertedEvents;
-#else
- // preserve binary compatibility with code compiled without Qt 3 support
- // keeping the binary layout stable helps the Qt Creator debugger
- void *unused;
-#endif
-
QList<QPointer<QObject> > eventFilters;
union {
QObject *currentChildBeingDeleted;
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index efce4d5456..705956869d 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -83,9 +83,6 @@ class QString;
#define Q_OVERRIDE(text)
#define Q_ENUMS(x)
#define Q_FLAGS(x)
-#ifdef QT3_SUPPORT
-# define Q_SETS(x)
-#endif
#define Q_SCRIPTABLE
#define Q_INVOKABLE
#define Q_SIGNAL
@@ -188,9 +185,6 @@ private:
#define Q_OVERRIDE(text) Q_OVERRIDE(text)
#define Q_ENUMS(x) Q_ENUMS(x)
#define Q_FLAGS(x) Q_FLAGS(x)
-#ifdef QT3_SUPPORT
-# define Q_SETS(x) Q_SETS(x)
-#endif
/* tmake ignore Q_OBJECT */
#define Q_OBJECT Q_OBJECT
/* tmake ignore Q_OBJECT */
@@ -233,12 +227,6 @@ Q_CORE_EXPORT const char *qFlagLocation(const char *method);
# define SIGNAL(a) "2"#a
#endif
-#ifdef QT3_SUPPORT
-#define METHOD_CODE 0 // member type codes
-#define SLOT_CODE 1
-#define SIGNAL_CODE 2
-#endif
-
#define QMETHOD_CODE 0 // member type codes
#define QSLOT_CODE 1
#define QSIGNAL_CODE 2
@@ -461,10 +449,6 @@ struct Q_CORE_EXPORT QMetaObject
int static_metacall(Call, int, void **) const;
static int metacall(QObject *, Call, int, void **);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT const char *superClassName() const;
-#endif
-
struct { // private data
const QMetaObject *superdata;
const char *stringdata;
@@ -494,11 +478,6 @@ inline const char *QMetaObject::className() const
inline const QMetaObject *QMetaObject::superClass() const
{ return d.superdata; }
-#ifdef QT3_SUPPORT
-inline const char *QMetaObject::superClassName() const
-{ return d.superdata ? d.superdata->className() : 0; }
-#endif
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/corelib/kernel/qsignalmapper.cpp b/src/corelib/kernel/qsignalmapper.cpp
index 2306450300..665b9e22b5 100644
--- a/src/corelib/kernel/qsignalmapper.cpp
+++ b/src/corelib/kernel/qsignalmapper.cpp
@@ -121,18 +121,6 @@ QSignalMapper::QSignalMapper(QObject* parent)
{
}
-#ifdef QT3_SUPPORT
-/*!
- \overload QSignalMapper()
- \obsolete
- */
-QSignalMapper::QSignalMapper(QObject *parent, const char *name)
- : QObject(*new QSignalMapperPrivate, parent)
-{
- setObjectName(QString::fromAscii(name));
-}
-#endif
-
/*!
Destroys the QSignalMapper.
*/
diff --git a/src/corelib/kernel/qsignalmapper.h b/src/corelib/kernel/qsignalmapper.h
index c28b9df319..72593679a9 100644
--- a/src/corelib/kernel/qsignalmapper.h
+++ b/src/corelib/kernel/qsignalmapper.h
@@ -85,11 +85,6 @@ public Q_SLOTS:
private:
Q_DISABLE_COPY(QSignalMapper)
Q_PRIVATE_SLOT(d_func(), void _q_senderDestroyed())
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QSignalMapper(QObject *parent, const char *name);
-#endif
};
#endif // QT_NO_SIGNALMAPPER
diff --git a/src/corelib/kernel/qsocketnotifier.cpp b/src/corelib/kernel/qsocketnotifier.cpp
index d59838ba23..5e99d1d483 100644
--- a/src/corelib/kernel/qsocketnotifier.cpp
+++ b/src/corelib/kernel/qsocketnotifier.cpp
@@ -185,40 +185,6 @@ QSocketNotifier::QSocketNotifier(int socket, Type type, QObject *parent)
}
}
-#ifdef QT3_SUPPORT
-/*!
- \obsolete
-
- Use the QSocketNotifier() constructor combined with the
- QObject::setObjectName() function instead.
-
- \oldcode
- QSocketNotifier *notifier = new QSocketNotifier(socket, type, parent, name);
- \newcode
- QSocketNotifier *notifier = new QSocketNotifier(socket, type, parent);
- notifier->setObjectName(name);
- \endcode
-*/
-
-QSocketNotifier::QSocketNotifier(int socket, Type type, QObject *parent,
- const char *name)
- : QObject(parent)
-{
- setObjectName(QString::fromAscii(name));
- if (socket < 0)
- qWarning("QSocketNotifier: Invalid socket specified");
- sockfd = socket;
- sntype = type;
- snenabled = true;
-
- Q_D(QObject);
- if (!d->threadData->eventDispatcher) {
- qWarning("QSocketNotifier: Can only be used with threads started with QThread");
- } else {
- d->threadData->eventDispatcher->registerSocketNotifier(this);
- }
-}
-#endif
/*!
Destroys this socket notifier.
*/
diff --git a/src/corelib/kernel/qsocketnotifier.h b/src/corelib/kernel/qsocketnotifier.h
index 4390d17c62..07dc129825 100644
--- a/src/corelib/kernel/qsocketnotifier.h
+++ b/src/corelib/kernel/qsocketnotifier.h
@@ -59,9 +59,6 @@ public:
enum Type { Read, Write, Exception };
QSocketNotifier(int socket, Type, QObject *parent = 0);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QSocketNotifier(int socket, Type, QObject *parent, const char *name);
-#endif
~QSocketNotifier();
inline int socket() const { return sockfd; }
diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp
index 0edcb3b3ac..5870885c63 100644
--- a/src/corelib/kernel/qtimer.cpp
+++ b/src/corelib/kernel/qtimer.cpp
@@ -147,18 +147,6 @@ QTimer::QTimer(QObject *parent)
}
-#ifdef QT3_SUPPORT
-/*!
- Constructs a timer called \a name, with a \a parent.
-*/
-
-QTimer::QTimer(QObject *parent, const char *name)
- : QObject(parent), id(INV_TIMER), single(0), nulltimer(0)
-{
- setObjectName(QString::fromAscii(name));
-}
-#endif
-
/*!
Destroys the timer.
*/
@@ -235,24 +223,6 @@ void QTimer::start(int msec)
}
-#ifdef QT3_SUPPORT
-/*! \overload start()
-
- Call setSingleShot(\a sshot) and start(\a msec) instead.
-*/
-
-int QTimer::start(int msec, bool sshot)
-{
- if (id >=0 && nulltimer && !msec && sshot)
- return id;
- stop();
- setInterval(msec);
- setSingleShot(sshot);
- start();
- return timerId();
-}
-#endif
-
/*!
Stops the timer.
diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h
index 02f6ba455b..707bc83d3c 100644
--- a/src/corelib/kernel/qtimer.h
+++ b/src/corelib/kernel/qtimer.h
@@ -61,9 +61,6 @@ class Q_CORE_EXPORT QTimer : public QObject
Q_PROPERTY(bool active READ isActive)
public:
explicit QTimer(QObject *parent = 0);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QTimer(QObject *parent, const char *name);
-#endif
~QTimer();
inline bool isActive() const { return id >= 0; }
@@ -83,11 +80,6 @@ public Q_SLOTS:
void start();
void stop();
-#ifdef QT3_SUPPORT
- inline QT_MOC_COMPAT void changeInterval(int msec) { start(msec); }
- QT_MOC_COMPAT int start(int msec, bool sshot);
-#endif
-
Q_SIGNALS:
void timeout();
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index d2554229e2..1b3e06dd69 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -332,18 +332,6 @@ QTranslator::QTranslator(QObject * parent)
{
}
-#ifdef QT3_SUPPORT
-/*!
- \overload QTranslator()
- \obsolete
- */
-QTranslator::QTranslator(QObject * parent, const char * name)
- : QObject(*new QTranslatorPrivate, parent)
-{
- setObjectName(QString::fromAscii(name));
-}
-#endif
-
/*!
Destroys the object and frees any allocated resources.
*/
diff --git a/src/corelib/kernel/qtranslator.h b/src/corelib/kernel/qtranslator.h
index 495137c4cd..0a9bbde953 100644
--- a/src/corelib/kernel/qtranslator.h
+++ b/src/corelib/kernel/qtranslator.h
@@ -61,9 +61,6 @@ class Q_CORE_EXPORT QTranslator : public QObject
Q_OBJECT
public:
explicit QTranslator(QObject *parent = 0);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QTranslator(QObject * parent, const char * name);
-#endif
~QTranslator();
// ### Qt 5: Merge (with "int n = -1")
@@ -85,11 +82,6 @@ public:
const QString & suffix = QString());
bool load(const uchar *data, int len);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT QString find(const char *context, const char *sourceText, const char * comment = 0) const
- { return translate(context, sourceText, comment); }
-#endif
-
private:
Q_DISABLE_COPY(QTranslator)
Q_DECLARE_PRIVATE(QTranslator)
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 7f750b38f2..01e12ee968 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -2886,21 +2886,6 @@ void* QVariant::data()
}
-#ifdef QT3_SUPPORT
-/*! \internal
- */
-void *QVariant::castOrDetach(Type t)
-{
- if (d.type != uint(t)) {
- if (!convert(t))
- create(t, 0);
- } else {
- detach();
- }
- return data();
-}
-#endif
-
/*!
Returns true if this is a NULL variant, false otherwise.
*/
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 6aa0fabc2c..e77fc90b92 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -226,13 +226,6 @@ class Q_CORE_EXPORT QVariant
bool canConvert(Type t) const;
bool convert(Type t);
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT bool canCast(Type t) const
- { return canConvert(t); }
- inline QT3_SUPPORT bool cast(Type t)
- { return convert(t); }
-#endif
-
inline bool isValid() const;
bool isNull() const;
@@ -280,27 +273,6 @@ class Q_CORE_EXPORT QVariant
QEasingCurve toEasingCurve() const;
#endif
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT int &asInt();
- inline QT3_SUPPORT uint &asUInt();
- inline QT3_SUPPORT qlonglong &asLongLong();
- inline QT3_SUPPORT qulonglong &asULongLong();
- inline QT3_SUPPORT bool &asBool();
- inline QT3_SUPPORT double &asDouble();
- inline QT3_SUPPORT QByteArray &asByteArray();
- inline QT3_SUPPORT QBitArray &asBitArray();
- inline QT3_SUPPORT QString &asString();
- inline QT3_SUPPORT QStringList &asStringList();
- inline QT3_SUPPORT QDate &asDate();
- inline QT3_SUPPORT QTime &asTime();
- inline QT3_SUPPORT QDateTime &asDateTime();
- inline QT3_SUPPORT QList<QVariant> &asList();
- inline QT3_SUPPORT QMap<QString,QVariant> &asMap();
- inline QT3_SUPPORT QPoint &asPoint();
- inline QT3_SUPPORT QRect &asRect();
- inline QT3_SUPPORT QSize &asSize();
-#endif //QT3_SUPPORT
-
#ifndef QT_NO_DATASTREAM
void load(QDataStream &ds);
void save(QDataStream &ds) const;
@@ -308,12 +280,6 @@ class Q_CORE_EXPORT QVariant
static const char *typeToName(Type type);
static Type nameToType(const char *name);
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT_CONSTRUCTOR QVariant(bool val, int) { create(Bool, &val); }
- inline QT3_SUPPORT const QByteArray toCString() const { return toByteArray(); }
- inline QT3_SUPPORT QByteArray &asCString() { return *reinterpret_cast<QByteArray *>(castOrDetach(ByteArray)); }
-#endif
-
void *data();
const void *constData() const;
inline const void *data() const { return constData(); }
@@ -412,9 +378,6 @@ protected:
static const Handler *handler;
void create(int type, const void *copy);
-#ifdef QT3_SUPPORT
- void *castOrDetach(Type t);
-#endif
bool cmp(const QVariant &other) const;
private:
@@ -424,10 +387,6 @@ private:
// force compile error when implicit conversion is not wanted
inline QVariant(const char *) { Q_ASSERT(false); }
#endif
-#ifndef QT3_SUPPORT
- // force compile error, prevent QVariant(QVariant::Type, int) to be called
- inline QVariant(bool, int) { Q_ASSERT(false); }
-#endif
public:
typedef Private DataPtr;
inline DataPtr &data_ptr() { return d; }
@@ -477,45 +436,6 @@ inline void qVariantSetValue<QVariant>(QVariant &v, const QVariant &t)
inline QVariant::QVariant() {}
inline bool QVariant::isValid() const { return d.type != Invalid; }
-#ifdef QT3_SUPPORT
-inline int &QVariant::asInt()
-{ return *reinterpret_cast<int *>(castOrDetach(Int)); }
-inline uint &QVariant::asUInt()
-{ return *reinterpret_cast<uint *>(castOrDetach(UInt)); }
-inline qlonglong &QVariant::asLongLong()
-{ return *reinterpret_cast<qlonglong *>(castOrDetach(LongLong)); }
-inline qulonglong &QVariant::asULongLong()
-{ return *reinterpret_cast<qulonglong *>(castOrDetach(ULongLong)); }
-inline bool &QVariant::asBool()
-{ return *reinterpret_cast<bool *>(castOrDetach(Bool)); }
-inline double &QVariant::asDouble()
-{ return *reinterpret_cast<double *>(castOrDetach(Double)); }
-inline QByteArray& QVariant::asByteArray()
-{ return *reinterpret_cast<QByteArray *>(castOrDetach(ByteArray)); }
-inline QBitArray& QVariant::asBitArray()
-{ return *reinterpret_cast<QBitArray *>(castOrDetach(BitArray)); }
-inline QString& QVariant::asString()
-{ return *reinterpret_cast<QString *>(castOrDetach(String)); }
-inline QStringList& QVariant::asStringList()
-{ return *reinterpret_cast<QStringList *>(castOrDetach(StringList)); }
-inline QDate& QVariant::asDate()
-{ return *reinterpret_cast<QDate *>(castOrDetach(Date)); }
-inline QTime& QVariant::asTime()
-{ return *reinterpret_cast<QTime *>(castOrDetach(Time)); }
-inline QDateTime& QVariant::asDateTime()
-{ return *reinterpret_cast<QDateTime *>(castOrDetach(DateTime)); }
-inline QList<QVariant>& QVariant::asList()
-{ return *reinterpret_cast<QList<QVariant> *>(castOrDetach(List)); }
-inline QMap<QString, QVariant>& QVariant::asMap()
-{ return *reinterpret_cast<QMap<QString, QVariant> *>(castOrDetach(Map)); }
-inline QPoint &QVariant::asPoint()
-{ return *reinterpret_cast<QPoint *>(castOrDetach(Point)); }
-inline QRect &QVariant::asRect()
-{ return *reinterpret_cast<QRect *>(castOrDetach(Rect)); }
-inline QSize &QVariant::asSize()
-{ return *reinterpret_cast<QSize *>(castOrDetach(Size)); }
-#endif //QT3_SUPPORT
-
template<typename T>
inline void QVariant::setValue(const T &avalue)
{ qVariantSetValue(*this, avalue); }
diff --git a/src/corelib/plugin/qlibrary.h b/src/corelib/plugin/qlibrary.h
index 72ba054ec7..0154e949b3 100644
--- a/src/corelib/plugin/qlibrary.h
+++ b/src/corelib/plugin/qlibrary.h
@@ -99,10 +99,6 @@ public:
void setLoadHints(LoadHints hints);
LoadHints loadHints() const;
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT QString library() const { return fileName(); }
- inline QT3_SUPPORT void setAutoUnload( bool ) {}
-#endif
private:
QLibraryPrivate *d;
bool did_load;
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index 0f3a72d43f..cc667560db 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -76,20 +76,6 @@ public:
void unlock(); //### Qt5: make inline;
inline void unlockInline();
-#if defined(QT3_SUPPORT)
- inline QT3_SUPPORT bool locked()
- {
- if (!tryLock())
- return true;
- unlock();
- return false;
- }
- inline QT3_SUPPORT_CONSTRUCTOR QMutex(bool recursive)
- {
- new (this) QMutex(recursive ? Recursive : NonRecursive);
- }
-#endif
-
private:
void lockInternal();
void unlockInternal();
@@ -217,10 +203,6 @@ public:
static inline void unlock() {}
static inline void unlockInline() {}
-#if defined(QT3_SUPPORT)
- static inline QT3_SUPPORT bool locked() { return false; }
-#endif
-
private:
Q_DISABLE_COPY(QMutex)
};
diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h
index 878a13c882..bc529fd53b 100644
--- a/src/corelib/thread/qthread.h
+++ b/src/corelib/thread/qthread.h
@@ -116,12 +116,6 @@ protected:
static void msleep(unsigned long);
static void usleep(unsigned long);
-#ifdef QT3_SUPPORT
-public:
- inline QT3_SUPPORT bool finished() const { return isFinished(); }
- inline QT3_SUPPORT bool running() const { return isRunning(); }
-#endif
-
protected:
QThread(QThreadPrivate &dd, QObject *parent = 0);
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index 13df3e6fea..461d93dd50 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -93,6 +93,8 @@ inline bool operator<(const QPostEvent &pe, int priority)
return priority < pe.priority;
}
+// This class holds the list of posted events.
+// The list has to be kept sorted by priority
class QPostEventList : public QList<QPostEvent>
{
public:
@@ -109,6 +111,25 @@ public:
inline QPostEventList()
: QList<QPostEvent>(), recursion(0), startOffset(0), insertionOffset(0)
{ }
+
+ void addEvent(const QPostEvent &ev) {
+ int priority = ev.priority;
+ if (isEmpty() || last().priority >= priority) {
+ // optimization: we can simply append if the last event in
+ // the queue has higher or equal priority
+ append(ev);
+ } else {
+ // insert event in descending priority order, using upper
+ // bound for a given priority (to ensure proper ordering
+ // of events with the same priority)
+ QPostEventList::iterator at = qUpperBound(begin() + insertionOffset, end(), priority);
+ insert(at, ev);
+ }
+ }
+private:
+ //hides because they do not keep that list sorted. addEvent must be used
+ using QList<QPostEvent>::append;
+ using QList<QPostEvent>::insert;
};
#ifndef QT_NO_THREAD
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index 2cb79c3f51..9f54f1a831 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -110,19 +110,6 @@ Q_CORE_EXPORT int qstrnicmp(const char *, const char *, uint len);
Q_CORE_EXPORT int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap);
Q_CORE_EXPORT int qsnprintf(char *str, size_t n, const char *fmt, ...);
-#ifdef QT3_SUPPORT
-inline QT3_SUPPORT void *qmemmove(void *dst, const void *src, uint len)
-{ return memmove(dst, src, len); }
-inline QT3_SUPPORT uint cstrlen(const char *str)
-{ return uint(strlen(str)); }
-inline QT3_SUPPORT char *cstrcpy(char *dst, const char *src)
-{ return qstrcpy(dst,src); }
-inline QT3_SUPPORT int cstrcmp(const char *str1, const char *str2)
-{ return strcmp(str1,str2); }
-inline QT3_SUPPORT int cstrncmp(const char *str1, const char *str2, uint len)
-{ return strncmp(str1,str2,len); }
-#endif
-
// qChecksum: Internet checksum
Q_CORE_EXPORT quint16 qChecksum(const char *s, uint len);
@@ -234,13 +221,6 @@ public:
QByteArray leftJustified(int width, char fill = ' ', bool truncate = false) const;
QByteArray rightJustified(int width, char fill = ' ', bool truncate = false) const;
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT QByteArray leftJustify(uint width, char aFill = ' ', bool aTruncate = false) const
- { return leftJustified(int(width), aFill, aTruncate); }
- inline QT3_SUPPORT QByteArray rightJustify(uint width, char aFill = ' ', bool aTruncate = false) const
- { return rightJustified(int(width), aFill, aTruncate); }
-#endif
-
QByteArray &prepend(char c);
QByteArray &prepend(const char *s);
QByteArray &prepend(const char *s, int len);
@@ -356,29 +336,6 @@ public:
int length() const { return d->size; }
bool isNull() const;
- // compatibility
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QByteArray(int size);
- inline QT3_SUPPORT QByteArray& duplicate(const QByteArray& a) { *this = a; return *this; }
- inline QT3_SUPPORT QByteArray& duplicate(const char *a, uint n)
- { *this = QByteArray(a, n); return *this; }
- inline QT3_SUPPORT void resetRawData(const char *, uint) { clear(); }
- inline QT3_SUPPORT QByteArray lower() const { return toLower(); }
- inline QT3_SUPPORT QByteArray upper() const { return toUpper(); }
- inline QT3_SUPPORT QByteArray stripWhiteSpace() const { return trimmed(); }
- inline QT3_SUPPORT QByteArray simplifyWhiteSpace() const { return simplified(); }
- inline QT3_SUPPORT int find(char c, int from = 0) const { return indexOf(c, from); }
- inline QT3_SUPPORT int find(const char *c, int from = 0) const { return indexOf(c, from); }
- inline QT3_SUPPORT int find(const QByteArray &ba, int from = 0) const { return indexOf(ba, from); }
- inline QT3_SUPPORT int findRev(char c, int from = -1) const { return lastIndexOf(c, from); }
- inline QT3_SUPPORT int findRev(const char *c, int from = -1) const { return lastIndexOf(c, from); }
- inline QT3_SUPPORT int findRev(const QByteArray &ba, int from = -1) const { return lastIndexOf(ba, from); }
-#ifndef QT_NO_CAST_TO_ASCII
- QT3_SUPPORT int find(const QString &s, int from = 0) const;
- QT3_SUPPORT int findRev(const QString &s, int from = -1) const;
-#endif
-#endif
-
private:
operator QNoImplicitBoolCast() const;
static Data shared_null;
@@ -438,10 +395,6 @@ inline bool QByteArray::isDetached() const
{ return d->ref == 1; }
inline QByteArray::QByteArray(const QByteArray &a) : d(a.d)
{ d->ref.ref(); }
-#ifdef QT3_SUPPORT
-inline QByteArray::QByteArray(int aSize) : d(&shared_null)
-{ d->ref.ref(); if (aSize > 0) fill('\0', aSize); }
-#endif
inline int QByteArray::capacity() const
{ return d->alloc; }
diff --git a/src/corelib/tools/qcache.h b/src/corelib/tools/qcache.h
index 16861c9869..c42a908f5c 100644
--- a/src/corelib/tools/qcache.h
+++ b/src/corelib/tools/qcache.h
@@ -96,10 +96,6 @@ class QCache
public:
inline explicit QCache(int maxCost = 100);
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT_CONSTRUCTOR QCache(int maxCost, int /* dummy */)
- : f(0), l(0), mx(maxCost), total(0) {}
-#endif
inline ~QCache() { clear(); }
inline int maxCost() const { return mx; }
@@ -123,11 +119,6 @@ public:
private:
void trim(int m);
-
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT T *find(const Key &key) const { return object(key); }
-#endif
-
};
template <class Key, class T>
diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h
index 3ec53bd18e..b7793403bd 100644
--- a/src/corelib/tools/qchar.h
+++ b/src/corelib/tools/qchar.h
@@ -89,13 +89,6 @@ public:
ObjectReplacementCharacter = 0xfffc,
ByteOrderMark = 0xfeff,
ByteOrderSwapped = 0xfffe,
-#ifdef QT3_SUPPORT
- null = Null,
- replacement = ReplacementCharacter,
- byteOrderMark = ByteOrderMark,
- byteOrderSwapped = ByteOrderSwapped,
- nbsp = Nbsp,
-#endif
ParagraphSeparator = 0x2029,
LineSeparator = 0x2028
};
@@ -173,10 +166,6 @@ public:
Square,
Compat,
Fraction
-
-#ifdef QT3_SUPPORT
- , Single = NoDecomposition
-#endif
};
enum Joining
@@ -338,22 +327,6 @@ public:
static QString QT_FASTCALL decomposition(uint ucs4);
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT bool mirrored() const { return hasMirrored(); }
- inline QT3_SUPPORT QChar lower() const { return toLower(); }
- inline QT3_SUPPORT QChar upper() const { return toUpper(); }
- static inline QT3_SUPPORT bool networkOrdered() {
- return QSysInfo::ByteOrder == QSysInfo::BigEndian;
- }
-#ifdef Q_COMPILER_MANGLES_RETURN_TYPE
- inline QT3_SUPPORT const char latin1() const { return toLatin1(); }
- inline QT3_SUPPORT const char ascii() const { return toAscii(); }
-#else
- inline QT3_SUPPORT char latin1() const { return toLatin1(); }
- inline QT3_SUPPORT char ascii() const { return toAscii(); }
-#endif
-#endif
-
private:
#ifdef QT_NO_CAST_FROM_ASCII
QChar(char c);
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index be14df7841..62bdcab7cc 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -76,10 +76,6 @@ public:
int weekNumber(int *yearNum = 0) const;
#ifndef QT_NO_TEXTDATE
-#ifdef QT3_SUPPORT
- static QT3_SUPPORT QString monthName(int month) { return shortMonthName(month); }
- static QT3_SUPPORT QString dayName(int weekday) { return shortDayName(weekday); }
-#endif
// ### Qt 5: merge these functions.
static QString shortMonthName(int month);
static QString shortMonthName(int month, MonthNameType type);
@@ -118,18 +114,11 @@ public:
#endif
static bool isValid(int y, int m, int d);
static bool isLeapYear(int year);
-#ifdef QT3_SUPPORT
- inline static QT3_SUPPORT bool leapYear(int year) { return isLeapYear(year); }
-#endif
// ### Qt 5: remove these two functions
static uint gregorianToJulian(int y, int m, int d);
static void julianToGregorian(uint jd, int &y, int &m, int &d);
-#ifdef QT3_SUPPORT
- static QT3_SUPPORT QDate currentDate(Qt::TimeSpec spec);
-#endif
-
static inline QDate fromJulianDay(int jd) { QDate d; d.jd = jd; return d; }
inline int toJulianDay() const { return jd; }
@@ -187,10 +176,6 @@ public:
#endif
static bool isValid(int h, int m, int s, int ms = 0);
-#ifdef QT3_SUPPORT
- static QT3_SUPPORT QTime currentTime(Qt::TimeSpec spec);
-#endif
-
void start();
int restart();
int elapsed() const;
@@ -273,21 +258,6 @@ public:
static QDateTime fromMSecsSinceEpoch(qint64 msecs);
static qint64 currentMSecsSinceEpoch();
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT void setTime_t(uint secsSince1Jan1970UTC, Qt::TimeSpec spec) {
- setTime_t(secsSince1Jan1970UTC);
- if (spec == Qt::UTC)
- *this = toUTC();
- }
- static inline QT3_SUPPORT QDateTime currentDateTime(Qt::TimeSpec spec) {
- if (spec == Qt::LocalTime)
- return currentDateTime();
- else
- return currentDateTime().toUTC();
- }
-
-#endif
-
private:
friend class QDateTimePrivate;
void detach();
@@ -300,24 +270,6 @@ private:
};
Q_DECLARE_TYPEINFO(QDateTime, Q_MOVABLE_TYPE);
-#ifdef QT3_SUPPORT
-inline QDate QDate::currentDate(Qt::TimeSpec spec)
-{
- if (spec == Qt::LocalTime)
- return currentDate();
- else
- return QDateTime::currentDateTime().toUTC().date();
-}
-
-inline QTime QTime::currentTime(Qt::TimeSpec spec)
-{
- if (spec == Qt::LocalTime)
- return currentTime();
- else
- return QDateTime::currentDateTime().toUTC().time();
-}
-#endif
-
#ifndef QT_NO_DATASTREAM
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QDate &);
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QDate &);
diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h
index 18afb29e9e..9f2834a7d7 100644
--- a/src/corelib/tools/qlinkedlist.h
+++ b/src/corelib/tools/qlinkedlist.h
@@ -227,21 +227,6 @@ public:
{ std::list<T> tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
#endif
-#ifdef QT3_SUPPORT
- // compatibility
- inline QT3_SUPPORT iterator remove(iterator pos) { return erase(pos); }
- inline QT3_SUPPORT int findIndex(const T& t) const
- { int i=0; for (const_iterator it = begin(); it != end(); ++it, ++i) if(*it == t) return i; return -1;}
- inline QT3_SUPPORT iterator find(iterator from, const T& t)
- { while (from != end() && !(*from == t)) ++from; return from; }
- inline QT3_SUPPORT iterator find(const T& t)
- { return find(begin(), t); }
- inline QT3_SUPPORT const_iterator find(const_iterator from, const T& t) const
- { while (from != end() && !(*from == t)) ++from; return from; }
- inline QT3_SUPPORT const_iterator find(const T& t) const
- { return find(begin(), t); }
-#endif
-
// comfort
QLinkedList<T> &operator+=(const QLinkedList<T> &l);
QLinkedList<T> operator+(const QLinkedList<T> &l) const;
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 4eb05d63b6..f8f62cc8b2 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -310,20 +310,6 @@ public:
typedef const value_type &const_reference;
typedef qptrdiff difference_type;
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT iterator remove(iterator pos) { return erase(pos); }
- inline QT3_SUPPORT int remove(const T &t) { return removeAll(t); }
- inline QT3_SUPPORT int findIndex(const T& t) const { return indexOf(t); }
- inline QT3_SUPPORT iterator find(const T& t)
- { int i = indexOf(t); return (i == -1 ? end() : (begin()+i)); }
- inline QT3_SUPPORT const_iterator find (const T& t) const
- { int i = indexOf(t); return (i == -1 ? end() : (begin()+i)); }
- inline QT3_SUPPORT iterator find(iterator from, const T& t)
- { int i = indexOf(t, from - begin()); return i == -1 ? end() : begin()+i; }
- inline QT3_SUPPORT const_iterator find(const_iterator from, const T& t) const
- { int i = indexOf(t, from - begin()); return i == -1 ? end() : begin()+i; }
-#endif
-
// comfort
QList<T> &operator+=(const QList<T> &l);
inline QList<T> operator+(const QList<T> &l) const
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index 39b3eb8af1..36d8eefbdb 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -249,9 +249,6 @@ public:
inline const Key &key() const { return concrete(i)->key; }
inline T &value() const { return concrete(i)->value; }
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT T &data() const { return concrete(i)->value; }
-#endif
inline T &operator*() const { return concrete(i)->value; }
inline T *operator->() const { return &concrete(i)->value; }
inline bool operator==(const iterator &o) const { return i == o.i; }
@@ -323,9 +320,6 @@ public:
inline const Key &key() const { return concrete(i)->key; }
inline const T &value() const { return concrete(i)->value; }
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT const T &data() const { return concrete(i)->value; }
-#endif
inline const T &operator*() const { return concrete(i)->value; }
inline const T *operator->() const { return &concrete(i)->value; }
inline bool operator==(const const_iterator &o) const { return i == o.i; }
@@ -379,10 +373,6 @@ public:
inline const_iterator end() const { return const_iterator(e); }
inline const_iterator constEnd() const { return const_iterator(e); }
iterator erase(iterator it);
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT iterator remove(iterator it) { return erase(it); }
- inline QT3_SUPPORT void erase(const Key &aKey) { remove(aKey); }
-#endif
// more Qt
typedef iterator Iterator;
@@ -396,13 +386,7 @@ public:
iterator upperBound(const Key &key);
const_iterator upperBound(const Key &key) const;
iterator insert(const Key &key, const T &value);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT iterator insert(const Key &key, const T &value, bool overwrite);
-#endif
iterator insertMulti(const Key &key, const T &value);
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT iterator replace(const Key &aKey, const T &aValue) { return insert(aKey, aValue); }
-#endif
QMap<Key, T> &unite(const QMap<Key, T> &other);
// STL compatibility
@@ -571,26 +555,6 @@ Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::insert(const Key
return iterator(node);
}
-#ifdef QT3_SUPPORT
-template <class Key, class T>
-Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::insert(const Key &akey,
- const T &avalue,
- bool aoverwrite)
-{
- detach();
-
- QMapData::Node *update[QMapData::LastLevel + 1];
- QMapData::Node *node = mutableFindNode(update, akey);
- if (node == e) {
- node = node_create(d, update, akey, avalue);
- } else {
- if (aoverwrite)
- concrete(node)->value = avalue;
- }
- return iterator(node);
-}
-#endif
-
template <class Key, class T>
Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::insertMulti(const Key &akey,
const T &avalue)
diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h
index cbed04f628..5d6db9867e 100644
--- a/src/corelib/tools/qrect.h
+++ b/src/corelib/tools/qrect.h
@@ -73,15 +73,6 @@ public:
int bottom() const;
QRect normalized() const;
-#ifdef QT3_SUPPORT
- QT3_SUPPORT int &rLeft() { return x1; }
- QT3_SUPPORT int &rTop() { return y1; }
- QT3_SUPPORT int &rRight() { return x2; }
- QT3_SUPPORT int &rBottom() { return y2; }
-
- QT3_SUPPORT QRect normalize() const { return normalized(); }
-#endif
-
int x() const;
int y() const;
void setLeft(int pos);
@@ -120,18 +111,10 @@ public:
void moveTo(int x, int t);
void moveTo(const QPoint &p);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT void moveBy(int dx, int dy) { translate(dx, dy); }
- QT3_SUPPORT void moveBy(const QPoint &p) { translate(p); }
-#endif
-
void setRect(int x, int y, int w, int h);
inline void getRect(int *x, int *y, int *w, int *h) const;
void setCoords(int x1, int y1, int x2, int y2);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT void addCoords(int x1, int y1, int x2, int y2);
-#endif
inline void getCoords(int *x1, int *y1, int *x2, int *y2) const;
inline void adjust(int x1, int y1, int x2, int y2);
@@ -162,12 +145,6 @@ public:
friend Q_CORE_EXPORT_INLINE bool operator==(const QRect &, const QRect &);
friend Q_CORE_EXPORT_INLINE bool operator!=(const QRect &, const QRect &);
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT void rect(int *x, int *y, int *w, int *h) const { getRect(x, y, w, h); }
- inline QT3_SUPPORT void coords(int *ax1, int *ay1, int *ax2, int *ay2) const
- { getCoords(ax1, ay1, ax2, ay2); }
-#endif
-
private:
#if defined(Q_WS_X11)
friend void qt_setCoords(QRect *r, int xp1, int yp1, int xp2, int yp2);
@@ -421,13 +398,6 @@ inline void QRect::setCoords(int xp1, int yp1, int xp2, int yp2)
y2 = yp2;
}
-#ifdef QT3_SUPPORT
-inline void QRect::addCoords(int dx1, int dy1, int dx2, int dy2)
-{
- adjust(dx1, dy1, dx2, dy2);
-}
-#endif
-
inline QRect QRect::adjusted(int xp1, int yp1, int xp2, int yp2) const
{ return QRect(QPoint(x1 + xp1, y1 + yp1), QPoint(x2 + xp2, y2 + yp2)); }
diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h
index 12e42a95b7..4ce2f6e0be 100644
--- a/src/corelib/tools/qregexp.h
+++ b/src/corelib/tools/qregexp.h
@@ -45,9 +45,6 @@
#ifndef QT_NO_REGEXP
#include <QtCore/qstring.h>
-#ifdef QT3_SUPPORT
-#include <new>
-#endif
QT_BEGIN_HEADER
@@ -91,37 +88,16 @@ public:
void setPattern(const QString &pattern);
Qt::CaseSensitivity caseSensitivity() const;
void setCaseSensitivity(Qt::CaseSensitivity cs);
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT bool caseSensitive() const { return caseSensitivity() == Qt::CaseSensitive; }
- inline QT3_SUPPORT void setCaseSensitive(bool sensitive)
- { setCaseSensitivity(sensitive ? Qt::CaseSensitive : Qt::CaseInsensitive); }
-#endif
PatternSyntax patternSyntax() const;
void setPatternSyntax(PatternSyntax syntax);
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT bool wildcard() const { return patternSyntax() == Wildcard; }
- inline QT3_SUPPORT void setWildcard(bool aWildcard)
- { setPatternSyntax(aWildcard ? Wildcard : RegExp); }
-#endif
bool isMinimal() const;
void setMinimal(bool minimal);
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT bool minimal() const { return isMinimal(); }
-#endif
bool exactMatch(const QString &str) const;
int indexIn(const QString &str, int offset = 0, CaretMode caretMode = CaretAtZero) const;
int lastIndexIn(const QString &str, int offset = -1, CaretMode caretMode = CaretAtZero) const;
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT int search(const QString &str, int from = 0,
- CaretMode caretMode = CaretAtZero) const
- { return indexIn(str, from, caretMode); }
- inline QT3_SUPPORT int searchRev(const QString &str, int from = -1,
- CaretMode caretMode = CaretAtZero) const
- { return lastIndexIn(str, from, caretMode); }
-#endif
int matchedLength() const;
#ifndef QT_NO_REGEXP_CAPTURE
#ifdef QT_DEPRECATED
@@ -140,15 +116,6 @@ public:
static QString escape(const QString &str);
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT_CONSTRUCTOR QRegExp(const QString &aPattern, bool cs, bool aWildcard = false)
- {
- new (this)
- QRegExp(aPattern, cs ? Qt::CaseSensitive : Qt::CaseInsensitive,
- aWildcard ? Wildcard : RegExp);
- }
-#endif
-
private:
QRegExpPrivate *priv;
};
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index b15bcacd97..a24f62e7ba 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -208,8 +208,10 @@ template <typename T, typename Cleanup = QScopedPointerArrayDeleter<T> >
class QScopedArrayPointer : public QScopedPointer<T, Cleanup>
{
public:
+ inline QScopedArrayPointer() : QScopedPointer<T, Cleanup>(0) {}
+
template <typename D>
- explicit inline QScopedArrayPointer(D *p = 0, typename QtPrivate::QScopedArrayEnsureSameType<T,D>::Type = 0)
+ explicit inline QScopedArrayPointer(D *p, typename QtPrivate::QScopedArrayEnsureSameType<T,D>::Type = 0)
: QScopedPointer<T, Cleanup>(p)
{
}
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index e27afb8586..afb396ce50 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -102,10 +102,6 @@ QT_BEGIN_NAMESPACE
QTextCodec *QString::codecForCStrings;
#endif
-#ifdef QT3_SUPPORT
-static QHash<void *, QByteArray> *asciiCache = 0;
-#endif
-
#ifdef QT_USE_ICU
// qlocale_icu.cpp
extern bool qt_ucol_strcoll(const QChar *source, int sourceLength, const QChar *target, int targetLength, int *result);
@@ -802,9 +798,9 @@ const QString::Null QString::null = { };
*/
QString::Data QString::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1),
- 0, 0, shared_null.array, 0, 0, 0, 0, 0, 0, {0} };
+ 0, 0, shared_null.array, 0, 0, 0, 0, 0, {0} };
QString::Data QString::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1),
- 0, 0, shared_empty.array, 0, 0, 0, 0, 0, 0, {0} };
+ 0, 0, shared_empty.array, 0, 0, 0, 0, 0, {0} };
int QString::grow(int size)
{
@@ -1058,7 +1054,7 @@ QString::QString(const QChar *unicode, int size)
Q_CHECK_PTR(d);
d->ref = 1;
d->alloc = d->size = size;
- d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
+ d->clean = d->simpletext = d->righttoleft = d->capacity = 0;
d->data = d->array;
memcpy(d->array, unicode, size * sizeof(QChar));
d->array[size] = '\0';
@@ -1091,7 +1087,7 @@ QString::QString(const QChar *unicode)
Q_CHECK_PTR(d);
d->ref = 1;
d->alloc = d->size = size;
- d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
+ d->clean = d->simpletext = d->righttoleft = d->capacity = 0;
d->data = d->array;
memcpy(d->array, unicode, size * sizeof(QChar));
d->array[size] = '\0';
@@ -1116,7 +1112,7 @@ QString::QString(int size, QChar ch)
Q_CHECK_PTR(d);
d->ref = 1;
d->alloc = d->size = size;
- d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
+ d->clean = d->simpletext = d->righttoleft = d->capacity = 0;
d->data = d->array;
d->array[size] = '\0';
ushort *i = d->array + size;
@@ -1139,7 +1135,7 @@ QString::QString(int size, Qt::Initialization)
Q_CHECK_PTR(d);
d->ref = 1;
d->alloc = d->size = size;
- d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
+ d->clean = d->simpletext = d->righttoleft = d->capacity = 0;
d->data = d->array;
d->array[size] = '\0';
}
@@ -1161,7 +1157,7 @@ QString::QString(QChar ch)
d = reinterpret_cast<Data *>(buf);
d->ref = 1;
d->alloc = d->size = 1;
- d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
+ d->clean = d->simpletext = d->righttoleft = d->capacity = 0;
d->data = d->array;
d->array[0] = ch.unicode();
d->array[1] = '\0';
@@ -1222,12 +1218,6 @@ QString::QString(QChar ch)
// ### Qt 5: rename freeData() to avoid confusion. See task 197625.
void QString::free(Data *d)
{
-#ifdef QT3_SUPPORT
- if (d->asciiCache) {
- Q_ASSERT(asciiCache);
- asciiCache->remove(d);
- }
-#endif
qFree(d);
}
@@ -1344,7 +1334,6 @@ void QString::realloc(int alloc)
x->size = qMin(alloc, d->size);
::memcpy(x->array, d->data, x->size * sizeof(QChar));
x->array[x->size] = 0;
- x->asciiCache = 0;
x->ref = 1;
x->alloc = alloc;
x->clean = d->clean;
@@ -1356,12 +1345,6 @@ void QString::realloc(int alloc)
QString::free(d);
d = x;
} else {
-#ifdef QT3_SUPPORT
- if (d->asciiCache) {
- Q_ASSERT(asciiCache);
- asciiCache->remove(d);
- }
-#endif
Data *p = static_cast<Data *>(qRealloc(d, sizeof(Data) + alloc * sizeof(QChar)));
Q_CHECK_PTR(p);
d = p;
@@ -3794,7 +3777,7 @@ QString::Data *QString::fromLatin1_helper(const char *str, int size)
Q_CHECK_PTR(d);
d->ref = 1;
d->alloc = d->size = size;
- d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
+ d->clean = d->simpletext = d->righttoleft = d->capacity = 0;
d->data = d->array;
d->array[size] = '\0';
ushort *dst = d->data;
@@ -3868,44 +3851,6 @@ QString QString::fromLatin1(const char *str, int size)
}
-#ifdef QT3_SUPPORT
-
-/*!
- \internal
-*/
-const char *QString::ascii_helper() const
-{
- if (!asciiCache)
- asciiCache = new QHash<void *, QByteArray>();
-
- d->asciiCache = true;
- QByteArray ascii = toAscii();
- QByteArray old = asciiCache->value(d);
- if (old == ascii)
- return old.constData();
- asciiCache->insert(d, ascii);
- return ascii.constData();
-}
-
-/*!
- \internal
-*/
-const char *QString::latin1_helper() const
-{
- if (!asciiCache)
- asciiCache = new QHash<void *, QByteArray>();
-
- d->asciiCache = true;
- QByteArray ascii = toLatin1();
- QByteArray old = asciiCache->value(d);
- if (old == ascii)
- return old.constData();
- asciiCache->insert(d, ascii);
- return ascii.constData();
-}
-
-#endif
-
/*!
Returns a QString initialized with the first \a size characters
of the 8-bit string \a str.
@@ -4636,25 +4581,16 @@ QString& QString::fill(QChar ch, int size)
sensitivity setting \a cs.
*/
+
/*!
\overload compare()
+ \since 4.2
Lexically compares this string with the \a other string and
returns an integer less than, equal to, or greater than zero if
this string is less than, equal to, or greater than the other
string.
- Equivalent to \c {compare(*this, other)}.
-*/
-int QString::compare(const QString &other) const
-{
- return ucstrcmp(constData(), length(), other.constData(), other.length());
-}
-
-/*!
- \overload compare()
- \since 4.2
-
Same as compare(*this, \a other, \a cs).
*/
int QString::compare(const QString &other, Qt::CaseSensitivity cs) const
@@ -7196,7 +7132,7 @@ QString QString::fromRawData(const QChar *unicode, int size)
x->ref = 1;
x->alloc = x->size = size;
*x->array = '\0';
- x->clean = x->asciiCache = x->simpletext = x->righttoleft = x->capacity = 0;
+ x->clean = x->simpletext = x->righttoleft = x->capacity = 0;
return QString(x, 0);
}
@@ -7219,12 +7155,6 @@ QString &QString::setRawData(const QChar *unicode, int size)
if (d->ref != 1 || (d->data == d->array && d->alloc)) {
*this = fromRawData(unicode, size);
} else {
-#ifdef QT3_SUPPORT
- if (d->asciiCache) {
- Q_ASSERT(asciiCache);
- asciiCache->remove(d);
- }
-#endif
if (unicode) {
d->data = (ushort *)unicode;
} else {
@@ -7233,7 +7163,7 @@ QString &QString::setRawData(const QChar *unicode, int size)
}
d->alloc = d->size = size;
*d->array = '\0';
- d->clean = d->asciiCache = d->simpletext = d->righttoleft = d->capacity = 0;
+ d->clean = d->simpletext = d->righttoleft = d->capacity = 0;
}
return *this;
}
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index c61d09e37d..154012d132 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -46,9 +46,6 @@
#include <QtCore/qbytearray.h>
#include <QtCore/qatomic.h>
#include <QtCore/qnamespace.h>
-#ifdef QT_INCLUDE_COMPAT
-#include <Qt3Support/q3cstring.h>
-#endif
#ifndef QT_NO_STL
# include <string>
@@ -340,16 +337,10 @@ public:
QString &setUnicode(const QChar *unicode, int size);
inline QString &setUtf16(const ushort *utf16, int size);
- // ### Qt 5: merge these two functions
- int compare(const QString &s) const;
- int compare(const QString &s, Qt::CaseSensitivity cs) const;
-
+ int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
int compare(const QLatin1String &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
- // ### Qt 5: merge these two functions
- static inline int compare(const QString &s1, const QString &s2)
- { return s1.compare(s2); }
- static inline int compare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs)
+ static inline int compare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive)
{ return s1.compare(s2, cs); }
static inline int compare(const QString& s1, const QLatin1String &s2,
@@ -504,86 +495,6 @@ public:
inline QString &operator=(const Null &) { *this = QString(); return *this; }
inline bool isNull() const { return d == &shared_null; }
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT const char *ascii() const { return ascii_helper(); }
- inline QT3_SUPPORT const char *latin1() const { return latin1_helper(); }
- inline QT3_SUPPORT QByteArray utf8() const { return toUtf8(); }
- inline QT3_SUPPORT QByteArray local8Bit() const{ return toLocal8Bit(); }
- inline QT3_SUPPORT void setLength(int nl) { resize(nl); }
- inline QT3_SUPPORT QString copy() const { return *this; }
- inline QT3_SUPPORT QString &remove(QChar c, bool cs)
- { return remove(c, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
- inline QT3_SUPPORT QString &remove(const QString &s, bool cs)
- { return remove(s, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
- inline QT3_SUPPORT QString &replace(QChar c, const QString &after, bool cs)
- { return replace(c, after, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
- inline QT3_SUPPORT QString &replace(const QString &before, const QString &after, bool cs)
- { return replace(before, after, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
-#ifndef QT_NO_CAST_FROM_ASCII
- inline QT3_SUPPORT QString &replace(char c, const QString &after, bool cs)
- { return replace(QChar::fromAscii(c), after, cs ? Qt::CaseSensitive : Qt::CaseInsensitive); }
- // strange overload, required to avoid GCC 3.3 error
- inline QT3_SUPPORT QString &replace(char c, const QString &after, Qt::CaseSensitivity cs)
- { return replace(QChar::fromAscii(c), after, cs ? Qt::CaseSensitive : Qt::CaseInsensitive); }
-#endif
- inline QT3_SUPPORT int find(QChar c, int i = 0, bool cs = true) const
- { return indexOf(c, i, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
- inline QT3_SUPPORT int find(const QString &s, int i = 0, bool cs = true) const
- { return indexOf(s, i, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
- inline QT3_SUPPORT int findRev(QChar c, int i = -1, bool cs = true) const
- { return lastIndexOf(c, i, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
- inline QT3_SUPPORT int findRev(const QString &s, int i = -1, bool cs = true) const
- { return lastIndexOf(s, i, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
-#ifndef QT_NO_REGEXP
- inline QT3_SUPPORT int find(const QRegExp &rx, int i=0) const
- { return indexOf(rx, i); }
- inline QT3_SUPPORT int findRev(const QRegExp &rx, int i=-1) const
- { return lastIndexOf(rx, i); }
- inline QT3_SUPPORT int find(QRegExp &rx, int i=0) const
- { return indexOf(rx, i); }
- inline QT3_SUPPORT int findRev(QRegExp &rx, int i=-1) const
- { return lastIndexOf(rx, i); }
-#endif
- inline QT3_SUPPORT QBool contains(QChar c, bool cs) const
- { return contains(c, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
- inline QT3_SUPPORT QBool contains(const QString &s, bool cs) const
- { return contains(s, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
- inline QT3_SUPPORT bool startsWith(const QString &s, bool cs) const
- { return startsWith(s, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
- inline QT3_SUPPORT bool endsWith(const QString &s, bool cs) const
- { return endsWith(s, cs?Qt::CaseSensitive:Qt::CaseInsensitive); }
- inline QT3_SUPPORT QChar constref(uint i) const
- { return at(i); }
- QT3_SUPPORT QChar &ref(uint i);
- inline QT3_SUPPORT QString leftJustify(int width, QChar aFill = QLatin1Char(' '), bool trunc=false) const
- { return leftJustified(width, aFill, trunc); }
- inline QT3_SUPPORT QString rightJustify(int width, QChar aFill = QLatin1Char(' '), bool trunc=false) const
- { return rightJustified(width, aFill, trunc); }
- inline QT3_SUPPORT QString lower() const { return toLower(); }
- inline QT3_SUPPORT QString upper() const { return toUpper(); }
- inline QT3_SUPPORT QString stripWhiteSpace() const { return trimmed(); }
- inline QT3_SUPPORT QString simplifyWhiteSpace() const { return simplified(); }
- inline QT3_SUPPORT QString &setUnicodeCodes(const ushort *unicode_as_ushorts, int aSize)
- { return setUtf16(unicode_as_ushorts, aSize); }
- inline QT3_SUPPORT const ushort *ucs2() const { return utf16(); }
- inline static QT3_SUPPORT QString fromUcs2(const ushort *unicode, int size = -1)
- { return fromUtf16(unicode, size); }
- inline QT3_SUPPORT QString &setAscii(const char *str, int len = -1)
- { *this = fromAscii(str, len); return *this; }
- inline QT3_SUPPORT QString &setLatin1(const char *str, int len = -1)
- { *this = fromLatin1(str, len); return *this; }
-protected:
- friend class QObject;
- const char *ascii_helper() const;
- const char *latin1_helper() const;
-public:
-#ifndef QT_NO_CAST_TO_ASCII
- inline QT3_SUPPORT operator const char *() const { return ascii_helper(); }
-private:
- QT3_SUPPORT operator QNoImplicitBoolCast() const;
-public:
-#endif
-#endif
bool isSimpleText() const { if (!d->clean) updateProperties(); return d->simpletext; }
bool isRightToLeft() const;
@@ -607,7 +518,6 @@ private:
ushort clean : 1;
ushort simpletext : 1;
ushort righttoleft : 1;
- ushort asciiCache : 1;
ushort capacity : 1;
ushort reserved : 11;
// ### Qt5: try to ensure that "array" is aligned to 16 bytes on both 32- and 64-bit
@@ -857,18 +767,6 @@ public:
#endif
ushort& unicode() { return s.data()[i].unicode(); }
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT bool mirrored() const { return hasMirrored(); }
- inline QT3_SUPPORT QChar lower() const { return QChar(*this).toLower(); }
- inline QT3_SUPPORT QChar upper() const { return QChar(*this).toUpper(); }
-#ifdef Q_COMPILER_MANGLES_RETURN_TYPE
- const QT3_SUPPORT char latin1() const { return QChar(*this).toLatin1(); }
- const QT3_SUPPORT char ascii() const { return QChar(*this).toAscii(); }
-#else
- QT3_SUPPORT char latin1() const { return QChar(*this).toLatin1(); }
- QT3_SUPPORT char ascii() const { return QChar(*this).toAscii(); }
-#endif
-#endif
};
inline void QCharRef::setRow(uchar arow) { QChar(*this).setRow(arow); }
@@ -1008,12 +906,6 @@ inline int QByteArray::indexOf(const QString &s, int from) const
{ return indexOf(s.toAscii(), from); }
inline int QByteArray::lastIndexOf(const QString &s, int from) const
{ return lastIndexOf(s.toAscii(), from); }
-# ifdef QT3_SUPPORT
-inline int QByteArray::find(const QString &s, int from) const
-{ return indexOf(s.toAscii(), from); }
-inline int QByteArray::findRev(const QString &s, int from) const
-{ return lastIndexOf(s.toAscii(), from); }
-# endif // QT3_SUPPORT
#endif // QT_NO_CAST_TO_ASCII
#if !defined(QT_USE_FAST_OPERATOR_PLUS) && !defined(QT_USE_QSTRINGBUILDER)
@@ -1066,30 +958,11 @@ inline QString QString::fromStdWString(const QStdWString &s)
# endif
#endif
-#ifdef QT3_SUPPORT
-inline QChar &QString::ref(uint i)
-{
- if (int(i) > d->size || d->ref != 1)
- resize(qMax(int(i), d->size));
- return reinterpret_cast<QChar&>(d->data[i]);
-}
-#endif
-
#if !defined(QT_NO_DATASTREAM) || (defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE))
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QString &);
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QString &);
#endif
-#ifdef QT3_SUPPORT
-class QConstString : public QString
-{
-public:
- inline QT3_SUPPORT_CONSTRUCTOR QConstString(const QChar *aUnicode, int aSize)
- :QString(aUnicode, aSize){} // cannot use fromRawData() due to changed semantics
- inline QT3_SUPPORT const QString &string() const { return *this; }
-};
-#endif
-
Q_DECLARE_TYPEINFO(QString, Q_MOVABLE_TYPE);
Q_DECLARE_SHARED(QString)
Q_DECLARE_OPERATORS_FOR_FLAGS(QString::SectionFlags)
diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp
index 45de6bc1c3..1cc7e5d2c3 100644
--- a/src/corelib/tools/qstringbuilder.cpp
+++ b/src/corelib/tools/qstringbuilder.cpp
@@ -162,6 +162,8 @@ void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out
}
#endif
if (len == -1) {
+ if (!a)
+ return;
while (*a)
*out++ = QLatin1Char(*a++);
} else {
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index 709d84a578..594ab2f183 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -352,6 +352,8 @@ template <> struct QConcatenable<const char *> : private QAbstractConcatenable
#endif
static inline void appendTo(const char *a, char *&out)
{
+ if (!a)
+ return;
while (*a)
*out++ = *a++;
}
diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp
index 8b47137fd8..44cc692b2f 100644
--- a/src/corelib/tools/qstringlist.cpp
+++ b/src/corelib/tools/qstringlist.cpp
@@ -234,42 +234,6 @@ void QtPrivate::QStringList_sort(QStringList *that)
}
-#ifdef QT3_SUPPORT
-/*!
- \fn QStringList QStringList::split(const QChar &sep, const QString &str, bool allowEmptyEntries)
-
- \overload
-
- This version of the function uses a QChar as separator.
-
- \sa join() QString::section()
-*/
-
-/*!
- \fn QStringList QStringList::split(const QString &sep, const QString &str, bool allowEmptyEntries)
-
- \overload
-
- This version of the function uses a QString as separator.
-
- \sa join() QString::section()
-*/
-#ifndef QT_NO_REGEXP
-/*!
- \fn QStringList QStringList::split(const QRegExp &sep, const QString &str, bool allowEmptyEntries)
-
- Use QString::split(\a sep, QString::SkipEmptyParts) or
- QString::split(\a sep, QString::KeepEmptyParts) instead.
-
- Be aware that the QString::split()'s return value is a
- QStringList that always contains at least one element, even if \a
- str is empty.
-
- \sa join() QString::section()
-*/
-#endif
-#endif // QT3_SUPPORT
-
/*!
\fn QStringList QStringList::filter(const QString &str, Qt::CaseSensitivity cs) const
diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h
index 2159512b20..efb7f46c9b 100644
--- a/src/corelib/tools/qstringlist.h
+++ b/src/corelib/tools/qstringlist.h
@@ -48,9 +48,6 @@
#include <QtCore/qregexp.h>
#include <QtCore/qstring.h>
#include <QtCore/qstringmatcher.h>
-#ifdef QT_INCLUDE_COMPAT
-#include <Qt3Support/q3valuelist.h>
-#endif
QT_BEGIN_HEADER
@@ -108,24 +105,6 @@ public:
inline int lastIndexOf(const QString &str, int from = -1) const
{ return QList<QString>::lastIndexOf(str, from); }
#endif
-#ifdef QT3_SUPPORT
- static inline QT3_SUPPORT QStringList split(const QString &sep, const QString &str, bool allowEmptyEntries = false);
- static inline QT3_SUPPORT QStringList split(const QChar &sep, const QString &str, bool allowEmptyEntries = false);
- inline QT3_SUPPORT QStringList grep(const QString &str, bool cs = true) const
- { return filter(str, cs ? Qt::CaseSensitive : Qt::CaseInsensitive); }
-
-#ifndef QT_NO_REGEXP
- static inline QT3_SUPPORT QStringList split(const QRegExp &sep, const QString &str, bool allowEmptyEntries = false);
- inline QT3_SUPPORT QStringList grep(const QRegExp &rx) const { return filter(rx); }
- inline QT3_SUPPORT QStringList &gres(const QRegExp &rx, const QString &after)
- { return replaceInStrings(rx, after); }
-#endif
- inline QT3_SUPPORT QStringList &gres(const QString &before, const QString &after, bool cs = true)
- { return replaceInStrings(before, after, cs ? Qt::CaseSensitive : Qt::CaseInsensitive); }
-
- inline Iterator QT3_SUPPORT fromLast() { return (isEmpty() ? end() : --end()); }
- inline ConstIterator QT3_SUPPORT fromLast() const { return (isEmpty() ? end() : --end()); }
-#endif
};
namespace QtPrivate {
@@ -214,36 +193,6 @@ inline int QStringList::lastIndexOf(QRegExp &rx, int from) const
#endif
-#ifdef QT3_SUPPORT
-inline QStringList QStringList::split(const QChar &sep, const QString &str, bool allowEmptyEntries)
-{
- if (str.isEmpty())
- return QStringList();
- return str.split(sep, allowEmptyEntries ? QString::KeepEmptyParts
- : QString::SkipEmptyParts);
-}
-
-inline QStringList QStringList::split(const QString &sep, const QString &str, bool allowEmptyEntries)
-{
- if (str.isEmpty())
- return QStringList();
- return str.split(sep, allowEmptyEntries ? QString::KeepEmptyParts
- : QString::SkipEmptyParts);
-}
-
-#ifndef QT_NO_REGEXP
-inline QStringList QStringList::split(const QRegExp &sep, const QString &str, bool allowEmptyEntries)
-{
- if (str.isEmpty())
- return QStringList();
- return str.split(sep, allowEmptyEntries ? QString::KeepEmptyParts
- : QString::SkipEmptyParts);
-}
-#endif // QT_NO_REGEXP
-
-#endif // QT3_SUPPORT
-
-
#ifndef QT_NO_DATASTREAM
inline QDataStream &operator>>(QDataStream &in, QStringList &list)
{
diff --git a/src/dbus/dbus.pro b/src/dbus/dbus.pro
index 12efd8638b..c91c2f6ad7 100644
--- a/src/dbus/dbus.pro
+++ b/src/dbus/dbus.pro
@@ -35,7 +35,7 @@ win32 {
}
load(qt_module_config)
-HEADERS += $$QT_SOURCE_TREE/src/dub/qtdbusversion.h
+HEADERS += $$QT_SOURCE_TREE/src/dbus/qtdbusversion.h
PUB_HEADERS = qdbusargument.h \
qdbusconnectioninterface.h \
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 9e6a8d6e52..fff27cd908 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -48,6 +48,7 @@
#include "qmime.h"
#include "private/qdnd_p.h"
#include "qevent_p.h"
+#include "qmath.h"
#ifdef Q_OS_SYMBIAN
#include "private/qcore_symbian_p.h"
@@ -161,7 +162,7 @@ QInputEvent::~QInputEvent()
position explicitly.
*/
-QMouseEvent::QMouseEvent(Type type, const QPoint &position, Qt::MouseButton button,
+QMouseEvent::QMouseEvent(Type type, const QPointF &position, Qt::MouseButton button,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
: QInputEvent(type, modifiers), p(position), b(button), mouseState(buttons)
{
@@ -193,28 +194,20 @@ QMouseEvent::~QMouseEvent()
modifiers.
*/
-QMouseEvent::QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
+QMouseEvent::QMouseEvent(Type type, const QPointF &pos, const QPointF &globalPos,
Qt::MouseButton button, Qt::MouseButtons buttons,
Qt::KeyboardModifiers modifiers)
: QInputEvent(type, modifiers), p(pos), g(globalPos), b(button), mouseState(buttons)
{}
/*!
- \internal
-*/
-QMouseEvent *QMouseEvent::createExtendedMouseEvent(Type type, const QPointF &pos,
- const QPoint &globalPos, Qt::MouseButton button,
- Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
-{
- return new QMouseEventEx(type, pos, globalPos, button, buttons, modifiers);
-}
-
-/*!
\fn bool QMouseEvent::hasExtendedInfo() const
\internal
*/
/*!
+ \fn QPointF QMouseEvent::posF() const
+
\since 4.4
Returns the position of the mouse cursor as a QPointF, relative to the
@@ -226,28 +219,6 @@ QMouseEvent *QMouseEvent::createExtendedMouseEvent(Type type, const QPointF &pos
\sa x() y() pos() globalPos()
*/
-QPointF QMouseEvent::posF() const
-{
- return hasExtendedInfo() ? reinterpret_cast<const QMouseEventEx *>(this)->posF : QPointF(pos());
-}
-
-/*!
- \internal
-*/
-QMouseEventEx::QMouseEventEx(Type type, const QPointF &pos, const QPoint &globalPos,
- Qt::MouseButton button, Qt::MouseButtons buttons,
- Qt::KeyboardModifiers modifiers)
- : QMouseEvent(type, pos.toPoint(), globalPos, button, buttons, modifiers), posF(pos)
-{
- d = reinterpret_cast<QEventPrivate *>(this);
-}
-
-/*!
- \internal
-*/
-QMouseEventEx::~QMouseEventEx()
-{
-}
/*!
\fn const QPoint &QMouseEvent::pos() const
@@ -440,8 +411,8 @@ QMouseEventEx::~QMouseEventEx()
receiving widget, while \a oldPos is the previous mouse cursor's
position relative to the receiving widget.
*/
-QHoverEvent::QHoverEvent(Type type, const QPoint &pos, const QPoint &oldPos)
- : QEvent(type), p(pos), op(oldPos)
+QHoverEvent::QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos, Qt::KeyboardModifiers modifiers)
+ : QInputEvent(type, modifiers), p(pos), op(oldPos)
{
}
@@ -507,7 +478,7 @@ QHoverEvent::~QHoverEvent()
\sa pos() delta() state()
*/
#ifndef QT_NO_WHEELEVENT
-QWheelEvent::QWheelEvent(const QPoint &pos, int delta,
+QWheelEvent::QWheelEvent(const QPointF &pos, int delta,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
Qt::Orientation orient)
: QInputEvent(Wheel, modifiers), p(pos), d(delta), mouseState(buttons), o(orient)
@@ -533,7 +504,7 @@ QWheelEvent::~QWheelEvent()
\sa pos() globalPos() delta() state()
*/
-QWheelEvent::QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta,
+QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
Qt::Orientation orient)
: QInputEvent(Wheel, modifiers), p(pos), g(globalPos), d(delta), mouseState(buttons), o(orient)
@@ -4355,4 +4326,101 @@ const QScrollEventPrivate *QScrollEvent::d_func() const
return reinterpret_cast<const QScrollEventPrivate *>(d);
}
+/*!
+ \enum QScreenOrientationChangeEvent::Orientation
+
+ This enum describes the orientations that a device can have.
+
+ \value Portrait The device is in a position where its top edge is pointing up.
+
+ \value Landscape The device is rotated clockwise 90 degrees, so that its left edge is pointing up.
+
+ \value PortraitInverted The device is rotated 180 degrees, so that its bottom edge is pointing up.
+
+ \value LandscapeInverted The device is counterclockwise 90 degrees, so that its right edge is pointing up.
+
+ \sa QScreenOrientationChangeEvent::orientation()
+ \sa QScreenOrientationChangeEvent::orientationInDegrees()
+*/
+
+/*!
+ Creates a new QScreenOrientationChangeEvent
+ \a screenOrientationInDegrees is the new screen orientation, expressed in degrees.
+ The orientation must be expressed in steps of 90 degrees.
+*/
+QScreenOrientationChangeEvent::QScreenOrientationChangeEvent(qint32 screenOrientationInDegrees)
+ : QEvent(QEvent::OrientationChange)
+{
+ d = reinterpret_cast<QEventPrivate *>(new QScreenOrientationChangeEventPrivate());
+ d_func()->orientationInDegrees = screenOrientationInDegrees;
+
+ qint32 orientationIndex = (qAbs(screenOrientationInDegrees) % 360) / 90;
+ // flip around the negative coords to correct order.
+ if (screenOrientationInDegrees < 0) {
+ if (orientationIndex == 1)
+ orientationIndex = 3;
+ else if (orientationIndex == 3)
+ orientationIndex = 1;
+ }
+
+ orientationIndex = qPow(2, orientationIndex);
+ d_func()->orientation = (QScreenOrientationChangeEvent::Orientation)(orientationIndex);
+ d_func()->isValid = (screenOrientationInDegrees % 90 == 0);
+}
+
+/*!
+ Creates a new QScreenOrientationChangeEvent
+ \a orientation is the new orientation of the screen.
+*/
+QScreenOrientationChangeEvent::QScreenOrientationChangeEvent(QScreenOrientationChangeEvent::Orientation screenOrientation)
+ : QEvent(QEvent::OrientationChange)
+{
+ d = reinterpret_cast<QEventPrivate *>(new QScreenOrientationChangeEventPrivate());
+ d_func()->orientation = screenOrientation;
+ d_func()->orientationInDegrees = 90 * ((uint)screenOrientation);
+ d_func()->isValid = true;
+}
+
+/*!
+ Destroys QScreenOrientationChangeEvent.
+*/
+QScreenOrientationChangeEvent::~QScreenOrientationChangeEvent()
+{
+ delete reinterpret_cast<QScrollEventPrivate *>(d);
+}
+
+/*!
+ Returns the orientation of the screen.
+*/
+QScreenOrientationChangeEvent::Orientation QScreenOrientationChangeEvent::orientation() const
+{
+ return d_func()->orientation;
+}
+
+/*!
+ Returns the screen orientation in degrees.
+ The orientation is expressed in steps of 90 degrees and depends on the previous value of the orientation.
+ This is intended to allow for smooth animations from one orientation to the other.
+*/
+qint32 QScreenOrientationChangeEvent::orientationInDegrees() const
+{
+ return d_func()->orientationInDegrees;
+}
+
+/*!
+ \internal
+*/
+QScreenOrientationChangeEventPrivate *QScreenOrientationChangeEvent::d_func()
+{
+ return reinterpret_cast<QScreenOrientationChangeEventPrivate *>(d);
+}
+
+/*!
+ \internal
+*/
+const QScreenOrientationChangeEventPrivate *QScreenOrientationChangeEvent::d_func() const
+{
+ return reinterpret_cast<const QScreenOrientationChangeEventPrivate *>(d);
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index 59d50df268..de0d6b3793 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -84,62 +84,62 @@ protected:
class Q_GUI_EXPORT QMouseEvent : public QInputEvent
{
public:
- QMouseEvent(Type type, const QPoint &pos, Qt::MouseButton button,
+ QMouseEvent(Type type, const QPointF &pos, Qt::MouseButton button,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
- QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
+ QMouseEvent(Type type, const QPointF &pos, const QPointF &globalPos,
Qt::MouseButton button, Qt::MouseButtons buttons,
Qt::KeyboardModifiers modifiers);
~QMouseEvent();
- inline const QPoint &pos() const { return p; }
- inline const QPoint &globalPos() const { return g; }
- inline int x() const { return p.x(); }
- inline int y() const { return p.y(); }
- inline int globalX() const { return g.x(); }
- inline int globalY() const { return g.y(); }
+ inline QPoint pos() const { return p.toPoint(); }
+ inline QPoint globalPos() const { return g.toPoint(); }
+ inline int x() const { return qRound(p.x()); }
+ inline int y() const { return qRound(p.y()); }
+ inline int globalX() const { return qRound(g.x()); }
+ inline int globalY() const { return qRound(g.y()); }
inline Qt::MouseButton button() const { return b; }
inline Qt::MouseButtons buttons() const { return mouseState; }
- static QMouseEvent *createExtendedMouseEvent(Type type, const QPointF &pos,
- const QPoint &globalPos, Qt::MouseButton button,
- Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
- inline bool hasExtendedInfo() const { return reinterpret_cast<const QMouseEvent *>(d) == this; }
- QPointF posF() const;
+ const QPointF &posF() const { return p; }
+ const QPointF &globalPosF() const { return g; }
protected:
- QPoint p, g;
+ QPointF p, g;
Qt::MouseButton b;
Qt::MouseButtons mouseState;
};
-class Q_GUI_EXPORT QHoverEvent : public QEvent
+class Q_GUI_EXPORT QHoverEvent : public QInputEvent
{
public:
- QHoverEvent(Type type, const QPoint &pos, const QPoint &oldPos);
+ QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
~QHoverEvent();
- inline const QPoint &pos() const { return p; }
- inline const QPoint &oldPos() const { return op; }
+ inline QPoint pos() const { return p.toPoint(); }
+ inline QPoint oldPos() const { return op.toPoint(); }
+
+ inline const QPointF &posF() const { return p; }
+ inline const QPointF &oldPosF() const { return op; }
protected:
- QPoint p, op;
+ QPointF p, op;
};
#ifndef QT_NO_WHEELEVENT
class Q_GUI_EXPORT QWheelEvent : public QInputEvent
{
public:
- QWheelEvent(const QPoint &pos, int delta,
+ QWheelEvent(const QPointF &pos, int delta,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
Qt::Orientation orient = Qt::Vertical);
- QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta,
+ QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
Qt::Orientation orient = Qt::Vertical);
~QWheelEvent();
inline int delta() const { return d; }
- inline const QPoint &pos() const { return p; }
- inline const QPoint &globalPos() const { return g; }
+ inline QPoint pos() const { return p.toPoint(); }
+ inline QPoint globalPos() const { return g.toPoint(); }
inline int x() const { return p.x(); }
inline int y() const { return p.y(); }
inline int globalX() const { return g.x(); }
@@ -148,9 +148,12 @@ public:
inline Qt::MouseButtons buttons() const { return mouseState; }
Qt::Orientation orientation() const { return o; }
+ inline const QPointF &posF() const { return p; }
+ inline const QPointF &globalPosF() const { return g; }
+
protected:
- QPoint p;
- QPoint g;
+ QPointF p;
+ QPointF g;
int d;
Qt::MouseButtons mouseState;
Qt::Orientation o;
@@ -819,6 +822,30 @@ private:
const QScrollEventPrivate *d_func() const;
};
+class QScreenOrientationChangeEventPrivate;
+class Q_GUI_EXPORT QScreenOrientationChangeEvent : public QEvent
+{
+public:
+ enum Orientation {
+ Portrait = 1,
+ Landscape = 2,
+ PortraitInverted = 4,
+ LandscapeInverted = 8
+ };
+ QScreenOrientationChangeEvent(qint32 screenOrientationInDegrees);
+ QScreenOrientationChangeEvent(Orientation screenOrientation);
+ ~QScreenOrientationChangeEvent();
+
+ bool isValid() const;
+ qint32 orientationInDegrees() const;
+ Orientation orientation() const;
+
+private:
+ QScreenOrientationChangeEventPrivate *d_func();
+ const QScreenOrientationChangeEventPrivate *d_func() const;
+
+};
+
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index 731cfc97f2..59eb270230 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -81,20 +81,6 @@ protected:
friend class QKeyEvent;
};
-// ### Qt 5: remove
-class QMouseEventEx : public QMouseEvent
-{
-public:
- QMouseEventEx(Type type, const QPointF &pos, const QPoint &globalPos,
- Qt::MouseButton button, Qt::MouseButtons buttons,
- Qt::KeyboardModifiers modifiers);
- ~QMouseEventEx();
-
-protected:
- QPointF posF;
- friend class QMouseEvent;
-};
-
class QTouchEventTouchPointPrivate
{
public:
@@ -167,6 +153,17 @@ public:
QScrollEvent::ScrollState state;
};
+class QScreenOrientationChangeEventPrivate
+{
+public:
+ inline QScreenOrientationChangeEventPrivate()
+ {
+ }
+ QScreenOrientationChangeEvent::Orientation orientation;
+ qint32 orientationInDegrees;
+ bool isValid;
+};
+
QT_END_NAMESPACE
#endif // QEVENT_P_H
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index 98ed02879a..d644bbace1 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -1277,7 +1277,7 @@ QDataStream &operator>>(QDataStream &s, QBrush &b)
{coordinate mode} use coordinateMode().
- \sa {demos/gradients}{The Gradients Demo}, QBrush
+ \sa {painting/gradients}{The Gradients Example}, QBrush
*/
/*!
@@ -1587,8 +1587,8 @@ bool QGradient::operator==(const QGradient &gradient)
returns the final stop point of the gradient, and the start()
function returning the start point of the gradient.
- \sa QRadialGradient, QConicalGradient, {demos/gradients}{The
- Gradients Demo}
+ \sa QRadialGradient, QConicalGradient, {painting/gradients}{The
+ Gradients Example}
*/
@@ -1773,8 +1773,8 @@ void QLinearGradient::setFinalStop(const QPointF &stop)
radius() functions returning the gradient's center, focal point
and radius respectively.
- \sa QLinearGradient, QConicalGradient, {demos/gradients}{The
- Gradients Demo}
+ \sa QLinearGradient, QConicalGradient, {painting/gradients}{The
+ Gradients Example}
*/
static QPointF qt_radial_gradient_adapt_focal_point(const QPointF &center,
@@ -2143,8 +2143,8 @@ void QRadialGradient::setFocalPoint(const QPointF &focalPoint)
gradient can be specified through its radius or final stop points,
respectively.
- \sa QLinearGradient, QRadialGradient, {demos/gradients}{The
- Gradients Demo}
+ \sa QLinearGradient, QRadialGradient, {painting/gradients}{The
+ Gradients Example}
*/
diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp
index d694b4b9a8..cdc0978ed7 100644
--- a/src/gui/painting/qcosmeticstroker.cpp
+++ b/src/gui/painting/qcosmeticstroker.cpp
@@ -409,10 +409,11 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal
if (clipLine(rx1, ry1, rx2, ry2))
return;
- int x1 = toF26Dot6(rx1);
- int y1 = toF26Dot6(ry1);
- int x2 = toF26Dot6(rx2);
- int y2 = toF26Dot6(ry2);
+ const int half = 32;
+ int x1 = toF26Dot6(rx1) + half;
+ int y1 = toF26Dot6(ry1) + half;
+ int x2 = toF26Dot6(rx2) + half;
+ int y2 = toF26Dot6(ry2) + half;
int dx = qAbs(x2 - x1);
int dy = qAbs(y2 - y1);
@@ -424,6 +425,7 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal
swapped = true;
qSwap(y1, y2);
qSwap(x1, x2);
+ --x1; --x2; --y1; --y2;
}
int xinc = F16Dot16FixedDiv(x2 - x1, y2 - y1);
int x = x1 << 10;
@@ -455,6 +457,7 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal
swapped = true;
qSwap(x1, x2);
qSwap(y1, y2);
+ --x1; --x2; --y1; --y2;
}
int yinc = F16Dot16FixedDiv(y2 - y1, x2 - x1);
int y = y1 << 10;
@@ -525,7 +528,9 @@ void QCosmeticStroker::drawPath(const QVectorPath &path)
const QPainterPath::ElementType *e = subPath(type, end, points, &closed);
if (closed) {
const qreal *p = points + 2*(e-type);
- calculateLastPoint(p[-4], p[-3], p[-2], p[-1]);
+ QPointF p1 = QPointF(p[-4], p[-3]) * state->matrix;
+ QPointF p2 = QPointF(p[-2], p[-1]) * state->matrix;
+ calculateLastPoint(p1.x(), p1.y(), p2.x(), p2.y());
}
int caps = (!closed & drawCaps) ? CapBegin : NoCaps;
// qDebug() << "closed =" << closed << capString(caps);
@@ -577,8 +582,10 @@ void QCosmeticStroker::drawPath(const QVectorPath &path)
// handle closed path case
bool closed = path.hasImplicitClose() || (points[0] == end[-2] && points[1] == end[-1]);
int caps = (!closed & drawCaps) ? CapBegin : NoCaps;
- if (closed)
- calculateLastPoint(end[-2], end[-1], points[0], points[1]);
+ if (closed) {
+ QPointF p2 = QPointF(end[-2], end[-1]) * state->matrix;
+ calculateLastPoint(p2.x(), p2.y(), p.x(), p.y());
+ }
points += 2;
while (points < end) {
@@ -656,8 +663,8 @@ void QCosmeticStroker::renderCubicSubdivision(QCosmeticStroker::PointF *points,
qreal dy = points[3].y - points[0].y;
qreal len = ((qreal).25) * (qAbs(dx) + qAbs(dy));
- if (qAbs(dx * (points[0].y - points[2].y) - dy * (points[0].x - points[2].x)) > len ||
- qAbs(dx * (points[0].y - points[1].y) - dy * (points[0].x - points[1].x)) > len) {
+ if (qAbs(dx * (points[0].y - points[2].y) - dy * (points[0].x - points[2].x)) >= len ||
+ qAbs(dx * (points[0].y - points[1].y) - dy * (points[0].x - points[1].x)) >= len) {
splitCubic(points);
--level;
diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp
index d2c84f0485..767706a5bc 100644
--- a/src/gui/painting/qmatrix.cpp
+++ b/src/gui/painting/qmatrix.cpp
@@ -177,7 +177,7 @@ QT_BEGIN_NAMESPACE
\endtable
\sa QPainter, QTransform, {Coordinate System},
- {demos/affine}{Affine Transformations Demo}, {Transformations Example}
+ {painting/affine}{Affine Transformations Example}, {Transformations Example}
*/
diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp
index 7c17c1b46e..8b607b28b8 100644
--- a/src/gui/painting/qoutlinemapper.cpp
+++ b/src/gui/painting/qoutlinemapper.cpp
@@ -47,6 +47,8 @@
QT_BEGIN_NAMESPACE
+static const qreal aliasedCoordinateDelta = 0.5 - 0.015625;
+
#define qreal_to_fixed_26_6(f) (int(f * 64))
@@ -214,6 +216,13 @@ void QOutlineMapper::endOutline()
elements = m_elements_dev.data();
}
+ if (m_round_coords) {
+ // round coordinates to match outlines drawn with drawLine_midpoint_i
+ for (int i = 0; i < m_elements.size(); ++i)
+ elements[i] = QPointF(qFloor(elements[i].x() + aliasedCoordinateDelta),
+ qFloor(elements[i].y() + aliasedCoordinateDelta));
+ }
+
controlPointRect = boundingRect(elements, element_count);
#ifdef QT_DEBUG_CONVERT
diff --git a/src/gui/painting/qoutlinemapper_p.h b/src/gui/painting/qoutlinemapper_p.h
index 1432d6fc4b..388858ca44 100644
--- a/src/gui/painting/qoutlinemapper_p.h
+++ b/src/gui/painting/qoutlinemapper_p.h
@@ -95,7 +95,8 @@ public:
m_tags(0),
m_contours(0),
m_polygon_dev(0),
- m_in_clip_elements(false)
+ m_in_clip_elements(false),
+ m_round_coords(false)
{
}
@@ -201,6 +202,8 @@ public:
QT_FT_Outline *convertPath(const QPainterPath &path);
QT_FT_Outline *convertPath(const QVectorPath &path);
+ void setCoordinateRounding(bool coordinateRounding) { m_round_coords = coordinateRounding; }
+
inline QPainterPath::ElementType *elementTypes() const { return m_element_types.size() == 0 ? 0 : m_element_types.data(); }
public:
@@ -234,6 +237,9 @@ public:
bool m_valid;
bool m_in_clip_elements;
+
+private:
+ bool m_round_coords;
};
QT_END_NAMESPACE
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index c93cb88135..09ffc8ec59 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -118,6 +118,8 @@ void dumpClip(int width, int height, const QClipData *clip);
// 4 pixels.
#define int_dim(pos, dim) (int(pos+dim) - int(pos))
+static const qreal aliasedCoordinateDelta = 0.5 - 0.015625;
+
#ifdef Q_OS_WIN
static inline bool winClearTypeFontsEnabled()
@@ -165,6 +167,10 @@ enum LineDrawMode {
LineDrawIncludeLastPixel
};
+static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip,
+ ProcessSpans pen_func, ProcessSpans brush_func,
+ QSpanData *pen_data, QSpanData *brush_data);
+
struct QRasterFloatPoint {
qreal x;
qreal y;
@@ -479,10 +485,6 @@ bool QRasterPaintEngine::begin(QPaintDevice *device)
}
#endif
-#if defined(Q_OS_WIN)
- d->isPlain45DegreeRotation = true;
-#endif
-
if (d->mono_surface)
d->glyphCacheType = QFontEngineGlyphCache::Raster_Mono;
#if defined(Q_OS_WIN)
@@ -586,33 +588,6 @@ void QRasterPaintEngine::updateMatrix(const QTransform &matrix)
s->flags.tx_noshear = qt_scaleForTransform(s->matrix, &s->txscale);
ensureOutlineMapper();
-
-#ifdef Q_OS_WIN
- Q_D(QRasterPaintEngine);
- d->isPlain45DegreeRotation = false;
- if (txop >= QTransform::TxRotate) {
- d->isPlain45DegreeRotation =
- (qFuzzyIsNull(matrix.m11())
- && qFuzzyIsNull(matrix.m12() - qreal(1))
- && qFuzzyIsNull(matrix.m21() + qreal(1))
- && qFuzzyIsNull(matrix.m22())
- )
- ||
- (qFuzzyIsNull(matrix.m11() + qreal(1))
- && qFuzzyIsNull(matrix.m12())
- && qFuzzyIsNull(matrix.m21())
- && qFuzzyIsNull(matrix.m22() + qreal(1))
- )
- ||
- (qFuzzyIsNull(matrix.m11())
- && qFuzzyIsNull(matrix.m12() + qreal(1))
- && qFuzzyIsNull(matrix.m21() - qreal(1))
- && qFuzzyIsNull(matrix.m22())
- )
- ;
- }
-#endif
-
}
@@ -1182,8 +1157,7 @@ void QRasterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
const QPainterPath::ElementType *types = path.elements();
// There are some cases that are not supported by clip(QRect)
- if (op != Qt::UniteClip && (op != Qt::IntersectClip || !s->clip
- || s->clip->hasRectClip || s->clip->hasRegionClip)) {
+ if (op != Qt::IntersectClip || !s->clip || s->clip->hasRectClip || s->clip->hasRegionClip) {
if (s->matrix.type() <= QTransform::TxScale
&& ((path.shape() == QVectorPath::RectangleHint)
|| (isRect(points, path.elementCount())
@@ -1226,18 +1200,6 @@ void QRasterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
newClip->fixup();
- if (op == Qt::UniteClip) {
- // merge clips
- QClipData *result = new QClipData(d->rasterBuffer->height());
- QClipData *current = s->clip ? s->clip : new QClipData(d->rasterBuffer->height());
- qt_merge_clip(current, newClip, result);
- result->fixup();
- delete newClip;
- if (!s->clip)
- delete current;
- newClip = result;
- }
-
if (s->flags.has_clip_ownership)
delete s->clip;
@@ -1263,7 +1225,7 @@ void QRasterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op)
if (op == Qt::NoClip) {
qrasterpaintengine_state_setNoClip(s);
- } else if (op == Qt::UniteClip || s->matrix.type() > QTransform::TxScale) {
+ } else if (s->matrix.type() > QTransform::TxScale) {
QPaintEngineEx::clip(rect, op);
return;
@@ -1348,7 +1310,6 @@ void QRasterPaintEngine::clip(const QRegion &region, Qt::ClipOperation op)
if (op == Qt::NoClip) {
qrasterpaintengine_state_setNoClip(s);
} else if (s->matrix.type() > QTransform::TxScale
- || op == Qt::UniteClip
|| (op == Qt::IntersectClip && !clip->hasRectClip && !clip->hasRegionClip)
|| (op == Qt::ReplaceClip && !baseClip->hasRectClip && !baseClip->hasRegionClip)) {
QPaintEngineEx::clip(region, op);
@@ -1662,10 +1623,10 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
static inline QRect toNormalizedFillRect(const QRectF &rect)
{
- int x1 = qRound(rect.x());
- int y1 = qRound(rect.y());
- int x2 = qRound(rect.right());
- int y2 = qRound(rect.bottom());
+ int x1 = qRound(rect.x() + aliasedCoordinateDelta);
+ int y1 = qRound(rect.y() + aliasedCoordinateDelta);
+ int x2 = qRound(rect.right() + aliasedCoordinateDelta);
+ int y2 = qRound(rect.bottom() + aliasedCoordinateDelta);
if (x2 < x1)
qSwap(x1, x2);
@@ -1935,7 +1896,9 @@ void QRasterPaintEngine::drawPolygon(const QPointF *points, int pointCount, Poly
// Do the fill...
ensureBrush();
if (s->brushData.blend) {
+ d->outlineMapper->setCoordinateRounding(s->penData.blend && s->flags.fast_pen && s->lastPen.brush().isOpaque());
fillPolygon(points, pointCount, mode);
+ d->outlineMapper->setCoordinateRounding(false);
}
}
@@ -1982,6 +1945,7 @@ void QRasterPaintEngine::drawPolygon(const QPoint *points, int pointCount, Polyg
if (s->brushData.blend) {
// Compose polygon fill..,
ensureOutlineMapper();
+ d->outlineMapper->setCoordinateRounding(s->penData.blend != 0);
d->outlineMapper->beginOutline(mode == WindingMode ? Qt::WindingFill : Qt::OddEvenFill);
d->outlineMapper->moveTo(*points);
const QPoint *p = points;
@@ -1995,6 +1959,7 @@ void QRasterPaintEngine::drawPolygon(const QPoint *points, int pointCount, Polyg
ProcessSpans brushBlend = d->getBrushFunc(d->outlineMapper->controlPointRect,
&s->brushData);
d->rasterize(d->outlineMapper->outline(), brushBlend, &s->brushData, d->rasterBuffer.data());
+ d->outlineMapper->setCoordinateRounding(false);
}
}
@@ -2244,7 +2209,10 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
int sr_b = qCeil(sr.bottom()) - 1;
if (s->matrix.type() <= QTransform::TxScale && !s->flags.antialiased && sr_l == sr_r && sr_t == sr_b) {
+ // as fillRect will apply the aliased coordinate delta we need to
+ // subtract it here as we don't use it for image drawing
QTransform old = s->matrix;
+ s->matrix = s->matrix * QTransform::fromTranslate(-aliasedCoordinateDelta, -aliasedCoordinateDelta);
// Do whatever fillRect() does, but without premultiplying the color if it's already premultiplied.
QRgb color = img.pixel(sr_l, sr_t);
@@ -2388,9 +2356,11 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
d->initializeRasterizer(&d->image_filler_xform);
d->rasterizer->setAntialiased(s->flags.antialiased);
+ const QPointF offs = s->flags.antialiased ? QPointF() : QPointF(aliasedCoordinateDelta, aliasedCoordinateDelta);
+
const QRectF &rect = r.normalized();
- const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f);
- const QPointF b = s->matrix.map((rect.topRight() + rect.bottomRight()) * 0.5f);
+ const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f) - offs;
+ const QPointF b = s->matrix.map((rect.topRight() + rect.bottomRight()) * 0.5f) - offs;
if (s->flags.tx_noshear)
d->rasterizer->rasterizeLine(a, b, rect.height() / rect.width());
@@ -2399,12 +2369,13 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
return;
}
#endif
+ const qreal offs = s->flags.antialiased ? qreal(0) : aliasedCoordinateDelta;
QPainterPath path;
path.addRect(r);
QTransform m = s->matrix;
s->matrix = QTransform(m.m11(), m.m12(), m.m13(),
m.m21(), m.m22(), m.m23(),
- m.m31(), m.m32(), m.m33());
+ m.m31() - offs, m.m32() - offs, m.m33());
fillPath(path, &d->image_filler_xform);
s->matrix = m;
} else {
@@ -2856,6 +2827,7 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs,
rightShift = 3; // divide by 8
int margin = cache->glyphMargin();
+ const QFixed offs = QFixed::fromReal(aliasedCoordinateDelta);
const uchar *bits = image.bits();
for (int i=0; i<numGlyphs; ++i) {
@@ -2865,8 +2837,8 @@ bool QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs,
if (c.isNull())
continue;
- int x = qFloor(positions[i].x) + c.baseLineX - margin;
- int y = qFloor(positions[i].y) - c.baseLineY - margin;
+ int x = qFloor(positions[i].x + offs) + c.baseLineX - margin;
+ int y = qFloor(positions[i].y + offs) - c.baseLineY - margin;
// printf("drawing [%d %d %d %d] baseline [%d %d], glyph: %d, to: %d %d, pos: %d %d\n",
// c.x, c.y,
@@ -2904,13 +2876,15 @@ void QRasterPaintEngine::drawGlyphsS60(const QPointF &p, const QTextItemInt &ti)
fe->setFontScale(matrix.m11());
ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
+ const QFixed aliasDelta = QFixed::fromReal(aliasedCoordinateDelta);
+
for (int i=0; i<glyphs.size(); ++i) {
TOpenFontCharMetrics tmetrics;
const TUint8 *glyphBitmapBytes;
TSize glyphBitmapSize;
fe->getCharacterData(glyphs[i], tmetrics, glyphBitmapBytes, glyphBitmapSize);
- const int x = qFloor(positions[i].x + tmetrics.HorizBearingX());
- const int y = qFloor(positions[i].y - tmetrics.HorizBearingY());
+ const int x = qFloor(positions[i].x + tmetrics.HorizBearingX() + aliasDelta);
+ const int y = qFloor(positions[i].y - tmetrics.HorizBearingY() + aliasDelta);
alphaPenBlt(glyphBitmapBytes, glyphBitmapSize.iWidth, 8, x, y, glyphBitmapSize.iWidth, glyphBitmapSize.iHeight);
}
@@ -3010,6 +2984,19 @@ QRasterPaintEnginePrivate::getBrushFunc(const QRectF &rect,
return isUnclipped(rect, 0) ? data->unclipped_blend : data->blend;
}
+inline ProcessSpans
+QRasterPaintEnginePrivate::getPenFunc(const QRectF &rect,
+ const QSpanData *data) const
+{
+ Q_Q(const QRasterPaintEngine);
+ const QRasterPaintEngineState *s = q->state();
+
+ if (!s->flags.fast_pen && s->matrix.type() > QTransform::TxTranslate)
+ return data->blend;
+ const int penWidth = s->flags.fast_pen ? 1 : qCeil(s->lastPen.widthF());
+ return isUnclipped(rect, penWidth) ? data->unclipped_blend : data->blend;
+}
+
/*!
\reimp
*/
@@ -3089,6 +3076,7 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
for(int i = 0; i < glyphs.size(); i++) {
QImage img = fontEngine->alphaMapForGlyph(glyphs[i]);
glyph_metrics_t metrics = fontEngine->boundingBox(glyphs[i]);
+ // ### hm, perhaps an QFixed offs = QFixed::fromReal(aliasedCoordinateDelta) is needed here?
alphaPenBlt(img.bits(), img.bytesPerLine(), img.depth(),
qRound(positions[i].x + metrics.x),
qRound(positions[i].y + metrics.y),
@@ -3269,6 +3257,30 @@ void QRasterPaintEngine::drawLines(const QLineF *lines, int lineCount)
*/
void QRasterPaintEngine::drawEllipse(const QRectF &rect)
{
+ Q_D(QRasterPaintEngine);
+ QRasterPaintEngineState *s = state();
+
+ ensurePen();
+ if (((qpen_style(s->lastPen) == Qt::SolidLine && s->flags.fast_pen)
+ || (qpen_style(s->lastPen) == Qt::NoPen))
+ && !s->flags.antialiased
+ && qMax(rect.width(), rect.height()) < QT_RASTER_COORD_LIMIT
+ && !rect.isEmpty()
+ && s->matrix.type() <= QTransform::TxScale) // no shear
+ {
+ ensureBrush();
+ const QRectF r = s->matrix.mapRect(rect);
+ ProcessSpans penBlend = d->getPenFunc(r, &s->penData);
+ ProcessSpans brushBlend = d->getBrushFunc(r, &s->brushData);
+ const QRect brect = QRect(int(r.x()), int(r.y()),
+ int_dim(r.x(), r.width()),
+ int_dim(r.y(), r.height()));
+ if (brect == r) {
+ drawEllipse_midpoint_i(brect, d->deviceRect, penBlend, brushBlend,
+ &s->penData, &s->brushData);
+ return;
+ }
+ }
QPaintEngineEx::drawEllipse(rect);
}
@@ -4221,7 +4233,6 @@ static void qt_span_clip(int count, const QSpan *spans, void *userData)
}
break;
- case Qt::UniteClip:
case Qt::ReplaceClip:
clipData->newClip->appendSpans(spans, count);
break;
@@ -4767,6 +4778,125 @@ void QSpanData::initTexture(const QImage *image, int alpha, QTextureData::Type _
adjustSpanMethods();
}
+/*!
+ \internal
+ \a x and \a y is relative to the midpoint of \a rect.
+*/
+static inline void drawEllipsePoints(int x, int y, int length,
+ const QRect &rect,
+ const QRect &clip,
+ ProcessSpans pen_func, ProcessSpans brush_func,
+ QSpanData *pen_data, QSpanData *brush_data)
+{
+ if (length == 0)
+ return;
+
+ QT_FT_Span outline[4];
+ const int midx = rect.x() + (rect.width() + 1) / 2;
+ const int midy = rect.y() + (rect.height() + 1) / 2;
+
+ x = x + midx;
+ y = midy - y;
+
+ // topleft
+ outline[0].x = midx + (midx - x) - (length - 1) - (rect.width() & 0x1);
+ outline[0].len = qMin(length, x - outline[0].x);
+ outline[0].y = y;
+ outline[0].coverage = 255;
+
+ // topright
+ outline[1].x = x;
+ outline[1].len = length;
+ outline[1].y = y;
+ outline[1].coverage = 255;
+
+ // bottomleft
+ outline[2].x = outline[0].x;
+ outline[2].len = outline[0].len;
+ outline[2].y = midy + (midy - y) - (rect.height() & 0x1);
+ outline[2].coverage = 255;
+
+ // bottomright
+ outline[3].x = x;
+ outline[3].len = length;
+ outline[3].y = outline[2].y;
+ outline[3].coverage = 255;
+
+ if (brush_func && outline[0].x + outline[0].len < outline[1].x) {
+ QT_FT_Span fill[2];
+
+ // top fill
+ fill[0].x = outline[0].x + outline[0].len - 1;
+ fill[0].len = qMax(0, outline[1].x - fill[0].x);
+ fill[0].y = outline[1].y;
+ fill[0].coverage = 255;
+
+ // bottom fill
+ fill[1].x = outline[2].x + outline[2].len - 1;
+ fill[1].len = qMax(0, outline[3].x - fill[1].x);
+ fill[1].y = outline[3].y;
+ fill[1].coverage = 255;
+
+ int n = (fill[0].y >= fill[1].y ? 1 : 2);
+ n = qt_intersect_spans(fill, n, clip);
+ if (n > 0)
+ brush_func(n, fill, brush_data);
+ }
+ if (pen_func) {
+ int n = (outline[1].y >= outline[2].y ? 2 : 4);
+ n = qt_intersect_spans(outline, n, clip);
+ if (n > 0)
+ pen_func(n, outline, pen_data);
+ }
+}
+
+/*!
+ \internal
+ Draws an ellipse using the integer point midpoint algorithm.
+*/
+static void drawEllipse_midpoint_i(const QRect &rect, const QRect &clip,
+ ProcessSpans pen_func, ProcessSpans brush_func,
+ QSpanData *pen_data, QSpanData *brush_data)
+{
+ const qreal a = qreal(rect.width()) / 2;
+ const qreal b = qreal(rect.height()) / 2;
+ qreal d = b*b - (a*a*b) + 0.25*a*a;
+
+ int x = 0;
+ int y = (rect.height() + 1) / 2;
+ int startx = x;
+
+ // region 1
+ while (a*a*(2*y - 1) > 2*b*b*(x + 1)) {
+ if (d < 0) { // select E
+ d += b*b*(2*x + 3);
+ ++x;
+ } else { // select SE
+ d += b*b*(2*x + 3) + a*a*(-2*y + 2);
+ drawEllipsePoints(startx, y, x - startx + 1, rect, clip,
+ pen_func, brush_func, pen_data, brush_data);
+ startx = ++x;
+ --y;
+ }
+ }
+ drawEllipsePoints(startx, y, x - startx + 1, rect, clip,
+ pen_func, brush_func, pen_data, brush_data);
+
+ // region 2
+ d = b*b*(x + 0.5)*(x + 0.5) + a*a*((y - 1)*(y - 1) - b*b);
+ const int miny = rect.height() & 0x1;
+ while (y > miny) {
+ if (d < 0) { // select SE
+ d += b*b*(2*x + 2) + a*a*(-2*y + 3);
+ ++x;
+ } else { // select S
+ d += a*a*(-2*y + 3);
+ }
+ --y;
+ drawEllipsePoints(x, y, 1, rect, clip,
+ pen_func, brush_func, pen_data, brush_data);
+ }
+}
/*!
\fn void QRasterPaintEngine::drawPoints(const QPoint *points, int pointCount)
diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h
index 9bdfbff9f6..d387e1312a 100644
--- a/src/gui/painting/qpaintengine_raster_p.h
+++ b/src/gui/painting/qpaintengine_raster_p.h
@@ -314,6 +314,7 @@ public:
bool isUnclipped_normalized(const QRect &rect) const;
bool isUnclipped(const QRect &rect, int penWidth) const;
bool isUnclipped(const QRectF &rect, int penWidth) const;
+ ProcessSpans getPenFunc(const QRectF &rect, const QSpanData *data) const;
ProcessSpans getBrushFunc(const QRect &rect, const QSpanData *data) const;
ProcessSpans getBrushFunc(const QRectF &rect, const QSpanData *data) const;
@@ -356,10 +357,6 @@ public:
uint mono_surface : 1;
uint outlinemapper_xform_dirty : 1;
-#ifdef Q_OS_WIN
- uint isPlain45DegreeRotation : 1;
-#endif
-
QScopedPointer<QRasterizer> rasterizer;
};
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index d46b30b6e2..be5c41ce76 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -1092,19 +1092,19 @@ void QPainterPrivate::updateState(QPainterState *newState)
function that draws the outline of the given path (i.e. strokes
the path).
- See also the \l {demos/deform}{Vector Deformation} demo which
+ See also the \l {painting/deform}{Vector Deformation} example which
shows how to use advanced vector techniques to draw text using a
- QPainterPath, the \l {demos/gradients}{Gradients} demo which shows
+ QPainterPath, the \l {painting/gradients}{Gradients} example which shows
the different types of gradients that are available in Qt, and the \l
- {demos/pathstroke}{Path Stroking} demo which shows Qt's built-in
+ {painting/pathstroke}{Path Stroking} example which shows Qt's built-in
dash patterns and shows how custom patterns can be used to extend
the range of available patterns.
\table
\header
- \o \l {demos/deform}{Vector Deformation}
- \o \l {demos/gradients}{Gradients}
- \o \l {demos/pathstroke}{Path Stroking}
+ \o \l {painting/deform}{Vector Deformation}
+ \o \l {painting/gradients}{Gradients}
+ \o \l {painting/pathstroke}{Path Stroking}
\row
\o \inlineimage qpainter-vectordeformation.png
\o \inlineimage qpainter-gradients.png
@@ -1196,7 +1196,7 @@ void QPainterPrivate::updateState(QPainterState *newState)
rotate it clockwise and translate() to translate it (i.e. adding a
given offset to the points). You can also twist the coordinate
system around the origin using the shear() function. See the \l
- {demos/affine}{Affine Transformations} demo for a visualization of
+ {painting/affine}{Affine Transformations} example for a visualization of
a sheared coordinate system.
See also the \l {painting/transformations}{Transformations}
@@ -1207,9 +1207,9 @@ void QPainterPrivate::updateState(QPainterState *newState)
\table 100%
\row
\o
- \bold {Affine Transformations Demo}
+ \bold {Affine Transformations Example}
- The \l {demos/affine}{Affine Transformations} demo show Qt's
+ The \l {painting/affine}{Affine Transformations} example shows Qt's
ability to perform affine transformations on painting
operations. The demo also allows the user to experiment with the
transformation operations and see the results immediately.
@@ -1293,8 +1293,8 @@ void QPainterPrivate::updateState(QPainterState *newState)
\o
\bold {Composition Modes Demo}
- The \l {demos/composition}{Composition Modes} demo, available in
- Qt's demo directory, allows you to experiment with the various
+ The \l {painting/composition}{Composition Modes} example, available in
+ Qt's examples directory, allows you to experiment with the various
composition modes and see the results immediately.
\endtable
@@ -2526,8 +2526,6 @@ QRegion QPainter::clipRegion() const
}
if (info.operation == Qt::IntersectClip)
region &= info.region * matrix;
- else if (info.operation == Qt::UniteClip)
- region |= info.region * matrix;
else if (info.operation == Qt::NoClip) {
lastWasNothing = true;
region = QRegion();
@@ -2547,9 +2545,6 @@ QRegion QPainter::clipRegion() const
if (info.operation == Qt::IntersectClip) {
region &= QRegion((info.path * matrix).toFillPolygon().toPolygon(),
info.path.fillRule());
- } else if (info.operation == Qt::UniteClip) {
- region |= QRegion((info.path * matrix).toFillPolygon().toPolygon(),
- info.path.fillRule());
} else if (info.operation == Qt::NoClip) {
lastWasNothing = true;
region = QRegion();
@@ -2573,8 +2568,6 @@ QRegion QPainter::clipRegion() const
region &= matrix.mapRect(info.rect);
else
region &= matrix.map(QRegion(info.rect));
- } else if (info.operation == Qt::UniteClip) {
- region |= QRegion(info.rect) * matrix;
} else if (info.operation == Qt::NoClip) {
lastWasNothing = true;
region = QRegion();
@@ -2597,8 +2590,6 @@ QRegion QPainter::clipRegion() const
region &= matrix.mapRect(info.rectf.toRect());
else
region &= matrix.map(QRegion(info.rectf.toRect()));
- } else if (info.operation == Qt::UniteClip) {
- region |= QRegion(info.rectf.toRect()) * matrix;
} else if (info.operation == Qt::NoClip) {
lastWasNothing = true;
region = QRegion();
@@ -2687,7 +2678,7 @@ QRectF QPainter::clipBoundingRect() const
}
// Accumulate the bounding box in device space. This is not 100%
- // precise, but it fits within the guarantee and it is resonably
+ // precise, but it fits within the guarantee and it is reasonably
// fast.
QRectF bounds;
for (int i=0; i<d->state->clipInfo.size(); ++i) {
@@ -2709,8 +2700,6 @@ QRectF QPainter::clipBoundingRect() const
bounds = r;
else if (info.operation == Qt::IntersectClip)
bounds &= r;
- else if (info.operation == Qt::UniteClip)
- bounds |= r;
}
@@ -2739,7 +2728,7 @@ void QPainter::setClipRect(const QRectF &rect, Qt::ClipOperation op)
Q_D(QPainter);
if (d->extended) {
- if ((!d->state->clipEnabled && op != Qt::NoClip) || (d->state->clipOperation == Qt::NoClip && op == Qt::UniteClip))
+ if ((!d->state->clipEnabled && op != Qt::NoClip))
op = Qt::ReplaceClip;
if (!d->engine) {
@@ -2797,7 +2786,7 @@ void QPainter::setClipRect(const QRect &rect, Qt::ClipOperation op)
return;
}
- if ((!d->state->clipEnabled && op != Qt::NoClip) || (d->state->clipOperation == Qt::NoClip && op == Qt::UniteClip))
+ if ((!d->state->clipEnabled && op != Qt::NoClip))
op = Qt::ReplaceClip;
if (d->extended) {
@@ -2852,7 +2841,7 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op)
return;
}
- if ((!d->state->clipEnabled && op != Qt::NoClip) || (d->state->clipOperation == Qt::NoClip && op == Qt::UniteClip))
+ if ((!d->state->clipEnabled && op != Qt::NoClip))
op = Qt::ReplaceClip;
if (d->extended) {
@@ -3257,7 +3246,7 @@ void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation op)
return;
}
- if ((!d->state->clipEnabled && op != Qt::NoClip) || (d->state->clipOperation == Qt::NoClip && op == Qt::UniteClip))
+ if ((!d->state->clipEnabled && op != Qt::NoClip))
op = Qt::ReplaceClip;
if (d->extended) {
@@ -3374,7 +3363,7 @@ void QPainter::fillPath(const QPainterPath &path, const QBrush &brush)
\endtable
\sa {painting/painterpaths}{the Painter Paths
- example},{demos/deform}{the Vector Deformation demo}
+ example},{painting/deform}{the Vector Deformation example}
*/
void QPainter::drawPath(const QPainterPath &path)
{
@@ -5658,6 +5647,8 @@ void QPainter::drawImage(const QRectF &targetRect, const QImage &image, const QR
}
/*!
+ \fn void QPainter::drawGlyphRun(const QPointF &position, const QGlyphRun &glyphs)
+
Draws the glyphs represented by \a glyphs at \a position. The \a position gives the
edge of the baseline for the string of glyphs. The glyphs will be retrieved from the font
selected on \a glyphs and at offsets given by the positions in \a glyphs.
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index c238578199..8bb599f9f0 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -305,19 +305,19 @@ static void qt_debug_path(const QPainterPath &path)
\section1 Examples
Qt provides the \l {painting/painterpaths}{Painter Paths Example}
- and the \l {demos/deform}{Vector Deformation Demo} which are
- located in Qt's example and demo directories respectively.
+ and the \l {painting/deform}{Vector Deformation example} which are
+ located in Qt's example directory.
The \l {painting/painterpaths}{Painter Paths Example} shows how
painter paths can be used to build complex shapes for rendering
and lets the user experiment with the filling and stroking. The
- \l {demos/deform}{Vector Deformation Demo} shows how to use
+ \l {painting/deform}{Vector Deformation Example} shows how to use
QPainterPath to draw text.
\table
\header
\o \l {painting/painterpaths}{Painter Paths Example}
- \o \l {demos/deform}{Vector Deformation Demo}
+ \o \l {painting/deform}{Vector Deformation Example}
\row
\o \inlineimage qpainterpath-example.png
\o \inlineimage qpainterpath-demo.png
diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp
index cc652d84f2..7185f0d346 100644
--- a/src/gui/painting/qpen.cpp
+++ b/src/gui/painting/qpen.cpp
@@ -214,14 +214,14 @@ typedef QPenPrivate QPenData;
\table 100%
\row
\o \inlineimage qpen-demo.png
- \o \bold {\l {demos/pathstroke}{The Path Stroking Demo}}
+ \o \bold {\l {painting/pathstroke}{The Path Stroking Example}}
- The Path Stroking demo shows Qt's built-in dash patterns and shows
+ The Path Stroking example shows Qt's built-in dash patterns and shows
how custom patterns can be used to extend the range of available
patterns.
\endtable
- \sa QPainter, QBrush, {demos/pathstroke}{Path Stroking Demo},
+ \sa QPainter, QBrush, {painting/pathstroke}{Path Stroking Example},
{Scribble Example}
*/
diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp
index 6c5edbc44d..1d3f581b88 100644
--- a/src/gui/painting/qrasterizer.cpp
+++ b/src/gui/painting/qrasterizer.cpp
@@ -62,8 +62,8 @@ typedef int Q16Dot16;
#define SPAN_BUFFER_SIZE 256
-#define COORD_ROUNDING 0 // 0: round up, 1: round down
-#define COORD_OFFSET 0 // 26.6, 32 is half a pixel
+#define COORD_ROUNDING 1 // 0: round up, 1: round down
+#define COORD_OFFSET 32 // 26.6, 32 is half a pixel
static inline QT_FT_Vector PointToVector(const QPointF &p)
{
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index 4d7b3391a6..e42eec6f96 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -223,8 +223,8 @@ QT_BEGIN_NAMESPACE
\snippet doc/src/snippets/transform/main.cpp 2
\endtable
- \sa QPainter, {Coordinate System}, {demos/affine}{Affine
- Transformations Demo}, {Transformations Example}
+ \sa QPainter, {Coordinate System}, {painting/affine}{Affine
+ Transformations Example}, {Transformations Example}
*/
/*!
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 846d5a3814..b85c045064 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -73,7 +73,8 @@
#include <QtGui/private/qguiapplication_p.h>
#endif
-#include <QMutexLocker>
+#include <QtCore/QMutexLocker>
+#include <QtCore/QMutex>
// #define QFONTCACHE_DEBUG
#ifdef QFONTCACHE_DEBUG
@@ -140,7 +141,7 @@ bool QFontDef::exactMatch(const QFontDef &other) const
&& weight == other.weight
&& style == other.style
&& this_family == other_family
- && styleName == other.styleName
+ && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName)
&& (this_foundry.isEmpty()
|| other_foundry.isEmpty()
|| this_foundry == other_foundry)
diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h
index 4ae31c38d6..ebc842c794 100644
--- a/src/gui/text/qfont_p.h
+++ b/src/gui/text/qfont_p.h
@@ -113,7 +113,7 @@ struct QFontDef
&& styleStrategy == other.styleStrategy
&& ignorePitch == other.ignorePitch && fixedPitch == other.fixedPitch
&& family == other.family
- && styleName == other.styleName
+ && (styleName.isEmpty() || other.styleName.isEmpty() || styleName == other.styleName)
&& hintingPreference == other.hintingPreference
#ifdef Q_WS_X11
&& addStyle == other.addStyle
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 5369ac52f3..98b43d5b5e 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -218,16 +218,17 @@ struct QtFontStyle
Key(const QString &styleString);
Key() : style(QFont::StyleNormal),
weight(QFont::Normal), stretch(0) { }
- Key(const Key &o) : style(o.style),
+ Key(const Key &o) : styleName(o.styleName), style(o.style),
weight(o.weight), stretch(o.stretch) { }
+ QString styleName;
uint style : 2;
signed int weight : 8;
signed int stretch : 12;
bool operator==(const Key & other) {
- return (style == other.style &&
+ return styleName == other.styleName && style == other.style &&
weight == other.weight &&
- (stretch == 0 || other.stretch == 0 || stretch == other.stretch));
+ (stretch == 0 || other.stretch == 0 || stretch == other.stretch);
}
bool operator!=(const Key &other) {
return !operator==(other);
@@ -292,7 +293,7 @@ struct QtFontStyle
};
QtFontStyle::Key::Key(const QString &styleString)
- : style(QFont::StyleNormal), weight(QFont::Normal), stretch(0)
+ : styleName(styleString), style(QFont::StyleNormal), weight(QFont::Normal), stretch(0)
{
weight = getFontWeight(styleString);
@@ -1139,6 +1140,12 @@ static QtFontStyle *bestStyle(QtFontFoundry *foundry, const QtFontStyle::Key &st
for ( int i = 0; i < foundry->count; i++ ) {
QtFontStyle *style = foundry->styles[i];
+ if (!styleKey.styleName.isEmpty() && styleKey.styleName == style->key.styleName) {
+ dist = 0;
+ best = i;
+ break;
+ }
+
int d = qAbs( styleKey.weight - style->key.weight );
if ( styleKey.stretch != 0 && style->key.stretch != 0 ) {
@@ -1532,7 +1539,8 @@ static QString styleStringHelper(int weight, QFont::Style style)
*/
QString QFontDatabase::styleString(const QFont &font)
{
- return styleStringHelper(font.weight(), font.style());
+ return font.styleName().isEmpty() ? styleStringHelper(font.weight(), font.style())
+ : font.styleName();
}
/*!
@@ -1542,7 +1550,8 @@ QString QFontDatabase::styleString(const QFont &font)
*/
QString QFontDatabase::styleString(const QFontInfo &fontInfo)
{
- return styleStringHelper(fontInfo.weight(), fontInfo.style());
+ return fontInfo.styleName().isEmpty() ? styleStringHelper(fontInfo.weight(), fontInfo.style())
+ : fontInfo.styleName();
}
@@ -1793,8 +1802,12 @@ QStringList QFontDatabase::styles(const QString &family) const
}
}
- for (int i = 0; i < allStyles.count; i++)
- l.append(styleStringHelper(allStyles.styles[i]->key.weight, (QFont::Style)allStyles.styles[i]->key.style));
+ for (int i = 0; i < allStyles.count; i++) {
+ l.append(allStyles.styles[i]->key.styleName.isEmpty() ?
+ styleStringHelper(allStyles.styles[i]->key.weight,
+ (QFont::Style)allStyles.styles[i]->key.style) :
+ allStyles.styles[i]->key.styleName);
+ }
return l;
}
@@ -2017,9 +2030,16 @@ QFont QFontDatabase::font(const QString &family, const QString &style,
if (!s) // no styles found?
return QGuiApplication::font();
- QFont fnt(family, pointSize, s->key.weight);
- fnt.setStyle((QFont::Style)s->key.style);
- return fnt;
+ if (s->key.styleName.isEmpty()) {
+ QFont fnt(family, pointSize, s->key.weight);
+ fnt.setStyle((QFont::Style)s->key.style);
+ return fnt;
+ } else {
+ // found a perfect match
+ QFont fnt(family, pointSize);
+ fnt.setStyleName(s->key.styleName);
+ return fnt;
+ }
}
diff --git a/src/gui/text/qfontenginedirectwrite.cpp b/src/gui/text/qfontenginedirectwrite.cpp
index 890cad9824..d6932738f5 100644
--- a/src/gui/text/qfontenginedirectwrite.cpp
+++ b/src/gui/text/qfontenginedirectwrite.cpp
@@ -390,6 +390,60 @@ glyph_metrics_t QFontEngineDirectWrite::boundingBox(const QGlyphLayout &glyphs)
return glyph_metrics_t(0, -m_ascent, w - lastRightBearing(glyphs), m_ascent + m_descent, w, 0);
}
+glyph_metrics_t QFontEngineDirectWrite::alphaMapBoundingBox(glyph_t glyph, QFixed subPixelPosition,
+ const QTransform &matrix,
+ GlyphFormat /*format*/)
+{
+ glyph_metrics_t bbox = QFontEngine::boundingBox(glyph, matrix); // To get transformed advance
+
+ UINT16 glyphIndex = glyph;
+ FLOAT glyphAdvance = 0;
+
+ DWRITE_GLYPH_OFFSET glyphOffset;
+ glyphOffset.advanceOffset = 0;
+ glyphOffset.ascenderOffset = 0;
+
+ DWRITE_GLYPH_RUN glyphRun;
+ glyphRun.fontFace = m_directWriteFontFace;
+ glyphRun.fontEmSize = fontDef.pixelSize;
+ glyphRun.glyphCount = 1;
+ glyphRun.glyphIndices = &glyphIndex;
+ glyphRun.glyphAdvances = &glyphAdvance;
+ glyphRun.isSideways = false;
+ glyphRun.bidiLevel = 0;
+ glyphRun.glyphOffsets = &glyphOffset;
+
+ DWRITE_MATRIX transform;
+ transform.dx = subPixelPosition.toReal();
+ transform.dy = 0;
+ transform.m11 = matrix.m11();
+ transform.m12 = matrix.m12();
+ transform.m21 = matrix.m21();
+ transform.m22 = matrix.m22();
+
+ IDWriteGlyphRunAnalysis *glyphAnalysis = NULL;
+ HRESULT hr = m_directWriteFactory->CreateGlyphRunAnalysis(
+ &glyphRun,
+ 1.0f,
+ &transform,
+ DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC,
+ DWRITE_MEASURING_MODE_NATURAL,
+ 0.0, 0.0,
+ &glyphAnalysis
+ );
+
+ if (SUCCEEDED(hr)) {
+ RECT rect;
+ glyphAnalysis->GetAlphaTextureBounds(DWRITE_TEXTURE_CLEARTYPE_3x1, &rect);
+ glyphAnalysis->Release();
+
+ return glyph_metrics_t(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
+ bbox.xoff, bbox.yoff);
+ } else {
+ return glyph_metrics_t();
+ }
+}
+
glyph_metrics_t QFontEngineDirectWrite::boundingBox(glyph_t g)
{
if (m_directWriteFontFace == 0)
@@ -459,9 +513,10 @@ qreal QFontEngineDirectWrite::maxCharWidth() const
extern uint qt_pow_gamma[256];
-QImage QFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition)
+QImage QFontEngineDirectWrite::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition,
+ const QTransform &xform)
{
- QImage im = imageForGlyph(glyph, subPixelPosition, 0, QTransform());
+ QImage im = imageForGlyph(glyph, subPixelPosition, 0, xform);
QImage indexed(im.width(), im.height(), QImage::Format_Indexed8);
QVector<QRgb> colors(256);
@@ -492,12 +547,8 @@ QImage QFontEngineDirectWrite::imageForGlyph(glyph_t t,
int margin,
const QTransform &xform)
{
- glyph_metrics_t metrics = QFontEngine::boundingBox(t, xform);
- int width = (metrics.width + margin * 2 + 4).ceil().toInt() ;
- int height = (metrics.height + margin * 2 + 4).ceil().toInt();
-
UINT16 glyphIndex = t;
- FLOAT glyphAdvance = metrics.xoff.toReal();
+ FLOAT glyphAdvance = 0;
DWRITE_GLYPH_OFFSET glyphOffset;
glyphOffset.advanceOffset = 0;
@@ -513,12 +564,9 @@ QImage QFontEngineDirectWrite::imageForGlyph(glyph_t t,
glyphRun.bidiLevel = 0;
glyphRun.glyphOffsets = &glyphOffset;
- QFixed x = margin - metrics.x.round() + subPixelPosition;
- QFixed y = margin - metrics.y.floor();
-
DWRITE_MATRIX transform;
- transform.dx = x.toReal();
- transform.dy = y.toReal();
+ transform.dx = subPixelPosition.toReal();
+ transform.dy = 0;
transform.m11 = xform.m11();
transform.m12 = xform.m12();
transform.m21 = xform.m21();
@@ -537,48 +585,54 @@ QImage QFontEngineDirectWrite::imageForGlyph(glyph_t t,
if (SUCCEEDED(hr)) {
RECT rect;
- rect.left = 0;
- rect.top = 0;
- rect.right = width;
- rect.bottom = height;
-
- int size = width * height * 3;
- BYTE *alphaValues = new BYTE[size];
- qMemSet(alphaValues, size, 0);
-
- hr = glyphAnalysis->CreateAlphaTexture(DWRITE_TEXTURE_CLEARTYPE_3x1,
- &rect,
- alphaValues,
- size);
-
- if (SUCCEEDED(hr)) {
- QImage img(width, height, QImage::Format_RGB32);
- img.fill(0xffffffff);
+ glyphAnalysis->GetAlphaTextureBounds(DWRITE_TEXTURE_CLEARTYPE_3x1, &rect);
- for (int y=0; y<height; ++y) {
- uint *dest = reinterpret_cast<uint *>(img.scanLine(y));
- BYTE *src = alphaValues + width * 3 * y;
+ rect.left -= margin;
+ rect.top -= margin;
+ rect.right += margin;
+ rect.bottom += margin;
- for (int x=0; x<width; ++x) {
- dest[x] = *(src) << 16
- | *(src + 1) << 8
- | *(src + 2);
+ int width = rect.right - rect.left;
+ int height = rect.bottom - rect.top;
- src += 3;
+ int size = width * height * 3;
+ if (size > 0) {
+ BYTE *alphaValues = new BYTE[size];
+ qMemSet(alphaValues, size, 0);
+
+ hr = glyphAnalysis->CreateAlphaTexture(DWRITE_TEXTURE_CLEARTYPE_3x1,
+ &rect,
+ alphaValues,
+ size);
+
+ if (SUCCEEDED(hr)) {
+ QImage img(width, height, QImage::Format_RGB32);
+ img.fill(0xffffffff);
+
+ for (int y=0; y<height; ++y) {
+ uint *dest = reinterpret_cast<uint *>(img.scanLine(y));
+ BYTE *src = alphaValues + width * 3 * y;
+
+ for (int x=0; x<width; ++x) {
+ dest[x] = *(src) << 16
+ | *(src + 1) << 8
+ | *(src + 2);
+
+ src += 3;
+ }
}
- }
- delete[] alphaValues;
- glyphAnalysis->Release();
+ delete[] alphaValues;
+ glyphAnalysis->Release();
- return img;
- } else {
- delete[] alphaValues;
- glyphAnalysis->Release();
+ return img;
+ } else {
+ delete[] alphaValues;
+ glyphAnalysis->Release();
- qErrnoWarning("QFontEngineDirectWrite::imageForGlyph: CreateAlphaTexture failed");
+ qErrnoWarning("QFontEngineDirectWrite::imageForGlyph: CreateAlphaTexture failed");
+ }
}
-
} else {
qErrnoWarning("QFontEngineDirectWrite::imageForGlyph: CreateGlyphRunAnalysis failed");
}
diff --git a/src/gui/text/qfontenginedirectwrite_p.h b/src/gui/text/qfontenginedirectwrite_p.h
index d0086fc49b..edf1e6a182 100644
--- a/src/gui/text/qfontenginedirectwrite_p.h
+++ b/src/gui/text/qfontenginedirectwrite_p.h
@@ -86,6 +86,10 @@ public:
glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
glyph_metrics_t boundingBox(glyph_t g);
+ glyph_metrics_t alphaMapBoundingBox(glyph_t glyph,
+ QFixed subPixelPosition,
+ const QTransform &matrix,
+ GlyphFormat format);
QFixed ascent() const;
QFixed descent() const;
@@ -97,7 +101,7 @@ public:
bool supportsSubPixelPositions() const;
- QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition);
+ QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t);
QImage alphaRGBMapForGlyph(glyph_t t, QFixed subPixelPosition, int margin,
const QTransform &xform);
diff --git a/src/gui/text/qglyphrun.cpp b/src/gui/text/qglyphrun.cpp
index 18b6357863..cc825525c4 100644
--- a/src/gui/text/qglyphrun.cpp
+++ b/src/gui/text/qglyphrun.cpp
@@ -175,7 +175,8 @@ QRawFont QGlyphRun::rawFont() const
}
/*!
- Sets the font in which to look up the glyph indexes to \a font.
+ Sets the font in which to look up the glyph indexes to the \a rawFont
+ specified.
\sa rawFont(), setGlyphIndexes()
*/
diff --git a/src/gui/text/qharfbuzz_copy_p.h b/src/gui/text/qharfbuzz_copy_p.h
index 835d8fb1a6..10356e4aea 100644
--- a/src/gui/text/qharfbuzz_copy_p.h
+++ b/src/gui/text/qharfbuzz_copy_p.h
@@ -66,6 +66,13 @@ typedef enum {
HB_Err_Out_Of_Memory = 0xDEAD
} HB_Error;
+typedef enum {
+ HB_NoBreak,
+ HB_SoftHyphen,
+ HB_Break,
+ HB_ForcedBreak
+} HB_LineBreakType;
+
typedef QT_PREPEND_NAMESPACE(quint32) HB_Glyph;
typedef void * HB_Font;
typedef void * HB_Face;
diff --git a/src/gui/text/qplatformfontdatabase_qpa.cpp b/src/gui/text/qplatformfontdatabase_qpa.cpp
index 7e829dbd3f..059dc3e188 100644
--- a/src/gui/text/qplatformfontdatabase_qpa.cpp
+++ b/src/gui/text/qplatformfontdatabase_qpa.cpp
@@ -52,7 +52,7 @@ extern void qt_registerFont(const QString &familyname, const QString &foundrynam
const QSupportedWritingSystems &writingSystems, void *hanlde);
/*!
- \fn void QPlatformFontDatabase::registerQPF2Font(const QByteArray &dataArray, void *)
+ \fn void QPlatformFontDatabase::registerQPF2Font(const QByteArray &dataArray, void *handle)
Registers the pre-rendered QPF2 font contained in the given \a dataArray.
@@ -149,17 +149,26 @@ public:
QVector<bool> vector;
};
+/*!
+ Constructs a new object to handle supported writing systems.
+*/
QSupportedWritingSystems::QSupportedWritingSystems()
{
d = new QWritingSystemsPrivate;
}
+/*!
+ Constructs a copy of the \a other writing systems object.
+*/
QSupportedWritingSystems::QSupportedWritingSystems(const QSupportedWritingSystems &other)
{
d = other.d;
d->ref.ref();
}
+/*!
+ Constructs a copy of the \a other writing systems object.
+*/
QSupportedWritingSystems &QSupportedWritingSystems::operator=(const QSupportedWritingSystems &other)
{
if (d != other.d) {
@@ -171,12 +180,18 @@ QSupportedWritingSystems &QSupportedWritingSystems::operator=(const QSupportedWr
return *this;
}
+/*!
+ Destroys the supported writing systems object.
+*/
QSupportedWritingSystems::~QSupportedWritingSystems()
{
if (!d->ref.deref())
delete d;
}
+/*!
+ \internal
+*/
void QSupportedWritingSystems::detach()
{
if (d->ref != 1) {
@@ -187,12 +202,20 @@ void QSupportedWritingSystems::detach()
}
}
+/*!
+ Sets or clears support for the specified \a writingSystem based on the
+ value given by \a support.
+*/
void QSupportedWritingSystems::setSupported(QFontDatabase::WritingSystem writingSystem, bool support)
{
detach();
d->vector[writingSystem] = support;
}
+/*!
+ Returns true if the writing system specified by \a writingSystem is
+ supported; otherwise returns false.
+*/
bool QSupportedWritingSystems::supported(QFontDatabase::WritingSystem writingSystem) const
{
return d->vector.at(writingSystem);
@@ -210,10 +233,12 @@ bool QSupportedWritingSystems::supported(QFontDatabase::WritingSystem writingSys
*/
/*!
- This function is called once at startup by Qts internal fontdatabase. Reimplement this function
- in a subclass for a convenient place to initialise the internal fontdatabase.
+ This function is called once at startup by Qt's internal font database.
+ Reimplement this function in a subclass for a convenient place to initialize
+ the internal font database.
- The default implementation looks in the fontDir() location and registers all qpf2 fonts.
+ The default implementation looks in the fontDir() location and registers all
+ QPF2 fonts.
*/
void QPlatformFontDatabase::populateFontDatabase()
{
@@ -294,7 +319,7 @@ QStringList QPlatformFontDatabase::addApplicationFont(const QByteArray &fontData
}
/*!
-
+ Releases the specified font \a handle.
*/
void QPlatformFontDatabase::releaseHandle(void *handle)
{
@@ -303,7 +328,7 @@ void QPlatformFontDatabase::releaseHandle(void *handle)
}
/*!
-
+ Returns the directory containing the fonts used by the database.
*/
QString QPlatformFontDatabase::fontDir() const
{
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index 71762df09f..4c65ad5de0 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -393,6 +393,30 @@ qreal QRawFont::unitsPerEm() const
}
/*!
+ Returns the thickness for drawing lines (underline, overline, etc.)
+ along with text drawn in this font.
+ */
+qreal QRawFont::lineThickness() const
+{
+ if (!isValid())
+ return 0.0;
+
+ return d->fontEngine->lineThickness().toReal();
+}
+
+/*!
+ Returns the position from baseline for drawing underlines below the text
+ rendered with this font.
+ */
+qreal QRawFont::underlinePosition() const
+{
+ if (!isValid())
+ return 0.0;
+
+ return d->fontEngine->underlinePosition().toReal();
+}
+
+/*!
Returns the family name of this QRawFont.
*/
QString QRawFont::familyName() const
@@ -652,6 +676,9 @@ extern int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSyst
/*!
Fetches the physical representation based on a \a font query. The physical font returned is
the font that will be preferred by Qt in order to display text in the selected \a writingSystem.
+
+ \warning This function is potentially expensive and should not be called in performance
+ sensitive code.
*/
QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writingSystem)
{
diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h
index aca33af127..e94bd99b8c 100644
--- a/src/gui/text/qrawfont.h
+++ b/src/gui/text/qrawfont.h
@@ -111,6 +111,8 @@ public:
qreal xHeight() const;
qreal averageCharWidth() const;
qreal maxCharWidth() const;
+ qreal lineThickness() const;
+ qreal underlinePosition() const;
qreal unitsPerEm() const;
@@ -133,6 +135,7 @@ public:
private:
friend class QRawFontPrivate;
+ friend class QTextLayout;
void detach();
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index baa9eebb79..10c494dec9 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -425,14 +425,17 @@ namespace {
public:
DrawTextItemRecorder(bool untransformedCoordinates, bool useBackendOptimizations)
: m_dirtyPen(false), m_useBackendOptimizations(useBackendOptimizations),
- m_untransformedCoordinates(untransformedCoordinates)
+ m_untransformedCoordinates(untransformedCoordinates), m_currentColor(Qt::black)
{
}
virtual void updateState(const QPaintEngineState &newState)
{
- if (newState.state() & QPaintEngine::DirtyPen)
+ if (newState.state() & QPaintEngine::DirtyPen
+ && newState.pen().color() != m_currentColor) {
m_dirtyPen = true;
+ m_currentColor = newState.pen().color();
+ }
}
virtual void drawTextItem(const QPointF &position, const QTextItem &textItem)
@@ -448,7 +451,7 @@ namespace {
currentItem.positionOffset = m_glyphs.size(); // Offset into position pool
currentItem.useBackendOptimizations = m_useBackendOptimizations;
if (m_dirtyPen)
- currentItem.color = state->pen().color();
+ currentItem.color = m_currentColor;
QTransform matrix = m_untransformedCoordinates ? QTransform() : state->transform();
matrix.translate(position.x(), position.y());
@@ -519,6 +522,7 @@ namespace {
bool m_dirtyPen;
bool m_useBackendOptimizations;
bool m_untransformedCoordinates;
+ QColor m_currentColor;
};
class DrawTextItemDevice: public QPaintDevice
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 03e00ed0df..918ddcc280 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1002,15 +1002,46 @@ QList<QGlyphRun> QTextLayout::glyphRuns(int from, int length) const
if (length < 0)
length = text().length();
- QList<QGlyphRun> glyphs;
+ QHash<QPair<QFontEngine *, int>, QGlyphRun> glyphRunHash;
for (int i=0; i<d->lines.size(); ++i) {
if (d->lines[i].from > from + length)
break;
- else if (d->lines[i].from + d->lines[i].length >= from)
- glyphs += QTextLine(i, d).glyphRuns(from, length);
+ else if (d->lines[i].from + d->lines[i].length >= from) {
+ QList<QGlyphRun> glyphRuns = QTextLine(i, d).glyphRuns(from, length);
+
+ for (int j = 0; j < glyphRuns.size(); j++) {
+ const QGlyphRun &glyphRun = glyphRuns.at(j);
+ QRawFont rawFont = glyphRun.rawFont();
+
+ QFontEngine *fontEngine = rawFont.d->fontEngine;
+ QTextItem::RenderFlags flags;
+ if (glyphRun.underline())
+ flags |= QTextItem::Underline;
+ if (glyphRun.overline())
+ flags |= QTextItem::Overline;
+ if (glyphRun.strikeOut())
+ flags |= QTextItem::StrikeOut;
+ QPair<QFontEngine *, int> key(fontEngine, int(flags));
+ // merge the glyph runs using the same font
+ if (glyphRunHash.contains(key)) {
+ QGlyphRun &oldGlyphRun = glyphRunHash[key];
+
+ QVector<quint32> indexes = oldGlyphRun.glyphIndexes();
+ QVector<QPointF> positions = oldGlyphRun.positions();
+
+ indexes += glyphRun.glyphIndexes();
+ positions += glyphRun.positions();
+
+ oldGlyphRun.setGlyphIndexes(indexes);
+ oldGlyphRun.setPositions(positions);
+ } else {
+ glyphRunHash[key] = glyphRun;
+ }
+ }
+ }
}
- return glyphs;
+ return glyphRunHash.values();
}
#endif // QT_NO_RAWFONT
@@ -2075,19 +2106,65 @@ static void setPenAndDrawBackground(QPainter *p, const QPen &defaultPen, const Q
}
-namespace {
- struct GlyphInfo
- {
- GlyphInfo(const QGlyphLayout &layout, const QPointF &position,
- const QTextItemInt::RenderFlags &renderFlags)
- : glyphLayout(layout), itemPosition(position), flags(renderFlags)
- {
- }
+static QGlyphRun glyphRunWithInfo(QFontEngine *fontEngine, const QGlyphLayout &glyphLayout,
+ const QPointF &pos, const QTextItem::RenderFlags &flags)
+{
+ QGlyphRun glyphRun;
- QGlyphLayout glyphLayout;
- QPointF itemPosition;
- QTextItem::RenderFlags flags;
- };
+ // Make a font for this particular engine
+ QRawFont font;
+ QRawFontPrivate *fontD = QRawFontPrivate::get(font);
+ fontD->fontEngine = fontEngine;
+ fontD->fontEngine->ref.ref();
+
+#if defined(Q_WS_WIN)
+ if (fontEngine->supportsSubPixelPositions())
+ fontD->hintingPreference = QFont::PreferVerticalHinting;
+ else
+ fontD->hintingPreference = QFont::PreferFullHinting;
+#elif defined(Q_WS_MAC)
+ fontD->hintingPreference = QFont::PreferNoHinting;
+#elif !defined(QT_NO_FREETYPE)
+ if (fontEngine->type() == QFontEngine::Freetype) {
+ QFontEngineFT *freeTypeEngine = static_cast<QFontEngineFT *>(fontEngine);
+ switch (freeTypeEngine->defaultHintStyle()) {
+ case QFontEngineFT::HintNone:
+ fontD->hintingPreference = QFont::PreferNoHinting;
+ break;
+ case QFontEngineFT::HintLight:
+ fontD->hintingPreference = QFont::PreferVerticalHinting;
+ break;
+ case QFontEngineFT::HintMedium:
+ case QFontEngineFT::HintFull:
+ fontD->hintingPreference = QFont::PreferFullHinting;
+ break;
+ };
+ }
+#endif
+
+ QVarLengthArray<glyph_t> glyphsArray;
+ QVarLengthArray<QFixedPoint> positionsArray;
+
+ fontEngine->getGlyphPositions(glyphLayout, QTransform(), flags, glyphsArray,
+ positionsArray);
+ Q_ASSERT(glyphsArray.size() == positionsArray.size());
+
+ QVector<quint32> glyphs;
+ QVector<QPointF> positions;
+ for (int i=0; i<glyphsArray.size(); ++i) {
+ glyphs.append(glyphsArray.at(i) & 0xffffff);
+ positions.append(positionsArray.at(i).toPointF() + pos);
+ }
+
+ glyphRun.setGlyphIndexes(glyphs);
+ glyphRun.setPositions(positions);
+
+ glyphRun.setOverline(flags.testFlag(QTextItem::Overline));
+ glyphRun.setUnderline(flags.testFlag(QTextItem::Underline));
+ glyphRun.setStrikeOut(flags.testFlag(QTextItem::StrikeOut));
+ glyphRun.setRawFont(font);
+
+ return glyphRun;
}
/*!
@@ -2117,10 +2194,9 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
if (length < 0)
length = textLength();
- QHash<QFontEngine *, GlyphInfo> glyphLayoutHash;
-
QTextLineItemIterator iterator(eng, i);
qreal y = line.y.toReal() + line.base().toReal();
+ QList<QGlyphRun> glyphRuns;
while (!iterator.atEnd()) {
QScriptItem &si = iterator.next();
if (si.analysis.flags >= QScriptAnalysis::TabOrObject)
@@ -2191,8 +2267,8 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
continue;
QGlyphLayout subLayout = glyphLayout.mid(start, end - start);
- glyphLayoutHash.insertMulti(multiFontEngine->engine(which),
- GlyphInfo(subLayout, pos, flags));
+ glyphRuns.append(glyphRunWithInfo(multiFontEngine->engine(which),
+ subLayout, pos, flags));
for (int i = 0; i < subLayout.numGlyphs; i++) {
pos += QPointF(subLayout.advances_x[i].toReal(),
subLayout.advances_y[i].toReal());
@@ -2203,101 +2279,15 @@ QList<QGlyphRun> QTextLine::glyphRuns(int from, int length) const
}
QGlyphLayout subLayout = glyphLayout.mid(start, end - start);
- glyphLayoutHash.insertMulti(multiFontEngine->engine(which),
- GlyphInfo(subLayout, pos, flags));
-
+ glyphRuns.append(glyphRunWithInfo(multiFontEngine->engine(which),
+ subLayout, pos, flags));
} else {
- glyphLayoutHash.insertMulti(mainFontEngine,
- GlyphInfo(glyphLayout, pos, flags));
- }
- }
- }
-
- QHash<QPair<QFontEngine *, int>, QGlyphRun> glyphsHash;
-
- QList<QFontEngine *> keys = glyphLayoutHash.uniqueKeys();
- for (int i=0; i<keys.size(); ++i) {
- QFontEngine *fontEngine = keys.at(i);
-
- // Make a font for this particular engine
- QRawFont font;
- QRawFontPrivate *fontD = QRawFontPrivate::get(font);
- fontD->fontEngine = fontEngine;
- fontD->fontEngine->ref.ref();
-
-#if defined(Q_WS_WIN)
- if (fontEngine->supportsSubPixelPositions())
- fontD->hintingPreference = QFont::PreferVerticalHinting;
- else
- fontD->hintingPreference = QFont::PreferFullHinting;
-#elif defined(Q_WS_MAC)
- fontD->hintingPreference = QFont::PreferNoHinting;
-#elif !defined(QT_NO_FREETYPE)
- if (fontEngine->type() == QFontEngine::Freetype) {
- QFontEngineFT *freeTypeEngine = static_cast<QFontEngineFT *>(fontEngine);
- switch (freeTypeEngine->defaultHintStyle()) {
- case QFontEngineFT::HintNone:
- fontD->hintingPreference = QFont::PreferNoHinting;
- break;
- case QFontEngineFT::HintLight:
- fontD->hintingPreference = QFont::PreferVerticalHinting;
- break;
- case QFontEngineFT::HintMedium:
- case QFontEngineFT::HintFull:
- fontD->hintingPreference = QFont::PreferFullHinting;
- break;
- };
- }
-#endif
-
- QList<GlyphInfo> glyphLayouts = glyphLayoutHash.values(fontEngine);
- for (int j=0; j<glyphLayouts.size(); ++j) {
- const QPointF &pos = glyphLayouts.at(j).itemPosition;
- const QGlyphLayout &glyphLayout = glyphLayouts.at(j).glyphLayout;
- const QTextItem::RenderFlags &flags = glyphLayouts.at(j).flags;
-
- QVarLengthArray<glyph_t> glyphsArray;
- QVarLengthArray<QFixedPoint> positionsArray;
-
- fontEngine->getGlyphPositions(glyphLayout, QTransform(), flags, glyphsArray,
- positionsArray);
- Q_ASSERT(glyphsArray.size() == positionsArray.size());
-
- QVector<quint32> glyphs;
- QVector<QPointF> positions;
- for (int i=0; i<glyphsArray.size(); ++i) {
- glyphs.append(glyphsArray.at(i) & 0xffffff);
- positions.append(positionsArray.at(i).toPointF() + pos);
- }
-
- QGlyphRun glyphIndexes;
- glyphIndexes.setGlyphIndexes(glyphs);
- glyphIndexes.setPositions(positions);
-
- glyphIndexes.setOverline(flags.testFlag(QTextItem::Overline));
- glyphIndexes.setUnderline(flags.testFlag(QTextItem::Underline));
- glyphIndexes.setStrikeOut(flags.testFlag(QTextItem::StrikeOut));
- glyphIndexes.setRawFont(font);
-
- QPair<QFontEngine *, int> key(fontEngine, int(flags));
- if (!glyphsHash.contains(key)) {
- glyphsHash.insert(key, glyphIndexes);
- } else {
- QGlyphRun &glyphRun = glyphsHash[key];
-
- QVector<quint32> indexes = glyphRun.glyphIndexes();
- QVector<QPointF> positions = glyphRun.positions();
-
- indexes += glyphIndexes.glyphIndexes();
- positions += glyphIndexes.positions();
-
- glyphRun.setGlyphIndexes(indexes);
- glyphRun.setPositions(positions);
+ glyphRuns.append(glyphRunWithInfo(mainFontEngine, glyphLayout, pos, flags));
}
}
}
- return glyphsHash.values();
+ return glyphRuns;
}
#endif // QT_NO_RAWFONT
diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp
index 50a3b1edaa..a7f96fa463 100644
--- a/src/network/access/qftp.cpp
+++ b/src/network/access/qftp.cpp
@@ -1434,36 +1434,6 @@ QFtp::QFtp(QObject *parent)
SIGNAL(listInfo(QUrlInfo)));
}
-#ifdef QT3_SUPPORT
-/*!
- Use one of the constructors that doesn't take the \a name
- argument and then use setObjectName() instead.
-*/
-QFtp::QFtp(QObject *parent, const char *name)
- : QObject(*new QFtpPrivate, parent)
-{
- Q_D(QFtp);
- setObjectName(QLatin1String(name));
- d->errorString = tr("Unknown error");
-
- connect(&d->pi, SIGNAL(connectState(int)),
- SLOT(_q_piConnectState(int)));
- connect(&d->pi, SIGNAL(finished(QString)),
- SLOT(_q_piFinished(QString)));
- connect(&d->pi, SIGNAL(error(int,QString)),
- SLOT(_q_piError(int,QString)));
- connect(&d->pi, SIGNAL(rawFtpReply(int,QString)),
- SLOT(_q_piFtpReply(int,QString)));
-
- connect(&d->pi.dtp, SIGNAL(readyRead()),
- SIGNAL(readyRead()));
- connect(&d->pi.dtp, SIGNAL(dataTransferProgress(qint64,qint64)),
- SIGNAL(dataTransferProgress(qint64,qint64)));
- connect(&d->pi.dtp, SIGNAL(listInfo(QUrlInfo)),
- SIGNAL(listInfo(QUrlInfo)));
-}
-#endif
-
/*!
\enum QFtp::State
diff --git a/src/network/access/qftp.h b/src/network/access/qftp.h
index 2a58344780..671b9ba7c7 100644
--- a/src/network/access/qftp.h
+++ b/src/network/access/qftp.h
@@ -124,10 +124,6 @@ public:
qint64 bytesAvailable() const;
qint64 read(char *data, qint64 maxlen);
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT qint64 readBlock(char *data, quint64 maxlen)
- { return read(data, qint64(maxlen)); }
-#endif
QByteArray readAll();
int currentId() const;
@@ -155,11 +151,6 @@ Q_SIGNALS:
void commandFinished(int, bool);
void done(bool);
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QFtp(QObject *parent, const char *name);
-#endif
-
private:
Q_DISABLE_COPY(QFtp)
Q_DECLARE_PRIVATE(QFtp)
diff --git a/src/network/access/qhttp.h b/src/network/access/qhttp.h
index 9018b767ff..83b23f85f9 100644
--- a/src/network/access/qhttp.h
+++ b/src/network/access/qhttp.h
@@ -232,10 +232,6 @@ public:
qint64 bytesAvailable() const;
qint64 read(char *data, qint64 maxlen);
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT qint64 readBlock(char *data, quint64 maxlen)
- { return read(data, qint64(maxlen)); }
-#endif
QByteArray readAll();
int currentId() const;
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index d950af4ee2..a8a4fd9ae7 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -46,6 +46,7 @@
#include <private/qnetworkrequest_p.h>
#include <private/qobject_p.h>
#include <private/qauthenticator_p.h>
+#include "private/qhostinfo_p.h"
#include <qnetworkproxy.h>
#include <qauthenticator.h>
@@ -83,7 +84,8 @@ const int QHttpNetworkConnectionPrivate::defaultRePipelineLength = 2;
QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(const QString &hostName, quint16 port, bool encrypt)
: state(RunningState),
hostName(hostName), port(port), encrypt(encrypt),
- channelCount(defaultChannelCount)
+ channelCount(defaultChannelCount),
+ networkLayerState(Unknown)
#ifndef QT_NO_NETWORKPROXY
, networkProxy(QNetworkProxy::NoProxy)
#endif
@@ -94,7 +96,8 @@ QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(const QString &host
QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(quint16 channelCount, const QString &hostName, quint16 port, bool encrypt)
: state(RunningState),
hostName(hostName), port(port), encrypt(encrypt),
- channelCount(channelCount)
+ channelCount(channelCount),
+ networkLayerState(Unknown)
#ifndef QT_NO_NETWORKPROXY
, networkProxy(QNetworkProxy::NoProxy)
#endif
@@ -174,6 +177,45 @@ int QHttpNetworkConnectionPrivate::indexOf(QAbstractSocket *socket) const
return 0;
}
+// If the connection is in the InProgress state channel errors should not always be
+// emitted. This function will check the status of the connection channels if we
+// have not decided the networkLayerState and will return true if the channel error
+// should be emitted by the channel.
+bool QHttpNetworkConnectionPrivate::shouldEmitChannelError(QAbstractSocket *socket)
+{
+ Q_Q(QHttpNetworkConnection);
+
+ bool emitError = true;
+ int i = indexOf(socket);
+ int otherSocket = (i == 0 ? 1 : 0);
+
+ if (networkLayerState == QHttpNetworkConnectionPrivate::InProgress) {
+ if (channels[otherSocket].isSocketBusy() && (channels[otherSocket].state != QHttpNetworkConnectionChannel::ClosingState)) {
+ // this was the first socket to fail.
+ channels[i].close();
+ emitError = false;
+ }
+ else {
+ // Both connection attempts has failed.
+ networkLayerState = QHttpNetworkConnectionPrivate::Unknown;
+ channels[i].close();
+ emitError = true;
+ }
+ } else {
+ if ((networkLayerState == QHttpNetworkConnectionPrivate::IPv4) && (channels[i].networkLayerPreference != QAbstractSocket::IPv4Protocol)
+ || (networkLayerState == QHttpNetworkConnectionPrivate::IPv6) && (channels[i].networkLayerPreference != QAbstractSocket::IPv6Protocol)) {
+ // First connection worked so this is the second one to complete and it failed.
+ channels[i].close();
+ QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection);
+ emitError = false;
+ }
+ if (networkLayerState == QHttpNetworkConnectionPrivate::Unknown)
+ qWarning() << "We got a connection error when networkLayerState is Unknown";
+ }
+ return emitError;
+}
+
+
qint64 QHttpNetworkConnectionPrivate::uncompressedBytesAvailable(const QHttpNetworkReply &reply) const
{
return reply.d_func()->responseData.byteAmount();
@@ -469,17 +511,23 @@ QHttpNetworkReply* QHttpNetworkConnectionPrivate::queueRequest(const QHttpNetwor
break;
}
- // this used to be called via invokeMethod and a QueuedConnection
- // It is the only place _q_startNextRequest is called directly without going
- // through the event loop using a QueuedConnection.
- // This is dangerous because of recursion that might occur when emitting
- // signals as DirectConnection from this code path. Therefore all signal
- // emissions that can come out from this code path need to
- // be QueuedConnection.
- // We are currently trying to fine-tune this.
- _q_startNextRequest();
-
-
+ // For Happy Eyeballs the networkLayerState is set to Unkown
+ // untill we have started the first connection attempt. So no
+ // request will be started untill we know if IPv4 or IPv6
+ // should be used.
+ if (networkLayerState == Unknown) {
+ startHostInfoLookup();
+ } else if ( networkLayerState == IPv4 || networkLayerState == IPv6 ) {
+ // this used to be called via invokeMethod and a QueuedConnection
+ // It is the only place _q_startNextRequest is called directly without going
+ // through the event loop using a QueuedConnection.
+ // This is dangerous because of recursion that might occur when emitting
+ // signals as DirectConnection from this code path. Therefore all signal
+ // emissions that can come out from this code path need to
+ // be QueuedConnection.
+ // We are currently trying to fine-tune this.
+ _q_startNextRequest();
+ }
return reply;
}
@@ -781,6 +829,10 @@ void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply)
// although it is called _q_startNextRequest, it will actually start multiple requests when possible
void QHttpNetworkConnectionPrivate::_q_startNextRequest()
{
+ // If there is no network layer state decided we should not start any new requests.
+ if (networkLayerState == Unknown || networkLayerState == InProgress)
+ return;
+
// If the QHttpNetworkConnection is currently paused then bail out immediately
if (state == PausedState)
return;
@@ -830,11 +882,15 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest()
// connected or not. This is to reuse connected channels before we connect new once.
int queuedRequest = highPriorityQueue.count() + lowPriorityQueue.count();
for (int i = 0; i < channelCount; ++i) {
- if (channels[i].socket->state() == QAbstractSocket::ConnectingState)
+ if ((channels[i].socket->state() == QAbstractSocket::ConnectingState) || (channels[i].socket->state() == QAbstractSocket::HostLookupState))
queuedRequest--;
if ( queuedRequest <=0 )
break;
if (!channels[i].reply && !channels[i].isSocketBusy() && (channels[i].socket->state() == QAbstractSocket::UnconnectedState)) {
+ if (networkLayerState == IPv4)
+ channels[i].networkLayerPreference = QAbstractSocket::IPv4Protocol;
+ else if (networkLayerState == IPv6)
+ channels[i].networkLayerPreference = QAbstractSocket::IPv6Protocol;
channels[i].ensureConnection();
queuedRequest--;
}
@@ -853,6 +909,100 @@ void QHttpNetworkConnectionPrivate::readMoreLater(QHttpNetworkReply *reply)
}
}
+
+
+// The first time we start the connection is used we do not know if we
+// should use IPv4 or IPv6. So we start a hostlookup to figure this out.
+// Later when we do the connection the socket will not need to do another
+// lookup as then the hostinfo will already be in the cache.
+void QHttpNetworkConnectionPrivate::startHostInfoLookup()
+{
+ // At this time all channels should be unconnected.
+ Q_ASSERT(!channels[0].isSocketBusy());
+ Q_ASSERT(!channels[1].isSocketBusy());
+
+ networkLayerState = InProgress;
+
+ // check if we already now can descide if this is IPv4 or IPv6
+ QHostAddress temp;
+ if (temp.setAddress(hostName)) {
+ if (temp.protocol() == QAbstractSocket::IPv4Protocol) {
+ networkLayerState = QHttpNetworkConnectionPrivate::IPv4;
+ QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);
+ return;
+ } else if (temp.protocol() == QAbstractSocket::IPv6Protocol) {
+ networkLayerState = QHttpNetworkConnectionPrivate::IPv6;
+ QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);
+ return;
+ }
+ } else {
+ int hostLookupId;
+ bool immediateResultValid = false;
+ QHostInfo hostInfo = qt_qhostinfo_lookup(hostName,
+ this->q_func(),
+ SLOT(_q_hostLookupFinished(QHostInfo)),
+ &immediateResultValid,
+ &hostLookupId);
+ if (immediateResultValid) {
+ _q_hostLookupFinished(hostInfo);
+ }
+ }
+}
+
+
+void QHttpNetworkConnectionPrivate::_q_hostLookupFinished(QHostInfo info)
+{
+ bool bIpv4 = false;
+ bool bIpv6 = false;
+
+ foreach (QHostAddress address, info.addresses()) {
+ if (address.protocol() == QAbstractSocket::IPv4Protocol)
+ bIpv4 = true;
+ else if (address.protocol() == QAbstractSocket::IPv6Protocol)
+ bIpv6 = true;
+ }
+
+ if (bIpv4 && bIpv6)
+ startNetworkLayerStateLookup();
+ else if (bIpv4) {
+ networkLayerState = QHttpNetworkConnectionPrivate::IPv4;
+ QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);
+ } else if (bIpv6) {
+ networkLayerState = QHttpNetworkConnectionPrivate::IPv6;
+ QMetaObject::invokeMethod(this->q_func(), "_q_startNextRequest", Qt::QueuedConnection);
+ } else {
+ if (dequeueRequest(channels[0].socket)) {
+ emitReplyError(channels[0].socket, channels[0].reply, QNetworkReply::HostNotFoundError);
+ networkLayerState = QHttpNetworkConnectionPrivate::Unknown;
+ } else {
+ // Should not happen
+ qWarning() << "QHttpNetworkConnectionPrivate::_q_hostLookupFinished could not dequeu request";
+ networkLayerState = QHttpNetworkConnectionPrivate::Unknown;
+ }
+ }
+}
+
+
+// This will be used if the host lookup found both and Ipv4 and
+// Ipv6 address. Then we will start up two connections and pick
+// the network layer of the one that finish first. The second
+// connection will then be disconnected.
+void QHttpNetworkConnectionPrivate::startNetworkLayerStateLookup()
+{
+ // At this time all channels should be unconnected.
+ Q_ASSERT(!channels[0].isSocketBusy());
+ Q_ASSERT(!channels[1].isSocketBusy());
+
+ networkLayerState = InProgress;
+
+ channels[0].networkLayerPreference = QAbstractSocket::IPv4Protocol;
+ channels[1].networkLayerPreference = QAbstractSocket::IPv6Protocol;
+
+ channels[0].ensureConnection(); // Possibly delay this one..
+ channels[1].ensureConnection();
+}
+
+
#ifndef QT_NO_BEARERMANAGEMENT
QHttpNetworkConnection::QHttpNetworkConnection(const QString &hostName, quint16 port, bool encrypt, QObject *parent, QSharedPointer<QNetworkSession> networkSession)
: QObject(*(new QHttpNetworkConnectionPrivate(hostName, port, encrypt)), parent)
diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h
index 6c953be58d..0c86fd94b9 100644
--- a/src/network/access/qhttpnetworkconnection_p.h
+++ b/src/network/access/qhttpnetworkconnection_p.h
@@ -82,6 +82,7 @@ QT_BEGIN_NAMESPACE
class QHttpNetworkRequest;
class QHttpNetworkReply;
class QByteArray;
+class QHostInfo;
class QHttpNetworkConnectionPrivate;
class Q_AUTOTEST_EXPORT QHttpNetworkConnection : public QObject
@@ -132,6 +133,7 @@ private:
friend class QHttpNetworkConnectionChannel;
Q_PRIVATE_SLOT(d_func(), void _q_startNextRequest())
+ Q_PRIVATE_SLOT(d_func(), void _q_hostLookupFinished(QHostInfo))
};
@@ -152,6 +154,13 @@ public:
PausedState = 1,
};
+ enum NetworkLayerPreferenceState {
+ Unknown,
+ InProgress,
+ IPv4,
+ IPv6
+ };
+
QHttpNetworkConnectionPrivate(const QString &hostName, quint16 port, bool encrypt);
QHttpNetworkConnectionPrivate(quint16 channelCount, const QString &hostName, quint16 port, bool encrypt);
~QHttpNetworkConnectionPrivate();
@@ -160,6 +169,7 @@ public:
void pauseConnection();
void resumeConnection();
ConnectionState state;
+ NetworkLayerPreferenceState networkLayerState;
enum { ChunkSize = 4096 };
@@ -179,9 +189,14 @@ public:
void copyCredentials(int fromChannel, QAuthenticator *auth, bool isProxy);
+ void startHostInfoLookup();
+ void startNetworkLayerStateLookup();
+
// private slots
void _q_startNextRequest(); // send the next request from the queue
+ void _q_hostLookupFinished(QHostInfo info);
+
void createAuthorization(QAbstractSocket *socket, QHttpNetworkRequest &request);
QString errorDetail(QNetworkReply::NetworkError errorCode, QAbstractSocket *socket,
@@ -198,6 +213,7 @@ public:
const int channelCount;
QHttpNetworkConnectionChannel *channels; // parallel connections to the server
+ bool shouldEmitChannelError(QAbstractSocket *socket);
qint64 uncompressedBytesAvailable(const QHttpNetworkReply &reply) const;
qint64 uncompressedBytesAvailableNextBlock(const QHttpNetworkReply &reply) const;
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 7c644ad4b9..b8ed8ee567 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -80,6 +80,7 @@ QHttpNetworkConnectionChannel::QHttpNetworkConnectionChannel()
#endif
, pipeliningSupported(PipeliningSupportUnknown)
, connection(0)
+ , networkLayerPreference(QAbstractSocket::AnyIPProtocol)
{
// Inlining this function in the header leads to compiler error on
// release-armv5, on at least timebox 9.2 and 10.1.
@@ -594,7 +595,7 @@ bool QHttpNetworkConnectionChannel::ensureConnection()
if (ssl) {
#ifndef QT_NO_OPENSSL
QSslSocket *sslSocket = qobject_cast<QSslSocket*>(socket);
- sslSocket->connectToHostEncrypted(connectHost, connectPort);
+ sslSocket->connectToHostEncrypted(connectHost, connectPort, QIODevice::ReadWrite, networkLayerPreference);
if (ignoreAllSslErrors)
sslSocket->ignoreSslErrors();
sslSocket->ignoreSslErrors(ignoreSslErrorsList);
@@ -613,12 +614,12 @@ bool QHttpNetworkConnectionChannel::ensureConnection()
&& connection->cacheProxy().type() == QNetworkProxy::NoProxy
&& connection->transparentProxy().type() == QNetworkProxy::NoProxy) {
#endif
- socket->connectToHost(connectHost, connectPort, QIODevice::ReadWrite | QIODevice::Unbuffered);
+ socket->connectToHost(connectHost, connectPort, QIODevice::ReadWrite | QIODevice::Unbuffered, networkLayerPreference);
// For an Unbuffered QTcpSocket, the read buffer size has a special meaning.
socket->setReadBufferSize(1*1024);
#ifndef QT_NO_NETWORKPROXY
} else {
- socket->connectToHost(connectHost, connectPort);
+ socket->connectToHost(connectHost, connectPort, QIODevice::ReadWrite, networkLayerPreference);
// limit the socket read buffer size. we will read everything into
// the QHttpNetworkReply anyway, so let's grow only that and not
@@ -1002,6 +1003,25 @@ void QHttpNetworkConnectionChannel::_q_disconnected()
void QHttpNetworkConnectionChannel::_q_connected()
{
+ // For the Happy Eyeballs we need to check if this is the first channel to connect.
+ if (!pendingEncrypt) {
+ if (connection->d_func()->networkLayerState == QHttpNetworkConnectionPrivate::InProgress) {
+ if (networkLayerPreference == QAbstractSocket::IPv4Protocol)
+ connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv4;
+ else if (networkLayerPreference == QAbstractSocket::IPv6Protocol)
+ connection->d_func()->networkLayerState = QHttpNetworkConnectionPrivate::IPv6;
+ } else {
+ if (((connection->d_func()->networkLayerState == QHttpNetworkConnectionPrivate::IPv4) && (networkLayerPreference != QAbstractSocket::IPv4Protocol))
+ || ((connection->d_func()->networkLayerState == QHttpNetworkConnectionPrivate::IPv6) && (networkLayerPreference != QAbstractSocket::IPv6Protocol))) {
+ close();
+ // This is the second connection so it has to be closed and we can schedule it for another request.
+ QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
+ return;
+ }
+ //The connections networkLayerState had already been decided.
+ }
+ }
+
// improve performance since we get the request sent by the kernel ASAP
//socket->setSocketOption(QAbstractSocket::LowDelayOption, 1);
// We have this commented out now. It did not have the effect we wanted. If we want to
@@ -1089,6 +1109,11 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket
QPointer<QHttpNetworkConnection> that = connection;
QString errorString = connection->d_func()->errorDetail(errorCode, socket, socket->errorString());
+ // In the InProgress state the channel should not emit the error.
+ // This will instead be handled by the connection.
+ if (!connection->d_func()->shouldEmitChannelError(socket))
+ return;
+
// Need to dequeu the request so that we can emit the error.
if (!reply)
connection->d_func()->dequeueRequest(socket);
diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h
index f635cc9557..8400f62ab9 100644
--- a/src/network/access/qhttpnetworkconnectionchannel_p.h
+++ b/src/network/access/qhttpnetworkconnectionchannel_p.h
@@ -136,6 +136,8 @@ public:
void detectPipeliningSupport();
QHttpNetworkConnectionChannel();
+
+ QAbstractSocket::NetworkLayerProtocol networkLayerPreference;
void setConnection(QHttpNetworkConnection *c);
QPointer<QHttpNetworkConnection> connection;
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index f4c905f007..df0a32dd6c 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -365,6 +365,7 @@ qint64 QNetworkReplyHttpImpl::readData(char* data, qint64 maxlen)
void QNetworkReplyHttpImpl::setReadBufferSize(qint64 size)
{
+ Q_UNUSED(size);
// FIXME, unsupported right now
return;
}
@@ -379,7 +380,8 @@ bool QNetworkReplyHttpImpl::canReadLine () const
if (d->cacheLoadDevice)
return d->cacheLoadDevice->canReadLine() || d->downloadMultiBuffer.canReadLine();
- // FIXME zerocopy buffer?
+ if (d->downloadZerocopyBuffer)
+ return memchr(d->downloadZerocopyBuffer + d->downloadBufferReadPosition, '\n', d->downloadBufferCurrentSize - d->downloadBufferReadPosition);
return d->downloadMultiBuffer.canReadLine();
}
@@ -876,6 +878,7 @@ void QNetworkReplyHttpImplPrivate::postRequest()
delegate->isPipeliningUsed,
QSharedPointer<char>(),
delegate->incomingContentLength);
+ replyDownloadData(delegate->synchronousDownloadData);
httpError(delegate->incomingErrorCode, delegate->incomingErrorDetail);
} else {
replyDownloadMetaData
@@ -1168,7 +1171,6 @@ void QNetworkReplyHttpImplPrivate::replyDownloadProgressSlot(qint64 bytesReceive
void QNetworkReplyHttpImplPrivate::httpAuthenticationRequired(const QHttpNetworkRequest &,
QAuthenticator *auth)
{
- Q_Q(QNetworkReplyHttpImpl);
managerPrivate->authenticationRequired(auth, q_func(), synchronous, url, &urlForLastAuthentication);
}
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index 5608f1f9a3..7f61ef9239 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -77,28 +77,33 @@ QT_BEGIN_NAMESPACE
List of known header types that QNetworkRequest parses. Each known
header is also represented in raw form with its full HTTP name.
- \value ContentTypeHeader corresponds to the HTTP Content-Type
+ \value ContentDispositionHeader Corresponds to the HTTP
+ Content-Disposition header and contains a string containing the
+ disposition type (for instance, attachment) and a parameter (for
+ instance, filename).
+
+ \value ContentTypeHeader Corresponds to the HTTP Content-Type
header and contains a string containing the media (MIME) type and
- any auxiliary data (for instance, charset)
+ any auxiliary data (for instance, charset).
- \value ContentLengthHeader corresponds to the HTTP Content-Length
+ \value ContentLengthHeader Corresponds to the HTTP Content-Length
header and contains the length in bytes of the data transmitted.
- \value LocationHeader corresponds to the HTTP Location
+ \value LocationHeader Corresponds to the HTTP Location
header and contains a URL representing the actual location of the
data, including the destination URL in case of redirections.
- \value LastModifiedHeader corresponds to the HTTP Last-Modified
+ \value LastModifiedHeader Corresponds to the HTTP Last-Modified
header and contains a QDateTime representing the last modification
- date of the contents
+ date of the contents.
- \value CookieHeader corresponds to the HTTP Cookie header
+ \value CookieHeader Corresponds to the HTTP Cookie header
and contains a QList<QNetworkCookie> representing the cookies to
- be sent back to the server
+ be sent back to the server.
- \value SetCookieHeader corresponds to the HTTP Set-Cookie
+ \value SetCookieHeader Corresponds to the HTTP Set-Cookie
header and contains a QList<QNetworkCookie> representing the
- cookies sent by the server to be stored locally
+ cookies sent by the server to be stored locally.
\sa header(), setHeader(), rawHeader(), setRawHeader()
*/
diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp
index bff351c34f..3dd7461a75 100644
--- a/src/network/kernel/qhostaddress.cpp
+++ b/src/network/kernel/qhostaddress.cpp
@@ -38,19 +38,18 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
#include "qhostaddress.h"
#include "qhostaddress_p.h"
#include "qdebug.h"
+#if defined(Q_OS_WIN)
+#include <winsock2.h>
+#endif
#include "qplatformdefs.h"
#include "qstringlist.h"
#include "qendian.h"
#ifndef QT_NO_DATASTREAM
#include <qdatastream.h>
#endif
-#if defined(Q_OS_WINCE)
-#include <winsock.h>
-#endif
#ifdef QT_LINUXBASE
# include <arpa/inet.h>
@@ -65,7 +64,6 @@ QT_BEGIN_NAMESPACE
} while (0)
#ifdef Q_OS_WIN
-# if !defined (QT_NO_IPV6)
// sockaddr_in6 size changed between old and new SDK
// Only the new version is the correct one, so always
// use this structure.
@@ -90,12 +88,6 @@ typedef struct {
struct qt_in6_addr sin6_addr; /* IPv6 address */
u_long sin6_scope_id; /* set of interfaces for a scope */
} qt_sockaddr_in6;
-# else
-typedef void * qt_sockaddr_in6 ;
-# endif
-# ifndef AF_INET6
-# define AF_INET6 23 /* Internetwork Version 6 */
-# endif
#else
#define qt_sockaddr_in6 sockaddr_in6
#define qt_s6_addr s6_addr
@@ -545,10 +537,8 @@ QHostAddress::QHostAddress(const struct sockaddr *sockaddr)
{
if (sockaddr->sa_family == AF_INET)
setAddress(htonl(((sockaddr_in *)sockaddr)->sin_addr.s_addr));
-#ifndef QT_NO_IPV6
else if (sockaddr->sa_family == AF_INET6)
setAddress(((qt_sockaddr_in6 *)sockaddr)->sin6_addr.qt_s6_addr);
-#endif
}
/*!
@@ -700,10 +690,8 @@ void QHostAddress::setAddress(const struct sockaddr *sockaddr)
clear();
if (sockaddr->sa_family == AF_INET)
setAddress(htonl(((sockaddr_in *)sockaddr)->sin_addr.s_addr));
-#ifndef QT_NO_IPV6
else if (sockaddr->sa_family == AF_INET6)
setAddress(((qt_sockaddr_in6 *)sockaddr)->sin6_addr.qt_s6_addr);
-#endif
}
/*!
diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h
index efb3198fc0..3d364de6e6 100644
--- a/src/network/kernel/qhostaddress.h
+++ b/src/network/kernel/qhostaddress.h
@@ -117,15 +117,6 @@ public:
bool isNull() const;
void clear();
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT quint32 ip4Addr() const { return toIPv4Address(); }
- inline QT3_SUPPORT bool isIPv4Address() const { return protocol() == QAbstractSocket::IPv4Protocol
- || protocol() == QAbstractSocket::UnknownNetworkLayerProtocol; }
- inline QT3_SUPPORT bool isIp4Addr() const { return protocol() == QAbstractSocket::IPv4Protocol
- || protocol() == QAbstractSocket::UnknownNetworkLayerProtocol; }
- inline QT3_SUPPORT bool isIPv6Address() const { return protocol() == QAbstractSocket::IPv6Protocol; }
-#endif
-
bool isInSubnet(const QHostAddress &subnet, int netmask) const;
bool isInSubnet(const QPair<QHostAddress, int> &subnet) const;
diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index 0a56bc309a..37444ae2d9 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -149,9 +149,7 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
// Reverse lookups using getnameinfo are broken on darwin, use gethostbyaddr instead.
#if !defined (QT_NO_GETADDRINFO) && !defined (Q_OS_DARWIN)
sockaddr_in sa4;
-#ifndef QT_NO_IPV6
sockaddr_in6 sa6;
-#endif
sockaddr *sa = 0;
QT_SOCKLEN_T saSize = 0;
if (address.protocol() == QAbstractSocket::IPv4Protocol) {
@@ -161,7 +159,6 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
sa4.sin_family = AF_INET;
sa4.sin_addr.s_addr = htonl(address.toIPv4Address());
}
-#ifndef QT_NO_IPV6
else {
sa = (sockaddr *)&sa6;
saSize = sizeof(sa6);
@@ -169,7 +166,6 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
sa6.sin6_family = AF_INET6;
memcpy(sa6.sin6_addr.s6_addr, address.toIPv6Address().c, sizeof(sa6.sin6_addr.s6_addr));
}
-#endif
char hbuf[NI_MAXHOST];
if (sa && getnameinfo(sa, saSize, hbuf, sizeof(hbuf), 0, 0, 0) == 0)
@@ -231,7 +227,6 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
if (!addresses.contains(addr))
addresses.append(addr);
}
-#ifndef QT_NO_IPV6
else if (node->ai_family == AF_INET6) {
QHostAddress addr;
sockaddr_in6 *sa6 = (sockaddr_in6 *) node->ai_addr;
@@ -241,7 +236,6 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
if (!addresses.contains(addr))
addresses.append(addr);
}
-#endif
node = node->ai_next;
}
if (addresses.isEmpty() && node == 0) {
diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp
index 0ce21f905f..528e195ef6 100644
--- a/src/network/kernel/qnetworkinterface_unix.cpp
+++ b/src/network/kernel/qnetworkinterface_unix.cpp
@@ -80,10 +80,9 @@ static QHostAddress addressFromSockaddr(sockaddr *sa)
if (sa->sa_family == AF_INET)
address.setAddress(htonl(((sockaddr_in *)sa)->sin_addr.s_addr));
-#ifndef QT_NO_IPV6
else if (sa->sa_family == AF_INET6)
address.setAddress(((sockaddr_in6 *)sa)->sin6_addr.s6_addr);
-#endif
+
return address;
}
diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp
index 4f9836e863..1062663b23 100644
--- a/src/network/kernel/qnetworkproxy.cpp
+++ b/src/network/kernel/qnetworkproxy.cpp
@@ -1191,6 +1191,11 @@ void QNetworkProxyQuery::setUrl(const QUrl &url)
}
#ifndef QT_NO_BEARERMANAGEMENT
+/*!
+ Returns the network configuration component of the query.
+
+ \sa setNetworkConfiguration()
+*/
QNetworkConfiguration QNetworkProxyQuery::networkConfiguration() const
{
return d ? d->config : QNetworkConfiguration();
@@ -1206,7 +1211,7 @@ QNetworkConfiguration QNetworkProxyQuery::networkConfiguration() const
you should first start the QNetworkSession and obtain the active
configuration from its properties.
- \sa networkConfiguration
+ \sa networkConfiguration()
*/
void QNetworkProxyQuery::setNetworkConfiguration(const QNetworkConfiguration &networkConfiguration)
{
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 5316626638..b662a75259 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -483,7 +483,8 @@ QAbstractSocketPrivate::QAbstractSocketPrivate()
hostLookupId(-1),
socketType(QAbstractSocket::UnknownSocketType),
state(QAbstractSocket::UnconnectedState),
- socketError(QAbstractSocket::UnknownSocketError)
+ socketError(QAbstractSocket::UnknownSocketError),
+ preferredNetworkLayerProtocol(QAbstractSocket::UnknownNetworkLayerProtocol)
{
}
@@ -892,6 +893,7 @@ void QAbstractSocketPrivate::startConnectingByName(const QString &host)
void QAbstractSocketPrivate::_q_startConnecting(const QHostInfo &hostInfo)
{
Q_Q(QAbstractSocket);
+ addresses.clear();
if (state != QAbstractSocket::HostLookupState)
return;
@@ -899,7 +901,16 @@ void QAbstractSocketPrivate::_q_startConnecting(const QHostInfo &hostInfo)
qWarning("QAbstractSocketPrivate::_q_startConnecting() received hostInfo for wrong lookup ID %d expected %d", hostInfo.lookupId(), hostLookupId);
}
- addresses = hostInfo.addresses();
+ // Only add the addresses for the prefered network layer.
+ // Or all if prefered network layer is not set.
+ if (preferredNetworkLayerProtocol == QAbstractSocket::UnknownNetworkLayerProtocol || preferredNetworkLayerProtocol == QAbstractSocket::AnyIPProtocol) {
+ addresses = hostInfo.addresses();
+ } else {
+ foreach (QHostAddress address, hostInfo.addresses())
+ if (address.protocol() == preferredNetworkLayerProtocol)
+ addresses += address;
+ }
+
#if defined(QABSTRACTSOCKET_DEBUG)
QString s = QLatin1String("{");
@@ -993,17 +1004,6 @@ void QAbstractSocketPrivate::_q_connectToNextAddress()
host.toString().toLatin1().constData(), port, addresses.count());
#endif
-#if defined(QT_NO_IPV6)
- if (host.protocol() == QAbstractSocket::IPv6Protocol) {
- // If we have no IPv6 support, then we will not be able to
- // connect. So we just pretend we didn't see this address.
-#if defined(QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocketPrivate::_q_connectToNextAddress(), skipping IPv6 entry");
-#endif
- continue;
- }
-#endif
-
if (!initSocketLayer(host.protocol())) {
// hope that the next address is better
#if defined(QABSTRACTSOCKET_DEBUG)
@@ -1330,8 +1330,12 @@ bool QAbstractSocket::isValid() const
\sa state(), peerName(), peerAddress(), peerPort(), waitForConnected()
*/
void QAbstractSocket::connectToHost(const QString &hostName, quint16 port,
- OpenMode openMode)
+ OpenMode openMode,
+ NetworkLayerProtocol protocol)
{
+ Q_D(QAbstractSocket);
+ d->preferredNetworkLayerProtocol = protocol;
+
QMetaObject::invokeMethod(this, "connectToHostImplementation",
Qt::DirectConnection,
Q_ARG(QString, hostName),
@@ -2501,10 +2505,6 @@ void QAbstractSocket::disconnectFromHostImplementation()
return;
}
-#ifdef QT3_SUPPORT
- emit connectionClosed(); // compat signal
-#endif
-
// Disable and delete read notification
if (d->socketEngine)
d->socketEngine->setReadNotificationEnabled(false);
@@ -2567,9 +2567,6 @@ void QAbstractSocket::disconnectFromHostImplementation()
emit stateChanged(d->state);
emit readChannelFinished(); // we got an EOF
-#ifdef QT3_SUPPORT
- emit delayedCloseFinished(); // compat signal
-#endif
// only emit disconnected if we were connected before
if (previousState == ConnectedState || previousState == ClosingState)
emit disconnected();
@@ -2747,78 +2744,6 @@ QNetworkProxy QAbstractSocket::proxy() const
}
#endif // QT_NO_NETWORKPROXY
-#ifdef QT3_SUPPORT
-/*!
- \enum QAbstractSocket::Error
- \compat
-
- Use QAbstractSocket::SocketError instead.
-
- \value ErrConnectionRefused Use QAbstractSocket::ConnectionRefusedError instead.
- \value ErrHostNotFound Use QAbstractSocket::HostNotFoundError instead.
- \value ErrSocketRead Use QAbstractSocket::UnknownSocketError instead.
-*/
-
-/*!
- \typedef QAbstractSocket::State
- \compat
-
- Use QAbstractSocket::SocketState instead.
-
- \table
- \header \o Qt 3 enum value \o Qt 4 enum value
- \row \o \c Idle \o \l UnconnectedState
- \row \o \c HostLookup \o \l HostLookupState
- \row \o \c Connecting \o \l ConnectingState
- \row \o \c Connected \o \l ConnectedState
- \row \o \c Closing \o \l ClosingState
- \row \o \c Connection \o \l ConnectedState
- \endtable
-*/
-
-/*!
- \fn int QAbstractSocket::socket() const
-
- Use socketDescriptor() instead.
-*/
-
-/*!
- \fn void QAbstractSocket::setSocket(int socket)
-
- Use setSocketDescriptor() instead.
-*/
-
-/*!
- \fn Q_ULONG QAbstractSocket::waitForMore(int msecs, bool *timeout = 0) const
-
- Use waitForReadyRead() instead.
-
- \oldcode
- bool timeout;
- Q_ULONG numBytes = socket->waitForMore(30000, &timeout);
- \newcode
- qint64 numBytes = 0;
- if (socket->waitForReadyRead(msecs))
- numBytes = socket->bytesAvailable();
- bool timeout = (error() == QAbstractSocket::SocketTimeoutError);
- \endcode
-
- \sa waitForReadyRead(), bytesAvailable(), error(), SocketTimeoutError
-*/
-
-/*!
- \fn void QAbstractSocket::connectionClosed()
-
- Use disconnected() instead.
-*/
-
-/*!
- \fn void QAbstractSocket::delayedCloseFinished()
-
- Use disconnected() instead.
-*/
-#endif // QT3_SUPPORT
-
#ifndef QT_NO_DEBUG_STREAM
Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, QAbstractSocket::SocketError error)
{
diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h
index 2717ceb58a..b757092915 100644
--- a/src/network/socket/qabstractsocket.h
+++ b/src/network/socket/qabstractsocket.h
@@ -108,15 +108,6 @@ public:
BoundState,
ListeningState,
ClosingState
-#ifdef QT3_SUPPORT
- ,
- Idle = UnconnectedState,
- HostLookup = HostLookupState,
- Connecting = ConnectingState,
- Connected = ConnectedState,
- Closing = ClosingState,
- Connection = ConnectedState
-#endif
};
enum SocketOption {
LowDelayOption, // TCP_NODELAY
@@ -129,7 +120,7 @@ public:
virtual ~QAbstractSocket();
// ### Qt 5: Make connectToHost() and disconnectFromHost() virtual.
- void connectToHost(const QString &hostName, quint16 port, OpenMode mode = ReadWrite);
+ void connectToHost(const QString &hostName, quint16 port, OpenMode mode = ReadWrite, NetworkLayerProtocol protocol = AnyIPProtocol);
void connectToHost(const QHostAddress &address, quint16 port, OpenMode mode = ReadWrite);
void disconnectFromHost();
@@ -221,32 +212,6 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_abortConnectionAttempt())
Q_PRIVATE_SLOT(d_func(), void _q_testConnection())
Q_PRIVATE_SLOT(d_func(), void _q_forceDisconnect())
-
-#ifdef QT3_SUPPORT
-public:
- enum Error {
- ErrConnectionRefused = ConnectionRefusedError,
- ErrHostNotFound = HostNotFoundError,
- ErrSocketRead = UnknownSocketError
- };
- inline QT3_SUPPORT int socket() const { return socketDescriptor(); }
- inline QT3_SUPPORT void setSocket(int socket) { setSocketDescriptor(socket); }
- inline QT3_SUPPORT qulonglong waitForMore(int msecs, bool *timeout = 0) const
- {
- QAbstractSocket *that = const_cast<QAbstractSocket *>(this);
- if (that->waitForReadyRead(msecs))
- return qulonglong(bytesAvailable());
- if (error() == SocketTimeoutError && timeout)
- *timeout = true;
- return 0;
- }
- typedef SocketState State;
-Q_SIGNALS:
- QT_MOC_COMPAT void connectionClosed(); // same as disconnected()
- QT_MOC_COMPAT void delayedCloseFinished(); // same as disconnected()
-
-
-#endif
};
#ifndef QT_NO_DEBUG_STREAM
diff --git a/src/network/socket/qabstractsocket_p.h b/src/network/socket/qabstractsocket_p.h
index cf7d98895f..978fb1433a 100644
--- a/src/network/socket/qabstractsocket_p.h
+++ b/src/network/socket/qabstractsocket_p.h
@@ -156,6 +156,8 @@ public:
QAbstractSocket::SocketError socketError;
+ QAbstractSocket::NetworkLayerProtocol preferredNetworkLayerProtocol;
+
bool prePauseReadSocketNotifierState;
bool prePauseWriteSocketNotifierState;
bool prePauseExceptionSocketNotifierState;
diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp
index 875852265e..2dc6a40d99 100644
--- a/src/network/socket/qnativesocketengine.cpp
+++ b/src/network/socket/qnativesocketengine.cpp
@@ -203,6 +203,7 @@ void QNativeSocketEnginePrivate::setError(QAbstractSocket::SocketError error, Er
case BroadcastingInitFailedErrorString:
socketErrorString = QNativeSocketEngine::tr("Unable to initialize broadcast socket");
break;
+ // should not happen anymore
case NoIpV6ErrorString:
socketErrorString = QNativeSocketEngine::tr("Attempt to use IPv6 socket on a platform with no IPv6 support");
break;
@@ -345,14 +346,6 @@ bool QNativeSocketEngine::initialize(QAbstractSocket::SocketType socketType, QAb
if (isValid())
close();
-#if defined(QT_NO_IPV6)
- if (protocol == QAbstractSocket::IPv6Protocol) {
- d->setError(QAbstractSocket::UnsupportedSocketOperationError,
- QNativeSocketEnginePrivate::NoIpV6ErrorString);
- return false;
- }
-#endif
-
// Create the socket
if (!d->createNewSocket(socketType, protocol)) {
#if defined (QNATIVESOCKETENGINE_DEBUG)
@@ -511,13 +504,6 @@ bool QNativeSocketEngine::connectToHost(const QHostAddress &address, quint16 por
Q_D(QNativeSocketEngine);
Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::connectToHost(), false);
-#if defined (QT_NO_IPV6)
- if (address.protocol() == QAbstractSocket::IPv6Protocol) {
- d->setError(QAbstractSocket::UnsupportedSocketOperationError,
- QNativeSocketEnginePrivate::NoIpV6ErrorString);
- return false;
- }
-#endif
if (!d->checkProxy(address))
return false;
@@ -581,13 +567,6 @@ bool QNativeSocketEngine::bind(const QHostAddress &address, quint16 port)
Q_D(QNativeSocketEngine);
Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::bind(), false);
-#if defined (QT_NO_IPV6)
- if (address.protocol() == QAbstractSocket::IPv6Protocol) {
- d->setError(QAbstractSocket::UnsupportedSocketOperationError,
- QNativeSocketEnginePrivate::NoIpV6ErrorString);
- return false;
- }
-#endif
if (!d->checkProxy(address))
return false;
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index 26053981ce..246b5ede9b 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -124,7 +124,6 @@ static void qt_ignore_sigpipe()
*/
static inline void qt_socket_getPortAndAddress(const qt_sockaddr *s, quint16 *port, QHostAddress *addr)
{
-#if !defined(QT_NO_IPV6)
if (s->a.sa_family == AF_INET6) {
Q_IPV6ADDR tmp;
memcpy(&tmp, &s->a6.sin6_addr, sizeof(tmp));
@@ -144,7 +143,7 @@ static inline void qt_socket_getPortAndAddress(const qt_sockaddr *s, quint16 *po
*port = ntohs(s->a6.sin6_port);
return;
}
-#endif
+
if (port)
*port = ntohs(s->a4.sin_port);
if (addr) {
@@ -162,12 +161,7 @@ static inline void qt_socket_getPortAndAddress(const qt_sockaddr *s, quint16 *po
bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType socketType,
QAbstractSocket::NetworkLayerProtocol socketProtocol)
{
-#ifndef QT_NO_IPV6
int protocol = (socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) ? AF_INET6 : AF_INET;
-#else
- Q_UNUSED(socketProtocol);
- int protocol = AF_INET;
-#endif
int type = (socketType == QAbstractSocket::UdpSocket) ? SOCK_DGRAM : SOCK_STREAM;
int socket = qt_safe_socket(protocol, type, 0);
@@ -238,24 +232,20 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co
n = SO_KEEPALIVE;
break;
case QNativeSocketEngine::MulticastTtlOption:
-#ifndef QT_NO_IPV6
if (socketProtocol == QAbstractSocket::IPv6Protocol) {
level = IPPROTO_IPV6;
n = IPV6_MULTICAST_HOPS;
} else
-#endif
{
level = IPPROTO_IP;
n = IP_MULTICAST_TTL;
}
break;
case QNativeSocketEngine::MulticastLoopbackOption:
-#ifndef QT_NO_IPV6
if (socketProtocol == QAbstractSocket::IPv6Protocol) {
level = IPPROTO_IPV6;
n = IPV6_MULTICAST_LOOP;
} else
-#endif
{
level = IPPROTO_IP;
n = IP_MULTICAST_LOOP;
@@ -343,24 +333,20 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
n = SO_KEEPALIVE;
break;
case QNativeSocketEngine::MulticastTtlOption:
-#ifndef QT_NO_IPV6
if (socketProtocol == QAbstractSocket::IPv6Protocol) {
level = IPPROTO_IPV6;
n = IPV6_MULTICAST_HOPS;
} else
-#endif
{
level = IPPROTO_IP;
n = IP_MULTICAST_TTL;
}
break;
case QNativeSocketEngine::MulticastLoopbackOption:
-#ifndef QT_NO_IPV6
if (socketProtocol == QAbstractSocket::IPv6Protocol) {
level = IPPROTO_IPV6;
n = IPV6_MULTICAST_LOOP;
} else
-#endif
{
level = IPPROTO_IP;
n = IP_MULTICAST_LOOP;
@@ -381,7 +367,6 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &addr, quint16
struct sockaddr *sockAddrPtr = 0;
QT_SOCKLEN_T sockAddrSize = 0;
-#if !defined(QT_NO_IPV6)
struct sockaddr_in6 sockAddrIPv6;
if (addr.protocol() == QAbstractSocket::IPv6Protocol) {
@@ -402,10 +387,6 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &addr, quint16
sockAddrSize = sizeof(sockAddrIPv6);
sockAddrPtr = (struct sockaddr *) &sockAddrIPv6;
} else
-#if 0
- {}
-#endif
-#endif
if (addr.protocol() == QAbstractSocket::IPv4Protocol) {
memset(&sockAddrIPv4, 0, sizeof(sockAddrIPv4));
sockAddrIPv4.sin_family = AF_INET;
@@ -492,7 +473,7 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &address, quint16
struct sockaddr *sockAddrPtr = 0;
QT_SOCKLEN_T sockAddrSize = 0;
-#if !defined(QT_NO_IPV6)
+
struct sockaddr_in6 sockAddrIPv6;
if (address.protocol() == QAbstractSocket::IPv6Protocol || address.protocol() == QAbstractSocket::AnyIPProtocol) {
@@ -516,7 +497,6 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &address, quint16
sockAddrSize = sizeof(sockAddrIPv6);
sockAddrPtr = (struct sockaddr *) &sockAddrIPv6;
} else
-#endif
if (address.protocol() == QAbstractSocket::IPv4Protocol) {
memset(&sockAddrIPv4, 0, sizeof(sockAddrIPv4));
sockAddrIPv4.sin_family = AF_INET;
@@ -612,7 +592,6 @@ static bool multicastMembershipHelper(QNativeSocketEnginePrivate *d,
int sockArgSize;
ip_mreq mreq4;
-#ifndef QT_NO_IPV6
ipv6_mreq mreq6;
if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) {
@@ -625,7 +604,6 @@ static bool multicastMembershipHelper(QNativeSocketEnginePrivate *d,
memcpy(&mreq6.ipv6mr_multiaddr, &ip6, sizeof(ip6));
mreq6.ipv6mr_interface = interface.index();
} else
-#endif
if (groupAddress.protocol() == QAbstractSocket::IPv4Protocol) {
level = IPPROTO_IP;
sockOpt = how4;
@@ -679,11 +657,7 @@ bool QNativeSocketEnginePrivate::nativeJoinMulticastGroup(const QHostAddress &gr
const QNetworkInterface &interface)
{
return multicastMembershipHelper(this,
-#ifndef QT_NO_IPV6
IPV6_JOIN_GROUP,
-#else
- 0,
-#endif
IP_ADD_MEMBERSHIP,
groupAddress,
interface);
@@ -693,11 +667,7 @@ bool QNativeSocketEnginePrivate::nativeLeaveMulticastGroup(const QHostAddress &g
const QNetworkInterface &interface)
{
return multicastMembershipHelper(this,
-#ifndef QT_NO_IPV6
IPV6_LEAVE_GROUP,
-#else
- 0,
-#endif
IP_DROP_MEMBERSHIP,
groupAddress,
interface);
@@ -705,7 +675,6 @@ bool QNativeSocketEnginePrivate::nativeLeaveMulticastGroup(const QHostAddress &g
QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const
{
-#ifndef QT_NO_IPV6
if (socketProtocol == QAbstractSocket::IPv6Protocol) {
uint v;
QT_SOCKOPTLEN_T sizeofv = sizeof(v);
@@ -713,7 +682,6 @@ QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const
return QNetworkInterface();
return QNetworkInterface::interfaceFromIndex(v);
}
-#endif
struct in_addr v = { 0 };
QT_SOCKOPTLEN_T sizeofv = sizeof(v);
@@ -737,12 +705,10 @@ QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const
bool QNativeSocketEnginePrivate::nativeSetMulticastInterface(const QNetworkInterface &iface)
{
-#ifndef QT_NO_IPV6
if (socketProtocol == QAbstractSocket::IPv6Protocol) {
uint v = iface.index();
return (::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_MULTICAST_IF, &v, sizeof(v)) != -1);
}
-#endif
struct in_addr v;
if (iface.isValid()) {
@@ -871,7 +837,6 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l
struct sockaddr *sockAddrPtr = 0;
QT_SOCKLEN_T sockAddrSize = 0;
-#if !defined(QT_NO_IPV6)
struct sockaddr_in6 sockAddrIPv6;
if (host.protocol() == QAbstractSocket::IPv6Protocol
|| socketProtocol == QAbstractSocket::IPv6Protocol) {
@@ -884,7 +849,7 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l
sockAddrSize = sizeof(sockAddrIPv6);
sockAddrPtr = (struct sockaddr *)&sockAddrIPv6;
} else
-#endif
+
if (host.protocol() == QAbstractSocket::IPv4Protocol) {
memset(&sockAddrIPv4, 0, sizeof(sockAddrIPv4));
sockAddrIPv4.sin_family = AF_INET;
@@ -941,11 +906,9 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters()
case AF_INET:
socketProtocol = QAbstractSocket::IPv4Protocol;
break;
-#if !defined (QT_NO_IPV6)
case AF_INET6:
socketProtocol = QAbstractSocket::IPv6Protocol;
break;
-#endif
default:
socketProtocol = QAbstractSocket::UnknownNetworkLayerProtocol;
break;
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp
index ba62bd6da2..67a9a2131a 100644
--- a/src/network/socket/qnativesocketengine_win.cpp
+++ b/src/network/socket/qnativesocketengine_win.cpp
@@ -165,7 +165,6 @@ static QByteArray qt_prettyDebug(const char *data, int len, int maxLength)
*/
static inline void qt_socket_getPortAndAddress(SOCKET socketDescriptor, const qt_sockaddr *sa, quint16 *port, QHostAddress *address)
{
-#if !defined (QT_NO_IPV6)
if (sa->a.sa_family == AF_INET6) {
const qt_sockaddr_in6 *sa6 = &sa->a6;
Q_IPV6ADDR tmp;
@@ -178,7 +177,7 @@ static inline void qt_socket_getPortAndAddress(SOCKET socketDescriptor, const qt
if (port)
WSANtohs(socketDescriptor, sa6->sin6_port, port);
} else
-#endif
+
if (sa->a.sa_family == AF_INET) {
const sockaddr_in *sa4 = &sa->a4;
unsigned long addr;
@@ -200,7 +199,7 @@ static inline void qt_socket_getPortAndAddress(SOCKET socketDescriptor, const qt
void QNativeSocketEnginePrivate::setPortAndAddress(sockaddr_in * sockAddrIPv4, qt_sockaddr_in6 * sockAddrIPv6,
quint16 port, const QHostAddress & address, sockaddr ** sockAddrPtr, QT_SOCKLEN_T *sockAddrSize)
{
-#if !defined(QT_NO_IPV6)
+
if (address.protocol() == QAbstractSocket::IPv6Protocol
|| address.protocol() == QAbstractSocket::AnyIPProtocol
|| socketProtocol == QAbstractSocket::IPv6Protocol) {
@@ -213,7 +212,7 @@ void QNativeSocketEnginePrivate::setPortAndAddress(sockaddr_in * sockAddrIPv4, q
*sockAddrSize = sizeof(qt_sockaddr_in6);
*sockAddrPtr = (struct sockaddr *) sockAddrIPv6;
} else
-#endif
+
if (address.protocol() == QAbstractSocket::IPv4Protocol
|| address.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol) {
memset(sockAddrIPv4, 0, sizeof(sockaddr_in));
@@ -403,24 +402,21 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co
n = SO_KEEPALIVE;
break;
case QNativeSocketEngine::MulticastTtlOption:
-#ifndef QT_NO_IPV6
+
if (socketProtocol == QAbstractSocket::IPv6Protocol) {
level = IPPROTO_IPV6;
n = IPV6_MULTICAST_HOPS;
} else
-#endif
{
level = IPPROTO_IP;
n = IP_MULTICAST_TTL;
}
break;
case QNativeSocketEngine::MulticastLoopbackOption:
-#ifndef QT_NO_IPV6
if (socketProtocol == QAbstractSocket::IPv6Protocol) {
level = IPPROTO_IPV6;
n = IPV6_MULTICAST_LOOP;
} else
-#endif
{
level = IPPROTO_IP;
n = IP_MULTICAST_LOOP;
@@ -487,24 +483,20 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
n = SO_KEEPALIVE;
break;
case QNativeSocketEngine::MulticastTtlOption:
-#ifndef QT_NO_IPV6
if (socketProtocol == QAbstractSocket::IPv6Protocol) {
level = IPPROTO_IPV6;
n = IPV6_MULTICAST_HOPS;
} else
-#endif
{
level = IPPROTO_IP;
n = IP_MULTICAST_TTL;
}
break;
case QNativeSocketEngine::MulticastLoopbackOption:
-#ifndef QT_NO_IPV6
if (socketProtocol == QAbstractSocket::IPv6Protocol) {
level = IPPROTO_IPV6;
n = IPV6_MULTICAST_LOOP;
} else
-#endif
{
level = IPPROTO_IP;
n = IP_MULTICAST_LOOP;
@@ -545,11 +537,9 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters()
case AF_INET:
socketProtocol = QAbstractSocket::IPv4Protocol;
break;
-#if !defined (QT_NO_IPV6)
case AF_INET6:
socketProtocol = QAbstractSocket::IPv6Protocol;
break;
-#endif
default:
socketProtocol = QAbstractSocket::UnknownNetworkLayerProtocol;
break;
@@ -714,7 +704,7 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &a, quint16 port)
// binding to a multicast address
address = QHostAddress(QHostAddress::AnyIPv6);
}
-#if !defined (QT_NO_IPV6) && defined (IPV6_V6ONLY)
+#if defined (IPV6_V6ONLY)
//This is default in current windows versions, it may change in future so set it explicitly
if (QSysInfo::windowsVersion() >= QSysInfo::WV_6_0) {
ipv6only = 1;
@@ -729,7 +719,7 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &a, quint16 port)
}
break;
case QAbstractSocket::AnyIPProtocol:
-#if !defined (QT_NO_IPV6) && defined (IPV6_V6ONLY)
+#if defined (IPV6_V6ONLY)
if (QSysInfo::windowsVersion() >= QSysInfo::WV_6_0)
ipv6only = ::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&ipv6only, sizeof(ipv6only) );
else
@@ -849,7 +839,6 @@ static bool multicastMembershipHelper(QNativeSocketEnginePrivate *d,
int sockArgSize;
struct ip_mreq mreq4;
-#ifndef QT_NO_IPV6
struct ipv6_mreq mreq6;
if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) {
@@ -862,7 +851,7 @@ static bool multicastMembershipHelper(QNativeSocketEnginePrivate *d,
memcpy(&mreq6.ipv6mr_multiaddr, &ip6, sizeof(ip6));
mreq6.ipv6mr_interface = iface.index();
} else
-#endif
+
if (groupAddress.protocol() == QAbstractSocket::IPv4Protocol) {
level = IPPROTO_IP;
sockOpt = how4;
@@ -904,11 +893,7 @@ bool QNativeSocketEnginePrivate::nativeJoinMulticastGroup(const QHostAddress &gr
const QNetworkInterface &iface)
{
return multicastMembershipHelper(this,
-#ifndef QT_NO_IPV6
IPV6_JOIN_GROUP,
-#else
- 0,
-#endif
IP_ADD_MEMBERSHIP,
groupAddress,
iface);
@@ -918,11 +903,7 @@ bool QNativeSocketEnginePrivate::nativeLeaveMulticastGroup(const QHostAddress &g
const QNetworkInterface &iface)
{
return multicastMembershipHelper(this,
-#ifndef QT_NO_IPV6
IPV6_LEAVE_GROUP,
-#else
- 0,
-#endif
IP_DROP_MEMBERSHIP,
groupAddress,
iface);
@@ -930,7 +911,6 @@ bool QNativeSocketEnginePrivate::nativeLeaveMulticastGroup(const QHostAddress &g
QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const
{
-#ifndef QT_NO_IPV6
if (socketProtocol == QAbstractSocket::IPv6Protocol) {
uint v;
QT_SOCKOPTLEN_T sizeofv = sizeof(v);
@@ -938,7 +918,6 @@ QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const
return QNetworkInterface();
return QNetworkInterface::interfaceFromIndex(v);
}
-#endif
struct in_addr v;
v.s_addr = 0;
@@ -965,12 +944,11 @@ QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const
bool QNativeSocketEnginePrivate::nativeSetMulticastInterface(const QNetworkInterface &iface)
{
-#ifndef QT_NO_IPV6
+
if (socketProtocol == QAbstractSocket::IPv6Protocol) {
uint v = iface.isValid() ? iface.index() : 0;
return (::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_MULTICAST_IF, (char *) &v, sizeof(v)) != -1);
}
-#endif
struct in_addr v;
if (iface.isValid()) {
diff --git a/src/network/socket/qudpsocket.cpp b/src/network/socket/qudpsocket.cpp
index 6bc93dd7f0..009ce92d8e 100644
--- a/src/network/socket/qudpsocket.cpp
+++ b/src/network/socket/qudpsocket.cpp
@@ -192,15 +192,6 @@ bool QUdpSocketPrivate::doEnsureInitialized(const QHostAddress &bindAddress, qui
proto = address->protocol();
}
-#if defined(QT_NO_IPV6)
- Q_Q(QUdpSocket);
- if (proto == QUdpSocket::IPv6Protocol) {
- socketError = QUdpSocket::UnsupportedSocketOperationError;
- q->setErrorString(QUdpSocket::tr("This platform does not support IPv6"));
- return false;
- }
-#endif
-
// now check if the socket engine is initialized and to the right type
if (!socketEngine || !socketEngine->isValid()) {
resolveProxy(remoteAddress.toString(), bindPort);
diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp
index 6100c68a2d..7403590f8c 100644
--- a/src/network/ssl/qsslcertificate.cpp
+++ b/src/network/ssl/qsslcertificate.cpp
@@ -307,6 +307,9 @@ static QString _q_SubjectInfoToString(QSslCertificate::SubjectInfo info)
case QSslCertificate::OrganizationalUnitName: str = QLatin1String("OU"); break;
case QSslCertificate::CountryName: str = QLatin1String("C"); break;
case QSslCertificate::StateOrProvinceName: str = QLatin1String("ST"); break;
+ case QSslCertificate::DistinguishedNameQualifier: str = QLatin1String("dnQualifier"); break;
+ case QSslCertificate::SerialNumber: str = QLatin1String("serialNumber"); break;
+ case QSslCertificate::EmailAddress: str = QLatin1String("emailAddress"); break;
}
return str;
}
@@ -320,14 +323,14 @@ static QString _q_SubjectInfoToString(QSslCertificate::SubjectInfo info)
\sa subjectInfo()
*/
-QString QSslCertificate::issuerInfo(SubjectInfo info) const
+QStringList QSslCertificate::issuerInfo(SubjectInfo info) const
{
// lazy init
if (d->issuerInfo.isEmpty() && d->x509)
d->issuerInfo =
_q_mapFromX509Name(q_X509_get_issuer_name(d->x509));
- return d->issuerInfo.value(_q_SubjectInfoToString(info));
+ return d->issuerInfo.values(_q_SubjectInfoToString(info));
}
/*!
@@ -337,14 +340,14 @@ QString QSslCertificate::issuerInfo(SubjectInfo info) const
\sa subjectInfo()
*/
-QString QSslCertificate::issuerInfo(const QByteArray &tag) const
+QStringList QSslCertificate::issuerInfo(const QByteArray &tag) const
{
// lazy init
if (d->issuerInfo.isEmpty() && d->x509)
d->issuerInfo =
_q_mapFromX509Name(q_X509_get_issuer_name(d->x509));
- return d->issuerInfo.value(QString::fromLatin1(tag));
+ return d->issuerInfo.values(QString::fromLatin1(tag));
}
/*!
@@ -356,14 +359,14 @@ QString QSslCertificate::issuerInfo(const QByteArray &tag) const
\sa issuerInfo()
*/
-QString QSslCertificate::subjectInfo(SubjectInfo info) const
+QStringList QSslCertificate::subjectInfo(SubjectInfo info) const
{
// lazy init
if (d->subjectInfo.isEmpty() && d->x509)
d->subjectInfo =
_q_mapFromX509Name(q_X509_get_subject_name(d->x509));
- return d->subjectInfo.value(_q_SubjectInfoToString(info));
+ return d->subjectInfo.values(_q_SubjectInfoToString(info));
}
/*!
@@ -372,14 +375,14 @@ QString QSslCertificate::subjectInfo(SubjectInfo info) const
\sa issuerInfo()
*/
-QString QSslCertificate::subjectInfo(const QByteArray &tag) const
+QStringList QSslCertificate::subjectInfo(const QByteArray &tag) const
{
// lazy init
if (d->subjectInfo.isEmpty() && d->x509)
d->subjectInfo =
_q_mapFromX509Name(q_X509_get_subject_name(d->x509));
- return d->subjectInfo.value(QString::fromLatin1(tag));
+ return d->subjectInfo.values(QString::fromLatin1(tag));
}
/*!
@@ -711,7 +714,7 @@ static QMap<QString, QString> _q_mapFromX509Name(X509_NAME *name)
const char *obj = q_OBJ_nid2sn(q_OBJ_obj2nid(q_X509_NAME_ENTRY_get_object(e)));
unsigned char *data = 0;
int size = q_ASN1_STRING_to_UTF8(&data, q_X509_NAME_ENTRY_get_data(e));
- info[QString::fromUtf8(obj)] = QString::fromUtf8((char*)data, size);
+ info.insertMulti(QString::fromUtf8(obj), QString::fromUtf8((char*)data, size));
q_CRYPTO_free(data);
}
return info;
@@ -867,6 +870,9 @@ QDebug operator<<(QDebug debug, QSslCertificate::SubjectInfo info)
case QSslCertificate::LocalityName: debug << "LocalityName"; break;
case QSslCertificate::OrganizationalUnitName: debug << "OrganizationalUnitName"; break;
case QSslCertificate::StateOrProvinceName: debug << "StateOrProvinceName"; break;
+ case QSslCertificate::DistinguishedNameQualifier: debug << "DistinguishedNameQualifier"; break;
+ case QSslCertificate::SerialNumber: debug << "SerialNumber"; break;
+ case QSslCertificate::EmailAddress: debug << "EmailAddress"; break;
}
return debug;
}
diff --git a/src/network/ssl/qsslcertificate.h b/src/network/ssl/qsslcertificate.h
index b942bd8a25..8abaa3f73e 100644
--- a/src/network/ssl/qsslcertificate.h
+++ b/src/network/ssl/qsslcertificate.h
@@ -76,7 +76,10 @@ public:
LocalityName,
OrganizationalUnitName,
CountryName,
- StateOrProvinceName
+ StateOrProvinceName,
+ DistinguishedNameQualifier,
+ SerialNumber,
+ EmailAddress
};
QSslCertificate(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem);
@@ -96,10 +99,10 @@ public:
QByteArray version() const;
QByteArray serialNumber() const;
QByteArray digest(QCryptographicHash::Algorithm algorithm = QCryptographicHash::Md5) const;
- QString issuerInfo(SubjectInfo info) const;
- QString issuerInfo(const QByteArray &tag) const;
- QString subjectInfo(SubjectInfo info) const;
- QString subjectInfo(const QByteArray &tag) const;
+ QStringList issuerInfo(SubjectInfo info) const;
+ QStringList issuerInfo(const QByteArray &tag) const;
+ QStringList subjectInfo(SubjectInfo info) const;
+ QStringList subjectInfo(const QByteArray &tag) const;
QMultiMap<QSsl::AlternateNameEntryType, QString> alternateSubjectNames() const;
QDateTime effectiveDate() const;
QDateTime expiryDate() const;
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index df61fb6c18..f191ed9324 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -405,7 +405,7 @@ QSslSocket::~QSslSocket()
\sa connectToHost(), startClientEncryption(), waitForConnected(), waitForEncrypted()
*/
-void QSslSocket::connectToHostEncrypted(const QString &hostName, quint16 port, OpenMode mode)
+void QSslSocket::connectToHostEncrypted(const QString &hostName, quint16 port, OpenMode mode, NetworkLayerProtocol protocol)
{
Q_D(QSslSocket);
if (d->state == ConnectedState || d->state == ConnectingState) {
@@ -419,7 +419,7 @@ void QSslSocket::connectToHostEncrypted(const QString &hostName, quint16 port, O
// Note: When connecting to localhost, some platforms (e.g., HP-UX and some BSDs)
// establish the connection immediately (i.e., first attempt).
- connectToHost(hostName, port, mode);
+ connectToHost(hostName, port, mode, protocol);
}
/*!
@@ -434,7 +434,8 @@ void QSslSocket::connectToHostEncrypted(const QString &hostName, quint16 port, O
\sa connectToHostEncrypted()
*/
void QSslSocket::connectToHostEncrypted(const QString &hostName, quint16 port,
- const QString &sslPeerName, OpenMode mode)
+ const QString &sslPeerName, OpenMode mode,
+ NetworkLayerProtocol protocol)
{
Q_D(QSslSocket);
if (d->state == ConnectedState || d->state == ConnectingState) {
@@ -449,7 +450,7 @@ void QSslSocket::connectToHostEncrypted(const QString &hostName, quint16 port,
// Note: When connecting to localhost, some platforms (e.g., HP-UX and some BSDs)
// establish the connection immediately (i.e., first attempt).
- connectToHost(hostName, port, mode);
+ connectToHost(hostName, port, mode, protocol);
}
/*!
@@ -1740,7 +1741,7 @@ void QSslSocket::connectToHostImplementation(const QString &hostName, quint16 po
d->plainSocket->setProperty("_q_user-agent", property("_q_user-agent"));
#endif
QIODevice::open(openMode);
- d->plainSocket->connectToHost(hostName, port, openMode);
+ d->plainSocket->connectToHost(hostName, port, openMode, d->preferredNetworkLayerProtocol);
d->cachedSocketDescriptor = d->plainSocket->socketDescriptor();
}
diff --git a/src/network/ssl/qsslsocket.h b/src/network/ssl/qsslsocket.h
index 1e7c67ce91..f175ffd946 100644
--- a/src/network/ssl/qsslsocket.h
+++ b/src/network/ssl/qsslsocket.h
@@ -85,8 +85,8 @@ public:
~QSslSocket();
// Autostarting the SSL client handshake.
- void connectToHostEncrypted(const QString &hostName, quint16 port, OpenMode mode = ReadWrite);
- void connectToHostEncrypted(const QString &hostName, quint16 port, const QString &sslPeerName, OpenMode mode = ReadWrite);
+ void connectToHostEncrypted(const QString &hostName, quint16 port, OpenMode mode = ReadWrite, NetworkLayerProtocol protocol = AnyIPProtocol);
+ void connectToHostEncrypted(const QString &hostName, quint16 port, const QString &sslPeerName, OpenMode mode = ReadWrite, NetworkLayerProtocol protocol = AnyIPProtocol);
bool setSocketDescriptor(int socketDescriptor, SocketState state = ConnectedState,
OpenMode openMode = ReadWrite);
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index fb41b7c9e9..479a6bd60e 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -420,7 +420,11 @@ init_context:
QByteArray ace = QUrl::toAce(tlsHostName);
// only send the SNI header if the URL is valid and not an IP
if (!ace.isEmpty() && !QHostAddress().setAddress(tlsHostName)) {
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+ if (!q_SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, ace.data()))
+#else
if (!q_SSL_ctrl(ssl, SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, ace.constData()))
+#endif
qWarning("could not set SSL_CTRL_SET_TLSEXT_HOSTNAME, Server Name Indication disabled");
}
}
@@ -1262,10 +1266,17 @@ bool QSslSocketBackendPrivate::startHandshake()
// if we're the server, don't check CN
if (mode == QSslSocket::SslClientMode) {
QString peerName = (verificationPeerName.isEmpty () ? q->peerName() : verificationPeerName);
- QString commonName = configuration.peerCertificate.subjectInfo(QSslCertificate::CommonName);
+ QStringList commonNameList = configuration.peerCertificate.subjectInfo(QSslCertificate::CommonName);
+ bool matched = false;
+
+ foreach (const QString &commonName, commonNameList) {
+ if (isMatchingHostname(commonName.toLower(), peerName.toLower())) {
+ matched = true;
+ break;
+ }
+ }
- if (!isMatchingHostname(commonName.toLower(), peerName.toLower())) {
- bool matched = false;
+ if (!matched) {
foreach (const QString &altName, configuration.peerCertificate
.alternateSubjectNames().values(QSsl::DnsEntry)) {
if (isMatchingHostname(altName.toLower(), peerName.toLower())) {
@@ -1273,15 +1284,15 @@ bool QSslSocketBackendPrivate::startHandshake()
break;
}
}
+ }
- if (!matched) {
- // No matches in common names or alternate names.
- QSslError error(QSslError::HostNameMismatch, configuration.peerCertificate);
- errors << error;
- emit q->peerVerifyError(error);
- if (q->state() != QAbstractSocket::ConnectedState)
- return false;
- }
+ if (!matched) {
+ // No matches in common names or alternate names.
+ QSslError error(QSslError::HostNameMismatch, configuration.peerCertificate);
+ errors << error;
+ emit q->peerVerifyError(error);
+ if (q->state() != QAbstractSocket::ConnectedState)
+ return false;
}
}
} else {
diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp
index 6d29b294a1..b652833b45 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
+++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
@@ -210,8 +210,12 @@ DEFINEFUNC(int, SSL_library_init, void, DUMMYARG, return -1, return)
DEFINEFUNC(void, SSL_load_error_strings, void, DUMMYARG, return, DUMMYARG)
DEFINEFUNC(SSL *, SSL_new, SSL_CTX *a, a, return 0, return)
#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+DEFINEFUNC4(long, SSL_ctrl, SSL *a, a, int cmd, cmd, long larg, larg, void *parg, parg, return -1, return)
+#else
DEFINEFUNC4(long, SSL_ctrl, SSL *a, a, int cmd, cmd, long larg, larg, const void *parg, parg, return -1, return)
#endif
+#endif
DEFINEFUNC3(int, SSL_read, SSL *a, a, void *b, b, int c, c, return -1, return)
DEFINEFUNC3(void, SSL_set_bio, SSL *a, a, BIO *b, b, BIO *c, c, return, DUMMYARG)
DEFINEFUNC(void, SSL_set_accept_state, SSL *a, a, return, DUMMYARG)
diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h
index 00f56d65af..658aa144a7 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols_p.h
+++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h
@@ -318,8 +318,12 @@ int q_SSL_library_init();
void q_SSL_load_error_strings();
SSL *q_SSL_new(SSL_CTX *a);
#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+long q_SSL_ctrl(SSL *ssl,int cmd, long larg, void *parg);
+#else
long q_SSL_ctrl(SSL *ssl,int cmd, long larg, const void *parg);
#endif
+#endif
int q_SSL_read(SSL *a, void *b, int c);
void q_SSL_set_bio(SSL *a, BIO *b, BIO *c);
void q_SSL_set_accept_state(SSL *a);
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index b2f4b34b02..ab103ba836 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -1691,6 +1691,8 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
}
int numGlyphs = vertexCoordinates->vertexCount() / 4;
+ if (numGlyphs == 0)
+ return;
if (elementIndices.size() < numGlyphs*6) {
Q_ASSERT(elementIndices.size() % 6 == 0);
@@ -2318,41 +2320,6 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op)
state()->currentClip = d->maxClip;
state()->clipTestEnabled = true;
break;
- case Qt::UniteClip: {
- d->resetClipIfNeeded();
- ++d->maxClip;
- if (state()->rectangleClip.isValid()) {
- QPainterPath path;
- path.addRect(state()->rectangleClip);
-
- // flush the existing clip rectangle to the depth buffer
- d->writeClip(qtVectorPathForPath(state()->matrix.inverted().map(path)), d->maxClip);
- }
-
- state()->clipTestEnabled = false;
-#ifndef QT_GL_NO_SCISSOR_TEST
- QRect oldRectangleClip = state()->rectangleClip;
-
- state()->rectangleClip = state()->rectangleClip.united(pathRect);
- d->updateClipScissorTest();
-
- QRegion extendRegion = QRegion(state()->rectangleClip) - oldRectangleClip;
-
- if (!extendRegion.isEmpty()) {
- QPainterPath extendPath;
- extendPath.addRegion(extendRegion);
-
- // first clear the depth buffer in the extended region
- d->writeClip(qtVectorPathForPath(state()->matrix.inverted().map(extendPath)), 0);
- }
-#endif
- // now write the clip path
- d->writeClip(path, d->maxClip);
- state()->canRestoreClip = false;
- state()->currentClip = d->maxClip;
- state()->clipTestEnabled = true;
- break;
- }
default:
break;
}
diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h
index 28c56a969a..26c0025342 100644
--- a/src/opengl/qgl.h
+++ b/src/opengl/qgl.h
@@ -83,7 +83,11 @@ typedef GLfloat GLdouble;
typedef GLfloat GLdouble;
# endif
#else
-# include <GL/gl.h>
+# if defined(Q_OS_MAC)
+# include <OpenGL/gl.h>
+# else
+# include <GL/gl.h>
+# endif
#endif
QT_BEGIN_NAMESPACE
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp
index e05f312404..3c35c0334c 100644
--- a/src/opengl/qpaintengine_opengl.cpp
+++ b/src/opengl/qpaintengine_opengl.cpp
@@ -2413,11 +2413,6 @@ void QOpenGLPaintEngine::updateClipRegion(const QRegion &clipRegion, Qt::ClipOpe
else
state()->clipRegion = region;
break;
- case Qt::UniteClip:
- state()->clipRegion |= region;
- if (d->use_system_clip)
- state()->clipRegion &= sysClip;
- break;
default:
break;
}
diff --git a/src/plugins/generic/touchscreen/70-qtouchscreen.rules b/src/plugins/generic/touchscreen/70-qtouchscreen.rules
new file mode 100644
index 0000000000..8119a14382
--- /dev/null
+++ b/src/plugins/generic/touchscreen/70-qtouchscreen.rules
@@ -0,0 +1 @@
+KERNEL=="event*", ENV{ID_INPUT_TOUCHPAD}=="1", ENV{QT_TOUCH}="1", MODE="0644"
diff --git a/src/plugins/generic/touchscreen/README b/src/plugins/generic/touchscreen/README
new file mode 100644
index 0000000000..76f695371d
--- /dev/null
+++ b/src/plugins/generic/touchscreen/README
@@ -0,0 +1,45 @@
+Generic plug-in for evdev touch events
+
+(a) Using as a QPA generic plug-in
+
+1. set up the touch device
+2. sudo apt-get install libmtdev-dev libudev-dev
+3. build this plug-in (qmake && make)
+4. sudo cp 70-qtouchscreen.rules /etc/udev/rules.d
+5. sudo udevadm trigger --subsystem-match=input
+6. run apps like this: app -platform xcb -plugin LinuxTouchScreen
+
+If automatic detection does not work, use -plugin
+LinuxTouchScreen:/dev/input/eventN to explicitly set the device file
+name.
+
+By default the surface of the touch device is mapped to the entire
+screen. If this is not desired, define FORCE_TO_ACTIVE_WINDOW in
+qtoucheventsenderqpa.cpp. This will map the touch surface to the
+active window instead.
+
+Only touch events are generated (via
+QWindowSystemInterface::handleTouchEvent), mouse events are not. This
+is because on desktop the touch device will usually act as a
+single-touch mouse replacement anyway. For pointer-less systems the
+code needs to be extended to generate also mouse events (by calling
+handleMouseEvent too).
+
+(b) Using in a compositor
+
+The classes (QTouchScreenHandler, QTouchScreenHandlerThread) are also
+suitable for direct inclusion into an application, e.g. a Wayland
+compositor. The compositor will then usually register its own
+QTouchScreenObserver because relying on the QTouchEvents generated by
+the QPA event sender is often not satisfactory, as some low-level
+details may get lost, and due to performance reasons.
+
+
+Known issues:
+
+The udev rule matches any touchpad device. If there are multiple ones,
+specify the device as described above.
+
+On recent distributions (e.g. Ubuntu 11.04) you may need to remove
+50-synaptics.conf from /usr/share/X11/xorg.conf.d (followed by
+logout/login) otherwise no evdev events can be read.
diff --git a/src/plugins/generic/touchscreen/main.cpp b/src/plugins/generic/touchscreen/main.cpp
new file mode 100644
index 0000000000..8ad756355d
--- /dev/null
+++ b/src/plugins/generic/touchscreen/main.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins 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 <qgenericplugin_qpa.h>
+#include "qtouchscreen.h"
+#include "qtoucheventsenderqpa.h"
+
+QT_BEGIN_NAMESPACE
+
+class QTouchScreenPlugin : public QGenericPlugin
+{
+public:
+ QTouchScreenPlugin();
+
+ QStringList keys() const;
+ QObject* create(const QString &key, const QString &specification);
+};
+
+QTouchScreenPlugin::QTouchScreenPlugin()
+{
+}
+
+QStringList QTouchScreenPlugin::keys() const
+{
+ return QStringList() << "LinuxTouchScreen";
+}
+
+QObject* QTouchScreenPlugin::create(const QString &key,
+ const QString &spec)
+{
+ if (!key.compare(QLatin1String("LinuxTouchScreen"), Qt::CaseInsensitive)) {
+ QTouchScreenHandler *h = new QTouchScreenHandler(spec);
+ h->addObserver(new QTouchEventSenderQPA);
+ return h;
+ }
+
+ return 0;
+ }
+
+Q_EXPORT_PLUGIN2(qtouchscreenplugin, QTouchScreenPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/generic/touchscreen/qtoucheventsenderqpa.cpp b/src/plugins/generic/touchscreen/qtoucheventsenderqpa.cpp
new file mode 100644
index 0000000000..7dff55b1bc
--- /dev/null
+++ b/src/plugins/generic/touchscreen/qtoucheventsenderqpa.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins 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 "qtoucheventsenderqpa.h"
+#include <QApplication>
+#include <QDesktopWidget>
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+//#define POINT_DEBUG
+//#define FORCE_TO_ACTIVE_WINDOW
+
+void QTouchEventSenderQPA::touch_configure(int x_min, int x_max, int y_min, int y_max)
+{
+ hw_range_x_min = x_min;
+ hw_range_x_max = x_max;
+ hw_range_y_min = y_min;
+ hw_range_y_max = y_max;
+}
+
+void QTouchEventSenderQPA::touch_point(QEvent::Type state,
+ const QList<QWindowSystemInterface::TouchPoint> &points)
+{
+#ifdef FORCE_TO_ACTIVE_WINDOW
+ QWidget *win = QApplication::activeWindow(); // ### migrate to QWindow later on
+ if (!win) {
+#ifdef POINT_DEBUG
+ qDebug("sendTouchEvent: No active window");
+#endif
+ return;
+ }
+ const QRect winRect = win->geometry();
+#else
+ const QRect winRect = QApplication::desktop()->screenGeometry();
+#endif
+
+#ifdef POINT_DEBUG
+ qDebug() << points.size() << "points" << winRect << state;
+#endif
+
+ QList<QWindowSystemInterface::TouchPoint> touchPoints = points;
+ // Translate the coordinates and set the normalized position. QPA expects
+ // 'area' to be in screen coordinates, while the device reports them in its
+ // own system with (0, 0) being the center point of the device.
+ for (int i = 0; i < touchPoints.size(); ++i) {
+ QWindowSystemInterface::TouchPoint &tp(touchPoints[i]);
+
+ // Translate so that (0, 0) is the top-left corner.
+ const int hw_x = qBound(hw_range_x_min, int(tp.area.left()), hw_range_x_max) - hw_range_x_min;
+ const int hw_y = qBound(hw_range_y_min, int(tp.area.top()), hw_range_y_max) - hw_range_y_min;
+
+ // Get a normalized position in range 0..1.
+ const int hw_w = hw_range_x_max - hw_range_x_min;
+ const int hw_h = hw_range_y_max - hw_range_y_min;
+ tp.normalPosition = QPointF(hw_x / qreal(hw_w),
+ hw_y / qreal(hw_h));
+
+ qreal nx = tp.normalPosition.x();
+ qreal ny = tp.normalPosition.y();
+
+ // Generate a screen position that is always inside the active window or the default screen.
+ const int wx = winRect.left() + int(nx * winRect.width());
+ const int wy = winRect.top() + int(ny * winRect.height());
+ tp.area.moveTopLeft(QPoint(wx, wy));
+
+#ifdef POINT_DEBUG
+ qDebug() << " " << i << tp.area << tp.state << tp.id << tp.isPrimary << tp.pressure;
+#endif
+ }
+
+ QWindowSystemInterface::handleTouchEvent(0, state, QTouchEvent::TouchScreen, touchPoints);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/generic/touchscreen/qtoucheventsenderqpa.h b/src/plugins/generic/touchscreen/qtoucheventsenderqpa.h
new file mode 100644
index 0000000000..68d621a4e5
--- /dev/null
+++ b/src/plugins/generic/touchscreen/qtoucheventsenderqpa.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins 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 QTOUCHEVENTSENDERQPA_H
+#define QTOUCHEVENTSENDERQPA_H
+
+#include "qtouchscreen.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QTouchEventSenderQPA : public QTouchScreenObserver
+{
+public:
+ void touch_configure(int x_min, int x_max, int y_min, int y_max);
+ void touch_point(QEvent::Type state, const QList<QWindowSystemInterface::TouchPoint> &points);
+
+private:
+ int hw_range_x_min;
+ int hw_range_x_max;
+ int hw_range_y_min;
+ int hw_range_y_max;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QTOUCHEVENTSENDERQPA_H
diff --git a/src/plugins/generic/touchscreen/qtouchscreen.cpp b/src/plugins/generic/touchscreen/qtouchscreen.cpp
new file mode 100644
index 0000000000..2bbed6a62f
--- /dev/null
+++ b/src/plugins/generic/touchscreen/qtouchscreen.cpp
@@ -0,0 +1,324 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins 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 "qtouchscreen.h"
+#include <QStringList>
+#include <QSocketNotifier>
+#include <QtCore/private/qcore_unix_p.h>
+#include <QDebug>
+
+#include <libudev.h>
+
+extern "C" {
+#include <mtdev.h>
+}
+
+//#define POINT_DEBUG
+
+QT_BEGIN_NAMESPACE
+
+class QTouchScreenData
+{
+public:
+ QTouchScreenData(QTouchScreenHandler *q_ptr);
+
+ void handle(input_event *data);
+
+ QTouchScreenHandler *q;
+ QEvent::Type m_state;
+ QEvent::Type m_prevState;
+ QList<QWindowSystemInterface::TouchPoint> m_touchPoints;
+
+ struct Slot {
+ int trackingId;
+ int x;
+ int y;
+ Qt::TouchPointState state;
+ bool primary;
+ Slot() : trackingId(0), x(0), y(0), state(Qt::TouchPointPressed), primary(false) { }
+ };
+ QMap<int, Slot> m_slots;
+ QMap<int, QPoint> m_lastReport;
+ int m_currentSlot;
+
+ int hw_range_x_min;
+ int hw_range_x_max;
+ int hw_range_y_min;
+ int hw_range_y_max;
+ QString hw_name;
+
+ QList<QTouchScreenObserver *> m_observers;
+};
+
+QTouchScreenData::QTouchScreenData(QTouchScreenHandler *q_ptr)
+ : q(q_ptr),
+ m_state(QEvent::TouchBegin),
+ m_prevState(m_state),
+ m_currentSlot(0),
+ hw_range_x_min(0), hw_range_x_max(0),
+ hw_range_y_min(0), hw_range_y_max(0)
+{
+}
+
+QTouchScreenHandler::QTouchScreenHandler(const QString &spec)
+ : m_notify(0), m_fd(-1), m_mtdev(0), d(0)
+{
+ setObjectName(QLatin1String("LinuxInputSubsystem Touch Handler"));
+
+ QString dev = QLatin1String("/dev/input/event5");
+ try_udev(&dev);
+
+ QStringList args = spec.split(QLatin1Char(':'));
+ for (int i = 0; i < args.count(); ++i)
+ if (args.at(i).startsWith(QLatin1String("/dev/")))
+ dev = args.at(i);
+
+ qDebug("Using device '%s'", qPrintable(dev));
+ m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
+
+ if (m_fd >= 0) {
+ m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
+ connect(m_notify, SIGNAL(activated(int)), this, SLOT(readData()));
+ } else {
+ qWarning("Cannot open input device '%s': %s", qPrintable(dev), strerror(errno));
+ return;
+ }
+
+ m_mtdev = (mtdev *) calloc(1, sizeof(mtdev));
+ int mtdeverr = mtdev_open(m_mtdev, m_fd);
+ if (mtdeverr) {
+ qWarning("mtdev_open failed: %d", mtdeverr);
+ QT_CLOSE(m_fd);
+ return;
+ }
+
+ d = new QTouchScreenData(this);
+
+ input_absinfo absInfo;
+ memset(&absInfo, 0, sizeof(input_absinfo));
+ if (!ioctl(m_fd, EVIOCGABS(ABS_X), &absInfo) >= 0) {
+ qDebug("min X: %d max X: %d", absInfo.minimum, absInfo.maximum);
+ d->hw_range_x_min = absInfo.minimum;
+ d->hw_range_x_max = absInfo.maximum;
+ }
+ if (!ioctl(m_fd, EVIOCGABS(ABS_Y), &absInfo) >= 0) {
+ qDebug("min Y: %d max Y: %d", absInfo.minimum, absInfo.maximum);
+ d->hw_range_y_min = absInfo.minimum;
+ d->hw_range_y_max = absInfo.maximum;
+ }
+ char name[1024];
+ if (ioctl(m_fd, EVIOCGNAME(sizeof(name) - 1), name) >= 0) {
+ d->hw_name = QString::fromUtf8(name);
+ qDebug() << "device name" << d->hw_name;
+ }
+}
+
+QTouchScreenHandler::~QTouchScreenHandler()
+{
+ if (m_fd >= 0)
+ QT_CLOSE(m_fd);
+
+ if (m_mtdev) {
+ mtdev_close(m_mtdev);
+ free(m_mtdev);
+ }
+
+ delete d;
+}
+
+void QTouchScreenHandler::addObserver(QTouchScreenObserver *observer)
+{
+ if (!d || !observer)
+ return;
+ d->m_observers.append(observer);
+ observer->touch_configure(d->hw_range_x_min, d->hw_range_x_max,
+ d->hw_range_y_min, d->hw_range_y_max);
+}
+
+void QTouchScreenHandler::try_udev(QString *path)
+{
+ udev *u = udev_new();
+ udev_enumerate *ue = udev_enumerate_new(u);
+ udev_enumerate_add_match_subsystem(ue, "input");
+ udev_enumerate_add_match_property(ue, "QT_TOUCH", "1");
+ udev_enumerate_scan_devices(ue);
+ udev_list_entry *entry;
+ udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(ue)) {
+ const char *syspath = udev_list_entry_get_name(entry);
+ udev_device *udevice = udev_device_new_from_syspath(u, syspath);
+ *path = QString::fromLocal8Bit(udev_device_get_devnode(udevice));
+ qDebug("from udev: %s", qPrintable(*path));
+ udev_device_unref(udevice);
+ }
+ udev_enumerate_unref(ue);
+ udev_unref(u);
+}
+
+void QTouchScreenHandler::readData()
+{
+ input_event buffer[32];
+ int n = 0;
+ n = mtdev_get(m_mtdev, m_fd, buffer, sizeof(buffer) / sizeof(input_event));
+ if (n < 0) {
+ if (errno != EINTR && errno != EAGAIN)
+ qWarning("Could not read from input device: %s", strerror(errno));
+ } else if (n > 0) {
+ for (int i = 0; i < n; ++i) {
+ input_event *data = &buffer[i];
+ d->handle(data);
+ }
+ }
+}
+
+void QTouchScreenData::handle(input_event *data)
+{
+ if (data->type == EV_ABS) {
+ if (data->code == ABS_MT_POSITION_X) {
+ m_slots[m_currentSlot].x = data->value;
+ } else if (data->code == ABS_MT_POSITION_Y) {
+ m_slots[m_currentSlot].y = data->value;
+ } else if (data->code == ABS_MT_SLOT) {
+ m_currentSlot = data->value;
+ } else if (data->code == ABS_MT_TRACKING_ID) {
+ if (data->value == -1) {
+ bool wasPrimary = m_slots[m_currentSlot].primary;
+ m_lastReport.remove(m_slots[m_currentSlot].trackingId);
+ m_slots.remove(m_currentSlot);
+ if (wasPrimary && !m_slots.isEmpty())
+ m_slots[m_slots.keys().at(0)].primary = true;
+ } else {
+ m_slots[m_currentSlot].trackingId = data->value;
+ m_slots[m_currentSlot].primary = m_slots.count() == 1;
+ }
+ } else if (data->code == ABS_MT_TOUCH_MAJOR) {
+ if (data->value == 0)
+ m_slots[m_currentSlot].state = Qt::TouchPointReleased;
+ }
+ } else if (data->type == EV_SYN && data->code == SYN_REPORT) {
+ m_touchPoints.clear();
+ QList<int> keys = m_slots.keys();
+ int ignoredSlotCount = 0;
+ for (int i = 0; i < keys.count(); ++i) {
+ const Slot &slot(m_slots.value(keys.at(i)));
+ if (slot.trackingId == 0) {
+ ++ignoredSlotCount;
+ continue;
+ }
+ QWindowSystemInterface::TouchPoint tp;
+ tp.id = slot.trackingId;
+ tp.isPrimary = slot.primary;
+ tp.pressure = slot.state == Qt::TouchPointReleased ? 0 : 1;
+ tp.area = QRectF(slot.x, slot.y, 1, 1);
+ tp.state = slot.state;
+ if (slot.state == Qt::TouchPointMoved && m_lastReport.contains(slot.trackingId)) {
+ QPoint lastPos = m_lastReport.value(slot.trackingId);
+ if (lastPos.x() == slot.x && lastPos.y() == slot.y)
+ tp.state = Qt::TouchPointStationary;
+ }
+ m_touchPoints.append(tp);
+ m_lastReport.insert(slot.trackingId, QPoint(slot.x, slot.y));
+ }
+ if (m_slots.count() - ignoredSlotCount == 0)
+ m_state = QEvent::TouchEnd;
+
+ // Skip if state is TouchUpdate and all points are Stationary.
+ bool skip = false;
+ if (m_state == QEvent::TouchUpdate) {
+ skip = true;
+ for (int i = 0; i < m_touchPoints.count(); ++i)
+ if (m_touchPoints.at(i).state != Qt::TouchPointStationary) {
+ skip = false;
+ break;
+ }
+ }
+
+ // ### TODO Add timestamps and remove points that stay unchanged for too long.
+ // The user's finger may fall off the touchscreen, which means there will be
+ // no released event sent ever for that particular point.
+
+#ifdef POINT_DEBUG
+ qDebug() << m_touchPoints.count() << "touchpoints, event type" << m_state;
+ for (int i = 0; i < m_touchPoints.count(); ++i)
+ qDebug() << " " << m_touchPoints[i].id << m_touchPoints[i].state << m_touchPoints[i].area;
+#endif
+
+ if (!skip && !(m_state == m_prevState && m_state == QEvent::TouchEnd))
+ for (int i = 0; i < m_observers.count(); ++i)
+ m_observers.at(i)->touch_point(m_state, m_touchPoints);
+
+ for (int i = 0; i < keys.count(); ++i) {
+ Slot &slot(m_slots[keys.at(i)]);
+ if (slot.state == Qt::TouchPointPressed)
+ slot.state = Qt::TouchPointMoved;
+ }
+ m_prevState = m_state;
+ if (m_state == QEvent::TouchBegin)
+ m_state = QEvent::TouchUpdate;
+ else if (m_state == QEvent::TouchEnd)
+ m_state = QEvent::TouchBegin;
+ }
+}
+
+
+QTouchScreenHandlerThread::QTouchScreenHandlerThread(const QString &spec,
+ QTouchScreenObserver *observer)
+ : m_spec(spec), m_handler(0), m_observer(observer)
+{
+ start();
+}
+
+QTouchScreenHandlerThread::~QTouchScreenHandlerThread()
+{
+ quit();
+ wait();
+}
+
+void QTouchScreenHandlerThread::run()
+{
+ m_handler = new QTouchScreenHandler(m_spec);
+ m_handler->addObserver(m_observer);
+ exec();
+ delete m_handler;
+ m_handler = 0;
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/plugins/generic/touchscreen/qtouchscreen.h b/src/plugins/generic/touchscreen/qtouchscreen.h
new file mode 100644
index 0000000000..915a213d41
--- /dev/null
+++ b/src/plugins/generic/touchscreen/qtouchscreen.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins 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 QTOUCHSCREEN_H
+#define QTOUCHSCREEN_H
+
+#include <QObject>
+#include <QString>
+#include <QList>
+#include <QThread>
+#include <QtGui/private/qwindowsysteminterface_qpa_p.h>
+
+QT_BEGIN_HEADER
+
+struct mtdev;
+
+QT_BEGIN_NAMESPACE
+
+class QSocketNotifier;
+class QTouchScreenData;
+
+class QTouchScreenObserver
+{
+public:
+ virtual void touch_configure(int x_min, int x_max, int y_min, int y_max) = 0;
+ virtual void touch_point(QEvent::Type state, const QList<QWindowSystemInterface::TouchPoint> &points) = 0;
+};
+
+class QTouchScreenHandler : public QObject
+{
+ Q_OBJECT
+
+public:
+ QTouchScreenHandler(const QString &spec = QString());
+ ~QTouchScreenHandler();
+ void addObserver(QTouchScreenObserver *observer);
+
+private slots:
+ void readData();
+
+private:
+ void try_udev(QString *path);
+
+ QSocketNotifier *m_notify;
+ int m_fd;
+ mtdev *m_mtdev;
+ QTouchScreenData *d;
+};
+
+class QTouchScreenHandlerThread : public QThread
+{
+public:
+ QTouchScreenHandlerThread(const QString &spec, QTouchScreenObserver *observer);
+ ~QTouchScreenHandlerThread();
+ void run();
+ QTouchScreenHandler *handler() { return m_handler; }
+
+private:
+ QString m_spec;
+ QTouchScreenHandler *m_handler;
+ QTouchScreenObserver *m_observer;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QTOUCHSCREEN_H
diff --git a/src/plugins/generic/touchscreen/touchscreen.pro b/src/plugins/generic/touchscreen/touchscreen.pro
new file mode 100644
index 0000000000..26725190b0
--- /dev/null
+++ b/src/plugins/generic/touchscreen/touchscreen.pro
@@ -0,0 +1,18 @@
+TARGET = qtouchscreenplugin
+load(qt_plugin)
+
+DESTDIR = $$QT.gui.plugins/generic
+target.path = $$[QT_INSTALL_PLUGINS]/generic
+INSTALLS += target
+
+HEADERS = \
+ qtouchscreen.h \
+ qtoucheventsenderqpa.h
+
+SOURCES = main.cpp \
+ qtouchscreen.cpp \
+ qtoucheventsenderqpa.cpp
+
+QT += core-private gui-private
+
+LIBS += -ludev -lmtdev
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
index f3e2e9fb94..1314eda012 100644
--- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
@@ -311,7 +311,7 @@ void QWaylandDisplay::displayHandleGlobal(uint32_t id,
wl_shell_add_listener(mShell, &shellListener, this);
} else if (interface == "wl_input_device") {
QWaylandInputDevice *inputDevice =
- new QWaylandInputDevice(mDisplay, id);
+ new QWaylandInputDevice(this, id);
mInputDevices.append(inputDevice);
} else if (interface == "wl_selection_offer") {
QWaylandClipboard::instance(display)->createSelectionOffer(id);
diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
index 7f3737613f..c1e2325766 100644
--- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
+++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
@@ -45,10 +45,9 @@
#include "qwaylandwindow.h"
#include "qwaylandbuffer.h"
-#include <QWindowSystemInterface>
-
#include <QtGui/private/qpixmap_raster_p.h>
#include <QtGui/QPlatformWindow>
+#include <QDebug>
#include <unistd.h>
#include <fcntl.h>
@@ -58,13 +57,17 @@
#include <X11/keysym.h>
#endif
-QWaylandInputDevice::QWaylandInputDevice(struct wl_display *display,
+//#define POINT_DEBUG
+
+QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display,
uint32_t id)
- : mDisplay(display)
- , mInputDevice(wl_input_device_create(display, id, 1))
+ : mQDisplay(display)
+ , mDisplay(display->wl_display())
+ , mInputDevice(wl_input_device_create(mDisplay, id, 1))
, mPointerFocus(NULL)
, mKeyboardFocus(NULL)
, mButtons(0)
+ , mTouchState(QEvent::TouchBegin)
{
wl_input_device_add_listener(mInputDevice,
&inputDeviceListener,
@@ -338,12 +341,168 @@ void QWaylandInputDevice::inputHandleKeyboardFocus(void *data,
#endif
}
+void QWaylandInputDevice::inputHandleTouchDown(void *data,
+ struct wl_input_device *wl_input_device,
+ uint32_t time,
+ int id,
+ int x,
+ int y)
+{
+ QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
+ inputDevice->handleTouchPoint(id, x, y, Qt::TouchPointPressed);
+}
+
+void QWaylandInputDevice::inputHandleTouchUp(void *data,
+ struct wl_input_device *wl_input_device,
+ uint32_t time,
+ int id)
+{
+ QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
+ inputDevice->handleTouchPoint(id, 0, 0, Qt::TouchPointReleased);
+}
+
+void QWaylandInputDevice::inputHandleTouchMotion(void *data,
+ struct wl_input_device *wl_input_device,
+ uint32_t time,
+ int id,
+ int x,
+ int y)
+{
+ QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
+ inputDevice->handleTouchPoint(id, x, y, Qt::TouchPointMoved);
+}
+
+void QWaylandInputDevice::handleTouchPoint(int id, int x, int y, Qt::TouchPointState state)
+{
+ QWindowSystemInterface::TouchPoint tp;
+
+ // Find out the coordinates for Released events.
+ bool coordsOk = false;
+ if (state == Qt::TouchPointReleased)
+ for (int i = 0; i < mPrevTouchPoints.count(); ++i)
+ if (mPrevTouchPoints.at(i).id == id) {
+ tp.area = mPrevTouchPoints.at(i).area;
+ coordsOk = true;
+ break;
+ }
+
+ if (!coordsOk) {
+ // x and y are surface relative.
+ // We need a global (screen) position.
+
+ QWaylandWindow *win = mPointerFocus;
+ if (!win)
+ win = mKeyboardFocus;
+#ifdef POINT_DEBUG
+ qDebug() << "surface relative coords" << x << y << "using window" << win;
+#endif
+ if (!win)
+ return;
+
+ QRect winRect = win->geometry();
+
+ // Get a normalized position (0..1).
+ const qreal nx = x / qreal(winRect.width());
+ const qreal ny = y / qreal(winRect.height());
+ tp.normalPosition = QPointF(nx, ny);
+
+ // Map to screen.
+ QPlatformScreen *screen = mQDisplay->screens().at(0);
+ QRect screenRect = screen->geometry();
+ x = int(nx * screenRect.width());
+ y = int(ny * screenRect.height());
+
+#ifdef POINT_DEBUG
+ qDebug() << "normalized position" << nx << ny
+ << "win rect" << winRect << "screen rect" << screenRect;
+ qDebug() << "mapped to screen position" << x << y;
+#endif
+
+ tp.area = QRectF(x, y, 1, 1);
+ }
+
+ tp.state = state;
+ tp.id = id;
+ tp.isPrimary = mTouchPoints.isEmpty();
+ tp.pressure = tp.state == Qt::TouchPointReleased ? 0 : 1;
+ mTouchPoints.append(tp);
+}
+
+void QWaylandInputDevice::inputHandleTouchFrame(void *data, struct wl_input_device *wl_input_device)
+{
+ QWaylandInputDevice *inputDevice = (QWaylandInputDevice *) data;
+ inputDevice->handleTouchFrame();
+}
+
+void QWaylandInputDevice::handleTouchFrame()
+{
+ // Copy all points, that are in the previous but not in the current list, as stationary.
+ for (int i = 0; i < mPrevTouchPoints.count(); ++i) {
+ const QWindowSystemInterface::TouchPoint &prevPoint(mPrevTouchPoints.at(i));
+ if (prevPoint.state == Qt::TouchPointReleased)
+ continue;
+ bool found = false;
+ for (int j = 0; j < mTouchPoints.count(); ++j)
+ if (mTouchPoints.at(j).id == prevPoint.id) {
+ found = true;
+ break;
+ }
+ if (!found) {
+ QWindowSystemInterface::TouchPoint p = prevPoint;
+ p.state = Qt::TouchPointStationary;
+ mTouchPoints.append(p);
+ }
+ }
+
+ if (mTouchPoints.isEmpty()) {
+ mPrevTouchPoints.clear();
+ return;
+ }
+
+#ifdef POINT_DEBUG
+ qDebug() << mTouchPoints.count() << "touchpoints, event type" << mTouchState;
+ for (int i = 0; i < mTouchPoints.count(); ++i)
+ qDebug() << " " << mTouchPoints[i].id << mTouchPoints[i].state << mTouchPoints[i].area;
+#endif
+
+ QWindowSystemInterface::handleTouchEvent(0, mTouchState, QTouchEvent::TouchScreen, mTouchPoints);
+
+ bool allReleased = true;
+ for (int i = 0; i < mTouchPoints.count(); ++i)
+ if (mTouchPoints.at(i).state != Qt::TouchPointReleased) {
+ allReleased = false;
+ break;
+ }
+
+ mPrevTouchPoints = mTouchPoints;
+ mTouchPoints.clear();
+
+ if (allReleased) {
+#ifdef POINT_DEBUG
+ qDebug() << mTouchPoints.count() << "touchpoints, event type" << QEvent::TouchEnd;
+#endif
+ QWindowSystemInterface::handleTouchEvent(0, QEvent::TouchEnd, QTouchEvent::TouchScreen, mTouchPoints);
+ mTouchState = QEvent::TouchBegin;
+ mPrevTouchPoints.clear();
+ } else if (mTouchState == QEvent::TouchBegin)
+ mTouchState = QEvent::TouchUpdate;
+}
+
+void QWaylandInputDevice::inputHandleTouchCancel(void *data, struct wl_input_device *wl_input_device)
+{
+}
+
const struct wl_input_device_listener QWaylandInputDevice::inputDeviceListener = {
QWaylandInputDevice::inputHandleMotion,
QWaylandInputDevice::inputHandleButton,
QWaylandInputDevice::inputHandleKey,
QWaylandInputDevice::inputHandlePointerFocus,
QWaylandInputDevice::inputHandleKeyboardFocus,
+ QWaylandInputDevice::inputHandleTouchDown,
+ QWaylandInputDevice::inputHandleTouchUp,
+ QWaylandInputDevice::inputHandleTouchMotion,
+ QWaylandInputDevice::inputHandleTouchFrame,
+ QWaylandInputDevice::inputHandleTouchCancel
};
void QWaylandInputDevice::attach(QWaylandBuffer *buffer, int x, int y)
diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.h b/src/plugins/platforms/wayland/qwaylandinputdevice.h
index e5be5bb8d2..008ecf144d 100644
--- a/src/plugins/platforms/wayland/qwaylandinputdevice.h
+++ b/src/plugins/platforms/wayland/qwaylandinputdevice.h
@@ -48,21 +48,24 @@
#include <QObject>
#include <QtGui/QPlatformIntegration>
#include <QtGui/QPlatformScreen>
+#include <QWindowSystemInterface>
#include <wayland-client.h>
QT_BEGIN_NAMESPACE
class QWaylandWindow;
+class QWaylandDisplay;
class QWaylandInputDevice {
public:
- QWaylandInputDevice(struct wl_display *display, uint32_t id);
+ QWaylandInputDevice(QWaylandDisplay *display, uint32_t id);
void attach(QWaylandBuffer *buffer, int x, int y);
void handleWindowDestroyed(QWaylandWindow *window);
struct wl_input_device *wl_input_device() const { return mInputDevice; }
private:
+ QWaylandDisplay *mQDisplay;
struct wl_display *mDisplay;
struct wl_input_device *mInputDevice;
QWaylandWindow *mPointerFocus;
@@ -95,6 +98,32 @@ private:
uint32_t time,
struct wl_surface *surface,
struct wl_array *keys);
+ static void inputHandleTouchDown(void *data,
+ struct wl_input_device *wl_input_device,
+ uint32_t time,
+ int id,
+ int x,
+ int y);
+ static void inputHandleTouchUp(void *data,
+ struct wl_input_device *wl_input_device,
+ uint32_t time,
+ int id);
+ static void inputHandleTouchMotion(void *data,
+ struct wl_input_device *wl_input_device,
+ uint32_t time,
+ int id,
+ int x,
+ int y);
+ static void inputHandleTouchFrame(void *data,
+ struct wl_input_device *wl_input_device);
+ static void inputHandleTouchCancel(void *data,
+ struct wl_input_device *wl_input_device);
+
+ void handleTouchPoint(int id, int x, int y, Qt::TouchPointState state);
+ void handleTouchFrame();
+ QList<QWindowSystemInterface::TouchPoint> mTouchPoints;
+ QList<QWindowSystemInterface::TouchPoint> mPrevTouchPoints;
+ QEvent::Type mTouchState;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp
index 2376df55c9..f685dae729 100644
--- a/src/plugins/platforms/wayland/qwaylandwindow.cpp
+++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp
@@ -146,8 +146,8 @@ void QWaylandWindow::newSurfaceCreated()
{
if (mBuffer) {
wl_surface_attach(mSurface,mBuffer->buffer(),0,0);
- QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size()));
- wl_surface_damage(mSurface,0,0,mBuffer->size().width(),mBuffer->size().height());
+ // do not damage the surface here, as this leads to graphical corruptions in the compositor until
+ // the first frame has been rendered
}
}
diff --git a/src/plugins/platforms/wayland/wayland_sha1.txt b/src/plugins/platforms/wayland/wayland_sha1.txt
index a696e760d5..9596f7b0a8 100644
--- a/src/plugins/platforms/wayland/wayland_sha1.txt
+++ b/src/plugins/platforms/wayland/wayland_sha1.txt
@@ -1,3 +1,3 @@
This version of the Qt Wayland plugin is checked against the following sha1
from the Wayland repository:
-bfea3d6befdb688d5354e6f15a9400ea637febf9
+aa7bbb210b7121b9314993228960240358e9b123
diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h
index 73673aef6f..e781b16c41 100644
--- a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h
+++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanager-client-protocol.h
@@ -36,71 +36,67 @@ struct wl_client;
struct wl_windowmanager;
-struct wl_proxy;
-
-extern void
-wl_proxy_marshal(struct wl_proxy *p, uint32_t opcode, ...);
-extern struct wl_proxy *
-wl_proxy_create(struct wl_proxy *factory,
- const struct wl_interface *interface);
-extern struct wl_proxy *
-wl_proxy_create_for_id(struct wl_display *display,
- const struct wl_interface *interface, uint32_t id);
-extern void
-wl_proxy_destroy(struct wl_proxy *proxy);
-
-extern int
-wl_proxy_add_listener(struct wl_proxy *proxy,
- void (**implementation)(void), void *data);
-
-extern void
-wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data);
-
-extern void *
-wl_proxy_get_user_data(struct wl_proxy *proxy);
-
extern const struct wl_interface wl_windowmanager_interface;
-#define wl_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS 0
-#define wl_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN 1
+struct wl_windowmanager_listener {
+ void (*client_onscreen_visibility)(void *data,
+ struct wl_windowmanager *wl_windowmanager,
+ int visible);
+ void (*set_screen_rotation)(void *data,
+ struct wl_windowmanager *wl_windowmanager,
+ int rotation);
+};
+
+static inline int
+wl_windowmanager_add_listener(struct wl_windowmanager *wl_windowmanager,
+ const struct wl_windowmanager_listener *listener, void *data)
+{
+ return wl_proxy_add_listener((struct wl_proxy *) wl_windowmanager,
+ (void (**)(void)) listener, data);
+}
+
+#define WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS 0
+#define WL_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN 1
static inline struct wl_windowmanager *
-wl_windowmanager_create(struct wl_display *display, uint32_t id)
+wl_windowmanager_create(struct wl_display *display, uint32_t id, uint32_t version)
{
- return (struct wl_windowmanager *)
- wl_proxy_create_for_id(display, &wl_windowmanager_interface, id);
+ wl_display_bind(display, id, "wl_windowmanager", version);
+
+ return (struct wl_windowmanager *)
+ wl_proxy_create_for_id(display, &wl_windowmanager_interface, id);
}
static inline void
wl_windowmanager_set_user_data(struct wl_windowmanager *wl_windowmanager, void *user_data)
{
- wl_proxy_set_user_data((struct wl_proxy *) wl_windowmanager, user_data);
+ wl_proxy_set_user_data((struct wl_proxy *) wl_windowmanager, user_data);
}
static inline void *
wl_windowmanager_get_user_data(struct wl_windowmanager *wl_windowmanager)
{
- return wl_proxy_get_user_data((struct wl_proxy *) wl_windowmanager);
+ return wl_proxy_get_user_data((struct wl_proxy *) wl_windowmanager);
}
static inline void
wl_windowmanager_destroy(struct wl_windowmanager *wl_windowmanager)
{
- wl_proxy_destroy((struct wl_proxy *) wl_windowmanager);
+ wl_proxy_destroy((struct wl_proxy *) wl_windowmanager);
}
static inline void
wl_windowmanager_map_client_to_process(struct wl_windowmanager *wl_windowmanager, uint32_t processid)
{
- wl_proxy_marshal((struct wl_proxy *) wl_windowmanager,
- wl_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS, processid);
+ wl_proxy_marshal((struct wl_proxy *) wl_windowmanager,
+ WL_WINDOWMANAGER_MAP_CLIENT_TO_PROCESS, processid);
}
static inline void
-wl_windowmanager_authenticate_with_token(struct wl_windowmanager *wl_windowmanager, const char *wl_authentication_token)
+wl_windowmanager_authenticate_with_token(struct wl_windowmanager *wl_windowmanager, const char *processid)
{
- wl_proxy_marshal((struct wl_proxy *) wl_windowmanager,
- wl_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN, wl_authentication_token);
+ wl_proxy_marshal((struct wl_proxy *) wl_windowmanager,
+ WL_WINDOWMANAGER_AUTHENTICATE_WITH_TOKEN, processid);
}
#ifdef __cplusplus
diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp
index 4236f395cb..7390c52740 100644
--- a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp
+++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.cpp
@@ -43,6 +43,15 @@
#include "qwaylandwindowmanager-client-protocol.h"
#include <stdint.h>
+#include <QDebug>
+#include <QEvent>
+#include <QtGui/QtEvents>
+#include <QCoreApplication>
+
+const struct wl_windowmanager_listener QWaylandWindowManagerIntegration::mWindowManagerListener = {
+ QWaylandWindowManagerIntegration::wlHandleOnScreenVisibilityChange,
+ QWaylandWindowManagerIntegration::wlHandleScreenOrientationChange,
+};
QWaylandWindowManagerIntegration *QWaylandWindowManagerIntegration::createIntegration(QWaylandDisplay *waylandDisplay)
{
@@ -70,9 +79,12 @@ struct wl_windowmanager *QWaylandWindowManagerIntegration::windowManager() const
void QWaylandWindowManagerIntegration::wlHandleListenerGlobal(wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data)
{
+ Q_UNUSED(version);
if (strcmp(interface, "wl_windowmanager") == 0) {
QWaylandWindowManagerIntegration *integration = static_cast<QWaylandWindowManagerIntegration *>(data);
- integration->mWaylandWindowManager = wl_windowmanager_create(display, id);
+ integration->mWaylandWindowManager = wl_windowmanager_create(display, id, 1);
+
+ wl_windowmanager_add_listener(integration->mWaylandWindowManager, &mWindowManagerListener, integration);
}
}
@@ -90,3 +102,22 @@ void QWaylandWindowManagerIntegration::authenticateWithToken(const QByteArray &t
if (mWaylandWindowManager)
wl_windowmanager_authenticate_with_token(mWaylandWindowManager, authToken.constData());
}
+
+void QWaylandWindowManagerIntegration::wlHandleOnScreenVisibilityChange(void *data, struct wl_windowmanager *wl_windowmanager, int visible)
+{
+ Q_UNUSED(data);
+ Q_UNUSED(wl_windowmanager);
+ QEvent evt(visible != 0 ? QEvent::ApplicationActivated : QEvent::ApplicationDeactivated);
+
+ QCoreApplication::sendEvent(QCoreApplication::instance(), &evt);
+
+ qDebug() << "OnScreenVisibility" << (visible != 0);
+}
+
+void QWaylandWindowManagerIntegration::wlHandleScreenOrientationChange(void *data, struct wl_windowmanager *wl_windowmanager, int screenOrientation)
+{
+ Q_UNUSED(data);
+ Q_UNUSED(wl_windowmanager);
+ QScreenOrientationChangeEvent event(screenOrientation);
+ QCoreApplication::sendEvent(QCoreApplication::instance(), &event);
+}
diff --git a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h
index 0e3781dbe2..6b4658c7e1 100644
--- a/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h
+++ b/src/plugins/platforms/wayland/windowmanager_integration/qwaylandwindowmanagerintegration.h
@@ -62,9 +62,14 @@ private:
static void wlHandleListenerGlobal(wl_display *display, uint32_t id,
const char *interface, uint32_t version, void *data);
+ static void wlHandleOnScreenVisibilityChange(void *data, struct wl_windowmanager *wl_windowmanager, int visible);
+ static void wlHandleScreenOrientationChange(void *data, struct wl_windowmanager *wl_windowmanager, int screenOrientation);
private:
+
QWaylandDisplay *mWaylandDisplay;
struct wl_windowmanager *mWaylandWindowManager;
+
+ static const struct wl_windowmanager_listener mWindowManagerListener;
};
#endif // QWAYLANDWINDOWMANAGERINTEGRATION_H
diff --git a/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c b/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c
index 0250801b1f..8125dec4d3 100644
--- a/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c
+++ b/src/plugins/platforms/wayland/windowmanager_integration/wayland-windowmanager-protocol.c
@@ -26,12 +26,18 @@
#include "wayland-util.h"
static const struct wl_message wl_windowmanager_requests[] = {
- { "map_client_to_process", "u" },
- { "authenticate_with_token", "s" },
+ { "map_client_to_process", "u", NULL },
+ { "authenticate_with_token", "s", NULL },
+};
+
+static const struct wl_message wl_windowmanager_events[] = {
+ { "client_onscreen_visibility", "i", NULL },
+ { "set_screen_rotation", "i", NULL },
};
WL_EXPORT const struct wl_interface wl_windowmanager_interface = {
- "wl_windowmanager", 1,
- ARRAY_LENGTH(wl_windowmanager_requests), wl_windowmanager_requests,
- 0, NULL,
+ "wl_windowmanager", 1,
+ ARRAY_LENGTH(wl_windowmanager_requests), wl_windowmanager_requests,
+ ARRAY_LENGTH(wl_windowmanager_events), wl_windowmanager_events,
};
+
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
index 127578c7c9..0b8cccaaeb 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
@@ -274,12 +274,12 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
pos = mapToReceiver(pos, receiver);
// Send mouse event.
- QMouseEvent *mouseEvent = QMouseEvent::createExtendedMouseEvent(type, pos,
- receiver->mapToGlobal(pos.toPoint()), event->button(),
- event->buttons(), event->modifiers());
+ QMouseEvent mouseEvent(type, pos,
+ receiver->mapToGlobal(pos.toPoint()), event->button(),
+ event->buttons(), event->modifiers());
QWidget *embeddedMouseGrabberPtr = (QWidget *)embeddedMouseGrabber;
- QApplicationPrivate::sendMouseEvent(receiver, mouseEvent, alienWidget, widget,
+ QApplicationPrivate::sendMouseEvent(receiver, &mouseEvent, alienWidget, widget,
&embeddedMouseGrabberPtr, lastWidgetUnderMouse, event->spontaneous());
embeddedMouseGrabber = embeddedMouseGrabberPtr;
@@ -302,8 +302,7 @@ void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent
#endif
}
- event->setAccepted(mouseEvent->isAccepted());
- delete mouseEvent;
+ event->setAccepted(mouseEvent.isAccepted());
}
void QGraphicsProxyWidgetPrivate::sendWidgetKeyEvent(QKeyEvent *event)
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index fd745c16b5..0e1b691b36 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -1221,8 +1221,8 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis
|| event->type() == QEvent::LanguageChange
|| event->type() == QEvent::UpdateSoftKeys
|| event->type() == QEvent::InputMethod)) {
- for (int i = 0; i < postedEvents->size(); ++i) {
- const QPostEvent &cur = postedEvents->at(i);
+ for (QPostEventList::const_iterator it = postedEvents->constBegin(); it != postedEvents->constEnd(); ++it) {
+ const QPostEvent &cur = *it;
if (cur.receiver != receiver || cur.event == 0 || cur.event->type() != event->type())
continue;
if (cur.event->type() == QEvent::LayoutRequest
@@ -2651,7 +2651,8 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) {
if (w->testAttribute(Qt::WA_Hover) &&
(!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
Q_ASSERT(instance());
- QHoverEvent he(QEvent::HoverLeave, QPoint(-1, -1), w->mapFromGlobal(QApplicationPrivate::instance()->hoverGlobalPos));
+ QHoverEvent he(QEvent::HoverLeave, QPoint(-1, -1), w->mapFromGlobal(QApplicationPrivate::instance()->hoverGlobalPos),
+ QApplication::keyboardModifiers());
qApp->d_func()->notify_helper(w, &he);
}
}
@@ -2664,7 +2665,8 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) {
QApplication::sendEvent(w, &enterEvent);
if (w->testAttribute(Qt::WA_Hover) &&
(!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
- QHoverEvent he(QEvent::HoverEnter, w->mapFromGlobal(posEnter), QPoint(-1, -1));
+ QHoverEvent he(QEvent::HoverEnter, w->mapFromGlobal(posEnter), QPoint(-1, -1),
+ QApplication::keyboardModifiers());
qApp->d_func()->notify_helper(w, &he);
}
}
@@ -3826,7 +3828,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
while (w) {
if (w->testAttribute(Qt::WA_Hover) &&
(!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
- QHoverEvent he(QEvent::HoverMove, relpos, relpos - diff);
+ QHoverEvent he(QEvent::HoverMove, relpos, relpos - diff, mouse->modifiers());
d->notify_helper(w, &he);
}
if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
diff --git a/src/widgets/platforms/mac/qfontdatabase_mac.cpp b/src/widgets/platforms/mac/qfontdatabase_mac.cpp
index 724dbf6c4a..b7335d684e 100644
--- a/src/widgets/platforms/mac/qfontdatabase_mac.cpp
+++ b/src/widgets/platforms/mac/qfontdatabase_mac.cpp
@@ -106,12 +106,14 @@ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
CTFontDescriptorRef font = (CTFontDescriptorRef)CFArrayGetValueAtIndex(fonts, i);
QCFString family_name = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute);
+ QCFString style_name = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontStyleNameAttribute);
QtFontFamily *family = db->family(family_name, true);
for(int ws = 1; ws < QFontDatabase::WritingSystemsCount; ++ws)
family->writingSystems[ws] = QtFontFamily::Supported;
QtFontFoundry *foundry = family->foundry(foundry_name, true);
QtFontStyle::Key styleKey;
+ styleKey.styleName = style_name;
if(QCFType<CFDictionaryRef> styles = (CFDictionaryRef)CTFontDescriptorCopyAttribute(font, kCTFontTraitsAttribute)) {
if(CFNumberRef weight = (CFNumberRef)CFDictionaryGetValue(styles, kCTFontWeightTrait)) {
Q_ASSERT(CFNumberIsFloatType(weight));
diff --git a/src/widgets/platforms/mac/qpaintengine_mac.cpp b/src/widgets/platforms/mac/qpaintengine_mac.cpp
index 802c455ab8..0d459a5d89 100644
--- a/src/widgets/platforms/mac/qpaintengine_mac.cpp
+++ b/src/widgets/platforms/mac/qpaintengine_mac.cpp
@@ -798,9 +798,6 @@ QCoreGraphicsPaintEngine::updateClipPath(const QPainterPath &p, Qt::ClipOperatio
} else if(op == Qt::IntersectClip) {
d->current.clip = d->current.clip.intersected(clipRegion);
d->setClip(&d->current.clip);
- } else if(op == Qt::UniteClip) {
- d->current.clip = d->current.clip.united(clipRegion);
- d->setClip(&d->current.clip);
}
}
}
@@ -822,8 +819,6 @@ QCoreGraphicsPaintEngine::updateClipRegion(const QRegion &clipRegion, Qt::ClipOp
d->current.clip = d->current.clip.intersected(clipRegion);
else if(op == Qt::ReplaceClip)
d->current.clip = clipRegion;
- else if(op == Qt::UniteClip)
- d->current.clip = d->current.clip.united(clipRegion);
d->setClip(&d->current.clip);
}
}
diff --git a/src/widgets/platforms/win/qprintengine_win.cpp b/src/widgets/platforms/win/qprintengine_win.cpp
index ebce404c3c..5ba33c043c 100644
--- a/src/widgets/platforms/win/qprintengine_win.cpp
+++ b/src/widgets/platforms/win/qprintengine_win.cpp
@@ -586,8 +586,7 @@ void QWin32PrintEngine::updateClipPath(const QPainterPath &clipPath, Qt::ClipOpe
const int ops[] = {
-1, // Qt::NoClip, covered above
RGN_COPY, // Qt::ReplaceClip
- RGN_AND, // Qt::IntersectClip
- RGN_OR // Qt::UniteClip
+ RGN_AND // Qt::IntersectClip
};
Q_ASSERT(op > 0 && unsigned(op) <= sizeof(ops) / sizeof(int));
SelectClipPath(d->hdc, ops[op]);
diff --git a/src/widgets/platforms/x11/qfontdatabase_x11.cpp b/src/widgets/platforms/x11/qfontdatabase_x11.cpp
index 958daa2506..ed94fa6be1 100644
--- a/src/widgets/platforms/x11/qfontdatabase_x11.cpp
+++ b/src/widgets/platforms/x11/qfontdatabase_x11.cpp
@@ -1034,13 +1034,14 @@ static void loadFontConfig()
FcChar8 *file_value;
int index_value;
FcChar8 *foundry_value;
+ FcChar8 *style_value;
FcBool scalable;
{
FcObjectSet *os = FcObjectSetCreate();
FcPattern *pattern = FcPatternCreate();
const char *properties [] = {
- FC_FAMILY, FC_WEIGHT, FC_SLANT,
+ FC_FAMILY, FC_STYLE, FC_WEIGHT, FC_SLANT,
FC_SPACING, FC_FILE, FC_INDEX,
FC_LANG, FC_CHARSET, FC_FOUNDRY, FC_SCALABLE, FC_PIXEL_SIZE, FC_WEIGHT,
FC_WIDTH,
@@ -1085,6 +1086,8 @@ static void loadFontConfig()
scalable = FcTrue;
if (FcPatternGetString(fonts->fonts[i], FC_FOUNDRY, 0, &foundry_value) != FcResultMatch)
foundry_value = 0;
+ if (FcPatternGetString(fonts->fonts[i], FC_STYLE, 0, &style_value) != FcResultMatch)
+ style_value = 0;
QtFontFamily *family = db->family(familyName, true);
FcLangSet *langset = 0;
@@ -1142,6 +1145,7 @@ static void loadFontConfig()
family->fontFileIndex = index_value;
QtFontStyle::Key styleKey;
+ styleKey.styleName = style_value ? QString::fromUtf8((const char *) style_value) : QString();
styleKey.style = (slant_value == FC_SLANT_ITALIC)
? QFont::StyleItalic
: ((slant_value == FC_SLANT_OBLIQUE)
diff --git a/src/widgets/platforms/x11/qpaintengine_x11.cpp b/src/widgets/platforms/x11/qpaintengine_x11.cpp
index a7ea84c918..6b480815cf 100644
--- a/src/widgets/platforms/x11/qpaintengine_x11.cpp
+++ b/src/widgets/platforms/x11/qpaintengine_x11.cpp
@@ -2078,11 +2078,6 @@ void QX11PaintEngine::updateClipRegion_dev(const QRegion &clipRegion, Qt::ClipOp
else
d->crgn = clipRegion;
break;
- case Qt::UniteClip:
- d->crgn |= clipRegion;
- if (!sysClip.isEmpty())
- d->crgn = d->crgn.intersected(sysClip);
- break;
default:
break;
}
diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
index 92b8fb77fa..5bb7a3bbf2 100644
--- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
+++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
@@ -84,7 +84,7 @@
developer to provide the autorelease pool.
The following is a snippet of subclassing QMacCocoaViewContainer to wrap a NSSearchField.
- \snippet demos/macmainwindow/macmainwindow.mm 0
+ \snippet examples/mainwindows/macmainwindow/macmainwindow.mm 0
*/