From 4248244704211a45a20a39f390ec00c9687a8d1c Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 21 Jan 2010 07:57:25 +0100 Subject: Fix how we select antialiasing method for text under Mac OS X Reviewed-by: Eskil --- src/gui/kernel/qapplication_mac.mm | 42 ++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index 688e51f..7cdd50a 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -227,8 +227,29 @@ void onApplicationChangedActivation( bool activated ); static void qt_mac_read_fontsmoothing_settings() { - NSInteger appleFontSmoothing = [[NSUserDefaults standardUserDefaults] integerForKey:@"AppleFontSmoothing"]; - qt_applefontsmoothing_enabled = (appleFontSmoothing > 0); + qt_applefontsmoothing_enabled = true; + int w = 10, h = 10; + QImage image(w, h, QImage::Format_RGB32); + image.fill(0xffffffff); + QPainter p(&image); + p.drawText(0, h, "X\\"); + p.end(); + + const int *bits = (const int *) ((const QImage &) image).bits(); + int bpl = image.bytesPerLine() / 4; + for (int y=0; ylastUpdateWidget = widget; } else if (it->lastUpdateWidget == widget) { - // Update the gl wigets that the widget intersected the last time around, - // and that we are not intersecting now. This prevents paint errors when the + // Update the gl wigets that the widget intersected the last time around, + // and that we are not intersecting now. This prevents paint errors when the // intersecting widget leaves a gl widget. qt_post_window_change_event(glWidget); - it->lastUpdateWidget = 0; + it->lastUpdateWidget = 0; } } #else @@ -808,8 +829,8 @@ Q_GUI_EXPORT void qt_event_request_window_change(QWidget *widget) // Post a kEventQtRequestWindowChange event. This event is semi-public, // don't remove this line! qt_event_request_window_change(); - - // Post update request on gl widgets unconditionally. + + // Post update request on gl widgets unconditionally. if (qt_widget_private(widget)->isGLWidget == true) { qt_post_window_change_event(widget); return; @@ -1214,8 +1235,6 @@ void qt_init(QApplicationPrivate *priv, int) if (QApplication::desktopSettingsAware()) QApplicationPrivate::qt_mac_apply_settings(); - qt_mac_read_fontsmoothing_settings(); - // Cocoa application delegate #ifdef QT_MAC_USE_COCOA NSApplication *cocoaApp = [NSApplication sharedApplication]; @@ -1253,6 +1272,7 @@ void qt_init(QApplicationPrivate *priv, int) } priv->native_modal_dialog_active = false; + qt_mac_read_fontsmoothing_settings(); } void qt_release_apple_event_handler() @@ -1705,7 +1725,7 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event // kEventMouseWheelMoved events if we dont eat this event // (actually two events; one for horizontal and one for vertical). // As a results of this, and to make sure we dont't receive duplicate events, - // we try to detect when this happend by checking the 'compatibilityEvent'. + // we try to detect when this happend by checking the 'compatibilityEvent'. SInt32 mdelt = 0; GetEventParameter(event, kEventParamMouseWheelSmoothHorizontalDelta, typeSInt32, 0, sizeof(mdelt), 0, &mdelt); @@ -2576,7 +2596,7 @@ void QApplicationPrivate::closePopup(QWidget *popup) if (QApplicationPrivate::popupWidgets->isEmpty()) { // this was the last popup delete QApplicationPrivate::popupWidgets; QApplicationPrivate::popupWidgets = 0; - + // Special case for Tool windows: since they are activated and deactived together // with a normal window they never become the QApplicationPrivate::active_window. QWidget *appFocusWidget = QApplication::focusWidget(); -- cgit v0.12 From aa2d3eb0f05dc87347e30fc0a6c843fc3d1b4855 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 21 Jan 2010 08:49:12 +0100 Subject: Don't use a mutex lock in QPainter::redirection unless strictly required --- src/gui/painting/qpainter.cpp | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index a9dcea0..764ec68 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7385,10 +7385,15 @@ struct QPaintDeviceRedirection typedef QList QPaintDeviceRedirectionList; Q_GLOBAL_STATIC(QPaintDeviceRedirectionList, globalRedirections) Q_GLOBAL_STATIC(QMutex, globalRedirectionsMutex) +Q_GLOBAL_STATIC(QAtomicInt, globalRedirectionAtomic) /*! \threadsafe + \obsolete + + Please use QWidget::render() instead. + Redirects all paint commands for the given paint \a device, to the \a replacement device. The optional point \a offset defines an offset within the source device. @@ -7398,9 +7403,10 @@ Q_GLOBAL_STATIC(QMutex, globalRedirectionsMutex) device's painter (if any) before redirecting. Call restoreRedirected() to restore the previous redirection. - In general, you'll probably find that calling - QPixmap::grabWidget() or QPixmap::grabWindow() is an easier - solution. + \warning Making use of redirections in the QPainter API implies + that QPainter::begin() and QPaintDevice destructors need to hold + a mutex for a short period. This can impact performance. Use of + QWidget::render is strongly encouraged. \sa redirected(), restoreRedirected() */ @@ -7432,14 +7438,24 @@ void QPainter::setRedirected(const QPaintDevice *device, Q_ASSERT(redirections != 0); *redirections += QPaintDeviceRedirection(device, rdev ? rdev : replacement, offset + roffset, hadInternalWidgetRedirection ? redirections->size() - 1 : -1); + globalRedirectionAtomic()->ref(); } /*! \threadsafe + \obsolete + + Using QWidget::render() obsoletes the use of this function. + Restores the previous redirection for the given \a device after a call to setRedirected(). + \warning Making use of redirections in the QPainter API implies + that QPainter::begin() and QPaintDevice destructors need to hold + a mutex for a short period. This can impact performance. Use of + QWidget::render is strongly encouraged. + \sa redirected() */ void QPainter::restoreRedirected(const QPaintDevice *device) @@ -7450,6 +7466,7 @@ void QPainter::restoreRedirected(const QPaintDevice *device) Q_ASSERT(redirections != 0); for (int i = redirections->size()-1; i >= 0; --i) { if (redirections->at(i) == device) { + globalRedirectionAtomic()->deref(); const int internalWidgetRedirectionIndex = redirections->at(i).internalWidgetRedirectionIndex; redirections->removeAt(i); // Restore the internal widget redirection, i.e. remove it from the global @@ -7471,21 +7488,34 @@ void QPainter::restoreRedirected(const QPaintDevice *device) /*! \threadsafe + \obsolete + + Using QWidget::render() obsoletes the use of this function. + Returns the replacement for given \a device. The optional out parameter \a offset returns the offset within the replaced device. + \warning Making use of redirections in the QPainter API implies + that QPainter::begin() and QPaintDevice destructors need to hold + a mutex for a short period. This can impact performance. Use of + QWidget::render is strongly encouraged. + \sa setRedirected(), restoreRedirected() */ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset) { Q_ASSERT(device != 0); + if (*globalRedirectionAtomic() == 0) + return 0; + if (device->devType() == QInternal::Widget) { const QWidgetPrivate *widgetPrivate = static_cast(device)->d_func(); if (widgetPrivate->redirectDev) return widgetPrivate->redirected(offset); } + QMutexLocker locker(globalRedirectionsMutex()); QPaintDeviceRedirectionList *redirections = globalRedirections(); Q_ASSERT(redirections != 0); @@ -7503,6 +7533,9 @@ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset) void qt_painter_removePaintDevice(QPaintDevice *dev) { + if (*globalRedirectionAtomic() == 0) + return; + QMutex *mutex = 0; QT_TRY { mutex = globalRedirectionsMutex(); -- cgit v0.12 From 848ae6da25e567e9f64bc98dcbf868912448d136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Thu, 21 Jan 2010 10:32:14 +0100 Subject: Doc fixes: Remove some lies from QEasingCurve. Task-number: QTBUG-7418 --- src/corelib/tools/qeasingcurve.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index 0ef92d9..b6a2df4 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -125,7 +125,7 @@ \value OutCubic \inlineimage qeasingcurve-outcubic.png \br Easing curve for a cubic (t^3) function: - decelerating from zero velocity. + decelerating to zero velocity. \value InOutCubic \inlineimage qeasingcurve-inoutcubic.png \br Easing curve for a cubic (t^3) function: @@ -141,7 +141,7 @@ \value OutQuart \inlineimage qeasingcurve-outquart.png \br Easing curve for a cubic (t^4) function: - decelerating from zero velocity. + decelerating to zero velocity. \value InOutQuart \inlineimage qeasingcurve-inoutquart.png \br Easing curve for a cubic (t^4) function: @@ -157,7 +157,7 @@ \value OutQuint \inlineimage qeasingcurve-outquint.png \br Easing curve for a cubic (t^5) function: - decelerating from zero velocity. + decelerating to zero velocity. \value InOutQuint \inlineimage qeasingcurve-inoutquint.png \br Easing curve for a cubic (t^5) function: -- cgit v0.12 From 1729c2baea4e39f97d71b77f4c25af131f23221c Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 20 Jan 2010 08:59:48 +0100 Subject: Remove unnecessary depth uniform from GL2 engine's GLSL Reviewed-By: Samuel --- src/opengl/gl2paintengineex/qglengineshadersource_p.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index d9a61e9..6e98b02 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -64,23 +64,19 @@ QT_MODULE(OpenGL) static const char* const qglslMainVertexShader = "\ - uniform highp float depth;\ void setPosition();\ void main(void)\ {\ setPosition();\ - gl_Position.z = depth * gl_Position.w;\ }"; static const char* const qglslMainWithTexCoordsVertexShader = "\ attribute highp vec2 textureCoordArray; \ varying highp vec2 textureCoords; \ - uniform highp float depth;\ void setPosition();\ void main(void) \ {\ setPosition();\ - gl_Position.z = depth * gl_Position.w;\ textureCoords = textureCoordArray; \ }"; @@ -89,12 +85,10 @@ static const char* const qglslMainWithTexCoordsAndOpacityVertexShader = "\ attribute lowp float opacityArray; \ varying highp vec2 textureCoords; \ varying lowp float opacity; \ - uniform highp float depth; \ void setPosition(); \ void main(void) \ { \ setPosition(); \ - gl_Position.z = depth * gl_Position.w; \ textureCoords = textureCoordArray; \ opacity = opacityArray; \ }"; -- cgit v0.12 From 3a8236a01f89882d91e22a336f1e7134d3a84b68 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 20 Jan 2010 10:18:32 +0100 Subject: Use an attribute value for the PMV matrix rather than a uniform This has several advantages: First, updating an attribute value seems to be cheaper than updating a uniform. Second, vertex atribute values are independent of shader program, which means they persist across changing of the shader program. This makes code simpler and reduces GL state changes. Note: Credit goes to Samuel for finding this little gem. :-) For the 25920 solid QGraphicsRectItem test case, this gives 10% improvement on desktop and 27% on the SGX. Reviewed-By: Kim --- .../gl2paintengineex/qglengineshadermanager.cpp | 7 ++++- .../gl2paintengineex/qglengineshadermanager_p.h | 5 +++- .../gl2paintengineex/qglengineshadersource_p.h | 34 +++++++++++++++++----- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 25 ++++------------ .../gl2paintengineex/qpaintengineex_opengl2_p.h | 2 -- 5 files changed, 42 insertions(+), 31 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 556b888..9fd9e18 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -324,6 +324,11 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS newProg->program->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR); if (newProg->useOpacityAttribute) newProg->program->bindAttributeLocation("opacityArray", QT_OPACITY_ATTR); + if (newProg->usePmvMatrix) { + newProg->program->bindAttributeLocation("pmvMatrix1", QT_PMV_MATRIX_1_ATTR); + newProg->program->bindAttributeLocation("pmvMatrix2", QT_PMV_MATRIX_2_ATTR); + newProg->program->bindAttributeLocation("pmvMatrix3", QT_PMV_MATRIX_3_ATTR); + } newProg->program->link(); if (!newProg->program->isLinked()) { @@ -424,7 +429,6 @@ GLuint QGLEngineShaderManager::getUniformLocation(Uniform id) "patternColor", "globalOpacity", "depth", - "pmvMatrix", "maskTexture", "fragmentColor", "linearData", @@ -743,6 +747,7 @@ bool QGLEngineShaderManager::useCorrectShaderProg() } requiredProgram.useTextureCoords = texCoords; requiredProgram.useOpacityAttribute = (opacityMode == AttributeOpacity); + requiredProgram.usePmvMatrix = true; // At this point, requiredProgram is fully populated so try to find the program in the cache currentShaderProg = sharedShaders->findProgramInCache(requiredProgram); diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index c52e5c0..3ab4ebe 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -253,6 +253,9 @@ struct QGLEngineCachedShaderProg static const GLuint QT_VERTEX_COORDS_ATTR = 0; static const GLuint QT_TEXTURE_COORDS_ATTR = 1; static const GLuint QT_OPACITY_ATTR = 2; +static const GLuint QT_PMV_MATRIX_1_ATTR = 3; +static const GLuint QT_PMV_MATRIX_2_ATTR = 4; +static const GLuint QT_PMV_MATRIX_3_ATTR = 5; class QGLEngineShaderProg; @@ -397,6 +400,7 @@ public: bool useTextureCoords; bool useOpacityAttribute; + bool usePmvMatrix; bool operator==(const QGLEngineShaderProg& other) { // We don't care about the program @@ -431,7 +435,6 @@ public: PatternColor, GlobalOpacity, Depth, - PmvMatrix, MaskTexture, FragmentColor, LinearData, diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index 6e98b02..b471b81 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -97,9 +97,12 @@ static const char* const qglslMainWithTexCoordsAndOpacityVertexShader = "\ // shader are also perspective corrected. static const char* const qglslPositionOnlyVertexShader = "\ attribute highp vec2 vertexCoordsArray;\ - uniform highp mat3 pmvMatrix;\ + attribute highp vec3 pmvMatrix1; \ + attribute highp vec3 pmvMatrix2; \ + attribute highp vec3 pmvMatrix3; \ void setPosition(void)\ {\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ gl_Position = vec4(transformedPos.xy, 0.0, transformedPos.z); \ }"; @@ -114,12 +117,15 @@ static const char* const qglslUntransformedPositionVertexShader = "\ // Pattern Brush - This assumes the texture size is 8x8 and thus, the inverted size is 0.125 static const char* const qglslPositionWithPatternBrushVertexShader = "\ attribute highp vec2 vertexCoordsArray; \ - uniform highp mat3 pmvMatrix; \ + attribute highp vec3 pmvMatrix1; \ + attribute highp vec3 pmvMatrix2; \ + attribute highp vec3 pmvMatrix3; \ uniform mediump vec2 halfViewportSize; \ uniform highp vec2 invertedTextureSize; \ uniform highp mat3 brushTransform; \ varying highp vec2 patternTexCoords; \ void setPosition(void) { \ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ gl_Position.xy = transformedPos.xy / transformedPos.z; \ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ @@ -144,12 +150,15 @@ static const char* const qglslPatternBrushSrcFragmentShader = "\ // Linear Gradient Brush static const char* const qglslPositionWithLinearGradientBrushVertexShader = "\ attribute highp vec2 vertexCoordsArray; \ - uniform highp mat3 pmvMatrix; \ + attribute highp vec3 pmvMatrix1; \ + attribute highp vec3 pmvMatrix2; \ + attribute highp vec3 pmvMatrix3; \ uniform mediump vec2 halfViewportSize; \ uniform highp vec3 linearData; \ uniform highp mat3 brushTransform; \ varying mediump float index; \ void setPosition() { \ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ gl_Position.xy = transformedPos.xy / transformedPos.z; \ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ @@ -174,12 +183,15 @@ static const char* const qglslLinearGradientBrushSrcFragmentShader = "\ // Conical Gradient Brush static const char* const qglslPositionWithConicalGradientBrushVertexShader = "\ attribute highp vec2 vertexCoordsArray;\ - uniform highp mat3 pmvMatrix;\ + attribute highp vec3 pmvMatrix1; \ + attribute highp vec3 pmvMatrix2; \ + attribute highp vec3 pmvMatrix3; \ uniform mediump vec2 halfViewportSize; \ uniform highp mat3 brushTransform; \ varying highp vec2 A; \ - void setPosition(void)\ - {\ + void setPosition(void) \ + { \ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ gl_Position.xy = transformedPos.xy / transformedPos.z; \ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ @@ -210,7 +222,9 @@ static const char* const qglslConicalGradientBrushSrcFragmentShader = "\n\ // Radial Gradient Brush static const char* const qglslPositionWithRadialGradientBrushVertexShader = "\ attribute highp vec2 vertexCoordsArray;\ - uniform highp mat3 pmvMatrix;\ + attribute highp vec3 pmvMatrix1; \ + attribute highp vec3 pmvMatrix2; \ + attribute highp vec3 pmvMatrix3; \ uniform mediump vec2 halfViewportSize; \ uniform highp mat3 brushTransform; \ uniform highp vec2 fmp; \ @@ -218,6 +232,7 @@ static const char* const qglslPositionWithRadialGradientBrushVertexShader = "\ varying highp vec2 A; \ void setPosition(void) \ {\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ gl_Position.xy = transformedPos.xy / transformedPos.z; \ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ @@ -247,12 +262,15 @@ static const char* const qglslRadialGradientBrushSrcFragmentShader = "\ // Texture Brush static const char* const qglslPositionWithTextureBrushVertexShader = "\ attribute highp vec2 vertexCoordsArray; \ - uniform highp mat3 pmvMatrix; \ + attribute highp vec3 pmvMatrix1; \ + attribute highp vec3 pmvMatrix2; \ + attribute highp vec3 pmvMatrix3; \ uniform mediump vec2 halfViewportSize; \ uniform highp vec2 invertedTextureSize; \ uniform highp mat3 brushTransform; \ varying highp vec2 textureCoords; \ void setPosition(void) { \ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ gl_Position.xy = transformedPos.xy / transformedPos.z; \ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index caa679b..b282676 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -168,12 +168,6 @@ void QGL2PaintEngineExPrivate::useSimpleShader() if (matrixDirty) updateMatrix(); - - if (simpleShaderMatrixUniformDirty) { - const GLuint location = shaderManager->simpleProgram()->uniformLocation("pmvMatrix"); - glUniformMatrix3fv(location, 1, GL_FALSE, (GLfloat*)pmvMatrix); - simpleShaderMatrixUniformDirty = false; - } } void QGL2PaintEngineExPrivate::updateBrushTexture() @@ -392,9 +386,11 @@ void QGL2PaintEngineExPrivate::updateMatrix() matrixDirty = false; - // The actual data has been updated so both shader program's uniforms need updating - simpleShaderMatrixUniformDirty = true; - shaderMatrixUniformDirty = true; + // Set the PMV matrix attribute. As we use an attributes rather than uniforms, we only + // need to do this once for every matrix change and persists across all shader programs. + glVertexAttrib3fv(QT_PMV_MATRIX_1_ATTR, pmvMatrix[0]); + glVertexAttrib3fv(QT_PMV_MATRIX_2_ATTR, pmvMatrix[1]); + glVertexAttrib3fv(QT_PMV_MATRIX_3_ATTR, pmvMatrix[2]); dasher.setInvScale(inverseScale); stroker.setInvScale(inverseScale); @@ -932,18 +928,12 @@ bool QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque) if (changed) { // The shader program has changed so mark all uniforms as dirty: brushUniformsDirty = true; - shaderMatrixUniformDirty = true; opacityUniformDirty = true; } if (brushUniformsDirty && mode != ImageDrawingMode && mode != ImageArrayDrawingMode) updateBrushUniforms(); - if (shaderMatrixUniformDirty) { - glUniformMatrix3fv(location(QGLEngineShaderManager::PmvMatrix), 1, GL_FALSE, (GLfloat*)pmvMatrix); - shaderMatrixUniformDirty = false; - } - if (opacityMode == QGLEngineShaderManager::UniformOpacity && opacityUniformDirty) { shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::GlobalOpacity), (GLfloat)q->state()->opacity); opacityUniformDirty = false; @@ -1955,11 +1945,8 @@ void QGL2PaintEngineEx::setState(QPainterState *new_state) if (old_state == s || old_state->renderHintsChanged) renderHintsChanged(); - if (old_state == s || old_state->matrixChanged) { + if (old_state == s || old_state->matrixChanged) d->matrixDirty = true; - d->simpleShaderMatrixUniformDirty = true; - d->shaderMatrixUniformDirty = true; - } if (old_state == s || old_state->compositionModeChanged) d->compositionModeDirty = true; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index ce1b538..8fa0eff 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -252,8 +252,6 @@ public: bool compositionModeDirty; bool brushTextureDirty; bool brushUniformsDirty; - bool simpleShaderMatrixUniformDirty; - bool shaderMatrixUniformDirty; bool opacityUniformDirty; bool stencilClean; // Has the stencil not been used for clipping so far? -- cgit v0.12 From 87ca0fa9389b7ef77e179b6db7ddc970b7228d6c Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 20 Jan 2010 12:47:18 +0100 Subject: Purely cosmetic (formatting) changes to GL2 engine's GLSL This makes GLSL dumps _significantly_ easier to read. Reviewed-By: TrustMe --- .../gl2paintengineex/qglengineshadersource_p.h | 690 +++++++++++---------- 1 file changed, 357 insertions(+), 333 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index b471b81..ee04166 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -63,222 +63,229 @@ QT_BEGIN_NAMESPACE QT_MODULE(OpenGL) -static const char* const qglslMainVertexShader = "\ - void setPosition();\ - void main(void)\ - {\ - setPosition();\ - }"; - -static const char* const qglslMainWithTexCoordsVertexShader = "\ - attribute highp vec2 textureCoordArray; \ - varying highp vec2 textureCoords; \ - void setPosition();\ - void main(void) \ - {\ - setPosition();\ - textureCoords = textureCoordArray; \ - }"; - -static const char* const qglslMainWithTexCoordsAndOpacityVertexShader = "\ - attribute highp vec2 textureCoordArray; \ - attribute lowp float opacityArray; \ - varying highp vec2 textureCoords; \ - varying lowp float opacity; \ - void setPosition(); \ - void main(void) \ - { \ - setPosition(); \ - textureCoords = textureCoordArray; \ - opacity = opacityArray; \ - }"; +static const char* const qglslMainVertexShader = "\n\ + void setPosition(); \n\ + void main(void) \n\ + { \n\ + setPosition(); \n\ + }\n"; + +static const char* const qglslMainWithTexCoordsVertexShader = "\n\ + attribute highp vec2 textureCoordArray; \n\ + varying highp vec2 textureCoords; \n\ + void setPosition(); \n\ + void main(void) \n\ + { \n\ + setPosition(); \n\ + textureCoords = textureCoordArray; \n\ + }\n"; + +static const char* const qglslMainWithTexCoordsAndOpacityVertexShader = "\n\ + attribute highp vec2 textureCoordArray; \n\ + attribute lowp float opacityArray; \n\ + varying highp vec2 textureCoords; \n\ + varying lowp float opacity; \n\ + void setPosition(); \n\ + void main(void) \n\ + { \n\ + setPosition(); \n\ + textureCoords = textureCoordArray; \n\ + opacity = opacityArray; \n\ + }\n"; // NOTE: We let GL do the perspective correction so texture lookups in the fragment // shader are also perspective corrected. -static const char* const qglslPositionOnlyVertexShader = "\ - attribute highp vec2 vertexCoordsArray;\ - attribute highp vec3 pmvMatrix1; \ - attribute highp vec3 pmvMatrix2; \ - attribute highp vec3 pmvMatrix3; \ - void setPosition(void)\ - {\ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ - gl_Position = vec4(transformedPos.xy, 0.0, transformedPos.z); \ - }"; - -static const char* const qglslUntransformedPositionVertexShader = "\ - attribute highp vec4 vertexCoordsArray;\ - void setPosition(void)\ - {\ - gl_Position = vertexCoordsArray;\ - }"; +static const char* const qglslPositionOnlyVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray; \n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + void setPosition(void) \n\ + { \n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position = vec4(transformedPos.xy, 0.0, transformedPos.z); \n\ + }\n"; + +static const char* const qglslUntransformedPositionVertexShader = "\n\ + attribute highp vec4 vertexCoordsArray; \n\ + void setPosition(void) \n\ + { \n\ + gl_Position = vertexCoordsArray; \n\ + }\n"; // Pattern Brush - This assumes the texture size is 8x8 and thus, the inverted size is 0.125 -static const char* const qglslPositionWithPatternBrushVertexShader = "\ - attribute highp vec2 vertexCoordsArray; \ - attribute highp vec3 pmvMatrix1; \ - attribute highp vec3 pmvMatrix2; \ - attribute highp vec3 pmvMatrix3; \ - uniform mediump vec2 halfViewportSize; \ - uniform highp vec2 invertedTextureSize; \ - uniform highp mat3 brushTransform; \ - varying highp vec2 patternTexCoords; \ - void setPosition(void) { \ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ - gl_Position.xy = transformedPos.xy / transformedPos.z; \ - mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ - mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1.0); \ - mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ - gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \ - patternTexCoords.xy = (hTexCoords.xy * 0.125) * invertedHTexCoordsZ; \ - }"; +static const char* const qglslPositionWithPatternBrushVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray; \n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + uniform mediump vec2 halfViewportSize; \n\ + uniform highp vec2 invertedTextureSize; \n\ + uniform highp mat3 brushTransform; \n\ + varying highp vec2 patternTexCoords; \n\ + void setPosition(void) \n\ + { \n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1.0); \n\ + mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + patternTexCoords.xy = (hTexCoords.xy * 0.125) * invertedHTexCoordsZ; \n\ + }\n"; static const char* const qglslAffinePositionWithPatternBrushVertexShader = qglslPositionWithPatternBrushVertexShader; -static const char* const qglslPatternBrushSrcFragmentShader = "\ - uniform lowp sampler2D brushTexture;\ - uniform lowp vec4 patternColor; \ - varying highp vec2 patternTexCoords;\ - lowp vec4 srcPixel() { \ - return patternColor * (1.0 - texture2D(brushTexture, patternTexCoords).r); \ +static const char* const qglslPatternBrushSrcFragmentShader = "\n\ + uniform lowp sampler2D brushTexture; \n\ + uniform lowp vec4 patternColor; \n\ + varying highp vec2 patternTexCoords;\n\ + lowp vec4 srcPixel() \n\ + { \n\ + return patternColor * (1.0 - texture2D(brushTexture, patternTexCoords).r); \n\ }\n"; // Linear Gradient Brush -static const char* const qglslPositionWithLinearGradientBrushVertexShader = "\ - attribute highp vec2 vertexCoordsArray; \ - attribute highp vec3 pmvMatrix1; \ - attribute highp vec3 pmvMatrix2; \ - attribute highp vec3 pmvMatrix3; \ - uniform mediump vec2 halfViewportSize; \ - uniform highp vec3 linearData; \ - uniform highp mat3 brushTransform; \ - varying mediump float index; \ - void setPosition() { \ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ - gl_Position.xy = transformedPos.xy / transformedPos.z; \ - mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ - mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ - mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ - gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \ - index = (dot(linearData.xy, hTexCoords.xy) * linearData.z) * invertedHTexCoordsZ; \ - }"; +static const char* const qglslPositionWithLinearGradientBrushVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray; \n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + uniform mediump vec2 halfViewportSize; \n\ + uniform highp vec3 linearData; \n\ + uniform highp mat3 brushTransform; \n\ + varying mediump float index; \n\ + void setPosition() \n\ + { \n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ + mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + index = (dot(linearData.xy, hTexCoords.xy) * linearData.z) * invertedHTexCoordsZ; \n\ + }\n"; static const char* const qglslAffinePositionWithLinearGradientBrushVertexShader = qglslPositionWithLinearGradientBrushVertexShader; -static const char* const qglslLinearGradientBrushSrcFragmentShader = "\ - uniform lowp sampler2D brushTexture; \ - varying mediump float index; \ - lowp vec4 srcPixel() { \ - mediump vec2 val = vec2(index, 0.5); \ - return texture2D(brushTexture, val); \ +static const char* const qglslLinearGradientBrushSrcFragmentShader = "\n\ + uniform lowp sampler2D brushTexture; \n\ + varying mediump float index; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + mediump vec2 val = vec2(index, 0.5); \n\ + return texture2D(brushTexture, val); \n\ }\n"; // Conical Gradient Brush -static const char* const qglslPositionWithConicalGradientBrushVertexShader = "\ - attribute highp vec2 vertexCoordsArray;\ - attribute highp vec3 pmvMatrix1; \ - attribute highp vec3 pmvMatrix2; \ - attribute highp vec3 pmvMatrix3; \ - uniform mediump vec2 halfViewportSize; \ - uniform highp mat3 brushTransform; \ - varying highp vec2 A; \ - void setPosition(void) \ - { \ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ - gl_Position.xy = transformedPos.xy / transformedPos.z; \ - mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ - mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ - mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ - gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \ - A = hTexCoords.xy * invertedHTexCoordsZ; \ - }"; +static const char* const qglslPositionWithConicalGradientBrushVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray; \n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + uniform mediump vec2 halfViewportSize; \n\ + uniform highp mat3 brushTransform; \n\ + varying highp vec2 A; \n\ + void setPosition(void) \n\ + { \n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ + mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + A = hTexCoords.xy * invertedHTexCoordsZ; \n\ + }\n"; static const char* const qglslAffinePositionWithConicalGradientBrushVertexShader = qglslPositionWithConicalGradientBrushVertexShader; static const char* const qglslConicalGradientBrushSrcFragmentShader = "\n\ #define INVERSE_2PI 0.1591549430918953358 \n\ - uniform lowp sampler2D brushTexture; \n\ - uniform mediump float angle; \ - varying highp vec2 A; \ - lowp vec4 srcPixel() { \ - highp float t; \ - if (abs(A.y) == abs(A.x)) \ - t = (atan(-A.y + 0.002, A.x) + angle) * INVERSE_2PI; \ - else \ - t = (atan(-A.y, A.x) + angle) * INVERSE_2PI; \ - return texture2D(brushTexture, vec2(t - floor(t), 0.5)); \ - }"; + uniform lowp sampler2D brushTexture; \n\ + uniform mediump float angle; \n\ + varying highp vec2 A; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + highp float t; \n\ + if (abs(A.y) == abs(A.x)) \n\ + t = (atan(-A.y + 0.002, A.x) + angle) * INVERSE_2PI; \n\ + else \n\ + t = (atan(-A.y, A.x) + angle) * INVERSE_2PI; \n\ + return texture2D(brushTexture, vec2(t - floor(t), 0.5)); \n\ + }\n"; // Radial Gradient Brush -static const char* const qglslPositionWithRadialGradientBrushVertexShader = "\ - attribute highp vec2 vertexCoordsArray;\ - attribute highp vec3 pmvMatrix1; \ - attribute highp vec3 pmvMatrix2; \ - attribute highp vec3 pmvMatrix3; \ - uniform mediump vec2 halfViewportSize; \ - uniform highp mat3 brushTransform; \ - uniform highp vec2 fmp; \ - varying highp float b; \ - varying highp vec2 A; \ - void setPosition(void) \ - {\ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ - gl_Position.xy = transformedPos.xy / transformedPos.z; \ - mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ - mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ - mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ - gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \ - A = hTexCoords.xy * invertedHTexCoordsZ; \ - b = 2.0 * dot(A, fmp); \ - }"; +static const char* const qglslPositionWithRadialGradientBrushVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray;\n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + uniform mediump vec2 halfViewportSize; \n\ + uniform highp mat3 brushTransform; \n\ + uniform highp vec2 fmp; \n\ + varying highp float b; \n\ + varying highp vec2 A; \n\ + void setPosition(void) \n\ + {\n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ + mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + A = hTexCoords.xy * invertedHTexCoordsZ; \n\ + b = 2.0 * dot(A, fmp); \n\ + }\n"; static const char* const qglslAffinePositionWithRadialGradientBrushVertexShader = qglslPositionWithRadialGradientBrushVertexShader; -static const char* const qglslRadialGradientBrushSrcFragmentShader = "\ - uniform lowp sampler2D brushTexture; \ - uniform highp float fmp2_m_radius2; \ - uniform highp float inverse_2_fmp2_m_radius2; \ - varying highp float b; \ - varying highp vec2 A; \ - lowp vec4 srcPixel() { \ - highp float c = -dot(A, A); \ - highp vec2 val = vec2((-b + sqrt(b*b - 4.0*fmp2_m_radius2*c)) * inverse_2_fmp2_m_radius2, 0.5); \ - return texture2D(brushTexture, val); \ - }"; +static const char* const qglslRadialGradientBrushSrcFragmentShader = "\n\ + uniform lowp sampler2D brushTexture; \n\ + uniform highp float fmp2_m_radius2; \n\ + uniform highp float inverse_2_fmp2_m_radius2; \n\ + varying highp float b; \n\ + varying highp vec2 A; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + highp float c = -dot(A, A); \n\ + highp vec2 val = vec2((-b + sqrt(b*b - 4.0*fmp2_m_radius2*c)) * inverse_2_fmp2_m_radius2, 0.5); \n\ + return texture2D(brushTexture, val); \n\ + }\n"; // Texture Brush -static const char* const qglslPositionWithTextureBrushVertexShader = "\ - attribute highp vec2 vertexCoordsArray; \ - attribute highp vec3 pmvMatrix1; \ - attribute highp vec3 pmvMatrix2; \ - attribute highp vec3 pmvMatrix3; \ - uniform mediump vec2 halfViewportSize; \ - uniform highp vec2 invertedTextureSize; \ - uniform highp mat3 brushTransform; \ - varying highp vec2 textureCoords; \ - void setPosition(void) { \ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ - gl_Position.xy = transformedPos.xy / transformedPos.z; \ - mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ - mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ - mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ - gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \ - textureCoords.xy = (hTexCoords.xy * invertedTextureSize) * gl_Position.w; \ - }"; +static const char* const qglslPositionWithTextureBrushVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray; \n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + uniform mediump vec2 halfViewportSize; \n\ + uniform highp vec2 invertedTextureSize; \n\ + uniform highp mat3 brushTransform; \n\ + varying highp vec2 textureCoords; \n\ + void setPosition(void) \n\ + { \n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ + mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + textureCoords.xy = (hTexCoords.xy * invertedTextureSize) * gl_Position.w; \n\ + }\n"; static const char* const qglslAffinePositionWithTextureBrushVertexShader = qglslPositionWithTextureBrushVertexShader; @@ -287,148 +294,165 @@ static const char* const qglslAffinePositionWithTextureBrushVertexShader // OpenGL ES does not support GL_REPEAT wrap modes for NPOT textures. So instead, // we emulate GL_REPEAT by only taking the fractional part of the texture coords. // TODO: Special case POT textures which don't need this emulation -static const char* const qglslTextureBrushSrcFragmentShader = "\ - varying highp vec2 textureCoords; \ - uniform lowp sampler2D brushTexture; \ - lowp vec4 srcPixel() { \ - return texture2D(brushTexture, fract(textureCoords)); \ - }"; +static const char* const qglslTextureBrushSrcFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform lowp sampler2D brushTexture; \n\ + lowp vec4 srcPixel() { \n\ + return texture2D(brushTexture, fract(textureCoords)); \n\ + }\n"; #else -static const char* const qglslTextureBrushSrcFragmentShader = "\ - varying highp vec2 textureCoords; \ - uniform lowp sampler2D brushTexture; \ - lowp vec4 srcPixel() { \ - return texture2D(brushTexture, textureCoords); \ - }"; +static const char* const qglslTextureBrushSrcFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform lowp sampler2D brushTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return texture2D(brushTexture, textureCoords); \n\ + }\n"; #endif -static const char* const qglslTextureBrushSrcWithPatternFragmentShader = "\ - varying highp vec2 textureCoords; \ - uniform lowp vec4 patternColor; \ - uniform lowp sampler2D brushTexture; \ - lowp vec4 srcPixel() { \ - return patternColor * (1.0 - texture2D(brushTexture, textureCoords).r); \ - }"; +static const char* const qglslTextureBrushSrcWithPatternFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform lowp vec4 patternColor; \n\ + uniform lowp sampler2D brushTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return patternColor * (1.0 - texture2D(brushTexture, textureCoords).r); \n\ + }\n"; // Solid Fill Brush -static const char* const qglslSolidBrushSrcFragmentShader = "\ - uniform lowp vec4 fragmentColor; \ - lowp vec4 srcPixel() { \ - return fragmentColor; \ - }"; - -static const char* const qglslImageSrcFragmentShader = "\ - varying highp vec2 textureCoords; \ - uniform lowp sampler2D imageTexture; \ - lowp vec4 srcPixel() { \ - return texture2D(imageTexture, textureCoords); \ - }"; - -static const char* const qglslCustomSrcFragmentShader = "\ - varying highp vec2 textureCoords; \ - uniform lowp sampler2D imageTexture; \ - lowp vec4 customShader(lowp sampler2D texture, highp vec2 coords); \ - lowp vec4 srcPixel() { \ - return customShader(imageTexture, textureCoords); \ - }"; - -static const char* const qglslImageSrcWithPatternFragmentShader = "\ - varying highp vec2 textureCoords; \ - uniform lowp vec4 patternColor; \ - uniform lowp sampler2D imageTexture; \ - lowp vec4 srcPixel() { \ - return patternColor * (1.0 - texture2D(imageTexture, textureCoords).r); \ - }\n"; - -static const char* const qglslNonPremultipliedImageSrcFragmentShader = "\ - varying highp vec2 textureCoords; \ - uniform lowp sampler2D imageTexture; \ - lowp vec4 srcPixel() { \ - lowp vec4 sample = texture2D(imageTexture, textureCoords); \ - sample.rgb = sample.rgb * sample.a; \ - return sample; \ - }"; - -static const char* const qglslShockingPinkSrcFragmentShader = "\ - lowp vec4 srcPixel() { \ - return vec4(0.98, 0.06, 0.75, 1.0); \ - }"; - -static const char* const qglslMainFragmentShader_ImageArrays = "\ - varying lowp float opacity; \ - lowp vec4 srcPixel(); \ - void main() { \ - gl_FragColor = srcPixel() * opacity; \ - }"; - -static const char* const qglslMainFragmentShader_CMO = "\ - uniform lowp float globalOpacity; \ - lowp vec4 srcPixel(); \ - lowp vec4 applyMask(lowp vec4); \ - lowp vec4 compose(lowp vec4); \ - void main() { \ - gl_FragColor = applyMask(compose(srcPixel()*globalOpacity))); \ - }"; - -static const char* const qglslMainFragmentShader_CM = "\ - lowp vec4 srcPixel(); \ - lowp vec4 applyMask(lowp vec4); \ - lowp vec4 compose(lowp vec4); \ - void main() { \ - gl_FragColor = applyMask(compose(srcPixel())); \ - }"; - -static const char* const qglslMainFragmentShader_MO = "\ - uniform lowp float globalOpacity; \ - lowp vec4 srcPixel(); \ - lowp vec4 applyMask(lowp vec4); \ - void main() { \ - gl_FragColor = applyMask(srcPixel()*globalOpacity); \ - }"; - -static const char* const qglslMainFragmentShader_M = "\ - lowp vec4 srcPixel(); \ - lowp vec4 applyMask(lowp vec4); \ - void main() { \ - gl_FragColor = applyMask(srcPixel()); \ - }"; - -static const char* const qglslMainFragmentShader_CO = "\ - uniform lowp float globalOpacity; \ - lowp vec4 srcPixel(); \ - lowp vec4 compose(lowp vec4); \ - void main() { \ - gl_FragColor = compose(srcPixel()*globalOpacity); \ - }"; - -static const char* const qglslMainFragmentShader_C = "\ - lowp vec4 srcPixel(); \ - lowp vec4 compose(lowp vec4); \ - void main() { \ - gl_FragColor = compose(srcPixel()); \ - }"; - -static const char* const qglslMainFragmentShader_O = "\ - uniform lowp float globalOpacity; \ - lowp vec4 srcPixel(); \ - void main() { \ - gl_FragColor = srcPixel()*globalOpacity; \ - }"; - -static const char* const qglslMainFragmentShader = "\ - lowp vec4 srcPixel(); \ - void main() { \ - gl_FragColor = srcPixel(); \ - }"; - -static const char* const qglslMaskFragmentShader = "\ - varying highp vec2 textureCoords;\ - uniform lowp sampler2D maskTexture;\ - lowp vec4 applyMask(lowp vec4 src) \ - {\ - lowp vec4 mask = texture2D(maskTexture, textureCoords); \ - return src * mask.a; \ - }"; +static const char* const qglslSolidBrushSrcFragmentShader = "\n\ + uniform lowp vec4 fragmentColor; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return fragmentColor; \n\ + }\n"; + +static const char* const qglslImageSrcFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform lowp sampler2D imageTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return texture2D(imageTexture, textureCoords); \n\ + }\n"; + +static const char* const qglslCustomSrcFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform lowp sampler2D imageTexture; \n\ + lowp vec4 customShader(lowp sampler2D texture, highp vec2 coords); \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return customShader(imageTexture, textureCoords); \n\ + }\n"; + +static const char* const qglslImageSrcWithPatternFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform lowp vec4 patternColor; \n\ + uniform lowp sampler2D imageTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return patternColor * (1.0 - texture2D(imageTexture, textureCoords).r); \n\ + }\n"; + +static const char* const qglslNonPremultipliedImageSrcFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform lowp sampler2D imageTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + lowp vec4 sample = texture2D(imageTexture, textureCoords); \n\ + sample.rgb = sample.rgb * sample.a; \n\ + return sample; \n\ + }\n"; + +static const char* const qglslShockingPinkSrcFragmentShader = "\n\ + lowp vec4 srcPixel() \n\ + { \n\ + return vec4(0.98, 0.06, 0.75, 1.0); \n\ + }\n"; + +static const char* const qglslMainFragmentShader_ImageArrays = "\n\ + varying lowp float opacity; \n\ + lowp vec4 srcPixel(); \n\ + void main() \n\ + { \n\ + gl_FragColor = srcPixel() * opacity; \n\ + }\n"; + +static const char* const qglslMainFragmentShader_CMO = "\n\ + uniform lowp float globalOpacity; \n\ + lowp vec4 srcPixel(); \n\ + lowp vec4 applyMask(lowp vec4); \n\ + lowp vec4 compose(lowp vec4); \n\ + void main() \n\ + { \n\ + gl_FragColor = applyMask(compose(srcPixel()*globalOpacity))); \n\ + }\n"; + +static const char* const qglslMainFragmentShader_CM = "\n\ + lowp vec4 srcPixel(); \n\ + lowp vec4 applyMask(lowp vec4); \n\ + lowp vec4 compose(lowp vec4); \n\ + void main() \n\ + { \n\ + gl_FragColor = applyMask(compose(srcPixel())); \n\ + }\n"; + +static const char* const qglslMainFragmentShader_MO = "\n\ + uniform lowp float globalOpacity; \n\ + lowp vec4 srcPixel(); \n\ + lowp vec4 applyMask(lowp vec4); \n\ + void main() \n\ + { \n\ + gl_FragColor = applyMask(srcPixel()*globalOpacity); \n\ + }\n"; + +static const char* const qglslMainFragmentShader_M = "\n\ + lowp vec4 srcPixel(); \n\ + lowp vec4 applyMask(lowp vec4); \n\ + void main() \n\ + { \n\ + gl_FragColor = applyMask(srcPixel()); \n\ + }\n"; + +static const char* const qglslMainFragmentShader_CO = "\n\ + uniform lowp float globalOpacity; \n\ + lowp vec4 srcPixel(); \n\ + lowp vec4 compose(lowp vec4); \n\ + void main() \n\ + { \n\ + gl_FragColor = compose(srcPixel()*globalOpacity); \n\ + }\n"; + +static const char* const qglslMainFragmentShader_C = "\n\ + lowp vec4 srcPixel(); \n\ + lowp vec4 compose(lowp vec4); \n\ + void main() \n\ + { \n\ + gl_FragColor = compose(srcPixel()); \n\ + }\n"; + +static const char* const qglslMainFragmentShader_O = "\n\ + uniform lowp float globalOpacity; \n\ + lowp vec4 srcPixel(); \n\ + void main() \n\ + { \n\ + gl_FragColor = srcPixel()*globalOpacity; \n\ + }\n"; + +static const char* const qglslMainFragmentShader = "\n\ + lowp vec4 srcPixel(); \n\ + void main() \n\ + { \n\ + gl_FragColor = srcPixel(); \n\ + }\n"; + +static const char* const qglslMaskFragmentShader = "\n\ + varying highp vec2 textureCoords;\n\ + uniform lowp sampler2D maskTexture;\n\ + lowp vec4 applyMask(lowp vec4 src) \n\ + {\n\ + lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\ + return src * mask.a; \n\ + }\n"; // For source over with subpixel antialiasing, the final color is calculated per component as follows // (.a is alpha component, .c is red, green or blue component): @@ -445,23 +469,23 @@ static const char* const qglslMaskFragmentShader = "\ // dest.c = dest.c * (1 - mask.c) + src.c * alpha // -static const char* const qglslRgbMaskFragmentShaderPass1 = "\ - varying highp vec2 textureCoords;\ - uniform lowp sampler2D maskTexture;\ - lowp vec4 applyMask(lowp vec4 src) \ - {\ - lowp vec4 mask = texture2D(maskTexture, textureCoords); \ - return src.a * mask; \ - }"; - -static const char* const qglslRgbMaskFragmentShaderPass2 = "\ - varying highp vec2 textureCoords;\ - uniform lowp sampler2D maskTexture;\ - lowp vec4 applyMask(lowp vec4 src) \ - {\ - lowp vec4 mask = texture2D(maskTexture, textureCoords); \ - return src * mask; \ - }"; +static const char* const qglslRgbMaskFragmentShaderPass1 = "\n\ + varying highp vec2 textureCoords;\n\ + uniform lowp sampler2D maskTexture;\n\ + lowp vec4 applyMask(lowp vec4 src) \n\ + { \n\ + lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\ + return src.a * mask; \n\ + }\n"; + +static const char* const qglslRgbMaskFragmentShaderPass2 = "\n\ + varying highp vec2 textureCoords;\n\ + uniform lowp sampler2D maskTexture;\n\ + lowp vec4 applyMask(lowp vec4 src) \n\ + { \n\ + lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\ + return src * mask; \n\ + }\n"; /* Left to implement: -- cgit v0.12 From 06ee48f7ad7f5ab8bdbaed765d301fa2c0b417fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Thu, 21 Jan 2010 15:54:18 +0100 Subject: Make sure cursor is painted at the correct position when we are using IM. When the line edit was refactored into a line control this regression was introduced. This regression was introduced by change fb7d86cf23227302d48db279ec589221d11a1f6a. Task-number: QTBUG-4789 Reviewed-by: Alan Alpert --- src/gui/widgets/qlinecontrol.cpp | 5 ++++- src/gui/widgets/qlinecontrol_p.h | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 414c2ed..b0a64ea 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -524,8 +524,11 @@ void QLineControl::draw(QPainter *painter, const QPoint &offset, const QRect &cl m_textLayout.draw(painter, offset, selections, clip); if (flags & DrawCursor){ + int cursor = m_cursor; + if (m_preeditCursor != -1) + cursor += m_preeditCursor; if(!m_blinkPeriod || m_blinkStatus) - m_textLayout.drawCursor(painter, offset, m_cursor, m_cursorWidth); + m_textLayout.drawCursor(painter, offset, cursor, m_cursorWidth); } } diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index 301ff72..d6f2705 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -549,7 +549,10 @@ inline qreal QLineControl::cursorToX(int cursor) const inline qreal QLineControl::cursorToX() const { - return cursorToX(m_cursor); + int cursor = m_cursor; + if (m_preeditCursor != -1) + cursor += m_preeditCursor; + return cursorToX(cursor); } inline bool QLineControl::isReadOnly() const -- cgit v0.12 From 474e0dce59e827e4dd502bf12e7817b2602fb2c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 13 Jan 2010 16:44:57 +0100 Subject: Improve performance of QGraphicsItem::setParentItem. The biggest optimization here is "updateAncestorFlags()". It's much faster to update all the flags rather than trying to enable/disable certain flags according to the current state. Task-number: QTBUG-6877 Reviewed-by: alexis --- src/gui/graphicsview/qgraphicsitem.cpp | 67 ++++++++++++++++++++++----------- src/gui/graphicsview/qgraphicsitem_p.h | 9 +++-- src/gui/graphicsview/qgraphicsscene.cpp | 21 ++++++----- 3 files changed, 62 insertions(+), 35 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 1361a89..541df7c 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -798,8 +798,36 @@ void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag ch return; } - foreach (QGraphicsItem *child, children) - child->d_ptr->updateAncestorFlag(childFlag, flag, enabled, false); + for (int i = 0; i < children.size(); ++i) + children.at(i)->d_ptr->updateAncestorFlag(childFlag, flag, enabled, false); +} + +void QGraphicsItemPrivate::updateAncestorFlags() +{ + int flags = 0; + if (parent) { + // Inherit the parent's ancestor flags. + QGraphicsItemPrivate *pd = parent->d_ptr.data(); + flags = pd->ancestorFlags; + + // Add in flags from the parent. + if (pd->filtersDescendantEvents) + flags |= AncestorFiltersChildEvents; + if (pd->handlesChildEvents) + flags |= AncestorHandlesChildEvents; + if (pd->flags & QGraphicsItem::ItemClipsChildrenToShape) + flags |= AncestorClipsChildren; + if (pd->flags & QGraphicsItem::ItemIgnoresTransformations) + flags |= AncestorIgnoresTransformations; + } + + if (ancestorFlags == flags) + return; // No change; stop propagation. + ancestorFlags = flags; + + // Propagate to children recursively. + for (int i = 0; i < children.size(); ++i) + children.at(i)->d_ptr->updateAncestorFlags(); } /*! @@ -1002,7 +1030,8 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) if (scene) { // Deliver the change to the index - scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParentVariant); + if (scene->d_func()->indexMethod != QGraphicsScene::NoIndex) + scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParentVariant); // Disable scene pos notifications for old ancestors if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges)) @@ -1042,7 +1071,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) QGraphicsItem *p = parent; QGraphicsItem *parentFocusScopeItem = 0; while (p) { - if (p->flags() & QGraphicsItem::ItemIsFocusScope) { + if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) { // If this item's focus scope's focus scope item points // to this item or a descendent, then clear it. QGraphicsItem *fsi = p->d_ptr->focusScopeItem; @@ -1063,11 +1092,11 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) QGraphicsItem *ancestorScope = 0; QGraphicsItem *p = subFocusItem->d_ptr->parent; while (p) { - if (p->flags() & QGraphicsItem::ItemIsFocusScope) + if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) ancestorScope = p; - if (p->isPanel()) + if (p->d_ptr->flags & QGraphicsItem::ItemIsPanel) break; - p = p->parentItem(); + p = p->d_ptr->parent; } if (ancestorScope) newFocusScopeItem = ancestorScope; @@ -1075,7 +1104,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) QGraphicsItem *p = newParent; while (p) { - if (p->flags() & QGraphicsItem::ItemIsFocusScope) { + if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) { p->d_ptr->focusScopeItem = newFocusScopeItem; // Ensure the new item is no longer the subFocusItem. The // only way to set focus on a child of a focus scope is @@ -1111,30 +1140,24 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) } // Inherit ancestor flags from the new parent. - updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2)); - updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1)); - updateAncestorFlag(QGraphicsItem::ItemClipsChildrenToShape); - updateAncestorFlag(QGraphicsItem::ItemIgnoresTransformations); + updateAncestorFlags(); // Update item visible / enabled. - if (parent->isVisible() != visible) { - if (!parent->isVisible() || !explicitlyHidden) - setVisibleHelper(parent->isVisible(), /* explicit = */ false, /* update = */ !implicitUpdate); + if (parent->d_ptr->visible != visible) { + if (!parent->d_ptr->visible || !explicitlyHidden) + setVisibleHelper(parent->d_ptr->visible, /* explicit = */ false, /* update = */ !implicitUpdate); } if (parent->isEnabled() != enabled) { - if (!parent->isEnabled() || !explicitlyDisabled) - setEnabledHelper(parent->isEnabled(), /* explicit = */ false, /* update = */ !implicitUpdate); + if (!parent->d_ptr->enabled || !explicitlyDisabled) + setEnabledHelper(parent->d_ptr->enabled, /* explicit = */ false, /* update = */ !implicitUpdate); } // Auto-activate if visible and the parent is active. - if (q->isVisible() && parent->isActive()) + if (visible && parent->isActive()) q->setActive(true); } else { // Inherit ancestor flags from the new parent. - updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2)); - updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1)); - updateAncestorFlag(QGraphicsItem::ItemClipsChildrenToShape); - updateAncestorFlag(QGraphicsItem::ItemIgnoresTransformations); + updateAncestorFlags(); if (!inDestructor) { // Update item visible / enabled. diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 2d34b80..cfdd382 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -153,7 +153,7 @@ public: dirtyChildren(0), localCollisionHack(0), inSetPosHelper(0), - needSortChildren(1), // ### can be 0 by default? + needSortChildren(0), allChildrenDirty(0), fullUpdatePending(0), flags(0), @@ -197,6 +197,7 @@ public: void updateAncestorFlag(QGraphicsItem::GraphicsItemFlag childFlag, AncestorFlag flag = NoFlag, bool enabled = false, bool root = true); + void updateAncestorFlags(); void setIsMemberOfGroup(bool enabled); void remapItemPos(QEvent *event, QGraphicsItem *item); QPointF genericMapFromScene(const QPointF &pos, const QWidget *viewport) const; @@ -721,11 +722,13 @@ inline QTransform QGraphicsItemPrivate::transformToParent() const inline void QGraphicsItemPrivate::ensureSortedChildren() { if (needSortChildren) { - qSort(children.begin(), children.end(), qt_notclosestLeaf); needSortChildren = 0; sequentialOrdering = 1; + if (children.isEmpty()) + return; + qSort(children.begin(), children.end(), qt_notclosestLeaf); for (int i = 0; i < children.size(); ++i) { - if (children[i]->d_ptr->siblingIndex != i) { + if (children.at(i)->d_ptr->siblingIndex != i) { sequentialOrdering = 0; break; } diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index cea723c..49925e1 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -2482,12 +2482,12 @@ void QGraphicsScene::addItem(QGraphicsItem *item) qWarning("QGraphicsScene::addItem: cannot add null item"); return; } - if (item->scene() == this) { + if (item->d_ptr->scene == this) { qWarning("QGraphicsScene::addItem: item has already been added to this scene"); return; } // Remove this item from its existing scene - if (QGraphicsScene *oldScene = item->scene()) + if (QGraphicsScene *oldScene = item->d_ptr->scene) oldScene->removeItem(item); // Notify the item that its scene is changing, and allow the item to @@ -2496,15 +2496,15 @@ void QGraphicsScene::addItem(QGraphicsItem *item) qVariantFromValue(this))); QGraphicsScene *targetScene = qVariantValue(newSceneVariant); if (targetScene != this) { - if (targetScene && item->scene() != targetScene) + if (targetScene && item->d_ptr->scene != targetScene) targetScene->addItem(item); return; } // Detach this item from its parent if the parent's scene is different // from this scene. - if (QGraphicsItem *itemParent = item->parentItem()) { - if (itemParent->scene() != this) + if (QGraphicsItem *itemParent = item->d_ptr->parent) { + if (itemParent->d_ptr->scene != this) item->setParentItem(0); } @@ -2534,7 +2534,7 @@ void QGraphicsScene::addItem(QGraphicsItem *item) d->enableMouseTrackingOnViews(); } #ifndef QT_NO_CURSOR - if (d->allItemsUseDefaultCursor && item->hasCursor()) { + if (d->allItemsUseDefaultCursor && item->d_ptr->hasCursor) { d->allItemsUseDefaultCursor = false; if (d->allItemsIgnoreHoverEvents) // already enabled otherwise d->enableMouseTrackingOnViews(); @@ -2542,7 +2542,7 @@ void QGraphicsScene::addItem(QGraphicsItem *item) #endif //QT_NO_CURSOR // Enable touch events if the item accepts touch events. - if (d->allItemsIgnoreTouchEvents && item->acceptTouchEvents()) { + if (d->allItemsIgnoreTouchEvents && item->d_ptr->acceptTouchEvents) { d->allItemsIgnoreTouchEvents = false; d->enableTouchEventsOnViews(); } @@ -2575,8 +2575,9 @@ void QGraphicsScene::addItem(QGraphicsItem *item) } // Add all children recursively - foreach (QGraphicsItem *child, item->children()) - addItem(child); + item->d_ptr->ensureSortedChildren(); + for (int i = 0; i < item->d_ptr->children.size(); ++i) + addItem(item->d_ptr->children.at(i)); // Resolve font and palette. item->d_ptr->resolveFont(d->font.resolve()); @@ -2619,7 +2620,7 @@ void QGraphicsScene::addItem(QGraphicsItem *item) } } - if (item->flags() & QGraphicsItem::ItemSendsScenePositionChanges) + if (item->d_ptr->flags & QGraphicsItem::ItemSendsScenePositionChanges) d->registerScenePosItem(item); // Ensure that newly added items that have subfocus set, gain -- cgit v0.12 From dc3005761d332f86d59257e2c6bb8aac70222b18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 14 Jan 2010 11:43:05 +0100 Subject: Optimize QGraphicsScenePrivate::itemAcceptsHoverEvents_helper Make sure we do cheap tests before the more expensive ones. This function is called from QGraphicsScene::addItem. Task-number: QTBUG-6877 Reviewed-by: alexis --- src/gui/graphicsview/qgraphicsscene.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 49925e1..fa9f794 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -3767,10 +3767,10 @@ void QGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent) bool QGraphicsScenePrivate::itemAcceptsHoverEvents_helper(const QGraphicsItem *item) const { - return (!item->isBlockedByModalPanel() && - (item->acceptHoverEvents() - || (item->isWidget() - && static_cast(item)->d_func()->hasDecoration()))); + return (item->d_ptr->acceptsHover + || (item->d_ptr->isWidget + && static_cast(item)->d_func()->hasDecoration())) + && !item->isBlockedByModalPanel(); } /*! -- cgit v0.12 From 0dd05278e91ca1b0f4ffd32195584a57064ed24d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 14 Jan 2010 16:13:37 +0100 Subject: Optimize QGraphicsItem::setFlags. We don't have to do a full blown QGraphicsItem::setFlag call from QGraphicsItem::setFlags, only to change the ItemStacksBehindParent bits. We can do it directly (with care). Task-number: QTBUG-6877 Reviewed-by: alexis --- src/gui/graphicsview/qgraphicsitem.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 541df7c..8d77fcb 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1630,7 +1630,7 @@ bool QGraphicsItem::isWidget() const */ bool QGraphicsItem::isWindow() const { - return isWidget() && (static_cast(this)->windowType() & Qt::Window); + return d_ptr->isWidget && (static_cast(this)->windowType() & Qt::Window); } /*! @@ -1667,9 +1667,9 @@ QGraphicsItem::GraphicsItemFlags QGraphicsItem::flags() const void QGraphicsItem::setFlag(GraphicsItemFlag flag, bool enabled) { if (enabled) - setFlags(flags() | flag); + setFlags(GraphicsItemFlags(d_ptr->flags) | flag); else - setFlags(flags() & ~flag); + setFlags(GraphicsItemFlags(d_ptr->flags) & ~flag); } /*! @@ -1716,7 +1716,7 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) flags = GraphicsItemFlags(itemChange(ItemFlagsChange, quint32(flags)).toUInt()); if (quint32(d_ptr->flags) == quint32(flags)) return; - if (d_ptr->scene) + if (d_ptr->scene && d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex) d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, quint32(flags)); // Flags that alter the geometry of the item (or its children). @@ -1726,7 +1726,7 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) d_ptr->paintedViewBoundingRectsNeedRepaint = 1; // Keep the old flags to compare the diff. - GraphicsItemFlags oldFlags = this->flags(); + GraphicsItemFlags oldFlags = GraphicsItemFlags(d_ptr->flags); // Update flags. d_ptr->flags = flags; @@ -1755,7 +1755,23 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) d_ptr->updateAncestorFlag(ItemIgnoresTransformations); } + if ((flags & ItemNegativeZStacksBehindParent) != (oldFlags & ItemNegativeZStacksBehindParent)) { + // NB! We change the flags directly here, so we must also update d_ptr->flags. + // Note that this has do be done before the ItemStacksBehindParent check + // below; otherwise we will loose the change. + + // Update stack-behind. + if (d_ptr->z < qreal(0.0)) + flags |= ItemStacksBehindParent; + else + flags &= ~ItemStacksBehindParent; + d_ptr->flags = flags; + } + if ((flags & ItemStacksBehindParent) != (oldFlags & ItemStacksBehindParent)) { + // NB! This check has to come after the ItemNegativeZStacksBehindParent + // check above. Be careful. + // Ensure child item sorting is up to date when toggling this flag. if (d_ptr->parent) d_ptr->parent->d_ptr->needSortChildren = 1; @@ -1769,10 +1785,6 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) d_ptr->scene->d_func()->updateInputMethodSensitivityInViews(); } - if ((flags & ItemNegativeZStacksBehindParent) != (oldFlags & ItemNegativeZStacksBehindParent)) { - // Update stack-behind. - setFlag(ItemStacksBehindParent, d_ptr->z < qreal(0.0)); - } if ((d_ptr->panelModality != NonModal) && d_ptr->scene -- cgit v0.12 From b5754f5bd28ed01979e94983ae0480e913649d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 19 Jan 2010 13:18:55 +0100 Subject: Pass value as const void *const to QGraphicsSceneIndex::itemChange. We need this change in order to bypass some of the QVariant itemChange notifications from QGraphicsItem::setParentItem. All this is internal stuff and we know what we do, so I don't consider the change too ugly. Task-number: QTBUG-6877 Reviewed-by: alexis --- src/gui/graphicsview/qgraphicsitem.cpp | 8 ++++---- src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp | 10 +++++----- src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h | 2 +- src/gui/graphicsview/qgraphicssceneindex.cpp | 2 +- src/gui/graphicsview/qgraphicssceneindex_p.h | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 8d77fcb..5c7ea76 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1031,7 +1031,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) if (scene) { // Deliver the change to the index if (scene->d_func()->indexMethod != QGraphicsScene::NoIndex) - scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParentVariant); + scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParent); // Disable scene pos notifications for old ancestors if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges)) @@ -1717,7 +1717,7 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) if (quint32(d_ptr->flags) == quint32(flags)) return; if (d_ptr->scene && d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex) - d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, quint32(flags)); + d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, &flags); // Flags that alter the geometry of the item (or its children). const quint32 geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations | ItemIsSelectable); @@ -4299,9 +4299,9 @@ void QGraphicsItem::setZValue(qreal z) if (newZ == d_ptr->z) return; - if (d_ptr->scene) { + if (d_ptr->scene && d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex) { // Z Value has changed, we have to notify the index. - d_ptr->scene->d_func()->index->itemChange(this, ItemZValueChange, newZVariant); + d_ptr->scene->d_func()->index->itemChange(this, ItemZValueChange, &newZ); } d_ptr->z = newZ; diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp index 2e92b87..2a91348 100644 --- a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp +++ b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp @@ -635,16 +635,17 @@ void QGraphicsSceneBspTreeIndex::updateSceneRect(const QRectF &rect) This method react to the \a change of the \a item and use the \a value to update the BSP tree if necessary. */ -void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const QVariant &value) +void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const void *const value) { Q_D(QGraphicsSceneBspTreeIndex); switch (change) { case QGraphicsItem::ItemFlagsChange: { // Handle ItemIgnoresTransformations + QGraphicsItem::GraphicsItemFlags newFlags = *static_cast(value); bool ignoredTransform = item->d_ptr->flags & QGraphicsItem::ItemIgnoresTransformations; - bool willIgnoreTransform = value.toUInt() & QGraphicsItem::ItemIgnoresTransformations; + bool willIgnoreTransform = newFlags & QGraphicsItem::ItemIgnoresTransformations; bool clipsChildren = item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape; - bool willClipChildren = value.toUInt() & QGraphicsItem::ItemClipsChildrenToShape; + bool willClipChildren = newFlags & QGraphicsItem::ItemClipsChildrenToShape; if ((ignoredTransform != willIgnoreTransform) || (clipsChildren != willClipChildren)) { QGraphicsItem *thatItem = const_cast(item); // Remove item and its descendants from the index and append @@ -661,7 +662,7 @@ void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphics case QGraphicsItem::ItemParentChange: { d->invalidateSortCache(); // Handle ItemIgnoresTransformations - QGraphicsItem *newParent = qVariantValue(value); + const QGraphicsItem *newParent = static_cast(value); bool ignoredTransform = item->d_ptr->itemIsUntransformable(); bool willIgnoreTransform = (item->d_ptr->flags & QGraphicsItem::ItemIgnoresTransformations) || (newParent && newParent->d_ptr->itemIsUntransformable()); @@ -682,7 +683,6 @@ void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphics default: break; } - return QGraphicsSceneIndex::itemChange(item, change, value); } /*! \reimp diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h b/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h index 119571b..f671fd9 100644 --- a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h +++ b/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h @@ -97,7 +97,7 @@ protected: void removeItem(QGraphicsItem *item); void prepareBoundingRectChange(const QGraphicsItem *item); - void itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const QVariant &value); + void itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const void *const value); private : Q_DECLARE_PRIVATE(QGraphicsSceneBspTreeIndex) diff --git a/src/gui/graphicsview/qgraphicssceneindex.cpp b/src/gui/graphicsview/qgraphicssceneindex.cpp index bc8a7dc..043c4eb 100644 --- a/src/gui/graphicsview/qgraphicssceneindex.cpp +++ b/src/gui/graphicsview/qgraphicssceneindex.cpp @@ -624,7 +624,7 @@ void QGraphicsSceneIndex::deleteItem(QGraphicsItem *item) \sa QGraphicsItem::GraphicsItemChange */ -void QGraphicsSceneIndex::itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const QVariant &value) +void QGraphicsSceneIndex::itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const void *const value) { Q_UNUSED(item); Q_UNUSED(change); diff --git a/src/gui/graphicsview/qgraphicssceneindex_p.h b/src/gui/graphicsview/qgraphicssceneindex_p.h index def58f0..597a229 100644 --- a/src/gui/graphicsview/qgraphicssceneindex_p.h +++ b/src/gui/graphicsview/qgraphicssceneindex_p.h @@ -110,7 +110,7 @@ protected: virtual void removeItem(QGraphicsItem *item) = 0; virtual void deleteItem(QGraphicsItem *item); - virtual void itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange, const QVariant &value); + virtual void itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange, const void *const value); virtual void prepareBoundingRectChange(const QGraphicsItem *item); QGraphicsSceneIndex(QGraphicsSceneIndexPrivate &dd, QGraphicsScene *scene); -- cgit v0.12 From 3c215a1644adcca32cfc451456b6891f9c8519fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 19 Jan 2010 13:30:55 +0100 Subject: Only send QGraphicsItem::ParentChange(d) notifications from setParentItem. QmlGraphicsItem doesn't need any parent change notifactions so we can call the helper class (QGraphicsItemPrivate::setParentItemHelper) direclty from QmlGraphicsItem::setParentItem. This avoids a lot of unnecessary instructions related to QVariant constructions as well as virtual function calls. I've made the variant pointers explicit in the declaration of setParentItemHelper so that we don't accidentally call setParentItemHelper from places where we need parent change notifications. Task-number: QTBUG-6877 Reviewed-by: alexis --- src/gui/graphicsview/qgraphicsitem.cpp | 43 +++++++++++++++++++-------------- src/gui/graphicsview/qgraphicsitem_p.h | 3 ++- src/gui/graphicsview/qgraphicsscene.cpp | 2 +- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 5c7ea76..d43176b 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1012,19 +1012,10 @@ QVariant QGraphicsItemPrivate::inputMethodQueryHelper(Qt::InputMethodQuery query prepareGeometryChange) if the item is in its destructor, i.e. inDestructor is 1. */ -void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) +void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const QVariant *newParentVariant, + const QVariant *thisPointerVariant) { Q_Q(QGraphicsItem); - if (newParent == q) { - qWarning("QGraphicsItem::setParentItem: cannot assign %p as a parent of itself", this); - return; - } - if (newParent == parent) - return; - - const QVariant newParentVariant(q->itemChange(QGraphicsItem::ItemParentChange, - qVariantFromValue(newParent))); - newParent = qVariantValue(newParentVariant); if (newParent == parent) return; @@ -1049,11 +1040,11 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) if (!inDestructor) q_ptr->prepareGeometryChange(); - const QVariant thisPointerVariant(qVariantFromValue(q)); if (parent) { // Remove from current parent parent->d_ptr->removeChild(q); - parent->itemChange(QGraphicsItem::ItemChildRemovedChange, thisPointerVariant); + if (thisPointerVariant) + parent->itemChange(QGraphicsItem::ItemChildRemovedChange, *thisPointerVariant); } // Update toplevelitem list. If this item is being deleted, its parent @@ -1129,7 +1120,8 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) } parent->d_ptr->addChild(q); - parent->itemChange(QGraphicsItem::ItemChildAddedChange, thisPointerVariant); + if (thisPointerVariant) + parent->itemChange(QGraphicsItem::ItemChildAddedChange, *thisPointerVariant); if (scene) { if (!implicitUpdate) scene->d_func()->markDirty(q_ptr); @@ -1184,7 +1176,8 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) } // Deliver post-change notification - q->itemChange(QGraphicsItem::ItemParentHasChanged, newParentVariant); + if (newParentVariant) + q->itemChange(QGraphicsItem::ItemParentHasChanged, *newParentVariant); if (isObject) emit static_cast(q)->parentChanged(); @@ -1373,7 +1366,7 @@ QGraphicsItem::~QGraphicsItem() d_ptr->scene->d_func()->removeItemHelper(this); } else { d_ptr->resetFocusProxy(); - d_ptr->setParentItemHelper(0); + setParentItem(0); } #ifndef QT_NO_GRAPHICSEFFECT @@ -1578,9 +1571,23 @@ const QGraphicsObject *QGraphicsItem::toGraphicsObject() const \sa parentItem(), childItems() */ -void QGraphicsItem::setParentItem(QGraphicsItem *parent) +void QGraphicsItem::setParentItem(QGraphicsItem *newParent) { - d_ptr->setParentItemHelper(parent); + if (newParent == this) { + qWarning("QGraphicsItem::setParentItem: cannot assign %p as a parent of itself", this); + return; + } + if (newParent == d_ptr->parent) + return; + + const QVariant newParentVariant(itemChange(QGraphicsItem::ItemParentChange, + qVariantFromValue(newParent))); + newParent = qVariantValue(newParentVariant); + if (newParent == d_ptr->parent) + return; + + const QVariant thisPointerVariant(qVariantFromValue(this)); + d_ptr->setParentItemHelper(newParent, &newParentVariant, &thisPointerVariant); } /*! diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index cfdd382..ac10aa7 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -230,7 +230,8 @@ public: void resolveDepth(); void addChild(QGraphicsItem *child); void removeChild(QGraphicsItem *child); - void setParentItemHelper(QGraphicsItem *parent); + void setParentItemHelper(QGraphicsItem *parent, const QVariant *newParentVariant, + const QVariant *thisPointerVariant); void childrenBoundingRectHelper(QTransform *x, QRectF *rect); void initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform, const QRegion &exposedRegion, bool allItems = false) const; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index fa9f794..088a6b9 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -599,7 +599,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) if (parentItem->scene()) { Q_ASSERT_X(parentItem->scene() == q, "QGraphicsScene::removeItem", "Parent item's scene is different from this item's scene"); - item->d_ptr->setParentItemHelper(0); + item->setParentItem(0); } } else { unregisterTopLevelItem(item); -- cgit v0.12 From 57c7df82ffbace8924c7ac8875ef4343783a2376 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 21 Jan 2010 08:49:12 +0100 Subject: Don't use a mutex lock in QPainter::redirection unless strictly required Reviewed-by: Trond --- src/gui/painting/qpainter.cpp | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 31132d9..1258d6b 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7382,10 +7382,15 @@ struct QPaintDeviceRedirection typedef QList QPaintDeviceRedirectionList; Q_GLOBAL_STATIC(QPaintDeviceRedirectionList, globalRedirections) Q_GLOBAL_STATIC(QMutex, globalRedirectionsMutex) +Q_GLOBAL_STATIC(QAtomicInt, globalRedirectionAtomic) /*! \threadsafe + \obsolete + + Please use QWidget::render() instead. + Redirects all paint commands for the given paint \a device, to the \a replacement device. The optional point \a offset defines an offset within the source device. @@ -7395,9 +7400,10 @@ Q_GLOBAL_STATIC(QMutex, globalRedirectionsMutex) device's painter (if any) before redirecting. Call restoreRedirected() to restore the previous redirection. - In general, you'll probably find that calling - QPixmap::grabWidget() or QPixmap::grabWindow() is an easier - solution. + \warning Making use of redirections in the QPainter API implies + that QPainter::begin() and QPaintDevice destructors need to hold + a mutex for a short period. This can impact performance. Use of + QWidget::render is strongly encouraged. \sa redirected(), restoreRedirected() */ @@ -7429,14 +7435,24 @@ void QPainter::setRedirected(const QPaintDevice *device, Q_ASSERT(redirections != 0); *redirections += QPaintDeviceRedirection(device, rdev ? rdev : replacement, offset + roffset, hadInternalWidgetRedirection ? redirections->size() - 1 : -1); + globalRedirectionAtomic()->ref(); } /*! \threadsafe + \obsolete + + Using QWidget::render() obsoletes the use of this function. + Restores the previous redirection for the given \a device after a call to setRedirected(). + \warning Making use of redirections in the QPainter API implies + that QPainter::begin() and QPaintDevice destructors need to hold + a mutex for a short period. This can impact performance. Use of + QWidget::render is strongly encouraged. + \sa redirected() */ void QPainter::restoreRedirected(const QPaintDevice *device) @@ -7447,6 +7463,7 @@ void QPainter::restoreRedirected(const QPaintDevice *device) Q_ASSERT(redirections != 0); for (int i = redirections->size()-1; i >= 0; --i) { if (redirections->at(i) == device) { + globalRedirectionAtomic()->deref(); const int internalWidgetRedirectionIndex = redirections->at(i).internalWidgetRedirectionIndex; redirections->removeAt(i); // Restore the internal widget redirection, i.e. remove it from the global @@ -7468,21 +7485,34 @@ void QPainter::restoreRedirected(const QPaintDevice *device) /*! \threadsafe + \obsolete + + Using QWidget::render() obsoletes the use of this function. + Returns the replacement for given \a device. The optional out parameter \a offset returns the offset within the replaced device. + \warning Making use of redirections in the QPainter API implies + that QPainter::begin() and QPaintDevice destructors need to hold + a mutex for a short period. This can impact performance. Use of + QWidget::render is strongly encouraged. + \sa setRedirected(), restoreRedirected() */ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset) { Q_ASSERT(device != 0); + if (*globalRedirectionAtomic() == 0) + return 0; + if (device->devType() == QInternal::Widget) { const QWidgetPrivate *widgetPrivate = static_cast(device)->d_func(); if (widgetPrivate->redirectDev) return widgetPrivate->redirected(offset); } + QMutexLocker locker(globalRedirectionsMutex()); QPaintDeviceRedirectionList *redirections = globalRedirections(); Q_ASSERT(redirections != 0); @@ -7500,6 +7530,9 @@ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset) void qt_painter_removePaintDevice(QPaintDevice *dev) { + if (*globalRedirectionAtomic() == 0) + return; + QMutex *mutex = 0; QT_TRY { mutex = globalRedirectionsMutex(); -- cgit v0.12 From 03c77ad02d5a3c69f4edfdfd2f3ef7cd7dc67aaa Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 22 Jan 2010 08:31:32 +0100 Subject: Fix documentation bug in QColor --- src/gui/painting/qcolor.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index f51dc36..d6d288e 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -934,8 +934,7 @@ void QColor::setRgb(int r, int g, int b, int a) /*! \fn QRgb QColor::rgba() const - Returns the RGB value of the color. Unlike rgb(), the alpha is not - stripped. + Returns the RGB value of the color, including its alpha. For an invalid color, the alpha value of the returned color is unspecified. @@ -950,8 +949,7 @@ QRgb QColor::rgba() const } /*! - Sets the RGBA value to \a rgba. Unlike setRgb(QRgb rgb), this function does - not ignore the alpha. + Sets the RGB value to \a rgba, including its alpha. \sa rgba(), rgb() */ @@ -968,8 +966,7 @@ void QColor::setRgba(QRgb rgba) /*! \fn QRgb QColor::rgb() const - Returns the RGB value of the color. The alpha is stripped for - compatibility. + Returns the RGB value of the color. The alpha value is opaque. \sa getRgb(), rgba() */ @@ -983,7 +980,7 @@ QRgb QColor::rgb() const /*! \overload - Sets the RGB value to \a rgb, ignoring the alpha. + Sets the RGB value to \a rgb. The alpha value is set to opaque. */ void QColor::setRgb(QRgb rgb) { -- cgit v0.12 From 820f55c3274c07a42ea01a96ad5405db343891d2 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 22 Jan 2010 09:18:28 +0100 Subject: Fix the parallel build of QtWebKit Added the missing dependency to xmlpatterns, to ensure it's built before QtWebKit if available. Reviewed-by: Tom --- src/src.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/src/src.pro b/src/src.pro index 8dec49b..f2070ae 100644 --- a/src/src.pro +++ b/src/src.pro @@ -106,6 +106,7 @@ src_declarative.target = sub-declarative contains(QT_CONFIG, webkit) { src_webkit.depends = src_gui src_sql src_network src_xml contains(QT_CONFIG, phonon):src_webkit.depends += src_phonon + contains(QT_CONFIG, xmlpatterns): src_webkit.depends += src_xmlpatterns contains(QT_CONFIG, declarative):src_declarative.depends += src_webkit #exists($$QT_SOURCE_TREE/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro): src_webkit.depends += src_javascriptcore } -- cgit v0.12 From fa41110be15ce458bd2b49bda03b147775d2ab01 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 22 Jan 2010 10:13:53 +0100 Subject: removed a debug trace --- src/corelib/animation/qabstractanimation.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 2b4ab47..cedb43f 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -299,8 +299,6 @@ void QUnifiedTimer::registerRunningAnimation(QAbstractAnimation *animation) return; if (QAbstractAnimationPrivate::get(animation)->isPause) { - if (animation->duration() == -1) - qDebug() << "toto"; runningPauseAnimations << animation; } else runningLeafAnimations++; -- cgit v0.12 From ec44f83c4c7fa77e609a2458c4a5e26054fd5e85 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 22 Jan 2010 11:10:35 +0100 Subject: Fix rendering with simple shader in GL2 engine Need to bind the PMV matrix's attributes to their indexes in the simple shader, which is created in a seperate code path to all the other shaders. This should fix the qgl autotest failures. Reviewed-By: TrustMe --- src/opengl/gl2paintengineex/qglengineshadermanager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 9fd9e18..8183f08 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -184,6 +184,9 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) simpleShaderProg->addShader(vertexShader); simpleShaderProg->addShader(fragShader); simpleShaderProg->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); + simpleShaderProg->bindAttributeLocation("pmvMatrix1", QT_PMV_MATRIX_1_ATTR); + simpleShaderProg->bindAttributeLocation("pmvMatrix2", QT_PMV_MATRIX_2_ATTR); + simpleShaderProg->bindAttributeLocation("pmvMatrix3", QT_PMV_MATRIX_3_ATTR); simpleShaderProg->link(); if (!simpleShaderProg->isLinked()) { qCritical() << "Errors linking simple shader:" -- cgit v0.12 From 5236f93d78d0a09f80819d364867793dd73112e9 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 22 Jan 2010 11:30:05 +0100 Subject: Add a reference to adjustSize() from the size property Task-number: QTBUG-7401 Reviewed-by: TrustMe --- src/gui/kernel/qwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 81a9a80..5fedb31 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -3344,7 +3344,7 @@ QPoint QWidget::pos() const \note Setting the size to \c{QSize(0, 0)} will cause the widget to not appear on screen. This also applies to windows. - \sa pos, geometry, minimumSize, maximumSize, resizeEvent() + \sa pos, geometry, minimumSize, maximumSize, resizeEvent(), adjustSize() */ /*! -- cgit v0.12 From 2ab883ca32df15f649b98120278707e078668c05 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 22 Jan 2010 12:39:18 +0100 Subject: Fix y-inverted pixmaps properly. There is a lot of code depending on that pixmaps are flipped upside down in the gl graphicssystem, so toggling this requires extensive testing. Since we're anyway questioning the relevance of this feature (compared to raster + GL viewport) its simply not worth the effort to fix it properly right now. Revert "Fixed y-inverted pixmaps on N900." This reverts commit 57473d5d2a7bd6ae3117f61ff29264a1b790bb01. --- src/opengl/qpixmapdata_gl.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index 6d47687..aa80664 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -252,10 +252,6 @@ QGLPixmapData::QGLPixmapData(PixelType type) { setSerialNumber(++qt_gl_pixmap_serial); m_glDevice.setPixmapData(this); - - // Set InteralBindOptions minus the memory managed, since this - // QGLTexture is not managed as part of the internal texture cache - m_texture.options = QGLContext::PremultipliedAlphaBindOption; } QGLPixmapData::~QGLPixmapData() @@ -344,18 +340,18 @@ void QGLPixmapData::ensureCreated() const } if (!m_source.isNull()) { - glBindTexture(target, m_texture.id); if (external_format == GL_RGB) { - const QImage tx = m_source.convertToFormat(QImage::Format_RGB888); + const QImage tx = m_source.convertToFormat(QImage::Format_RGB888).mirrored(false, true); + + glBindTexture(target, m_texture.id); glTexSubImage2D(target, 0, 0, 0, w, h, external_format, GL_UNSIGNED_BYTE, tx.bits()); } else { const QImage tx = ctx->d_func()->convertToGLFormat(m_source, true, external_format); + + glBindTexture(target, m_texture.id); glTexSubImage2D(target, 0, 0, 0, w, h, external_format, GL_UNSIGNED_BYTE, tx.bits()); - // convertToGLFormat will flip the Y axis, so it needs to - // be drawn upside down - m_texture.options |= QGLContext::InvertedYBindOption; } if (useFramebufferObjects()) -- cgit v0.12 From b4eb07f77f2b5793151a9aa9fb60fd3ef96c21da Mon Sep 17 00:00:00 2001 From: kh1 Date: Thu, 21 Jan 2010 18:17:13 +0100 Subject: Use HighlightAllOccurrences to have highlighting after full text search. Also use HighlightAllOccurrences to have highlighting during type and search. Some more refactoring. Task-number: QTBUG-3335 Reviewed-by: ck --- tools/assistant/tools/assistant/centralwidget.cpp | 95 +++++++++++++++-------- tools/assistant/tools/assistant/centralwidget.h | 8 +- 2 files changed, 67 insertions(+), 36 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 0b177ae..c8f41e4 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -358,7 +358,7 @@ void CentralWidget::zoomOut() void CentralWidget::findNext() { - find(findWidget->editFind->text(), true, false); + find(findWidget->editFind->text(), true); } void CentralWidget::nextPage() @@ -389,7 +389,7 @@ void CentralWidget::previousPage() void CentralWidget::findPrevious() { - find(findWidget->editFind->text(), false, true); + find(findWidget->editFind->text(), false); } void CentralWidget::closeTab() @@ -697,7 +697,7 @@ HelpViewer *CentralWidget::newEmptyTab() void CentralWidget::findCurrentText(const QString &text) { - find(text, false, false); + find(text, true); } void CentralWidget::connectSignals() @@ -896,19 +896,35 @@ void CentralWidget::keyPressEvent(QKeyEvent *e) QWidget::keyPressEvent(e); } -void CentralWidget::find(const QString &ttf, bool forward, bool backward) +void CentralWidget::find(const QString &ttf, bool forward) { QPalette p = findWidget->editFind->palette(); p.setColor(QPalette::Active, QPalette::Base, Qt::white); - if (!ttf.isEmpty()) { - HelpViewer *viewer = currentHelpViewer(); + bool found = false; - bool found = false; +#if defined(QT_NO_WEBKIT) + found = findInTextBrowser(ttf, forward); +#else + found = findInWebPage(ttf, forward); +#endif + + if (!found && !ttf.isEmpty()) + p.setColor(QPalette::Active, QPalette::Base, QColor(255, 102, 102)); + + if (!findWidget->isVisible()) + findWidget->show(); + findWidget->editFind->setPalette(p); +} + +bool CentralWidget::findInWebPage(const QString &ttf, bool forward) +{ #if !defined(QT_NO_WEBKIT) - if (viewer) { - QWebPage::FindFlags options; - if (backward) + if (HelpViewer *viewer = currentHelpViewer()) { + bool found = false; + QWebPage::FindFlags options; + if (!ttf.isEmpty()) { + if (!forward) options |= QWebPage::FindBackward; if (findWidget->checkCase->isChecked()) @@ -923,30 +939,27 @@ void CentralWidget::find(const QString &ttf, bool forward, bool backward) if (found) findWidget->labelWrapped->show(); } - } else if (tabWidget->currentWidget() == m_searchWidget) { - QTextBrowser *browser = qFindChild(m_searchWidget); - found = findInTextBrowser(browser, ttf, forward, backward); } -#else - QTextBrowser *browser = qobject_cast(viewer); - if (tabWidget->currentWidget() == m_searchWidget) - browser = qFindChild(m_searchWidget); - found = findInTextBrowser(browser, ttf, forward, backward); -#endif - - if (!found) - p.setColor(QPalette::Active, QPalette::Base, QColor(255, 102, 102)); + // force highlighting of all other matches, also when empty (clear) + options = QWebPage::HighlightAllOccurrences; + viewer->findText(QLatin1String(""), options); + viewer->findText(ttf, options); + return found; } - if (!findWidget->isVisible()) - findWidget->show(); - findWidget->editFind->setPalette(p); + // this needs to stay, case for active search results page + return findInTextBrowser(ttf, forward); +#endif + return false; } -bool CentralWidget::findInTextBrowser(QTextBrowser* browser, const QString &ttf, - bool forward, bool backward) +bool CentralWidget::findInTextBrowser(const QString &ttf, bool forward) { - if (!browser) + QTextBrowser *browser = qobject_cast(currentHelpViewer()); + if (tabWidget->currentWidget() == m_searchWidget) + browser = qFindChild(m_searchWidget); + + if (!browser || ttf.isEmpty()) return false; QTextDocument *doc = browser->document(); @@ -962,7 +975,7 @@ bool CentralWidget::findInTextBrowser(QTextBrowser* browser, const QString &ttf, QTextCursor::MoveAnchor); } - if (backward) + if (!forward) options |= QTextDocument::FindBackward; if (findWidget->checkCase->isChecked()) @@ -1074,20 +1087,29 @@ void CentralWidget::setSourceFromSearch(const QUrl &url) { setSource(url); - highlightSearchTerms(); +#if defined(QT_NO_WEBKIT) + highlightSearchTerms() +#else + connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, + SLOT(highlightSearchTerms())); +#endif } void CentralWidget::setSourceFromSearchInNewTab(const QUrl &url) { setSourceInNewTab(url); - highlightSearchTerms(); +#if defined(QT_NO_WEBKIT) + highlightSearchTerms() +#else + connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, + SLOT(highlightSearchTerms())); +#endif } void CentralWidget::highlightSearchTerms() { -#if defined(QT_NO_WEBKIT) HelpViewer *viewer = currentHelpViewer(); if (!viewer) return; @@ -1109,6 +1131,7 @@ CentralWidget::highlightSearchTerms() } } +#if defined(QT_NO_WEBKIT) viewer->viewport()->setUpdatesEnabled(false); QTextCharFormat marker; @@ -1140,6 +1163,14 @@ CentralWidget::highlightSearchTerms() viewer->setTextCursor(firstHit); viewer->viewport()->setUpdatesEnabled(true); +#else + viewer->findText("", QWebPage::HighlightAllOccurrences); + // clears existing selections + foreach (const QString& term, terms) + viewer->findText(term, QWebPage::HighlightAllOccurrences); + + disconnect(viewer, SIGNAL(loadFinished(bool)), this, + SLOT(highlightSearchTerms())); #endif } diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index 6c23190..9e32985 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -182,16 +182,16 @@ private slots: void printPreview(QPrinter *printer); void setSourceFromSearch(const QUrl &url); void setSourceFromSearchInNewTab(const QUrl &url); + void highlightSearchTerms(); private: void connectSignals(); bool eventFilter(QObject *object, QEvent *e); - void find(const QString &ttf, bool forward, bool backward); - bool findInTextBrowser(QTextBrowser* browser, const QString &ttf, - bool forward, bool backward); + void find(const QString &ttf, bool forward); + bool findInWebPage(const QString &ttf, bool forward); + bool findInTextBrowser(const QString &ttf, bool forward); void initPrinter(); QString quoteTabTitle(const QString &title) const; - void highlightSearchTerms(); void setLastShownPages(); void getBrowserFontFor(QWidget* viewer, QFont *font); -- cgit v0.12 From cbfe5019e135b85df37b3f38f79bef4dbe397cf6 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 22 Jan 2010 13:55:31 +0100 Subject: revert parts of 10392eef4fd4f9 We can't call QCOMPARE from within a nested function, because the return statement will just exit that function. VERIFY_COLOR can't be turned into a function this way. --- tests/auto/qwidget/tst_qwidget.cpp | 50 ++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index ee4e726..ea90ae3 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -5439,26 +5439,24 @@ public: QRegion r; }; -template -void verifyColor(R const& region, C const& color) -{ - const QRegion r = QRegion(region); - for (int i = 0; i < r.rects().size(); ++i) { - const QRect rect = r.rects().at(i); - for (int t = 0; t < 5; t++) { - const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), - rect.left(), rect.top(), - rect.width(), rect.height()); - QCOMPARE(pixmap.size(), rect.size()); - QPixmap expectedPixmap(pixmap); /* ensure equal formats */ - expectedPixmap.fill(color); - if (pixmap.toImage().pixel(0,0) != QColor(color).rgb() && t < 4 ) - { QTest::qWait(200); continue; } - QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb()); - QCOMPARE(pixmap, expectedPixmap); - break; - } - } +#define VERIFY_COLOR(region, color) { \ + const QRegion r = QRegion(region); \ + for (int i = 0; i < r.rects().size(); ++i) { \ + const QRect rect = r.rects().at(i); \ + for (int t = 0; t < 5; t++) { \ + const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), \ + rect.left(), rect.top(), \ + rect.width(), rect.height()); \ + QCOMPARE(pixmap.size(), rect.size()); \ + QPixmap expectedPixmap(pixmap); /* ensure equal formats */ \ + expectedPixmap.fill(color); \ + if (pixmap.toImage().pixel(0,0) != QColor(color).rgb() && t < 4 ) \ + { QTest::qWait(200); continue; } \ + QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb()); \ + QCOMPARE(pixmap, expectedPixmap); \ + break; \ + } \ + } \ } void tst_QWidget::moveChild_data() @@ -5499,9 +5497,9 @@ void tst_QWidget::moveChild() #endif QTRY_COMPARE(parent.r, QRegion(parent.rect()) - child.geometry()); QTRY_COMPARE(child.r, QRegion(child.rect())); - verifyColor(child.geometry().translated(tlwOffset), + VERIFY_COLOR(child.geometry().translated(tlwOffset), child.color); - verifyColor(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), + VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), parent.color); parent.reset(); child.reset(); @@ -5520,9 +5518,9 @@ void tst_QWidget::moveChild() // should be scrolled in backingstore QCOMPARE(child.r, QRegion()); #endif - verifyColor(child.geometry().translated(tlwOffset), + VERIFY_COLOR(child.geometry().translated(tlwOffset), child.color); - verifyColor(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), + VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), parent.color); } @@ -5553,8 +5551,8 @@ void tst_QWidget::showAndMoveChild() child.move(desktopDimensions.width()/2, desktopDimensions.height()/2); qApp->processEvents(); - verifyColor(child.geometry().translated(tlwOffset), Qt::blue); - verifyColor(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), Qt::red); + VERIFY_COLOR(child.geometry().translated(tlwOffset), Qt::blue); + VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), Qt::red); } void tst_QWidget::subtractOpaqueSiblings() -- cgit v0.12 From c8f4319b3a2ddacacd3bca67861a41e22dd1ada0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 22 Jan 2010 13:56:21 +0100 Subject: Re-added the Close button in QPrintPreviewDialog for Mac/Carbon. Modal Mac/Carbon dialogs do not have the close, minimize and resize window title buttons enabled, which makes it very hard to close modal dialogs. Task-number: QTBUG-7481 Reviewed-by: Kim --- src/gui/dialogs/qprintpreviewdialog.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gui/dialogs/qprintpreviewdialog.cpp b/src/gui/dialogs/qprintpreviewdialog.cpp index 42be780..6723b53 100644 --- a/src/gui/dialogs/qprintpreviewdialog.cpp +++ b/src/gui/dialogs/qprintpreviewdialog.cpp @@ -207,6 +207,9 @@ public: QActionGroup *printerGroup; QAction *printAction; QAction *pageSetupAction; +#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) + QAction *closeAction; +#endif QPointer receiverToDisconnectOnClose; QByteArray memberToDisconnectOnClose; @@ -287,6 +290,9 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer) toolbar->addSeparator(); toolbar->addAction(pageSetupAction); toolbar->addAction(printAction); +#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) + toolbar->addAction(closeAction); +#endif // Cannot use the actions' triggered signal here, since it doesn't autorepeat QToolButton *zoomInButton = static_cast(toolbar->widgetForAction(zoomInAction)); @@ -406,6 +412,10 @@ void QPrintPreviewDialogPrivate::setupActions() qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup")); QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print())); QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup())); +#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) + closeAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Close")); + QObject::connect(closeAction, SIGNAL(triggered(bool)), q, SLOT(reject())); +#endif // Initial state: fitPageAction->setChecked(true); -- cgit v0.12 From c50788df123d848b8212376884376cc216c31015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 22 Jan 2010 14:25:18 +0100 Subject: Fix NSCFNumber autorelease warning on Mac. Task: QTBUG-7385 Revby: Lorn Potter --- src/gui/kernel/qapplication_mac.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index 6aebef5..847c58d 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -227,6 +227,10 @@ void onApplicationChangedActivation( bool activated ); static void qt_mac_read_fontsmoothing_settings() { +#ifdef QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool2; +#endif + NSInteger appleFontSmoothing = [[NSUserDefaults standardUserDefaults] integerForKey:@"AppleFontSmoothing"]; qt_applefontsmoothing_enabled = (appleFontSmoothing > 0); } -- cgit v0.12 From 6968a9b9281ef191c566a8e44447fc299cbdd4b7 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 22 Jan 2010 14:47:15 +0100 Subject: Fix QPainter::redirection() to pass autotest. Reviewed-by: Trond --- src/gui/painting/qpainter.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 1258d6b..cde6a2d 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7503,15 +7503,14 @@ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset) { Q_ASSERT(device != 0); - if (*globalRedirectionAtomic() == 0) - return 0; - if (device->devType() == QInternal::Widget) { const QWidgetPrivate *widgetPrivate = static_cast(device)->d_func(); if (widgetPrivate->redirectDev) return widgetPrivate->redirected(offset); } + if (*globalRedirectionAtomic() == 0) + return 0; QMutexLocker locker(globalRedirectionsMutex()); QPaintDeviceRedirectionList *redirections = globalRedirections(); -- cgit v0.12 From df01c399c0d9f3412c872ad9ccb7342af0a44ea2 Mon Sep 17 00:00:00 2001 From: Thorvald Natvig Date: Fri, 22 Jan 2010 14:33:03 +0100 Subject: Fix QUrl::toAce for domains with dot at end Merge-request: 436 Reviewed-by: Thiago Macieira --- src/corelib/io/qurl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index a131d6c..ba1110d 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3241,8 +3241,11 @@ static QString qt_ACE_do(const QString &domain, AceOperation op) while (1) { int idx = nextDotDelimiter(domain, lastIdx); int labelLength = idx - lastIdx; - if (labelLength == 0) + if (labelLength == 0) { + if (idx == domain.length() && idx > 0) + break; return QString(); // two delimiters in a row -- empty label not allowed + } // RFC 3490 says, about the ToASCII operation: // 3. If the UseSTD3ASCIIRules flag is set, then perform these checks: -- cgit v0.12 From 670f90b3068d530f14000eb816dd9ff38f9fb005 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 22 Jan 2010 15:00:27 +0100 Subject: Autotest: add a test for allowing hostnames ending in dot Also, since domain is never empty, the idx > 0 test is unnecessary. --- src/corelib/io/qurl.cpp | 2 +- tests/auto/qurl/tst_qurl.cpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index ba1110d..076cc33 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3242,7 +3242,7 @@ static QString qt_ACE_do(const QString &domain, AceOperation op) int idx = nextDotDelimiter(domain, lastIdx); int labelLength = idx - lastIdx; if (labelLength == 0) { - if (idx == domain.length() && idx > 0) + if (idx == domain.length()) break; return QString(); // two delimiters in a row -- empty label not allowed } diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 33812fe..f108f4c 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -165,6 +165,8 @@ private slots: void ace_testsuite(); void std3violations_data(); void std3violations(); + void std3deviations_data(); + void std3deviations(); void tldRestrictions_data(); void tldRestrictions(); void emptyQueryOrFragment(); @@ -3238,6 +3240,8 @@ void tst_QUrl::std3violations_data() QTest::newRow("bang") << "foo!" << false; QTest::newRow("plus") << "foo+bar" << false; QTest::newRow("dot") << "foo.bar"; + QTest::newRow("startingdot") << ".bar" << false; + QTest::newRow("startingdot2") << ".example.com" << false; QTest::newRow("slash") << "foo/bar" << true; QTest::newRow("colon") << "foo:80" << true; QTest::newRow("question") << "foo?bar" << true; @@ -3282,6 +3286,24 @@ void tst_QUrl::std3violations() QVERIFY(!url.isValid()); } +void tst_QUrl::std3deviations_data() +{ + QTest::addColumn("source"); + + QTest::newRow("ending-dot") << "example.com."; + QTest::newRow("ending-dot3002") << QString("example.com") + QChar(0x3002); +} + +void tst_QUrl::std3deviations() +{ + QFETCH(QString, source); + QVERIFY(!QUrl::toAce(source).isEmpty()); + + QUrl url; + url.setHost(source); + QVERIFY(!url.host().isEmpty()); +} + void tst_QUrl::tldRestrictions_data() { QTest::addColumn("tld"); -- cgit v0.12 From f4ad659dde0c4b0b61dcc2bc5a69441f13c013b7 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Fri, 22 Jan 2010 15:03:42 +0100 Subject: minor optimization avoid needless atomic operations Merge-request: 442 Reviewed-by: Thiago Macieira --- src/dbus/qdbusmarshaller.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dbus/qdbusmarshaller.cpp b/src/dbus/qdbusmarshaller.cpp index f156e04..8ec328e 100644 --- a/src/dbus/qdbusmarshaller.cpp +++ b/src/dbus/qdbusmarshaller.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qdbusargument_p.h" +#include "qdbusmetatype_p.h" #include "qdbusutil_p.h" QT_BEGIN_NAMESPACE @@ -167,7 +168,7 @@ inline bool QDBusMarshaller::append(const QDBusVariant &arg) QByteArray tmpSignature; const char *signature = 0; - if (int(id) == qMetaTypeId()) { + if (int(id) == QDBusMetaTypeId::argument) { // take the signature from the QDBusArgument object we're marshalling tmpSignature = qvariant_cast(value).currentSignature().toLatin1(); @@ -353,7 +354,7 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg) } // intercept QDBusArgument parameters here - if (id == qMetaTypeId()) { + if (id == QDBusMetaTypeId::argument) { QDBusArgument dbusargument = qvariant_cast(arg); QDBusArgumentPrivate *d = QDBusArgumentPrivate::d(dbusargument); if (!d->message) -- cgit v0.12 From 5ea0be16612625aa75fbd6e519a3cbc7971c65c4 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Fri, 22 Jan 2010 15:03:42 +0100 Subject: fix copy-paste error Merge-request: 442 Reviewed-by: Thiago Macieira --- src/dbus/qdbusargument.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/dbus/qdbusargument.cpp b/src/dbus/qdbusargument.cpp index 3466d90..7defc9a 100644 --- a/src/dbus/qdbusargument.cpp +++ b/src/dbus/qdbusargument.cpp @@ -535,7 +535,6 @@ QDBusArgument &QDBusArgument::operator<<(const QByteArray &arg) /*! \internal - Returns the type signature of the D-Bus type this QDBusArgument \since 4.5 Appends the variant \a v. -- cgit v0.12 From 4f9666da561b317729964a402c3f05309778fe90 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 22 Jan 2010 17:06:05 +0200 Subject: S60Style: Add support for animations to style Add support of theme animations to AVKON-based QS60Style. Currently only QProgressBar's have animations, but adding others with same kind of S60 theming (mainly note animations) would be really easy to do. Task-number: QTBUG-4050 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 143 ++++++++++++++++---- src/gui/styles/qs60style.h | 3 + src/gui/styles/qs60style_p.h | 105 ++++++++++++++- src/gui/styles/qs60style_s60.cpp | 237 ++++++++++++++++++++++++++++++++- src/gui/styles/qs60style_simulated.cpp | 5 + src/gui/styles/styles.pri | 2 +- 6 files changed, 464 insertions(+), 31 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 100303e..498c6ef 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -564,9 +564,11 @@ QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part, const QSize &size, QPainter *painter, SkinElementFlags flags) { QPixmap result; + const int animationFrame = (flags & SF_Animation) ? currentAnimationFrame(part) : 0; + const QString cacheKey = - QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4") - .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags); + QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4 AnimationFrame=%5") + .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags).arg(animationFrame); if (!QPixmapCache::find(cacheKey, result)) { result = QS60StylePrivate::part(part, size, painter, flags); QPixmapCache::insert(cacheKey, result); @@ -813,13 +815,13 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag //ratio of 1:2 for horizontal tab bars (and 2:1 for vertical ones). result.setWidth(result.height() >> 1); break; - + case QS60StyleEnums::SP_QgnGrafNsliderEndLeft: case QS60StyleEnums::SP_QgnGrafNsliderEndRight: case QS60StyleEnums::SP_QgnGrafNsliderMiddle: result.setWidth(result.height() >> 1); break; - + case QS60StyleEnums::SP_QgnGrafNsliderMarker: case QS60StyleEnums::SP_QgnGrafNsliderMarkerSelected: result.scale(pixelMetric(QStyle::PM_SliderLength), @@ -948,11 +950,11 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom //Highlight /* if (optionSlider->state & QStyle::State_HasFocus) drawPrimitive(PE_FrameFocusRect, optionSlider, painter, widget);*/ - + //Groove graphics if (QS60StylePrivate::hasSliderGrooveGraphic()) { - const QS60StylePrivate::SkinElements grooveElement = horizontal ? - QS60StylePrivate::SE_SliderGrooveHorizontal : + const QS60StylePrivate::SkinElements grooveElement = horizontal ? + QS60StylePrivate::SE_SliderGrooveHorizontal : QS60StylePrivate::SE_SliderGrooveVertical; QS60StylePrivate::drawSkinElement(grooveElement, painter, sliderGroove, flags); } else { @@ -975,7 +977,7 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom if (optionSlider->state & QStyle::State_Sunken) handleElement = horizontal ? QS60StylePrivate::SE_SliderHandleSelectedHorizontal : QS60StylePrivate::SE_SliderHandleSelectedVertical; - else + else handleElement = horizontal ? QS60StylePrivate::SE_SliderHandleHorizontal : QS60StylePrivate::SE_SliderHandleVertical; QS60StylePrivate::drawSkinElement(handleElement, painter, sliderHandle, flags); @@ -994,7 +996,7 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom buttonOption.QStyleOption::operator=(*cmb); const int maxHeight = cmbxFrame.height(); const int maxWidth = cmbxFrame.width() - cmbxEditField.width(); - const int topLeftPoint = direction ? + const int topLeftPoint = direction ? (cmbxEditField.right() + 1) : (cmbxEditField.left() + 1 - maxWidth); const QRect buttonRect(topLeftPoint, cmbxEditField.top(), maxWidth, maxHeight); buttonOption.rect = buttonRect; @@ -1648,17 +1650,20 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, // busy indicator const QS60StylePrivate::SkinElementFlag orientationFlag = optionProgressBar->orientation == Qt::Horizontal ? QS60StylePrivate::SF_PointNorth : QS60StylePrivate::SF_PointWest; - QS60StylePrivate::drawSkinPart(QS60StyleEnums::SP_QgnGrafBarWait, painter, progressRect, flags | orientationFlag); + + QS60StylePrivate::drawSkinPart(QS60StyleEnums::SP_QgnGrafBarWaitAnim, + painter, progressRect, flags | orientationFlag | QS60StylePrivate::SF_Animation ); } else { const qreal progressFactor = (optionProgressBar->minimum == optionProgressBar->maximum) ? 1.0 : (qreal)optionProgressBar->progress / optionProgressBar->maximum; + const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget); if (optionProgressBar->orientation == Qt::Horizontal) { progressRect.setWidth(int(progressRect.width() * progressFactor)); if(optionProgressBar->direction == Qt::RightToLeft) - progressRect.translate(optionProgressBar->rect.width()-progressRect.width(), 0); - progressRect.adjust(1, 0, -1, 0); + progressRect.translate(optionProgressBar->rect.width() - progressRect.width(), 0); + progressRect.adjust(frameWidth, 0, -frameWidth, 0); } else { - progressRect.adjust(0, 1, 0, -1); + progressRect.adjust(0, frameWidth, 0, -frameWidth); progressRect.setTop(progressRect.bottom() - int(progressRect.height() * progressFactor)); } @@ -1925,8 +1930,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, break; case CE_MenuScroller: break; - case CE_FocusFrame: - { + case CE_FocusFrame: { // The pen width should nearly fill the layoutspacings around the widget const int penWidth = qMin(pixelMetric(QS60Style::PM_LayoutVerticalSpacing), pixelMetric(QS60Style::PM_LayoutHorizontalSpacing)) @@ -2004,8 +2008,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti } break; #endif // QT_NO_LINEEDIT - case PE_IndicatorCheckBox: - { + case PE_IndicatorCheckBox: { // Draw checkbox indicator as color skinned graphics. const QS60StyleEnums::SkinParts skinPart = (option->state & QStyle::State_On) ? QS60StyleEnums::SP_QgnIndiCheckboxOn : QS60StyleEnums::SP_QgnIndiCheckboxOff; @@ -2077,7 +2080,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti case PE_PanelButtonCommand: case PE_PanelButtonTool: case PE_PanelButtonBevel: - case PE_FrameButtonBevel: { + case PE_FrameButtonBevel: if (QS60StylePrivate::canDrawThemeBackground(option->palette.base())) { const bool isPressed = option->state & QStyle::State_Sunken; const QS60StylePrivate::SkinElements skinElement = @@ -2085,7 +2088,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); } else { commonStyleDraws = true; - } } break; #ifndef QT_NO_TOOLBUTTON @@ -2361,8 +2363,7 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, if (const QStyleOptionFrame *f = qstyleoption_cast(opt)) sz += QSize(2 * f->lineWidth, 4 * f->lineWidth); break; - case CT_TabBarTab: - { + case CT_TabBarTab: { const QSize naviPaneSize = QS60StylePrivate::naviPaneSize(); sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget); if (naviPaneSize.height() > sz.height()) @@ -2835,6 +2836,12 @@ void QS60Style::polish(QWidget *widget) if (!widget) return; + //Currently we only support animations in QProgressBar. +#ifndef QT_NO_PROGRESSBAR + if (qobject_cast(widget)) + widget->installEventFilter(this); +#endif + if (false #ifndef QT_NO_SCROLLBAR || qobject_cast(widget) @@ -2867,6 +2874,8 @@ void QS60Style::polish(QWidget *widget) */ void QS60Style::unpolish(QWidget *widget) { + Q_D(QS60Style); + if (false #ifndef QT_NO_SCROLLBAR || qobject_cast(widget) @@ -2893,6 +2902,12 @@ void QS60Style::unpolish(QWidget *widget) if (widget) widget->setPalette(QPalette()); +#ifndef QT_NO_PROGRESSBAR + if (QProgressBar *bar = qobject_cast(widget)) { + widget->removeEventFilter(this); + d->m_bars.removeAll(bar); + } +#endif QCommonStyle::unpolish(widget); } @@ -2923,11 +2938,25 @@ void QS60Style::unpolish(QApplication *application) */ bool QS60Style::event(QEvent *e) { -#ifdef QT_KEYPAD_NAVIGATION - if (QS60StylePrivate::isTouchSupported()) - return false; Q_D(QS60Style); + +#ifdef QT_KEYPAD_NAVIGATION + const QEvent::Type eventType = e->type(); + if ((eventType == QEvent::FocusIn || + eventType == QEvent::FocusOut || + eventType == QEvent::EnterEditFocus || + eventType == QEvent::LeaveEditFocus) && + QS60StylePrivate::isTouchSupported()) + return false; +#endif + switch (e->type()) { + case QEvent::Timer: { + QTimerEvent *te = static_cast(e); + timerEvent(te); + } + break; +#ifdef QT_KEYPAD_NAVIGATION case QEvent::FocusIn: if (QWidget *focusWidget = QApplication::focusWidget()) { if (!d->m_focusFrame) @@ -2946,12 +2975,10 @@ bool QS60Style::event(QEvent *e) if (d->m_focusFrame) d->m_focusFrame->update(); break; +#endif default: break; } -#else - Q_UNUSED(e) -#endif return false; } @@ -3045,6 +3072,68 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, QCommonStyle::standardIconImplementation(standardIcon, option, widget) : QIcon(cachedPixMap); } +/*! + \internal + Animate indeterminate progress bars only when visible +*/ +bool QS60Style::eventFilter(QObject *object, QEvent *event) +{ +#ifdef Q_WS_S60 +#ifndef QT_NO_PROGRESSBAR + Q_D(QS60Style); + switch(event->type()) { + case QEvent::StyleChange: + case QEvent::Show: + if (QProgressBar *bar = qobject_cast(object)) { + if (!d->m_bars.contains(bar)) + d->m_bars << bar; + if (d->m_bars.size() == 1) //only start with first animated progressbar + d->startAnimation(QS60StyleEnums::SP_QgnGrafBarWaitAnim); + } + break; + case QEvent::Destroy: + case QEvent::Hide: + d->stopAnimation(QS60StyleEnums::SP_QgnGrafBarWaitAnim); + d->m_bars.removeAll(reinterpret_cast(object)); + break; + default: + break; + } +#endif // QT_NO_PROGRESSBAR +#endif // Q_WS_S60 + return QStyle::eventFilter(object, event); +} + +void QS60Style::timerEvent(QTimerEvent *event) +{ +#ifdef Q_WS_S60 +#ifndef QT_NO_PROGRESSBAR + Q_D(QS60Style); + + QS60StyleAnimation *progressBarAnimation = + QS60StylePrivate::animationDefinition(QS60StyleEnums::SP_QgnGrafBarWaitAnim); + + if (event->timerId() == progressBarAnimation->timerId()) { + + Q_ASSERT(progressBarAnimation->interval() > 0); + + if (progressBarAnimation->currentFrame() == progressBarAnimation->frameCount() ) + if (progressBarAnimation->playMode() == QS60StyleEnums::AM_Looping) + progressBarAnimation->setCurrentFrame(0); + else + d->stopAnimation(progressBarAnimation->animationId()); + + foreach (QProgressBar *bar, d->m_bars) { + if ((bar->minimum() == 0 && bar->maximum() == 0)) + bar->update(); + } + progressBarAnimation->setCurrentFrame(progressBarAnimation->currentFrame() + 1); + } +#endif // QT_NO_PROGRESSBAR +#endif // Q_WS_S60 + event->ignore(); +} + extern QPoint qt_s60_fill_background_offset(const QWidget *targetWidget); bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush) diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h index adcb313..82cc21c 100644 --- a/src/gui/styles/qs60style.h +++ b/src/gui/styles/qs60style.h @@ -94,6 +94,9 @@ protected Q_SLOTS: QIcon standardIconImplementation( StandardPixmap standardIcon, const QStyleOption * option = 0, const QWidget * widget = 0 ) const; +protected: + void timerEvent(QTimerEvent *event); + bool eventFilter(QObject *o, QEvent *e); private: Q_DISABLE_COPY(QS60Style) friend class QStyleFactory; diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 1417552..2d2f2e1 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -93,6 +93,29 @@ class QS60StyleEnums #endif // !Q_WS_S60 public: + + // S60 definitions within theme + enum ThemeDefinitions { + TD_AnimationData, + }; + + //Defines which values are contained within animation data (retrieved using TD_AnimationData). + //Additionally defines the order in which the items are given out in QList. + enum AnimationData { + AD_Interval = 0, + AD_NumberOfFrames, + AD_AnimationPlayMode, //currently not used as themes seem to contain invalid data + }; + + // Animation modes + enum AnimationMode { + AM_PlayOnce = 0, //animation is played exactly once + AM_Looping, //animation is repeated until stopped + AM_Bounce //animation is played repeatedly until stopped, + //but frames are played in reverse order every second time + //(no support yet) + }; + // S60 look-and-feel font categories enum FontCategories { FC_Undefined, @@ -104,7 +127,7 @@ public: }; enum SkinParts { - SP_QgnGrafBarWait, + SP_QgnGrafBarWaitAnim, SP_QgnGrafBarFrameCenter, SP_QgnGrafBarFrameSideL, SP_QgnGrafBarFrameSideR, @@ -287,7 +310,70 @@ public: }; }; +#ifdef Q_WS_S60 +class CAknBitmapAnimation; +NONSHARABLE_CLASS (AnimationData) : public QObject +{ +public: + AnimationData(const QS60StyleEnums::SkinParts part, int frames, int interval); + + const QS60StyleEnums::SkinParts m_id; + int m_frames; + int m_interval; + QS60StyleEnums::AnimationMode m_mode; +}; + + +NONSHARABLE_CLASS (AnimationDataV2) : public AnimationData +{ +public: + AnimationDataV2(const AnimationData &data); + ~AnimationDataV2(); + + CAknBitmapAnimation *m_animation; + int m_currentFrame; + bool m_resourceBased; + int m_timerId; +}; + + +class QS60StyleAnimation : public QObject +{ +public: + QS60StyleAnimation(const QS60StyleEnums::SkinParts part, int frames, int interval); + ~QS60StyleAnimation(); + +public: + QS60StyleEnums::SkinParts animationId() const {return m_currentData->m_id;} + int frameCount() const { return m_currentData->m_frames;} + int interval() const {return m_currentData->m_interval;} + QS60StyleEnums::AnimationMode playMode() const {return m_currentData->m_mode;} + CAknBitmapAnimation* animationObject() const {return m_currentData->m_animation;} + bool isResourceBased() const {return m_currentData->m_resourceBased;} + int timerId() const {return m_currentData->m_timerId;} + int currentFrame() const {return m_currentData->m_currentFrame;} + + void setFrameCount(const int &frameCount) {m_currentData->m_frames = frameCount;} + void setInterval(const int &interval) {m_currentData->m_interval = interval;} + void setAnimationObject(CAknBitmapAnimation* animation); + void setResourceBased(bool resourceBased) {m_currentData->m_resourceBased = resourceBased;} + void setTimerId(const int &timerId) {m_currentData->m_timerId = timerId;} + void setCurrentFrame(const int ¤tFrame) {m_currentData->m_currentFrame = currentFrame;} + + void resetToDefaults(); + +private: //data members + //TODO: consider changing these to non-pointers as the classes are rather small anyway + AnimationData *m_defaultData; + AnimationDataV2 *m_currentData; +}; + +#endif //Q_WS_S60 + + class QFocusFrame; +class QProgressBar; +class QS60StyleAnimation; // Private class #ifdef Q_OS_SYMBIAN @@ -371,6 +457,7 @@ public: SF_StateEnabled = 0x0010, // Enabled = the default SF_StateDisabled = 0x0020, SF_ColorSkinned = 0x0040, // pixmap is colored with foreground pen color + SF_Animation = 0x0080, }; enum CacheClearReason { @@ -455,6 +542,16 @@ public: //so that theme graphic background can be drawn. static bool canDrawThemeBackground(const QBrush &backgroundBrush); + static int currentAnimationFrame(QS60StyleEnums::SkinParts part); +#ifdef Q_WS_S60 + + //No support for animations on emulated style + void startAnimation(QS60StyleEnums::SkinParts animation); + void stopAnimation(QS60StyleEnums::SkinParts animation); + static QS60StyleAnimation* animationDefinition(QS60StyleEnums::SkinParts part); + +#endif + private: static void drawPart(QS60StyleEnums::SkinParts part, QPainter *painter, const QRect &rect, SkinElementFlags flags = KDefaultSkinElementFlags); @@ -497,6 +594,12 @@ private: QPalette m_originalPalette; QPointer m_focusFrame; + +#ifdef Q_WS_S60 + //list of progress bars having animation running + QList m_bars; +#endif + }; QT_END_NAMESPACE diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index d03574f..5f3a499 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -63,6 +63,7 @@ #include #include #include +#include #if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN) @@ -72,6 +73,7 @@ enum TDrawType { EDrawIcon, EDrawGulIcon, EDrawBackground, + EDrawAnimation, ENoDraw }; @@ -97,6 +99,47 @@ typedef struct { int newMinorSkinId; } partMapEntry; +AnimationData::AnimationData(const QS60StyleEnums::SkinParts part, int frames, int interval) : m_id(part), + m_frames(frames), m_interval(interval), m_mode(QS60StyleEnums::AM_Looping) +{ +} + +AnimationDataV2::AnimationDataV2(const AnimationData &data) : AnimationData(data.m_id, data.m_frames, data.m_interval), + m_resourceBased(false), m_animation(0), m_timerId(0) +{ +} +AnimationDataV2::~AnimationDataV2() +{ + delete m_animation; +} + +QS60StyleAnimation::QS60StyleAnimation(const QS60StyleEnums::SkinParts part, int frames, int interval) +{ + QT_TRAP_THROWING(m_defaultData = new (ELeave) AnimationData(part, frames, interval)); + QT_TRAP_THROWING(m_currentData = new (ELeave) AnimationDataV2(*m_defaultData)); +} + +QS60StyleAnimation::~QS60StyleAnimation() +{ + delete m_currentData; + delete m_defaultData; +} + +void QS60StyleAnimation::setAnimationObject(CAknBitmapAnimation* animation) +{ + Q_ASSERT(animation); + if (m_currentData->m_animation) + delete m_currentData->m_animation; + m_currentData->m_animation = animation; +} + +void QS60StyleAnimation::resetToDefaults() +{ + delete m_currentData; + m_currentData = 0; + QT_TRAP_THROWING(m_currentData = new (ELeave) AnimationDataV2(*m_defaultData)); +} + class QS60StyleModeSpecifics { public: @@ -113,6 +156,8 @@ public: static QSize naviPaneSize(); static TAknsItemID partSpecificThemeId(int part); + static QVariant themeDefinition(QS60StyleEnums::ThemeDefinitions definition, QS60StyleEnums::SkinParts part); + private: static QPixmap createSkinnedGraphicsLX(QS60StyleEnums::SkinParts part, const QSize &size, QS60StylePrivate::SkinElementFlags flags); @@ -128,7 +173,7 @@ private: }; const partMapEntry QS60StyleModeSpecifics::m_partMap[] = { - /* SP_QgnGrafBarWait */ {KAknsIIDQgnGrafBarWaitAnim, EDrawIcon, ES60_All, -1,-1}, + /* SP_QgnGrafBarWaitAnim */ {KAknsIIDQgnGrafBarWaitAnim, EDrawAnimation, ES60_All, -1,-1}, /* SP_QgnGrafBarFrameCenter */ {KAknsIIDQgnGrafBarFrameCenter, EDrawIcon, ES60_All, -1,-1}, /* SP_QgnGrafBarFrameSideL */ {KAknsIIDQgnGrafBarFrameSideL, EDrawIcon, ES60_All, -1,-1}, /* SP_QgnGrafBarFrameSideR */ {KAknsIIDQgnGrafBarFrameSideR, EDrawIcon, ES60_All, -1,-1}, @@ -371,7 +416,7 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphics( void QS60StyleModeSpecifics::fallbackInfo(const QS60StyleEnums::SkinParts &stylePart, TInt &fallbackIndex) { switch(stylePart) { - case QS60StyleEnums::SP_QgnGrafBarWait: + case QS60StyleEnums::SP_QgnGrafBarWaitAnim: fallbackIndex = EMbmAvkonQgn_graf_bar_wait_1; break; case QS60StyleEnums::SP_QgnGrafBarFrameCenter: @@ -709,6 +754,69 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX( // QS60WindowSurface::lockBitmapHeap(); break; } + case EDrawAnimation: { + CFbsBitmap* animationFrame; + CFbsBitmap* frameMask; + CAknBitmapAnimation* aknAnimation = 0; + TBool constructedFromTheme = ETrue; + + QS60StyleAnimation* animation = QS60StylePrivate::animationDefinition(part); //ownership is not passed + if (animation) { + if (!animation->animationObject() && !animation->isResourceBased()) {// no pre-made item exists, create new animation + CAknBitmapAnimation* newAnimation = CAknBitmapAnimation::NewL(); + CleanupStack::PushL(newAnimation); + if (newAnimation) + constructedFromTheme = newAnimation->ConstructFromSkinL(skinId); + if (constructedFromTheme && newAnimation->BitmapAnimData()->FrameArray().Count() > 0) { + animation->setResourceBased(false); + animation->setAnimationObject(newAnimation); //animation takes ownership + } + CleanupStack::Pop(newAnimation); + } + //fill-in stored information + aknAnimation = animation->animationObject(); + constructedFromTheme = !animation->isResourceBased(); + } + + const int currentFrame = QS60StylePrivate::currentAnimationFrame(part); + if (constructedFromTheme && aknAnimation && aknAnimation->BitmapAnimData()->FrameArray().Count() > 0) { + //Animation was created succesfully and contains frames, just fetch current frame + if(currentFrame >= aknAnimation->BitmapAnimData()->FrameArray().Count()) + User::Leave(KErrOverflow); + const CBitmapFrameData* frameData = aknAnimation->BitmapAnimData()->FrameArray().At(currentFrame); + if (frameData) { + animationFrame = frameData->Bitmap(); + frameMask = frameData->Mask(); + } + } else { + //Theme does not contain animation theming, create frames from resource file + TInt fallbackGraphicID = -1; + fallbackInfo(part, fallbackGraphicID); + fallbackGraphicID = fallbackGraphicID + (currentFrame * 2); //skip masks + TInt fallbackGraphicsMaskID = + (fallbackGraphicID == KErrNotFound) ? KErrNotFound : fallbackGraphicID + 1; //masks are auto-generated as next in mif files + if (fallbackGraphicsMaskID != KErrNotFound) + fallbackGraphicsMaskID = fallbackGraphicsMaskID + (currentFrame * 2); //skip actual graphics + + //Then draw animation frame + AknsUtils::CreateIconL( + skinInstance, + KAknsIIDDefault, //animation is not themed, lets force fallback graphics + animationFrame, + frameMask, + AknIconUtils::AvkonIconFileName(), + fallbackGraphicID , + fallbackGraphicsMaskID); + } + result = fromFbsBitmap(animationFrame, frameMask, flags, targetSize); + if (!constructedFromTheme) { + delete animationFrame; + animationFrame = 0; + delete frameMask; + frameMask = 0; + } + break; + } } if (!result) result = QPixmap(); @@ -984,8 +1092,13 @@ void QS60StylePrivate::setActiveLayout() m_pmPointer = data[activeLayoutIndex]; } +Q_GLOBAL_STATIC(QList, m_animations) + QS60StylePrivate::QS60StylePrivate() { + //Animation defaults need to be created when style is instantiated + QS60StyleAnimation* progressBarAnimation = new QS60StyleAnimation(QS60StyleEnums::SP_QgnGrafBarWaitAnim, 7, 100); + m_animations()->append(progressBarAnimation); // No need to set active layout, if dynamic metrics API is available setActiveLayout(); } @@ -1186,6 +1299,11 @@ void QS60StylePrivate::handleSkinChange() setThemePalette(topLevelWidget); topLevelWidget->ensurePolished(); } +#ifndef QT_NO_PROGRESSBAR + //re-start animation timer + stopAnimation(QS60StyleEnums::SP_QgnGrafBarWaitAnim); //todo: once we have more animations, we could say "stop all running ones" + startAnimation(QS60StyleEnums::SP_QgnGrafBarWaitAnim); //and "re-start all previously running ones" +#endif } QSize QS60StylePrivate::naviPaneSize() @@ -1205,6 +1323,121 @@ QSize QS60StyleModeSpecifics::naviPaneSize() return QSize(0,0); } +int QS60StylePrivate::currentAnimationFrame(QS60StyleEnums::SkinParts part) +{ + QS60StyleAnimation *animation = animationDefinition(part); + // todo: looping could be done in QS60Style::timerEvent + if (animation->frameCount() == animation->currentFrame()) + animation->setCurrentFrame(0); + return animation->currentFrame(); +} + +QS60StyleAnimation* QS60StylePrivate::animationDefinition(QS60StyleEnums::SkinParts part) +{ + int i = 0; + const int animationsCount = m_animations()->isEmpty() ? 0 : m_animations()->count(); + for(; i < animationsCount; i++) { + if (part == m_animations()->at(i)->animationId()) + break; + } + return m_animations()->at(i); +} + +void QS60StylePrivate::startAnimation(QS60StyleEnums::SkinParts animationPart) +{ + Q_Q(QS60Style); + + //Query animation data from theme and store values to local struct. + QVariant themeAnimationDataVariant = QS60StyleModeSpecifics::themeDefinition( + QS60StyleEnums::TD_AnimationData, animationPart); + QList themeAnimationData = themeAnimationDataVariant.toList(); + + QS60StyleAnimation *animation = QS60StylePrivate::animationDefinition(animationPart); + if (animation) { + if (themeAnimationData.at(QS60StyleEnums::AD_Interval).toInt() != 0) + animation->setInterval(themeAnimationData.at(QS60StyleEnums::AD_Interval).toInt()); + + if (themeAnimationData.at(QS60StyleEnums::AD_NumberOfFrames).toInt() != 0) + animation->setFrameCount(themeAnimationData.at(QS60StyleEnums::AD_NumberOfFrames).toInt()); + + //todo: playmode is ignored for now, since it seems to return invalid data on some themes + //lets use the table values for play mode + + animation->setCurrentFrame(0); //always initialize + const int timerId = q->startTimer(animation->interval()); + animation->setTimerId(timerId); + } +} + +void QS60StylePrivate::stopAnimation(QS60StyleEnums::SkinParts animationPart) +{ + Q_Q(QS60Style); + + QS60StyleAnimation *animation = QS60StylePrivate::animationDefinition(animationPart); + if (animation) { + animation->setCurrentFrame(0); + if (animation->timerId() != 0) { + q->killTimer(animation->timerId()); + animation->setTimerId(0); + } + animation->resetToDefaults(); + } +} + +QVariant QS60StyleModeSpecifics::themeDefinition( + QS60StyleEnums::ThemeDefinitions definition, QS60StyleEnums::SkinParts part) +{ + MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); + + Q_ASSERT(skinInstance); + + switch(definition) { + //Animation definitions + case QS60StyleEnums::TD_AnimationData: + { + CAknsBmpAnimItemData *animationData; + TAknsItemID animationSkinId = partSpecificThemeId(part); + QList list; + + TRAPD( error, QT_TRYCATCH_LEAVING( + animationData = static_cast(skinInstance->CreateUncachedItemDataL( + animationSkinId, EAknsITBmpAnim)))); + if (error) + return list; + + if (animationData) { + list.append((int)animationData->FrameInterval()); + list.append((int)animationData->NumberOfImages()); + + QS60StyleEnums::AnimationMode playMode; + switch(animationData->PlayMode()) { + case CBitmapAnimClientData::EPlay: + playMode = QS60StyleEnums::AM_PlayOnce; + break; + case CBitmapAnimClientData::ECycle: + playMode = QS60StyleEnums::AM_Looping; + break; + case CBitmapAnimClientData::EBounce: + playMode = QS60StyleEnums::AM_Bounce; + break; + default: + break; + } + list.append(QVariant((int)playMode)); + delete animationData; + } else { + list.append(0); + list.append(0); + } + return list; + } + break; + default: + break; + } + return QVariant(); +} + #endif // Q_WS_S60 QT_END_NAMESPACE diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp index bd43eb7..557243c 100644 --- a/src/gui/styles/qs60style_simulated.cpp +++ b/src/gui/styles/qs60style_simulated.cpp @@ -364,6 +364,11 @@ QFont QS60StylePrivate::s60Font_specific( return result; } +int QS60StylePrivate::currentAnimationFrame(QS60StyleEnums::SkinParts part) +{ + return 0; +} + /*! Constructs a QS60Style object. */ diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri index 7e5c55a..f30f5af 100644 --- a/src/gui/styles/styles.pri +++ b/src/gui/styles/styles.pri @@ -168,7 +168,7 @@ contains( styles, s60 ):contains(QT_CONFIG, s60) { SOURCES += styles/qs60style.cpp symbian { SOURCES += styles/qs60style_s60.cpp - LIBS += -laknicon -laknskins -laknskinsrv -lfontutils -legul + LIBS += -laknicon -laknskins -laknskinsrv -lfontutils -legul -lbmpanim } else { SOURCES += styles/qs60style_simulated.cpp RESOURCES += styles/qstyle_s60_simulated.qrc -- cgit v0.12 From 7b8b83d2ea788e73a4c0f7dee09ba3394787e6bb Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 22 Jan 2010 17:18:48 +0200 Subject: S60Style: Add support for animations to style (part2) Missing #include added to avoid build break. Task-number: QTBUG-4050 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 498c6ef..28e94a3 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -68,6 +68,7 @@ #include "qtoolbutton.h" #include "qfocusframe.h" #include "qformlayout.h" +#include "qprogressbar.h" #include "private/qtoolbarextension_p.h" #include "private/qcombobox_p.h" -- cgit v0.12 From fa51e0a61fac98b20e55cb8734556d10acdbd1bc Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 22 Jan 2010 16:23:02 +0100 Subject: Doc: Fixed installation information for Qt for Embedded Linux. Reviewed-by: Trust Me --- doc/src/platforms/emb-install.qdoc | 4 +++- doc/src/snippets/code/doc_src_emb-install.qdoc | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/doc/src/platforms/emb-install.qdoc b/doc/src/platforms/emb-install.qdoc index c13fbef..623ba89 100644 --- a/doc/src/platforms/emb-install.qdoc +++ b/doc/src/platforms/emb-install.qdoc @@ -84,7 +84,9 @@ Before building the \l{Qt for Embedded Linux} library, run the \c ./configure script to configure the library for your development architecture. You can list all of the configuration system's - options by typing \c {./configure -help}. + options by typing + + \snippet doc/src/snippets/code/doc_src_emb-install.qdoc embedded help Note that by default, \l{Qt for Embedded Linux} is configured for installation in the \c{/usr/local/Trolltech/QtEmbedded-%VERSION%} diff --git a/doc/src/snippets/code/doc_src_emb-install.qdoc b/doc/src/snippets/code/doc_src_emb-install.qdoc index 60775d2..f24f087 100644 --- a/doc/src/snippets/code/doc_src_emb-install.qdoc +++ b/doc/src/snippets/code/doc_src_emb-install.qdoc @@ -41,18 +41,22 @@ //! [0] cd -gunzip qt-embedded-linux-commercial-src-%VERSION%.tar.gz -tar xf qt-embedded-linux-commercial-src-%VERSION%.tar +gunzip qt-everywhere-opensource-src-%VERSION%.tar.gz +tar xf qt-everywhere-opensource-src-%VERSION%.tar //! [0] //! [1] -~/qt-embedded-linux-commercial-src-%VERSION% +~/qt-everywhere-opensource-src-%VERSION% //! [1] +//! [embedded help] +./configure -embedded -help +//! [embedded help] + //! [2] -cd ~/qt-embedded-linux-commercial-src-%VERSION% +cd ~/qt-everywhere-opensource-src-%VERSION% ./configure -embedded [architecture] //! [2] -- cgit v0.12 From d8547cb670cee0e06f49697c7b36d447e27e455e Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 22 Jan 2010 16:24:36 +0100 Subject: Doc: Added a warning about the Accelerated Graphics Driver example. Task-number: QTBUG-7403 Reviewed-by: Trust Me --- doc/src/examples/svgalib.qdoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/src/examples/svgalib.qdoc b/doc/src/examples/svgalib.qdoc index 9142112..cf6512c 100644 --- a/doc/src/examples/svgalib.qdoc +++ b/doc/src/examples/svgalib.qdoc @@ -43,6 +43,9 @@ \example qws/svgalib \title Accelerated Graphics Driver Example + \warning This example was designed to work with Qt 4.4 and will not work + with current versions of Qt. It will be removed from Qt 4.7. + The Accelerated Graphics Driver example shows how you can write your own accelerated graphics driver and \l {add your graphics driver to Qt for Embedded Linux}. In \l{Qt for Embedded Linux}, -- cgit v0.12 From 1e7d6f3c5adb066f00cf50cc39b8646668174091 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 22 Jan 2010 16:28:27 +0100 Subject: Doc: Fixed broken link. Reviewed-by: Trust Me --- doc/src/windows-and-dialogs/mainwindow.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/windows-and-dialogs/mainwindow.qdoc b/doc/src/windows-and-dialogs/mainwindow.qdoc index ea8411f..6adfa75 100644 --- a/doc/src/windows-and-dialogs/mainwindow.qdoc +++ b/doc/src/windows-and-dialogs/mainwindow.qdoc @@ -51,7 +51,7 @@ \nextpage The Application Main Window - A \l{Widgets}{widget} that is not embedded in a parent widget is called a window. + A \l{Widgets Tutorial}{widget} that is not embedded in a parent widget is called a window. Usually, windows have a frame and a title bar, although it is also possible to create windows without such decoration using suitable window flags). In Qt, QMainWindow and the various subclasses of QDialog are the most common window types. -- cgit v0.12 From 6b79cbf5cadbaebef8be895a47ca314724afb1a1 Mon Sep 17 00:00:00 2001 From: Iain Date: Fri, 22 Jan 2010 18:18:06 +0100 Subject: Improve DEF file enable/disable mechanism on Symbian Provide configure flag to enable/disable the use of DEF files on Symbian. A useful side-effect was that it cleaned up how we control DEF files from qbase.pri and in WebKit. -nokia-developer still disables DEF files, as it triggers the autotest exports, which are not frozen into the DEF files. Disabling DEF files means that there is no BC with previously released versions of Qt, so this should only be used for development purposes. .pro files can specify custom locations for DEF files by setting defFilePath. Task-number: QTBUG-6556 Reviewed-by: Jason Barron --- configure.exe | Bin 1176064 -> 1178624 bytes mkspecs/features/symbian/def_files.prf | 26 +++++++++++++++++ mkspecs/features/symbian/def_files_disabled.prf | 7 +++++ src/qbase.pri | 36 ++++++++---------------- tools/configure/configureapp.cpp | 26 +++++++++++++++-- 5 files changed, 68 insertions(+), 27 deletions(-) create mode 100644 mkspecs/features/symbian/def_files.prf create mode 100644 mkspecs/features/symbian/def_files_disabled.prf diff --git a/configure.exe b/configure.exe index d88da13..03cbf37 100644 Binary files a/configure.exe and b/configure.exe differ diff --git a/mkspecs/features/symbian/def_files.prf b/mkspecs/features/symbian/def_files.prf new file mode 100644 index 0000000..c29d4ec --- /dev/null +++ b/mkspecs/features/symbian/def_files.prf @@ -0,0 +1,26 @@ +# With DEF files enabled, removed exported symbols are treated as errors +# and there is binary compatibility between successive builds. + +CONFIG -= def_files_disabled + +!isEmpty(defFilePath) { + defBlock = \ + "$${LITERAL_HASH}ifdef WINSCW" \ + "DEFFILE $$defFilePath/bwins/$${TARGET}.def" \ + "$${LITERAL_HASH}elif defined EABI" \ + "DEFFILE $$defFilePath/eabi/$${TARGET}.def" \ + "$${LITERAL_HASH}endif" + + MMP_RULES += defBlock +} else { + # If defFilePath is not defined, then put the folders containing the DEF files at the + # same level as the .pro (and generated MMP) file(s) + defBlock = \ + "$${LITERAL_HASH}ifdef WINSCW" \ + "DEFFILE ./bwins/$${TARGET}.def" \ + "$${LITERAL_HASH}elif defined EABI" \ + "DEFFILE ./eabi/$${TARGET}.def" \ + "$${LITERAL_HASH}endif" + + MMP_RULES += defBlock +} diff --git a/mkspecs/features/symbian/def_files_disabled.prf b/mkspecs/features/symbian/def_files_disabled.prf new file mode 100644 index 0000000..d5c9505 --- /dev/null +++ b/mkspecs/features/symbian/def_files_disabled.prf @@ -0,0 +1,7 @@ +# With DEF files disabled, binary compatibility is broken every time you build + +CONFIG -= def_files + +# with EXPORTUNFROZEN enabled, new exports are included in the dll without +# needing to run abld/sbs freeze +MMP_RULES += EXPORTUNFROZEN diff --git a/src/qbase.pri b/src/qbase.pri index d9832a1..3307ae3 100644 --- a/src/qbase.pri +++ b/src/qbase.pri @@ -94,31 +94,17 @@ symbian { DEFINES+=QT_MAKEDLL TARGET.CAPABILITY = All -Tcb - defBlock = \ - "$${LITERAL_HASH}ifdef WINSCW" \ - "DEFFILE ../s60installs/bwins/$${TARGET}.def" \ - "$${LITERAL_HASH}elif defined EABI" \ - "DEFFILE ../s60installs/eabi/$${TARGET}.def" \ - "$${LITERAL_HASH}endif" - - contains(QT_CONFIG, private_tests) { - #When building autotest configuration, there are extra exports from - #the Qt DLLs, which we don't want in the frozen DEF files. - MMP_RULES += EXPORTUNFROZEN - } else { - #When building without autotests, DEF files are used by default. - #This is to maintain binary compatibility with previous releases. - - #with defBlock enabled, removed exported symbols are treated as errors - #and there is binary compatibility between successive builds. - #with defBlock disabled, binary compatibility is broken every time you build - MMP_RULES += defBlock - - #with EXPORTUNFROZEN enabled, new exports are included in the dll without - #needing to run abld freeze, however binary compatibility is only maintained - #for symbols that are frozen (and only if defBlock is also enabled) - #the downside of EXPORTUNFROZEN is that the linker gets run twice - #MMP_RULES += EXPORTUNFROZEN + # When building without autotests, DEF files are used by default. + # This is to maintain binary compatibility with previous releases. + # To explicitly disable DEF files usage, eg. when lots of code churn is + # going on, and functions may be added and removed before shipping, + # configure with -no-usedeffiles + # WARNING - disabling DEF files *will* break BC with previous released versions + # of Qt, and the only compatibility will be between this build of Qt and anything + # built in this exact environment. *Never* use this when building a version + # for release. + contains(QT_CONFIG, def_files) { + defFilePath=../s60installs } } load(armcc_warnings) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 919e68f..3f105b5 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -317,6 +317,7 @@ Configure::Configure( int& argc, char** argv ) dictionary[ "OPENSSL" ] = "auto"; dictionary[ "DBUS" ] = "auto"; dictionary[ "S60" ] = "yes"; + dictionary[ "SYMBIAN_DEFFILES" ] = "yes"; dictionary[ "STYLE_WINDOWS" ] = "yes"; dictionary[ "STYLE_WINDOWSXP" ] = "auto"; @@ -482,6 +483,7 @@ void Configure::parseCmdLine() dictionary[ "BUILDNOKIA" ] = "yes"; dictionary[ "BUILDDEV" ] = "yes"; dictionary["LICENSE_CONFIRMED"] = "yes"; + dictionary[ "SYMBIAN_DEFFILES" ] = "no"; } else if( configCmdLine.at(i) == "-opensource" ) { dictionary[ "BUILDTYPE" ] = "opensource"; @@ -803,7 +805,7 @@ void Configure::parseCmdLine() else if( configCmdLine.at(i) == "-no-native-gestures" ) dictionary[ "NATIVE_GESTURES" ] = "no"; #if !defined(EVAL) - // Others --------------------------------------------------- + // Symbian Support ------------------------------------------- else if (configCmdLine.at(i) == "-fpu" ) { ++i; @@ -812,12 +814,17 @@ void Configure::parseCmdLine() dictionary[ "ARM_FPU_TYPE" ] = configCmdLine.at(i); } - // S60 Support ------------------------------------------- else if( configCmdLine.at(i) == "-s60" ) dictionary[ "S60" ] = "yes"; else if( configCmdLine.at(i) == "-no-s60" ) dictionary[ "S60" ] = "no"; + else if( configCmdLine.at(i) == "-usedeffiles" ) + dictionary[ "SYMBIAN_DEFFILES" ] = "yes"; + else if( configCmdLine.at(i) == "-no-usedeffiles" ) + dictionary[ "SYMBIAN_DEFFILES" ] = "no"; + + // Others --------------------------------------------------- else if (configCmdLine.at(i) == "-fast" ) dictionary[ "FAST" ] = "yes"; else if (configCmdLine.at(i) == "-no-fast" ) @@ -1823,6 +1830,8 @@ bool Configure::displayHelp() desc( "-fpu ", "VFP type on ARM, supported options: softvfp(default) | vfpv2 | softvfp+vfpv2"); desc("S60", "no", "-no-s60", "Do not compile in S60 support."); desc("S60", "yes", "-s60", "Compile with support for the S60 UI Framework\n"); + desc("SYMBIAN_DEFFILES", "no", "no-usedeffiles", "Disable the usage of DEF files."); + desc("SYMBIAN_DEFFILES", "yes", "usedeffiles", "Enable the usage of DEF files.\n"); return true; } return false; @@ -2744,6 +2753,11 @@ void Configure::generateCachefile() if ( dictionary["PLUGIN_MANIFESTS"] == "no" ) configStream << " no_plugin_manifest"; + if ( dictionary["SYMBIAN_DEFFILES"] == "yes" ) { + configStream << " def_files"; + } else if ( dictionary["SYMBIAN_DEFFILES"] == "no" ) { + configStream << " def_files_disabled"; + } configStream << endl; configStream << "QT_ARCH = " << dictionary[ "ARCHITECTURE" ] << endl; if (dictionary["QT_EDITION"].contains("OPENSOURCE")) @@ -3268,6 +3282,14 @@ void Configure::displayConfig() cout << "Support for S60............." << dictionary[ "S60" ] << endl; } + if (dictionary.contains("SYMBIAN_DEFFILES")) { + cout << "Symbian DEF files enabled..." << dictionary[ "SYMBIAN_DEFFILES" ] << endl; + if(dictionary["SYMBIAN_DEFFILES"] == "no") { + cout << "WARNING: Disabling DEF files will mean that Qt is NOT binary compatible with previous versions." << endl; + cout << " This feature is only intended for use during development, NEVER for release builds." << endl; + } + } + if(dictionary["ASSISTANT_WEBKIT"] == "yes") cout << "Using WebKit as html rendering engine in Qt Assistant." << endl; -- cgit v0.12 From 3e51b6c872e86a5e68a8e59770fc1bc32b84da0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Fri, 22 Jan 2010 12:46:32 +0100 Subject: QGraphicsWidget is painted twice on the inital show. Problem occured when doing something in the polishEvent() which eventually ended up as an update(). The problem was that in QGraphicsScene::addItem we scheduled a polish event after scheduling an update, resulting in update requests being processed before polish requests. Auto-test included. Task-number: QTBUG-6956 Reviewed-by: alexis --- src/gui/graphicsview/qgraphicsitem_p.h | 2 ++ src/gui/graphicsview/qgraphicsscene.cpp | 22 +++++++++++++------ src/gui/graphicsview/qgraphicsscene_p.h | 2 +- tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 25 ++++++++++++++++++++++ 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index ac10aa7..bdd8863 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -178,6 +178,7 @@ public: sequentialOrdering(1), updateDueToGraphicsEffect(0), scenePosDescendants(0), + pendingPolish(0), globalStackingOrder(-1), q_ptr(0) { @@ -486,6 +487,7 @@ public: quint32 sequentialOrdering : 1; quint32 updateDueToGraphicsEffect : 1; quint32 scenePosDescendants : 1; + quint32 pendingPolish : 1; // Optional stacking order int globalStackingOrder; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 088a6b9..7e182d0 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -429,12 +429,13 @@ void QGraphicsScenePrivate::unregisterTopLevelItem(QGraphicsItem *item) */ void QGraphicsScenePrivate::_q_polishItems() { - QSet::Iterator it = unpolishedItems.begin(); + QVector::Iterator it = unpolishedItems.begin(); const QVariant booleanTrueVariant(true); while (!unpolishedItems.isEmpty()) { QGraphicsItem *item = *it; it = unpolishedItems.erase(it); unpolishedItemsModified = false; + item->d_ptr->pendingPolish = false; if (!item->d_ptr->explicitlyHidden) { item->itemChange(QGraphicsItem::ItemVisibleChange, booleanTrueVariant); item->itemChange(QGraphicsItem::ItemVisibleHasChanged, booleanTrueVariant); @@ -638,8 +639,14 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) selectedItems.remove(item); hoverItems.removeAll(item); cachedItemsUnderMouse.removeAll(item); - unpolishedItems.remove(item); - unpolishedItemsModified = true; + if (item->d_ptr->pendingPolish) { + const int unpolishedIndex = unpolishedItems.indexOf(item); + if (unpolishedIndex != -1) { + unpolishedItems.remove(unpolishedIndex); + unpolishedItemsModified = true; + } + item->d_ptr->pendingPolish = false; + } resetDirtyItem(item); //We remove all references of item from the sceneEventFilter arrays @@ -2501,6 +2508,11 @@ void QGraphicsScene::addItem(QGraphicsItem *item) return; } + if (d->unpolishedItems.isEmpty()) + QMetaObject::invokeMethod(this, "_q_polishItems", Qt::QueuedConnection); + d->unpolishedItems.append(item); + item->d_ptr->pendingPolish = true; + // Detach this item from its parent if the parent's scene is different // from this scene. if (QGraphicsItem *itemParent = item->d_ptr->parent) { @@ -2583,10 +2595,6 @@ void QGraphicsScene::addItem(QGraphicsItem *item) item->d_ptr->resolveFont(d->font.resolve()); item->d_ptr->resolvePalette(d->palette.resolve()); - if (d->unpolishedItems.isEmpty()) - QMetaObject::invokeMethod(this, "_q_polishItems", Qt::QueuedConnection); - d->unpolishedItems.insert(item); - d->unpolishedItemsModified = true; // Reenable selectionChanged() for individual items --d->selectionChanging; diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index d10811c..a3e36d0 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -108,7 +108,7 @@ public: QPainterPath selectionArea; int selectionChanging; QSet selectedItems; - QSet unpolishedItems; + QVector unpolishedItems; QList topLevelItems; bool needSortTopLevelItems; bool unpolishedItemsModified; diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 909ea54..d3132fe 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -163,6 +163,7 @@ private slots: void addChildInpolishEvent(); void polishEvent(); void polishEvent2(); + void initialShow(); // Task fixes void task236127_bspTreeIndexFails(); @@ -2856,6 +2857,30 @@ void tst_QGraphicsWidget::polishEvent2() QVERIFY(widget->events.contains(QEvent::Polish)); } +void tst_QGraphicsWidget::initialShow() +{ + class MyGraphicsWidget : public QGraphicsWidget + { public: + MyGraphicsWidget() : repaints(0) {} + int repaints; + void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget*) { ++repaints; } + void polishEvent() { update(); } + }; + + QGraphicsScene scene; + MyGraphicsWidget *widget = new MyGraphicsWidget; + + QGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + + QTest::qWait(100); + scene.addItem(widget); + QTest::qWait(100); + + QCOMPARE(widget->repaints, 1); +} + void tst_QGraphicsWidget::QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems() { QGraphicsScene scene; -- cgit v0.12 From 5f4af1b5b5a96875b42750a778dcf6695a844623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Fri, 22 Jan 2010 17:25:38 +0100 Subject: Potential crash when adding items from QGraphicsWidget::polishEvent(). These were processed immediately, so there was a fair chance that we could end up doing a virtual function call on items that were not fully constructed. This patch is also an optimization, since we never remove anything from the vector. Auto-test included. Reviewed-by: Jan-Arve --- src/gui/graphicsview/qgraphicsscene.cpp | 42 ++++++++++++++--------- src/gui/graphicsview/qgraphicsscene_p.h | 1 - tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 43 ++++++++++++++++++++++-- 3 files changed, 68 insertions(+), 18 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 7e182d0..ae48bee 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -292,7 +292,6 @@ QGraphicsScenePrivate::QGraphicsScenePrivate() processDirtyItemsEmitted(false), selectionChanging(0), needSortTopLevelItems(true), - unpolishedItemsModified(true), holesInTopLevelSiblingIndex(false), topLevelSequentialOrdering(true), scenePosDescendantsUpdatePending(false), @@ -429,23 +428,38 @@ void QGraphicsScenePrivate::unregisterTopLevelItem(QGraphicsItem *item) */ void QGraphicsScenePrivate::_q_polishItems() { - QVector::Iterator it = unpolishedItems.begin(); + if (unpolishedItems.isEmpty()) + return; + const QVariant booleanTrueVariant(true); - while (!unpolishedItems.isEmpty()) { - QGraphicsItem *item = *it; - it = unpolishedItems.erase(it); - unpolishedItemsModified = false; - item->d_ptr->pendingPolish = false; - if (!item->d_ptr->explicitlyHidden) { + QGraphicsItem *item = 0; + QGraphicsItemPrivate *itemd = 0; + const int oldUnpolishedCount = unpolishedItems.count(); + + for (int i = 0; i < oldUnpolishedCount; ++i) { + item = unpolishedItems.at(i); + if (!item) + continue; + itemd = item->d_ptr.data(); + itemd->pendingPolish = false; + if (!itemd->explicitlyHidden) { item->itemChange(QGraphicsItem::ItemVisibleChange, booleanTrueVariant); item->itemChange(QGraphicsItem::ItemVisibleHasChanged, booleanTrueVariant); } - if (item->isWidget()) { + if (itemd->isWidget) { QEvent event(QEvent::Polish); QApplication::sendEvent((QGraphicsWidget *)item, &event); } - if (unpolishedItemsModified) - it = unpolishedItems.begin(); + } + + if (unpolishedItems.count() == oldUnpolishedCount) { + // No new items were added to the vector. + unpolishedItems.clear(); + } else { + // New items were appended; keep them and remove the old ones. + unpolishedItems.remove(0, oldUnpolishedCount); + unpolishedItems.squeeze(); + QMetaObject::invokeMethod(q_ptr, "_q_polishItems", Qt::QueuedConnection); } } @@ -641,10 +655,8 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) cachedItemsUnderMouse.removeAll(item); if (item->d_ptr->pendingPolish) { const int unpolishedIndex = unpolishedItems.indexOf(item); - if (unpolishedIndex != -1) { - unpolishedItems.remove(unpolishedIndex); - unpolishedItemsModified = true; - } + if (unpolishedIndex != -1) + unpolishedItems[unpolishedIndex] = 0; item->d_ptr->pendingPolish = false; } resetDirtyItem(item); diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index a3e36d0..54d8130 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -111,7 +111,6 @@ public: QVector unpolishedItems; QList topLevelItems; bool needSortTopLevelItems; - bool unpolishedItemsModified; bool holesInTopLevelSiblingIndex; bool topLevelSequentialOrdering; diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index c08a628e..547e7f5 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -270,6 +270,7 @@ private slots: void initialFocus_data(); void initialFocus(); void polishItems(); + void polishItems2(); void isActive(); void siblingIndexAlwaysValid(); @@ -3942,14 +3943,23 @@ void tst_QGraphicsScene::initialFocus() class PolishItem : public QGraphicsTextItem { public: - PolishItem(QGraphicsItem *parent = 0) : QGraphicsTextItem(parent) { } + PolishItem(QGraphicsItem *parent = 0) + : QGraphicsTextItem(parent), polished(false), deleteChildrenInPolish(true), addChildrenInPolish(false) { } + bool polished; + bool deleteChildrenInPolish; + bool addChildrenInPolish; protected: QVariant itemChange(GraphicsItemChange change, const QVariant& value) { if (change == ItemVisibleChange) { - if (value.toBool()) + polished = true; + if (deleteChildrenInPolish) qDeleteAll(childItems()); + if (addChildrenInPolish) { + for (int i = 0; i < 10; ++i) + new PolishItem(this); + } } return QGraphicsItem::itemChange(change, value); } @@ -3966,6 +3976,35 @@ void tst_QGraphicsScene::polishItems() QMetaObject::invokeMethod(&scene,"_q_polishItems"); } +void tst_QGraphicsScene::polishItems2() +{ + QGraphicsScene scene; + PolishItem *item = new PolishItem; + item->addChildrenInPolish = true; + item->deleteChildrenInPolish = true; + // These children should be deleted in the polish. + for (int i = 0; i < 20; ++i) + new PolishItem(item); + scene.addItem(item); + + // Wait for the polish event to be delivered. + QVERIFY(!item->polished); + QApplication::processEvents(); + QVERIFY(item->polished); + + // We deleted the children we added above, but we also + // added 10 new children. These should be polished in the next + // event loop iteration. + QList children = item->childItems(); + QCOMPARE(children.count(), 10); + foreach (QGraphicsItem *child, children) + QVERIFY(!static_cast(child)->polished); + + QApplication::processEvents(); + foreach (QGraphicsItem *child, children) + QVERIFY(static_cast(child)->polished); +} + void tst_QGraphicsScene::isActive() { QGraphicsScene scene1; -- cgit v0.12 From e5e6d9e7fe8f5c3baa5caf609198db1184f59ef9 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 22 Jan 2010 13:15:21 -0800 Subject: Implement QDirectFBPixmapData::scroll This is a very operation in DirectFB and saves a fair bit of overhead. Reviewed-by: Donald Carr --- .../gfxdrivers/directfb/qdirectfbpixmap.cpp | 31 +++++++++++++++++++--- src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h | 1 + 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index 1cbfdaf..f27440e 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -552,6 +552,34 @@ QImage *QDirectFBPixmapData::buffer() return &lockedImage; } + +bool QDirectFBPixmapData::scroll(int dx, int dy, const QRect &rect) +{ + if (!dfbSurface) { + return false; + } + unlockSurface(); + DFBResult result = dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX); + if (result != DFB_OK) { + DirectFBError("QDirectFBPixmapData::scroll", result); + return false; + } + result = dfbSurface->SetPorterDuff(dfbSurface, DSPD_NONE); + if (result != DFB_OK) { + DirectFBError("QDirectFBPixmapData::scroll", result); + return false; + } + + const DFBRectangle source = { rect.x(), rect.y(), rect.width(), rect.height() }; + result = dfbSurface->Blit(dfbSurface, dfbSurface, &source, source.x + dx, source.y + dy); + if (result != DFB_OK) { + DirectFBError("QDirectFBPixmapData::scroll", result); + return false; + } + + return true; +} + void QDirectFBPixmapData::invalidate() { if (dfbSurface) { @@ -568,6 +596,3 @@ void QDirectFBPixmapData::invalidate() QT_END_NAMESPACE #endif // QT_NO_QWS_DIRECTFB - - - diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h index f9b14a9..da6edc6 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h @@ -81,6 +81,7 @@ public: virtual QImage toImage() const; virtual QPaintEngine *paintEngine() const; virtual QImage *buffer(); + virtual bool scroll(int dx, int dy, const QRect &rect); // Pure virtual in QPixmapData, so re-implement here and delegate to QDirectFBPaintDevice virtual int metric(QPaintDevice::PaintDeviceMetric m) const { return QDirectFBPaintDevice::metric(m); } -- cgit v0.12 From 517631a6021a480e4098e39e7d6f65d91c35559d Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 22 Jan 2010 17:36:05 +0100 Subject: Another ASSERT while deleting spans That rare case when we are deleting the last span was not being taken care of. Unbelievable but true. Auto-test included. Reviewed-by: Thierry Reviewed-by: leo Task-number: QTBUG-6004 --- src/gui/itemviews/qtableview.cpp | 4 +++- tests/auto/qtableview/tst_qtableview.cpp | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index 7eefb0b..3111896 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -114,7 +114,9 @@ void QSpanCollection::updateSpan(QSpanCollection::Span *span, int old_height) } } else if (old_height > span->height()) { //remove the span from all the subspans lists that intersect the columns not covered anymore - Index::iterator it_y = index.lowerBound(qMin(-span->bottom(), 0)); + Index::iterator it_y = index.lowerBound(-span->bottom()); + if (it_y == index.end()) + it_y = index.find(-span->top()); // This is the only span remaining and we are deleting it. Q_ASSERT(it_y != index.end()); //it_y must exist since the span is in the list while (-it_y.key() <= span->top() + old_height -1) { if (-it_y.key() > span->bottom()) { diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 7a5e68f..430712c 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -3024,6 +3024,14 @@ void tst_QTableView::spans_data() << QPoint(0, 0) << 1 << 1; + + QTest::newRow("QTBUG-6004 (follow-up): No failing Q_ASSERT, then it passes.") + << 10 << 10 + << (SpanList() << QRect(2, 2, 1, 3) << QRect(2, 2, 1, 1)) + << false + << QPoint(0, 0) + << 1 + << 1; } void tst_QTableView::spans() -- cgit v0.12 From ad1bc0ae6500092cbfb75ab869b3757add7ba4b7 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 25 Jan 2010 10:53:27 +0200 Subject: Added Symbian backup & restore support for Qt.sis and fluidlauncher.sis. Task-number: QTBUG-7518 Reviewed-by: Janne Koskinen --- demos/embedded/fluidlauncher/backup_registration.xml | 8 ++++++++ demos/embedded/fluidlauncher/fluidlauncher.pro | 5 ++++- src/s60installs/backup_registration.xml | 5 +++++ src/s60installs/s60installs.pro | 6 +++++- 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 demos/embedded/fluidlauncher/backup_registration.xml create mode 100644 src/s60installs/backup_registration.xml diff --git a/demos/embedded/fluidlauncher/backup_registration.xml b/demos/embedded/fluidlauncher/backup_registration.xml new file mode 100644 index 0000000..794e11d --- /dev/null +++ b/demos/embedded/fluidlauncher/backup_registration.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/demos/embedded/fluidlauncher/fluidlauncher.pro b/demos/embedded/fluidlauncher/fluidlauncher.pro index bb8835b..92d6e1e 100644 --- a/demos/embedded/fluidlauncher/fluidlauncher.pro +++ b/demos/embedded/fluidlauncher/fluidlauncher.pro @@ -207,8 +207,11 @@ symbian { saxbookmarks.sources += $$PWD/../../../examples/xml/saxbookmarks/jennifer.xbel saxbookmarks.path = /data/qt/saxbookmarks + fluidbackup.sources = backup_registration.xml + fluidbackup.path = /private/$$replace(TARGET.UID3, 0x,) + DEPLOYMENT += config files executables viewerimages saxbookmarks reg_resource resource \ - mifs desktopservices_music desktopservices_images + mifs desktopservices_music desktopservices_images fluidbackup TARGET.EPOCHEAPSIZE = 100000 20000000 } diff --git a/src/s60installs/backup_registration.xml b/src/s60installs/backup_registration.xml new file mode 100644 index 0000000..e026140 --- /dev/null +++ b/src/s60installs/backup_registration.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 55eaee1..aaecf6c 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -78,7 +78,11 @@ symbian: { DEPLOYMENT += phonon_backend_plugins } - DEPLOYMENT += qtresources qtlibraries imageformats_plugins codecs_plugins graphicssystems_plugins + # Support backup & restore for Qt libraries + qtbackup.sources = backup_registration.xml + qtbackup.path = c:/private/10202D56/import/packages/$$replace(TARGET.UID3, 0x,) + + DEPLOYMENT += qtresources qtlibraries qtbackup imageformats_plugins codecs_plugins graphicssystems_plugins contains(QT_CONFIG, svg): { qtlibraries.sources += QtSvg.dll -- cgit v0.12 From 797fff07e03e1ff07fe544bbf0cfa44c35099c09 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 25 Jan 2010 10:57:22 +0100 Subject: Cosmetic: move the "Alsa support..." line to a more appropriate place --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 81872f9..4a94f93 100755 --- a/configure +++ b/configure @@ -7557,6 +7557,8 @@ elif [ "$CFG_OPENSSL" = "linked" ]; then OPENSSL_LINKAGE="(linked)" fi echo "OpenSSL support ..... $CFG_OPENSSL $OPENSSL_LINKAGE" +echo "Alsa support ........ $CFG_ALSA" +echo [ "$CFG_PTMALLOC" != "no" ] && echo "Use ptmalloc ........ $CFG_PTMALLOC" @@ -7581,8 +7583,6 @@ if [ "$PLATFORM_MAC" = "yes" ] && [ "$CFG_FRAMEWORK" = "yes" ] && [ "$CFG_DEBUG" echo "NOTE: Mac OS X frameworks implicitly build debug and release Qt libraries." echo fi -echo "alsa support ........ $CFG_ALSA" -echo sepath=`echo "$relpath" | sed -e 's/\\./\\\\./g'` PROCS=1 -- cgit v0.12 From 7bbd14b371fe6d931b0c65b00bf36f3b9a2ac33c Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 25 Jan 2010 12:29:19 +0200 Subject: QListView::setAlternatingRowColors is not working QS60Style does not really support alternating line/cell backgrounds. This is due to that no such thing exists on native side and we are using a graphical theme image as list/table background. For style, we'll use QPalette::Light with some transparecy to achieve this. Light is guaranteed to have good contrast with theme background as it is derived from QPalette::Button, which is calculated from button graphics, which *should* be used on top of theme background. Task-number: QTBUG-5980 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 28e94a3..5086549 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -675,8 +675,7 @@ void QS60StylePrivate::setThemePalette(QPalette *palette) const s60Color(QS60StyleEnums::CL_QsnHighlightColors, 2, 0)); // set background image as a texture brush palette->setBrush(QPalette::Window, backgroundTexture()); - // set these as transparent so that styled full screen theme background is visible - palette->setColor(QPalette::AlternateBase, Qt::transparent); + // set as transparent so that styled full screen theme background is visible palette->setBrush(QPalette::Base, Qt::transparent); // set button and tooltipbase based on pixel colors const QColor buttonColor = colorFromFrameGraphics(SF_ButtonNormal); @@ -688,6 +687,9 @@ void QS60StylePrivate::setThemePalette(QPalette *palette) const palette->setColor(QPalette::Midlight, palette->color(QPalette::Button).lighter(125)); palette->setColor(QPalette::Mid, palette->color(QPalette::Button).darker(150)); palette->setColor(QPalette::Shadow, Qt::black); + QColor alternateBase = palette->light().color(); + alternateBase.setAlphaF(0.8); + palette->setColor(QPalette::AlternateBase, alternateBase); QApplication::setPalette(*palette); //calling QApplication::setPalette clears palette hash setThemePaletteHash(palette); @@ -2210,7 +2212,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti break; #ifndef QT_NO_ITEMVIEWS case PE_PanelItemViewItem: - case PE_PanelItemViewRow: // ### Qt 5: remove break; #endif //QT_NO_ITEMVIEWS @@ -2279,7 +2280,23 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti } } break; - + case PE_PanelItemViewRow: // ### Qt 5: remove +#ifndef QT_NO_ITEMVIEWS + if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast(option)) { + if (vopt->palette.base().texture().cacheKey() != QS60StylePrivate::m_themePalette->base().texture().cacheKey()) { + //QPalette::Base has been changed, let commonstyle draw the item + commonStyleDraws = true; + } else { + QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled; + if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active)) + cg = QPalette::Inactive; + if (vopt->features & QStyleOptionViewItemV2::Alternate) + painter->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::AlternateBase)); + //apart from alternate base, no background for list item is drawn for S60Style + } + } +#endif + break; case PE_PanelScrollAreaCorner: break; -- cgit v0.12 From ce64d3c7e0b93fa6792513f804b42d31acccc68e Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 25 Jan 2010 12:37:13 +0200 Subject: RadioButtons/Checkboxes should have theme highlight Currently only keypad navigation focus is drawn to RadioButtons and CheckBoxes in non-touch devices. However, in S60 the native widgets have themed highlight (similar to lists). This task will add that highlight support for these widgets regardless if keypad navigation is active or not. Task-number: QTBUG-5536 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 65 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 5086549..de28cfb 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -68,6 +68,8 @@ #include "qtoolbutton.h" #include "qfocusframe.h" #include "qformlayout.h" +#include "qradiobutton.h" +#include "qcheckbox.h" #include "qprogressbar.h" #include "private/qtoolbarextension_p.h" @@ -780,6 +782,11 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const QApplication::setPalette(widgetPalette, "QComboBox"); widgetPalette = *palette; + widgetPalette.setColor(QPalette::WindowText, s60Color(QS60StyleEnums::CL_QsnTextColors, 7, 0)); + QApplication::setPalette(widgetPalette, "QRadioButton"); + QApplication::setPalette(widgetPalette, "QCheckBox"); + widgetPalette = *palette; + widgetPalette.setColor(QPalette::WindowText, mainAreaTextColor); widgetPalette.setColor(QPalette::Button, QApplication::palette().color(QPalette::Button)); widgetPalette.setColor(QPalette::Dark, mainAreaTextColor.darker()); @@ -1254,6 +1261,31 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, Q_D(const QS60Style); const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; switch (element) { + case CE_CheckBox: + case CE_RadioButton: + if (const QStyleOptionButton *btn = qstyleoption_cast(option)) { + bool isRadio = (element == CE_RadioButton); + // Highlight needs to be drawn first, as it goes "underneath" the text and indicator. + if (btn->state & State_HasFocus) { + QStyleOptionFocusRect fropt; + fropt.QStyleOption::operator=(*btn); + fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect + : SE_CheckBoxFocusRect, btn, widget); + drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); + } + QStyleOptionButton subopt = *btn; + + subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator + : SE_CheckBoxIndicator, btn, widget); + drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, + &subopt, painter, widget); + subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents + : SE_CheckBoxContents, btn, widget); + + drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget); + } + break; + case CE_PushButton: if (const QStyleOptionButton *btn = qstyleoption_cast(option)) { @@ -1997,6 +2029,17 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti bool commonStyleDraws = false; switch (element) { + case PE_FrameFocusRect: { + //Draw themed highlight to radiobuttons and checkboxes. + //For other widgets skip, unless palette has been modified. In that case, draw with commonstyle. + if (option->palette.highlight().color() == QS60StylePrivate::themePalette()->highlight().color()) + if ((qstyleoption_cast(option) && + (qobject_cast(widget) || qobject_cast(widget)))) + QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, option->rect, flags); + else + commonStyleDraws = true; + } + break; #ifndef QT_NO_LINEEDIT case PE_PanelLineEdit: if (const QStyleOptionFrame *lineEdit = qstyleoption_cast(option)) { @@ -2687,6 +2730,9 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con { QRect ret; switch (element) { + case SE_RadioButtonFocusRect: + ret = opt->rect; + break; case SE_LineEditContents: { // in S60 the input text box doesn't start from line Edit's TL, but // a bit indented. @@ -2837,6 +2883,25 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con } ret = visualRect(opt->direction, opt->rect, ret); break; + case SE_RadioButtonIndicator: { + const int height = pixelMetric(PM_ExclusiveIndicatorHeight, opt, widget); + ret.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - height) >> 1), + pixelMetric(PM_ExclusiveIndicatorWidth, opt, widget), height); + ret.translate(2, 0); //move indicator slightly to avoid highlight crossing over it + ret = visualRect(opt->direction, opt->rect, ret); + } + break; + case SE_CheckBoxIndicator: { + const int height = pixelMetric(PM_IndicatorHeight, opt, widget); + ret.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - height) >> 1), + pixelMetric(PM_IndicatorWidth, opt, widget), height); + ret.translate(2, 0); //move indicator slightly to avoid highlight crossing over it + ret = visualRect(opt->direction, opt->rect, ret); + } + break; + case SE_CheckBoxFocusRect: + ret = opt->rect; + break; default: ret = QCommonStyle::subElementRect(element, opt, widget); } -- cgit v0.12 From 87ee066fc86cf6410fd008a8a5d31122a7d5cc11 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 21 Jan 2010 13:43:27 +0100 Subject: Made characters in a password field briefly visible while typing. This was done by intercepting key events with text in them, and temporarily submit them as preedit text instead of real input text. Currently it does not work in WebKit, but that is because WebKit hides preedit text as well, which is a bug of its own. RevBy: Simon Hausmann Autotest: Manual testing went fine --- src/gui/inputmethod/qcoefepinputcontext_p.h | 7 ++++ src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 50 ++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_p.h b/src/gui/inputmethod/qcoefepinputcontext_p.h index 0b84e2f..f5034fc 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_p.h +++ b/src/gui/inputmethod/qcoefepinputcontext_p.h @@ -57,6 +57,7 @@ #include "qinputcontext.h" #include +#include #include #include @@ -91,6 +92,9 @@ public: TCoeInputCapabilities inputCapabilities(); +protected: + void timerEvent(QTimerEvent *timerEvent); + private: void commitCurrentString(bool triggeredBySymbian); void updateHints(bool mustUpdateInputCapabilities); @@ -98,6 +102,7 @@ private: void applyFormat(QList *attributes); void queueInputCapabilitiesChanged(); bool needsInputPanel(); + void commitTemporaryPreeditString(); private Q_SLOTS: void ensureInputCapabilitiesChanged(); @@ -148,6 +153,8 @@ private: MFepPointerEventHandlerDuringInlineEdit *m_pointerHandler; int m_longPress; int m_cursorPos; + QBasicTimer m_tempPreeditStringTimeout; + bool m_hasTempPreeditString; }; QT_END_NAMESPACE diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index d2f207a..793bcde 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -72,7 +72,8 @@ QCoeFepInputContext::QCoeFepInputContext(QObject *parent) m_formatRetriever(0), m_pointerHandler(0), m_longPress(0), - m_cursorPos(0) + m_cursorPos(0), + m_hasTempPreeditString(false) { m_fepState->SetObjectProvider(this); m_fepState->SetFlags(EAknEditorFlagDefault); @@ -100,6 +101,8 @@ QCoeFepInputContext::~QCoeFepInputContext() void QCoeFepInputContext::reset() { + commitTemporaryPreeditString(); + CCoeFep* fep = CCoeEnv::Static()->Fep(); if (fep) fep->CancelTransaction(); @@ -200,7 +203,11 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event) if (!focusWidget()) return false; - if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) { + switch (event->type()) { + case QEvent::KeyPress: + commitTemporaryPreeditString(); + // fall through intended + case QEvent::KeyRelease: const QKeyEvent *keyEvent = static_cast(event); switch (keyEvent->key()) { case Qt::Key_F20: @@ -223,6 +230,21 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event) default: break; } + + if (keyEvent->type() == QEvent::KeyPress + && focusWidget()->inputMethodHints() & Qt::ImhHiddenText + && !keyEvent->text().isEmpty()) { + // Send some temporary preedit text in order to make text visible for a moment. + m_preeditString = keyEvent->text(); + QList attributes; + QInputMethodEvent imEvent(m_preeditString, attributes); + QApplication::sendEvent(focusWidget(), &imEvent); + m_tempPreeditStringTimeout.start(1000, this); + m_hasTempPreeditString = true; + update(); + return true; + } + break; } if (!needsInputPanel()) @@ -253,6 +275,24 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event) return false; } +void QCoeFepInputContext::timerEvent(QTimerEvent *timerEvent) +{ + if (timerEvent->timerId() == m_tempPreeditStringTimeout.timerId()) + commitTemporaryPreeditString(); +} + +void QCoeFepInputContext::commitTemporaryPreeditString() +{ + if (m_tempPreeditStringTimeout.isActive()) + m_tempPreeditStringTimeout.stop(); + + if (!m_hasTempPreeditString) + return; + + commitCurrentString(false); + m_hasTempPreeditString = false; +} + void QCoeFepInputContext::mouseHandler( int x, QMouseEvent *event) { Q_ASSERT(focusWidget()); @@ -310,6 +350,8 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints) { using namespace Qt; + commitTemporaryPreeditString(); + bool numbersOnly = hints & ImhDigitsOnly || hints & ImhFormattedNumbersOnly || hints & ImhDialableCharactersOnly; bool noOnlys = !(numbersOnly || hints & ImhUppercaseOnly @@ -501,6 +543,8 @@ void QCoeFepInputContext::StartFepInlineEditL(const TDesC& aInitialInlineText, if (!w) return; + commitTemporaryPreeditString(); + m_cursorPos = w->inputMethodQuery(Qt::ImCursorPosition).toInt(); QList attributes; @@ -600,6 +644,8 @@ void QCoeFepInputContext::SetCursorSelectionForFepL(const TCursorSelection& aCur if (!w) return; + commitTemporaryPreeditString(); + int pos = aCursorSelection.iAnchorPos; int length = aCursorSelection.iCursorPos - pos; -- cgit v0.12 From 60db8ffc35b9e798fc2c24087a8d56736321d03b Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 25 Jan 2010 13:03:50 +0200 Subject: QS60Style: Combobox button is not drawn pressed Currently S60Style ignores the pressed down state when drawing the combobox button. This is due to button drawing picking up wrong QStyleOption (just initialized, no correct style data applied). Greatly simplified toolbutton drawing and fixed the combobox to use correct QStyleOption. Task-number: QTBUG-6950 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 110 ++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 75 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index de28cfb..1bbb45f 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1032,102 +1032,62 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom #ifndef QT_NO_TOOLBUTTON case CC_ToolButton: if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast(option)) { - const State bflags = toolBtn->state; + State bflags = toolBtn->state & ~State_Sunken; + + if (bflags & State_AutoRaise) { + if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) { + bflags &= ~State_Raised; + } + } + State mflags = bflags; + if (toolBtn->state & State_Sunken) { + if (toolBtn->activeSubControls & SC_ToolButton) + bflags |= State_Sunken; + mflags |= State_Sunken; + } + const QRect button(subControlRect(control, toolBtn, SC_ToolButton, widget)); QRect menuRect = QRect(); if (toolBtn->subControls & SC_ToolButtonMenu) menuRect = subControlRect(control, toolBtn, SC_ToolButtonMenu, widget); - QStyleOptionToolButton toolButton = *toolBtn; - - if (sub&SC_ToolButton) { + if (toolBtn->subControls & SC_ToolButton) { QStyleOption tool(0); tool.palette = toolBtn->palette; - // Check if toolbutton is in toolbar. - QToolBar *toolBar = 0; - if (widget) - toolBar = qobject_cast(widget->parentWidget()); - - if (bflags & (State_Sunken | State_On | State_Raised)) { + if (bflags & (State_Sunken | State_On | State_Raised | State_Enabled)) { tool.rect = button.unite(menuRect); tool.state = bflags; - - // todo: I'd like to move extension button next to where last button is - // however, the painter seems to want to clip the button rect even if I turn of the clipping. - if (toolBar && (qobject_cast(widget))){ - /*QList actionList = toolBar->actions(); - const int actionCount = actionList.count(); - const int toolbarWidth = toolBar->width(); - const int extButtonWidth = pixelMetric(PM_ToolBarExtensionExtent, option, widget); - const int toolBarButtonWidth = pixelMetric(PM_ToolBarIconSize, option, widget); - const int frame = pixelMetric(PM_ToolBarFrameWidth, option, widget); - const int margin = pixelMetric(PM_ToolBarItemMargin, option, widget); - const int border = frame + margin; - const int spacing = pixelMetric(PM_ToolBarItemSpacing, option, widget); - const int toolBarButtonArea = toolbarWidth - extButtonWidth - spacing - 2*border; - const int numberOfVisibleButtons = toolBarButtonArea / toolBarButtonWidth; - // new extension button place is after border and all the other visible buttons (with spacings) - const int newXForExtensionButton = numberOfVisibleButtons * toolBarButtonWidth + (numberOfVisibleButtons-1)*spacing + border; - painter->save(); - painter->setClipping(false); - tool.rect.translate(-newXForExtensionButton,0); - painter->restore();*/ - } - - if (toolBar){ - /*if (toolBar->orientation() == Qt::Vertical){ - // todo: I'd like to make all vertical buttons the same size, but again the painter - // prefers to use clipping for button rects, even though clipping has been set off. - painter->save(); - painter->setClipping(false); - - const int origWidth = tool.rect.width(); - const int newWidth = toolBar->width()-2*pixelMetric(PM_ToolBarFrameWidth, option, widget); - painter->translate(origWidth-newWidth,0); - tool.rect.translate(origWidth-tool.rect.width(),0); - tool.rect.setWidth(newWidth); - - if (option->state & QStyle::State_Sunken) - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ToolBarButtonPressed, painter, tool.rect, flags); - else - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ToolBarButton, painter, tool.rect, flags); - - }*/ - if (option->state & QStyle::State_Sunken) - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ToolBarButtonPressed, painter, tool.rect, flags); - else - QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ToolBarButton, painter, tool.rect, flags); - /* - if (toolBar->orientation() == Qt::Vertical) - painter->restore(); - */ - } else { - drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); - } - - if (toolButton.subControls & SC_ToolButtonMenu) { - tool.rect = menuRect; - tool.state = bflags; - drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); - } + const QToolButton *toolButtonWidget = qobject_cast(widget); + QS60StylePrivate::SkinElements element; + if (toolButtonWidget) + element = (toolButtonWidget->isDown()) ? QS60StylePrivate::SE_ToolBarButtonPressed : QS60StylePrivate::SE_ToolBarButton; + else + element = (option->state & State_Sunken) ? QS60StylePrivate::SE_ToolBarButtonPressed : QS60StylePrivate::SE_ToolBarButton; + QS60StylePrivate::drawSkinElement(element, painter, tool.rect, flags); + drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); + } + if (toolBtn->subControls & SC_ToolButtonMenu) { + tool.rect = menuRect; + tool.state = mflags; + drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); } } - + QStyleOptionToolButton toolButton = *toolBtn; if (toolBtn->features & QStyleOptionToolButton::Arrow) { - QStyle::PrimitiveElement pe; + PrimitiveElement pe; switch (toolBtn->arrowType) { case Qt::LeftArrow: - pe = QStyle::PE_IndicatorArrowLeft; + pe = PE_IndicatorArrowLeft; break; case Qt::RightArrow: - pe = QStyle::PE_IndicatorArrowRight; + pe = PE_IndicatorArrowRight; break; case Qt::UpArrow: - pe = QStyle::PE_IndicatorArrowUp; + pe = PE_IndicatorArrowUp; break; case Qt::DownArrow: - pe = QStyle::PE_IndicatorArrowDown; + pe = PE_IndicatorArrowDown; break; default: break; } -- cgit v0.12 From 855ce69f17f570bc91e02bfb34d9e3f1699b3b18 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 25 Jan 2010 12:29:25 +0100 Subject: QNativeSocketEngine_win: Don't mess with linger settings Reviewed-by: thiago --- src/network/socket/qnativesocketengine_win.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index 7088a57..bbe9fde 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -1199,8 +1199,10 @@ void QNativeSocketEnginePrivate::nativeClose() #if defined (QTCPSOCKETENGINE_DEBUG) qDebug("QNativeSocketEnginePrivate::nativeClose()"); #endif - linger l = {1, 0}; - ::setsockopt(socketDescriptor, SOL_SOCKET, SO_DONTLINGER, (char*)&l, sizeof(l)); + // We were doing a setsockopt here before with SO_DONTLINGER. (However with kind of wrong + // usage of parameters, it wants a BOOL but we used a struct and pretended it to be bool). + // We don't think setting this option should be done here, if a user wants it she/he can + // do it manually with socketDescriptor()/setSocketDescriptor(); ::closesocket(socketDescriptor); } -- cgit v0.12 From c56ede1d6f5082cd10c310d473779cfea3363fe6 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Mon, 25 Jan 2010 13:17:21 +0100 Subject: Crash when deleting QMainWindow with native toolbar on Cocoa. The crash happens while processing a paint message received by the NSToolbar after the corresponding QToolbar has been destroyed. So while cleaning up the toolbar, the view needs to be detached from the custom toolbar item. Task-number: QTBUG-7305 Reviewed-by: Carlos Manuel Duclos Vergara --- src/gui/widgets/qmainwindowlayout_mac.mm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qmainwindowlayout_mac.mm b/src/gui/widgets/qmainwindowlayout_mac.mm index ee79f5a..d92168a 100644 --- a/src/gui/widgets/qmainwindowlayout_mac.mm +++ b/src/gui/widgets/qmainwindowlayout_mac.mm @@ -472,14 +472,20 @@ void QMainWindowLayout::removeFromMacToolbar(QToolBar *toolbar) void QMainWindowLayout::cleanUpMacToolbarItems() { - for (int i = 0; i < toolbarItemsCopy.size(); ++i) +#ifdef QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool; +#endif + for (int i = 0; i < toolbarItemsCopy.size(); ++i) { +#ifdef QT_MAC_USE_COCOA + NSToolbarItem *item = static_cast(toolbarItemsCopy.at(i)); + [item setView:0]; +#endif CFRelease(toolbarItemsCopy.at(i)); + } toolbarItemsCopy.clear(); unifiedToolbarHash.clear(); #ifdef QT_MAC_USE_COCOA - QMacCocoaAutoReleasePool pool; - OSWindowRef window = qt_mac_window_for(layoutState.mainWindow); NSToolbar *macToolbar = [window toolbar]; if (macToolbar) { -- cgit v0.12 From 6a3889146985e9e95b8a54e31003be8265e2469e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 15 Jan 2010 13:23:51 +0100 Subject: Small optimization in raster paint engine. Don't repeatedly update the pen / brush if no pen / brush is set. Reviewed-by: Gunnar Sletta --- src/gui/painting/qpaintengine_raster_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index b937f66..a1c73cc 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -264,13 +264,13 @@ private: #endif // Q_OS_SYMBIAN && QT_NO_FREETYPE inline void ensureBrush(const QBrush &brush) { - if (!qbrush_fast_equals(state()->lastBrush, brush) || state()->fillFlags) + if (!qbrush_fast_equals(state()->lastBrush, brush) || (brush.style() != Qt::NoBrush && state()->fillFlags)) updateBrush(brush); } inline void ensureBrush() { ensureBrush(state()->brush); } inline void ensurePen(const QPen &pen) { - if (!qpen_fast_equals(state()->lastPen, pen) || state()->strokeFlags) + if (!qpen_fast_equals(state()->lastPen, pen) || (pen.style() != Qt::NoPen && state()->strokeFlags)) updatePen(pen); } inline void ensurePen() { ensurePen(state()->pen); } -- cgit v0.12 From 235ea60ba2c8552038cf9ddc62d473ee865e2b66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 19 Jan 2010 15:04:07 +0100 Subject: Made the trace replayer handle limited resolution cases better. Simply skip the updates that are outside the replay widget's bounds. Reviewed-by: Gunnar Sletta --- tools/qttracereplay/main.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/tools/qttracereplay/main.cpp b/tools/qttracereplay/main.cpp index 85e9b12..a932d72 100644 --- a/tools/qttracereplay/main.cpp +++ b/tools/qttracereplay/main.cpp @@ -52,6 +52,7 @@ public: ReplayWidget(const QString &filename); void paintEvent(QPaintEvent *event); + void resizeEvent(QResizeEvent *event); public slots: void updateRect(); @@ -64,14 +65,15 @@ public: int currentIteration; QTime timer; + QList visibleUpdates; QList iterationTimes; QString filename; }; void ReplayWidget::updateRect() { - if (!updates.isEmpty()) - update(updates.at(currentFrame)); + if (!visibleUpdates.isEmpty()) + update(updates.at(visibleUpdates.at(currentFrame))); } void ReplayWidget::paintEvent(QPaintEvent *) @@ -80,10 +82,10 @@ void ReplayWidget::paintEvent(QPaintEvent *) // p.setClipRegion(frames.at(currentFrame).updateRegion); - buffer.draw(&p, currentFrame); + buffer.draw(&p, visibleUpdates.at(currentFrame)); ++currentFrame; - if (currentFrame >= buffer.numFrames()) { + if (currentFrame >= visibleUpdates.size()) { currentFrame = 0; ++currentIteration; @@ -119,7 +121,7 @@ void ReplayWidget::paintEvent(QPaintEvent *) if (iterationTimes.size() >= 10 || stddev < 4) { printf("%s, iterations: %d, frames: %d, min(ms): %d, median(ms): %d, stddev: %f %%, max(fps): %f\n", qPrintable(filename), - iterationTimes.size(), updates.size(), min, median, stddev, 1000. * updates.size() / min); + iterationTimes.size(), visibleUpdates.size(), min, median, stddev, 1000. * visibleUpdates.size() / min); deleteLater(); return; } @@ -130,6 +132,21 @@ void ReplayWidget::paintEvent(QPaintEvent *) QTimer::singleShot(0, this, SLOT(updateRect())); } +void ReplayWidget::resizeEvent(QResizeEvent *event) +{ + visibleUpdates.clear(); + + QRect bounds = rect(); + for (int i = 0; i < updates.size(); ++i) { + if (updates.at(i).intersects(bounds)) + visibleUpdates << i; + } + + if (visibleUpdates.size() != updates.size()) + printf("Warning: skipped %d frames due to limited resolution\n", updates.size() - visibleUpdates.size()); + +} + ReplayWidget::ReplayWidget(const QString &filename_) : currentFrame(0) , currentIteration(0) @@ -138,7 +155,6 @@ ReplayWidget::ReplayWidget(const QString &filename_) setWindowTitle(filename); QFile file(filename); - QRect bounds; if (!file.open(QIODevice::ReadOnly)) { printf("Failed to load input file '%s'\n", qPrintable(filename_)); return; -- cgit v0.12 From e5be6baa698f4779b6af97175015856d146bc479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 14 Jan 2010 13:46:52 +0100 Subject: Fixed child items with graphics effects not inheriting opacity. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to invalidate the graphics source pixmap cache for both child items and parent items when changing the opacity of a graphics item. Reviewed-by: Bjørn Erik Nilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 23 +++++++++++++-- src/gui/graphicsview/qgraphicsitem_p.h | 6 +++- tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 34 ++++++++++++++++++++-- 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index d43176b..b8d392d 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -2565,7 +2565,9 @@ void QGraphicsItem::setOpacity(qreal opacity) // Update. if (d_ptr->scene) { #ifndef QT_NO_GRAPHICSEFFECT - d_ptr->invalidateGraphicsEffectsRecursively(); + d_ptr->invalidateParentGraphicsEffectsRecursively(); + if (!(d_ptr->flags & ItemDoesntPropagateOpacityToChildren)) + d_ptr->invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::OpacityChanged); #endif //QT_NO_GRAPHICSEFFECT d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true, @@ -5075,7 +5077,7 @@ int QGraphicsItemPrivate::depth() const \internal */ #ifndef QT_NO_GRAPHICSEFFECT -void QGraphicsItemPrivate::invalidateGraphicsEffectsRecursively() +void QGraphicsItemPrivate::invalidateParentGraphicsEffectsRecursively() { QGraphicsItemPrivate *itemPrivate = this; do { @@ -5087,6 +5089,21 @@ void QGraphicsItemPrivate::invalidateGraphicsEffectsRecursively() } } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0)); } + +void QGraphicsItemPrivate::invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::InvalidateReason reason) +{ + for (int i = 0; i < children.size(); ++i) { + QGraphicsItemPrivate *childPrivate = children.at(i)->d_ptr.data(); + if (reason == OpacityChanged && (childPrivate->flags & QGraphicsItem::ItemIgnoresParentOpacity)) + continue; + if (childPrivate->graphicsEffect) { + childPrivate->notifyInvalidated = 1; + static_cast(childPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache(); + } + + childPrivate->invalidateChildGraphicsEffectsRecursively(reason); + } +} #endif //QT_NO_GRAPHICSEFFECT /*! @@ -5331,7 +5348,7 @@ void QGraphicsItem::update(const QRectF &rect) // Make sure we notify effects about invalidated source. #ifndef QT_NO_GRAPHICSEFFECT - d_ptr->invalidateGraphicsEffectsRecursively(); + d_ptr->invalidateParentGraphicsEffectsRecursively(); #endif //QT_NO_GRAPHICSEFFECT if (CacheMode(d_ptr->cacheMode) != NoCache) { diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index bdd8863..ff6e8bd 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -225,7 +225,11 @@ public: bool ignoreDirtyBit = false, bool ignoreOpacity = false) const; int depth() const; #ifndef QT_NO_GRAPHICSEFFECT - void invalidateGraphicsEffectsRecursively(); + enum InvalidateReason { + OpacityChanged + }; + void invalidateParentGraphicsEffectsRecursively(); + void invalidateChildGraphicsEffectsRecursively(InvalidateReason reason); #endif //QT_NO_GRAPHICSEFFECT void invalidateDepthRecursively(); void resolveDepth(); diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index 51e2a57..795431b 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -71,6 +71,7 @@ private slots: void colorize(); void drawPixmapItem(); void deviceCoordinateTranslateCaching(); + void inheritOpacity(); }; void tst_QGraphicsEffect::initTestCase() @@ -79,8 +80,8 @@ void tst_QGraphicsEffect::initTestCase() class CustomItem : public QGraphicsRectItem { public: - CustomItem(qreal x, qreal y, qreal width, qreal height) - : QGraphicsRectItem(x, y, width, height), numRepaints(0), + CustomItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent = 0) + : QGraphicsRectItem(x, y, width, height, parent), numRepaints(0), m_painter(0), m_styleOption(0) {} @@ -560,6 +561,35 @@ void tst_QGraphicsEffect::deviceCoordinateTranslateCaching() QVERIFY(item->numRepaints == numRepaints); } +void tst_QGraphicsEffect::inheritOpacity() +{ + QGraphicsScene scene; + QGraphicsRectItem *rectItem = new QGraphicsRectItem(0, 0, 10, 10); + CustomItem *item = new CustomItem(0, 0, 10, 10, rectItem); + + scene.addItem(rectItem); + + item->setGraphicsEffect(new DeviceEffect); + item->setPen(Qt::NoPen); + item->setBrush(Qt::red); + + rectItem->setOpacity(0.5); + + QGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + + QTRY_VERIFY(item->numRepaints >= 1); + + int numRepaints = item->numRepaints; + + rectItem->setOpacity(1); + QTest::qWait(50); + + // item should have been rerendered due to opacity changing + QTRY_VERIFY(item->numRepaints > numRepaints); +} + QTEST_MAIN(tst_QGraphicsEffect) #include "tst_qgraphicseffect.moc" -- cgit v0.12 From a85f708449a5fb61740ec12abd4cb9df3a5265ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 25 Jan 2010 11:52:14 +0100 Subject: Added optimization flag to QGraphicsItemPrivate. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid traversing the whole child hierarchy when opacity changes unless there are children with graphics effects. Reviewed-by: Bjørn Erik Nilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 22 ++++++++++++++++++++++ src/gui/graphicsview/qgraphicsitem_p.h | 3 +++ 2 files changed, 25 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index b8d392d..66493b7 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1075,6 +1075,10 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q p = p->d_ptr->parent; } + // Update graphics effect optimization flag + if (newParent && (graphicsEffect || mayHaveChildWithGraphicsEffect)) + newParent->d_ptr->updateChildWithGraphicsEffectFlagRecursively(); + // Update focus scope item ptr in new scope. QGraphicsItem *newFocusScopeItem = subFocusItem ? subFocusItem : parentFocusScopeItem; if (newFocusScopeItem && newParent) { @@ -2612,6 +2616,8 @@ void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect) if (d_ptr->graphicsEffect) { delete d_ptr->graphicsEffect; d_ptr->graphicsEffect = 0; + } else if (d_ptr->parent) { + d_ptr->parent->d_ptr->updateChildWithGraphicsEffectFlagRecursively(); } if (effect) { @@ -2625,6 +2631,19 @@ void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect) } #endif //QT_NO_GRAPHICSEFFECT +void QGraphicsItemPrivate::updateChildWithGraphicsEffectFlagRecursively() +{ +#ifndef QT_NO_GRAPHICSEFFECT + QGraphicsItemPrivate *itemPrivate = this; + do { + // parent chain already notified? + if (itemPrivate->mayHaveChildWithGraphicsEffect) + return; + itemPrivate->mayHaveChildWithGraphicsEffect = 1; + } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0)); +#endif +} + /*! \internal \since 4.6 @@ -5092,6 +5111,9 @@ void QGraphicsItemPrivate::invalidateParentGraphicsEffectsRecursively() void QGraphicsItemPrivate::invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::InvalidateReason reason) { + if (!mayHaveChildWithGraphicsEffect) + return; + for (int i = 0; i < children.size(); ++i) { QGraphicsItemPrivate *childPrivate = children.at(i)->d_ptr.data(); if (reason == OpacityChanged && (childPrivate->flags & QGraphicsItem::ItemIgnoresParentOpacity)) diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index ff6e8bd..986a977 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -179,6 +179,7 @@ public: updateDueToGraphicsEffect(0), scenePosDescendants(0), pendingPolish(0), + mayHaveChildWithGraphicsEffect(0), globalStackingOrder(-1), q_ptr(0) { @@ -196,6 +197,7 @@ public: return item->d_ptr.data(); } + void updateChildWithGraphicsEffectFlagRecursively(); void updateAncestorFlag(QGraphicsItem::GraphicsItemFlag childFlag, AncestorFlag flag = NoFlag, bool enabled = false, bool root = true); void updateAncestorFlags(); @@ -492,6 +494,7 @@ public: quint32 updateDueToGraphicsEffect : 1; quint32 scenePosDescendants : 1; quint32 pendingPolish : 1; + quint32 mayHaveChildWithGraphicsEffect : 1; // Optional stacking order int globalStackingOrder; -- cgit v0.12 From 91ccf28292f7fb78e0192c281bde2818a9be3a97 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 25 Jan 2010 13:11:46 +0100 Subject: QFileNetworkReply: Use a QFileEngine Slight performance increase. Reviewed-by: Peter Hartmann --- src/network/access/qfilenetworkreply.cpp | 50 +++++++++++++++++++++----------- src/network/access/qfilenetworkreply_p.h | 7 +++-- 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/network/access/qfilenetworkreply.cpp b/src/network/access/qfilenetworkreply.cpp index 8c5065c..4ac9a8c 100644 --- a/src/network/access/qfilenetworkreply.cpp +++ b/src/network/access/qfilenetworkreply.cpp @@ -49,10 +49,15 @@ QT_BEGIN_NAMESPACE QFileNetworkReplyPrivate::QFileNetworkReplyPrivate() - : QNetworkReplyPrivate(), realFileSize(0) + : QNetworkReplyPrivate(), fileEngine(0), fileSize(0), filePos(0) { } +QFileNetworkReplyPrivate::~QFileNetworkReplyPrivate() +{ + delete fileEngine; +} + QFileNetworkReply::~QFileNetworkReply() { } @@ -94,9 +99,8 @@ QFileNetworkReply::QFileNetworkReply(QObject *parent, const QNetworkRequest &req if (fileName.isEmpty()) { fileName = url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery); } - d->realFile.setFileName(fileName); - QFileInfo fi(d->realFile); + QFileInfo fi(fileName); if (fi.isDir()) { QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Cannot open %1: Path is a directory").arg(url.toString()); setError(QNetworkReply::ContentOperationNotPermittedError, msg); @@ -106,14 +110,15 @@ QFileNetworkReply::QFileNetworkReply(QObject *parent, const QNetworkRequest &req return; } - bool opened = d->realFile.open(QIODevice::ReadOnly | QIODevice::Unbuffered); + d->fileEngine = QAbstractFileEngine::create(fileName); + bool opened = d->fileEngine->open(QIODevice::ReadOnly | QIODevice::Unbuffered); // could we open the file? if (!opened) { QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Error opening %1: %2") - .arg(d->realFile.fileName(), d->realFile.errorString()); + .arg(fileName, d->fileEngine->errorString()); - if (d->realFile.exists()) { + if (fi.exists()) { setError(QNetworkReply::ContentAccessDenied, msg); QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection, Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ContentAccessDenied)); @@ -126,13 +131,13 @@ QFileNetworkReply::QFileNetworkReply(QObject *parent, const QNetworkRequest &req return; } - d->realFileSize = fi.size(); + d->fileSize = fi.size(); setHeader(QNetworkRequest::LastModifiedHeader, fi.lastModified()); - setHeader(QNetworkRequest::ContentLengthHeader, d->realFileSize); + setHeader(QNetworkRequest::ContentLengthHeader, d->fileSize); QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "downloadProgress", Qt::QueuedConnection, - Q_ARG(qint64, d->realFileSize), Q_ARG(qint64, d->realFileSize)); + Q_ARG(qint64, d->fileSize), Q_ARG(qint64, d->fileSize)); QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection); } @@ -146,20 +151,25 @@ void QFileNetworkReply::close() { Q_D(QFileNetworkReply); QNetworkReply::close(); - d->realFile.close(); + if (d->fileEngine) + d->fileEngine->close(); } void QFileNetworkReply::abort() { Q_D(QFileNetworkReply); QNetworkReply::close(); - d->realFile.close(); + if (d->fileEngine) + d->fileEngine->close(); } qint64 QFileNetworkReply::bytesAvailable() const { Q_D(const QFileNetworkReply); - return QNetworkReply::bytesAvailable() + d->realFile.bytesAvailable(); + if (!d->fileEngine) + return 0; + + return QNetworkReply::bytesAvailable() + d->fileSize - d->filePos; } bool QFileNetworkReply::isSequential () const @@ -170,7 +180,7 @@ bool QFileNetworkReply::isSequential () const qint64 QFileNetworkReply::size() const { Q_D(const QFileNetworkReply); - return d->realFileSize; + return d->fileSize; } /*! @@ -179,11 +189,17 @@ qint64 QFileNetworkReply::size() const qint64 QFileNetworkReply::readData(char *data, qint64 maxlen) { Q_D(QFileNetworkReply); - qint64 ret = d->realFile.read(data, maxlen); - if (ret == 0 && bytesAvailable() == 0) + if (!d->fileEngine) + return -1; + + qint64 ret = d->fileEngine->read(data, maxlen); + if (ret == 0 && bytesAvailable() == 0) { return -1; // everything had been read - else - return ret; + } else if (ret > 0) { + d->filePos += ret; + } + + return ret; } diff --git a/src/network/access/qfilenetworkreply_p.h b/src/network/access/qfilenetworkreply_p.h index 125fa2e..710ec9f 100644 --- a/src/network/access/qfilenetworkreply_p.h +++ b/src/network/access/qfilenetworkreply_p.h @@ -57,6 +57,7 @@ #include "qnetworkreply_p.h" #include "qnetworkaccessmanager.h" #include +#include QT_BEGIN_NAMESPACE @@ -85,9 +86,11 @@ class QFileNetworkReplyPrivate: public QNetworkReplyPrivate { public: QFileNetworkReplyPrivate(); + ~QFileNetworkReplyPrivate(); - QFile realFile; - qint64 realFileSize; + QAbstractFileEngine *fileEngine; + qint64 fileSize; + qint64 filePos; virtual bool isFinished() const; -- cgit v0.12 From 5f9d86d137eedf45d1067dd54b1d54c2e1eab4b9 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 25 Jan 2010 15:09:44 +0200 Subject: Remove unnecessary scope definitions from QS60Style Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 140 +++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 1bbb45f..9dcf291 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -934,10 +934,10 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom horizontal ? QS60StylePrivate::SE_ScrollBarGrooveHorizontal : QS60StylePrivate::SE_ScrollBarGrooveVertical; QS60StylePrivate::drawSkinElement(grooveElement, painter, grooveRect, flags); - const QStyle::SubControls subControls = optionSlider->subControls; + const SubControls subControls = optionSlider->subControls; // select correct slider (horizontal/vertical/pressed) - const bool sliderPressed = ((optionSlider->state & QStyle::State_Sunken) && (subControls & SC_ScrollBarSlider)); + const bool sliderPressed = ((optionSlider->state & State_Sunken) && (subControls & SC_ScrollBarSlider)); const QS60StylePrivate::SkinElements handleElement = horizontal ? ( sliderPressed ? @@ -958,7 +958,7 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom const bool horizontal = optionSlider->orientation == Qt::Horizontal; //Highlight -/* if (optionSlider->state & QStyle::State_HasFocus) +/* if (optionSlider->state & State_HasFocus) drawPrimitive(PE_FrameFocusRect, optionSlider, painter, widget);*/ //Groove graphics @@ -1171,7 +1171,7 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom // Draw frame const QRect textRect = subControlRect(CC_GroupBox, option, SC_GroupBoxLabel, widget); const QRect checkBoxRect = subControlRect(CC_GroupBox, option, SC_GroupBoxCheckBox, widget); - if (groupBox->subControls & QStyle::SC_GroupBoxFrame) { + if (groupBox->subControls & SC_GroupBoxFrame) { QStyleOptionFrameV2 frame; frame.QStyleOption::operator=(*groupBox); frame.features = groupBox->features; @@ -1182,14 +1182,14 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom } // Draw title - if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) { + if ((groupBox->subControls & SC_GroupBoxLabel) && !groupBox->text.isEmpty()) { const QColor textColor = groupBox->textColor; painter->save(); if (textColor.isValid()) painter->setPen(textColor); int alignment = int(groupBox->textAlignment); - if (!styleHint(QStyle::SH_UnderlineShortcut, option, widget)) + if (!styleHint(SH_UnderlineShortcut, option, widget)) alignment |= Qt::TextHideMnemonic; drawItemText(painter, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | Qt::AlignVCenter | alignment, @@ -1258,13 +1258,13 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, break; case CE_PushButtonBevel: if (const QStyleOptionButton *button = qstyleoption_cast(option)) { - const bool isDisabled = !(option->state & QStyle::State_Enabled); + const bool isDisabled = !(option->state & State_Enabled); const bool isFlat = button->features & QStyleOptionButton::Flat; QS60StyleEnums::SkinParts skinPart; QS60StylePrivate::SkinElements skinElement; if (!isDisabled) { - const bool isPressed = (option->state & QStyle::State_Sunken) || - (option->state & QStyle::State_On); + const bool isPressed = (option->state & State_Sunken) || + (option->state & State_On); if (isFlat) { skinPart = isPressed ? QS60StyleEnums::SP_QsnFrButtonTbCenterPressed : QS60StyleEnums::SP_QsnFrButtonTbCenter; @@ -1289,7 +1289,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast(option)) { QStyleOptionToolButton optionToolButton = *toolBtn; - if (!optionToolButton.icon.isNull() && (optionToolButton.state & QStyle::State_Sunken) + if (!optionToolButton.icon.isNull() && (optionToolButton.state & State_Sunken) && (optionToolButton.state & State_Enabled)) { const QIcon::State state = optionToolButton.state & State_On ? QIcon::On : QIcon::Off; @@ -1348,8 +1348,8 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, painter->save(); painter->setClipRect(voptAdj.rect); - const bool isSelected = (vopt->state & QStyle::State_Selected); - const bool hasFocus = (vopt->state & QStyle::State_HasFocus); + const bool isSelected = (vopt->state & State_Selected); + const bool hasFocus = (vopt->state & State_HasFocus); bool isScrollBarVisible = false; int scrollBarWidth = 0; @@ -1423,8 +1423,8 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, } // draw the icon - const QIcon::Mode mode = (voptAdj.state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled; - const QIcon::State state = voptAdj.state & QStyle::State_Open ? QIcon::On : QIcon::Off; + const QIcon::Mode mode = (voptAdj.state & State_Enabled) ? QIcon::Normal : QIcon::Disabled; + const QIcon::State state = voptAdj.state & State_Open ? QIcon::On : QIcon::Off; voptAdj.icon.paint(painter, iconRect, voptAdj.decorationAlignment, mode, state); // Draw selection check mark. Show check mark only in multi selection modes. @@ -1436,29 +1436,29 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QStyleOptionViewItemV4 checkMarkOption(voptAdj); // Draw selection mark. - if (voptAdj.state & QStyle::State_Selected && !singleSelection) { + if (voptAdj.state & State_Selected && !singleSelection) { checkMarkOption.rect = selectionRect; - drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); + drawPrimitive(PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); if ( textRect.right() > selectionRect.left() ) textRect.setRight(selectionRect.left()); } else if (singleSelection && voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator && selectionRect.isValid()) { checkMarkOption.rect = selectionRect; - checkMarkOption.state = checkMarkOption.state & ~QStyle::State_HasFocus; + checkMarkOption.state = checkMarkOption.state & ~State_HasFocus; switch (vopt->checkState) { case Qt::Unchecked: - checkMarkOption.state |= QStyle::State_Off; + checkMarkOption.state |= State_Off; break; case Qt::PartiallyChecked: - checkMarkOption.state |= QStyle::State_NoChange; + checkMarkOption.state |= State_NoChange; break; case Qt::Checked: - checkMarkOption.state |= QStyle::State_On; + checkMarkOption.state |= State_On; break; } - drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); + drawPrimitive(PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget); } } @@ -1483,7 +1483,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, case CE_TabBarTabShape: if (const QStyleOptionTabV3 *optionTab = qstyleoption_cast(option)) { QStyleOptionTabV3 optionTabAdj = *optionTab; - const bool isSelected = optionTab->state & QStyle::State_Selected; + const bool isSelected = optionTab->state & State_Selected; const bool directionMirrored = (optionTab->direction == Qt::RightToLeft); QS60StylePrivate::SkinElements skinElement; switch (optionTab->shape) { @@ -1518,9 +1518,9 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, skinElement==QS60StylePrivate::SE_TabBarTabSouthActive|| skinElement==QS60StylePrivate::SE_TabBarTabWestActive) { const int borderThickness = - QS60StylePrivate::pixelMetric(QStyle::PM_DefaultFrameWidth); + QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); const int tabOverlap = - QS60StylePrivate::pixelMetric(QStyle::PM_TabBarTabOverlap) - borderThickness; + QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap) - borderThickness; //todo: draw navi wipe behind tabbar - must be drawn with first draw if (skinElement==QS60StylePrivate::SE_TabBarTabEastInactive|| @@ -1543,9 +1543,9 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QStyleOptionTabV3 optionTab = *tab; QRect tr = optionTab.rect; const bool directionMirrored = (optionTab.direction == Qt::RightToLeft); - const int borderThickness = QS60StylePrivate::pixelMetric(QStyle::PM_DefaultFrameWidth); + const int borderThickness = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); const int tabOverlap = - QS60StylePrivate::pixelMetric(QStyle::PM_TabBarTabOverlap) - borderThickness; + QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap) - borderThickness; const QRect windowRect = painter->window(); switch (tab->shape) { @@ -1599,12 +1599,12 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, m.rotate(newRotation); painter->setTransform(m, true); } - tr.adjust(0, 0, pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget), - pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget)); + tr.adjust(0, 0, pixelMetric(PM_TabBarTabShiftHorizontal, tab, widget), + pixelMetric(PM_TabBarTabShiftVertical, tab, widget)); if (selected) { - tr.setBottom(tr.bottom() - pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget)); - tr.setRight(tr.right() - pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget)); + tr.setBottom(tr.bottom() - pixelMetric(PM_TabBarTabShiftVertical, tab, widget)); + tr.setRight(tr.right() - pixelMetric(PM_TabBarTabShiftHorizontal, tab, widget)); } int alignment = Qt::AlignCenter | Qt::TextShowMnemonic; @@ -1714,9 +1714,9 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QRect textRect = subElementRect(SE_ItemViewItemText, &optionMenuItem, widget); //todo: move the vertical spacing stuff into subElementRect - const int vSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutVerticalSpacing); + const int vSpacing = QS60StylePrivate::pixelMetric(PM_LayoutVerticalSpacing); if (checkable){ - const int hSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing); + const int hSpacing = QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing); QStyleOptionMenuItem optionCheckBox; optionCheckBox.QStyleOptionMenuItem::operator=(*menuItem); optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth)); @@ -1754,7 +1754,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, QStyleOptionMenuItem arrowOptions; arrowOptions.QStyleOption::operator=(*menuItem); const int indicatorWidth = (pixelMetric(PM_ListViewIconSize, option, widget) >> 1) + - pixelMetric(QStyle::PM_LayoutVerticalSpacing, option, widget); + pixelMetric(PM_LayoutVerticalSpacing, option, widget); if (optionMenuItem.direction == Qt::LeftToRight) arrowOptions.rect.setLeft(textRect.right()); arrowOptions.rect.setWidth(indicatorWidth); @@ -2016,7 +2016,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti #endif // QT_NO_LINEEDIT case PE_IndicatorCheckBox: { // Draw checkbox indicator as color skinned graphics. - const QS60StyleEnums::SkinParts skinPart = (option->state & QStyle::State_On) ? + const QS60StyleEnums::SkinParts skinPart = (option->state & State_On) ? QS60StyleEnums::SP_QgnIndiCheckboxOn : QS60StyleEnums::SP_QgnIndiCheckboxOff; painter->save(); @@ -2041,7 +2041,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti if (checkBoxVisible && singleSelection) { drawPrimitive(PE_IndicatorCheckBox, option, painter, widget); // ... or normal "tick" selection at the end. - } else if (option->state & QStyle::State_Selected) { + } else if (option->state & State_Selected) { QRect tickRect = option->rect; const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth); // adjust tickmark rect to exclude frame border @@ -2076,7 +2076,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti painter->setPen(themeColor); // Draw radiobutton indicator as color skinned graphics. - QS60StyleEnums::SkinParts skinPart = (option->state & QStyle::State_On) ? + QS60StyleEnums::SkinParts skinPart = (option->state & State_On) ? QS60StyleEnums::SP_QgnIndiRadiobuttOn : QS60StyleEnums::SP_QgnIndiRadiobuttOff; QS60StylePrivate::drawSkinPart(skinPart, painter, buttonRect, (flags | QS60StylePrivate::SF_ColorSkinned)); @@ -2088,7 +2088,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti case PE_PanelButtonBevel: case PE_FrameButtonBevel: if (QS60StylePrivate::canDrawThemeBackground(option->palette.base())) { - const bool isPressed = option->state & QStyle::State_Sunken; + const bool isPressed = option->state & State_Sunken; const QS60StylePrivate::SkinElements skinElement = isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal; QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags); @@ -2290,8 +2290,8 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti //QPalette::Base has been changed, let commonstyle draw the item commonStyleDraws = true; } else { - QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled; - if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active)) + QPalette::ColorGroup cg = vopt->state & State_Enabled ? QPalette::Normal : QPalette::Disabled; + if (cg == QPalette::Normal && !(vopt->state & State_Active)) cg = QPalette::Inactive; if (vopt->features & QStyleOptionViewItemV2::Alternate) painter->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::AlternateBase)); @@ -2396,7 +2396,7 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, if (QS60StylePrivate::isTouchSupported()) //Make itemview easier to use in touch devices //QCommonStyle does not adjust height with horizontal margin, it only adjusts width - sz.setHeight(sz.height() + 2 * pixelMetric(QStyle::PM_FocusFrameVMargin)); + sz.setHeight(sz.height() + 2 * pixelMetric(PM_FocusFrameVMargin)); break; default: sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); @@ -2548,7 +2548,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast(option)) { const int frameThickness = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; const int buttonMargin = spinbox->frame ? 2 : 0; - const int buttonWidth = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize) + 2 * buttonMargin; + const int buttonWidth = QS60StylePrivate::pixelMetric(PM_ButtonIconSize) + 2 * buttonMargin; QSize buttonSize; buttonSize.setHeight(qMax(8, spinbox->rect.height() - frameThickness)); //width should at least be equal to height @@ -2597,7 +2597,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple ret = cmb->rect; const int width = cmb->rect.width(); const int height = cmb->rect.height(); - const int buttonIconSize = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize); + const int buttonIconSize = QS60StylePrivate::pixelMetric(PM_ButtonIconSize); const int buttonMargin = cmb->frame ? 2 : 0; // lets use spinbox frame here as well, as no combobox specific value available. const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0; @@ -2635,7 +2635,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple case SC_GroupBoxLabel: { //slightly indent text and boxes, so that dialog border does not mess with them. const int horizontalSpacing = - QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing); + QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing); ret.adjust(2, horizontalSpacing - 3, 0, 0); } break; @@ -2711,9 +2711,9 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con if (const QStyleOptionTabWidgetFrame *twf = qstyleoption_cast(opt)) { const int tabOverlapNoBorder = - QS60StylePrivate::pixelMetric(QStyle::PM_TabBarTabOverlap); + QS60StylePrivate::pixelMetric(PM_TabBarTabOverlap); const int tabOverlap = - tabOverlapNoBorder-QS60StylePrivate::pixelMetric(QStyle::PM_DefaultFrameWidth); + tabOverlapNoBorder-QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth); const QTabWidget *tab = qobject_cast(widget); int gain = (tab) ? tabOverlap * tab->count() : 0; switch (twf->shape) { @@ -2762,8 +2762,8 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con multiSelection && (vopt->features & QStyleOptionViewItemV2::HasCheckIndicator)) { const int verticalSpacing = - QS60StylePrivate::pixelMetric(QStyle::PM_LayoutVerticalSpacing); - //const int horizontalSpacing = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing); + QS60StylePrivate::pixelMetric(PM_LayoutVerticalSpacing); + //const int horizontalSpacing = QS60StylePrivate::pixelMetric(PM_LayoutHorizontalSpacing); const int checkBoxRectWidth = subElementRect(SE_ItemViewItemCheckIndicator, opt, widget).width(); ret.adjust(-checkBoxRectWidth - verticalSpacing, 0, -checkBoxRectWidth - verticalSpacing, 0); } @@ -2809,9 +2809,9 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con singleSelection; // Selection check mark rect. - const int indicatorWidth = QS60StylePrivate::pixelMetric(QStyle::PM_IndicatorWidth); - const int indicatorHeight = QS60StylePrivate::pixelMetric(QStyle::PM_IndicatorHeight); - const int spacing = QS60StylePrivate::pixelMetric(QStyle::PM_CheckBoxLabelSpacing); + const int indicatorWidth = QS60StylePrivate::pixelMetric(PM_IndicatorWidth); + const int indicatorHeight = QS60StylePrivate::pixelMetric(PM_IndicatorHeight); + const int spacing = QS60StylePrivate::pixelMetric(PM_CheckBoxLabelSpacing); const int itemHeight = opt->rect.height(); int heightOffset = 0; @@ -3031,7 +3031,7 @@ bool QS60Style::event(QEvent *e) QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const { - const int iconDimension = QS60StylePrivate::pixelMetric(QStyle::PM_ToolBarIconSize); + const int iconDimension = QS60StylePrivate::pixelMetric(PM_ToolBarIconSize); const QRect iconSize = (!option) ? QRect(0, 0, iconDimension, iconDimension) : option->rect; QS60StyleEnums::SkinParts part; QS60StylePrivate::SkinElementFlags adjustedFlags; @@ -3041,67 +3041,67 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon, QS60StylePrivate::SF_StateDisabled; switch(standardIcon) { - case QStyle::SP_MessageBoxWarning: + case SP_MessageBoxWarning: part = QS60StyleEnums::SP_QgnNoteWarning; break; - case QStyle::SP_MessageBoxInformation: + case SP_MessageBoxInformation: part = QS60StyleEnums::SP_QgnNoteInfo; break; - case QStyle::SP_MessageBoxCritical: + case SP_MessageBoxCritical: part = QS60StyleEnums::SP_QgnNoteError; break; - case QStyle::SP_MessageBoxQuestion: + case SP_MessageBoxQuestion: part = QS60StyleEnums::SP_QgnNoteQuery; break; - case QStyle::SP_ArrowRight: + case SP_ArrowRight: part = QS60StyleEnums::SP_QgnIndiNaviArrowRight; break; - case QStyle::SP_ArrowLeft: + case SP_ArrowLeft: part = QS60StyleEnums::SP_QgnIndiNaviArrowLeft; break; - case QStyle::SP_ArrowUp: + case SP_ArrowUp: part = QS60StyleEnums::SP_QgnIndiNaviArrowLeft; adjustedFlags |= QS60StylePrivate::SF_PointEast; break; - case QStyle::SP_ArrowDown: + case SP_ArrowDown: part = QS60StyleEnums::SP_QgnIndiNaviArrowLeft; adjustedFlags |= QS60StylePrivate::SF_PointWest; break; - case QStyle::SP_ArrowBack: + case SP_ArrowBack: if (QApplication::layoutDirection() == Qt::RightToLeft) return QS60Style::standardIcon(SP_ArrowRight, option, widget); return QS60Style::standardIcon(SP_ArrowLeft, option, widget); - case QStyle::SP_ArrowForward: + case SP_ArrowForward: if (QApplication::layoutDirection() == Qt::RightToLeft) return QS60Style::standardIcon(SP_ArrowLeft, option, widget); return QS60Style::standardIcon(SP_ArrowRight, option, widget); - case QStyle::SP_ComputerIcon: + case SP_ComputerIcon: part = QS60StyleEnums::SP_QgnPropPhoneMemcLarge; break; - case QStyle::SP_DirClosedIcon: + case SP_DirClosedIcon: part = QS60StyleEnums::SP_QgnPropFolderSmall; break; - case QStyle::SP_DirOpenIcon: + case SP_DirOpenIcon: part = QS60StyleEnums::SP_QgnPropFolderCurrent; break; - case QStyle::SP_DirIcon: + case SP_DirIcon: part = QS60StyleEnums::SP_QgnPropFolderSmall; break; - case QStyle::SP_FileDialogNewFolder: + case SP_FileDialogNewFolder: part = QS60StyleEnums::SP_QgnPropFolderSmallNew; break; - case QStyle::SP_FileIcon: + case SP_FileIcon: part = QS60StyleEnums::SP_QgnPropFileSmall; break; - case QStyle::SP_TrashIcon: + case SP_TrashIcon: part = QS60StyleEnums::SP_QgnNoteErased; break; - case QStyle::SP_ToolBarHorizontalExtensionButton: + case SP_ToolBarHorizontalExtensionButton: part = QS60StyleEnums::SP_QgnIndiSubMenu; if (QApplication::layoutDirection() == Qt::RightToLeft) adjustedFlags |= QS60StylePrivate::SF_PointSouth; break; - case QStyle::SP_ToolBarVerticalExtensionButton: + case SP_ToolBarVerticalExtensionButton: adjustedFlags |= QS60StylePrivate::SF_PointEast; part = QS60StyleEnums::SP_QgnIndiSubMenu; break; -- cgit v0.12 From 206fffb5927bae05a8d8b81c810c33a1c7a70a69 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 25 Jan 2010 12:56:15 +0100 Subject: 'test -e' is a bashism. It's not available in traditional sh. Task-number: QTBUG-7549 Reviewed-By: Markus Goetz --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 4a94f93..dc23392 100755 --- a/configure +++ b/configure @@ -115,7 +115,7 @@ getQMakeConf1() inc_file=`echo "$line" | sed -n -e "/^include.*(.*)/s/include.*(\(.*\)).*$/\1/p"` current_dir=`dirname "$1"` conf_file="$current_dir/$inc_file" - if [ ! -e "$conf_file" ]; then + if [ ! -f "$conf_file" ]; then echo "WARNING: Unable to find file $conf_file" >&2 continue fi @@ -2278,7 +2278,7 @@ if [ "$OPT_SHADOW" = "yes" ]; then fi # symlink fonts to be able to run application from build directory -if [ "$PLATFORM_QWS" = "yes" ] && [ ! -e "${outpath}/lib/fonts" ]; then +if [ "$PLATFORM_QWS" = "yes" ] && [ ! -d "${outpath}/lib/fonts" ]; then if [ "$PLATFORM" = "$XPLATFORM" ]; then mkdir -p "${outpath}/lib" ln -s "${relpath}/lib/fonts" "${outpath}/lib/fonts" -- cgit v0.12 From efce7393cb8c6d7df52539dd7b7ac616cf46036c Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 25 Jan 2010 14:55:28 +0100 Subject: Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit/qtwebkit-4.6 ( 0bc66e2d86149e0fb6a33428e4f23ebfe83bfde4 ) Changes in WebKit/qt since the last update: ++ b/WebKit/qt/ChangeLog 2010-01-25 Janne Koskinen Reviewed by Simon Hausmann. [Qt] Phone backup support for QtWebkit for Symbian devices. https://bugs.webkit.org/show_bug.cgi?id=34077 * symbian/backup_registration.xml: Added. --- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 21 +++++++++++++++++++++ src/3rdparty/webkit/WebCore/WebCore.pro | 17 +++++++---------- .../webkit/WebCore/platform/qt/PopupMenuQt.cpp | 4 ++-- src/3rdparty/webkit/WebKit/qt/ChangeLog | 9 +++++++++ .../WebKit/qt/symbian/backup_registration.xml | 5 +++++ 6 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 src/3rdparty/webkit/WebKit/qt/symbian/backup_registration.xml diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 6fe71d6..a055668 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - 8f5ca3ba5da63a47d4f90bbd867d3e8453443dd3 + 0bc66e2d86149e0fb6a33428e4f23ebfe83bfde4 diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 8e1c965..fd5606b 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,24 @@ +2010-01-25 Janne Koskinen + + Reviewed by Simon Hausmann. + + [Qt] Phone backup support for QtWebkit for Symbian devices. + https://bugs.webkit.org/show_bug.cgi?id=34077 + + * WebCore.pro: + +2010-01-21 Thiago Macieira + + Reviewed by Simon Hausmann. + + [Qt] Fix incorrect dependency to QtXmlPatterns in generated include/QtWebKit/QtWebKit header + + The generated file includes QtXmlPatterns/QtXmlPatterns, which is neither used/required by + the public QtWebKit API nor will it be available if Qt is configured with -no-xmlpatterns. + + * WebCore.pro: Trick syncqt to believe that xmlpatterns is not a dependency, so that it's not + included in the generated file. It'll still be used and linked to with this trick. + 2010-01-17 Srinidhi Shreedhara Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index 04aba62..bf4d6f9 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -18,7 +18,10 @@ symbian: { " " webkitlibs.pkg_prerules = vendorinfo - DEPLOYMENT += webkitlibs + webkitbackup.sources = ../WebKit/qt/symbian/backup_registration.xml + webkitbackup.path = /private/10202D56/import/packages/$$replace(TARGET.UID3, 0x,) + + DEPLOYMENT += webkitlibs webkitbackup TARGET.UID3 = 0x200267C2 # RO text (code) section in qtwebkit.dll exceeds allocated space for gcce udeb target. @@ -2780,7 +2783,7 @@ unix:!mac:CONFIG += link_pkgconfig contains(DEFINES, ENABLE_XSLT=1) { FEATURE_DEFINES_JAVASCRIPT += ENABLE_XSLT=1 - QT += xmlpatterns + tobe|!tobe: QT += xmlpatterns SOURCES += \ bindings/js/JSXSLTProcessorConstructor.cpp \ @@ -3415,14 +3418,8 @@ CONFIG(QTDIR_build):isEqual(QT_MAJOR_VERSION, 4):greaterThan(QT_MINOR_VERSION, 4 symbian { shared { - contains(MMP_RULES, defBlock) { - MMP_RULES -= defBlock - - MMP_RULES += "$${LITERAL_HASH}ifdef WINSCW" \ - "DEFFILE ../WebKit/qt/symbian/bwins/$${TARGET}.def" \ - "$${LITERAL_HASH}elif defined EABI" \ - "DEFFILE ../WebKit/qt/symbian/eabi/$${TARGET}.def" \ - "$${LITERAL_HASH}endif" + contains(CONFIG, def_files) { + defFilePath=../WebKit/qt/symbian } } } diff --git a/src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp b/src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp index 989b34c..1bd5976 100644 --- a/src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -100,9 +101,8 @@ void PopupMenu::show(const IntRect& r, FrameView* v, int index) if (QGraphicsView* view = qobject_cast(client->ownerWidget())) { if (!m_proxy) { - m_proxy = new QGraphicsProxyWidget; + m_proxy = new QGraphicsProxyWidget(qobject_cast(client->pluginParent())); m_proxy->setWidget(m_popup); - view->scene()->addItem(m_proxy); } else m_proxy->setVisible(true); m_proxy->setGeometry(rect); diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index ee555f3..09acd47 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,12 @@ +2010-01-25 Janne Koskinen + + Reviewed by Simon Hausmann. + + [Qt] Phone backup support for QtWebkit for Symbian devices. + https://bugs.webkit.org/show_bug.cgi?id=34077 + + * symbian/backup_registration.xml: Added. + 2009-11-19 Jocelyn Turcotte Reviewed by Kenneth Rohde Christiansen. diff --git a/src/3rdparty/webkit/WebKit/qt/symbian/backup_registration.xml b/src/3rdparty/webkit/WebKit/qt/symbian/backup_registration.xml new file mode 100644 index 0000000..e026140 --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/symbian/backup_registration.xml @@ -0,0 +1,5 @@ + + + + + -- cgit v0.12 From 9bb9991b7c6182249cbf922e4718e1c64e3c6433 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Mon, 25 Jan 2010 15:58:56 +0200 Subject: QListWidget itemActivated does not follow S60 conventions Set StyleHint SH_ItemView_ActivateItemOnSingleClick inactive for 3.x and 5th edition S60. Task-number: QTBUG-6182 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 2 +- src/gui/styles/qs60style_p.h | 1 + src/gui/styles/qs60style_s60.cpp | 5 +++++ src/gui/styles/qs60style_simulated.cpp | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 9dcf291..5a4e6df 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2436,7 +2436,7 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w retValue = QPalette::Base; break; case SH_ItemView_ActivateItemOnSingleClick: - retValue = true; + retValue = QS60StylePrivate::isSingleClickUi(); break; case SH_ProgressDialog_TextLabelAlignment: retValue = (QApplication::layoutDirection() == Qt::LeftToRight) ? diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 2d2f2e1..2cd238f 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -499,6 +499,7 @@ public: static bool isTouchSupported(); static bool isToolBarBackground(); static bool hasSliderGrooveGraphic(); + static bool isSingleClickUi(); // calculates average color based on button skin graphics (minus borders). QColor colorFromFrameGraphics(SkinFrameElements frame) const; diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 5f3a499..a3bb169 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -649,6 +649,11 @@ bool QS60StylePrivate::hasSliderGrooveGraphic() return QSysInfo::s60Version() != QSysInfo::SV_S60_3_1; } +bool QS60StylePrivate::isSingleClickUi() +{ + return (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0); +} + QPoint qt_s60_fill_background_offset(const QWidget *targetWidget) { CCoeControl *control = targetWidget->effectiveWinId(); diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp index 557243c..f87cf28 100644 --- a/src/gui/styles/qs60style_simulated.cpp +++ b/src/gui/styles/qs60style_simulated.cpp @@ -342,6 +342,11 @@ bool QS60StylePrivate::hasSliderGrooveGraphic() return false; } +bool QS60StylePrivate::isSingleClickUi() +{ + return false; +} + QFont QS60StylePrivate::s60Font_specific( QS60StyleEnums::FontCategories fontCategory, int pointSize, bool resolveFontSize) -- cgit v0.12 From df4d9f46e370a35c3178d95cae2a873e8a23ddb5 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 25 Jan 2010 15:07:14 +0100 Subject: Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit/qtwebkit-4.6 ( a54fd11a3abcd6d9c858e8162e85fd1f3aa21db1 ) Changes in WebKit/qt since the last update: Fix from Girish --- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index a055668..221c020 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - 0bc66e2d86149e0fb6a33428e4f23ebfe83bfde4 + a54fd11a3abcd6d9c858e8162e85fd1f3aa21db1 diff --git a/src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp b/src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp index 1bd5976..714cac9 100644 --- a/src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/qt/PopupMenuQt.cpp @@ -58,8 +58,10 @@ PopupMenu::PopupMenu(PopupMenuClient* client) PopupMenu::~PopupMenu() { - delete m_popup; - delete m_proxy; + // If we create a proxy, then the deletion of the proxy and the + // combo will be done by the proxy's parent (QGraphicsWebView) + if (!m_proxy) + delete m_popup; } void PopupMenu::clear() -- cgit v0.12 From f405a89621b4bfe957d7e0e4d321a9ea0931d34b Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 25 Jan 2010 14:56:27 +0100 Subject: Cocoa: Usage of QMacCocoaAutoReleasePool makes CPU peak The reason was that QMacCocoaAutoReleasePool included a a call to NSApplicationLoad(). This call should only be made for carbon based application anyway, so we just ifdef it out (event how clumsy the placing of the call is). The CPU problem came because after the call, [NSApp isRunning] would return true, an as such, confuse the event dispatcher later on. Reviewed-by: MortenS --- src/gui/kernel/qt_cocoa_helpers_mac.mm | 13 +++++++++++++ src/gui/util/qsystemtrayicon_mac.mm | 13 ------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index e36ab9b..e85a716 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -1278,4 +1278,17 @@ void qt_cocoaChangeOverrideCursor(const QCursor &cursor) } #endif +QMacCocoaAutoReleasePool::QMacCocoaAutoReleasePool() +{ +#ifndef QT_MAC_USE_COCOA + NSApplicationLoad(); +#endif + pool = (void*)[[NSAutoreleasePool alloc] init]; +} + +QMacCocoaAutoReleasePool::~QMacCocoaAutoReleasePool() +{ + [(NSAutoreleasePool*)pool release]; +} + QT_END_NAMESPACE diff --git a/src/gui/util/qsystemtrayicon_mac.mm b/src/gui/util/qsystemtrayicon_mac.mm index ae805f6..0265a83 100644 --- a/src/gui/util/qsystemtrayicon_mac.mm +++ b/src/gui/util/qsystemtrayicon_mac.mm @@ -569,16 +569,3 @@ private: } @end - -/* Done here because this is the only .mm for now! -Sam */ -QMacCocoaAutoReleasePool::QMacCocoaAutoReleasePool() -{ - NSApplicationLoad(); - pool = (void*)[[NSAutoreleasePool alloc] init]; -} - -QMacCocoaAutoReleasePool::~QMacCocoaAutoReleasePool() -{ - [(NSAutoreleasePool*)pool release]; -} - -- cgit v0.12 From 8cdab74082019c0b8a57883a11aa5093a644abdd Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 25 Jan 2010 15:22:11 +0100 Subject: Qt/Cocoa Event Dispatcher Problem in modal dialogs The problem is that we didn't check if the event dispatcher was interrupted before starting to wait for more events. This patch will do the interrupt test after processing modal session events, and just before starting to wait. This will fix applications that expects e.g an event loop to exit immidiatly upon a signal from a timer (without the need for the user to generate e.g. a mouse event to stop the wait). Task-number: QTBUG-7503 Reviewed-by: cduclos --- src/gui/kernel/qeventdispatcher_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm index eda75db..c7c7caf 100644 --- a/src/gui/kernel/qeventdispatcher_mac.mm +++ b/src/gui/kernel/qeventdispatcher_mac.mm @@ -569,7 +569,7 @@ bool QEventDispatcherMac::processEvents(QEventLoop::ProcessEventsFlags flags) // in cocoa. [NSApp run] should be called at least once for any cocoa app. if (NSModalSession session = d->currentModalSession()) { QBoolBlocker execGuard(d->currentExecIsNSAppRun, false); - while (!d->interrupt && [NSApp runModalSession:session] == NSRunContinuesResponse) + while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt) qt_mac_waitForMoreModalSessionEvents(); if (!d->interrupt && session == d->currentModalSessionCached) { // INVARIANT: Someone called e.g. [NSApp stopModal:] from outside the event -- cgit v0.12 From ef89c6a9f39924a3c8366ad9522b42e7b1915b01 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 25 Jan 2010 14:18:03 +0100 Subject: QNativeSocketEngine: Also handle unknown errors from socket engine Task-number: QTBUG-7316 Task-number: QTBUG-7317 Reviewed-by: thiago --- src/network/socket/qnativesocketengine.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index 6e1df93..9e7bb27 100644 --- a/src/network/socket/qnativesocketengine.cpp +++ b/src/network/socket/qnativesocketengine.cpp @@ -778,6 +778,11 @@ qint64 QNativeSocketEngine::read(char *data, qint64 maxSize) QNativeSocketEnginePrivate::RemoteHostClosedErrorString); close(); return -1; + } else if (readBytes == -1) { + d->setError(QAbstractSocket::NetworkError, + QNativeSocketEnginePrivate::ReadErrorString); + close(); + return -1; } return readBytes; } -- cgit v0.12 From 2109c57ef1fe2d8bbea2ed53c0f76c036843352d Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 25 Jan 2010 15:12:51 +0100 Subject: QNativeSocketEngine: Set OS error strings on failed read() Reviewed-by: thiago --- src/network/socket/qnativesocketengine.cpp | 7 +++++-- src/network/socket/qnativesocketengine_unix.cpp | 2 +- src/network/socket/qnativesocketengine_win.cpp | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index 9e7bb27..a890b3b 100644 --- a/src/network/socket/qnativesocketengine.cpp +++ b/src/network/socket/qnativesocketengine.cpp @@ -779,8 +779,11 @@ qint64 QNativeSocketEngine::read(char *data, qint64 maxSize) close(); return -1; } else if (readBytes == -1) { - d->setError(QAbstractSocket::NetworkError, - QNativeSocketEnginePrivate::ReadErrorString); + if (!d->hasSetSocketError) { + d->hasSetSocketError = true; + d->socketError = QAbstractSocket::NetworkError; + d->socketErrorString = qt_error_string(); + } close(); return -1; } diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index d3b0fe5..9a2c349 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -903,7 +903,7 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxSize) case EBADF: case EINVAL: case EIO: - setError(QAbstractSocket::NetworkError, ReadErrorString); + //error string is now set in read(), not here in nativeRead() break; #ifdef Q_OS_SYMBIAN case EPIPE: diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index bbe9fde..8177b4f 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -1068,7 +1068,7 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxLength) break; case WSAEBADF: case WSAEINVAL: - setError(QAbstractSocket::NetworkError, ReadErrorString); + //error string is now set in read(), not here in nativeRead() break; case WSAECONNRESET: case WSAECONNABORTED: -- cgit v0.12 From 8ef52111099e1a588d872305d07f0f9e514fe2e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Mon, 25 Jan 2010 17:30:26 +0100 Subject: Updated docs regarding QGLWidget::renderText() limitations. Reviewed-by: Trust Me --- src/opengl/qgl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 3f32cf3..48e43b2 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4393,6 +4393,13 @@ static void qt_gl_draw_text(QPainter *p, int x, int y, const QString &str, \note This function temporarily disables depth-testing when the text is drawn. + \note This function can only be used inside a + QPainter::beginNativePainting()/QPainter::endNativePainting() block + if the default OpenGL paint engine is QPaintEngine::OpenGL. To make + QPaintEngine::OpenGL the default GL engine, call + QGL::setPreferredPaintEngine(QPaintEngine::OpenGL) before the + QApplication constructor. + \l{Overpainting Example}{Overpaint} with QPainter::drawText() instead. */ -- cgit v0.12 From 0c822ea63a8b2b0c32c68a49de81e0c02548f059 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 09:54:09 +0100 Subject: Don't use QDebug references. Instead, pass by value. If you use refs, then you can't use this operator as the first argument, since qDebug() returns QDebug by-value (an rvalue temporary). That cannot be bound to a non-const ref. Task-number: QTBUG-7593 --- examples/tools/customtype/message.cpp | 2 +- examples/tools/customtype/message.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tools/customtype/message.cpp b/examples/tools/customtype/message.cpp index 4ef041a..d27159e 100644 --- a/examples/tools/customtype/message.cpp +++ b/examples/tools/customtype/message.cpp @@ -64,7 +64,7 @@ Message::Message(const QString &body, const QStringList &headers) } //! [custom type streaming operator] -QDebug &operator<<(QDebug &dbg, const Message &message) +QDebug operator<<(QDebug dbg, const Message &message) { QStringList pieces = message.body().split("\r\n", QString::SkipEmptyParts); if (pieces.isEmpty()) diff --git a/examples/tools/customtype/message.h b/examples/tools/customtype/message.h index 361f803..4ef48d4 100644 --- a/examples/tools/customtype/message.h +++ b/examples/tools/customtype/message.h @@ -70,7 +70,7 @@ Q_DECLARE_METATYPE(Message); //! [custom type meta-type declaration] //! [custom type streaming operator] -QDebug &operator<<(QDebug &dbg, const Message &message); +QDebug operator<<(QDebug dbg, const Message &message); //! [custom type streaming operator] #endif -- cgit v0.12 From f92e9c32160ca32b93173dafad2734963528446d Mon Sep 17 00:00:00 2001 From: Carlos Manuel Duclos Vergara Date: Mon, 25 Jan 2010 16:10:21 +0100 Subject: Drawing fake buttons using QMacStyle+QStyleOptionViewItemV4 lead to crash. The problem here is the fact that we "trusted" the user when the widget type was specified. The fix consists in checking the result of the conversions, if the conversion was successful (i.e. the widget was of the type specified by the user) then we proceed as usual. If the conversion was not successful (i.e. wrong widget type) then we ask the style for a sensible size. I modified this for QPushButton, QSlider and QToolButton. Task-number: qtbug-7522 Reviewed-by: jbache --- src/gui/styles/qmacstyle_mac.mm | 176 ++++++++++++++++++++++++---------------- 1 file changed, 104 insertions(+), 72 deletions(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 97d69b2..f4af579 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -667,32 +667,47 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg switch (ct) { case QStyle::CT_PushButton: { - const QPushButton *psh = static_cast(widg); - QString buttonText = qt_mac_removeMnemonics(psh->text()); - if (buttonText.contains(QLatin1Char('\n'))) - ret = QSize(-1, -1); - else if (sz == QAquaSizeLarge) - ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricPushButtonHeight)); - else if (sz == QAquaSizeSmall) - ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricSmallPushButtonHeight)); - else if (sz == QAquaSizeMini) - ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricMiniPushButtonHeight)); - - if (!psh->icon().isNull()){ - // If the button got an icon, and the icon is larger than the - // button, we can't decide on a default size - ret.setWidth(-1); - if (ret.height() < psh->iconSize().height()) - ret.setHeight(-1); - } - else if (buttonText == QLatin1String("OK") || buttonText == QLatin1String("Cancel")){ - // Aqua Style guidelines restrict the size of OK and Cancel buttons to 68 pixels. - // However, this doesn't work for German, therefore only do it for English, - // I suppose it would be better to do some sort of lookups for languages - // that like to have really long words. - ret.setWidth(77 - 8); - } - + const QPushButton *psh = qobject_cast(widg); + // If this comparison is false, then the widget was not a push button. + // This is bad and there's very little we can do since we were requested to find a + // sensible size for a widget that pretends to be a QPushButton but is not. + if(psh) { + QString buttonText = qt_mac_removeMnemonics(psh->text()); + if (buttonText.contains(QLatin1Char('\n'))) + ret = QSize(-1, -1); + else if (sz == QAquaSizeLarge) + ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricPushButtonHeight)); + else if (sz == QAquaSizeSmall) + ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricSmallPushButtonHeight)); + else if (sz == QAquaSizeMini) + ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricMiniPushButtonHeight)); + + if (!psh->icon().isNull()){ + // If the button got an icon, and the icon is larger than the + // button, we can't decide on a default size + ret.setWidth(-1); + if (ret.height() < psh->iconSize().height()) + ret.setHeight(-1); + } + else if (buttonText == QLatin1String("OK") || buttonText == QLatin1String("Cancel")){ + // Aqua Style guidelines restrict the size of OK and Cancel buttons to 68 pixels. + // However, this doesn't work for German, therefore only do it for English, + // I suppose it would be better to do some sort of lookups for languages + // that like to have really long words. + ret.setWidth(77 - 8); + } + } else { + // The only sensible thing to do is to return whatever the style suggests... + if (sz == QAquaSizeLarge) + ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricPushButtonHeight)); + else if (sz == QAquaSizeSmall) + ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricSmallPushButtonHeight)); + else if (sz == QAquaSizeMini) + ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricMiniPushButtonHeight)); + else + // Since there's no default size we return the large size... + ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricPushButtonHeight)); + } #if 0 //Not sure we are applying the rules correctly for RadioButtons/CheckBoxes --Sam } else if (ct == QStyle::CT_RadioButton) { QRadioButton *rdo = static_cast(widg); @@ -749,23 +764,30 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg if (sz == QAquaSizeSmall) { int width = 0, height = 0; if (szHint == QSize(-1, -1)) { //just 'guess'.. - const QToolButton *bt = static_cast(widg); - if (!bt->icon().isNull()) { - QSize iconSize = bt->iconSize(); - QSize pmSize = bt->icon().actualSize(QSize(32, 32), QIcon::Normal); - width = qMax(width, qMax(iconSize.width(), pmSize.width())); - height = qMax(height, qMax(iconSize.height(), pmSize.height())); - } - if (!bt->text().isNull() && bt->toolButtonStyle() != Qt::ToolButtonIconOnly) { - int text_width = bt->fontMetrics().width(bt->text()), - text_height = bt->fontMetrics().height(); - if (bt->toolButtonStyle() == Qt::ToolButtonTextUnderIcon) { - width = qMax(width, text_width); - height += text_height; - } else { - width += text_width; - width = qMax(height, text_height); + const QToolButton *bt = qobject_cast(widg); + // If this conversion fails then the widget was not what it claimed to be. + if(bt) { + if (!bt->icon().isNull()) { + QSize iconSize = bt->iconSize(); + QSize pmSize = bt->icon().actualSize(QSize(32, 32), QIcon::Normal); + width = qMax(width, qMax(iconSize.width(), pmSize.width())); + height = qMax(height, qMax(iconSize.height(), pmSize.height())); + } + if (!bt->text().isNull() && bt->toolButtonStyle() != Qt::ToolButtonIconOnly) { + int text_width = bt->fontMetrics().width(bt->text()), + text_height = bt->fontMetrics().height(); + if (bt->toolButtonStyle() == Qt::ToolButtonTextUnderIcon) { + width = qMax(width, text_width); + height += text_height; + } else { + width += text_width; + width = qMax(height, text_height); + } } + } else { + // Let's return the size hint... + width = szHint.width(); + height = szHint.height(); } } else { width = szHint.width(); @@ -778,37 +800,47 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg break; case QStyle::CT_Slider: { int w = -1; - const QSlider *sld = static_cast(widg); - if (sz == QAquaSizeLarge) { - if (sld->orientation() == Qt::Horizontal) { - w = qt_mac_aqua_get_metric(kThemeMetricHSliderHeight); - if (sld->tickPosition() != QSlider::NoTicks) - w += qt_mac_aqua_get_metric(kThemeMetricHSliderTickHeight); - } else { - w = qt_mac_aqua_get_metric(kThemeMetricVSliderWidth); - if (sld->tickPosition() != QSlider::NoTicks) - w += qt_mac_aqua_get_metric(kThemeMetricVSliderTickWidth); - } - } else if (sz == QAquaSizeSmall) { - if (sld->orientation() == Qt::Horizontal) { - w = qt_mac_aqua_get_metric(kThemeMetricSmallHSliderHeight); - if (sld->tickPosition() != QSlider::NoTicks) - w += qt_mac_aqua_get_metric(kThemeMetricSmallHSliderTickHeight); - } else { - w = qt_mac_aqua_get_metric(kThemeMetricSmallVSliderWidth); - if (sld->tickPosition() != QSlider::NoTicks) - w += qt_mac_aqua_get_metric(kThemeMetricSmallVSliderTickWidth); - } - } else if (sz == QAquaSizeMini) { - if (sld->orientation() == Qt::Horizontal) { - w = qt_mac_aqua_get_metric(kThemeMetricMiniHSliderHeight); - if (sld->tickPosition() != QSlider::NoTicks) - w += qt_mac_aqua_get_metric(kThemeMetricMiniHSliderTickHeight); - } else { - w = qt_mac_aqua_get_metric(kThemeMetricMiniVSliderWidth); - if (sld->tickPosition() != QSlider::NoTicks) - w += qt_mac_aqua_get_metric(kThemeMetricMiniVSliderTickWidth); + const QSlider *sld = qobject_cast(widg); + // If this conversion fails then the widget was not what it claimed to be. + if(sld) { + if (sz == QAquaSizeLarge) { + if (sld->orientation() == Qt::Horizontal) { + w = qt_mac_aqua_get_metric(kThemeMetricHSliderHeight); + if (sld->tickPosition() != QSlider::NoTicks) + w += qt_mac_aqua_get_metric(kThemeMetricHSliderTickHeight); + } else { + w = qt_mac_aqua_get_metric(kThemeMetricVSliderWidth); + if (sld->tickPosition() != QSlider::NoTicks) + w += qt_mac_aqua_get_metric(kThemeMetricVSliderTickWidth); + } + } else if (sz == QAquaSizeSmall) { + if (sld->orientation() == Qt::Horizontal) { + w = qt_mac_aqua_get_metric(kThemeMetricSmallHSliderHeight); + if (sld->tickPosition() != QSlider::NoTicks) + w += qt_mac_aqua_get_metric(kThemeMetricSmallHSliderTickHeight); + } else { + w = qt_mac_aqua_get_metric(kThemeMetricSmallVSliderWidth); + if (sld->tickPosition() != QSlider::NoTicks) + w += qt_mac_aqua_get_metric(kThemeMetricSmallVSliderTickWidth); + } + } else if (sz == QAquaSizeMini) { + if (sld->orientation() == Qt::Horizontal) { + w = qt_mac_aqua_get_metric(kThemeMetricMiniHSliderHeight); + if (sld->tickPosition() != QSlider::NoTicks) + w += qt_mac_aqua_get_metric(kThemeMetricMiniHSliderTickHeight); + } else { + w = qt_mac_aqua_get_metric(kThemeMetricMiniVSliderWidth); + if (sld->tickPosition() != QSlider::NoTicks) + w += qt_mac_aqua_get_metric(kThemeMetricMiniVSliderTickWidth); + } } + } else { + // This is tricky, we were requested to find a size for a slider which is not + // a slider. We don't know if this is vertical or horizontal or if we need to + // have tick marks or not. + // For this case we will return an horizontal slider without tick marks. + w = qt_mac_aqua_get_metric(kThemeMetricHSliderHeight); + w += qt_mac_aqua_get_metric(kThemeMetricHSliderTickHeight); } if (sld->orientation() == Qt::Horizontal) ret.setHeight(w); -- cgit v0.12 From 0a3ce6fa04ed2b085fe72b89d302a3a5f9e82948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 26 Jan 2010 10:55:31 +0100 Subject: Fixed an infinite loop that could occur when reading invalid BMP images. Task-number: QTBUG-7530 Reviewed-by: Kim --- src/gui/image/qbmphandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index 854be2e..42e19b8 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -144,7 +144,7 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi) static int calc_shift(int mask) { int result = 0; - while (!(mask & 1)) { + while (mask && !(mask & 1)) { result++; mask >>= 1; } -- cgit v0.12 From e571e0f012e3e27ffff56493755999da1960318c Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Tue, 26 Jan 2010 12:57:21 +0200 Subject: QFileDialog layout issue on Symbian If long path (or any other long string) is added to a combobox, it grows outside of screen area. QS60Style needs to check that widget will not grow wider than screen area. Task-number: QTBUG-6371 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 5a4e6df..0083803 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2398,6 +2398,24 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, //QCommonStyle does not adjust height with horizontal margin, it only adjusts width sz.setHeight(sz.height() + 2 * pixelMetric(PM_FocusFrameVMargin)); break; +#ifndef QT_NO_COMBOBOX + case CT_ComboBox: + if (const QStyleOptionComboBox *cmb = qstyleoption_cast(opt)) { + const int frameWidth = cmb->frame ? pixelMetric(PM_ComboBoxFrameWidth, opt, widget) * 2 : 0; + const int textMargins = 2*(pixelMetric(PM_FocusFrameHMargin) + 1); + const int smallestExtraWidth = 23; + // QItemDelegate::sizeHint expands the textMargins two times, thus the 2*textMargins... + const int extra = + qMax(smallestExtraWidth, 2*textMargins + pixelMetric(PM_ScrollBarExtent, opt, widget)); + sz = QSize(sz.width() + frameWidth + extra, sz.height() + frameWidth); + int maxScreenWidth = QApplication::desktop()->availableGeometry().size().width(); + if (sz.width() > maxScreenWidth) { + maxScreenWidth = maxScreenWidth - (extra + frameWidth); + sz.setWidth(maxScreenWidth); + } + } + break; +#endif default: sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); break; -- cgit v0.12 From 88719423de4fc3d36a5aab1eb13744984c8f5194 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 26 Jan 2010 13:42:48 +0100 Subject: Cocoa: qfiledialog test spits out memory warnings We need an auto release pool! (cherry picked from commit 7ad08868de4b3e481a51a3431504fcf42a4bbf6d) --- src/gui/kernel/qt_cocoa_helpers_mac.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index e85a716..e06a810 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -143,6 +143,9 @@ extern QPointer qt_button_down; //qapplication_mac.cpp void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds) { +#ifdef QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool; +#endif OSWindowRef wnd = static_cast(window); if (wnd) { QWidget *widget; -- cgit v0.12 From 5ccd8ceb06a9be29f773d170d5dd8c67a8d6c86d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 26 Jan 2010 14:14:47 +0100 Subject: Stabilize tst_QGraphicsScene::polishItems2 (new test) We are only interested in getting the posted MetaCall events delivered, so we can get away with sendPostedEvents() instead of processEvents(). Makes the test also pass on Mac g++ carbon 32. --- tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 547e7f5..6743fbe 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -3989,7 +3989,7 @@ void tst_QGraphicsScene::polishItems2() // Wait for the polish event to be delivered. QVERIFY(!item->polished); - QApplication::processEvents(); + QApplication::sendPostedEvents(&scene, QEvent::MetaCall); QVERIFY(item->polished); // We deleted the children we added above, but we also @@ -4000,7 +4000,7 @@ void tst_QGraphicsScene::polishItems2() foreach (QGraphicsItem *child, children) QVERIFY(!static_cast(child)->polished); - QApplication::processEvents(); + QApplication::sendPostedEvents(&scene, QEvent::MetaCall); foreach (QGraphicsItem *child, children) QVERIFY(static_cast(child)->polished); } -- cgit v0.12 From 8c29bbe3dcd192024d2dbfcf2faa72077b77107d Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Tue, 26 Jan 2010 15:32:11 +0200 Subject: QFileDialog layout issue on Symbian (part2) Added missing #include. Task-number: QTBUG-6371 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 0083803..3f4f190 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -70,6 +70,7 @@ #include "qformlayout.h" #include "qradiobutton.h" #include "qcheckbox.h" +#include "qdesktopwidget.h" #include "qprogressbar.h" #include "private/qtoolbarextension_p.h" -- cgit v0.12 From 9175f9e5bad0f77e5d53751a8e839c8ea7df4c23 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Tue, 26 Jan 2010 14:41:23 +0100 Subject: Add a convenience batch file to run the patch capabilities perl script Signed-off-by: Simon Hausmann --- bin/patch_capabilities.bat | 1 + 1 file changed, 1 insertion(+) create mode 100644 bin/patch_capabilities.bat diff --git a/bin/patch_capabilities.bat b/bin/patch_capabilities.bat new file mode 100644 index 0000000..6a0c4d7 --- /dev/null +++ b/bin/patch_capabilities.bat @@ -0,0 +1 @@ +@perl.exe -S %~dp0patch_capabilities.pl %* -- cgit v0.12 From 67a39e0eb04069e216b76672f45e7709fb076577 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 14:59:14 +0100 Subject: Autotest: make the test valid for multiple Qt versions Reviewed-by: TrustMe --- tests/auto/selftests/expected_xunit.txt | 4 ++-- tests/auto/selftests/tst_selftests.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/selftests/expected_xunit.txt b/tests/auto/selftests/expected_xunit.txt index 5ec4668..3c014e3 100644 --- a/tests/auto/selftests/expected_xunit.txt +++ b/tests/auto/selftests/expected_xunit.txt @@ -1,8 +1,8 @@ - - + + diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 89ece0f..0b9cee0 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -248,7 +248,7 @@ void tst_Selftests::doRunSubTest(QString &subdir, QStringList &arguments ) continue; const QString output(QString::fromLatin1(line)); - const QString expected(QString::fromLatin1(exp.at(i))); + const QString expected(QString::fromLatin1(exp.at(i)).replace("", QT_VERSION_STR)); if (line.contains("ASSERT") && output != expected) QEXPECT_FAIL("assert", "QTestLib prints out the absolute path.", Continue); -- cgit v0.12 From 5241ca84e0884e9d0814094eb6949ae27b19c6f9 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Fri, 8 Jan 2010 16:31:01 +0100 Subject: Fixes visibility update missing when doing setParentItem on graphicsitem Calling setParentItem is causing the previous opacity/visible updates to be discarded because the dirty flags were not propagated to the new parent. Also removed some unnecessary 'markDirty' and 'update' calls. Task-number: QTBUG-6738 Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 30 ++------- src/gui/graphicsview/qgraphicsitem_p.h | 33 ++++++++++ src/gui/graphicsview/qgraphicsscene.cpp | 14 +---- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 86 ++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 36 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 66493b7..dc20faf 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1113,11 +1113,9 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q } if ((parent = newParent)) { - bool implicitUpdate = false; if (parent->d_func()->scene && parent->d_func()->scene != scene) { // Move this item to its new parent's scene parent->d_func()->scene->addItem(q); - implicitUpdate = true; } else if (!parent->d_func()->scene && scene) { // Remove this item from its former scene scene->removeItem(q); @@ -1127,25 +1125,25 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q if (thisPointerVariant) parent->itemChange(QGraphicsItem::ItemChildAddedChange, *thisPointerVariant); if (scene) { - if (!implicitUpdate) - scene->d_func()->markDirty(q_ptr); - // Re-enable scene pos notifications for new ancestors if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges)) scene->d_func()->setScenePosItemEnabled(q, true); } + // Propagate dirty flags to the new parent + markParentDirty(/*updateBoundingRect=*/true); + // Inherit ancestor flags from the new parent. updateAncestorFlags(); // Update item visible / enabled. if (parent->d_ptr->visible != visible) { if (!parent->d_ptr->visible || !explicitlyHidden) - setVisibleHelper(parent->d_ptr->visible, /* explicit = */ false, /* update = */ !implicitUpdate); + setVisibleHelper(parent->d_ptr->visible, /* explicit = */ false, /* update = */ false); } if (parent->isEnabled() != enabled) { if (!parent->d_ptr->enabled || !explicitlyDisabled) - setEnabledHelper(parent->d_ptr->enabled, /* explicit = */ false, /* update = */ !implicitUpdate); + setEnabledHelper(parent->d_ptr->enabled, /* explicit = */ false, /* update = */ false); } // Auto-activate if visible and the parent is active. @@ -1161,10 +1159,6 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q setVisibleHelper(true, /* explicit = */ false); if (!enabled && !explicitlyDisabled) setEnabledHelper(true, /* explicit = */ false); - - // If the item is being deleted, the whole scene will be updated. - if (scene) - scene->d_func()->markDirty(q_ptr); } } @@ -7263,19 +7257,7 @@ void QGraphicsItem::prepareGeometryChange() } } - QGraphicsItem *parent = this; - while ((parent = parent->d_ptr->parent)) { - QGraphicsItemPrivate *parentp = parent->d_ptr.data(); - parentp->dirtyChildrenBoundingRect = 1; - // ### Only do this if the parent's effect applies to the entire subtree. - parentp->notifyBoundingRectChanged = 1; -#ifndef QT_NO_GRAPHICSEFFECT - if (parentp->scene && parentp->graphicsEffect) { - parentp->notifyInvalidated = 1; - static_cast(parentp->graphicsEffect->d_func()->source->d_func())->invalidateCache(); - } -#endif - } + d_ptr->markParentDirty(/*updateBoundingRect=*/true); } /*! diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 986a977..5ad6cd5 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -406,6 +406,8 @@ public: return !visible || (childrenCombineOpacity() && isFullyTransparent()); } + inline void markParentDirty(bool updateBoundingRect = false); + void setFocusHelper(Qt::FocusReason focusReason, bool climb); void setSubFocus(QGraphicsItem *rootItem = 0); void clearSubFocus(QGraphicsItem *rootItem = 0); @@ -754,6 +756,37 @@ inline bool QGraphicsItemPrivate::insertionOrder(QGraphicsItem *a, QGraphicsItem return a->d_ptr->siblingIndex < b->d_ptr->siblingIndex; } +/*! + \internal +*/ +inline void QGraphicsItemPrivate::markParentDirty(bool updateBoundingRect) +{ + QGraphicsItemPrivate *parentp = this; + while (parentp->parent) { + parentp = parentp->parent->d_ptr.data(); + parentp->dirtyChildren = 1; + + if (updateBoundingRect) { + parentp->dirtyChildrenBoundingRect = 1; + // ### Only do this if the parent's effect applies to the entire subtree. + parentp->notifyBoundingRectChanged = 1; + } +#ifndef QT_NO_GRAPHICSEFFECT + if (parentp->graphicsEffect) { + if (updateBoundingRect) { + parentp->notifyInvalidated = 1; + static_cast(parentp->graphicsEffect->d_func() + ->source->d_func())->invalidateCache(); + } + if (parentp->graphicsEffect->isEnabled()) { + parentp->dirty = 1; + parentp->fullUpdatePending = 1; + } + } +#endif + } +} + QT_END_NAMESPACE #endif // QT_NO_GRAPHICSVIEW diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index ae48bee..9219773 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -1955,7 +1955,7 @@ QList QGraphicsScene::items(const QRectF &rectangle, Qt::ItemSe \since 4.3 This convenience function is equivalent to calling items(QRectF(\a x, \a y, \a w, \a h), \a mode). - + This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead. @@ -4903,17 +4903,7 @@ void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, b if (ignoreOpacity) item->d_ptr->ignoreOpacity = 1; - QGraphicsItem *p = item->d_ptr->parent; - while (p) { - p->d_ptr->dirtyChildren = 1; -#ifndef QT_NO_GRAPHICSEFFECT - if (p->d_ptr->graphicsEffect && p->d_ptr->graphicsEffect->isEnabled()) { - p->d_ptr->dirty = 1; - p->d_ptr->fullUpdatePending = 1; - } -#endif //QT_NO_GRAPHICSEFFECT - p = p->d_ptr->parent; - } + item->d_ptr->markParentDirty(); } static inline bool updateHelper(QGraphicsViewPrivate *view, QGraphicsItemPrivate *item, diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 8e43bce..14b9ef0 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -316,6 +316,7 @@ private slots: void childrenBoundingRectTransformed(); void childrenBoundingRect2(); void childrenBoundingRect3(); + void childrenBoundingRect4(); void group(); void setGroup(); void setGroup2(); @@ -417,6 +418,7 @@ private slots: void task197802_childrenVisibility(); void QTBUG_4233_updateCachedWithSceneRect(); void QTBUG_5418_textItemSetDefaultColor(); + void QTBUG_6738_missingUpdateWithSetParent(); private: QList paintedItems; @@ -3257,6 +3259,32 @@ void tst_QGraphicsItem::childrenBoundingRect3() QCOMPARE(subTreeRect.height(), qreal(251.7766952966369)); } +void tst_QGraphicsItem::childrenBoundingRect4() +{ + QGraphicsScene scene; + + QGraphicsRectItem *rect = scene.addRect(QRectF(0, 0, 10, 10)); + QGraphicsRectItem *rect2 = scene.addRect(QRectF(0, 0, 20, 20)); + QGraphicsRectItem *rect3 = scene.addRect(QRectF(0, 0, 30, 30)); + rect2->setParentItem(rect); + rect3->setParentItem(rect); + + QGraphicsView view(&scene); + view.show(); + + QTest::qWaitForWindowShown(&view); + + // Try to mess up the cached bounding rect. + rect->childrenBoundingRect(); + rect2->childrenBoundingRect(); + + rect3->setOpacity(0.0); + rect3->setParentItem(rect2); + + QCOMPARE(rect->childrenBoundingRect(), rect3->boundingRect()); + QCOMPARE(rect2->childrenBoundingRect(), rect3->boundingRect()); +} + void tst_QGraphicsItem::group() { QGraphicsScene scene; @@ -9869,5 +9897,63 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor() QCOMPARE(i->painted, 0); //same color as before should not trigger an update (QTBUG-6242) } +void tst_QGraphicsItem::QTBUG_6738_missingUpdateWithSetParent() +{ + // In all 3 test cases below the reparented item should disappear + EventTester *parent = new EventTester; + EventTester *child = new EventTester(parent); + EventTester *child2 = new EventTester(parent); + EventTester *child3 = new EventTester(parent); + EventTester *child4 = new EventTester(parent); + + child->setPos(10, 10); + child2->setPos(20, 20); + child3->setPos(30, 30); + child4->setPos(40, 40); + + QGraphicsScene scene; + scene.addItem(parent); + + class MyGraphicsView : public QGraphicsView + { public: + int repaints; + QRegion paintedRegion; + MyGraphicsView(QGraphicsScene *scene) : QGraphicsView(scene), repaints(0) {} + void paintEvent(QPaintEvent *e) + { + ++repaints; + paintedRegion += e->region(); + QGraphicsView::paintEvent(e); + } + void reset() { repaints = 0; paintedRegion = QRegion(); } + }; + + MyGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + QTRY_VERIFY(view.repaints > 0); + + // test case #1 + view.reset(); + child2->setVisible(false); + child2->setParentItem(child); + + QTRY_VERIFY(view.repaints == 1); + + // test case #2 + view.reset(); + child3->setOpacity(0.0); + child3->setParentItem(child); + + QTRY_VERIFY(view.repaints == 1); + + // test case #3 + view.reset(); + child4->setParentItem(child); + child4->setVisible(false); + + QTRY_VERIFY(view.repaints == 1); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" -- cgit v0.12 From f98901601fee4947fd0248f113b3a39a142292d5 Mon Sep 17 00:00:00 2001 From: Iain Date: Mon, 25 Jan 2010 10:23:31 +0000 Subject: Updates to new Symbian DEF file system Fix bug in qbase.pri, where it tested QT_CONFIG instead of CONFIG to see if DEF files were enabled, when setting the DEF file path Fix bug in configure.exe implementation, where SYMBIAN_DEFFILES was defined when testing for its value, due to incorrect use of QMap::operator[] Tidy up configure.exe help for new def files option Task-number: QTBUG-6556 Reviewed-by: Jason Barron Reviewed-by: Janne Koskinen --- configure.exe | Bin 1178624 -> 1178112 bytes src/qbase.pri | 2 +- tools/configure/configureapp.cpp | 16 +++++++++------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/configure.exe b/configure.exe index 03cbf37..ed2b0b2 100644 Binary files a/configure.exe and b/configure.exe differ diff --git a/src/qbase.pri b/src/qbase.pri index 3307ae3..710a2b6 100644 --- a/src/qbase.pri +++ b/src/qbase.pri @@ -103,7 +103,7 @@ symbian { # of Qt, and the only compatibility will be between this build of Qt and anything # built in this exact environment. *Never* use this when building a version # for release. - contains(QT_CONFIG, def_files) { + contains(CONFIG, def_files) { defFilePath=../s60installs } } diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 3f105b5..7751143 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -1829,9 +1829,9 @@ bool Configure::displayHelp() desc("FREETYPE", "yes", "-qt-freetype", "Use the libfreetype bundled with Qt."); desc( "-fpu ", "VFP type on ARM, supported options: softvfp(default) | vfpv2 | softvfp+vfpv2"); desc("S60", "no", "-no-s60", "Do not compile in S60 support."); - desc("S60", "yes", "-s60", "Compile with support for the S60 UI Framework\n"); - desc("SYMBIAN_DEFFILES", "no", "no-usedeffiles", "Disable the usage of DEF files."); - desc("SYMBIAN_DEFFILES", "yes", "usedeffiles", "Enable the usage of DEF files.\n"); + desc("S60", "yes", "-s60", "Compile with support for the S60 UI Framework"); + desc("SYMBIAN_DEFFILES", "no", "-no-usedeffiles", "Disable the usage of DEF files."); + desc("SYMBIAN_DEFFILES", "yes", "-usedeffiles", "Enable the usage of DEF files.\n"); return true; } return false; @@ -2753,10 +2753,12 @@ void Configure::generateCachefile() if ( dictionary["PLUGIN_MANIFESTS"] == "no" ) configStream << " no_plugin_manifest"; - if ( dictionary["SYMBIAN_DEFFILES"] == "yes" ) { - configStream << " def_files"; - } else if ( dictionary["SYMBIAN_DEFFILES"] == "no" ) { - configStream << " def_files_disabled"; + if ( dictionary.contains("SYMBIAN_DEFFILES") ) { + if(dictionary["SYMBIAN_DEFFILES"] == "yes" ) { + configStream << " def_files"; + } else if ( dictionary["SYMBIAN_DEFFILES"] == "no" ) { + configStream << " def_files_disabled"; + } } configStream << endl; configStream << "QT_ARCH = " << dictionary[ "ARCHITECTURE" ] << endl; -- cgit v0.12 From 56e36ce9d4e1ec81e41f6f74f4e5cd39070b1f8f Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 26 Jan 2010 19:11:25 +0100 Subject: Fix broken build of simulated QS60Style The QProgressBar animating code is not meant for the simulated style. ifdef it out. Reviewed-by: Sami Merila modified: src/gui/styles/qs60style.cpp --- src/gui/styles/qs60style.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 3f4f190..24b2d34 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2964,11 +2964,13 @@ void QS60Style::unpolish(QWidget *widget) if (widget) widget->setPalette(QPalette()); -#ifndef QT_NO_PROGRESSBAR +#if defined(Q_WS_S60) && !defined(QT_NO_PROGRESSBAR) if (QProgressBar *bar = qobject_cast(widget)) { widget->removeEventFilter(this); d->m_bars.removeAll(bar); } +#else + Q_UNUSED(d) #endif QCommonStyle::unpolish(widget); } -- cgit v0.12 From c7636e37e62b8df54cad331989be3173ba4ca27d Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 26 Jan 2010 19:28:36 +0100 Subject: Remove warnings MSVC revealed some issues that are worth a warning. Reviewed-by: Sami Merila modified: src/gui/styles/qs60style.cpp --- src/gui/styles/qs60style.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 24b2d34..ecb3242 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1985,7 +1985,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, */ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { - Q_D(const QS60Style); const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled; bool commonStyleDraws = false; @@ -2021,8 +2020,8 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti QS60StyleEnums::SP_QgnIndiCheckboxOn : QS60StyleEnums::SP_QgnIndiCheckboxOff; painter->save(); - QColor themeColor = QS60StylePrivate::themePalette()->windowText().color(); - QColor windowTextColor = option->palette.windowText().color(); + const QColor themeColor = QS60StylePrivate::themePalette()->windowText().color(); + const QColor windowTextColor = option->palette.windowText().color(); if (themeColor != windowTextColor) painter->setPen(windowTextColor); @@ -2069,8 +2068,8 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti buttonRect.adjust(0, -newY, -1, -newY); painter->save(); - QColor themeColor = d->s60Color(QS60StyleEnums::CL_QsnTextColors, 6, option); - QColor buttonTextColor = option->palette.buttonText().color(); + const QColor themeColor = QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, option); + const QColor buttonTextColor = option->palette.buttonText().color(); if (themeColor != buttonTextColor) painter->setPen(buttonTextColor); else @@ -3002,9 +3001,8 @@ void QS60Style::unpolish(QApplication *application) */ bool QS60Style::event(QEvent *e) { - Q_D(QS60Style); - #ifdef QT_KEYPAD_NAVIGATION + Q_D(QS60Style); const QEvent::Type eventType = e->type(); if ((eventType == QEvent::FocusIn || eventType == QEvent::FocusOut || -- cgit v0.12 From 9eea7172d4d4984a111f009a60f5eaa0568fcf89 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 26 Jan 2010 19:31:01 +0100 Subject: Remove unneeded resources from QtGui QtGui contains loads of resources. 337,160 bytes just for qstyle. And since this is nearly exclusively full of PNG files, it won't really be compressed in the qt.sis package. And it will eat unneccessary Ram. This patch removes about 260,000 bytes of resources. We only want the 32-pixel big icons. No 16- and 129- pixel versions. Task-number: QTBUG-7277 Reviewed-by: Sami Merila modified: src/gui/kernel/qapplication.cpp new file: src/gui/styles/qstyle_s60.qrc modified: src/gui/styles/styles.pri --- src/gui/kernel/qapplication.cpp | 4 +- src/gui/styles/qstyle_s60.qrc | 137 ++++++++++++++++++++++++++++++++++++++++ src/gui/styles/styles.pri | 8 ++- 3 files changed, 145 insertions(+), 4 deletions(-) create mode 100644 src/gui/styles/qstyle_s60.qrc diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 12fe797..4fe3900 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -121,8 +121,10 @@ extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp static void initResources() { -#ifdef Q_WS_WINCE +#if defined(Q_WS_WINCE) Q_INIT_RESOURCE(qstyle_wince); +#elif defined(Q_OS_SYMBIAN) + Q_INIT_RESOURCE(qstyle_s60); #else Q_INIT_RESOURCE(qstyle); #endif diff --git a/src/gui/styles/qstyle_s60.qrc b/src/gui/styles/qstyle_s60.qrc new file mode 100644 index 0000000..dbee38b --- /dev/null +++ b/src/gui/styles/qstyle_s60.qrc @@ -0,0 +1,137 @@ + + + +images/filelink-32.png + + +images/file-32.png + + +images/newdirectory-32.png + + +images/parentdir-32.png + + + + + + + + + + + +images/harddrive-32.png + + + + + + + + + + +images/desktop-32.png + +images/dirclosed-32.png + + +images/dirlink-32.png + + +images/diropen-32.png + + +images/left-32.png + + +images/right-32.png + + +images/up-32.png + + +images/down-32.png + + +images/filecontents-32.png + + +images/fileinfo-32.png + + +images/viewdetailed-32.png + + +images/viewlist-32.png + +images/fontbitmap-16.png +images/fonttruetype-16.png + + +images/standardbutton-apply-32.png + + +images/standardbutton-cancel-32.png + + +images/standardbutton-clear-32.png + + +images/standardbutton-close-32.png + + +images/standardbutton-delete-32.png + + +images/standardbutton-help-32.png + + +images/standardbutton-no-32.png + + +images/standardbutton-ok-32.png + + +images/standardbutton-open-32.png + + +images/standardbutton-save-32.png + + +images/standardbutton-yes-32.png +images/standardbutton-closetab-16.png +images/standardbutton-closetab-down-16.png +images/standardbutton-closetab-hover-16.png + +images/refresh-32.png + +images/stop-32.png + +images/media-stop-32.png + +images/media-play-32.png + +images/media-pause-32.png + +images/media-seek-forward-32.png + +images/media-seek-backward-32.png + +images/media-skip-forward-32.png + +images/media-skip-backward-32.png +images/media-volume-16.png +images/media-volume-muted-16.png + + + diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri index f30f5af..676f59e 100644 --- a/src/gui/styles/styles.pri +++ b/src/gui/styles/styles.pri @@ -23,10 +23,12 @@ SOURCES += \ styles/qstylesheetstyle.cpp \ styles/qstylesheetstyle_default.cpp -!wince* { - RESOURCES += styles/qstyle.qrc +wince* { + RESOURCES += styles/qstyle_wince.qrc +} else:symbian { + RESOURCES += styles/qstyle_s60.qrc } else { - RESOURCES += styles/qstyle_wince.qrc + RESOURCES += styles/qstyle.qrc } contains( styles, all ) { -- cgit v0.12 From ff344c1844f729fd8f9d594a71eb0074dac09c60 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 21:11:36 +0100 Subject: Do the refcounting of services watched properly. Issue found while debugging KDE applications. --- src/dbus/qdbusintegrator.cpp | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 30fa0b6..fe8693c 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1660,9 +1660,6 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError } QString busService = QLatin1String(DBUS_SERVICE_DBUS); - WatchedServicesHash::mapped_type &bus = watchedServices[busService]; - bus.refcount = 1; - bus.owner = getNameOwnerNoCache(busService); connectSignal(busService, QString(), QString(), QLatin1String("NameAcquired"), QStringList(), QString(), this, SLOT(registerService(QString))); connectSignal(busService, QString(), QString(), QLatin1String("NameLost"), QStringList(), QString(), @@ -2046,10 +2043,7 @@ void QDBusConnectionPrivate::connectSignal(const QString &key, const SignalHook // Do we need to watch for this name? if (shouldWatchService(hook.service)) { WatchedServicesHash::mapped_type &data = watchedServices[hook.service]; - if (data.refcount) { - // already watching - ++data.refcount; - } else { + if (++data.refcount == 1) { // we need to watch for this service changing QString dbusServerService = QLatin1String(DBUS_SERVICE_DBUS); connectSignal(dbusServerService, QString(), QLatin1String(DBUS_INTERFACE_DBUS), @@ -2105,19 +2099,6 @@ QDBusConnectionPrivate::disconnectSignal(SignalHookHash::Iterator &it) { const SignalHook &hook = it.value(); - WatchedServicesHash::Iterator sit = watchedServices.find(hook.service); - if (sit != watchedServices.end()) { - if (sit.value().refcount == 1) { - watchedServices.erase(sit); - QString dbusServerService = QLatin1String(DBUS_SERVICE_DBUS); - disconnectSignal(dbusServerService, QString(), QLatin1String(DBUS_INTERFACE_DBUS), - QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(), - this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); - } else { - --sit.value().refcount; - } - } - bool erase = false; MatchRefCountHash::iterator i = matchRefCounts.find(hook.matchRule); if (i == matchRefCounts.end()) { @@ -2136,6 +2117,20 @@ QDBusConnectionPrivate::disconnectSignal(SignalHookHash::Iterator &it) if (connection && erase) { qDBusDebug("Removing rule: %s", hook.matchRule.constData()); q_dbus_bus_remove_match(connection, hook.matchRule, NULL); + + // Successfully disconnected the signal + // Were we watching for this name? + WatchedServicesHash::Iterator sit = watchedServices.find(hook.service); + if (sit != watchedServices.end()) { + if (--sit.value().refcount == 0) { + watchedServices.erase(sit); + QString dbusServerService = QLatin1String(DBUS_SERVICE_DBUS); + disconnectSignal(dbusServerService, QString(), QLatin1String(DBUS_INTERFACE_DBUS), + QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(), + this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); + } + } + } return signalHooks.erase(it); -- cgit v0.12 From e631e7bde04aea81292a950cb00a93764714c093 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 26 Jan 2010 21:41:17 +0100 Subject: When checking to see if a signal is connected, compare the match-arguments too --- src/dbus/qdbusintegrator.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index fe8693c..44abf7b 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -2001,7 +2001,8 @@ bool QDBusConnectionPrivate::connectSignal(const QString &service, entry.path == hook.path && entry.signature == hook.signature && entry.obj == hook.obj && - entry.midx == hook.midx) { + entry.midx == hook.midx && + entry.argumentMatch == hook.argumentMatch) { // no need to compare the parameters if it's the same slot return true; // already there } @@ -2083,7 +2084,8 @@ bool QDBusConnectionPrivate::disconnectSignal(const QString &service, entry.path == hook.path && entry.signature == hook.signature && entry.obj == hook.obj && - entry.midx == hook.midx) { + entry.midx == hook.midx && + entry.argumentMatch == hook.argumentMatch) { // no need to compare the parameters if it's the same slot disconnectSignal(it); return true; // it was there -- cgit v0.12 From 416cf8a5a9384f942282a2c715ec4832eeba001d Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 27 Jan 2010 09:34:39 +1000 Subject: Compile with no-webkit - add missing semi-colons. Reviewed-by: Sarah Smith --- tools/assistant/tools/assistant/centralwidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index c8f41e4..055fa1c 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -1088,7 +1088,7 @@ CentralWidget::setSourceFromSearch(const QUrl &url) { setSource(url); #if defined(QT_NO_WEBKIT) - highlightSearchTerms() + highlightSearchTerms(); #else connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, SLOT(highlightSearchTerms())); @@ -1100,7 +1100,7 @@ CentralWidget::setSourceFromSearchInNewTab(const QUrl &url) { setSourceInNewTab(url); #if defined(QT_NO_WEBKIT) - highlightSearchTerms() + highlightSearchTerms(); #else connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, SLOT(highlightSearchTerms())); -- cgit v0.12 From aebc34877fb17405e8e5915760012a82d0178b97 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 27 Jan 2010 09:52:26 +0100 Subject: doc: Corrected some bad grammar. Task-number: QTBUG-7640 --- src/gui/widgets/qmenu.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 5031d88..8ce7cc0 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -1588,10 +1588,9 @@ QAction *QMenu::insertSeparator(QAction *before) } /*! - This will set the default action to \a act. The default action may - have a visual queue depending on the current QStyle. A default - action is usually meant to indicate what will defaultly happen on a - drop, as shown in a context menu. + This sets the default action to \a act. The default action may have + a visual cue, depending on the current QStyle. A default action + usually indicates what will happen by default when a drop occurs. \sa defaultAction() */ -- cgit v0.12 From a2c153f01c9b12eb6f1d46ffaf5533bb7b3695e2 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 27 Jan 2010 10:16:21 +0100 Subject: doc: Specified default values for constructors. Task-number: QTBUG-7628 --- src/gui/text/qtextoption.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp index 0c8aeec..c1e254c 100644 --- a/src/gui/text/qtextoption.cpp +++ b/src/gui/text/qtextoption.cpp @@ -52,6 +52,9 @@ struct QTextOptionPrivate /*! Constructs a text option with default properties for text. + The text alignment property is set to Qt::AlignLeft. The + word wrap property is set to QTextOption::WordWrap. The + using of design metrics flag is set to false. */ QTextOption::QTextOption() : align(Qt::AlignLeft), @@ -67,6 +70,8 @@ QTextOption::QTextOption() /*! Constructs a text option with the given \a alignment for text. + The word wrap property is set to QTextOption::WordWrap. The using + of design metrics flag is set to false. */ QTextOption::QTextOption(Qt::Alignment alignment) : align(alignment), -- cgit v0.12 From fc7b48c2d2fb5926fa0b50f378fadc583564b7b8 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 27 Jan 2010 10:20:13 +0100 Subject: doc: Corrected misspelled word. Task-number: QTBUG-7626 --- src/corelib/tools/qsharedpointer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index 21816b9..1b4b356 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -130,7 +130,7 @@ multiple- or virtual-inheritance (that is, in cases where two different pointer addresses can refer to the same object). In that case, if a pointer is cast to a different type and its value changes, - QSharedPointer's pointer tracking mechanism mail fail to detect that the + QSharedPointer's pointer tracking mechanism may fail to detect that the object being tracked is the same. \omit -- cgit v0.12 From 634eac05a6475280f2a1cc6e41e23c0c35628247 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 27 Jan 2010 10:40:40 +0100 Subject: doc: Included a note showing the actual value of UserType. Task-number: QTBUG-7606 --- src/gui/graphicsview/qgraphicsitem.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 1361a89..1ea69fb 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -276,6 +276,8 @@ and declaring a Type enum value. Example: \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 1 + + \note UserType = 65536 */ /*! -- cgit v0.12 From be0807cf52a11f0bc4dc5b06c9a91bc2980667d3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 27 Jan 2010 10:41:48 +0100 Subject: Designer: Add lower/raise to context menu. Task-number: QTCREATORBUG-592 --- tools/designer/src/components/formeditor/formwindow.cpp | 5 +++++ tools/designer/src/components/formeditor/formwindow.h | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/designer/src/components/formeditor/formwindow.cpp b/tools/designer/src/components/formeditor/formwindow.cpp index 2d013c9..9fd084d 100644 --- a/tools/designer/src/components/formeditor/formwindow.cpp +++ b/tools/designer/src/components/formeditor/formwindow.cpp @@ -2219,6 +2219,11 @@ QMenu *FormWindow::createPopupMenu(QWidget *w) QToolBoxHelper::addToolBoxContextMenuActions(toolBox, popup); } + if (manager->actionLower()->isEnabled()) { + popup->addAction(manager->actionLower()); + popup->addAction(manager->actionRaise()); + popup->addSeparator(); + } popup->addAction(manager->actionCut()); popup->addAction(manager->actionCopy()); } diff --git a/tools/designer/src/components/formeditor/formwindow.h b/tools/designer/src/components/formeditor/formwindow.h index eed7417..3eee476 100644 --- a/tools/designer/src/components/formeditor/formwindow.h +++ b/tools/designer/src/components/formeditor/formwindow.h @@ -278,8 +278,6 @@ private: void checkPreviewGeometry(QRect &r); - void finishContextMenu(QWidget *w, QWidget *menuParent, QContextMenuEvent *e); - bool handleContextMenu(QWidget *widget, QWidget *managedWidget, QContextMenuEvent *e); bool handleMouseButtonDblClickEvent(QWidget *widget, QWidget *managedWidget, QMouseEvent *e); bool handleMousePressEvent(QWidget *widget, QWidget *managedWidget, QMouseEvent *e); -- cgit v0.12 From 44e3b8862cb0927637d841d276850fbac1681745 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 27 Jan 2010 11:35:32 +0100 Subject: Don't crash when comparing JSCore value without engine to non-JSCore value Task-number: None, discovering while doing test refactoring Reviewed-by: Jedrzej Nowacki --- src/script/api/qscriptvalue.cpp | 13 +++++++++---- tests/auto/qscriptvalue/tst_qscriptvalue.cpp | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index 1db2e1b..5bfe46a 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -1148,10 +1148,15 @@ bool QScriptValue::strictlyEquals(const QScriptValue &other) const } if (d->type != other.d_ptr->type) { - if (d->type == QScriptValuePrivate::JavaScriptCore) - return JSC::JSValue::strictEqual(d->jscValue, d->engine->scriptValueToJSCValue(other)); - else if (other.d_ptr->type == QScriptValuePrivate::JavaScriptCore) - return JSC::JSValue::strictEqual(other.d_ptr->engine->scriptValueToJSCValue(*this), other.d_ptr->jscValue); + if (d->type == QScriptValuePrivate::JavaScriptCore) { + QScriptEnginePrivate *eng_p = d->engine ? d->engine : other.d_ptr->engine; + if (eng_p) + return JSC::JSValue::strictEqual(d->jscValue, eng_p->scriptValueToJSCValue(other)); + } else if (other.d_ptr->type == QScriptValuePrivate::JavaScriptCore) { + QScriptEnginePrivate *eng_p = other.d_ptr->engine ? other.d_ptr->engine : d->engine; + if (eng_p) + return JSC::JSValue::strictEqual(eng_p->scriptValueToJSCValue(*this), other.d_ptr->jscValue); + } return false; } diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index b384a55..2aeabf0 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -3091,6 +3091,20 @@ void tst_QScriptValue::strictlyEquals() QVERIFY(!falskt.strictlyEquals(null)); QVERIFY(!falskt.strictlyEquals(QScriptValue())); + QVERIFY(!QScriptValue(false).strictlyEquals(123)); + QVERIFY(!QScriptValue(QScriptValue::UndefinedValue).strictlyEquals(123)); + QVERIFY(!QScriptValue(QScriptValue::NullValue).strictlyEquals(123)); + QVERIFY(!QScriptValue(false).strictlyEquals("ciao")); + QVERIFY(!QScriptValue(QScriptValue::UndefinedValue).strictlyEquals("ciao")); + QVERIFY(!QScriptValue(QScriptValue::NullValue).strictlyEquals("ciao")); + QVERIFY(QScriptValue(&eng, "ciao").strictlyEquals("ciao")); + QVERIFY(QScriptValue("ciao").strictlyEquals(QScriptValue(&eng, "ciao"))); + QVERIFY(!QScriptValue("ciao").strictlyEquals(123)); + QVERIFY(!QScriptValue("ciao").strictlyEquals(QScriptValue(&eng, 123))); + QVERIFY(!QScriptValue(123).strictlyEquals("ciao")); + QVERIFY(!QScriptValue(123).strictlyEquals(QScriptValue(&eng, "ciao"))); + QVERIFY(!QScriptValue(&eng, 123).strictlyEquals("ciao")); + QScriptValue obj1 = eng.newObject(); QScriptValue obj2 = eng.newObject(); QCOMPARE(obj1.strictlyEquals(obj2), false); -- cgit v0.12 From 878bf8b1dde10e28d9acd91002fd7b4e2a7a64e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 27 Jan 2010 11:58:34 +0100 Subject: Compiler warning. --- src/gui/effects/qgraphicseffect.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index ad23df3..10ef5ea 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -383,9 +383,9 @@ void QGraphicsEffectSourcePrivate::invalidateCache(InvalidateReason reason) cons { if (m_cachedMode != QGraphicsEffect::PadToEffectiveBoundingRect && (reason == EffectRectChanged - || reason == TransformChanged - && m_cachedSystem == Qt::LogicalCoordinates)) + || (reason == TransformChanged && m_cachedSystem == Qt::LogicalCoordinates))) { return; + } QPixmapCache::remove(m_cacheKey); } -- cgit v0.12 From ac1a7e4469050aa70d065e3c7def9b3fe7aca4a8 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Wed, 27 Jan 2010 13:35:35 +0200 Subject: Polishing QS60Style by removing compiler warning Removes one compiler warning caused by animation support additions (member variables are initialized in incorrect order in default constructor). Also, removing unnecessary struct variable and one unnecessary scope definition. Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 2 +- src/gui/styles/qs60style_p.h | 9 ++++----- src/gui/styles/qs60style_s60.cpp | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index ecb3242..47ba088 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -985,7 +985,7 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom //Handle graphics const QRect sliderHandle = subControlRect(control, optionSlider, SC_SliderHandle, widget); QS60StylePrivate::SkinElements handleElement; - if (optionSlider->state & QStyle::State_Sunken) + if (optionSlider->state & State_Sunken) handleElement = horizontal ? QS60StylePrivate::SE_SliderHandleSelectedHorizontal : QS60StylePrivate::SE_SliderHandleSelectedVertical; else diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 2cd238f..eae2291 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -74,7 +74,6 @@ typedef struct { unsigned short width; int major_version; int minor_version; - bool mirroring; // TODO: (nice to have) Use Qt::LayoutDirection const char* layoutName; } layoutHeader; @@ -353,12 +352,12 @@ public: int timerId() const {return m_currentData->m_timerId;} int currentFrame() const {return m_currentData->m_currentFrame;} - void setFrameCount(const int &frameCount) {m_currentData->m_frames = frameCount;} - void setInterval(const int &interval) {m_currentData->m_interval = interval;} + void setFrameCount(int frameCount) {m_currentData->m_frames = frameCount;} + void setInterval(int interval) {m_currentData->m_interval = interval;} void setAnimationObject(CAknBitmapAnimation* animation); void setResourceBased(bool resourceBased) {m_currentData->m_resourceBased = resourceBased;} - void setTimerId(const int &timerId) {m_currentData->m_timerId = timerId;} - void setCurrentFrame(const int ¤tFrame) {m_currentData->m_currentFrame = currentFrame;} + void setTimerId(int timerId) {m_currentData->m_timerId = timerId;} + void setCurrentFrame(int currentFrame) {m_currentData->m_currentFrame = currentFrame;} void resetToDefaults(); diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index a3bb169..872bc2b 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -105,7 +105,7 @@ AnimationData::AnimationData(const QS60StyleEnums::SkinParts part, int frames, i } AnimationDataV2::AnimationDataV2(const AnimationData &data) : AnimationData(data.m_id, data.m_frames, data.m_interval), - m_resourceBased(false), m_animation(0), m_timerId(0) + m_animation(0), m_currentFrame(0), m_resourceBased(false), m_timerId(0) { } AnimationDataV2::~AnimationDataV2() -- cgit v0.12 From b8d29f8ee076beee45cb45e8dfca8f4706d11ebd Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 27 Jan 2010 12:34:55 +0100 Subject: Cocoa: qaccessibility test crashes The reason is that the test first creates a menu bar with an exit item The exit item gets merged into the appmenu (together with a QAction) Then we destroy the menu bar, but leave the exit item in the appmenu untouched. Then we create a new menubar _without_ an exit item macUpdateMenubar will then, at one point, try to access the old exit item's QAction, wich is destroyed a long time ago; crash! This patch will make sure we clear out all actions in the menu bars appmenu when the menubar gets destroyed. Reviewed-by: Prasanth --- src/gui/kernel/qcocoamenuloader_mac.mm | 6 ++++++ src/gui/kernel/qcocoamenuloader_mac_p.h | 1 + src/gui/widgets/qmenu_mac.mm | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/src/gui/kernel/qcocoamenuloader_mac.mm b/src/gui/kernel/qcocoamenuloader_mac.mm index 9f90cec..18b3772 100644 --- a/src/gui/kernel/qcocoamenuloader_mac.mm +++ b/src/gui/kernel/qcocoamenuloader_mac.mm @@ -110,6 +110,12 @@ QT_USE_NAMESPACE } } +- (void)removeActionsFromAppMenu +{ + for (NSMenuItem *item in [appMenu itemArray]) + [item setTag:nil]; +} + - (void)dealloc { [lastAppSpecificItem release]; diff --git a/src/gui/kernel/qcocoamenuloader_mac_p.h b/src/gui/kernel/qcocoamenuloader_mac_p.h index 432a7a6..81c136e 100644 --- a/src/gui/kernel/qcocoamenuloader_mac_p.h +++ b/src/gui/kernel/qcocoamenuloader_mac_p.h @@ -70,6 +70,7 @@ } - (void)ensureAppMenuInMenu:(NSMenu *)menu; +- (void)removeActionsFromAppMenu; - (NSMenu *)applicationMenu; - (NSMenu *)menu; - (NSMenuItem *)quitMenuItem; diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index cd7f9bd..31bda9a 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -1830,6 +1830,10 @@ void QMenuBarPrivate::macDestroyMenuBar() mac_menubar = 0; if (qt_mac_current_menubar.qmenubar == q) { +#ifdef QT_MAC_USE_COCOA + QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); + [loader removeActionsFromAppMenu]; +#endif extern void qt_event_request_menubarupdate(); //qapplication_mac.cpp qt_event_request_menubarupdate(); } -- cgit v0.12 From 15f690e6890caae8d0c000bcc34103b1841307eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Wed, 27 Jan 2010 12:46:23 +0100 Subject: Added a warning to QGLWidget::renderText(). renderText() can't be used while a GL 2 paint engine is active on the same device, because it will clash with the GL 1 engine and wreck havoc. We simply don't support that scenario. Task-number: QTBUG-7592 Reviewed-by: Samuel --- src/opengl/qgl.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 48e43b2..2a60708 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4419,8 +4419,17 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font, bool auto_swap = autoBufferSwap(); QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine(); - qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); + QPaintEngine *engine = paintEngine(); + if (engine && (oldEngineType == QPaintEngine::OpenGL2) && engine->isActive()) { + qWarning("QGLWidget::renderText(): Calling renderText() while a GL 2 paint engine is" + " active on the same device is not allowed."); + return; + } + + // this changes what paintEngine() returns + qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); + engine = paintEngine(); QPainter *p; bool reuse_painter = false; if (engine->isActive()) { @@ -4513,8 +4522,17 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con win_y = height - win_y; // y is inverted QPaintEngine::Type oldEngineType = qgl_engine_selector()->preferredPaintEngine(); - qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); QPaintEngine *engine = paintEngine(); + + if (engine && (oldEngineType == QPaintEngine::OpenGL2) && engine->isActive()) { + qWarning("QGLWidget::renderText(): Calling renderText() while a GL 2 paint engine is" + " active on the same device is not allowed."); + return; + } + + // this changes what paintEngine() returns + qgl_engine_selector()->setPreferredPaintEngine(QPaintEngine::OpenGL); + engine = paintEngine(); QPainter *p; bool reuse_painter = false; bool use_depth_testing = glIsEnabled(GL_DEPTH_TEST); -- cgit v0.12 From 9a2a6531c91d63ad55f65ad6a2b0fdaf7d739bfe Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 27 Jan 2010 13:18:16 +0100 Subject: Carbon: deleting a QMenu while it's open will cause a crash This patch closes the menu bar if it's open when it gets destroyed Task-number: QTBUG-6597 Reviewed-by: cduclos --- src/gui/widgets/qmenu_mac.mm | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 31bda9a..7e4bbb5 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -175,6 +175,22 @@ static quint32 constructModifierMask(quint32 accel_key) return ret; } +static void cancelAllMenuTracking() +{ +#ifdef QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool; + NSMenu *mainMenu = [NSApp mainMenu]; + [mainMenu cancelTracking]; + for (NSMenuItem *item in [mainMenu itemArray]) { + if ([item submenu]) { + [[item submenu] cancelTracking]; + } + } +#else + CancelMenuTracking(AcquireRootMenu(), true, 0); +#endif +} + static bool actualMenuItemVisibility(const QMenuBarPrivate::QMacMenuBarPrivate *mbp, const QMacMenuAction *action) { @@ -1833,6 +1849,8 @@ void QMenuBarPrivate::macDestroyMenuBar() #ifdef QT_MAC_USE_COCOA QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *loader = getMenuLoader(); [loader removeActionsFromAppMenu]; +#else + cancelAllMenuTracking(); #endif extern void qt_event_request_menubarupdate(); //qapplication_mac.cpp qt_event_request_menubarupdate(); @@ -1937,20 +1955,6 @@ static bool qt_mac_should_disable_menu(QMenuBar *menuBar, QWidget *modalWidget) return qt_mac_is_ancestor(menuBar->parentWidget(), modalWidget); } -static void cancelAllMenuTracking() -{ -#ifdef QT_MAC_USE_COCOA - QMacCocoaAutoReleasePool pool; - NSMenu *mainMenu = [NSApp mainMenu]; - [mainMenu cancelTracking]; - for (NSMenuItem *item in [mainMenu itemArray]) { - if ([item submenu]) { - [[item submenu] cancelTracking]; - } - } -#endif -} - /*! \internal -- cgit v0.12 From c64635b53a014da36203c576954042916cf87a7c Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Wed, 27 Jan 2010 12:09:17 +0100 Subject: Avoid call markParentDirty twice in prepareGeometryChange Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 4 +++- src/gui/graphicsview/qgraphicsscene.cpp | 6 ++++-- src/gui/graphicsview/qgraphicsscene_p.h | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index dc20faf..561bd42 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -7240,7 +7240,9 @@ void QGraphicsItem::prepareGeometryChange() QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func(); scenePrivate->index->prepareBoundingRectChange(this); - scenePrivate->markDirty(this, QRectF(), /*invalidateChildren=*/true); + scenePrivate->markDirty(this, QRectF(), /*invalidateChildren=*/true, /*force=*/false, + /*ignoreOpacity=*/ false, /*removingItemFromScene=*/ false, + /*updateBoundingRect=*/true); // For compatibility reasons, we have to update the item's old geometry // if someone is connected to the changed signal or the scene has no views. diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 9219773..54d47fa 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4832,7 +4832,8 @@ void QGraphicsScenePrivate::draw(QGraphicsItem *item, QPainter *painter, const Q } void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, bool invalidateChildren, - bool force, bool ignoreOpacity, bool removingItemFromScene) + bool force, bool ignoreOpacity, bool removingItemFromScene, + bool updateBoundingRect) { Q_ASSERT(item); if (updateAll) @@ -4903,7 +4904,8 @@ void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, b if (ignoreOpacity) item->d_ptr->ignoreOpacity = 1; - item->d_ptr->markParentDirty(); + if (!updateBoundingRect) + item->d_ptr->markParentDirty(); } static inline bool updateHelper(QGraphicsViewPrivate *view, QGraphicsItemPrivate *item, diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index 54d8130..04ffe0f 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -222,7 +222,8 @@ public: QRegion *, QWidget *, qreal, const QTransform *const, bool, bool); void markDirty(QGraphicsItem *item, const QRectF &rect = QRectF(), bool invalidateChildren = false, - bool force = false, bool ignoreOpacity = false, bool removingItemFromScene = false); + bool force = false, bool ignoreOpacity = false, bool removingItemFromScene = false, + bool updateBoundingRect = false); void processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren = false, qreal parentOpacity = qreal(1.0)); -- cgit v0.12 From 0b2bde7af1ec6cec5c1bc674c9049b12fe0deb20 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 27 Jan 2010 14:43:54 +0200 Subject: Added support for embedded sis name/uid patching for Symbian Patch_capabilities.pl script now also patches any embedded sis file entries in pkg to embed corresponding *_selfsigned.sis instead. Also the script now removes dependencies to other packages from patched pkg to reduce unnecessary warnings about missing dependencies when said dependencies were installed via patched sises. Reviewed-by: Janne Koskinen --- bin/patch_capabilities.pl | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/bin/patch_capabilities.pl b/bin/patch_capabilities.pl index b6bf5c3..9daa13e 100755 --- a/bin/patch_capabilities.pl +++ b/bin/patch_capabilities.pl @@ -111,12 +111,31 @@ if (@ARGV) # Parse each line. while () { + # Patch pkg UID my $line = $_; my $newLine = $line; - if ( $line =~ m/^\#.*\(0x[0-9|a-f|A-F]*\).*$/) + if ($line =~ m/^\#.*\(0x[0-9|a-f|A-F]*\).*$/) { $newLine =~ s/\(0x./\(0xE/; } + + # Patch embedded sis name and UID + if ($line =~ m/^@.*\.sis.*\(0x[0-9|a-f|A-F]*\).*$/) + { + $newLine =~ s/\(0x./\(0xE/; + if ($line !~ m/^.*_selfsigned.sis.*$/) + { + $newLine =~ s/\.sis/_selfsigned\.sis/i; + } + } + + # Remove all dependencies to other packages to reduce unnecessary error messages + # from depended packages that are also patched and therefore have different UID. + if ($line =~ m/^\(0x[0-9|a-f|A-F]*\).*\{.*\}$/) + { + $newLine = "" + } + print NEW_PKG $newLine; chomp ($line); -- cgit v0.12 From c513782f7cbad45b7c91e069ae81552a4bbb2a5f Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 27 Jan 2010 14:55:54 +0200 Subject: Added a selfsigned version of sqlite3.sis Reviewed-by: TrustMe --- src/s60installs/sqlite3_selfsigned.sis | Bin 0 -> 285088 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/s60installs/sqlite3_selfsigned.sis diff --git a/src/s60installs/sqlite3_selfsigned.sis b/src/s60installs/sqlite3_selfsigned.sis new file mode 100644 index 0000000..a025ac5 Binary files /dev/null and b/src/s60installs/sqlite3_selfsigned.sis differ -- cgit v0.12 From 41ff82566a360a478766ee16e72958f5441947fc Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 27 Jan 2010 14:17:59 +0100 Subject: Removing unneeded code from QFontEngine::getGlyphPositions() Two QVarLengthArray resizes and one local int variable less. Reviewed-by: Simon Hausmann modified: src/gui/text/qfontengine.cpp --- src/gui/text/qfontengine.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 9343cb7..c000457 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -357,9 +357,6 @@ void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform ++i; } } else { - positions.resize(glyphs.numGlyphs); - glyphs_out.resize(glyphs.numGlyphs); - int i = 0; while (i < glyphs.numGlyphs) { if (!glyphs.attributes[i].dontPrint) { QFixed gpos_x = xpos + glyphs.offsets[i].x; -- cgit v0.12 From 9d207f042ea135eda6bcd91c47d581914470fa6d Mon Sep 17 00:00:00 2001 From: Carlos Manuel Duclos Vergara Date: Wed, 27 Jan 2010 14:44:59 +0100 Subject: Mac: Calling showFullScreen() then showNormal() on a widget results in top menu hiding. The problem here was the way we entered Full Screen Mode. We were using "kUIModeAllSuppressed" which does the following according to the manual: kUIModeAllSuppressed All system UI elements (including the menu bar) are hidden. However, these elements may automatically show themselves in response to mouse movements or other user activity. I changed it to "kUIModeAllHidden", which does the following: All system UI elements (including the menu bar) are hidden. To prevent a change of behavior I added the following option to the SetSystemUIMode: kUIOptionAutoShowMenuBar This flag specifies that the menu bar automatically shows itself when the user moves the mouse into the screen area that would ordinarily be occupied by the menu bar. Only valid for the presentation mode kUIModeAllHidden. Task-number: QTBUG-7625 Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qwidget_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 3dbc843..ebfab21 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -404,7 +404,7 @@ inline static void qt_mac_set_fullscreen_mode(bool b) return; qt_mac_app_fullscreen = b; if (b) { - SetSystemUIMode(kUIModeAllSuppressed, 0); + SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar); } else { SetSystemUIMode(kUIModeNormal, 0); } -- cgit v0.12 From 78bb23107d9fcde431cd2ba83c1a9e9886b6d51a Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Wed, 27 Jan 2010 15:56:24 +0200 Subject: QComboBox drawn incorrectly in RightToLeft mode QS60Style does not regard layout orientation when calculating subrects for QComboBox. This leads to a situation where button is not visible on UI with RightToLeft orientation. Task-number: QTBUG-7584 Reviewed-by: Alessandro Portale --- src/gui/styles/qs60style.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 47ba088..78279d1 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2620,29 +2620,31 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple // lets use spinbox frame here as well, as no combobox specific value available. const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0; const int buttonWidth = qMax(cmb->rect.height(), buttonIconSize); - const int xposMod = (cmb->rect.x()) + width - buttonMargin - buttonWidth; - const int ypos = cmb->rect.y(); QSize buttonSize; buttonSize.setWidth(buttonWidth + 2 * buttonMargin); buttonSize.setHeight(qMax(8, (cmb->rect.height() >> 1) - frameThickness)); //buttons should be squares buttonSize = buttonSize.expandedTo(QApplication::globalStrut()); switch (scontrol) { - case SC_ComboBoxArrow: + case SC_ComboBoxArrow: { + const int xposMod = cmb->rect.x() + width - buttonMargin - buttonWidth; + const int ypos = cmb->rect.y(); ret.setRect(xposMod, ypos + buttonMargin, buttonWidth, height - 2 * buttonMargin); + } break; case SC_ComboBoxEditField: { - const int withFrameX = cmb->rect.x() + cmb->rect.width() - frameThickness - buttonSize.width(); + const int withFrameX = cmb->rect.x() + width - frameThickness - buttonSize.width(); ret = QRect( frameThickness, frameThickness, withFrameX - frameThickness, - cmb->rect.height() - 2 * frameThickness); + height - 2 * frameThickness); } break; default: break; } + ret = visualRect(cmb->direction, cmb->rect, ret); } break; case CC_GroupBox: -- cgit v0.12 From d74f8fd8d7d378bbf23872ddc24ddfbfd948e295 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 26 Jan 2010 15:59:24 +0100 Subject: fix bogus warning message --- tools/linguist/lrelease/main.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/linguist/lrelease/main.cpp b/tools/linguist/lrelease/main.cpp index 7834b06..c418bcc 100644 --- a/tools/linguist/lrelease/main.cpp +++ b/tools/linguist/lrelease/main.cpp @@ -260,10 +260,7 @@ int main(int argc, char **argv) return 1; } } else { - qWarning("error: lrelease encountered project file functionality that is currently not supported.\n" - "You might want to consider using TS files as input instead of a project file.\n" - "Try the following syntax:\n" - " lrelease [options] ts-files [-qm qm-file]\n"); + qWarning("lrelease error: cannot read project file %s.", qPrintable(inputFile)); } } else { if (outputFile.isEmpty()) { -- cgit v0.12 From d97a3e97f54d1e1d028fd7bc2b46171c6b0be966 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 25 Jan 2010 19:28:51 +0100 Subject: do not sort the TS files really no point in doing so ... --- tools/linguist/lupdate/main.cpp | 1 - tools/linguist/shared/proreader.cpp | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index 2129265..0db2b25 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -525,7 +525,6 @@ int main(int argc, char **argv) if (!cd.error().isEmpty()) printOut(cd.error()); - tsFiles.sort(); tsFiles.removeDuplicates(); if (!tsFiles.isEmpty()) diff --git a/tools/linguist/shared/proreader.cpp b/tools/linguist/shared/proreader.cpp index 4a621a8..f249f24 100644 --- a/tools/linguist/shared/proreader.cpp +++ b/tools/linguist/shared/proreader.cpp @@ -95,9 +95,8 @@ void evaluateProFile(const ProFileEvaluator &visitor, QHashinsert("SOURCES", sourceFiles); -- cgit v0.12 From 20c871370727630b83adce1e96ac0437802c433a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 25 Jan 2010 19:36:38 +0100 Subject: still complain if only ts files where specified on the cmdline --- tools/linguist/lupdate/main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index 0db2b25..301f217 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -367,8 +367,6 @@ int main(int argc, char **argv) return 1; } - numFiles++; - codecForTr.clear(); codecForSource.clear(); @@ -395,6 +393,7 @@ int main(int argc, char **argv) } else if (arg.endsWith(QLatin1String(".pro"), Qt::CaseInsensitive) || arg.endsWith(QLatin1String(".pri"), Qt::CaseInsensitive)) { proFiles << arg; + numFiles++; } else { QFileInfo fi(arg); if (!fi.exists()) { @@ -439,9 +438,15 @@ int main(int argc, char **argv) } else { sourceFiles << QDir::cleanPath(fi.absoluteFilePath());; } + numFiles++; } } // for args + if (numFiles == 0) { + printUsage(); + return 1; + } + foreach (const QString &proFile, proFiles) projectRoots.insert(QDir::cleanPath(QFileInfo(proFile).absolutePath()) + QLatin1Char('/')); @@ -533,10 +538,5 @@ int main(int argc, char **argv) firstPass = false; } - if (numFiles == 0) { - printUsage(); - return 1; - } - return fail ? 1 : 0; } -- cgit v0.12 From 03e114b11ee5cd51e0b9151e0c728fe370578d53 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 26 Jan 2010 17:15:43 +0100 Subject: complain if both sources and projects are given on the cmdline --- tools/linguist/lupdate/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index 301f217..c5051cd 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -442,6 +442,10 @@ int main(int argc, char **argv) } } // for args + if (!proFiles.isEmpty() && !sourceFiles.isEmpty()) { + qWarning("lupdate error: Both project and source files specified.\n"); + return 1; + } if (numFiles == 0) { printUsage(); return 1; -- cgit v0.12 From b0a454fd09e0cbf74304aabd160ea25c2c83b4b9 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 26 Jan 2010 19:19:33 +0100 Subject: unshare pro post-processing code lrelease needs only the TRANSLATIONS value anyway, so there is hardly anything to share for real --- tools/linguist/lrelease/main.cpp | 40 ++++++----- tools/linguist/lupdate/main.cpp | 60 +++++++++++++---- tools/linguist/shared/proparser.pri | 2 - tools/linguist/shared/proreader.cpp | 130 ------------------------------------ tools/linguist/shared/proreader.h | 57 ---------------- 5 files changed, 73 insertions(+), 216 deletions(-) delete mode 100644 tools/linguist/shared/proreader.cpp delete mode 100644 tools/linguist/shared/proreader.h diff --git a/tools/linguist/lrelease/main.cpp b/tools/linguist/lrelease/main.cpp index c418bcc..266474e 100644 --- a/tools/linguist/lrelease/main.cpp +++ b/tools/linguist/lrelease/main.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "translator.h" -#include "proreader.h" +#include "profileevaluator.h" #ifndef QT_BOOTSTRAPPED #include @@ -246,21 +246,31 @@ int main(int argc, char **argv) foreach (const QString &inputFile, inputFiles) { if (inputFile.endsWith(QLatin1String(".pro"), Qt::CaseInsensitive) || inputFile.endsWith(QLatin1String(".pri"), Qt::CaseInsensitive)) { - QHash varMap; - bool ok = evaluateProFile(inputFile, cd.isVerbose(), &varMap); - if (ok) { - QStringList translations = varMap.value("TRANSLATIONS"); - if (translations.isEmpty()) { - qWarning("lrelease warning: Met no 'TRANSLATIONS' entry in" - " project file '%s'\n", - qPrintable(inputFile)); - } else { - foreach (const QString &trans, translations) - if (!releaseTsFile(trans, cd, removeIdentical)) - return 1; - } + QFileInfo fi(inputFile); + ProFile pro(fi.absoluteFilePath()); + + ProFileEvaluator visitor; + visitor.setVerbose(cd.isVerbose()); + + if (!visitor.queryProFile(&pro)) { + qWarning("lrelease error: cannot read project file '%s'.", qPrintable(inputFile)); + continue; + } + if (!visitor.accept(&pro)) { + qWarning("lrelease error: cannot process project file '%s'.", qPrintable(inputFile)); + continue; + } + + QStringList translations = visitor.values(QLatin1String("TRANSLATIONS")); + if (translations.isEmpty()) { + qWarning("lrelease warning: Met no 'TRANSLATIONS' entry in" + " project file '%s'\n", + qPrintable(inputFile)); } else { - qWarning("lrelease error: cannot read project file %s.", qPrintable(inputFile)); + QDir proDir(fi.absolutePath()); + foreach (const QString &trans, translations) + if (!releaseTsFile(QFileInfo(proDir, trans).filePath(), cd, removeIdentical)) + return 1; } } else { if (outputFile.isEmpty()) { diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index c5051cd..44717bf 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -43,7 +43,6 @@ #include #include -#include #include #include @@ -214,6 +213,42 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil } } +static QStringList getSources(const char *var, const char *vvar, const QStringList &baseVPaths, + const QString &projectDir, const ProFileEvaluator &visitor) +{ + QStringList vPaths = visitor.absolutePathValues(QLatin1String(vvar), projectDir); + vPaths += baseVPaths; + vPaths.removeDuplicates(); + return visitor.absoluteFileValues(QLatin1String(var), projectDir, vPaths, 0); +} + +static QStringList getSources(const ProFileEvaluator &visitor, const QString &projectDir) +{ + QStringList baseVPaths; + baseVPaths += visitor.absolutePathValues(QLatin1String("VPATH"), projectDir); + baseVPaths << projectDir; // QMAKE_ABSOLUTE_SOURCE_PATH + baseVPaths += visitor.absolutePathValues(QLatin1String("DEPENDPATH"), projectDir); + baseVPaths.removeDuplicates(); + + QStringList sourceFiles; + + // app/lib template + sourceFiles += getSources("SOURCES", "VPATH_SOURCES", baseVPaths, projectDir, visitor); + + sourceFiles += getSources("FORMS", "VPATH_FORMS", baseVPaths, projectDir, visitor); + sourceFiles += getSources("FORMS3", "VPATH_FORMS3", baseVPaths, projectDir, visitor); + + QStringList vPathsInc = baseVPaths; + vPathsInc += visitor.absolutePathValues(QLatin1String("INCLUDEPATH"), projectDir); + vPathsInc.removeDuplicates(); + sourceFiles += visitor.absoluteFileValues(QLatin1String("HEADERS"), projectDir, vPathsInc, 0); + + sourceFiles.removeDuplicates(); + sourceFiles.sort(); + + return sourceFiles; +} + int main(int argc, char **argv) { QCoreApplication app(argc, argv); @@ -467,7 +502,6 @@ int main(int argc, char **argv) QStringList tsFiles = tsFileNames; if (proFiles.count() > 0) { QFileInfo pfi(proFiles.takeFirst()); - QHash variables; ProFileEvaluator visitor; visitor.setVerbose(options & Verbose); @@ -494,19 +528,19 @@ int main(int argc, char **argv) cd.m_includePath += visitor.values(QLatin1String("INCLUDEPATH")); - evaluateProFile(visitor, &variables, pfi.absolutePath()); - - sourceFiles = variables.value("SOURCES"); + sourceFiles = getSources(visitor, pfi.absolutePath()); - QStringList tmp = variables.value("CODECFORTR"); - if (!tmp.isEmpty() && !tmp.first().isEmpty()) { - codecForTr = tmp.first().toLatin1(); + QStringList tmp = visitor.values(QLatin1String("CODEC")) + + visitor.values(QLatin1String("DEFAULTCODEC")) + + visitor.values(QLatin1String("CODECFORTR")); + if (!tmp.isEmpty()) { + codecForTr = tmp.last().toLatin1(); fetchedTor.setCodecName(codecForTr); cd.m_outputCodec = codecForTr; } - tmp = variables.value("CODECFORSRC"); - if (!tmp.isEmpty() && !tmp.first().isEmpty()) { - codecForSource = tmp.first().toLatin1(); + tmp = visitor.values(QLatin1String("CODECFORSRC")); + if (!tmp.isEmpty()) { + codecForSource = tmp.last().toLatin1(); if (!QTextCodec::codecForName(codecForSource)) qWarning("lupdate warning: Codec for source '%s' is invalid. Falling back to codec for tr().", codecForSource.constData()); @@ -514,7 +548,9 @@ int main(int argc, char **argv) cd.m_codecForSource = codecForSource; } - tsFiles += variables.value("TRANSLATIONS"); + QDir proDir(pfi.absolutePath()); + foreach (const QString &tsFile, visitor.values(QLatin1String("TRANSLATIONS"))) + tsFiles << QFileInfo(proDir, tsFile).filePath(); } QStringList sourceFilesCpp; diff --git a/tools/linguist/shared/proparser.pri b/tools/linguist/shared/proparser.pri index 99d32e7..372247e 100644 --- a/tools/linguist/shared/proparser.pri +++ b/tools/linguist/shared/proparser.pri @@ -2,13 +2,11 @@ INCLUDEPATH *= $$PWD HEADERS += \ - $$PWD/proreader.h \ $$PWD/abstractproitemvisitor.h \ $$PWD/proitems.h \ $$PWD/profileevaluator.h \ $$PWD/proparserutils.h SOURCES += \ - $$PWD/proreader.cpp \ $$PWD/proitems.cpp \ $$PWD/profileevaluator.cpp diff --git a/tools/linguist/shared/proreader.cpp b/tools/linguist/shared/proreader.cpp deleted file mode 100644 index f249f24..0000000 --- a/tools/linguist/shared/proreader.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Linguist 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 "profileevaluator.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -static QStringList getSources(const char *var, const char *vvar, const QStringList &baseVPaths, - const QString &projectDir, const ProFileEvaluator &visitor) -{ - QStringList vPaths = - visitor.absolutePathValues(QLatin1String(vvar), projectDir); - vPaths += baseVPaths; - vPaths.removeDuplicates(); - return visitor.absoluteFileValues(QLatin1String(var), projectDir, vPaths, 0); -} - -void evaluateProFile(const ProFileEvaluator &visitor, QHash *varMap, - const QString &projectDir) -{ - QStringList baseVPaths; - baseVPaths += visitor.absolutePathValues(QLatin1String("VPATH"), projectDir); - baseVPaths << projectDir; // QMAKE_ABSOLUTE_SOURCE_PATH - baseVPaths += visitor.absolutePathValues(QLatin1String("DEPENDPATH"), projectDir); - baseVPaths.removeDuplicates(); - - QStringList sourceFiles; - QString codecForTr; - QString codecForSource; - QStringList tsFileNames; - - // app/lib template - sourceFiles += getSources("SOURCES", "VPATH_SOURCES", baseVPaths, projectDir, visitor); - - sourceFiles += getSources("FORMS", "VPATH_FORMS", baseVPaths, projectDir, visitor); - sourceFiles += getSources("FORMS3", "VPATH_FORMS3", baseVPaths, projectDir, visitor); - - QStringList vPathsInc = baseVPaths; - vPathsInc += visitor.absolutePathValues(QLatin1String("INCLUDEPATH"), projectDir); - vPathsInc.removeDuplicates(); - sourceFiles += visitor.absoluteFileValues(QLatin1String("HEADERS"), projectDir, vPathsInc, 0); - - QDir proDir(projectDir); - foreach (const QString &tsFile, visitor.values(QLatin1String("TRANSLATIONS"))) - tsFileNames << QFileInfo(proDir, tsFile).filePath(); - - QStringList trcodec = visitor.values(QLatin1String("CODEC")) - + visitor.values(QLatin1String("DEFAULTCODEC")) - + visitor.values(QLatin1String("CODECFORTR")); - if (!trcodec.isEmpty()) - codecForTr = trcodec.last(); - - QStringList srccodec = visitor.values(QLatin1String("CODECFORSRC")); - if (!srccodec.isEmpty()) - codecForSource = srccodec.last(); - - sourceFiles.removeDuplicates(); - sourceFiles.sort(); - tsFileNames.removeDuplicates(); - - varMap->insert("SOURCES", sourceFiles); - varMap->insert("CODECFORTR", QStringList() << codecForTr); - varMap->insert("CODECFORSRC", QStringList() << codecForSource); - varMap->insert("TRANSLATIONS", tsFileNames); -} - -bool evaluateProFile(const QString &fileName, bool verbose, QHash *varMap) -{ - QFileInfo fi(fileName); - if (!fi.exists()) - return false; - - ProFile pro(fi.absoluteFilePath()); - - ProFileEvaluator visitor; - visitor.setVerbose(verbose); - - if (!visitor.queryProFile(&pro)) - return false; - - if (!visitor.accept(&pro)) - return false; - - evaluateProFile(visitor, varMap, fi.absolutePath()); - - return true; -} - -QT_END_NAMESPACE diff --git a/tools/linguist/shared/proreader.h b/tools/linguist/shared/proreader.h deleted file mode 100644 index 70421d7..0000000 --- a/tools/linguist/shared/proreader.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Linguist 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 PROREADER_H -#define PROREADER_H - -#include - -QT_BEGIN_NAMESPACE - -class ProFileEvaluator; - -void evaluateProFile(const ProFileEvaluator &visitor, QHash *varMap, - const QString &projectDir); -bool evaluateProFile(const QString &fileName, bool verbose, QHash *varMap); - -QT_END_NAMESPACE - -#endif // PROREADER_H -- cgit v0.12 From bcd35f48a93591a1d2524490ebba9887075ee92e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 26 Jan 2010 20:41:40 +0100 Subject: fix printing output from failed command --- tests/auto/linguist/lupdate/tst_lupdate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/linguist/lupdate/tst_lupdate.cpp b/tests/auto/linguist/lupdate/tst_lupdate.cpp index 568be37..6095140 100644 --- a/tests/auto/linguist/lupdate/tst_lupdate.cpp +++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp @@ -287,7 +287,7 @@ void tst_lupdate::good() "\"lupdate " + lupdatecmd.toLatin1() + "\" crashed\n" + output); QVERIFY2(!proc.exitCode(), "\"lupdate " + lupdatecmd.toLatin1() + "\" exited with code " + - QByteArray::number(proc.exitCode()) + "\n" + proc.readAll()); + QByteArray::number(proc.exitCode()) + "\n" + output); // If the file expectedoutput.txt exists, compare the // console output with the content of that file -- cgit v0.12 From 6874f4381278d17ad62298e145f366d4e0f038bd Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 26 Jan 2010 19:49:13 +0100 Subject: support multiple output files --- tests/auto/linguist/lupdate/tst_lupdate.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/auto/linguist/lupdate/tst_lupdate.cpp b/tests/auto/linguist/lupdate/tst_lupdate.cpp index 6095140..b68eadc 100644 --- a/tests/auto/linguist/lupdate/tst_lupdate.cpp +++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp @@ -245,10 +245,9 @@ void tst_lupdate::good() qDebug() << "Checking..."; - QString generatedtsfile(dir + QLatin1String("/project.ts")); - - // look for a command + QStringList generatedtsfiles(dir + QLatin1String("/project.ts")); QString lupdatecmd; + QFile file(dir + "/lupdatecmd"); if (file.exists()) { QVERIFY2(file.open(QIODevice::ReadOnly | QIODevice::Text), qPrintable(file.fileName())); @@ -262,16 +261,21 @@ void tst_lupdate::good() break; } else if (cmdstring.startsWith("TRANSLATION:")) { cmdstring.remove(0, 12); - generatedtsfile = dir + QLatin1Char('/') + cmdstring.trimmed(); + generatedtsfiles.clear(); + foreach (const QByteArray &s, cmdstring.split(' ')) + if (!s.isEmpty()) + generatedtsfiles << dir + QLatin1Char('/') + s; } } file.close(); } - QFile::remove(generatedtsfile); - QString beforetsfile = generatedtsfile + QLatin1String(".before"); - if (QFile::exists(beforetsfile)) - QVERIFY2(QFile::copy(beforetsfile, generatedtsfile), qPrintable(beforetsfile)); + foreach (const QString &ts, generatedtsfiles) { + QFile::remove(ts); + QString beforetsfile = ts + QLatin1String(".before"); + if (QFile::exists(beforetsfile)) + QVERIFY2(QFile::copy(beforetsfile, ts), qPrintable(beforetsfile)); + } if (lupdatecmd.isEmpty()) lupdatecmd = QLatin1String("project.pro"); @@ -299,8 +303,8 @@ void tst_lupdate::good() return; } - QString expectedFile = generatedtsfile + QLatin1String(".result"); - doCompare(generatedtsfile, expectedFile, false); + foreach (const QString &ts, generatedtsfiles) + doCompare(ts, ts + QLatin1String(".result"), false); } void tst_lupdate::commandline_data() -- cgit v0.12 From 7c824cff70d528644b992595f3195f9fd2474fc2 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 26 Jan 2010 20:09:59 +0100 Subject: add ability to set working dir for test --- tests/auto/linguist/lupdate/tst_lupdate.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/auto/linguist/lupdate/tst_lupdate.cpp b/tests/auto/linguist/lupdate/tst_lupdate.cpp index b68eadc..b45383f 100644 --- a/tests/auto/linguist/lupdate/tst_lupdate.cpp +++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp @@ -245,7 +245,8 @@ void tst_lupdate::good() qDebug() << "Checking..."; - QStringList generatedtsfiles(dir + QLatin1String("/project.ts")); + QString workDir = dir; + QStringList generatedtsfiles(QLatin1String("project.ts")); QString lupdatecmd; QFile file(dir + "/lupdatecmd"); @@ -264,17 +265,21 @@ void tst_lupdate::good() generatedtsfiles.clear(); foreach (const QByteArray &s, cmdstring.split(' ')) if (!s.isEmpty()) - generatedtsfiles << dir + QLatin1Char('/') + s; + generatedtsfiles << s; + } else if (cmdstring.startsWith("cd ")) { + cmdstring.remove(0, 3); + workDir = QDir::cleanPath(dir + QLatin1Char('/') + cmdstring); } } file.close(); } foreach (const QString &ts, generatedtsfiles) { - QFile::remove(ts); - QString beforetsfile = ts + QLatin1String(".before"); + QString genTs = workDir + QLatin1Char('/') + ts; + QFile::remove(genTs); + QString beforetsfile = dir + QLatin1Char('/') + ts + QLatin1String(".before"); if (QFile::exists(beforetsfile)) - QVERIFY2(QFile::copy(beforetsfile, ts), qPrintable(beforetsfile)); + QVERIFY2(QFile::copy(beforetsfile, genTs), qPrintable(beforetsfile)); } if (lupdatecmd.isEmpty()) @@ -282,7 +287,7 @@ void tst_lupdate::good() lupdatecmd.prepend("-silent "); QProcess proc; - proc.setWorkingDirectory(dir); + proc.setWorkingDirectory(workDir); proc.setProcessChannelMode(QProcess::MergedChannels); proc.start(m_cmdLupdate + ' ' + lupdatecmd, QIODevice::ReadWrite | QIODevice::Text); QVERIFY2(proc.waitForFinished(5000), qPrintable(lupdatecmd)); @@ -304,7 +309,8 @@ void tst_lupdate::good() } foreach (const QString &ts, generatedtsfiles) - doCompare(ts, ts + QLatin1String(".result"), false); + doCompare(workDir + QLatin1Char('/') + ts, + dir + QLatin1Char('/') + ts + QLatin1String(".result"), false); } void tst_lupdate::commandline_data() -- cgit v0.12 From df9a6a9bf9d7bf3609ac034e705d076b82572333 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 26 Jan 2010 20:16:59 +0100 Subject: absorb cmdline tests into "good" structure --- tests/auto/linguist/lupdate/.gitignore | 1 - .../testdata/good/cmdline_deeppath/lupdatecmd | 2 + .../good/cmdline_deeppath/project.ts.result | 27 +++++ .../testdata/good/cmdline_recurse/lupdatecmd | 2 + .../good/cmdline_recurse/project.ts.result | 115 +++++++++++++++++++++ .../lupdate/testdata/recursivescan/bar.ts.result | 27 ----- .../lupdate/testdata/recursivescan/foo.ts.result | 115 --------------------- tests/auto/linguist/lupdate/tst_lupdate.cpp | 41 -------- 8 files changed, 146 insertions(+), 184 deletions(-) create mode 100644 tests/auto/linguist/lupdate/testdata/good/cmdline_deeppath/lupdatecmd create mode 100644 tests/auto/linguist/lupdate/testdata/good/cmdline_deeppath/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/cmdline_recurse/lupdatecmd create mode 100644 tests/auto/linguist/lupdate/testdata/good/cmdline_recurse/project.ts.result delete mode 100644 tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result delete mode 100644 tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result diff --git a/tests/auto/linguist/lupdate/.gitignore b/tests/auto/linguist/lupdate/.gitignore index 389f2dc..3572c82 100644 --- a/tests/auto/linguist/lupdate/.gitignore +++ b/tests/auto/linguist/lupdate/.gitignore @@ -1,4 +1,3 @@ tst_lupdate testdata/good/*/project.ts testdata/good/*/*/project.ts -testdata/recursivescan/*.ts diff --git a/tests/auto/linguist/lupdate/testdata/good/cmdline_deeppath/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/cmdline_deeppath/lupdatecmd new file mode 100644 index 0000000..301d839 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/cmdline_deeppath/lupdatecmd @@ -0,0 +1,2 @@ +cd ../../recursivescan +lupdate sub/finddialog.cpp -ts project.ts diff --git a/tests/auto/linguist/lupdate/testdata/good/cmdline_deeppath/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/cmdline_deeppath/project.ts.result new file mode 100644 index 0000000..5c3c21c --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/cmdline_deeppath/project.ts.result @@ -0,0 +1,27 @@ + + + + + FindDialog + + + Enter the text you want to find. + + + + + Search reached end of the document + + + + + Search reached start of the document + + + + + Text not found + + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/cmdline_recurse/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/cmdline_recurse/lupdatecmd new file mode 100644 index 0000000..1814e67 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/cmdline_recurse/lupdatecmd @@ -0,0 +1,2 @@ +cd ../../recursivescan +lupdate . -ts project.ts diff --git a/tests/auto/linguist/lupdate/testdata/good/cmdline_recurse/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/cmdline_recurse/project.ts.result new file mode 100644 index 0000000..95a34fa --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/cmdline_recurse/project.ts.result @@ -0,0 +1,115 @@ + + + + + FindDialog + + + Qt Assistant - Finn text + + + + + Finn tekst + + + + + Enter the text you want to find. + + + + + Search reached end of the document + + + + + Search reached start of the document + + + + + Text not found + + + + + QObject + + + +newline at the start + + + + + newline at the end + + + + + + newline and space at the end + + + + + + space and newline at the end + + + + + + Tab at the start and newline at the end + + + + + + + newline and tab at the start + + + + + space and tab at the start + + + + + space_first + + + + + space_last + + + + + text/c++ + + + test + + + + + text/cpp + + + test + + + + + text/cxx + + + test + + + + diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result b/tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result deleted file mode 100644 index 5c3c21c..0000000 --- a/tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result +++ /dev/null @@ -1,27 +0,0 @@ - - - - - FindDialog - - - Enter the text you want to find. - - - - - Search reached end of the document - - - - - Search reached start of the document - - - - - Text not found - - - - diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result b/tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result deleted file mode 100644 index 95a34fa..0000000 --- a/tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result +++ /dev/null @@ -1,115 +0,0 @@ - - - - - FindDialog - - - Qt Assistant - Finn text - - - - - Finn tekst - - - - - Enter the text you want to find. - - - - - Search reached end of the document - - - - - Search reached start of the document - - - - - Text not found - - - - - QObject - - - -newline at the start - - - - - newline at the end - - - - - - newline and space at the end - - - - - - space and newline at the end - - - - - - Tab at the start and newline at the end - - - - - - - newline and tab at the start - - - - - space and tab at the start - - - - - space_first - - - - - space_last - - - - - text/c++ - - - test - - - - - text/cpp - - - test - - - - - text/cxx - - - test - - - - diff --git a/tests/auto/linguist/lupdate/tst_lupdate.cpp b/tests/auto/linguist/lupdate/tst_lupdate.cpp index b45383f..c179462 100644 --- a/tests/auto/linguist/lupdate/tst_lupdate.cpp +++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp @@ -59,8 +59,6 @@ public: private slots: void good_data(); void good(); - void commandline_data(); - void commandline(); #if CHECK_SIMTEXTH void simtexth(); void simtexth_data(); @@ -313,45 +311,6 @@ void tst_lupdate::good() dir + QLatin1Char('/') + ts + QLatin1String(".result"), false); } -void tst_lupdate::commandline_data() -{ - QTest::addColumn("currentPath"); - QTest::addColumn("commandline"); - QTest::addColumn("generatedtsfile"); - QTest::addColumn("expectedtsfile"); - - QTest::newRow("Recursive scan") << QString("recursivescan") - << QString(". -ts foo.ts") << QString("foo.ts") << QString("foo.ts.result"); - QTest::newRow("Deep path argument") << QString("recursivescan") - << QString("sub/finddialog.cpp -ts bar.ts") << QString("bar.ts") << QString("bar.ts.result"); -} - -void tst_lupdate::commandline() -{ - QFETCH(QString, currentPath); - QFETCH(QString, commandline); - QFETCH(QString, generatedtsfile); - QFETCH(QString, expectedtsfile); - - QString generated = - m_basePath + currentPath + QLatin1Char('/') + generatedtsfile; - QFile gen(generated); - if (gen.exists()) - QVERIFY(gen.remove()); - QProcess proc; - proc.setWorkingDirectory(m_basePath + currentPath); - proc.setProcessChannelMode(QProcess::MergedChannels); - proc.start(m_cmdLupdate + " -silent " + commandline, QIODevice::ReadWrite | QIODevice::Text); - QVERIFY2(proc.waitForFinished(5000), qPrintable(commandline)); - QVERIFY2(proc.exitStatus() == QProcess::NormalExit, - "\"lupdate -silent " + commandline.toLatin1() + "\" crashed\n" + proc.readAll()); - QVERIFY2(!proc.exitCode(), - "\"lupdate -silent " + commandline.toLatin1() + "\" exited with code " + - QByteArray::number(proc.exitCode()) + "\n" + proc.readAll()); - - doCompare(generated, m_basePath + currentPath + QLatin1Char('/') + expectedtsfile, false); -} - #if CHECK_SIMTEXTH void tst_lupdate::simtexth() { -- cgit v0.12 From b62b87d6ae3ced4466c1a1b085b51cec757e24f5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 26 Jan 2010 21:00:05 +0100 Subject: sanitize lupdate's behavior regarding SUBDIRS projects previously, the semantics of nesting projects were pretty bizarre: the list of TS files grew ever as the subdirs were visited. the source files otoh were cleared for every project. this meant that some TS files were updated over and over again, each time with different data. this is obviously total nonsense, so there is no compatibilty to keep. so here come the new semantics: - each project is scanned separately. it has separate include paths and may override the inherited CODECFORSRC. - the messages from all sub-projects are merged - if a sub-project has a TRANSLATIONS entry, it is "detached" from its parent project, thus starting an own merged translator. it is also possible to name an empty set of TS files to simply exclude the sub-project. - CODECFORTR can be specified in each project with TRANSLATIONS - if TS files are specified on the command line, they override TRANSLATIONS from the top level project and stop processing of detached projects alltogether. if multiple top-level projects are specified, they are all merged. this is somewhat slower, as now includes are re-scanned per project, while previously all sources were simply accumulated and scanned as one project. this can be fixed retroactively if needed. --- tests/auto/linguist/lupdate/.gitignore | 5 +- .../testdata/good/recurse_full/expectedoutput.txt | 0 .../lupdate/testdata/good/recurse_full/lupdatecmd | 2 + .../testdata/good/recurse_full/project.ts.result | 20 ++ .../good/recurse_full/project_sub.ts.result | 13 + .../good/recurse_full_ts/expectedoutput.txt | 2 + .../testdata/good/recurse_full_ts/lupdatecmd | 3 + .../good/recurse_full_ts/project.ts.result | 20 ++ .../good/recurse_full_ts/project_sub.ts.before | 0 .../good/recurse_full_ts/project_sub.ts.result | 0 .../good/recurse_full_ts_join/expectedoutput.txt | 0 .../testdata/good/recurse_full_ts_join/lupdatecmd | 2 + .../good/recurse_full_ts_join/project.ts.result | 20 ++ .../testdata/good/recurse_part/expectedoutput.txt | 1 + .../lupdate/testdata/good/recurse_part/lupdatecmd | 2 + .../testdata/good/recurse_part/project.ts.before | 0 .../testdata/good/recurse_part/project.ts.result | 0 .../good/recurse_part/project_sub.ts.result | 13 + .../good/recurse_part_ts/expectedoutput.txt | 1 + .../testdata/good/recurse_part_ts/lupdatecmd | 3 + .../good/recurse_part_ts/project.ts.result | 20 ++ .../good/recurse_part_ts/project_sub.ts.before | 0 .../good/recurse_part_ts/project_sub.ts.result | 0 .../lupdate/testdata/good/reloutput/lupdatecmd | 1 - .../lupdate/testdata/subdirs_full/project.pro | 4 + .../lupdate/testdata/subdirs_full/subdir1/main.cpp | 46 ++++ .../testdata/subdirs_full/subdir1/subdir1.pro | 1 + .../testdata/subdirs_full/subdir2/subdir2.pro | 2 + .../testdata/subdirs_full/subdir2/subsub1/main.cpp | 46 ++++ .../subdirs_full/subdir2/subsub1/subsub1.pro | 1 + .../testdata/subdirs_full/subdir2/subsub2/main.cpp | 46 ++++ .../subdirs_full/subdir2/subsub2/subsub2.pro | 4 + .../lupdate/testdata/subdirs_part/project.pro | 2 + .../lupdate/testdata/subdirs_part/subdir1/main.cpp | 46 ++++ .../testdata/subdirs_part/subdir1/subdir1.pro | 1 + .../testdata/subdirs_part/subdir2/subdir2.pro | 2 + .../testdata/subdirs_part/subdir2/subsub1/main.cpp | 46 ++++ .../subdirs_part/subdir2/subsub1/subsub1.pro | 1 + .../testdata/subdirs_part/subdir2/subsub2/main.cpp | 46 ++++ .../subdirs_part/subdir2/subsub2/subsub2.pro | 4 + tools/linguist/lupdate/main.cpp | 264 +++++++++++++-------- 41 files changed, 592 insertions(+), 98 deletions(-) create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_full/expectedoutput.txt create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_full/lupdatecmd create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_full/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_full/project_sub.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/expectedoutput.txt create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/lupdatecmd create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.before create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/expectedoutput.txt create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/lupdatecmd create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_part/expectedoutput.txt create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_part/lupdatecmd create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.before create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_part/project_sub.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/expectedoutput.txt create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/lupdatecmd create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.before create mode 100644 tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/subdirs_full/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/subdir1.pro create mode 100644 tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subdir2.pro create mode 100644 tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/subsub1.pro create mode 100644 tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/subsub2.pro create mode 100644 tests/auto/linguist/lupdate/testdata/subdirs_part/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/subdir1.pro create mode 100644 tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subdir2.pro create mode 100644 tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/subsub1.pro create mode 100644 tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/subsub2.pro diff --git a/tests/auto/linguist/lupdate/.gitignore b/tests/auto/linguist/lupdate/.gitignore index 3572c82..a11e8d1 100644 --- a/tests/auto/linguist/lupdate/.gitignore +++ b/tests/auto/linguist/lupdate/.gitignore @@ -1,3 +1,4 @@ tst_lupdate -testdata/good/*/project.ts -testdata/good/*/*/project.ts +testdata/*/*.ts +testdata/*/*/*.ts +testdata/*/*/*/*.ts diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/recurse_full/expectedoutput.txt new file mode 100644 index 0000000..e69de29 diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/recurse_full/lupdatecmd new file mode 100644 index 0000000..40987e2 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full/lupdatecmd @@ -0,0 +1,2 @@ +TRANSLATION: project.ts project_sub.ts +cd ../../subdirs_full diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_full/project.ts.result new file mode 100644 index 0000000..7d9a6f4 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full/project.ts.result @@ -0,0 +1,20 @@ + + + + + subdir1 + + + minimal test + + + + + subsub1 + + + minimal test + + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full/project_sub.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_full/project_sub.ts.result new file mode 100644 index 0000000..cddb963 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full/project_sub.ts.result @@ -0,0 +1,13 @@ + + + +ISO-8859-2 + + subsub2 + + + minimal test + + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/expectedoutput.txt new file mode 100644 index 0000000..fd7a158 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/expectedoutput.txt @@ -0,0 +1,2 @@ +lupdate warning: TS files from command line will override TRANSLATIONS in project\.pro\. +lupdate warning: TS files from command line prevent recursing into .*/subdir2/subsub2/subsub2\.pro\. diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/lupdatecmd new file mode 100644 index 0000000..33296c3 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/lupdatecmd @@ -0,0 +1,3 @@ +TRANSLATION: project.ts project_sub.ts +cd ../../subdirs_full +lupdate project.pro -ts project.ts diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project.ts.result new file mode 100644 index 0000000..7d9a6f4 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project.ts.result @@ -0,0 +1,20 @@ + + + + + subdir1 + + + minimal test + + + + + subsub1 + + + minimal test + + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.before b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.before new file mode 100644 index 0000000..e69de29 diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.result new file mode 100644 index 0000000..e69de29 diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/expectedoutput.txt new file mode 100644 index 0000000..e69de29 diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/lupdatecmd new file mode 100644 index 0000000..628acc0 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/lupdatecmd @@ -0,0 +1,2 @@ +cd ../../subdirs_full +lupdate subdir1/subdir1.pro subdir2/subsub1/subsub1.pro -ts project.ts diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/project.ts.result new file mode 100644 index 0000000..7d9a6f4 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/project.ts.result @@ -0,0 +1,20 @@ + + + + + subdir1 + + + minimal test + + + + + subsub1 + + + minimal test + + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/recurse_part/expectedoutput.txt new file mode 100644 index 0000000..808db18 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part/expectedoutput.txt @@ -0,0 +1 @@ +lupdate warning: no TS files specified\. Only diagnostics will be produced for 'project\.pro'\. diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/recurse_part/lupdatecmd new file mode 100644 index 0000000..3e15bc7 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part/lupdatecmd @@ -0,0 +1,2 @@ +TRANSLATION: project.ts project_sub.ts +cd ../../subdirs_part diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.before new file mode 100644 index 0000000..e69de29 diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.result new file mode 100644 index 0000000..e69de29 diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part/project_sub.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_part/project_sub.ts.result new file mode 100644 index 0000000..cddb963 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part/project_sub.ts.result @@ -0,0 +1,13 @@ + + + +ISO-8859-2 + + subsub2 + + + minimal test + + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/expectedoutput.txt new file mode 100644 index 0000000..b904390 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/expectedoutput.txt @@ -0,0 +1 @@ +lupdate warning: TS files from command line prevent recursing into .*/subdir2/subsub2/subsub2\.pro\. diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/lupdatecmd new file mode 100644 index 0000000..41bfcec --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/lupdatecmd @@ -0,0 +1,3 @@ +TRANSLATION: project.ts project_sub.ts +cd ../../subdirs_part +lupdate project.pro -ts project.ts diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project.ts.result new file mode 100644 index 0000000..7d9a6f4 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project.ts.result @@ -0,0 +1,20 @@ + + + + + subdir1 + + + minimal test + + + + + subsub1 + + + minimal test + + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.before b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.before new file mode 100644 index 0000000..e69de29 diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.result new file mode 100644 index 0000000..e69de29 diff --git a/tests/auto/linguist/lupdate/testdata/good/reloutput/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/reloutput/lupdatecmd index da6103f..90f609b 100644 --- a/tests/auto/linguist/lupdate/testdata/good/reloutput/lupdatecmd +++ b/tests/auto/linguist/lupdate/testdata/good/reloutput/lupdatecmd @@ -1,2 +1 @@ TRANSLATION: translations/project.ts -lupdate project.pro -ts translations/project.ts diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/project.pro b/tests/auto/linguist/lupdate/testdata/subdirs_full/project.pro new file mode 100644 index 0000000..1f744a7 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/project.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +SUBDIRS = subdir1 subdir2/subdir2.pro + +TRANSLATIONS = project.ts diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/main.cpp new file mode 100644 index 0000000..0f1dc70 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/main.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** +****************************************************************************/ + + +QString foo() +{ + QCoreApplication::translate("subdir1","minimal test"); +} diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/subdir1.pro b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/subdir1.pro new file mode 100644 index 0000000..28dcadc --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/subdir1.pro @@ -0,0 +1 @@ +SOURCES += main.cpp diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subdir2.pro b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subdir2.pro new file mode 100644 index 0000000..f8d03df --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subdir2.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = subsub1 subsub2 diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/main.cpp new file mode 100644 index 0000000..8c82c80 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/main.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** +****************************************************************************/ + + +QString foo() +{ + QCoreApplication::translate("subsub1","minimal test"); +} diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/subsub1.pro b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/subsub1.pro new file mode 100644 index 0000000..28dcadc --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/subsub1.pro @@ -0,0 +1 @@ +SOURCES += main.cpp diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/main.cpp new file mode 100644 index 0000000..ff85936 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/main.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** +****************************************************************************/ + + +QString foo() +{ + QCoreApplication::translate("subsub2","minimal test"); +} diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/subsub2.pro b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/subsub2.pro new file mode 100644 index 0000000..3499222 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/subsub2.pro @@ -0,0 +1,4 @@ +SOURCES += main.cpp + +TRANSLATIONS = ../../project_sub.ts +CODECFORTR = ISO-8859-2 diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/project.pro b/tests/auto/linguist/lupdate/testdata/subdirs_part/project.pro new file mode 100644 index 0000000..d803c37 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/project.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = subdir1 subdir2/subdir2.pro diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/main.cpp new file mode 100644 index 0000000..0f1dc70 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/main.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** +****************************************************************************/ + + +QString foo() +{ + QCoreApplication::translate("subdir1","minimal test"); +} diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/subdir1.pro b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/subdir1.pro new file mode 100644 index 0000000..28dcadc --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/subdir1.pro @@ -0,0 +1 @@ +SOURCES += main.cpp diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subdir2.pro b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subdir2.pro new file mode 100644 index 0000000..f8d03df --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subdir2.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = subsub1 subsub2 diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/main.cpp new file mode 100644 index 0000000..8c82c80 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/main.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** +****************************************************************************/ + + +QString foo() +{ + QCoreApplication::translate("subsub1","minimal test"); +} diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/subsub1.pro b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/subsub1.pro new file mode 100644 index 0000000..28dcadc --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/subsub1.pro @@ -0,0 +1 @@ +SOURCES += main.cpp diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/main.cpp new file mode 100644 index 0000000..ff85936 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/main.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** +****************************************************************************/ + + +QString foo() +{ + QCoreApplication::translate("subsub2","minimal test"); +} diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/subsub2.pro b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/subsub2.pro new file mode 100644 index 0000000..3499222 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/subsub2.pro @@ -0,0 +1,4 @@ +SOURCES += main.cpp + +TRANSLATIONS = ../../project_sub.ts +CODECFORTR = ISO-8859-2 diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index 44717bf..6d91aa3 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -117,14 +117,17 @@ static void printUsage() " -disable-heuristic {sametext|similartext|number}\n" " Disable the named merge heuristic. Can be specified multiple times.\n" " -pro \n" - " Name of a .pro file. Useful for files with .pro\n" - " file syntax but different file suffix\n" + " Name of a .pro file. Useful for files with .pro file syntax but\n" + " different file suffix. Projects are recursed into and merged.\n" " -source-language [_]\n" " Specify the language of the source strings for new files.\n" " Defaults to POSIX if not specified.\n" " -target-language [_]\n" " Specify the language of the translations for new files.\n" " Guessed from the file name if not specified.\n" + " -ts ...\n" + " Specify the output file(s). This will override the TRANSLATIONS\n" + " and nullify the CODECFORTR from possibly specified project files.\n" " -version\n" " Display the version of lupdate and exit.\n" ).arg(m_defaultExtensions)); @@ -249,16 +252,151 @@ static QStringList getSources(const ProFileEvaluator &visitor, const QString &pr return sourceFiles; } +static void processSources(Translator &fetchedTor, + const QStringList &sourceFiles, ConversionData &cd) +{ + QStringList sourceFilesCpp; + for (QStringList::const_iterator it = sourceFiles.begin(); it != sourceFiles.end(); ++it) { + if (it->endsWith(QLatin1String(".java"), Qt::CaseInsensitive)) + loadJava(fetchedTor, *it, cd); + else if (it->endsWith(QLatin1String(".ui"), Qt::CaseInsensitive) + || it->endsWith(QLatin1String(".jui"), Qt::CaseInsensitive)) + loadUI(fetchedTor, *it, cd); + else if (it->endsWith(QLatin1String(".js"), Qt::CaseInsensitive) + || it->endsWith(QLatin1String(".qs"), Qt::CaseInsensitive)) + loadQScript(fetchedTor, *it, cd); + else + sourceFilesCpp << *it; + } + loadCPP(fetchedTor, sourceFilesCpp, cd); + if (!cd.error().isEmpty()) + printOut(cd.error()); +} + +static void processProjects( + bool topLevel, bool nestComplain, const QStringList &proFiles, + UpdateOptions options, const QByteArray &codecForSource, + const QString &targetLanguage, const QString &sourceLanguage, + Translator *parentTor, bool *fail); + +static void processProject( + bool nestComplain, const QFileInfo &pfi, ProFileEvaluator &visitor, + UpdateOptions options, const QByteArray &_codecForSource, + const QString &targetLanguage, const QString &sourceLanguage, + Translator *fetchedTor, bool *fail) +{ + QByteArray codecForSource = _codecForSource; + QStringList tmp = visitor.values(QLatin1String("CODECFORSRC")); + if (!tmp.isEmpty()) { + codecForSource = tmp.last().toLatin1(); + if (!QTextCodec::codecForName(codecForSource)) { + qWarning("lupdate warning: Codec for source '%s' is invalid. " + "Falling back to codec for tr().", codecForSource.constData()); + codecForSource.clear(); + } + } + if (visitor.templateType() == ProFileEvaluator::TT_Subdirs) { + QStringList subProFiles; + QDir proDir(pfi.absoluteDir()); + foreach (const QString &subdir, visitor.values(QLatin1String("SUBDIRS"))) { + QString subPro = QDir::cleanPath(proDir.absoluteFilePath(subdir)); + QFileInfo subInfo(subPro); + if (subInfo.isDir()) + subProFiles << (subPro + QLatin1Char('/') + + subInfo.fileName() + QLatin1String(".pro")); + else + subProFiles << subPro; + } + processProjects(false, nestComplain, subProFiles, options, codecForSource, + targetLanguage, sourceLanguage, fetchedTor, fail); + } else { + ConversionData cd; + cd.m_noUiLines = options & NoUiLines; + cd.m_codecForSource = codecForSource; + cd.m_includePath = visitor.values(QLatin1String("INCLUDEPATH")); + QStringList sourceFiles = getSources(visitor, pfi.absolutePath()); + QSet projectRoots; + projectRoots.insert(QDir::cleanPath(pfi.absolutePath()) + QLatin1Char('/')); + cd.m_projectRoots = projectRoots; + processSources(*fetchedTor, sourceFiles, cd); + } +} + +static void processProjects( + bool topLevel, bool nestComplain, const QStringList &proFiles, + UpdateOptions options, const QByteArray &codecForSource, + const QString &targetLanguage, const QString &sourceLanguage, + Translator *parentTor, bool *fail) +{ + foreach (const QString &proFile, proFiles) { + ProFileEvaluator visitor; + visitor.setVerbose(options & Verbose); + + QFileInfo pfi(proFile); + ProFile pro(pfi.absoluteFilePath()); + if (!visitor.queryProFile(&pro) || !visitor.accept(&pro)) { + if (topLevel) + *fail = true; + continue; + } + + if (visitor.contains(QLatin1String("TRANSLATIONS"))) { + if (parentTor) { + if (topLevel) { + std::cerr << "lupdate warning: TS files from command line " + "will override TRANSLATIONS in " << qPrintable(proFile) << ".\n"; + goto noTrans; + } else if (nestComplain) { + std::cerr << "lupdate warning: TS files from command line " + "prevent recursing into " << qPrintable(proFile) << ".\n"; + continue; + } + } + QStringList tsFiles; + QDir proDir(pfi.absolutePath()); + foreach (const QString &tsFile, visitor.values(QLatin1String("TRANSLATIONS"))) + tsFiles << QFileInfo(proDir, tsFile).filePath(); + if (tsFiles.isEmpty()) { + // This might mean either a buggy PRO file or an intentional detach - + // we can't know without seeing the actual RHS of the assignment ... + // Just assume correctness and be silent. + continue; + } + Translator tor; + QByteArray codecForTr; + QStringList tmp = visitor.values(QLatin1String("CODEC")) + + visitor.values(QLatin1String("DEFAULTCODEC")) + + visitor.values(QLatin1String("CODECFORTR")); + if (!tmp.isEmpty()) { + codecForTr = tmp.last().toLatin1(); + tor.setCodecName(codecForTr); + } + processProject(false, pfi, visitor, options, codecForSource, + targetLanguage, sourceLanguage, &tor, fail); + updateTsFiles(tor, tsFiles, codecForTr, sourceLanguage, targetLanguage, options, fail); + continue; + } + noTrans: + if (!parentTor) { + if (topLevel) + std::cerr << "lupdate warning: no TS files specified. Only diagnostics " + "will be produced for '" << qPrintable(proFile) << "'.\n"; + Translator tor; + processProject(nestComplain, pfi, visitor, options, codecForSource, + targetLanguage, sourceLanguage, &tor, fail); + } else { + processProject(nestComplain, pfi, visitor, options, codecForSource, + targetLanguage, sourceLanguage, parentTor, fail); + } + } +} + int main(int argc, char **argv) { QCoreApplication app(argc, argv); m_defaultExtensions = QLatin1String("ui,c,c++,cc,cpp,cxx,ch,h,h++,hh,hpp,hxx"); QStringList args = app.arguments(); - QString defaultContext; // This was QLatin1String("@default") before. - Translator fetchedTor; - QByteArray codecForTr; - QByteArray codecForSource; QStringList tsFileNames; QStringList proFiles; QMultiHash allCSources; @@ -402,9 +540,6 @@ int main(int argc, char **argv) return 1; } - codecForTr.clear(); - codecForSource.clear(); - if (metTsFlag) { bool found = false; foreach (const Translator::FileFormat &fmt, Translator::registeredFileFormats()) { @@ -477,106 +612,45 @@ int main(int argc, char **argv) } } // for args - if (!proFiles.isEmpty() && !sourceFiles.isEmpty()) { - qWarning("lupdate error: Both project and source files specified.\n"); - return 1; - } if (numFiles == 0) { printUsage(); return 1; } - foreach (const QString &proFile, proFiles) - projectRoots.insert(QDir::cleanPath(QFileInfo(proFile).absolutePath()) + QLatin1Char('/')); + if (!targetLanguage.isEmpty() && tsFileNames.count() != 1) + std::cerr << "lupdate warning: -target-language usually only " + "makes sense with exactly one TS file.\n"; - bool firstPass = true; bool fail = false; - while (firstPass || !proFiles.isEmpty()) { + if (proFiles.isEmpty()) { + if (tsFileNames.isEmpty()) + std::cerr << "lupdate warning: no TS files specified. " + "Only diagnostics will be produced.\n"; + + Translator fetchedTor; ConversionData cd; - cd.m_defaultContext = defaultContext; cd.m_noUiLines = options & NoUiLines; cd.m_projectRoots = projectRoots; cd.m_includePath = includePath; cd.m_allCSources = allCSources; - - QStringList tsFiles = tsFileNames; - if (proFiles.count() > 0) { - QFileInfo pfi(proFiles.takeFirst()); - - ProFileEvaluator visitor; - visitor.setVerbose(options & Verbose); - - ProFile pro(pfi.absoluteFilePath()); - if (!visitor.queryProFile(&pro)) - return 2; - if (!visitor.accept(&pro)) - return 2; - - if (visitor.templateType() == ProFileEvaluator::TT_Subdirs) { - QDir proDir(pfi.absoluteDir()); - foreach (const QString &subdir, visitor.values(QLatin1String("SUBDIRS"))) { - QString subPro = QDir::cleanPath(proDir.absoluteFilePath(subdir)); - QFileInfo subInfo(subPro); - if (subInfo.isDir()) - proFiles << (subPro + QLatin1Char('/') - + subInfo.fileName() + QLatin1String(".pro")); - else - proFiles << subPro; - } - continue; - } - - cd.m_includePath += visitor.values(QLatin1String("INCLUDEPATH")); - - sourceFiles = getSources(visitor, pfi.absolutePath()); - - QStringList tmp = visitor.values(QLatin1String("CODEC")) - + visitor.values(QLatin1String("DEFAULTCODEC")) - + visitor.values(QLatin1String("CODECFORTR")); - if (!tmp.isEmpty()) { - codecForTr = tmp.last().toLatin1(); - fetchedTor.setCodecName(codecForTr); - cd.m_outputCodec = codecForTr; - } - tmp = visitor.values(QLatin1String("CODECFORSRC")); - if (!tmp.isEmpty()) { - codecForSource = tmp.last().toLatin1(); - if (!QTextCodec::codecForName(codecForSource)) - qWarning("lupdate warning: Codec for source '%s' is invalid. Falling back to codec for tr().", - codecForSource.constData()); - else - cd.m_codecForSource = codecForSource; - } - - QDir proDir(pfi.absolutePath()); - foreach (const QString &tsFile, visitor.values(QLatin1String("TRANSLATIONS"))) - tsFiles << QFileInfo(proDir, tsFile).filePath(); + processSources(fetchedTor, sourceFiles, cd); + updateTsFiles(fetchedTor, tsFileNames, QByteArray(), + sourceLanguage, targetLanguage, options, &fail); + } else { + if (!sourceFiles.isEmpty() || !includePath.isEmpty()) { + qWarning("lupdate error: Both project and source files / include paths specified.\n"); + return 1; } - - QStringList sourceFilesCpp; - for (QStringList::iterator it = sourceFiles.begin(); it != sourceFiles.end(); ++it) { - if (it->endsWith(QLatin1String(".java"), Qt::CaseInsensitive)) - loadJava(fetchedTor, *it, cd); - else if (it->endsWith(QLatin1String(".ui"), Qt::CaseInsensitive) - || it->endsWith(QLatin1String(".jui"), Qt::CaseInsensitive)) - loadUI(fetchedTor, *it, cd); - else if (it->endsWith(QLatin1String(".js"), Qt::CaseInsensitive) - || it->endsWith(QLatin1String(".qs"), Qt::CaseInsensitive)) - loadQScript(fetchedTor, *it, cd); - else - sourceFilesCpp << *it; + if (!tsFileNames.isEmpty()) { + Translator fetchedTor; + processProjects(true, true, proFiles, options, QByteArray(), + targetLanguage, sourceLanguage, &fetchedTor, &fail); + updateTsFiles(fetchedTor, tsFileNames, QByteArray(), + sourceLanguage, targetLanguage, options, &fail); + } else { + processProjects(true, false, proFiles, options, QByteArray(), + targetLanguage, sourceLanguage, 0, &fail); } - loadCPP(fetchedTor, sourceFilesCpp, cd); - if (!cd.error().isEmpty()) - printOut(cd.error()); - - tsFiles.removeDuplicates(); - - if (!tsFiles.isEmpty()) - updateTsFiles(fetchedTor, tsFiles, codecForTr, sourceLanguage, targetLanguage, options, &fail); - - firstPass = false; } - return fail ? 1 : 0; } -- cgit v0.12 From 2a8fd7584590016dbe22fb74f440e71a2578dc81 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 27 Jan 2010 16:02:38 +0100 Subject: add -codecfortr option this has always been kind of an omission ... --- tools/linguist/lupdate/main.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index 6d91aa3..fd9c696 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -128,6 +128,8 @@ static void printUsage() " -ts ...\n" " Specify the output file(s). This will override the TRANSLATIONS\n" " and nullify the CODECFORTR from possibly specified project files.\n" + " -codecfortr \n" + " Specify the codec assumed for tr() calls. Effective only with -ts.\n" " -version\n" " Display the version of lupdate and exit.\n" ).arg(m_defaultExtensions)); @@ -405,6 +407,7 @@ int main(int argc, char **argv) QStringList includePath; QString targetLanguage; QString sourceLanguage; + QByteArray codecForTr; UpdateOptions options = Verbose | // verbose is on by default starting with Qt 4.2 @@ -503,6 +506,14 @@ int main(int argc, char **argv) } else if (arg == QLatin1String("-version")) { printOut(QObject::tr("lupdate version %1\n").arg(QLatin1String(QT_VERSION_STR))); return 0; + } else if (arg == QLatin1String("-codecfortr")) { + ++i; + if (i == argc) { + qWarning("The -codecfortr option should be followed by a codec name."); + return 1; + } + codecForTr = args[i].toLatin1(); + continue; } else if (arg == QLatin1String("-ts")) { metTsFlag = true; continue; @@ -620,6 +631,8 @@ int main(int argc, char **argv) if (!targetLanguage.isEmpty() && tsFileNames.count() != 1) std::cerr << "lupdate warning: -target-language usually only " "makes sense with exactly one TS file.\n"; + if (!codecForTr.isEmpty() && tsFileNames.isEmpty()) + std::cerr << "lupdate warning: -codecfortr has no effect without -ts.\n"; bool fail = false; if (proFiles.isEmpty()) { @@ -633,8 +646,9 @@ int main(int argc, char **argv) cd.m_projectRoots = projectRoots; cd.m_includePath = includePath; cd.m_allCSources = allCSources; + fetchedTor.setCodecName(codecForTr); processSources(fetchedTor, sourceFiles, cd); - updateTsFiles(fetchedTor, tsFileNames, QByteArray(), + updateTsFiles(fetchedTor, tsFileNames, codecForTr, sourceLanguage, targetLanguage, options, &fail); } else { if (!sourceFiles.isEmpty() || !includePath.isEmpty()) { @@ -643,9 +657,10 @@ int main(int argc, char **argv) } if (!tsFileNames.isEmpty()) { Translator fetchedTor; + fetchedTor.setCodecName(codecForTr); processProjects(true, true, proFiles, options, QByteArray(), targetLanguage, sourceLanguage, &fetchedTor, &fail); - updateTsFiles(fetchedTor, tsFileNames, QByteArray(), + updateTsFiles(fetchedTor, tsFileNames, codecForTr, sourceLanguage, targetLanguage, options, &fail); } else { processProjects(true, false, proFiles, options, QByteArray(), -- cgit v0.12 From 3a49c547d13e07fdb0659ffffcc2d980a5657214 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 21 Jan 2010 07:57:25 +0100 Subject: Fix how we select antialiasing method for text under Mac OS X Reviewed-by: Eskil --- src/gui/kernel/qapplication_mac.mm | 46 +++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index 847c58d..e8b821af 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -227,12 +227,29 @@ void onApplicationChangedActivation( bool activated ); static void qt_mac_read_fontsmoothing_settings() { -#ifdef QT_MAC_USE_COCOA - QMacCocoaAutoReleasePool pool2; -#endif - - NSInteger appleFontSmoothing = [[NSUserDefaults standardUserDefaults] integerForKey:@"AppleFontSmoothing"]; - qt_applefontsmoothing_enabled = (appleFontSmoothing > 0); + qt_applefontsmoothing_enabled = true; + int w = 10, h = 10; + QImage image(w, h, QImage::Format_RGB32); + image.fill(0xffffffff); + QPainter p(&image); + p.drawText(0, h, "X\\"); + p.end(); + + const int *bits = (const int *) ((const QImage &) image).bits(); + int bpl = image.bytesPerLine() / 4; + for (int y=0; ylastUpdateWidget = widget; } else if (it->lastUpdateWidget == widget) { - // Update the gl wigets that the widget intersected the last time around, - // and that we are not intersecting now. This prevents paint errors when the + // Update the gl wigets that the widget intersected the last time around, + // and that we are not intersecting now. This prevents paint errors when the // intersecting widget leaves a gl widget. qt_post_window_change_event(glWidget); - it->lastUpdateWidget = 0; + it->lastUpdateWidget = 0; } } #else @@ -812,8 +829,8 @@ Q_GUI_EXPORT void qt_event_request_window_change(QWidget *widget) // Post a kEventQtRequestWindowChange event. This event is semi-public, // don't remove this line! qt_event_request_window_change(); - - // Post update request on gl widgets unconditionally. + + // Post update request on gl widgets unconditionally. if (qt_widget_private(widget)->isGLWidget == true) { qt_post_window_change_event(widget); return; @@ -1218,8 +1235,6 @@ void qt_init(QApplicationPrivate *priv, int) if (QApplication::desktopSettingsAware()) QApplicationPrivate::qt_mac_apply_settings(); - qt_mac_read_fontsmoothing_settings(); - // Cocoa application delegate #ifdef QT_MAC_USE_COCOA NSApplication *cocoaApp = [NSApplication sharedApplication]; @@ -1257,6 +1272,7 @@ void qt_init(QApplicationPrivate *priv, int) } priv->native_modal_dialog_active = false; + qt_mac_read_fontsmoothing_settings(); } void qt_release_apple_event_handler() @@ -1709,7 +1725,7 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event // kEventMouseWheelMoved events if we dont eat this event // (actually two events; one for horizontal and one for vertical). // As a results of this, and to make sure we dont't receive duplicate events, - // we try to detect when this happend by checking the 'compatibilityEvent'. + // we try to detect when this happend by checking the 'compatibilityEvent'. SInt32 mdelt = 0; GetEventParameter(event, kEventParamMouseWheelSmoothHorizontalDelta, typeSInt32, 0, sizeof(mdelt), 0, &mdelt); @@ -2580,7 +2596,7 @@ void QApplicationPrivate::closePopup(QWidget *popup) if (QApplicationPrivate::popupWidgets->isEmpty()) { // this was the last popup delete QApplicationPrivate::popupWidgets; QApplicationPrivate::popupWidgets = 0; - + // Special case for Tool windows: since they are activated and deactived together // with a normal window they never become the QApplicationPrivate::active_window. QWidget *appFocusWidget = QApplication::focusWidget(); -- cgit v0.12 From d77cb228d7f693043970bdc247447fc5a61cbffc Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 21 Jan 2010 08:49:12 +0100 Subject: Don't use a mutex lock in QPainter::redirection unless strictly required --- src/gui/painting/qpainter.cpp | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 31132d9..1258d6b 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7382,10 +7382,15 @@ struct QPaintDeviceRedirection typedef QList QPaintDeviceRedirectionList; Q_GLOBAL_STATIC(QPaintDeviceRedirectionList, globalRedirections) Q_GLOBAL_STATIC(QMutex, globalRedirectionsMutex) +Q_GLOBAL_STATIC(QAtomicInt, globalRedirectionAtomic) /*! \threadsafe + \obsolete + + Please use QWidget::render() instead. + Redirects all paint commands for the given paint \a device, to the \a replacement device. The optional point \a offset defines an offset within the source device. @@ -7395,9 +7400,10 @@ Q_GLOBAL_STATIC(QMutex, globalRedirectionsMutex) device's painter (if any) before redirecting. Call restoreRedirected() to restore the previous redirection. - In general, you'll probably find that calling - QPixmap::grabWidget() or QPixmap::grabWindow() is an easier - solution. + \warning Making use of redirections in the QPainter API implies + that QPainter::begin() and QPaintDevice destructors need to hold + a mutex for a short period. This can impact performance. Use of + QWidget::render is strongly encouraged. \sa redirected(), restoreRedirected() */ @@ -7429,14 +7435,24 @@ void QPainter::setRedirected(const QPaintDevice *device, Q_ASSERT(redirections != 0); *redirections += QPaintDeviceRedirection(device, rdev ? rdev : replacement, offset + roffset, hadInternalWidgetRedirection ? redirections->size() - 1 : -1); + globalRedirectionAtomic()->ref(); } /*! \threadsafe + \obsolete + + Using QWidget::render() obsoletes the use of this function. + Restores the previous redirection for the given \a device after a call to setRedirected(). + \warning Making use of redirections in the QPainter API implies + that QPainter::begin() and QPaintDevice destructors need to hold + a mutex for a short period. This can impact performance. Use of + QWidget::render is strongly encouraged. + \sa redirected() */ void QPainter::restoreRedirected(const QPaintDevice *device) @@ -7447,6 +7463,7 @@ void QPainter::restoreRedirected(const QPaintDevice *device) Q_ASSERT(redirections != 0); for (int i = redirections->size()-1; i >= 0; --i) { if (redirections->at(i) == device) { + globalRedirectionAtomic()->deref(); const int internalWidgetRedirectionIndex = redirections->at(i).internalWidgetRedirectionIndex; redirections->removeAt(i); // Restore the internal widget redirection, i.e. remove it from the global @@ -7468,21 +7485,34 @@ void QPainter::restoreRedirected(const QPaintDevice *device) /*! \threadsafe + \obsolete + + Using QWidget::render() obsoletes the use of this function. + Returns the replacement for given \a device. The optional out parameter \a offset returns the offset within the replaced device. + \warning Making use of redirections in the QPainter API implies + that QPainter::begin() and QPaintDevice destructors need to hold + a mutex for a short period. This can impact performance. Use of + QWidget::render is strongly encouraged. + \sa setRedirected(), restoreRedirected() */ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset) { Q_ASSERT(device != 0); + if (*globalRedirectionAtomic() == 0) + return 0; + if (device->devType() == QInternal::Widget) { const QWidgetPrivate *widgetPrivate = static_cast(device)->d_func(); if (widgetPrivate->redirectDev) return widgetPrivate->redirected(offset); } + QMutexLocker locker(globalRedirectionsMutex()); QPaintDeviceRedirectionList *redirections = globalRedirections(); Q_ASSERT(redirections != 0); @@ -7500,6 +7530,9 @@ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset) void qt_painter_removePaintDevice(QPaintDevice *dev) { + if (*globalRedirectionAtomic() == 0) + return; + QMutex *mutex = 0; QT_TRY { mutex = globalRedirectionsMutex(); -- cgit v0.12 From 9dc8d0eeaaae09a86eb869b79f76ad7c66b6f563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Thu, 21 Jan 2010 10:32:14 +0100 Subject: Doc fixes: Remove some lies from QEasingCurve. Task-number: QTBUG-7418 --- src/corelib/tools/qeasingcurve.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp index 0ef92d9..b6a2df4 100644 --- a/src/corelib/tools/qeasingcurve.cpp +++ b/src/corelib/tools/qeasingcurve.cpp @@ -125,7 +125,7 @@ \value OutCubic \inlineimage qeasingcurve-outcubic.png \br Easing curve for a cubic (t^3) function: - decelerating from zero velocity. + decelerating to zero velocity. \value InOutCubic \inlineimage qeasingcurve-inoutcubic.png \br Easing curve for a cubic (t^3) function: @@ -141,7 +141,7 @@ \value OutQuart \inlineimage qeasingcurve-outquart.png \br Easing curve for a cubic (t^4) function: - decelerating from zero velocity. + decelerating to zero velocity. \value InOutQuart \inlineimage qeasingcurve-inoutquart.png \br Easing curve for a cubic (t^4) function: @@ -157,7 +157,7 @@ \value OutQuint \inlineimage qeasingcurve-outquint.png \br Easing curve for a cubic (t^5) function: - decelerating from zero velocity. + decelerating to zero velocity. \value InOutQuint \inlineimage qeasingcurve-inoutquint.png \br Easing curve for a cubic (t^5) function: -- cgit v0.12 From 8315b169f152c81bbad88c1c093283c00b94f43f Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 20 Jan 2010 08:59:48 +0100 Subject: Remove unnecessary depth uniform from GL2 engine's GLSL Reviewed-By: Samuel --- src/opengl/gl2paintengineex/qglengineshadersource_p.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index d9a61e9..6e98b02 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -64,23 +64,19 @@ QT_MODULE(OpenGL) static const char* const qglslMainVertexShader = "\ - uniform highp float depth;\ void setPosition();\ void main(void)\ {\ setPosition();\ - gl_Position.z = depth * gl_Position.w;\ }"; static const char* const qglslMainWithTexCoordsVertexShader = "\ attribute highp vec2 textureCoordArray; \ varying highp vec2 textureCoords; \ - uniform highp float depth;\ void setPosition();\ void main(void) \ {\ setPosition();\ - gl_Position.z = depth * gl_Position.w;\ textureCoords = textureCoordArray; \ }"; @@ -89,12 +85,10 @@ static const char* const qglslMainWithTexCoordsAndOpacityVertexShader = "\ attribute lowp float opacityArray; \ varying highp vec2 textureCoords; \ varying lowp float opacity; \ - uniform highp float depth; \ void setPosition(); \ void main(void) \ { \ setPosition(); \ - gl_Position.z = depth * gl_Position.w; \ textureCoords = textureCoordArray; \ opacity = opacityArray; \ }"; -- cgit v0.12 From 94e9dba9289f129598a92f817f835b0205188c6c Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 20 Jan 2010 10:18:32 +0100 Subject: Use an attribute value for the PMV matrix rather than a uniform This has several advantages: First, updating an attribute value seems to be cheaper than updating a uniform. Second, vertex atribute values are independent of shader program, which means they persist across changing of the shader program. This makes code simpler and reduces GL state changes. Note: Credit goes to Samuel for finding this little gem. :-) For the 25920 solid QGraphicsRectItem test case, this gives 10% improvement on desktop and 27% on the SGX. Reviewed-By: Kim --- .../gl2paintengineex/qglengineshadermanager.cpp | 7 ++++- .../gl2paintengineex/qglengineshadermanager_p.h | 5 +++- .../gl2paintengineex/qglengineshadersource_p.h | 34 +++++++++++++++++----- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 25 ++++------------ .../gl2paintengineex/qpaintengineex_opengl2_p.h | 2 -- 5 files changed, 42 insertions(+), 31 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 556b888..9fd9e18 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -324,6 +324,11 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS newProg->program->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR); if (newProg->useOpacityAttribute) newProg->program->bindAttributeLocation("opacityArray", QT_OPACITY_ATTR); + if (newProg->usePmvMatrix) { + newProg->program->bindAttributeLocation("pmvMatrix1", QT_PMV_MATRIX_1_ATTR); + newProg->program->bindAttributeLocation("pmvMatrix2", QT_PMV_MATRIX_2_ATTR); + newProg->program->bindAttributeLocation("pmvMatrix3", QT_PMV_MATRIX_3_ATTR); + } newProg->program->link(); if (!newProg->program->isLinked()) { @@ -424,7 +429,6 @@ GLuint QGLEngineShaderManager::getUniformLocation(Uniform id) "patternColor", "globalOpacity", "depth", - "pmvMatrix", "maskTexture", "fragmentColor", "linearData", @@ -743,6 +747,7 @@ bool QGLEngineShaderManager::useCorrectShaderProg() } requiredProgram.useTextureCoords = texCoords; requiredProgram.useOpacityAttribute = (opacityMode == AttributeOpacity); + requiredProgram.usePmvMatrix = true; // At this point, requiredProgram is fully populated so try to find the program in the cache currentShaderProg = sharedShaders->findProgramInCache(requiredProgram); diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index c52e5c0..3ab4ebe 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -253,6 +253,9 @@ struct QGLEngineCachedShaderProg static const GLuint QT_VERTEX_COORDS_ATTR = 0; static const GLuint QT_TEXTURE_COORDS_ATTR = 1; static const GLuint QT_OPACITY_ATTR = 2; +static const GLuint QT_PMV_MATRIX_1_ATTR = 3; +static const GLuint QT_PMV_MATRIX_2_ATTR = 4; +static const GLuint QT_PMV_MATRIX_3_ATTR = 5; class QGLEngineShaderProg; @@ -397,6 +400,7 @@ public: bool useTextureCoords; bool useOpacityAttribute; + bool usePmvMatrix; bool operator==(const QGLEngineShaderProg& other) { // We don't care about the program @@ -431,7 +435,6 @@ public: PatternColor, GlobalOpacity, Depth, - PmvMatrix, MaskTexture, FragmentColor, LinearData, diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index 6e98b02..b471b81 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -97,9 +97,12 @@ static const char* const qglslMainWithTexCoordsAndOpacityVertexShader = "\ // shader are also perspective corrected. static const char* const qglslPositionOnlyVertexShader = "\ attribute highp vec2 vertexCoordsArray;\ - uniform highp mat3 pmvMatrix;\ + attribute highp vec3 pmvMatrix1; \ + attribute highp vec3 pmvMatrix2; \ + attribute highp vec3 pmvMatrix3; \ void setPosition(void)\ {\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ gl_Position = vec4(transformedPos.xy, 0.0, transformedPos.z); \ }"; @@ -114,12 +117,15 @@ static const char* const qglslUntransformedPositionVertexShader = "\ // Pattern Brush - This assumes the texture size is 8x8 and thus, the inverted size is 0.125 static const char* const qglslPositionWithPatternBrushVertexShader = "\ attribute highp vec2 vertexCoordsArray; \ - uniform highp mat3 pmvMatrix; \ + attribute highp vec3 pmvMatrix1; \ + attribute highp vec3 pmvMatrix2; \ + attribute highp vec3 pmvMatrix3; \ uniform mediump vec2 halfViewportSize; \ uniform highp vec2 invertedTextureSize; \ uniform highp mat3 brushTransform; \ varying highp vec2 patternTexCoords; \ void setPosition(void) { \ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ gl_Position.xy = transformedPos.xy / transformedPos.z; \ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ @@ -144,12 +150,15 @@ static const char* const qglslPatternBrushSrcFragmentShader = "\ // Linear Gradient Brush static const char* const qglslPositionWithLinearGradientBrushVertexShader = "\ attribute highp vec2 vertexCoordsArray; \ - uniform highp mat3 pmvMatrix; \ + attribute highp vec3 pmvMatrix1; \ + attribute highp vec3 pmvMatrix2; \ + attribute highp vec3 pmvMatrix3; \ uniform mediump vec2 halfViewportSize; \ uniform highp vec3 linearData; \ uniform highp mat3 brushTransform; \ varying mediump float index; \ void setPosition() { \ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ gl_Position.xy = transformedPos.xy / transformedPos.z; \ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ @@ -174,12 +183,15 @@ static const char* const qglslLinearGradientBrushSrcFragmentShader = "\ // Conical Gradient Brush static const char* const qglslPositionWithConicalGradientBrushVertexShader = "\ attribute highp vec2 vertexCoordsArray;\ - uniform highp mat3 pmvMatrix;\ + attribute highp vec3 pmvMatrix1; \ + attribute highp vec3 pmvMatrix2; \ + attribute highp vec3 pmvMatrix3; \ uniform mediump vec2 halfViewportSize; \ uniform highp mat3 brushTransform; \ varying highp vec2 A; \ - void setPosition(void)\ - {\ + void setPosition(void) \ + { \ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ gl_Position.xy = transformedPos.xy / transformedPos.z; \ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ @@ -210,7 +222,9 @@ static const char* const qglslConicalGradientBrushSrcFragmentShader = "\n\ // Radial Gradient Brush static const char* const qglslPositionWithRadialGradientBrushVertexShader = "\ attribute highp vec2 vertexCoordsArray;\ - uniform highp mat3 pmvMatrix;\ + attribute highp vec3 pmvMatrix1; \ + attribute highp vec3 pmvMatrix2; \ + attribute highp vec3 pmvMatrix3; \ uniform mediump vec2 halfViewportSize; \ uniform highp mat3 brushTransform; \ uniform highp vec2 fmp; \ @@ -218,6 +232,7 @@ static const char* const qglslPositionWithRadialGradientBrushVertexShader = "\ varying highp vec2 A; \ void setPosition(void) \ {\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ gl_Position.xy = transformedPos.xy / transformedPos.z; \ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ @@ -247,12 +262,15 @@ static const char* const qglslRadialGradientBrushSrcFragmentShader = "\ // Texture Brush static const char* const qglslPositionWithTextureBrushVertexShader = "\ attribute highp vec2 vertexCoordsArray; \ - uniform highp mat3 pmvMatrix; \ + attribute highp vec3 pmvMatrix1; \ + attribute highp vec3 pmvMatrix2; \ + attribute highp vec3 pmvMatrix3; \ uniform mediump vec2 halfViewportSize; \ uniform highp vec2 invertedTextureSize; \ uniform highp mat3 brushTransform; \ varying highp vec2 textureCoords; \ void setPosition(void) { \ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ gl_Position.xy = transformedPos.xy / transformedPos.z; \ mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index caa679b..b282676 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -168,12 +168,6 @@ void QGL2PaintEngineExPrivate::useSimpleShader() if (matrixDirty) updateMatrix(); - - if (simpleShaderMatrixUniformDirty) { - const GLuint location = shaderManager->simpleProgram()->uniformLocation("pmvMatrix"); - glUniformMatrix3fv(location, 1, GL_FALSE, (GLfloat*)pmvMatrix); - simpleShaderMatrixUniformDirty = false; - } } void QGL2PaintEngineExPrivate::updateBrushTexture() @@ -392,9 +386,11 @@ void QGL2PaintEngineExPrivate::updateMatrix() matrixDirty = false; - // The actual data has been updated so both shader program's uniforms need updating - simpleShaderMatrixUniformDirty = true; - shaderMatrixUniformDirty = true; + // Set the PMV matrix attribute. As we use an attributes rather than uniforms, we only + // need to do this once for every matrix change and persists across all shader programs. + glVertexAttrib3fv(QT_PMV_MATRIX_1_ATTR, pmvMatrix[0]); + glVertexAttrib3fv(QT_PMV_MATRIX_2_ATTR, pmvMatrix[1]); + glVertexAttrib3fv(QT_PMV_MATRIX_3_ATTR, pmvMatrix[2]); dasher.setInvScale(inverseScale); stroker.setInvScale(inverseScale); @@ -932,18 +928,12 @@ bool QGL2PaintEngineExPrivate::prepareForDraw(bool srcPixelsAreOpaque) if (changed) { // The shader program has changed so mark all uniforms as dirty: brushUniformsDirty = true; - shaderMatrixUniformDirty = true; opacityUniformDirty = true; } if (brushUniformsDirty && mode != ImageDrawingMode && mode != ImageArrayDrawingMode) updateBrushUniforms(); - if (shaderMatrixUniformDirty) { - glUniformMatrix3fv(location(QGLEngineShaderManager::PmvMatrix), 1, GL_FALSE, (GLfloat*)pmvMatrix); - shaderMatrixUniformDirty = false; - } - if (opacityMode == QGLEngineShaderManager::UniformOpacity && opacityUniformDirty) { shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::GlobalOpacity), (GLfloat)q->state()->opacity); opacityUniformDirty = false; @@ -1955,11 +1945,8 @@ void QGL2PaintEngineEx::setState(QPainterState *new_state) if (old_state == s || old_state->renderHintsChanged) renderHintsChanged(); - if (old_state == s || old_state->matrixChanged) { + if (old_state == s || old_state->matrixChanged) d->matrixDirty = true; - d->simpleShaderMatrixUniformDirty = true; - d->shaderMatrixUniformDirty = true; - } if (old_state == s || old_state->compositionModeChanged) d->compositionModeDirty = true; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index ce1b538..8fa0eff 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -252,8 +252,6 @@ public: bool compositionModeDirty; bool brushTextureDirty; bool brushUniformsDirty; - bool simpleShaderMatrixUniformDirty; - bool shaderMatrixUniformDirty; bool opacityUniformDirty; bool stencilClean; // Has the stencil not been used for clipping so far? -- cgit v0.12 From e001ce29fa3aece2c8eb312be68a33560184c9be Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 20 Jan 2010 12:47:18 +0100 Subject: Purely cosmetic (formatting) changes to GL2 engine's GLSL This makes GLSL dumps _significantly_ easier to read. Reviewed-By: TrustMe --- .../gl2paintengineex/qglengineshadersource_p.h | 690 +++++++++++---------- 1 file changed, 357 insertions(+), 333 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadersource_p.h b/src/opengl/gl2paintengineex/qglengineshadersource_p.h index b471b81..ee04166 100644 --- a/src/opengl/gl2paintengineex/qglengineshadersource_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadersource_p.h @@ -63,222 +63,229 @@ QT_BEGIN_NAMESPACE QT_MODULE(OpenGL) -static const char* const qglslMainVertexShader = "\ - void setPosition();\ - void main(void)\ - {\ - setPosition();\ - }"; - -static const char* const qglslMainWithTexCoordsVertexShader = "\ - attribute highp vec2 textureCoordArray; \ - varying highp vec2 textureCoords; \ - void setPosition();\ - void main(void) \ - {\ - setPosition();\ - textureCoords = textureCoordArray; \ - }"; - -static const char* const qglslMainWithTexCoordsAndOpacityVertexShader = "\ - attribute highp vec2 textureCoordArray; \ - attribute lowp float opacityArray; \ - varying highp vec2 textureCoords; \ - varying lowp float opacity; \ - void setPosition(); \ - void main(void) \ - { \ - setPosition(); \ - textureCoords = textureCoordArray; \ - opacity = opacityArray; \ - }"; +static const char* const qglslMainVertexShader = "\n\ + void setPosition(); \n\ + void main(void) \n\ + { \n\ + setPosition(); \n\ + }\n"; + +static const char* const qglslMainWithTexCoordsVertexShader = "\n\ + attribute highp vec2 textureCoordArray; \n\ + varying highp vec2 textureCoords; \n\ + void setPosition(); \n\ + void main(void) \n\ + { \n\ + setPosition(); \n\ + textureCoords = textureCoordArray; \n\ + }\n"; + +static const char* const qglslMainWithTexCoordsAndOpacityVertexShader = "\n\ + attribute highp vec2 textureCoordArray; \n\ + attribute lowp float opacityArray; \n\ + varying highp vec2 textureCoords; \n\ + varying lowp float opacity; \n\ + void setPosition(); \n\ + void main(void) \n\ + { \n\ + setPosition(); \n\ + textureCoords = textureCoordArray; \n\ + opacity = opacityArray; \n\ + }\n"; // NOTE: We let GL do the perspective correction so texture lookups in the fragment // shader are also perspective corrected. -static const char* const qglslPositionOnlyVertexShader = "\ - attribute highp vec2 vertexCoordsArray;\ - attribute highp vec3 pmvMatrix1; \ - attribute highp vec3 pmvMatrix2; \ - attribute highp vec3 pmvMatrix3; \ - void setPosition(void)\ - {\ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ - gl_Position = vec4(transformedPos.xy, 0.0, transformedPos.z); \ - }"; - -static const char* const qglslUntransformedPositionVertexShader = "\ - attribute highp vec4 vertexCoordsArray;\ - void setPosition(void)\ - {\ - gl_Position = vertexCoordsArray;\ - }"; +static const char* const qglslPositionOnlyVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray; \n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + void setPosition(void) \n\ + { \n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position = vec4(transformedPos.xy, 0.0, transformedPos.z); \n\ + }\n"; + +static const char* const qglslUntransformedPositionVertexShader = "\n\ + attribute highp vec4 vertexCoordsArray; \n\ + void setPosition(void) \n\ + { \n\ + gl_Position = vertexCoordsArray; \n\ + }\n"; // Pattern Brush - This assumes the texture size is 8x8 and thus, the inverted size is 0.125 -static const char* const qglslPositionWithPatternBrushVertexShader = "\ - attribute highp vec2 vertexCoordsArray; \ - attribute highp vec3 pmvMatrix1; \ - attribute highp vec3 pmvMatrix2; \ - attribute highp vec3 pmvMatrix3; \ - uniform mediump vec2 halfViewportSize; \ - uniform highp vec2 invertedTextureSize; \ - uniform highp mat3 brushTransform; \ - varying highp vec2 patternTexCoords; \ - void setPosition(void) { \ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ - gl_Position.xy = transformedPos.xy / transformedPos.z; \ - mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ - mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1.0); \ - mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ - gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \ - patternTexCoords.xy = (hTexCoords.xy * 0.125) * invertedHTexCoordsZ; \ - }"; +static const char* const qglslPositionWithPatternBrushVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray; \n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + uniform mediump vec2 halfViewportSize; \n\ + uniform highp vec2 invertedTextureSize; \n\ + uniform highp mat3 brushTransform; \n\ + varying highp vec2 patternTexCoords; \n\ + void setPosition(void) \n\ + { \n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1.0); \n\ + mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + patternTexCoords.xy = (hTexCoords.xy * 0.125) * invertedHTexCoordsZ; \n\ + }\n"; static const char* const qglslAffinePositionWithPatternBrushVertexShader = qglslPositionWithPatternBrushVertexShader; -static const char* const qglslPatternBrushSrcFragmentShader = "\ - uniform lowp sampler2D brushTexture;\ - uniform lowp vec4 patternColor; \ - varying highp vec2 patternTexCoords;\ - lowp vec4 srcPixel() { \ - return patternColor * (1.0 - texture2D(brushTexture, patternTexCoords).r); \ +static const char* const qglslPatternBrushSrcFragmentShader = "\n\ + uniform lowp sampler2D brushTexture; \n\ + uniform lowp vec4 patternColor; \n\ + varying highp vec2 patternTexCoords;\n\ + lowp vec4 srcPixel() \n\ + { \n\ + return patternColor * (1.0 - texture2D(brushTexture, patternTexCoords).r); \n\ }\n"; // Linear Gradient Brush -static const char* const qglslPositionWithLinearGradientBrushVertexShader = "\ - attribute highp vec2 vertexCoordsArray; \ - attribute highp vec3 pmvMatrix1; \ - attribute highp vec3 pmvMatrix2; \ - attribute highp vec3 pmvMatrix3; \ - uniform mediump vec2 halfViewportSize; \ - uniform highp vec3 linearData; \ - uniform highp mat3 brushTransform; \ - varying mediump float index; \ - void setPosition() { \ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ - gl_Position.xy = transformedPos.xy / transformedPos.z; \ - mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ - mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ - mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ - gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \ - index = (dot(linearData.xy, hTexCoords.xy) * linearData.z) * invertedHTexCoordsZ; \ - }"; +static const char* const qglslPositionWithLinearGradientBrushVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray; \n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + uniform mediump vec2 halfViewportSize; \n\ + uniform highp vec3 linearData; \n\ + uniform highp mat3 brushTransform; \n\ + varying mediump float index; \n\ + void setPosition() \n\ + { \n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ + mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + index = (dot(linearData.xy, hTexCoords.xy) * linearData.z) * invertedHTexCoordsZ; \n\ + }\n"; static const char* const qglslAffinePositionWithLinearGradientBrushVertexShader = qglslPositionWithLinearGradientBrushVertexShader; -static const char* const qglslLinearGradientBrushSrcFragmentShader = "\ - uniform lowp sampler2D brushTexture; \ - varying mediump float index; \ - lowp vec4 srcPixel() { \ - mediump vec2 val = vec2(index, 0.5); \ - return texture2D(brushTexture, val); \ +static const char* const qglslLinearGradientBrushSrcFragmentShader = "\n\ + uniform lowp sampler2D brushTexture; \n\ + varying mediump float index; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + mediump vec2 val = vec2(index, 0.5); \n\ + return texture2D(brushTexture, val); \n\ }\n"; // Conical Gradient Brush -static const char* const qglslPositionWithConicalGradientBrushVertexShader = "\ - attribute highp vec2 vertexCoordsArray;\ - attribute highp vec3 pmvMatrix1; \ - attribute highp vec3 pmvMatrix2; \ - attribute highp vec3 pmvMatrix3; \ - uniform mediump vec2 halfViewportSize; \ - uniform highp mat3 brushTransform; \ - varying highp vec2 A; \ - void setPosition(void) \ - { \ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ - gl_Position.xy = transformedPos.xy / transformedPos.z; \ - mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ - mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ - mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ - gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \ - A = hTexCoords.xy * invertedHTexCoordsZ; \ - }"; +static const char* const qglslPositionWithConicalGradientBrushVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray; \n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + uniform mediump vec2 halfViewportSize; \n\ + uniform highp mat3 brushTransform; \n\ + varying highp vec2 A; \n\ + void setPosition(void) \n\ + { \n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ + mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + A = hTexCoords.xy * invertedHTexCoordsZ; \n\ + }\n"; static const char* const qglslAffinePositionWithConicalGradientBrushVertexShader = qglslPositionWithConicalGradientBrushVertexShader; static const char* const qglslConicalGradientBrushSrcFragmentShader = "\n\ #define INVERSE_2PI 0.1591549430918953358 \n\ - uniform lowp sampler2D brushTexture; \n\ - uniform mediump float angle; \ - varying highp vec2 A; \ - lowp vec4 srcPixel() { \ - highp float t; \ - if (abs(A.y) == abs(A.x)) \ - t = (atan(-A.y + 0.002, A.x) + angle) * INVERSE_2PI; \ - else \ - t = (atan(-A.y, A.x) + angle) * INVERSE_2PI; \ - return texture2D(brushTexture, vec2(t - floor(t), 0.5)); \ - }"; + uniform lowp sampler2D brushTexture; \n\ + uniform mediump float angle; \n\ + varying highp vec2 A; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + highp float t; \n\ + if (abs(A.y) == abs(A.x)) \n\ + t = (atan(-A.y + 0.002, A.x) + angle) * INVERSE_2PI; \n\ + else \n\ + t = (atan(-A.y, A.x) + angle) * INVERSE_2PI; \n\ + return texture2D(brushTexture, vec2(t - floor(t), 0.5)); \n\ + }\n"; // Radial Gradient Brush -static const char* const qglslPositionWithRadialGradientBrushVertexShader = "\ - attribute highp vec2 vertexCoordsArray;\ - attribute highp vec3 pmvMatrix1; \ - attribute highp vec3 pmvMatrix2; \ - attribute highp vec3 pmvMatrix3; \ - uniform mediump vec2 halfViewportSize; \ - uniform highp mat3 brushTransform; \ - uniform highp vec2 fmp; \ - varying highp float b; \ - varying highp vec2 A; \ - void setPosition(void) \ - {\ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ - gl_Position.xy = transformedPos.xy / transformedPos.z; \ - mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ - mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ - mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ - gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \ - A = hTexCoords.xy * invertedHTexCoordsZ; \ - b = 2.0 * dot(A, fmp); \ - }"; +static const char* const qglslPositionWithRadialGradientBrushVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray;\n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + uniform mediump vec2 halfViewportSize; \n\ + uniform highp mat3 brushTransform; \n\ + uniform highp vec2 fmp; \n\ + varying highp float b; \n\ + varying highp vec2 A; \n\ + void setPosition(void) \n\ + {\n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ + mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + A = hTexCoords.xy * invertedHTexCoordsZ; \n\ + b = 2.0 * dot(A, fmp); \n\ + }\n"; static const char* const qglslAffinePositionWithRadialGradientBrushVertexShader = qglslPositionWithRadialGradientBrushVertexShader; -static const char* const qglslRadialGradientBrushSrcFragmentShader = "\ - uniform lowp sampler2D brushTexture; \ - uniform highp float fmp2_m_radius2; \ - uniform highp float inverse_2_fmp2_m_radius2; \ - varying highp float b; \ - varying highp vec2 A; \ - lowp vec4 srcPixel() { \ - highp float c = -dot(A, A); \ - highp vec2 val = vec2((-b + sqrt(b*b - 4.0*fmp2_m_radius2*c)) * inverse_2_fmp2_m_radius2, 0.5); \ - return texture2D(brushTexture, val); \ - }"; +static const char* const qglslRadialGradientBrushSrcFragmentShader = "\n\ + uniform lowp sampler2D brushTexture; \n\ + uniform highp float fmp2_m_radius2; \n\ + uniform highp float inverse_2_fmp2_m_radius2; \n\ + varying highp float b; \n\ + varying highp vec2 A; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + highp float c = -dot(A, A); \n\ + highp vec2 val = vec2((-b + sqrt(b*b - 4.0*fmp2_m_radius2*c)) * inverse_2_fmp2_m_radius2, 0.5); \n\ + return texture2D(brushTexture, val); \n\ + }\n"; // Texture Brush -static const char* const qglslPositionWithTextureBrushVertexShader = "\ - attribute highp vec2 vertexCoordsArray; \ - attribute highp vec3 pmvMatrix1; \ - attribute highp vec3 pmvMatrix2; \ - attribute highp vec3 pmvMatrix3; \ - uniform mediump vec2 halfViewportSize; \ - uniform highp vec2 invertedTextureSize; \ - uniform highp mat3 brushTransform; \ - varying highp vec2 textureCoords; \ - void setPosition(void) { \ - highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \ - vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \ - gl_Position.xy = transformedPos.xy / transformedPos.z; \ - mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \ - mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \ - mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \ - gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \ - textureCoords.xy = (hTexCoords.xy * invertedTextureSize) * gl_Position.w; \ - }"; +static const char* const qglslPositionWithTextureBrushVertexShader = "\n\ + attribute highp vec2 vertexCoordsArray; \n\ + attribute highp vec3 pmvMatrix1; \n\ + attribute highp vec3 pmvMatrix2; \n\ + attribute highp vec3 pmvMatrix3; \n\ + uniform mediump vec2 halfViewportSize; \n\ + uniform highp vec2 invertedTextureSize; \n\ + uniform highp mat3 brushTransform; \n\ + varying highp vec2 textureCoords; \n\ + void setPosition(void) \n\ + { \n\ + highp mat3 pmvMatrix = mat3(pmvMatrix1, pmvMatrix2, pmvMatrix3); \n\ + vec3 transformedPos = pmvMatrix * vec3(vertexCoordsArray.xy, 1.0); \n\ + gl_Position.xy = transformedPos.xy / transformedPos.z; \n\ + mediump vec2 viewportCoords = (gl_Position.xy + 1.0) * halfViewportSize; \n\ + mediump vec3 hTexCoords = brushTransform * vec3(viewportCoords, 1); \n\ + mediump float invertedHTexCoordsZ = 1.0 / hTexCoords.z; \n\ + gl_Position = vec4(gl_Position.xy * invertedHTexCoordsZ, 0.0, invertedHTexCoordsZ); \n\ + textureCoords.xy = (hTexCoords.xy * invertedTextureSize) * gl_Position.w; \n\ + }\n"; static const char* const qglslAffinePositionWithTextureBrushVertexShader = qglslPositionWithTextureBrushVertexShader; @@ -287,148 +294,165 @@ static const char* const qglslAffinePositionWithTextureBrushVertexShader // OpenGL ES does not support GL_REPEAT wrap modes for NPOT textures. So instead, // we emulate GL_REPEAT by only taking the fractional part of the texture coords. // TODO: Special case POT textures which don't need this emulation -static const char* const qglslTextureBrushSrcFragmentShader = "\ - varying highp vec2 textureCoords; \ - uniform lowp sampler2D brushTexture; \ - lowp vec4 srcPixel() { \ - return texture2D(brushTexture, fract(textureCoords)); \ - }"; +static const char* const qglslTextureBrushSrcFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform lowp sampler2D brushTexture; \n\ + lowp vec4 srcPixel() { \n\ + return texture2D(brushTexture, fract(textureCoords)); \n\ + }\n"; #else -static const char* const qglslTextureBrushSrcFragmentShader = "\ - varying highp vec2 textureCoords; \ - uniform lowp sampler2D brushTexture; \ - lowp vec4 srcPixel() { \ - return texture2D(brushTexture, textureCoords); \ - }"; +static const char* const qglslTextureBrushSrcFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform lowp sampler2D brushTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return texture2D(brushTexture, textureCoords); \n\ + }\n"; #endif -static const char* const qglslTextureBrushSrcWithPatternFragmentShader = "\ - varying highp vec2 textureCoords; \ - uniform lowp vec4 patternColor; \ - uniform lowp sampler2D brushTexture; \ - lowp vec4 srcPixel() { \ - return patternColor * (1.0 - texture2D(brushTexture, textureCoords).r); \ - }"; +static const char* const qglslTextureBrushSrcWithPatternFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform lowp vec4 patternColor; \n\ + uniform lowp sampler2D brushTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return patternColor * (1.0 - texture2D(brushTexture, textureCoords).r); \n\ + }\n"; // Solid Fill Brush -static const char* const qglslSolidBrushSrcFragmentShader = "\ - uniform lowp vec4 fragmentColor; \ - lowp vec4 srcPixel() { \ - return fragmentColor; \ - }"; - -static const char* const qglslImageSrcFragmentShader = "\ - varying highp vec2 textureCoords; \ - uniform lowp sampler2D imageTexture; \ - lowp vec4 srcPixel() { \ - return texture2D(imageTexture, textureCoords); \ - }"; - -static const char* const qglslCustomSrcFragmentShader = "\ - varying highp vec2 textureCoords; \ - uniform lowp sampler2D imageTexture; \ - lowp vec4 customShader(lowp sampler2D texture, highp vec2 coords); \ - lowp vec4 srcPixel() { \ - return customShader(imageTexture, textureCoords); \ - }"; - -static const char* const qglslImageSrcWithPatternFragmentShader = "\ - varying highp vec2 textureCoords; \ - uniform lowp vec4 patternColor; \ - uniform lowp sampler2D imageTexture; \ - lowp vec4 srcPixel() { \ - return patternColor * (1.0 - texture2D(imageTexture, textureCoords).r); \ - }\n"; - -static const char* const qglslNonPremultipliedImageSrcFragmentShader = "\ - varying highp vec2 textureCoords; \ - uniform lowp sampler2D imageTexture; \ - lowp vec4 srcPixel() { \ - lowp vec4 sample = texture2D(imageTexture, textureCoords); \ - sample.rgb = sample.rgb * sample.a; \ - return sample; \ - }"; - -static const char* const qglslShockingPinkSrcFragmentShader = "\ - lowp vec4 srcPixel() { \ - return vec4(0.98, 0.06, 0.75, 1.0); \ - }"; - -static const char* const qglslMainFragmentShader_ImageArrays = "\ - varying lowp float opacity; \ - lowp vec4 srcPixel(); \ - void main() { \ - gl_FragColor = srcPixel() * opacity; \ - }"; - -static const char* const qglslMainFragmentShader_CMO = "\ - uniform lowp float globalOpacity; \ - lowp vec4 srcPixel(); \ - lowp vec4 applyMask(lowp vec4); \ - lowp vec4 compose(lowp vec4); \ - void main() { \ - gl_FragColor = applyMask(compose(srcPixel()*globalOpacity))); \ - }"; - -static const char* const qglslMainFragmentShader_CM = "\ - lowp vec4 srcPixel(); \ - lowp vec4 applyMask(lowp vec4); \ - lowp vec4 compose(lowp vec4); \ - void main() { \ - gl_FragColor = applyMask(compose(srcPixel())); \ - }"; - -static const char* const qglslMainFragmentShader_MO = "\ - uniform lowp float globalOpacity; \ - lowp vec4 srcPixel(); \ - lowp vec4 applyMask(lowp vec4); \ - void main() { \ - gl_FragColor = applyMask(srcPixel()*globalOpacity); \ - }"; - -static const char* const qglslMainFragmentShader_M = "\ - lowp vec4 srcPixel(); \ - lowp vec4 applyMask(lowp vec4); \ - void main() { \ - gl_FragColor = applyMask(srcPixel()); \ - }"; - -static const char* const qglslMainFragmentShader_CO = "\ - uniform lowp float globalOpacity; \ - lowp vec4 srcPixel(); \ - lowp vec4 compose(lowp vec4); \ - void main() { \ - gl_FragColor = compose(srcPixel()*globalOpacity); \ - }"; - -static const char* const qglslMainFragmentShader_C = "\ - lowp vec4 srcPixel(); \ - lowp vec4 compose(lowp vec4); \ - void main() { \ - gl_FragColor = compose(srcPixel()); \ - }"; - -static const char* const qglslMainFragmentShader_O = "\ - uniform lowp float globalOpacity; \ - lowp vec4 srcPixel(); \ - void main() { \ - gl_FragColor = srcPixel()*globalOpacity; \ - }"; - -static const char* const qglslMainFragmentShader = "\ - lowp vec4 srcPixel(); \ - void main() { \ - gl_FragColor = srcPixel(); \ - }"; - -static const char* const qglslMaskFragmentShader = "\ - varying highp vec2 textureCoords;\ - uniform lowp sampler2D maskTexture;\ - lowp vec4 applyMask(lowp vec4 src) \ - {\ - lowp vec4 mask = texture2D(maskTexture, textureCoords); \ - return src * mask.a; \ - }"; +static const char* const qglslSolidBrushSrcFragmentShader = "\n\ + uniform lowp vec4 fragmentColor; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return fragmentColor; \n\ + }\n"; + +static const char* const qglslImageSrcFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform lowp sampler2D imageTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return texture2D(imageTexture, textureCoords); \n\ + }\n"; + +static const char* const qglslCustomSrcFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform lowp sampler2D imageTexture; \n\ + lowp vec4 customShader(lowp sampler2D texture, highp vec2 coords); \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return customShader(imageTexture, textureCoords); \n\ + }\n"; + +static const char* const qglslImageSrcWithPatternFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform lowp vec4 patternColor; \n\ + uniform lowp sampler2D imageTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + return patternColor * (1.0 - texture2D(imageTexture, textureCoords).r); \n\ + }\n"; + +static const char* const qglslNonPremultipliedImageSrcFragmentShader = "\n\ + varying highp vec2 textureCoords; \n\ + uniform lowp sampler2D imageTexture; \n\ + lowp vec4 srcPixel() \n\ + { \n\ + lowp vec4 sample = texture2D(imageTexture, textureCoords); \n\ + sample.rgb = sample.rgb * sample.a; \n\ + return sample; \n\ + }\n"; + +static const char* const qglslShockingPinkSrcFragmentShader = "\n\ + lowp vec4 srcPixel() \n\ + { \n\ + return vec4(0.98, 0.06, 0.75, 1.0); \n\ + }\n"; + +static const char* const qglslMainFragmentShader_ImageArrays = "\n\ + varying lowp float opacity; \n\ + lowp vec4 srcPixel(); \n\ + void main() \n\ + { \n\ + gl_FragColor = srcPixel() * opacity; \n\ + }\n"; + +static const char* const qglslMainFragmentShader_CMO = "\n\ + uniform lowp float globalOpacity; \n\ + lowp vec4 srcPixel(); \n\ + lowp vec4 applyMask(lowp vec4); \n\ + lowp vec4 compose(lowp vec4); \n\ + void main() \n\ + { \n\ + gl_FragColor = applyMask(compose(srcPixel()*globalOpacity))); \n\ + }\n"; + +static const char* const qglslMainFragmentShader_CM = "\n\ + lowp vec4 srcPixel(); \n\ + lowp vec4 applyMask(lowp vec4); \n\ + lowp vec4 compose(lowp vec4); \n\ + void main() \n\ + { \n\ + gl_FragColor = applyMask(compose(srcPixel())); \n\ + }\n"; + +static const char* const qglslMainFragmentShader_MO = "\n\ + uniform lowp float globalOpacity; \n\ + lowp vec4 srcPixel(); \n\ + lowp vec4 applyMask(lowp vec4); \n\ + void main() \n\ + { \n\ + gl_FragColor = applyMask(srcPixel()*globalOpacity); \n\ + }\n"; + +static const char* const qglslMainFragmentShader_M = "\n\ + lowp vec4 srcPixel(); \n\ + lowp vec4 applyMask(lowp vec4); \n\ + void main() \n\ + { \n\ + gl_FragColor = applyMask(srcPixel()); \n\ + }\n"; + +static const char* const qglslMainFragmentShader_CO = "\n\ + uniform lowp float globalOpacity; \n\ + lowp vec4 srcPixel(); \n\ + lowp vec4 compose(lowp vec4); \n\ + void main() \n\ + { \n\ + gl_FragColor = compose(srcPixel()*globalOpacity); \n\ + }\n"; + +static const char* const qglslMainFragmentShader_C = "\n\ + lowp vec4 srcPixel(); \n\ + lowp vec4 compose(lowp vec4); \n\ + void main() \n\ + { \n\ + gl_FragColor = compose(srcPixel()); \n\ + }\n"; + +static const char* const qglslMainFragmentShader_O = "\n\ + uniform lowp float globalOpacity; \n\ + lowp vec4 srcPixel(); \n\ + void main() \n\ + { \n\ + gl_FragColor = srcPixel()*globalOpacity; \n\ + }\n"; + +static const char* const qglslMainFragmentShader = "\n\ + lowp vec4 srcPixel(); \n\ + void main() \n\ + { \n\ + gl_FragColor = srcPixel(); \n\ + }\n"; + +static const char* const qglslMaskFragmentShader = "\n\ + varying highp vec2 textureCoords;\n\ + uniform lowp sampler2D maskTexture;\n\ + lowp vec4 applyMask(lowp vec4 src) \n\ + {\n\ + lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\ + return src * mask.a; \n\ + }\n"; // For source over with subpixel antialiasing, the final color is calculated per component as follows // (.a is alpha component, .c is red, green or blue component): @@ -445,23 +469,23 @@ static const char* const qglslMaskFragmentShader = "\ // dest.c = dest.c * (1 - mask.c) + src.c * alpha // -static const char* const qglslRgbMaskFragmentShaderPass1 = "\ - varying highp vec2 textureCoords;\ - uniform lowp sampler2D maskTexture;\ - lowp vec4 applyMask(lowp vec4 src) \ - {\ - lowp vec4 mask = texture2D(maskTexture, textureCoords); \ - return src.a * mask; \ - }"; - -static const char* const qglslRgbMaskFragmentShaderPass2 = "\ - varying highp vec2 textureCoords;\ - uniform lowp sampler2D maskTexture;\ - lowp vec4 applyMask(lowp vec4 src) \ - {\ - lowp vec4 mask = texture2D(maskTexture, textureCoords); \ - return src * mask; \ - }"; +static const char* const qglslRgbMaskFragmentShaderPass1 = "\n\ + varying highp vec2 textureCoords;\n\ + uniform lowp sampler2D maskTexture;\n\ + lowp vec4 applyMask(lowp vec4 src) \n\ + { \n\ + lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\ + return src.a * mask; \n\ + }\n"; + +static const char* const qglslRgbMaskFragmentShaderPass2 = "\n\ + varying highp vec2 textureCoords;\n\ + uniform lowp sampler2D maskTexture;\n\ + lowp vec4 applyMask(lowp vec4 src) \n\ + { \n\ + lowp vec4 mask = texture2D(maskTexture, textureCoords); \n\ + return src * mask; \n\ + }\n"; /* Left to implement: -- cgit v0.12 From 9fa39653a42e1e29f83ce272de746bf1441c3800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Thu, 21 Jan 2010 15:54:18 +0100 Subject: Make sure cursor is painted at the correct position when we are using IM. When the line edit was refactored into a line control this regression was introduced. This regression was introduced by change fb7d86cf23227302d48db279ec589221d11a1f6a. Task-number: QTBUG-4789 Reviewed-by: Alan Alpert --- src/gui/widgets/qlinecontrol.cpp | 5 ++++- src/gui/widgets/qlinecontrol_p.h | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 414c2ed..b0a64ea 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -524,8 +524,11 @@ void QLineControl::draw(QPainter *painter, const QPoint &offset, const QRect &cl m_textLayout.draw(painter, offset, selections, clip); if (flags & DrawCursor){ + int cursor = m_cursor; + if (m_preeditCursor != -1) + cursor += m_preeditCursor; if(!m_blinkPeriod || m_blinkStatus) - m_textLayout.drawCursor(painter, offset, m_cursor, m_cursorWidth); + m_textLayout.drawCursor(painter, offset, cursor, m_cursorWidth); } } diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index 301ff72..d6f2705 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -549,7 +549,10 @@ inline qreal QLineControl::cursorToX(int cursor) const inline qreal QLineControl::cursorToX() const { - return cursorToX(m_cursor); + int cursor = m_cursor; + if (m_preeditCursor != -1) + cursor += m_preeditCursor; + return cursorToX(cursor); } inline bool QLineControl::isReadOnly() const -- cgit v0.12 From 1ace126b121bdec0a54aef808cca749e2ef04acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 13 Jan 2010 16:44:57 +0100 Subject: Improve performance of QGraphicsItem::setParentItem. The biggest optimization here is "updateAncestorFlags()". It's much faster to update all the flags rather than trying to enable/disable certain flags according to the current state. Task-number: QTBUG-6877 Reviewed-by: alexis --- src/gui/graphicsview/qgraphicsitem.cpp | 67 ++++++++++++++++++++++----------- src/gui/graphicsview/qgraphicsitem_p.h | 9 +++-- src/gui/graphicsview/qgraphicsscene.cpp | 21 ++++++----- 3 files changed, 62 insertions(+), 35 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 1ea69fb..9008be3 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -800,8 +800,36 @@ void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag ch return; } - foreach (QGraphicsItem *child, children) - child->d_ptr->updateAncestorFlag(childFlag, flag, enabled, false); + for (int i = 0; i < children.size(); ++i) + children.at(i)->d_ptr->updateAncestorFlag(childFlag, flag, enabled, false); +} + +void QGraphicsItemPrivate::updateAncestorFlags() +{ + int flags = 0; + if (parent) { + // Inherit the parent's ancestor flags. + QGraphicsItemPrivate *pd = parent->d_ptr.data(); + flags = pd->ancestorFlags; + + // Add in flags from the parent. + if (pd->filtersDescendantEvents) + flags |= AncestorFiltersChildEvents; + if (pd->handlesChildEvents) + flags |= AncestorHandlesChildEvents; + if (pd->flags & QGraphicsItem::ItemClipsChildrenToShape) + flags |= AncestorClipsChildren; + if (pd->flags & QGraphicsItem::ItemIgnoresTransformations) + flags |= AncestorIgnoresTransformations; + } + + if (ancestorFlags == flags) + return; // No change; stop propagation. + ancestorFlags = flags; + + // Propagate to children recursively. + for (int i = 0; i < children.size(); ++i) + children.at(i)->d_ptr->updateAncestorFlags(); } /*! @@ -1004,7 +1032,8 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) if (scene) { // Deliver the change to the index - scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParentVariant); + if (scene->d_func()->indexMethod != QGraphicsScene::NoIndex) + scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParentVariant); // Disable scene pos notifications for old ancestors if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges)) @@ -1044,7 +1073,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) QGraphicsItem *p = parent; QGraphicsItem *parentFocusScopeItem = 0; while (p) { - if (p->flags() & QGraphicsItem::ItemIsFocusScope) { + if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) { // If this item's focus scope's focus scope item points // to this item or a descendent, then clear it. QGraphicsItem *fsi = p->d_ptr->focusScopeItem; @@ -1065,11 +1094,11 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) QGraphicsItem *ancestorScope = 0; QGraphicsItem *p = subFocusItem->d_ptr->parent; while (p) { - if (p->flags() & QGraphicsItem::ItemIsFocusScope) + if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) ancestorScope = p; - if (p->isPanel()) + if (p->d_ptr->flags & QGraphicsItem::ItemIsPanel) break; - p = p->parentItem(); + p = p->d_ptr->parent; } if (ancestorScope) newFocusScopeItem = ancestorScope; @@ -1077,7 +1106,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) QGraphicsItem *p = newParent; while (p) { - if (p->flags() & QGraphicsItem::ItemIsFocusScope) { + if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) { p->d_ptr->focusScopeItem = newFocusScopeItem; // Ensure the new item is no longer the subFocusItem. The // only way to set focus on a child of a focus scope is @@ -1113,30 +1142,24 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) } // Inherit ancestor flags from the new parent. - updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2)); - updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1)); - updateAncestorFlag(QGraphicsItem::ItemClipsChildrenToShape); - updateAncestorFlag(QGraphicsItem::ItemIgnoresTransformations); + updateAncestorFlags(); // Update item visible / enabled. - if (parent->isVisible() != visible) { - if (!parent->isVisible() || !explicitlyHidden) - setVisibleHelper(parent->isVisible(), /* explicit = */ false, /* update = */ !implicitUpdate); + if (parent->d_ptr->visible != visible) { + if (!parent->d_ptr->visible || !explicitlyHidden) + setVisibleHelper(parent->d_ptr->visible, /* explicit = */ false, /* update = */ !implicitUpdate); } if (parent->isEnabled() != enabled) { - if (!parent->isEnabled() || !explicitlyDisabled) - setEnabledHelper(parent->isEnabled(), /* explicit = */ false, /* update = */ !implicitUpdate); + if (!parent->d_ptr->enabled || !explicitlyDisabled) + setEnabledHelper(parent->d_ptr->enabled, /* explicit = */ false, /* update = */ !implicitUpdate); } // Auto-activate if visible and the parent is active. - if (q->isVisible() && parent->isActive()) + if (visible && parent->isActive()) q->setActive(true); } else { // Inherit ancestor flags from the new parent. - updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2)); - updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1)); - updateAncestorFlag(QGraphicsItem::ItemClipsChildrenToShape); - updateAncestorFlag(QGraphicsItem::ItemIgnoresTransformations); + updateAncestorFlags(); if (!inDestructor) { // Update item visible / enabled. diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 2d34b80..cfdd382 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -153,7 +153,7 @@ public: dirtyChildren(0), localCollisionHack(0), inSetPosHelper(0), - needSortChildren(1), // ### can be 0 by default? + needSortChildren(0), allChildrenDirty(0), fullUpdatePending(0), flags(0), @@ -197,6 +197,7 @@ public: void updateAncestorFlag(QGraphicsItem::GraphicsItemFlag childFlag, AncestorFlag flag = NoFlag, bool enabled = false, bool root = true); + void updateAncestorFlags(); void setIsMemberOfGroup(bool enabled); void remapItemPos(QEvent *event, QGraphicsItem *item); QPointF genericMapFromScene(const QPointF &pos, const QWidget *viewport) const; @@ -721,11 +722,13 @@ inline QTransform QGraphicsItemPrivate::transformToParent() const inline void QGraphicsItemPrivate::ensureSortedChildren() { if (needSortChildren) { - qSort(children.begin(), children.end(), qt_notclosestLeaf); needSortChildren = 0; sequentialOrdering = 1; + if (children.isEmpty()) + return; + qSort(children.begin(), children.end(), qt_notclosestLeaf); for (int i = 0; i < children.size(); ++i) { - if (children[i]->d_ptr->siblingIndex != i) { + if (children.at(i)->d_ptr->siblingIndex != i) { sequentialOrdering = 0; break; } diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index cea723c..49925e1 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -2482,12 +2482,12 @@ void QGraphicsScene::addItem(QGraphicsItem *item) qWarning("QGraphicsScene::addItem: cannot add null item"); return; } - if (item->scene() == this) { + if (item->d_ptr->scene == this) { qWarning("QGraphicsScene::addItem: item has already been added to this scene"); return; } // Remove this item from its existing scene - if (QGraphicsScene *oldScene = item->scene()) + if (QGraphicsScene *oldScene = item->d_ptr->scene) oldScene->removeItem(item); // Notify the item that its scene is changing, and allow the item to @@ -2496,15 +2496,15 @@ void QGraphicsScene::addItem(QGraphicsItem *item) qVariantFromValue(this))); QGraphicsScene *targetScene = qVariantValue(newSceneVariant); if (targetScene != this) { - if (targetScene && item->scene() != targetScene) + if (targetScene && item->d_ptr->scene != targetScene) targetScene->addItem(item); return; } // Detach this item from its parent if the parent's scene is different // from this scene. - if (QGraphicsItem *itemParent = item->parentItem()) { - if (itemParent->scene() != this) + if (QGraphicsItem *itemParent = item->d_ptr->parent) { + if (itemParent->d_ptr->scene != this) item->setParentItem(0); } @@ -2534,7 +2534,7 @@ void QGraphicsScene::addItem(QGraphicsItem *item) d->enableMouseTrackingOnViews(); } #ifndef QT_NO_CURSOR - if (d->allItemsUseDefaultCursor && item->hasCursor()) { + if (d->allItemsUseDefaultCursor && item->d_ptr->hasCursor) { d->allItemsUseDefaultCursor = false; if (d->allItemsIgnoreHoverEvents) // already enabled otherwise d->enableMouseTrackingOnViews(); @@ -2542,7 +2542,7 @@ void QGraphicsScene::addItem(QGraphicsItem *item) #endif //QT_NO_CURSOR // Enable touch events if the item accepts touch events. - if (d->allItemsIgnoreTouchEvents && item->acceptTouchEvents()) { + if (d->allItemsIgnoreTouchEvents && item->d_ptr->acceptTouchEvents) { d->allItemsIgnoreTouchEvents = false; d->enableTouchEventsOnViews(); } @@ -2575,8 +2575,9 @@ void QGraphicsScene::addItem(QGraphicsItem *item) } // Add all children recursively - foreach (QGraphicsItem *child, item->children()) - addItem(child); + item->d_ptr->ensureSortedChildren(); + for (int i = 0; i < item->d_ptr->children.size(); ++i) + addItem(item->d_ptr->children.at(i)); // Resolve font and palette. item->d_ptr->resolveFont(d->font.resolve()); @@ -2619,7 +2620,7 @@ void QGraphicsScene::addItem(QGraphicsItem *item) } } - if (item->flags() & QGraphicsItem::ItemSendsScenePositionChanges) + if (item->d_ptr->flags & QGraphicsItem::ItemSendsScenePositionChanges) d->registerScenePosItem(item); // Ensure that newly added items that have subfocus set, gain -- cgit v0.12 From 15e00f91133874455df32ac1d5799fccdab5cd10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 14 Jan 2010 11:43:05 +0100 Subject: Optimize QGraphicsScenePrivate::itemAcceptsHoverEvents_helper Make sure we do cheap tests before the more expensive ones. This function is called from QGraphicsScene::addItem. Task-number: QTBUG-6877 Reviewed-by: alexis --- src/gui/graphicsview/qgraphicsscene.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 49925e1..fa9f794 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -3767,10 +3767,10 @@ void QGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent) bool QGraphicsScenePrivate::itemAcceptsHoverEvents_helper(const QGraphicsItem *item) const { - return (!item->isBlockedByModalPanel() && - (item->acceptHoverEvents() - || (item->isWidget() - && static_cast(item)->d_func()->hasDecoration()))); + return (item->d_ptr->acceptsHover + || (item->d_ptr->isWidget + && static_cast(item)->d_func()->hasDecoration())) + && !item->isBlockedByModalPanel(); } /*! -- cgit v0.12 From 33fb442f7e95c0bf5af800f5b96fc3d78bffdd98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 14 Jan 2010 16:13:37 +0100 Subject: Optimize QGraphicsItem::setFlags. We don't have to do a full blown QGraphicsItem::setFlag call from QGraphicsItem::setFlags, only to change the ItemStacksBehindParent bits. We can do it directly (with care). Task-number: QTBUG-6877 Reviewed-by: alexis --- src/gui/graphicsview/qgraphicsitem.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 9008be3..8196829 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1632,7 +1632,7 @@ bool QGraphicsItem::isWidget() const */ bool QGraphicsItem::isWindow() const { - return isWidget() && (static_cast(this)->windowType() & Qt::Window); + return d_ptr->isWidget && (static_cast(this)->windowType() & Qt::Window); } /*! @@ -1669,9 +1669,9 @@ QGraphicsItem::GraphicsItemFlags QGraphicsItem::flags() const void QGraphicsItem::setFlag(GraphicsItemFlag flag, bool enabled) { if (enabled) - setFlags(flags() | flag); + setFlags(GraphicsItemFlags(d_ptr->flags) | flag); else - setFlags(flags() & ~flag); + setFlags(GraphicsItemFlags(d_ptr->flags) & ~flag); } /*! @@ -1718,7 +1718,7 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) flags = GraphicsItemFlags(itemChange(ItemFlagsChange, quint32(flags)).toUInt()); if (quint32(d_ptr->flags) == quint32(flags)) return; - if (d_ptr->scene) + if (d_ptr->scene && d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex) d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, quint32(flags)); // Flags that alter the geometry of the item (or its children). @@ -1728,7 +1728,7 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) d_ptr->paintedViewBoundingRectsNeedRepaint = 1; // Keep the old flags to compare the diff. - GraphicsItemFlags oldFlags = this->flags(); + GraphicsItemFlags oldFlags = GraphicsItemFlags(d_ptr->flags); // Update flags. d_ptr->flags = flags; @@ -1757,7 +1757,23 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) d_ptr->updateAncestorFlag(ItemIgnoresTransformations); } + if ((flags & ItemNegativeZStacksBehindParent) != (oldFlags & ItemNegativeZStacksBehindParent)) { + // NB! We change the flags directly here, so we must also update d_ptr->flags. + // Note that this has do be done before the ItemStacksBehindParent check + // below; otherwise we will loose the change. + + // Update stack-behind. + if (d_ptr->z < qreal(0.0)) + flags |= ItemStacksBehindParent; + else + flags &= ~ItemStacksBehindParent; + d_ptr->flags = flags; + } + if ((flags & ItemStacksBehindParent) != (oldFlags & ItemStacksBehindParent)) { + // NB! This check has to come after the ItemNegativeZStacksBehindParent + // check above. Be careful. + // Ensure child item sorting is up to date when toggling this flag. if (d_ptr->parent) d_ptr->parent->d_ptr->needSortChildren = 1; @@ -1771,10 +1787,6 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) d_ptr->scene->d_func()->updateInputMethodSensitivityInViews(); } - if ((flags & ItemNegativeZStacksBehindParent) != (oldFlags & ItemNegativeZStacksBehindParent)) { - // Update stack-behind. - setFlag(ItemStacksBehindParent, d_ptr->z < qreal(0.0)); - } if ((d_ptr->panelModality != NonModal) && d_ptr->scene -- cgit v0.12 From dd29275d302ca10b9b07c4cc246402036b854830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 19 Jan 2010 13:18:55 +0100 Subject: Pass value as const void *const to QGraphicsSceneIndex::itemChange. We need this change in order to bypass some of the QVariant itemChange notifications from QGraphicsItem::setParentItem. All this is internal stuff and we know what we do, so I don't consider the change too ugly. Task-number: QTBUG-6877 Reviewed-by: alexis --- src/gui/graphicsview/qgraphicsitem.cpp | 8 ++++---- src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp | 10 +++++----- src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h | 2 +- src/gui/graphicsview/qgraphicssceneindex.cpp | 2 +- src/gui/graphicsview/qgraphicssceneindex_p.h | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 8196829..d66e9b6 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1033,7 +1033,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) if (scene) { // Deliver the change to the index if (scene->d_func()->indexMethod != QGraphicsScene::NoIndex) - scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParentVariant); + scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParent); // Disable scene pos notifications for old ancestors if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges)) @@ -1719,7 +1719,7 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags) if (quint32(d_ptr->flags) == quint32(flags)) return; if (d_ptr->scene && d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex) - d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, quint32(flags)); + d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, &flags); // Flags that alter the geometry of the item (or its children). const quint32 geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations | ItemIsSelectable); @@ -4301,9 +4301,9 @@ void QGraphicsItem::setZValue(qreal z) if (newZ == d_ptr->z) return; - if (d_ptr->scene) { + if (d_ptr->scene && d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex) { // Z Value has changed, we have to notify the index. - d_ptr->scene->d_func()->index->itemChange(this, ItemZValueChange, newZVariant); + d_ptr->scene->d_func()->index->itemChange(this, ItemZValueChange, &newZ); } d_ptr->z = newZ; diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp index 2e92b87..2a91348 100644 --- a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp +++ b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp @@ -635,16 +635,17 @@ void QGraphicsSceneBspTreeIndex::updateSceneRect(const QRectF &rect) This method react to the \a change of the \a item and use the \a value to update the BSP tree if necessary. */ -void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const QVariant &value) +void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const void *const value) { Q_D(QGraphicsSceneBspTreeIndex); switch (change) { case QGraphicsItem::ItemFlagsChange: { // Handle ItemIgnoresTransformations + QGraphicsItem::GraphicsItemFlags newFlags = *static_cast(value); bool ignoredTransform = item->d_ptr->flags & QGraphicsItem::ItemIgnoresTransformations; - bool willIgnoreTransform = value.toUInt() & QGraphicsItem::ItemIgnoresTransformations; + bool willIgnoreTransform = newFlags & QGraphicsItem::ItemIgnoresTransformations; bool clipsChildren = item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape; - bool willClipChildren = value.toUInt() & QGraphicsItem::ItemClipsChildrenToShape; + bool willClipChildren = newFlags & QGraphicsItem::ItemClipsChildrenToShape; if ((ignoredTransform != willIgnoreTransform) || (clipsChildren != willClipChildren)) { QGraphicsItem *thatItem = const_cast(item); // Remove item and its descendants from the index and append @@ -661,7 +662,7 @@ void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphics case QGraphicsItem::ItemParentChange: { d->invalidateSortCache(); // Handle ItemIgnoresTransformations - QGraphicsItem *newParent = qVariantValue(value); + const QGraphicsItem *newParent = static_cast(value); bool ignoredTransform = item->d_ptr->itemIsUntransformable(); bool willIgnoreTransform = (item->d_ptr->flags & QGraphicsItem::ItemIgnoresTransformations) || (newParent && newParent->d_ptr->itemIsUntransformable()); @@ -682,7 +683,6 @@ void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphics default: break; } - return QGraphicsSceneIndex::itemChange(item, change, value); } /*! \reimp diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h b/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h index 119571b..f671fd9 100644 --- a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h +++ b/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h @@ -97,7 +97,7 @@ protected: void removeItem(QGraphicsItem *item); void prepareBoundingRectChange(const QGraphicsItem *item); - void itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const QVariant &value); + void itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const void *const value); private : Q_DECLARE_PRIVATE(QGraphicsSceneBspTreeIndex) diff --git a/src/gui/graphicsview/qgraphicssceneindex.cpp b/src/gui/graphicsview/qgraphicssceneindex.cpp index bc8a7dc..043c4eb 100644 --- a/src/gui/graphicsview/qgraphicssceneindex.cpp +++ b/src/gui/graphicsview/qgraphicssceneindex.cpp @@ -624,7 +624,7 @@ void QGraphicsSceneIndex::deleteItem(QGraphicsItem *item) \sa QGraphicsItem::GraphicsItemChange */ -void QGraphicsSceneIndex::itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const QVariant &value) +void QGraphicsSceneIndex::itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const void *const value) { Q_UNUSED(item); Q_UNUSED(change); diff --git a/src/gui/graphicsview/qgraphicssceneindex_p.h b/src/gui/graphicsview/qgraphicssceneindex_p.h index def58f0..597a229 100644 --- a/src/gui/graphicsview/qgraphicssceneindex_p.h +++ b/src/gui/graphicsview/qgraphicssceneindex_p.h @@ -110,7 +110,7 @@ protected: virtual void removeItem(QGraphicsItem *item) = 0; virtual void deleteItem(QGraphicsItem *item); - virtual void itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange, const QVariant &value); + virtual void itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange, const void *const value); virtual void prepareBoundingRectChange(const QGraphicsItem *item); QGraphicsSceneIndex(QGraphicsSceneIndexPrivate &dd, QGraphicsScene *scene); -- cgit v0.12 From de9b91a5363ae27de50de7475e958f4858f6dd8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 19 Jan 2010 13:30:55 +0100 Subject: Only send QGraphicsItem::ParentChange(d) notifications from setParentItem. QmlGraphicsItem doesn't need any parent change notifactions so we can call the helper class (QGraphicsItemPrivate::setParentItemHelper) direclty from QmlGraphicsItem::setParentItem. This avoids a lot of unnecessary instructions related to QVariant constructions as well as virtual function calls. I've made the variant pointers explicit in the declaration of setParentItemHelper so that we don't accidentally call setParentItemHelper from places where we need parent change notifications. Task-number: QTBUG-6877 Reviewed-by: alexis --- src/gui/graphicsview/qgraphicsitem.cpp | 43 +++++++++++++++++++-------------- src/gui/graphicsview/qgraphicsitem_p.h | 3 ++- src/gui/graphicsview/qgraphicsscene.cpp | 2 +- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index d66e9b6..1139be0 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1014,19 +1014,10 @@ QVariant QGraphicsItemPrivate::inputMethodQueryHelper(Qt::InputMethodQuery query prepareGeometryChange) if the item is in its destructor, i.e. inDestructor is 1. */ -void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) +void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const QVariant *newParentVariant, + const QVariant *thisPointerVariant) { Q_Q(QGraphicsItem); - if (newParent == q) { - qWarning("QGraphicsItem::setParentItem: cannot assign %p as a parent of itself", this); - return; - } - if (newParent == parent) - return; - - const QVariant newParentVariant(q->itemChange(QGraphicsItem::ItemParentChange, - qVariantFromValue(newParent))); - newParent = qVariantValue(newParentVariant); if (newParent == parent) return; @@ -1051,11 +1042,11 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) if (!inDestructor) q_ptr->prepareGeometryChange(); - const QVariant thisPointerVariant(qVariantFromValue(q)); if (parent) { // Remove from current parent parent->d_ptr->removeChild(q); - parent->itemChange(QGraphicsItem::ItemChildRemovedChange, thisPointerVariant); + if (thisPointerVariant) + parent->itemChange(QGraphicsItem::ItemChildRemovedChange, *thisPointerVariant); } // Update toplevelitem list. If this item is being deleted, its parent @@ -1131,7 +1122,8 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) } parent->d_ptr->addChild(q); - parent->itemChange(QGraphicsItem::ItemChildAddedChange, thisPointerVariant); + if (thisPointerVariant) + parent->itemChange(QGraphicsItem::ItemChildAddedChange, *thisPointerVariant); if (scene) { if (!implicitUpdate) scene->d_func()->markDirty(q_ptr); @@ -1186,7 +1178,8 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) } // Deliver post-change notification - q->itemChange(QGraphicsItem::ItemParentHasChanged, newParentVariant); + if (newParentVariant) + q->itemChange(QGraphicsItem::ItemParentHasChanged, *newParentVariant); if (isObject) emit static_cast(q)->parentChanged(); @@ -1375,7 +1368,7 @@ QGraphicsItem::~QGraphicsItem() d_ptr->scene->d_func()->removeItemHelper(this); } else { d_ptr->resetFocusProxy(); - d_ptr->setParentItemHelper(0); + setParentItem(0); } #ifndef QT_NO_GRAPHICSEFFECT @@ -1580,9 +1573,23 @@ const QGraphicsObject *QGraphicsItem::toGraphicsObject() const \sa parentItem(), childItems() */ -void QGraphicsItem::setParentItem(QGraphicsItem *parent) +void QGraphicsItem::setParentItem(QGraphicsItem *newParent) { - d_ptr->setParentItemHelper(parent); + if (newParent == this) { + qWarning("QGraphicsItem::setParentItem: cannot assign %p as a parent of itself", this); + return; + } + if (newParent == d_ptr->parent) + return; + + const QVariant newParentVariant(itemChange(QGraphicsItem::ItemParentChange, + qVariantFromValue(newParent))); + newParent = qVariantValue(newParentVariant); + if (newParent == d_ptr->parent) + return; + + const QVariant thisPointerVariant(qVariantFromValue(this)); + d_ptr->setParentItemHelper(newParent, &newParentVariant, &thisPointerVariant); } /*! diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index cfdd382..ac10aa7 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -230,7 +230,8 @@ public: void resolveDepth(); void addChild(QGraphicsItem *child); void removeChild(QGraphicsItem *child); - void setParentItemHelper(QGraphicsItem *parent); + void setParentItemHelper(QGraphicsItem *parent, const QVariant *newParentVariant, + const QVariant *thisPointerVariant); void childrenBoundingRectHelper(QTransform *x, QRectF *rect); void initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform, const QRegion &exposedRegion, bool allItems = false) const; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index fa9f794..088a6b9 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -599,7 +599,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) if (parentItem->scene()) { Q_ASSERT_X(parentItem->scene() == q, "QGraphicsScene::removeItem", "Parent item's scene is different from this item's scene"); - item->d_ptr->setParentItemHelper(0); + item->setParentItem(0); } } else { unregisterTopLevelItem(item); -- cgit v0.12 From 51f8dd863b037415f84d53884f1576171c11566d Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 22 Jan 2010 08:31:32 +0100 Subject: Fix documentation bug in QColor --- src/gui/painting/qcolor.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index f51dc36..d6d288e 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -934,8 +934,7 @@ void QColor::setRgb(int r, int g, int b, int a) /*! \fn QRgb QColor::rgba() const - Returns the RGB value of the color. Unlike rgb(), the alpha is not - stripped. + Returns the RGB value of the color, including its alpha. For an invalid color, the alpha value of the returned color is unspecified. @@ -950,8 +949,7 @@ QRgb QColor::rgba() const } /*! - Sets the RGBA value to \a rgba. Unlike setRgb(QRgb rgb), this function does - not ignore the alpha. + Sets the RGB value to \a rgba, including its alpha. \sa rgba(), rgb() */ @@ -968,8 +966,7 @@ void QColor::setRgba(QRgb rgba) /*! \fn QRgb QColor::rgb() const - Returns the RGB value of the color. The alpha is stripped for - compatibility. + Returns the RGB value of the color. The alpha value is opaque. \sa getRgb(), rgba() */ @@ -983,7 +980,7 @@ QRgb QColor::rgb() const /*! \overload - Sets the RGB value to \a rgb, ignoring the alpha. + Sets the RGB value to \a rgb. The alpha value is set to opaque. */ void QColor::setRgb(QRgb rgb) { -- cgit v0.12 From e6cd01d47cd7da1b34e36b0bc3de7e94429f6d58 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 22 Jan 2010 10:13:53 +0100 Subject: removed a debug trace --- src/corelib/animation/qabstractanimation.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 2b4ab47..cedb43f 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -299,8 +299,6 @@ void QUnifiedTimer::registerRunningAnimation(QAbstractAnimation *animation) return; if (QAbstractAnimationPrivate::get(animation)->isPause) { - if (animation->duration() == -1) - qDebug() << "toto"; runningPauseAnimations << animation; } else runningLeafAnimations++; -- cgit v0.12 From 3e03a6330de1bf4b96fc990d2204826ffd5d2bb4 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 22 Jan 2010 11:10:35 +0100 Subject: Fix rendering with simple shader in GL2 engine Need to bind the PMV matrix's attributes to their indexes in the simple shader, which is created in a seperate code path to all the other shaders. This should fix the qgl autotest failures. Reviewed-By: TrustMe --- src/opengl/gl2paintengineex/qglengineshadermanager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 9fd9e18..8183f08 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -184,6 +184,9 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) simpleShaderProg->addShader(vertexShader); simpleShaderProg->addShader(fragShader); simpleShaderProg->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); + simpleShaderProg->bindAttributeLocation("pmvMatrix1", QT_PMV_MATRIX_1_ATTR); + simpleShaderProg->bindAttributeLocation("pmvMatrix2", QT_PMV_MATRIX_2_ATTR); + simpleShaderProg->bindAttributeLocation("pmvMatrix3", QT_PMV_MATRIX_3_ATTR); simpleShaderProg->link(); if (!simpleShaderProg->isLinked()) { qCritical() << "Errors linking simple shader:" -- cgit v0.12 From 0f59e2a256266e9981a56945103ffd2a850f0d95 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 22 Jan 2010 12:39:18 +0100 Subject: Fix y-inverted pixmaps properly. There is a lot of code depending on that pixmaps are flipped upside down in the gl graphicssystem, so toggling this requires extensive testing. Since we're anyway questioning the relevance of this feature (compared to raster + GL viewport) its simply not worth the effort to fix it properly right now. Revert "Fixed y-inverted pixmaps on N900." This reverts commit 57473d5d2a7bd6ae3117f61ff29264a1b790bb01. --- src/opengl/qpixmapdata_gl.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index 6d47687..aa80664 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -252,10 +252,6 @@ QGLPixmapData::QGLPixmapData(PixelType type) { setSerialNumber(++qt_gl_pixmap_serial); m_glDevice.setPixmapData(this); - - // Set InteralBindOptions minus the memory managed, since this - // QGLTexture is not managed as part of the internal texture cache - m_texture.options = QGLContext::PremultipliedAlphaBindOption; } QGLPixmapData::~QGLPixmapData() @@ -344,18 +340,18 @@ void QGLPixmapData::ensureCreated() const } if (!m_source.isNull()) { - glBindTexture(target, m_texture.id); if (external_format == GL_RGB) { - const QImage tx = m_source.convertToFormat(QImage::Format_RGB888); + const QImage tx = m_source.convertToFormat(QImage::Format_RGB888).mirrored(false, true); + + glBindTexture(target, m_texture.id); glTexSubImage2D(target, 0, 0, 0, w, h, external_format, GL_UNSIGNED_BYTE, tx.bits()); } else { const QImage tx = ctx->d_func()->convertToGLFormat(m_source, true, external_format); + + glBindTexture(target, m_texture.id); glTexSubImage2D(target, 0, 0, 0, w, h, external_format, GL_UNSIGNED_BYTE, tx.bits()); - // convertToGLFormat will flip the Y axis, so it needs to - // be drawn upside down - m_texture.options |= QGLContext::InvertedYBindOption; } if (useFramebufferObjects()) -- cgit v0.12 From 98e2e1d674669bdfb773ddc8b8281eeb935a14e1 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 22 Jan 2010 13:55:31 +0100 Subject: revert parts of 10392eef4fd4f9 We can't call QCOMPARE from within a nested function, because the return statement will just exit that function. VERIFY_COLOR can't be turned into a function this way. --- tests/auto/qwidget/tst_qwidget.cpp | 50 ++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index ee4e726..ea90ae3 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -5439,26 +5439,24 @@ public: QRegion r; }; -template -void verifyColor(R const& region, C const& color) -{ - const QRegion r = QRegion(region); - for (int i = 0; i < r.rects().size(); ++i) { - const QRect rect = r.rects().at(i); - for (int t = 0; t < 5; t++) { - const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), - rect.left(), rect.top(), - rect.width(), rect.height()); - QCOMPARE(pixmap.size(), rect.size()); - QPixmap expectedPixmap(pixmap); /* ensure equal formats */ - expectedPixmap.fill(color); - if (pixmap.toImage().pixel(0,0) != QColor(color).rgb() && t < 4 ) - { QTest::qWait(200); continue; } - QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb()); - QCOMPARE(pixmap, expectedPixmap); - break; - } - } +#define VERIFY_COLOR(region, color) { \ + const QRegion r = QRegion(region); \ + for (int i = 0; i < r.rects().size(); ++i) { \ + const QRect rect = r.rects().at(i); \ + for (int t = 0; t < 5; t++) { \ + const QPixmap pixmap = QPixmap::grabWindow(QDesktopWidget().winId(), \ + rect.left(), rect.top(), \ + rect.width(), rect.height()); \ + QCOMPARE(pixmap.size(), rect.size()); \ + QPixmap expectedPixmap(pixmap); /* ensure equal formats */ \ + expectedPixmap.fill(color); \ + if (pixmap.toImage().pixel(0,0) != QColor(color).rgb() && t < 4 ) \ + { QTest::qWait(200); continue; } \ + QCOMPARE(pixmap.toImage().pixel(0,0), QColor(color).rgb()); \ + QCOMPARE(pixmap, expectedPixmap); \ + break; \ + } \ + } \ } void tst_QWidget::moveChild_data() @@ -5499,9 +5497,9 @@ void tst_QWidget::moveChild() #endif QTRY_COMPARE(parent.r, QRegion(parent.rect()) - child.geometry()); QTRY_COMPARE(child.r, QRegion(child.rect())); - verifyColor(child.geometry().translated(tlwOffset), + VERIFY_COLOR(child.geometry().translated(tlwOffset), child.color); - verifyColor(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), + VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), parent.color); parent.reset(); child.reset(); @@ -5520,9 +5518,9 @@ void tst_QWidget::moveChild() // should be scrolled in backingstore QCOMPARE(child.r, QRegion()); #endif - verifyColor(child.geometry().translated(tlwOffset), + VERIFY_COLOR(child.geometry().translated(tlwOffset), child.color); - verifyColor(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), + VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), parent.color); } @@ -5553,8 +5551,8 @@ void tst_QWidget::showAndMoveChild() child.move(desktopDimensions.width()/2, desktopDimensions.height()/2); qApp->processEvents(); - verifyColor(child.geometry().translated(tlwOffset), Qt::blue); - verifyColor(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), Qt::red); + VERIFY_COLOR(child.geometry().translated(tlwOffset), Qt::blue); + VERIFY_COLOR(QRegion(parent.geometry()) - child.geometry().translated(tlwOffset), Qt::red); } void tst_QWidget::subtractOpaqueSiblings() -- cgit v0.12 From c8d6b751955d2857385a44aafd1ecade8d4d3c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 22 Jan 2010 13:56:21 +0100 Subject: Re-added the Close button in QPrintPreviewDialog for Mac/Carbon. Modal Mac/Carbon dialogs do not have the close, minimize and resize window title buttons enabled, which makes it very hard to close modal dialogs. Task-number: QTBUG-7481 Reviewed-by: Kim --- src/gui/dialogs/qprintpreviewdialog.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gui/dialogs/qprintpreviewdialog.cpp b/src/gui/dialogs/qprintpreviewdialog.cpp index 42be780..6723b53 100644 --- a/src/gui/dialogs/qprintpreviewdialog.cpp +++ b/src/gui/dialogs/qprintpreviewdialog.cpp @@ -207,6 +207,9 @@ public: QActionGroup *printerGroup; QAction *printAction; QAction *pageSetupAction; +#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) + QAction *closeAction; +#endif QPointer receiverToDisconnectOnClose; QByteArray memberToDisconnectOnClose; @@ -287,6 +290,9 @@ void QPrintPreviewDialogPrivate::init(QPrinter *_printer) toolbar->addSeparator(); toolbar->addAction(pageSetupAction); toolbar->addAction(printAction); +#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) + toolbar->addAction(closeAction); +#endif // Cannot use the actions' triggered signal here, since it doesn't autorepeat QToolButton *zoomInButton = static_cast(toolbar->widgetForAction(zoomInAction)); @@ -406,6 +412,10 @@ void QPrintPreviewDialogPrivate::setupActions() qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup")); QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print())); QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup())); +#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) + closeAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Close")); + QObject::connect(closeAction, SIGNAL(triggered(bool)), q, SLOT(reject())); +#endif // Initial state: fitPageAction->setChecked(true); -- cgit v0.12 From ef427d48fa684578ecb69e4e1ce2072f12362682 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 22 Jan 2010 14:47:15 +0100 Subject: Fix QPainter::redirection() to pass autotest. Reviewed-by: Trond --- src/gui/painting/qpainter.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 1258d6b..cde6a2d 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7503,15 +7503,14 @@ QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset) { Q_ASSERT(device != 0); - if (*globalRedirectionAtomic() == 0) - return 0; - if (device->devType() == QInternal::Widget) { const QWidgetPrivate *widgetPrivate = static_cast(device)->d_func(); if (widgetPrivate->redirectDev) return widgetPrivate->redirected(offset); } + if (*globalRedirectionAtomic() == 0) + return 0; QMutexLocker locker(globalRedirectionsMutex()); QPaintDeviceRedirectionList *redirections = globalRedirections(); -- cgit v0.12 From 4bcc8a24129b69efa1217dd033f0af949df0bcb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Fri, 22 Jan 2010 12:46:32 +0100 Subject: QGraphicsWidget is painted twice on the inital show. Problem occured when doing something in the polishEvent() which eventually ended up as an update(). The problem was that in QGraphicsScene::addItem we scheduled a polish event after scheduling an update, resulting in update requests being processed before polish requests. Auto-test included. Task-number: QTBUG-6956 Reviewed-by: alexis --- src/gui/graphicsview/qgraphicsitem_p.h | 2 ++ src/gui/graphicsview/qgraphicsscene.cpp | 22 +++++++++++++------ src/gui/graphicsview/qgraphicsscene_p.h | 2 +- tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 25 ++++++++++++++++++++++ 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index ac10aa7..bdd8863 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -178,6 +178,7 @@ public: sequentialOrdering(1), updateDueToGraphicsEffect(0), scenePosDescendants(0), + pendingPolish(0), globalStackingOrder(-1), q_ptr(0) { @@ -486,6 +487,7 @@ public: quint32 sequentialOrdering : 1; quint32 updateDueToGraphicsEffect : 1; quint32 scenePosDescendants : 1; + quint32 pendingPolish : 1; // Optional stacking order int globalStackingOrder; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 088a6b9..7e182d0 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -429,12 +429,13 @@ void QGraphicsScenePrivate::unregisterTopLevelItem(QGraphicsItem *item) */ void QGraphicsScenePrivate::_q_polishItems() { - QSet::Iterator it = unpolishedItems.begin(); + QVector::Iterator it = unpolishedItems.begin(); const QVariant booleanTrueVariant(true); while (!unpolishedItems.isEmpty()) { QGraphicsItem *item = *it; it = unpolishedItems.erase(it); unpolishedItemsModified = false; + item->d_ptr->pendingPolish = false; if (!item->d_ptr->explicitlyHidden) { item->itemChange(QGraphicsItem::ItemVisibleChange, booleanTrueVariant); item->itemChange(QGraphicsItem::ItemVisibleHasChanged, booleanTrueVariant); @@ -638,8 +639,14 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) selectedItems.remove(item); hoverItems.removeAll(item); cachedItemsUnderMouse.removeAll(item); - unpolishedItems.remove(item); - unpolishedItemsModified = true; + if (item->d_ptr->pendingPolish) { + const int unpolishedIndex = unpolishedItems.indexOf(item); + if (unpolishedIndex != -1) { + unpolishedItems.remove(unpolishedIndex); + unpolishedItemsModified = true; + } + item->d_ptr->pendingPolish = false; + } resetDirtyItem(item); //We remove all references of item from the sceneEventFilter arrays @@ -2501,6 +2508,11 @@ void QGraphicsScene::addItem(QGraphicsItem *item) return; } + if (d->unpolishedItems.isEmpty()) + QMetaObject::invokeMethod(this, "_q_polishItems", Qt::QueuedConnection); + d->unpolishedItems.append(item); + item->d_ptr->pendingPolish = true; + // Detach this item from its parent if the parent's scene is different // from this scene. if (QGraphicsItem *itemParent = item->d_ptr->parent) { @@ -2583,10 +2595,6 @@ void QGraphicsScene::addItem(QGraphicsItem *item) item->d_ptr->resolveFont(d->font.resolve()); item->d_ptr->resolvePalette(d->palette.resolve()); - if (d->unpolishedItems.isEmpty()) - QMetaObject::invokeMethod(this, "_q_polishItems", Qt::QueuedConnection); - d->unpolishedItems.insert(item); - d->unpolishedItemsModified = true; // Reenable selectionChanged() for individual items --d->selectionChanging; diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index d10811c..a3e36d0 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -108,7 +108,7 @@ public: QPainterPath selectionArea; int selectionChanging; QSet selectedItems; - QSet unpolishedItems; + QVector unpolishedItems; QList topLevelItems; bool needSortTopLevelItems; bool unpolishedItemsModified; diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 909ea54..d3132fe 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -163,6 +163,7 @@ private slots: void addChildInpolishEvent(); void polishEvent(); void polishEvent2(); + void initialShow(); // Task fixes void task236127_bspTreeIndexFails(); @@ -2856,6 +2857,30 @@ void tst_QGraphicsWidget::polishEvent2() QVERIFY(widget->events.contains(QEvent::Polish)); } +void tst_QGraphicsWidget::initialShow() +{ + class MyGraphicsWidget : public QGraphicsWidget + { public: + MyGraphicsWidget() : repaints(0) {} + int repaints; + void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget*) { ++repaints; } + void polishEvent() { update(); } + }; + + QGraphicsScene scene; + MyGraphicsWidget *widget = new MyGraphicsWidget; + + QGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + + QTest::qWait(100); + scene.addItem(widget); + QTest::qWait(100); + + QCOMPARE(widget->repaints, 1); +} + void tst_QGraphicsWidget::QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems() { QGraphicsScene scene; -- cgit v0.12 From 9f8272b979be69574ae7e5211219363b03d23316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Fri, 22 Jan 2010 17:25:38 +0100 Subject: Potential crash when adding items from QGraphicsWidget::polishEvent(). These were processed immediately, so there was a fair chance that we could end up doing a virtual function call on items that were not fully constructed. This patch is also an optimization, since we never remove anything from the vector. Auto-test included. Reviewed-by: Jan-Arve --- src/gui/graphicsview/qgraphicsscene.cpp | 42 ++++++++++++++--------- src/gui/graphicsview/qgraphicsscene_p.h | 1 - tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 43 ++++++++++++++++++++++-- 3 files changed, 68 insertions(+), 18 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 7e182d0..ae48bee 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -292,7 +292,6 @@ QGraphicsScenePrivate::QGraphicsScenePrivate() processDirtyItemsEmitted(false), selectionChanging(0), needSortTopLevelItems(true), - unpolishedItemsModified(true), holesInTopLevelSiblingIndex(false), topLevelSequentialOrdering(true), scenePosDescendantsUpdatePending(false), @@ -429,23 +428,38 @@ void QGraphicsScenePrivate::unregisterTopLevelItem(QGraphicsItem *item) */ void QGraphicsScenePrivate::_q_polishItems() { - QVector::Iterator it = unpolishedItems.begin(); + if (unpolishedItems.isEmpty()) + return; + const QVariant booleanTrueVariant(true); - while (!unpolishedItems.isEmpty()) { - QGraphicsItem *item = *it; - it = unpolishedItems.erase(it); - unpolishedItemsModified = false; - item->d_ptr->pendingPolish = false; - if (!item->d_ptr->explicitlyHidden) { + QGraphicsItem *item = 0; + QGraphicsItemPrivate *itemd = 0; + const int oldUnpolishedCount = unpolishedItems.count(); + + for (int i = 0; i < oldUnpolishedCount; ++i) { + item = unpolishedItems.at(i); + if (!item) + continue; + itemd = item->d_ptr.data(); + itemd->pendingPolish = false; + if (!itemd->explicitlyHidden) { item->itemChange(QGraphicsItem::ItemVisibleChange, booleanTrueVariant); item->itemChange(QGraphicsItem::ItemVisibleHasChanged, booleanTrueVariant); } - if (item->isWidget()) { + if (itemd->isWidget) { QEvent event(QEvent::Polish); QApplication::sendEvent((QGraphicsWidget *)item, &event); } - if (unpolishedItemsModified) - it = unpolishedItems.begin(); + } + + if (unpolishedItems.count() == oldUnpolishedCount) { + // No new items were added to the vector. + unpolishedItems.clear(); + } else { + // New items were appended; keep them and remove the old ones. + unpolishedItems.remove(0, oldUnpolishedCount); + unpolishedItems.squeeze(); + QMetaObject::invokeMethod(q_ptr, "_q_polishItems", Qt::QueuedConnection); } } @@ -641,10 +655,8 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) cachedItemsUnderMouse.removeAll(item); if (item->d_ptr->pendingPolish) { const int unpolishedIndex = unpolishedItems.indexOf(item); - if (unpolishedIndex != -1) { - unpolishedItems.remove(unpolishedIndex); - unpolishedItemsModified = true; - } + if (unpolishedIndex != -1) + unpolishedItems[unpolishedIndex] = 0; item->d_ptr->pendingPolish = false; } resetDirtyItem(item); diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index a3e36d0..54d8130 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -111,7 +111,6 @@ public: QVector unpolishedItems; QList topLevelItems; bool needSortTopLevelItems; - bool unpolishedItemsModified; bool holesInTopLevelSiblingIndex; bool topLevelSequentialOrdering; diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index c08a628e..547e7f5 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -270,6 +270,7 @@ private slots: void initialFocus_data(); void initialFocus(); void polishItems(); + void polishItems2(); void isActive(); void siblingIndexAlwaysValid(); @@ -3942,14 +3943,23 @@ void tst_QGraphicsScene::initialFocus() class PolishItem : public QGraphicsTextItem { public: - PolishItem(QGraphicsItem *parent = 0) : QGraphicsTextItem(parent) { } + PolishItem(QGraphicsItem *parent = 0) + : QGraphicsTextItem(parent), polished(false), deleteChildrenInPolish(true), addChildrenInPolish(false) { } + bool polished; + bool deleteChildrenInPolish; + bool addChildrenInPolish; protected: QVariant itemChange(GraphicsItemChange change, const QVariant& value) { if (change == ItemVisibleChange) { - if (value.toBool()) + polished = true; + if (deleteChildrenInPolish) qDeleteAll(childItems()); + if (addChildrenInPolish) { + for (int i = 0; i < 10; ++i) + new PolishItem(this); + } } return QGraphicsItem::itemChange(change, value); } @@ -3966,6 +3976,35 @@ void tst_QGraphicsScene::polishItems() QMetaObject::invokeMethod(&scene,"_q_polishItems"); } +void tst_QGraphicsScene::polishItems2() +{ + QGraphicsScene scene; + PolishItem *item = new PolishItem; + item->addChildrenInPolish = true; + item->deleteChildrenInPolish = true; + // These children should be deleted in the polish. + for (int i = 0; i < 20; ++i) + new PolishItem(item); + scene.addItem(item); + + // Wait for the polish event to be delivered. + QVERIFY(!item->polished); + QApplication::processEvents(); + QVERIFY(item->polished); + + // We deleted the children we added above, but we also + // added 10 new children. These should be polished in the next + // event loop iteration. + QList children = item->childItems(); + QCOMPARE(children.count(), 10); + foreach (QGraphicsItem *child, children) + QVERIFY(!static_cast(child)->polished); + + QApplication::processEvents(); + foreach (QGraphicsItem *child, children) + QVERIFY(static_cast(child)->polished); +} + void tst_QGraphicsScene::isActive() { QGraphicsScene scene1; -- cgit v0.12 From 3ec5241a21d233cac879e535719fb546f391add3 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 22 Jan 2010 13:15:21 -0800 Subject: Implement QDirectFBPixmapData::scroll This is a very operation in DirectFB and saves a fair bit of overhead. Reviewed-by: Donald Carr --- .../gfxdrivers/directfb/qdirectfbpixmap.cpp | 31 +++++++++++++++++++--- src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h | 1 + 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index 1cbfdaf..f27440e 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -552,6 +552,34 @@ QImage *QDirectFBPixmapData::buffer() return &lockedImage; } + +bool QDirectFBPixmapData::scroll(int dx, int dy, const QRect &rect) +{ + if (!dfbSurface) { + return false; + } + unlockSurface(); + DFBResult result = dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX); + if (result != DFB_OK) { + DirectFBError("QDirectFBPixmapData::scroll", result); + return false; + } + result = dfbSurface->SetPorterDuff(dfbSurface, DSPD_NONE); + if (result != DFB_OK) { + DirectFBError("QDirectFBPixmapData::scroll", result); + return false; + } + + const DFBRectangle source = { rect.x(), rect.y(), rect.width(), rect.height() }; + result = dfbSurface->Blit(dfbSurface, dfbSurface, &source, source.x + dx, source.y + dy); + if (result != DFB_OK) { + DirectFBError("QDirectFBPixmapData::scroll", result); + return false; + } + + return true; +} + void QDirectFBPixmapData::invalidate() { if (dfbSurface) { @@ -568,6 +596,3 @@ void QDirectFBPixmapData::invalidate() QT_END_NAMESPACE #endif // QT_NO_QWS_DIRECTFB - - - diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h index f9b14a9..da6edc6 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h @@ -81,6 +81,7 @@ public: virtual QImage toImage() const; virtual QPaintEngine *paintEngine() const; virtual QImage *buffer(); + virtual bool scroll(int dx, int dy, const QRect &rect); // Pure virtual in QPixmapData, so re-implement here and delegate to QDirectFBPaintDevice virtual int metric(QPaintDevice::PaintDeviceMetric m) const { return QDirectFBPaintDevice::metric(m); } -- cgit v0.12 From 9098631b8a3927ebdf945ccdbaf20b9a7616636d Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 22 Jan 2010 17:36:05 +0100 Subject: Another ASSERT while deleting spans That rare case when we are deleting the last span was not being taken care of. Unbelievable but true. Auto-test included. Reviewed-by: Thierry Reviewed-by: leo Task-number: QTBUG-6004 --- src/gui/itemviews/qtableview.cpp | 4 +++- tests/auto/qtableview/tst_qtableview.cpp | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index 7eefb0b..3111896 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -114,7 +114,9 @@ void QSpanCollection::updateSpan(QSpanCollection::Span *span, int old_height) } } else if (old_height > span->height()) { //remove the span from all the subspans lists that intersect the columns not covered anymore - Index::iterator it_y = index.lowerBound(qMin(-span->bottom(), 0)); + Index::iterator it_y = index.lowerBound(-span->bottom()); + if (it_y == index.end()) + it_y = index.find(-span->top()); // This is the only span remaining and we are deleting it. Q_ASSERT(it_y != index.end()); //it_y must exist since the span is in the list while (-it_y.key() <= span->top() + old_height -1) { if (-it_y.key() > span->bottom()) { diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 7a5e68f..430712c 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -3024,6 +3024,14 @@ void tst_QTableView::spans_data() << QPoint(0, 0) << 1 << 1; + + QTest::newRow("QTBUG-6004 (follow-up): No failing Q_ASSERT, then it passes.") + << 10 << 10 + << (SpanList() << QRect(2, 2, 1, 3) << QRect(2, 2, 1, 1)) + << false + << QPoint(0, 0) + << 1 + << 1; } void tst_QTableView::spans() -- cgit v0.12 From 3741fd9aed480f5db37502cc57634fec97432e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 15 Jan 2010 13:23:51 +0100 Subject: Small optimization in raster paint engine. Don't repeatedly update the pen / brush if no pen / brush is set. Reviewed-by: Gunnar Sletta --- src/gui/painting/qpaintengine_raster_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index b937f66..a1c73cc 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -264,13 +264,13 @@ private: #endif // Q_OS_SYMBIAN && QT_NO_FREETYPE inline void ensureBrush(const QBrush &brush) { - if (!qbrush_fast_equals(state()->lastBrush, brush) || state()->fillFlags) + if (!qbrush_fast_equals(state()->lastBrush, brush) || (brush.style() != Qt::NoBrush && state()->fillFlags)) updateBrush(brush); } inline void ensureBrush() { ensureBrush(state()->brush); } inline void ensurePen(const QPen &pen) { - if (!qpen_fast_equals(state()->lastPen, pen) || state()->strokeFlags) + if (!qpen_fast_equals(state()->lastPen, pen) || (pen.style() != Qt::NoPen && state()->strokeFlags)) updatePen(pen); } inline void ensurePen() { ensurePen(state()->pen); } -- cgit v0.12 From 00371f6b694c98e44799a15058002ab58ab389d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 19 Jan 2010 15:04:07 +0100 Subject: Made the trace replayer handle limited resolution cases better. Simply skip the updates that are outside the replay widget's bounds. Reviewed-by: Gunnar Sletta --- tools/qttracereplay/main.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/tools/qttracereplay/main.cpp b/tools/qttracereplay/main.cpp index 85e9b12..a932d72 100644 --- a/tools/qttracereplay/main.cpp +++ b/tools/qttracereplay/main.cpp @@ -52,6 +52,7 @@ public: ReplayWidget(const QString &filename); void paintEvent(QPaintEvent *event); + void resizeEvent(QResizeEvent *event); public slots: void updateRect(); @@ -64,14 +65,15 @@ public: int currentIteration; QTime timer; + QList visibleUpdates; QList iterationTimes; QString filename; }; void ReplayWidget::updateRect() { - if (!updates.isEmpty()) - update(updates.at(currentFrame)); + if (!visibleUpdates.isEmpty()) + update(updates.at(visibleUpdates.at(currentFrame))); } void ReplayWidget::paintEvent(QPaintEvent *) @@ -80,10 +82,10 @@ void ReplayWidget::paintEvent(QPaintEvent *) // p.setClipRegion(frames.at(currentFrame).updateRegion); - buffer.draw(&p, currentFrame); + buffer.draw(&p, visibleUpdates.at(currentFrame)); ++currentFrame; - if (currentFrame >= buffer.numFrames()) { + if (currentFrame >= visibleUpdates.size()) { currentFrame = 0; ++currentIteration; @@ -119,7 +121,7 @@ void ReplayWidget::paintEvent(QPaintEvent *) if (iterationTimes.size() >= 10 || stddev < 4) { printf("%s, iterations: %d, frames: %d, min(ms): %d, median(ms): %d, stddev: %f %%, max(fps): %f\n", qPrintable(filename), - iterationTimes.size(), updates.size(), min, median, stddev, 1000. * updates.size() / min); + iterationTimes.size(), visibleUpdates.size(), min, median, stddev, 1000. * visibleUpdates.size() / min); deleteLater(); return; } @@ -130,6 +132,21 @@ void ReplayWidget::paintEvent(QPaintEvent *) QTimer::singleShot(0, this, SLOT(updateRect())); } +void ReplayWidget::resizeEvent(QResizeEvent *event) +{ + visibleUpdates.clear(); + + QRect bounds = rect(); + for (int i = 0; i < updates.size(); ++i) { + if (updates.at(i).intersects(bounds)) + visibleUpdates << i; + } + + if (visibleUpdates.size() != updates.size()) + printf("Warning: skipped %d frames due to limited resolution\n", updates.size() - visibleUpdates.size()); + +} + ReplayWidget::ReplayWidget(const QString &filename_) : currentFrame(0) , currentIteration(0) @@ -138,7 +155,6 @@ ReplayWidget::ReplayWidget(const QString &filename_) setWindowTitle(filename); QFile file(filename); - QRect bounds; if (!file.open(QIODevice::ReadOnly)) { printf("Failed to load input file '%s'\n", qPrintable(filename_)); return; -- cgit v0.12 From d867c403dfbc284e2f564939622854900ab66919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 14 Jan 2010 13:46:52 +0100 Subject: Fixed child items with graphics effects not inheriting opacity. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to invalidate the graphics source pixmap cache for both child items and parent items when changing the opacity of a graphics item. Reviewed-by: Bjørn Erik Nilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 23 +++++++++++++-- src/gui/graphicsview/qgraphicsitem_p.h | 6 +++- tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 34 ++++++++++++++++++++-- 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 1139be0..f4767b8 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -2567,7 +2567,9 @@ void QGraphicsItem::setOpacity(qreal opacity) // Update. if (d_ptr->scene) { #ifndef QT_NO_GRAPHICSEFFECT - d_ptr->invalidateGraphicsEffectsRecursively(); + d_ptr->invalidateParentGraphicsEffectsRecursively(); + if (!(d_ptr->flags & ItemDoesntPropagateOpacityToChildren)) + d_ptr->invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::OpacityChanged); #endif //QT_NO_GRAPHICSEFFECT d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true, @@ -5077,7 +5079,7 @@ int QGraphicsItemPrivate::depth() const \internal */ #ifndef QT_NO_GRAPHICSEFFECT -void QGraphicsItemPrivate::invalidateGraphicsEffectsRecursively() +void QGraphicsItemPrivate::invalidateParentGraphicsEffectsRecursively() { QGraphicsItemPrivate *itemPrivate = this; do { @@ -5089,6 +5091,21 @@ void QGraphicsItemPrivate::invalidateGraphicsEffectsRecursively() } } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0)); } + +void QGraphicsItemPrivate::invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::InvalidateReason reason) +{ + for (int i = 0; i < children.size(); ++i) { + QGraphicsItemPrivate *childPrivate = children.at(i)->d_ptr.data(); + if (reason == OpacityChanged && (childPrivate->flags & QGraphicsItem::ItemIgnoresParentOpacity)) + continue; + if (childPrivate->graphicsEffect) { + childPrivate->notifyInvalidated = 1; + static_cast(childPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache(); + } + + childPrivate->invalidateChildGraphicsEffectsRecursively(reason); + } +} #endif //QT_NO_GRAPHICSEFFECT /*! @@ -5333,7 +5350,7 @@ void QGraphicsItem::update(const QRectF &rect) // Make sure we notify effects about invalidated source. #ifndef QT_NO_GRAPHICSEFFECT - d_ptr->invalidateGraphicsEffectsRecursively(); + d_ptr->invalidateParentGraphicsEffectsRecursively(); #endif //QT_NO_GRAPHICSEFFECT if (CacheMode(d_ptr->cacheMode) != NoCache) { diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index bdd8863..ff6e8bd 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -225,7 +225,11 @@ public: bool ignoreDirtyBit = false, bool ignoreOpacity = false) const; int depth() const; #ifndef QT_NO_GRAPHICSEFFECT - void invalidateGraphicsEffectsRecursively(); + enum InvalidateReason { + OpacityChanged + }; + void invalidateParentGraphicsEffectsRecursively(); + void invalidateChildGraphicsEffectsRecursively(InvalidateReason reason); #endif //QT_NO_GRAPHICSEFFECT void invalidateDepthRecursively(); void resolveDepth(); diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index 51e2a57..795431b 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -71,6 +71,7 @@ private slots: void colorize(); void drawPixmapItem(); void deviceCoordinateTranslateCaching(); + void inheritOpacity(); }; void tst_QGraphicsEffect::initTestCase() @@ -79,8 +80,8 @@ void tst_QGraphicsEffect::initTestCase() class CustomItem : public QGraphicsRectItem { public: - CustomItem(qreal x, qreal y, qreal width, qreal height) - : QGraphicsRectItem(x, y, width, height), numRepaints(0), + CustomItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent = 0) + : QGraphicsRectItem(x, y, width, height, parent), numRepaints(0), m_painter(0), m_styleOption(0) {} @@ -560,6 +561,35 @@ void tst_QGraphicsEffect::deviceCoordinateTranslateCaching() QVERIFY(item->numRepaints == numRepaints); } +void tst_QGraphicsEffect::inheritOpacity() +{ + QGraphicsScene scene; + QGraphicsRectItem *rectItem = new QGraphicsRectItem(0, 0, 10, 10); + CustomItem *item = new CustomItem(0, 0, 10, 10, rectItem); + + scene.addItem(rectItem); + + item->setGraphicsEffect(new DeviceEffect); + item->setPen(Qt::NoPen); + item->setBrush(Qt::red); + + rectItem->setOpacity(0.5); + + QGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + + QTRY_VERIFY(item->numRepaints >= 1); + + int numRepaints = item->numRepaints; + + rectItem->setOpacity(1); + QTest::qWait(50); + + // item should have been rerendered due to opacity changing + QTRY_VERIFY(item->numRepaints > numRepaints); +} + QTEST_MAIN(tst_QGraphicsEffect) #include "tst_qgraphicseffect.moc" -- cgit v0.12 From 6a1a7d4ff16b87275a06c83e5316f778c974dba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 25 Jan 2010 11:52:14 +0100 Subject: Added optimization flag to QGraphicsItemPrivate. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid traversing the whole child hierarchy when opacity changes unless there are children with graphics effects. Reviewed-by: Bjørn Erik Nilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 22 ++++++++++++++++++++++ src/gui/graphicsview/qgraphicsitem_p.h | 3 +++ 2 files changed, 25 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index f4767b8..f81cb23 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1077,6 +1077,10 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q p = p->d_ptr->parent; } + // Update graphics effect optimization flag + if (newParent && (graphicsEffect || mayHaveChildWithGraphicsEffect)) + newParent->d_ptr->updateChildWithGraphicsEffectFlagRecursively(); + // Update focus scope item ptr in new scope. QGraphicsItem *newFocusScopeItem = subFocusItem ? subFocusItem : parentFocusScopeItem; if (newFocusScopeItem && newParent) { @@ -2614,6 +2618,8 @@ void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect) if (d_ptr->graphicsEffect) { delete d_ptr->graphicsEffect; d_ptr->graphicsEffect = 0; + } else if (d_ptr->parent) { + d_ptr->parent->d_ptr->updateChildWithGraphicsEffectFlagRecursively(); } if (effect) { @@ -2627,6 +2633,19 @@ void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect) } #endif //QT_NO_GRAPHICSEFFECT +void QGraphicsItemPrivate::updateChildWithGraphicsEffectFlagRecursively() +{ +#ifndef QT_NO_GRAPHICSEFFECT + QGraphicsItemPrivate *itemPrivate = this; + do { + // parent chain already notified? + if (itemPrivate->mayHaveChildWithGraphicsEffect) + return; + itemPrivate->mayHaveChildWithGraphicsEffect = 1; + } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0)); +#endif +} + /*! \internal \since 4.6 @@ -5094,6 +5113,9 @@ void QGraphicsItemPrivate::invalidateParentGraphicsEffectsRecursively() void QGraphicsItemPrivate::invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::InvalidateReason reason) { + if (!mayHaveChildWithGraphicsEffect) + return; + for (int i = 0; i < children.size(); ++i) { QGraphicsItemPrivate *childPrivate = children.at(i)->d_ptr.data(); if (reason == OpacityChanged && (childPrivate->flags & QGraphicsItem::ItemIgnoresParentOpacity)) diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index ff6e8bd..986a977 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -179,6 +179,7 @@ public: updateDueToGraphicsEffect(0), scenePosDescendants(0), pendingPolish(0), + mayHaveChildWithGraphicsEffect(0), globalStackingOrder(-1), q_ptr(0) { @@ -196,6 +197,7 @@ public: return item->d_ptr.data(); } + void updateChildWithGraphicsEffectFlagRecursively(); void updateAncestorFlag(QGraphicsItem::GraphicsItemFlag childFlag, AncestorFlag flag = NoFlag, bool enabled = false, bool root = true); void updateAncestorFlags(); @@ -492,6 +494,7 @@ public: quint32 updateDueToGraphicsEffect : 1; quint32 scenePosDescendants : 1; quint32 pendingPolish : 1; + quint32 mayHaveChildWithGraphicsEffect : 1; // Optional stacking order int globalStackingOrder; -- cgit v0.12 From 38b0bc95448f65404f56c6dfebc54dc5f33c11a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Mon, 25 Jan 2010 17:30:26 +0100 Subject: Updated docs regarding QGLWidget::renderText() limitations. Reviewed-by: Trust Me --- src/opengl/qgl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 3f32cf3..48e43b2 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4393,6 +4393,13 @@ static void qt_gl_draw_text(QPainter *p, int x, int y, const QString &str, \note This function temporarily disables depth-testing when the text is drawn. + \note This function can only be used inside a + QPainter::beginNativePainting()/QPainter::endNativePainting() block + if the default OpenGL paint engine is QPaintEngine::OpenGL. To make + QPaintEngine::OpenGL the default GL engine, call + QGL::setPreferredPaintEngine(QPaintEngine::OpenGL) before the + QApplication constructor. + \l{Overpainting Example}{Overpaint} with QPainter::drawText() instead. */ -- cgit v0.12 From cb9ff7135854b16fdebb637b28284d1e1883044c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 26 Jan 2010 10:55:31 +0100 Subject: Fixed an infinite loop that could occur when reading invalid BMP images. Task-number: QTBUG-7530 Reviewed-by: Kim --- src/gui/image/qbmphandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index 854be2e..42e19b8 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -144,7 +144,7 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi) static int calc_shift(int mask) { int result = 0; - while (!(mask & 1)) { + while (mask && !(mask & 1)) { result++; mask >>= 1; } -- cgit v0.12 From 0c85477397531cd624b8558bfa2cc6b3ccc9572c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 26 Jan 2010 14:14:47 +0100 Subject: Stabilize tst_QGraphicsScene::polishItems2 (new test) We are only interested in getting the posted MetaCall events delivered, so we can get away with sendPostedEvents() instead of processEvents(). Makes the test also pass on Mac g++ carbon 32. --- tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 547e7f5..6743fbe 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -3989,7 +3989,7 @@ void tst_QGraphicsScene::polishItems2() // Wait for the polish event to be delivered. QVERIFY(!item->polished); - QApplication::processEvents(); + QApplication::sendPostedEvents(&scene, QEvent::MetaCall); QVERIFY(item->polished); // We deleted the children we added above, but we also @@ -4000,7 +4000,7 @@ void tst_QGraphicsScene::polishItems2() foreach (QGraphicsItem *child, children) QVERIFY(!static_cast(child)->polished); - QApplication::processEvents(); + QApplication::sendPostedEvents(&scene, QEvent::MetaCall); foreach (QGraphicsItem *child, children) QVERIFY(static_cast(child)->polished); } -- cgit v0.12 From c55229b3fc8dfb92abdaa633609aae75fa10e06d Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Fri, 8 Jan 2010 16:31:01 +0100 Subject: Fixes visibility update missing when doing setParentItem on graphicsitem Calling setParentItem is causing the previous opacity/visible updates to be discarded because the dirty flags were not propagated to the new parent. Also removed some unnecessary 'markDirty' and 'update' calls. Task-number: QTBUG-6738 Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 30 ++------- src/gui/graphicsview/qgraphicsitem_p.h | 33 ++++++++++ src/gui/graphicsview/qgraphicsscene.cpp | 14 +---- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 86 ++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 36 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index f81cb23..2089206 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1115,11 +1115,9 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q } if ((parent = newParent)) { - bool implicitUpdate = false; if (parent->d_func()->scene && parent->d_func()->scene != scene) { // Move this item to its new parent's scene parent->d_func()->scene->addItem(q); - implicitUpdate = true; } else if (!parent->d_func()->scene && scene) { // Remove this item from its former scene scene->removeItem(q); @@ -1129,25 +1127,25 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q if (thisPointerVariant) parent->itemChange(QGraphicsItem::ItemChildAddedChange, *thisPointerVariant); if (scene) { - if (!implicitUpdate) - scene->d_func()->markDirty(q_ptr); - // Re-enable scene pos notifications for new ancestors if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges)) scene->d_func()->setScenePosItemEnabled(q, true); } + // Propagate dirty flags to the new parent + markParentDirty(/*updateBoundingRect=*/true); + // Inherit ancestor flags from the new parent. updateAncestorFlags(); // Update item visible / enabled. if (parent->d_ptr->visible != visible) { if (!parent->d_ptr->visible || !explicitlyHidden) - setVisibleHelper(parent->d_ptr->visible, /* explicit = */ false, /* update = */ !implicitUpdate); + setVisibleHelper(parent->d_ptr->visible, /* explicit = */ false, /* update = */ false); } if (parent->isEnabled() != enabled) { if (!parent->d_ptr->enabled || !explicitlyDisabled) - setEnabledHelper(parent->d_ptr->enabled, /* explicit = */ false, /* update = */ !implicitUpdate); + setEnabledHelper(parent->d_ptr->enabled, /* explicit = */ false, /* update = */ false); } // Auto-activate if visible and the parent is active. @@ -1163,10 +1161,6 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q setVisibleHelper(true, /* explicit = */ false); if (!enabled && !explicitlyDisabled) setEnabledHelper(true, /* explicit = */ false); - - // If the item is being deleted, the whole scene will be updated. - if (scene) - scene->d_func()->markDirty(q_ptr); } } @@ -7265,19 +7259,7 @@ void QGraphicsItem::prepareGeometryChange() } } - QGraphicsItem *parent = this; - while ((parent = parent->d_ptr->parent)) { - QGraphicsItemPrivate *parentp = parent->d_ptr.data(); - parentp->dirtyChildrenBoundingRect = 1; - // ### Only do this if the parent's effect applies to the entire subtree. - parentp->notifyBoundingRectChanged = 1; -#ifndef QT_NO_GRAPHICSEFFECT - if (parentp->scene && parentp->graphicsEffect) { - parentp->notifyInvalidated = 1; - static_cast(parentp->graphicsEffect->d_func()->source->d_func())->invalidateCache(); - } -#endif - } + d_ptr->markParentDirty(/*updateBoundingRect=*/true); } /*! diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 986a977..5ad6cd5 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -406,6 +406,8 @@ public: return !visible || (childrenCombineOpacity() && isFullyTransparent()); } + inline void markParentDirty(bool updateBoundingRect = false); + void setFocusHelper(Qt::FocusReason focusReason, bool climb); void setSubFocus(QGraphicsItem *rootItem = 0); void clearSubFocus(QGraphicsItem *rootItem = 0); @@ -754,6 +756,37 @@ inline bool QGraphicsItemPrivate::insertionOrder(QGraphicsItem *a, QGraphicsItem return a->d_ptr->siblingIndex < b->d_ptr->siblingIndex; } +/*! + \internal +*/ +inline void QGraphicsItemPrivate::markParentDirty(bool updateBoundingRect) +{ + QGraphicsItemPrivate *parentp = this; + while (parentp->parent) { + parentp = parentp->parent->d_ptr.data(); + parentp->dirtyChildren = 1; + + if (updateBoundingRect) { + parentp->dirtyChildrenBoundingRect = 1; + // ### Only do this if the parent's effect applies to the entire subtree. + parentp->notifyBoundingRectChanged = 1; + } +#ifndef QT_NO_GRAPHICSEFFECT + if (parentp->graphicsEffect) { + if (updateBoundingRect) { + parentp->notifyInvalidated = 1; + static_cast(parentp->graphicsEffect->d_func() + ->source->d_func())->invalidateCache(); + } + if (parentp->graphicsEffect->isEnabled()) { + parentp->dirty = 1; + parentp->fullUpdatePending = 1; + } + } +#endif + } +} + QT_END_NAMESPACE #endif // QT_NO_GRAPHICSVIEW diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index ae48bee..9219773 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -1955,7 +1955,7 @@ QList QGraphicsScene::items(const QRectF &rectangle, Qt::ItemSe \since 4.3 This convenience function is equivalent to calling items(QRectF(\a x, \a y, \a w, \a h), \a mode). - + This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead. @@ -4903,17 +4903,7 @@ void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, b if (ignoreOpacity) item->d_ptr->ignoreOpacity = 1; - QGraphicsItem *p = item->d_ptr->parent; - while (p) { - p->d_ptr->dirtyChildren = 1; -#ifndef QT_NO_GRAPHICSEFFECT - if (p->d_ptr->graphicsEffect && p->d_ptr->graphicsEffect->isEnabled()) { - p->d_ptr->dirty = 1; - p->d_ptr->fullUpdatePending = 1; - } -#endif //QT_NO_GRAPHICSEFFECT - p = p->d_ptr->parent; - } + item->d_ptr->markParentDirty(); } static inline bool updateHelper(QGraphicsViewPrivate *view, QGraphicsItemPrivate *item, diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 8e43bce..14b9ef0 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -316,6 +316,7 @@ private slots: void childrenBoundingRectTransformed(); void childrenBoundingRect2(); void childrenBoundingRect3(); + void childrenBoundingRect4(); void group(); void setGroup(); void setGroup2(); @@ -417,6 +418,7 @@ private slots: void task197802_childrenVisibility(); void QTBUG_4233_updateCachedWithSceneRect(); void QTBUG_5418_textItemSetDefaultColor(); + void QTBUG_6738_missingUpdateWithSetParent(); private: QList paintedItems; @@ -3257,6 +3259,32 @@ void tst_QGraphicsItem::childrenBoundingRect3() QCOMPARE(subTreeRect.height(), qreal(251.7766952966369)); } +void tst_QGraphicsItem::childrenBoundingRect4() +{ + QGraphicsScene scene; + + QGraphicsRectItem *rect = scene.addRect(QRectF(0, 0, 10, 10)); + QGraphicsRectItem *rect2 = scene.addRect(QRectF(0, 0, 20, 20)); + QGraphicsRectItem *rect3 = scene.addRect(QRectF(0, 0, 30, 30)); + rect2->setParentItem(rect); + rect3->setParentItem(rect); + + QGraphicsView view(&scene); + view.show(); + + QTest::qWaitForWindowShown(&view); + + // Try to mess up the cached bounding rect. + rect->childrenBoundingRect(); + rect2->childrenBoundingRect(); + + rect3->setOpacity(0.0); + rect3->setParentItem(rect2); + + QCOMPARE(rect->childrenBoundingRect(), rect3->boundingRect()); + QCOMPARE(rect2->childrenBoundingRect(), rect3->boundingRect()); +} + void tst_QGraphicsItem::group() { QGraphicsScene scene; @@ -9869,5 +9897,63 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor() QCOMPARE(i->painted, 0); //same color as before should not trigger an update (QTBUG-6242) } +void tst_QGraphicsItem::QTBUG_6738_missingUpdateWithSetParent() +{ + // In all 3 test cases below the reparented item should disappear + EventTester *parent = new EventTester; + EventTester *child = new EventTester(parent); + EventTester *child2 = new EventTester(parent); + EventTester *child3 = new EventTester(parent); + EventTester *child4 = new EventTester(parent); + + child->setPos(10, 10); + child2->setPos(20, 20); + child3->setPos(30, 30); + child4->setPos(40, 40); + + QGraphicsScene scene; + scene.addItem(parent); + + class MyGraphicsView : public QGraphicsView + { public: + int repaints; + QRegion paintedRegion; + MyGraphicsView(QGraphicsScene *scene) : QGraphicsView(scene), repaints(0) {} + void paintEvent(QPaintEvent *e) + { + ++repaints; + paintedRegion += e->region(); + QGraphicsView::paintEvent(e); + } + void reset() { repaints = 0; paintedRegion = QRegion(); } + }; + + MyGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + QTRY_VERIFY(view.repaints > 0); + + // test case #1 + view.reset(); + child2->setVisible(false); + child2->setParentItem(child); + + QTRY_VERIFY(view.repaints == 1); + + // test case #2 + view.reset(); + child3->setOpacity(0.0); + child3->setParentItem(child); + + QTRY_VERIFY(view.repaints == 1); + + // test case #3 + view.reset(); + child4->setParentItem(child); + child4->setVisible(false); + + QTRY_VERIFY(view.repaints == 1); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" -- cgit v0.12 From ac0462a6f077316fffd555f45522e38a1e6f53d2 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 27 Jan 2010 09:34:39 +1000 Subject: Compile with no-webkit - add missing semi-colons. Reviewed-by: Sarah Smith --- tools/assistant/tools/assistant/centralwidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index c8f41e4..055fa1c 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -1088,7 +1088,7 @@ CentralWidget::setSourceFromSearch(const QUrl &url) { setSource(url); #if defined(QT_NO_WEBKIT) - highlightSearchTerms() + highlightSearchTerms(); #else connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, SLOT(highlightSearchTerms())); @@ -1100,7 +1100,7 @@ CentralWidget::setSourceFromSearchInNewTab(const QUrl &url) { setSourceInNewTab(url); #if defined(QT_NO_WEBKIT) - highlightSearchTerms() + highlightSearchTerms(); #else connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, SLOT(highlightSearchTerms())); -- cgit v0.12 From e08030924344cf8ce22cd399f33c6ff01e1e07ee Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 27 Jan 2010 10:41:48 +0100 Subject: Designer: Add lower/raise to context menu. Task-number: QTCREATORBUG-592 --- tools/designer/src/components/formeditor/formwindow.cpp | 5 +++++ tools/designer/src/components/formeditor/formwindow.h | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/designer/src/components/formeditor/formwindow.cpp b/tools/designer/src/components/formeditor/formwindow.cpp index 2d013c9..9fd084d 100644 --- a/tools/designer/src/components/formeditor/formwindow.cpp +++ b/tools/designer/src/components/formeditor/formwindow.cpp @@ -2219,6 +2219,11 @@ QMenu *FormWindow::createPopupMenu(QWidget *w) QToolBoxHelper::addToolBoxContextMenuActions(toolBox, popup); } + if (manager->actionLower()->isEnabled()) { + popup->addAction(manager->actionLower()); + popup->addAction(manager->actionRaise()); + popup->addSeparator(); + } popup->addAction(manager->actionCut()); popup->addAction(manager->actionCopy()); } diff --git a/tools/designer/src/components/formeditor/formwindow.h b/tools/designer/src/components/formeditor/formwindow.h index eed7417..3eee476 100644 --- a/tools/designer/src/components/formeditor/formwindow.h +++ b/tools/designer/src/components/formeditor/formwindow.h @@ -278,8 +278,6 @@ private: void checkPreviewGeometry(QRect &r); - void finishContextMenu(QWidget *w, QWidget *menuParent, QContextMenuEvent *e); - bool handleContextMenu(QWidget *widget, QWidget *managedWidget, QContextMenuEvent *e); bool handleMouseButtonDblClickEvent(QWidget *widget, QWidget *managedWidget, QMouseEvent *e); bool handleMousePressEvent(QWidget *widget, QWidget *managedWidget, QMouseEvent *e); -- cgit v0.12 From f300f5cfdf3b32e687191b071c30e14ac2721fc8 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 27 Jan 2010 17:25:41 +0100 Subject: add directories with sources to list of project roots if the pro file for the translations lives in a sibling tree of the actual source tree, messages from included headers wouldn't have been collected, as they were not considered part of the project. Task-number: QTBUG-7495 --- .../lupdate/testdata/good/from_subdir/lupdatecmd | 1 + .../testdata/good/from_subdir/project.ts.result | 17 ++++++++ .../lupdate/testdata/good/from_subdir/src/main.cpp | 50 ++++++++++++++++++++++ .../lupdate/testdata/good/from_subdir/src/main.h | 45 +++++++++++++++++++ .../good/from_subdir/translations/translations.pro | 7 +++ tools/linguist/lupdate/main.cpp | 15 +++++-- 6 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 tests/auto/linguist/lupdate/testdata/good/from_subdir/lupdatecmd create mode 100644 tests/auto/linguist/lupdate/testdata/good/from_subdir/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.h create mode 100644 tests/auto/linguist/lupdate/testdata/good/from_subdir/translations/translations.pro diff --git a/tests/auto/linguist/lupdate/testdata/good/from_subdir/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/from_subdir/lupdatecmd new file mode 100644 index 0000000..8a5b4ad --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/from_subdir/lupdatecmd @@ -0,0 +1 @@ +lupdate translations/translations.pro diff --git a/tests/auto/linguist/lupdate/testdata/good/from_subdir/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/from_subdir/project.ts.result new file mode 100644 index 0000000..7167cf3 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/from_subdir/project.ts.result @@ -0,0 +1,17 @@ + + + + + QApplication + + + string in main.cpp + + + + + string in main.h + + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.cpp b/tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.cpp new file mode 100644 index 0000000..1a24ab2 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** +****************************************************************************/ + +// IMPORTANT!!!! If you want to add testdata to this file, +// always add it to the end in order to not change the linenumbers of translations!!! + +#include "main.h" + +int main(char **argv, int argc) +{ + return QApplication::tr("string in main.cpp"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.h b/tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.h new file mode 100644 index 0000000..cc07d7c --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.h @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** +****************************************************************************/ + +// IMPORTANT!!!! If you want to add testdata to this file, +// always add it to the end in order to not change the linenumbers of translations!!! + +QT_TRANSLATE_NOOP("QApplication", "string in main.h") diff --git a/tests/auto/linguist/lupdate/testdata/good/from_subdir/translations/translations.pro b/tests/auto/linguist/lupdate/testdata/good/from_subdir/translations/translations.pro new file mode 100644 index 0000000..1815c37 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/from_subdir/translations/translations.pro @@ -0,0 +1,7 @@ +VPATH = ../src +INCLUDEPATH = ../src + +SOURCES += main.cpp +HEADERS += main.h + +TRANSLATIONS += ../project.ts diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index fd9c696..a50c97a 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -317,9 +317,18 @@ static void processProject( cd.m_codecForSource = codecForSource; cd.m_includePath = visitor.values(QLatin1String("INCLUDEPATH")); QStringList sourceFiles = getSources(visitor, pfi.absolutePath()); - QSet projectRoots; - projectRoots.insert(QDir::cleanPath(pfi.absolutePath()) + QLatin1Char('/')); - cd.m_projectRoots = projectRoots; + QSet sourceDirs; + sourceDirs.insert(QDir::cleanPath(pfi.absolutePath()) + QLatin1Char('/')); + foreach (const QString &sf, sourceFiles) + sourceDirs.insert(sf.left(sf.lastIndexOf(QLatin1Char('/')) + 1)); + QStringList rootList = sourceDirs.toList(); + rootList.sort(); + for (int prev = 0, curr = 1; curr < rootList.length(); ) + if (rootList.at(curr).startsWith(rootList.at(prev))) + rootList.removeAt(curr); + else + prev = curr++; + cd.m_projectRoots = QSet::fromList(rootList); processSources(*fetchedTor, sourceFiles, cd); } } -- cgit v0.12 From 3093340cd24874bf79072d1cb6aaefa3ddc1d939 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Wed, 27 Jan 2010 18:15:55 +0100 Subject: Fix QSettings default paths not being initialized when setPath() is called This only coincidently worked on Linux, because it creates a QSettings object to read system settings before any user data was executed, thus initializing the static default path data. However, if only the SystemPath was modified, the UserPath never got initialized on non-Linux platforms, causing settings for the users below $PWD. Also, it removes unncessary checks and mutex locks, which should give a slight speed up. Reviewed-By: dt --- src/corelib/io/qsettings.cpp | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 2c31509..64015ce 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -1091,30 +1091,23 @@ static inline int pathHashKey(QSettings::Format format, QSettings::Scope scope) return int((uint(format) << 1) | uint(scope == QSettings::SystemScope)); } -static QString getPath(QSettings::Format format, QSettings::Scope scope) +static void initDefaultPaths(QMutexLocker *locker) { - Q_ASSERT((int)QSettings::NativeFormat == 0); - Q_ASSERT((int)QSettings::IniFormat == 1); - + PathHash *pathHash = pathHashFunc(); QString homePath = QDir::homePath(); QString systemPath; - QMutexLocker locker(globalMutex()); - PathHash *pathHash = pathHashFunc(); - bool loadSystemPath = pathHash->isEmpty(); - locker.unlock(); - - if (loadSystemPath) { - /* - QLibraryInfo::location() uses QSettings, so in order to - avoid a dead-lock, we can't hold the global mutex while - calling it. - */ - systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath); - systemPath += QLatin1Char('/'); - } + locker->unlock(); + + /* + QLibraryInfo::location() uses QSettings, so in order to + avoid a dead-lock, we can't hold the global mutex while + calling it. + */ + systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath); + systemPath += QLatin1Char('/'); - locker.relock(); + locker->relock(); if (pathHash->isEmpty()) { /* Lazy initialization of pathHash. We initialize the @@ -1155,6 +1148,17 @@ static QString getPath(QSettings::Format format, QSettings::Scope scope) #endif #endif } +} + +static QString getPath(QSettings::Format format, QSettings::Scope scope) +{ + Q_ASSERT((int)QSettings::NativeFormat == 0); + Q_ASSERT((int)QSettings::IniFormat == 1); + + QMutexLocker locker(globalMutex()); + PathHash *pathHash = pathHashFunc(); + if (pathHash->isEmpty()) + initDefaultPaths(&locker); QString result = pathHash->value(pathHashKey(format, scope)); if (!result.isEmpty()) @@ -3455,6 +3459,8 @@ void QSettings::setPath(Format format, Scope scope, const QString &path) { QMutexLocker locker(globalMutex()); PathHash *pathHash = pathHashFunc(); + if (pathHash->isEmpty()) + initDefaultPaths(&locker); pathHash->insert(pathHashKey(format, scope), path + QDir::separator()); } -- cgit v0.12 From a4538a2532582f4bb1b6e85ed1e125f9c68bb251 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 27 Jan 2010 18:48:26 +0100 Subject: don't falsely complain about mismatched codecfortr normalize the user input first --- .../testdata/good/codecfortr3/expectedoutput.txt | 1 + .../lupdate/testdata/good/codecfortr3/main.cpp | 45 ++++++++++++++++++++++ .../lupdate/testdata/good/codecfortr3/project.pro | 4 ++ .../testdata/good/codecfortr3/project.ts.before | 13 +++++++ .../testdata/good/codecfortr3/project.ts.result | 12 ++++++ .../testdata/good/codecfortr4/expectedoutput.txt | 0 .../lupdate/testdata/good/codecfortr4/main.cpp | 45 ++++++++++++++++++++++ .../lupdate/testdata/good/codecfortr4/project.pro | 4 ++ .../testdata/good/codecfortr4/project.ts.before | 13 +++++++ .../testdata/good/codecfortr4/project.ts.result | 13 +++++++ tools/linguist/lupdate/main.cpp | 26 ++++++------- tools/linguist/shared/translator.h | 1 + 12 files changed, 164 insertions(+), 13 deletions(-) create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr3/expectedoutput.txt create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr3/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.ts.before create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr4/expectedoutput.txt create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr4/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.ts.before create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.ts.result diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr3/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/expectedoutput.txt new file mode 100644 index 0000000..feecdda --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/expectedoutput.txt @@ -0,0 +1 @@ +lupdate warning: Codec for tr\(\) 'ISO-8859-1' disagrees with existing file's codec 'UTF-8'\. Expect trouble\. diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr3/main.cpp b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/main.cpp new file mode 100644 index 0000000..e4210c5 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/main.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** +****************************************************************************/ + +int main(int argc, char **argv) +{ + QObject::tr("hi"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.pro b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.pro new file mode 100644 index 0000000..00a4dc4 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.pro @@ -0,0 +1,4 @@ +SOURCES += main.cpp + +TRANSLATIONS = project.ts +CODECFORTR = latin1 diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.ts.before new file mode 100644 index 0000000..07ad79b --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.ts.before @@ -0,0 +1,13 @@ + + + +UTF-8 + + QObject + + + hi + + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.ts.result new file mode 100644 index 0000000..b6899c1 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr3/project.ts.result @@ -0,0 +1,12 @@ + + + + + QObject + + + hi + + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr4/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/expectedoutput.txt new file mode 100644 index 0000000..e69de29 diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr4/main.cpp b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/main.cpp new file mode 100644 index 0000000..e4210c5 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/main.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** +****************************************************************************/ + +int main(int argc, char **argv) +{ + QObject::tr("hi"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.pro b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.pro new file mode 100644 index 0000000..4fddb02 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.pro @@ -0,0 +1,4 @@ +SOURCES += main.cpp + +TRANSLATIONS = project.ts +CODECFORTR = latin2 diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.ts.before new file mode 100644 index 0000000..e18e34e --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.ts.before @@ -0,0 +1,13 @@ + + + +ISO-8859-2 + + QObject + + + hi + + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.ts.result new file mode 100644 index 0000000..e18e34e --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr4/project.ts.result @@ -0,0 +1,13 @@ + + + +ISO-8859-2 + + QObject + + + hi + + + + diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index a50c97a..b2bfd7c 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -136,7 +136,7 @@ static void printUsage() } static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFileNames, - const QByteArray &codecForTr, const QString &sourceLanguage, const QString &targetLanguage, + bool setCodec, const QString &sourceLanguage, const QString &targetLanguage, UpdateOptions options, bool *fail) { QDir dir; @@ -154,10 +154,10 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil } tor.resolveDuplicates(); cd.clearErrors(); - if (!codecForTr.isEmpty() && codecForTr != tor.codecName()) + if (setCodec && fetchedTor.codec() != tor.codec()) qWarning("lupdate warning: Codec for tr() '%s' disagrees with " "existing file's codec '%s'. Expect trouble.", - codecForTr.constData(), tor.codecName().constData()); + fetchedTor.codecName().constData(), tor.codecName().constData()); if (!targetLanguage.isEmpty() && targetLanguage != tor.languageCode()) qWarning("lupdate warning: Specified target language '%s' disagrees with " "existing file's language '%s'. Ignoring.", @@ -167,8 +167,8 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil "existing file's language '%s'. Ignoring.", qPrintable(sourceLanguage), qPrintable(tor.sourceLanguageCode())); } else { - if (!codecForTr.isEmpty()) - tor.setCodecName(codecForTr); + if (setCodec) + tor.setCodec(fetchedTor.codec()); if (!targetLanguage.isEmpty()) tor.setLanguageCode(targetLanguage); else @@ -190,8 +190,8 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil if (tor.locationsType() == Translator::NoLocations) // Could be set from file theseOptions |= NoLocations; Translator out = merge(tor, fetchedTor, theseOptions, err); - if (!codecForTr.isEmpty()) - out.setCodecName(codecForTr); + if (setCodec) + out.setCodec(fetchedTor.codec()); if ((options & Verbose) && !err.isEmpty()) { printOut(err); @@ -374,17 +374,17 @@ static void processProjects( continue; } Translator tor; - QByteArray codecForTr; + bool setCodec = false; QStringList tmp = visitor.values(QLatin1String("CODEC")) + visitor.values(QLatin1String("DEFAULTCODEC")) + visitor.values(QLatin1String("CODECFORTR")); if (!tmp.isEmpty()) { - codecForTr = tmp.last().toLatin1(); - tor.setCodecName(codecForTr); + tor.setCodecName(tmp.last().toLatin1()); + setCodec = true; } processProject(false, pfi, visitor, options, codecForSource, targetLanguage, sourceLanguage, &tor, fail); - updateTsFiles(tor, tsFiles, codecForTr, sourceLanguage, targetLanguage, options, fail); + updateTsFiles(tor, tsFiles, setCodec, sourceLanguage, targetLanguage, options, fail); continue; } noTrans: @@ -657,7 +657,7 @@ int main(int argc, char **argv) cd.m_allCSources = allCSources; fetchedTor.setCodecName(codecForTr); processSources(fetchedTor, sourceFiles, cd); - updateTsFiles(fetchedTor, tsFileNames, codecForTr, + updateTsFiles(fetchedTor, tsFileNames, !codecForTr.isEmpty(), sourceLanguage, targetLanguage, options, &fail); } else { if (!sourceFiles.isEmpty() || !includePath.isEmpty()) { @@ -669,7 +669,7 @@ int main(int argc, char **argv) fetchedTor.setCodecName(codecForTr); processProjects(true, true, proFiles, options, QByteArray(), targetLanguage, sourceLanguage, &fetchedTor, &fail); - updateTsFiles(fetchedTor, tsFileNames, codecForTr, + updateTsFiles(fetchedTor, tsFileNames, !codecForTr.isEmpty(), sourceLanguage, targetLanguage, options, &fail); } else { processProjects(true, false, proFiles, options, QByteArray(), diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index 0fcd598..0b88c07 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -153,6 +153,7 @@ public: void reportDuplicates(const Duplicates &dupes, const QString &fileName, bool verbose); void setCodecName(const QByteArray &name); + void setCodec(QTextCodec *codec) { m_codec = codec; } QByteArray codecName() const; QTextCodec *codec() const { return m_codec; } -- cgit v0.12 From 6b6b206ed8634323570712e003fc159fbf5f8303 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 28 Jan 2010 08:18:34 +1000 Subject: Better support for user-generated binary shaders If the user provided their own shader with glShaderBinary(), QGLShaderProgram::addShader() would refuse to add it because it wasn't marked as "compiled". According to the OpenGL/ES 2.0 specification: "It is permissible to attach a shader object to a program object before source code has been loaded into the shader object or before the shader object has been compiled." Based on this, the compile check has been removed from addShader() which should make supporting binary shaders easier. Similarly, link() and programId() have been modified to support applications that use glProgramBinaryOES() to specify program binaries. Task-number: QTBUG-7490 Reviewed-by: Tom Cooksey --- src/opengl/qglshaderprogram.cpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index 5e2f1f5..79484fa 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -106,6 +106,19 @@ QT_BEGIN_NAMESPACE \snippet doc/src/snippets/code/src_opengl_qglshaderprogram.cpp 2 + \section1 Binary shaders and programs + + Binary shaders may be specified using \c{glShaderBinary()} on + the return value from QGLShader::shaderId(). The QGLShader instance + containing the binary can then be added to the shader program with + addShader() and linked in the usual fashion with link(). + + Binary programs may be specified using \c{glProgramBinaryOES()} + on the return value from programId(). Then the application should + call link(), which will notice that the program has already been + specified and linked, allowing other operations to be performed + on the shader program. + \sa QGLShader */ @@ -632,8 +645,6 @@ bool QGLShaderProgram::addShader(QGLShader *shader) qWarning("QGLShaderProgram::addShader: Program and shader are not associated with same context."); return false; } - if (!shader->d_func()->compiled) - return false; if (!shader->d_func()->shaderGuard.id()) return false; glAttachShader(d->programGuard.id(), shader->d_func()->shaderGuard.id()); @@ -820,8 +831,20 @@ bool QGLShaderProgram::link() GLuint program = d->programGuard.id(); if (!program) return false; + GLint value; + if (d->shaders.isEmpty()) { + // If there are no explicit shaders, then it is possible that the + // application added a program binary with glProgramBinaryOES(), + // or otherwise populated the shaders itself. Check to see if the + // program is already linked and bail out if so. + value = 0; + glGetProgramiv(program, GL_LINK_STATUS, &value); + d->linked = (value != 0); + if (d->linked) + return true; + } glLinkProgram(program); - GLint value = 0; + value = 0; glGetProgramiv(program, GL_LINK_STATUS, &value); d->linked = (value != 0); value = 0; @@ -928,6 +951,15 @@ void QGLShaderProgram::release() GLuint QGLShaderProgram::programId() const { Q_D(const QGLShaderProgram); + GLuint id = d->programGuard.id(); + if (id) + return id; + + // Create the identifier if we don't have one yet. This is for + // applications that want to create the attached shader configuration + // themselves, particularly those using program binaries. + if (!const_cast(this)->init()) + return 0; return d->programGuard.id(); } -- cgit v0.12 From f3604bd0abc1ca0768c565e7753ce8e2fda0f2ba Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 28 Jan 2010 11:39:02 +1000 Subject: Add additional text and painting benchmarks. These benchmarks have been moved in from the kinetic-declarativeui branch as they are not QML specific. --- tests/benchmarks/qpainter/tst_qpainter.cpp | 503 +++++++++++++++++++++++++++++ tests/benchmarks/qtext/main.cpp | 205 ++++++++++++ 2 files changed, 708 insertions(+) diff --git a/tests/benchmarks/qpainter/tst_qpainter.cpp b/tests/benchmarks/qpainter/tst_qpainter.cpp index 7c6634e..39b2244 100644 --- a/tests/benchmarks/qpainter/tst_qpainter.cpp +++ b/tests/benchmarks/qpainter/tst_qpainter.cpp @@ -45,6 +45,10 @@ #include #include #include +#include +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif Q_DECLARE_METATYPE(QLine) Q_DECLARE_METATYPE(QRect) @@ -178,6 +182,35 @@ private slots: void clipAndFill_data(); void clipAndFill(); + void drawRoundedRect(); + void drawScaledRoundedRect(); + void drawTransformedRoundedRect(); + + void drawScaledAntialiasedRoundedRect_data(); + void drawTransformedAntialiasedRoundedRect_data(); + void drawAntialiasedRoundedRect(); + void drawScaledAntialiasedRoundedRect(); + void drawTransformedAntialiasedRoundedRect(); + + void drawScaledImageRoundedRect_data(); + void drawTransformedImageRoundedRect_data(); + void drawImageRoundedRect(); + void drawScaledImageRoundedRect(); + void drawTransformedImageRoundedRect(); + + void drawScaledBorderPixmapRoundedRect_data(); + void drawTransformedBorderPixmapRoundedRect_data(); + void drawBorderPixmapRoundedRect(); + void drawScaledBorderPixmapRoundedRect(); + void drawTransformedBorderPixmapRoundedRect(); + + void drawTransformedTransparentImage_data(); + void drawTransformedSemiTransparentImage_data(); + void drawTransformedFilledImage_data(); + void drawTransformedTransparentImage(); + void drawTransformedSemiTransparentImage(); + void drawTransformedFilledImage(); + private: void setupBrushes(); void createPrimitives(); @@ -185,6 +218,8 @@ private: void drawPrimitives_data_helper(bool fancypens); void fillPrimitives_helper(QPainter *painter, PrimitiveType type, PrimitiveSet *s); + QTransform transformForAngle(qreal angle); + QPaintDevice *surface() { return new QPixmap(1024, 1024); @@ -1123,6 +1158,474 @@ void tst_QPainter::clipAndFill() } } +QTransform tst_QPainter::transformForAngle(qreal angle) +{ + const qreal inv_dist_to_plane = 1. / 1024.; + + QTransform transform; + + QTransform rotTrans; + rotTrans.translate(-40, 0); + QTransform rotTrans2; + rotTrans2.translate(40, 0); + + qreal rad = angle * 2. * M_PI / 360.; + qreal c = ::cos(rad); + qreal s = ::sin(rad); + + qreal x = 0; + qreal y = 80; + qreal z = 0; + + qreal len = x * x + y * y + z * z; + if (len != 1.) { + len = ::sqrt(len); + x /= len; + y /= len; + z /= len; + } + + QTransform rot(x*x*(1-c)+c, x*y*(1-c)-z*s, x*z*(1-c)+y*s*inv_dist_to_plane, + y*x*(1-c)+z*s, y*y*(1-c)+c, y*z*(1-c)-x*s*inv_dist_to_plane, + 0, 0, 1); + + transform *= rotTrans; + transform *= rot; + transform *= rotTrans2; + + return transform; +} + +void tst_QPainter::drawRoundedRect() +{ + QImage surface(100, 100, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + p.setPen(QPen(Qt::black, 1)); + p.setBrush(Qt::red); + + QBENCHMARK { + p.drawRoundedRect(QRectF(.5, .5, 80, 80), 10, 10); + } +} + +void tst_QPainter::drawScaledRoundedRect() +{ + QImage surface(400, 400, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + p.setPen(QPen(Qt::black, 1)); + p.setBrush(Qt::red); + p.scale(3, 3); + + QBENCHMARK { + p.drawRoundedRect(10, 10, 80, 80, 10, 10); + } +} + +void tst_QPainter::drawTransformedRoundedRect() +{ + QImage surface(400, 400, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + p.setPen(QPen(Qt::black, 1)); + p.setBrush(Qt::red); + + QBENCHMARK { + p.setWorldTransform(QTransform(0.956957, 0, 0.000704124, 0, 1, 0, 16.141, 0, 0.735953)); + p.drawRoundedRect(100, 100, 80, 80, 10, 10); + } +} + +void tst_QPainter::drawAntialiasedRoundedRect() +{ + QImage surface(100, 100, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + p.setRenderHint(QPainter::Antialiasing, true); + p.setPen(QPen(Qt::black, 1)); + p.setBrush(Qt::red); + + QBENCHMARK { + p.drawRoundedRect(QRectF(.5, .5, 80, 80), 10, 10); + } +} + +void tst_QPainter::drawScaledAntialiasedRoundedRect_data() +{ + QTest::addColumn("scale"); + + for (float i = 0; i < 3; i += .1) + QTest::newRow(QString(QLatin1String("scale=%1")).arg(i).toLatin1()) << i; +} + +void tst_QPainter::drawScaledAntialiasedRoundedRect() +{ + QFETCH(float, scale); + + QImage surface(400, 400, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + p.setRenderHint(QPainter::Antialiasing, true); + p.setPen(QPen(Qt::black, 1)); + p.setBrush(Qt::red); + p.scale(scale, scale); + + QBENCHMARK { + p.drawRoundedRect(10, 10, 80, 80, 10, 10); + } +} + +void tst_QPainter::drawTransformedAntialiasedRoundedRect_data() +{ + QTest::addColumn("transform"); + + for (float angle = 0; angle < 360; angle += 10) + QTest::newRow(QString(QLatin1String("angle=%1")).arg(angle).toLatin1()) << transformForAngle(angle); +} + +void tst_QPainter::drawTransformedAntialiasedRoundedRect() +{ + QFETCH(QTransform, transform); + + QImage surface(400, 400, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + p.setRenderHint(QPainter::Antialiasing, true); + p.setPen(QPen(Qt::black, 1)); + p.setBrush(Qt::red); + + QBENCHMARK { + p.setWorldTransform(transform); + p.drawRoundedRect(100, 100, 80, 80, 10, 10); + } +} + +void tst_QPainter::drawImageRoundedRect() +{ + //setup image + const int radius = 10; + QImage rectImage(81, 81, QImage::Format_ARGB32_Premultiplied); + rectImage.fill(0); + QPainter rp(&rectImage); + rp.setRenderHint(QPainter::Antialiasing); + rp.setPen(Qt::black); + rp.setBrush(Qt::red); + rp.drawRoundedRect(QRectF(.5, .5, 80, 80), radius, radius); + + //setup surface + QImage surface(100, 100, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + QBENCHMARK { + p.drawImage(0,0, rectImage); + } +} + +void tst_QPainter::drawScaledImageRoundedRect_data() +{ + QTest::addColumn("imageType"); + + QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; + QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; +} + +void tst_QPainter::drawScaledImageRoundedRect() +{ + QFETCH(int, imageType); + + //setup image + const int radius = 10; + QImage rectImage(81, 81, (QImage::Format)imageType); + rectImage.fill(0); + QPainter rp(&rectImage); + rp.setRenderHint(QPainter::Antialiasing); + rp.setPen(Qt::black); + rp.setBrush(Qt::red); + rp.drawRoundedRect(QRectF(.5, .5, 80, 80), radius, radius); + + //setup surface + QImage surface(400, 400, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + p.scale(3, 3); + + QBENCHMARK { + p.drawImage(0,0, rectImage); + } +} + +void tst_QPainter::drawTransformedImageRoundedRect_data() +{ + QTest::addColumn("imageType"); + + QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; + QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; +} + +void tst_QPainter::drawTransformedImageRoundedRect() +{ + QFETCH(int, imageType); + + //setup image + const int radius = 10; + QImage rectImage(81, 81, (QImage::Format)imageType); + rectImage.fill(0); + QPainter rp(&rectImage); + rp.setRenderHint(QPainter::Antialiasing); + rp.setPen(Qt::black); + rp.setBrush(Qt::red); + rp.drawRoundedRect(QRectF(.5, .5, 80, 80), radius, radius); + + //setup surface + QImage surface(400, 400, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + QBENCHMARK { + p.setWorldTransform(QTransform(0.956957, 0, 0.000704124, 0, 1, 0, 16.141, 0, 0.735953)); + p.drawImage(100,100, rectImage); + } +} + +//code from QmlGraphicsRectangle for drawing rounded rects +void tst_QPainter::drawBorderPixmapRoundedRect() +{ + //setup image + const int pw = 1; + const int radius = 10; + QImage rectImage(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2, QImage::Format_ARGB32_Premultiplied); + rectImage.fill(0); + QPainter rp(&rectImage); + rp.setRenderHint(QPainter::Antialiasing); + rp.setPen(Qt::black); + rp.setBrush(Qt::red); + if (pw%2) + rp.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, rectImage.width()-(pw+1), rectImage.height()-(pw+1)), radius, radius); + else + rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius); + QPixmap rectPixmap = QPixmap::fromImage(rectImage); + + //setup surface + QImage surface(100, 100, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + QBENCHMARK { + const int pw = 2; + int width = 80; + int height = 80; + + int xOffset = (rectPixmap.width()-1)/2; + int yOffset = (rectPixmap.height()-1)/2; + Q_ASSERT(rectPixmap.width() == 2*xOffset + 1); + Q_ASSERT(rectPixmap.height() == 2*yOffset + 1); + + QMargins margins(xOffset, yOffset, xOffset, yOffset); + QTileRules rules(Qt::StretchTile, Qt::StretchTile); + //NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects + qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width+pw, height+pw), margins, rectPixmap, rectPixmap.rect(), margins, rules); + } +} + +void tst_QPainter::drawScaledBorderPixmapRoundedRect_data() +{ + QTest::addColumn("scale"); + QTest::addColumn("imageType"); + + for (float i = 0; i < 3; i += .1) + QTest::newRow(QString(QLatin1String("scale=%1; imagetype=ARGB32_Pre")).arg(i).toLatin1()) << i << (int)QImage::Format_ARGB32_Premultiplied; + //for (float i = 0; i < 3; i += .1) + // QTest::newRow(QString(QLatin1String("scale=%1; imagetype=ARGB8565_Pre")).arg(i).toLatin1()) << i << (int)QImage::Format_ARGB8565_Premultiplied; +} + +//code from QmlGraphicsRectangle for drawing rounded rects +void tst_QPainter::drawScaledBorderPixmapRoundedRect() +{ + QFETCH(float, scale); + QFETCH(int, imageType); + + //setup image + const int pw = 1; + const int radius = 10; + QImage rectImage(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2, (QImage::Format)imageType); + rectImage.fill(0); + QPainter rp(&rectImage); + rp.setRenderHint(QPainter::Antialiasing); + rp.setPen(Qt::black); + rp.setBrush(Qt::red); + if (pw%2) + rp.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, rectImage.width()-(pw+1), rectImage.height()-(pw+1)), radius, radius); + else + rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius); + + QPixmap rectPixmap = QPixmap::fromImage(rectImage); + + //setup surface + QImage surface(400, 400, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + p.scale(scale, scale); + + QBENCHMARK { + const int pw = 2; + int width = 80; + int height = 80; + + int xOffset = (rectPixmap.width()-1)/2; + int yOffset = (rectPixmap.height()-1)/2; + Q_ASSERT(rectPixmap.width() == 2*xOffset + 1); + Q_ASSERT(rectPixmap.height() == 2*yOffset + 1); + + QMargins margins(xOffset, yOffset, xOffset, yOffset); + QTileRules rules(Qt::StretchTile, Qt::StretchTile); + qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width+pw, height+pw), margins, rectPixmap, rectPixmap.rect(), margins, rules); + } +} + +void tst_QPainter::drawTransformedBorderPixmapRoundedRect_data() +{ + QTest::addColumn("transform"); + QTest::addColumn("imageType"); + + for (float angle = 0; angle < 360; angle += 10) + QTest::newRow(QString(QLatin1String("angle=%1; imagetype=ARGB32_Pre")).arg(angle).toLatin1()) << transformForAngle(angle) << (int)QImage::Format_ARGB32_Premultiplied; + //for (float angle = 0; angle < 360; angle += 10) + // QTest::newRow(QString(QLatin1String("angle=%1; imagetype=ARGB8565_Pre")).arg(angle).toLatin1()) << transformForAngle(angle) << (int)QImage::Format_ARGB8565_Premultiplied; + +} + +//code from QmlGraphicsRectangle for drawing rounded rects +void tst_QPainter::drawTransformedBorderPixmapRoundedRect() +{ + QFETCH(QTransform, transform); + QFETCH(int, imageType); + + //setup image + const int pw = 1; + const int radius = 10; + QImage rectImage(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2, (QImage::Format)imageType); + rectImage.fill(0); + QPainter rp(&rectImage); + rp.setRenderHint(QPainter::Antialiasing); + rp.setPen(Qt::black); + rp.setBrush(Qt::red); + if (pw%2) + rp.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, rectImage.width()-(pw+1), rectImage.height()-(pw+1)), radius, radius); + else + rp.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, rectImage.width()-pw, rectImage.height()-pw), radius, radius); + + QPixmap rectPixmap = QPixmap::fromImage(rectImage); + + //setup surface + QImage surface(400, 400, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + QBENCHMARK { + p.setWorldTransform(transform); + const int pw = 2; + int width = 80; + int height = 80; + + int xOffset = (rectPixmap.width()-1)/2; + int yOffset = (rectPixmap.height()-1)/2; + Q_ASSERT(rectPixmap.width() == 2*xOffset + 1); + Q_ASSERT(rectPixmap.height() == 2*yOffset + 1); + + QMargins margins(xOffset, yOffset, xOffset, yOffset); + QTileRules rules(Qt::StretchTile, Qt::StretchTile); + qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width+pw, height+pw), margins, rectPixmap, rectPixmap.rect(), margins, rules); + } +} + +void tst_QPainter::drawTransformedTransparentImage_data() +{ + QTest::addColumn("imageType"); + + QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; + QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; +} + +void tst_QPainter::drawTransformedTransparentImage() +{ + QFETCH(int, imageType); + + //setup image + QImage transImage(200, 200, (QImage::Format)imageType); + transImage.fill(0); + + //setup surface + QImage surface(200, 200, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + QBENCHMARK { + p.setWorldTransform(QTransform(0.956957, 0, 0.000704124, 0, 1, 0, 16.141, 0, 0.735953)); + p.drawImage(0,0, transImage); + } +} + +void tst_QPainter::drawTransformedSemiTransparentImage_data() +{ + QTest::addColumn("imageType"); + + QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; + QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; +} + +void tst_QPainter::drawTransformedSemiTransparentImage() +{ + QFETCH(int, imageType); + + //setup image + QImage transImage(200, 200, (QImage::Format)imageType); + transImage.fill(QColor(0,0,0, 128).rgba()); + + //setup surface + QImage surface(200, 200, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + QBENCHMARK { + p.setWorldTransform(QTransform(0.956957, 0, 0.000704124, 0, 1, 0, 16.141, 0, 0.735953)); + p.drawImage(0,0, transImage); + } +} + +void tst_QPainter::drawTransformedFilledImage_data() +{ + QTest::addColumn("imageType"); + + QTest::newRow("imagetype=ARGB32_Pre") << (int)QImage::Format_ARGB32_Premultiplied; + QTest::newRow("imagetype=ARGB8565_Pre") << (int)QImage::Format_ARGB8565_Premultiplied; +} + +void tst_QPainter::drawTransformedFilledImage() +{ + QFETCH(int, imageType); + + //setup image + QImage filledImage(200, 200, (QImage::Format)imageType); + filledImage.fill(QColor(0,0,0).rgb()); + + //setup surface + QImage surface(200, 200, QImage::Format_RGB16); + surface.fill(QColor(255,255,255).rgb()); + QPainter p(&surface); + + QBENCHMARK { + p.setWorldTransform(QTransform(0.956957, 0, 0.000704124, 0, 1, 0, 16.141, 0, 0.735953)); + p.drawImage(0,0, filledImage); + } +} QTEST_MAIN(tst_QPainter) diff --git a/tests/benchmarks/qtext/main.cpp b/tests/benchmarks/qtext/main.cpp index 4bd2bee..9854a9f 100644 --- a/tests/benchmarks/qtext/main.cpp +++ b/tests/benchmarks/qtext/main.cpp @@ -44,7 +44,10 @@ #include #include #include +#include +#include #include +#include #include #include @@ -56,6 +59,7 @@ class tst_QText: public QObject public: tst_QText() { m_lorem = QString::fromLatin1("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi."); + m_shortLorem = QString::fromLatin1("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."); } private slots: @@ -69,8 +73,26 @@ private slots: void odfWriting_text(); void odfWriting_images(); + void constructControl(); + void constructDocument(); + + void layout(); + void paintLayoutToPixmap(); + void paintLayoutToPixmap_painterFill(); + + void document(); + void paintDocToPixmap(); + void paintDocToPixmap_painterFill(); + + void control(); + void paintControlToPixmap(); + void paintControlToPixmap_painterFill(); + private: + QSize setupTextLayout(QTextLayout *layout); + QString m_lorem; + QString m_shortLorem; }; void tst_QText::loadHtml_data() @@ -195,6 +217,189 @@ void tst_QText::odfWriting_images() delete doc; } +QSize tst_QText::setupTextLayout(QTextLayout *layout) +{ + bool wrap = true; + int wrapWidth = 300; + layout->setCacheEnabled(true); + + int height = 0; + qreal widthUsed = 0; + qreal lineWidth = 0; + + //set manual width + if (wrap) + lineWidth = wrapWidth; + + layout->beginLayout(); + + while (1) { + QTextLine line = layout->createLine(); + if (!line.isValid()) + break; + + if (wrap) + line.setLineWidth(lineWidth); + } + layout->endLayout(); + + for (int i = 0; i < layout->lineCount(); ++i) { + QTextLine line = layout->lineAt(i); + widthUsed = qMax(widthUsed, line.naturalTextWidth()); + line.setPosition(QPointF(0, height)); + height += int(line.height()); + } + return QSize(qCeil(widthUsed), height); +} + +void tst_QText::constructControl() +{ + QTextControl *control = new QTextControl; + delete control; + + QBENCHMARK { + QTextControl *control = new QTextControl; + delete control; + } +} + +void tst_QText::constructDocument() +{ + QTextDocument *doc = new QTextDocument; + delete doc; + + QBENCHMARK { + QTextDocument *doc = new QTextDocument; + delete doc; + } +} + +void tst_QText::layout() +{ + QTextLayout layout(m_shortLorem); + setupTextLayout(&layout); + + QBENCHMARK { + QTextLayout layout(m_shortLorem); + setupTextLayout(&layout); + } +} + +void tst_QText::paintLayoutToPixmap() +{ + QTextLayout layout(m_shortLorem); + QSize size = setupTextLayout(&layout); + + QBENCHMARK { + QPixmap img(size); + img.fill(Qt::transparent); + QPainter p(&img); + layout.draw(&p, QPointF(0, 0)); + } +} + +void tst_QText::paintLayoutToPixmap_painterFill() +{ + QTextLayout layout(m_shortLorem); + QSize size = setupTextLayout(&layout); + + QBENCHMARK { + QPixmap img(size); + QPainter p(&img); + p.setCompositionMode(QPainter::CompositionMode_Source); + p.fillRect(0, 0, img.width(), img.height(), Qt::transparent); + p.setCompositionMode(QPainter::CompositionMode_SourceOver); + layout.draw(&p, QPointF(0, 0)); + } +} + +void tst_QText::document() +{ + QTextDocument *doc = new QTextDocument; + + QBENCHMARK { + QTextDocument *doc = new QTextDocument; + doc->setHtml(m_shortLorem); + } +} + +void tst_QText::paintDocToPixmap() +{ + QTextDocument *doc = new QTextDocument; + doc->setHtml(m_shortLorem); + doc->setTextWidth(300); + QSize size = doc->size().toSize(); + + QBENCHMARK { + QPixmap img(size); + img.fill(Qt::transparent); + QPainter p(&img); + doc->drawContents(&p); + } +} + +void tst_QText::paintDocToPixmap_painterFill() +{ + QTextDocument *doc = new QTextDocument; + doc->setHtml(m_shortLorem); + doc->setTextWidth(300); + QSize size = doc->size().toSize(); + + QBENCHMARK { + QPixmap img(size); + QPainter p(&img); + p.setCompositionMode(QPainter::CompositionMode_Source); + p.fillRect(0, 0, img.width(), img.height(), Qt::transparent); + p.setCompositionMode(QPainter::CompositionMode_SourceOver); + doc->drawContents(&p); + } +} + +void tst_QText::control() +{ + QTextControl *control = new QTextControl(m_shortLorem); + + QBENCHMARK { + QTextControl *control = new QTextControl; + QTextDocument *doc = control->document(); + doc->setHtml(m_shortLorem); + } +} + +void tst_QText::paintControlToPixmap() +{ + QTextControl *control = new QTextControl; + QTextDocument *doc = control->document(); + doc->setHtml(m_shortLorem); + doc->setTextWidth(300); + QSize size = doc->size().toSize(); + + QBENCHMARK { + QPixmap img(size); + img.fill(Qt::transparent); + QPainter p(&img); + control->drawContents(&p, QRectF(QPointF(0, 0), QSizeF(size))); + } +} + +void tst_QText::paintControlToPixmap_painterFill() +{ + QTextControl *control = new QTextControl; + QTextDocument *doc = control->document(); + doc->setHtml(m_shortLorem); + doc->setTextWidth(300); + QSize size = doc->size().toSize(); + + QBENCHMARK { + QPixmap img(size); + QPainter p(&img); + p.setCompositionMode(QPainter::CompositionMode_Source); + p.fillRect(0, 0, img.width(), img.height(), Qt::transparent); + p.setCompositionMode(QPainter::CompositionMode_SourceOver); + control->drawContents(&p, QRectF(QPointF(0, 0), QSizeF(size))); + } +} + QTEST_MAIN(tst_QText) #include "main.moc" -- cgit v0.12 From aa854adabedbe5ff95d02c0371ae90d85921061c Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 28 Jan 2010 08:48:02 +0100 Subject: doc: Document the "Type" enum value as a const in variable. Task-number: QTBUG-7605 --- doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp | 11 +++++++++++ src/gui/graphicsview/qgraphicsitem.cpp | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp b/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp index 483c675..4f27661 100644 --- a/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp +++ b/doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp @@ -260,3 +260,14 @@ class CustomItem : public QGraphicsItem ... }; //! [QGraphicsItem type] + +//! [18] +class QGraphicsPathItem : public QAbstractGraphicsShapeItem +{ + public: + enum { Type = 2 }; + int type() const { return Type; } + ... +}; +//! [18] + diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 1ea69fb..b633b41 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -268,6 +268,17 @@ */ /*! + \variable QGraphicsItem::Type + + The type value returned by the virtual type() function in standard + graphics item classes in Qt. All such standard graphics item + classes in Qt are associated with a unique value for Type, + e.g. the value returned by QGraphicsPathItem::type() is 2. + + \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 18 +*/ + +/*! \variable QGraphicsItem::UserType The lowest permitted type value for custom items (subclasses -- cgit v0.12 From 902229bfffd709fb3294ac92180f1b171dc37eb8 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 28 Jan 2010 10:46:01 +0100 Subject: don't build unneeded QtDesigner parts on Windows CE We just build uitools like on Symbian. The following subdirs have been removed from tools/designer/src/src.pro tools/designer/src/lib tools/designer/src/components Reviewed-by: mauricek --- tools/designer/src/src.pro | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/designer/src/src.pro b/tools/designer/src/src.pro index e1710b8..78665b7 100644 --- a/tools/designer/src/src.pro +++ b/tools/designer/src/src.pro @@ -9,6 +9,4 @@ SUBDIRS = \ CONFIG(shared,shared|static):SUBDIRS += plugins -wince*: SUBDIRS -= designer plugins -symbian: SUBDIRS = uitools -contains(DEFINES, QT_NO_CURSOR): SUBDIRS -= lib components \ No newline at end of file +symbian|wince*: SUBDIRS = uitools -- cgit v0.12 From f5c16c649137856b84d769932a9356365f3250f9 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 28 Jan 2010 12:21:16 +0100 Subject: doc: Fixed the last qdoc errors. --- src/gui/graphicsview/qgraphicsitem.cpp | 17 +++++++++-------- src/gui/styles/qs60style.cpp | 4 ++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 10d31ea..d9b9416 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1570,17 +1570,18 @@ const QGraphicsObject *QGraphicsItem::toGraphicsObject() const } /*! - Sets this item's parent item to \a parent. If this item already has a - parent, it is first removed from the previous parent. If \a parent is 0, - this item will become a top-level item. + Sets this item's parent item to \a newParent. If this item already + has a parent, it is first removed from the previous parent. If \a + newParent is 0, this item will become a top-level item. - Note that this implicitly adds this graphics item to the scene of - the parent. You should not \l{QGraphicsScene::addItem()}{add} the - item to the scene yourself. + Note that this implicitly adds this graphics item to the scene of + the parent. You should not \l{QGraphicsScene::addItem()}{add} the + item to the scene yourself. - Calling this function on an item that is an ancestor of \a parent have undefined behaviour. + Calling this function on an item that is an ancestor of \a newParent + have undefined behaviour. - \sa parentItem(), childItems() + \sa parentItem(), childItems() */ void QGraphicsItem::setParentItem(QGraphicsItem *newParent) { diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index ecb3242..f657fff 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -3166,6 +3166,10 @@ bool QS60Style::eventFilter(QObject *object, QEvent *event) return QStyle::eventFilter(object, event); } +/*! + \internal + Handle the timer \a event. +*/ void QS60Style::timerEvent(QTimerEvent *event) { #ifdef Q_WS_S60 -- cgit v0.12 From 7c2000060bbc152ae32594f3d4dd60bd3351dab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Thu, 28 Jan 2010 13:29:54 +0100 Subject: Fixed an endless loop if printing web pages. Entering a page range which is valid, but outside of the printable range would result in an infinite loop. Task-number: QTBUG-6051 Reviewed-by: Simon Hausmann --- src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp index 29bde0d..e4c2afc 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp @@ -1369,6 +1369,11 @@ void QWebFrame::print(QPrinter *printer) const // paranoia check fromPage = qMax(1, fromPage); toPage = qMin(printContext.pageCount(), toPage); + if (toPage < fromPage) { + // if the user entered a page range outside the actual number + // of printable pages, just return + return; + } if (printer->pageOrder() == QPrinter::LastPageFirst) { int tmp = fromPage; -- cgit v0.12 From b4d60000981e298b7e40605a284f2b8b9b18fff5 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 28 Jan 2010 15:38:55 +0100 Subject: Fix header labels on mac with rtl The removed code simply reduces the size of the rect when running with RightToLeft without compensating anywhere else. It seems to be a leftover from a previously removed piece of code. Reviewed-by: richard Task-number: QTBUG-6882 --- src/gui/styles/qmacstyle_mac.mm | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index f4af579..7a680f2 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -4341,8 +4341,6 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, rect.setY(0); rect.setHeight(widget->height()); } - if (opt->direction == Qt::RightToLeft) - rect.adjust(15, 0, -20, 0); } break; case SE_ProgressBarGroove: -- cgit v0.12 From 1a6e9a69235458e55b2e726e51d2797434780384 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 28 Jan 2010 16:46:51 +0100 Subject: Core classes, examples, demos: Some changes from string to char Reviewed-by: Peter Hartmann --- examples/network/network-chat/chatdialog.cpp | 2 +- examples/network/network-chat/client.cpp | 4 ++-- examples/network/network-chat/connection.cpp | 6 +++--- examples/network/network-chat/peermanager.cpp | 2 +- examples/network/qftp/ftpwindow.cpp | 3 ++- examples/network/securesocketclient/sslclient.cpp | 2 +- examples/network/torrent/trackerclient.cpp | 2 +- src/corelib/io/qfsfileengine_unix.cpp | 2 +- src/network/access/qnetworkaccesshttpbackend.cpp | 2 +- src/network/ssl/qsslcertificate.cpp | 4 ++-- 10 files changed, 15 insertions(+), 14 deletions(-) diff --git a/examples/network/network-chat/chatdialog.cpp b/examples/network/network-chat/chatdialog.cpp index d8bcb30..da65270 100644 --- a/examples/network/network-chat/chatdialog.cpp +++ b/examples/network/network-chat/chatdialog.cpp @@ -79,7 +79,7 @@ void ChatDialog::appendMessage(const QString &from, const QString &message) QTextCursor cursor(textEdit->textCursor()); cursor.movePosition(QTextCursor::End); QTextTable *table = cursor.insertTable(1, 2, tableFormat); - table->cellAt(0, 0).firstCursorPosition().insertText("<" + from + "> "); + table->cellAt(0, 0).firstCursorPosition().insertText('<' + from + "> "); table->cellAt(0, 1).firstCursorPosition().insertText(message); QScrollBar *bar = textEdit->verticalScrollBar(); bar->setValue(bar->maximum()); diff --git a/examples/network/network-chat/client.cpp b/examples/network/network-chat/client.cpp index 2b8725c..f516783 100644 --- a/examples/network/network-chat/client.cpp +++ b/examples/network/network-chat/client.cpp @@ -69,8 +69,8 @@ void Client::sendMessage(const QString &message) QString Client::nickName() const { - return QString(peerManager->userName()) + "@" + QHostInfo::localHostName() - + ":" + QString::number(server.serverPort()); + return QString(peerManager->userName()) + '@' + QHostInfo::localHostName() + + ':' + QString::number(server.serverPort()); } bool Client::hasConnection(const QHostAddress &senderIp, int senderPort) const diff --git a/examples/network/network-chat/connection.cpp b/examples/network/network-chat/connection.cpp index 1df8a2d..5c636b9 100644 --- a/examples/network/network-chat/connection.cpp +++ b/examples/network/network-chat/connection.cpp @@ -83,7 +83,7 @@ bool Connection::sendMessage(const QString &message) return false; QByteArray msg = message.toUtf8(); - QByteArray data = "MESSAGE " + QByteArray::number(msg.size()) + " " + msg; + QByteArray data = "MESSAGE " + QByteArray::number(msg.size()) + ' ' + msg; return write(data) == data.size(); } @@ -118,7 +118,7 @@ void Connection::processReadyRead() return; } - username = QString(buffer) + "@" + peerAddress().toString() + ":" + username = QString(buffer) + '@' + peerAddress().toString() + ':' + QString::number(peerPort()); currentDataType = Undefined; numBytesForCurrentDataType = 0; @@ -162,7 +162,7 @@ void Connection::sendPing() void Connection::sendGreetingMessage() { QByteArray greeting = greetingMessage.toUtf8(); - QByteArray data = "GREETING " + QByteArray::number(greeting.size()) + " " + greeting; + QByteArray data = "GREETING " + QByteArray::number(greeting.size()) + ' ' + greeting; if (write(data) == data.size()) isGreetingMessageSent = true; } diff --git a/examples/network/network-chat/peermanager.cpp b/examples/network/network-chat/peermanager.cpp index 5ad2dc7..430031b 100644 --- a/examples/network/network-chat/peermanager.cpp +++ b/examples/network/network-chat/peermanager.cpp @@ -61,7 +61,7 @@ PeerManager::PeerManager(Client *client) foreach (QString string, envVariables) { int index = environment.indexOf(QRegExp(string)); if (index != -1) { - QStringList stringList = environment.at(index).split("="); + QStringList stringList = environment.at(index).split('='); if (stringList.size() == 2) { username = stringList.at(1).toUtf8(); break; diff --git a/examples/network/qftp/ftpwindow.cpp b/examples/network/qftp/ftpwindow.cpp index ae3a2b6..3fd62f8 100644 --- a/examples/network/qftp/ftpwindow.cpp +++ b/examples/network/qftp/ftpwindow.cpp @@ -324,7 +324,8 @@ void FtpWindow::processItem(QTreeWidgetItem *item, int /*column*/) if (isDirectory.value(name)) { fileList->clear(); isDirectory.clear(); - currentPath += "/" + name; + currentPath += '/'; + currentPath += name; ftp->cd(name); ftp->list(); cdToParentButton->setEnabled(true); diff --git a/examples/network/securesocketclient/sslclient.cpp b/examples/network/securesocketclient/sslclient.cpp index 1422f1c..0d6a581 100644 --- a/examples/network/securesocketclient/sslclient.cpp +++ b/examples/network/securesocketclient/sslclient.cpp @@ -177,7 +177,7 @@ void SslClient::socketReadyRead() void SslClient::sendData() { QString input = form->sessionInput->text(); - appendString(input + "\n"); + appendString(input + '\n'); socket->write(input.toUtf8() + "\r\n"); form->sessionInput->clear(); } diff --git a/examples/network/torrent/trackerclient.cpp b/examples/network/torrent/trackerclient.cpp index 4f23d54..2397737 100644 --- a/examples/network/torrent/trackerclient.cpp +++ b/examples/network/torrent/trackerclient.cpp @@ -105,7 +105,7 @@ void TrackerClient::fetchPeerList() QString passkey = "?"; if (fullUrl.contains("?passkey")) { passkey = metaInfo.announceUrl().mid(fullUrl.indexOf("?passkey"), -1); - passkey += "&"; + passkey += '&'; } // Percent encode the hash diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 722d6d3..9179485 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -98,7 +98,7 @@ static inline QByteArray openModeToFopenMode(QIODevice::OpenMode flags, const QS if (!fileName.isEmpty() && QT_STAT(QFile::encodeName(fileName), &statBuf) == 0 && (statBuf.st_mode & S_IFMT) == S_IFREG) { - mode += "+"; + mode += '+'; } else { mode = "wb+"; } diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index 58123b2..61a95fe 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -753,7 +753,7 @@ void QNetworkAccessHttpBackend::replyHeaderChanged() QByteArray value = rawHeader(it->first); if (!value.isEmpty()) { if (qstricmp(it->first.constData(), "set-cookie") == 0) - value += "\n"; + value += '\n'; else value += ", "; } diff --git a/src/network/ssl/qsslcertificate.cpp b/src/network/ssl/qsslcertificate.cpp index 9a9b1b5..fd647e2 100644 --- a/src/network/ssl/qsslcertificate.cpp +++ b/src/network/ssl/qsslcertificate.cpp @@ -634,11 +634,11 @@ QByteArray QSslCertificatePrivate::QByteArray_from_X509(X509 *x509, QSsl::Encodi QByteArray tmp; for (int i = 0; i <= array.size() - 64; i += 64) { tmp += QByteArray::fromRawData(array.data() + i, 64); - tmp += "\n"; + tmp += '\n'; } if (int remainder = array.size() % 64) { tmp += QByteArray::fromRawData(array.data() + array.size() - remainder, remainder); - tmp += "\n"; + tmp += '\n'; } return BEGINCERTSTRING "\n" + tmp + ENDCERTSTRING "\n"; -- cgit v0.12 From dfc530e1dd9040e3a8516108a9973af73d092246 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 28 Jan 2010 16:50:59 +0100 Subject: googlesuggest example: Add newline to end of file Reviewed-by: TrustMe --- examples/network/googlesuggest/googlesuggest.cpp | 3 ++- examples/network/googlesuggest/searchbox.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/network/googlesuggest/googlesuggest.cpp b/examples/network/googlesuggest/googlesuggest.cpp index 79bc448..0c85773 100644 --- a/examples/network/googlesuggest/googlesuggest.cpp +++ b/examples/network/googlesuggest/googlesuggest.cpp @@ -231,4 +231,5 @@ void GSuggestCompletion::handleNetworkData(QNetworkReply *networkReply) networkReply->deleteLater(); } -//! [9] \ No newline at end of file +//! [9] + diff --git a/examples/network/googlesuggest/searchbox.cpp b/examples/network/googlesuggest/searchbox.cpp index 69dc20e..8ef6f00 100644 --- a/examples/network/googlesuggest/searchbox.cpp +++ b/examples/network/googlesuggest/searchbox.cpp @@ -69,4 +69,5 @@ void SearchBox::doSearch() QString url = QString(GSEARCH_URL).arg(text()); QDesktopServices::openUrl(QUrl(url)); } -//! [2] \ No newline at end of file +//! [2] + -- cgit v0.12 From 7d66d263b93164ddc501050d07ddcc198921da8c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 28 Jan 2010 16:58:25 +0100 Subject: Designer: Fix source code scanning issues. Fix spelling errors, foreach()/QString usage, explicit constructors. Reviewed-By: Joerg Bornemann --- .../src/components/formeditor/qdesigner_resource.cpp | 4 ++-- .../components/propertyeditor/designerpropertymanager.h | 2 +- tools/designer/src/designer/qdesigner_actions.cpp | 4 ++-- tools/designer/src/designer/qdesigner_server.cpp | 6 ++---- tools/designer/src/designer/qdesigner_server.h | 2 +- tools/designer/src/lib/shared/actioneditor.cpp | 2 +- tools/designer/src/lib/shared/actionrepository.cpp | 2 +- tools/designer/src/lib/shared/connectionedit_p.h | 2 +- tools/designer/src/lib/shared/filterwidget_p.h | 2 +- tools/designer/src/lib/shared/iconloader.cpp | 2 +- tools/designer/src/lib/shared/iconselector_p.h | 2 +- tools/designer/src/lib/shared/plugindialog.cpp | 4 ++-- tools/designer/src/lib/shared/qdesigner_introspection.cpp | 2 +- .../designer/src/lib/shared/qdesigner_objectinspector_p.h | 2 +- .../designer/src/lib/shared/qdesigner_promotiondialog_p.h | 14 +++++++------- tools/designer/src/lib/shared/qdesigner_propertyeditor_p.h | 2 +- tools/designer/src/lib/shared/qdesigner_toolbar.cpp | 2 +- tools/designer/src/lib/shared/qdesigner_utils_p.h | 8 ++++---- tools/designer/src/lib/shared/qdesigner_widgetbox_p.h | 2 +- tools/designer/src/lib/shared/qtresourceview_p.h | 4 ++-- tools/designer/src/lib/shared/richtexteditor_p.h | 2 +- tools/designer/src/lib/shared/shared_settings.cpp | 2 +- tools/designer/src/lib/shared/textpropertyeditor_p.h | 2 +- tools/designer/src/lib/shared/widgetdatabase_p.h | 6 +++--- tools/designer/src/lib/uilib/abstractformbuilder.cpp | 2 +- tools/designer/src/lib/uilib/formbuilder.cpp | 2 +- tools/designer/src/plugins/activeqt/qaxwidgetextrainfo.h | 2 +- tools/designer/src/plugins/activeqt/qdesigneraxwidget.h | 2 +- .../src/plugins/widgets/q3iconview/q3iconview_extrainfo.h | 2 +- .../src/plugins/widgets/q3iconview/q3iconview_plugin.h | 2 +- .../src/plugins/widgets/q3listbox/q3listbox_extrainfo.h | 2 +- .../src/plugins/widgets/q3listbox/q3listbox_plugin.h | 2 +- .../src/plugins/widgets/q3listview/q3listview_extrainfo.h | 2 +- .../src/plugins/widgets/q3listview/q3listview_plugin.h | 2 +- .../src/plugins/widgets/q3mainwindow/q3mainwindow_plugin.h | 2 +- .../src/plugins/widgets/q3table/q3table_extrainfo.h | 2 +- .../src/plugins/widgets/q3textedit/q3textedit_extrainfo.h | 2 +- .../src/plugins/widgets/q3textedit/q3textedit_plugin.h | 2 +- .../src/plugins/widgets/q3toolbar/q3toolbar_extrainfo.h | 2 +- .../src/plugins/widgets/q3widgets/q3widget_plugins.h | 12 ++++++------ .../src/plugins/widgets/q3wizard/q3wizard_container.h | 2 +- .../src/plugins/widgets/q3wizard/q3wizard_plugin.h | 2 +- tools/shared/findwidget/texteditfindwidget.h | 2 +- tools/shared/fontpanel/fontpanel.cpp | 2 +- tools/shared/qtgradienteditor/qtgradientutils.cpp | 2 +- tools/shared/qttoolbardialog/qttoolbardialog.h | 4 ++-- 46 files changed, 68 insertions(+), 70 deletions(-) diff --git a/tools/designer/src/components/formeditor/qdesigner_resource.cpp b/tools/designer/src/components/formeditor/qdesigner_resource.cpp index b005e42..b659179 100644 --- a/tools/designer/src/components/formeditor/qdesigner_resource.cpp +++ b/tools/designer/src/components/formeditor/qdesigner_resource.cpp @@ -1446,7 +1446,7 @@ void QDesignerResource::applyTabStops(QWidget *widget, DomTabStops *tabStops) return; QList tabOrder; - foreach (QString widgetName, tabStops->elementTabStop()) { + foreach (const QString &widgetName, tabStops->elementTabStop()) { if (QWidget *w = qFindChild(widget, widgetName)) { tabOrder.append(w); } @@ -2418,7 +2418,7 @@ DomResources *QDesignerResource::saveResources(const QStringList &qrcPaths) QList dom_include; if (resourceSet) { const QStringList activePaths = resourceSet->activeQrcPaths(); - foreach (QString path, activePaths) { + foreach (const QString &path, activePaths) { if (qrcPaths.contains(path)) { DomResource *dom_res = new DomResource; QString conv_path = path; diff --git a/tools/designer/src/components/propertyeditor/designerpropertymanager.h b/tools/designer/src/components/propertyeditor/designerpropertymanager.h index 0ec5241..11f900b 100644 --- a/tools/designer/src/components/propertyeditor/designerpropertymanager.h +++ b/tools/designer/src/components/propertyeditor/designerpropertymanager.h @@ -102,7 +102,7 @@ class DesignerPropertyManager : public QtVariantPropertyManager { Q_OBJECT public: - DesignerPropertyManager(QDesignerFormEditorInterface *core, QObject *parent = 0); + explicit DesignerPropertyManager(QDesignerFormEditorInterface *core, QObject *parent = 0); ~DesignerPropertyManager(); virtual QStringList attributes(int propertyType) const; diff --git a/tools/designer/src/designer/qdesigner_actions.cpp b/tools/designer/src/designer/qdesigner_actions.cpp index fbaf461..887ba98 100644 --- a/tools/designer/src/designer/qdesigner_actions.cpp +++ b/tools/designer/src/designer/qdesigner_actions.cpp @@ -580,7 +580,7 @@ bool QDesignerActions::openForm(QWidget *parent) return false; bool atLeastOne = false; - foreach (QString fileName, fileNames) { + foreach (const QString &fileName, fileNames) { if (readInForm(fileName) && !atLeastOne) atLeastOne = true; } @@ -869,7 +869,7 @@ bool QDesignerActions::writeOutForm(QDesignerFormWindowInterface *fw, const QStr if (f.fileName() != fileName) { removeBackup(backupFile); fi.setFile(fileName); - backupFile = QString(); + backupFile.clear(); if (fi.exists()) backupFile = createBackup(fileName); } diff --git a/tools/designer/src/designer/qdesigner_server.cpp b/tools/designer/src/designer/qdesigner_server.cpp index 8016dff..de1532c 100644 --- a/tools/designer/src/designer/qdesigner_server.cpp +++ b/tools/designer/src/designer/qdesigner_server.cpp @@ -83,7 +83,7 @@ void QDesignerServer::sendOpenRequest(int port, const QStringList &files) sSocket->connectToHost(QHostAddress::LocalHost, port); if(sSocket->waitForConnected(3000)) { - foreach(QString file, files) + foreach(const QString &file, files) { QFileInfo fi(file); sSocket->write(fi.absoluteFilePath().toUtf8() + '\n'); @@ -96,9 +96,8 @@ void QDesignerServer::sendOpenRequest(int port, const QStringList &files) void QDesignerServer::readFromClient() { - QString file = QString(); while (m_socket->canReadLine()) { - file = QString::fromUtf8(m_socket->readLine()); + QString file = QString::fromUtf8(m_socket->readLine()); if (!file.isNull()) { file.remove(QLatin1Char('\n')); file.remove(QLatin1Char('\r')); @@ -143,7 +142,6 @@ QDesignerClient::~QDesignerClient() void QDesignerClient::readFromSocket() { - QString file = QString(); while (m_socket->canReadLine()) { QString file = QString::fromUtf8(m_socket->readLine()); if (!file.isNull()) { diff --git a/tools/designer/src/designer/qdesigner_server.h b/tools/designer/src/designer/qdesigner_server.h index 08bce68..d522056 100644 --- a/tools/designer/src/designer/qdesigner_server.h +++ b/tools/designer/src/designer/qdesigner_server.h @@ -53,7 +53,7 @@ class QDesignerServer: public QObject { Q_OBJECT public: - QDesignerServer(QObject *parent = 0); + explicit QDesignerServer(QObject *parent = 0); virtual ~QDesignerServer(); quint16 serverPort() const; diff --git a/tools/designer/src/lib/shared/actioneditor.cpp b/tools/designer/src/lib/shared/actioneditor.cpp index 624b8bb..26ac8a8 100644 --- a/tools/designer/src/lib/shared/actioneditor.cpp +++ b/tools/designer/src/lib/shared/actioneditor.cpp @@ -428,7 +428,7 @@ void ActionEditor::unmanageAction(QAction *action) m_actionView->model()->remove(row); } -// Set an intial property and mark it as changed in the sheet +// Set an initial property and mark it as changed in the sheet static void setInitialProperty(QDesignerPropertySheetExtension *sheet, const QString &name, const QVariant &value) { const int index = sheet->indexOf(name); diff --git a/tools/designer/src/lib/shared/actionrepository.cpp b/tools/designer/src/lib/shared/actionrepository.cpp index 64cf9c4..e3ff2c1 100644 --- a/tools/designer/src/lib/shared/actionrepository.cpp +++ b/tools/designer/src/lib/shared/actionrepository.cpp @@ -244,7 +244,7 @@ QMimeData *ActionModel::mimeData(const QModelIndexList &indexes ) const ActionRepositoryMimeData::ActionList actionList; QSet actions; - foreach (const QModelIndex &index, indexes) + foreach (const QModelIndex &index, indexes) if (QStandardItem *item = itemFromIndex(index)) if (QAction *action = actionOfItem(item)) actions.insert(action); diff --git a/tools/designer/src/lib/shared/connectionedit_p.h b/tools/designer/src/lib/shared/connectionedit_p.h index 4f0148d..37dfe75 100644 --- a/tools/designer/src/lib/shared/connectionedit_p.h +++ b/tools/designer/src/lib/shared/connectionedit_p.h @@ -87,7 +87,7 @@ public: class EndPoint { public: enum Type { Source, Target }; - EndPoint(Connection *_con = 0, Type _type = Source) : con(_con), type(_type) {} + explicit EndPoint(Connection *_con = 0, Type _type = Source) : con(_con), type(_type) {} bool isNull() const { return con == 0; } bool operator == (const EndPoint &other) const { return con == other.con && type == other.type; } bool operator != (const EndPoint &other) const { return !operator == (other); } diff --git a/tools/designer/src/lib/shared/filterwidget_p.h b/tools/designer/src/lib/shared/filterwidget_p.h index fdb199d..025d708 100644 --- a/tools/designer/src/lib/shared/filterwidget_p.h +++ b/tools/designer/src/lib/shared/filterwidget_p.h @@ -66,7 +66,7 @@ class QPushButton; namespace qdesigner_internal { /* A line edit that displays a grayed hintText (like "Type Here to Filter") - * when not focussed and empty. When connecting to the changed signals and + * when not focused and empty. When connecting to the changed signals and * querying text, one has to be aware that the text is set to that hint * text if isShowingHintText() returns true (that is, does not contain * valid user input). This widget should never have initial focus diff --git a/tools/designer/src/lib/shared/iconloader.cpp b/tools/designer/src/lib/shared/iconloader.cpp index 2c97f62..df0bb7e 100644 --- a/tools/designer/src/lib/shared/iconloader.cpp +++ b/tools/designer/src/lib/shared/iconloader.cpp @@ -60,7 +60,7 @@ QDESIGNER_SHARED_EXPORT QIcon createIconSet(const QString &name) #endif << (QString::fromUtf8(":/trolltech/formeditor/images/designer_") + name); - foreach (QString f, candidates) { + foreach (const QString &f, candidates) { if (QFile::exists(f)) return QIcon(f); } diff --git a/tools/designer/src/lib/shared/iconselector_p.h b/tools/designer/src/lib/shared/iconselector_p.h index 63d4ad7..3373f80 100644 --- a/tools/designer/src/lib/shared/iconselector_p.h +++ b/tools/designer/src/lib/shared/iconselector_p.h @@ -76,7 +76,7 @@ class QDESIGNER_SHARED_EXPORT LanguageResourceDialog : public QDialog { Q_OBJECT - LanguageResourceDialog(QDesignerResourceBrowserInterface *rb, QWidget *parent = 0); + explicit LanguageResourceDialog(QDesignerResourceBrowserInterface *rb, QWidget *parent = 0); public: virtual ~LanguageResourceDialog(); diff --git a/tools/designer/src/lib/shared/plugindialog.cpp b/tools/designer/src/lib/shared/plugindialog.cpp index c79dcf2..3e88043 100644 --- a/tools/designer/src/lib/shared/plugindialog.cpp +++ b/tools/designer/src/lib/shared/plugindialog.cpp @@ -105,7 +105,7 @@ void PluginDialog::populateTreeWidget() QTreeWidgetItem *topLevelItem = setTopLevelItem(QLatin1String("Loaded Plugins")); QFont boldFont = topLevelItem->font(0); - foreach (QString fileName, fileNames) { + foreach (const QString &fileName, fileNames) { QPluginLoader loader(fileName); const QFileInfo fileInfo(fileName); @@ -127,7 +127,7 @@ void PluginDialog::populateTreeWidget() if (!notLoadedPlugins.isEmpty()) { QTreeWidgetItem *topLevelItem = setTopLevelItem(QLatin1String("Failed Plugins")); const QFont boldFont = topLevelItem->font(0); - foreach (const QString plugin, notLoadedPlugins) { + foreach (const QString &plugin, notLoadedPlugins) { const QString failureReason = pluginManager->failureReason(plugin); QTreeWidgetItem *pluginItem = setPluginItem(topLevelItem, plugin, boldFont); setItem(pluginItem, failureReason, failureReason, QString(), QIcon()); diff --git a/tools/designer/src/lib/shared/qdesigner_introspection.cpp b/tools/designer/src/lib/shared/qdesigner_introspection.cpp index 170a111..7bc60d4 100644 --- a/tools/designer/src/lib/shared/qdesigner_introspection.cpp +++ b/tools/designer/src/lib/shared/qdesigner_introspection.cpp @@ -63,7 +63,7 @@ static QStringList byteArrayListToStringList(const QList &l) static inline QString charToQString(const char *c) { if (!c) - return QString::null; + return QString(); return QString::fromUtf8(c); } diff --git a/tools/designer/src/lib/shared/qdesigner_objectinspector_p.h b/tools/designer/src/lib/shared/qdesigner_objectinspector_p.h index 354ef2a..f4b6672 100644 --- a/tools/designer/src/lib/shared/qdesigner_objectinspector_p.h +++ b/tools/designer/src/lib/shared/qdesigner_objectinspector_p.h @@ -85,7 +85,7 @@ class QDESIGNER_SHARED_EXPORT QDesignerObjectInspector: public QDesignerObjectIn { Q_OBJECT public: - QDesignerObjectInspector(QWidget *parent = 0, Qt::WindowFlags flags = 0); + explicit QDesignerObjectInspector(QWidget *parent = 0, Qt::WindowFlags flags = 0); // Select a qobject unmanaged by form window virtual bool selectObject(QObject *o) = 0; diff --git a/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h b/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h index d1e407d..1e63d81 100644 --- a/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h +++ b/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h @@ -80,9 +80,9 @@ namespace qdesigner_internal { class NewPromotedClassPanel : public QGroupBox { Q_OBJECT public: - NewPromotedClassPanel(const QStringList &baseClasses, - int selectedBaseClass = -1, - QWidget *parent = 0); + explicit NewPromotedClassPanel(const QStringList &baseClasses, + int selectedBaseClass = -1, + QWidget *parent = 0); signals: void newPromotedClass(const PromotionParameters &, bool *ok); @@ -114,10 +114,10 @@ namespace qdesigner_internal { public: enum Mode { ModeEdit, ModeEditChooseClass }; - QDesignerPromotionDialog(QDesignerFormEditorInterface *core, - QWidget *parent = 0, - const QString &promotableWidgetClassName = QString(), - QString *promoteTo = 0); + explicit QDesignerPromotionDialog(QDesignerFormEditorInterface *core, + QWidget *parent = 0, + const QString &promotableWidgetClassName = QString(), + QString *promoteTo = 0); // Return an alphabetically ordered list of base class names for adding new classes. static const QStringList &baseClassNames(const QDesignerPromotionInterface *promotion); diff --git a/tools/designer/src/lib/shared/qdesigner_propertyeditor_p.h b/tools/designer/src/lib/shared/qdesigner_propertyeditor_p.h index c618bd7..cdd53f0 100644 --- a/tools/designer/src/lib/shared/qdesigner_propertyeditor_p.h +++ b/tools/designer/src/lib/shared/qdesigner_propertyeditor_p.h @@ -69,7 +69,7 @@ class QDESIGNER_SHARED_EXPORT QDesignerPropertyEditor: public QDesignerPropertyE { Q_OBJECT public: - QDesignerPropertyEditor(QWidget *parent = 0, Qt::WindowFlags flags = 0); + explicit QDesignerPropertyEditor(QWidget *parent = 0, Qt::WindowFlags flags = 0); // A pair . typedef QPair StringPropertyParameters; diff --git a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp index 1cee074..02a2f6d 100644 --- a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp +++ b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp @@ -440,7 +440,7 @@ QAction *ToolBarEventFilter::actionAt(const QToolBar *tb, const QPoint &pos) return tb->actions().at(index); } -//that's a trick to get acces to the initStyleOption which is a protected member +//that's a trick to get access to the initStyleOption which is a protected member class FriendlyToolBar : public QToolBar { public: friend class ToolBarEventFilter; diff --git a/tools/designer/src/lib/shared/qdesigner_utils_p.h b/tools/designer/src/lib/shared/qdesigner_utils_p.h index 502703d..fac0697 100644 --- a/tools/designer/src/lib/shared/qdesigner_utils_p.h +++ b/tools/designer/src/lib/shared/qdesigner_utils_p.h @@ -298,7 +298,7 @@ class QDESIGNER_SHARED_EXPORT DesignerIconCache : public QObject { Q_OBJECT public: - DesignerIconCache(DesignerPixmapCache *pixmapCache, QObject *parent = 0); + explicit DesignerIconCache(DesignerPixmapCache *pixmapCache, QObject *parent = 0); QIcon icon(const PropertySheetIconValue &value) const; void clear(); signals: @@ -313,7 +313,7 @@ private: class QDESIGNER_SHARED_EXPORT PropertySheetStringValue { public: - PropertySheetStringValue(const QString &value = QString(), + explicit PropertySheetStringValue(const QString &value = QString(), bool translatable = true, const QString &disambiguation = QString(), const QString &comment = QString()); @@ -345,11 +345,11 @@ private: class QDESIGNER_SHARED_EXPORT PropertySheetKeySequenceValue { public: - PropertySheetKeySequenceValue(const QKeySequence &value = QKeySequence(), + explicit PropertySheetKeySequenceValue(const QKeySequence &value = QKeySequence(), bool translatable = true, const QString &disambiguation = QString(), const QString &comment = QString()); - PropertySheetKeySequenceValue(const QKeySequence::StandardKey &standardKey, + explicit PropertySheetKeySequenceValue(const QKeySequence::StandardKey &standardKey, bool translatable = true, const QString &disambiguation = QString(), const QString &comment = QString()); diff --git a/tools/designer/src/lib/shared/qdesigner_widgetbox_p.h b/tools/designer/src/lib/shared/qdesigner_widgetbox_p.h index cf944b9..13b7f74 100644 --- a/tools/designer/src/lib/shared/qdesigner_widgetbox_p.h +++ b/tools/designer/src/lib/shared/qdesigner_widgetbox_p.h @@ -70,7 +70,7 @@ class QDESIGNER_SHARED_EXPORT QDesignerWidgetBox : public QDesignerWidgetBoxInte public: enum LoadMode { LoadMerge, LoadReplace, LoadCustomWidgetsOnly }; - QDesignerWidgetBox(QWidget *parent = 0, Qt::WindowFlags flags = 0); + explicit QDesignerWidgetBox(QWidget *parent = 0, Qt::WindowFlags flags = 0); LoadMode loadMode() const; void setLoadMode(LoadMode lm); diff --git a/tools/designer/src/lib/shared/qtresourceview_p.h b/tools/designer/src/lib/shared/qtresourceview_p.h index 26c4754..8da2975 100644 --- a/tools/designer/src/lib/shared/qtresourceview_p.h +++ b/tools/designer/src/lib/shared/qtresourceview_p.h @@ -68,7 +68,7 @@ class QDESIGNER_SHARED_EXPORT QtResourceView : public QWidget { Q_OBJECT public: - QtResourceView(QDesignerFormEditorInterface *core, QWidget *parent = 0); + explicit QtResourceView(QDesignerFormEditorInterface *core, QWidget *parent = 0); ~QtResourceView(); void setDragEnabled(bool dragEnabled); @@ -120,7 +120,7 @@ class QDESIGNER_SHARED_EXPORT QtResourceViewDialog : public QDialog { Q_OBJECT public: - QtResourceViewDialog(QDesignerFormEditorInterface *core, QWidget *parent = 0); + explicit QtResourceViewDialog(QDesignerFormEditorInterface *core, QWidget *parent = 0); virtual ~QtResourceViewDialog(); QString selectedResource() const; diff --git a/tools/designer/src/lib/shared/richtexteditor_p.h b/tools/designer/src/lib/shared/richtexteditor_p.h index 4157d2c..44023ef 100644 --- a/tools/designer/src/lib/shared/richtexteditor_p.h +++ b/tools/designer/src/lib/shared/richtexteditor_p.h @@ -72,7 +72,7 @@ class QDESIGNER_SHARED_EXPORT RichTextEditorDialog : public QDialog { Q_OBJECT public: - RichTextEditorDialog(QDesignerFormEditorInterface *core, QWidget *parent = 0); + explicit RichTextEditorDialog(QDesignerFormEditorInterface *core, QWidget *parent = 0); ~RichTextEditorDialog(); int showDialog(); diff --git a/tools/designer/src/lib/shared/shared_settings.cpp b/tools/designer/src/lib/shared/shared_settings.cpp index d6fd4bc..281b5c6 100644 --- a/tools/designer/src/lib/shared/shared_settings.cpp +++ b/tools/designer/src/lib/shared/shared_settings.cpp @@ -161,7 +161,7 @@ QStringList QDesignerSharedSettings::additionalFormTemplatePaths() const { // get template paths excluding internal ones QStringList rc = formTemplatePaths(); - foreach (QString internalTemplatePath, defaultFormTemplatePaths()) { + foreach (const QString &internalTemplatePath, defaultFormTemplatePaths()) { const int index = rc.indexOf(internalTemplatePath); if (index != -1) rc.removeAt(index); diff --git a/tools/designer/src/lib/shared/textpropertyeditor_p.h b/tools/designer/src/lib/shared/textpropertyeditor_p.h index 5b913ac..48f7898 100644 --- a/tools/designer/src/lib/shared/textpropertyeditor_p.h +++ b/tools/designer/src/lib/shared/textpropertyeditor_p.h @@ -90,7 +90,7 @@ namespace qdesigner_internal { UpdateOnFinished }; - TextPropertyEditor(QWidget *parent = 0, EmbeddingMode embeddingMode = EmbeddingNone, TextPropertyValidationMode validationMode = ValidationMultiLine); + explicit TextPropertyEditor(QWidget *parent = 0, EmbeddingMode embeddingMode = EmbeddingNone, TextPropertyValidationMode validationMode = ValidationMultiLine); TextPropertyValidationMode textPropertyValidationMode() const { return m_validationMode; } void setTextPropertyValidationMode(TextPropertyValidationMode vm); diff --git a/tools/designer/src/lib/shared/widgetdatabase_p.h b/tools/designer/src/lib/shared/widgetdatabase_p.h index 0e99999..873e79b 100644 --- a/tools/designer/src/lib/shared/widgetdatabase_p.h +++ b/tools/designer/src/lib/shared/widgetdatabase_p.h @@ -74,8 +74,8 @@ namespace qdesigner_internal { class QDESIGNER_SHARED_EXPORT WidgetDataBaseItem: public QDesignerWidgetDataBaseItemInterface { public: - WidgetDataBaseItem(const QString &name = QString(), - const QString &group = QString()); + explicit WidgetDataBaseItem(const QString &name = QString(), + const QString &group = QString()); QString name() const; void setName(const QString &name); @@ -159,7 +159,7 @@ class QDESIGNER_SHARED_EXPORT WidgetDataBase: public QDesignerWidgetDataBaseInte { Q_OBJECT public: - WidgetDataBase(QDesignerFormEditorInterface *core, QObject *parent = 0); + explicit WidgetDataBase(QDesignerFormEditorInterface *core, QObject *parent = 0); virtual ~WidgetDataBase(); virtual QDesignerFormEditorInterface *core() const; diff --git a/tools/designer/src/lib/uilib/abstractformbuilder.cpp b/tools/designer/src/lib/uilib/abstractformbuilder.cpp index 1d2d6f8..a0c9e83 100644 --- a/tools/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/tools/designer/src/lib/uilib/abstractformbuilder.cpp @@ -364,7 +364,7 @@ QWidget *QAbstractFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidge const QStringList zOrderNames = ui_widget->elementZOrder(); if (!zOrderNames.isEmpty()) { QList zOrder = qVariantValue(w->property("_q_zOrder")); - foreach (QString widgetName, zOrderNames) { + foreach (const QString &widgetName, zOrderNames) { if (QWidget *child = qFindChild(w, widgetName)) { if (child->parentWidget() == w) { zOrder.removeAll(child); diff --git a/tools/designer/src/lib/uilib/formbuilder.cpp b/tools/designer/src/lib/uilib/formbuilder.cpp index cc8483f..c97daac 100644 --- a/tools/designer/src/lib/uilib/formbuilder.cpp +++ b/tools/designer/src/lib/uilib/formbuilder.cpp @@ -494,7 +494,7 @@ void QFormBuilder::updateCustomWidgets() { m_customWidgets.clear(); - foreach (QString path, m_pluginPaths) { + foreach (const QString &path, m_pluginPaths) { const QDir dir(path); const QStringList candidates = dir.entryList(QDir::Files); diff --git a/tools/designer/src/plugins/activeqt/qaxwidgetextrainfo.h b/tools/designer/src/plugins/activeqt/qaxwidgetextrainfo.h index c48449c..9f3c252 100644 --- a/tools/designer/src/plugins/activeqt/qaxwidgetextrainfo.h +++ b/tools/designer/src/plugins/activeqt/qaxwidgetextrainfo.h @@ -77,7 +77,7 @@ class QAxWidgetExtraInfoFactory: public QExtensionFactory { Q_OBJECT public: - QAxWidgetExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + explicit QAxWidgetExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); protected: virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; diff --git a/tools/designer/src/plugins/activeqt/qdesigneraxwidget.h b/tools/designer/src/plugins/activeqt/qdesigneraxwidget.h index 1308fe2..50132a6 100644 --- a/tools/designer/src/plugins/activeqt/qdesigneraxwidget.h +++ b/tools/designer/src/plugins/activeqt/qdesigneraxwidget.h @@ -105,7 +105,7 @@ private: class QDesignerAxPluginWidget : public QDesignerAxWidget { - // No Q_OBJECT here! - meta functionality is overriden + // No Q_OBJECT here! - meta functionality is overridden public: explicit QDesignerAxPluginWidget(QWidget *parent); virtual ~QDesignerAxPluginWidget(); diff --git a/tools/designer/src/plugins/widgets/q3iconview/q3iconview_extrainfo.h b/tools/designer/src/plugins/widgets/q3iconview/q3iconview_extrainfo.h index 49a8a40..4f2b3b2 100644 --- a/tools/designer/src/plugins/widgets/q3iconview/q3iconview_extrainfo.h +++ b/tools/designer/src/plugins/widgets/q3iconview/q3iconview_extrainfo.h @@ -81,7 +81,7 @@ class Q3IconViewExtraInfoFactory: public QExtensionFactory { Q_OBJECT public: - Q3IconViewExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + explicit Q3IconViewExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); protected: virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; diff --git a/tools/designer/src/plugins/widgets/q3iconview/q3iconview_plugin.h b/tools/designer/src/plugins/widgets/q3iconview/q3iconview_plugin.h index 19213d8..e20e344 100644 --- a/tools/designer/src/plugins/widgets/q3iconview/q3iconview_plugin.h +++ b/tools/designer/src/plugins/widgets/q3iconview/q3iconview_plugin.h @@ -51,7 +51,7 @@ class Q3IconViewPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3IconViewPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3IconViewPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; diff --git a/tools/designer/src/plugins/widgets/q3listbox/q3listbox_extrainfo.h b/tools/designer/src/plugins/widgets/q3listbox/q3listbox_extrainfo.h index 7e291b6..bfb6738 100644 --- a/tools/designer/src/plugins/widgets/q3listbox/q3listbox_extrainfo.h +++ b/tools/designer/src/plugins/widgets/q3listbox/q3listbox_extrainfo.h @@ -79,7 +79,7 @@ class Q3ListBoxExtraInfoFactory: public QExtensionFactory { Q_OBJECT public: - Q3ListBoxExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + explicit Q3ListBoxExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); protected: virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; diff --git a/tools/designer/src/plugins/widgets/q3listbox/q3listbox_plugin.h b/tools/designer/src/plugins/widgets/q3listbox/q3listbox_plugin.h index 66002f5..68d6913 100644 --- a/tools/designer/src/plugins/widgets/q3listbox/q3listbox_plugin.h +++ b/tools/designer/src/plugins/widgets/q3listbox/q3listbox_plugin.h @@ -51,7 +51,7 @@ class Q3ListBoxPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3ListBoxPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3ListBoxPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; diff --git a/tools/designer/src/plugins/widgets/q3listview/q3listview_extrainfo.h b/tools/designer/src/plugins/widgets/q3listview/q3listview_extrainfo.h index f14f256..e5222ed 100644 --- a/tools/designer/src/plugins/widgets/q3listview/q3listview_extrainfo.h +++ b/tools/designer/src/plugins/widgets/q3listview/q3listview_extrainfo.h @@ -82,7 +82,7 @@ class Q3ListViewExtraInfoFactory: public QExtensionFactory { Q_OBJECT public: - Q3ListViewExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + explicit Q3ListViewExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); protected: virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; diff --git a/tools/designer/src/plugins/widgets/q3listview/q3listview_plugin.h b/tools/designer/src/plugins/widgets/q3listview/q3listview_plugin.h index 7127a57..f9c82a2 100644 --- a/tools/designer/src/plugins/widgets/q3listview/q3listview_plugin.h +++ b/tools/designer/src/plugins/widgets/q3listview/q3listview_plugin.h @@ -51,7 +51,7 @@ class Q3ListViewPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3ListViewPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3ListViewPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; diff --git a/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_plugin.h b/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_plugin.h index de2a75e..4ac7daa 100644 --- a/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_plugin.h +++ b/tools/designer/src/plugins/widgets/q3mainwindow/q3mainwindow_plugin.h @@ -51,7 +51,7 @@ class Q3MainWindowPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3MainWindowPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3MainWindowPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; diff --git a/tools/designer/src/plugins/widgets/q3table/q3table_extrainfo.h b/tools/designer/src/plugins/widgets/q3table/q3table_extrainfo.h index 40222bd..4de8b71 100644 --- a/tools/designer/src/plugins/widgets/q3table/q3table_extrainfo.h +++ b/tools/designer/src/plugins/widgets/q3table/q3table_extrainfo.h @@ -79,7 +79,7 @@ class Q3TableExtraInfoFactory: public QExtensionFactory { Q_OBJECT public: - Q3TableExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + explicit Q3TableExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); protected: virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; diff --git a/tools/designer/src/plugins/widgets/q3textedit/q3textedit_extrainfo.h b/tools/designer/src/plugins/widgets/q3textedit/q3textedit_extrainfo.h index 94f663a..beeaf3b 100644 --- a/tools/designer/src/plugins/widgets/q3textedit/q3textedit_extrainfo.h +++ b/tools/designer/src/plugins/widgets/q3textedit/q3textedit_extrainfo.h @@ -79,7 +79,7 @@ class Q3TextEditExtraInfoFactory: public QExtensionFactory { Q_OBJECT public: - Q3TextEditExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + explicit Q3TextEditExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); protected: virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; diff --git a/tools/designer/src/plugins/widgets/q3textedit/q3textedit_plugin.h b/tools/designer/src/plugins/widgets/q3textedit/q3textedit_plugin.h index 28e0386..77bfb58 100644 --- a/tools/designer/src/plugins/widgets/q3textedit/q3textedit_plugin.h +++ b/tools/designer/src/plugins/widgets/q3textedit/q3textedit_plugin.h @@ -51,7 +51,7 @@ class Q3TextEditPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3TextEditPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3TextEditPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; diff --git a/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_extrainfo.h b/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_extrainfo.h index f3ed995..22562b1 100644 --- a/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_extrainfo.h +++ b/tools/designer/src/plugins/widgets/q3toolbar/q3toolbar_extrainfo.h @@ -78,7 +78,7 @@ class Q3ToolBarExtraInfoFactory: public QExtensionFactory { Q_OBJECT public: - Q3ToolBarExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); + explicit Q3ToolBarExtraInfoFactory(QDesignerFormEditorInterface *core, QExtensionManager *parent = 0); protected: virtual QObject *createExtension(QObject *object, const QString &iid, QObject *parent) const; diff --git a/tools/designer/src/plugins/widgets/q3widgets/q3widget_plugins.h b/tools/designer/src/plugins/widgets/q3widgets/q3widget_plugins.h index c79390c..c750cfe 100644 --- a/tools/designer/src/plugins/widgets/q3widgets/q3widget_plugins.h +++ b/tools/designer/src/plugins/widgets/q3widgets/q3widget_plugins.h @@ -51,7 +51,7 @@ class Q3ButtonGroupPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3ButtonGroupPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3ButtonGroupPlugin(const QIcon &icon, QObject *parent = 0); virtual ~Q3ButtonGroupPlugin(); virtual QString name() const; @@ -80,7 +80,7 @@ class Q3ComboBoxPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3ComboBoxPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3ComboBoxPlugin(const QIcon &icon, QObject *parent = 0); virtual ~Q3ComboBoxPlugin(); virtual QString name() const; @@ -109,7 +109,7 @@ class Q3DateEditPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3DateEditPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3DateEditPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; @@ -157,7 +157,7 @@ class Q3FramePlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3FramePlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3FramePlugin(const QIcon &icon, QObject *parent = 0); virtual ~Q3FramePlugin(); virtual QString name() const; @@ -215,7 +215,7 @@ class Q3ProgressBarPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3ProgressBarPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3ProgressBarPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; @@ -263,7 +263,7 @@ class Q3TimeEditPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3TimeEditPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3TimeEditPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; diff --git a/tools/designer/src/plugins/widgets/q3wizard/q3wizard_container.h b/tools/designer/src/plugins/widgets/q3wizard/q3wizard_container.h index 524f3fd..e8cf4fa 100644 --- a/tools/designer/src/plugins/widgets/q3wizard/q3wizard_container.h +++ b/tools/designer/src/plugins/widgets/q3wizard/q3wizard_container.h @@ -59,7 +59,7 @@ class Q3WizardHelper : public QObject { Q_OBJECT public: - Q3WizardHelper(Q3Wizard *wizard); + explicit Q3WizardHelper(Q3Wizard *wizard); private slots: void slotCurrentChanged(); private: diff --git a/tools/designer/src/plugins/widgets/q3wizard/q3wizard_plugin.h b/tools/designer/src/plugins/widgets/q3wizard/q3wizard_plugin.h index 1837769..c9fff40 100644 --- a/tools/designer/src/plugins/widgets/q3wizard/q3wizard_plugin.h +++ b/tools/designer/src/plugins/widgets/q3wizard/q3wizard_plugin.h @@ -51,7 +51,7 @@ class Q3WizardPlugin: public QObject, public QDesignerCustomWidgetInterface Q_OBJECT Q_INTERFACES(QDesignerCustomWidgetInterface) public: - Q3WizardPlugin(const QIcon &icon, QObject *parent = 0); + explicit Q3WizardPlugin(const QIcon &icon, QObject *parent = 0); virtual QString name() const; virtual QString group() const; diff --git a/tools/shared/findwidget/texteditfindwidget.h b/tools/shared/findwidget/texteditfindwidget.h index 3034a42..a051f0e 100644 --- a/tools/shared/findwidget/texteditfindwidget.h +++ b/tools/shared/findwidget/texteditfindwidget.h @@ -53,7 +53,7 @@ class TextEditFindWidget : public AbstractFindWidget Q_OBJECT public: - TextEditFindWidget(FindFlags flags = FindFlags(), QWidget *parent = 0); + explicit TextEditFindWidget(FindFlags flags = FindFlags(), QWidget *parent = 0); QTextEdit *textEdit() const { return m_textEdit; } diff --git a/tools/shared/fontpanel/fontpanel.cpp b/tools/shared/fontpanel/fontpanel.cpp index 0b6f394..ad297df 100644 --- a/tools/shared/fontpanel/fontpanel.cpp +++ b/tools/shared/fontpanel/fontpanel.cpp @@ -217,7 +217,7 @@ void FontPanel::updateFamily(const QString &family) const QString normalStyle = QLatin1String("Normal"); if (hasStyles) { - foreach (QString style, styles) { + foreach (const QString &style, styles) { // try to maintain selection or select 'normal' preferably const int newIndex = m_styleComboBox->count(); m_styleComboBox->addItem(style); diff --git a/tools/shared/qtgradienteditor/qtgradientutils.cpp b/tools/shared/qtgradienteditor/qtgradientutils.cpp index 9fa0324..083ba89 100644 --- a/tools/shared/qtgradienteditor/qtgradientutils.cpp +++ b/tools/shared/qtgradienteditor/qtgradientutils.cpp @@ -395,7 +395,7 @@ static QStringList styleSheetParameters(const QGradient &gradient) static QStringList styleSheetStops(const QGradient &gradient) { QStringList result; - foreach (QGradientStop stop, gradient.stops()) { + foreach (const QGradientStop &stop, gradient.stops()) { const QColor color = stop.second; const QString stopDescription = QLatin1String("stop:") + QString::number(stop.first) + QLatin1String(" rgba(") diff --git a/tools/shared/qttoolbardialog/qttoolbardialog.h b/tools/shared/qttoolbardialog/qttoolbardialog.h index a1c099a..e182368 100644 --- a/tools/shared/qttoolbardialog/qttoolbardialog.h +++ b/tools/shared/qttoolbardialog/qttoolbardialog.h @@ -68,7 +68,7 @@ class QtToolBarManager : public QObject Q_OBJECT public: - QtToolBarManager(QObject *parent = 0); + explicit QtToolBarManager(QObject *parent = 0); ~QtToolBarManager(); void setMainWindow(QMainWindow *mainWindow); @@ -100,7 +100,7 @@ class QtToolBarDialog : public QDialog Q_OBJECT public: - QtToolBarDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0); + explicit QtToolBarDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0); ~QtToolBarDialog(); void setToolBarManager(QtToolBarManager *toolBarManager); -- cgit v0.12 From d381bb257f210432725221952d0a295decd56d91 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 28 Jan 2010 17:02:59 +0100 Subject: Fix some foreach usage to use const refs Reviewed-by: joao --- src/network/access/qhttpnetworkheader.cpp | 2 +- src/network/access/qnetworkrequest.cpp | 2 +- src/network/kernel/qnetworkinterface.cpp | 4 ++-- src/network/ssl/qsslsocket.cpp | 2 +- src/network/ssl/qsslsocket_openssl.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/network/access/qhttpnetworkheader.cpp b/src/network/access/qhttpnetworkheader.cpp index c2cc69c..669f9cf 100644 --- a/src/network/access/qhttpnetworkheader.cpp +++ b/src/network/access/qhttpnetworkheader.cpp @@ -80,7 +80,7 @@ QByteArray QHttpNetworkHeaderPrivate::headerField(const QByteArray &name, const QByteArray result; bool first = true; - foreach (QByteArray value, allValues) { + foreach (const QByteArray &value, allValues) { if (!first) result += ", "; first = false; diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index 6dcd05d..a2bef67 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -649,7 +649,7 @@ static QVariant parseCookieHeader(const QByteArray &raw) { QList result; QList cookieList = raw.split(';'); - foreach (QByteArray cookie, cookieList) { + foreach (const QByteArray &cookie, cookieList) { QList parsed = QNetworkCookie::parseCookies(cookie.trimmed()); if (parsed.count() != 1) return QVariant(); // invalid Cookie: header diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp index 367e3c4..1115c63 100644 --- a/src/network/kernel/qnetworkinterface.cpp +++ b/src/network/kernel/qnetworkinterface.cpp @@ -541,7 +541,7 @@ QList QNetworkInterface::allInterfaces() { QList > privs = manager()->allInterfaces(); QList result; - foreach (QSharedDataPointer p, privs) { + foreach (const QSharedDataPointer &p, privs) { QNetworkInterface item; item.d = p; result << item; @@ -560,7 +560,7 @@ QList QNetworkInterface::allAddresses() { QList > privs = manager()->allInterfaces(); QList result; - foreach (const QSharedDataPointer p, privs) { + foreach (const QSharedDataPointer &p, privs) { foreach (const QNetworkAddressEntry &entry, p->addressEntries) result += entry.ip(); } diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 6947aa7..9623570 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1109,7 +1109,7 @@ void QSslSocket::setCiphers(const QString &ciphers) { Q_D(QSslSocket); d->configuration.ciphers.clear(); - foreach (QString cipherName, ciphers.split(QLatin1String(":"),QString::SkipEmptyParts)) { + foreach (const QString &cipherName, ciphers.split(QLatin1String(":"),QString::SkipEmptyParts)) { for (int i = 0; i < 3; ++i) { // ### Crude QSslCipher cipher(cipherName, QSsl::SslProtocol(i)); diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 892d330..ce2aee1 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -818,7 +818,7 @@ bool QSslSocketBackendPrivate::startHandshake() QRegExp regexp(commonName, Qt::CaseInsensitive, QRegExp::Wildcard); if (!regexp.exactMatch(peerName)) { bool matched = false; - foreach (QString altName, configuration.peerCertificate + foreach (const QString &altName, configuration.peerCertificate .alternateSubjectNames().values(QSsl::DnsEntry)) { regexp.setPattern(altName); if (regexp.exactMatch(peerName)) { -- cgit v0.12 From 0585997b7dbe25ece9f60684171c16206d10d65f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Thu, 28 Jan 2010 16:34:21 +0100 Subject: Fix a regression: icons with slightly wrong ICO header did not load. Regression was introduced by commit fd9cdaa55da455b90eacec571aeb2c84fa55f7e0. Also fix a completely broken autotest that didn't actually test anything. Task-number: QTBUG-7688 Reviewed-by: Alexis --- src/plugins/imageformats/ico/qicohandler.cpp | 4 ++++ tests/auto/qimagereader/baseline/35floppy.ico | Bin 4286 -> 0 bytes tests/auto/qimagereader/baseline/35floppy.png | Bin 0 -> 329 bytes tests/auto/qimagereader/baseline/connect.png | Bin 0 -> 12943 bytes tests/auto/qimagereader/baseline/kde_favicon.ico | Bin 1150 -> 0 bytes tests/auto/qimagereader/baseline/kde_favicon.png | Bin 0 -> 514 bytes tests/auto/qimagereader/baseline/semitransparent.ico | Bin 9662 -> 0 bytes tests/auto/qimagereader/baseline/semitransparent.png | Bin 0 -> 545 bytes tests/auto/qimagereader/tst_qimagereader.cpp | 13 ++++++++++--- 9 files changed, 14 insertions(+), 3 deletions(-) delete mode 100644 tests/auto/qimagereader/baseline/35floppy.ico create mode 100644 tests/auto/qimagereader/baseline/35floppy.png create mode 100644 tests/auto/qimagereader/baseline/connect.png delete mode 100644 tests/auto/qimagereader/baseline/kde_favicon.ico create mode 100644 tests/auto/qimagereader/baseline/kde_favicon.png delete mode 100644 tests/auto/qimagereader/baseline/semitransparent.ico create mode 100644 tests/auto/qimagereader/baseline/semitransparent.png diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index 4f49476..b2351fa 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -556,7 +556,11 @@ QImage ICOReader::iconAt(int index) else // # colors used icoAttrib.ncolors = header.biClrUsed ? header.biClrUsed : 1 << icoAttrib.nbits; icoAttrib.w = iconEntry.bWidth; + if (icoAttrib.w == 0) + icoAttrib.w = header.biWidth; icoAttrib.h = iconEntry.bHeight; + if (icoAttrib.h == 0) + icoAttrib.h = header.biHeight/2; QImage::Format format = QImage::Format_ARGB32; if (icoAttrib.nbits == 24) diff --git a/tests/auto/qimagereader/baseline/35floppy.ico b/tests/auto/qimagereader/baseline/35floppy.ico deleted file mode 100644 index 59fd37e..0000000 Binary files a/tests/auto/qimagereader/baseline/35floppy.ico and /dev/null differ diff --git a/tests/auto/qimagereader/baseline/35floppy.png b/tests/auto/qimagereader/baseline/35floppy.png new file mode 100644 index 0000000..56b9b44 Binary files /dev/null and b/tests/auto/qimagereader/baseline/35floppy.png differ diff --git a/tests/auto/qimagereader/baseline/connect.png b/tests/auto/qimagereader/baseline/connect.png new file mode 100644 index 0000000..9544bb9 Binary files /dev/null and b/tests/auto/qimagereader/baseline/connect.png differ diff --git a/tests/auto/qimagereader/baseline/kde_favicon.ico b/tests/auto/qimagereader/baseline/kde_favicon.ico deleted file mode 100644 index 15bcdbb..0000000 Binary files a/tests/auto/qimagereader/baseline/kde_favicon.ico and /dev/null differ diff --git a/tests/auto/qimagereader/baseline/kde_favicon.png b/tests/auto/qimagereader/baseline/kde_favicon.png new file mode 100644 index 0000000..e19287b Binary files /dev/null and b/tests/auto/qimagereader/baseline/kde_favicon.png differ diff --git a/tests/auto/qimagereader/baseline/semitransparent.ico b/tests/auto/qimagereader/baseline/semitransparent.ico deleted file mode 100644 index dd23de9..0000000 Binary files a/tests/auto/qimagereader/baseline/semitransparent.ico and /dev/null differ diff --git a/tests/auto/qimagereader/baseline/semitransparent.png b/tests/auto/qimagereader/baseline/semitransparent.png new file mode 100644 index 0000000..a3ad780 Binary files /dev/null and b/tests/auto/qimagereader/baseline/semitransparent.png differ diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index 72c5c8b..e7cfe68 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -1633,7 +1633,8 @@ void tst_QImageReader::pixelCompareWithBaseline_data() QTest::newRow("floppy (16px,32px - 16 colors)") << "35floppy.ico"; QTest::newRow("semitransparent") << "semitransparent.ico"; - QTest::newRow("slightlybroken") << "kde_favicon.ico"; + QTest::newRow("slightlybrokenBMPHeader") << "kde_favicon.ico"; + QTest::newRow("sightlybrokenIconHeader") << "connect.ico"; } void tst_QImageReader::pixelCompareWithBaseline() @@ -1641,14 +1642,20 @@ void tst_QImageReader::pixelCompareWithBaseline() QFETCH(QString, fileName); QImage icoImg; + const QString inputFileName(QString::fromAscii("images/%1").arg(fileName)); + QFileInfo fi(inputFileName); + // might fail if the plugin does not exist, which is ok. - if (icoImg.load(QString::fromAscii("images/%1").arg(fileName))) { - QString baselineFileName = QString::fromAscii("baseline/%1").arg(fileName); + if (icoImg.load(inputFileName)) { + icoImg = icoImg.convertToFormat(QImage::Format_ARGB32_Premultiplied); + const QString baselineFileName(QString::fromAscii("baseline/%1.png").arg(fi.baseName())); #if 0 icoImg.save(baselineFileName); #else QImage baseImg; QVERIFY(baseImg.load(baselineFileName)); + baseImg = baseImg.convertToFormat(QImage::Format_ARGB32_Premultiplied); + QCOMPARE(int(baseImg.format()), int(icoImg.format())); QCOMPARE(baseImg, icoImg); #endif } -- cgit v0.12 From bc1bf5fa40b56bf2787fbdf10d1612ca5803167e Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 28 Jan 2010 17:16:26 +0100 Subject: Call cheaper clear() instead of assigning new QString() Reviewed-by: joao Reviewed-by: Peter Hartmann --- src/network/kernel/qauthenticator.cpp | 4 ++-- src/network/socket/qlocalserver.cpp | 10 +++++----- src/network/socket/qlocalsocket_tcp.cpp | 10 +++++----- src/network/socket/qlocalsocket_unix.cpp | 14 +++++++------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 193a043..e4023c8 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -270,7 +270,7 @@ void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header, break; case Ntlm: // #### extract from header - realm = QString(); + realm.clear(); break; case DigestMd5: { realm = QString::fromLatin1(options.value("realm")); @@ -281,7 +281,7 @@ void QAuthenticatorPrivate::parseHttpResponse(const QHttpResponseHeader &header, break; } default: - realm = QString(); + realm.clear(); challenge = QByteArray(); phase = Invalid; } diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp index ede3c89..ef7fc02 100644 --- a/src/network/socket/qlocalserver.cpp +++ b/src/network/socket/qlocalserver.cpp @@ -122,9 +122,9 @@ void QLocalServer::close() qDeleteAll(d->pendingConnections); d->pendingConnections.clear(); d->closeServer(); - d->serverName = QString(); - d->fullServerName = QString(); - d->errorString = QString(); + d->serverName.clear(); + d->fullServerName.clear(); + d->errorString.clear(); d->error = QAbstractSocket::UnknownSocketError; } @@ -226,8 +226,8 @@ bool QLocalServer::listen(const QString &name) } if (!d->listen(name)) { - d->serverName = QString(); - d->fullServerName = QString(); + d->serverName.clear(); + d->fullServerName.clear(); return false; } diff --git a/src/network/socket/qlocalsocket_tcp.cpp b/src/network/socket/qlocalsocket_tcp.cpp index 9f574d4..5b5e84f 100644 --- a/src/network/socket/qlocalsocket_tcp.cpp +++ b/src/network/socket/qlocalsocket_tcp.cpp @@ -102,8 +102,8 @@ void QLocalSocketPrivate::_q_stateChanged(QAbstractSocket::SocketState newState) switch(newState) { case QAbstractSocket::UnconnectedState: state = QLocalSocket::UnconnectedState; - serverName = QString(); - fullServerName = QString(); + serverName.clear(); + fullServerName.clear(); break; case QAbstractSocket::ConnectingState: state = QLocalSocket::ConnectingState; @@ -218,7 +218,7 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) || state() == ConnectingState) return; - d->errorString = QString(); + d->errorString.clear(); d->state = ConnectingState; emit stateChanged(d->state); @@ -333,8 +333,8 @@ void QLocalSocket::close() { Q_D(QLocalSocket); d->tcpSocket->close(); - d->serverName = QString(); - d->fullServerName = QString(); + d->serverName.clear(); + d->fullServerName.clear(); QIODevice::close(); } diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index 73c2465..1ca11d8 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -109,8 +109,8 @@ void QLocalSocketPrivate::_q_stateChanged(QAbstractSocket::SocketState newState) switch(newState) { case QAbstractSocket::UnconnectedState: state = QLocalSocket::UnconnectedState; - serverName = QString(); - fullServerName = QString(); + serverName.clear(); + fullServerName.clear(); break; case QAbstractSocket::ConnectingState: state = QLocalSocket::ConnectingState; @@ -225,7 +225,7 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode) || state() == ConnectingState) return; - d->errorString = QString(); + d->errorString.clear(); d->unixSocket.setSocketState(QAbstractSocket::ConnectingState); d->state = ConnectingState; emit stateChanged(d->state); @@ -341,7 +341,7 @@ void QLocalSocketPrivate::_q_connectToSocket() errorOccurred(QLocalSocket::UnknownSocketError, function); } connectingSocket = -1; - connectingName = QString(); + connectingName.clear(); connectingOpenMode = 0; } @@ -438,10 +438,10 @@ void QLocalSocket::close() if (d->connectingSocket != -1) ::close(d->connectingSocket); d->connectingSocket = -1; - d->connectingName = QString(); + d->connectingName.clear(); d->connectingOpenMode = 0; - d->serverName = QString(); - d->fullServerName = QString(); + d->serverName.clear(); + d->fullServerName.clear(); QIODevice::close(); } -- cgit v0.12 From 2ffe2fafcd8ed7c2b6267a016401af86ed57b540 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 28 Jan 2010 18:24:39 +0100 Subject: Doc: Put the correct images with the D-Bus and Embedded Linux sections. Reviewed-by: Trust Me --- doc/src/getting-started/examples.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/getting-started/examples.qdoc b/doc/src/getting-started/examples.qdoc index 6b4ec61..0c18773 100644 --- a/doc/src/getting-started/examples.qdoc +++ b/doc/src/getting-started/examples.qdoc @@ -406,7 +406,7 @@ \clearfloat \section1 \l{D-Bus Examples}{D-Bus} \beginfloatleft - \l{D-Bus Examples}{\inlineimage qt-embedded-examples.png + \l{D-Bus Examples}{\inlineimage dbus-examples.png } \endfloat @@ -416,7 +416,7 @@ \clearfloat \section1 \l{Qt for Embedded Linux Examples}{Qt for Embedded Linux} \beginfloatleft - \l{Qt for Embedded Linux Examples}{\inlineimage dbus-examples.png + \l{Qt for Embedded Linux Examples}{\inlineimage qt-embedded-examples.png } \endfloat -- cgit v0.12 From 9c2ee0daafd159058d0804d4fc65a8ef1a4ed852 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 29 Jan 2010 12:46:07 +1000 Subject: Fixed `make test' for xmlpatternsxqts. As far as I can tell, setting lib.file here is unnecessary, and it happens to break `make test'. The reason is that, on the first pass, qmake will generate Makefile.lib; then, when `make' is run, it will generate Makefile, and any additional parameters originally passed to qmake will be omitted. --- tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro b/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro index 39267c8..3f49ccc 100644 --- a/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro +++ b/tests/auto/xmlpatternsxqts/xmlpatternsxqts.pro @@ -1,7 +1,6 @@ TEMPLATE = subdirs contains(QT_CONFIG,xmlpatterns) { SUBDIRS += lib - !wince*:lib.file = lib/lib.pro test.depends = lib } SUBDIRS += test -- cgit v0.12 From 9e376b07ff206c39af731f112b1e6de28b438e97 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 29 Jan 2010 13:59:36 +1000 Subject: Add QFontMetrics benchmark. --- tests/benchmarks/benchmarks.pro | 1 + tests/benchmarks/qfontmetrics/main.cpp | 112 +++++++++++++++++++++++++ tests/benchmarks/qfontmetrics/qfontmetrics.pro | 5 ++ 3 files changed, 118 insertions(+) create mode 100644 tests/benchmarks/qfontmetrics/main.cpp create mode 100644 tests/benchmarks/qfontmetrics/qfontmetrics.pro diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro index 1c78f1f..7a27cc9 100644 --- a/tests/benchmarks/benchmarks.pro +++ b/tests/benchmarks/benchmarks.pro @@ -5,6 +5,7 @@ SUBDIRS = containers-associative \ qbytearray \ qfileinfo \ qfile_vs_qnetworkaccessmanager \ + qfontmetrics \ qhostinfo \ qpainter \ qtestlib-simple events \ diff --git a/tests/benchmarks/qfontmetrics/main.cpp b/tests/benchmarks/qfontmetrics/main.cpp new file mode 100644 index 0000000..d3f85ef --- /dev/null +++ b/tests/benchmarks/qfontmetrics/main.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** +****************************************************************************/ + +#include +#include +#include + +#include + +//this test benchmarks the once-off (per font configuration) cost +//associated with using QFontMetrics +class tst_QFontMetrics : public QObject +{ + Q_OBJECT +public: + tst_QFontMetrics() {} +private slots: + void fontmetrics_create(); + void fontmetrics_create_once_loaded(); + + void fontmetrics_height(); + void fontmetrics_height_once_loaded(); + +private: + void testQFontMetrics(const QFontMetrics &fm); +}; + +void tst_QFontMetrics::testQFontMetrics( const QFontMetrics &fm ) +{ + int fontHeight = fm.height(); +} + +void tst_QFontMetrics::fontmetrics_create() +{ + QBENCHMARK { + QFont boldfont = QApplication::font(); + boldfont.setBold( true ); + boldfont.setPointSize(boldfont.pointSize() * 1.5 ); + QFontMetrics bfm( boldfont ); + } +} + +void tst_QFontMetrics::fontmetrics_create_once_loaded() +{ + QBENCHMARK { + QFont boldfont = QApplication::font(); + boldfont.setBold( true ); + boldfont.setPointSize(boldfont.pointSize() * 1.5 ); + QFontMetrics bfm( boldfont ); + } +} + +void tst_QFontMetrics::fontmetrics_height() +{ + QFont boldfont = QApplication::font(); + boldfont.setBold( true ); + boldfont.setPointSize(boldfont.pointSize() * 1.5 ); + QFontMetrics bfm( boldfont ); + + QBENCHMARK { testQFontMetrics(bfm); } +} + +void tst_QFontMetrics::fontmetrics_height_once_loaded() +{ + QFont boldfont = QApplication::font(); + boldfont.setBold( true ); + boldfont.setPointSize(boldfont.pointSize() * 1.5 ); + QFontMetrics bfm( boldfont ); + QBENCHMARK { testQFontMetrics(bfm); } +} + +QTEST_MAIN(tst_QFontMetrics) + +#include "main.moc" diff --git a/tests/benchmarks/qfontmetrics/qfontmetrics.pro b/tests/benchmarks/qfontmetrics/qfontmetrics.pro new file mode 100644 index 0000000..b6c7b92 --- /dev/null +++ b/tests/benchmarks/qfontmetrics/qfontmetrics.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_QFontMetrics + +SOURCES += main.cpp -- cgit v0.12 From cefda8e4491ff82c96fceea2091f69160f8ae584 Mon Sep 17 00:00:00 2001 From: ck Date: Fri, 29 Jan 2010 16:07:29 +0100 Subject: Assistant: Fix unintended tr context change. Bug was introduced by af30aeb6a1ebb7307f06c122c0c93d152f4d958c Contributed-by: Ritt Konstantin --- tools/assistant/lib/qhelpsearchquerywidget.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/assistant/lib/qhelpsearchquerywidget.cpp b/tools/assistant/lib/qhelpsearchquerywidget.cpp index b614cb4..f2bb816 100644 --- a/tools/assistant/lib/qhelpsearchquerywidget.cpp +++ b/tools/assistant/lib/qhelpsearchquerywidget.cpp @@ -122,17 +122,17 @@ private: void retranslate() { - simpleSearchLabel->setText(tr("Search for:")); - prevQueryButton->setToolTip(tr("Previous search")); - nextQueryButton->setToolTip(tr("Next search")); - searchButton->setText(tr("Search")); + simpleSearchLabel->setText(QHelpSearchQueryWidget::tr("Search for:")); + prevQueryButton->setToolTip(QHelpSearchQueryWidget::tr("Previous search")); + nextQueryButton->setToolTip(QHelpSearchQueryWidget::tr("Next search")); + searchButton->setText(QHelpSearchQueryWidget::tr("Search")); #ifdef QT_CLUCENE_SUPPORT - advancedSearchLabel->setText(tr("Advanced search")); - similarLabel->setText(tr("words similar to:")); - withoutLabel->setText(tr("without the words:")); - exactLabel->setText(tr("with exact phrase:")); - allLabel->setText(tr("with all of the words:")); - atLeastLabel->setText(tr("with at least one of the words:")); + advancedSearchLabel->setText(QHelpSearchQueryWidget::tr("Advanced search")); + similarLabel->setText(QHelpSearchQueryWidget::tr("words similar to:")); + withoutLabel->setText(QHelpSearchQueryWidget::tr("without the words:")); + exactLabel->setText(QHelpSearchQueryWidget::tr("with exact phrase:")); + allLabel->setText(QHelpSearchQueryWidget::tr("with all of the words:")); + atLeastLabel->setText(QHelpSearchQueryWidget::tr("with at least one of the words:")); #endif } -- cgit v0.12 From 65493e69454f8914d0ae1607e5a071ea07bb7017 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Mon, 1 Feb 2010 14:42:47 +1000 Subject: audiodevices example: no devices available audio-backend option was not being written out to qconfig.pri Task-number:QTBUG-7782 Reviewed-by:Justin McPherson --- tools/configure/configureapp.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 7751143..abf81bd 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -2535,8 +2535,11 @@ void Configure::generateOutputVars() qtConfig += "phonon-backend"; } - if (dictionary["MULTIMEDIA"] == "yes") + if (dictionary["MULTIMEDIA"] == "yes") { qtConfig += "multimedia"; + if (dictionary["AUDIO_BACKEND"] == "yes") + qtConfig += "audio-backend"; + } if (dictionary["WEBKIT"] == "yes") qtConfig += "webkit"; -- cgit v0.12