summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/boxes/qtbox.cpp14
-rw-r--r--demos/boxes/qtbox.h6
-rw-r--r--examples/graphicsview/padnavigator/main.cpp2
-rw-r--r--examples/webkit/fancybrowser/mainwindow.cpp2
-rw-r--r--examples/webkit/googlechat/main.cpp4
-rw-r--r--examples/widgets/tablet/tabletcanvas.cpp4
-rw-r--r--src/activeqt/container/qaxwidget.cpp7
-rw-r--r--src/corelib/arch/arch.pri3
-rw-r--r--src/corelib/arch/qatomic_windows.h560
-rw-r--r--src/corelib/io/qprocess.cpp5
-rw-r--r--src/corelib/io/qprocess_symbian.cpp2
-rw-r--r--src/corelib/io/qprocess_unix.cpp2
-rw-r--r--src/corelib/io/qtemporaryfile.cpp38
-rw-r--r--src/corelib/kernel/qabstractitemmodel.cpp2
-rw-r--r--src/corelib/kernel/qmetaobject.cpp11
-rw-r--r--src/corelib/thread/qbasicatomic.h15
-rw-r--r--src/corelib/tools/qlist.h1
-rw-r--r--src/corelib/tools/qmargins.cpp167
-rw-r--r--src/corelib/tools/qmargins.h147
-rw-r--r--src/corelib/tools/tools.pri128
-rw-r--r--src/gui/effects/qgraphicseffect.cpp43
-rw-r--r--src/gui/effects/qgraphicseffect.h20
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp53
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h2
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h8
-rw-r--r--src/gui/graphicsview/qgraphicsproxywidget.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp149
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h2
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp6
-rw-r--r--src/gui/image/qimage.cpp6
-rw-r--r--src/gui/image/qpnghandler.cpp8
-rw-r--r--src/gui/itemviews/qheaderview.cpp4
-rw-r--r--src/gui/kernel/qapplication_x11.cpp111
-rw-r--r--src/gui/kernel/qwidget.cpp40
-rw-r--r--src/gui/kernel/qwidget.h4
-rw-r--r--src/gui/painting/qcolor.cpp2
-rw-r--r--src/gui/painting/qdrawutil.cpp137
-rw-r--r--src/gui/painting/qdrawutil.h20
-rw-r--r--src/gui/styles/qcleanlooksstyle.cpp364
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp2
-rw-r--r--src/network/kernel/qnetworkproxy.cpp24
-rw-r--r--src/network/kernel/qnetworkproxy.h1
-rw-r--r--src/network/kernel/qnetworkproxy_p.h85
-rw-r--r--src/network/kernel/qnetworkproxy_win.cpp7
-rw-r--r--src/network/ssl/qsslcertificate.cpp10
-rw-r--r--src/network/ssl/qsslerror.cpp15
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols.cpp2
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols_p.h1
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp52
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h19
-rw-r--r--src/opengl/qgl.cpp34
-rw-r--r--src/opengl/qgl_p.h41
-rw-r--r--src/opengl/qglextensions.cpp4
-rw-r--r--src/opengl/qglextensions_p.h162
-rw-r--r--src/opengl/qglframebufferobject.cpp56
-rw-r--r--src/opengl/qglpixmapfilter.cpp53
-rw-r--r--src/opengl/qglshaderprogram.cpp75
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp8
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h11
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp7
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbmouse.h11
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp9
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h10
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp11
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h8
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp11
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h10
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp83
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.h18
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp3
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp31
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h13
-rw-r--r--src/plugins/imageformats/gif/qgifhandler.cpp4
-rw-r--r--src/script/bridge/qscriptactivationobject.cpp4
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.cpp12
-rw-r--r--src/svg/qsvghandler.cpp127
-rw-r--r--src/testlib/qtestcase.cpp4
-rw-r--r--tests/auto/gestures/customgesturerecognizer.cpp208
-rw-r--r--tests/auto/gestures/customgesturerecognizer.h228
-rw-r--r--tests/auto/gestures/gestures.pro3
-rw-r--r--tests/auto/gestures/tst_gestures.cpp962
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp41
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp2/main2.cpp41
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsecpp2/main3.cpp41
-rw-r--r--tests/auto/qabstractitemmodel/dynamictreemodel.cpp9
-rw-r--r--tests/auto/qabstractitemmodel/dynamictreemodel.h9
-rw-r--r--tests/auto/qabstractitemmodel/qabstractitemmodel.pro2
-rw-r--r--tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp2
-rw-r--r--tests/auto/qatomicint/tst_qatomicint.cpp44
-rw-r--r--tests/auto/qatomicpointer/tst_qatomicpointer.cpp48
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp205
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp6
-rw-r--r--tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp8
-rw-r--r--tests/auto/qimagereader/images/qt.gifbin0 -> 26504 bytes
-rw-r--r--tests/auto/qimagereader/images/qt1.gifbin0 -> 7216 bytes
-rw-r--r--tests/auto/qimagereader/images/qt2.gifbin0 -> 5559 bytes
-rw-r--r--tests/auto/qimagereader/images/qt3.gifbin0 -> 4702 bytes
-rw-r--r--tests/auto/qimagereader/images/qt4.gifbin0 -> 4310 bytes
-rw-r--r--tests/auto/qimagereader/images/qt5.gifbin0 -> 4234 bytes
-rw-r--r--tests/auto/qimagereader/images/qt6.gifbin0 -> 4732 bytes
-rw-r--r--tests/auto/qimagereader/images/qt7.gifbin0 -> 5265 bytes
-rw-r--r--tests/auto/qimagereader/images/qt8.gifbin0 -> 6144 bytes
-rw-r--r--tests/auto/qimagereader/qimagereader.qrc13
-rw-r--r--tests/auto/qimagereader/tst_qimagereader.cpp13
-rw-r--r--tests/auto/qmargins/qmargins.pro3
-rw-r--r--tests/auto/qmargins/tst_qmargins.cpp108
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp6
-rw-r--r--tests/auto/qpainterpath/tst_qpainterpath.cpp5
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp29
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp41
-rw-r--r--tests/auto/qsslcertificate/tst_qsslcertificate.cpp6
-rw-r--r--tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp82
-rw-r--r--tests/benchmarks/qgraphicsanchorlayout/qgraphicsanchorlayout.pro6
-rw-r--r--tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp197
-rw-r--r--tests/manual/qhttpnetworkconnection/main.cpp81
-rw-r--r--tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro13
-rw-r--r--tests/manual/qtabletevent/device_information/main.cpp (renamed from tests/manual/qtabletevent/main.cpp)4
-rw-r--r--tests/manual/qtabletevent/device_information/qtabletevent.pro (renamed from tests/manual/qtabletevent/qtabletevent.pro)0
-rw-r--r--tests/manual/qtabletevent/device_information/tabletwidget.cpp (renamed from tests/manual/qtabletevent/tabletwidget.cpp)0
-rw-r--r--tests/manual/qtabletevent/device_information/tabletwidget.h (renamed from tests/manual/qtabletevent/tabletwidget.h)0
-rw-r--r--tests/manual/qtabletevent/event_compression/event_compression.pro7
-rw-r--r--tests/manual/qtabletevent/event_compression/main.cpp58
-rw-r--r--tests/manual/qtabletevent/event_compression/mousestatwidget.cpp99
-rw-r--r--tests/manual/qtabletevent/event_compression/mousestatwidget.h69
-rw-r--r--tools/qdoc3/test/classic.css38
125 files changed, 3279 insertions, 2595 deletions
diff --git a/demos/boxes/qtbox.cpp b/demos/boxes/qtbox.cpp
index 015bc95..54882fb 100644
--- a/demos/boxes/qtbox.cpp
+++ b/demos/boxes/qtbox.cpp
@@ -122,7 +122,7 @@ void ItemBase::duplicateSelectedItems(QGraphicsScene *scene)
selected = scene->selectedItems();
foreach (QGraphicsItem *item, selected) {
- ItemBase *itemBase = dynamic_cast<ItemBase *>(item);
+ ItemBase *itemBase = qgraphicsitem_cast<ItemBase *>(item);
if (itemBase)
scene->addItem(itemBase->createNew(itemBase->m_size, itemBase->pos().x() + itemBase->m_size, itemBase->pos().y()));
}
@@ -137,7 +137,7 @@ void ItemBase::deleteSelectedItems(QGraphicsScene *scene)
selected = scene->selectedItems();
foreach (QGraphicsItem *item, selected) {
- ItemBase *itemBase = dynamic_cast<ItemBase *>(item);
+ ItemBase *itemBase = qgraphicsitem_cast<ItemBase *>(item);
if (itemBase)
delete itemBase;
}
@@ -152,7 +152,7 @@ void ItemBase::growSelectedItems(QGraphicsScene *scene)
selected = scene->selectedItems();
foreach (QGraphicsItem *item, selected) {
- ItemBase *itemBase = dynamic_cast<ItemBase *>(item);
+ ItemBase *itemBase = qgraphicsitem_cast<ItemBase *>(item);
if (itemBase) {
itemBase->prepareGeometryChange();
itemBase->m_size *= 2;
@@ -171,7 +171,7 @@ void ItemBase::shrinkSelectedItems(QGraphicsScene *scene)
selected = scene->selectedItems();
foreach (QGraphicsItem *item, selected) {
- ItemBase *itemBase = dynamic_cast<ItemBase *>(item);
+ ItemBase *itemBase = qgraphicsitem_cast<ItemBase *>(item);
if (itemBase) {
itemBase->prepareGeometryChange();
itemBase->m_size /= 2;
@@ -257,6 +257,12 @@ void ItemBase::wheelEvent(QGraphicsSceneWheelEvent *event)
m_size = MIN_ITEM_SIZE;
}
+int ItemBase::type() const
+{
+ return Type;
+}
+
+
bool ItemBase::isInResizeArea(const QPointF &pos)
{
return (-pos.y() < pos.x() - m_size + 9);
diff --git a/demos/boxes/qtbox.h b/demos/boxes/qtbox.h
index 6f39b0d..9465911 100644
--- a/demos/boxes/qtbox.h
+++ b/demos/boxes/qtbox.h
@@ -47,10 +47,11 @@
#include <QtGui/qvector3d.h>
#include "glbuffers.h"
-class ItemBase : public QObject, public QGraphicsItem
+class ItemBase : public QGraphicsItem
{
- Q_OBJECT
public:
+ enum { Type = UserType + 1 };
+
ItemBase(int size, int x, int y);
virtual ~ItemBase();
virtual QRectF boundingRect() const;
@@ -64,6 +65,7 @@ protected:
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void keyPressEvent(QKeyEvent *event);
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
+ virtual int type() const;
bool isInResizeArea(const QPointF &pos);
static void duplicateSelectedItems(QGraphicsScene *scene);
diff --git a/examples/graphicsview/padnavigator/main.cpp b/examples/graphicsview/padnavigator/main.cpp
index a984eab..30e1dc3 100644
--- a/examples/graphicsview/padnavigator/main.cpp
+++ b/examples/graphicsview/padnavigator/main.cpp
@@ -53,7 +53,7 @@ int main(int argc, char *argv[])
Panel panel(3, 3);
panel.setFocus();
- panel.showFullScreen();
+ panel.show();
return app.exec();
}
diff --git a/examples/webkit/fancybrowser/mainwindow.cpp b/examples/webkit/fancybrowser/mainwindow.cpp
index ecca36b..06b1e30 100644
--- a/examples/webkit/fancybrowser/mainwindow.cpp
+++ b/examples/webkit/fancybrowser/mainwindow.cpp
@@ -56,6 +56,8 @@ MainWindow::MainWindow()
file.close();
//! [1]
+ QNetworkProxyFactory::setUseSystemConfigurationEnabled(true);
+
//! [2]
view = new QWebView(this);
view->load(QUrl("http://www.google.com/ncr"));
diff --git a/examples/webkit/googlechat/main.cpp b/examples/webkit/googlechat/main.cpp
index 31937ee..09d94ef 100644
--- a/examples/webkit/googlechat/main.cpp
+++ b/examples/webkit/googlechat/main.cpp
@@ -40,11 +40,15 @@
****************************************************************************/
#include <QtGui>
+#include <QNetworkProxyFactory>
#include "googlechat.h"
int main(int argc, char * argv[])
{
QApplication app(argc, argv);
+
+ QNetworkProxyFactory::setUseSystemConfigurationEnabled(true);
+
GoogleChat *chat = new GoogleChat;
chat->show();
return app.exec();
diff --git a/examples/widgets/tablet/tabletcanvas.cpp b/examples/widgets/tablet/tabletcanvas.cpp
index abb667c..612a635 100644
--- a/examples/widgets/tablet/tabletcanvas.cpp
+++ b/examples/widgets/tablet/tabletcanvas.cpp
@@ -98,8 +98,10 @@ void TabletCanvas::tabletEvent(QTabletEvent *event)
switch (event->type()) {
case QEvent::TabletPress:
- if (!deviceDown)
+ if (!deviceDown) {
deviceDown = true;
+ polyLine[0] = polyLine[1] = polyLine[2] = event->pos();
+ }
break;
case QEvent::TabletRelease:
if (deviceDown)
diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp
index 621c836..94f85a5 100644
--- a/src/activeqt/container/qaxwidget.cpp
+++ b/src/activeqt/container/qaxwidget.cpp
@@ -1437,6 +1437,9 @@ extern Q_GUI_EXPORT bool qt_win_ignoreNextMouseReleaseEvent;
HRESULT WINAPI QAxClientSite::EnableModeless(BOOL fEnable)
{
+#if !defined(Q_OS_WINCE)
+ LockWindowUpdate(host->window()->winId());
+#endif
EnableWindow(host->window()->winId(), fEnable);
if (!fEnable) {
@@ -1447,7 +1450,9 @@ HRESULT WINAPI QAxClientSite::EnableModeless(BOOL fEnable)
QApplicationPrivate::leaveModal(host);
}
qt_win_ignoreNextMouseReleaseEvent = false;
-
+#if !defined(Q_OS_WINCE)
+ LockWindowUpdate(0);
+#endif
return S_OK;
}
diff --git a/src/corelib/arch/arch.pri b/src/corelib/arch/arch.pri
index a25027b..57bc80a 100644
--- a/src/corelib/arch/arch.pri
+++ b/src/corelib/arch/arch.pri
@@ -1,6 +1,9 @@
win32:HEADERS += arch/qatomic_windows.h \
arch/qatomic_generic.h
+win32-g++*:HEADERS += arch/qatomic_i386.h \
+ arch/qatomic_x86_64.h
+
mac:HEADERS += arch/qatomic_macosx.h \
arch/qatomic_generic.h
diff --git a/src/corelib/arch/qatomic_windows.h b/src/corelib/arch/qatomic_windows.h
index a826bd3..9b7ff5d 100644
--- a/src/corelib/arch/qatomic_windows.h
+++ b/src/corelib/arch/qatomic_windows.h
@@ -42,6 +42,197 @@
#ifndef QATOMIC_WINDOWS_H
#define QATOMIC_WINDOWS_H
+#ifndef Q_CC_MSVC
+
+// Mingw and other GCC platforms get inline assembly
+
+# ifdef __i386__
+# include "QtCore/qatomic_i386.h"
+# else
+# include "QtCore/qatomic_x86_64.h"
+# endif
+
+#else // Q_CC_MSVC
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef Q_OS_WINCE
+
+// use compiler intrinsics for all atomic functions
+# define QT_INTERLOCKED_PREFIX _
+# define QT_INTERLOCKED_PROTOTYPE __cdecl
+# define QT_INTERLOCKED_DECLARE_PROTOTYPES
+# define QT_INTERLOCKED_INTRINSIC
+
+#else // Q_OS_WINCE
+
+# if _WIN32_WCE < 0x600 && defined(_X86_)
+// For X86 Windows CE, include winbase.h to catch inline functions which
+// override the regular definitions inside of coredll.dll.
+// Though one could use the original version of Increment/Decrement, others are
+// not exported at all.
+# include <winbase.h>
+
+// It's safer to remove the volatile and let the compiler add it as needed.
+# define QT_INTERLOCKED_NO_VOLATILE
+
+# else // _WIN32_WCE >= 0x600 || !_X86_
+
+# define QT_INTERLOCKED_PROTOTYPE __cdecl
+# define QT_INTERLOCKED_DECLARE_PROTOTYPES
+
+# if _WIN32_WCE >= 0x600
+# if defined(_X86_)
+# define QT_INTERLOCKED_PREFIX _
+# define QT_INTERLOCKED_INTRINSIC
+# endif
+# else
+# define QT_INTERLOCKED_NO_VOLATILE
+# endif
+
+# endif // _WIN32_WCE >= 0x600 || !_X86_
+
+#endif // Q_OS_WINCE
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Prototype declaration
+
+#define QT_INTERLOCKED_CONCAT_I(prefix, suffix) \
+ prefix ## suffix
+#define QT_INTERLOCKED_CONCAT(prefix, suffix) \
+ QT_INTERLOCKED_CONCAT_I(prefix, suffix)
+
+// MSVC intrinsics prefix function names with an underscore
+#define QT_INTERLOCKED_FUNCTION(name) \
+ QT_INTERLOCKED_CONCAT(QT_INTERLOCKED_PREFIX, name)
+
+#ifdef QT_INTERLOCKED_NO_VOLATILE
+# define QT_INTERLOCKED_VOLATILE
+# define QT_INTERLOCKED_REMOVE_VOLATILE(a) qt_interlocked_remove_volatile(a)
+#else
+# define QT_INTERLOCKED_VOLATILE volatile
+# define QT_INTERLOCKED_REMOVE_VOLATILE(a) a
+#endif
+
+#ifndef QT_INTERLOCKED_PREFIX
+#define QT_INTERLOCKED_PREFIX
+#endif
+
+#ifndef QT_INTERLOCKED_PROTOTYPE
+#define QT_INTERLOCKED_PROTOTYPE
+#endif
+
+#ifdef QT_INTERLOCKED_DECLARE_PROTOTYPES
+#undef QT_INTERLOCKED_DECLARE_PROTOTYPES
+
+extern "C" {
+
+ long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedIncrement )(long QT_INTERLOCKED_VOLATILE *);
+ long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedDecrement )(long QT_INTERLOCKED_VOLATILE *);
+ long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedCompareExchange )(long QT_INTERLOCKED_VOLATILE *, long, long);
+ long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedExchange )(long QT_INTERLOCKED_VOLATILE *, long);
+ long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedExchangeAdd )(long QT_INTERLOCKED_VOLATILE *, long);
+
+# if !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86)
+ void * QT_INTERLOCKED_FUNCTION( InterlockedCompareExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *, void *);
+ void * QT_INTERLOCKED_FUNCTION( InterlockedExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *);
+ __int64 QT_INTERLOCKED_FUNCTION( InterlockedExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64);
+# endif
+
+}
+
+#endif // QT_INTERLOCKED_DECLARE_PROTOTYPES
+
+#undef QT_INTERLOCKED_PROTOTYPE
+#undef QT_INTERLOCKED_VOLATILE
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef QT_INTERLOCKED_INTRINSIC
+#undef QT_INTERLOCKED_INTRINSIC
+
+# pragma intrinsic (_InterlockedIncrement)
+# pragma intrinsic (_InterlockedDecrement)
+# pragma intrinsic (_InterlockedExchange)
+# pragma intrinsic (_InterlockedCompareExchange)
+# pragma intrinsic (_InterlockedExchangeAdd)
+
+# ifndef _M_IX86
+# pragma intrinsic (_InterlockedCompareExchangePointer)
+# pragma intrinsic (_InterlockedExchangePointer)
+# pragma intrinsic (_InterlockedExchangeAdd64)
+# endif
+
+#endif // QT_INTERLOCKED_INTRINSIC
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Interlocked* replacement macros
+
+#define QT_INTERLOCKED_INCREMENT(value) \
+ QT_INTERLOCKED_FUNCTION(InterlockedIncrement)( \
+ QT_INTERLOCKED_REMOVE_VOLATILE( value ) )
+
+#define QT_INTERLOCKED_DECREMENT(value) \
+ QT_INTERLOCKED_FUNCTION(InterlockedDecrement)( \
+ QT_INTERLOCKED_REMOVE_VOLATILE( value ) )
+
+#define QT_INTERLOCKED_COMPARE_EXCHANGE(value, newValue, expectedValue) \
+ QT_INTERLOCKED_FUNCTION(InterlockedCompareExchange)( \
+ QT_INTERLOCKED_REMOVE_VOLATILE( value ), \
+ newValue, \
+ expectedValue )
+
+#define QT_INTERLOCKED_EXCHANGE(value, newValue) \
+ QT_INTERLOCKED_FUNCTION(InterlockedExchange)( \
+ QT_INTERLOCKED_REMOVE_VOLATILE( value ), \
+ newValue )
+
+#define QT_INTERLOCKED_EXCHANGE_ADD(value, valueToAdd) \
+ QT_INTERLOCKED_FUNCTION(InterlockedExchangeAdd)( \
+ QT_INTERLOCKED_REMOVE_VOLATILE( value ), \
+ valueToAdd )
+
+#if defined(Q_OS_WINCE) || defined(__i386__) || defined(_M_IX86)
+
+# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \
+ reinterpret_cast<void *>( \
+ QT_INTERLOCKED_FUNCTION(InterlockedCompareExchange)( \
+ QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \
+ (long)( newValue ), \
+ (long)( expectedValue ) ))
+
+# define QT_INTERLOCKED_EXCHANGE_POINTER(value, newValue) \
+ QT_INTERLOCKED_FUNCTION(InterlockedExchange)( \
+ QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \
+ (quintptr)( newValue ) )
+
+# define QT_INTERLOCKED_EXCHANGE_ADD_POINTER(value, valueToAdd) \
+ QT_INTERLOCKED_FUNCTION(InterlockedExchangeAdd)( \
+ QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \
+ valueToAdd )
+
+#else // !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86)
+
+# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \
+ QT_INTERLOCKED_FUNCTION(InterlockedCompareExchangePointer)( \
+ QT_INTERLOCKED_REMOVE_VOLATILE( value ), \
+ newValue, \
+ expectedValue )
+
+# define QT_INTERLOCKED_EXCHANGE_POINTER(value, newValue) \
+ QT_INTERLOCKED_FUNCTION(InterlockedExchangePointer)( \
+ QT_INTERLOCKED_REMOVE_VOLATILE( value ), \
+ newValue )
+
+# define QT_INTERLOCKED_EXCHANGE_ADD_POINTER(value, valueToAdd) \
+ QT_INTERLOCKED_FUNCTION(InterlockedExchangeAdd64)( \
+ QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \
+ valueToAdd )
+
+#endif // !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86)
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -107,369 +298,68 @@ template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddWaitFree()
{ return true; }
-#if defined(Q_CC_MSVC) || defined(Q_CC_MWERKS)
-
-// MSVC++ 6.0 doesn't generate correct code when optimizations are turned on!
-#if _MSC_VER < 1300 && defined (_M_IX86)
-
-inline bool QBasicAtomicInt::ref()
-{
- volatile int *pointer = &_q_value;
- unsigned char retVal;
- __asm {
- mov ECX,pointer
- lock inc DWORD ptr[ECX]
- setne retVal
- }
- return retVal != 0;
-}
-
-inline bool QBasicAtomicInt::deref()
-{
- volatile int *pointer = &_q_value;
- unsigned char retVal;
- __asm {
- mov ECX,pointer
- lock dec DWORD ptr[ECX]
- setne retVal
- }
- return retVal != 0;
-}
-
-inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
-{
- volatile int *pointer = &_q_value;
- __asm {
- mov EDX,pointer
- mov EAX,expectedValue
- mov ECX,newValue
- lock cmpxchg dword ptr[EDX],ECX
- mov newValue,EAX
- }
- return newValue == expectedValue;
-}
-
-
-inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
-{
- volatile int *pointer = &_q_value;
- __asm {
- mov EDX,pointer
- mov ECX,newValue
- lock xchg dword ptr[EDX],ECX
- mov newValue,ECX
- }
- return newValue;
-}
-
-
-inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
-{
- volatile int *pointer = &_q_value;
- __asm {
- mov EDX,pointer
- mov ECX,valueToAdd
- lock xadd dword ptr[EDX],ECX
- mov valueToAdd,ECX
- }
- return valueToAdd;
-}
+////////////////////////////////////////////////////////////////////////////////////////////////////
-template <typename T>
-Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
-{
- volatile void *pointer = &_q_value;
- __asm {
- mov EDX,pointer
- mov EAX,expectedValue
- mov ECX,newValue
- lock cmpxchg dword ptr[EDX],ECX
- mov newValue,EAX
- }
- return newValue == expectedValue;
-}
-
-template <typename T>
-Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
-{
- volatile void *pointer = &_q_value;
- __asm {
- mov EDX,pointer
- mov ECX,newValue
- lock xchg dword ptr[EDX],ECX
- mov newValue,ECX
- }
- return reinterpret_cast<T *>(newValue);
-}
-
-template <typename T>
-Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
+#ifdef QT_INTERLOCKED_NO_VOLATILE
+template <class T>
+Q_INLINE_TEMPLATE T *qt_interlocked_remove_volatile(T volatile *t)
{
- volatile void *pointer = &_q_value;
- valueToAdd *= sizeof(T);
- __asm {
- mov EDX,pointer
- mov ECX,valueToAdd
- lock xadd dword ptr[EDX],ECX
- mov pointer,ECX
- }
- return reinterpret_cast<T *>(const_cast<void *>(pointer));
+ return const_cast<T *>(t);
}
+#endif // !QT_INTERLOCKED_NO_VOLATILE
-#else
-
-#if !defined(Q_OS_WINCE) && !defined(Q_CC_MWERKS)
-// use compiler intrinsics for all atomic functions
-//those functions need to be define in the global namespace
-QT_END_NAMESPACE
-
-extern "C" {
- long __cdecl _InterlockedIncrement(volatile long *);
- long __cdecl _InterlockedDecrement(volatile long *);
- long __cdecl _InterlockedExchange(volatile long *, long);
- long __cdecl _InterlockedCompareExchange(volatile long *, long, long);
- long __cdecl _InterlockedExchangeAdd(volatile long *, long);
-}
-# pragma intrinsic (_InterlockedIncrement)
-# pragma intrinsic (_InterlockedDecrement)
-# pragma intrinsic (_InterlockedExchange)
-# pragma intrinsic (_InterlockedCompareExchange)
-# pragma intrinsic (_InterlockedExchangeAdd)
-
-# ifndef _M_IX86
-extern "C" {
- void *_InterlockedCompareExchangePointer(void * volatile *, void *, void *);
- void *_InterlockedExchangePointer(void * volatile *, void *);
- __int64 _InterlockedExchangeAdd64(__int64 volatile * Addend, __int64 Value);
-}
-# pragma intrinsic (_InterlockedCompareExchangePointer)
-# pragma intrinsic (_InterlockedExchangePointer)
-# pragma intrinsic (_InterlockedExchangeAdd64)
-# define _InterlockedExchangeAddPointer(a,b) \
- _InterlockedExchangeAdd64(reinterpret_cast<volatile __int64 *>(a), __int64(b))
-# else
-# define _InterlockedCompareExchangePointer(a,b,c) \
- _InterlockedCompareExchange(reinterpret_cast<volatile long *>(a), long(b), long(c))
-# define _InterlockedExchangePointer(a, b) \
- _InterlockedExchange(reinterpret_cast<volatile long *>(a), long(b))
-# define _InterlockedExchangeAddPointer(a,b) \
- _InterlockedExchangeAdd(reinterpret_cast<volatile long *>(a), long(b))
-# endif
-
-QT_BEGIN_NAMESPACE
+////////////////////////////////////////////////////////////////////////////////////////////////////
inline bool QBasicAtomicInt::ref()
{
- return _InterlockedIncrement(reinterpret_cast<volatile long *>(&_q_value)) != 0;
+ return QT_INTERLOCKED_INCREMENT(&_q_value) != 0;
}
inline bool QBasicAtomicInt::deref()
{
- return _InterlockedDecrement(reinterpret_cast<volatile long *>(&_q_value)) != 0;
+ return QT_INTERLOCKED_DECREMENT(&_q_value) != 0;
}
inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
{
- return _InterlockedCompareExchange(reinterpret_cast<volatile long *>(&_q_value), newValue, expectedValue) == expectedValue;
+ return QT_INTERLOCKED_COMPARE_EXCHANGE(&_q_value, newValue, expectedValue)
+ == expectedValue;
}
inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
{
- return _InterlockedExchange(reinterpret_cast<volatile long *>(&_q_value), newValue);
+ return QT_INTERLOCKED_EXCHANGE(&_q_value, newValue);
}
inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
{
- return _InterlockedExchangeAdd(reinterpret_cast<volatile long *>(&_q_value), valueToAdd);
+ return QT_INTERLOCKED_EXCHANGE_ADD(&_q_value, valueToAdd);
}
-#if defined(Q_CC_MSVC)
-#pragma warning( push )
-#pragma warning( disable : 4311 ) // ignoring the warning from /Wp64
-#endif
+////////////////////////////////////////////////////////////////////////////////////////////////////
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
{
- return (_InterlockedCompareExchangePointer(reinterpret_cast<void * volatile *>(&_q_value),
- newValue, expectedValue) ==
-#ifndef _M_IX86
- (void *)
-#else
- (long)
-#endif
- (expectedValue));
-}
-
-#if defined(Q_CC_MSVC)
-#pragma warning( pop )
-#endif
-
-template <typename T>
-Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
-{
- return reinterpret_cast<T *>(_InterlockedExchangePointer(reinterpret_cast<void * volatile *>(&_q_value), newValue));
+ return QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(&_q_value, newValue, expectedValue)
+ == expectedValue;
}
template <typename T>
-Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
-{
- return reinterpret_cast<T *>(_InterlockedExchangeAddPointer(reinterpret_cast<void * volatile *>(&_q_value), valueToAdd * sizeof(T)));
-}
-
-#else // Q_OS_WINCE
-
-#if (_WIN32_WCE < 0x600 && defined(_X86_)) || defined(Q_CC_MWERKS)
-// For X86 Windows CE build we need to include winbase.h to be able
-// to catch the inline functions which overwrite the regular
-// definitions inside of coredll.dll. Though one could use the
-// original version of Increment/Decrement, the others are not
-// exported at all.
-#include <winbase.h>
-#else
-#if _WIN32_WCE >= 0x600 || defined(Q_CC_MWERKS)
-#define Q_ARGUMENT_TYPE volatile
-# if defined(_X86_)
-# define InterlockedIncrement _InterlockedIncrement
-# define InterlockedDecrement _InterlockedDecrement
-# define InterlockedExchange _InterlockedExchange
-# define InterlockedCompareExchange _InterlockedCompareExchange
-# define InterlockedExchangeAdd _InterlockedExchangeAdd
-# endif
-#else
-#define Q_ARGUMENT_TYPE
-#endif
-
-QT_END_NAMESPACE
-
-extern "C" {
-long __cdecl InterlockedIncrement(long Q_ARGUMENT_TYPE * lpAddend);
-long __cdecl InterlockedDecrement(long Q_ARGUMENT_TYPE * lpAddend);
-long __cdecl InterlockedExchange(long Q_ARGUMENT_TYPE * Target, long Value);
-long __cdecl InterlockedCompareExchange(long Q_ARGUMENT_TYPE * Destination, long Exchange, long Comperand);
-long __cdecl InterlockedExchangeAdd(long Q_ARGUMENT_TYPE * Addend, long Value);
-}
-
-#if _WIN32_WCE >= 0x600 && defined(_X86_)
-# pragma intrinsic (_InterlockedIncrement)
-# pragma intrinsic (_InterlockedDecrement)
-# pragma intrinsic (_InterlockedExchange)
-# pragma intrinsic (_InterlockedCompareExchange)
-# pragma intrinsic (_InterlockedExchangeAdd)
-#endif
-
-QT_BEGIN_NAMESPACE
-
-#endif
-
-
-inline bool QBasicAtomicInt::ref()
-{
- return InterlockedIncrement((long*)(&_q_value)) != 0;
-}
-
-inline bool QBasicAtomicInt::deref()
-{
- return InterlockedDecrement((long*)(&_q_value)) != 0;
-}
-
-inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
-{
- return InterlockedCompareExchange((long*)(&_q_value), newValue, expectedValue) == expectedValue;
-}
-
-inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
-{
- return InterlockedExchange((long*)(&_q_value), newValue);
-}
-
-inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
-{
- return InterlockedExchangeAdd((long*)(&_q_value), valueToAdd);
-}
-
-template <typename T>
-Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
-{
- return (InterlockedCompareExchange((long*)(&_q_value),
- (long)newValue, (long)expectedValue) ==
- (long)(expectedValue));
-}
-
-template <typename T>
-Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T* newValue)
{
- return reinterpret_cast<T *>(InterlockedExchange((long*)(&_q_value), (long)newValue));
+ return reinterpret_cast<T *>(
+ QT_INTERLOCKED_EXCHANGE_POINTER(&_q_value, newValue));
}
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
{
- return reinterpret_cast<T *>(InterlockedExchangeAdd((long*)(&_q_value), valueToAdd * sizeof(T)));
-}
-
-#endif //Q_OS_WINCE
-
-#endif // _MSC_VER ...
-
-#else
-
-// __INTERLOCKED_DECLARED is defined in MinGW's winbase.h. Simply, preferrably we use
-// MinGW's definition, such that we pick up variations in the headers.
-#ifndef __INTERLOCKED_DECLARED
-#define __INTERLOCKED_DECLARED
-QT_END_NAMESPACE
-
-extern "C" {
- __declspec(dllimport) long __stdcall InterlockedCompareExchange(long *, long, long);
- __declspec(dllimport) long __stdcall InterlockedIncrement(long *);
- __declspec(dllimport) long __stdcall InterlockedDecrement(long *);
- __declspec(dllimport) long __stdcall InterlockedExchange(long *, long);
- __declspec(dllimport) long __stdcall InterlockedExchangeAdd(long *, long);
-}
-
-QT_BEGIN_NAMESPACE
-#endif
-
-inline bool QBasicAtomicInt::ref()
-{
- return InterlockedIncrement(reinterpret_cast<long *>(const_cast<int *>(&_q_value))) != 0;
-}
-
-inline bool QBasicAtomicInt::deref()
-{
- return InterlockedDecrement(reinterpret_cast<long *>(const_cast<int *>(&_q_value))) != 0;
+ return reinterpret_cast<T *>(
+ QT_INTERLOCKED_EXCHANGE_ADD_POINTER(&_q_value, valueToAdd * sizeof(T)));
}
-inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
-{
- return InterlockedCompareExchange(reinterpret_cast<long *>(const_cast<int *>(&_q_value)), newValue, expectedValue) == expectedValue;
-}
-
-inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
-{ return InterlockedExchange(reinterpret_cast<long *>(const_cast<int *>(&_q_value)), newValue); }
-
-inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
-{
- return InterlockedExchangeAdd(reinterpret_cast<long *>(const_cast<int *>(&_q_value)), valueToAdd);
-}
-
-template <typename T>
-Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T* newValue)
-{ return InterlockedCompareExchange(reinterpret_cast<long *>(const_cast<T **>(&_q_value)),
- reinterpret_cast<long>(newValue),
- reinterpret_cast<long>(expectedValue)) == reinterpret_cast<long>(expectedValue); }
-
-template <typename T>
-Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T* newValue)
-{ return reinterpret_cast<T *>(InterlockedExchange(reinterpret_cast<long *>(const_cast<T **>(&_q_value)),
- reinterpret_cast<long>(newValue))); }
-
-template <typename T>
-Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
-{ return reinterpret_cast<T *>(InterlockedExchangeAdd(reinterpret_cast<long *>(const_cast<T **>(&_q_value)), valueToAdd * sizeof(T))); }
-
-#endif // Q_CC_GNU
+////////////////////////////////////////////////////////////////////////////////////////////////////
inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
{
@@ -516,6 +406,8 @@ inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
return fetchAndAddOrdered(valueToAdd);
}
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
{
@@ -570,8 +462,30 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueTo
return fetchAndAddOrdered(valueToAdd);
}
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Cleanup
+
+#undef QT_INTERLOCKED_CONCAT_I
+#undef QT_INTERLOCKED_CONCAT
+#undef QT_INTERLOCKED_FUNCTION
+#undef QT_INTERLOCKED_PREFIX
+
+#undef QT_INTERLOCKED_NO_VOLATILE
+#undef QT_INTERLOCKED_REMOVE_VOLATILE
+
+#undef QT_INTERLOCKED_INCREMENT
+#undef QT_INTERLOCKED_DECREMENT
+#undef QT_INTERLOCKED_COMPARE_EXCHANGE
+#undef QT_INTERLOCKED_EXCHANGE
+#undef QT_INTERLOCKED_EXCHANGE_ADD
+#undef QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER
+#undef QT_INTERLOCKED_EXCHANGE_POINTER
+#undef QT_INTERLOCKED_EXCHANGE_ADD_POINTER
+
QT_END_NAMESPACE
QT_END_HEADER
+#endif // Q_CC_MSVC
+
#endif // QATOMIC_WINDOWS_H
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index f7049d3..5b6830c 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -411,6 +411,11 @@ void QProcessPrivate::Channel::clear()
process = 0;
}
+/*! \fn bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid)
+
+\internal
+ */
+
/*!
\class QProcess
diff --git a/src/corelib/io/qprocess_symbian.cpp b/src/corelib/io/qprocess_symbian.cpp
index e558387..d41321b 100644
--- a/src/corelib/io/qprocess_symbian.cpp
+++ b/src/corelib/io/qprocess_symbian.cpp
@@ -1009,8 +1009,6 @@ void QProcessPrivate::_q_notified()
// Nothing to do in Symbian
}
-/*! \internal
- */
bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid)
{
QPROCESS_DEBUG_PRINT("QProcessPrivate::startDetached()");
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index baf90c4..d45ff03 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -1163,8 +1163,6 @@ void QProcessPrivate::_q_notified()
{
}
-/*! \internal
- */
bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid)
{
processManager()->start();
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index 48f34d6..fa3ed09 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -292,14 +292,20 @@ class QTemporaryFileEngine : public QFSFileEngine
Q_DECLARE_PRIVATE(QFSFileEngine)
public:
QTemporaryFileEngine(const QString &file, bool fileIsTemplate = true)
- : QFSFileEngine(file), filePathIsTemplate(fileIsTemplate)
+ : QFSFileEngine(), filePathIsTemplate(fileIsTemplate)
{
+ Q_D(QFSFileEngine);
+ d->filePath = file;
+
+ if (!filePathIsTemplate)
+ QFSFileEngine::setFileName(file);
}
~QTemporaryFileEngine();
bool isReallyOpen();
void setFileName(const QString &file);
+ void setFileTemplate(const QString &fileTemplate);
bool open(QIODevice::OpenMode flags);
bool remove();
@@ -336,6 +342,13 @@ void QTemporaryFileEngine::setFileName(const QString &file)
QFSFileEngine::setFileName(file);
}
+void QTemporaryFileEngine::setFileTemplate(const QString &fileTemplate)
+{
+ Q_D(QFSFileEngine);
+ if (filePathIsTemplate)
+ d->filePath = fileTemplate;
+}
+
bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
{
Q_D(QFSFileEngine);
@@ -382,12 +395,19 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode)
return false;
}
+ QString template_ = d->filePath;
d->filePath = QString::fromLocal8Bit(filename);
- filePathIsTemplate = false;
d->nativeInitFileName();
- d->closeFileHandle = true;
delete [] filename;
- return QFSFileEngine::open(openMode);
+
+ if (QFSFileEngine::open(openMode)) {
+ filePathIsTemplate = false;
+ return true;
+ }
+
+ d->filePath = template_;
+ d->nativeFilePath.clear();
+ return false;
#endif
}
@@ -533,7 +553,8 @@ QTemporaryFile::QTemporaryFile()
QTemporaryFile::QTemporaryFile(const QString &templateName)
: QFile(*new QTemporaryFilePrivate, 0)
{
- setFileTemplate(templateName);
+ Q_D(QTemporaryFile);
+ d->templateName = templateName;
}
/*!
@@ -567,7 +588,8 @@ QTemporaryFile::QTemporaryFile(QObject *parent)
QTemporaryFile::QTemporaryFile(const QString &templateName, QObject *parent)
: QFile(*new QTemporaryFilePrivate, parent)
{
- setFileTemplate(templateName);
+ Q_D(QTemporaryFile);
+ d->templateName = templateName;
}
#endif
@@ -671,10 +693,10 @@ QString QTemporaryFile::fileTemplate() const
*/
void QTemporaryFile::setFileTemplate(const QString &name)
{
- Q_ASSERT(!isOpen());
Q_D(QTemporaryFile);
- fileEngine()->setFileName(name);
d->templateName = name;
+ if (d->fileEngine)
+ static_cast<QTemporaryFileEngine*>(d->fileEngine)->setFileTemplate(name);
}
/*!
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp
index 0a6c628..ec8fb76 100644
--- a/src/corelib/kernel/qabstractitemmodel.cpp
+++ b/src/corelib/kernel/qabstractitemmodel.cpp
@@ -601,7 +601,6 @@ void QAbstractItemModelPrivate::rowsInserted(const QModelIndex &parent,
void QAbstractItemModelPrivate::itemsAboutToBeMoved(const QModelIndex &srcParent, int srcFirst, int srcLast, const QModelIndex &destinationParent, int destinationChild, Qt::Orientation orientation)
{
- Q_Q(QAbstractItemModel);
QVector<QPersistentModelIndexData *> persistent_moved_explicitly;
QVector<QPersistentModelIndexData *> persistent_moved_in_source;
QVector<QPersistentModelIndexData *> persistent_moved_in_destination;
@@ -2469,7 +2468,6 @@ void QAbstractItemModel::endRemoveRows()
*/
bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int start, int end, const QModelIndex &destinationParent, int destinationStart, Qt::Orientation orientation)
{
- Q_Q(QAbstractItemModel);
// Don't move the range within itself.
if ( ( destinationParent == srcParent )
&& ( destinationStart >= start )
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 30f1cc8..c311465 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -943,7 +943,7 @@ QByteArray QMetaObject::normalizedType(const char *type)
if (!type || !*type)
return result;
- QVarLengthArray<char> stackbuf((int)strlen(type));
+ QVarLengthArray<char> stackbuf(int(strlen(type)) + 1);
qRemoveWhitespace(type, stackbuf.data());
int templdepth = 0;
qNormalizeType(stackbuf.data(), templdepth, result);
@@ -968,10 +968,9 @@ QByteArray QMetaObject::normalizedSignature(const char *method)
if (!method || !*method)
return result;
int len = int(strlen(method));
- char stackbuf[64];
- char *buf = (len >= 64 ? new char[len+1] : stackbuf);
- qRemoveWhitespace(method, buf);
- char *d = buf;
+ QVarLengthArray<char> stackbuf(len + 1);
+ char *d = stackbuf.data();
+ qRemoveWhitespace(method, d);
result.reserve(len);
@@ -987,8 +986,6 @@ QByteArray QMetaObject::normalizedSignature(const char *method)
result += *d++;
}
- if (buf != stackbuf)
- delete [] buf;
return result;
}
diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h
index e96b4d2..629fb3d 100644
--- a/src/corelib/thread/qbasicatomic.h
+++ b/src/corelib/thread/qbasicatomic.h
@@ -56,7 +56,13 @@ public:
#ifdef QT_ARCH_PARISC
int _q_lock[4];
#endif
+#if defined(QT_ARCH_WINDOWS) || defined(QT_ARCH_WINDOWSCE)
+ union { // needed for Q_BASIC_ATOMIC_INITIALIZER
+ volatile long _q_value;
+ };
+#else
volatile int _q_value;
+#endif
// Non-atomic API
inline bool operator==(int value) const
@@ -128,7 +134,14 @@ public:
#ifdef QT_ARCH_PARISC
int _q_lock[4];
#endif
+#if defined(QT_ARCH_WINDOWS) || defined(QT_ARCH_WINDOWSCE)
+ union {
+ T * volatile _q_value;
+ long volatile _q_value_integral;
+ };
+#else
T * volatile _q_value;
+#endif
// Non-atomic API
inline bool operator==(T *value) const
@@ -194,6 +207,8 @@ public:
#ifdef QT_ARCH_PARISC
# define Q_BASIC_ATOMIC_INITIALIZER(a) {{-1,-1,-1,-1},(a)}
+#elif defined(QT_ARCH_WINDOWS) || defined(QT_ARCH_WINDOWSCE)
+# define Q_BASIC_ATOMIC_INITIALIZER(a) { {(a)} }
#else
# define Q_BASIC_ATOMIC_INITIALIZER(a) { (a) }
#endif
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index ba8ae56..c2bdbee 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -52,6 +52,7 @@
#endif
#include <new>
+#include <string.h>
QT_BEGIN_HEADER
diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp
new file mode 100644
index 0000000..747ea5e
--- /dev/null
+++ b/src/corelib/tools/qmargins.cpp
@@ -0,0 +1,167 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmargins.h"
+#include "qdatastream.h"
+#include "qdebug.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QMargins
+ \ingroup painting
+
+ \brief The QMargins class defines the four margins of a rectangle.
+
+ QMargin defines a set of four margins; left, top, right and bottom,
+ that describe the size of the borders surrounding a rectangle.
+
+ The isNull() function returns true only if all margins are set to zero.
+
+ QMargin objects can be streamed as well as compared.
+
+*/
+
+
+/*****************************************************************************
+ QMargins member functions
+ *****************************************************************************/
+
+/*!
+ \fn QMargins::QMargins()
+
+ Constructs a margins object with all margins set to 0.
+
+ \sa isNull()
+*/
+
+/*!
+ \fn QMargins::QMargins(int left, int top, int right, int bottom)
+
+ Constructs margins with the given \a left, \a top, \a right, \a bottom
+
+ \sa setLeft(), setRight(), setTop(), setBottom()
+*/
+
+/*!
+ \fn bool QMargins::isNull() const
+
+ Returns true if all margins are is 0; otherwise returns
+ false.
+*/
+
+
+/*!
+ \fn int QMargins::left() const
+
+ Returns the left margin.
+
+ \sa setLeft()
+*/
+
+/*!
+ \fn int QMargins::top() const
+
+ Returns the top margin.
+
+ \sa setTop()
+*/
+
+/*!
+ \fn int QMargins::right() const
+
+ Returns the right margin.
+*/
+
+/*!
+ \fn int QMargins::bottom() const
+
+ Returns the bottom margin.
+*/
+
+
+/*!
+ \fn void QMargins::setLeft(int left)
+
+ Sets the left margin to \a left.
+*/
+
+/*!
+ \fn void QMargins::setTop(int Top)
+
+ Sets the Top margin to \a Top.
+*/
+
+/*!
+ \fn void QMargins::setRight(int right)
+
+ Sets the right margin to \a right.
+*/
+
+/*!
+ \fn void QMargins::setBottom(int bottom)
+
+ Sets the bottom margin to \a bottom.
+*/
+
+/*!
+ \fn bool operator==(const QMargins &m1, const QMargins &m2)
+ \relates QMargins
+
+ Returns true if \a m1 and \a m2 are equal; otherwise returns false.
+*/
+
+/*!
+ \fn bool operator!=(const QMargins &m1, const QMargins &m2)
+ \relates QMargins
+
+ Returns true if \a m1 and \a m2 are different; otherwise returns false.
+*/
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QMargins &m) {
+ dbg.nospace() << "QMargins(" << m.left() << ", "
+ << m.top() << ", " << m.right() << ", " << m.bottom() << ')';
+ return dbg.space();
+}
+#endif
+
+QT_END_NAMESPACE
diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h
new file mode 100644
index 0000000..549c634
--- /dev/null
+++ b/src/corelib/tools/qmargins.h
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMARGINS_H
+#define QMARGINS_H
+
+#include <QtCore/qnamespace.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Core)
+
+class QMargins
+{
+public:
+ QMargins();
+ QMargins(int left, int top, int right, int bottom);
+
+ bool isNull() const;
+
+ int left() const;
+ int top() const;
+ int right() const;
+ int bottom() const;
+
+ void setLeft(int left);
+ void setTop(int top);
+ void setRight(int right);
+ void setBottom(int bottom);
+
+private:
+ int m_left;
+ int m_top;
+ int m_right;
+ int m_bottom;
+
+ friend inline bool operator==(const QMargins &, const QMargins &);
+ friend inline bool operator!=(const QMargins &, const QMargins &);
+};
+
+Q_DECLARE_TYPEINFO(QMargins, Q_MOVABLE_TYPE);
+
+/*****************************************************************************
+ QMargins inline functions
+ *****************************************************************************/
+
+inline QMargins::QMargins()
+{ m_top = m_bottom = m_left = m_right = 0; }
+
+inline QMargins::QMargins(int left, int top, int right, int bottom)
+{ m_left = left; m_top = top; m_right = right; m_bottom = bottom; }
+
+inline bool QMargins::isNull() const
+{ return m_left==0 && m_top==0 && m_right==0 && m_bottom==0; }
+
+inline int QMargins::left() const
+{ return m_left; }
+
+inline int QMargins::top() const
+{ return m_top; }
+
+inline int QMargins::right() const
+{ return m_right; }
+
+inline int QMargins::bottom() const
+{ return m_bottom; }
+
+
+inline void QMargins::setLeft(int left)
+{ m_left = left; }
+
+inline void QMargins::setTop(int top)
+{ m_top = top; }
+
+inline void QMargins::setRight(int right)
+{ m_right = right; }
+
+inline void QMargins::setBottom(int bottom)
+{ m_bottom = bottom; }
+
+inline bool operator==(const QMargins &m1, const QMargins &m2)
+{
+ return
+ m1.m_left == m2.m_left &&
+ m1.m_top == m2.m_top &&
+ m1.m_right == m2.m_right &&
+ m1.m_bottom == m2.m_bottom;
+}
+
+inline bool operator!=(const QMargins &m1, const QMargins &m2)
+{
+ return
+ m1.m_left != m2.m_left ||
+ m1.m_top != m2.m_top ||
+ m1.m_right != m2.m_right ||
+ m1.m_bottom != m2.m_bottom;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+Q_CORE_EXPORT QDebug operator<<(QDebug, const QMargins &);
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QMARGINS_H
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index 464c60f..007b763 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -1,77 +1,79 @@
# Qt tools module
HEADERS += \
- tools/qalgorithms.h \
- tools/qbitarray.h \
- tools/qbytearray.h \
- tools/qbytearraymatcher.h \
+ tools/qalgorithms.h \
+ tools/qbitarray.h \
+ tools/qbytearray.h \
+ tools/qbytearraymatcher.h \
tools/qbytedata_p.h \
- tools/qcache.h \
- tools/qchar.h \
- tools/qcontainerfwd.h \
- tools/qcryptographichash.h \
- tools/qdatetime.h \
- tools/qdatetime_p.h \
+ tools/qcache.h \
+ tools/qchar.h \
+ tools/qcontainerfwd.h \
+ tools/qcryptographichash.h \
+ tools/qdatetime.h \
+ tools/qdatetime_p.h \
tools/qeasingcurve.h \
- tools/qhash.h \
+ tools/qhash.h \
tools/qline.h \
- tools/qlinkedlist.h \
- tools/qlist.h \
- tools/qlocale.h \
- tools/qlocale_p.h \
- tools/qlocale_data_p.h \
- tools/qmap.h \
+ tools/qlinkedlist.h \
+ tools/qlist.h \
+ tools/qlocale.h \
+ tools/qlocale_p.h \
+ tools/qlocale_data_p.h \
+ tools/qmap.h \
+ tools/qmargins.h \
tools/qcontiguouscache.h \
tools/qpodlist_p.h \
tools/qpoint.h \
- tools/qqueue.h \
+ tools/qqueue.h \
tools/qrect.h \
- tools/qregexp.h \
- tools/qringbuffer_p.h \
- tools/qshareddata.h \
+ tools/qregexp.h \
+ tools/qringbuffer_p.h \
+ tools/qshareddata.h \
tools/qsharedpointer.h \
tools/qsharedpointer_impl.h \
- tools/qset.h \
+ tools/qset.h \
tools/qsize.h \
- tools/qstack.h \
- tools/qstring.h \
- tools/qstringbuilder.h \
- tools/qstringlist.h \
- tools/qstringmatcher.h \
- tools/qtextboundaryfinder.h \
- tools/qtimeline.h \
- tools/qunicodetables_p.h \
- tools/qvarlengtharray.h \
- tools/qvector.h \
+ tools/qstack.h \
+ tools/qstring.h \
+ tools/qstringbuilder.h \
+ tools/qstringlist.h \
+ tools/qstringmatcher.h \
+ tools/qtextboundaryfinder.h \
+ tools/qtimeline.h \
+ tools/qunicodetables_p.h \
+ tools/qvarlengtharray.h \
+ tools/qvector.h \
tools/qscopedpointer.h
SOURCES += \
- tools/qbitarray.cpp \
- tools/qbytearray.cpp \
- tools/qbytearraymatcher.cpp \
- tools/qcryptographichash.cpp \
- tools/qdatetime.cpp \
+ tools/qbitarray.cpp \
+ tools/qbytearray.cpp \
+ tools/qbytearraymatcher.cpp \
+ tools/qcryptographichash.cpp \
+ tools/qdatetime.cpp \
tools/qeasingcurve.cpp \
- tools/qhash.cpp \
+ tools/qhash.cpp \
tools/qline.cpp \
- tools/qlinkedlist.cpp \
- tools/qlist.cpp \
- tools/qlocale.cpp \
+ tools/qlinkedlist.cpp \
+ tools/qlist.cpp \
+ tools/qlocale.cpp \
tools/qpoint.cpp \
- tools/qmap.cpp \
- tools/qcontiguouscache.cpp \
+ tools/qmap.cpp \
+ tools/qmargins.cpp \
+ tools/qcontiguouscache.cpp \
tools/qrect.cpp \
- tools/qregexp.cpp \
- tools/qshareddata.cpp \
- tools/qsharedpointer.cpp \
+ tools/qregexp.cpp \
+ tools/qshareddata.cpp \
+ tools/qsharedpointer.cpp \
tools/qsize.cpp \
- tools/qstring.cpp \
- tools/qstringbuilder.cpp \
- tools/qstringlist.cpp \
- tools/qtextboundaryfinder.cpp \
- tools/qtimeline.cpp \
- tools/qvector.cpp \
+ tools/qstring.cpp \
+ tools/qstringbuilder.cpp \
+ tools/qstringlist.cpp \
+ tools/qtextboundaryfinder.cpp \
+ tools/qtimeline.cpp \
+ tools/qvector.cpp \
tools/qvsnprintf.cpp
symbian:SOURCES+=tools/qlocale_symbian.cpp
@@ -81,17 +83,17 @@ contains(QT_CONFIG, zlib) {
wince*: DEFINES += NO_ERRNO_H
INCLUDEPATH += ../3rdparty/zlib
SOURCES+= \
- ../3rdparty/zlib/adler32.c \
- ../3rdparty/zlib/compress.c \
- ../3rdparty/zlib/crc32.c \
- ../3rdparty/zlib/deflate.c \
- ../3rdparty/zlib/gzio.c \
- ../3rdparty/zlib/inffast.c \
- ../3rdparty/zlib/inflate.c \
- ../3rdparty/zlib/inftrees.c \
- ../3rdparty/zlib/trees.c \
- ../3rdparty/zlib/uncompr.c \
- ../3rdparty/zlib/zutil.c
+ ../3rdparty/zlib/adler32.c \
+ ../3rdparty/zlib/compress.c \
+ ../3rdparty/zlib/crc32.c \
+ ../3rdparty/zlib/deflate.c \
+ ../3rdparty/zlib/gzio.c \
+ ../3rdparty/zlib/inffast.c \
+ ../3rdparty/zlib/inflate.c \
+ ../3rdparty/zlib/inftrees.c \
+ ../3rdparty/zlib/trees.c \
+ ../3rdparty/zlib/uncompr.c \
+ ../3rdparty/zlib/zutil.c
} else:!contains(QT_CONFIG, no-zlib) {
unix:LIBS_PRIVATE += -lz
# win32:LIBS += libz.lib
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp
index ccbf7fc..2be6a49 100644
--- a/src/gui/effects/qgraphicseffect.cpp
+++ b/src/gui/effects/qgraphicseffect.cpp
@@ -349,6 +349,22 @@ void QGraphicsEffect::setEnabled(bool enable)
*/
/*!
+ Schedules a redraw of the source. Call this function whenever the source
+ needs to be redrawn.
+
+ This convenience function is equivalent to calling
+ QGraphicsEffectSource::update().
+
+ \sa updateBoundingRect(), QGraphicsEffectSource::update()
+*/
+void QGraphicsEffect::update()
+{
+ Q_D(QGraphicsEffect);
+ if (d->source)
+ d->source->update();
+}
+
+/*!
Returns a pointer to the source, which provides extra context information
that can be useful for the effect.
@@ -366,6 +382,8 @@ QGraphicsEffectSource *QGraphicsEffect::source() const
function whenever you change any parameters that will cause the virtual
boundingRectFor() function to return a different value.
+ This function will call update() if this is necessary.
+
\sa boundingRectFor(), boundingRect()
*/
void QGraphicsEffect::updateBoundingRect()
@@ -523,6 +541,7 @@ void QGraphicsColorizeEffect::setColor(const QColor &color)
return;
d->filter->setColor(color);
+ update();
emit colorChanged(color);
}
@@ -610,6 +629,7 @@ void QGraphicsPixelizeEffect::setPixelSize(int size)
return;
d->pixelSize = size;
+ update();
emit pixelSizeChanged(size);
}
@@ -820,7 +840,7 @@ QGraphicsDropShadowEffect::~QGraphicsDropShadowEffect()
By default, the offset is 8 pixels towards the lower right.
- \sa blurRadius(), color()
+ \sa xOffset(), yOffset(), blurRadius(), color()
*/
QPointF QGraphicsDropShadowEffect::offset() const
{
@@ -840,6 +860,24 @@ void QGraphicsDropShadowEffect::setOffset(const QPointF &offset)
}
/*!
+ \property QGraphicsDropShadowEffect::xOffset
+ \brief the horizontal shadow offset in pixels.
+
+ By default, the horizontal shadow offset is 8 pixels.
+
+ \sa yOffset(), offset()
+*/
+
+/*!
+ \property QGraphicsDropShadowEffect::yOffset
+ \brief the vertical shadow offset in pixels.
+
+ By default, the vertical shadow offset is 8 pixels.
+
+ \sa xOffset(), offset()
+*/
+
+/*!
\fn void QGraphicsDropShadowEffect::offsetChanged(const QPointF &offset)
This signal is emitted whenever the effect's shadow offset changes.
@@ -903,6 +941,7 @@ void QGraphicsDropShadowEffect::setColor(const QColor &color)
return;
d->filter->setColor(color);
+ update();
emit colorChanged(color);
}
@@ -1012,6 +1051,7 @@ void QGraphicsOpacityEffect::setOpacity(qreal opacity)
d->isFullyOpaque = 0;
else
d->isFullyOpaque = qFuzzyIsNull(d->opacity - 1);
+ update();
emit opacityChanged(opacity);
}
@@ -1050,6 +1090,7 @@ void QGraphicsOpacityEffect::setOpacityMask(const QBrush &mask)
d->opacityMask = mask;
d->hasOpacityMask = (mask.style() != Qt::NoBrush);
+ update();
emit opacityMaskChanged(mask);
}
diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h
index 8e5384c..aee7834 100644
--- a/src/gui/effects/qgraphicseffect.h
+++ b/src/gui/effects/qgraphicseffect.h
@@ -118,7 +118,7 @@ public:
public Q_SLOTS:
void setEnabled(bool enable);
- // ### add update() slot
+ void update();
Q_SIGNALS:
void enabledChanged(bool enabled);
@@ -237,6 +237,8 @@ class Q_GUI_EXPORT QGraphicsDropShadowEffect: public QGraphicsEffect
{
Q_OBJECT
Q_PROPERTY(QPointF offset READ offset WRITE setOffset NOTIFY offsetChanged)
+ Q_PROPERTY(qreal xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged)
+ Q_PROPERTY(qreal yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged)
Q_PROPERTY(int blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
public:
@@ -245,15 +247,31 @@ public:
QRectF boundingRectFor(const QRectF &rect) const;
QPointF offset() const;
+
+ inline qreal xOffset() const
+ { return offset().x(); }
+
+ inline qreal yOffset() const
+ { return offset().y(); }
+
int blurRadius() const;
QColor color() const;
public Q_SLOTS:
void setOffset(const QPointF &ofs);
+
inline void setOffset(qreal dx, qreal dy)
{ setOffset(QPointF(dx, dy)); }
+
inline void setOffset(qreal d)
{ setOffset(QPointF(d, d)); }
+
+ inline void setXOffset(qreal dx)
+ { setOffset(QPointF(dx, yOffset())); }
+
+ inline void setYOffset(qreal dy)
+ { setOffset(QPointF(xOffset(), dy)); }
+
void setBlurRadius(int blurRadius);
void setColor(const QColor &color);
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 86c589d..822c208 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -1007,6 +1007,9 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent)
setEnabledHelper(parent->isEnabled(), /* explicit = */ false, /* update = */ !implicitUpdate);
}
+ // Auto-activate if visible and the parent is active.
+ if (q->isVisible() && parent->isActive())
+ q->setActive(true);
} else {
// Inherit ancestor flags from the new parent.
updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2));
@@ -1941,6 +1944,17 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
child->d_ptr->setVisibleHelper(newVisible, false, updateChildren);
}
+ // Update activation
+ if (scene && q->isPanel()) {
+ if (newVisible) {
+ if (parent && parent->isActive())
+ q->setActive(true);
+ } else {
+ if (q->isActive())
+ scene->setActivePanel(parent);
+ }
+ }
+
// Enable subfocus
if (newVisible && isWidget) {
QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(q_ptr);
@@ -2669,6 +2683,37 @@ bool QGraphicsItem::isActive() const
}
/*!
+ \since 4.6
+
+ If \a active is true, and the scene is active, this item's panel will be
+ activated. Otherwise, the panel is deactivated.
+
+ If the item is not part of an active scene, \a active will decide what
+ happens to the panel when the scene becomes active or the item is added to
+ the scene. If true, the item's panel will be activated when the item is
+ either added to the scene or the scene is activated. Otherwise, the item
+ will stay inactive independent of the scene's activated state.
+
+ \sa isPanel(), QGraphicsScene::setActivePanel(), QGraphicsScene::isActive()
+*/
+void QGraphicsItem::setActive(bool active)
+{
+ d_ptr->explicitActivate = 1;
+ d_ptr->wantsActive = active;
+ if (d_ptr->scene) {
+ if (active) {
+ // Activate this item.
+ d_ptr->scene->setActivePanel(this);
+ } else {
+ // Deactivate this item, and reactivate the last active item
+ // (if any).
+ QGraphicsItem *lastActive = d_ptr->scene->d_func()->lastActivePanel;
+ d_ptr->scene->setActivePanel(lastActive != this ? lastActive : 0);
+ }
+ }
+}
+
+/*!
Returns true if this item is active, and it or its \l{focusProxy()}{focus
proxy} has keyboard input focus; otherwise, returns false.
@@ -6099,8 +6144,10 @@ bool QGraphicsItem::sceneEvent(QEvent *event)
if (d_ptr->scene) {
for (int i = 0; i < d_ptr->children.size(); ++i) {
QGraphicsItem *child = d_ptr->children.at(i);
- if (!(child->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents))
- d_ptr->scene->sendEvent(child, event);
+ if (child->isVisible() && !child->isPanel()) {
+ if (!(child->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents))
+ d_ptr->scene->sendEvent(child, event);
+ }
}
}
break;
@@ -6945,7 +6992,7 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent
\property QGraphicsObject::id
\brief the id of of the item
- \sa QGraphicsItem::opacity(), QGraphicsItem::setOpacity()
+ \sa QObject::objectName(), QObject::setObjectName()
*/
/*!
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index 04fe0cb..df25e6a 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -235,6 +235,8 @@ public:
void setHandlesChildEvents(bool enabled);
bool isActive() const;
+ void setActive(bool active);
+
bool hasFocus() const;
void setFocus(Qt::FocusReason focusReason = Qt::OtherFocusReason);
void clearFocus();
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index 2bc876c..1090620 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -171,6 +171,8 @@ public:
notifyBoundingRectChanged(0),
notifyInvalidated(0),
mouseSetsFocus(1),
+ explicitActivate(0),
+ wantsActive(0),
globalStackingOrder(-1),
q_ptr(0)
{
@@ -461,7 +463,7 @@ public:
quint32 needSortChildren : 1;
quint32 allChildrenDirty : 1;
- // New 32 bits
+ // Packed 32 bits
quint32 fullUpdatePending : 1;
quint32 flags : 16;
quint32 dirtyChildrenBoundingRect : 1;
@@ -480,6 +482,10 @@ public:
quint32 notifyInvalidated : 1;
quint32 mouseSetsFocus : 1;
+ // New 32 bits
+ quint32 explicitActivate : 1;
+ quint32 wantsActive : 1;
+
// Optional stacking order
int globalStackingOrder;
QGraphicsItem *q_ptr;
diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp
index 447fc50..c710c55 100644
--- a/src/gui/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/gui/graphicsview/qgraphicsproxywidget.cpp
@@ -390,7 +390,7 @@ QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next)
if (child->isEnabled()
&& child->isVisibleTo(widget)
&& (child->focusPolicy() & Qt::TabFocus)) {
- return child;
+ return child;
}
child = next ? child->d_func()->focus_next : child->d_func()->focus_prev;
} while (child != oldChild && !(next && child == widget) && !(!next && child == widget->d_func()->focus_prev));
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index ac30668..2ac1dca 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -291,6 +291,7 @@ QGraphicsScenePrivate::QGraphicsScenePrivate()
activePanel(0),
lastActivePanel(0),
activationRefCount(0),
+ childExplicitActivation(0),
lastMouseGrabberItem(0),
lastMouseGrabberItemHasImplicitMouseGrab(false),
dragDropItem(0),
@@ -571,6 +572,66 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
/*!
\internal
*/
+void QGraphicsScenePrivate::setActivePanelHelper(QGraphicsItem *item, bool duringActivationEvent)
+{
+ Q_Q(QGraphicsScene);
+ if (item && item->scene() != q) {
+ qWarning("QGraphicsScene::setActivePanel: item %p must be part of this scene",
+ item);
+ return;
+ }
+
+ // Find the item's panel.
+ QGraphicsItem *panel = item ? item->panel() : 0;
+ lastActivePanel = panel ? activePanel : 0;
+ if (panel == activePanel || (!q->isActive() && !duringActivationEvent))
+ return;
+
+ // Deactivate the last active panel.
+ if (activePanel) {
+ if (QGraphicsItem *fi = activePanel->focusItem()) {
+ // Remove focus from the current focus item.
+ if (fi == q->focusItem())
+ q->setFocusItem(0, Qt::ActiveWindowFocusReason);
+ }
+
+ QEvent event(QEvent::WindowDeactivate);
+ q->sendEvent(activePanel, &event);
+ } else if (panel && !duringActivationEvent) {
+ // Deactivate the scene if changing activation to a panel.
+ QEvent event(QEvent::WindowDeactivate);
+ foreach (QGraphicsItem *item, q->items()) {
+ if (item->isVisible() && !item->isPanel() && !item->parentItem())
+ q->sendEvent(item, &event);
+ }
+ }
+
+ // Update activate state.
+ activePanel = panel;
+ QEvent event(QEvent::ActivationChange);
+ QApplication::sendEvent(q, &event);
+
+ // Activate
+ if (panel) {
+ QEvent event(QEvent::WindowActivate);
+ q->sendEvent(panel, &event);
+
+ // Set focus on the panel's focus item.
+ if (QGraphicsItem *focusItem = panel->focusItem())
+ focusItem->setFocus(Qt::ActiveWindowFocusReason);
+ } else if (q->isActive()) {
+ // Activate the scene
+ QEvent event(QEvent::WindowActivate);
+ foreach (QGraphicsItem *item, q->items()) {
+ if (item->isVisible() && !item->isPanel() && !item->parentItem())
+ q->sendEvent(item, &event);
+ }
+ }
+}
+
+/*!
+ \internal
+*/
void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
Qt::FocusReason focusReason)
{
@@ -2351,9 +2412,29 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
// Deliver post-change notification
item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);
- // Auto-activate the first inactive panel if the scene is active.
- if (isActive() && !d->activePanel && item->isPanel())
- setActivePanel(item);
+ // Update explicit activation
+ bool autoActivate = true;
+ if (!d->childExplicitActivation && item->d_ptr->explicitActivate)
+ d->childExplicitActivation = item->d_ptr->wantsActive ? 1 : 2;
+ if (d->childExplicitActivation && item->isPanel()) {
+ if (d->childExplicitActivation == 1)
+ setActivePanel(item);
+ else
+ autoActivate = false;
+ d->childExplicitActivation = 0;
+ } else if (!item->d_ptr->parent) {
+ d->childExplicitActivation = 0;
+ }
+
+ // Auto-activate this item's panel if nothing else has been activated
+ if (autoActivate) {
+ if (!d->lastActivePanel && !d->activePanel && item->isPanel()) {
+ if (isActive())
+ setActivePanel(item);
+ else
+ d->lastActivePanel = item;
+ }
+ }
// Ensure that newly added items that have subfocus set, gain
// focus automatically if there isn't a focus item already.
@@ -3129,11 +3210,11 @@ bool QGraphicsScene::event(QEvent *event)
if (!d->activationRefCount++) {
if (d->lastActivePanel) {
// Activate the last panel.
- setActivePanel(d->lastActivePanel);
+ d->setActivePanelHelper(d->lastActivePanel, true);
} else if (d->tabFocusFirst && d->tabFocusFirst->isPanel()) {
// Activate the panel of the first item in the tab focus
// chain.
- setActivePanel(d->tabFocusFirst);
+ d->setActivePanelHelper(d->tabFocusFirst, true);
} else {
// Activate all toplevel items.
QEvent event(QEvent::WindowActivate);
@@ -3150,7 +3231,7 @@ bool QGraphicsScene::event(QEvent *event)
// Deactivate the active panel (but keep it so we can
// reactivate it later).
QGraphicsItem *lastActivePanel = d->activePanel;
- setActivePanel(0);
+ d->setActivePanelHelper(0, true);
d->lastActivePanel = lastActivePanel;
} else {
// Activate all toplevel items.
@@ -5095,63 +5176,15 @@ QGraphicsItem *QGraphicsScene::activePanel() const
can also pass 0 for \a item, in which case QGraphicsScene will
deactivate any currently active panel.
+ If the scene is currently inactive, \a item remains inactive until the
+ scene becomes active (or, ir \a item is 0, no item will be activated).
+
\sa activePanel(), isActive(), QGraphicsItem::isActive()
*/
void QGraphicsScene::setActivePanel(QGraphicsItem *item)
{
Q_D(QGraphicsScene);
- if (item && item->scene() != this) {
- qWarning("QGraphicsScene::setActivePanel: item %p must be part of this scene",
- item);
- return;
- }
-
- // Find the item's panel.
- QGraphicsItem *panel = item ? item->panel() : 0;
- d->lastActivePanel = panel ? d->activePanel : 0;
- if (panel == d->activePanel)
- return;
-
- // Deactivate the last active panel.
- if (d->activePanel) {
- if (QGraphicsItem *fi = d->activePanel->focusItem()) {
- // Remove focus from the current focus item.
- if (fi == focusItem())
- setFocusItem(0, Qt::ActiveWindowFocusReason);
- }
-
- QEvent event(QEvent::WindowDeactivate);
- sendEvent(d->activePanel, &event);
- } else if (panel) {
- // Deactivate the scene if changing activation to a panel.
- QEvent event(QEvent::WindowDeactivate);
- foreach (QGraphicsItem *item, items()) {
- if (item->isVisible() && !item->isPanel() && !item->parentItem())
- sendEvent(item, &event);
- }
- }
-
- // Update activate state.
- d->activePanel = panel;
- QEvent event(QEvent::ActivationChange);
- QApplication::sendEvent(this, &event);
-
- // Activate
- if (panel) {
- QEvent event(QEvent::WindowActivate);
- sendEvent(panel, &event);
-
- // Set focus on the panel's focus item.
- if (QGraphicsItem *focusItem = panel->focusItem())
- focusItem->setFocus(Qt::ActiveWindowFocusReason);
- } else if (isActive()) {
- // Activate the scene
- QEvent event(QEvent::WindowActivate);
- foreach (QGraphicsItem *item, items()) {
- if (item->isVisible() && !item->isPanel() && !item->parentItem())
- sendEvent(item, &event);
- }
- }
+ d->setActivePanelHelper(item, false);
}
/*!
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h
index c1b78ff..1f66eb4 100644
--- a/src/gui/graphicsview/qgraphicsscene_p.h
+++ b/src/gui/graphicsview/qgraphicsscene_p.h
@@ -132,6 +132,8 @@ public:
QGraphicsItem *activePanel;
QGraphicsItem *lastActivePanel;
int activationRefCount;
+ int childExplicitActivation;
+ void setActivePanelHelper(QGraphicsItem *item, bool duringActivationEvent);
void setFocusItemHelper(QGraphicsItem *item, Qt::FocusReason focusReason);
QList<QGraphicsWidget *> popupWidgets;
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 9972223..afabf49 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -1665,11 +1665,7 @@ void QGraphicsWidget::setWindowFlags(Qt::WindowFlags wFlags)
*/
bool QGraphicsWidget::isActiveWindow() const
{
- Q_D(const QGraphicsWidget);
- if (!d->scene)
- return false;
- const QGraphicsWidget *w = window();
- return (!w && d->scene->isActive()) || (w && d->scene->activeWindow() == w);
+ return isActive();
}
/*!
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 2b82f49..89af452 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -2892,6 +2892,12 @@ static void convert_Indexed8_to_X32(QImageData *dest, const QImageData *src, Qt:
Q_ASSERT(src->height == dest->height);
QVector<QRgb> colorTable = fix_color_table(src->colortable, dest->format);
+ if (colorTable.size() == 0) {
+ colorTable.resize(256);
+ for (int i=0; i<256; ++i)
+ colorTable[i] = qRgb(i, i, i);
+
+ }
int w = src->width;
const uchar *src_data = src->data;
diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp
index 3f3a55c..c4733cf 100644
--- a/src/gui/image/qpnghandler.cpp
+++ b/src/gui/image/qpnghandler.cpp
@@ -205,7 +205,11 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre
image.setColor(i, qRgba(c,c,c,0xff));
}
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
+#if PNG_LIBPNG_VER_MAJOR < 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR < 4)
const int g = info_ptr->trans_values.gray;
+#else
+ const int g = info_ptr->trans_color.gray;
+#endif
if (g < ncols) {
image.setColor(g, 0);
}
@@ -234,7 +238,11 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, float scre
info_ptr->palette[i].red,
info_ptr->palette[i].green,
info_ptr->palette[i].blue,
+#if PNG_LIBPNG_VER_MAJOR < 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR < 4)
info_ptr->trans[i]
+#else
+ info_ptr->trans_alpha[i]
+#endif
)
);
i++;
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index a1c3e4e..4dbd6dc 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -1047,7 +1047,9 @@ int QHeaderView::visualIndex(int logicalIndex) const
/*!
Returns the logicalIndex for the section at the given \a visualIndex
- position, or -1 otherwise.
+ position, or -1 if visualIndex < 0 or visualIndex >= QHeaderView::count().
+
+ Note that the visualIndex is not affected by hidden sections.
\sa visualIndex(), sectionPosition()
*/
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 69dba40..0056b9e 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -4510,7 +4510,9 @@ void fetchWacomToolId(int &deviceType, qint64 &serialId)
struct qt_tablet_motion_data
{
- Time timestamp;
+ bool filterByWidget;
+ const QWidget *widget;
+ const QWidget *etWidget;
int tabletMotionType;
bool error; // found a reason to stop searching
};
@@ -4533,15 +4535,20 @@ static Bool qt_tabletMotion_scanner(Display *, XEvent *event, XPointer arg)
qt_tablet_motion_data *data = (qt_tablet_motion_data *) arg;
if (data->error)
return false;
-
if (event->type == data->tabletMotionType) {
- if (data->timestamp > 0) {
- if ((reinterpret_cast<const XDeviceMotionEvent*>(event))->time > data->timestamp) {
- data->error = true;
- return false;
+ const XDeviceMotionEvent *const motion = reinterpret_cast<const XDeviceMotionEvent*>(event);
+ if (data->filterByWidget) {
+ const QPoint curr(motion->x, motion->y);
+ const QWidget *w = data->etWidget;
+ const QWidget *const child = w->childAt(curr);
+ if (child) {
+ w = child;
}
+ if (w == data->widget)
+ return true;
+ } else {
+ return true;
}
- return true;
}
data->error = event->type != MotionNotify; // we stop compression when another event gets in between.
@@ -4574,57 +4581,17 @@ bool QETWidget::translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet
qreal rotation = 0;
int deviceType = QTabletEvent::NoDevice;
int pointerType = QTabletEvent::UnknownPointer;
- XEvent mouseMotionEvent;
- XEvent dummy;
const XDeviceMotionEvent *motion = 0;
XDeviceButtonEvent *button = 0;
const XProximityNotifyEvent *proximity = 0;
QEvent::Type t;
Qt::KeyboardModifiers modifiers = 0;
- bool reinsertMouseEvent = false;
- XEvent mouseMotionEventSave;
#if !defined (Q_OS_IRIX)
XID device_id;
#endif
if (ev->type == tablet->xinput_motion) {
motion = reinterpret_cast<const XDeviceMotionEvent*>(ev);
-
- // Do event compression. Skip over tablet+mouse move events if there are newer ones.
- qt_tablet_motion_data tabletMotionData;
- tabletMotionData.tabletMotionType = tablet->xinput_motion;
- while (true) {
- // Find first mouse event since we expect them in pairs inside Qt
- tabletMotionData.error =false;
- tabletMotionData.timestamp = 0;
- if (XCheckIfEvent(X11->display, &mouseMotionEvent, &qt_mouseMotion_scanner, (XPointer) &tabletMotionData)) {
- mouseMotionEventSave = mouseMotionEvent;
- reinsertMouseEvent = true;
- } else {
- break;
- }
-
- // Now discard any duplicate tablet events.
- tabletMotionData.error = false;
- tabletMotionData.timestamp = mouseMotionEvent.xmotion.time;
- while (XCheckIfEvent(X11->display, &dummy, &qt_tabletMotion_scanner, (XPointer) &tabletMotionData)) {
- motion = reinterpret_cast<const XDeviceMotionEvent*>(&dummy);
- }
-
- // now check if there are more recent tablet motion events since we'll compress the current one with
- // newer ones in that case
- tabletMotionData.error = false;
- tabletMotionData.timestamp = 0;
- if (! XCheckIfEvent(X11->display, &dummy, &qt_tabletMotion_scanner, (XPointer) &tabletMotionData)) {
- break; // done with compression
- }
- motion = reinterpret_cast<const XDeviceMotionEvent*>(&dummy);
- }
-
- if (reinsertMouseEvent) {
- XPutBackEvent(X11->display, &mouseMotionEventSave);
- }
-
t = QEvent::TabletMove;
global = QPoint(motion->x_root, motion->y_root);
curr = QPoint(motion->x, motion->y);
@@ -4777,11 +4744,14 @@ bool QETWidget::translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet
}
#endif
- QWidget *child = w->childAt(curr);
- if (child) {
- w = child;
- curr = w->mapFromGlobal(global);
+ if (tablet->widgetToGetPress) {
+ w = tablet->widgetToGetPress;
+ } else {
+ QWidget *child = w->childAt(curr);
+ if (child)
+ w = child;
}
+ curr = w->mapFromGlobal(global);
if (t == QEvent::TabletPress) {
tablet->widgetToGetPress = w;
@@ -4795,10 +4765,45 @@ bool QETWidget::translateXinputEvent(const XEvent *ev, QTabletDeviceData *tablet
deviceType, pointerType,
qreal(pressure / qreal(tablet->maxPressure - tablet->minPressure)),
xTilt, yTilt, tangentialPressure, rotation, z, modifiers, uid);
- if (proximity)
+ if (proximity) {
QApplication::sendSpontaneousEvent(qApp, &e);
- else
+ } else {
QApplication::sendSpontaneousEvent(w, &e);
+ const bool accepted = e.isAccepted();
+ if (!accepted && ev->type == tablet->xinput_motion) {
+ // If the widget does not accept tablet events, we drop the next ones from the event queue
+ // for this widget so it is not overloaded with the numerous tablet events.
+ qt_tablet_motion_data tabletMotionData;
+ tabletMotionData.tabletMotionType = tablet->xinput_motion;
+ tabletMotionData.widget = w;
+ tabletMotionData.etWidget = this;
+ // if nothing is pressed, the events are filtered by position
+ tabletMotionData.filterByWidget = (tablet->widgetToGetPress == 0);
+
+ bool reinsertMouseEvent = false;
+ XEvent mouseMotionEvent;
+ while (true) {
+ // Find first mouse event since we expect them in pairs inside Qt
+ tabletMotionData.error =false;
+ if (XCheckIfEvent(X11->display, &mouseMotionEvent, &qt_mouseMotion_scanner, (XPointer) &tabletMotionData)) {
+ reinsertMouseEvent = true;
+ } else {
+ break;
+ }
+
+ // Now discard any duplicate tablet events.
+ tabletMotionData.error = false;
+ XEvent dummy;
+ while (XCheckIfEvent(X11->display, &dummy, &qt_tabletMotion_scanner, (XPointer) &tabletMotionData)) {
+ // just discard the event
+ }
+ }
+
+ if (reinsertMouseEvent) {
+ XPutBackEvent(X11->display, &mouseMotionEvent);
+ }
+ }
+ }
return true;
}
#endif
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index ab809df..863c43e 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -919,7 +919,7 @@ void QWidget::setAutoFillBackground(bool enabled)
any amount of widgets there might be physical restrictions to amount of
softkeys that can be used by the device.
- \o Series60: For series60 menu button is automatically mapped to left
+ \e Series60: For series60 menu button is automatically mapped to left
soft key if there is QMainWindow with QMenuBar in widgets parent hierarchy.
\sa softKeys()
@@ -5962,6 +5962,8 @@ bool QWidget::hasFocus() const
isActiveWindow() active window\endlink. The \a reason argument will
be passed into any focus event sent from this function, it is used
to give an explanation of what caused the widget to get focus.
+ If the window is not active, the widget will be given the focus when
+ the window becomes active.
First, a focus out event is sent to the focus widget (if any) to
tell it that it is about to lose the focus. Then a focus in event
@@ -6748,7 +6750,27 @@ void QWidget::setContentsMargins(int left, int top, int right, int bottom)
QApplication::sendEvent(this, &e);
}
-/*! Returns the widget's contents margins for \a left, \a top, \a
+/*!
+ \overload
+ \since 4.6
+
+ Sets the margins around the contents of the widget to have the
+ sizes determined by \a margins. The margins are
+ used by the layout system, and may be used by subclasses to
+ specify the area to draw in (e.g. excluding the frame).
+
+ Changing the margins will trigger a resizeEvent().
+
+ \sa contentsRect(), getContentsMargins()
+*/
+void QWidget::setContentsMargins(const QMargins &margins)
+{
+ setContentsMargins(margins.left(), margins.top(),
+ margins.right(), margins.bottom());
+}
+
+/*!
+ Returns the widget's contents margins for \a left, \a top, \a
right, and \a bottom.
\sa setContentsMargins(), contentsRect()
@@ -6767,6 +6789,20 @@ void QWidget::getContentsMargins(int *left, int *top, int *right, int *bottom) c
}
/*!
+ \since 4.6
+
+ Returns the widget's contents margins.
+
+ \sa getContentsMargins(), setContentsMargins(), contentsRect()
+ */
+QMargins QWidget::contentsMargins() const
+{
+ Q_D(const QWidget);
+ return QMargins(d->leftmargin, d->topmargin, d->rightmargin, d->bottommargin);
+}
+
+
+/*!
Returns the area inside the widget's margins.
\sa setContentsMargins(), getContentsMargins()
diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h
index 38650f0..f398dbd 100644
--- a/src/gui/kernel/qwidget.h
+++ b/src/gui/kernel/qwidget.h
@@ -44,6 +44,7 @@
#include <QtGui/qwindowdefs.h>
#include <QtCore/qobject.h>
+#include <QtCore/qmargins.h>
#include <QtGui/qpaintdevice.h>
#include <QtGui/qpalette.h>
#include <QtGui/qfont.h>
@@ -527,7 +528,10 @@ public:
QRegion visibleRegion() const;
void setContentsMargins(int left, int top, int right, int bottom);
+ void setContentsMargins(const QMargins &margins);
void getContentsMargins(int *left, int *top, int *right, int *bottom) const;
+ QMargins contentsMargins() const;
+
QRect contentsRect() const;
public:
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 422d5a3..173c870 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -298,7 +298,7 @@ QT_BEGIN_NAMESPACE
/*!
\enum QColor::Spec
- The type of color specified, either RGB, HSV or CMYK.
+ The type of color specified, either RGB, HSV, CMYK or HSL.
\value Rgb
\value Hsv
diff --git a/src/gui/painting/qdrawutil.cpp b/src/gui/painting/qdrawutil.cpp
index 59a5063..2220206 100644
--- a/src/gui/painting/qdrawutil.cpp
+++ b/src/gui/painting/qdrawutil.cpp
@@ -1038,27 +1038,6 @@ void qDrawItem(QPainter *p, Qt::GUIStyle gs,
#endif
/*!
- \class QMargins
- \since 4.6
-
- Holds the borders used to split a pixmap into nine segments in order to
- draw it, similar to \l{http://www.w3.org/TR/css3-background/}
- {CSS3 border-images}.
-
- \sa Qt::TileRule, QTileRules
-*/
-
-/*! \fn QMargins::QMargins(int margin)
- Constructs a QMargins with the top, left, bottom, and
- right margins set to \a margin.
-*/
-
-/*! \fn QMargins::QMargins(int topMargin, int leftMargin, int bottomMargin, int rightMargin)
- Constructs a QMargins with the given \a topMargin, \a leftMargin,
- \a bottomMargin, and \a rightMargin.
- */
-
-/*!
\class QTileRules
\since 4.6
@@ -1195,79 +1174,79 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin
// source center
const int sourceTop = sourceRect.top();
const int sourceLeft = sourceRect.left();
- const int sourceCenterTop = sourceTop + sourceMargins.top;
- const int sourceCenterLeft = sourceLeft + sourceMargins.left;
- const int sourceCenterBottom = sourceRect.bottom() - sourceMargins.bottom + 1;
- const int sourceCenterRight = sourceRect.right() - sourceMargins.right + 1;
- const int sourceCenterWidth = sourceCenterRight - sourceMargins.left;
- const int sourceCenterHeight = sourceCenterBottom - sourceMargins.top;
+ const int sourceCenterTop = sourceTop + sourceMargins.top();
+ const int sourceCenterLeft = sourceLeft + sourceMargins.left();
+ const int sourceCenterBottom = sourceRect.bottom() - sourceMargins.bottom() + 1;
+ const int sourceCenterRight = sourceRect.right() - sourceMargins.right() + 1;
+ const int sourceCenterWidth = sourceCenterRight - sourceMargins.left();
+ const int sourceCenterHeight = sourceCenterBottom - sourceMargins.top();
// target center
const int targetTop = targetRect.top();
const int targetLeft = targetRect.left();
- const int targetCenterTop = targetTop + targetMargins.top;
- const int targetCenterLeft = targetLeft + targetMargins.left;
- const int targetCenterBottom = targetRect.bottom() - targetMargins.bottom + 1;
- const int targetCenterRight = targetRect.right() - targetMargins.right + 1;
+ const int targetCenterTop = targetTop + targetMargins.top();
+ const int targetCenterLeft = targetLeft + targetMargins.left();
+ const int targetCenterBottom = targetRect.bottom() - targetMargins.bottom() + 1;
+ const int targetCenterRight = targetRect.right() - targetMargins.right() + 1;
const int targetCenterWidth = targetCenterRight - targetCenterLeft;
const int targetCenterHeight = targetCenterBottom - targetCenterTop;
// corners
- if (targetMargins.top > 0 && targetMargins.left > 0 && sourceMargins.top > 0 && sourceMargins.left > 0) { // top left
- const QRect targetTopLeftRect(targetLeft, targetTop, targetMargins.left, targetMargins.top);
- const QRect sourceTopLeftRect(sourceLeft, sourceTop, sourceMargins.left, sourceMargins.top);
+ if (targetMargins.top() > 0 && targetMargins.left() > 0 && sourceMargins.top() > 0 && sourceMargins.left() > 0) { // top left
+ const QRect targetTopLeftRect(targetLeft, targetTop, targetMargins.left(), targetMargins.top());
+ const QRect sourceTopLeftRect(sourceLeft, sourceTop, sourceMargins.left(), sourceMargins.top());
qDrawPixmap(painter, targetTopLeftRect, pixmap, sourceTopLeftRect);
}
- if (targetMargins.top > 0 && targetMargins.right > 0 && sourceMargins.top > 0 && sourceMargins.right > 0) { // top right
- const QRect targetTopRightRect(targetCenterRight, targetTop, targetMargins.right, targetMargins.top);
- const QRect sourceTopRightRect(sourceCenterRight, sourceTop, sourceMargins.right, sourceMargins.top);
+ if (targetMargins.top() > 0 && targetMargins.right() > 0 && sourceMargins.top() > 0 && sourceMargins.right() > 0) { // top right
+ const QRect targetTopRightRect(targetCenterRight, targetTop, targetMargins.right(), targetMargins.top());
+ const QRect sourceTopRightRect(sourceCenterRight, sourceTop, sourceMargins.right(), sourceMargins.top());
qDrawPixmap(painter, targetTopRightRect, pixmap, sourceTopRightRect);
}
- if (targetMargins.bottom > 0 && targetMargins.left > 0 && sourceMargins.bottom > 0 && sourceMargins.left > 0) { // bottom left
- const QRect targetBottomLeftRect(targetLeft, targetCenterBottom, targetMargins.left, targetMargins.bottom);
- const QRect sourceBottomLeftRect(sourceLeft, sourceCenterBottom, sourceMargins.left, sourceMargins.bottom);
+ if (targetMargins.bottom() > 0 && targetMargins.left() > 0 && sourceMargins.bottom() > 0 && sourceMargins.left() > 0) { // bottom left
+ const QRect targetBottomLeftRect(targetLeft, targetCenterBottom, targetMargins.left(), targetMargins.bottom());
+ const QRect sourceBottomLeftRect(sourceLeft, sourceCenterBottom, sourceMargins.left(), sourceMargins.bottom());
qDrawPixmap(painter, targetBottomLeftRect, pixmap, sourceBottomLeftRect);
}
- if (targetMargins.bottom > 0 && targetMargins.right > 0 && sourceMargins.bottom > 0 && sourceMargins.right > 0) { // bottom right
- const QRect targetBottomRightRect(targetCenterRight, targetCenterBottom, targetMargins.right, targetMargins.bottom);
- const QRect sourceBottomRightRect(sourceCenterRight, sourceCenterBottom, sourceMargins.right, sourceMargins.bottom);
+ if (targetMargins.bottom() > 0 && targetMargins.right() > 0 && sourceMargins.bottom() > 0 && sourceMargins.right() > 0) { // bottom right
+ const QRect targetBottomRightRect(targetCenterRight, targetCenterBottom, targetMargins.right(), targetMargins.bottom());
+ const QRect sourceBottomRightRect(sourceCenterRight, sourceCenterBottom, sourceMargins.right(), sourceMargins.bottom());
qDrawPixmap(painter, targetBottomRightRect, pixmap, sourceBottomRightRect);
}
// horizontal edges
switch (rules.horizontal) {
case Qt::Stretch:
- if (targetMargins.top > 0 && sourceMargins.top > 0) { // top
- const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top);
- const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top);
+ if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top
+ const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top());
+ const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top());
qDrawPixmap(painter, targetTopRect, pixmap, sourceTopRect);
}
- if (targetMargins.bottom > 0 && sourceMargins.bottom > 0) { // bottom
- const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom);
- const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom);
+ if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom
+ const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom());
+ const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom());
qDrawPixmap(painter, targetBottomRect, pixmap, sourceBottomRect);
}
break;
case Qt::Repeat:
- if (targetMargins.top > 0 && sourceMargins.top > 0) { // top
- const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top);
- const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top);
+ if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top
+ const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top());
+ const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top());
qDrawHorizontallyRepeatedPixmap(painter, targetTopRect, pixmap, sourceTopRect);
}
- if (targetMargins.bottom > 0 && sourceMargins.bottom > 0) { // bottom
- const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom);
- const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom);
+ if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom
+ const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom());
+ const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom());
qDrawHorizontallyRepeatedPixmap(painter, targetBottomRect, pixmap, sourceBottomRect);
}
break;
case Qt::Round:
- if (targetMargins.top > 0 && sourceMargins.top > 0) { // top
- const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top);
- const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top);
+ if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top
+ const QRect targetTopRect(targetCenterLeft, targetTop, targetCenterWidth, targetMargins.top());
+ const QRect sourceTopRect(sourceCenterLeft, sourceTop, sourceCenterWidth, sourceMargins.top());
qDrawHorizontallyRoundedPixmap(painter, targetTopRect, pixmap, sourceTopRect);
}
- if (targetMargins.bottom > 0 && sourceMargins.bottom > 0) { // bottom
- const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom);
- const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom);
+ if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom
+ const QRect targetBottomRect(targetCenterLeft, targetCenterBottom, targetCenterWidth, targetMargins.bottom());
+ const QRect sourceBottomRect(sourceCenterLeft, sourceCenterBottom, sourceCenterWidth, sourceMargins.bottom());
qDrawHorizontallyRoundedPixmap(painter, targetBottomRect, pixmap, sourceBottomRect);
}
break;
@@ -1276,38 +1255,38 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin
// vertical edges
switch (rules.vertical) {
case Qt::Stretch:
- if (targetMargins.left > 0 && sourceMargins.left > 0) { // left
- const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left, targetCenterHeight);
- const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left, sourceCenterHeight);
+ if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left
+ const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left(), targetCenterHeight);
+ const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left(), sourceCenterHeight);
qDrawPixmap(painter, targetLeftRect, pixmap, sourceLeftRect);
}
- if (targetMargins.right > 0 && sourceMargins.right > 0) { // right
- const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right, targetCenterHeight);
- const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right, sourceCenterHeight);
+ if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right
+ const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right(), targetCenterHeight);
+ const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right(), sourceCenterHeight);
qDrawPixmap(painter, targetRightRect, pixmap, sourceRightRect);
}
break;
case Qt::Repeat:
- if (targetMargins.left > 0 && sourceMargins.left > 0) { // left
- const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left, targetCenterHeight);
- const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left, sourceCenterHeight);
+ if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left
+ const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left(), targetCenterHeight);
+ const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left(), sourceCenterHeight);
qDrawVerticallyRepeatedPixmap(painter, targetLeftRect, pixmap, sourceLeftRect);
}
- if (targetMargins.right > 0 && sourceMargins.right > 0) { // right
- const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right, targetCenterHeight);
- const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right, sourceCenterHeight);
+ if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right
+ const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right(), targetCenterHeight);
+ const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right(), sourceCenterHeight);
qDrawVerticallyRepeatedPixmap(painter, targetRightRect, pixmap, sourceRightRect);
}
break;
case Qt::Round:
- if (targetMargins.left > 0 && sourceMargins.left > 0) { // left
- const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left, targetCenterHeight);
- const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left, sourceCenterHeight);
+ if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left
+ const QRect targetLeftRect(targetLeft, targetCenterTop, targetMargins.left(), targetCenterHeight);
+ const QRect sourceLeftRect(sourceLeft, sourceCenterTop, sourceMargins.left(), sourceCenterHeight);
qDrawVerticallyRoundedPixmap(painter, targetLeftRect, pixmap, sourceLeftRect);
}
- if (targetMargins.right > 0 && sourceMargins.right > 0) { // right
- const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right, targetCenterHeight);
- const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right, sourceCenterHeight);
+ if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right
+ const QRect targetRightRect(targetCenterRight, targetCenterTop, targetMargins.right(), targetCenterHeight);
+ const QRect sourceRightRect(sourceCenterRight, sourceCenterTop, sourceMargins.right(), sourceCenterHeight);
qDrawVerticallyRoundedPixmap(painter, targetRightRect, pixmap, sourceRightRect);
}
break;
diff --git a/src/gui/painting/qdrawutil.h b/src/gui/painting/qdrawutil.h
index 4135c19..38ef30e 100644
--- a/src/gui/painting/qdrawutil.h
+++ b/src/gui/painting/qdrawutil.h
@@ -44,8 +44,8 @@
#include <QtCore/qnamespace.h>
#include <QtCore/qstring.h> // char*->QString conversion
+#include <QtCore/qmargins.h>
#include <QtGui/qpixmap.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -133,24 +133,6 @@ Q_GUI_EXPORT QT3_SUPPORT void qDrawArrow(QPainter *p, Qt::ArrowType type, Qt::GU
const QPalette &pal, bool enabled);
#endif
-struct QMargins
-{
- inline QMargins(int margin = 0)
- : top(margin),
- left(margin),
- bottom(margin),
- right(margin) {}
- inline QMargins(int topMargin, int leftMargin, int bottomMargin, int rightMargin)
- : top(topMargin),
- left(leftMargin),
- bottom(bottomMargin),
- right(rightMargin) {}
- int top;
- int left;
- int bottom;
- int right;
-};
-
struct QTileRules
{
inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule = Qt::Stretch)
diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp
index 6d957ca..20f1d26 100644
--- a/src/gui/styles/qcleanlooksstyle.cpp
+++ b/src/gui/styles/qcleanlooksstyle.cpp
@@ -561,14 +561,20 @@ static void qt_cleanlooks_draw_mdibutton(QPainter *painter, const QStyleOptionTi
QColor mdiButtonBorderColor(active ? option->palette.highlight().color().darker(180): dark.darker(110));
painter->setPen(QPen(mdiButtonBorderColor, 1));
- painter->drawLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top());
- painter->drawLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom());
- painter->drawLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2);
- painter->drawLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2);
- painter->drawPoint(tmp.left() + 1, tmp.top() + 1);
- painter->drawPoint(tmp.right() - 1, tmp.top() + 1);
- painter->drawPoint(tmp.left() + 1, tmp.bottom() - 1);
- painter->drawPoint(tmp.right() - 1, tmp.bottom() - 1);
+ const QLine lines[4] = {
+ QLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()),
+ QLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()),
+ QLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2),
+ QLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2)
+ };
+ painter->drawLines(lines, 4);
+ const QPoint points[4] = {
+ QPoint(tmp.left() + 1, tmp.top() + 1),
+ QPoint(tmp.right() - 1, tmp.top() + 1),
+ QPoint(tmp.left() + 1, tmp.bottom() - 1),
+ QPoint(tmp.right() - 1, tmp.bottom() - 1)
+ };
+ painter->drawPoints(points, 4);
painter->setPen(titleBarHighlight);
painter->drawLine(tmp.left() + 2, tmp.top() + 1, tmp.right() - 2, tmp.top() + 1);
@@ -900,14 +906,17 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem,
QRect r = rect.adjusted(0, 1, 0, -1);
painter->setPen(buttonShadowAlpha);
painter->drawLine(QPoint(r.left() + 2, r.top() - 1), QPoint(r.right() - 2, r.top() - 1));
- painter->drawPoint(r.right() - 1, r.top());
- painter->drawPoint(r.right(), r.top() + 1);
- painter->drawPoint(r.right() - 1, r.bottom());
- painter->drawPoint(r.right(), r.bottom() - 1);
- painter->drawPoint(r.left() + 1, r.top() );
- painter->drawPoint(r.left(), r.top() + 1);
- painter->drawPoint(r.left() + 1, r.bottom() );
- painter->drawPoint(r.left(), r.bottom() - 1);
+ const QPoint points[8] = {
+ QPoint(r.right() - 1, r.top()),
+ QPoint(r.right(), r.top() + 1),
+ QPoint(r.right() - 1, r.bottom()),
+ QPoint(r.right(), r.bottom() - 1),
+ QPoint(r.left() + 1, r.top() ),
+ QPoint(r.left(), r.top() + 1),
+ QPoint(r.left() + 1, r.bottom() ),
+ QPoint(r.left(), r.bottom() - 1)
+ };
+ painter->drawPoints(points, 8);
painter->setPen(QPen(option->palette.background().color(), 1));
painter->drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1));
@@ -939,10 +948,13 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem,
painter->drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2));
painter->drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2));
painter->drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right() - 2, r.bottom()));
- painter->drawPoint(QPoint(r.right() - 1, r.bottom() - 1));
- painter->drawPoint(QPoint(r.right() - 1, r.top() + 1));
- painter->drawPoint(QPoint(r.left() + 1, r.bottom() - 1));
- painter->drawPoint(QPoint(r.left() + 1, r.top() + 1));
+ const QPoint points2[4] = {
+ QPoint(r.right() - 1, r.bottom() - 1),
+ QPoint(r.right() - 1, r.top() + 1),
+ QPoint(r.left() + 1, r.bottom() - 1),
+ QPoint(r.left() + 1, r.top() + 1)
+ };
+ painter->drawPoints(points2, 4);
painter->drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top()));
painter->setPen(oldPen);
}
@@ -1040,10 +1052,13 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem,
painter->setBrush(QBrush(dark.darker(120), Qt::Dense4Pattern));
painter->setBrushOrigin(rect.topLeft());
painter->setPen(Qt::NoPen);
- painter->drawRect(rect.left(), rect.top(), rect.width(), 1); // Top
- painter->drawRect(rect.left(), rect.bottom(), rect.width(), 1); // Bottom
- painter->drawRect(rect.left(), rect.top(), 1, rect.height()); // Left
- painter->drawRect(rect.right(), rect.top(), 1, rect.height()); // Right
+ const QRect rects[4] = {
+ QRect(rect.left(), rect.top(), rect.width(), 1), // Top
+ QRect(rect.left(), rect.bottom(), rect.width(), 1), // Bottom
+ QRect(rect.left(), rect.top(), 1, rect.height()), // Left
+ QRect(rect.right(), rect.top(), 1, rect.height()) // Right
+ };
+ painter->drawRects(rects, 4);
painter->restore();
}
break;
@@ -1065,18 +1080,24 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem,
if (isDefault) {
r = option->rect.adjusted(0, 1, 0, -1);
painter->setPen(QPen(Qt::black, 0));
- painter->drawLine(QPoint(r.left() + 2, r.top()),
- QPoint(r.right() - 2, r.top()));
- painter->drawLine(QPoint(r.left(), r.top() + 2),
- QPoint(r.left(), r.bottom() - 2));
- painter->drawLine(QPoint(r.right(), r.top() + 2),
- QPoint(r.right(), r.bottom() - 2));
- painter->drawLine(QPoint(r.left() + 2, r.bottom()),
- QPoint(r.right() - 2, r.bottom()));
- painter->drawPoint(QPoint(r.right() - 1, r.bottom() - 1));
- painter->drawPoint(QPoint(r.right() - 1, r.top() + 1));
- painter->drawPoint(QPoint(r.left() + 1, r.bottom() - 1));
- painter->drawPoint(QPoint(r.left() + 1, r.top() + 1));
+ const QLine lines[4] = {
+ QLine(QPoint(r.left() + 2, r.top()),
+ QPoint(r.right() - 2, r.top())),
+ QLine(QPoint(r.left(), r.top() + 2),
+ QPoint(r.left(), r.bottom() - 2)),
+ QLine(QPoint(r.right(), r.top() + 2),
+ QPoint(r.right(), r.bottom() - 2)),
+ QLine(QPoint(r.left() + 2, r.bottom()),
+ QPoint(r.right() - 2, r.bottom()))
+ };
+ painter->drawLines(lines, 4);
+ const QPoint points[4] = {
+ QPoint(r.right() - 1, r.bottom() - 1),
+ QPoint(r.right() - 1, r.top() + 1),
+ QPoint(r.left() + 1, r.bottom() - 1),
+ QPoint(r.left() + 1, r.top() + 1)
+ };
+ painter->drawPoints(points, 4);
painter->setPen(oldPen);
}
return;
@@ -1140,10 +1161,13 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem,
QPoint(r.right(), r.bottom() - 2));
p->drawLine(QPoint(r.left() + 2, r.bottom()),
QPoint(r.right() - 2, r.bottom()));
- p->drawPoint(QPoint(r.right() - 1, r.bottom() - 1));
- p->drawPoint(QPoint(r.right() - 1, r.top() + 1));
- p->drawPoint(QPoint(r.left() + 1, r.bottom() - 1));
- p->drawPoint(QPoint(r.left() + 1, r.top() + 1));
+ const QPoint points[4] = {
+ QPoint(r.right() - 1, r.bottom() - 1),
+ QPoint(r.right() - 1, r.top() + 1),
+ QPoint(r.left() + 1, r.bottom() - 1),
+ QPoint(r.left() + 1, r.top() + 1)
+ };
+ p->drawPoints(points, 4);
if (!isDefault && !hasFocus && isEnabled)
p->setPen(QPen(darkOutline.darker(110), 0));
@@ -1163,14 +1187,17 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem,
topShadow.setAlpha(60);
p->setPen(topShadow);
- p->drawPoint(QPoint(r.right(), r.top() + 1));
- p->drawPoint(QPoint(r.right() - 1, r.top() ));
- p->drawPoint(QPoint(r.right(), r.bottom() - 1));
- p->drawPoint(QPoint(r.right() - 1, r.bottom() ));
- p->drawPoint(QPoint(r.left() + 1, r.bottom()));
- p->drawPoint(QPoint(r.left(), r.bottom() - 1));
- p->drawPoint(QPoint(r.left() + 1, r.top()));
- p->drawPoint(QPoint(r.left(), r.top() + 1));
+ const QPoint points2[8] = {
+ QPoint(r.right(), r.top() + 1),
+ QPoint(r.right() - 1, r.top() ),
+ QPoint(r.right(), r.bottom() - 1),
+ QPoint(r.right() - 1, r.bottom() ),
+ QPoint(r.left() + 1, r.bottom()),
+ QPoint(r.left(), r.bottom() - 1),
+ QPoint(r.left() + 1, r.top()),
+ QPoint(r.left(), r.top() + 1)
+ };
+ p->drawPoints(points2, 8);
topShadow.setAlpha(30);
p->setPen(topShadow);
@@ -1183,18 +1210,24 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem,
if (isDefault) {
r.adjust(-1, -1, 1, 1);
p->setPen(buttonShadowAlpha.darker(120));
- p->drawLine(r.topLeft() + QPoint(3, 0), r.topRight() - QPoint(3, 0));
- p->drawLine(r.bottomLeft() + QPoint(3, 0), r.bottomRight() - QPoint(3, 0));
- p->drawLine(r.topLeft() + QPoint(0, 3), r.bottomLeft() - QPoint(0, 3));
- p->drawLine(r.topRight() + QPoint(0, 3), r.bottomRight() - QPoint(0, 3));
- p->drawPoint(r.topRight() + QPoint(-2, 1));
- p->drawPoint(r.topRight() + QPoint(-1, 2));
- p->drawPoint(r.bottomRight() + QPoint(-1, -2));
- p->drawPoint(r.bottomRight() + QPoint(-2, -1));
- p->drawPoint(r.topLeft() + QPoint(1, 2));
- p->drawPoint(r.topLeft() + QPoint(2, 1));
- p->drawPoint(r.bottomLeft() + QPoint(1, -2));
- p->drawPoint(r.bottomLeft() + QPoint(2, -1));
+ const QLine lines[4] = {
+ QLine(r.topLeft() + QPoint(3, 0), r.topRight() - QPoint(3, 0)),
+ QLine(r.bottomLeft() + QPoint(3, 0), r.bottomRight() - QPoint(3, 0)),
+ QLine(r.topLeft() + QPoint(0, 3), r.bottomLeft() - QPoint(0, 3)),
+ QLine(r.topRight() + QPoint(0, 3), r.bottomRight() - QPoint(0, 3))
+ };
+ p->drawLines(lines, 4);
+ const QPoint points3[8] = {
+ r.topRight() + QPoint(-2, 1),
+ r.topRight() + QPoint(-1, 2),
+ r.bottomRight() + QPoint(-1, -2),
+ r.bottomRight() + QPoint(-2, -1),
+ r.topLeft() + QPoint(1, 2),
+ r.topLeft() + QPoint(2, 1),
+ r.bottomLeft() + QPoint(1, -2),
+ r.bottomLeft() + QPoint(2, -1)
+ };
+ p->drawPoints(points3, 8);
}
painter->setPen(oldPen);
painter->setBrush(oldBrush);
@@ -1307,12 +1340,15 @@ void QCleanlooksStyle::drawPrimitive(PrimitiveElement elem,
painter->drawLine(innerBottomLine);
painter->setPen(alphaCornerColor);
- painter->drawPoint(leftBottomInnerCorner1);
- painter->drawPoint(leftBottomInnerCorner2);
- painter->drawPoint(rightBottomInnerCorner1);
- painter->drawPoint(rightBottomInnerCorner2);
- painter->drawPoint(leftTopInnerCorner1);
- painter->drawPoint(leftTopInnerCorner2);
+ const QPoint points[6] = {
+ leftBottomInnerCorner1,
+ leftBottomInnerCorner2,
+ rightBottomInnerCorner1,
+ rightBottomInnerCorner2,
+ leftTopInnerCorner1,
+ leftTopInnerCorner2
+ };
+ painter->drawPoints(points, 6);
}
#endif // QT_NO_TABWIDGET
painter->restore();
@@ -1670,19 +1706,25 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o
painter->fillRect(rect, option->palette.base());
QColor borderColor = dark.lighter(110);
painter->setPen(QPen(borderColor, 0));
- painter->drawLine(QPoint(rect.left() + 1, rect.top()), QPoint(rect.right() - 1, rect.top()));
- painter->drawLine(QPoint(rect.left() + 1, rect.bottom()), QPoint(rect.right() - 1, rect.bottom()));
- painter->drawLine(QPoint(rect.left(), rect.top() + 1), QPoint(rect.left(), rect.bottom() - 1));
- painter->drawLine(QPoint(rect.right(), rect.top() + 1), QPoint(rect.right(), rect.bottom() - 1));
+ const QLine lines[4] = {
+ QLine(QPoint(rect.left() + 1, rect.top()), QPoint(rect.right() - 1, rect.top())),
+ QLine(QPoint(rect.left() + 1, rect.bottom()), QPoint(rect.right() - 1, rect.bottom())),
+ QLine(QPoint(rect.left(), rect.top() + 1), QPoint(rect.left(), rect.bottom() - 1)),
+ QLine(QPoint(rect.right(), rect.top() + 1), QPoint(rect.right(), rect.bottom() - 1))
+ };
+ painter->drawLines(lines, 4);
QColor alphaCorner = mergedColors(borderColor, option->palette.background().color());
QColor innerShadow = mergedColors(borderColor, option->palette.base().color());
//corner smoothing
painter->setPen(alphaCorner);
- painter->drawPoint(rect.topRight());
- painter->drawPoint(rect.topLeft());
- painter->drawPoint(rect.bottomRight());
- painter->drawPoint(rect.bottomLeft());
+ const QPoint points[4] = {
+ rect.topRight(),
+ rect.topLeft(),
+ rect.bottomRight(),
+ rect.bottomLeft()
+ };
+ painter->drawPoints(points, 4);
//inner shadow
painter->setPen(innerShadow);
@@ -1807,10 +1849,13 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o
option->palette.highlight());
painter->setPen(QPen(highlightOutline, 0));
- painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom()));
- painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom()));
- painter->drawLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom()));
- painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top()));
+ const QLine lines[4] = {
+ QLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom())),
+ QLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom())),
+ QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())),
+ QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top()))
+ };
+ painter->drawLines(lines, 4);
//draw text
QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText;
@@ -1864,10 +1909,13 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o
highlight);
r = r.adjusted(-1, 0, 1, 0);
painter->setPen(QPen(highlightOutline, 0));
- painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom() - 1));
- painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom() - 1));
- painter->drawLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom()));
- painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top()));
+ const QLine lines[4] = {
+ QLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom() - 1)),
+ QLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom() - 1)),
+ QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())),
+ QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top()))
+ };
+ painter->drawLines(lines, 4);
} else {
painter->fillRect(option->rect, menuBackground);
}
@@ -2447,14 +2495,17 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
cachePainter.setPen(topShadow);
// antialias corners
- cachePainter.drawPoint(QPoint(r.right(), r.top() + 1));
- cachePainter.drawPoint(QPoint(r.right() - 1, r.top() ));
- cachePainter.drawPoint(QPoint(r.right(), r.bottom() - 1));
- cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() ));
- cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom()));
- cachePainter.drawPoint(QPoint(r.left(), r.bottom() - 1));
- cachePainter.drawPoint(QPoint(r.left() + 1, r.top()));
- cachePainter.drawPoint(QPoint(r.left(), r.top() + 1));
+ const QPoint points[8] = {
+ QPoint(r.right(), r.top() + 1),
+ QPoint(r.right() - 1, r.top() ),
+ QPoint(r.right(), r.bottom() - 1),
+ QPoint(r.right() - 1, r.bottom() ),
+ QPoint(r.left() + 1, r.bottom()),
+ QPoint(r.left(), r.bottom() - 1),
+ QPoint(r.left() + 1, r.top()),
+ QPoint(r.left(), r.top() + 1)
+ };
+ cachePainter.drawPoints(points, 8);
// draw frame
topShadow.setAlpha(30);
@@ -2482,10 +2533,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
cachePainter.setPen(QPen(darkOutline, 1));
// top and bottom lines
- cachePainter.drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- 2, r.bottom()));
- cachePainter.drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top()));
- cachePainter.drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2));
- cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2));
+ const QLine lines[4] = {
+ QLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- 2, r.bottom())),
+ QLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())),
+ QLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)),
+ QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2))
+ };
+ cachePainter.drawLines(lines, 4);
}
// gradients
@@ -2519,10 +2573,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
if (spinBox->frame) {
// rounded corners
- cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom() - 1));
- cachePainter.drawPoint(QPoint(r.left() + 1, r.top() + 1));
- cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() - 1));
- cachePainter.drawPoint(QPoint(r.right() - 1, r.top() + 1));
+ const QPoint points[4] = {
+ QPoint(r.left() + 1, r.bottom() - 1),
+ QPoint(r.left() + 1, r.top() + 1),
+ QPoint(r.right() - 1, r.bottom() - 1),
+ QPoint(r.right() - 1, r.top() + 1)
+ };
+ cachePainter.drawPoints(points, 4);
if (option->state & State_HasFocus) {
QColor darkoutline = option->palette.highlight().color().darker(150);
@@ -2531,10 +2588,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
if (spinBox->direction == Qt::LeftToRight) {
cachePainter.drawRect(rect.adjusted(1, 2, -3 -downRect.width(), -3));
cachePainter.setPen(QPen(darkoutline, 0));
- cachePainter.drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- downRect.width() - 1, r.bottom()));
- cachePainter.drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - downRect.width() - 1, r.top()));
- cachePainter.drawLine(QPoint(r.right() - downRect.width() - 1, r.top() + 1), QPoint(r.right()- downRect.width() - 1, r.bottom() - 1));
- cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2));
+ const QLine lines[4] = {
+ QLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- downRect.width() - 1, r.bottom())),
+ QLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - downRect.width() - 1, r.top())),
+ QLine(QPoint(r.right() - downRect.width() - 1, r.top() + 1), QPoint(r.right()- downRect.width() - 1, r.bottom() - 1)),
+ QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2))
+ };
+ cachePainter.drawLines(lines, 4);
cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom() - 1));
cachePainter.drawPoint(QPoint(r.left() + 1, r.top() + 1));
cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2));
@@ -2679,18 +2739,24 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
// top outline
painter->drawLine(fullRect.left() + 5, fullRect.top(), fullRect.right() - 5, fullRect.top());
painter->drawLine(fullRect.left(), fullRect.top() + 4, fullRect.left(), fullRect.bottom());
- painter->drawPoint(fullRect.left() + 4, fullRect.top() + 1);
- painter->drawPoint(fullRect.left() + 3, fullRect.top() + 1);
- painter->drawPoint(fullRect.left() + 2, fullRect.top() + 2);
- painter->drawPoint(fullRect.left() + 1, fullRect.top() + 3);
- painter->drawPoint(fullRect.left() + 1, fullRect.top() + 4);
+ const QPoint points[5] = {
+ QPoint(fullRect.left() + 4, fullRect.top() + 1),
+ QPoint(fullRect.left() + 3, fullRect.top() + 1),
+ QPoint(fullRect.left() + 2, fullRect.top() + 2),
+ QPoint(fullRect.left() + 1, fullRect.top() + 3),
+ QPoint(fullRect.left() + 1, fullRect.top() + 4)
+ };
+ painter->drawPoints(points, 5);
painter->drawLine(fullRect.right(), fullRect.top() + 4, fullRect.right(), fullRect.bottom());
- painter->drawPoint(fullRect.right() - 3, fullRect.top() + 1);
- painter->drawPoint(fullRect.right() - 4, fullRect.top() + 1);
- painter->drawPoint(fullRect.right() - 2, fullRect.top() + 2);
- painter->drawPoint(fullRect.right() - 1, fullRect.top() + 3);
- painter->drawPoint(fullRect.right() - 1, fullRect.top() + 4);
+ const QPoint points2[5] = {
+ QPoint(fullRect.right() - 3, fullRect.top() + 1),
+ QPoint(fullRect.right() - 4, fullRect.top() + 1),
+ QPoint(fullRect.right() - 2, fullRect.top() + 2),
+ QPoint(fullRect.right() - 1, fullRect.top() + 3),
+ QPoint(fullRect.right() - 1, fullRect.top() + 4)
+ };
+ painter->drawPoints(points2, 5);
// draw bottomline
painter->drawLine(fullRect.right(), fullRect.bottom(), fullRect.left(), fullRect.bottom());
@@ -2749,10 +2815,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1,
maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1);
painter->setPen(textAlphaColor);
- painter->drawPoint(maxButtonIconRect.topLeft());
- painter->drawPoint(maxButtonIconRect.topRight());
- painter->drawPoint(maxButtonIconRect.bottomLeft());
- painter->drawPoint(maxButtonIconRect.bottomRight());
+ const QPoint points[4] = {
+ maxButtonIconRect.topLeft(),
+ maxButtonIconRect.topRight(),
+ maxButtonIconRect.bottomLeft(),
+ maxButtonIconRect.bottomRight()
+ };
+ painter->drawPoints(points, 4);
}
}
@@ -2765,18 +2834,24 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
qt_cleanlooks_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken);
QRect closeIconRect = closeButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin);
painter->setPen(textAlphaColor);
- painter->drawLine(closeIconRect.left() + 1, closeIconRect.top(),
- closeIconRect.right(), closeIconRect.bottom() - 1);
- painter->drawLine(closeIconRect.left(), closeIconRect.top() + 1,
- closeIconRect.right() - 1, closeIconRect.bottom());
- painter->drawLine(closeIconRect.right() - 1, closeIconRect.top(),
- closeIconRect.left(), closeIconRect.bottom() - 1);
- painter->drawLine(closeIconRect.right(), closeIconRect.top() + 1,
- closeIconRect.left() + 1, closeIconRect.bottom());
- painter->drawPoint(closeIconRect.topLeft());
- painter->drawPoint(closeIconRect.topRight());
- painter->drawPoint(closeIconRect.bottomLeft());
- painter->drawPoint(closeIconRect.bottomRight());
+ const QLine lines[4] = {
+ QLine(closeIconRect.left() + 1, closeIconRect.top(),
+ closeIconRect.right(), closeIconRect.bottom() - 1),
+ QLine(closeIconRect.left(), closeIconRect.top() + 1,
+ closeIconRect.right() - 1, closeIconRect.bottom()),
+ QLine(closeIconRect.right() - 1, closeIconRect.top(),
+ closeIconRect.left(), closeIconRect.bottom() - 1),
+ QLine(closeIconRect.right(), closeIconRect.top() + 1,
+ closeIconRect.left() + 1, closeIconRect.bottom())
+ };
+ painter->drawLines(lines, 4);
+ const QPoint points[4] = {
+ closeIconRect.topLeft(),
+ closeIconRect.topRight(),
+ closeIconRect.bottomLeft(),
+ closeIconRect.bottomRight()
+ };
+ painter->drawPoints(points, 4);
painter->setPen(textColor);
painter->drawLine(closeIconRect.left() + 1, closeIconRect.top() + 1,
@@ -2806,10 +2881,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
painter->drawLine(frontWindowRect.left() + 1, frontWindowRect.top() + 1,
frontWindowRect.right() - 1, frontWindowRect.top() + 1);
painter->setPen(textAlphaColor);
- painter->drawPoint(frontWindowRect.topLeft());
- painter->drawPoint(frontWindowRect.topRight());
- painter->drawPoint(frontWindowRect.bottomLeft());
- painter->drawPoint(frontWindowRect.bottomRight());
+ const QPoint points[4] = {
+ frontWindowRect.topLeft(),
+ frontWindowRect.topRight(),
+ frontWindowRect.bottomLeft(),
+ frontWindowRect.bottomRight()
+ };
+ painter->drawPoints(points, 4);
QRect backWindowRect = normalButtonIconRect.adjusted(3, 0, 0, -3);
QRegion clipRegion = backWindowRect;
@@ -2821,10 +2899,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
painter->drawLine(backWindowRect.left() + 1, backWindowRect.top() + 1,
backWindowRect.right() - 1, backWindowRect.top() + 1);
painter->setPen(textAlphaColor);
- painter->drawPoint(backWindowRect.topLeft());
- painter->drawPoint(backWindowRect.topRight());
- painter->drawPoint(backWindowRect.bottomLeft());
- painter->drawPoint(backWindowRect.bottomRight());
+ const QPoint points2[4] = {
+ backWindowRect.topLeft(),
+ backWindowRect.topRight(),
+ backWindowRect.bottomLeft(),
+ backWindowRect.bottomRight()
+ };
+ painter->drawPoints(points2, 4);
painter->restore();
}
}
@@ -3498,10 +3579,13 @@ void QCleanlooksStyle::drawComplexControl(ComplexControl control, const QStyleOp
handlePainter.save();
handlePainter.setRenderHint(QPainter::Antialiasing);
handlePainter.translate(0.5, 0.5);
- handlePainter.drawLine(QPoint(r.left(), r.bottom() - 2), QPoint(r.left() + 2, r.bottom()));
- handlePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left() + 2, r.top()));
- handlePainter.drawLine(QPoint(r.right(), r.bottom() - 2), QPoint(r.right() - 2, r.bottom()));
- handlePainter.drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right() - 2, r.top()));
+ const QLine lines[4] = {
+ QLine(QPoint(r.left(), r.bottom() - 2), QPoint(r.left() + 2, r.bottom())),
+ QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left() + 2, r.top())),
+ QLine(QPoint(r.right(), r.bottom() - 2), QPoint(r.right() - 2, r.bottom())),
+ QLine(QPoint(r.right(), r.top() + 2), QPoint(r.right() - 2, r.top()))
+ };
+ handlePainter.drawLines(lines, 4);
handlePainter.restore();;
handlePainter.setPen(QPen(outline.darker(130), 1));
handlePainter.drawLine(QPoint(r.left() + 3, r.top()), QPoint(r.right() - 3, r.top()));
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index e68aa3a..da9ec09 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -519,7 +519,7 @@ bool QHttpNetworkConnectionPrivate::fillPipeline(QList<HttpMessagePair> &queue,
if (queue.isEmpty())
return true;
- for (int i = 0; i < queue.length(); i++) {
+ for (int i = queue.count() - 1; i >= 0; --i) {
HttpMessagePair messagePair = queue.at(i);
const QHttpNetworkRequest &request = messagePair.first;
diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp
index af8d6fb..908f01f 100644
--- a/src/network/kernel/qnetworkproxy.cpp
+++ b/src/network/kernel/qnetworkproxy.cpp
@@ -220,6 +220,7 @@
#ifndef QT_NO_NETWORKPROXY
+#include "private/qnetworkproxy_p.h"
#include "private/qsocks5socketengine_p.h"
#include "private/qhttpsocketengine_p.h"
#include "qauthenticator.h"
@@ -1156,6 +1157,29 @@ QNetworkProxyFactory::~QNetworkProxyFactory()
{
}
+
+/*!
+ Enables the use of the platform-specific proxy settings, and only those.
+ See systemProxyForQuery() for more information.
+
+ Internally, this method (when called with \a enable set to true)
+ sets an application-wide proxy factory. For this reason, this method
+ is mutually exclusive with setApplicationProxyFactory: calling
+ setApplicationProxyFactory overrides the use of the system-wide proxy,
+ and calling setUseSystemConfigurationEnabled overrides any
+ application proxy or proxy factory that was previously set.
+
+ \since 4.6
+*/
+void QNetworkProxyFactory::setUseSystemConfigurationEnabled(bool enable)
+{
+ if (enable) {
+ setApplicationProxyFactory(new QSystemConfigurationProxyFactory);
+ } else {
+ setApplicationProxyFactory(0);
+ }
+}
+
/*!
Sets the application-wide proxy factory to be \a factory. This
function will take ownership of that object and will delete it
diff --git a/src/network/kernel/qnetworkproxy.h b/src/network/kernel/qnetworkproxy.h
index d64ba09..01a88b8 100644
--- a/src/network/kernel/qnetworkproxy.h
+++ b/src/network/kernel/qnetworkproxy.h
@@ -171,6 +171,7 @@ public:
virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery()) = 0;
+ static void setUseSystemConfigurationEnabled(bool enable);
static void setApplicationProxyFactory(QNetworkProxyFactory *factory);
static QList<QNetworkProxy> proxyForQuery(const QNetworkProxyQuery &query);
static QList<QNetworkProxy> systemProxyForQuery(const QNetworkProxyQuery &query = QNetworkProxyQuery());
diff --git a/src/network/kernel/qnetworkproxy_p.h b/src/network/kernel/qnetworkproxy_p.h
new file mode 100644
index 0000000..facbfed
--- /dev/null
+++ b/src/network/kernel/qnetworkproxy_p.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 David Faure <dfaure@kdab.net>
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QNETWORKPROXY_P_H
+#define QNETWORKPROXY_P_H
+
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the QLibrary class. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#ifndef QT_NO_NETWORKPROXY
+
+QT_BEGIN_NAMESPACE
+
+class QSystemConfigurationProxyFactory : public QNetworkProxyFactory
+{
+public:
+ QSystemConfigurationProxyFactory() : QNetworkProxyFactory() {}
+
+ virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery& query)
+ {
+ QList<QNetworkProxy> proxies = QNetworkProxyFactory::systemProxyForQuery(query);
+
+ // Make sure NoProxy is in the list, so that QTcpServer can work:
+ // it searches for the first proxy that can has the ListeningCapability capability
+ // if none have (as is the case with HTTP proxies), it fails to bind.
+ // NoProxy allows it to fallback to the 'no proxy' case and bind.
+ proxies.append(QNetworkProxy::NoProxy);
+
+ return proxies;
+ }
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_NETWORKINTERFACE
+
+#endif
+
diff --git a/src/network/kernel/qnetworkproxy_win.cpp b/src/network/kernel/qnetworkproxy_win.cpp
index 34a702b..8080261 100644
--- a/src/network/kernel/qnetworkproxy_win.cpp
+++ b/src/network/kernel/qnetworkproxy_win.cpp
@@ -363,8 +363,13 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
if (sp->isAutoConfig) {
WINHTTP_PROXY_INFO proxyInfo;
- // try to get the proxy config for the URL, if we have a URL
+ // try to get the proxy config for the URL
QUrl url = query.url();
+ // url could be empty, e.g. from QNetworkProxy::applicationProxy(), that's fine,
+ // we'll still ask for the proxy.
+ // But for a file url, we know we don't need one.
+ if (url.scheme() == QLatin1String("file") || url.scheme() == QLatin1String("qrc"))
+ return sp->defaultResult;
if (query.queryType() != QNetworkProxyQuery::UrlRequest) {
// change the scheme to https, maybe it'll work
url.setScheme(QLatin1String("https"));
diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp
index 666770d..3793b1e 100644
--- a/src/network/ssl/qsslcertificate.cpp
+++ b/src/network/ssl/qsslcertificate.cpp
@@ -250,14 +250,22 @@ void QSslCertificate::clear()
*/
QByteArray QSslCertificate::version() const
{
+ if (d->versionString.isEmpty() && d->x509)
+ d->versionString =
+ QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->version)) + 1);
+
return d->versionString;
}
/*!
- Returns the certificate's serial number string.
+ Returns the certificate's serial number string in decimal format.
*/
QByteArray QSslCertificate::serialNumber() const
{
+ if (d->serialNumberString.isEmpty() && d->x509)
+ d->serialNumberString =
+ QByteArray::number(qlonglong(q_ASN1_INTEGER_get(d->x509->cert_info->serialNumber)));
+
return d->serialNumberString;
}
diff --git a/src/network/ssl/qsslerror.cpp b/src/network/ssl/qsslerror.cpp
index 69d2ccd..d47c91d 100644
--- a/src/network/ssl/qsslerror.cpp
+++ b/src/network/ssl/qsslerror.cpp
@@ -105,10 +105,8 @@ public:
};
/*!
- Constructs a QSslError object. The two optional arguments specify the \a
- error that occurred, and which \a certificate the error relates to.
+ Constructs a QSslError object with no error and default certificate.
- \sa QSslCertificate
*/
// RVCT compiler in debug build does not like about default values in const-
@@ -120,6 +118,11 @@ QSslError::QSslError()
d->certificate = QSslCertificate();
}
+/*!
+ Constructs a QSslError object. The argument specifies the \a
+ error that occurred.
+
+*/
QSslError::QSslError(SslError error)
: d(new QSslErrorPrivate)
{
@@ -127,6 +130,12 @@ QSslError::QSslError(SslError error)
d->certificate = QSslCertificate();
}
+/*!
+ Constructs a QSslError object. The two arguments specify the \a
+ error that occurred, and which \a certificate the error relates to.
+
+ \sa QSslCertificate
+*/
QSslError::QSslError(SslError error, const QSslCertificate &certificate)
: d(new QSslErrorPrivate)
{
diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp
index 5b04a57..d3dcd51 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
+++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
@@ -94,6 +94,7 @@ QT_BEGIN_NAMESPACE
#ifdef SSLEAY_MACROS
DEFINEFUNC3(void *, ASN1_dup, i2d_of_void *a, a, d2i_of_void *b, b, char *c, c, return 0, return)
#endif
+DEFINEFUNC(long, ASN1_INTEGER_get, ASN1_INTEGER *a, a, return 0, return)
DEFINEFUNC(unsigned char *, ASN1_STRING_data, ASN1_STRING *a, a, return 0, return)
DEFINEFUNC(int, ASN1_STRING_length, ASN1_STRING *a, a, return 0, return)
DEFINEFUNC4(long, BIO_ctrl, BIO *a, a, int b, b, long c, c, void *d, d, return -1, return)
@@ -608,6 +609,7 @@ bool q_resolveOpenSslSymbols()
#ifdef SSLEAY_MACROS
RESOLVEFUNC(ASN1_dup)
#endif
+ RESOLVEFUNC(ASN1_INTEGER_get)
RESOLVEFUNC(ASN1_STRING_data)
RESOLVEFUNC(ASN1_STRING_length)
RESOLVEFUNC(BIO_ctrl)
diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h
index f9c92e5..30762ca 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols_p.h
+++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h
@@ -201,6 +201,7 @@ QT_BEGIN_NAMESPACE
#endif // !defined QT_LINKED_OPENSSL
bool q_resolveOpenSslSymbols();
+long q_ASN1_INTEGER_get(ASN1_INTEGER *a);
unsigned char * q_ASN1_STRING_data(ASN1_STRING *a);
int q_ASN1_STRING_length(ASN1_STRING *a);
long q_BIO_ctrl(BIO *a, int b, long c, void *d);
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 895dd65..0c01263 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -226,6 +226,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height)
glDisable(GL_DEPTH_TEST);
glDisable(GL_SCISSOR_TEST);
+ glDisable(GL_BLEND);
glViewport(0, 0, oldWidth, oldHeight);
@@ -379,7 +380,7 @@ void QGL2PaintEngineExPrivate::useSimpleShader()
}
if (simpleShaderDepthUniformDirty) {
- shaderManager->simpleProgram()->setUniformValue("depth", (GLfloat)q->state()->currentDepth);
+ shaderManager->simpleProgram()->setUniformValue("depth", normalizedDeviceDepth(q->state()->currentDepth));
simpleShaderDepthUniformDirty = false;
}
}
@@ -730,7 +731,6 @@ void QGL2PaintEngineExPrivate::resetGLState()
glActiveTexture(GL_TEXTURE0);
glDisable(GL_DEPTH_TEST);
glDisable(GL_SCISSOR_TEST);
- glDepthFunc(GL_LESS);
glDepthMask(true);
glClearDepth(1);
}
@@ -958,7 +958,7 @@ bool QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque)
}
if (depthUniformDirty) {
- shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Depth), (GLfloat)q->state()->currentDepth);
+ shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Depth), normalizedDeviceDepth(q->state()->currentDepth));
depthUniformDirty = false;
}
@@ -1350,7 +1350,7 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
if (!d->inRenderText) {
glDisable(GL_DEPTH_TEST);
glDisable(GL_SCISSOR_TEST);
- glDepthFunc(GL_LEQUAL);
+ glDepthFunc(GL_LESS);
glDepthMask(false);
}
@@ -1440,7 +1440,7 @@ void QGL2PaintEngineEx::ensureActive()
if (d->needsSync) {
glViewport(0, 0, d->width, d->height);
glDepthMask(false);
- glDepthFunc(GL_LEQUAL);
+ glDepthFunc(GL_LESS);
setState(state());
d->needsSync = false;
}
@@ -1491,7 +1491,7 @@ void QGL2PaintEngineEx::clipEnabledChanged()
d->regenerateDepthClip();
} else {
if (d->use_system_clip) {
- state()->currentDepth = -0.5f;
+ state()->currentDepth = 0;
} else {
state()->depthTestEnabled = false;
}
@@ -1500,7 +1500,7 @@ void QGL2PaintEngineEx::clipEnabledChanged()
}
}
-void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, float depth)
+void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, uint depth)
{
transferMode(BrushDrawingMode);
@@ -1509,7 +1509,7 @@ void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, float depth)
if (q->state()->needsDepthBufferClear) {
glDepthMask(true);
- glClearDepth(0.5);
+ glClearDepth(rawDepth(2));
glClear(GL_DEPTH_BUFFER_BIT);
q->state()->needsDepthBufferClear = false;
glDepthMask(false);
@@ -1531,7 +1531,7 @@ void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, float depth)
glColorMask(false, false, false, false);
glDepthMask(true);
- shaderManager->simpleProgram()->setUniformValue("depth", depth);
+ shaderManager->simpleProgram()->setUniformValue("depth", normalizedDeviceDepth(depth));
simpleShaderDepthUniformDirty = true;
glEnable(GL_DEPTH_TEST);
@@ -1595,12 +1595,12 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op)
glDepthFunc(GL_ALWAYS);
- state()->maxDepth = 0.5f;
+ state()->maxDepth = 4;
d->writeClip(qtVectorPathForPath(path), state()->maxDepth);
- state()->currentDepth = 0.25f;
+ state()->currentDepth = 3;
state()->depthTestEnabled = true;
- glDepthFunc(GL_LEQUAL);
+ glDepthFunc(GL_LESS);
glEnable(GL_DEPTH_TEST);
}
@@ -1609,7 +1609,7 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op)
if (d->use_system_clip) {
glEnable(GL_DEPTH_TEST);
state()->depthTestEnabled = true;
- state()->currentDepth = -0.5;
+ state()->currentDepth = 0;
} else {
glDisable(GL_DEPTH_TEST);
state()->depthTestEnabled = false;
@@ -1617,18 +1617,18 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op)
state()->canRestoreClip = false;
break;
case Qt::IntersectClip:
- state()->maxDepth = (1.0f + state()->maxDepth) * 0.5;
+ ++state()->maxDepth;
d->writeClip(path, state()->maxDepth);
- state()->currentDepth = 1.5 * state()->maxDepth - 0.5f;
+ state()->currentDepth = state()->maxDepth - 1;
state()->depthTestEnabled = true;
break;
case Qt::ReplaceClip:
d->systemStateChanged();
state()->rectangleClip = QRect();
- state()->maxDepth = 0.5f;
+ state()->maxDepth = 4;
glDepthFunc(GL_ALWAYS);
d->writeClip(path, state()->maxDepth);
- state()->currentDepth = 0.25f;
+ state()->currentDepth = 3;
state()->canRestoreClip = false;
state()->depthTestEnabled = true;
break;
@@ -1640,7 +1640,7 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op)
break;
}
- glDepthFunc(GL_LEQUAL);
+ glDepthFunc(GL_LESS);
if (state()->depthTestEnabled) {
glEnable(GL_DEPTH_TEST);
d->simpleShaderDepthUniformDirty = true;
@@ -1671,8 +1671,8 @@ void QGL2PaintEngineExPrivate::systemStateChanged()
glDisable(GL_SCISSOR_TEST);
- q->state()->currentDepth = -0.5f;
- q->state()->maxDepth = 0.5f;
+ q->state()->currentDepth = 1;
+ q->state()->maxDepth = 4;
q->state()->rectangleClip = QRect(0, 0, width, height);
@@ -1707,8 +1707,8 @@ void QGL2PaintEngineExPrivate::systemStateChanged()
path.addRegion(systemClip);
glDepthFunc(GL_ALWAYS);
- writeClip(qtVectorPathForPath(path), 0.0f);
- glDepthFunc(GL_LEQUAL);
+ writeClip(qtVectorPathForPath(path), 2);
+ glDepthFunc(GL_LESS);
glEnable(GL_DEPTH_TEST);
q->state()->depthTestEnabled = true;
@@ -1717,7 +1717,7 @@ void QGL2PaintEngineExPrivate::systemStateChanged()
q->transformChanged();
}
- q->state()->currentDepth = -0.5f;
+ q->state()->currentDepth = 1;
simpleShaderDepthUniformDirty = true;
depthUniformDirty = true;
}
@@ -1756,7 +1756,7 @@ void QGL2PaintEngineEx::setState(QPainterState *new_state)
if (old_state && old_state != s && old_state->canRestoreClip) {
d->updateDepthScissorTest();
glDepthMask(false);
- glDepthFunc(GL_LEQUAL);
+ glDepthFunc(GL_LESS);
s->maxDepth = old_state->maxDepth;
} else {
d->regenerateDepthClip();
@@ -1801,8 +1801,8 @@ QOpenGL2PaintEngineState::QOpenGL2PaintEngineState()
needsDepthBufferClear = true;
depthTestEnabled = false;
scissorTestEnabled = false;
- currentDepth = -0.5f;
- maxDepth = 0.5f;
+ currentDepth = 1;
+ maxDepth = 4;
canRestoreClip = true;
hasRectangleClip = false;
}
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index 58fcde1..552e390 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -82,8 +82,8 @@ public:
bool depthTestEnabled;
bool scissorTestEnabled;
- qreal currentDepth;
- qreal maxDepth;
+ uint maxDepth;
+ uint currentDepth;
bool canRestoreClip;
QRect rectangleClip;
@@ -230,13 +230,26 @@ public:
QGLEngineShaderManager* shaderManager;
- void writeClip(const QVectorPath &path, float depth);
+ void writeClip(const QVectorPath &path, uint depth);
void updateDepthScissorTest();
void setScissor(const QRect &rect);
void regenerateDepthClip();
void systemStateChanged();
uint use_system_clip : 1;
+ static inline GLfloat rawDepth(uint depth)
+ {
+ // assume at least 16 bits in the depth buffer, and
+ // use 2^15 depth levels to be safe with regard to
+ // rounding issues etc
+ return depth * (1.0f / GLfloat((1 << 15) - 1));
+ }
+
+ static inline GLfloat normalizedDeviceDepth(uint depth)
+ {
+ return 2.0f * rawDepth(depth) - 1.0f;
+ }
+
uint location(QGLEngineShaderManager::Uniform uniform)
{
return shaderManager->getUniformLocation(uniform);
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index f8a9196..8b7674e 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1273,6 +1273,14 @@ bool operator!=(const QGLFormat& a, const QGLFormat& b)
/*****************************************************************************
QGLContext implementation
*****************************************************************************/
+QGLContextPrivate::~QGLContextPrivate()
+{
+ if (!group->m_refs.deref()) {
+ Q_ASSERT(group->context() == q_ptr);
+ delete group;
+ }
+}
+
void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
{
Q_Q(QGLContext);
@@ -4861,40 +4869,40 @@ bool QGLDrawable::autoFillBackground() const
bool QGLShareRegister::checkSharing(const QGLContext *context1, const QGLContext *context2) {
- bool sharing = (context1 && context2 && context1->d_ptr->groupResources == context2->d_ptr->groupResources);
+ bool sharing = (context1 && context2 && context1->d_ptr->group == context2->d_ptr->group);
return sharing;
}
void QGLShareRegister::addShare(const QGLContext *context, const QGLContext *share) {
Q_ASSERT(context && share);
- if (context->d_ptr->groupResources == share->d_ptr->groupResources)
+ if (context->d_ptr->group == share->d_ptr->group)
return;
// Make sure 'context' is not already shared with another group of contexts.
- Q_ASSERT(reg.find(context->d_ptr->groupResources) == reg.end());
- Q_ASSERT(context->d_ptr->groupResources->refs == 1);
+ Q_ASSERT(reg.find(context->d_ptr->group) == reg.end());
+ Q_ASSERT(context->d_ptr->group->m_refs == 1);
// Free 'context' group resources and make it use the same resources as 'share'.
- delete context->d_ptr->groupResources;
- context->d_ptr->groupResources = share->d_ptr->groupResources;
- context->d_ptr->groupResources->refs.ref();
+ delete context->d_ptr->group;
+ context->d_ptr->group = share->d_ptr->group;
+ context->d_ptr->group->m_refs.ref();
// Maintain a list of all the contexts in each group of sharing contexts.
- SharingHash::iterator it = reg.find(share->d_ptr->groupResources);
+ SharingHash::iterator it = reg.find(share->d_ptr->group);
if (it == reg.end())
- it = reg.insert(share->d_ptr->groupResources, ContextList() << share);
+ it = reg.insert(share->d_ptr->group, ContextList() << share);
it.value() << context;
}
QList<const QGLContext *> QGLShareRegister::shares(const QGLContext *context) {
- SharingHash::const_iterator it = reg.find(context->d_ptr->groupResources);
+ SharingHash::const_iterator it = reg.find(context->d_ptr->group);
if (it == reg.end())
return ContextList();
return it.value();
}
void QGLShareRegister::removeShare(const QGLContext *context) {
- SharingHash::iterator it = reg.find(context->d_ptr->groupResources);
+ SharingHash::iterator it = reg.find(context->d_ptr->group);
if (it == reg.end())
return;
@@ -4902,6 +4910,10 @@ void QGLShareRegister::removeShare(const QGLContext *context) {
Q_ASSERT(count == 1);
Q_UNUSED(count);
+ // Update context group representative.
+ if (context->d_ptr->group->m_context == context)
+ context->d_ptr->group->m_context = it.value().first();
+
Q_ASSERT(it.value().size() != 0);
if (it.value().size() == 1)
reg.erase(it);
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 2fd3070..a39c52c 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -193,11 +193,24 @@ public:
#endif
};
-struct QGLContextGroupResources
+// QGLContextPrivate has the responsibility of creating context groups.
+// QGLContextPrivate and QGLShareRegister will both maintain the reference counter and destroy
+// context groups when needed.
+// QGLShareRegister has the responsibility of keeping the context pointer up to date.
+class QGLContextGroup
{
- QGLContextGroupResources() : refs(1) { }
- QGLExtensionFuncs extensionFuncs;
- QAtomicInt refs;
+public:
+ QGLExtensionFuncs &extensionFuncs() {return m_extensionFuncs;}
+ const QGLContext *context() const {return m_context;}
+private:
+ QGLContextGroup(const QGLContext *context) : m_context(context), m_refs(1) { }
+
+ QGLExtensionFuncs m_extensionFuncs;
+ const QGLContext *m_context; // context group's representative
+ QAtomicInt m_refs;
+
+ friend class QGLShareRegister;
+ friend class QGLContextPrivate;
};
class QGLTexture;
@@ -206,8 +219,8 @@ class QGLContextPrivate
{
Q_DECLARE_PUBLIC(QGLContext)
public:
- explicit QGLContextPrivate(QGLContext *context) : internal_context(false), q_ptr(context) {groupResources = new QGLContextGroupResources;}
- ~QGLContextPrivate() {if (!groupResources->refs.deref()) delete groupResources;}
+ explicit QGLContextPrivate(QGLContext *context) : internal_context(false), q_ptr(context) {group = new QGLContextGroup(context);}
+ ~QGLContextPrivate();
QGLTexture *bindTexture(const QImage &image, GLenum target, GLint format,
QGLContext::BindOptions options);
QGLTexture *bindTexture(const QImage &image, GLenum target, GLint format, const qint64 key,
@@ -269,23 +282,23 @@ public:
QGLContext *q_ptr;
QGLFormat::OpenGLVersionFlags version_flags;
- QGLContextGroupResources *groupResources;
+ QGLContextGroup *group;
GLint max_texture_size;
GLuint current_fbo;
QPaintEngine *active_engine;
- static inline QGLContextGroupResources *qt_get_context_group(const QGLContext *ctx) { return ctx->d_ptr->groupResources; }
+ static inline QGLContextGroup *contextGroup(const QGLContext *ctx) { return ctx->d_ptr->group; }
#ifdef Q_WS_WIN
- static inline QGLExtensionFuncs& qt_get_extension_funcs(const QGLContext *ctx) { return ctx->d_ptr->groupResources->extensionFuncs; }
- static inline QGLExtensionFuncs& qt_get_extension_funcs(QGLContextGroupResources *ctx) { return ctx->extensionFuncs; }
+ static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *ctx) { return ctx->d_ptr->group->extensionFuncs(); }
+ static inline QGLExtensionFuncs& extensionFuncs(QGLContextGroup *ctx) { return ctx->extensionFuncs(); }
#endif
#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
static QGLExtensionFuncs qt_extensionFuncs;
- static inline QGLExtensionFuncs& qt_get_extension_funcs(const QGLContext *) { return qt_extensionFuncs; }
- static inline QGLExtensionFuncs& qt_get_extension_funcs(QGLContextGroupResources *ctx) { return qt_extensionFuncs; }
+ static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *) { return qt_extensionFuncs; }
+ static inline QGLExtensionFuncs& extensionFuncs(QGLContextGroup *) { return qt_extensionFuncs; }
#endif
QPixmapFilter *createPixmapFilter(int type) const;
@@ -402,9 +415,9 @@ public:
QList<const QGLContext *> shares(const QGLContext *context);
void removeShare(const QGLContext *context);
private:
- // Use a context's 'groupResources' pointer to uniquely identify a group.
+ // Use a context's 'group' pointer to uniquely identify a group.
typedef QList<const QGLContext *> ContextList;
- typedef QHash<const QGLContextGroupResources *, ContextList> SharingHash;
+ typedef QHash<const QGLContextGroup *, ContextList> SharingHash;
SharingHash reg;
};
diff --git a/src/opengl/qglextensions.cpp b/src/opengl/qglextensions.cpp
index e1ab6a4..a883c42 100644
--- a/src/opengl/qglextensions.cpp
+++ b/src/opengl/qglextensions.cpp
@@ -175,10 +175,10 @@ bool qt_resolve_glsl_extensions(QGLContext *ctx)
#if defined(QT_OPENGL_ES_2)
// The GLSL shader functions are always present in OpenGL/ES 2.0.
// The only exceptions are glGetProgramBinaryOES and glProgramBinaryOES.
- if (!QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glslResolved) {
+ if (!QGLContextPrivate::extensionFuncs(ctx).qt_glslResolved) {
glGetProgramBinaryOES = (_glGetProgramBinaryOES) ctx->getProcAddress(QLatin1String("glGetProgramBinaryOES"));
glProgramBinaryOES = (_glProgramBinaryOES) ctx->getProcAddress(QLatin1String("glProgramBinaryOES"));
- QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glslResolved = true;
+ QGLContextPrivate::extensionFuncs(ctx).qt_glslResolved = true;
}
return true;
#else
diff --git a/src/opengl/qglextensions_p.h b/src/opengl/qglextensions_p.h
index 60a4173..8839f60 100644
--- a/src/opengl/qglextensions_p.h
+++ b/src/opengl/qglextensions_p.h
@@ -605,114 +605,114 @@ struct QGLExtensionFuncs
#if !defined(QT_OPENGL_ES_2)
-#define glProgramStringARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glProgramStringARB
-#define glBindProgramARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBindProgramARB
-#define glDeleteProgramsARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteProgramsARB
-#define glGenProgramsARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGenProgramsARB
-#define glProgramLocalParameter4fvARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glProgramLocalParameter4fvARB
+#define glProgramStringARB QGLContextPrivate::extensionFuncs(ctx).qt_glProgramStringARB
+#define glBindProgramARB QGLContextPrivate::extensionFuncs(ctx).qt_glBindProgramARB
+#define glDeleteProgramsARB QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteProgramsARB
+#define glGenProgramsARB QGLContextPrivate::extensionFuncs(ctx).qt_glGenProgramsARB
+#define glProgramLocalParameter4fvARB QGLContextPrivate::extensionFuncs(ctx).qt_glProgramLocalParameter4fvARB
-#define glActiveStencilFaceEXT QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glActiveStencilFaceEXT
+#define glActiveStencilFaceEXT QGLContextPrivate::extensionFuncs(ctx).qt_glActiveStencilFaceEXT
-#define glMultiTexCoord4f QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glMultiTexCoord4f
+#define glMultiTexCoord4f QGLContextPrivate::extensionFuncs(ctx).qt_glMultiTexCoord4f
-#define glActiveTexture QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glActiveTexture
+#define glActiveTexture QGLContextPrivate::extensionFuncs(ctx).qt_glActiveTexture
#endif // !defined(QT_OPENGL_ES_2)
// FBOs
#if !defined(QT_OPENGL_ES_2)
-#define glIsRenderbuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glIsRenderbuffer
-#define glBindRenderbuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBindRenderbuffer
-#define glDeleteRenderbuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteRenderbuffers
-#define glGenRenderbuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGenRenderbuffers
-#define glRenderbufferStorage QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glRenderbufferStorage
-#define glGetRenderbufferParameteriv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetRenderbufferParameteriv
-#define glIsFramebuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glIsFramebuffer
-#define glBindFramebuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBindFramebuffer
-#define glDeleteFramebuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteFramebuffers
-#define glGenFramebuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGenFramebuffers
-#define glCheckFramebufferStatus QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glCheckFramebufferStatus
-#define glFramebufferTexture2D QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glFramebufferTexture2D
-#define glFramebufferRenderbuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glFramebufferRenderbuffer
-#define glGetFramebufferAttachmentParameteriv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetFramebufferAttachmentParameteriv
-#define glGenerateMipmap QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGenerateMipmap
+#define glIsRenderbuffer QGLContextPrivate::extensionFuncs(ctx).qt_glIsRenderbuffer
+#define glBindRenderbuffer QGLContextPrivate::extensionFuncs(ctx).qt_glBindRenderbuffer
+#define glDeleteRenderbuffers QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteRenderbuffers
+#define glGenRenderbuffers QGLContextPrivate::extensionFuncs(ctx).qt_glGenRenderbuffers
+#define glRenderbufferStorage QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorage
+#define glGetRenderbufferParameteriv QGLContextPrivate::extensionFuncs(ctx).qt_glGetRenderbufferParameteriv
+#define glIsFramebuffer QGLContextPrivate::extensionFuncs(ctx).qt_glIsFramebuffer
+#define glBindFramebuffer QGLContextPrivate::extensionFuncs(ctx).qt_glBindFramebuffer
+#define glDeleteFramebuffers QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteFramebuffers
+#define glGenFramebuffers QGLContextPrivate::extensionFuncs(ctx).qt_glGenFramebuffers
+#define glCheckFramebufferStatus QGLContextPrivate::extensionFuncs(ctx).qt_glCheckFramebufferStatus
+#define glFramebufferTexture2D QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferTexture2D
+#define glFramebufferRenderbuffer QGLContextPrivate::extensionFuncs(ctx).qt_glFramebufferRenderbuffer
+#define glGetFramebufferAttachmentParameteriv QGLContextPrivate::extensionFuncs(ctx).qt_glGetFramebufferAttachmentParameteriv
+#define glGenerateMipmap QGLContextPrivate::extensionFuncs(ctx).qt_glGenerateMipmap
#endif // QT_OPENGL_ES_2
-#define glBlitFramebufferEXT QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBlitFramebufferEXT
-#define glRenderbufferStorageMultisampleEXT QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glRenderbufferStorageMultisampleEXT
+#define glBlitFramebufferEXT QGLContextPrivate::extensionFuncs(ctx).qt_glBlitFramebufferEXT
+#define glRenderbufferStorageMultisampleEXT QGLContextPrivate::extensionFuncs(ctx).qt_glRenderbufferStorageMultisampleEXT
// Buffer objects
#if !defined(QT_OPENGL_ES_2)
-#define glBindBuffer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBindBuffer
-#define glDeleteBuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteBuffers
-#define glGenBuffers QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGenBuffers
-#define glBufferData QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBufferData
+#define glBindBuffer QGLContextPrivate::extensionFuncs(ctx).qt_glBindBuffer
+#define glDeleteBuffers QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteBuffers
+#define glGenBuffers QGLContextPrivate::extensionFuncs(ctx).qt_glGenBuffers
+#define glBufferData QGLContextPrivate::extensionFuncs(ctx).qt_glBufferData
#endif
-#define glMapBufferARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glMapBufferARB
-#define glUnmapBufferARB QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUnmapBufferARB
+#define glMapBufferARB QGLContextPrivate::extensionFuncs(ctx).qt_glMapBufferARB
+#define glUnmapBufferARB QGLContextPrivate::extensionFuncs(ctx).qt_glUnmapBufferARB
// GLSL
#if !defined(QT_OPENGL_ES_2)
-#define glCreateShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glCreateShader
-#define glShaderSource QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glShaderSource
-#define glShaderBinary QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glShaderBinary
-#define glCompileShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glCompileShader
-#define glDeleteShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteShader
-#define glIsShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glIsShader
-
-#define glCreateProgram QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glCreateProgram
-#define glAttachShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glAttachShader
-#define glDetachShader QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDetachShader
-#define glLinkProgram QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glLinkProgram
-#define glUseProgram QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUseProgram
-#define glDeleteProgram QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDeleteProgram
-#define glIsProgram QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glIsProgram
-
-#define glGetShaderInfoLog QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetShaderInfoLog
-#define glGetShaderiv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetShaderiv
-#define glGetShaderSource QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetShaderSource
-#define glGetProgramiv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetProgramiv
-#define glGetProgramInfoLog QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetProgramInfoLog
-
-#define glGetUniformLocation QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetUniformLocation
-#define glUniform4fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform4fv
-#define glUniform3fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform3fv
-#define glUniform2fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform2fv
-#define glUniform1fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform1fv
-#define glUniform1i QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform1i
-#define glUniform1iv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniform1iv
-#define glUniformMatrix2fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix2fv
-#define glUniformMatrix3fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix3fv
-#define glUniformMatrix4fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix4fv
-#define glUniformMatrix2x3fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix2x3fv
-#define glUniformMatrix2x4fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix2x4fv
-#define glUniformMatrix3x2fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix3x2fv
-#define glUniformMatrix3x4fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix3x4fv
-#define glUniformMatrix4x2fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix4x2fv
-#define glUniformMatrix4x3fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glUniformMatrix4x3fv
-
-#define glBindAttribLocation QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glBindAttribLocation
-#define glGetAttribLocation QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetAttribLocation
-#define glVertexAttrib1fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glVertexAttrib1fv
-#define glVertexAttrib2fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glVertexAttrib2fv
-#define glVertexAttrib3fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glVertexAttrib3fv
-#define glVertexAttrib4fv QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glVertexAttrib4fv
-#define glVertexAttribPointer QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glVertexAttribPointer
-#define glDisableVertexAttribArray QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glDisableVertexAttribArray
-#define glEnableVertexAttribArray QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glEnableVertexAttribArray
+#define glCreateShader QGLContextPrivate::extensionFuncs(ctx).qt_glCreateShader
+#define glShaderSource QGLContextPrivate::extensionFuncs(ctx).qt_glShaderSource
+#define glShaderBinary QGLContextPrivate::extensionFuncs(ctx).qt_glShaderBinary
+#define glCompileShader QGLContextPrivate::extensionFuncs(ctx).qt_glCompileShader
+#define glDeleteShader QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteShader
+#define glIsShader QGLContextPrivate::extensionFuncs(ctx).qt_glIsShader
+
+#define glCreateProgram QGLContextPrivate::extensionFuncs(ctx).qt_glCreateProgram
+#define glAttachShader QGLContextPrivate::extensionFuncs(ctx).qt_glAttachShader
+#define glDetachShader QGLContextPrivate::extensionFuncs(ctx).qt_glDetachShader
+#define glLinkProgram QGLContextPrivate::extensionFuncs(ctx).qt_glLinkProgram
+#define glUseProgram QGLContextPrivate::extensionFuncs(ctx).qt_glUseProgram
+#define glDeleteProgram QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteProgram
+#define glIsProgram QGLContextPrivate::extensionFuncs(ctx).qt_glIsProgram
+
+#define glGetShaderInfoLog QGLContextPrivate::extensionFuncs(ctx).qt_glGetShaderInfoLog
+#define glGetShaderiv QGLContextPrivate::extensionFuncs(ctx).qt_glGetShaderiv
+#define glGetShaderSource QGLContextPrivate::extensionFuncs(ctx).qt_glGetShaderSource
+#define glGetProgramiv QGLContextPrivate::extensionFuncs(ctx).qt_glGetProgramiv
+#define glGetProgramInfoLog QGLContextPrivate::extensionFuncs(ctx).qt_glGetProgramInfoLog
+
+#define glGetUniformLocation QGLContextPrivate::extensionFuncs(ctx).qt_glGetUniformLocation
+#define glUniform4fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform4fv
+#define glUniform3fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform3fv
+#define glUniform2fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform2fv
+#define glUniform1fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform1fv
+#define glUniform1i QGLContextPrivate::extensionFuncs(ctx).qt_glUniform1i
+#define glUniform1iv QGLContextPrivate::extensionFuncs(ctx).qt_glUniform1iv
+#define glUniformMatrix2fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix2fv
+#define glUniformMatrix3fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix3fv
+#define glUniformMatrix4fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix4fv
+#define glUniformMatrix2x3fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix2x3fv
+#define glUniformMatrix2x4fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix2x4fv
+#define glUniformMatrix3x2fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix3x2fv
+#define glUniformMatrix3x4fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix3x4fv
+#define glUniformMatrix4x2fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix4x2fv
+#define glUniformMatrix4x3fv QGLContextPrivate::extensionFuncs(ctx).qt_glUniformMatrix4x3fv
+
+#define glBindAttribLocation QGLContextPrivate::extensionFuncs(ctx).qt_glBindAttribLocation
+#define glGetAttribLocation QGLContextPrivate::extensionFuncs(ctx).qt_glGetAttribLocation
+#define glVertexAttrib1fv QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib1fv
+#define glVertexAttrib2fv QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib2fv
+#define glVertexAttrib3fv QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib3fv
+#define glVertexAttrib4fv QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttrib4fv
+#define glVertexAttribPointer QGLContextPrivate::extensionFuncs(ctx).qt_glVertexAttribPointer
+#define glDisableVertexAttribArray QGLContextPrivate::extensionFuncs(ctx).qt_glDisableVertexAttribArray
+#define glEnableVertexAttribArray QGLContextPrivate::extensionFuncs(ctx).qt_glEnableVertexAttribArray
#else // QT_OPENGL_ES_2
-#define glGetProgramBinaryOES QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glGetProgramBinaryOES
-#define glProgramBinaryOES QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glProgramBinaryOES
+#define glGetProgramBinaryOES QGLContextPrivate::extensionFuncs(ctx).qt_glGetProgramBinaryOES
+#define glProgramBinaryOES QGLContextPrivate::extensionFuncs(ctx).qt_glProgramBinaryOES
#endif // QT_OPENGL_ES_2
#if !defined(QT_OPENGL_ES_2)
-#define glStencilOpSeparate QGLContextPrivate::qt_get_extension_funcs(ctx).qt_glStencilOpSeparate
+#define glStencilOpSeparate QGLContextPrivate::extensionFuncs(ctx).qt_glStencilOpSeparate
#endif
#if defined(QT_OPENGL_ES_2)
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp
index fe967e7..8fd113a 100644
--- a/src/opengl/qglframebufferobject.cpp
+++ b/src/opengl/qglframebufferobject.cpp
@@ -262,7 +262,7 @@ GLenum QGLFramebufferObjectFormat::internalFormat() const
class QGLFramebufferObjectPrivate
{
public:
- QGLFramebufferObjectPrivate() : depth_stencil_buffer(0), valid(false), bound(false), ctx(0), previous_fbo(0) {}
+ QGLFramebufferObjectPrivate() : depth_stencil_buffer(0), valid(false), bound(false), ctx(0), previous_fbo(0), engine(0) {}
~QGLFramebufferObjectPrivate() {}
void init(const QSize& sz, QGLFramebufferObject::Attachment attachment,
@@ -280,6 +280,7 @@ public:
QGLFramebufferObject::Attachment fbo_attachment;
QGLContext *ctx; // for Windows extension ptrs
GLuint previous_fbo;
+ mutable QPaintEngine *engine;
};
bool QGLFramebufferObjectPrivate::checkFramebufferStatus() const
@@ -723,6 +724,8 @@ QGLFramebufferObject::~QGLFramebufferObject()
Q_D(QGLFramebufferObject);
QGL_FUNC_CONTEXT;
+ delete d->engine;
+
if (isValid()
&& (d->ctx == QGLContext::currentContext()
|| qgl_share_reg()->checkSharing(d->ctx, QGLContext::currentContext())))
@@ -872,9 +875,22 @@ QImage QGLFramebufferObject::toImage() const
if (!d->valid)
return QImage();
- const_cast<QGLFramebufferObject *>(this)->bind();
+ // qt_gl_read_framebuffer doesn't work on a multisample FBO
+ if (format().samples() != 0) {
+ QGLFramebufferObject temp(size());
+
+ QRect rect(QPoint(0, 0), size());
+ blitFramebuffer(&temp, rect, const_cast<QGLFramebufferObject *>(this), rect);
+
+ return temp.toImage();
+ }
+
+ bool wasBound = isBound();
+ if (!wasBound)
+ const_cast<QGLFramebufferObject *>(this)->bind();
QImage image = qt_gl_read_framebuffer(d->size, d->ctx->format().alpha(), true);
- const_cast<QGLFramebufferObject *>(this)->release();
+ if (!wasBound)
+ const_cast<QGLFramebufferObject *>(this)->release();
return image;
}
@@ -890,16 +906,32 @@ Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_buffer_engine)
/*! \reimp */
QPaintEngine *QGLFramebufferObject::paintEngine() const
{
-#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_1_CL)
- return qt_buffer_engine();
-#elif defined(QT_OPENGL_ES_2)
- return qt_buffer_2_engine();
-#else
Q_D(const QGLFramebufferObject);
- if (qt_gl_preferGL2Engine())
- return qt_buffer_2_engine();
- else
- return qt_buffer_engine();
+ if (d->engine)
+ return d->engine;
+
+#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)
+#if !defined (QT_OPENGL_ES_2)
+ if (qt_gl_preferGL2Engine()) {
+#endif
+ QPaintEngine *engine = qt_buffer_2_engine();
+ if (engine->isActive() && engine->paintDevice() != this) {
+ d->engine = new QGL2PaintEngineEx;
+ return d->engine;
+ }
+ return engine;
+#if !defined (QT_OPENGL_ES_2)
+ }
+#endif
+#endif
+
+#if !defined(QT_OPENGL_ES_2)
+ QPaintEngine *engine = qt_buffer_engine();
+ if (engine->isActive() && engine->paintDevice() != this) {
+ d->engine = new QOpenGLPaintEngine;
+ return d->engine;
+ }
+ return engine;
#endif
}
diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp
index 808038b..c51ccc7 100644
--- a/src/opengl/qglpixmapfilter.cpp
+++ b/src/opengl/qglpixmapfilter.cpp
@@ -119,6 +119,8 @@ private:
mutable QSize m_textureSize;
+ mutable bool m_horizontalBlur;
+
QGLShaderProgram *m_program;
};
@@ -336,46 +338,37 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBindTexture(GL_TEXTURE_2D, 0);
- QGL2PaintEngineEx *engine = static_cast<QGL2PaintEngineEx *>(painter->paintEngine());
-
- painter->save();
-
- // ensure GL_LINEAR filtering is used
- painter->setRenderHint(QPainter::SmoothPixmapTransform);
-
// prepare for updateUniforms
m_textureSize = src.size();
- // first pass, to fbo
- fbo->bind();
+ // horizontal pass, to pixmap
+ m_horizontalBlur = true;
+
+ QPainter fboPainter(fbo);
+
if (src.hasAlphaChannel()) {
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
}
- filter->setOnPainter(painter);
-
- QTransform transform = engine->state()->matrix;
- if (!transform.isIdentity()) {
- engine->state()->matrix = QTransform();
- engine->transformChanged();
- }
-
- engine->drawPixmap(src.rect().translated(0, painter->device()->height() - fbo->height()),
- src, src.rect());
+ // ensure GL_LINEAR filtering is used
+ fboPainter.setRenderHint(QPainter::SmoothPixmapTransform);
+ filter->setOnPainter(&fboPainter);
+ fboPainter.drawPixmap(0, 0, src);
+ filter->removeFromPainter(&fboPainter);
+ fboPainter.end();
- if (!transform.isIdentity()) {
- engine->state()->matrix = transform;
- engine->transformChanged();
- }
+ QGL2PaintEngineEx *engine = static_cast<QGL2PaintEngineEx *>(painter->paintEngine());
- fbo->release();
+ // vertical pass, to painter
+ m_horizontalBlur = false;
- // second pass, to widget
- m_program->setUniformValue("delta", 0.0, 1.0);
+ painter->save();
+ // ensure GL_LINEAR filtering is used
+ painter->setRenderHint(QPainter::SmoothPixmapTransform);
+ filter->setOnPainter(painter);
engine->drawTexture(src.rect().translated(pos.x(), pos.y()), fbo->texture(), fbo->size(), src.rect().translated(0, fbo->height() - src.height()));
filter->removeFromPainter(painter);
-
painter->restore();
qgl_fbo_pool()->release(fbo);
@@ -386,7 +379,11 @@ bool QGLPixmapBlurFilter::processGL(QPainter *painter, const QPointF &pos, const
void QGLPixmapBlurFilter::setUniforms(QGLShaderProgram *program)
{
program->setUniformValue("invTextureSize", 1.0 / m_textureSize.width(), 1.0 / m_textureSize.height());
- program->setUniformValue("delta", 1.0, 0.0);
+
+ if (m_horizontalBlur)
+ program->setUniformValue("delta", 1.0, 0.0);
+ else
+ program->setUniformValue("delta", 0.0, 1.0);
m_program = program;
}
diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp
index c9bfd08..56b55d0 100644
--- a/src/opengl/qglshaderprogram.cpp
+++ b/src/opengl/qglshaderprogram.cpp
@@ -194,7 +194,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \enum QGLShader::ShaderType
+ \enum QGLShader::ShaderTypeBits
This enum specifies the type of QGLShader that is being created.
\value VertexShader Vertex shader written in the OpenGL Shading Language (GLSL).
@@ -246,10 +246,10 @@ QT_BEGIN_NAMESPACE
#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
#endif
-inline bool qt_check_sharing_with_current_context(QGLContextGroupResources *group)
+inline bool qt_check_sharing_with_current_context(QGLContextGroup *group)
{
const QGLContext *context = QGLContext::currentContext();
- return context && QGLContextPrivate::qt_get_context_group(context) == group;
+ return context && QGLContextPrivate::contextGroup(context) == group;
}
class QGLShaderPrivate
@@ -265,7 +265,7 @@ public:
{
}
- QGLContextGroupResources *ctx;
+ QGLContextGroup *ctx;
GLuint shader;
QGLShader::ShaderType shaderType;
bool compiled;
@@ -284,7 +284,7 @@ bool QGLShaderPrivate::create(const QGLContext *context)
context = QGLContext::currentContext();
if (!context)
return false;
- ctx = QGLContextPrivate::qt_get_context_group(context);
+ ctx = QGLContextPrivate::contextGroup(context);
if (isPartial)
return true;
if (qt_resolve_glsl_extensions(const_cast<QGLContext *>(context))) {
@@ -367,7 +367,7 @@ QGLShader::QGLShader
d = new QGLShaderPrivate(type);
if (d->create(QGLContext::currentContext()) && !compileFile(fileName)) {
if (d->shader) {
- QGLContextGroupResources *ctx = d->ctx;
+ QGLContextGroup *ctx = d->ctx;
glDeleteShader(d->shader);
}
d->shader = 0;
@@ -421,7 +421,7 @@ QGLShader::QGLShader
#endif
if (d->create(context) && !compileFile(fileName)) {
if (d->shader) {
- QGLContextGroupResources *ctx = d->ctx;
+ QGLContextGroup *ctx = d->ctx;
glDeleteShader(d->shader);
}
d->shader = 0;
@@ -436,7 +436,7 @@ QGLShader::QGLShader
QGLShader::~QGLShader()
{
if (d->shader) {
- QGLContextGroupResources *ctx = d->ctx;
+ QGLContextGroup *ctx = d->ctx;
#ifndef QT_NO_DEBUG
if (!qt_check_sharing_with_current_context(ctx))
qWarning("QGLShader::~QGLShader: Shader is not associated with current context.");
@@ -501,6 +501,25 @@ bool QGLShader::compile(const char *source)
return d->compile(this);
} else if (d->shader) {
QVarLengthArray<const char *> src;
+ int headerLen = 0;
+ while (source && source[headerLen] == '#') {
+ // Skip #version and #extension directives at the start of
+ // the shader code. We need to insert the qualifierDefines
+ // and redefineHighp just after them.
+ if (qstrncmp(source + headerLen, "#version", 8) != 0 &&
+ qstrncmp(source + headerLen, "#extension", 10) != 0) {
+ break;
+ }
+ while (source[headerLen] != '\0' && source[headerLen] != '\n')
+ ++headerLen;
+ if (source[headerLen] == '\n')
+ ++headerLen;
+ }
+ QByteArray header;
+ if (headerLen > 0) {
+ header = QByteArray(source, headerLen);
+ src.append(header.constData());
+ }
#ifdef QGL_DEFINE_QUALIFIERS
src.append(qualifierDefines);
#endif
@@ -509,8 +528,8 @@ bool QGLShader::compile(const char *source)
d->shaderType == PartialFragmentShader)
src.append(redefineHighp);
#endif
- src.append(source);
- QGLContextGroupResources *ctx = d->ctx;
+ src.append(source + headerLen);
+ QGLContextGroup *ctx = d->ctx;
glShaderSource(d->shader, src.size(), src.data(), 0);
return d->compile(this);
} else {
@@ -593,7 +612,7 @@ bool QGLShader::compileFile(const QString& fileName)
*/
bool QGLShader::setShaderBinary(GLenum format, const void *binary, int length)
{
- QGLContextGroupResources *ctx = d->ctx;
+ QGLContextGroup *ctx = d->ctx;
#ifndef QT_NO_DEBUG
if (!qt_check_sharing_with_current_context(ctx)) {
qWarning("QGLShader::setShaderBinary: Shader is not associated with current context.");
@@ -633,7 +652,7 @@ bool QGLShader::setShaderBinary(GLenum format, const void *binary, int length)
bool QGLShader::setShaderBinary
(QGLShader& otherShader, GLenum format, const void *binary, int length)
{
- QGLContextGroupResources *ctx = d->ctx;
+ QGLContextGroup *ctx = d->ctx;
#ifndef QT_NO_DEBUG
if (!qt_check_sharing_with_current_context(ctx)) {
qWarning("QGLShader::setShaderBinary: Shader is not associated with current context.");
@@ -699,7 +718,7 @@ QByteArray QGLShader::sourceCode() const
if (!d->shader)
return QByteArray();
GLint size = 0;
- QGLContextGroupResources *ctx = d->ctx;
+ QGLContextGroup *ctx = d->ctx;
glGetShaderiv(d->shader, GL_SHADER_SOURCE_LENGTH, &size);
if (size <= 0)
return QByteArray();
@@ -749,7 +768,7 @@ class QGLShaderProgramPrivate
{
public:
QGLShaderProgramPrivate(const QGLContext *context)
- : ctx(context ? QGLContextPrivate::qt_get_context_group(context) : 0)
+ : ctx(context ? QGLContextPrivate::contextGroup(context) : 0)
, program(0)
, linked(false)
, inited(false)
@@ -761,7 +780,7 @@ public:
}
~QGLShaderProgramPrivate();
- QGLContextGroupResources *ctx;
+ QGLContextGroup *ctx;
GLuint program;
bool linked;
bool inited;
@@ -832,7 +851,7 @@ bool QGLShaderProgram::init()
if (!context)
return false;
if (!d->ctx)
- d->ctx = QGLContextPrivate::qt_get_context_group(context);
+ d->ctx = QGLContextPrivate::contextGroup(context);
#ifndef QT_NO_DEBUG
else if (!qt_check_sharing_with_current_context(d->ctx)) {
qWarning("QGLShaderProgram: Shader program is not associated with current context.");
@@ -840,7 +859,7 @@ bool QGLShaderProgram::init()
}
#endif
if (qt_resolve_glsl_extensions(const_cast<QGLContext *>(context))) {
- QGLContextGroupResources *ctx = d->ctx;
+ QGLContextGroup *ctx = d->ctx;
d->program = glCreateProgram();
if (!(d->program)) {
qWarning() << "QGLShaderProgram: could not create shader program";
@@ -886,7 +905,7 @@ bool QGLShaderProgram::addShader(QGLShader *shader)
if (!shader->d->isPartial) {
if (!shader->d->shader)
return false;
- QGLContextGroupResources *ctx = d->ctx;
+ QGLContextGroup *ctx = d->ctx;
glAttachShader(d->program, shader->d->shader);
} else {
d->hasPartialShaders = true;
@@ -999,7 +1018,7 @@ bool QGLShaderProgram::addShaderFromFile
void QGLShaderProgram::removeShader(QGLShader *shader)
{
if (d->program && shader && shader->d->shader) {
- QGLContextGroupResources *ctx = d->ctx;
+ QGLContextGroup *ctx = d->ctx;
#ifndef QT_NO_DEBUG
if (!qt_check_sharing_with_current_context(ctx))
qWarning("QGLShaderProgram::removeShader: Program is not associated with current context.");
@@ -1037,7 +1056,7 @@ QList<QGLShader *> QGLShaderProgram::shaders() const
void QGLShaderProgram::removeAllShaders()
{
d->removingShaders = true;
- QGLContextGroupResources *ctx = d->ctx;
+ QGLContextGroup *ctx = d->ctx;
#ifndef QT_NO_DEBUG
if (!qt_check_sharing_with_current_context(ctx))
qWarning("QGLShaderProgram::removeAllShaders: Program is not associated with current context.");
@@ -1094,6 +1113,12 @@ QByteArray QGLShaderProgram::programBinary(int *format) const
if (!isLinked())
return QByteArray();
+ QGLContextGroup *ctx = d->ctx;
+#ifndef QT_NO_DEBUG
+ if (!qt_check_sharing_with_current_context(ctx))
+ qWarning("QGLShaderProgram::programBinary: Program is not associated with current context.");
+#endif
+
// Get the length of the binary data, bailing out if there is none.
GLint length = 0;
glGetProgramiv(d->program, GL_PROGRAM_BINARY_LENGTH_OES, &length);
@@ -1124,6 +1149,12 @@ QByteArray QGLShaderProgram::programBinary(int *format) const
bool QGLShaderProgram::setProgramBinary(int format, const QByteArray& binary)
{
#if defined(QT_OPENGL_ES_2)
+ QGLContextGroup *ctx = d->ctx;
+#ifndef QT_NO_DEBUG
+ if (!qt_check_sharing_with_current_context(ctx))
+ qWarning("QGLShaderProgram::setProgramBinary: Program is not associated with current context.");
+#endif
+
// Load the binary and check that it was linked correctly.
glProgramBinaryOES(d->program, (GLenum)format,
binary.constData(), binary.size());
@@ -1193,7 +1224,7 @@ bool QGLShaderProgram::link()
{
if (!d->program)
return false;
- QGLContextGroupResources *ctx = d->ctx;
+ QGLContextGroup *ctx = d->ctx;
#ifndef QT_NO_DEBUG
if (!qt_check_sharing_with_current_context(ctx)) {
qWarning("QGLShaderProgram::link: Program is not associated with current context.");
@@ -1303,7 +1334,7 @@ bool QGLShaderProgram::enable()
return false;
if (!d->linked && !link())
return false;
- QGLContextGroupResources *ctx = d->ctx;
+ QGLContextGroup *ctx = d->ctx;
#ifndef QT_NO_DEBUG
if (!qt_check_sharing_with_current_context(ctx)) {
qWarning("QGLShaderProgram::enable: Program is not associated with current context.");
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp
index fe77fd1..f207ebc 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp
@@ -41,7 +41,7 @@
#include "qdirectfbkeyboard.h"
-#ifndef QT_NO_DIRECTFB
+#ifndef QT_NO_QWS_DIRECTFB
#include "qdirectfbscreen.h"
#include <qobject.h>
@@ -53,6 +53,8 @@
#include <fcntl.h>
#include <errno.h>
+QT_BEGIN_NAMESPACE
+
class KeyMap : public QHash<DFBInputDeviceKeySymbol, Qt::Key>
{
public:
@@ -429,6 +431,6 @@ KeyMap::KeyMap()
insert(DIKS_TILDE , Qt::Key_AsciiTilde);
}
+QT_END_NAMESPACE
#include "qdirectfbkeyboard.moc"
-
-#endif // QT_NO_DIRECTFB
+#endif // QT_NO_QWS_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h
index 756892f..96d73ac 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h
@@ -42,13 +42,16 @@
#ifndef QDIRECTFBKEYBOARD_H
#define QDIRECTFBKEYBOARD_H
+#include <qglobal.h>
#include <QtGui/qkbd_qws.h>
+#ifndef QT_NO_QWS_DIRECTFB
+
QT_BEGIN_HEADER
-QT_MODULE(Gui)
+QT_BEGIN_NAMESPACE
-#ifndef QT_NO_DIRECTFB
+QT_MODULE(Gui)
class QDirectFBKeyboardHandlerPrivate;
@@ -62,7 +65,9 @@ private:
QDirectFBKeyboardHandlerPrivate *d;
};
-#endif // QT_NO_DIRECTFB
+QT_END_NAMESPACE
+
+#endif // QT_NO_QWS_DIRECTFB
QT_END_HEADER
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp
index 1f2b363..2fb1520 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp
@@ -41,6 +41,8 @@
#include "qdirectfbmouse.h"
+#ifndef QT_NO_QWS_DIRECTFB
+
#include "qdirectfbscreen.h"
#include <qsocketnotifier.h>
@@ -49,6 +51,8 @@
#include <fcntl.h>
#include <errno.h>
+QT_BEGIN_NAMESPACE
+
class QDirectFBMouseHandlerPrivate : public QObject
{
Q_OBJECT
@@ -269,5 +273,8 @@ void QDirectFBMouseHandler::resume()
d->setEnabled(true);
}
+QT_END_NAMESPACE
#include "qdirectfbmouse.moc"
+#endif // QT_NO_QWS_DIRECTFB
+
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h
index 14026ee..5ef229c 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h
@@ -42,13 +42,16 @@
#ifndef QDIRECTFBMOUSE_H
#define QDIRECTFBMOUSE_H
+#include <qglobal.h>
#include <QtGui/qmouse_qws.h>
+#ifndef QT_NO_QWS_DIRECTFB
+
QT_BEGIN_HEADER
-QT_MODULE(Gui)
+QT_BEGIN_NAMESPACE
-#ifndef QT_NO_DIRECTFB
+QT_MODULE(Gui)
class QDirectFBMouseHandlerPrivate;
@@ -65,8 +68,8 @@ protected:
QDirectFBMouseHandlerPrivate *d;
};
-#endif // QT_NO_DIRECTFB
+QT_END_NAMESPACE
QT_END_HEADER
-
+#endif // QT_NO_QWS_DIRECTFB
#endif // QDIRECTFBMOUSE_H
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
index dec4bdd..106de0d 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
@@ -39,12 +39,14 @@
**
****************************************************************************/
-#ifndef QT_NO_DIRECTFB
-
#include "qdirectfbscreen.h"
#include "qdirectfbpaintdevice.h"
#include "qdirectfbpaintengine.h"
+#ifndef QT_NO_QWS_DIRECTFB
+
+QT_BEGIN_NAMESPACE
+
QDirectFBPaintDevice::QDirectFBPaintDevice(QDirectFBScreen *scr)
: QCustomRasterPaintDevice(0), dfbSurface(0), lockedImage(0), screen(scr),
bpl(-1), lockFlgs(DFBSurfaceLockFlags(0)), mem(0), engine(0),
@@ -169,5 +171,6 @@ QPaintEngine *QDirectFBPaintDevice::paintEngine() const
return engine;
}
-#endif
+QT_END_NAMESPACE
+#endif // QT_NO_QWS_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
index ca958c8..f5de44b 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
@@ -43,11 +43,14 @@
#define QDIRECTFBPAINTDEVICE_H
#include <private/qpaintengine_raster_p.h>
-#include <directfb.h>
#include "qdirectfbscreen.h"
+#ifndef QT_NO_QWS_DIRECTFB
+
QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
QT_MODULE(Gui)
// Inherited by both window surface and pixmap
@@ -57,7 +60,7 @@ class QDirectFBPaintDevice : public QCustomRasterPaintDevice
public:
~QDirectFBPaintDevice();
- IDirectFBSurface *directFBSurface() const;
+ virtual IDirectFBSurface *directFBSurface() const;
void lockDirectFB(DFBSurfaceLockFlags lock);
void unlockDirectFB();
@@ -94,6 +97,9 @@ private:
Q_DISABLE_COPY(QDirectFBPaintDevice);
};
+QT_END_NAMESPACE
+
QT_END_HEADER
+#endif // QT_NO_QWS_DIRECTFB
#endif //QDIRECTFBPAINTDEVICE_H
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
index 337e75a..9a9553e 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
@@ -41,7 +41,7 @@
#include "qdirectfbpaintengine.h"
-#ifndef QT_NO_DIRECTFB
+#ifndef QT_NO_QWS_DIRECTFB
#include "qdirectfbwindowsurface.h"
#include "qdirectfbscreen.h"
@@ -55,6 +55,8 @@
#include <private/qpixmap_raster_p.h>
#include <private/qimagepixmapcleanuphooks_p.h>
+QT_BEGIN_NAMESPACE
+
class SurfaceCache;
class QDirectFBPaintEnginePrivate : public QRasterPaintEnginePrivate
{
@@ -145,7 +147,9 @@ private:
#ifdef QT_DIRECTFB_IMAGECACHE
+QT_BEGIN_INCLUDE_NAMESPACE
#include <private/qimage_p.h>
+QT_END_INCLUDE_NAMESPACE
struct CachedImage
{
IDirectFBSurface *surface;
@@ -1246,4 +1250,7 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device *
}
#endif // QT_DIRECTFB_WARN_ON_RASTERFALLBACKS
-#endif // QT_NO_DIRECTFB
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_QWS_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h
index 51468ad..b4f0b5d 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h
@@ -45,8 +45,12 @@
#include <QtGui/qpaintengine.h>
#include <private/qpaintengine_raster_p.h>
+#ifndef QT_NO_QWS_DIRECTFB
+
QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
QT_MODULE(Gui)
class QDirectFBPaintEnginePrivate;
@@ -107,6 +111,10 @@ public:
static void initImageCache(int size);
};
+QT_END_NAMESPACE
+
QT_END_HEADER
+#endif // QT_NO_QWS_DIRECTFB
+
#endif // QPAINTENGINE_DIRECTFB_P_H
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
index 2e3d32d..0717020 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
@@ -41,6 +41,8 @@
#include "qdirectfbpixmap.h"
+#ifndef QT_NO_QWS_DIRECTFB
+
#include "qdirectfbscreen.h"
#include "qdirectfbpaintengine.h"
@@ -48,6 +50,9 @@
#include <QtCore/qfile.h>
#include <directfb.h>
+
+QT_BEGIN_NAMESPACE
+
static int global_ser_no = 0;
QDirectFBPixmapData::QDirectFBPixmapData(QDirectFBScreen *screen, PixelType pixelType)
@@ -574,3 +579,9 @@ void QDirectFBPixmapData::invalidate()
imageFormat = QImage::Format_Invalid;
}
+QT_END_NAMESPACE
+
+#endif // QT_NO_QWS_DIRECTFB
+
+
+
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h
index 8bf1e73..7b4ae47 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h
@@ -42,6 +42,10 @@
#ifndef QDIRECTFBPIXMAP_H
#define QDIRECTFBPIXMAP_H
+#include <qglobal.h>
+
+#ifndef QT_NO_QWS_DIRECTFB
+
#include <QtGui/private/qpixmapdata_p.h>
#include <QtGui/private/qpaintengine_raster_p.h>
#include "qdirectfbpaintdevice.h"
@@ -49,6 +53,8 @@
QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
QT_MODULE(Gui)
class QDirectFBPaintEngine;
@@ -91,6 +97,10 @@ private:
bool alpha;
};
+QT_END_NAMESPACE
+
QT_END_HEADER
+#endif // QT_NO_QWS_DIRECTFB
+
#endif // QDIRECTFBPIXMAP_H
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
index 8be0355..59fa191 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
@@ -54,6 +54,10 @@
#include <QtCore/qvector.h>
#include <QtCore/qrect.h>
+#ifndef QT_NO_QWS_DIRECTFB
+
+QT_BEGIN_NAMESPACE
+
class QDirectFBScreenPrivate : public QObject, public QWSGraphicsSystem
{
Q_OBJECT
@@ -94,8 +98,6 @@ public:
QDirectFBScreen *q;
};
-#include "qdirectfbscreen.moc"
-
QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *qptr)
: QWSGraphicsSystem(qptr), dfb(0), flipFlags(DSFLIP_NONE),
directFBFlags(QDirectFBScreen::NoFlags), alphaPixmapFormat(QImage::Format_Invalid),
@@ -494,14 +496,6 @@ void QDirectFBScreen::setSurfaceColorTable(IDirectFBSurface *surface,
#endif // QT_NO_DIRECTFB_PALETTE
-#ifndef QT_NO_QWS_CURSOR
-#if defined QT_DIRECTFB_WM && defined QT_DIRECTFB_WINDOW_AS_CURSOR
-#define QT_DIRECTFB_CURSOR
-#elif defined QT_DIRECTFB_LAYER
-#define QT_DIRECTFB_CURSOR
-#endif
-#endif
-
#if defined QT_DIRECTFB_CURSOR
class Q_GUI_EXPORT QDirectFBScreenCursor : public QScreenCursor
{
@@ -1015,7 +1009,7 @@ static void printDirectFBInfo(IDirectFB *fb, IDirectFBSurface *primarySurface)
static inline bool setIntOption(const QStringList &arguments, const QString &variable, int *value)
{
Q_ASSERT(value);
- QRegExp rx(QString("%1=?(\\d+)").arg(variable));
+ QRegExp rx(QString::fromLatin1("%1=?(\\d+)").arg(variable));
rx.setCaseSensitivity(Qt::CaseInsensitive);
if (arguments.indexOf(rx) != -1) {
*value = rx.cap(1).toInt();
@@ -1024,36 +1018,6 @@ static inline bool setIntOption(const QStringList &arguments, const QString &var
return false;
}
-static inline int depth(QImage::Format format)
-{
- switch (format) {
- case QImage::Format_Mono:
- case QImage::Format_MonoLSB:
- return 1;
- case QImage::Format_Indexed8:
- return 8;
- case QImage::Format_RGB32:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- return 32;
- case QImage::Format_ARGB8565_Premultiplied:
- case QImage::Format_RGB666:
- case QImage::Format_ARGB6666_Premultiplied:
- case QImage::Format_ARGB8555_Premultiplied:
- case QImage::Format_RGB888:
- return 24;
- case QImage::Format_RGB555:
- case QImage::Format_RGB444:
- case QImage::Format_RGB16:
- case QImage::Format_ARGB4444_Premultiplied:
- return 16;
- case QImage::Format_Invalid:
- case QImage::NImageFormats:
- break;
- }
- return -1;
-}
-
bool QDirectFBScreen::connect(const QString &displaySpec)
{
DFBResult result = DFB_OK;
@@ -1199,7 +1163,7 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
break;
}
setPixelFormat(pixelFormat);
- QScreen::d = ::depth(pixelFormat);
+ QScreen::d = QDirectFBScreen::depth(pixelFormat);
data = 0;
lstep = 0;
size = 0;
@@ -1227,6 +1191,8 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
"Unable to get screen size!", result);
return false;
}
+ ::setIntOption(displayArgs, QLatin1String("width"), &w);
+ ::setIntOption(displayArgs, QLatin1String("height"), &h);
dw = w;
dh = h;
@@ -1252,7 +1218,7 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
surface->Release(surface);
#endif
- QRegExp backgroundColorRegExp("bgcolor=?(.+)");
+ QRegExp backgroundColorRegExp(QLatin1String("bgcolor=?(.+)"));
backgroundColorRegExp.setCaseSensitivity(Qt::CaseInsensitive);
if (displayArgs.indexOf(backgroundColorRegExp) != -1) {
d_ptr->backgroundColor.setNamedColor(backgroundColorRegExp.cap(1));
@@ -1305,12 +1271,10 @@ bool QDirectFBScreen::initDevice()
}
#endif
-#ifndef QT_NO_QWS_CURSOR
-#if defined QT_NO_DIRECTFB_WM || defined QT_NO_DIRECTFB_LAYER
- QScreenCursor::initSoftwareCursor();
-#else
+#ifdef QT_DIRECTFB_CURSOR
qt_screencursor = new QDirectFBScreenCursor;
-#endif
+#elif !defined QT_NO_QWS_CURSOR
+ QScreenCursor::initSoftwareCursor();
#endif
return true;
}
@@ -1370,17 +1334,18 @@ QWSWindowSurface *QDirectFBScreen::createSurface(const QString &key) const
// window surfaces. Normal, directFB surfaces are handled by DirectFB.
void QDirectFBScreen::exposeRegion(QRegion r, int changing)
{
-#ifdef QT_NO_DIRECTFB_WM
+#if defined QT_NO_DIRECTFB_WM
const QList<QWSWindow*> windows = QWSServer::instance()->clientWindows();
- if (changing < 0 || changing >= windows.size())
+ if (changing < 0 || changing >= windows.size()) {
return;
-
+ }
QWSWindow *win = windows.at(changing);
QWSWindowSurface *s = win->windowSurface();
r &= region();
- if (r.isEmpty())
+ if (r.isEmpty()) {
return;
+ }
const QRect brect = r.boundingRect();
@@ -1398,15 +1363,18 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing)
? static_cast<QDirectFBWindowSurface*>(s) : 0;
if (dfbWindowSurface) {
IDirectFBSurface *surface = dfbWindowSurface->directFBSurface();
+ Q_ASSERT(surface);
const int n = insideWindow.numRects();
if (n == 1 || d_ptr->directFBFlags & BoundingRectFlip) {
const QRect source = (insideWindow.boundingRect().intersected(windowGeometry)).translated(-windowGeometry.topLeft());
const DFBRectangle rect = {
source.x(), source.y(), source.width(), source.height()
};
+
d_ptr->primarySurface->Blit(d_ptr->primarySurface, surface, &rect,
windowGeometry.x() + source.x(),
windowGeometry.y() + source.y());
+
} else {
const QVector<QRect> rects = insideWindow.rects();
QVarLengthArray<DFBRectangle, 16> dfbRectangles(n);
@@ -1429,6 +1397,7 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing)
}
}
+#ifdef QT_NO_DIRECTFB_CURSOR
if (QScreenCursor *cursor = QScreenCursor::instance()) {
const QRect cursorRectangle = cursor->boundingRect();
if (cursor->isVisible() && !cursor->isAccelerated() && cursorRectangle.intersects(brect)) {
@@ -1442,6 +1411,7 @@ void QDirectFBScreen::exposeRegion(QRegion r, int changing)
#endif
}
}
+#endif
flipSurface(d_ptr->primarySurface, d_ptr->flipFlags, r, QPoint());
#else
Q_UNUSED(r);
@@ -1459,8 +1429,8 @@ void QDirectFBScreen::solidFill(const QColor &color, const QRegion &region)
return;
d_ptr->primarySurface->SetColor(d_ptr->primarySurface,
- color.red(), color.green(), color.blue(),
- color.alpha());
+ color.red(), color.green(), color.blue(),
+ color.alpha());
const int n = region.numRects();
if (n > 1) {
const QRect r = region.boundingRect();
@@ -1590,3 +1560,8 @@ IDirectFBSurface *QDirectFBScreen::subSurfaceForWidget(const QWidget *widget, co
return subSurface;
}
+QT_END_NAMESPACE
+
+#include "qdirectfbscreen.moc"
+#endif // QT_NO_QWS_DIRECTFB
+
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
index df0eea4..e74adb1 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
@@ -42,12 +42,16 @@
#ifndef QDIRECTFBSCREEN_H
#define QDIRECTFBSCREEN_H
+#include <qglobal.h>
+#ifndef QT_NO_QWS_DIRECTFB
#include <QtGui/qscreen_qws.h>
#include <directfb.h>
#include <directfb_version.h>
QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
QT_MODULE(Gui)
#if !defined QT_NO_DIRECTFB_LAYER && !defined QT_DIRECTFB_LAYER
@@ -83,6 +87,16 @@ QT_MODULE(Gui)
#if !defined QT_NO_DIRECTFB_OPAQUE_DETECTION && !defined QT_DIRECTFB_OPAQUE_DETECTION
#define QT_DIRECTFB_OPAQUE_DETECTION
#endif
+#ifndef QT_NO_QWS_CURSOR
+#if defined QT_DIRECTFB_WM && defined QT_DIRECTFB_WINDOW_AS_CURSOR
+#define QT_DIRECTFB_CURSOR
+#elif defined QT_DIRECTFB_LAYER
+#define QT_DIRECTFB_CURSOR
+#endif
+#endif
+#ifndef QT_DIRECTFB_CURSOR
+#define QT_NO_DIRECTFB_CURSOR
+#endif
#if defined QT_NO_DIRECTFB_LAYER && defined QT_DIRECTFB_WM
#error QT_NO_DIRECTFB_LAYER requires QT_NO_DIRECTFB_WM
#endif
@@ -269,6 +283,10 @@ inline bool QDirectFBScreen::hasAlphaChannel(IDirectFBSurface *surface)
return QDirectFBScreen::hasAlphaChannel(format);
}
+QT_END_NAMESPACE
+
QT_END_HEADER
+#endif // QT_NO_QWS_DIRECTFB
#endif // QDIRECTFBSCREEN_H
+
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp
index 4caee414..05fe70f 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp
@@ -43,6 +43,7 @@
#include <QtGui/qscreendriverplugin_qws.h>
#include <QtCore/qstringlist.h>
+#ifndef QT_NO_QWS_DIRECTFB
class DirectFBScreenDriverPlugin : public QScreenDriverPlugin
{
@@ -73,3 +74,5 @@ QScreen* DirectFBScreenDriverPlugin::create(const QString& driver,
}
Q_EXPORT_PLUGIN2(qdirectfbscreen, DirectFBScreenDriverPlugin)
+
+#endif
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
index a05ad21..73a6dd7 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
@@ -48,11 +48,15 @@
#include <qpaintdevice.h>
#include <qvarlengtharray.h>
+#ifndef QT_NO_QWS_DIRECTFB
+
+QT_BEGIN_NAMESPACE
+
QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr)
: QDirectFBPaintDevice(scr)
+ , sibling(0)
#ifndef QT_NO_DIRECTFB_WM
, dfbWindow(0)
- , sibling(0)
#endif
, flipFlags(flip)
, boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip)
@@ -69,9 +73,9 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect
QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr, QWidget *widget)
: QWSWindowSurface(widget), QDirectFBPaintDevice(scr)
+ , sibling(0)
#ifndef QT_NO_DIRECTFB_WM
, dfbWindow(0)
- , sibling(0)
#endif
, flipFlags(flip)
, boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip)
@@ -243,23 +247,16 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect)
QByteArray QDirectFBWindowSurface::permanentState() const
{
-#ifdef QT_DIRECTFB_WM
QByteArray state(sizeof(this), 0);
*reinterpret_cast<const QDirectFBWindowSurface**>(state.data()) = this;
return state;
-#endif
- return QByteArray();
}
void QDirectFBWindowSurface::setPermanentState(const QByteArray &state)
{
-#ifdef QT_DIRECTFB_WM
if (state.size() == sizeof(this)) {
sibling = *reinterpret_cast<QDirectFBWindowSurface *const*>(state.constData());
}
-#else
- Q_UNUSED(state);
-#endif
}
static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy)
@@ -381,6 +378,7 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion &region,
}
}
+#ifdef QT_NO_DIRECTFB_CURSOR
if (QScreenCursor *cursor = QScreenCursor::instance()) {
const QRect cursorRectangle = cursor->boundingRect();
if (cursor->isVisible() && !cursor->isAccelerated()
@@ -396,6 +394,7 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion &region,
#endif
}
}
+#endif
if (mode == Offscreen) {
screen->flipSurface(primarySurface, flipFlags, region, offset + windowGeometry.topLeft());
} else
@@ -424,6 +423,14 @@ void QDirectFBWindowSurface::endPaint(const QRegion &)
unlockDirectFB();
}
+IDirectFBSurface *QDirectFBWindowSurface::directFBSurface() const
+{
+ if (!dfbSurface && sibling && sibling->dfbSurface)
+ return sibling->dfbSurface;
+ return dfbSurface;
+}
+
+
IDirectFBSurface *QDirectFBWindowSurface::surfaceForWidget(const QWidget *widget, QRect *rect) const
{
Q_ASSERT(widget);
@@ -449,3 +456,9 @@ void QDirectFBWindowSurface::updateFormat()
{
imageFormat = dfbSurface ? QDirectFBScreen::getImageFormat(dfbSurface) : QImage::Format_Invalid;
}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_QWS_DIRECTFB
+
+
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
index a2861e5..ca76613 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
@@ -46,9 +46,10 @@
#include "qdirectfbpaintdevice.h"
#include "qdirectfbscreen.h"
+#ifndef QT_NO_QWS_DIRECTFB
+
#include <private/qpaintengine_raster_p.h>
#include <private/qwindowsurface_qws_p.h>
-#include <directfb.h>
#ifdef QT_DIRECTFB_TIMING
#include <qdatetime.h>
@@ -56,6 +57,8 @@
QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
QT_MODULE(Gui)
class QDirectFBWindowSurface : public QWSWindowSurface, public QDirectFBPaintDevice
@@ -89,12 +92,14 @@ public:
void endPaint(const QRegion &);
IDirectFBSurface *surfaceForWidget(const QWidget *widget, QRect *rect) const;
+ IDirectFBSurface *directFBSurface() const;
private:
void updateFormat();
+ QDirectFBWindowSurface *sibling;
+
#ifdef QT_DIRECTFB_WM
void createWindow();
IDirectFBWindow *dfbWindow;
- QDirectFBWindowSurface *sibling;
#else
enum Mode {
Primary,
@@ -110,6 +115,10 @@ private:
#endif
};
+QT_END_NAMESPACE
+
QT_END_HEADER
+#endif // QT_NO_QWS_DIRECTFB
+
#endif // QDIRECFBWINDOWSURFACE_H
diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp
index de985d8..0f6a349 100644
--- a/src/plugins/imageformats/gif/qgifhandler.cpp
+++ b/src/plugins/imageformats/gif/qgifhandler.cpp
@@ -234,7 +234,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
#define LM(l, m) (((m)<<8)|l)
digress = false;
- int initial = length;
+ const int initial = length;
while (!digress && length) {
length--;
unsigned char ch=*buffer++;
@@ -333,7 +333,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
sheight = newtop + newheight;
QImage::Format format = trans_index >= 0 ? QImage::Format_ARGB32 : QImage::Format_RGB32;
- if (image->isNull() || (image->size() != QSize(swidth, sheight)) || image->format() != format) {
+ if (image->isNull()) {
(*image) = QImage(swidth, sheight, format);
memset(image->bits(), 0, image->numBytes());
diff --git a/src/script/bridge/qscriptactivationobject.cpp b/src/script/bridge/qscriptactivationobject.cpp
index c6d405e..1c7b912 100644
--- a/src/script/bridge/qscriptactivationobject.cpp
+++ b/src/script/bridge/qscriptactivationobject.cpp
@@ -52,8 +52,8 @@ namespace JSC
QT_BEGIN_NAMESPACE
/*!
-\class QScriptActivationObject
-\internal
+ \class QScript::QScriptActivationObject
+ \internal
Represent a scope for native function call.
*/
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp
index 742d596..2692c96 100644
--- a/src/sql/drivers/odbc/qsql_odbc.cpp
+++ b/src/sql/drivers/odbc/qsql_odbc.cpp
@@ -323,12 +323,12 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni
colSize *= 2; // a tiny bit faster, since it saves a SQLGetData() call
}
}
- char* buf = new char[colSize];
+ QVarLengthArray<char> buf(colSize);
while (true) {
r = SQLGetData(hStmt,
column+1,
unicode ? SQL_C_WCHAR : SQL_C_CHAR,
- (SQLPOINTER)buf,
+ (SQLPOINTER)buf.data(),
colSize,
&lengthIndicator);
if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
@@ -343,11 +343,12 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni
// colSize-1: remove 0 termination when there is more data to fetch
int rSize = (r == SQL_SUCCESS_WITH_INFO) ? (unicode ? colSize-2 : colSize-1) : lengthIndicator;
if (unicode) {
- fieldVal += QString((QChar*) buf, rSize / 2);
+ fieldVal += QString((const QChar*) buf.constData(), rSize / 2);
} else {
- fieldVal += QString::fromAscii(buf, rSize);
+ fieldVal += QString::fromAscii(buf.constData(), rSize);
}
- if (lengthIndicator - fieldVal.size() <= 0) {
+ memset(buf.data(), 0, colSize);
+ if (lengthIndicator < colSize) {
// workaround for Drivermanagers that don't return SQL_NO_DATA
break;
}
@@ -359,7 +360,6 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni
break;
}
}
- delete[] buf;
return fieldVal;
}
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index d0b52da..371b845 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -64,6 +64,7 @@
#include "qdebug.h"
#include "qmath.h"
#include "qnumeric.h"
+#include "qvarlengtharray.h"
#include "private/qmath_p.h"
#include "float.h"
@@ -181,21 +182,21 @@ QSvgAttributes::QSvgAttributes(const QXmlStreamAttributes &xmlAttributes, QSvgHa
case 's':
if (name.length() > 5 && QStringRef(name.string(), name.position() + 1, 5) == QLatin1String("troke")) {
QStringRef strokeRef(name.string(), name.position() + 6, name.length() - 6);
- if (name.isEmpty())
+ if (strokeRef.isEmpty())
stroke = value;
- else if (name == QLatin1String("-dasharray"))
+ else if (strokeRef == QLatin1String("-dasharray"))
strokeDashArray = value;
- else if (name == QLatin1String("-dashoffset"))
+ else if (strokeRef == QLatin1String("-dashoffset"))
strokeDashOffset = value;
- else if (name == QLatin1String("-linecap"))
+ else if (strokeRef == QLatin1String("-linecap"))
strokeLineCap = value;
- else if (name == QLatin1String("-linejoin"))
+ else if (strokeRef == QLatin1String("-linejoin"))
strokeLineJoin = value;
- else if (name == QLatin1String("-miterlimit"))
+ else if (strokeRef == QLatin1String("-miterlimit"))
strokeMiterLimit = value;
- else if (name == QLatin1String("-opacity"))
+ else if (strokeRef == QLatin1String("-opacity"))
strokeOpacity = value;
- else if (name == QLatin1String("-width"))
+ else if (strokeRef == QLatin1String("-width"))
strokeWidth = value;
}
else if (name == QLatin1String("stop-color"))
@@ -276,21 +277,21 @@ QSvgAttributes::QSvgAttributes(const QXmlStreamAttributes &xmlAttributes, QSvgHa
case 's':
if (name.length() > 5 && QStringRef(name.string(), name.position() + 1, 5) == QLatin1String("troke")) {
QStringRef strokeRef(name.string(), name.position() + 6, name.length() - 6);
- if (name.isEmpty())
+ if (strokeRef.isEmpty())
stroke = value;
- else if (name == QLatin1String("-dasharray"))
+ else if (strokeRef == QLatin1String("-dasharray"))
strokeDashArray = value;
- else if (name == QLatin1String("-dashoffset"))
+ else if (strokeRef == QLatin1String("-dashoffset"))
strokeDashOffset = value;
- else if (name == QLatin1String("-linecap"))
+ else if (strokeRef == QLatin1String("-linecap"))
strokeLineCap = value;
- else if (name == QLatin1String("-linejoin"))
+ else if (strokeRef == QLatin1String("-linejoin"))
strokeLineJoin = value;
- else if (name == QLatin1String("-miterlimit"))
+ else if (strokeRef == QLatin1String("-miterlimit"))
strokeMiterLimit = value;
- else if (name == QLatin1String("-opacity"))
+ else if (strokeRef == QLatin1String("-opacity"))
strokeOpacity = value;
- else if (name == QLatin1String("-width"))
+ else if (strokeRef == QLatin1String("-width"))
strokeWidth = value;
}
else if (name == QLatin1String("stop-color"))
@@ -474,6 +475,13 @@ public:
}
};
+// '0' is 0x30 and '9' is 0x39
+static inline bool isDigit(ushort ch)
+{
+ static quint16 magic = 0x3ff;
+ return ((ch >> 4) == 3) && (magic >> (ch & 15));
+}
+
static qreal toDouble(const QChar *&str)
{
const int maxLen = 255;//technically doubles can go til 308+ but whatever
@@ -486,7 +494,7 @@ static qreal toDouble(const QChar *&str)
} else if (*str == QLatin1Char('+')) {
++str;
}
- while (*str >= QLatin1Char('0') && *str <= QLatin1Char('9') && pos < maxLen) {
+ while (isDigit(str->unicode()) && pos < maxLen) {
temp[pos++] = str->toLatin1();
++str;
}
@@ -494,7 +502,7 @@ static qreal toDouble(const QChar *&str)
temp[pos++] = '.';
++str;
}
- while (*str >= QLatin1Char('0') && *str <= QLatin1Char('9') && pos < maxLen) {
+ while (isDigit(str->unicode()) && pos < maxLen) {
temp[pos++] = str->toLatin1();
++str;
}
@@ -507,7 +515,7 @@ static qreal toDouble(const QChar *&str)
temp[pos++] = str->toLatin1();
++str;
}
- while (*str >= QLatin1Char('0') && *str <= QLatin1Char('9') && pos < maxLen) {
+ while (isDigit(str->unicode()) && pos < maxLen) {
temp[pos++] = str->toLatin1();
++str;
}
@@ -587,7 +595,7 @@ static QVector<qreal> parseNumbersList(const QChar *&str)
while (*str == QLatin1Char(' '))
++str;
- while ((*str >= QLatin1Char('0') && *str <= QLatin1Char('9')) ||
+ while (isDigit(str->unicode()) ||
*str == QLatin1Char('-') || *str == QLatin1Char('+') ||
*str == QLatin1Char('.')) {
@@ -606,6 +614,27 @@ static QVector<qreal> parseNumbersList(const QChar *&str)
return points;
}
+static inline void parseNumbersArray(const QChar *&str, QVarLengthArray<qreal, 8> &points)
+{
+ while (*str == QLatin1Char(' '))
+ ++str;
+ while (isDigit(str->unicode()) ||
+ *str == QLatin1Char('-') || *str == QLatin1Char('+') ||
+ *str == QLatin1Char('.')) {
+
+ points.append(toDouble(str));
+
+ while (*str == QLatin1Char(' '))
+ ++str;
+ if (*str == QLatin1Char(','))
+ ++str;
+
+ //eat the rest of space
+ while (*str == QLatin1Char(' '))
+ ++str;
+ }
+}
+
static QVector<qreal> parsePercentageList(const QChar *&str)
{
QVector<qreal> points;
@@ -949,7 +978,8 @@ static QMatrix parseTransformationMatrix(const QString &value)
if (*str != QLatin1Char('('))
goto error;
++str;
- QVector<qreal> points = parseNumbersList(str);
+ QVarLengthArray<qreal, 8> points;
+ parseNumbersArray(str, points);
if (*str != QLatin1Char(')'))
goto error;
++str;
@@ -1819,27 +1849,49 @@ static inline QStringList stringToList(const QString &str)
static bool parseCoreNode(QSvgNode *node,
const QXmlStreamAttributes &attributes)
{
- QString featuresStr = attributes.value(QLatin1String("requiredFeatures")).toString();
- QString extensionsStr = attributes.value(QLatin1String("requiredExtensions")).toString();
- QString languagesStr = attributes.value(QLatin1String("systemLanguage")).toString();
- QString formatsStr = attributes.value(QLatin1String("requiredFormats")).toString();
- QString fontsStr = attributes.value(QLatin1String("requiredFonts")).toString();
- QString nodeIdStr = someId(attributes);
- QString xmlClassStr = attributes.value(QLatin1String("class")).toString();
-
+ QStringList features;
+ QStringList extensions;
+ QStringList languages;
+ QStringList formats;
+ QStringList fonts;
+ QString xmlClassStr;
- QStringList features = stringToList(featuresStr);
- QStringList extensions = stringToList(extensionsStr);
- QStringList languages = stringToList(languagesStr);
- QStringList formats = stringToList(formatsStr);
- QStringList fonts = stringToList(fontsStr);
+ for (int i = 0; i < attributes.count(); ++i) {
+ const QXmlStreamAttribute &attribute = attributes.at(i);
+ QStringRef name = attribute.qualifiedName();
+ if (name.isEmpty())
+ continue;
+ QStringRef value = attribute.value();
+ switch (name.at(0).unicode()) {
+ case 'c':
+ if (name == QLatin1String("class"))
+ xmlClassStr = value.toString();
+ break;
+ case 'r':
+ if (name == QLatin1String("requiredFeatures"))
+ features = stringToList(value.toString());
+ else if (name == QLatin1String("requiredExtensions"))
+ extensions = stringToList(value.toString());
+ else if (name == QLatin1String("requiredFormats"))
+ formats = stringToList(value.toString());
+ else if (name == QLatin1String("requiredFonts"))
+ fonts = stringToList(value.toString());
+ break;
+ case 's':
+ if (name == QLatin1String("systemLanguage"))
+ languages = stringToList(value.toString());
+ break;
+ default:
+ break;
+ }
+ }
node->setRequiredFeatures(features);
node->setRequiredExtensions(extensions);
node->setRequiredLanguages(languages);
node->setRequiredFormats(formats);
node->setRequiredFonts(fonts);
- node->setNodeId(nodeIdStr);
+ node->setNodeId(someId(attributes));
node->setXmlClass(xmlClassStr);
return true;
@@ -1981,8 +2033,9 @@ static void parseOthers(QSvgNode *node,
const QSvgAttributes &attributes,
QSvgHandler *)
{
- QString displayStr = attributes.display.toString();
- displayStr = displayStr.trimmed();
+ if (attributes.display.isEmpty())
+ return;
+ QString displayStr = attributes.display.toString().trimmed();
if (!displayStr.isEmpty()) {
node->setDisplayMode(displayStringToEnum(displayStr));
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index c655cad..b9636c9 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -2121,6 +2121,10 @@ bool QTest::compare_string_helper(const char *t1, const char *t2, const char *ac
\internal
*/
+/*! \fn bool QTest::qCompare(bool const &t1, int const &t2, const char *actual, const char *expected, const char *file, int line)
+ \internal
+ */
+
/*! \fn bool QTest::qTest(const T& actual, const char *elementName, const char *actualStr, const char *expected, const char *file, int line)
\internal
*/
diff --git a/tests/auto/gestures/customgesturerecognizer.cpp b/tests/auto/gestures/customgesturerecognizer.cpp
deleted file mode 100644
index 96028be..0000000
--- a/tests/auto/gestures/customgesturerecognizer.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, 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.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "customgesturerecognizer.h"
-#include "qgesture.h"
-
-const char* SingleshotGestureRecognizer::Name = "SingleshotGesture";
-const char* PinchGestureRecognizer::Name = "PinchGesture";
-const char* SecondFingerGestureRecognizer::Name = "SecondFingerGesture";
-const char* PanGestureRecognizer::Name = "PanGesture";
-
-SingleshotGestureRecognizer::SingleshotGestureRecognizer(QObject *parent)
- : QGestureRecognizer(QString(SingleshotGestureRecognizer::Name), parent)
-{
- gesture = new SingleshotGesture(this, SingleshotGestureRecognizer::Name);
-}
-
-QGestureRecognizer::Result SingleshotGestureRecognizer::filterEvent(const QEvent *event)
-{
- if (event->type() == SingleshotEvent::Type) {
- gesture->setHotSpot(static_cast<const SingleshotEvent*>(event)->point);
- return QGestureRecognizer::GestureFinished;
- }
- return QGestureRecognizer::NotGesture;
-}
-
-void SingleshotGestureRecognizer::reset()
-{
- gesture->setHotSpot(QPoint());
- gesture->offset = QPoint();
-}
-
-PinchGestureRecognizer::PinchGestureRecognizer(QObject *parent)
- : QGestureRecognizer(PinchGestureRecognizer::Name, parent)
-{
- gesture = new PinchGesture(this, PinchGestureRecognizer::Name);
-}
-
-QGestureRecognizer::Result PinchGestureRecognizer::filterEvent(const QEvent *event)
-{
- if (event->type() != TouchEvent::Type)
- return QGestureRecognizer::Ignore;
-
- const TouchEvent *e = static_cast<const TouchEvent*>(event);
- if (e->points[0].state == TouchPoint::Begin)
- gesture->startPoints[0] = e->points[0];
- if (e->points[1].state == TouchPoint::Begin)
- gesture->startPoints[1] = e->points[1];
- gesture->lastPoints[0] = gesture->points[0];
- gesture->lastPoints[1] = gesture->points[1];
- gesture->points[0] = e->points[0];
- gesture->points[1] = e->points[1];
- if (((e->points[0].state == TouchPoint::Begin || e->points[0].state == TouchPoint::Update))) {
- if (e->points[1].state == TouchPoint::End || e->points[1].state == TouchPoint::None)
- return MaybeGesture;
- return GestureStarted;
- } else if (((e->points[1].state == TouchPoint::Begin || e->points[1].state == TouchPoint::Update))) {
- if (e->points[0].state == TouchPoint::End || e->points[0].state == TouchPoint::None)
- return MaybeGesture;
- return GestureStarted;
- } else if ((e->points[0].state == TouchPoint::End && e->points[1].state == TouchPoint::End) ||
- (e->points[0].state == TouchPoint::End && e->points[1].state == TouchPoint::None) ||
- (e->points[0].state == TouchPoint::None && e->points[1].state == TouchPoint::End)) {
- return QGestureRecognizer::NotGesture;
- }
- return QGestureRecognizer::NotGesture;
-}
-
-void PinchGestureRecognizer::reset()
-{
- gesture->startPoints[0] = TouchPoint();
- gesture->startPoints[1] = TouchPoint();
- gesture->lastPoints[0] = TouchPoint();
- gesture->lastPoints[1] = TouchPoint();
- gesture->points[0] = TouchPoint();
- gesture->points[1] = TouchPoint();
- gesture->offset = QPoint();
-}
-
-SecondFingerGestureRecognizer::SecondFingerGestureRecognizer(QObject *parent)
- : QGestureRecognizer(SecondFingerGestureRecognizer::Name, parent)
-{
- gesture = new SecondFingerGesture(this, SecondFingerGestureRecognizer::Name);
-}
-
-QGestureRecognizer::Result SecondFingerGestureRecognizer::filterEvent(const QEvent *event)
-{
- if (event->type() != TouchEvent::Type)
- return QGestureRecognizer::Ignore;
-
- const TouchEvent *e = static_cast<const TouchEvent*>(event);
- if (e->points[1].state != TouchPoint::None) {
- if (e->points[1].state == TouchPoint::Begin)
- gesture->startPoint = e->points[1];
- gesture->lastPoint = gesture->point;
- gesture->point = e->points[1];
- if (e->points[1].state == TouchPoint::End)
- return QGestureRecognizer::GestureFinished;
- else if (e->points[1].state != TouchPoint::None)
- return QGestureRecognizer::GestureStarted;
- }
- return QGestureRecognizer::NotGesture;
-}
-
-void SecondFingerGestureRecognizer::reset()
-{
- gesture->startPoint = TouchPoint();
- gesture->lastPoint = TouchPoint();
- gesture->point = TouchPoint();
- gesture->offset = QPoint();
-}
-
-PanGestureRecognizer::PanGestureRecognizer(QObject *parent)
- : QGestureRecognizer(PanGestureRecognizer::Name, parent)
-{
- gesture = new PanGesture(this, PanGestureRecognizer::Name);
-}
-
-QGestureRecognizer::Result PanGestureRecognizer::filterEvent(const QEvent *event)
-{
- if (event->type() != QEvent::TouchBegin &&
- event->type() != QEvent::TouchUpdate &&
- event->type() != QEvent::TouchEnd)
- return QGestureRecognizer::Ignore;
-
- const QTouchEvent *e = static_cast<const QTouchEvent*>(event);
- const QList<QTouchEvent::TouchPoint> &points = e->touchPoints();
-
- if (points.size() >= 1) {
- gesture->lastPoints[0] = gesture->points[0];
- gesture->points[0].id = points.at(0).id();
- gesture->points[0].pt = points.at(0).startPos().toPoint();
- gesture->points[0].state = (TouchPoint::State)points.at(0).state();
- if (points.at(0).state() == Qt::TouchPointPressed) {
- gesture->startPoints[0] = gesture->points[0];
- gesture->lastPoints[0] = gesture->points[0];
- }
- }
- if (points.size() >= 2) {
- gesture->lastPoints[1] = gesture->points[1];
- gesture->points[1].id = points.at(1).id();
- gesture->points[1].pt = points.at(1).startPos().toPoint();
- gesture->points[1].state = (TouchPoint::State)points.at(1).state();
- if (points.at(1).state() == Qt::TouchPointPressed) {
- gesture->startPoints[1] = gesture->points[1];
- gesture->lastPoints[1] = gesture->points[1];
- }
- }
-
- if (points.size() == 2)
- return QGestureRecognizer::GestureStarted;
- if (points.size() > 2)
- return QGestureRecognizer::MaybeGesture;
- if (points.at(0).state() == Qt::TouchPointPressed)
- return QGestureRecognizer::MaybeGesture;
- if (points.at(0).state() == Qt::TouchPointReleased)
- return QGestureRecognizer::GestureFinished;
- return QGestureRecognizer::GestureStarted;
-}
-
-void PanGestureRecognizer::reset()
-{
- gesture->startPoints[0] = TouchPoint();
- gesture->startPoints[1] = TouchPoint();
- gesture->lastPoints[0] = TouchPoint();
- gesture->lastPoints[1] = TouchPoint();
- gesture->points[0] = TouchPoint();
- gesture->points[1] = TouchPoint();
- gesture->offset = QPoint();
-}
diff --git a/tests/auto/gestures/customgesturerecognizer.h b/tests/auto/gestures/customgesturerecognizer.h
deleted file mode 100644
index 2a24efb..0000000
--- a/tests/auto/gestures/customgesturerecognizer.h
+++ /dev/null
@@ -1,228 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, 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.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef CUSTOMGESTURERECOGNIZER_H
-#define CUSTOMGESTURERECOGNIZER_H
-
-#include "qgesturerecognizer.h"
-#include "qgesture.h"
-#include "qevent.h"
-
-class SingleshotEvent : public QEvent
-{
-public:
- static const int Type = QEvent::User + 1;
-
- QPoint point;
-
- explicit SingleshotEvent(int x = 0, int y = 0)
- : QEvent(QEvent::Type(Type)), point(x, y) { }
-};
-
-class SingleshotGesture : public QGesture
-{
- Q_OBJECT
-public:
- SingleshotGesture(QObject *parent, const QString &type)
- : QGesture(parent, type) { }
-
- QPoint offset;
-
-protected:
- void translate(const QPoint &pt)
- {
- offset += pt;
- }
-};
-
-class SingleshotGestureRecognizer : public QGestureRecognizer
-{
- Q_OBJECT
-public:
- static const char *Name;
-
- SingleshotGestureRecognizer(QObject *parent = 0);
-
- QGestureRecognizer::Result filterEvent(const QEvent *event);
- QGesture* getGesture() { return gesture; }
- void reset();
-
-private:
- SingleshotGesture *gesture;
-};
-
-struct TouchPoint {
- enum State
- {
- None = 0,
- Begin = Qt::TouchPointPressed,
- Update = Qt::TouchPointMoved,
- End = Qt::TouchPointReleased
- };
- int id;
- QPoint pt;
- State state;
- TouchPoint() : id(0), state(None) { }
- TouchPoint(int id_, int x_, int y_, State state_) : id(id_), pt(x_, y_), state(state_) { }
-};
-
-class TouchEvent : public QEvent
-{
-public:
- static const int Type = QEvent::User + 2;
-
- TouchEvent()
- : QEvent(QEvent::Type(Type))
- {
- }
-
- TouchPoint points[2];
-};
-
-class PinchGesture : public QGesture
-{
- Q_OBJECT
-public:
- PinchGesture(QObject *parent, const QString &type)
- : QGesture(parent, type) { }
-
- TouchPoint startPoints[2];
- TouchPoint lastPoints[2];
- TouchPoint points[2];
-
- QPoint offset;
-
-protected:
- void translate(const QPoint &pt)
- {
- offset += pt;
- }
-};
-
-class PinchGestureRecognizer : public QGestureRecognizer
-{
- Q_OBJECT
-public:
- static const char *Name;
-
- PinchGestureRecognizer(QObject *parent = 0);
-
- QGestureRecognizer::Result filterEvent(const QEvent *event);
- QGesture* getGesture() { return gesture; }
- void reset();
-
-private:
- PinchGesture *gesture;
-};
-
-class SecondFingerGesture : public QGesture
-{
- Q_OBJECT
-public:
- SecondFingerGesture(QObject *parent, const QString &type)
- : QGesture(parent, type) { }
-
- TouchPoint startPoint;
- TouchPoint lastPoint;
- TouchPoint point;
-
- QPoint offset;
-
-protected:
- void translate(const QPoint &pt)
- {
- offset += pt;
- }
-};
-
-class SecondFingerGestureRecognizer : public QGestureRecognizer
-{
- Q_OBJECT
-public:
- static const char *Name;
-
- SecondFingerGestureRecognizer(QObject *parent = 0);
-
- QGestureRecognizer::Result filterEvent(const QEvent *event);
- QGesture* getGesture() { return gesture; }
- void reset();
-
-private:
- SecondFingerGesture *gesture;
-};
-
-class PanGesture : public QGesture
-{
- Q_OBJECT
-public:
- PanGesture(QObject *parent, const QString &type)
- : QGesture(parent, type) { }
-
- TouchPoint startPoints[2];
- TouchPoint lastPoints[2];
- TouchPoint points[2];
-
- QPoint offset;
-
-protected:
- void translate(const QPoint &pt)
- {
- offset += pt;
- }
-};
-
-class PanGestureRecognizer : public QGestureRecognizer
-{
- Q_OBJECT
-public:
- static const char *Name;
-
- PanGestureRecognizer(QObject *parent = 0);
-
- QGestureRecognizer::Result filterEvent(const QEvent *event);
- QGesture* getGesture() { return gesture; }
- void reset();
-
-private:
- PanGesture *gesture;
-};
-
-#endif
diff --git a/tests/auto/gestures/gestures.pro b/tests/auto/gestures/gestures.pro
deleted file mode 100644
index ac99b19..0000000
--- a/tests/auto/gestures/gestures.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-load(qttest_p4)
-SOURCES += tst_gestures.cpp customgesturerecognizer.cpp
-HEADERS += customgesturerecognizer.h
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp
deleted file mode 100644
index 85fd355..0000000
--- a/tests/auto/gestures/tst_gestures.cpp
+++ /dev/null
@@ -1,962 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, 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.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <QtGui>
-
-#include <QtTest/QtTest>
-
-#include "customgesturerecognizer.h"
-
-//TESTED_CLASS=
-//TESTED_FILES=
-
-// color generator for syntax highlighting from QQ-26 by Helder Correia
-QVector<QColor> highlight(const QColor &bg, const
- QColor &fg, int noColors)
-{
- QVector<QColor> colors;
- const int HUE_BASE = (bg.hue() == -1) ? 90 : bg.hue();
- int h, s, v;
- for (int i = 0; i < noColors; i++) {
- h = int(HUE_BASE + (360.0 / noColors * i)) % 360;
- s = 240;
- v = int(qMax(bg.value(), fg.value()) * 0.85);
-
- const int M = 35;
- if ((h < bg.hue() + M && h > bg.hue() - M)
- || (h < fg.hue() + M && h > fg.hue() - M))
- {
- h = ((bg.hue() + fg.hue()) / (i+1)) % 360;
- s = ((bg.saturation() + fg.saturation() + 2*i)
- / 2) % 256;
- v = ((bg.value() + fg.value() + 2*i) / 2)
- % 256;
- }
- colors.append(QColor::fromHsv(h, s, v));
- }
- return colors;
-}
-
-
-// a hack to mark an event as spontaneous.
-class QETWidget
-{
-public:
- static void setSpont(QEvent *event, bool spont) { event->spont = spont; }
-};
-
-struct GestureState
-{
- int seenGestureEvent;
- struct LastGestureEvent
- {
- struct SingleshotGesture
- {
- bool delivered;
- QPoint offset;
- } singleshot;
- struct PinchGesture
- {
- bool delivered;
- TouchPoint startPoints[2];
- TouchPoint lastPoints[2];
- TouchPoint points[2];
- QPoint offset;
- } pinch;
- struct SecondFingerGesture
- {
- bool delivered;
- TouchPoint startPoint;
- TouchPoint lastPoint;
- TouchPoint point;
- QPoint offset;
- } secondfinger;
- struct PanGesture
- {
- bool delivered;
- TouchPoint startPoints[2];
- TouchPoint lastPoints[2];
- TouchPoint points[2];
- QPoint offset;
- } pan;
- QSet<QString> cancelled;
- } last;
-
- GestureState() { reset(); }
- void reset()
- {
- seenGestureEvent = 0;
- last.singleshot.delivered = false;
- last.singleshot.offset = QPoint();
- last.pinch.delivered = false;
- last.pinch.startPoints[0] = TouchPoint();
- last.pinch.startPoints[1] = TouchPoint();
- last.pinch.lastPoints[0] = TouchPoint();
- last.pinch.lastPoints[1] = TouchPoint();
- last.pinch.points[0] = TouchPoint();
- last.pinch.points[1] = TouchPoint();
- last.pinch.offset = QPoint();
- last.secondfinger.delivered = false;
- last.secondfinger.startPoint = TouchPoint();
- last.secondfinger.lastPoint = TouchPoint();
- last.secondfinger.point = TouchPoint();
- last.secondfinger.offset = QPoint();
- last.pan.delivered = false;
- last.pan.startPoints[0] = TouchPoint();
- last.pan.startPoints[1] = TouchPoint();
- last.pan.lastPoints[0] = TouchPoint();
- last.pan.lastPoints[1] = TouchPoint();
- last.pan.points[0] = TouchPoint();
- last.pan.points[1] = TouchPoint();
- last.cancelled.clear();
- }
-};
-
-struct TouchState
-{
- int seenTouchBeginEvent;
- int seenTouchUpdateEvent;
- int seenTouchEndEvent;
-
- TouchState() { reset(); }
- void reset()
- {
- seenTouchBeginEvent = seenTouchUpdateEvent = seenTouchEndEvent = 0;
- }
-};
-
-class GestureWidget : public QWidget
-{
- Q_OBJECT
- static QVector<QColor> colors;
- static int numberOfWidgets;
-
-public:
- enum Type { DoNotGrabGestures, GrabAllGestures, GrabSingleshot,
- GrabPinch, GrabSecondFinger, GrabPan };
-
- static const int LeftMargin = 10;
- static const int TopMargin = 20;
-
- GestureWidget(Type type = GrabAllGestures)
- {
- if (colors.isEmpty()) {
- colors = highlight(palette().color(QPalette::Window), palette().color(QPalette::Text), 5);
- }
- QPalette p = palette();
- p.setColor(QPalette::Window, colors[numberOfWidgets % colors.size()]);
- setPalette(p);
- setAutoFillBackground(true);
- ++numberOfWidgets;
-
- QVBoxLayout *l = new QVBoxLayout(this);
- l->setSpacing(0);
- l->setContentsMargins(LeftMargin, TopMargin, LeftMargin, TopMargin);
-
- singleshotGestureId = -1;
- pinchGestureId = -1;
- secondFingerGestureId = -1;
- panGestureId = -1;
- if (type == GrabAllGestures || type == GrabSingleshot) {
- singleshotGestureId = grabGesture(SingleshotGestureRecognizer::Name);
- }
- if (type == GrabAllGestures || type == GrabPinch) {
- pinchGestureId = grabGesture(PinchGestureRecognizer::Name);
- }
- if (type == GrabAllGestures || type == GrabSecondFinger) {
- secondFingerGestureId = grabGesture(SecondFingerGestureRecognizer::Name);
- }
- if (type == GrabAllGestures || type == GrabPan) {
- panGestureId = grabGesture(PanGestureRecognizer::Name);
- }
- reset();
- }
- ~GestureWidget()
- {
- --numberOfWidgets;
- ungrabGestures();
- }
-
- void grabSingleshotGesture()
- {
- singleshotGestureId = grabGesture(SingleshotGestureRecognizer::Name);
- }
- void grabPinchGesture()
- {
- pinchGestureId = grabGesture(PinchGestureRecognizer::Name);
- }
- void grabSecondFingerGesture()
- {
- secondFingerGestureId = grabGesture(SecondFingerGestureRecognizer::Name);
- }
- void grabPanGesture()
- {
- panGestureId = grabGesture(PanGestureRecognizer::Name);
- }
- void ungrabGestures()
- {
- releaseGesture(singleshotGestureId);
- singleshotGestureId = -1;
- releaseGesture(pinchGestureId);
- pinchGestureId = -1;
- releaseGesture(secondFingerGestureId);
- secondFingerGestureId = -1;
- releaseGesture(panGestureId);
- panGestureId = -1;
- }
-
- int singleshotGestureId;
- int pinchGestureId;
- int secondFingerGestureId;
- int panGestureId;
-
- bool shouldAcceptSingleshotGesture;
- bool shouldAcceptPinchGesture;
- bool shouldAcceptSecondFingerGesture;
- bool shouldAcceptPanGesture;
-
- GestureState gesture;
- TouchState touch;
-
- void reset()
- {
- shouldAcceptSingleshotGesture = true;
- shouldAcceptPinchGesture = true;
- shouldAcceptSecondFingerGesture = true;
- shouldAcceptPanGesture = true;
- gesture.reset();
- touch.reset();
- }
-protected:
- bool event(QEvent *event)
- {
- if (event->type() == QEvent::TouchBegin) {
- event->accept();
- ++touch.seenTouchBeginEvent;
- return true;
- } else if (event->type() == QEvent::TouchUpdate) {
- ++touch.seenTouchUpdateEvent;
- } else if (event->type() == QEvent::TouchEnd) {
- ++touch.seenTouchEndEvent;
- } else if (event->type() == QEvent::Gesture) {
- QGestureEvent *e = static_cast<QGestureEvent*>(event);
- ++gesture.seenGestureEvent;
- if (SingleshotGesture *g = (SingleshotGesture*)e->gesture(SingleshotGestureRecognizer::Name)) {
- gesture.last.singleshot.delivered = true;
- gesture.last.singleshot.offset = g->offset;
- if (shouldAcceptSingleshotGesture)
- g->accept();
- }
- if (PinchGesture *g = (PinchGesture*)e->gesture(PinchGestureRecognizer::Name)) {
- gesture.last.pinch.delivered = true;
- gesture.last.pinch.startPoints[0] = g->startPoints[0];
- gesture.last.pinch.startPoints[1] = g->startPoints[1];
- gesture.last.pinch.lastPoints[0] = g->lastPoints[0];
- gesture.last.pinch.lastPoints[1] = g->lastPoints[1];
- gesture.last.pinch.points[0] = g->points[0];
- gesture.last.pinch.points[1] = g->points[1];
- gesture.last.pinch.offset = g->offset;
- if (shouldAcceptPinchGesture)
- g->accept();
- }
- if (SecondFingerGesture *g = (SecondFingerGesture*)e->gesture(SecondFingerGestureRecognizer::Name)) {
- gesture.last.secondfinger.delivered = true;
- gesture.last.secondfinger.startPoint = g->startPoint;
- gesture.last.secondfinger.lastPoint = g->lastPoint;
- gesture.last.secondfinger.point = g->point;
- gesture.last.secondfinger.offset = g->offset;
- if (shouldAcceptSecondFingerGesture)
- g->accept();
- }
- if (PanGesture *g = (PanGesture*)e->gesture(PanGestureRecognizer::Name)) {
- gesture.last.pan.delivered = true;
- gesture.last.pan.startPoints[0] = g->startPoints[0];
- gesture.last.pan.startPoints[1] = g->startPoints[1];
- gesture.last.pan.lastPoints[0] = g->lastPoints[0];
- gesture.last.pan.lastPoints[1] = g->lastPoints[1];
- gesture.last.pan.points[0] = g->points[0];
- gesture.last.pan.points[1] = g->points[1];
- gesture.last.pan.offset = g->offset;
- if (shouldAcceptPanGesture)
- g->accept();
- }
- gesture.last.cancelled = e->cancelledGestures();
- return true;
- }
- return QWidget::event(event);
- }
-};
-QVector<QColor> GestureWidget::colors;
-int GestureWidget::numberOfWidgets = 0;
-
-class GraphicsScene : public QGraphicsScene
-{
-public:
- GraphicsScene()
- {
- reset();
- }
- bool shouldAcceptSingleshotGesture;
- bool shouldAcceptPinchGesture;
- bool shouldAcceptSecondFingerGesture;
- GestureState gesture;
-
- void reset()
- {
- shouldAcceptSingleshotGesture = false;
- shouldAcceptPinchGesture = false;
- shouldAcceptSecondFingerGesture = false;
- gesture.reset();
- }
-protected:
- bool event(QEvent *event)
- {
- if (event->type() == QEvent::GraphicsSceneGesture) {
- QGraphicsSceneGestureEvent *e = static_cast<QGraphicsSceneGestureEvent*>(event);
- ++gesture.seenGestureEvent;
- QGraphicsScene::event(event);
- if (SingleshotGesture *g = (SingleshotGesture*)e->gesture(SingleshotGestureRecognizer::Name)) {
- gesture.last.singleshot.delivered = true;
- gesture.last.singleshot.offset = g->offset;
- if (shouldAcceptSingleshotGesture)
- g->accept();
- }
- if (PinchGesture *g = (PinchGesture*)e->gesture(PinchGestureRecognizer::Name)) {
- gesture.last.pinch.delivered = true;
- gesture.last.pinch.startPoints[0] = g->startPoints[0];
- gesture.last.pinch.startPoints[1] = g->startPoints[1];
- gesture.last.pinch.lastPoints[0] = g->lastPoints[0];
- gesture.last.pinch.lastPoints[1] = g->lastPoints[1];
- gesture.last.pinch.points[0] = g->points[0];
- gesture.last.pinch.points[1] = g->points[1];
- gesture.last.pinch.offset = g->offset;
- if (shouldAcceptPinchGesture)
- g->accept();
- }
- if (SecondFingerGesture *g = (SecondFingerGesture*)e->gesture(SecondFingerGestureRecognizer::Name)) {
- gesture.last.secondfinger.delivered = true;
- gesture.last.secondfinger.startPoint = g->startPoint;
- gesture.last.secondfinger.lastPoint = g->lastPoint;
- gesture.last.secondfinger.point = g->point;
- gesture.last.secondfinger.offset = g->offset;
- if (shouldAcceptSecondFingerGesture)
- g->accept();
- }
- gesture.last.cancelled = e->cancelledGestures();
- return true;
- }
- return QGraphicsScene::event(event);
- }
-};
-
-class GraphicsItem : public QGraphicsItem
-{
-public:
- GraphicsItem(int w = 100, int h = 100)
- : width(w), height(h)
- {
- reset();
- }
-
- QRectF boundingRect() const
- {
- return QRectF(0, 0, width, height);
- }
-
- void paint(QPainter *painter, const QStyleOptionGraphicsItem*, QWidget*)
- {
- painter->setBrush(Qt::green);
- painter->drawRect(0, 0, width, height);
- }
-
- void grabSingleshotGesture()
- {
- singleshotGestureId = grabGesture(SingleshotGestureRecognizer::Name);
- }
- void grabPinchGesture()
- {
- pinchGestureId = grabGesture(PinchGestureRecognizer::Name);
- }
- void grabSecondFingerGesture()
- {
- secondFingerGestureId = grabGesture(SecondFingerGestureRecognizer::Name);
- }
- void ungrabGestures()
- {
- releaseGesture(singleshotGestureId);
- singleshotGestureId = -1;
- releaseGesture(pinchGestureId);
- pinchGestureId = -1;
- releaseGesture(secondFingerGestureId);
- secondFingerGestureId = -1;
- }
-
- int width;
- int height;
-
- int singleshotGestureId;
- int pinchGestureId;
- int secondFingerGestureId;
-
- bool shouldAcceptSingleshotGesture;
- bool shouldAcceptPinchGesture;
- bool shouldAcceptSecondFingerGesture;
- GestureState gesture;
-
- TouchState touch;
-
- void reset()
- {
- shouldAcceptSingleshotGesture = true;
- shouldAcceptPinchGesture = true;
- shouldAcceptSecondFingerGesture = true;
- gesture.reset();
- }
-protected:
- bool sceneEvent(QEvent *event)
- {
- if (event->type() == QEvent::TouchBegin) {
- event->accept();
- ++touch.seenTouchBeginEvent;
- return true;
- } else if (event->type() == QEvent::TouchUpdate) {
- ++touch.seenTouchUpdateEvent;
- } else if (event->type() == QEvent::TouchEnd) {
- ++touch.seenTouchEndEvent;
- } else if (event->type() == QEvent::GraphicsSceneGesture) {
- QGraphicsSceneGestureEvent *e = static_cast<QGraphicsSceneGestureEvent*>(event);
- ++gesture.seenGestureEvent;
- if (SingleshotGesture *g = (SingleshotGesture*)e->gesture(SingleshotGestureRecognizer::Name)) {
- gesture.last.singleshot.delivered = true;
- gesture.last.singleshot.offset = g->offset;
- if (shouldAcceptSingleshotGesture)
- g->accept();
- }
- if (PinchGesture *g = (PinchGesture*)e->gesture(PinchGestureRecognizer::Name)) {
- gesture.last.pinch.delivered = true;
- gesture.last.pinch.startPoints[0] = g->startPoints[0];
- gesture.last.pinch.startPoints[1] = g->startPoints[1];
- gesture.last.pinch.lastPoints[0] = g->lastPoints[0];
- gesture.last.pinch.lastPoints[1] = g->lastPoints[1];
- gesture.last.pinch.points[0] = g->points[0];
- gesture.last.pinch.points[1] = g->points[1];
- gesture.last.pinch.offset = g->offset;
- if (shouldAcceptPinchGesture)
- g->accept();
- }
- if (SecondFingerGesture *g = (SecondFingerGesture*)e->gesture(SecondFingerGestureRecognizer::Name)) {
- gesture.last.secondfinger.delivered = true;
- gesture.last.secondfinger.startPoint = g->startPoint;
- gesture.last.secondfinger.lastPoint = g->lastPoint;
- gesture.last.secondfinger.point = g->point;
- gesture.last.secondfinger.offset = g->offset;
- if (shouldAcceptSecondFingerGesture)
- g->accept();
- }
- gesture.last.cancelled = e->cancelledGestures();
- return true;
- }
- return QGraphicsItem::sceneEvent(event);
- }
-};
-
-class tst_Gestures : public QObject
-{
- Q_OBJECT
-
-public:
- tst_Gestures();
- virtual ~tst_Gestures();
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
-private slots:
- void singleshotGesture();
- void pinchGesture();
-
- void simplePropagation();
- void simplePropagation2();
- void acceptedGesturePropagation();
-
- void simpleGraphicsView();
- void simpleGraphicsItem();
- void overlappingGraphicsItems();
-
- void touch_widget();
- void touch_graphicsView();
-
- void panOnWidgets();
-
-private:
- SingleshotGestureRecognizer *singleshotRecognizer;
- PinchGestureRecognizer *pinchRecognizer;
- SecondFingerGestureRecognizer *secondFingerRecognizer;
- PanGestureRecognizer *panGestureRecognizer;
- GestureWidget *mainWidget;
-
- void sendPinchEvents(QWidget *receiver, const QPoint &fromFinger1, const QPoint &fromFinger2);
-};
-
-tst_Gestures::tst_Gestures()
-{
- singleshotRecognizer = new SingleshotGestureRecognizer;
- pinchRecognizer = new PinchGestureRecognizer;
- secondFingerRecognizer = new SecondFingerGestureRecognizer;
- panGestureRecognizer = new PanGestureRecognizer;
- qApp->addGestureRecognizer(singleshotRecognizer);
- qApp->addGestureRecognizer(pinchRecognizer);
- qApp->addGestureRecognizer(secondFingerRecognizer);
- qApp->addGestureRecognizer(panGestureRecognizer);
-}
-
-tst_Gestures::~tst_Gestures()
-{
-}
-
-
-void tst_Gestures::initTestCase()
-{
- mainWidget = new GestureWidget(GestureWidget::DoNotGrabGestures);
- mainWidget->setObjectName("MainGestureWidget");
- mainWidget->resize(500, 600);
- mainWidget->show();
-}
-
-void tst_Gestures::cleanupTestCase()
-{
- delete mainWidget; mainWidget = 0;
-}
-
-void tst_Gestures::init()
-{
- // TODO: Add initialization code here.
- // This will be executed immediately before each test is run.
- mainWidget->reset();
-}
-
-void tst_Gestures::cleanup()
-{
-}
-
-bool sendSpontaneousEvent(QWidget *receiver, QEvent *event)
-{
- QETWidget::setSpont(event, true);
- return qApp->notify(receiver, event);
-}
-
-void tst_Gestures::singleshotGesture()
-{
- mainWidget->grabSingleshotGesture();
- SingleshotEvent event;
- sendSpontaneousEvent(mainWidget, &event);
- QVERIFY(mainWidget->gesture.seenGestureEvent);
- QVERIFY(mainWidget->gesture.last.singleshot.delivered);
- QVERIFY(mainWidget->gesture.last.cancelled.isEmpty());
-}
-
-void tst_Gestures::sendPinchEvents(QWidget *receiver, const QPoint &fromFinger1, const QPoint &fromFinger2)
-{
- int x1 = fromFinger1.x();
- int y1 = fromFinger1.x();
- int x2 = fromFinger2.x();
- int y2 = fromFinger2.x();
-
- TouchEvent event;
- event.points[0] = TouchPoint(0,x1,y1, TouchPoint::Begin);
- event.points[1] = TouchPoint();
- sendSpontaneousEvent(receiver, &event);
- event.points[0] = TouchPoint(0, x1+=2,y1+=2, TouchPoint::Update);
- event.points[1] = TouchPoint();
- sendSpontaneousEvent(receiver, &event);
- event.points[0] = TouchPoint(0, x1,y1, TouchPoint::Update);
- event.points[1] = TouchPoint(1, x2,y2, TouchPoint::Begin);
- sendSpontaneousEvent(receiver, &event);
- event.points[0] = TouchPoint(0, x1+=5,y1+=10, TouchPoint::End);
- event.points[1] = TouchPoint(1, x2+=3,y2+=6, TouchPoint::Update);
- sendSpontaneousEvent(receiver, &event);
- event.points[0] = TouchPoint();
- event.points[1] = TouchPoint(1, x2+=10,y2+=15, TouchPoint::Update);
- sendSpontaneousEvent(receiver, &event);
- event.points[0] = TouchPoint();
- event.points[1] = TouchPoint(1, x2,y2, TouchPoint::End);
- sendSpontaneousEvent(receiver, &event);
-}
-
-void tst_Gestures::pinchGesture()
-{
- mainWidget->grabPinchGesture();
- sendPinchEvents(mainWidget, QPoint(10,10), QPoint(20,20));
-
- QVERIFY(mainWidget->gesture.seenGestureEvent);
- QVERIFY(!mainWidget->gesture.last.singleshot.delivered);
- QVERIFY(mainWidget->gesture.last.cancelled.isEmpty());
- QVERIFY(mainWidget->gesture.last.pinch.delivered);
- QCOMPARE(mainWidget->gesture.last.pinch.startPoints[0].pt, QPoint(10,10));
- QCOMPARE(mainWidget->gesture.last.pinch.startPoints[1].pt, QPoint(20,20));
- QCOMPARE(mainWidget->gesture.last.pinch.offset, QPoint(0,0));
-}
-
-void tst_Gestures::simplePropagation()
-{
- mainWidget->grabSingleshotGesture();
- GestureWidget offsetWidget(GestureWidget::DoNotGrabGestures);
- offsetWidget.setFixedSize(30, 30);
- mainWidget->layout()->addWidget(&offsetWidget);
- GestureWidget nonGestureWidget(GestureWidget::DoNotGrabGestures);
- mainWidget->layout()->addWidget(&nonGestureWidget);
- QApplication::processEvents();
-
- SingleshotEvent event;
- sendSpontaneousEvent(&nonGestureWidget, &event);
- QVERIFY(!offsetWidget.gesture.seenGestureEvent);
- QVERIFY(!nonGestureWidget.gesture.seenGestureEvent);
- QVERIFY(mainWidget->gesture.seenGestureEvent);
- QVERIFY(mainWidget->gesture.last.cancelled.isEmpty());
- QVERIFY(mainWidget->gesture.last.singleshot.delivered);
- QCOMPARE(mainWidget->gesture.last.singleshot.offset, QPoint(GestureWidget::LeftMargin, 30 + GestureWidget::TopMargin));
-}
-
-void tst_Gestures::simplePropagation2()
-{
- mainWidget->grabSingleshotGesture();
- mainWidget->grabPinchGesture();
- GestureWidget nonGestureMiddleWidget(GestureWidget::DoNotGrabGestures);
- GestureWidget secondGestureWidget(GestureWidget::GrabPinch);
- nonGestureMiddleWidget.layout()->addWidget(&secondGestureWidget);
- mainWidget->layout()->addWidget(&nonGestureMiddleWidget);
- QApplication::processEvents();
-
- SingleshotEvent event;
- sendSpontaneousEvent(&secondGestureWidget, &event);
- QVERIFY(!secondGestureWidget.gesture.seenGestureEvent);
- QVERIFY(!nonGestureMiddleWidget.gesture.seenGestureEvent);
- QVERIFY(mainWidget->gesture.seenGestureEvent);
- QVERIFY(mainWidget->gesture.last.singleshot.delivered);
- QVERIFY(mainWidget->gesture.last.cancelled.isEmpty());
- QCOMPARE(mainWidget->gesture.last.singleshot.offset, QPoint(GestureWidget::LeftMargin*2,GestureWidget::TopMargin*2));
-
- mainWidget->reset();
- nonGestureMiddleWidget.reset();
- secondGestureWidget.reset();
-
- sendPinchEvents(&secondGestureWidget, QPoint(10,10), QPoint(20,20));
- QVERIFY(secondGestureWidget.gesture.seenGestureEvent);
- QVERIFY(!secondGestureWidget.gesture.last.singleshot.delivered);
- QVERIFY(secondGestureWidget.gesture.last.pinch.delivered);
- QCOMPARE(secondGestureWidget.gesture.last.pinch.startPoints[0].pt, QPoint(10,10));
- QCOMPARE(secondGestureWidget.gesture.last.pinch.startPoints[1].pt, QPoint(20,20));
- QCOMPARE(secondGestureWidget.gesture.last.pinch.offset, QPoint(0,0));
- QVERIFY(!nonGestureMiddleWidget.gesture.seenGestureEvent);
- QVERIFY(!mainWidget->gesture.seenGestureEvent);
-}
-
-void tst_Gestures::acceptedGesturePropagation()
-{
- mainWidget->grabSingleshotGesture();
- mainWidget->grabPinchGesture();
- mainWidget->grabSecondFingerGesture();
- GestureWidget nonGestureMiddleWidget(GestureWidget::DoNotGrabGestures);
- nonGestureMiddleWidget.setObjectName("nonGestureMiddleWidget");
- GestureWidget secondGestureWidget(GestureWidget::GrabSecondFinger);
- secondGestureWidget.setObjectName("secondGestureWidget");
- nonGestureMiddleWidget.layout()->addWidget(&secondGestureWidget);
- mainWidget->layout()->addWidget(&nonGestureMiddleWidget);
- QApplication::processEvents();
-
- sendPinchEvents(&secondGestureWidget, QPoint(10, 10), QPoint(40, 40));
- QVERIFY(secondGestureWidget.gesture.seenGestureEvent);
- QVERIFY(!secondGestureWidget.gesture.last.singleshot.delivered);
- QVERIFY(!secondGestureWidget.gesture.last.pinch.delivered);
- QVERIFY(secondGestureWidget.gesture.last.secondfinger.delivered);
- QCOMPARE(secondGestureWidget.gesture.last.secondfinger.startPoint.pt, QPoint(40,40));
- QVERIFY(!nonGestureMiddleWidget.gesture.seenGestureEvent);
- QVERIFY(mainWidget->gesture.seenGestureEvent);
- QVERIFY(!mainWidget->gesture.last.singleshot.delivered);
- QVERIFY(!mainWidget->gesture.last.secondfinger.delivered);
- QVERIFY(mainWidget->gesture.last.pinch.delivered);
- QCOMPARE(mainWidget->gesture.last.pinch.startPoints[0].pt, QPoint(10,10));
- QCOMPARE(mainWidget->gesture.last.pinch.startPoints[1].pt, QPoint(40,40));
-
- mainWidget->reset();
- nonGestureMiddleWidget.reset();
- secondGestureWidget.reset();
-
- // don't accept it and make sure it propagates to parent
- secondGestureWidget.shouldAcceptSecondFingerGesture = false;
- sendPinchEvents(&secondGestureWidget, QPoint(10, 10), QPoint(40, 40));
- QVERIFY(secondGestureWidget.gesture.seenGestureEvent);
- QVERIFY(secondGestureWidget.gesture.last.secondfinger.delivered);
- QVERIFY(!nonGestureMiddleWidget.gesture.seenGestureEvent);
- QVERIFY(mainWidget->gesture.seenGestureEvent);
- QVERIFY(!mainWidget->gesture.last.singleshot.delivered);
- QVERIFY(mainWidget->gesture.last.secondfinger.delivered);
- QVERIFY(mainWidget->gesture.last.pinch.delivered);
-}
-
-void tst_Gestures::simpleGraphicsView()
-{
- mainWidget->grabSingleshotGesture();
- GraphicsScene scene;
- QGraphicsView view(&scene);
- view.grabGesture(SingleshotGestureRecognizer::Name);
- mainWidget->layout()->addWidget(&view);
- QApplication::processEvents();
-
- scene.shouldAcceptSingleshotGesture = true;
-
- SingleshotEvent event;
- sendSpontaneousEvent(&view, &event);
- QVERIFY(!mainWidget->gesture.seenGestureEvent);
- QVERIFY(scene.gesture.seenGestureEvent);
- QVERIFY(scene.gesture.last.singleshot.delivered);
- QVERIFY(scene.gesture.last.cancelled.isEmpty());
-}
-
-void tst_Gestures::simpleGraphicsItem()
-{
- mainWidget->grabSingleshotGesture();
- GraphicsScene scene;
- QGraphicsView view(&scene);
- mainWidget->layout()->addWidget(&view);
- GraphicsItem *item = new GraphicsItem;
- item->grabSingleshotGesture();
- item->setPos(30, 50);
- scene.addItem(item);
- QApplication::processEvents();
-
- QPoint pt = view.mapFromScene(item->mapToScene(30, 30));
- SingleshotEvent event(pt.x(), pt.y());
- sendSpontaneousEvent(&view, &event);
- QVERIFY(item->gesture.seenGestureEvent);
- QVERIFY(scene.gesture.seenGestureEvent);
- QVERIFY(!mainWidget->gesture.seenGestureEvent);
-
- item->reset();
- scene.reset();
- mainWidget->reset();
-
- item->shouldAcceptSingleshotGesture = false;
- // outside of the graphicsitem
- pt = view.mapFromScene(item->mapToScene(-10, -10));
- SingleshotEvent event2(pt.x(), pt.y());
- sendSpontaneousEvent(&view, &event2);
- QVERIFY(!item->gesture.seenGestureEvent);
- QVERIFY(scene.gesture.seenGestureEvent);
- QVERIFY(mainWidget->gesture.seenGestureEvent);
-}
-
-void tst_Gestures::overlappingGraphicsItems()
-{
- mainWidget->grabSingleshotGesture();
- GraphicsScene scene;
- QGraphicsView view(&scene);
- mainWidget->layout()->addWidget(&view);
-
- GraphicsItem *item = new GraphicsItem(300, 100);
- item->setPos(30, 50);
- scene.addItem(item);
- GraphicsItem *subitem1 = new GraphicsItem(50, 70);
- subitem1->setPos(70, 70);
- subitem1->setZValue(1);
- scene.addItem(subitem1);
- GraphicsItem *subitem2 = new GraphicsItem(50, 70);
- subitem2->setPos(250, 70);
- subitem2->setZValue(1);
- scene.addItem(subitem2);
- QApplication::processEvents();
-
- item->grabSingleshotGesture();
- item->grabPinchGesture();
- item->grabSecondFingerGesture();
- subitem1->grabSingleshotGesture();
- subitem2->grabSecondFingerGesture();
-
- QPoint pt = view.mapFromScene(subitem1->mapToScene(20, 20));
- SingleshotEvent event(pt.x(), pt.y());
- sendSpontaneousEvent(&view, &event);
- QVERIFY(scene.gesture.seenGestureEvent);
- QVERIFY(!subitem2->gesture.seenGestureEvent);
- QVERIFY(!item->gesture.seenGestureEvent);
- QVERIFY(!mainWidget->gesture.seenGestureEvent);
- QVERIFY(subitem1->gesture.seenGestureEvent);
- QVERIFY(subitem1->gesture.last.singleshot.delivered);
-
- item->reset();
- subitem1->reset();
- subitem2->reset();
- scene.reset();
- mainWidget->reset();
-
- subitem1->shouldAcceptSingleshotGesture = false;
- SingleshotEvent event2(pt.x(), pt.y());
- sendSpontaneousEvent(&view, &event2);
- QVERIFY(scene.gesture.seenGestureEvent);
- QVERIFY(!subitem2->gesture.seenGestureEvent);
- QVERIFY(subitem1->gesture.seenGestureEvent);
- QVERIFY(item->gesture.seenGestureEvent);
- QVERIFY(!mainWidget->gesture.seenGestureEvent);
- QVERIFY(subitem1->gesture.last.singleshot.delivered);
- QVERIFY(item->gesture.last.singleshot.delivered);
-}
-
-void tst_Gestures::touch_widget()
-{
- GestureWidget leftWidget(GestureWidget::DoNotGrabGestures);
- leftWidget.setObjectName("leftWidget");
- leftWidget.setAttribute(Qt::WA_AcceptTouchEvents);
- GestureWidget rightWidget(GestureWidget::DoNotGrabGestures);
- rightWidget.setObjectName("rightWidget");
- rightWidget.setAttribute(Qt::WA_AcceptTouchEvents);
- delete mainWidget->layout();
- (void)new QHBoxLayout(mainWidget);
- mainWidget->layout()->addWidget(&leftWidget);
- mainWidget->layout()->addWidget(&rightWidget);
- QApplication::processEvents();
-
- QTest::touchEvent()
- .press(0, QPoint(10, 10), &leftWidget);
- QTest::touchEvent()
- .move(0, QPoint(12, 30), &leftWidget);
- QTest::touchEvent()
- .stationary(0)
- .press(1, QPoint(15, 15), &rightWidget);
- QTest::touchEvent()
- .move(0, QPoint(10, 35), &leftWidget)
- .press(1, QPoint(15, 15), &rightWidget);
- QTest::touchEvent()
- .move(0, QPoint(10, 40), &leftWidget)
- .move(1, QPoint(20, 50), &rightWidget);
- QTest::touchEvent()
- .release(0, QPoint(10, 40), &leftWidget)
- .release(1, QPoint(20, 50), &rightWidget);
- QVERIFY(!mainWidget->touch.seenTouchBeginEvent);
- QVERIFY(leftWidget.touch.seenTouchBeginEvent);
- QVERIFY(leftWidget.touch.seenTouchUpdateEvent);
- QVERIFY(leftWidget.touch.seenTouchEndEvent);
- QVERIFY(rightWidget.touch.seenTouchBeginEvent);
- QVERIFY(rightWidget.touch.seenTouchUpdateEvent);
- QVERIFY(rightWidget.touch.seenTouchEndEvent);
-}
-
-void tst_Gestures::touch_graphicsView()
-{
- mainWidget->setAttribute(Qt::WA_AcceptTouchEvents);
- GraphicsScene scene;
- QGraphicsView view(&scene);
- view.viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
- mainWidget->layout()->addWidget(&view);
-
- GraphicsItem *item = new GraphicsItem(300, 100);
- item->setAcceptTouchEvents(true);
- item->setPos(30, 50);
- scene.addItem(item);
- GraphicsItem *subitem1 = new GraphicsItem(50, 70);
- subitem1->setAcceptTouchEvents(true);
- subitem1->setPos(70, 70);
- scene.addItem(subitem1);
- GraphicsItem *subitem2 = new GraphicsItem(50, 70);
- subitem2->setAcceptTouchEvents(true);
- subitem2->setPos(250, 70);
- scene.addItem(subitem2);
- QApplication::processEvents();
-
- QRect itemRect = view.mapFromScene(item->mapRectToScene(item->boundingRect())).boundingRect();
- QPoint pt = itemRect.center();
- QTest::touchEvent(view.viewport())
- .press(0, pt)
- .press(1, pt);
- QTest::touchEvent(view.viewport())
- .move(0, pt + QPoint(20, 30))
- .move(1, QPoint(300, 300));
- QTest::touchEvent(view.viewport())
- .stationary(0)
- .move(1, QPoint(330, 330));
- QTest::touchEvent(view.viewport())
- .release(0, QPoint(120, 120))
- .release(1, QPoint(300, 300));
-
- QVERIFY(item->touch.seenTouchBeginEvent);
- QVERIFY(item->touch.seenTouchUpdateEvent);
- QVERIFY(item->touch.seenTouchEndEvent);
-}
-
-void tst_Gestures::panOnWidgets()
-{
- GestureWidget leftWidget(GestureWidget::GrabPan);
- leftWidget.setObjectName("leftWidget");
- leftWidget.setAttribute(Qt::WA_AcceptTouchEvents);
- GestureWidget rightWidget(GestureWidget::GrabPan);
- rightWidget.setObjectName("rightWidget");
- rightWidget.setAttribute(Qt::WA_AcceptTouchEvents);
- delete mainWidget->layout();
- (void)new QHBoxLayout(mainWidget);
- mainWidget->layout()->addWidget(&leftWidget);
- mainWidget->layout()->addWidget(&rightWidget);
- QApplication::processEvents();
-
- QTest::touchEvent()
- .press(0, QPoint(10, 10), &leftWidget);
- QTest::touchEvent()
- .move(0, QPoint(12, 30), &leftWidget);
- QTest::touchEvent()
- .stationary(0)
- .press(1, QPoint(15, 15), &rightWidget);
- QTest::touchEvent()
- .move(0, QPoint(10, 35), &leftWidget)
- .press(1, QPoint(15, 15), &rightWidget);
- QTest::touchEvent()
- .move(0, QPoint(10, 40), &leftWidget)
- .move(1, QPoint(20, 50), &rightWidget);
- QTest::touchEvent()
- .release(0, QPoint(10, 40), &leftWidget)
- .release(1, QPoint(20, 50), &rightWidget);
-
- QVERIFY(leftWidget.gesture.last.pan.delivered);
- QVERIFY(rightWidget.gesture.last.pan.delivered);
-}
-
-QTEST_MAIN(tst_Gestures)
-#include "tst_gestures.moc"
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp
index eb4a09b..e6668a9 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main.cpp
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
// IMPORTANT!!!! If you want to add testdata to this file,
// always add it to the end in order to not change the linenumbers of translations!!!
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main2.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main2.cpp
index 1c72ac2..61029b3 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main2.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main2.cpp
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
// IMPORTANT!!!! If you want to add testdata to this file,
// always add it to the end in order to not change the linenumbers of translations!!!
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main3.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main3.cpp
index 731d5cdf..6a80349 100644
--- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main3.cpp
+++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/main3.cpp
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
// IMPORTANT!!!! If you want to add testdata to this file,
// always add it to the end in order to not change the linenumbers of translations!!!
diff --git a/tests/auto/qabstractitemmodel/dynamictreemodel.cpp b/tests/auto/qabstractitemmodel/dynamictreemodel.cpp
index 6425dcd..dd0615d 100644
--- a/tests/auto/qabstractitemmodel/dynamictreemodel.cpp
+++ b/tests/auto/qabstractitemmodel/dynamictreemodel.cpp
@@ -41,13 +41,10 @@
#include "dynamictreemodel.h"
-#include <QHash>
-#include <QList>
-#include <QTimer>
+#include <QtCore/QHash>
+#include <QtCore/QList>
+#include <QtCore/QTimer>
-#include <QDebug>
-
-#include <kdebug.h>
DynamicTreeModel::DynamicTreeModel(QObject *parent)
: QAbstractItemModel(parent),
diff --git a/tests/auto/qabstractitemmodel/dynamictreemodel.h b/tests/auto/qabstractitemmodel/dynamictreemodel.h
index d84bf68..a769c38 100644
--- a/tests/auto/qabstractitemmodel/dynamictreemodel.h
+++ b/tests/auto/qabstractitemmodel/dynamictreemodel.h
@@ -42,14 +42,11 @@
#ifndef DYNAMICTREEMODEL_H
#define DYNAMICTREEMODEL_H
-#include <QAbstractItemModel>
+#include <QtCore/QAbstractItemModel>
-#include <QHash>
-#include <QList>
+#include <QtCore/QHash>
+#include <QtCore/QList>
-#include <QDebug>
-
-#include <kdebug.h>
template<typename T> class QList;
diff --git a/tests/auto/qabstractitemmodel/qabstractitemmodel.pro b/tests/auto/qabstractitemmodel/qabstractitemmodel.pro
index 84ed5a2..a31868b 100644
--- a/tests/auto/qabstractitemmodel/qabstractitemmodel.pro
+++ b/tests/auto/qabstractitemmodel/qabstractitemmodel.pro
@@ -2,5 +2,5 @@ load(qttest_p4)
SOURCES += tst_qabstractitemmodel.cpp dynamictreemodel.cpp
HEADERS += dynamictreemodel.h
-QT = core
+
diff --git a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
index da65e7d..58832c7 100644
--- a/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
+++ b/tests/auto/qabstractitemmodel/tst_qabstractitemmodel.cpp
@@ -43,7 +43,7 @@
#include <QtTest/QtTest>
#include <QtCore/QtCore>
-#include <QSortFilterProxyModel>
+#include <QtGui/QSortFilterProxyModel>
//TESTED_CLASS=QAbstractListModel QAbstractTableModel
//TESTED_FILES=
diff --git a/tests/auto/qatomicint/tst_qatomicint.cpp b/tests/auto/qatomicint/tst_qatomicint.cpp
index c3ea31d..5fde633 100644
--- a/tests/auto/qatomicint/tst_qatomicint.cpp
+++ b/tests/auto/qatomicint/tst_qatomicint.cpp
@@ -59,6 +59,8 @@ public:
~tst_QAtomicInt();
private slots:
+ void warningFree();
+
// QAtomicInt members
void constructor_data();
void constructor();
@@ -101,6 +103,9 @@ private slots:
void testAndSet_loop();
void fetchAndAdd_loop();
void fetchAndAdd_threadedLoop();
+
+private:
+ static void warningFreeHelper();
};
tst_QAtomicInt::tst_QAtomicInt()
@@ -109,6 +114,45 @@ tst_QAtomicInt::tst_QAtomicInt()
tst_QAtomicInt::~tst_QAtomicInt()
{ }
+void tst_QAtomicInt::warningFreeHelper()
+{
+ Q_ASSERT(false);
+ // The code below is bogus, and shouldn't be run. We're looking for warnings, only.
+
+ QBasicAtomicInt i = Q_BASIC_ATOMIC_INITIALIZER(0);
+
+ int expectedValue = 0;
+ int newValue = 0;
+ int valueToAdd = 0;
+
+ i.ref();
+ i.deref();
+
+ i.testAndSetRelaxed(expectedValue, newValue);
+ i.testAndSetAcquire(expectedValue, newValue);
+ i.testAndSetRelease(expectedValue, newValue);
+ i.testAndSetOrdered(expectedValue, newValue);
+
+ i.fetchAndStoreRelaxed(newValue);
+ i.fetchAndStoreAcquire(newValue);
+ i.fetchAndStoreRelease(newValue);
+ i.fetchAndStoreOrdered(newValue);
+
+ i.fetchAndAddRelaxed(valueToAdd);
+ i.fetchAndAddAcquire(valueToAdd);
+ i.fetchAndAddRelease(valueToAdd);
+ i.fetchAndAddOrdered(valueToAdd);
+}
+
+void tst_QAtomicInt::warningFree()
+{
+ // This is a compile time check for warnings.
+ // No need for actual work here.
+
+ void (*foo)() = &warningFreeHelper;
+ (void)foo;
+}
+
void tst_QAtomicInt::constructor_data()
{
QTest::addColumn<int>("value");
diff --git a/tests/auto/qatomicpointer/tst_qatomicpointer.cpp b/tests/auto/qatomicpointer/tst_qatomicpointer.cpp
index b9636a0..c1e0efd 100644
--- a/tests/auto/qatomicpointer/tst_qatomicpointer.cpp
+++ b/tests/auto/qatomicpointer/tst_qatomicpointer.cpp
@@ -58,6 +58,8 @@ public:
~tst_QAtomicPointer();
private slots:
+ void warningFree();
+
void constructor();
void copy_constructor();
void equality_operator();
@@ -78,6 +80,9 @@ private slots:
void isFetchAndAddWaitFree();
void fetchAndAdd_data();
void fetchAndAdd();
+
+private:
+ static void warningFreeHelper();
};
tst_QAtomicPointer::tst_QAtomicPointer()
@@ -86,6 +91,49 @@ tst_QAtomicPointer::tst_QAtomicPointer()
tst_QAtomicPointer::~tst_QAtomicPointer()
{ }
+struct WFHC
+{
+ void bar() {}
+};
+
+void tst_QAtomicPointer::warningFreeHelper()
+{
+ Q_ASSERT(false);
+ // The code below is bogus, and shouldn't be run. We're looking for warnings, only.
+
+ QBasicAtomicPointer<WFHC> p = Q_BASIC_ATOMIC_INITIALIZER(0);
+
+ p->bar();
+
+ WFHC *expectedValue = 0;
+ WFHC *newValue = 0;
+ qptrdiff valueToAdd = 0;
+
+ p.testAndSetRelaxed(expectedValue, newValue);
+ p.testAndSetAcquire(expectedValue, newValue);
+ p.testAndSetRelease(expectedValue, newValue);
+ p.testAndSetOrdered(expectedValue, newValue);
+
+ p.fetchAndStoreRelaxed(newValue);
+ p.fetchAndStoreAcquire(newValue);
+ p.fetchAndStoreRelease(newValue);
+ p.fetchAndStoreOrdered(newValue);
+
+ p.fetchAndAddRelaxed(valueToAdd);
+ p.fetchAndAddAcquire(valueToAdd);
+ p.fetchAndAddRelease(valueToAdd);
+ p.fetchAndAddOrdered(valueToAdd);
+}
+
+void tst_QAtomicPointer::warningFree()
+{
+ // This is a compile time check for warnings.
+ // No need for actual work here.
+
+ void (*foo)() = &warningFreeHelper;
+ (void)foo;
+}
+
void tst_QAtomicPointer::constructor()
{
void *one = this;
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 541b5ba..aa1f2b8 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -289,6 +289,9 @@ private slots:
void setGraphicsEffect();
void panel();
void addPanelToActiveScene();
+ void activate();
+ void setActivePanelOnInactiveScene();
+ void activationOnShowHide();
// task specific tests below me
void task141694_textItemEnsureVisible();
@@ -5417,6 +5420,7 @@ void tst_QGraphicsItem::contextMenuEventPropagation()
qt_x11_wait_for_window_manager(&view);
#endif
view.resize(200, 200);
+ QTest::qWait(250);
QContextMenuEvent event(QContextMenuEvent::Mouse, QPoint(10, 10),
view.viewport()->mapToGlobal(QPoint(10, 10)));
@@ -7823,26 +7827,15 @@ void tst_QGraphicsItem::panel()
// No previous activation, so the scene is active.
QVERIFY(scene.isActive());
- QVERIFY(!scene.activePanel());
- QVERIFY(!panel1->isActive());
- QVERIFY(!panel2->isActive());
- QVERIFY(!panel3->isActive());
- QVERIFY(!panel4->isActive());
- QVERIFY(notPanel1->isActive());
- QVERIFY(notPanel2->isActive());
- QCOMPARE(spy_activate_notPanel1.count(), 1);
- QCOMPARE(spy_activate_notPanel2.count(), 1);
-
- // Switch to panel1.
- scene.setActivePanel(panel1);
+ QCOMPARE(scene.activePanel(), (QGraphicsItem *)panel1);
QVERIFY(panel1->isActive());
QVERIFY(!panel2->isActive());
QVERIFY(!panel3->isActive());
QVERIFY(!panel4->isActive());
QVERIFY(!notPanel1->isActive());
QVERIFY(!notPanel2->isActive());
- QCOMPARE(spy_deactivate_notPanel1.count(), 1);
- QCOMPARE(spy_deactivate_notPanel2.count(), 1);
+ QCOMPARE(spy_deactivate_notPanel1.count(), 0);
+ QCOMPARE(spy_deactivate_notPanel2.count(), 0);
QCOMPARE(spy_activate_panel1.count(), 1);
QCOMPARE(spy_activate_panel2.count(), 0);
QCOMPARE(spy_activate_panel3.count(), 0);
@@ -7857,8 +7850,8 @@ void tst_QGraphicsItem::panel()
QVERIFY(!panel4->isActive());
QVERIFY(notPanel1->isActive());
QVERIFY(notPanel2->isActive());
- QCOMPARE(spy_activate_notPanel1.count(), 2);
- QCOMPARE(spy_activate_notPanel2.count(), 2);
+ QCOMPARE(spy_activate_notPanel1.count(), 1);
+ QCOMPARE(spy_activate_notPanel2.count(), 1);
// Deactivate the scene
QApplication::sendEvent(&scene, &deactivate);
@@ -7869,8 +7862,8 @@ void tst_QGraphicsItem::panel()
QVERIFY(!panel4->isActive());
QVERIFY(!notPanel1->isActive());
QVERIFY(!notPanel2->isActive());
- QCOMPARE(spy_deactivate_notPanel1.count(), 2);
- QCOMPARE(spy_deactivate_notPanel2.count(), 2);
+ QCOMPARE(spy_deactivate_notPanel1.count(), 1);
+ QCOMPARE(spy_deactivate_notPanel2.count(), 1);
// Reactivate the scene
QApplication::sendEvent(&scene, &activate);
@@ -7881,14 +7874,14 @@ void tst_QGraphicsItem::panel()
QVERIFY(!panel4->isActive());
QVERIFY(notPanel1->isActive());
QVERIFY(notPanel2->isActive());
- QCOMPARE(spy_activate_notPanel1.count(), 3);
- QCOMPARE(spy_activate_notPanel2.count(), 3);
+ QCOMPARE(spy_activate_notPanel1.count(), 2);
+ QCOMPARE(spy_activate_notPanel2.count(), 2);
// Switch to panel1
scene.setActivePanel(panel1);
QVERIFY(panel1->isActive());
- QCOMPARE(spy_deactivate_notPanel1.count(), 3);
- QCOMPARE(spy_deactivate_notPanel2.count(), 3);
+ QCOMPARE(spy_deactivate_notPanel1.count(), 2);
+ QCOMPARE(spy_deactivate_notPanel2.count(), 2);
QCOMPARE(spy_activate_panel1.count(), 2);
// Deactivate the scene
@@ -7942,5 +7935,173 @@ void tst_QGraphicsItem::addPanelToActiveScene()
QCOMPARE(scene.activePanel(), (QGraphicsItem *)rect);
}
+void tst_QGraphicsItem::activate()
+{
+ QGraphicsScene scene;
+ QGraphicsRectItem *rect = scene.addRect(-10, -10, 20, 20);
+ QVERIFY(!rect->isActive());
+
+ QEvent activate(QEvent::WindowActivate);
+ QEvent deactivate(QEvent::WindowDeactivate);
+
+ QApplication::sendEvent(&scene, &activate);
+
+ // Non-panel item (active when scene is active).
+ QVERIFY(rect->isActive());
+
+ QGraphicsRectItem *rect2 = new QGraphicsRectItem;
+ rect2->setFlag(QGraphicsItem::ItemIsPanel);
+ QGraphicsRectItem *rect3 = new QGraphicsRectItem;
+ rect3->setFlag(QGraphicsItem::ItemIsPanel);
+
+ // Test normal activation.
+ QVERIFY(!rect2->isActive());
+ scene.addItem(rect2);
+ QVERIFY(rect2->isActive()); // first panel item is activated
+ scene.addItem(rect3);
+ QVERIFY(!rect3->isActive()); // second panel item is _not_ activated
+ rect3->setActive(true);
+ QVERIFY(rect3->isActive());
+ scene.removeItem(rect3);
+ QVERIFY(!rect3->isActive()); // no panel is active anymore
+ QCOMPARE(scene.activePanel(), (QGraphicsItem *)0);
+ scene.addItem(rect3);
+ QVERIFY(rect3->isActive()); // second panel item is activated
+
+ // Test pending activation.
+ scene.removeItem(rect3);
+ rect2->setActive(true);
+ QVERIFY(rect2->isActive()); // first panel item is activated
+ rect3->setActive(true);
+ QVERIFY(!rect3->isActive()); // not active (yet)
+ scene.addItem(rect3);
+ QVERIFY(rect3->isActive()); // now becomes active
+
+ // Test pending deactivation.
+ scene.removeItem(rect3);
+ rect3->setActive(false);
+ scene.addItem(rect3);
+ QVERIFY(!rect3->isActive()); // doesn't become active
+
+ // Child of panel activation.
+ rect3->setActive(true);
+ QGraphicsRectItem *rect4 = new QGraphicsRectItem;
+ rect4->setFlag(QGraphicsItem::ItemIsPanel);
+ QGraphicsRectItem *rect5 = new QGraphicsRectItem(rect4);
+ QGraphicsRectItem *rect6 = new QGraphicsRectItem(rect5);
+ scene.addItem(rect4);
+ QCOMPARE(scene.activePanel(), (QGraphicsItem *)rect3);
+ scene.removeItem(rect4);
+ rect6->setActive(true);
+ scene.addItem(rect4);
+ QVERIFY(rect4->isActive());
+ QVERIFY(rect5->isActive());
+ QVERIFY(rect6->isActive());
+ QCOMPARE(scene.activePanel(), (QGraphicsItem *)rect4);
+ scene.removeItem(rect4); // no active panel
+ rect6->setActive(false);
+ scene.addItem(rect4);
+ QVERIFY(!rect4->isActive());
+ QVERIFY(!rect5->isActive());
+ QVERIFY(!rect6->isActive());
+ QCOMPARE(scene.activePanel(), (QGraphicsItem *)0);
+
+ // Controlling auto-activation when the scene changes activation.
+ rect4->setActive(true);
+ QApplication::sendEvent(&scene, &deactivate);
+ QVERIFY(!scene.isActive());
+ QVERIFY(!rect4->isActive());
+ rect4->setActive(false);
+ QApplication::sendEvent(&scene, &activate);
+ QVERIFY(scene.isActive());
+ QVERIFY(!scene.activePanel());
+ QVERIFY(!rect4->isActive());
+}
+
+void tst_QGraphicsItem::setActivePanelOnInactiveScene()
+{
+ QGraphicsScene scene;
+ QGraphicsRectItem *item = scene.addRect(QRectF());
+ QGraphicsRectItem *panel = scene.addRect(QRectF());
+ panel->setFlag(QGraphicsItem::ItemIsPanel);
+
+ EventSpy itemActivateSpy(&scene, item, QEvent::WindowActivate);
+ EventSpy itemDeactivateSpy(&scene, item, QEvent::WindowDeactivate);
+ EventSpy panelActivateSpy(&scene, panel, QEvent::WindowActivate);
+ EventSpy panelDeactivateSpy(&scene, panel, QEvent::WindowDeactivate);
+ EventSpy sceneActivationChangeSpy(&scene, QEvent::ActivationChange);
+
+ scene.setActivePanel(panel);
+ QCOMPARE(scene.activePanel(), (QGraphicsItem *)0);
+ QCOMPARE(itemActivateSpy.count(), 0);
+ QCOMPARE(itemDeactivateSpy.count(), 0);
+ QCOMPARE(panelActivateSpy.count(), 0);
+ QCOMPARE(panelDeactivateSpy.count(), 0);
+ QCOMPARE(sceneActivationChangeSpy.count(), 0);
+}
+
+void tst_QGraphicsItem::activationOnShowHide()
+{
+ QGraphicsScene scene;
+ QEvent activate(QEvent::WindowActivate);
+ QApplication::sendEvent(&scene, &activate);
+
+ QGraphicsRectItem *rootPanel = scene.addRect(QRectF());
+ rootPanel->setFlag(QGraphicsItem::ItemIsPanel);
+ rootPanel->setActive(true);
+
+ QGraphicsRectItem *subPanel = new QGraphicsRectItem;
+ subPanel->setFlag(QGraphicsItem::ItemIsPanel);
+
+ // Reparenting onto an active panel auto-activates the child panel.
+ subPanel->setParentItem(rootPanel);
+ QVERIFY(subPanel->isActive());
+ QVERIFY(!rootPanel->isActive());
+
+ // Hiding an active child panel will reactivate the parent panel.
+ subPanel->hide();
+ QVERIFY(rootPanel->isActive());
+
+ // Showing a child panel will auto-activate it.
+ subPanel->show();
+ QVERIFY(subPanel->isActive());
+ QVERIFY(!rootPanel->isActive());
+
+ // Adding an unrelated panel doesn't affect activation.
+ QGraphicsRectItem *otherPanel = new QGraphicsRectItem;
+ otherPanel->setFlag(QGraphicsItem::ItemIsPanel);
+ scene.addItem(otherPanel);
+ QVERIFY(subPanel->isActive());
+
+ // Showing an unrelated panel doesn't affect activation.
+ otherPanel->hide();
+ otherPanel->show();
+ QVERIFY(subPanel->isActive());
+
+ // Add a non-panel item.
+ QGraphicsRectItem *otherItem = new QGraphicsRectItem;
+ scene.addItem(otherItem);
+ otherItem->setActive(true);
+ QVERIFY(otherItem->isActive());
+
+ // Reparent a panel onto an active non-panel item.
+ subPanel->setParentItem(otherItem);
+ QVERIFY(subPanel->isActive());
+
+ // Showing a child panel of a non-panel item will activate it.
+ subPanel->hide();
+ QVERIFY(!subPanel->isActive());
+ QVERIFY(otherItem->isActive());
+ subPanel->show();
+ QVERIFY(subPanel->isActive());
+
+ // Hiding a toplevel active panel will pass activation back
+ // to the non-panel items.
+ rootPanel->setActive(true);
+ rootPanel->hide();
+ QVERIFY(!rootPanel->isActive());
+ QVERIFY(otherItem->isActive());
+}
+
QTEST_MAIN(tst_QGraphicsItem)
#include "tst_qgraphicsitem.moc"
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index 663de22..65e6e56 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -352,12 +352,12 @@ void tst_QGraphicsWidget::activation()
QEvent activateEvent(QEvent::WindowActivate);
QApplication::sendEvent(&scene, &activateEvent);
- QVERIFY(widget->isActiveWindow());
- QVERIFY(!window1->isActiveWindow());
+ QVERIFY(!widget->isActiveWindow());
+ QVERIFY(window1->isActiveWindow());
QVERIFY(!window2->isActiveWindow());
scene.setActiveWindow(window1);
- QVERIFY(widget->isActiveWindow());
+ QVERIFY(!widget->isActiveWindow());
QVERIFY(window1->isActiveWindow());
QVERIFY(!window2->isActiveWindow());
diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
index 6549be8..419eb71 100644
--- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
+++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
@@ -189,7 +189,9 @@ void tst_QHttpNetworkConnection::head()
QCOMPARE(reply->statusCode(), statusCode);
QCOMPARE(reply->reasonPhrase(), statusString);
- QCOMPARE(reply->contentLength(), qint64(contentLength));
+ // only check it if it is set
+ if (reply->contentLength() != -1)
+ QCOMPARE(reply->contentLength(), qint64(contentLength));
QVERIFY(reply->isFinished());
@@ -249,7 +251,9 @@ void tst_QHttpNetworkConnection::get()
QCOMPARE(reply->statusCode(), statusCode);
QCOMPARE(reply->reasonPhrase(), statusString);
- QCOMPARE(reply->contentLength(), qint64(contentLength));
+ // only check it if it is set
+ if (reply->contentLength() != -1)
+ QCOMPARE(reply->contentLength(), qint64(contentLength));
stopWatch.start();
QByteArray ba;
diff --git a/tests/auto/qimagereader/images/qt.gif b/tests/auto/qimagereader/images/qt.gif
new file mode 100644
index 0000000..e0a5a80
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt.gif
Binary files differ
diff --git a/tests/auto/qimagereader/images/qt1.gif b/tests/auto/qimagereader/images/qt1.gif
new file mode 100644
index 0000000..0ce910c
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt1.gif
Binary files differ
diff --git a/tests/auto/qimagereader/images/qt2.gif b/tests/auto/qimagereader/images/qt2.gif
new file mode 100644
index 0000000..993a315
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt2.gif
Binary files differ
diff --git a/tests/auto/qimagereader/images/qt3.gif b/tests/auto/qimagereader/images/qt3.gif
new file mode 100644
index 0000000..7391678
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt3.gif
Binary files differ
diff --git a/tests/auto/qimagereader/images/qt4.gif b/tests/auto/qimagereader/images/qt4.gif
new file mode 100644
index 0000000..41109a9
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt4.gif
Binary files differ
diff --git a/tests/auto/qimagereader/images/qt5.gif b/tests/auto/qimagereader/images/qt5.gif
new file mode 100644
index 0000000..5a3fb54
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt5.gif
Binary files differ
diff --git a/tests/auto/qimagereader/images/qt6.gif b/tests/auto/qimagereader/images/qt6.gif
new file mode 100644
index 0000000..f22e7c9
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt6.gif
Binary files differ
diff --git a/tests/auto/qimagereader/images/qt7.gif b/tests/auto/qimagereader/images/qt7.gif
new file mode 100644
index 0000000..a315671
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt7.gif
Binary files differ
diff --git a/tests/auto/qimagereader/images/qt8.gif b/tests/auto/qimagereader/images/qt8.gif
new file mode 100644
index 0000000..2a7d09e
--- /dev/null
+++ b/tests/auto/qimagereader/images/qt8.gif
Binary files differ
diff --git a/tests/auto/qimagereader/qimagereader.qrc b/tests/auto/qimagereader/qimagereader.qrc
index c6b963b..11b9406 100644
--- a/tests/auto/qimagereader/qimagereader.qrc
+++ b/tests/auto/qimagereader/qimagereader.qrc
@@ -1,5 +1,5 @@
-<!DOCTYPE RCC><RCC version="1.0">
- <qresource>
+<RCC>
+ <qresource prefix="/" >
<file>images/16bpp.bmp</file>
<file>images/4bpp-rle.bmp</file>
<file>images/YCbCr_cmyk.jpg</file>
@@ -48,5 +48,14 @@
<file>images/tst7.png</file>
<file>images/transparent.xpm</file>
<file>images/trolltech.gif</file>
+ <file>images/qt.gif</file>
+ <file>images/qt1.gif</file>
+ <file>images/qt2.gif</file>
+ <file>images/qt3.gif</file>
+ <file>images/qt4.gif</file>
+ <file>images/qt5.gif</file>
+ <file>images/qt6.gif</file>
+ <file>images/qt7.gif</file>
+ <file>images/qt8.gif</file>
</qresource>
</RCC>
diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp
index 27c6925..a325a33 100644
--- a/tests/auto/qimagereader/tst_qimagereader.cpp
+++ b/tests/auto/qimagereader/tst_qimagereader.cpp
@@ -140,6 +140,7 @@ private slots:
#if defined QTEST_HAVE_GIF
void gifHandlerBugs();
+ void animatedGif();
#endif
void readCorruptImage_data();
@@ -710,6 +711,18 @@ void tst_QImageReader::gifHandlerBugs()
QCOMPARE(im1.convertToFormat(QImage::Format_ARGB32), im2.convertToFormat(QImage::Format_ARGB32));
}
}
+
+void tst_QImageReader::animatedGif()
+{
+ QImageReader io(prefix + "qt.gif");
+ QImage image= io.read();
+ int i=0;
+ while(!image.isNull()){
+ QString frameName = QString(prefix + "qt%1.gif").arg(++i);
+ QCOMPARE(image, QImage(frameName));
+ image=io.read();
+ }
+}
#endif
class Server : public QObject
diff --git a/tests/auto/qmargins/qmargins.pro b/tests/auto/qmargins/qmargins.pro
new file mode 100644
index 0000000..5a6aa4f
--- /dev/null
+++ b/tests/auto/qmargins/qmargins.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+SOURCES += tst_qmargins.cpp
+QT = core
diff --git a/tests/auto/qmargins/tst_qmargins.cpp b/tests/auto/qmargins/tst_qmargins.cpp
new file mode 100644
index 0000000..6ee2495
--- /dev/null
+++ b/tests/auto/qmargins/tst_qmargins.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <qmargins.h>
+
+Q_DECLARE_METATYPE(QMargins)
+
+//TESTED_CLASS=
+//TESTED_FILES=
+
+class tst_QMargins : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QMargins();
+ virtual ~tst_QMargins();
+
+
+public slots:
+ void init();
+ void cleanup();
+private slots:
+ void getSetCheck();
+};
+
+// Testing get/set functions
+void tst_QMargins::getSetCheck()
+{
+ QMargins margins;
+ // int QMargins::width()
+ // void QMargins::setWidth(int)
+ margins.setLeft(0);
+ QCOMPARE(0, margins.left());
+ margins.setTop(INT_MIN);
+ QCOMPARE(INT_MIN, margins.top());
+ margins.setBottom(INT_MAX);
+ QCOMPARE(INT_MAX, margins.bottom());
+ margins.setRight(INT_MAX);
+ QCOMPARE(INT_MAX, margins.right());
+
+ margins = QMargins();
+ QVERIFY(margins.isNull());
+ margins.setLeft(5);
+ margins.setRight(5);
+ QVERIFY(!margins.isNull());
+ QCOMPARE(margins, QMargins(5, 0, 5, 0));
+}
+
+tst_QMargins::tst_QMargins()
+{
+}
+
+tst_QMargins::~tst_QMargins()
+{
+}
+
+void tst_QMargins::init()
+{
+}
+
+void tst_QMargins::cleanup()
+{
+}
+
+
+
+QTEST_APPLESS_MAIN(tst_QMargins)
+#include "tst_qmargins.moc"
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 52e967f..a223d1c 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -1366,8 +1366,10 @@ void tst_QNetworkReply::getFromHttp()
QCOMPARE(reply->url(), request.url());
QCOMPARE(reply->error(), QNetworkReply::NoError);
QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
-
- QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), reference.size());
+ QCOMPARE(reply->size(), reference.size());
+ // only compare when the header is set.
+ if (reply->header(QNetworkRequest::ContentLengthHeader).isValid())
+ QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), reference.size());
QCOMPARE(reply->readAll(), reference.readAll());
}
diff --git a/tests/auto/qpainterpath/tst_qpainterpath.cpp b/tests/auto/qpainterpath/tst_qpainterpath.cpp
index 26c1f9b..9c4cbc4 100644
--- a/tests/auto/qpainterpath/tst_qpainterpath.cpp
+++ b/tests/auto/qpainterpath/tst_qpainterpath.cpp
@@ -1145,8 +1145,9 @@ void tst_QPainterPath::testToFillPolygons()
path.lineTo(QPointF(70, 100));
path.lineTo(QPointF(40, 100));
- QPolygonF polygon = path.toFillPolygons(QMatrix()).first();
- QCOMPARE(polygon.count(QPointF(70, 50)), 2);
+ const QList<QPolygonF> polygons = path.toFillPolygons();
+ QCOMPARE(polygons.size(), 2);
+ QCOMPARE(polygons.first().count(QPointF(70, 50)), 0);
}
void tst_QPainterPath::connectPathDuplicatePoint()
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 02ab1cc..7752a4f 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -95,6 +95,9 @@ private slots:
void fromImage_data();
void fromImage();
+ void fromUninitializedImage_data();
+ void fromUninitializedImage();
+
void convertFromImage_data();
void convertFromImage();
@@ -318,6 +321,32 @@ void tst_QPixmap::fromImage()
QCOMPARE(result, image);
}
+
+void tst_QPixmap::fromUninitializedImage_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+
+ QTest::newRow("Format_Mono") << QImage::Format_Mono;
+ QTest::newRow("Format_MonoLSB") << QImage::Format_MonoLSB;
+ QTest::newRow("Format_Indexed8") << QImage::Format_Indexed8;
+ QTest::newRow("Format_RGB32") << QImage::Format_RGB32;
+ QTest::newRow("Format_ARGB32") << QImage::Format_ARGB32;
+ QTest::newRow("Format_ARGB32_Premultiplied") << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("Format_RGB16") << QImage::Format_RGB16;
+}
+
+void tst_QPixmap::fromUninitializedImage()
+{
+ QFETCH(QImage::Format, format);
+
+ QImage image(100, 100, format);
+ QPixmap pix = QPixmap::fromImage(image);
+
+ // it simply shouldn't crash...
+ QVERIFY(true);
+
+}
+
void tst_QPixmap::convertFromImage_data()
{
QTest::addColumn<QImage>("img1");
diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
index a6b887a..e9a0670 100644
--- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
@@ -180,6 +180,8 @@ private slots:
void odbc_uintfield();
void odbc_bindBoolean_data() { generic_data("QODBC"); }
void odbc_bindBoolean();
+ void odbc_testqGetString_data() { generic_data("QODBC"); }
+ void odbc_testqGetString();
void oci_serverDetach_data() { generic_data("QOCI"); }
void oci_serverDetach(); // For task 154518
@@ -347,6 +349,7 @@ void tst_QSqlDatabase::dropTestTables(QSqlDatabase db)
<< qTableName("numericfields")
<< qTableName("qtest_ibaseblobs")
<< qTableName("qtestBindBool")
+ << qTableName("testqGetString")
<< qTableName("qtest_sqlguid")
<< qTableName("uint_table")
<< qTableName("uint_test")
@@ -2024,6 +2027,44 @@ void tst_QSqlDatabase::odbc_bindBoolean()
QCOMPARE(q.value(1).toBool(), false);
}
+void tst_QSqlDatabase::odbc_testqGetString()
+{
+ QFETCH(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+
+ QSqlQuery q(db);
+ QVERIFY_SQL(q, exec("CREATE TABLE " + qTableName("testqGetString") + "(id int, vcvalue varchar(65538))"));
+
+ QString largeString;
+ largeString.fill('A', 65536);
+
+ // Bind and insert
+ QVERIFY_SQL(q, prepare("INSERT INTO " + qTableName("testqGetString") + " VALUES(?, ?)"));
+ q.bindValue(0, 1);
+ q.bindValue(1, largeString);
+ QVERIFY_SQL(q, exec());
+ q.bindValue(0, 2);
+ q.bindValue(1, largeString+QLatin1Char('B'));
+ QVERIFY_SQL(q, exec());
+ q.bindValue(0, 3);
+ q.bindValue(1, largeString+QLatin1Char('B')+QLatin1Char('C'));
+ QVERIFY_SQL(q, exec());
+
+ // Retrive
+ QVERIFY_SQL(q, exec("SELECT id, vcvalue FROM " + qTableName("testqGetString") + " ORDER BY id"));
+ QVERIFY_SQL(q, next());
+ QCOMPARE(q.value(0).toInt(), 1);
+ QCOMPARE(q.value(1).toString().length(), 65536);
+ QVERIFY_SQL(q, next());
+ QCOMPARE(q.value(0).toInt(), 2);
+ QCOMPARE(q.value(1).toString().length(), 65537);
+ QVERIFY_SQL(q, next());
+ QCOMPARE(q.value(0).toInt(), 3);
+ QCOMPARE(q.value(1).toString().length(), 65538);
+}
+
+
void tst_QSqlDatabase::mysql_multiselect()
{
QFETCH(QString, dbName);
diff --git a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp
index add48c4..4dfb6b9 100644
--- a/tests/auto/qsslcertificate/tst_qsslcertificate.cpp
+++ b/tests/auto/qsslcertificate/tst_qsslcertificate.cpp
@@ -267,6 +267,8 @@ void tst_QSslCertificate::compareCertificates(
QCOMPARE(cert1.alternateSubjectNames(), cert2.alternateSubjectNames());
QCOMPARE(cert1.effectiveDate(), cert2.effectiveDate());
QCOMPARE(cert1.expiryDate(), cert2.expiryDate());
+ QCOMPARE(cert1.version(), cert2.version());
+ QCOMPARE(cert1.serialNumber(), cert2.serialNumber());
// ### add more functions here ...
}
@@ -677,7 +679,9 @@ void tst_QSslCertificate::certInfo()
QCOMPARE(cert.subjectInfo("C"), QString("NO"));
QCOMPARE(cert.subjectInfo("ST"), QString());
- QCOMPARE(cert.version(), QByteArray());
+ QCOMPARE(cert.version(), QByteArray::number(1));
+ QCOMPARE(cert.serialNumber(), QByteArray::number(17));
+
QCOMPARE(cert.toPem().constData(), (const char*)pem);
QCOMPARE(cert.toDer(), QByteArray::fromHex(der));
diff --git a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp
index b797c39..5a84cc1 100644
--- a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp
+++ b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp
@@ -93,6 +93,8 @@ private slots:
void renameFdLeak();
void reOpenThroughQFile();
void keepOpenMode();
+ void resetTemplateAfterError();
+ void setTemplateAfterOpen();
public:
};
@@ -476,5 +478,85 @@ void tst_QTemporaryFile::keepOpenMode()
}
}
+void tst_QTemporaryFile::resetTemplateAfterError()
+{
+ // calling setFileTemplate on a failed open
+
+ QString tempPath = QDir::tempPath();
+
+ QString const fileTemplate("destination/qt_temp_file_test.XXXXXX");
+ QString const fileTemplate2(tempPath + "/qt_temp_file_test.XXXXXX");
+
+ QVERIFY2( QDir(tempPath).exists() || QDir().mkpath(tempPath), "Test precondition" );
+ QVERIFY2( !QFile::exists("destination"), "Test precondition" );
+ QVERIFY2( !QFile::exists(fileTemplate2) || QFile::remove(fileTemplate2), "Test precondition" );
+
+ QFile file(fileTemplate2);
+ QByteArray fileContent("This file is intentionally NOT left empty.");
+
+ QVERIFY( file.open(QIODevice::ReadWrite | QIODevice::Truncate) );
+ QCOMPARE( file.write(fileContent), (qint64)fileContent.size() );
+ QVERIFY( file.flush() );
+
+ QString fileName;
+ {
+ QTemporaryFile temp;
+
+ QVERIFY( temp.fileName().isEmpty() );
+ QVERIFY( !temp.fileTemplate().isEmpty() );
+
+ temp.setFileTemplate( fileTemplate );
+
+ QVERIFY( temp.fileName().isEmpty() );
+ QCOMPARE( temp.fileTemplate(), fileTemplate );
+
+ QVERIFY( !temp.open() );
+
+ QVERIFY( temp.fileName().isEmpty() );
+ QCOMPARE( temp.fileTemplate(), fileTemplate );
+
+ temp.setFileTemplate( fileTemplate2 );
+ QVERIFY( temp.open() );
+
+ fileName = temp.fileName();
+ QVERIFY( QFile::exists(fileName) );
+ QVERIFY( !fileName.isEmpty() );
+ QVERIFY2( fileName != fileTemplate2,
+ ("Generated name shouldn't be same as template: " + fileTemplate2).toLocal8Bit().constData() );
+ }
+
+ QVERIFY( !QFile::exists(fileName) );
+
+ file.seek(0);
+ QCOMPARE( QString(file.readAll()), QString(fileContent) );
+ QVERIFY( file.remove() );
+}
+
+void tst_QTemporaryFile::setTemplateAfterOpen()
+{
+ QTemporaryFile temp;
+
+ QVERIFY( temp.fileName().isEmpty() );
+ QVERIFY( !temp.fileTemplate().isEmpty() );
+
+ QVERIFY( temp.open() );
+
+ QString const fileName = temp.fileName();
+ QString const newTemplate("funny-path/funny-name-XXXXXX.tmp");
+
+ QVERIFY( !fileName.isEmpty() );
+ QVERIFY( QFile::exists(fileName) );
+ QVERIFY( !temp.fileTemplate().isEmpty() );
+ QVERIFY( temp.fileTemplate() != newTemplate );
+
+ temp.close(); // QTemporaryFile::setFileTemplate will assert on isOpen() up to 4.5.2
+ temp.setFileTemplate(newTemplate);
+ QCOMPARE( temp.fileTemplate(), newTemplate );
+
+ QVERIFY( temp.open() );
+ QCOMPARE( temp.fileName(), fileName );
+ QCOMPARE( temp.fileTemplate(), newTemplate );
+}
+
QTEST_MAIN(tst_QTemporaryFile)
#include "tst_qtemporaryfile.moc"
diff --git a/tests/benchmarks/qgraphicsanchorlayout/qgraphicsanchorlayout.pro b/tests/benchmarks/qgraphicsanchorlayout/qgraphicsanchorlayout.pro
new file mode 100644
index 0000000..0d563b9
--- /dev/null
+++ b/tests/benchmarks/qgraphicsanchorlayout/qgraphicsanchorlayout.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_qgraphicsanchorlayout
+
+SOURCES += tst_qgraphicsanchorlayout.cpp
+
diff --git a/tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
new file mode 100644
index 0000000..e419bae
--- /dev/null
+++ b/tests/benchmarks/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenGL module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://qt.nokia.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtGui/qgraphicsanchorlayout.h>
+#include <QtGui/qgraphicswidget.h>
+#include <QtGui/qgraphicsview.h>
+
+class tst_QGraphicsAnchorLayout : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QGraphicsAnchorLayout() {}
+ ~tst_QGraphicsAnchorLayout() {}
+
+private slots:
+ void s60_hard_complex_data();
+ void s60_hard_complex();
+};
+
+
+class RectWidget : public QGraphicsWidget
+{
+public:
+ RectWidget(QGraphicsItem *parent = 0) : QGraphicsWidget(parent){}
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+ {
+ Q_UNUSED(option);
+ Q_UNUSED(widget);
+ painter->drawRoundRect(rect());
+ painter->drawLine(rect().topLeft(), rect().bottomRight());
+ painter->drawLine(rect().bottomLeft(), rect().topRight());
+ }
+};
+
+static QGraphicsWidget *createItem(const QSizeF &minimum = QSizeF(100.0, 100.0),
+ const QSizeF &preferred = QSize(150.0, 100.0),
+ const QSizeF &maximum = QSizeF(200.0, 100.0),
+ const QString &name = QString())
+{
+ QGraphicsWidget *w = new RectWidget;
+ w->setMinimumSize(minimum);
+ w->setPreferredSize(preferred);
+ w->setMaximumSize(maximum);
+ w->setData(0, name);
+ return w;
+}
+
+static void setAnchor(QGraphicsAnchorLayout *l,
+ QGraphicsLayoutItem *firstItem,
+ Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem,
+ Qt::AnchorPoint secondEdge,
+ qreal spacing)
+{
+ l->addAnchor(firstItem, firstEdge, secondItem, secondEdge);
+ l->setAnchorSpacing(firstItem, firstEdge, secondItem, secondEdge, spacing);
+}
+
+void tst_QGraphicsAnchorLayout::s60_hard_complex_data()
+{
+ QTest::addColumn<int>("whichSizeHint");
+ QTest::newRow("minimumSizeHint")
+ << int(Qt::MinimumSize);
+ QTest::newRow("preferredSizeHint")
+ << int(Qt::PreferredSize);
+ QTest::newRow("maximumSizeHint")
+ << int(Qt::MaximumSize);
+ // Add it as a reference to see how much overhead the body of effectiveSizeHint takes.
+ QTest::newRow("noSizeHint")
+ << -1;
+}
+
+void tst_QGraphicsAnchorLayout::s60_hard_complex()
+{
+ QFETCH(int, whichSizeHint);
+
+ // Test for "hard" complex case, taken from wiki
+ // https://cwiki.nokia.com/S60QTUI/AnchorLayoutComplexCases
+ QSizeF min(0, 10);
+ QSizeF pref(50, 10);
+ QSizeF max(100, 10);
+
+ QGraphicsWidget *a = createItem(min, pref, max, "a");
+ QGraphicsWidget *b = createItem(min, pref, max, "b");
+ QGraphicsWidget *c = createItem(min, pref, max, "c");
+ QGraphicsWidget *d = createItem(min, pref, max, "d");
+ QGraphicsWidget *e = createItem(min, pref, max, "e");
+ QGraphicsWidget *f = createItem(min, pref, max, "f");
+ QGraphicsWidget *g = createItem(min, pref, max, "g");
+
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
+ l->setContentsMargins(0, 0, 0, 0);
+
+ //<!-- Trunk -->
+ setAnchor(l, l, Qt::AnchorLeft, a, Qt::AnchorLeft, 10);
+ setAnchor(l, a, Qt::AnchorRight, b, Qt::AnchorLeft, 10);
+ setAnchor(l, b, Qt::AnchorRight, c, Qt::AnchorLeft, 10);
+ setAnchor(l, c, Qt::AnchorRight, d, Qt::AnchorLeft, 10);
+ setAnchor(l, d, Qt::AnchorRight, l, Qt::AnchorRight, 10);
+
+ //<!-- Above trunk -->
+ setAnchor(l, b, Qt::AnchorLeft, e, Qt::AnchorLeft, 10);
+ setAnchor(l, e, Qt::AnchorRight, d, Qt::AnchorLeft, 10);
+
+ //<!-- Below trunk -->
+ setAnchor(l, a, Qt::AnchorHorizontalCenter, g, Qt::AnchorLeft, 10);
+ setAnchor(l, g, Qt::AnchorRight, f, Qt::AnchorHorizontalCenter, 10);
+ setAnchor(l, c, Qt::AnchorLeft, f, Qt::AnchorLeft, 10);
+ setAnchor(l, f, Qt::AnchorRight, d, Qt::AnchorRight, 10);
+
+ //<!-- vertical is simpler -->
+ setAnchor(l, l, Qt::AnchorTop, e, Qt::AnchorTop, 0);
+ setAnchor(l, e, Qt::AnchorBottom, a, Qt::AnchorTop, 0);
+ setAnchor(l, e, Qt::AnchorBottom, b, Qt::AnchorTop, 0);
+ setAnchor(l, e, Qt::AnchorBottom, c, Qt::AnchorTop, 0);
+ setAnchor(l, e, Qt::AnchorBottom, d, Qt::AnchorTop, 0);
+ setAnchor(l, a, Qt::AnchorBottom, f, Qt::AnchorTop, 0);
+ setAnchor(l, a, Qt::AnchorBottom, b, Qt::AnchorBottom, 0);
+ setAnchor(l, a, Qt::AnchorBottom, c, Qt::AnchorBottom, 0);
+ setAnchor(l, a, Qt::AnchorBottom, d, Qt::AnchorBottom, 0);
+ setAnchor(l, f, Qt::AnchorBottom, g, Qt::AnchorTop, 0);
+ setAnchor(l, g, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
+
+ // It won't query the size hint if it already has a size set.
+ // If only one of the sizes is unset it will query sizeHint only of for that hint type.
+ l->setMinimumSize(60,40);
+ l->setPreferredSize(220,40);
+ l->setMaximumSize(240,40);
+
+ switch (whichSizeHint) {
+ case Qt::MinimumSize:
+ l->setMinimumSize(-1, -1);
+ break;
+ case Qt::PreferredSize:
+ l->setPreferredSize(-1, -1);
+ break;
+ case Qt::MaximumSize:
+ l->setMaximumSize(-1, -1);
+ break;
+ default:
+ break;
+ }
+
+ QSizeF sizeHint;
+ // warm up instruction cache
+ l->invalidate();
+ sizeHint = l->effectiveSizeHint((Qt::SizeHint)whichSizeHint);
+ // ...then measure...
+ QBENCHMARK {
+ l->invalidate();
+ sizeHint = l->effectiveSizeHint((Qt::SizeHint)whichSizeHint);
+ }
+}
+
+QTEST_MAIN(tst_QGraphicsAnchorLayout)
+
+#include "tst_qgraphicsanchorlayout.moc"
diff --git a/tests/manual/qhttpnetworkconnection/main.cpp b/tests/manual/qhttpnetworkconnection/main.cpp
new file mode 100644
index 0000000..b15a7ed
--- /dev/null
+++ b/tests/manual/qhttpnetworkconnection/main.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+// This file contains benchmarks for QNetworkReply functions.
+
+#include <QDebug>
+#include <qtest.h>
+#include <QtTest/QtTest>
+#include <QtNetwork/qnetworkreply.h>
+#include <QtNetwork/qnetworkrequest.h>
+#include <QtNetwork/qnetworkaccessmanager.h>
+#include "../../auto/network-settings.h"
+
+class tst_qhttpnetworkconnection : public QObject
+{
+ Q_OBJECT
+private slots:
+ void bigRemoteFile();
+
+};
+
+void tst_qhttpnetworkconnection::bigRemoteFile()
+{
+ QNetworkAccessManager manager;
+ qint64 size;
+ QTime t;
+ QNetworkRequest request(QUrl("http://nds1.nokia.com/files/support/global/phones/software/Nokia_Ovi_Suite_webinstaller.exe"));
+ QNetworkReply* reply = manager.get(request);
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection);
+ qDebug() << "Starting download";
+ t.start();
+ QTestEventLoop::instance().enterLoop(50);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ size = reply->size();
+ delete reply;
+ qDebug() << "Finished!" << endl;
+ qDebug() << "Time:" << t.elapsed() << "msec";
+ qDebug() << "Bytes:" << size;
+ qDebug() << "Speed:" << (size / 1024) / (t.elapsed() / 1000) << "KB/sec";
+}
+
+QTEST_MAIN(tst_qhttpnetworkconnection)
+
+#include "main.moc"
diff --git a/tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro b/tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro
new file mode 100644
index 0000000..2471389
--- /dev/null
+++ b/tests/manual/qhttpnetworkconnection/qhttpnetworkconnection.pro
@@ -0,0 +1,13 @@
+load(qttest_p4)
+TEMPLATE = app
+TARGET = tst_qhttpnetworkconnection
+DEPENDPATH += .
+INCLUDEPATH += .
+
+QT -= gui
+QT += network
+
+CONFIG += release
+
+# Input
+SOURCES += main.cpp
diff --git a/tests/manual/qtabletevent/main.cpp b/tests/manual/qtabletevent/device_information/main.cpp
index 44afcaf..69867bc 100644
--- a/tests/manual/qtabletevent/main.cpp
+++ b/tests/manual/qtabletevent/device_information/main.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the test suite module of the Qt Toolkit.
+** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -47,4 +47,4 @@ int main(int argc, char **argv) {
TabletWidget tabletWidget;
tabletWidget.showMaximized();
return app.exec();
-}
+}
diff --git a/tests/manual/qtabletevent/qtabletevent.pro b/tests/manual/qtabletevent/device_information/qtabletevent.pro
index e0ed549..e0ed549 100644
--- a/tests/manual/qtabletevent/qtabletevent.pro
+++ b/tests/manual/qtabletevent/device_information/qtabletevent.pro
diff --git a/tests/manual/qtabletevent/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp
index 15a3d80..15a3d80 100644
--- a/tests/manual/qtabletevent/tabletwidget.cpp
+++ b/tests/manual/qtabletevent/device_information/tabletwidget.cpp
diff --git a/tests/manual/qtabletevent/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h
index d3ccb32..d3ccb32 100644
--- a/tests/manual/qtabletevent/tabletwidget.h
+++ b/tests/manual/qtabletevent/device_information/tabletwidget.h
diff --git a/tests/manual/qtabletevent/event_compression/event_compression.pro b/tests/manual/qtabletevent/event_compression/event_compression.pro
new file mode 100644
index 0000000..273fd6c
--- /dev/null
+++ b/tests/manual/qtabletevent/event_compression/event_compression.pro
@@ -0,0 +1,7 @@
+TEMPLATE = app
+QT += testlib
+
+# Input
+SOURCES += main.cpp \
+ mousestatwidget.cpp
+HEADERS += mousestatwidget.h
diff --git a/tests/manual/qtabletevent/event_compression/main.cpp b/tests/manual/qtabletevent/event_compression/main.cpp
new file mode 100644
index 0000000..26611d3
--- /dev/null
+++ b/tests/manual/qtabletevent/event_compression/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mousestatwidget.h"
+
+#include <QApplication>
+#include <QWidget>
+#include <QVBoxLayout>
+
+int main(int argc, char **argv){
+ QApplication app(argc, argv);
+
+ QWidget main;
+ QVBoxLayout *layout = new QVBoxLayout(&main);
+ layout->addWidget(new MouseStatWidget(true));
+ layout->addWidget(new MouseStatWidget(false));
+ main.resize(800, 600);
+ main.show();
+ return app.exec();
+}
diff --git a/tests/manual/qtabletevent/event_compression/mousestatwidget.cpp b/tests/manual/qtabletevent/event_compression/mousestatwidget.cpp
new file mode 100644
index 0000000..024e14a
--- /dev/null
+++ b/tests/manual/qtabletevent/event_compression/mousestatwidget.cpp
@@ -0,0 +1,99 @@
+#include "mousestatwidget.h"
+
+#include <QTabletEvent>
+#include <QPainter>
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QTextOption>
+#include <QTest>
+
+MouseStatWidget::MouseStatWidget(bool acceptTabletEvent):acceptTabletEvent(acceptTabletEvent),
+ receivedMouseEventCount(0),
+ receivedMouseEventCountToPaint(0),
+ receivedTabletEventCount(0),
+ receivedTabletEventCountToPaint(0)
+{
+ startTimer(1000);
+}
+
+
+void MouseStatWidget::tabletEvent(QTabletEvent *event)
+{
+ ++receivedTabletEventCount;
+ if (acceptTabletEvent)
+ event->accept();
+ else
+ event->ignore();
+ // make sure the event loop is slow
+ QTest::qSleep(15);
+}
+
+void MouseStatWidget::mouseMoveEvent(QMouseEvent *)
+{
+ ++receivedMouseEventCount;
+}
+
+void MouseStatWidget::timerEvent(QTimerEvent *)
+{
+ receivedMouseEventCountToPaint = receivedMouseEventCount;
+ receivedTabletEventCountToPaint = receivedTabletEventCount;
+ receivedMouseEventCount = 0;
+ receivedTabletEventCount = 0;
+ update();
+}
+
+void MouseStatWidget::paintEvent(QPaintEvent *)
+{
+ QPainter painter(this);
+ painter.setPen(Qt::black);
+ painter.drawRect(rect());
+ QStringList text;
+ text << ((acceptTabletEvent) ? " - tablet events accepted - " : " - tablet events ignored - ");
+ text << QString("Number of tablet events received in the last second: %1").arg(QString::number(receivedTabletEventCountToPaint));
+ text << QString("Number of mouse events received in the last second: %1").arg(QString::number(receivedMouseEventCountToPaint));
+
+ QTextOption textOption(Qt::AlignCenter);
+ textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
+ painter.drawText(rect(),
+ text.join("\n"),
+ textOption);
+}
diff --git a/tests/manual/qtabletevent/event_compression/mousestatwidget.h b/tests/manual/qtabletevent/event_compression/mousestatwidget.h
new file mode 100644
index 0000000..22c0dff
--- /dev/null
+++ b/tests/manual/qtabletevent/event_compression/mousestatwidget.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MOUSESTATWIDGET_H
+#define MOUSESTATWIDGET_H
+
+#include <QWidget>
+
+class QTabletEvent;
+class QMouseEvent;
+class QTimerEvent;
+class QPaintEvent;
+
+class MouseStatWidget : public QWidget
+{
+public:
+ MouseStatWidget(bool acceptTabletEvent = true);
+protected:
+ void tabletEvent(QTabletEvent *);
+ void mouseMoveEvent(QMouseEvent *);
+ void timerEvent(QTimerEvent *);
+ void paintEvent(QPaintEvent *);
+private:
+ const bool acceptTabletEvent;
+ int receivedMouseEventCount;
+ int receivedMouseEventCountToPaint;
+ int receivedTabletEventCount;
+ int receivedTabletEventCountToPaint;
+};
+
+#endif // MOUSESTATWIDGET_H
diff --git a/tools/qdoc3/test/classic.css b/tools/qdoc3/test/classic.css
index f97bdbe..c0bc3d47 100644
--- a/tools/qdoc3/test/classic.css
+++ b/tools/qdoc3/test/classic.css
@@ -251,45 +251,25 @@ span.string,span.char
.qmlname {
white-space: nowrap;
- font-weight: bold;
- font-size: 125%;
}
.qmltype {
- font-weight: bold;
- font-size: 125%;
-}
-
-.qmlproto, .qmldoc {
- // border-top: 1px solid #84b0c7;
+ text-align: center;
+ font-size: 160%;
}
.qmlproto {
- padding: 0;
- //background-color: #e4e4e4;//#d5e1e8;
- //font-weight: bold;
- //-webkit-border-top-left-radius: 8px;
- //-webkit-border-top-right-radius: 8px;
- //-moz-border-radius-topleft: 8px;
- //-moz-border-radius-topright: 8px;
+ background-color: #eee;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #ddd;
+ font-weight: bold;
+ padding: 6px 0px 6px 10px;
+ margin: 42px 0px 0px 0px;
}
.qmldoc {
- border-top: 1px solid #e4e4e4;
- //padding: 2px 5px;
- //background-color: #eef3f5;
- //border-top-width: 0;
- //-webkit-border-bottom-left-radius: 8px;
- //-webkit-border-bottom-right-radius: 8px;
- //-moz-border-radius-bottomleft: 8px;
- //-moz-border-radius-bottomright: 8px;
-}
-
-.qmldoc p, .qmldoc dl, .qmldoc ul {
- //margin: 6px 0;
}
*.qmlitem p {
- //margin-top: 0px;
- //margin-bottom: 0px;
}