diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-09-09 05:31:43 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-09-09 05:31:43 (GMT) |
commit | ae7a3485c0e6748361789491af33ee7b7fe093bc (patch) | |
tree | 7d653db085947561419efbea4f9d66659eecae05 | |
parent | bd54370a759db272ce06d2fcdcce3e90c1dd17e8 (diff) | |
parent | dc4d2b260debda80b8a0d81c9a032050232fdaab (diff) | |
download | Qt-ae7a3485c0e6748361789491af33ee7b7fe093bc.zip Qt-ae7a3485c0e6748361789491af33ee7b7fe093bc.tar.gz Qt-ae7a3485c0e6748361789491af33ee7b7fe093bc.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
156 files changed, 2484 insertions, 2312 deletions
diff --git a/demos/boxes/boxes.pro b/demos/boxes/boxes.pro index 59c9132..4963fb9 100644 --- a/demos/boxes/boxes.pro +++ b/demos/boxes/boxes.pro @@ -44,6 +44,6 @@ wince*: { win32-msvc* { QMAKE_CXXFLAGS -= -Zm200 QMAKE_CFLAGS -= -Zm200 - QMAKE_CXXFLAGS += -Zm1200 - QMAKE_CFLAGS += -Zm1200 + QMAKE_CXXFLAGS += -Zm500 + QMAKE_CFLAGS += -Zm500 } diff --git a/demos/composition/main.cpp b/demos/composition/main.cpp index 3a959a9..fe142ad 100644 --- a/demos/composition/main.cpp +++ b/demos/composition/main.cpp @@ -42,11 +42,17 @@ #include "composition.h" #include <QApplication> +#ifdef QT_OPENGL_SUPPORT +#include <QtOpenGL> +#endif int main(int argc, char **argv) { // Q_INIT_RESOURCE(deform); +#ifdef QT_OPENGL_SUPPORT + QGL::setPreferredPaintEngine(QPaintEngine::OpenGL); +#endif QApplication app(argc, argv); CompositionWidget compWidget(0); diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml index fa169aa..72431af 100644 --- a/demos/declarative/minehunt/minehunt.qml +++ b/demos/declarative/minehunt/minehunt.qml @@ -135,8 +135,8 @@ Item { x: 1 y: 1 Component { - ComponentInstance { - component: tile + Loader { + sourceComponent: tile x: (index - (Math.floor(index/9) * 9)) * 41 y: Math.floor(index/9) * 41 } diff --git a/demos/declarative/twitter/content/AuthView.qml b/demos/declarative/twitter/content/AuthView.qml index 7d0d865..febee94 100644 --- a/demos/declarative/twitter/content/AuthView.qml +++ b/demos/declarative/twitter/content/AuthView.qml @@ -5,10 +5,9 @@ import "../../flickr/mobile" Item { id: wrapper Column { - width: childrenRect.width; height:childrenRect.height; anchors.centerIn: parent + anchors.centerIn: parent spacing: 20 Row{ - width: childrenRect.width; height:childrenRect.height; spacing: 4 Text { width: 100 @@ -39,7 +38,6 @@ Item { } } Row{ - width: childrenRect.width; height:childrenRect.height; spacing: 4 Text { width: 100 @@ -65,8 +63,8 @@ Item { } } Item{ - width: childrenRect.width; anchors.horizontalCenter: parent.horizontalCenter - height: childrenRect.height + width: childrenRect.width; height:childrenRect.height; + anchors.horizontalCenter: parent.horizontalCenter Button { x: 10 width: 100 diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index ca984ac..f9984d3 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -54,8 +54,15 @@ information about a particular change. this is that Nokia focuses on OpenGL for desktop hardware accelerated rendering. - - When mixing OpenGL and QPainter calls you need to surround your custom - OpenGL calls with QPainter::beginNativePainting() and + - The default engine used to draw onto OpenGL buffers has changed in + Qt 4.6. The QPaintEngine::OpenGL2 engine is now used as the default + engine. This *may* cause compatibility problems for applications + that use a mix of QPainter and native OpenGL calls to draw into a GL + buffer. Use the QGL::setPreferredPaintEngine() function to enforce + usage of the old GL paint engine. + + - When mixing OpenGL and QPainter calls you need to surround your + custom OpenGL calls with QPainter::beginNativePainting() and QPainter::endNativePainting(). This is to ensure that the paint engine flushes any pending drawing and sets up the GL modelview/projection matrices properly before you can issue custom diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index 47cb19c..ca17fda 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -101,7 +101,6 @@ The following table lists the QML elements provided by the Qt Declarative module \o \l Loader \o \l Repeater \o \l SystemPalette -\o \l ComponentInstance \o \l GraphicsObjectContainer \endlist diff --git a/doc/src/frameworks-technologies/gestures.qdoc b/doc/src/frameworks-technologies/gestures.qdoc index 317bb31..7929331 100644 --- a/doc/src/frameworks-technologies/gestures.qdoc +++ b/doc/src/frameworks-technologies/gestures.qdoc @@ -81,7 +81,7 @@ \table \header \o New State \o Description \o QGesture Actions on Entering this State - \row \o Qt::NoGesture \o Initial value \o emit \l {QGesture::cancelled()}{cancelled()} + \row \o Qt::NoGesture \o Initial value \o emit \l {QGesture::canceled()}{canceled()} \row \o Qt::GestureStarted \o A continuous gesture has started \o emit \l{QGesture::started()}{started()} and emit \l{QGesture::triggered()}{triggered()} \row \o Qt::GestureUpdated \o A gesture continues \o emit \l{QGesture::triggered()}{triggered()} \row \o Qt::GestureFinished \o A gesture has finished. \o emit \l{QGesture::finished()}{finished()} @@ -130,13 +130,13 @@ then the gesture is considered to have finished whether or not the appropriate touch or mouse event has occurred. Also if a large jump in the position of the event occurs, as calculated by the \l {QPoint::manhattanLength()}{manhattanLength()} - call, then the gesture is cancelled by calling \l{QGesture::reset()}{reset()} + call, then the gesture is canceled by calling \l{QGesture::reset()}{reset()} which tidies up and uses \l{QGesture::updateState()}{updateState()} to - change state to NoGesture which will result in the \l{QGesture::cancelled()}{cancelled()} + change state to NoGesture which will result in the \l{QGesture::canceled()}{canceled()} signal being emitted by the recognizer. ImageWidget handles the signals by connecting the slots to the signals, - although \c cancelled() is not connected here. + although \c canceled() is not connected here. \snippet doc/src/snippets/gestures/imageviewer/imagewidget.cpp imagewidget-connect diff --git a/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp b/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp index f01757a..d2096cf 100644 --- a/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp +++ b/doc/src/snippets/code/src_corelib_io_qfileinfo.cpp @@ -72,9 +72,9 @@ info1.size(); // returns 743 info1.symLinkTarget(); // returns "C:/Pretty++/untabify" QFileInfo info2(info1.symLinkTarget()); -info1.isSymLink(); // returns false -info1.absoluteFilePath(); // returns "C:/Pretty++/untabify" -info1.size(); // returns 63942 +info2.isSymLink(); // returns false +info2.absoluteFilePath(); // returns "C:/Pretty++/untabify" +info2.size(); // returns 63942 #endif //! [1] diff --git a/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp b/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp index 128799f..8933ef3 100644 --- a/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp +++ b/doc/src/snippets/code/src_corelib_statemachine_qstatemachine.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the 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$ +** +****************************************************************************/ + //! [simple state machine] QPushButton button; diff --git a/doc/src/tutorials/declarative.qdoc b/doc/src/tutorials/declarative.qdoc index 7780988..48beabd 100644 --- a/doc/src/tutorials/declarative.qdoc +++ b/doc/src/tutorials/declarative.qdoc @@ -392,7 +392,7 @@ the contact field. There are also two other ways to reuse components in QML. A component - can be reused from within the same QML file using Component and ComponentInstance + can be reused from within the same QML file using Component and Loader elements. The next code snippet produces three red rounded rectangles within a large blue rectangle. diff --git a/doc/src/widgets-and-layouts/stylesheet.qdoc b/doc/src/widgets-and-layouts/stylesheet.qdoc index 354050d..c137d6a 100644 --- a/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -230,9 +230,11 @@ \o \c{QPushButton[flat="false"]} \o Matches instances of QPushButton that are not \l{QPushButton::}{flat}. You may use this selector to test - for any Qt property specified using Q_PROPERTY(). In - addition, the special \c class property is supported, for - the name of the class. + for any Qt \l{Qt's Property System}{property} that supports + QVariant::toString() (see the \l{QVariant::}{toString()} + function documentation for details). In addition, the + special \c class property is supported, for the name of the + class. This selector may also be used to test dynamic properties. For more information on customization using dynamic properties, diff --git a/examples/declarative/tutorials/contacts/2_Reuse/1b/BlueRect.qml b/examples/declarative/tutorials/contacts/2_Reuse/1b/BlueRect.qml index ec115fe..7bcdf50 100644 --- a/examples/declarative/tutorials/contacts/2_Reuse/1b/BlueRect.qml +++ b/examples/declarative/tutorials/contacts/2_Reuse/1b/BlueRect.qml @@ -16,18 +16,18 @@ Rectangle { } } ] - ComponentInstance { - component: redRectangle + Loader { + sourceComponent: redRectangle anchors.right: parent.right anchors.top: parent.top } - ComponentInstance { - component: redRectangle + Loader { + sourceComponent: redRectangle anchors.left: parent.left anchors.top: parent.top } - ComponentInstance { - component: redRectangle + Loader { + sourceComponent: redRectangle anchors.left: parent.left anchors.bottom: parent.bottom } diff --git a/examples/declarative/webview/newwindows.qml b/examples/declarative/webview/newwindows.qml index 9ff902e2..57cbf4e 100644 --- a/examples/declarative/webview/newwindows.qml +++ b/examples/declarative/webview/newwindows.qml @@ -24,5 +24,5 @@ Row { } ] width: 500 - ComponentInstance { component: WebViewPage } + Loader { sourceComponent: WebViewPage } } diff --git a/examples/opengl/opengl.pro b/examples/opengl/opengl.pro index 567eb7b..b86e0ba 100644 --- a/examples/opengl/opengl.pro +++ b/examples/opengl/opengl.pro @@ -5,6 +5,9 @@ contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles1cl)|contains(QT_CONF SUBDIRS = hellogl_es2 } else { SUBDIRS = hellogl_es + !contains(QT_CONFIG, opengles1cl) { + SUBDIRS += textures + } } } else { SUBDIRS = 2dpainting \ diff --git a/examples/opengl/textures/glwidget.cpp b/examples/opengl/textures/glwidget.cpp index cfb99b0..9c6d5ea 100644 --- a/examples/opengl/textures/glwidget.cpp +++ b/examples/opengl/textures/glwidget.cpp @@ -42,12 +42,17 @@ #include <QtGui> #include <QtOpenGL> -#include <math.h> - #include "glwidget.h" -GLuint GLWidget::sharedObject = 0; -int GLWidget::refCount = 0; +class CubeObject +{ +public: + GLuint textures[6]; + QVector<QVector3D> vertices; + QVector<QVector2D> texCoords; + + void draw(); +}; GLWidget::GLWidget(QWidget *parent, QGLWidget *shareWidget) : QGLWidget(parent, shareWidget) @@ -56,14 +61,12 @@ GLWidget::GLWidget(QWidget *parent, QGLWidget *shareWidget) xRot = 0; yRot = 0; zRot = 0; + cube = 0; } GLWidget::~GLWidget() { - if (--refCount == 0) { - makeCurrent(); - glDeleteLists(sharedObject, 1); - } + delete cube; } QSize GLWidget::minimumSizeHint() const @@ -92,9 +95,7 @@ void GLWidget::setClearColor(const QColor &color) void GLWidget::initializeGL() { - if (!sharedObject) - sharedObject = makeObject(); - ++refCount; + makeObject(); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); @@ -106,11 +107,11 @@ void GLWidget::paintGL() qglClearColor(clearColor); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); - glTranslated(0.0, 0.0, -10.0); - glRotated(xRot / 16.0, 1.0, 0.0, 0.0); - glRotated(yRot / 16.0, 0.0, 1.0, 0.0); - glRotated(zRot / 16.0, 0.0, 0.0, 1.0); - glCallList(sharedObject); + glTranslatef(0.0f, 0.0f, -10.0f); + glRotatef(xRot / 16.0f, 1.0f, 0.0f, 0.0f); + glRotatef(yRot / 16.0f, 0.0f, 1.0f, 0.0f); + glRotatef(zRot / 16.0f, 0.0f, 0.0f, 1.0f); + cube->draw(); } void GLWidget::resizeGL(int width, int height) @@ -120,7 +121,11 @@ void GLWidget::resizeGL(int width, int height) glMatrixMode(GL_PROJECTION); glLoadIdentity(); +#ifndef QT_OPENGL_ES glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0); +#else + glOrthof(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0); +#endif glMatrixMode(GL_MODELVIEW); } @@ -147,7 +152,7 @@ void GLWidget::mouseReleaseEvent(QMouseEvent * /* event */) emit clicked(); } -GLuint GLWidget::makeObject() +void GLWidget::makeObject() { static const int coords[6][4][3] = { { { +1, -1, -1 }, { -1, -1, -1 }, { -1, +1, -1 }, { +1, +1, -1 } }, @@ -158,25 +163,32 @@ GLuint GLWidget::makeObject() { { -1, -1, +1 }, { +1, -1, +1 }, { +1, +1, +1 }, { -1, +1, +1 } } }; + cube = new CubeObject(); - GLuint textures[6]; - for (int j=0; j < 6; ++j) - textures[j] = bindTexture(QPixmap(QString(":/images/side%1.png").arg(j + 1)), - GL_TEXTURE_2D); + for (int j=0; j < 6; ++j) { + cube->textures[j] = bindTexture + (QPixmap(QString(":/images/side%1.png").arg(j + 1)), GL_TEXTURE_2D); + } - GLuint list = glGenLists(1); - glNewList(list, GL_COMPILE); for (int i = 0; i < 6; ++i) { - glBindTexture(GL_TEXTURE_2D, textures[i]); - glBegin(GL_QUADS); for (int j = 0; j < 4; ++j) { - glTexCoord2d(j == 0 || j == 3, j == 0 || j == 1); - glVertex3d(0.2 * coords[i][j][0], 0.2 * coords[i][j][1], - 0.2 * coords[i][j][2]); + cube->texCoords.append + (QVector2D(j == 0 || j == 3, j == 0 || j == 1)); + cube->vertices.append + (QVector3D(0.2 * coords[i][j][0], 0.2 * coords[i][j][1], + 0.2 * coords[i][j][2])); } - glEnd(); } +} - glEndList(); - return list; +void CubeObject::draw() +{ + glVertexPointer(3, GL_FLOAT, 0, vertices.constData()); + glTexCoordPointer(2, GL_FLOAT, 0, texCoords.constData()); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + for (int i = 0; i < 6; ++i) { + glBindTexture(GL_TEXTURE_2D, textures[i]); + glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4); + } } diff --git a/examples/opengl/textures/glwidget.h b/examples/opengl/textures/glwidget.h index 68be8bc..f793d6d 100644 --- a/examples/opengl/textures/glwidget.h +++ b/examples/opengl/textures/glwidget.h @@ -44,6 +44,8 @@ #include <QGLWidget> +class CubeObject; + class GLWidget : public QGLWidget { Q_OBJECT @@ -69,16 +71,14 @@ protected: void mouseReleaseEvent(QMouseEvent *event); private: - GLuint makeObject(); + void makeObject(); QColor clearColor; QPoint lastPos; int xRot; int yRot; int zRot; - - static GLuint sharedObject; - static int refCount; + CubeObject *cube; }; #endif diff --git a/examples/opengl/textures/window.cpp b/examples/opengl/textures/window.cpp index ea64512..9bd7931 100644 --- a/examples/opengl/textures/window.cpp +++ b/examples/opengl/textures/window.cpp @@ -48,8 +48,6 @@ Window::Window() { QGridLayout *mainLayout = new QGridLayout; - glWidgets[0][0] = 0; - for (int i = 0; i < NumRows; ++i) { for (int j = 0; j < NumColumns; ++j) { QColor clearColor; @@ -57,7 +55,7 @@ Window::Window() / (NumRows * NumColumns - 1), 255, 63); - glWidgets[i][j] = new GLWidget(0, glWidgets[0][0]); + glWidgets[i][j] = new GLWidget(0, 0); glWidgets[i][j]->setClearColor(clearColor); glWidgets[i][j]->rotateBy(+42 * 16, +42 * 16, -21 * 16); mainLayout->addWidget(glWidgets[i][j], i, j); diff --git a/mkspecs/common/wince.conf b/mkspecs/common/wince/qmake.conf index d6e4ba7..d6e4ba7 100644 --- a/mkspecs/common/wince.conf +++ b/mkspecs/common/wince/qmake.conf diff --git a/mkspecs/common/wince/qplatformdefs.h b/mkspecs/common/wince/qplatformdefs.h new file mode 100644 index 0000000..4e67948 --- /dev/null +++ b/mkspecs/common/wince/qplatformdefs.h @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the qmake spec 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 QPLATFORMDEFS_H +#define QPLATFORMDEFS_H + +#ifdef UNICODE +#ifndef _UNICODE +#define _UNICODE +#endif +#endif + +// Get Qt defines/settings + +#include "qglobal.h" +#include "qfunctions_wince.h" + +#define _POSIX_ +#include <limits.h> +#undef _POSIX_ + +#include <tchar.h> +#include <stdio.h> +#include <stdlib.h> +#include <windows.h> + +#define Q_FS_FAT +#ifdef QT_LARGEFILE_SUPPORT +#define QT_STATBUF struct _stati64 // non-ANSI defs +#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs +#define QT_STAT ::_stati64 +#define QT_FSTAT ::_fstati64 +#else +#define QT_STATBUF struct stat // non-ANSI defs +#define QT_STATBUF4TSTAT struct stat // non-ANSI defs +#define QT_STAT ::qt_wince_stat +#define QT_FSTAT ::qt_wince__fstat +#endif +#define QT_STAT_REG _S_IFREG +#define QT_STAT_DIR _S_IFDIR +#define QT_STAT_MASK _S_IFMT +#if defined(_S_IFLNK) +# define QT_STAT_LNK _S_IFLNK +#endif +#define QT_FILENO ::qt_wince___fileno +#define QT_OPEN ::qt_wince_open +#define QT_CLOSE ::qt_wince__close +#ifdef QT_LARGEFILE_SUPPORT +#define QT_LSEEK ::_lseeki64 +#define QT_TSTAT ::_tstati64 +#else +#define QT_LSEEK ::qt_wince__lseek +#define QT_TSTAT ::_tstat +#endif +#define QT_READ ::qt_wince__read +#define QT_WRITE ::qt_wince__write +#define QT_ACCESS ::qt_wince__access +#define QT_GETCWD ::_getcwd +#define QT_CHDIR ::_chdir +#define QT_MKDIR ::qt_wince__mkdir +#define QT_RMDIR ::qt_wince__rmdir +#define QT_OPEN_RDONLY _O_RDONLY +#define QT_OPEN_WRONLY _O_WRONLY +#define QT_OPEN_RDWR _O_RDWR +#define QT_OPEN_CREAT _O_CREAT +#define QT_OPEN_TRUNC _O_TRUNC +#define QT_OPEN_APPEND _O_APPEND +# define QT_OPEN_TEXT _O_TEXT +# define QT_OPEN_BINARY _O_BINARY + +#define QT_FOPEN ::fopen +#define QT_FSEEK ::fseek +#define QT_FTELL ::ftell +#define QT_FGETPOS ::fgetpos +#define QT_FSETPOS ::fsetpos +#define QT_FPOS_T fpos_t +#define QT_OFF_T long + +#define QT_SIGNAL_ARGS int + +#define QT_VSNPRINTF(buffer, count, format, arg) \ + _vsnprintf(buffer, count, format, arg) + +#define QT_SNPRINTF ::_snprintf + +# define F_OK 0 +# define X_OK 1 +# define W_OK 2 +# define R_OK 4 + +typedef int mode_t; + +#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wince50standard-armv4i-msvc2005/qmake.conf b/mkspecs/wince50standard-armv4i-msvc2005/qmake.conf index 45ebcf7..28ca6a6 100644 --- a/mkspecs/wince50standard-armv4i-msvc2005/qmake.conf +++ b/mkspecs/wince50standard-armv4i-msvc2005/qmake.conf @@ -3,7 +3,7 @@ # # Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 5.0 (ARMV4I) # -include(../common/wince.conf) +include(../common/wince/qmake.conf) CE_SDK = STANDARDSDK_500 CE_ARCH = ARMV4I diff --git a/mkspecs/wince50standard-armv4i-msvc2005/qplatformdefs.h b/mkspecs/wince50standard-armv4i-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wince50standard-armv4i-msvc2005/qplatformdefs.h +++ b/mkspecs/wince50standard-armv4i-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include <limits.h> -#undef _POSIX_ - -#include <tchar.h> -#include <stdio.h> -#include <stdlib.h> -#include <windows.h> - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wince50standard-armv4i-msvc2008/qplatformdefs.h b/mkspecs/wince50standard-armv4i-msvc2008/qplatformdefs.h index f775941..cda4ff4 100644 --- a/mkspecs/wince50standard-armv4i-msvc2008/qplatformdefs.h +++ b/mkspecs/wince50standard-armv4i-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wince50standard-armv4i-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wince50standard-mipsii-msvc2005/qmake.conf b/mkspecs/wince50standard-mipsii-msvc2005/qmake.conf index 7d765de..0cc1ab0 100644 --- a/mkspecs/wince50standard-mipsii-msvc2005/qmake.conf +++ b/mkspecs/wince50standard-mipsii-msvc2005/qmake.conf @@ -3,7 +3,7 @@ # # Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 5.0 (MIPSII) # -include(../common/wince.conf) +include(../common/wince/qmake.conf) CE_SDK = STANDARDSDK_500 CE_ARCH = MIPSII diff --git a/mkspecs/wince50standard-mipsii-msvc2005/qplatformdefs.h b/mkspecs/wince50standard-mipsii-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wince50standard-mipsii-msvc2005/qplatformdefs.h +++ b/mkspecs/wince50standard-mipsii-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include <limits.h> -#undef _POSIX_ - -#include <tchar.h> -#include <stdio.h> -#include <stdlib.h> -#include <windows.h> - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wince50standard-mipsii-msvc2008/qplatformdefs.h b/mkspecs/wince50standard-mipsii-msvc2008/qplatformdefs.h index 319d49a..cda4ff4 100644 --- a/mkspecs/wince50standard-mipsii-msvc2008/qplatformdefs.h +++ b/mkspecs/wince50standard-mipsii-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wince50standard-mipsii-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wince50standard-mipsiv-msvc2005/qmake.conf b/mkspecs/wince50standard-mipsiv-msvc2005/qmake.conf index 4750d88..a22505c 100644 --- a/mkspecs/wince50standard-mipsiv-msvc2005/qmake.conf +++ b/mkspecs/wince50standard-mipsiv-msvc2005/qmake.conf @@ -3,7 +3,7 @@ # # Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 5.0 (MIPSIV) # -include(../common/wince.conf) +include(../common/wince/qmake.conf) CE_SDK = STANDARDSDK_500 CE_ARCH = MIPSIV diff --git a/mkspecs/wince50standard-mipsiv-msvc2005/qplatformdefs.h b/mkspecs/wince50standard-mipsiv-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wince50standard-mipsiv-msvc2005/qplatformdefs.h +++ b/mkspecs/wince50standard-mipsiv-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include <limits.h> -#undef _POSIX_ - -#include <tchar.h> -#include <stdio.h> -#include <stdlib.h> -#include <windows.h> - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wince50standard-mipsiv-msvc2008/qplatformdefs.h b/mkspecs/wince50standard-mipsiv-msvc2008/qplatformdefs.h index 9a6f3ed..cda4ff4 100644 --- a/mkspecs/wince50standard-mipsiv-msvc2008/qplatformdefs.h +++ b/mkspecs/wince50standard-mipsiv-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wince50standard-mipsiv-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wince50standard-sh4-msvc2005/qmake.conf b/mkspecs/wince50standard-sh4-msvc2005/qmake.conf index aa420f2..1ee8950 100644 --- a/mkspecs/wince50standard-sh4-msvc2005/qmake.conf +++ b/mkspecs/wince50standard-sh4-msvc2005/qmake.conf @@ -3,7 +3,7 @@ # # Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 5.0 (SH4) # -include(../common/wince.conf) +include(../common/wince/qmake.conf) CE_SDK = STANDARDSDK_500 CE_ARCH = SH4 diff --git a/mkspecs/wince50standard-sh4-msvc2005/qplatformdefs.h b/mkspecs/wince50standard-sh4-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wince50standard-sh4-msvc2005/qplatformdefs.h +++ b/mkspecs/wince50standard-sh4-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include <limits.h> -#undef _POSIX_ - -#include <tchar.h> -#include <stdio.h> -#include <stdlib.h> -#include <windows.h> - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wince50standard-sh4-msvc2008/qplatformdefs.h b/mkspecs/wince50standard-sh4-msvc2008/qplatformdefs.h index 88ca7ab..cda4ff4 100644 --- a/mkspecs/wince50standard-sh4-msvc2008/qplatformdefs.h +++ b/mkspecs/wince50standard-sh4-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wince50standard-sh4-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wince50standard-x86-msvc2005/qmake.conf b/mkspecs/wince50standard-x86-msvc2005/qmake.conf index 13bcc9f..2fa7556 100644 --- a/mkspecs/wince50standard-x86-msvc2005/qmake.conf +++ b/mkspecs/wince50standard-x86-msvc2005/qmake.conf @@ -3,7 +3,7 @@ # # Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 5.0 (x86) # -include(../common/wince.conf) +include(../common/wince/qmake.conf) CE_SDK = STANDARDSDK_500 CE_ARCH = x86 diff --git a/mkspecs/wince50standard-x86-msvc2005/qplatformdefs.h b/mkspecs/wince50standard-x86-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wince50standard-x86-msvc2005/qplatformdefs.h +++ b/mkspecs/wince50standard-x86-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include <limits.h> -#undef _POSIX_ - -#include <tchar.h> -#include <stdio.h> -#include <stdlib.h> -#include <windows.h> - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wince50standard-x86-msvc2008/qplatformdefs.h b/mkspecs/wince50standard-x86-msvc2008/qplatformdefs.h index 76dc923..cda4ff4 100644 --- a/mkspecs/wince50standard-x86-msvc2008/qplatformdefs.h +++ b/mkspecs/wince50standard-x86-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wince50standard-x86-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wince60standard-armv4i-msvc2005/qmake.conf b/mkspecs/wince60standard-armv4i-msvc2005/qmake.conf index 6386141..3bb18af 100644 --- a/mkspecs/wince60standard-armv4i-msvc2005/qmake.conf +++ b/mkspecs/wince60standard-armv4i-msvc2005/qmake.conf @@ -1,65 +1,20 @@ # # qmake configuration for wince-msvc2005 # -# Written for Microsoft VC2005.NET with Standard SDK for WindowsCE 6.0 (ARMV4I) +# Written for Microsoft VS 2005 for WindowsCE 6.0 (ARMV4I) +# This is just a template for creating Windows CE 6 mkspecs. # -MAKEFILE_GENERATOR = MSVC.NET -TEMPLATE = app -CONFIG += qt warn_on release incremental flat link_prl precompile_header autogen_precompile_source copy_dir_files debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe -QT += core gui -CE_SDK = STANDARDSDK_600 -CE_ARCH = ARMV4I - -DEFINES += UNDER_CE WINCE _WINDOWS _UNICODE UNICODE STANDARDSHELL_UI_MODEL _WIN32_WCE=0x600 $$CE_ARCH _ARMV4I_ armv4i _ARM_ ARM _M_ARM ARM _WIN32 __arm__ Q_OS_WINCE_STD QT_NO_PRINTER QT_NO_PRINTDIALOG - -QMAKE_COMPILER_DEFINES += _MSC_VER=1400 - -QMAKE_CC = cl -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = byacc -QMAKE_YACCFLAGS = -d -QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t- -QRarch4T -QRinterwork-return -QMAKE_CFLAGS_WARN_ON = -W3 -QMAKE_CFLAGS_WARN_OFF = -W0 -QMAKE_CFLAGS_RELEASE = -O2 -GL -MD -QMAKE_CFLAGS_DEBUG = -DDEBUG -D_DEBUG -Zi -MDd -QMAKE_CFLAGS_YACC = - -QMAKE_CXX = $$QMAKE_CC -QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -w34100 -w34189 -QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_STL_ON = -EHsc -QMAKE_CXXFLAGS_STL_OFF = -QMAKE_CXXFLAGS_RTTI_ON = -GR -QMAKE_CXXFLAGS_RTTI_OFF = -QMAKE_CXXFLAGS_EXCEPTIONS_ON = -EHsc -QMAKE_CXXFLAGS_EXCEPTIONS_OFF = +include(../common/wince/qmake.conf) -QMAKE_INCDIR = -QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] -QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] +CE_SDK = STANDARDSDK_600 # replace with actual SDK name +CE_ARCH = ARMV4I -QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CC_IMP_BATCH = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ @<< -QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CXX_IMP_BATCH = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ @<< +DEFINES += STANDARDSHELL_UI_MODEL _WIN32_WCE=0x600 $$CE_ARCH _ARMV4I_ armv4i _ARM_ ARM _M_ARM ARM _WIN32 __arm__ -QMAKE_LINK = link -QMAKE_LFLAGS = /NOLOGO /NODEFAULTLIB:OLDNAMES.LIB -QMAKE_LFLAGS_RELEASE = /LTCG /INCREMENTAL:NO -QMAKE_LFLAGS_DEBUG = /DEBUG QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:THUMB /ENTRY:mainACRTStartup QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:THUMB QMAKE_LFLAGS_DLL = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:THUMB /DLL /SAFESEH:NO -QMAKE_LIBFLAGS = $$QMAKE_LFLAGS_WINDOWS QMAKE_LIBFLAGS_RELEASE = /LTCG QMAKE_LIBS = corelibc.lib coredll.lib QMAKE_LIBS_CORE = libcmt.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib @@ -68,27 +23,5 @@ QMAKE_LIBS_NETWORK = ws2.lib $$QMAKE_LIBS_GUI QMAKE_LIBS_OPENGL = QMAKE_LIBS_COMPAT = -QMAKE_LIBS_QT_ENTRY = -lqtmain - -QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe -QMAKE_UIC = $$[QT_INSTALL_BINS]\uic.exe -QMAKE_IDC = $$[QT_INSTALL_BINS]\idc.exe - -QMAKE_IDL = midl -QMAKE_LIB = lib QMAKE_RC = rc /DUNDER_CE=600 /D_WIN32_WCE=0x600 -QMAKE_ZIP = zip -r -9 - -QMAKE_COPY = copy /y -QMAKE_COPY_DIR = xcopy /s /q /y /i -QMAKE_MOVE = move -QMAKE_DEL_FILE = del -QMAKE_DEL_DIR = rmdir -QMAKE_CHK_DIR_EXISTS = if not exist -QMAKE_MKDIR = mkdir - -VCPROJ_EXTENSION = .vcproj -VCSOLUTION_EXTENSION = .sln -VCPROJ_KEYWORD = Qt4VSv1.0 -load(qt_config) diff --git a/mkspecs/wince60standard-armv4i-msvc2005/qplatformdefs.h b/mkspecs/wince60standard-armv4i-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wince60standard-armv4i-msvc2005/qplatformdefs.h +++ b/mkspecs/wince60standard-armv4i-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include <limits.h> -#undef _POSIX_ - -#include <tchar.h> -#include <stdio.h> -#include <stdlib.h> -#include <windows.h> - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wince60standard-x86-msvc2005/qmake.conf b/mkspecs/wince60standard-x86-msvc2005/qmake.conf new file mode 100644 index 0000000..2896c69 --- /dev/null +++ b/mkspecs/wince60standard-x86-msvc2005/qmake.conf @@ -0,0 +1,27 @@ +# +# qmake configuration for wince-msvc2005 +# +# Written for Microsoft VS 2005 for WindowsCE 6.0 (x86) +# This is just a template for creating Windows CE 6 mkspecs. +# + +include(../common/wince/qmake.conf) + +CE_SDK = STANDARDSDK_600 # replace with actual SDK name +CE_ARCH = x86 + +DEFINES += STANDARDSHELL_UI_MODEL _WIN32_WCE=0x600 $$CE_ARCH _X86_ _M_IX86 + +QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:X86 /ENTRY:mainACRTStartup +QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:X86 +QMAKE_LFLAGS_DLL = /SUBSYSTEM:WINDOWSCE,6.00 /MACHINE:X86 /DLL /SAFESEH:NO +QMAKE_LIBFLAGS_RELEASE = /LTCG +QMAKE_LIBS = corelibc.lib coredll.lib +QMAKE_LIBS_CORE = corelibc.lib ole32.lib oleaut32.lib uuid.lib commctrl.lib coredll.lib winsock.lib +QMAKE_LIBS_GUI = ceshell.lib ole32.lib $$QMAKE_LIBS_CORE +QMAKE_LIBS_NETWORK = ws2.lib $$QMAKE_LIBS_GUI +QMAKE_LIBS_OPENGL = +QMAKE_LIBS_COMPAT = + +QMAKE_RC = rc /DUNDER_CE=600 /D_WIN32_WCE=0x600 + diff --git a/mkspecs/wince60standard-x86-msvc2005/qplatformdefs.h b/mkspecs/wince60standard-x86-msvc2005/qplatformdefs.h new file mode 100644 index 0000000..cda4ff4 --- /dev/null +++ b/mkspecs/wince60standard-x86-msvc2005/qplatformdefs.h @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the qmake spec 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 "../common/wince/qplatformdefs.h" + diff --git a/mkspecs/wincewm50pocket-msvc2005/qmake.conf b/mkspecs/wincewm50pocket-msvc2005/qmake.conf index d75d86e..676be5a 100644 --- a/mkspecs/wincewm50pocket-msvc2005/qmake.conf +++ b/mkspecs/wincewm50pocket-msvc2005/qmake.conf @@ -3,7 +3,7 @@ # # Written for Microsoft VC2005.NET with Windows Mobile 5.0 SDK for Pocket PC (ARMV4I) # -include(../common/wince.conf) +include(../common/wince/qmake.conf) CE_SDK = Windows Mobile 5.0 Pocket PC SDK CE_ARCH = ARMV4I diff --git a/mkspecs/wincewm50pocket-msvc2005/qplatformdefs.h b/mkspecs/wincewm50pocket-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wincewm50pocket-msvc2005/qplatformdefs.h +++ b/mkspecs/wincewm50pocket-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include <limits.h> -#undef _POSIX_ - -#include <tchar.h> -#include <stdio.h> -#include <stdlib.h> -#include <windows.h> - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wincewm50pocket-msvc2008/qplatformdefs.h b/mkspecs/wincewm50pocket-msvc2008/qplatformdefs.h index f444562..cda4ff4 100644 --- a/mkspecs/wincewm50pocket-msvc2008/qplatformdefs.h +++ b/mkspecs/wincewm50pocket-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wincewm50pocket-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wincewm50smart-msvc2005/qmake.conf b/mkspecs/wincewm50smart-msvc2005/qmake.conf index 372b266..c0f09cc 100644 --- a/mkspecs/wincewm50smart-msvc2005/qmake.conf +++ b/mkspecs/wincewm50smart-msvc2005/qmake.conf @@ -3,7 +3,7 @@ # # Written for Microsoft VC2005.NET with Windows Mobile 5.0 SDK for Smartphone (ARMV4I) # -include(../common/wince.conf) +include(../common/wince/qmake.conf) CE_SDK = Windows Mobile 5.0 Smartphone SDK CE_ARCH = ARMV4I diff --git a/mkspecs/wincewm50smart-msvc2005/qplatformdefs.h b/mkspecs/wincewm50smart-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wincewm50smart-msvc2005/qplatformdefs.h +++ b/mkspecs/wincewm50smart-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include <limits.h> -#undef _POSIX_ - -#include <tchar.h> -#include <stdio.h> -#include <stdlib.h> -#include <windows.h> - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wincewm50smart-msvc2008/qplatformdefs.h b/mkspecs/wincewm50smart-msvc2008/qplatformdefs.h index 37c8f62..cda4ff4 100644 --- a/mkspecs/wincewm50smart-msvc2008/qplatformdefs.h +++ b/mkspecs/wincewm50smart-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wincewm50smart-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wincewm60professional-msvc2005/qplatformdefs.h b/mkspecs/wincewm60professional-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wincewm60professional-msvc2005/qplatformdefs.h +++ b/mkspecs/wincewm60professional-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include <limits.h> -#undef _POSIX_ - -#include <tchar.h> -#include <stdio.h> -#include <stdlib.h> -#include <windows.h> - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wincewm60professional-msvc2008/qplatformdefs.h b/mkspecs/wincewm60professional-msvc2008/qplatformdefs.h index a0737ae..cda4ff4 100644 --- a/mkspecs/wincewm60professional-msvc2008/qplatformdefs.h +++ b/mkspecs/wincewm60professional-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wincewm60professional-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wincewm60standard-msvc2005/qplatformdefs.h b/mkspecs/wincewm60standard-msvc2005/qplatformdefs.h index 4e67948..cda4ff4 100644 --- a/mkspecs/wincewm60standard-msvc2005/qplatformdefs.h +++ b/mkspecs/wincewm60standard-msvc2005/qplatformdefs.h @@ -39,93 +39,5 @@ ** ****************************************************************************/ -#ifndef QPLATFORMDEFS_H -#define QPLATFORMDEFS_H +#include "../common/wince/qplatformdefs.h" -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#endif - -// Get Qt defines/settings - -#include "qglobal.h" -#include "qfunctions_wince.h" - -#define _POSIX_ -#include <limits.h> -#undef _POSIX_ - -#include <tchar.h> -#include <stdio.h> -#include <stdlib.h> -#include <windows.h> - -#define Q_FS_FAT -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct _stati64 // non-ANSI defs -#define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs -#define QT_STAT ::_stati64 -#define QT_FSTAT ::_fstati64 -#else -#define QT_STATBUF struct stat // non-ANSI defs -#define QT_STATBUF4TSTAT struct stat // non-ANSI defs -#define QT_STAT ::qt_wince_stat -#define QT_FSTAT ::qt_wince__fstat -#endif -#define QT_STAT_REG _S_IFREG -#define QT_STAT_DIR _S_IFDIR -#define QT_STAT_MASK _S_IFMT -#if defined(_S_IFLNK) -# define QT_STAT_LNK _S_IFLNK -#endif -#define QT_FILENO ::qt_wince___fileno -#define QT_OPEN ::qt_wince_open -#define QT_CLOSE ::qt_wince__close -#ifdef QT_LARGEFILE_SUPPORT -#define QT_LSEEK ::_lseeki64 -#define QT_TSTAT ::_tstati64 -#else -#define QT_LSEEK ::qt_wince__lseek -#define QT_TSTAT ::_tstat -#endif -#define QT_READ ::qt_wince__read -#define QT_WRITE ::qt_wince__write -#define QT_ACCESS ::qt_wince__access -#define QT_GETCWD ::_getcwd -#define QT_CHDIR ::_chdir -#define QT_MKDIR ::qt_wince__mkdir -#define QT_RMDIR ::qt_wince__rmdir -#define QT_OPEN_RDONLY _O_RDONLY -#define QT_OPEN_WRONLY _O_WRONLY -#define QT_OPEN_RDWR _O_RDWR -#define QT_OPEN_CREAT _O_CREAT -#define QT_OPEN_TRUNC _O_TRUNC -#define QT_OPEN_APPEND _O_APPEND -# define QT_OPEN_TEXT _O_TEXT -# define QT_OPEN_BINARY _O_BINARY - -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long - -#define QT_SIGNAL_ARGS int - -#define QT_VSNPRINTF(buffer, count, format, arg) \ - _vsnprintf(buffer, count, format, arg) - -#define QT_SNPRINTF ::_snprintf - -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 - -typedef int mode_t; - -#endif // QPLATFORMDEFS_H diff --git a/mkspecs/wincewm60standard-msvc2008/qplatformdefs.h b/mkspecs/wincewm60standard-msvc2008/qplatformdefs.h index 819f150..cda4ff4 100644 --- a/mkspecs/wincewm60standard-msvc2008/qplatformdefs.h +++ b/mkspecs/wincewm60standard-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wincewm60standard-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/mkspecs/wincewm65professional-msvc2005/qplatformdefs.h b/mkspecs/wincewm65professional-msvc2005/qplatformdefs.h index c3270e2..cda4ff4 100644 --- a/mkspecs/wincewm65professional-msvc2005/qplatformdefs.h +++ b/mkspecs/wincewm65professional-msvc2005/qplatformdefs.h @@ -39,4 +39,5 @@ ** ****************************************************************************/ -#include "../wincewm60professional-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" + diff --git a/mkspecs/wincewm65professional-msvc2008/qplatformdefs.h b/mkspecs/wincewm65professional-msvc2008/qplatformdefs.h index 35219d0..cda4ff4 100644 --- a/mkspecs/wincewm65professional-msvc2008/qplatformdefs.h +++ b/mkspecs/wincewm65professional-msvc2008/qplatformdefs.h @@ -39,5 +39,5 @@ ** ****************************************************************************/ -#include "../wincewm65professional-msvc2005/qplatformdefs.h" +#include "../common/wince/qplatformdefs.h" diff --git a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi index 2d69c7d..5a75ab7 100644 --- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi +++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi @@ -323,7 +323,7 @@ 'runtime/TimeoutChecker.cpp', 'runtime/TimeoutChecker.h', 'runtime/Tracing.h', - 'runtime/TypeInfo.h', + 'runtime/JSTypeInfo.h', 'runtime/UString.cpp', 'runtime/UString.h', 'wrec/CharacterClass.cpp', diff --git a/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp b/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp index 29a13ca..de5175e 100644 --- a/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/interpreter/RegisterFile.cpp @@ -36,6 +36,9 @@ RegisterFile::~RegisterFile() #if HAVE(MMAP) munmap(reinterpret_cast<char*>(m_buffer), ((m_max - m_start) + m_maxGlobals) * sizeof(Register)); #elif HAVE(VIRTUALALLOC) +#if PLATFORM(WINCE) + VirtualFree(m_buffer, DWORD(m_commitEnd) - DWORD(m_buffer), MEM_DECOMMIT); +#endif VirtualFree(m_buffer, 0, MEM_RELEASE); #else fastFree(m_buffer); diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/TypeInfo.h b/src/3rdparty/webkit/JavaScriptCore/runtime/JSTypeInfo.h index 70aeed3..bea188b 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/TypeInfo.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/JSTypeInfo.h @@ -24,8 +24,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef TypeInfo_h -#define TypeInfo_h +#ifndef JSTypeInfo_h +#define JSTypeInfo_h #include "JSType.h" @@ -69,4 +69,4 @@ namespace JSC { } -#endif // TypeInfo_h +#endif // JSTypeInfo_h diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h index dcd4e50..ca4552b 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h @@ -31,7 +31,7 @@ #include "JSValue.h" #include "PropertyMapHashTable.h" #include "StructureTransitionTable.h" -#include "TypeInfo.h" +#include "JSTypeInfo.h" #include "UString.h" #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index e1b8509..31f0841 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -157,6 +157,19 @@ #define DEFAULT_TIMER_INTERVAL 16 +#ifdef Q_WS_WIN + /// Fix for Qt 4.7 + //on windows if you're currently dragging a widget an inner eventloop was started by the system + //to make sure that this timer is getting fired, we need to make sure to use the system timers + //that will send a WM_TIMER event. We do that by settings the timer interval to 11 + //It is 11 because QEventDispatcherWin32Private::registerTimer specifically checks if the interval + //is greater than 10 to determine if it should use a system timer (or the multimedia timer). +#define STARTSTOP_TIMER_DELAY 11 +#else +#define STARTSTOP_TIMER_DELAY 0 +#endif + + QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer) @@ -217,7 +230,7 @@ void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation) if (animations.contains(animation) || animationsToStart.contains(animation)) return; animationsToStart << animation; - startStopAnimationTimer.start(0, this); // we delay the check if we should start/stop the global timer + startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this); // we delay the check if we should start/stop the global timer } void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation) @@ -233,7 +246,7 @@ void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation) } else { animationsToStart.removeOne(animation); } - startStopAnimationTimer.start(0, this); // we delay the check if we should start/stop the global timer + startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this); // we delay the check if we should start/stop the global timer } diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 8f34e30..93de911 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1655,7 +1655,8 @@ public: FramebufferObject = 0x07, // GL framebuffer object CustomRaster = 0x08, MacQuartz = 0x09, - PaintBuffer = 0x0a + PaintBuffer = 0x0a, + OpenGL = 0x0b }; enum RelayoutType { RelayoutNormal, diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 50b4af7..80ccda3 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -865,15 +865,22 @@ QString QFSFileEngine::fileName(FileName file) const QString ret; if (!isRelativePathSymbian(d->filePath)) { if (d->filePath.size() > 2 && d->filePath.at(1) == QLatin1Char(':') - && d->filePath.at(2) != slashChar || // It's a drive-relative path, so Z:a.txt -> Z:\currentpath\a.txt - d->filePath.startsWith(slashChar) // It's a absolute path to the current drive, so \a.txt -> Z:\a.txt - ) { - ret = QString(QDir::currentPath().left(2) + QDir::fromNativeSeparators(d->filePath)); + && d->filePath.at(2) != slashChar){ + // It's a drive-relative path, so C:a.txt -> C:/currentpath/a.txt, + // or if it's different drive than current, Z:a.txt -> Z:/a.txt + QString currentPath = QDir::currentPath(); + if (0 == currentPath.left(1).compare(d->filePath.left(1), Qt::CaseInsensitive)) + ret = currentPath + slashChar + d->filePath.mid(2); + else + ret = d->filePath.left(2) + slashChar + d->filePath.mid(2); + } else if (d->filePath.startsWith(slashChar)) { + // It's a absolute path to the current drive, so /a.txt -> C:/a.txt + ret = QDir::currentPath().left(2) + d->filePath; } else { ret = d->filePath; } } else { - ret = QDir::cleanPath(QDir::currentPath() + slashChar + d->filePath); + ret = QDir::currentPath() + slashChar + d->filePath; } // The path should be absolute at this point. @@ -889,6 +896,12 @@ QString QFSFileEngine::fileName(FileName file) const ret[0] = ret.at(0).toUpper(); } + // Clean up the path + bool isDir = ret.endsWith(slashChar); + ret = QDir::cleanPath(ret); + if (isDir) + ret += slashChar; + if (file == AbsolutePathName) { int slash = ret.lastIndexOf(slashChar); if (slash < 0) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index c2bdbee..f316fec 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -367,21 +367,26 @@ Q_INLINE_TEMPLATE void QList<T>::node_copy(Node *from, Node *to, Node *src) if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) { QT_TRY { while(current != to) { - (current++)->v = new T(*reinterpret_cast<T*>((src++)->v)); + current->v = new T(*reinterpret_cast<T*>(src->v)); + ++current; + ++src; } } QT_CATCH(...) { - while (current != from) - delete reinterpret_cast<T*>(current--); + while (current-- != from) + delete reinterpret_cast<T*>(current->v); QT_RETHROW; } } else if (QTypeInfo<T>::isComplex) { QT_TRY { - while(current != to) - new (current++) T(*reinterpret_cast<T*>(src++)); + while(current != to) { + new (current) T(*reinterpret_cast<T*>(src)); + ++current; + ++src; + } } QT_CATCH(...) { - while (current != from) - (reinterpret_cast<T*>(current--))->~T(); + while (current-- != from) + (reinterpret_cast<T*>(current))->~T(); QT_RETHROW; } } else { diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp index 052c456..28ec963 100644 --- a/src/corelib/tools/qtimeline.cpp +++ b/src/corelib/tools/qtimeline.cpp @@ -388,6 +388,10 @@ void QTimeLine::setDirection(Direction direction) By default, this value is 1000 (i.e., 1 second), but you can change this by either passing a duration to QTimeLine's constructor, or by calling setDuration(). The duration must be larger than 0. + + \note Changing the duration does not cause the current time to be reset + to zero or the new duration. You also need to call setCurrentTime() with + the desired value. */ int QTimeLine::duration() const { diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 9bf4b10..87873f2 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -59,6 +59,8 @@ WebView: status -> statusText WebView: mouseX -> clickX (parameter to onDoubleClick) WebView: mouseY -> clickY (parameter to onDoubleClick) WebView: cacheSize -> pixelCacheSize +Repeater: component -> delegate +Repeater: dataSource -> model Additions: MouseRegion: add "acceptedButtons" property @@ -67,6 +69,8 @@ MouseRegion: add "pressedButtons" property Timer: add start() and stop() slots WebView: add newWindowComponent and newWindowParent properties Loader: add status() and progress() properties +Loader: add sourceComponent property +Loader: add resizeMode property Deletions: Column/VerticalPositioner: lost "margins" property @@ -74,6 +78,7 @@ Row/HorizontalPositioner: lost "margins" property Grid/Positioner/Layout: lost "margins" property WebView: lost "interactive" property (always true now) Flickable: removed "dragMode" property +ComponentInstance: removed. Replaced by Loader.sourceComponent Other Changes: Drag: axis becomes an enum with values "XAxis", "YAxis", "XandYAxis" diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri index 80a6fdd..cfe78e1 100644 --- a/src/declarative/fx/fx.pri +++ b/src/declarative/fx/fx.pri @@ -1,8 +1,6 @@ HEADERS += \ fx/qfxanchors.h \ fx/qfxanchors_p.h \ - fx/qfxcomponentinstance.h \ - fx/qfxcomponentinstance_p.h \ fx/qfxevents_p.h \ fx/qfxflickable.h \ fx/qfxflickable_p.h \ @@ -49,7 +47,6 @@ HEADERS += \ SOURCES += \ fx/qfxanchors.cpp \ - fx/qfxcomponentinstance.cpp \ fx/qfxevents.cpp \ fx/qfxflickable.cpp \ fx/qfxflipable.cpp \ diff --git a/src/declarative/fx/qfxcomponentinstance.cpp b/src/declarative/fx/qfxcomponentinstance.cpp deleted file mode 100644 index 7a712aa..0000000 --- a/src/declarative/fx/qfxcomponentinstance.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative 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 qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qfxcomponentinstance.h" -#include "qfxcomponentinstance_p.h" -#include <private/qfxperf_p.h> -#include <QtDeclarative/qmlinfo.h> - - -QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,ComponentInstance,QFxComponentInstance) - -/*! - \internal - \class QFxComponentInstance ComponentInstance - - \brief The QFxComponentInstance class provides a way to instantiate an item from a component. - */ - -/*! - \qmlclass ComponentInstance QFxComponentInstance - \brief The ComponentInstance item allows you to instantiate a \l{Component}. - - \qml - Item { - Component { - id: RedSquare - Rectangle { color: "red"; width: 10; height: 10 } - } - - ComponentInstance { component: RedSquare } - } - \endqml -*/ -QFxComponentInstance::QFxComponentInstance(QFxItem *parent) - : QFxItem(*(new QFxComponentInstancePrivate), parent) -{ -} - -QFxComponentInstance::QFxComponentInstance(QFxComponentInstancePrivate &dd, QFxItem *parent) - : QFxItem(dd, parent) -{ -} - -/*! - \qmlproperty Component QFxComponentInstance::component - - This property holds the component to instantiate. -*/ -QmlComponent *QFxComponentInstance::component() const -{ - Q_D(const QFxComponentInstance); - return d->component; -} - -void QFxComponentInstance::setComponent(QmlComponent *c) -{ - Q_D(QFxComponentInstance); - if (d->component) { - qmlInfo(this) << "component is a write-once property."; - return; - } - d->component = c; - create(); -} - -void QFxComponentInstance::create() -{ - Q_D(QFxComponentInstance); - if (d->component) { - QObject *obj= d->component->create(qmlContext(this)); - if (obj) { - QFxItem *objitem = qobject_cast<QFxItem *>(obj); - if (objitem) { - d->instance = objitem; - objitem->setParentItem(this); - objitem->setFocus(true); - connect(objitem, SIGNAL(widthChanged()), this, SLOT(updateSize())); - connect(objitem, SIGNAL(heightChanged()), this, SLOT(updateSize())); - updateSize(); - emit instanceChanged(); - } else { - delete obj; - } - } - } -} - -void QFxComponentInstance::updateSize() -{ - QFxItem *i = instance(); - if (i) { - if (!widthValid()) - setImplicitWidth(i->width()); - if (!heightValid()) - setImplicitHeight(i->height()); - } -} - -/*! - \qmlproperty Item QFxComponentInstance::instance - - This property holds the instantiated component. -*/ -QFxItem *QFxComponentInstance::instance() const -{ - Q_D(const QFxComponentInstance); - return d->instance; -} - -QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxcomponentinstance.h b/src/declarative/fx/qfxcomponentinstance.h deleted file mode 100644 index b223ca2..0000000 --- a/src/declarative/fx/qfxcomponentinstance.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative 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 qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXCOMPONENTINSTANCE_H -#define QFXCOMPONENTINSTANCE_H - -#include <QtDeclarative/qfxitem.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -//### remove -//### add component property to Loader - -class QFxComponentInstancePrivate; -class Q_DECLARATIVE_EXPORT QFxComponentInstance : public QFxItem -{ - Q_OBJECT - Q_PROPERTY(QmlComponent *component READ component WRITE setComponent) - Q_PROPERTY(QFxItem *instance READ instance) - Q_CLASSINFO("DefaultProperty", "component") -public: - QFxComponentInstance(QFxItem *parent=0); - - QmlComponent *component() const; - void setComponent(QmlComponent *); - - QFxItem *instance() const; - -Q_SIGNALS: - void instanceChanged(); - -private Q_SLOTS: - void updateSize(); - -private: - void create(); - -protected: - QFxComponentInstance(QFxComponentInstancePrivate &dd, QFxItem *parent); - -private: - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QFxComponentInstance) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QFxComponentInstance) - -QT_END_HEADER - -#endif // QFXCOMPONENTINSTANCE_H diff --git a/src/declarative/fx/qfxcomponentinstance_p.h b/src/declarative/fx/qfxcomponentinstance_p.h deleted file mode 100644 index defeb74..0000000 --- a/src/declarative/fx/qfxcomponentinstance_p.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative 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 qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXCOMPONENTINSTANCE_P_H -#define QFXCOMPONENTINSTANCE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qfxitem_p.h" - - -QT_BEGIN_NAMESPACE -class QFxComponentInstancePrivate : public QFxItemPrivate -{ - Q_DECLARE_PUBLIC(QFxComponentInstance) - -public: - QFxComponentInstancePrivate() - : component(0), instance(0) - { - } - - QmlComponent *component; - QFxItem *instance; -}; - -QT_END_NAMESPACE - -#endif // QFXCOMPONENTINSTANCE_P_H diff --git a/src/declarative/fx/qfxgridview.h b/src/declarative/fx/qfxgridview.h index 4ebd311..954f9fe 100644 --- a/src/declarative/fx/qfxgridview.h +++ b/src/declarative/fx/qfxgridview.h @@ -60,14 +60,14 @@ class Q_DECLARATIVE_EXPORT QFxGridView : public QFxFlickable Q_PROPERTY(QVariant model READ model WRITE setModel) Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) - Q_PROPERTY(QFxItem *current READ currentItem NOTIFY currentIndexChanged) + Q_PROPERTY(QFxItem *current READ currentItem NOTIFY currentIndexChanged) //### currentItem Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(QmlComponent *highlight READ highlight WRITE setHighlight) Q_PROPERTY(bool autoHighlight READ autoHighlight WRITE setAutoHighlight) Q_PROPERTY(Flow flow READ flow WRITE setFlow) Q_PROPERTY(bool wrap READ isWrapEnabled WRITE setWrapEnabled) Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer) - Q_PROPERTY(int cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellSizeChanged) + Q_PROPERTY(int cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellSizeChanged) //### columnCount, rowCount Q_PROPERTY(int cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellSizeChanged) Q_CLASSINFO("DefaultProperty", "data") diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h index 42ce1a2..dc0b039 100644 --- a/src/declarative/fx/qfxlistview.h +++ b/src/declarative/fx/qfxlistview.h @@ -50,6 +50,11 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) +//### get rid of z = index and set known z-value (1 for items, 0 for highlight) +//### incrementCurrentIndex(), decrementCurrentIndex() slots +//### default Keys.OnUp/DownPressed handler + + class QFxVisualModel; class QFxListViewAttached; class QFxListViewPrivate; @@ -60,17 +65,17 @@ class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable Q_ENUMS(CurrentItemPositioning) Q_PROPERTY(QVariant model READ model WRITE setModel) - Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate) + Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate) //### what happens if delegate is not a QFxItem? Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) - Q_PROPERTY(QFxItem *current READ currentItem NOTIFY currentIndexChanged) + Q_PROPERTY(QFxItem *current READ currentItem NOTIFY currentIndexChanged) //### currentItem Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(QmlComponent *highlight READ highlight WRITE setHighlight) - Q_PROPERTY(bool autoHighlight READ autoHighlight WRITE setAutoHighlight) - Q_PROPERTY(CurrentItemPositioning currentItemPositioning READ currentItemPositioning WRITE setCurrentItemPositioning) + Q_PROPERTY(bool autoHighlight READ autoHighlight WRITE setAutoHighlight) //### highlightFollowsCurrentItem + Q_PROPERTY(CurrentItemPositioning currentItemPositioning READ currentItemPositioning WRITE setCurrentItemPositioning) //### mode Q_PROPERTY(int snapPosition READ snapPosition WRITE setSnapPosition) - Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) + Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) //### qreal Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) - Q_PROPERTY(bool wrap READ isWrapEnabled WRITE setWrapEnabled) + Q_PROPERTY(bool wrap READ isWrapEnabled WRITE setWrapEnabled) //### keyNavigationWraps, stops at end when held Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer) Q_PROPERTY(QString sectionExpression READ sectionExpression WRITE setSectionExpression NOTIFY sectionExpressionChanged) Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged) @@ -98,6 +103,11 @@ public: bool autoHighlight() const; void setAutoHighlight(bool); + //### QSpan preferredHighlightRange + //### bool strictlyEnforceHighlightRange + + //### don't jump around unnecessarily + //### fix highlight for snapAuto enum CurrentItemPositioning { Free, Snap, SnapAuto }; CurrentItemPositioning currentItemPositioning() const; void setCurrentItemPositioning(CurrentItemPositioning mode); diff --git a/src/declarative/fx/qfxloader.cpp b/src/declarative/fx/qfxloader.cpp index 869a5b0..e75ce6d 100644 --- a/src/declarative/fx/qfxloader.cpp +++ b/src/declarative/fx/qfxloader.cpp @@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE QFxLoaderPrivate::QFxLoaderPrivate() -: item(0), qmlcomp(0) +: item(0), component(0), ownComponent(false), resizeMode(QFxLoader::SizeLoaderToItem) { } @@ -59,9 +59,22 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Loader,QFxLoader) \qmlclass Loader \inherits Item - \brief The Loader item allows you to dynamically load an Item-based - subtree from a QML URL. - */ + \brief The Loader item allows dynamically loading an Item-based + subtree from a QML URL or Component. + + Loader instantiates an item from a component. The component to + instantiate may be specified directly by the \c sourceComponent + property, or loaded from a URL via the \c source property. + + It is also an effective means of delaying the creation of a component + until it is required: + \code + Loader { id: PageLoader } + Rectangle { + MouseRegion { anchors.fill: parent; onClicked: PageLoader.source = "Page1.qml" } + } + \endcode +*/ /*! \internal @@ -86,10 +99,10 @@ QFxLoader::~QFxLoader() /*! \qmlproperty url Loader::source - This property holds the dynamic URL of the QML for the item. + This property holds the URL of the QML component to + instantiate. - This property is used for dynamically loading QML into the - item. + \sa status, progress */ QUrl QFxLoader::source() const { @@ -103,44 +116,98 @@ void QFxLoader::setSource(const QUrl &url) if (d->source == url) return; - if (!d->source.isEmpty()) { - QHash<QString, QFxItem *>::Iterator iter = d->cachedChildren.find(d->source.toString()); - if (iter != d->cachedChildren.end()) - (*iter)->setOpacity(0.); + if (d->ownComponent) { + delete d->component; + d->component = 0; } - - d->source = url; d->item = 0; - emit itemChanged(); + delete d->item; + d->source = url; if (d->source.isEmpty()) { emit sourceChanged(); emit statusChanged(); emit progressChanged(); + emit itemChanged(); + return; + } + + d->component = new QmlComponent(qmlEngine(this), d->source, this); + d->ownComponent = true; + if (!d->component->isLoading()) { + d->_q_sourceLoaded(); + } else { + connect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), + this, SLOT(_q_sourceLoaded())); + connect(d->component, SIGNAL(progressChanged(qreal)), + this, SIGNAL(progressChanged())); + emit statusChanged(); + emit progressChanged(); + emit sourceChanged(); + emit itemChanged(); + } +} + +/*! + \qmlproperty Component Loader::sourceComponent + The sourceComponent property holds the \l{Component} to instantiate. + + \qml + Item { + Component { + id: RedSquare + Rectangle { color: "red"; width: 10; height: 10 } + } + + Loader { sourceComponent: RedSquare } + Loader { sourceComponent: RedSquare; x: 10 } + } + \endqml + + \sa source +*/ + +QmlComponent *QFxLoader::sourceComponent() const +{ + Q_D(const QFxLoader); + return d->component; +} + +void QFxLoader::setSourceComponent(QmlComponent *comp) +{ + Q_D(QFxLoader); + if (comp == d->component) return; + + d->source = QUrl(); + if (d->ownComponent) { + delete d->component; + d->component = 0; } + delete d->item; + d->item = 0; - QHash<QString, QFxItem *>::Iterator iter = d->cachedChildren.find(d->source.toString()); - if (iter != d->cachedChildren.end()) { - (*iter)->setOpacity(1.); - d->item = (*iter); + d->component = comp; + d->ownComponent = false; + if (!d->component) { emit sourceChanged(); emit statusChanged(); emit progressChanged(); emit itemChanged(); + return; + } + + if (!d->component->isLoading()) { + d->_q_sourceLoaded(); } else { - d->qmlcomp = - new QmlComponent(qmlEngine(this), d->source, this); - if (!d->qmlcomp->isLoading()) { - d->_q_sourceLoaded(); - } else { - connect(d->qmlcomp, SIGNAL(statusChanged(QmlComponent::Status)), - this, SLOT(_q_sourceLoaded())); - connect(d->qmlcomp, SIGNAL(progressChanged(qreal)), - this, SIGNAL(progressChanged())); - emit statusChanged(); - emit progressChanged(); - } + connect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), + this, SLOT(_q_sourceLoaded())); + connect(d->component, SIGNAL(progressChanged(qreal)), + this, SIGNAL(progressChanged())); + emit progressChanged(); + emit sourceChanged(); + emit statusChanged(); + emit itemChanged(); } } @@ -148,33 +215,39 @@ void QFxLoaderPrivate::_q_sourceLoaded() { Q_Q(QFxLoader); - if (qmlcomp) { + if (component) { QmlContext *ctxt = new QmlContext(qmlContext(q)); ctxt->addDefaultObject(q); - if (!qmlcomp->errors().isEmpty()) { - qWarning() << qmlcomp->errors(); - delete qmlcomp; - qmlcomp = 0; + if (!component->errors().isEmpty()) { + qWarning() << component->errors(); emit q->sourceChanged(); emit q->statusChanged(); emit q->progressChanged(); return; } - QObject *obj = qmlcomp->create(ctxt); - if (!qmlcomp->errors().isEmpty()) - qWarning() << qmlcomp->errors(); - QFxItem *qmlChild = qobject_cast<QFxItem *>(obj); - if (qmlChild) { - qmlChild->setParentItem(q); - cachedChildren.insert(source.toString(), qmlChild); - item = qmlChild; + + QObject *obj = component->create(ctxt); + if (obj) { + item = qobject_cast<QFxItem *>(obj); + if (item) { + item->setParentItem(q); +// item->setFocus(true); + QFxItem *resizeItem = 0; + if (resizeMode == QFxLoader::SizeLoaderToItem) + resizeItem = item; + else if (resizeMode == QFxLoader::SizeItemToLoader) + resizeItem = q; + if (resizeItem) { + QObject::connect(resizeItem, SIGNAL(widthChanged()), q, SLOT(_q_updateSize())); + QObject::connect(resizeItem, SIGNAL(heightChanged()), q, SLOT(_q_updateSize())); + } + _q_updateSize(); + } } else { - delete qmlChild; + delete obj; source = QUrl(); } - delete qmlcomp; - qmlcomp = 0; emit q->sourceChanged(); emit q->statusChanged(); emit q->progressChanged(); @@ -196,6 +269,19 @@ void QFxLoaderPrivate::_q_sourceLoaded() \sa progress */ +QFxLoader::Status QFxLoader::status() const +{ + Q_D(const QFxLoader); + + if (d->component) + return static_cast<QFxLoader::Status>(d->component->status()); + + if (d->item) + return Ready; + + return d->source.isEmpty() ? Null : Error; +} + /*! \qmlproperty real Loader::progress @@ -204,27 +290,89 @@ void QFxLoaderPrivate::_q_sourceLoaded() \sa status */ -QFxLoader::Status QFxLoader::status() const +qreal QFxLoader::progress() const { Q_D(const QFxLoader); - if (d->qmlcomp) - return static_cast<QFxLoader::Status>(d->qmlcomp->status()); - if (d->item) - return Ready; + return 1.0; - return d->source.isEmpty() ? Null : Error; + if (d->component) + return d->component->progress(); + + return 0.0; } -qreal QFxLoader::progress() const +/*! + \qmlproperty enum Loader::resizeMode + + This property determines how the Loader or item are resized: + \list + \o NoResize - no item will be resized + \o SizeLoaderToItem - the Loader will be sized to the size of the item, unless the size of the Loader has been otherwise specified. + \o SizeItemToLoader - the item will be sized to the size of the Loader. + \endlist + + The default resizeMode is SizeLoaderToItem. +*/ +QFxLoader::ResizeMode QFxLoader::resizeMode() const { Q_D(const QFxLoader); + return d->resizeMode; +} - if (d->qmlcomp) - return d->qmlcomp->progress(); +void QFxLoader::setResizeMode(ResizeMode mode) +{ + Q_D(QFxLoader); + if (mode == d->resizeMode) + return; - return d->item ? 1.0 : 0.0; + if (d->item) { + QFxItem *resizeItem = 0; + if (d->resizeMode == SizeLoaderToItem) + resizeItem = d->item; + else if (d->resizeMode == SizeItemToLoader) + resizeItem = this; + if (resizeItem) { + disconnect(resizeItem, SIGNAL(widthChanged()), this, SLOT(_q_updateSize())); + disconnect(resizeItem, SIGNAL(heightChanged()), this, SLOT(_q_updateSize())); + } + } + + d->resizeMode = mode; + + if (d->item) { + QFxItem *resizeItem = 0; + if (d->resizeMode == SizeLoaderToItem) + resizeItem = d->item; + else if (d->resizeMode == SizeItemToLoader) + resizeItem = this; + if (resizeItem) { + connect(resizeItem, SIGNAL(widthChanged()), this, SLOT(_q_updateSize())); + connect(resizeItem, SIGNAL(heightChanged()), this, SLOT(_q_updateSize())); + } + } +} + +void QFxLoaderPrivate::_q_updateSize() +{ + Q_Q(QFxLoader); + if (!item) + return; + switch (resizeMode) { + case QFxLoader::SizeLoaderToItem: + if (!q->widthValid()) + q->setImplicitWidth(item->width()); + if (!q->heightValid()) + q->setImplicitHeight(item->height()); + break; + case QFxLoader::SizeItemToLoader: + item->setWidth(q->width()); + item->setHeight(q->height()); + break; + default: + break; + } } /*! diff --git a/src/declarative/fx/qfxloader.h b/src/declarative/fx/qfxloader.h index 132c8f4..b967465 100644 --- a/src/declarative/fx/qfxloader.h +++ b/src/declarative/fx/qfxloader.h @@ -55,14 +55,15 @@ class Q_DECLARATIVE_EXPORT QFxLoader : public QFxItem { Q_OBJECT Q_ENUMS(Status) + Q_ENUMS(ResizeMode) Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) + Q_PROPERTY(QmlComponent *sourceComponent READ sourceComponent WRITE setSourceComponent NOTIFY sourceChanged) + Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode) Q_PROPERTY(QFxItem *item READ item NOTIFY itemChanged) Q_PROPERTY(Status status READ status NOTIFY statusChanged) Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) //### sourceItem - //### sourceComponent - //### resizeMode { NoResize, SizeLoaderToItem (default), SizeItemToLoader } public: QFxLoader(QFxItem *parent=0); @@ -71,10 +72,17 @@ public: QUrl source() const; void setSource(const QUrl &); + QmlComponent *sourceComponent() const; + void setSourceComponent(QmlComponent *); + enum Status { Null, Ready, Loading, Error }; Status status() const; qreal progress() const; + enum ResizeMode { NoResize, SizeLoaderToItem, SizeItemToLoader }; + ResizeMode resizeMode() const; + void setResizeMode(ResizeMode mode); + QFxItem *item() const; Q_SIGNALS: @@ -87,6 +95,7 @@ private: Q_DISABLE_COPY(QFxLoader) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QFxLoader) Q_PRIVATE_SLOT(d_func(), void _q_sourceLoaded()) + Q_PRIVATE_SLOT(d_func(), void _q_updateSize()) }; QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxloader_p.h b/src/declarative/fx/qfxloader_p.h index 13f3b53..0700fcd 100644 --- a/src/declarative/fx/qfxloader_p.h +++ b/src/declarative/fx/qfxloader_p.h @@ -69,10 +69,12 @@ public: QUrl source; QFxItem *item; - QmlComponent *qmlcomp; - QHash<QString, QFxItem *> cachedChildren; + QmlComponent *component; + bool ownComponent; + QFxLoader::ResizeMode resizeMode; void _q_sourceLoaded(); + void _q_updateSize(); }; QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxpositioners.cpp b/src/declarative/fx/qfxpositioners.cpp index bad4944..e4500aa 100644 --- a/src/declarative/fx/qfxpositioners.cpp +++ b/src/declarative/fx/qfxpositioners.cpp @@ -251,6 +251,18 @@ void QFxBasePositioner::prePositioning() d->_animated.clear(); doPositioning(); finishApplyTransitions(); + //Set implicit size to the size of its children + //###To keep this valid, do we need to update on pos change as well? + qreal h = 0.0f; + qreal w = 0.0f; + foreach(QFxItem *child, d->_items){ + if(!child->isVisible() || child->opacity() <= 0) + continue; + h = qMax(h, child->y() + child->height()); + w = qMax(w, child->x() + child->width()); + } + setImplicitHeight(h); + setImplicitWidth(w); } void QFxBasePositioner::applyTransition(const QList<QPair<QString, QVariant> >& changes, QFxItem* target, QmlStateOperation::ActionList &actions) diff --git a/src/declarative/fx/qfxtextinput.cpp b/src/declarative/fx/qfxtextinput.cpp index 4dd29cd..39a0187 100644 --- a/src/declarative/fx/qfxtextinput.cpp +++ b/src/declarative/fx/qfxtextinput.cpp @@ -480,6 +480,13 @@ void QFxTextInput::focusChanged(bool hasFocus) void QFxTextInput::keyPressEvent(QKeyEvent* ev) { Q_D(QFxTextInput); + if((d->control->cursor() == 0 && ev->key() == Qt::Key_Left) + || (d->control->cursor() == d->control->text().length() + && ev->key() == Qt::Key_Right)){ + //ignore moving off the end + ev->ignore(); + return; + } d->control->processKeyEvent(ev); if (!ev->isAccepted()) QFxPaintedItem::keyPressEvent(ev); @@ -500,6 +507,7 @@ bool QFxTextInput::event(QEvent* ev) Q_D(QFxTextInput); //Anything we don't deal with ourselves, pass to the control switch(ev->type()){ + case QEvent::KeyPress: case QEvent::GraphicsSceneMousePress: break; default: @@ -645,7 +653,8 @@ void QFxTextInput::updateSize() setImplicitHeight(d->control->height()); //d->control->width() is max width, not current width QFontMetrics fm = QFontMetrics(d->font); - setImplicitWidth(fm.boundingRect(d->control->text()).width()+1); + setImplicitWidth(fm.width(d->control->text())+1); + //setImplicitWidth(d->control->naturalWidth());//### This fn should be coming into 4.6 shortly, and might be faster setContentsSize(QSize(width(), height())); } diff --git a/src/declarative/qml/parser/qmljs.g b/src/declarative/qml/parser/qmljs.g index b0ef866..4ed75e8 100644 --- a/src/declarative/qml/parser/qmljs.g +++ b/src/declarative/qml/parser/qmljs.g @@ -80,6 +80,7 @@ %token T_DEBUGGER "debugger" %token T_RESERVED_WORD "reserved word" %token T_MULTILINE_STRING_LITERAL "multiline string literal" +%token T_COMMENT "comment" --- context keywords. %token T_PUBLIC "public" diff --git a/src/declarative/qml/parser/qmljsastfwd_p.h b/src/declarative/qml/parser/qmljsastfwd_p.h index f79cfc2..a6fee1d 100644 --- a/src/declarative/qml/parser/qmljsastfwd_p.h +++ b/src/declarative/qml/parser/qmljsastfwd_p.h @@ -62,9 +62,9 @@ namespace QmlJS { namespace AST { class SourceLocation { public: - SourceLocation(quint32 offset = 0, quint32 length = 0) + SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0) : offset(offset), length(length), - startLine(0), startColumn(0) + startLine(line), startColumn(column) { } bool isValid() const { return length != 0; } diff --git a/src/declarative/qml/parser/qmljsengine_p.cpp b/src/declarative/qml/parser/qmljsengine_p.cpp index 02d9b9c..eab8944 100644 --- a/src/declarative/qml/parser/qmljsengine_p.cpp +++ b/src/declarative/qml/parser/qmljsengine_p.cpp @@ -178,6 +178,12 @@ Engine::~Engine() QSet<NameId> Engine::literals() const { return _literals; } +void Engine::addComment(int pos, int len, int line, int col) +{ if (len > 0) _comments.append(QmlJS::AST::SourceLocation(pos, len, line, col)); } + +QList<QmlJS::AST::SourceLocation> Engine::comments() const +{ return _comments; } + NameId *Engine::intern(const QChar *u, int s) { return const_cast<NameId *>(&*_literals.insert(NameId(u, s))); } diff --git a/src/declarative/qml/parser/qmljsengine_p.h b/src/declarative/qml/parser/qmljsengine_p.h index 5aea983..877fff2 100644 --- a/src/declarative/qml/parser/qmljsengine_p.h +++ b/src/declarative/qml/parser/qmljsengine_p.h @@ -143,6 +143,7 @@ class Engine Lexer *_lexer; NodePool *_nodePool; QSet<NameId> _literals; + QList<QmlJS::AST::SourceLocation> _comments; public: Engine(); @@ -150,6 +151,9 @@ public: QSet<NameId> literals() const; + void addComment(int pos, int len, int line, int col); + QList<QmlJS::AST::SourceLocation> comments() const; + NameId *intern(const QChar *u, int s); static QString toString(NameId *id); diff --git a/src/declarative/qml/parser/qmljslexer.cpp b/src/declarative/qml/parser/qmljslexer.cpp index 9da6ec0..f302733 100644 --- a/src/declarative/qml/parser/qmljslexer.cpp +++ b/src/declarative/qml/parser/qmljslexer.cpp @@ -71,7 +71,7 @@ extern double integerFromString(const char *buf, int size, int radix); using namespace QmlJS; -Lexer::Lexer(Engine *eng) +Lexer::Lexer(Engine *eng, bool tokenizeComments) : driver(eng), yylineno(0), done(false), @@ -94,7 +94,8 @@ Lexer::Lexer(Engine *eng) check_reserved(true), parenthesesState(IgnoreParentheses), parenthesesCount(0), - prohibitAutomaticSemicolon(false) + prohibitAutomaticSemicolon(false), + tokenizeComments(tokenizeComments) { driver->setLexer(this); // allocate space for read buffers @@ -647,22 +648,28 @@ int Lexer::lex() setDone(Other); } else state = Start; + driver->addComment(startpos, tokenLength(), startlineno, startcolumn); } else if (current == 0) { + driver->addComment(startpos, tokenLength(), startlineno, startcolumn); setDone(Eof); } + break; case InMultiLineComment: if (current == 0) { setDone(Bad); err = UnclosedComment; errmsg = QLatin1String("Unclosed comment at end of file"); + driver->addComment(startpos, tokenLength(), startlineno, startcolumn); } else if (isLineTerminator()) { shiftWindowsLineBreak(); yylineno++; } else if (current == '*' && next1 == '/') { state = Start; shift(1); + driver->addComment(startpos, tokenLength(), startlineno, startcolumn); } + break; case InIdentifier: if (isIdentLetter(current) || isDecimalDigit(current)) { diff --git a/src/declarative/qml/parser/qmljslexer_p.h b/src/declarative/qml/parser/qmljslexer_p.h index 5817868..6cca45d 100644 --- a/src/declarative/qml/parser/qmljslexer_p.h +++ b/src/declarative/qml/parser/qmljslexer_p.h @@ -67,7 +67,7 @@ class NameId; class Lexer { public: - Lexer(Engine *eng); + Lexer(Engine *eng, bool tokenizeComments = false); ~Lexer(); void setCode(const QString &c, int lineno); @@ -239,6 +239,7 @@ private: ParenthesesState parenthesesState; int parenthesesCount; bool prohibitAutomaticSemicolon; + bool tokenizeComments; }; } // namespace QmlJS diff --git a/src/declarative/qml/qmetaobjectbuilder_p.h b/src/declarative/qml/qmetaobjectbuilder_p.h index d503163..c0b7426 100644 --- a/src/declarative/qml/qmetaobjectbuilder_p.h +++ b/src/declarative/qml/qmetaobjectbuilder_p.h @@ -68,7 +68,7 @@ class QMetaPropertyBuilderPrivate; class QMetaEnumBuilder; class QMetaEnumBuilderPrivate; -class Q_CORE_EXPORT QMetaObjectBuilder +class Q_DECLARATIVE_EXPORT QMetaObjectBuilder { public: enum AddMember @@ -189,7 +189,7 @@ private: friend class QMetaEnumBuilder; }; -class Q_CORE_EXPORT QMetaMethodBuilder +class Q_DECLARATIVE_EXPORT QMetaMethodBuilder { public: QMetaMethodBuilder() : _mobj(0), _index(0) {} @@ -227,7 +227,7 @@ private: QMetaMethodBuilderPrivate *d_func() const; }; -class Q_CORE_EXPORT QMetaPropertyBuilder +class Q_DECLARATIVE_EXPORT QMetaPropertyBuilder { public: QMetaPropertyBuilder() : _mobj(0), _index(0) {} @@ -278,7 +278,7 @@ private: QMetaPropertyBuilderPrivate *d_func() const; }; -class Q_CORE_EXPORT QMetaEnumBuilder +class Q_DECLARATIVE_EXPORT QMetaEnumBuilder { public: QMetaEnumBuilder() : _mobj(0), _index(0) {} diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index f291ac0..1c35606 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -91,8 +91,8 @@ Item { height: 10 } } - ComponentInstance { component: RedSquare } - ComponentInstance { component: RedSquare; x: 20 } + Loader { sourceComponent: RedSquare } + Loader { sourceComponent: RedSquare; x: 20 } } \endqml */ @@ -328,6 +328,7 @@ QmlComponent::QmlComponent(QmlEngine *engine, QmlCompiledData *cc, int start, in d->start = start; d->count = count; d->url = cc->url; + d->progress = 1.0; } /*! diff --git a/src/declarative/qml/qmlrewrite.cpp b/src/declarative/qml/qmlrewrite.cpp index 3f35160..5166c96 100644 --- a/src/declarative/qml/qmlrewrite.cpp +++ b/src/declarative/qml/qmlrewrite.cpp @@ -73,8 +73,8 @@ QString RewriteBinding::rewrite(QString code, unsigned position, unsigned startOfStatement = node->firstSourceLocation().begin() - _position; unsigned endOfStatement = node->lastSourceLocation().end() - _position; - _writer->replace(startOfStatement, 0, QLatin1String("(function() {\n")); - _writer->replace(endOfStatement, 0, QLatin1String("\n})")); + _writer->replace(startOfStatement, 0, QLatin1String("(function() { ")); + _writer->replace(endOfStatement, 0, QLatin1String(" })")); w.write(&code); diff --git a/src/declarative/util/qfxperf.cpp b/src/declarative/util/qfxperf.cpp index 90f639e..739e480 100644 --- a/src/declarative/util/qfxperf.cpp +++ b/src/declarative/util/qfxperf.cpp @@ -58,7 +58,6 @@ Q_DEFINE_PERFORMANCE_LOG(QFxPerf, "QFx") { Q_DEFINE_PERFORMANCE_METRIC(CreateParticle, " QFxParticles: Particle creation") Q_DEFINE_PERFORMANCE_METRIC(ItemComponentComplete, " QFxItem::componentComplete") Q_DEFINE_PERFORMANCE_METRIC(ImageComponentComplete, " QFxImage::componentComplete") - Q_DEFINE_PERFORMANCE_METRIC(ComponentInstanceComponentComplete, " QFxComponentInstance::componentComplete") Q_DEFINE_PERFORMANCE_METRIC(BaseLayoutComponentComplete, " QFxBasePositioner::componentComplete") Q_DEFINE_PERFORMANCE_METRIC(TextComponentComplete, " QFxText::componentComplete") Q_DEFINE_PERFORMANCE_METRIC(QFxText_setText, " QFxText::setText") diff --git a/src/declarative/util/qfxperf_p.h b/src/declarative/util/qfxperf_p.h index a1e38b7..cea7e80 100644 --- a/src/declarative/util/qfxperf_p.h +++ b/src/declarative/util/qfxperf_p.h @@ -77,7 +77,6 @@ Q_DECLARE_PERFORMANCE_LOG(QFxPerf) { Q_DECLARE_PERFORMANCE_METRIC(CreateParticle) Q_DECLARE_PERFORMANCE_METRIC(ItemComponentComplete) Q_DECLARE_PERFORMANCE_METRIC(ImageComponentComplete) - Q_DECLARE_PERFORMANCE_METRIC(ComponentInstanceComponentComplete) Q_DECLARE_PERFORMANCE_METRIC(BaseLayoutComponentComplete) Q_DECLARE_PERFORMANCE_METRIC(TextComponentComplete) Q_DECLARE_PERFORMANCE_METRIC(QFxText_setText) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 6047d4a..3edbc5f 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -1442,8 +1442,7 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,ParallelAnimation,QmlParallelAni void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) { if (variant.type() != QVariant::String) { - if ((uint)type < QVariant::UserType) - variant.convert((QVariant::Type)type); + variant.convert((QVariant::Type)type); return; } diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 8bd3648..73ea75e 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -930,7 +930,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) } QGraphicsItem *lastSubFocusItem = subFocusItem; - if (subFocusItem && !inDestructor) { + if (subFocusItem) { // Update the child focus chain; when reparenting an item that has a // focus child, ensure that that focus child clears its focus child // chain from our parents before it's reparented. @@ -1204,6 +1204,8 @@ QGraphicsItem::~QGraphicsItem() Q_ASSERT(d_ptr->children.isEmpty()); } + d_ptr->subFocusItem = 0; + if (d_ptr->scene) { d_ptr->scene->d_func()->removeItemHelper(this); } else { diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 52529ff..99e9aeb 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -1661,6 +1661,10 @@ void QAbstractItemView::mouseReleaseEvent(QMouseEvent *event) EditTrigger trigger = (selectedClicked ? SelectedClicked : NoEditTriggers); bool edited = edit(index, trigger, event); + //in the case the user presses on no item we might decide to clear the selection + if (d->selectionModel && !index.isValid()) + d->selectionModel->select(QModelIndex(), selectionCommand(index, event)); + setState(NoState); if (click) { diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 511c797..a3420da 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -4772,7 +4772,12 @@ void QApplicationPrivate::emitLastWindowClosed() If \a enable is true, Qt::Key_Up and Qt::Key_Down are used to change focus. - This feature is available in Qt for Embedded Linux and Symbian only. + This feature is available in Qt for Embedded Linux, Symbian and Windows CE + only. + + \note On Windows CE this feature is disabled by default for touch device + mkspecs. To enable keypad navigation, build Qt with + QT_KEYPAD_NAVIGATION defined. \sa keypadNavigationEnabled() */ @@ -4785,7 +4790,12 @@ void QApplication::setKeypadNavigationEnabled(bool enable) Returns true if Qt is set to use keypad navigation; otherwise returns false. The default value is true on Symbian, but false on other platforms. - This feature is available in Qt for Embedded Linux and Symbian only. + This feature is available in Qt for Embedded Linux, Symbian and Windows CE + only. + + \note On Windows CE this feature is disabled by default for touch device + mkspecs. To enable keypad navigation, build Qt with + QT_KEYPAD_NAVIGATION defined. \sa setKeypadNavigationEnabled() */ diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp index e3bd786..ba2e6a6 100644 --- a/src/gui/kernel/qapplication_qws.cpp +++ b/src/gui/kernel/qapplication_qws.cpp @@ -2202,6 +2202,8 @@ void qt_init(QApplicationPrivate *priv, int type) mouse_double_click_distance = read_int_env_var("QWS_DBLCLICK_DISTANCE", 5); + priv->inputContext = 0; + int flags = 0; char *p; int argc = priv->argc; @@ -2361,6 +2363,11 @@ void qt_cleanup() delete mouseInWidget; mouseInWidget = 0; + +#if !defined(QT_NO_IM) + delete QApplicationPrivate::inputContext; + QApplicationPrivate::inputContext = 0; +#endif } diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index 8e76715..b3e137d 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -535,6 +535,12 @@ void QPinchGesture::reset() QGesture::reset(); } +/*! \enum QPinchGesture::WhatChange + \value ScaleFactorChanged + \value RotationAngleChanged + \value CenterPointChanged +*/ + /*! \property QPinchGesture::whatChanged diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index 284558f..bd30cad 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -731,6 +731,7 @@ private: friend class QGLContext; friend class QGLWidget; friend class QGLWindowSurface; + friend class QGLWindowSurfaceGLPaintDevice; friend class QVGWindowSurface; friend class QX11PaintEngine; friend class QWin32PaintEngine; diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp index f442788..42da637 100644 --- a/src/gui/painting/qpaintengine.cpp +++ b/src/gui/painting/qpaintengine.cpp @@ -386,6 +386,7 @@ void QPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDraw \value User First user type ID \value MaxUser Last user type ID \value OpenGL2 + \value PaintBuffer */ /*! diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 3d8dec6..b1fd415 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -1130,10 +1130,10 @@ void QRenderRule::drawBorderImage(QPainter *p, const QRect& rect) const QStyleSheetBorderImageData *borderImageData = border()->borderImage(); const int *targetBorders = border()->borders; const int *sourceBorders = borderImageData->cuts; - QMargins sourceMargins(sourceBorders[TopEdge], sourceBorders[LeftEdge], - sourceBorders[BottomEdge], sourceBorders[RightEdge]); - QMargins targetMargins(targetBorders[TopEdge], targetBorders[LeftEdge], - targetBorders[BottomEdge], targetBorders[RightEdge]); + QMargins sourceMargins(sourceBorders[LeftEdge], sourceBorders[TopEdge], + sourceBorders[RightEdge], sourceBorders[BottomEdge]); + QMargins targetMargins(targetBorders[LeftEdge], targetBorders[TopEdge], + targetBorders[RightEdge], targetBorders[BottomEdge]); bool wasSmoothPixmapTransform = p->renderHints() & QPainter::SmoothPixmapTransform; p->setRenderHint(QPainter::SmoothPixmapTransform); diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index b150f50..60e5296 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1589,27 +1589,54 @@ void QTextLine::setNumColumns(int numColumns, qreal alignmentWidth) #define LB_DEBUG if (0) qDebug #endif -static inline bool checkFullOtherwiseExtend(QScriptLine &line, QScriptLine &tmpData, QScriptLine &spaceData, - int glyphCount, int maxGlyphs, QFixed &minw, bool manualWrap, - QFixed softHyphenWidth = QFixed()) -{ +namespace { + + struct LineBreakHelper + { + LineBreakHelper() : glyphCount(0), maxGlyphs(0), manualWrap(false) {} + + QScriptLine tmpData; + QScriptLine spaceData; + + int glyphCount; + int maxGlyphs; + + QFixed minw; + QFixed softHyphenWidth; + QFixed rightBearing; + + bool manualWrap; + + bool checkFullOtherwiseExtend(QScriptLine &line); + }; + +inline bool LineBreakHelper::checkFullOtherwiseExtend(QScriptLine &line) +{ LB_DEBUG("possible break width %f, spacew=%f", tmpData.textWidth.toReal(), spaceData.textWidth.toReal()); - if (line.length && !manualWrap && - (line.textWidth + tmpData.textWidth + spaceData.textWidth + softHyphenWidth > line.width || glyphCount > maxGlyphs)) + + QFixed newWidth = line.textWidth + tmpData.textWidth + spaceData.textWidth + softHyphenWidth + rightBearing; + if (line.length && !manualWrap && (newWidth > line.width || glyphCount > maxGlyphs)) return true; + minw = qMax(minw, tmpData.textWidth); line += tmpData; line.textWidth += spaceData.textWidth; + line.length += spaceData.length; tmpData.textWidth = 0; tmpData.length = 0; spaceData.textWidth = 0; spaceData.length = 0; + return false; } +} // anonymous namespace + + static inline void addNextCluster(int &pos, int end, QScriptLine &line, int &glyphCount, - const QScriptItem ¤t, const unsigned short *logClusters, const QGlyphLayout &glyphs) + const QScriptItem ¤t, const unsigned short *logClusters, + const QGlyphLayout &glyphs) { int glyphPosition = logClusters[pos]; do { // got to the first next cluster @@ -1642,9 +1669,13 @@ void QTextLine::layout_helper(int maxGlyphs) Q_ASSERT(line.from < eng->layoutData->string.length()); + LineBreakHelper lbh; + + lbh.maxGlyphs = maxGlyphs; + QTextOption::WrapMode wrapMode = eng->option.wrapMode(); bool breakany = (wrapMode == QTextOption::WrapAnywhere); - bool manualWrap = (wrapMode == QTextOption::ManualWrap || wrapMode == QTextOption::NoWrap); + lbh.manualWrap = (wrapMode == QTextOption::ManualWrap || wrapMode == QTextOption::NoWrap); // #### binary search! int item = -1; @@ -1654,12 +1685,7 @@ void QTextLine::layout_helper(int maxGlyphs) break; } - QFixed minw = 0; - int glyphCount = 0; - LB_DEBUG("from: %d: item=%d, total %d, width available %f", line.from, newItem, eng->layoutData->items.size(), line.width.toReal()); - QScriptLine tmpData; - QScriptLine spaceData; Qt::Alignment alignment = eng->option.alignment(); @@ -1668,7 +1694,10 @@ void QTextLine::layout_helper(int maxGlyphs) int end = 0; QGlyphLayout glyphs; const unsigned short *logClusters = eng->layoutData->logClustersPtr; + while (newItem < eng->layoutData->items.size()) { + lbh.rightBearing = 0; + lbh.softHyphenWidth = 0; if (newItem != item) { item = newItem; const QScriptItem ¤t = eng->layoutData->items[item]; @@ -1683,57 +1712,60 @@ void QTextLine::layout_helper(int maxGlyphs) } const QScriptItem ¤t = eng->layoutData->items[item]; - tmpData.ascent = qMax(tmpData.ascent, current.ascent); - tmpData.descent = qMax(tmpData.descent, current.descent); + lbh.tmpData.ascent = qMax(lbh.tmpData.ascent, current.ascent); + lbh.tmpData.descent = qMax(lbh.tmpData.descent, current.descent); if (current.analysis.flags == QScriptAnalysis::Tab && (alignment & (Qt::AlignLeft | Qt::AlignRight | Qt::AlignCenter | Qt::AlignJustify))) { - if (checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap)) + if (lbh.checkFullOtherwiseExtend(line)) goto found; - QFixed x = line.x + line.textWidth + tmpData.textWidth + spaceData.textWidth; - spaceData.textWidth += eng->calculateTabWidth(item, x); - spaceData.length++; + QFixed x = line.x + line.textWidth + lbh.tmpData.textWidth + lbh.spaceData.textWidth; + lbh.spaceData.textWidth += eng->calculateTabWidth(item, x); + lbh.spaceData.length++; newItem = item + 1; - ++glyphCount; - if (checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap)) + ++lbh.glyphCount; + if (lbh.checkFullOtherwiseExtend(line)) goto found; } else if (current.analysis.flags == QScriptAnalysis::LineOrParagraphSeparator) { // if the line consists only of the line separator make sure // we have a sane height - if (!line.length && !tmpData.length) + if (!line.length && !lbh.tmpData.length) line.setDefaultHeight(eng); if (eng->option.flags() & QTextOption::ShowLineAndParagraphSeparators) { - addNextCluster(pos, end, tmpData, glyphCount, current, logClusters, glyphs); + addNextCluster(pos, end, lbh.tmpData, lbh.glyphCount, + current, logClusters, glyphs); } else { - tmpData.length++; + lbh.tmpData.length++; } - line += tmpData; + line += lbh.tmpData; goto found; } else if (current.analysis.flags == QScriptAnalysis::Object) { - tmpData.length++; + lbh.tmpData.length++; QTextFormat format = eng->formats()->format(eng->formatIndex(&eng->layoutData->items[item])); if (eng->block.docHandle()) eng->docLayout()->positionInlineObject(QTextInlineObject(item, eng), eng->block.position() + current.position, format); - tmpData.textWidth += current.width; + lbh.tmpData.textWidth += current.width; newItem = item + 1; - ++glyphCount; - if (checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap)) + ++lbh.glyphCount; + if (lbh.checkFullOtherwiseExtend(line)) goto found; } else if (attributes[pos].whiteSpace) { while (pos < end && attributes[pos].whiteSpace) - addNextCluster(pos, end, spaceData, glyphCount, current, logClusters, glyphs); + addNextCluster(pos, end, lbh.spaceData, lbh.glyphCount, + current, logClusters, glyphs); - if (!manualWrap && spaceData.textWidth > line.width) { - spaceData.textWidth = line.width; // ignore spaces that fall out of the line. + if (!lbh.manualWrap && lbh.spaceData.textWidth > line.width) { + lbh.spaceData.textWidth = line.width; // ignore spaces that fall out of the line. goto found; } } else { bool sb_or_ws = false; do { - addNextCluster(pos, end, tmpData, glyphCount, current, logClusters, glyphs); + addNextCluster(pos, end, lbh.tmpData, lbh.glyphCount, + current, logClusters, glyphs); if (attributes[pos].whiteSpace || attributes[pos-1].lineBreakType != HB_NoBreak) { sb_or_ws = true; @@ -1742,9 +1774,8 @@ void QTextLine::layout_helper(int maxGlyphs) break; } } while (pos < end); - minw = qMax(tmpData.textWidth, minw); + lbh.minw = qMax(lbh.tmpData.textWidth, lbh.minw); - QFixed softHyphenWidth; if (pos && attributes[pos - 1].lineBreakType == HB_SoftHyphen) { // if we are splitting up a word because of // a soft hyphen then we ... @@ -1763,16 +1794,29 @@ void QTextLine::layout_helper(int maxGlyphs) // and thus become invisible again. // if (line.length) - softHyphenWidth = glyphs.advances_x[logClusters[pos - 1]]; + lbh.softHyphenWidth = glyphs.advances_x[logClusters[pos - 1]]; else if (breakany) - tmpData.textWidth += glyphs.advances_x[logClusters[pos - 1]]; + lbh.tmpData.textWidth += glyphs.advances_x[logClusters[pos - 1]]; } - if ((sb_or_ws|breakany) - && checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap, softHyphenWidth)) { + // The actual width of the text needs to take the right bearing into account. The + // right bearing is left-ward, which means that if the rightmost pixel is to the right + // of the advance of the glyph, the bearing will be negative. We flip the sign + // for the code to be more readable. Logic borrowed from qfontmetrics.cpp. + if (pos) { + QFontEngine *fontEngine = eng->fontEngine(current); + glyph_t glyph = glyphs.glyphs[logClusters[pos - 1]]; + glyph_metrics_t gi = fontEngine->boundingBox(glyph); + lbh.rightBearing = -qRound(gi.xoff - gi.x - gi.width); + } + + if ((sb_or_ws|breakany) && lbh.checkFullOtherwiseExtend(line)) { if (!breakany) { - line.textWidth += softHyphenWidth; + line.textWidth += lbh.softHyphenWidth; } + + line.textWidth += lbh.rightBearing; + goto found; } } @@ -1780,45 +1824,48 @@ void QTextLine::layout_helper(int maxGlyphs) newItem = item + 1; } LB_DEBUG("reached end of line"); - checkFullOtherwiseExtend(line, tmpData, spaceData, glyphCount, maxGlyphs, minw, manualWrap); -found: + lbh.checkFullOtherwiseExtend(line); + line.textWidth += lbh.rightBearing; + +found: if (line.length == 0) { LB_DEBUG("no break available in line, adding temp: length %d, width %f, space: length %d, width %f", - tmpData.length, tmpData.textWidth.toReal(), spaceData.length, spaceData.textWidth.toReal()); - line += tmpData; + lbh.tmpData.length, lbh.tmpData.textWidth.toReal(), + lbh.spaceData.length, lbh.spaceData.textWidth.toReal()); + line += lbh.tmpData; } LB_DEBUG("line length = %d, ascent=%f, descent=%f, textWidth=%f (spacew=%f)", line.length, line.ascent.toReal(), - line.descent.toReal(), line.textWidth.toReal(), spaceData.width.toReal()); + line.descent.toReal(), line.textWidth.toReal(), lbh.spaceData.width.toReal()); LB_DEBUG(" : '%s'", eng->layoutData->string.mid(line.from, line.length).toUtf8().data()); - if (manualWrap) { + if (lbh.manualWrap) { eng->minWidth = qMax(eng->minWidth, line.textWidth); eng->maxWidth = qMax(eng->maxWidth, line.textWidth); } else { - eng->minWidth = qMax(eng->minWidth, minw); + eng->minWidth = qMax(eng->minWidth, lbh.minw); eng->maxWidth += line.textWidth; } if (line.textWidth > 0 && item < eng->layoutData->items.size()) - eng->maxWidth += spaceData.textWidth; + eng->maxWidth += lbh.spaceData.textWidth; if (eng->option.flags() & QTextOption::IncludeTrailingSpaces) - line.textWidth += spaceData.textWidth; - line.length += spaceData.length; - if (spaceData.length) + line.textWidth += lbh.spaceData.textWidth; + line.length += lbh.spaceData.length; + if (lbh.spaceData.length) line.hasTrailingSpaces = true; line.justified = false; line.gridfitted = false; if (eng->option.wrapMode() == QTextOption::WrapAtWordBoundaryOrAnywhere) { - if ((maxGlyphs != INT_MAX && glyphCount > maxGlyphs) - || (maxGlyphs == INT_MAX && line.textWidth > line.width)) { + if ((lbh.maxGlyphs != INT_MAX && lbh.glyphCount > lbh.maxGlyphs) + || (lbh.maxGlyphs == INT_MAX && line.textWidth > line.width)) { eng->option.setWrapMode(QTextOption::WrapAnywhere); line.length = 0; line.textWidth = 0; - layout_helper(maxGlyphs); + layout_helper(lbh.maxGlyphs); eng->option.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); } } diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index a81f138..f46abf1 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -109,6 +109,7 @@ public: int width() const; int height() const; int ascent() const; + qreal naturalTextWidth() const; void setSelection(int start, int length); @@ -410,6 +411,11 @@ inline int QLineControl::width() const return qRound(m_textLayout.lineAt(0).width()) + 1; } +inline qreal QLineControl::naturalTextWidth() const +{ + return m_textLayout.lineAt(0).naturalTextWidth(); +} + inline int QLineControl::height() const { return qRound(m_textLayout.lineAt(0).height()) + 1; diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 3065c7f..9571860 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1808,7 +1808,7 @@ void QLineEdit::paintEvent(QPaintEvent *) // (cix). int minLB = qMax(0, -fm.minLeftBearing()); int minRB = qMax(0, -fm.minRightBearing()); - int widthUsed = d->control->width() + minRB; + int widthUsed = qRound(d->control->naturalTextWidth()) + 1 + minRB; if ((minLB + widthUsed) <= lineRect.width()) { // text fits in lineRect; use hscroll for alignment switch (va & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) { diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp index d8d974f..5de5c27 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -341,8 +341,6 @@ QList<QByteArray> QAudioDeviceInfoPrivate::deviceList(QAudio::Mode mode) QList<QByteArray> devices; - devices.append("default"); - if(mode == QAudio::AudioOutput) { WAVEOUTCAPS woc; unsigned long iNumDevs,i; @@ -365,6 +363,9 @@ QList<QByteArray> QAudioDeviceInfoPrivate::deviceList(QAudio::Mode mode) } } + if(devices.count() > 0) + devices.append("default"); + return devices; } diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index e24539b..e028e63 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -710,7 +710,7 @@ void QGL2PaintEngineEx::beginNativePainting() { mtx.dx(), mtx.dy(), 0, mtx.m33() } }; - const QSize sz = d->drawable.size(); + const QSize sz = d->device->size(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -1308,21 +1308,20 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) Q_D(QGL2PaintEngineEx); // qDebug("QGL2PaintEngineEx::begin()"); - d->drawable.setDevice(pdev); - d->ctx = d->drawable.context(); - - if (d->ctx->d_ptr->active_engine) { - QGL2PaintEngineEx *engine = static_cast<QGL2PaintEngineEx *>(d->ctx->d_ptr->active_engine); - QGL2PaintEngineExPrivate *p = static_cast<QGL2PaintEngineExPrivate *>(engine->d_ptr.data()); - p->transferMode(BrushDrawingMode); - p->drawable.doneCurrent(); - } + if (pdev->devType() == QInternal::OpenGL) + d->device = static_cast<QGLPaintDevice*>(pdev); + else + d->device = QGLPaintDevice::getDevice(pdev); + + if (!d->device) + return false; + + d->ctx = d->device->context(); d->ctx->d_ptr->active_engine = this; d->last_created_state = 0; - d->drawable.makeCurrent(); - QSize sz = d->drawable.size(); + QSize sz = d->device->size(); d->width = sz.width(); d->height = sz.height(); d->mode = BrushDrawingMode; @@ -1333,8 +1332,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->shaderManager = new QGLEngineShaderManager(d->ctx); - glViewport(0, 0, d->width, d->height); - d->brushTextureDirty = true; d->brushUniformsDirty = true; d->matrixDirty = true; @@ -1343,10 +1340,12 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->simpleShaderDepthUniformDirty = true; d->depthUniformDirty = true; d->opacityUniformDirty = true; - d->needsSync = false; - + d->needsSync = true; d->use_system_clip = !systemClip().isEmpty(); + + d->device->beginPaint(); + if (!d->inRenderText) { glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); @@ -1358,30 +1357,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) glDisable(GL_MULTISAMPLE); #endif - QGLPixmapData *source = d->drawable.copyOnBegin(); - if (d->drawable.context()->d_func()->clear_on_painter_begin && d->drawable.autoFillBackground()) { - if (d->drawable.hasTransparentBackground()) - glClearColor(0.0, 0.0, 0.0, 0.0); - else { - const QColor &c = d->drawable.backgroundColor(); - float alpha = c.alphaF(); - glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha); - } - glClear(GL_COLOR_BUFFER_BIT); - } else if (source) { - QGLContext *ctx = d->ctx; - - d->transferMode(ImageDrawingMode); - - glActiveTexture(GL_TEXTURE0 + QT_IMAGE_TEXTURE_UNIT); - source->bind(false); - - QRect rect(0, 0, source->width(), source->height()); - d->updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, false); - d->drawTexture(QRectF(rect), QRectF(rect), rect.size(), true); - } - - d->systemStateChanged(); return true; } @@ -1389,19 +1364,11 @@ bool QGL2PaintEngineEx::end() { Q_D(QGL2PaintEngineEx); QGLContext *ctx = d->ctx; - if (ctx->d_ptr->active_engine != this) { - QGL2PaintEngineEx *engine = static_cast<QGL2PaintEngineEx *>(ctx->d_ptr->active_engine); - if (engine && engine->isActive()) { - QGL2PaintEngineExPrivate *p = static_cast<QGL2PaintEngineExPrivate *>(engine->d_ptr.data()); - p->transferMode(BrushDrawingMode); - p->drawable.doneCurrent(); - } - d->drawable.makeCurrent(); - } glUseProgram(0); d->transferMode(BrushDrawingMode); - d->drawable.swapBuffers(); + d->device->endPaint(); + #if defined(Q_WS_X11) // On some (probably all) drivers, deleting an X pixmap which has been bound to a texture // before calling glFinish/swapBuffers renders garbage. Presumably this is because X deletes @@ -1410,7 +1377,6 @@ bool QGL2PaintEngineEx::end() // them here, after swapBuffers, where they can be safely deleted. ctx->d_func()->boundPixmaps.clear(); #endif - d->drawable.doneCurrent(); d->ctx->d_ptr->active_engine = 0; d->resetGLState(); @@ -1427,21 +1393,12 @@ void QGL2PaintEngineEx::ensureActive() QGLContext *ctx = d->ctx; if (isActive() && ctx->d_ptr->active_engine != this) { - QGL2PaintEngineEx *engine = static_cast<QGL2PaintEngineEx *>(ctx->d_ptr->active_engine); - if (engine && engine->isActive()) { - QGL2PaintEngineExPrivate *p = static_cast<QGL2PaintEngineExPrivate *>(engine->d_ptr.data()); - p->transferMode(BrushDrawingMode); - p->drawable.doneCurrent(); - } - d->drawable.context()->makeCurrent(); - d->drawable.makeCurrent(); - ctx->d_ptr->active_engine = this; d->needsSync = true; - } else { - d->drawable.context()->makeCurrent(); } + d->device->ensureActiveTarget(); + if (d->needsSync) { glViewport(0, 0, d->width, d->height); glDepthMask(false); diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index cb23b11..2fbee1b 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -58,6 +58,7 @@ #include <private/qpaintengineex_p.h> #include <private/qglengineshadermanager_p.h> #include <private/qgl2pexvertexarray_p.h> +#include <private/qglpaintdevice_p.h> enum EngineMode { ImageDrawingMode, @@ -199,7 +200,7 @@ public: static QGLEngineShaderManager* shaderManagerForEngine(QGL2PaintEngineEx *engine) { return engine->d_func()->shaderManager; } QGL2PaintEngineEx* q; - QGLDrawable drawable; + QGLPaintDevice* device; int width, height; QGLContext *ctx; EngineMode mode; diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 560d31f..d479c2e 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -22,13 +22,18 @@ HEADERS += qgl.h \ qglpixelbuffer.h \ qglpixelbuffer_p.h \ qglframebufferobject.h \ - qglextensions_p.h + qglframebufferobject_p.h \ + qglextensions_p.h \ + qglpaintdevice_p.h \ + SOURCES += qgl.cpp \ qglcolormap.cpp \ qglpixelbuffer.cpp \ qglframebufferobject.cpp \ qglextensions.cpp \ + qglpaintdevice.cpp \ + !contains(QT_CONFIG, opengles2) { HEADERS += qpaintengine_opengl_p.h diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 9e0c5f8..a0b2d3a 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -63,6 +63,7 @@ #include "qpixmap.h" #include "qimage.h" +#include "qmatrix4x4.h" #include "qgl_p.h" #if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) @@ -140,6 +141,48 @@ QGLSignalProxy *QGLSignalProxy::instance() return theSignalProxy(); } + +class QGLEngineSelector +{ +public: + QGLEngineSelector() : engineType(QPaintEngine::MaxUser) { } + + void setPreferredPaintEngine(QPaintEngine::Type type) { + if (type == QPaintEngine::OpenGL || type == QPaintEngine::OpenGL2) + engineType = type; + } + + QPaintEngine::Type preferredPaintEngine() { + if (engineType == QPaintEngine::MaxUser) { + // No user-set engine - use the defaults +#if defined(QT_OPENGL_ES_2) + engineType = QPaintEngine::OpenGL2; +#else + // We can't do this in the constructor for this object because it + // needs to be called *before* the QApplication constructor + if ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) + && qgetenv("QT_GL_USE_OPENGL1ENGINE").isEmpty()) + engineType = QPaintEngine::OpenGL2; + else + engineType = QPaintEngine::OpenGL; +#endif + } + return engineType; + } + +private: + QPaintEngine::Type engineType; +}; + +Q_GLOBAL_STATIC(QGLEngineSelector, qgl_engine_selector) + + +bool qt_gl_preferGL2Engine() +{ + return qgl_engine_selector()->preferredPaintEngine() == QPaintEngine::OpenGL2; +} + + /*! \namespace QGL \inmodule QtOpenGL @@ -180,6 +223,32 @@ QGLSignalProxy *QGLSignalProxy::instance() \sa {Sample Buffers Example} */ +/*! + \fn void QGL::setPreferredPaintEngine(QPaintEngine::Type engineType) + + \since 4.6 + + Sets the preferred OpenGL paint engine that is used to draw onto + QGLWidgets, QGLPixelBuffers and QGLFrameBufferObjects with QPainter + in Qt. + + The \a engineType parameter specifies which of the GL engines to + use. Only \c QPaintEngine::OpenGL and \c QPaintEngine::OpenGL2 are + valid parameters to this function. All other values are ignored. + + By default, the \c QPaintEngine::OpenGL2 engine is used if GL/GLES + version 2.0 is available, otherwise \c QPaintEngine::OpenGL is + used. + + \warning This function must be called before the QApplication + constructor is called. +*/ +void QGL::setPreferredPaintEngine(QPaintEngine::Type engineType) +{ + qgl_engine_selector()->setPreferredPaintEngine(engineType); +} + + /***************************************************************************** QGLFormat implementation *****************************************************************************/ @@ -251,46 +320,24 @@ QGLSignalProxy *QGLSignalProxy::instance() \sa QGLContext, QGLWidget */ -static inline void transform_point(GLdouble out[4], const GLdouble m[16], const GLdouble in[4]) -{ -#define M(row,col) m[col*4+row] - out[0] = - M(0, 0) * in[0] + M(0, 1) * in[1] + M(0, 2) * in[2] + M(0, 3) * in[3]; - out[1] = - M(1, 0) * in[0] + M(1, 1) * in[1] + M(1, 2) * in[2] + M(1, 3) * in[3]; - out[2] = - M(2, 0) * in[0] + M(2, 1) * in[1] + M(2, 2) * in[2] + M(2, 3) * in[3]; - out[3] = - M(3, 0) * in[0] + M(3, 1) * in[1] + M(3, 2) * in[2] + M(3, 3) * in[3]; -#undef M -} - -static inline GLint qgluProject(GLdouble objx, GLdouble objy, GLdouble objz, - const GLdouble model[16], const GLdouble proj[16], - const GLint viewport[4], - GLdouble * winx, GLdouble * winy, GLdouble * winz) +static inline void qgluProject + (qreal objx, qreal objy, qreal objz, + const QMatrix4x4& model, const QMatrix4x4& proj, const GLint viewport[4], + GLfloat *winx, GLfloat *winy, GLfloat* winz) { - GLdouble in[4], out[4]; - - in[0] = objx; - in[1] = objy; - in[2] = objz; - in[3] = 1.0; - transform_point(out, model, in); - transform_point(in, proj, out); + QVector4D transformed = proj.map(model.map(QVector4D(objx, objy, objz, 1))); - if (in[3] == 0.0) - return GL_FALSE; + qreal w = transformed.w(); + if (w == 0.0f) + w = 1.0f; // Just in case! - in[0] /= in[3]; - in[1] /= in[3]; - in[2] /= in[3]; + qreal x = transformed.x() / w; + qreal y = transformed.y() / w; - *winx = viewport[0] + (1 + in[0]) * viewport[2] / 2; - *winy = viewport[1] + (1 + in[1]) * viewport[3] / 2; + *winx = viewport[0] + (1 + x) * viewport[2] / 2; + *winy = viewport[1] + (1 + y) * viewport[3] / 2; - *winz = (1 + in[2]) / 2; - return GL_TRUE; + *winz = (1 + transformed.z() / w) / 2; } /*! @@ -1352,7 +1399,6 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) crWin = false; initDone = false; sharing = false; - clear_on_painter_begin = true; max_texture_size = -1; version_flags_cached = false; version_flags = QGLFormat::OpenGL_Version_None; @@ -2073,6 +2119,7 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G case QImage::Format_RGB16: pixel_type = GL_UNSIGNED_SHORT_5_6_5; texture_format = GL_RGB; + format = GL_RGB; break; case QImage::Format_RGB32: if (format == GL_RGBA) @@ -4113,6 +4160,30 @@ static void qt_gl_draw_text(QPainter *p, int x, int y, const QString &str, p->setFont(old_font); } +#if defined(GL_OES_VERSION_1_0) && !defined(GL_OES_VERSION_1_1) + +// OpenGL/ES 1.0 cannot fetch viewports from the GL server. +// We therefore create a default viewport to simulate the fetch. + +static void qt_gl_get_viewport(GLint *view, int deviceWidth, int deviceHeight) +{ + view[0] = 0; + view[1] = 0; + view[2] = deviceWidth; + view[3] = deviceHeight; +} + +#else + +static void qt_gl_get_viewport(GLint *view, int deviceWidth, int deviceHeight) +{ + Q_UNUSED(deviceWidth); + Q_UNUSED(deviceHeight); + glGetIntegerv(GL_VIEWPORT, view); +} + +#endif + /*! Renders the string \a str into the GL context of this widget. @@ -4138,13 +4209,19 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, GLint view[4]; #ifndef QT_OPENGL_ES bool use_scissor_testing = glIsEnabled(GL_SCISSOR_TEST); - if (!use_scissor_testing) - glGetIntegerv(GL_VIEWPORT, &view[0]); #else bool use_scissor_testing = false; #endif int width = d->glcx->device()->width(); int height = d->glcx->device()->height(); + if (!use_scissor_testing) { + qt_gl_get_viewport(&view[0], width, height); + } else { + view[0] = 0; + view[1] = 0; + view[2] = width; + view[3] = height; + } bool auto_swap = autoBufferSwap(); QPaintEngine *engine = paintEngine(); @@ -4176,7 +4253,7 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, } else { setAutoBufferSwap(false); // disable glClear() as a result of QPainter::begin() - d->glcx->d_func()->clear_on_painter_begin = false; + d->disable_clear_on_painter_begin = true; if (engine->type() == QPaintEngine::OpenGL2) { qt_save_gl_state(); #ifndef QT_OPENGL_ES_2 @@ -4206,7 +4283,7 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, p->end(); delete p; setAutoBufferSwap(auto_swap); - d->glcx->d_func()->clear_on_painter_begin = true; + d->disable_clear_on_painter_begin = false; if (engine->type() == QPaintEngine::OpenGL2) qt_restore_gl_state(); } @@ -4216,12 +4293,95 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, #endif } +#if defined(QT_OPENGL_ES_2) || \ + (defined(GL_OES_VERSION_1_0) && !defined(GL_OES_VERSION_1_1)) + +// OpenGL/ES 1.0 cannot fetch matrices from the GL server. +// OpenGL/ES 2.0 does not use fixed-function matrices at all. +// We therefore create some default matrices to simulate the fetch. + +static QMatrix4x4 qt_gl_projection_matrix(int deviceWidth, int deviceHeight) +{ + QMatrix4x4 m; + m.ortho(0, deviceWidth, deviceHeight, 0, -1, 1); + return m; +} + +static QMatrix4x4 qt_gl_modelview_matrix(void) +{ + return QMatrix4x4(); +} + +#else // !QT_OPENGL_ES_2 + +static QMatrix4x4 qt_gl_fetch_matrix(GLenum type) +{ + QMatrix4x4 matrix; +#if defined(QT_OPENGL_ES_1_CL) + GLfixed mat[16]; + glGetFixedv(type, mat); + qreal *m = matrix.data(); + for (int index = 0; index < 16; ++index) + m[index] = vt2f(mat[index]); +#else + if (sizeof(qreal) == sizeof(GLfloat)) { + glGetFloatv(type, reinterpret_cast<GLfloat *>(matrix.data())); +#if !defined(QT_OPENGL_ES) + } else if (sizeof(qreal) == sizeof(GLdouble)) { + glGetDoublev(type, reinterpret_cast<GLdouble *>(matrix.data())); +#endif + } else { + GLfloat mat[16]; + glGetFloatv(type, mat); + qreal *m = matrix.data(); + for (int index = 0; index < 16; ++index) + m[index] = mat[index]; + } +#endif + matrix.inferSpecialType(); + return matrix; +} + +static QMatrix4x4 qt_gl_projection_matrix(int deviceWidth, int deviceHeight) +{ + Q_UNUSED(deviceWidth); + Q_UNUSED(deviceHeight); + return qt_gl_fetch_matrix(GL_PROJECTION_MATRIX); +} + +static QMatrix4x4 qt_gl_modelview_matrix(void) +{ + return qt_gl_fetch_matrix(GL_MODELVIEW_MATRIX); +} + +#endif // !QT_OPENGL_ES_2 + /*! \overload \a x, \a y and \a z are specified in scene or object coordinates relative to the currently set projection and model matrices. This can be useful if you want to annotate models with text labels and have the labels move with the model as it is rotated etc. + + This function fetches the modelview matrix, projection matrix, and + current viewport from the GL server to map (\a x, \a y, \a z) + into window co-ordinates. This entails several round-trips to the GL + server which will probably impact performance. + + Fetching the modelview and projection matrices is not supported + under OpenGL/ES 1.0 and OpenGL/ES 2.0 so a default orthographic + projection will be used to map the co-ordinates on those platforms. + This probably will not give results that are consistent with desktop + and OpenGL/ES 1.1 systems. Fetching the viewport is not supported + under OpenGL/ES 1.0, so the full device will be used as the viewport. + + This function is deprecated because it is non-portable. It is + recommended that the application map the co-ordinates itself using + application-provided matrix data that reflects the desired + transformation. Then use QPainter::drawText() to draw \a str at + the mapped position. + + \sa QMatrix4x4 */ void QGLWidget::renderText(double x, double y, double z, const QString &str, const QFont &font, int) { @@ -4233,16 +4393,15 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con int width = d->glcx->device()->width(); int height = d->glcx->device()->height(); - GLdouble model[4][4], proj[4][4]; + + QMatrix4x4 model = qt_gl_modelview_matrix(); + QMatrix4x4 proj = qt_gl_projection_matrix(width, height); GLint view[4]; -#ifndef QT_OPENGL_ES - glGetDoublev(GL_MODELVIEW_MATRIX, &model[0][0]); - glGetDoublev(GL_PROJECTION_MATRIX, &proj[0][0]); - glGetIntegerv(GL_VIEWPORT, &view[0]); -#endif - GLdouble win_x = 0, win_y = 0, win_z = 0; - qgluProject(x, y, z, &model[0][0], &proj[0][0], &view[0], - &win_x, &win_y, &win_z); + qt_gl_get_viewport(view, width, height); + + GLfloat win_x = 0, win_y = 0, win_z = 0; + qgluProject(qreal(x), qreal(y), qreal(z), + model, proj, &view[0], &win_x, &win_y, &win_z); win_y = height - win_y; // y is inverted QPaintEngine *engine = paintEngine(); @@ -4267,7 +4426,7 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con } else { setAutoBufferSwap(false); // disable glClear() as a result of QPainter::begin() - d->glcx->d_func()->clear_on_painter_begin = false; + d->disable_clear_on_painter_begin = true; if (engine->type() == QPaintEngine::OpenGL2) qt_save_gl_state(); p = new QPainter(this); @@ -4295,11 +4454,7 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con glEnable(GL_ALPHA_TEST); if (use_depth_testing) glEnable(GL_DEPTH_TEST); -#ifndef QT_OPENGL_ES - glTranslated(0, 0, -win_z); -#else glTranslatef(0, 0, -win_z); -#endif #endif // !defined(QT_OPENGL_ES_2) qt_gl_draw_text(p, qRound(win_x), qRound(win_y), str, font); @@ -4311,7 +4466,7 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con if (engine->type() == QPaintEngine::OpenGL2) qt_restore_gl_state(); setAutoBufferSwap(auto_swap); - d->glcx->d_func()->clear_on_painter_begin = true; + d->disable_clear_on_painter_begin = false; } #ifndef QT_OPENGL_ES if (engine->type() == QPaintEngine::OpenGL2) @@ -4659,6 +4814,8 @@ void QGLWidgetPrivate::initContext(QGLContext *context, const QGLWidget* shareWi { Q_Q(QGLWidget); + glDevice.setWidget(q); + QGLExtensions::init(); glcx = 0; autoSwap = true; @@ -4694,242 +4851,6 @@ Q_OPENGL_EXPORT const QString qt_gl_library_name() } #endif -void QGLDrawable::setDevice(QPaintDevice *pdev) -{ - wasBound = false; - widget = 0; - buffer = 0; - fbo = 0; -#ifdef Q_WS_QWS - wsurf = 0; -#endif - -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - if (pdev->devType() == QInternal::Pixmap) { - QPixmapData *data = static_cast<QPixmap *>(pdev)->pixmapData(); - Q_ASSERT(data->classId() == QPixmapData::OpenGLClass); - pixmapData = static_cast<QGLPixmapData *>(data); - - fbo = pixmapData->fbo(); - } -#else - Q_ASSERT(pdev->devType() != QInternal::Pixmap); -#endif - - if (pdev->devType() == QInternal::Widget) - widget = static_cast<QGLWidget *>(pdev); - else if (pdev->devType() == QInternal::Pbuffer) - buffer = static_cast<QGLPixelBuffer *>(pdev); - else if (pdev->devType() == QInternal::FramebufferObject) - fbo = static_cast<QGLFramebufferObject *>(pdev); -#ifdef Q_WS_QWS - else if (pdev->devType() == QInternal::UnknownDevice) - wsurf = static_cast<QWSGLPaintDevice*>(pdev)->windowSurface(); -#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - else if (pdev->devType() == QInternal::UnknownDevice) - wsurf = static_cast<QGLWindowSurface *>(pdev); -#endif -} - -void QGLDrawable::swapBuffers() -{ - if (widget) { - if (widget->autoBufferSwap()) - widget->swapBuffers(); -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - } else if (pixmapData) { - pixmapData->swapBuffers(); -#endif - } else { - glFlush(); - } -} - -void QGLDrawable::makeCurrent() -{ - previous_fbo = 0; -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - if (!pixmapData && !fbo) { -#else - if (!fbo) { -#endif - QGLContext *ctx = context(); - previous_fbo = ctx->d_ptr->current_fbo; - ctx->d_ptr->current_fbo = 0; - if (previous_fbo) - glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); - } - - if (widget) - widget->makeCurrent(); -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - else if (pixmapData) - pixmapData->makeCurrent(); -#endif - else if (buffer) - buffer->makeCurrent(); -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - else if (wsurf) - wsurf->context()->makeCurrent(); -#endif - else if (fbo) { - wasBound = fbo->isBound(); - if (!wasBound) - fbo->bind(); - } -} - -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) -QGLPixmapData *QGLDrawable::copyOnBegin() const -{ - if (!pixmapData || pixmapData->isUninitialized()) - return 0; - return pixmapData; -} -#endif - -void QGLDrawable::doneCurrent() -{ -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - if (pixmapData) { - pixmapData->doneCurrent(); - return; - } -#endif - - if (previous_fbo) { - QGLContext *ctx = context(); - ctx->d_ptr->current_fbo = previous_fbo; - glBindFramebuffer(GL_FRAMEBUFFER_EXT, previous_fbo); - } - - if (fbo && !wasBound) - fbo->release(); -} - -QSize QGLDrawable::size() const -{ - if (widget) { - return QSize(widget->d_func()->glcx->device()->width(), - widget->d_func()->glcx->device()->height()); -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - } else if (pixmapData) { - return pixmapData->size(); -#endif - } else if (buffer) { - return buffer->size(); - } else if (fbo) { - return fbo->size(); - } -#ifdef Q_WS_QWS - else if (wsurf) - return wsurf->window()->frameSize(); -#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - else if (wsurf) - return QSize(wsurf->width(), wsurf->height()); -#endif - return QSize(); -} - -QGLFormat QGLDrawable::format() const -{ - if (widget) - return widget->format(); - else if (buffer) - return buffer->format(); -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - else if (wsurf) - return wsurf->context()->format(); -#endif - else if (fbo && QGLContext::currentContext()) { - QGLFormat fmt = QGLContext::currentContext()->format(); - fmt.setStencil(fbo->attachment() == QGLFramebufferObject::CombinedDepthStencil); - fmt.setDepth(fbo->attachment() != QGLFramebufferObject::NoAttachment); - return fmt; - } - - return QGLFormat(); -} - -GLuint QGLDrawable::bindTexture(const QImage &image, GLenum target, GLint format, - QGLContext::BindOptions options) -{ - QGLTexture *texture = 0; - options |= QGLContext::MemoryManagedBindOption; - if (widget) - texture = widget->d_func()->glcx->d_func()->bindTexture(image, target, format, options); - else if (buffer) - texture = buffer->d_func()->qctx->d_func()->bindTexture(image, target, format, options); - else if (fbo && QGLContext::currentContext()) - texture = const_cast<QGLContext *>(QGLContext::currentContext())->d_func()->bindTexture(image, target, format, options); -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - else if (wsurf) - texture = wsurf->context()->d_func()->bindTexture(image, target, format, options); -#endif - return texture->id; -} - -GLuint QGLDrawable::bindTexture(const QPixmap &pixmap, GLenum target, GLint format, - QGLContext::BindOptions options) -{ - QGLTexture *texture = 0; - if (widget) - texture = widget->d_func()->glcx->d_func()->bindTexture(pixmap, target, format, options); - else if (buffer) - texture = buffer->d_func()->qctx->d_func()->bindTexture(pixmap, target, format, options); - else if (fbo && QGLContext::currentContext()) - texture = const_cast<QGLContext *>(QGLContext::currentContext())->d_func()->bindTexture(pixmap, target, format, options); -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - else if (wsurf) - texture = wsurf->context()->d_func()->bindTexture(pixmap, target, format, options); -#endif - return texture->id; -} - -QColor QGLDrawable::backgroundColor() const -{ - if (widget) - return widget->palette().brush(widget->backgroundRole()).color(); -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - else if (pixmapData) - return pixmapData->fillColor(); -#endif - return QApplication::palette().brush(QPalette::Background).color(); -} - -bool QGLDrawable::hasTransparentBackground() const -{ - return widget && widget->testAttribute(Qt::WA_TranslucentBackground); -} - -QGLContext *QGLDrawable::context() const -{ - if (widget) - return widget->d_func()->glcx; - else if (buffer) - return buffer->d_func()->qctx; - else if (fbo) - return const_cast<QGLContext *>(QGLContext::currentContext()); -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - else if (wsurf) - return wsurf->context(); -#endif - return 0; -} - -bool QGLDrawable::autoFillBackground() const -{ - if (widget) - return widget->autoFillBackground(); -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - else if (pixmapData) - return pixmapData->needsFill(); -#endif - else - return false; -} - - bool QGLShareRegister::checkSharing(const QGLContext *context1, const QGLContext *context2) { bool sharing = (context1 && context2 && context1->d_ptr->group == context2->d_ptr->group); return sharing; diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index daac760..151c7c4 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -43,6 +43,7 @@ #define QGL_H #include <QtGui/qwidget.h> +#include <QtGui/qpaintengine.h> #include <QtOpenGL/qglcolormap.h> #include <QtCore/qmap.h> #include <QtCore/qscopedpointer.h> @@ -130,6 +131,8 @@ class QGLContextPrivate; // Namespace class: namespace QGL { + Q_OPENGL_EXPORT void setPreferredPaintEngine(QPaintEngine::Type engineType); + enum FormatOption { DoubleBuffer = 0x0001, DepthBuffer = 0x0002, @@ -382,7 +385,6 @@ private: friend class QGLPixelBuffer; friend class QGLPixelBufferPrivate; friend class QGLWidget; - friend class QGLDrawable; friend class QGLWidgetPrivate; friend class QGLGlyphCache; friend class QOpenGLPaintEngine; @@ -404,6 +406,8 @@ private: #endif friend class QGLFramebufferObject; friend class QGLFramebufferObjectPrivate; + friend class QGLFBOGLPaintDevice; + friend class QGLPaintDevice; private: Q_DISABLE_COPY(QGLContext) }; @@ -539,6 +543,8 @@ private: friend class QGLContext; friend class QGLOverlayWidget; friend class QOpenGLPaintEngine; + friend class QGLPaintDevice; + friend class QGLWidgetGLPaintDevice; }; diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index d4b7597..b10d5da 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -62,6 +62,7 @@ #include "QtCore/qatomic.h" #include "private/qwidget_p.h" #include "qcache.h" +#include "qglpaintdevice_p.h" #ifndef QT_OPENGL_ES_1_CL #define q_vertexType float @@ -174,6 +175,7 @@ class QGLWidgetPrivate : public QWidgetPrivate Q_DECLARE_PUBLIC(QGLWidget) public: QGLWidgetPrivate() : QWidgetPrivate() + , disable_clear_on_painter_begin(false) #ifdef Q_WS_QWS , wsurf(0) #endif @@ -190,11 +192,14 @@ public: void cleanupColormaps(); QGLContext *glcx; + QGLWidgetGLPaintDevice glDevice; bool autoSwap; QGLColormap cmap; QMap<QString, int> displayListCache; + bool disable_clear_on_painter_begin; + #if defined(Q_WS_WIN) void updateColormap(); QGLContext *olcx; @@ -293,7 +298,6 @@ public: uint sharing : 1; uint initDone : 1; uint crWin : 1; - uint clear_on_painter_begin : 1; uint internal_context : 1; uint version_flags_cached : 1; QPaintDevice *paintDevice; @@ -337,57 +341,6 @@ Q_SIGNALS: void aboutToDestroyContext(const QGLContext *context); }; -class QGLPixelBuffer; -class QGLFramebufferObject; -class QWSGLWindowSurface; -class QGLWindowSurface; -class QGLPixmapData; -class QGLDrawable { -public: - QGLDrawable() : widget(0), buffer(0), fbo(0) -#if defined(Q_WS_QWS) || (!defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL)) - , wsurf(0) -#endif -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - , pixmapData(0) -#endif - {} - void setDevice(QPaintDevice *pdev); - void swapBuffers(); - void makeCurrent(); - void doneCurrent(); - QSize size() const; - QGLFormat format() const; - GLuint bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA, - QGLContext::BindOptions = QGLContext::InternalBindOption); - GLuint bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA, - QGLContext::BindOptions = QGLContext::InternalBindOption); - QColor backgroundColor() const; - QGLContext *context() const; - bool autoFillBackground() const; - bool hasTransparentBackground() const; - -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - QGLPixmapData *copyOnBegin() const; -#endif - -private: - bool wasBound; - QGLWidget *widget; - QGLPixelBuffer *buffer; - QGLFramebufferObject *fbo; -#ifdef Q_WS_QWS - QWSGLWindowSurface *wsurf; -#elif !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - QGLWindowSurface *wsurf; -#endif - -#if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) - QGLPixmapData *pixmapData; -#endif - int previous_fbo; -}; - // GL extension definitions class QGLExtensions { public: @@ -519,15 +472,7 @@ extern QPaintEngine* qt_qgl_paint_engine(); extern EGLDisplay qt_qgl_egl_display(); #endif -inline bool qt_gl_preferGL2Engine() -{ -#if defined(QT_OPENGL_ES_2) - return true; -#else - return (QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0) - && qgetenv("QT_GL_USE_OPENGL1ENGINE").isEmpty(); -#endif -} +bool qt_gl_preferGL2Engine(); inline GLenum qt_gl_preferredTextureFormat() { diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index 81985cd..a7376b2 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -1308,7 +1308,6 @@ void QGLWidget::setContext(QGLContext *context, QGLContext* oldcx = d->glcx; d->glcx = context; - if (parentWidget()) { // force creation of delay-created widgets parentWidget()->winId(); diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index c53ed3a..9dbf5c8 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qglframebufferobject.h" +#include "qglframebufferobject_p.h" #include <qdebug.h> #include <private/qgl_p.h> @@ -74,15 +75,6 @@ extern QImage qt_gl_read_framebuffer(const QSize&, bool, bool); } \ } -class QGLFramebufferObjectFormatPrivate -{ -public: - int samples; - QGLFramebufferObject::Attachment attachment; - GLenum target; - GLenum internal_format; -}; - /*! \class QGLFramebufferObjectFormat \brief The QGLFramebufferObjectFormat class specifies the format of an OpenGL @@ -109,6 +101,20 @@ public: */ /*! + \internal +*/ +void QGLFramebufferObjectFormat::detach() +{ + if (d->ref != 1) { + QGLFramebufferObjectFormatPrivate *newd + = new QGLFramebufferObjectFormatPrivate(d); + if (!d->ref.deref()) + delete d; + d = newd; + } +} + +/*! Creates a QGLFramebufferObjectFormat object for specifying the format of an OpenGL framebuffer object. @@ -118,19 +124,9 @@ public: \sa samples(), attachment(), target(), internalTextureFormat() */ -#ifndef QT_OPENGL_ES -#define DEFAULT_FORMAT GL_RGBA8 -#else -#define DEFAULT_FORMAT GL_RGBA -#endif - QGLFramebufferObjectFormat::QGLFramebufferObjectFormat() { d = new QGLFramebufferObjectFormatPrivate; - d->samples = 0; - d->attachment = QGLFramebufferObject::NoAttachment; - d->target = GL_TEXTURE_2D; - d->internal_format = DEFAULT_FORMAT; } /*! @@ -139,8 +135,8 @@ QGLFramebufferObjectFormat::QGLFramebufferObjectFormat() QGLFramebufferObjectFormat::QGLFramebufferObjectFormat(const QGLFramebufferObjectFormat &other) { - d = new QGLFramebufferObjectFormatPrivate; - *d = *other.d; + d = other.d; + d->ref.ref(); } /*! @@ -149,7 +145,12 @@ QGLFramebufferObjectFormat::QGLFramebufferObjectFormat(const QGLFramebufferObjec QGLFramebufferObjectFormat &QGLFramebufferObjectFormat::operator=(const QGLFramebufferObjectFormat &other) { - *d = *other.d; + if (d != other.d) { + other.d->ref.ref(); + if (!d->ref.deref()) + delete d; + d = other.d; + } return *this; } @@ -158,7 +159,8 @@ QGLFramebufferObjectFormat &QGLFramebufferObjectFormat::operator=(const QGLFrame */ QGLFramebufferObjectFormat::~QGLFramebufferObjectFormat() { - delete d; + if (!d->ref.deref()) + delete d; } /*! @@ -176,6 +178,7 @@ QGLFramebufferObjectFormat::~QGLFramebufferObjectFormat() */ void QGLFramebufferObjectFormat::setSamples(int samples) { + detach(); d->samples = samples; } @@ -197,6 +200,7 @@ int QGLFramebufferObjectFormat::samples() const */ void QGLFramebufferObjectFormat::setAttachment(QGLFramebufferObject::Attachment attachment) { + detach(); d->attachment = attachment; } @@ -219,6 +223,7 @@ QGLFramebufferObject::Attachment QGLFramebufferObjectFormat::attachment() const */ void QGLFramebufferObjectFormat::setTextureTarget(GLenum target) { + detach(); d->target = target; } @@ -242,6 +247,7 @@ GLenum QGLFramebufferObjectFormat::textureTarget() const */ void QGLFramebufferObjectFormat::setInternalTextureFormat(GLenum internalTextureFormat) { + detach(); d->internal_format = internalTextureFormat; } @@ -260,38 +266,71 @@ GLenum QGLFramebufferObjectFormat::internalTextureFormat() const /*! \internal */ void QGLFramebufferObjectFormat::setTextureTarget(QMacCompatGLenum target) { + detach(); d->target = target; } /*! \internal */ void QGLFramebufferObjectFormat::setInternalTextureFormat(QMacCompatGLenum internalTextureFormat) { + detach(); d->internal_format = internalTextureFormat; } #endif -class QGLFramebufferObjectPrivate +/*! + Returns true if all the options of this framebuffer object format + are the same as \a other; otherwise returns false. +*/ +bool QGLFramebufferObjectFormat::operator==(const QGLFramebufferObjectFormat& other) const +{ + if (d == other.d) + return true; + else + return d->equals(other.d); +} + +/*! + Returns false if all the options of this framebuffer object format + are the same as \a other; otherwise returns true. +*/ +bool QGLFramebufferObjectFormat::operator!=(const QGLFramebufferObjectFormat& other) const +{ + return !(*this == other); +} + +void QGLFBOGLPaintDevice::setFBO(QGLFramebufferObject* f) { -public: - QGLFramebufferObjectPrivate() : depth_stencil_buffer(0), valid(false), ctx(0), previous_fbo(0), engine(0) {} - ~QGLFramebufferObjectPrivate() {} - - void init(const QSize& sz, QGLFramebufferObject::Attachment attachment, - GLenum internal_format, GLenum texture_target, GLint samples = 0); - bool checkFramebufferStatus() const; - GLuint texture; - GLuint fbo; - GLuint depth_stencil_buffer; - GLuint color_buffer; - GLenum target; - QSize size; - QGLFramebufferObjectFormat format; - uint valid : 1; - QGLFramebufferObject::Attachment fbo_attachment; - QGLContextGroup *ctx; // for Windows extension ptrs - GLuint previous_fbo; - mutable QPaintEngine *engine; -}; + fbo = f; + m_thisFBO = fbo->d_func()->fbo; // This shouldn't be needed +} + +void QGLFBOGLPaintDevice::ensureActiveTarget() +{ + QGLContext* ctx = const_cast<QGLContext*>(QGLContext::currentContext()); + Q_ASSERT(ctx); + const GLuint fboId = fbo->d_func()->fbo; + if (ctx->d_func()->current_fbo != fboId) { + ctx->d_func()->current_fbo = fboId; + glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId); + } +} + +void QGLFBOGLPaintDevice::beginPaint() +{ + // We let QFBO track the previously bound FBO rather than doing it + // ourselves here. This has the advantage that begin/release & bind/end + // work as expected. + wasBound = fbo->isBound(); + if (!wasBound) + fbo->bind(); +} + +void QGLFBOGLPaintDevice::endPaint() +{ + if (!wasBound) + fbo->release(); +} bool QGLFramebufferObjectPrivate::checkFramebufferStatus() const { @@ -337,11 +376,14 @@ bool QGLFramebufferObjectPrivate::checkFramebufferStatus() const return false; } -void QGLFramebufferObjectPrivate::init(const QSize &sz, QGLFramebufferObject::Attachment attachment, +void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz, + QGLFramebufferObject::Attachment attachment, GLenum texture_target, GLenum internal_format, GLint samples) { QGLContext *currentContext = const_cast<QGLContext *>(QGLContext::currentContext()); ctx = QGLContextPrivate::contextGroup(currentContext); + glDevice.setFBO(q); + bool ext_detected = (QGLExtensions::glExtensions & QGLExtensions::FramebufferObject); if (!ext_detected || (ext_detected && !qt_resolve_framebufferobject_extensions(currentContext))) return; @@ -354,6 +396,8 @@ void QGLFramebufferObjectPrivate::init(const QSize &sz, QGLFramebufferObject::At glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo); + glDevice.setFBO(q); + QT_CHECK_GLERROR(); // init texture if (samples == 0) { @@ -600,7 +644,8 @@ QGLFramebufferObject::QGLFramebufferObject(const QSize &size, GLenum target) : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(size, NoAttachment, target, DEFAULT_FORMAT); + d->glDevice.setFBO(this); + d->init(this, size, NoAttachment, target, DEFAULT_FORMAT); } #ifdef Q_MAC_COMPAT_GL_FUNCTIONS @@ -624,7 +669,7 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, GLenum target) : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(QSize(width, height), NoAttachment, target, DEFAULT_FORMAT); + d->init(this, QSize(width, height), NoAttachment, target, DEFAULT_FORMAT); } /*! \overload @@ -637,7 +682,8 @@ QGLFramebufferObject::QGLFramebufferObject(const QSize &size, const QGLFramebuff : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(size, format.attachment(), format.textureTarget(), format.internalTextureFormat(), format.samples()); + d->init(this, size, format.attachment(), format.textureTarget(), format.internalTextureFormat(), + format.samples()); } /*! \overload @@ -650,7 +696,8 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, const QGLFrame : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(QSize(width, height), format.attachment(), format.textureTarget(), format.internalTextureFormat(), format.samples()); + d->init(this, QSize(width, height), format.attachment(), format.textureTarget(), + format.internalTextureFormat(), format.samples()); } #ifdef Q_MAC_COMPAT_GL_FUNCTIONS @@ -659,7 +706,7 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, QMacCompatGLen : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(QSize(width, height), NoAttachment, target, DEFAULT_FORMAT); + d->init(this, QSize(width, height), NoAttachment, target, DEFAULT_FORMAT); } #endif @@ -680,7 +727,7 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, Attachment att : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(QSize(width, height), attachment, target, internal_format); + d->init(this, QSize(width, height), attachment, target, internal_format); } #ifdef Q_MAC_COMPAT_GL_FUNCTIONS @@ -690,7 +737,7 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, Attachment att : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(QSize(width, height), attachment, target, internal_format); + d->init(this, QSize(width, height), attachment, target, internal_format); } #endif @@ -711,7 +758,7 @@ QGLFramebufferObject::QGLFramebufferObject(const QSize &size, Attachment attachm : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(size, attachment, target, internal_format); + d->init(this, size, attachment, target, internal_format); } #ifdef Q_MAC_COMPAT_GL_FUNCTIONS @@ -721,7 +768,7 @@ QGLFramebufferObject::QGLFramebufferObject(const QSize &size, Attachment attachm : d_ptr(new QGLFramebufferObjectPrivate) { Q_D(QGLFramebufferObject); - d->init(size, attachment, target, internal_format); + d->init(this, size, attachment, target, internal_format); } #endif @@ -871,7 +918,7 @@ QSize QGLFramebufferObject::size() const /*! Returns the format of this framebuffer object. */ -const QGLFramebufferObjectFormat &QGLFramebufferObject::format() const +QGLFramebufferObjectFormat QGLFramebufferObject::format() const { Q_D(const QGLFramebufferObject); return d->format; diff --git a/src/opengl/qglframebufferobject.h b/src/opengl/qglframebufferobject.h index ec1ae7d..6efbb73 100644 --- a/src/opengl/qglframebufferobject.h +++ b/src/opengl/qglframebufferobject.h @@ -93,7 +93,7 @@ public: virtual ~QGLFramebufferObject(); - const QGLFramebufferObjectFormat &format() const; + QGLFramebufferObjectFormat format() const; bool isValid() const; bool isBound() const; @@ -130,7 +130,8 @@ protected: private: Q_DISABLE_COPY(QGLFramebufferObject) QScopedPointer<QGLFramebufferObjectPrivate> d_ptr; - friend class QGLDrawable; + friend class QGLPaintDevice; + friend class QGLFBOGLPaintDevice; }; class QGLFramebufferObjectFormatPrivate; @@ -159,8 +160,13 @@ public: void setInternalTextureFormat(QMacCompatGLenum internalTextureFormat); #endif + bool operator==(const QGLFramebufferObjectFormat& other) const; + bool operator!=(const QGLFramebufferObjectFormat& other) const; + private: QGLFramebufferObjectFormatPrivate *d; + + void detach(); }; QT_END_NAMESPACE diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h new file mode 100644 index 0000000..58e6505 --- /dev/null +++ b/src/opengl/qglframebufferobject_p.h @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** 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 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 QGLFRAMEBUFFEROBJECT_P_H +#define QGLFRAMEBUFFEROBJECT_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. +// + +QT_BEGIN_NAMESPACE + +QT_BEGIN_INCLUDE_NAMESPACE + +#include <qglframebufferobject.h> +#include <private/qglpaintdevice_p.h> +#include <private/qgl_p.h> + +QT_END_INCLUDE_NAMESPACE + +#ifndef QT_OPENGL_ES +#define DEFAULT_FORMAT GL_RGBA8 +#else +#define DEFAULT_FORMAT GL_RGBA +#endif + +class QGLFramebufferObjectFormatPrivate +{ +public: + QGLFramebufferObjectFormatPrivate() + : ref(1), + samples(0), + attachment(QGLFramebufferObject::NoAttachment), + target(GL_TEXTURE_2D), + internal_format(DEFAULT_FORMAT) + { + } + QGLFramebufferObjectFormatPrivate + (const QGLFramebufferObjectFormatPrivate *other) + : ref(1), + samples(other->samples), + attachment(other->attachment), + target(other->target), + internal_format(other->internal_format) + { + } + bool equals(const QGLFramebufferObjectFormatPrivate *other) + { + return samples == other->samples && + attachment == other->attachment && + target == other->target && + internal_format == other->internal_format; + } + + QAtomicInt ref; + int samples; + QGLFramebufferObject::Attachment attachment; + GLenum target; + GLenum internal_format; +}; + +class QGLFBOGLPaintDevice : public QGLPaintDevice +{ +public: + virtual QPaintEngine* paintEngine() const {return fbo->paintEngine();} + virtual QSize size() const {return fbo->size();} + virtual QGLContext* context() const {return const_cast<QGLContext *>(QGLContext::currentContext());} + virtual void ensureActiveTarget(); + virtual void beginPaint(); + virtual void endPaint(); + + void setFBO(QGLFramebufferObject* f); + +private: + bool wasBound; + QGLFramebufferObject* fbo; +}; + +class QGLFramebufferObjectPrivate +{ +public: + QGLFramebufferObjectPrivate() : depth_stencil_buffer(0), valid(false), ctx(0), previous_fbo(0), engine(0) {} + ~QGLFramebufferObjectPrivate() {} + + void init(QGLFramebufferObject *q, const QSize& sz, + QGLFramebufferObject::Attachment attachment, + GLenum internal_format, GLenum texture_target, GLint samples = 0); + bool checkFramebufferStatus() const; + GLuint texture; + GLuint fbo; + GLuint depth_stencil_buffer; + GLuint color_buffer; + GLenum target; + QSize size; + QGLFramebufferObjectFormat format; + uint valid : 1; + QGLFramebufferObject::Attachment fbo_attachment; + QGLContextGroup *ctx; // for Windows extension ptrs + GLuint previous_fbo; + mutable QPaintEngine *engine; + QGLFBOGLPaintDevice glDevice; +}; + + +QT_END_NAMESPACE + +#endif // QGLFRAMEBUFFEROBJECT_P_H diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp new file mode 100644 index 0000000..a89b884 --- /dev/null +++ b/src/opengl/qglpaintdevice.cpp @@ -0,0 +1,187 @@ +/**************************************************************************** +** +** 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 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 <private/qglpaintdevice_p.h> +#include <private/qgl_p.h> +#include <private/qglpixelbuffer_p.h> +#include <private/qglframebufferobject_p.h> +#include <private/qwindowsurface_gl_p.h> +#include <private/qpixmapdata_gl_p.h> + +QT_BEGIN_NAMESPACE + +QGLPaintDevice::QGLPaintDevice() + : m_thisFBO(0) +{ +} + +QGLPaintDevice::~QGLPaintDevice() +{ +} + + +void QGLPaintDevice::beginPaint() +{ + // Make sure our context is the current one: + QGLContext *ctx = context(); + if (ctx != QGLContext::currentContext()) + ctx->makeCurrent(); + + // Record the currently bound FBO so we can restore it again + // in endPaint() and bind this device's FBO + m_previousFBO = ctx->d_func()->current_fbo; + if (m_previousFBO != m_thisFBO) { + ctx->d_ptr->current_fbo = m_thisFBO; + glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_thisFBO); + } +} + +void QGLPaintDevice::ensureActiveTarget() +{ + QGLContext* ctx = context(); + if (ctx != QGLContext::currentContext()) + ctx->makeCurrent(); + + if (ctx->d_ptr->current_fbo != m_thisFBO) { + ctx->d_ptr->current_fbo = m_thisFBO; + glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_thisFBO); + } +} + +void QGLPaintDevice::endPaint() +{ + // Make sure the FBO bound at beginPaint is re-bound again here: + QGLContext *ctx = context(); + if (m_previousFBO != ctx->d_func()->current_fbo) { + ctx->d_ptr->current_fbo = m_previousFBO; + glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_previousFBO); + } +} + +QGLFormat QGLPaintDevice::format() const +{ + return context()->format(); +} + + + + +////////////////// QGLWidgetGLPaintDevice ////////////////// + +QGLWidgetGLPaintDevice::QGLWidgetGLPaintDevice() +{ +} + +QPaintEngine* QGLWidgetGLPaintDevice::paintEngine() const +{ + return glWidget->paintEngine(); +} + +void QGLWidgetGLPaintDevice::setWidget(QGLWidget* w) +{ + glWidget = w; +} + +void QGLWidgetGLPaintDevice::beginPaint() +{ + QGLPaintDevice::beginPaint(); + if (!glWidget->d_func()->disable_clear_on_painter_begin && glWidget->autoFillBackground()) { + if (glWidget->testAttribute(Qt::WA_TranslucentBackground)) + glClearColor(0.0, 0.0, 0.0, 0.0); + else { + const QColor &c = glWidget->palette().brush(glWidget->backgroundRole()).color(); + float alpha = c.alphaF(); + glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha); + } + glClear(GL_COLOR_BUFFER_BIT); + } +} + +void QGLWidgetGLPaintDevice::endPaint() +{ + if (glWidget->autoBufferSwap()) + glWidget->swapBuffers(); + QGLPaintDevice::endPaint(); +} + + +QSize QGLWidgetGLPaintDevice::size() const +{ + return glWidget->size(); +} + +QGLContext* QGLWidgetGLPaintDevice::context() const +{ + return const_cast<QGLContext*>(glWidget->context()); +} + +// returns the QGLPaintDevice for the given QPaintDevice +QGLPaintDevice* QGLPaintDevice::getDevice(QPaintDevice* pd) +{ + QGLPaintDevice* glpd = 0; + + switch(pd->devType()) { + case QInternal::Widget: + // Should not be called on a non-gl widget: + Q_ASSERT(qobject_cast<QGLWidget*>(static_cast<QWidget*>(pd))); + glpd = &(static_cast<QGLWidget*>(pd)->d_func()->glDevice); + break; + case QInternal::Pbuffer: + glpd = &(static_cast<QGLPixelBuffer*>(pd)->d_func()->glDevice); + break; + case QInternal::FramebufferObject: + glpd = &(static_cast<QGLFramebufferObject*>(pd)->d_func()->glDevice); + break; + case QInternal::Pixmap: { + QPixmapData* pmd = static_cast<QPixmap*>(pd)->pixmapData(); + Q_ASSERT(pmd->classId() == QPixmapData::OpenGLClass); + glpd = static_cast<QGLPixmapData*>(pmd)->glDevice(); + break; + } + default: + qWarning("QGLPaintDevice::getDevice() - Unknown device type %d", pd->devType()); + break; + } + + return glpd; +} + +QT_END_NAMESPACE diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h new file mode 100644 index 0000000..32a1275 --- /dev/null +++ b/src/opengl/qglpaintdevice_p.h @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** 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 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 QGLPAINTDEVICE_P_H +#define QGLPAINTDEVICE_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 QtOpenGL module. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + + +#include <qpaintdevice.h> +#include <qgl.h> + + +QT_BEGIN_NAMESPACE + +class QGLPaintDevice : public QPaintDevice +{ +public: + QGLPaintDevice(); + virtual ~QGLPaintDevice(); + + int devType() const {return QInternal::OpenGL;} + + virtual void beginPaint(); + virtual void ensureActiveTarget(); + virtual void endPaint(); + + virtual QGLContext* context() const = 0; + QGLFormat format() const; + virtual QSize size() const = 0; + + // returns the QGLPaintDevice for the given QPaintDevice + static QGLPaintDevice* getDevice(QPaintDevice*); + +protected: + GLuint m_previousFBO; + GLuint m_thisFBO; +}; + + +// Wraps a QGLWidget +class QGLWidget; +class QGLWidgetGLPaintDevice : public QGLPaintDevice +{ +public: + QGLWidgetGLPaintDevice(); + + virtual QPaintEngine* paintEngine() const; + + // QGLWidgets need to do swapBufers in endPaint: + virtual void beginPaint(); + virtual void endPaint(); + virtual QSize size() const; + virtual QGLContext* context() const; + + void setWidget(QGLWidget*); + +private: + friend class QGLWidget; + QGLWidget *glWidget; +}; + +QT_END_NAMESPACE + +#endif // QGLPAINTDEVICE_P_H diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index f082ff0..b6a919c 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -100,6 +100,22 @@ void qgl_cleanup_glyph_cache(QGLContext *) {} extern QImage qt_gl_read_framebuffer(const QSize&, bool, bool); + +QGLContext* QGLPBufferGLPaintDevice::context() const +{ + return pbuf->d_func()->qctx; +} + +void QGLPBufferGLPaintDevice::endPaint() { + glFlush(); + QGLPaintDevice::endPaint(); +} + +void QGLPBufferGLPaintDevice::setPBuffer(QGLPixelBuffer* pb) +{ + pbuf = pb; +} + void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &format, QGLWidget *shareWidget) { Q_Q(QGLPixelBuffer); @@ -115,6 +131,7 @@ void QGLPixelBufferPrivate::common_init(const QSize &size, const QGLFormat &form shareWidget->d_func()->glcx->d_func()->sharing = true; } + glDevice.setPBuffer(q); qctx->d_func()->paintDevice = q; qctx->d_func()->valid = true; #if defined(Q_WS_WIN) && !defined(QT_OPENGL_ES) diff --git a/src/opengl/qglpixelbuffer.h b/src/opengl/qglpixelbuffer.h index 5e81ea3..fe313a6 100644 --- a/src/opengl/qglpixelbuffer.h +++ b/src/opengl/qglpixelbuffer.h @@ -110,6 +110,8 @@ private: QScopedPointer<QGLPixelBufferPrivate> d_ptr; friend class QGLDrawable; friend class QGLWindowSurface; + friend class QGLPaintDevice; + friend class QGLPBufferGLPaintDevice; }; QT_END_NAMESPACE diff --git a/src/opengl/qglpixelbuffer_p.h b/src/opengl/qglpixelbuffer_p.h index 74cb330..96d41d7 100644 --- a/src/opengl/qglpixelbuffer_p.h +++ b/src/opengl/qglpixelbuffer_p.h @@ -58,6 +58,7 @@ QT_BEGIN_NAMESPACE QT_BEGIN_INCLUDE_NAMESPACE #include "QtOpenGL/qglpixelbuffer.h" #include <private/qgl_p.h> +#include <private/qglpaintdevice_p.h> #if defined(Q_WS_X11) && !defined(QT_OPENGL_ES) #include <GL/glx.h> @@ -135,6 +136,19 @@ QT_END_INCLUDE_NAMESPACE class QEglContext; + +class QGLPBufferGLPaintDevice : public QGLPaintDevice +{ +public: + virtual QPaintEngine* paintEngine() const {return pbuf->paintEngine();} + virtual QSize size() const {return pbuf->size();} + virtual QGLContext* context() const; + virtual void endPaint(); + void setPBuffer(QGLPixelBuffer* pb); +private: + QGLPixelBuffer* pbuf; +}; + class QGLPixelBufferPrivate { Q_DECLARE_PUBLIC(QGLPixelBuffer) public: @@ -154,6 +168,7 @@ public: QGLPixelBuffer *q_ptr; bool invalid; QGLContext *qctx; + QGLPBufferGLPaintDevice glDevice; QGLFormat format; QGLFormat req_format; diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index bf4d4b9..34fff10 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -49,6 +49,7 @@ #include "qbrush.h" #include "qgl.h" #include <private/qgl_p.h> +#include <private/qglpaintdevice_p.h> #include <private/qpainter_p.h> #include "qmap.h" #include <private/qpaintengine_opengl_p.h> @@ -75,7 +76,7 @@ #include "qgl_cl_p.h" #endif -#define QGL_FUNC_CONTEXT QGLContext *ctx = const_cast<QGLContext *>(drawable.context()); +#define QGL_FUNC_CONTEXT QGLContext *ctx = const_cast<QGLContext *>(device->context()); #include <stdlib.h> #include "qpaintengine_opengl_p.h" @@ -286,7 +287,7 @@ public Q_SLOTS: } private: - QGLDrawable drawable; + QGLPaintDevice* device; QGLFramebufferObject *offscreen; QGLContext *ctx; @@ -305,7 +306,13 @@ private: inline void QGLOffscreen::setDevice(QPaintDevice *pdev) { - drawable.setDevice(pdev); + if (pdev->devType() == QInternal::OpenGL) + device = static_cast<QGLPaintDevice*>(pdev); + else + device = QGLPaintDevice::getDevice(pdev); + + if (!device) + return; drawable_fbo = (pdev->devType() == QInternal::FramebufferObject); } @@ -329,12 +336,12 @@ void QGLOffscreen::initialize() activated = true; initialized = true; - int dim = qMax(2048, static_cast<int>(qt_next_power_of_two(qMax(drawable.size().width(), drawable.size().height())))); + int dim = qMax(2048, static_cast<int>(qt_next_power_of_two(qMax(device->size().width(), device->size().height())))); - bool shared_context = qgl_share_reg()->checkSharing(drawable.context(), ctx); + bool shared_context = qgl_share_reg()->checkSharing(device->context(), ctx); bool would_fail = last_failed_size.isValid() && - (drawable.size().width() >= last_failed_size.width() || - drawable.size().height() >= last_failed_size.height()); + (device->size().width() >= last_failed_size.width() || + device->size().height() >= last_failed_size.height()); bool needs_refresh = dim > mask_dim || !shared_context; if (needs_refresh && !would_fail) { @@ -348,13 +355,13 @@ void QGLOffscreen::initialize() delete offscreen; offscreen = 0; mask_dim = 0; - last_failed_size = drawable.size(); + last_failed_size = device->size(); } } qt_mask_texture_cache()->setOffscreenSize(offscreenSize()); - qt_mask_texture_cache()->setDrawableSize(drawable.size()); - ctx = drawable.context(); + qt_mask_texture_cache()->setDrawableSize(device->size()); + ctx = device->context(); #endif } @@ -428,11 +435,11 @@ inline void QGLOffscreen::release() DEBUG_ONCE_STR("QGLOffscreen: releasing offscreen"); if (drawable_fbo) - drawable.makeCurrent(); + device->ensureActiveTarget(); //### else offscreen->release(); - QSize sz(drawable.size()); + QSize sz(device->size()); glViewport(0, 0, sz.width(), sz.height()); glMatrixMode(GL_PROJECTION); @@ -455,7 +462,7 @@ inline bool QGLOffscreen::isBound() const inline QSize QGLOffscreen::drawableSize() const { - return drawable.size(); + return device->size(); } inline QSize QGLOffscreen::offscreenSize() const @@ -757,7 +764,7 @@ public: GLubyte pen_color[4]; GLubyte brush_color[4]; QTransform::TransformationType txop; - QGLDrawable drawable; + QGLPaintDevice* device; QGLOffscreen offscreen; qreal inverseScale; @@ -1167,7 +1174,7 @@ void QOpenGLPaintEnginePrivate::createGradientPaletteTexture(const QGradient& g) #ifdef QT_OPENGL_ES //### Q_UNUSED(g); #else - GLuint texId = qt_opengl_gradient_cache()->getBuffer(g, opacity, drawable.context()); + GLuint texId = qt_opengl_gradient_cache()->getBuffer(g, opacity, device->context()); glBindTexture(GL_TEXTURE_1D, texId); grad_palette = texId; if (g.spread() == QGradient::RepeatSpread || g.type() == QGradient::ConicalGradient) @@ -1236,12 +1243,19 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) { Q_D(QOpenGLPaintEngine); - d->drawable.setDevice(pdev); + if (pdev->devType() == QInternal::OpenGL) + d->device = static_cast<QGLPaintDevice*>(pdev); + else + d->device = QGLPaintDevice::getDevice(pdev); + + if (!d->device) + return false; + d->offscreen.setDevice(pdev); d->has_fast_pen = false; d->inverseScale = 1; d->opacity = 1; - d->drawable.makeCurrent(); + d->device->beginPaint(); d->matrix = QTransform(); d->has_antialiasing = false; d->high_quality_antialiasing = false; @@ -1256,7 +1270,7 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) bool has_frag_program = (QGLExtensions::glExtensions & QGLExtensions::FragmentProgram) && (pdev->devType() != QInternal::Pixmap); - QGLContext *ctx = const_cast<QGLContext *>(d->drawable.context()); + QGLContext *ctx = const_cast<QGLContext *>(d->device->context()); if (!ctx) { qWarning() << "QOpenGLPaintEngine: paint device doesn't have a valid GL context."; return false; @@ -1265,9 +1279,9 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) if (has_frag_program) has_frag_program = qt_resolve_frag_program_extensions(ctx) && qt_resolve_version_1_3_functions(ctx); - d->use_stencil_method = d->drawable.format().stencil() + d->use_stencil_method = d->device->format().stencil() && (QGLExtensions::glExtensions & QGLExtensions::StencilWrap); - if (d->drawable.format().directRendering() + if (d->device->format().directRendering() && (d->use_stencil_method && QGLExtensions::glExtensions & QGLExtensions::StencilTwoSide)) d->has_stencil_face_ext = qt_resolve_stencil_face_extension(ctx); @@ -1333,23 +1347,7 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) d->offscreen.begin(); - if (d->drawable.context()->d_func()->clear_on_painter_begin && d->drawable.autoFillBackground()) { - - if (d->drawable.hasTransparentBackground()) - glClearColor(0.0, 0.0, 0.0, 0.0); - else { - const QColor &c = d->drawable.backgroundColor(); - glClearColor(c.redF(), c.greenF(), c.blueF(), 1.0); - } - - GLbitfield clearBits = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT; -#ifndef QT_OPENGL_ES - clearBits |= GL_ACCUM_BUFFER_BIT; -#endif - glClear(clearBits); - } - - QSize sz(d->drawable.size()); + QSize sz(d->device->size()); glViewport(0, 0, sz.width(), sz.height()); // XXX (Embedded): We need a solution for GLWidgets that draw in a part or a bigger surface... glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -1366,7 +1364,7 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) #ifdef QT_OPENGL_ES d->max_texture_size = ctx->d_func()->maxTextureSize(); #else - bool shared_ctx = qgl_share_reg()->checkSharing(d->drawable.context(), d->shader_ctx); + bool shared_ctx = qgl_share_reg()->checkSharing(d->device->context(), d->shader_ctx); if (shared_ctx) { d->max_texture_size = d->shader_ctx->d_func()->maxTextureSize(); @@ -1382,7 +1380,7 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) glDeleteTextures(1, &d->drawable_texture); ctx->makeCurrent(); } - d->shader_ctx = d->drawable.context(); + d->shader_ctx = d->device->context(); glGenTextures(1, &d->grad_palette); qt_mask_texture_cache()->clearCache(); @@ -1417,7 +1415,7 @@ bool QOpenGLPaintEngine::end() Q_D(QOpenGLPaintEngine); d->flushDrawQueue(); d->offscreen.end(); - QGLContext *ctx = const_cast<QGLContext *>(d->drawable.context()); + QGLContext *ctx = const_cast<QGLContext *>(d->device->context()); if (!ctx->d_ptr->internal_context) { glMatrixMode(GL_TEXTURE); glPopMatrix(); @@ -1434,8 +1432,7 @@ bool QOpenGLPaintEngine::end() glPopClientAttrib(); } #endif - d->drawable.swapBuffers(); - d->drawable.doneCurrent(); + d->device->endPaint(); qt_mask_texture_cache()->maintainCache(); return true; @@ -1961,7 +1958,7 @@ void QOpenGLPaintEnginePrivate::fillVertexArray(Qt::FillRule fillRule) const int left = rect.left(); const int width = rect.width(); - const int bottom = drawable.size().height() - (rect.bottom() + 1); + const int bottom = device->size().height() - (rect.bottom() + 1); const int height = rect.height(); glScissor(left, bottom, width, height); @@ -2242,7 +2239,7 @@ void QOpenGLPaintEnginePrivate::updateDepthClip() const int left = fastClip.left(); const int width = fastClip.width(); - const int bottom = drawable.size().height() - (fastClip.bottom() + 1); + const int bottom = device->size().height() - (fastClip.bottom() + 1); const int height = fastClip.height(); glScissor(left, bottom, width, height); @@ -2325,7 +2322,7 @@ void QOpenGLPaintEngine::updateClipRegion(const QRegion &clipRegion, Qt::ClipOpe // clipping is only supported when a stencil or depth buffer is // available - if (!d->drawable.format().depth()) + if (!d->device->format().depth()) return; d->use_system_clip = false; @@ -2362,7 +2359,7 @@ void QOpenGLPaintEngine::updateClipRegion(const QRegion &clipRegion, Qt::ClipOpe path.addRect(untransformedRects[0]); path = d->matrix.map(path); - if (path.contains(QRectF(QPointF(), d->drawable.size()))) + if (path.contains(QRectF(QPointF(), d->device->size()))) isScreenClip = true; } } @@ -3369,7 +3366,7 @@ void QOpenGLPaintEnginePrivate::drawOffscreenPath(const QPainterPath &path) disableClipping(); - GLuint program = qt_gl_program_cache()->getProgram(drawable.context(), + GLuint program = qt_gl_program_cache()->getProgram(device->context(), FRAGMENT_PROGRAM_MASK_TRAPEZOID_AA, 0, true); QGLPathMaskGenerator maskGenerator(path, matrix, offscreen, program); addItem(qt_mask_texture_cache()->getMask(maskGenerator, this)); @@ -3506,7 +3503,7 @@ void QOpenGLPaintEngine::drawRects(const QRectF *rects, int rectCount) if (d->has_brush) { d->disableClipping(); - GLuint program = qt_gl_program_cache()->getProgram(d->drawable.context(), + GLuint program = qt_gl_program_cache()->getProgram(d->device->context(), FRAGMENT_PROGRAM_MASK_TRAPEZOID_AA, 0, true); if (d->matrix.type() >= QTransform::TxProject) { @@ -3916,7 +3913,7 @@ void QOpenGLPaintEnginePrivate::strokeLines(const QPainterPath &path) qreal penWidth = cpen.widthF(); - GLuint program = qt_gl_program_cache()->getProgram(drawable.context(), + GLuint program = qt_gl_program_cache()->getProgram(device->context(), FRAGMENT_PROGRAM_MASK_TRAPEZOID_AA, 0, true); QGLLineMaskGenerator maskGenerator(path, matrix, penWidth == 0 ? 1.0 : penWidth, offscreen, program); @@ -4302,7 +4299,7 @@ void QOpenGLPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QR else { GLenum target = qt_gl_preferredTextureTarget(); d->flushDrawQueue(); - d->drawable.bindTexture(pm, target); + d->device->context()->bindTexture(pm, target); drawTextureRect(pm.width(), pm.height(), r, sr, target); } } @@ -4336,9 +4333,9 @@ void QOpenGLPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, con d->flushDrawQueue(); if (scaled.isNull()) - d->drawable.bindTexture(pm); + d->device->context()->bindTexture(pm); else - d->drawable.bindTexture(scaled); + d->device->context()->bindTexture(scaled); updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, d->use_smooth_pixmap_transform); #ifndef QT_OPENGL_ES @@ -4404,7 +4401,7 @@ void QOpenGLPaintEngine::drawImage(const QRectF &r, const QImage &image, const Q else { GLenum target = qt_gl_preferredTextureTarget(); d->flushDrawQueue(); - d->drawable.bindTexture(image, target); + d->device->context()->bindTexture(image, target); drawTextureRect(image.width(), image.height(), r, sr, target); } } @@ -4871,7 +4868,7 @@ void QOpenGLPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); // make sure the glyphs we want to draw are in the cache - qt_glyph_cache()->cacheGlyphs(d->drawable.context(), ti, glyphs); + qt_glyph_cache()->cacheGlyphs(d->device->context(), ti, glyphs); d->setGradientOps(Qt::SolidPattern, QRectF()); // turns off gradient ops qt_glColor4ubv(d->pen_color); @@ -4949,7 +4946,7 @@ void QOpenGLPaintEngine::drawEllipse(const QRectF &rect) glPushMatrix(); glLoadIdentity(); - GLuint program = qt_gl_program_cache()->getProgram(d->drawable.context(), + GLuint program = qt_gl_program_cache()->getProgram(d->device->context(), FRAGMENT_PROGRAM_MASK_ELLIPSE_AA, 0, true); QGLEllipseMaskGenerator maskGenerator(rect, d->matrix, @@ -5084,10 +5081,10 @@ void QOpenGLPaintEnginePrivate::copyDrawable(const QRectF &rect) QRectF screen_rect = rect.adjusted(-1, -1, 1, 1); int left = qMax(0, static_cast<int>(screen_rect.left())); - int width = qMin(drawable.size().width() - left, static_cast<int>(screen_rect.width()) + 1); + int width = qMin(device->size().width() - left, static_cast<int>(screen_rect.width()) + 1); - int bottom = qMax(0, static_cast<int>(drawable.size().height() - screen_rect.bottom())); - int height = qMin(drawable.size().height() - bottom, static_cast<int>(screen_rect.height()) + 1); + int bottom = qMax(0, static_cast<int>(device->size().height() - screen_rect.bottom())); + int height = qMin(device->size().height() - bottom, static_cast<int>(screen_rect.height()) + 1); glBindTexture(GL_TEXTURE_2D, drawable_texture); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, left, bottom, left, bottom, width, height); @@ -5181,9 +5178,9 @@ void QOpenGLPaintEnginePrivate::composite(GLuint primitive, const q_vertexType * glActiveTexture(GL_TEXTURE0 + brush_texture_location); if (current_style == Qt::TexturePattern) - drawable.bindTexture(cbrush.textureImage()); + device->context()->bindTexture(cbrush.textureImage()); else - drawable.bindTexture(qt_imageForBrush(current_style, true)); + device->context()->bindTexture(qt_imageForBrush(current_style, true)); updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, use_smooth_pixmap_transform); } @@ -5191,7 +5188,7 @@ void QOpenGLPaintEnginePrivate::composite(GLuint primitive, const q_vertexType * glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, q_vertexTypeEnum, 0, vertexArray); glEnable(GL_FRAGMENT_PROGRAM_ARB); - GLuint program = qt_gl_program_cache()->getProgram(drawable.context(), + GLuint program = qt_gl_program_cache()->getProgram(device->context(), fragment_brush, fragment_composition_mode, false); glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, program); @@ -5263,7 +5260,7 @@ void QOpenGLPaintEnginePrivate::drawItem(const QDrawQueueItem &item) setGradientOps(item.brush, item.location.screen_rect); composite(item.location.screen_rect, item.location.rect.topLeft() - item.location.screen_rect.topLeft() - - QPoint(0, offscreen.offscreenSize().height() - drawable.size().height())); + - QPoint(0, offscreen.offscreenSize().height() - device->size().height())); } void QOpenGLPaintEnginePrivate::flushDrawQueue() diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index d63d2ad..ae616a8 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -80,12 +80,7 @@ QGLFramebufferObject *QGLFramebufferObjectPool::acquire(const QSize &requestSize for (int i = 0; !chosen && i < m_fbos.size(); ++i) { QGLFramebufferObject *fbo = m_fbos.at(i); - QGLFramebufferObjectFormat format = fbo->format(); - if (format.samples() == requestFormat.samples() - && format.attachment() == requestFormat.attachment() - && format.textureTarget() == requestFormat.textureTarget() - && format.internalTextureFormat() == requestFormat.internalTextureFormat()) - { + if (fbo->format() == requestFormat) { // choose the fbo with a matching format and the closest size if (!candidate || areaDiff(requestSize, candidate) > areaDiff(requestSize, fbo)) candidate = fbo; @@ -132,6 +127,76 @@ void QGLFramebufferObjectPool::release(QGLFramebufferObject *fbo) m_fbos << fbo; } + +QPaintEngine* QGLPixmapGLPaintDevice::paintEngine() const +{ + return data->paintEngine(); +} + +void QGLPixmapGLPaintDevice::beginPaint() +{ + if (!data->isValid()) + return; + + // QGLPaintDevice::beginPaint will store the current binding and replace + // it with m_thisFBO: + m_thisFBO = data->m_renderFbo->handle(); + QGLPaintDevice::beginPaint(); + + Q_ASSERT(data->paintEngine()->type() == QPaintEngine::OpenGL2); + + // QPixmap::fill() is deferred until now, where we actually need to do the fill: + if (data->needsFill()) { + const QColor &c = data->fillColor(); + float alpha = c.alphaF(); + glClearColor(c.redF() * alpha, c.greenF() * alpha, c.blueF() * alpha, alpha); + glClear(GL_COLOR_BUFFER_BIT); + } + else if (!data->isUninitialized()) { + // If the pixmap (GL Texture) has valid content (it has been + // uploaded from an image or rendered into before), we need to + // copy it from the texture to the render FBO. + + // Pass false to tell bind to _not_ copy the FBO into the texture! + GLuint texId = data->bind(false); + + QGL2PaintEngineEx* pe = static_cast<QGL2PaintEngineEx*>(data->paintEngine()); + QRect rect(0, 0, data->width(), data->height()); + pe->drawTexture(QRectF(rect), texId, rect.size(), QRectF(rect)); + } +} + +void QGLPixmapGLPaintDevice::endPaint() +{ + if (!data->isValid()) + return; + + data->copyBackFromRenderFbo(false); + + data->m_renderFbo->release(); + qgl_fbo_pool()->release(data->m_renderFbo); + data->m_renderFbo = 0; + + // Base's endPaint will restore the previous FBO binding + QGLPaintDevice::endPaint(); +} + +QGLContext* QGLPixmapGLPaintDevice::context() const +{ + data->ensureCreated(); + return data->m_ctx; +} + +QSize QGLPixmapGLPaintDevice::size() const +{ + return data->size(); +} + +void QGLPixmapGLPaintDevice::setPixmapData(QGLPixmapData* d) +{ + data = d; +} + static int qt_gl_pixmap_serial = 0; QGLPixmapData::QGLPixmapData(PixelType type) @@ -144,6 +209,7 @@ QGLPixmapData::QGLPixmapData(PixelType type) , m_hasAlpha(false) { setSerialNumber(++qt_gl_pixmap_serial); + m_glDevice.setPixmapData(this); } QGLPixmapData::~QGLPixmapData() @@ -237,11 +303,6 @@ void QGLPixmapData::ensureCreated() const m_texture.options &= ~QGLContext::MemoryManagedBindOption; } -QGLFramebufferObject *QGLPixmapData::fbo() const -{ - return m_renderFbo; -} - void QGLPixmapData::fromImage(const QImage &image, Qt::ImageConversionFlags) { @@ -417,31 +478,6 @@ void QGLPixmapData::copyBackFromRenderFbo(bool keepCurrentFboBound) const glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->current_fbo); } -void QGLPixmapData::swapBuffers() -{ - if (!isValid()) - return; - - copyBackFromRenderFbo(false); - m_renderFbo->release(); - - qgl_fbo_pool()->release(m_renderFbo); - - m_renderFbo = 0; -} - -void QGLPixmapData::makeCurrent() -{ - if (isValid() && m_renderFbo) - m_renderFbo->bind(); -} - -void QGLPixmapData::doneCurrent() -{ - if (isValid() && m_renderFbo) - m_renderFbo->release(); -} - bool QGLPixmapData::useFramebufferObjects() { return QGLFramebufferObject::hasOpenGLFramebufferObjects() @@ -490,6 +526,10 @@ QPaintEngine* QGLPixmapData::paintEngine() const return m_source.paintEngine(); } + +// If copyBack is true, bind will copy the contents of the render +// FBO to the texture (which is not bound to the texture, as it's +// a multisample FBO). GLuint QGLPixmapData::bind(bool copyBack) const { if (m_renderFbo && copyBack) { @@ -509,12 +549,6 @@ GLuint QGLPixmapData::bind(bool copyBack) const return id; } -GLuint QGLPixmapData::textureId() const -{ - ensureCreated(); - return m_texture.id; -} - QGLTexture* QGLPixmapData::texture() const { return &m_texture; @@ -553,4 +587,9 @@ int QGLPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const } } +QGLPaintDevice *QGLPixmapData::glDevice() const +{ + return &m_glDevice; +} + QT_END_NAMESPACE diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h index ab1ff47..31ae7c7 100644 --- a/src/opengl/qpixmapdata_gl_p.h +++ b/src/opengl/qpixmapdata_gl_p.h @@ -57,12 +57,14 @@ #include "qgl.h" #include "private/qpixmapdata_p.h" +#include "private/qglpaintdevice_p.h" QT_BEGIN_NAMESPACE class QPaintEngine; class QGLFramebufferObject; class QGLFramebufferObjectFormat; +class QGLPixmapData; class QGLFramebufferObjectPool { @@ -76,31 +78,50 @@ private: QGLFramebufferObjectPool* qgl_fbo_pool(); + +class QGLPixmapGLPaintDevice : public QGLPaintDevice +{ +public: + QPaintEngine* paintEngine() const; + + void beginPaint(); + void endPaint(); + QGLContext* context() const; + QSize size() const; + + void setPixmapData(QGLPixmapData*); +private: + QGLPixmapData *data; +}; + + class QGLPixmapData : public QPixmapData { public: QGLPixmapData(PixelType type); ~QGLPixmapData(); - bool isValid() const; - + // Re-implemented from QPixmapData: void resize(int width, int height); - void fromImage(const QImage &image, - Qt::ImageConversionFlags flags); + void fromImage(const QImage &image, Qt::ImageConversionFlags flags); void copy(const QPixmapData *data, const QRect &rect); - bool scroll(int dx, int dy, const QRect &rect); - void fill(const QColor &color); bool hasAlphaChannel() const; QImage toImage() const; QPaintEngine *paintEngine() const; + int metric(QPaintDevice::PaintDeviceMetric metric) const; + // For accessing as a target: + QGLPaintDevice *glDevice() const; + + // For accessing as a source: + bool isValidContext(const QGLContext *ctx) const; GLuint bind(bool copyBack = true) const; - GLuint textureId() const; QGLTexture *texture() const; - bool isValidContext(const QGLContext *ctx) const; +private: + bool isValid() const; void ensureCreated() const; @@ -109,22 +130,13 @@ public: bool needsFill() const { return m_hasFillColor; } QColor fillColor() const { return m_fillColor; } - QSize size() const { return QSize(w, h); } - - QGLFramebufferObject *fbo() const; - void makeCurrent(); - void doneCurrent(); - void swapBuffers(); -protected: - int metric(QPaintDevice::PaintDeviceMetric metric) const; - -private: QGLPixmapData(const QGLPixmapData &other); QGLPixmapData &operator=(const QGLPixmapData &other); void copyBackFromRenderFbo(bool keepCurrentFboBound) const; + QSize size() const { return QSize(w, h); } static bool useFramebufferObjects(); @@ -145,6 +157,10 @@ private: mutable bool m_hasFillColor; mutable bool m_hasAlpha; + + mutable QGLPixmapGLPaintDevice m_glDevice; + + friend class QGLPixmapGLPaintDevice; }; QT_END_NAMESPACE diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index a85b9ae..3a6ed06 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -229,6 +229,7 @@ QGLWidget* qt_gl_share_widget() return _qt_gl_share_widget()->shareWidget(); } + struct QGLWindowSurfacePrivate { QGLFramebufferObject *fbo; @@ -248,10 +249,49 @@ struct QGLWindowSurfacePrivate QSize size; QList<QImage> buffers; + QGLWindowSurfaceGLPaintDevice glDevice; + QGLWindowSurface* q_ptr; }; QGLFormat QGLWindowSurface::surfaceFormat; +void QGLWindowSurfaceGLPaintDevice::endPaint() +{ + glFlush(); + QGLPaintDevice::endPaint(); +} + +QSize QGLWindowSurfaceGLPaintDevice::size() const +{ + return d->size; +} + +QGLContext* QGLWindowSurfaceGLPaintDevice::context() const +{ + return d->ctx; +} + + +int QGLWindowSurfaceGLPaintDevice::metric(PaintDeviceMetric m) const +{ + return d->q_ptr->window()->metric(m); +} + +Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_window_surface_2_engine) + +#if !defined (QT_OPENGL_ES_2) +Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_window_surface_engine) +#endif + +QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const +{ +#if !defined(QT_OPENGL_ES_2) + if (!qt_gl_preferGL2Engine()) + return qt_gl_window_surface_engine(); +#endif + return qt_gl_window_surface_2_engine(); +} + QGLWindowSurface::QGLWindowSurface(QWidget *window) : QWindowSurface(window), d_ptr(new QGLWindowSurfacePrivate) { @@ -263,6 +303,8 @@ QGLWindowSurface::QGLWindowSurface(QWidget *window) d_ptr->tried_fbo = false; d_ptr->tried_pb = false; d_ptr->destructive_swap_buffers = qgetenv("QT_GL_SWAPBUFFER_PRESERVE").isNull(); + d_ptr->glDevice.d = d_ptr; + d_ptr->q_ptr = this; } QGLWindowSurface::~QGLWindowSurface() @@ -320,27 +362,6 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) qDebug() << "hijackWindow() context created for" << widget << d_ptr->contexts.size(); } -Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_window_surface_2_engine) - -#if !defined (QT_OPENGL_ES_2) -Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_window_surface_engine) -#endif - -/*! \reimp */ -QPaintEngine *QGLWindowSurface::paintEngine() const -{ -#if !defined(QT_OPENGL_ES_2) - if (!qt_gl_preferGL2Engine()) - return qt_gl_window_surface_engine(); -#endif - return qt_gl_window_surface_2_engine(); -} - -int QGLWindowSurface::metric(PaintDeviceMetric m) const -{ - return window()->metric(m); -} - QGLContext *QGLWindowSurface::context() const { return d_ptr->ctx; @@ -354,7 +375,7 @@ QPaintDevice *QGLWindowSurface::paintDevice() return d_ptr->pb; if (d_ptr->ctx) - return this; + return &d_ptr->glDevice; QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext); ctx->makeCurrent(); diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h index ad583b2..7b18f2e 100644 --- a/src/opengl/qwindowsurface_gl_p.h +++ b/src/opengl/qwindowsurface_gl_p.h @@ -56,6 +56,7 @@ #include <qglobal.h> #include <qgl.h> #include <private/qwindowsurface_p.h> +#include <private/qglpaintdevice_p.h> QT_BEGIN_NAMESPACE @@ -65,7 +66,18 @@ class QRegion; class QWidget; struct QGLWindowSurfacePrivate; -class QGLWindowSurface : public QObject, public QWindowSurface, public QPaintDevice +class QGLWindowSurfaceGLPaintDevice : public QGLPaintDevice +{ +public: + QPaintEngine* paintEngine() const; + void endPaint(); + QSize size() const; + int metric(PaintDeviceMetric m) const; + QGLContext* context() const; + QGLWindowSurfacePrivate* d; +}; + +class QGLWindowSurface : public QObject, public QWindowSurface // , public QPaintDevice { Q_OBJECT public: @@ -87,11 +99,6 @@ public: static QGLFormat surfaceFormat; - QPaintEngine *paintEngine() const; - -protected: - int metric(PaintDeviceMetric metric) const; - private slots: void deleted(QObject *object); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index 6550683..f88055e 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -330,17 +330,17 @@ bool QDirectFBPixmapData::fromDataBufferDescription(const DFBDataBufferDescripti #endif -void QDirectFBPixmapData::fromImage(const QImage &image, +void QDirectFBPixmapData::fromImage(const QImage &img, Qt::ImageConversionFlags flags) { - if (image.depth() == 1) { - fromImage(image.convertToFormat(screen->alphaPixmapFormat()), flags); + if (img.depth() == 1) { + fromImage(img.convertToFormat(screen->alphaPixmapFormat()), flags); return; } - if (image.hasAlphaChannel() + if (img.hasAlphaChannel() #ifndef QT_NO_DIRECTFB_OPAQUE_DETECTION - && (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(image)) + && (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(img)) #endif ) { alpha = true; @@ -349,13 +349,37 @@ void QDirectFBPixmapData::fromImage(const QImage &image, alpha = false; imageFormat = screen->pixelFormat(); } + QImage image; + if (flags != Qt::AutoColor) { + image = img.convertToFormat(imageFormat, flags); + flags = Qt::AutoColor; + } else { + image = img; + } + + IDirectFBSurface *imageSurface = screen->createDFBSurface(image, image.format(), QDirectFBScreen::DontTrackSurface); + if (!imageSurface) { + qWarning("QDirectFBPixmapData::fromImage()"); + invalidate(); + return; + } - dfbSurface = screen->createDFBSurface(image, imageFormat, QDirectFBScreen::TrackSurface|QDirectFBScreen::NoPreallocated); + dfbSurface = screen->createDFBSurface(image.size(), imageFormat, QDirectFBScreen::TrackSurface); if (!dfbSurface) { qWarning("QDirectFBPixmapData::fromImage()"); invalidate(); return; } + + if (image.hasAlphaChannel()) { + dfbSurface->Clear(dfbSurface, 0, 0, 0, 0); + dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_BLEND_ALPHACHANNEL); + } else { + dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX); + } + dfbSurface->Blit(dfbSurface, imageSurface, 0, 0, 0); + imageSurface->Release(imageSurface); + w = image.width(); h = image.height(); is_null = (w <= 0 || h <= 0); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 46d06ef..5955f27 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -66,7 +66,7 @@ QT_MODULE(Gui) #if !defined QT_DIRECTFB_IMAGECACHE && !defined QT_NO_DIRECTFB_IMAGECACHE #define QT_NO_DIRECTFB_IMAGECACHE #endif -#if !defined QT_DIRECTFB_NO_IMAGEPROVIDER && !defined QT_DIRECTFB_IMAGEPROVIDER +#if !defined QT_NO_DIRECTFB_IMAGEPROVIDER && !defined QT_DIRECTFB_IMAGEPROVIDER #define QT_DIRECTFB_IMAGEPROVIDER #endif #if !defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE && !defined QT_NO_DIRECTFB_IMAGEPROVIDER_KEEPALIVE diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index b1ffe69..82c2f81 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -127,6 +127,8 @@ void QDirectFBWindowSurface::createWindow(const QRect &rect) qFatal("QDirectFBWindowSurface: Unable to get primary display layer!"); DFBWindowDescription description; + memset(&description, 0, sizeof(DFBWindowDescription)); + description.caps = DWCAPS_NODECORATION|DWCAPS_DOUBLEBUFFER; description.flags = DWDESC_CAPS|DWDESC_SURFACE_CAPS|DWDESC_PIXELFORMAT|DWDESC_HEIGHT|DWDESC_WIDTH|DWDESC_POSX|DWDESC_POSY; diff --git a/src/scripttools/debugging/qscriptdebuggerbackend.cpp b/src/scripttools/debugging/qscriptdebuggerbackend.cpp index 2efff04..feaea63 100644 --- a/src/scripttools/debugging/qscriptdebuggerbackend.cpp +++ b/src/scripttools/debugging/qscriptdebuggerbackend.cpp @@ -805,13 +805,7 @@ int QScriptDebuggerBackend::contextCount() const { if (!engine()) return 0; - int count = 0; - QScriptContext *ctx = engine()->currentContext(); - while (ctx) { - ++count; - ctx = ctx->parentContext(); - } - return count; + return contextIds().count(); } /*! diff --git a/tests/auto/declarative/qfxloader/NoResize.qml b/tests/auto/declarative/qfxloader/NoResize.qml new file mode 100644 index 0000000..cfbb55a --- /dev/null +++ b/tests/auto/declarative/qfxloader/NoResize.qml @@ -0,0 +1,7 @@ +import Qt 4.6 + +Loader { + resizeMode: "NoResize" + width: 200; height: 80 + source: "Rect120x60.qml" +} diff --git a/tests/auto/declarative/qfxloader/Rect120x60.qml b/tests/auto/declarative/qfxloader/Rect120x60.qml new file mode 100644 index 0000000..aa4b0c2 --- /dev/null +++ b/tests/auto/declarative/qfxloader/Rect120x60.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +Rectangle { + width: 120 + height:60 +} diff --git a/tests/auto/declarative/qfxloader/SetSourceComponent.qml b/tests/auto/declarative/qfxloader/SetSourceComponent.qml new file mode 100644 index 0000000..c5dd7ff --- /dev/null +++ b/tests/auto/declarative/qfxloader/SetSourceComponent.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +Item { + Component { id: Comp; Rectangle { width: 120; height: 60 } } + Loader { sourceComponent: Comp } +} diff --git a/tests/auto/declarative/qfxloader/SizeToItem.qml b/tests/auto/declarative/qfxloader/SizeToItem.qml new file mode 100644 index 0000000..b52fa03 --- /dev/null +++ b/tests/auto/declarative/qfxloader/SizeToItem.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +Loader { + resizeMode: "SizeLoaderToItem" + source: "Rect120x60.qml" +} diff --git a/tests/auto/declarative/qfxloader/SizeToLoader.qml b/tests/auto/declarative/qfxloader/SizeToLoader.qml new file mode 100644 index 0000000..1a107e1 --- /dev/null +++ b/tests/auto/declarative/qfxloader/SizeToLoader.qml @@ -0,0 +1,7 @@ +import Qt 4.6 + +Loader { + resizeMode: "SizeItemToLoader" + width: 200; height: 80 + source: "Rect120x60.qml" +} diff --git a/tests/auto/declarative/qfxloader/qfxloader.pro b/tests/auto/declarative/qfxloader/qfxloader.pro new file mode 100644 index 0000000..643c18c --- /dev/null +++ b/tests/auto/declarative/qfxloader/qfxloader.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui +SOURCES += tst_qfxloader.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qfxloader/tst_qfxloader.cpp b/tests/auto/declarative/qfxloader/tst_qfxloader.cpp new file mode 100644 index 0000000..2109898 --- /dev/null +++ b/tests/auto/declarative/qfxloader/tst_qfxloader.cpp @@ -0,0 +1,103 @@ +#include <qtest.h> +#include <QtDeclarative/qmlengine.h> +#include <QtDeclarative/qmlcomponent.h> +#include <QtDeclarative/qfxloader.h> + +class tst_qfxloader : public QObject + +{ + Q_OBJECT +public: + tst_qfxloader(); + +private slots: + void url(); + void component(); + void sizeLoaderToItem(); + void sizeItemToLoader(); + void noResize(); + +private: + QmlEngine engine; +}; + +/* +inline QUrl TEST_FILE(const QString &filename) +{ + QFileInfo fileInfo(__FILE__); + return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(filename)); +} + +inline QUrl TEST_FILE(const char *filename) +{ + return TEST_FILE(QLatin1String(filename)); +} +*/ + +tst_qfxloader::tst_qfxloader() +{ +} + +void tst_qfxloader::url() +{ + QmlComponent component(&engine, QByteArray("import Qt 4.6\nLoader { source: \"Rect120x60.qml\" }"), QUrl("file://" SRCDIR "/")); + QFxLoader *loader = qobject_cast<QFxLoader*>(component.create()); + QVERIFY(loader != 0); + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); +} + +void tst_qfxloader::component() +{ + QmlComponent component(&engine, QUrl("file://" SRCDIR "/SetSourceComponent.qml")); + QFxItem *item = qobject_cast<QFxItem*>(component.create()); + QVERIFY(item); + + QFxLoader *loader = qobject_cast<QFxLoader*>(item->QGraphicsObject::children().at(1)); + QVERIFY(loader); + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); +} + +void tst_qfxloader::sizeLoaderToItem() +{ + QmlComponent component(&engine, QUrl("file://" SRCDIR "/SizeToItem.qml")); + QFxLoader *loader = qobject_cast<QFxLoader*>(component.create()); + QVERIFY(loader != 0); + QCOMPARE(loader->width(), 120.0); + QCOMPARE(loader->height(), 60.0); +} + +void tst_qfxloader::sizeItemToLoader() +{ + QmlComponent component(&engine, QUrl("file://" SRCDIR "/SizeToLoader.qml")); + QFxLoader *loader = qobject_cast<QFxLoader*>(component.create()); + QVERIFY(loader != 0); + QCOMPARE(loader->width(), 200.0); + QCOMPARE(loader->height(), 80.0); + + QFxItem *rect = loader->item(); + QVERIFY(rect); + QCOMPARE(rect->width(), 200.0); + QCOMPARE(rect->height(), 80.0); +} + +void tst_qfxloader::noResize() +{ + QmlComponent component(&engine, QUrl("file://" SRCDIR "/NoResize.qml")); + QFxLoader *loader = qobject_cast<QFxLoader*>(component.create()); + QVERIFY(loader != 0); + QCOMPARE(loader->width(), 200.0); + QCOMPARE(loader->height(), 80.0); + + QFxItem *rect = loader->item(); + QVERIFY(rect); + QCOMPARE(rect->width(), 120.0); + QCOMPARE(rect->height(), 60.0); +} + +QTEST_MAIN(tst_qfxloader) + +#include "tst_qfxloader.moc" diff --git a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp index 075fa01..46d5b9d 100644 --- a/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp +++ b/tests/auto/exceptionsafety_objects/tst_exceptionsafety_objects.cpp @@ -462,22 +462,62 @@ struct Integer int Integer::instanceCount = 0; -template <template<typename T> class Container> +struct IntegerMoveable + { + IntegerMoveable(int value = 42) + : val(value) + { + delete new int; + ++instanceCount; + } + + IntegerMoveable(const IntegerMoveable &other) + : val(other.val) + { + delete new int; + ++instanceCount; + } + + IntegerMoveable &operator=(const IntegerMoveable &other) + { + delete new int; + val = other.val; + return *this; + } + + ~IntegerMoveable() + { + --instanceCount; + } + + int value() const + { + return val; + } + + int val; + static int instanceCount; + }; + +int IntegerMoveable::instanceCount = 0; +Q_DECLARE_TYPEINFO(IntegerMoveable, Q_MOVABLE_TYPE); + +template <typename T, template<typename> class Container > void containerInsertTest(QObject*) { - Container<Integer> container; + Container<T> container; // insert an item in an empty container try { container.insert(container.begin(), 41); } catch (...) { QVERIFY(container.isEmpty()); - QCOMPARE(Integer::instanceCount, 0); + QCOMPARE(T::instanceCount, 0); return; } QCOMPARE(container.size(), 1); - QCOMPARE(Integer::instanceCount, 1); + QCOMPARE(T::instanceCount, 1); // insert an item before another item try { @@ -485,11 +525,11 @@ void containerInsertTest(QObject*) } catch (...) { QCOMPARE(container.size(), 1); QCOMPARE(container.first().value(), 41); - QCOMPARE(Integer::instanceCount, 1); + QCOMPARE(T::instanceCount, 1); return; } - QCOMPARE(Integer::instanceCount, 2); + QCOMPARE(T::instanceCount, 2); // insert an item in between try { @@ -498,24 +538,24 @@ void containerInsertTest(QObject*) QCOMPARE(container.size(), 2); QCOMPARE(container.first().value(), 41); QCOMPARE((container.begin() + 1)->value(), 42); - QCOMPARE(Integer::instanceCount, 2); + QCOMPARE(T::instanceCount, 2); return; } - QCOMPARE(Integer::instanceCount, 3); + QCOMPARE(T::instanceCount, 3); } -template <template<typename T> class Container> +template <typename T, template<typename> class Container> void containerAppendTest(QObject*) { - Container<Integer> container; + Container<T> container; // append to an empty container try { container.append(42); } catch (...) { QCOMPARE(container.size(), 0); - QCOMPARE(Integer::instanceCount, 0); + QCOMPARE(T::instanceCount, 0); return; } @@ -525,15 +565,38 @@ void containerAppendTest(QObject*) } catch (...) { QCOMPARE(container.size(), 1); QCOMPARE(container.first().value(), 42); - QCOMPARE(Integer::instanceCount, 1); + QCOMPARE(T::instanceCount, 1); return; } + + Container<T> container2; + + try { + container2.append(44); + } catch (...) { + // don't care + return; + } + QCOMPARE(T::instanceCount, 3); + + // append another container with one item + try { + container += container2; + } catch (...) { + QCOMPARE(container.size(), 2); + QCOMPARE(container.first().value(), 42); + QCOMPARE((container.begin() + 1)->value(), 43); + QCOMPARE(T::instanceCount, 3); + return; + } + + QCOMPARE(T::instanceCount, 4); } -template <template<typename T> class Container> +template <typename T, template<typename> class Container> void containerEraseTest(QObject*) { - Container<Integer> container; + Container<T> container; try { container.append(42); @@ -548,7 +611,7 @@ void containerEraseTest(QObject*) // sanity checks QCOMPARE(container.size(), 5); - QCOMPARE(Integer::instanceCount, 5); + QCOMPARE(T::instanceCount, 5); // delete the first one try { @@ -556,20 +619,20 @@ void containerEraseTest(QObject*) } catch (...) { QCOMPARE(container.size(), 5); QCOMPARE(container.first().value(), 42); - QCOMPARE(Integer::instanceCount, 5); + QCOMPARE(T::instanceCount, 5); return; } QCOMPARE(container.size(), 4); QCOMPARE(container.first().value(), 43); - QCOMPARE(Integer::instanceCount, 4); + QCOMPARE(T::instanceCount, 4); // delete the last one try { container.erase(container.end() - 1); } catch (...) { QCOMPARE(container.size(), 4); - QCOMPARE(Integer::instanceCount, 4); + QCOMPARE(T::instanceCount, 4); return; } @@ -577,7 +640,7 @@ void containerEraseTest(QObject*) QCOMPARE(container.first().value(), 43); QCOMPARE((container.begin() + 1)->value(), 44); QCOMPARE((container.begin() + 2)->value(), 45); - QCOMPARE(Integer::instanceCount, 3); + QCOMPARE(T::instanceCount, 3); // delete the middle one try { @@ -587,14 +650,14 @@ void containerEraseTest(QObject*) QCOMPARE(container.first().value(), 43); QCOMPARE((container.begin() + 1)->value(), 44); QCOMPARE((container.begin() + 2)->value(), 45); - QCOMPARE(Integer::instanceCount, 3); + QCOMPARE(T::instanceCount, 3); return; } QCOMPARE(container.size(), 2); QCOMPARE(container.first().value(), 43); QCOMPARE((container.begin() + 1)->value(), 45); - QCOMPARE(Integer::instanceCount, 2); + QCOMPARE(T::instanceCount, 2); } template <template<typename T> class Container> @@ -602,9 +665,12 @@ static void containerData() { QTest::addColumn<TestFunction>("testFunction"); - QTest::newRow("insert") << static_cast<TestFunction>(containerInsertTest<Container>); - QTest::newRow("append") << static_cast<TestFunction>(containerAppendTest<Container>); - QTest::newRow("erase") << static_cast<TestFunction>(containerEraseTest<Container>); + QTest::newRow("insert static") << static_cast<TestFunction>(containerInsertTest<Integer, Container>); + QTest::newRow("append static") << static_cast<TestFunction>(containerAppendTest<Integer, Container>); + QTest::newRow("erase static") << static_cast<TestFunction>(containerEraseTest<Integer, Container>); + QTest::newRow("insert moveable") << static_cast<TestFunction>(containerInsertTest<IntegerMoveable, Container>); + QTest::newRow("append moveable") << static_cast<TestFunction>(containerAppendTest<IntegerMoveable, Container>); + QTest::newRow("erase moveable") << static_cast<TestFunction>(containerEraseTest<IntegerMoveable, Container>); } void tst_ExceptionSafetyObjects::vector_data() @@ -616,7 +682,8 @@ void tst_ExceptionSafetyObjects::vector() { QFETCH(TestFunction, testFunction); - if (QLatin1String(QTest::currentDataTag()) == QLatin1String("insert")) + if (QLatin1String(QTest::currentDataTag()) == QLatin1String("insert static") + || QLatin1String(QTest::currentDataTag()) == QLatin1String("insert moveable")) QSKIP("QVector::insert is currently not strongly exception safe", SkipSingle); doOOMTest(testFunction, 0); diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index 144f7b3..a770f8e 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -328,3 +328,19 @@ QByteArray QtNetworkSettings::imapExpectedReplySsl; #else #define Q_SET_DEFAULT_IAP #endif + +#ifdef QT_NETWORK_LIB +class QtNetworkSettingsInitializerCode { +public: + QtNetworkSettingsInitializerCode() { + QHostInfo testServerResult = QHostInfo::fromName(QtNetworkSettings::serverName()); + if (testServerResult.error() != QHostInfo::NoError) { + qWarning() << "Could not lookup" << QtNetworkSettings::serverName(); + qWarning() << "Please configure the test environment!"; + qWarning() << "See /etc/hosts or network-settings.h"; + qFatal("Exiting"); + } + } +}; +QtNetworkSettingsInitializerCode qtNetworkSettingsInitializer; +#endif diff --git a/tests/auto/qabstractbutton/tst_qabstractbutton.cpp b/tests/auto/qabstractbutton/tst_qabstractbutton.cpp index de2d9f4..7ee52ad 100644 --- a/tests/auto/qabstractbutton/tst_qabstractbutton.cpp +++ b/tests/auto/qabstractbutton/tst_qabstractbutton.cpp @@ -550,6 +550,7 @@ void tst_QAbstractButton::setShortcut() { QKeySequence seq( Qt::Key_A ); testWidget->setShortcut( seq ); + QApplication::setActiveWindow(testWidget); // must be active to get shortcuts for (int i = 0; !testWidget->isActiveWindow() && i < 100; ++i) { @@ -557,8 +558,8 @@ void tst_QAbstractButton::setShortcut() QApplication::instance()->processEvents(); QTest::qWait(100); } - QVERIFY(testWidget->isActiveWindow()); - + QVERIFY(testWidget->isActiveWindow()); + QTest::keyClick( testWidget, 'A' ); QTest::qWait(300); // Animate click takes time QCOMPARE(click_count, (uint)1); diff --git a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp index f49568d..82969b9 100644 --- a/tests/auto/qbuttongroup/tst_qbuttongroup.cpp +++ b/tests/auto/qbuttongroup/tst_qbuttongroup.cpp @@ -100,7 +100,7 @@ private slots: #if QT_VERSION >= 0x040600 void autoIncrementId(); #endif - + void task209485_removeFromGroupInEventHandler_data(); void task209485_removeFromGroupInEventHandler(); }; @@ -333,12 +333,12 @@ void tst_QButtonGroup::testSignals() QCOMPARE(clickedSpy.count(), 1); QCOMPARE(clickedIdSpy.count(), 1); - - int expectedId = -1; + + int expectedId = -1; #if QT_VERSION >= 0x040600 expectedId = -2; #endif - + QVERIFY(clickedIdSpy.takeFirst().at(0).toInt() == expectedId); QCOMPARE(pressedSpy.count(), 1); QCOMPARE(pressedIdSpy.count(), 1); diff --git a/tests/auto/qbytearray/qbytearray.pro b/tests/auto/qbytearray/qbytearray.pro index d14534b..a0c143e 100644 --- a/tests/auto/qbytearray/qbytearray.pro +++ b/tests/auto/qbytearray/qbytearray.pro @@ -4,16 +4,17 @@ SOURCES += tst_qbytearray.cpp QT = core -wince*|symbian: { +wince*|symbian { addFile.sources = rfc3252.txt addFile.path = . DEPLOYMENT += addFile } -wince: { - DEFINES += SRCDIR=\\\"\\\" -} symbian: { +wince* { + DEFINES += SRCDIR=\\\"./\\\" +} else:symbian { TARGET.EPOCHEAPSIZE="0x100 0x800000" } else { - DEFINES += SRCDIR=\\\"$$PWD/\\\" + DEFINES += SRCDIR=\\\"$$PWD/\\\" } + diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp index 928d826..7eefb26 100644 --- a/tests/auto/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/qcompleter/tst_qcompleter.cpp @@ -1025,6 +1025,7 @@ void tst_QCompleter::multipleWidgets() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&window); #endif + QApplication::setActiveWindow(&window); QTest::qWait(50); QTRY_VERIFY(qApp->focusWidget() == comboBox); comboBox->lineEdit()->setText("it"); @@ -1058,6 +1059,7 @@ void tst_QCompleter::focusIn() window.show(); QTest::qWait(100); window.activateWindow(); + QApplication::setActiveWindow(&window); QTest::qWait(100); QTRY_COMPARE(qApp->activeWindow(), &window); @@ -1322,8 +1324,10 @@ void tst_QCompleter::task253125_lineEditCompletion() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&edit); #endif + QTest::qWait(10); + QApplication::setActiveWindow(&edit); + QTRY_COMPARE(QApplication::activeWindow(), &edit); - QTest::qWait(100); QTest::keyClick(&edit, 'i'); QCOMPARE(edit.completer()->currentCompletion(), QString("iota")); QTest::keyClick(edit.completer()->popup(), Qt::Key_Down); @@ -1358,7 +1362,9 @@ void tst_QCompleter::task247560_keyboardNavigation() qt_x11_wait_for_window_manager(&edit); #endif - QTest::qWait(100); + QTest::qWait(10); + QApplication::setActiveWindow(&edit); + QTRY_COMPARE(QApplication::activeWindow(), &edit); QTest::keyClick(&edit, 'r'); QTest::keyClick(edit.completer()->popup(), Qt::Key_Down); diff --git a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp index 6162be0..aa3ccb7 100644 --- a/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp +++ b/tests/auto/qdoublespinbox/tst_qdoublespinbox.cpp @@ -52,6 +52,9 @@ #include <qlineedit.h> #include <qdebug.h> + +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES=gui/widgets/qspinbox.h gui/widgets/qspinbox.cpp gui/widgets/qabstractspinbox.cpp gui/widgets/qabstractspinbox_p.h gui/widgets/qabstractspinbox.h @@ -772,8 +775,8 @@ void tst_QDoubleSpinBox::editingFinished() layout->addWidget(box2); testFocusWidget->show(); - QTest::qWait(100); - QVERIFY(box->isActiveWindow()); + QTest::qWait(10); + QTRY_VERIFY(box->isActiveWindow()); box->setFocus(); QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished())); diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index d951a86..076934c 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -411,6 +411,10 @@ void tst_QFileInfo::absolutePath_data() QString drivePrefix; #if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN) drivePrefix = QDir::currentPath().left(2); + + // Make sure drive-relative paths return correct absolute paths (task 255326) + QTest::newRow("c:my.dll") << "c:my.dll" << QDir::currentPath() << "my.dll"; + QTest::newRow("x:my.dll") << "x:my.dll" << "X:/" << "my.dll"; #endif QTest::newRow("0") << "/machine/share/dir1/" << drivePrefix + "/machine/share/dir1" << ""; QTest::newRow("1") << "/machine/share/dir1" << drivePrefix + "/machine/share" << "dir1"; @@ -449,6 +453,10 @@ void tst_QFileInfo::absFilePath_data() curr.remove(0, 2); // Make it a absolute path with no drive specifier: \depot\qt-4.2\tests\auto\qfileinfo QTest::newRow(".") << curr << QDir::currentPath(); QTest::newRow("absFilePath") << "c:\\home\\andy\\tmp.txt" << "C:/home/andy/tmp.txt"; + + // Make sure drive-relative paths return correct absolute paths (task 255326) + QTest::newRow("c:my.dll") << "c:temp/my.dll" << QDir::currentPath() + "/temp/my.dll"; + QTest::newRow("x:my.dll") << "x:temp/my.dll" << "X:/temp/my.dll"; #else QTest::newRow("absFilePath") << "/home/andy/tmp.txt" << "/home/andy/tmp.txt"; #endif @@ -1052,19 +1060,19 @@ void tst_QFileInfo::isHidden_data() QFile file(hiddenFileName); if (file.open(QIODevice::WriteOnly)) { QTextStream t(&file); - t << "foobar"; + t << "foobar"; } else { qWarning("Failed to create hidden file"); } QFile file2(notHiddenFileName); if (file2.open(QIODevice::WriteOnly)) { QTextStream t(&file); - t << "foobar"; + t << "foobar"; } else { qWarning("Failed to create non-hidden file"); } } - + RFs rfs; TInt err = rfs.Connect(); if (err == KErrNone) { diff --git a/tests/auto/qfocusevent/tst_qfocusevent.cpp b/tests/auto/qfocusevent/tst_qfocusevent.cpp index 662f115..5ad78de 100644 --- a/tests/auto/qfocusevent/tst_qfocusevent.cpp +++ b/tests/auto/qfocusevent/tst_qfocusevent.cpp @@ -56,6 +56,8 @@ #include <qlineedit.h> #include <QBoxLayout> +#include "../../shared/util.h" + QT_FORWARD_DECLARE_CLASS(QWidget) //TESTED_CLASS= @@ -168,6 +170,7 @@ void tst_QFocusEvent::initWidget() { // On X11 we have to ensure the event was processed before doing any checking, on Windows // this is processed straight away. + QApplication::setActiveWindow(childFocusWidgetOne); for (int i = 0; i < 1000; ++i) { if (childFocusWidgetOne->isActiveWindow() && childFocusWidgetOne->hasFocus()) @@ -243,9 +246,9 @@ void tst_QFocusEvent::checkReason_BackTab() // Now test the backtab key QTest::keyClick( childFocusWidgetOne, Qt::Key_Backtab ); - QTest::qWait(2000); + QTest::qWait(200); - QVERIFY(childFocusWidgetOne->focusOutEventRecieved); + QTRY_VERIFY(childFocusWidgetOne->focusOutEventRecieved); QVERIFY(childFocusWidgetTwo->focusInEventRecieved); QVERIFY(childFocusWidgetOne->focusOutEventLostFocus); QVERIFY(childFocusWidgetTwo->focusInEventGotFocus); @@ -265,9 +268,9 @@ void tst_QFocusEvent::checkReason_Popup() Q3PopupMenu* popupMenu = new Q3PopupMenu( testFocusWidget ); popupMenu->insertItem( "Test" ); popupMenu->popup( QPoint(0,0) ); - QTest::qWait(500); + QTest::qWait(50); - QVERIFY(childFocusWidgetOne->focusOutEventLostFocus); + QTRY_VERIFY(childFocusWidgetOne->focusOutEventLostFocus); QVERIFY( childFocusWidgetOne->hasFocus() ); QVERIFY( !childFocusWidgetOne->focusInEventRecieved ); @@ -290,11 +293,11 @@ void tst_QFocusEvent::checkReason_Popup() QMenu* popupMenu = new QMenu( testFocusWidget ); popupMenu->addMenu( "Test" ); popupMenu->popup( QPoint(0,0) ); - QTest::qWait(500); + QTest::qWait(50); - QVERIFY(childFocusWidgetOne->focusOutEventLostFocus); + QTRY_VERIFY(childFocusWidgetOne->focusOutEventLostFocus); - QVERIFY( childFocusWidgetOne->hasFocus() ); + QTRY_VERIFY( childFocusWidgetOne->hasFocus() ); QVERIFY( !childFocusWidgetOne->focusInEventRecieved ); QVERIFY( childFocusWidgetOne->focusOutEventRecieved ); QVERIFY( !childFocusWidgetTwo->focusInEventRecieved ); @@ -368,13 +371,13 @@ void tst_QFocusEvent::checkReason_focusWidget() QLineEdit edit1; QLineEdit edit2; - QVBoxLayout outerLayout; + QVBoxLayout outerLayout; outerLayout.addWidget(&frame1); outerLayout.addWidget(&frame2); window1.setLayout(&outerLayout); - - QVBoxLayout leftLayout; - QVBoxLayout rightLayout; + + QVBoxLayout leftLayout; + QVBoxLayout rightLayout; leftLayout.addWidget(&edit1); rightLayout.addWidget(&edit2); frame1.setLayout(&leftLayout); diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 650c1ca..43f4227 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -1432,6 +1432,55 @@ void tst_QGL::fboFormat() QVERIFY(format1.attachment() == QGLFramebufferObject::CombinedDepthStencil); QCOMPARE(int(format1.textureTarget()), int(GL_TEXTURE_3D)); QCOMPARE(int(format1.internalTextureFormat()), int(GL_RGB16)); + + // operator== and operator!= for QGLFramebufferObjectFormat. + QGLFramebufferObjectFormat format1c; + QGLFramebufferObjectFormat format2c; + + QVERIFY(format1c == format2c); + QVERIFY(!(format1c != format2c)); + format1c.setSamples(8); + QVERIFY(!(format1c == format2c)); + QVERIFY(format1c != format2c); + format2c.setSamples(8); + QVERIFY(format1c == format2c); + QVERIFY(!(format1c != format2c)); + + format1c.setAttachment(QGLFramebufferObject::CombinedDepthStencil); + QVERIFY(!(format1c == format2c)); + QVERIFY(format1c != format2c); + format2c.setAttachment(QGLFramebufferObject::CombinedDepthStencil); + QVERIFY(format1c == format2c); + QVERIFY(!(format1c != format2c)); + + format1c.setTextureTarget(GL_TEXTURE_3D); + QVERIFY(!(format1c == format2c)); + QVERIFY(format1c != format2c); + format2c.setTextureTarget(GL_TEXTURE_3D); + QVERIFY(format1c == format2c); + QVERIFY(!(format1c != format2c)); + + format1c.setInternalTextureFormat(GL_RGB16); + QVERIFY(!(format1c == format2c)); + QVERIFY(format1c != format2c); + format2c.setInternalTextureFormat(GL_RGB16); + QVERIFY(format1c == format2c); + QVERIFY(!(format1c != format2c)); + + QGLFramebufferObjectFormat format3c(format1c); + QGLFramebufferObjectFormat format4c; + QVERIFY(format1c == format3c); + QVERIFY(!(format1c != format3c)); + format3c.setInternalTextureFormat(DEFAULT_FORMAT); + QVERIFY(!(format1c == format3c)); + QVERIFY(format1c != format3c); + + format4c = format1c; + QVERIFY(format1c == format4c); + QVERIFY(!(format1c != format4c)); + format4c.setInternalTextureFormat(DEFAULT_FORMAT); + QVERIFY(!(format1c == format4c)); + QVERIFY(format1c != format4c); } QTEST_MAIN(tst_QGL) diff --git a/tests/auto/qgridlayout/tst_qgridlayout.cpp b/tests/auto/qgridlayout/tst_qgridlayout.cpp index 13d79b1..590bafa 100644 --- a/tests/auto/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/qgridlayout/tst_qgridlayout.cpp @@ -51,6 +51,8 @@ #include <QtGui/QWindowsStyle> #include <QStyleFactory> +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES=gui/kernel/qlayout.cpp gui/kernel/qlayout.h @@ -788,8 +790,8 @@ void tst_QGridLayout::minMaxSize_data() QTest::addColumn<QSize>("fixedSize"); //input and expected output QTest::addColumn<SizeInfoList>("sizeinfos"); - - QTest::newRow("3x1 grid, extend to minimumSize") << QString() << 3 << 1 + + QTest::newRow("3x1 grid, extend to minimumSize") << QString() << 3 << 1 << int(QSizePolicy::Minimum) << QSize(152, 50) << (SizeInfoList() << SizeInfo(QRect(10, 10, 43, 30), QSize( 75, 75), QSize(0,0)) << SizeInfo(QRect(10 + 45, 10, 43, 30), QSize(75, 75), QSize( 0, 0)) @@ -917,13 +919,14 @@ void tst_QGridLayout::minMaxSize() #if defined(Q_WS_X11) qt_x11_wait_for_window_manager(m_toplevel); // wait for the show #endif + QTest::qWait(20); m_toplevel->adjustSize(); - QTest::qWait(200); // wait for the implicit adjustSize + QTest::qWait(20); // wait for the implicit adjustSize // If the following fails we might have to wait longer. // If that does not help there is likely a problem with the implicit adjustSize in show() if (!fixedSize.isValid()) { // Note that this can fail if the desktop has large fonts on windows. - QCOMPARE(m_toplevel->size(), m_toplevel->sizeHint()); + QTRY_COMPARE(m_toplevel->size(), m_toplevel->sizeHint()); } // We are relying on the order here... for (int pi = 0; pi < sizehinters.count(); ++pi) { diff --git a/tests/auto/qgroupbox/tst_qgroupbox.cpp b/tests/auto/qgroupbox/tst_qgroupbox.cpp index 94b70e6..7346700 100644 --- a/tests/auto/qgroupbox/tst_qgroupbox.cpp +++ b/tests/auto/qgroupbox/tst_qgroupbox.cpp @@ -49,6 +49,8 @@ #include "qgroupbox.h" +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= @@ -81,7 +83,7 @@ private slots: void toggledVsClicked(); void childrenAreDisabled(); void propagateFocus(); - + private: bool checked; qint64 timeStamp; @@ -467,7 +469,7 @@ void tst_QGroupBox::propagateFocus() box.show(); box.setFocus(); QTest::qWait(250); - QCOMPARE(qApp->focusWidget(), static_cast<QWidget*>(&lineEdit)); + QTRY_COMPARE(qApp->focusWidget(), static_cast<QWidget*>(&lineEdit)); } QTEST_MAIN(tst_QGroupBox) diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp index 1ef77c0..9871da3 100644 --- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp @@ -63,6 +63,8 @@ #include <QPlainTextEdit> #include <QDialog> +#include "../../shared/util.h" + Q_DECLARE_METATYPE(QAbstractItemDelegate::EndEditHint) //TESTED_CLASS= @@ -862,6 +864,8 @@ void tst_QItemDelegate::decoration() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&table); #endif + QApplication::setActiveWindow(&table); + QTRY_COMPARE(QApplication::activeWindow(), &table); QVariant value; switch ((QVariant::Type)type) { @@ -1164,10 +1168,7 @@ void tst_QItemDelegate::task257859_finalizeEdit() QDialog dialog; QTimer::singleShot(100, &dialog, SLOT(close())); dialog.exec(); - - QTest::qWait(100); - - QVERIFY(!editor); + QTRY_VERIFY(!editor); } diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index 6bbdf5d..47f0730 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -343,6 +343,7 @@ void tst_QLineEdit::initTestCase() // to be safe and avoid failing setFocus with window managers qt_x11_wait_for_window_manager(testWidget); #endif + QTRY_VERIFY(testWidget->hasFocus()); changed_count = 0; edited_count = 0; @@ -1601,8 +1602,7 @@ void tst_QLineEdit::passwordEchoOnEdit() testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit); testWidget->setFocus(); testWidget->raise(); - QTest::qWait(250); - QVERIFY(testWidget->hasFocus()); + QTRY_VERIFY(testWidget->hasFocus()); QTest::keyPress(testWidget, '0'); QTest::keyPress(testWidget, '1'); @@ -1614,6 +1614,7 @@ void tst_QLineEdit::passwordEchoOnEdit() QVERIFY(!testWidget->hasFocus()); QCOMPARE(testWidget->displayText(), QString(5, fillChar)); testWidget->setFocus(); + QTRY_VERIFY(testWidget->hasFocus()); QCOMPARE(testWidget->displayText(), QString(5, fillChar)); QTest::keyPress(testWidget, '0'); @@ -3397,7 +3398,7 @@ void tst_QLineEdit::task210502_caseInsensitiveInlineCompletion() qt_x11_wait_for_window_manager(&lineEdit); #endif lineEdit.setFocus(); - QTest::qWait(200); + QTRY_VERIFY(lineEdit.hasFocus()); QTest::keyPress(&lineEdit, 'a'); QTest::keyPress(&lineEdit, Qt::Key_Return); QCOMPARE(lineEdit.text(), completion); @@ -3491,7 +3492,7 @@ void tst_QLineEdit::task241436_passwordEchoOnEditRestoreEchoMode() testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit); testWidget->setFocus(); - QTest::qWait(250); + QTRY_VERIFY(testWidget->hasFocus()); QTest::keyPress(testWidget, '0'); QCOMPARE(testWidget->displayText(), QString("0")); diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 2be1a03..2831747 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -113,6 +113,7 @@ private slots: void task254449_draggingItemToNegativeCoordinates(); void keyboardSearch(); void shiftSelectionWithNonUniformItemSizes(); + void clickOnViewportClearsSelection(); }; // Testing get/set functions @@ -1733,5 +1734,34 @@ void tst_QListView::shiftSelectionWithNonUniformItemSizes() } } +void tst_QListView::clickOnViewportClearsSelection() +{ + QStringList items; + items << "Text1"; + QStringListModel model(items); + QListView view; + view.setModel(&model); + view.setSelectionMode(QListView::ExtendedSelection); + + view.selectAll(); + QModelIndex index = model.index(0); + QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1); + QVERIFY(view.selectionModel()->isSelected(index)); + + //we try to click outside of the index + const QPoint point = view.visualRect(index).bottomRight() + QPoint(10,10); + + QTest::mousePress(view.viewport(), Qt::LeftButton, 0, point); + //at this point, the selection shouldn't have changed + QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1); + QVERIFY(view.selectionModel()->isSelected(index)); + + QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, point); + //now the selection should be cleared + QVERIFY(!view.selectionModel()->hasSelection()); + +} + + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" diff --git a/tests/auto/qmdiarea/tst_qmdiarea.cpp b/tests/auto/qmdiarea/tst_qmdiarea.cpp index 65dab48..246410d 100644 --- a/tests/auto/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/qmdiarea/tst_qmdiarea.cpp @@ -62,6 +62,8 @@ #endif #include <QMacStyle> +#include "../../shared/util.h" + static const Qt::WindowFlags DefaultWindowFlags = Qt::SubWindow | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint; @@ -467,7 +469,7 @@ void tst_QMdiArea::subWindowActivated2() qt_x11_wait_for_window_manager(&mdiArea); #endif - QCOMPARE(spy.count(), 5); + QTRY_COMPARE(spy.count(), 5); QCOMPARE(mdiArea.activeSubWindow(), mdiArea.subWindowList().back()); spy.clear(); @@ -493,7 +495,7 @@ void tst_QMdiArea::subWindowActivated2() qt_x11_wait_for_window_manager(&mdiArea); #endif QTest::qWait(100); - QCOMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 1); QVERIFY(!mdiArea.activeSubWindow()); QCOMPARE(mdiArea.currentSubWindow(), activeSubWindow); spy.clear(); @@ -503,7 +505,7 @@ void tst_QMdiArea::subWindowActivated2() qt_x11_wait_for_window_manager(&mdiArea); #endif QTest::qWait(100); - QCOMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 1); QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow); spy.clear(); @@ -516,14 +518,14 @@ void tst_QMdiArea::subWindowActivated2() if (!macHasAccessToWindowsServer()) QEXPECT_FAIL("", "showMinimized doesn't really minimize if you don't have access to the server", Abort); #endif - QTest::qWait(100); + QTest::qWait(10); #if defined(Q_WS_QWS) QEXPECT_FAIL("", "task 168682", Abort); #endif #ifdef Q_OS_WINCE QSKIP("Not fixed yet. See Task 197453", SkipAll); #endif - QCOMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 1); QVERIFY(!mdiArea.activeSubWindow()); QCOMPARE(mdiArea.currentSubWindow(), activeSubWindow); spy.clear(); @@ -533,7 +535,7 @@ void tst_QMdiArea::subWindowActivated2() qt_x11_wait_for_window_manager(&mdiArea); #endif QTest::qWait(100); - QCOMPARE(spy.count(), 1); + QTRY_COMPARE(spy.count(), 1); QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow); spy.clear(); } @@ -1734,6 +1736,7 @@ void tst_QMdiArea::tileSubWindows() qt_x11_wait_for_window_manager(&workspace); #endif qApp->processEvents(); + QTRY_COMPARE(workspace.size(), QSize(350, 150)); const QSize minSize(300, 100); foreach (QMdiSubWindow *subWindow, workspace.subWindowList()) @@ -1885,7 +1888,7 @@ void tst_QMdiArea::resizeMaximizedChildWindows() workspace.resize(workspaceSize + QSize(increment, increment)); QTest::qWait(100); qApp->processEvents(); - QCOMPARE(workspace.size(), workspaceSize + QSize(increment, increment)); + QTRY_COMPARE(workspace.size(), workspaceSize + QSize(increment, increment)); QCOMPARE(window->size(), windowSize + QSize(increment, increment)); workspaceSize = workspace.size(); } diff --git a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp index 78ba46b..4d5160b 100644 --- a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp @@ -63,6 +63,9 @@ #include <QMacStyle> #endif +#include "../../shared/util.h" + + QT_BEGIN_NAMESPACE #if defined(Q_WS_X11) extern void qt_x11_wait_for_window_manager(QWidget *w); @@ -1004,15 +1007,16 @@ void tst_QMdiSubWindow::setSystemMenu() qt_x11_wait_for_window_manager(&mainWindow); #endif - QVERIFY(subWindow->isVisible()); - QPoint globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topLeft()); + QTRY_VERIFY(subWindow->isVisible()); + QPoint globalPopupPos; // Show system menu QVERIFY(!qApp->activePopupWidget()); subWindow->showSystemMenu(); - QTest::qWait(250); - QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); - QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); + QTest::qWait(25); + QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); + QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), + (globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topLeft())) ); systemMenu->hide(); QVERIFY(!qApp->activePopupWidget()); @@ -1034,9 +1038,9 @@ void tst_QMdiSubWindow::setSystemMenu() // Show the new system menu QVERIFY(!qApp->activePopupWidget()); subWindow->showSystemMenu(); - QTest::qWait(250); - QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); - QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); + QTest::qWait(25); + QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); + QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); systemMenu->hide(); QVERIFY(!qApp->activePopupWidget()); @@ -1048,12 +1052,12 @@ void tst_QMdiSubWindow::setSystemMenu() QWidget *menuLabel = subWindow->maximizedSystemMenuIconWidget(); QVERIFY(menuLabel); subWindow->showSystemMenu(); - QTest::qWait(250); - QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); - globalPopupPos = menuLabel->mapToGlobal(QPoint(0, menuLabel->y() + menuLabel->height())); - QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); + QTest::qWait(25); + QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); + QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), + (globalPopupPos = menuLabel->mapToGlobal(QPoint(0, menuLabel->y() + menuLabel->height())))); systemMenu->hide(); - QVERIFY(!qApp->activePopupWidget()); + QTRY_VERIFY(!qApp->activePopupWidget()); subWindow->showNormal(); #endif @@ -1064,11 +1068,11 @@ void tst_QMdiSubWindow::setSystemMenu() subWindow->showSystemMenu(); QTest::qWait(250); - QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); + QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); // + QPoint(1, 0) because topRight() == QPoint(left() + width() -1, top()) globalPopupPos = subWindow->mapToGlobal(subWindow->contentsRect().topRight()) + QPoint(1, 0); globalPopupPos -= QPoint(systemMenu->sizeHint().width(), 0); - QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); + QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); systemMenu->hide(); QVERIFY(!qApp->activePopupWidget()); @@ -1081,10 +1085,10 @@ void tst_QMdiSubWindow::setSystemMenu() QVERIFY(menuLabel); subWindow->showSystemMenu(); QTest::qWait(250); - QCOMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); + QTRY_COMPARE(qApp->activePopupWidget(), qobject_cast<QWidget *>(systemMenu)); globalPopupPos = menuLabel->mapToGlobal(QPoint(menuLabel->width(), menuLabel->y() + menuLabel->height())); globalPopupPos -= QPoint(systemMenu->sizeHint().width(), 0); - QCOMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); + QTRY_COMPARE(systemMenu->mapToGlobal(QPoint(0, 0)), globalPopupPos); #endif delete systemMenu; @@ -1902,7 +1906,7 @@ void tst_QMdiSubWindow::task_182852() mainWindow.show(); mainWindow.menuBar()->setVisible(true); qApp->setActiveWindow(&mainWindow); - + QString originalWindowTitle = QString::fromLatin1("MainWindow - [foo]"); mainWindow.setWindowTitle(originalWindowTitle); @@ -1917,7 +1921,7 @@ void tst_QMdiSubWindow::task_182852() window->showMaximized(); qApp->processEvents(); QVERIFY(window->isMaximized()); - + QCOMPARE(mainWindow.windowTitle(), QString::fromLatin1("%1 - [%2]") .arg(originalWindowTitle, window->widget()->windowTitle())); diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index ab8dd48..4a4231a 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -55,6 +55,9 @@ #include <qmenu.h> #include <qstyle.h> #include <qdebug.h> + +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= @@ -437,15 +440,16 @@ void tst_QMenu::overrideMenuAction() m->addAction(aQuit); w.show(); - QTest::qWait(200); + w.setFocus(); + QTRY_VERIFY(w.hasFocus()); //test of the action inside the menu QTest::keyClick(&w, Qt::Key_X, Qt::ControlModifier); - QCOMPARE(activated, aQuit); + QTRY_COMPARE(activated, aQuit); //test if the menu still pops out QTest::keyClick(&w, Qt::Key_F, Qt::AltModifier); - QVERIFY(m->isVisible()); + QTRY_VERIFY(m->isVisible()); delete aFileMenu; @@ -703,12 +707,12 @@ void tst_QMenu::task250673_activeMultiColumnSubMenuPosition() }; QMenu sub; - + if (sub.style()->styleHint(QStyle::SH_Menu_Scrollable, 0, &sub)) { //the style prevents the menus from getting columns QSKIP("the style doesn't support multiple columns, it makes the menu scrollable", SkipSingle); } - + sub.addAction("Sub-Item1"); QAction *subAction = sub.addAction("Sub-Item2"); diff --git a/tests/auto/qmultiscreen/qmultiscreen.pro b/tests/auto/qmultiscreen/qmultiscreen.pro index 4e92a65..30666d7 100644 --- a/tests/auto/qmultiscreen/qmultiscreen.pro +++ b/tests/auto/qmultiscreen/qmultiscreen.pro @@ -1,6 +1,5 @@ load(qttest_p4) SOURCES += tst_qmultiscreen.cpp -QT = core requires(embedded) diff --git a/tests/auto/qpushbutton/tst_qpushbutton.cpp b/tests/auto/qpushbutton/tst_qpushbutton.cpp index 5059578..2013258 100644 --- a/tests/auto/qpushbutton/tst_qpushbutton.cpp +++ b/tests/auto/qpushbutton/tst_qpushbutton.cpp @@ -54,6 +54,8 @@ #include <QStyleFactory> #include <QTabWidget> +#include "../../shared/util.h" + Q_DECLARE_METATYPE(QPushButton*) //TESTED_CLASS= @@ -413,6 +415,7 @@ void tst_QPushButton::setAccel() // The shortcut will not be activated unless the button is in a active // window and has focus + QApplication::setActiveWindow(testWidget); testWidget->setFocus(); for (int i = 0; !testWidget->isActiveWindow() && i < 1000; ++i) { testWidget->activateWindow(); @@ -421,8 +424,8 @@ void tst_QPushButton::setAccel() } QVERIFY(testWidget->isActiveWindow()); QTest::keyClick( testWidget, 'A', Qt::AltModifier ); - QTest::qWait( 500 ); - QVERIFY( click_count == 1 ); + QTest::qWait( 50 ); + QTRY_VERIFY( click_count == 1 ); QVERIFY( press_count == 1 ); QVERIFY( release_count == 1 ); QVERIFY( toggle_count == 0 ); @@ -430,6 +433,7 @@ void tst_QPushButton::setAccel() // wait 200 ms because setAccel uses animateClick. // if we don't wait this may screw up a next test. QTest::qWait(200); + QTRY_VERIFY( !testWidget->isDown() ); } void tst_QPushButton::animateClick() diff --git a/tests/auto/qspinbox/tst_qspinbox.cpp b/tests/auto/qspinbox/tst_qspinbox.cpp index 73d25a2..f4d70d1 100644 --- a/tests/auto/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/qspinbox/tst_qspinbox.cpp @@ -140,7 +140,7 @@ private slots: void removeAll(); void startWithDash(); void undoRedo(); - + void specialValue(); void textFromValue(); @@ -750,11 +750,13 @@ void tst_QSpinBox::editingFinished() QSpinBox *box2 = new QSpinBox(testFocusWidget); layout->addWidget(box2); + testFocusWidget->show(); + QApplication::setActiveWindow(testFocusWidget); box->activateWindow(); - QTest::qWait(1000);//qApp->processEvents(); + QTest::qWait(100);//qApp->processEvents(); box->setFocus(); - QTRY_VERIFY(qApp->focusWidget() == box); + QTRY_COMPARE(qApp->focusWidget(), box); QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished())); QSignalSpy editingFinishedSpy2(box2, SIGNAL(editingFinished())); @@ -910,7 +912,7 @@ void tst_QSpinBox::undoRedo() void tst_QSpinBox::specialValue() { QString specialText="foo"; - + QWidget topWidget; QVBoxLayout layout(&topWidget); SpinBox spin(&topWidget); @@ -937,7 +939,7 @@ void tst_QSpinBox::specialValue() QCOMPARE(spin.text(), QString("0")); QTest::keyClick(&spin, Qt::Key_Return); QCOMPARE(spin.text(), specialText); - + spin.setValue(50); QTest::keyClick(&spin, Qt::Key_Return); QTest::keyClick(&spin, '0'); @@ -987,17 +989,17 @@ void tst_QSpinBox::sizeHint() QVERIFY(spinBox->sizeHintRequests > 0); // Suffix - spinBox->sizeHintRequests = 0; + spinBox->sizeHintRequests = 0; spinBox->setSuffix(QLatin1String("abcdefghij")); qApp->processEvents(); - QVERIFY(spinBox->sizeHintRequests > 0); + QVERIFY(spinBox->sizeHintRequests > 0); // Range - spinBox->sizeHintRequests = 0; + spinBox->sizeHintRequests = 0; spinBox->setRange(0, 1234567890); spinBox->setValue(spinBox->maximum()); qApp->processEvents(); - QVERIFY(spinBox->sizeHintRequests > 0); + QVERIFY(spinBox->sizeHintRequests > 0); } QTEST_MAIN(tst_QSpinBox) diff --git a/tests/auto/qstackedlayout/tst_qstackedlayout.cpp b/tests/auto/qstackedlayout/tst_qstackedlayout.cpp index c6a30a5..481ee2c 100644 --- a/tests/auto/qstackedlayout/tst_qstackedlayout.cpp +++ b/tests/auto/qstackedlayout/tst_qstackedlayout.cpp @@ -47,6 +47,8 @@ #include <qwidget.h> #include <QPushButton> +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES=gui/kernel/qlayout.cpp gui/kernel/qlayout.h @@ -149,7 +151,7 @@ void tst_QStackedLayout::testCase() QStackedLayout onStack(testWidget); QStackedLayout *testLayout = &onStack; testWidget->setLayout(testLayout); - + QSignalSpy spy(testLayout,SIGNAL(currentChanged(int))); // Nothing in layout @@ -350,12 +352,15 @@ void tst_QStackedLayout::keepFocusAfterSetCurrent() stackLayout->setCurrentIndex(0); + testWidget->show(); + QTest::qWait(25); + QApplication::setActiveWindow(testWidget); + edit1->setFocus(); - QTest::qWait(250); edit1->activateWindow(); - QTest::qWait(100); + QTest::qWait(25); - QVERIFY(edit1->hasFocus()); + QTRY_VERIFY(edit1->hasFocus()); stackLayout->setCurrentIndex(1); QVERIFY(!edit1->hasFocus()); diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 6fe2963..51d0e33 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -2334,8 +2334,10 @@ void tst_QTableView::scrollTo() QtTestTableView view; view.show(); - view.resize(columnWidth * 2, rowHeight * 2); + QSize forcedSize(columnWidth * 2, rowHeight * 2); + view.resize(forcedSize); QTest::qWait(0); + QTRY_COMPARE(view.size(), forcedSize); view.setModel(&model); view.setSpan(row, column, rowSpan, columnSpan); @@ -2910,6 +2912,7 @@ void tst_QTableView::tabFocus() window.setFocus(); QTest::qWait(100); window.activateWindow(); + QApplication::setActiveWindow(&window); QTest::qWait(100); qApp->processEvents(); @@ -2926,43 +2929,43 @@ void tst_QTableView::tabFocus() for (int i = 0; i < 2; ++i) { // tab to view QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab); - QVERIFY(!window.hasFocus()); + QTRY_VERIFY(!window.hasFocus()); QVERIFY(view->hasFocus()); QVERIFY(!edit->hasFocus()); // tab to edit QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab); + QTRY_VERIFY(edit->hasFocus()); QVERIFY(!window.hasFocus()); QVERIFY(!view->hasFocus()); - QVERIFY(edit->hasFocus()); } // backtab to view QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(view->hasFocus()); QVERIFY(!window.hasFocus()); - QVERIFY(view->hasFocus()); QVERIFY(!edit->hasFocus()); // backtab to edit QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(edit->hasFocus()); QVERIFY(!window.hasFocus()); QVERIFY(!view->hasFocus()); - QVERIFY(edit->hasFocus()); QStandardItemModel *model = new QStandardItemModel; view->setModel(model); // backtab to view QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(view->hasFocus()); QVERIFY(!window.hasFocus()); - QVERIFY(view->hasFocus()); QVERIFY(!edit->hasFocus()); // backtab to edit QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(edit->hasFocus()); QVERIFY(!window.hasFocus()); QVERIFY(!view->hasFocus()); - QVERIFY(edit->hasFocus()); model->insertRow(0, new QStandardItem("Hei")); model->insertRow(0, new QStandardItem("Hei")); @@ -2970,8 +2973,8 @@ void tst_QTableView::tabFocus() // backtab to view QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(view->hasFocus()); QVERIFY(!window.hasFocus()); - QVERIFY(view->hasFocus()); QVERIFY(!edit->hasFocus()); // backtab to edit doesn't work @@ -2984,14 +2987,14 @@ void tst_QTableView::tabFocus() // backtab to edit QTest::keyPress(qApp->focusWidget(), Qt::Key_Backtab); + QTRY_VERIFY(edit->hasFocus()); QVERIFY(!window.hasFocus()); QVERIFY(!view->hasFocus()); - QVERIFY(edit->hasFocus()); QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab); - QVERIFY(view->hasFocus()); + QTRY_VERIFY(view->hasFocus()); QTest::keyPress(qApp->focusWidget(), Qt::Key_Tab); - QVERIFY(edit->hasFocus()); + QTRY_VERIFY(edit->hasFocus()); delete model; } diff --git a/tests/auto/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/qtextbrowser/tst_qtextbrowser.cpp index 0311900..966e9c9 100644 --- a/tests/auto/qtextbrowser/tst_qtextbrowser.cpp +++ b/tests/auto/qtextbrowser/tst_qtextbrowser.cpp @@ -49,6 +49,8 @@ #include <qtextbrowser.h> #include <qtextobject.h> +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= @@ -64,9 +66,11 @@ public: #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(this); #endif + QApplication::setActiveWindow(this); activateWindow(); setFocus(); - QTest::qWait(100); + QTest::qWait(50); + QTRY_VERIFY(hasFocus()); } virtual QVariant loadResource(int type, const QUrl &name); diff --git a/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp b/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp index 6f8dd2b..61f4456 100644 --- a/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp +++ b/tests/auto/qtextpiecetable/tst_qtextpiecetable.cpp @@ -772,7 +772,9 @@ void tst_QTextPieceTable::blockRemoval1() QVERIFY(table->blocksFind(6).position() == 5); QVERIFY(table->blocksFind(11).position() == 10); + table->beginEditBlock(); table->remove(5, 5); + table->endEditBlock(); QVERIFY(table->blocksFind(4).blockFormat() == QTextBlockFormat()); QVERIFY(table->blocksFind(5).blockFormat() == fmt2); QVERIFY(table->blocksFind(4).position() == 0); @@ -864,7 +866,10 @@ void tst_QTextPieceTable::blockRemoval3() QVERIFY(table->blocksFind(6).position() == 5); QVERIFY(table->blocksFind(11).position() == 10); + table->beginEditBlock(); table->remove(3, 4); + table->endEditBlock(); + QVERIFY(table->blocksFind(1).blockFormat() == QTextBlockFormat()); QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat()); QVERIFY(table->blocksFind(1).position() == 0); @@ -958,7 +963,10 @@ void tst_QTextPieceTable::blockRemoval5() QVERIFY(table->blocksFind(6).position() == 5); QVERIFY(table->blocksFind(11).position() == 10); + table->beginEditBlock(); table->remove(3, 8); + table->endEditBlock(); + QVERIFY(table->blocksFind(0).blockFormat() == QTextBlockFormat()); QVERIFY(table->blocksFind(5).blockFormat() == QTextBlockFormat()); QVERIFY(table->blocksFind(1).position() == 0); diff --git a/tests/auto/qtransformedscreen/qtransformedscreen.pro b/tests/auto/qtransformedscreen/qtransformedscreen.pro index 39e3700..6914054 100644 --- a/tests/auto/qtransformedscreen/qtransformedscreen.pro +++ b/tests/auto/qtransformedscreen/qtransformedscreen.pro @@ -1,6 +1,5 @@ load(qttest_p4) SOURCES += tst_qtransformedscreen.cpp -QT = core embedded:!contains(gfx-drivers, transformed) { LIBS += ../../../plugins/gfxdrivers/libqgfxtransformed.so diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index fae4b26..f42d5f6 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -3354,7 +3354,7 @@ void tst_QTreeView::task246536_scrollbarsNotWorking() o.count = 0; tree.verticalScrollBar()->setValue(50); QTest::qWait(100); - QVERIFY(o.count > 0); + QTRY_VERIFY(o.count > 0); } void tst_QTreeView::task250683_wrongSectionSize() @@ -3404,8 +3404,9 @@ void tst_QTreeView::task239271_addRowsWithFirstColumnHidden() QStandardItem sub1("sub1"), sub11("sub11"); root0.appendRow(QList<QStandardItem*>() << &sub1 << &sub11); - QTest::qWait(200); + QTest::qWait(20); //items in the 2nd column should have been painted + QTRY_VERIFY(!delegate.paintedIndexes.isEmpty()); QVERIFY(delegate.paintedIndexes.contains(sub00.index())); QVERIFY(delegate.paintedIndexes.contains(sub11.index())); } diff --git a/tests/auto/qwsembedwidget/qwsembedwidget.pro b/tests/auto/qwsembedwidget/qwsembedwidget.pro index bd3c32c..c34212b 100644 --- a/tests/auto/qwsembedwidget/qwsembedwidget.pro +++ b/tests/auto/qwsembedwidget/qwsembedwidget.pro @@ -1,3 +1,2 @@ load(qttest_p4) SOURCES += tst_qwsembedwidget.cpp -QT = core diff --git a/tests/auto/qwsinputmethod/qwsinputmethod.pro b/tests/auto/qwsinputmethod/qwsinputmethod.pro index 69cce78..d549de0 100644 --- a/tests/auto/qwsinputmethod/qwsinputmethod.pro +++ b/tests/auto/qwsinputmethod/qwsinputmethod.pro @@ -1,3 +1,2 @@ load(qttest_p4) SOURCES += tst_qwsinputmethod.cpp -QT = core diff --git a/tests/auto/qwswindowsystem/qwswindowsystem.pro b/tests/auto/qwswindowsystem/qwswindowsystem.pro index 49466ee..ee33935 100644 --- a/tests/auto/qwswindowsystem/qwswindowsystem.pro +++ b/tests/auto/qwswindowsystem/qwswindowsystem.pro @@ -1,3 +1,2 @@ load(qttest_p4) SOURCES += tst_qwswindowsystem.cpp -QT = core |