summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/fx')
-rw-r--r--src/declarative/fx/fx.pri21
-rw-r--r--src/declarative/fx/qfxanchors.cpp14
-rw-r--r--src/declarative/fx/qfxblurfilter.cpp467
-rw-r--r--src/declarative/fx/qfxblurfilter.h83
-rw-r--r--src/declarative/fx/qfxcomponentinstance.h2
-rw-r--r--src/declarative/fx/qfxflickable.cpp5
-rw-r--r--src/declarative/fx/qfxflickable.h2
-rw-r--r--src/declarative/fx/qfxflipable.cpp24
-rw-r--r--src/declarative/fx/qfxflipable.h7
-rw-r--r--src/declarative/fx/qfxfocuspanel.h81
-rw-r--r--src/declarative/fx/qfxgraphicsobjectcontainer.cpp (renamed from src/declarative/fx/qfxfocuspanel.cpp)68
-rw-r--r--src/declarative/fx/qfxgraphicsobjectcontainer.h (renamed from src/declarative/fx/qfxwidgetcontainer.h)28
-rw-r--r--src/declarative/fx/qfxgridview.cpp4
-rw-r--r--src/declarative/fx/qfxgridview.h2
-rw-r--r--src/declarative/fx/qfxhighlightfilter.cpp320
-rw-r--r--src/declarative/fx/qfximage.cpp456
-rw-r--r--src/declarative/fx/qfximage.h17
-rw-r--r--src/declarative/fx/qfximage_p.h22
-rw-r--r--src/declarative/fx/qfxitem.cpp712
-rw-r--r--src/declarative/fx/qfxitem.h162
-rw-r--r--src/declarative/fx/qfxitem_p.h48
-rw-r--r--src/declarative/fx/qfxkeyactions.cpp2
-rw-r--r--src/declarative/fx/qfxkeyproxy.cpp120
-rw-r--r--src/declarative/fx/qfxkeyproxy.h2
-rw-r--r--src/declarative/fx/qfxlayouts.cpp24
-rw-r--r--src/declarative/fx/qfxlayouts.h2
-rw-r--r--src/declarative/fx/qfxlineedit.cpp518
-rw-r--r--src/declarative/fx/qfxlineedit.h188
-rw-r--r--src/declarative/fx/qfxlineedit_p.h (renamed from src/declarative/fx/qfxhighlightfilter.h)101
-rw-r--r--src/declarative/fx/qfxlistview.cpp3
-rw-r--r--src/declarative/fx/qfxlistview.h2
-rw-r--r--src/declarative/fx/qfxmouseregion.cpp52
-rw-r--r--src/declarative/fx/qfxmouseregion.h4
-rw-r--r--src/declarative/fx/qfxmouseregion_p.h5
-rw-r--r--src/declarative/fx/qfxpainteditem.cpp47
-rw-r--r--src/declarative/fx/qfxpainteditem.h6
-rw-r--r--src/declarative/fx/qfxpainteditem_p.h9
-rw-r--r--src/declarative/fx/qfxpath.cpp1
-rw-r--r--src/declarative/fx/qfxpathview.cpp5
-rw-r--r--src/declarative/fx/qfxpathview.h2
-rw-r--r--src/declarative/fx/qfxpathview_p.h2
-rw-r--r--src/declarative/fx/qfxpixmap.cpp1
-rw-r--r--src/declarative/fx/qfxpixmap.h3
-rw-r--r--src/declarative/fx/qfxrect.cpp356
-rw-r--r--src/declarative/fx/qfxrect.h10
-rw-r--r--src/declarative/fx/qfxrect_p.h10
-rw-r--r--src/declarative/fx/qfxreflectionfilter.cpp352
-rw-r--r--src/declarative/fx/qfxreflectionfilter.h97
-rw-r--r--src/declarative/fx/qfxrepeater.cpp5
-rw-r--r--src/declarative/fx/qfxrepeater.h4
-rw-r--r--src/declarative/fx/qfxscalegrid.h1
-rw-r--r--src/declarative/fx/qfxshadowfilter.cpp214
-rw-r--r--src/declarative/fx/qfxshadowfilter.h87
-rw-r--r--src/declarative/fx/qfxtext.cpp128
-rw-r--r--src/declarative/fx/qfxtext.h7
-rw-r--r--src/declarative/fx/qfxtext_p.h7
-rw-r--r--src/declarative/fx/qfxtextedit.cpp35
-rw-r--r--src/declarative/fx/qfxtextedit.h3
-rw-r--r--src/declarative/fx/qfxtextedit_p.h5
-rw-r--r--src/declarative/fx/qfxtransform.cpp113
-rw-r--r--src/declarative/fx/qfxtransform.h27
-rw-r--r--src/declarative/fx/qfxvisualitemmodel.cpp1
-rw-r--r--src/declarative/fx/qfxwebview.cpp61
-rw-r--r--src/declarative/fx/qfxwebview.h6
-rw-r--r--src/declarative/fx/qfxwidgetcontainer.cpp108
65 files changed, 1881 insertions, 3400 deletions
diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri
index 0c26356..24c5536 100644
--- a/src/declarative/fx/fx.pri
+++ b/src/declarative/fx/fx.pri
@@ -1,23 +1,20 @@
HEADERS += \
fx/qfxanchors.h \
fx/qfxanchors_p.h \
- fx/qfxblurfilter.h \
fx/qfxcomponentinstance.h \
fx/qfxcomponentinstance_p.h \
fx/qfxevents_p.h \
fx/qfxflickable.h \
fx/qfxflickable_p.h \
fx/qfxflipable.h \
- fx/qfxfocuspanel.h \
- fx/qfxfocusrealm.h \
fx/qfxgridview.h \
- fx/qfxhighlightfilter.h \
fx/qfximage.h \
fx/qfxpainteditem.h \
fx/qfxpainteditem_p.h \
fx/qfximage_p.h \
fx/qfxitem.h \
fx/qfxitem_p.h \
+ fx/qfxfocusrealm.h \
fx/qfxkeyactions.h \
fx/qfxkeyproxy.h \
fx/qfxlayouts.h \
@@ -30,11 +27,11 @@ HEADERS += \
fx/qfxpathview_p.h \
fx/qfxrect.h \
fx/qfxrect_p.h \
- fx/qfxreflectionfilter.h \
fx/qfxrepeater.h \
fx/qfxrepeater_p.h \
fx/qfxscalegrid.h \
- fx/qfxshadowfilter.h \
+ fx/qfxlineedit.h \
+ fx/qfxlineedit_p.h \
fx/qfxtextedit.h \
fx/qfxtextedit_p.h \
fx/qfxtext.h \
@@ -43,22 +40,19 @@ HEADERS += \
fx/qfxpixmap.cpp \
fx/qfxvisualitemmodel.h \
fx/qfxlistview.h \
- fx/qfxwidgetcontainer.h \
+ fx/qfxgraphicsobjectcontainer.h \
SOURCES += \
fx/qfxanchors.cpp \
- fx/qfxblurfilter.cpp \
fx/qfxcomponentinstance.cpp \
fx/qfxevents.cpp \
fx/qfxflickable.cpp \
fx/qfxflipable.cpp \
- fx/qfxfocuspanel.cpp \
- fx/qfxfocusrealm.cpp \
fx/qfxgridview.cpp \
- fx/qfxhighlightfilter.cpp \
fx/qfximage.cpp \
fx/qfxpainteditem.cpp \
fx/qfxitem.cpp \
+ fx/qfxfocusrealm.cpp \
fx/qfxkeyactions.cpp \
fx/qfxkeyproxy.cpp \
fx/qfxlayouts.cpp \
@@ -66,17 +60,16 @@ SOURCES += \
fx/qfxpath.cpp \
fx/qfxpathview.cpp \
fx/qfxrect.cpp \
- fx/qfxreflectionfilter.cpp \
fx/qfxrepeater.cpp \
fx/qfxscalegrid.cpp \
- fx/qfxshadowfilter.cpp \
+ fx/qfxlineedit.cpp \
fx/qfxtext.cpp \
fx/qfxtextedit.cpp \
fx/qfxtransform.cpp \
fx/qfxpixmap.cpp \
fx/qfxvisualitemmodel.cpp \
fx/qfxlistview.cpp \
- fx/qfxwidgetcontainer.cpp \
+ fx/qfxgraphicsobjectcontainer.cpp \
contains(QT_CONFIG, webkit) {
QT+=webkit
diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp
index 9a5c516..e1b450d 100644
--- a/src/declarative/fx/qfxanchors.cpp
+++ b/src/declarative/fx/qfxanchors.cpp
@@ -222,7 +222,7 @@ void QFxAnchorsPrivate::addDepend(QFxItem *item)
if (!item)
return;
QFxItemPrivate *p =
- static_cast<QFxItemPrivate *>(QObjectPrivate::get(item));
+ static_cast<QFxItemPrivate *>(QGraphicsItemPrivate::get(item));
p->dependantAnchors.append(q);
}
@@ -232,7 +232,7 @@ void QFxAnchorsPrivate::remDepend(QFxItem *item)
if (!item)
return;
QFxItemPrivate *p =
- static_cast<QFxItemPrivate *>(QObjectPrivate::get(item));
+ static_cast<QFxItemPrivate *>(QGraphicsItemPrivate::get(item));
p->dependantAnchors.removeAll(q);
}
@@ -324,6 +324,11 @@ QFxItem *QFxAnchors::fill() const
void QFxAnchors::setFill(QFxItem *f)
{
Q_D(QFxAnchors);
+ if (!f) {
+ d->remDepend(d->fill);
+ d->fill = f;
+ return;
+ }
if (f != d->item->itemParent() && f->itemParent() != d->item->itemParent()){
qmlInfo(d->item) << "Can't anchor to an item that isn't a parent or sibling.";
return;
@@ -351,8 +356,9 @@ QFxItem *QFxAnchors::centeredIn() const
void QFxAnchors::setCenteredIn(QFxItem* c)
{
Q_D(QFxAnchors);
- if (!c){
- qmlInfo(d->item) << "Cannot center in null item.";
+ if (!c) {
+ d->remDepend(d->centeredIn);
+ d->centeredIn = c;
return;
}
if (c != d->item->itemParent() && c->itemParent() != d->item->itemParent()){
diff --git a/src/declarative/fx/qfxblurfilter.cpp b/src/declarative/fx/qfxblurfilter.cpp
deleted file mode 100644
index 84799ec..0000000
--- a/src/declarative/fx/qfxblurfilter.cpp
+++ /dev/null
@@ -1,467 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfxblurfilter.h"
-#include <private/qsimplecanvasitem_p.h>
-
-#if defined(QFX_RENDER_OPENGL2)
-#include <glsave.h>
-#include <QtOpenGL/qglframebufferobject.h>
-#include <glbasicshaders.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-class QFxBlurFilterPrivate
-{
-public:
- QFxBlurFilterPrivate()
- : radius(0)
- {
- }
- qreal radius;
-};
-
-/*!
- \qmlclass Blur
- \brief The Blur filter blurs an item and its contents.
- \inherits Filter
-
- Blurring reduces the clarity of a visual item. The following example
- shows an icon at a blur radius of 0, 5 and 10.
-
- \table
- \row
- \o
- \qml
-HorizontalLayout {
- Image {
- source: "icon.png"
- filter: Blur { radius: 0 }
- }
- Image {
- source: "icon.png"
- filter: Blur { radius: 5 }
- }
- Image {
- source: "icon.png"
- filter: Blur { radius: 10 }
- }
-}
- \endqml
- \row
- \o \image blur_example.png
- \endtable
-
- Bluring is only supported when Qt Declarative is compiled for OpenGL ES 2.0.
- Otherwise the Blur filter has no effect.
- */
-/*!
- \internal
- \class QFxBlurFilter
- \ingroup group_effects
- \brief The QFxBlurFilter class allows you to blur an item.
-*/
-
-QFxBlurFilter::QFxBlurFilter(QObject *parent)
-: QSimpleCanvasFilter(parent), d(new QFxBlurFilterPrivate)
-{
-}
-
-QFxBlurFilter::~QFxBlurFilter()
-{
- delete d; d = 0;
-}
-
-/*!
- \qmlproperty real Blur::radius
-
- Sets the blur kernel radius.
- The larger the radius the more blurry the item will appear.
- A radius of 0 (or less) is equivalent to no blur.
- */
-
-/*!
- \property QFxBlurFilter::radius
- \brief the radius of the blur.
-*/
-qreal QFxBlurFilter::radius() const
-{
- return d->radius;
-}
-
-void QFxBlurFilter::setRadius(qreal radius)
-{
- if (d->radius == radius) return;
- d->radius = radius;
- emit radiusChanged(radius);
- update();
-}
-
-QRectF QFxBlurFilter::itemBoundingRect(const QRectF &r) const
-{
- QRectF rv = r;
- if (d->radius > 0)
- rv.adjust(-d->radius, -d->radius, d->radius, d->radius);
- return rv;
-}
-
-#include <math.h>
-void QFxBlurFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
-{
-#if defined(QFX_RENDER_OPENGL2)
-#if 1
- if (d->radius <= 0) {
- renderToScreen();
- return;
- }
- float radius = d->radius;
- QSimpleCanvasItem *item = this->item();
-
- QRect r = item->itemBoundingRect();
- float blurScale = 1.0;
- QRect tr = QRect(QPoint(0, 0), r.size() * blurScale);
- radius *= blurScale;
-
- QGLFramebufferObject *fbo = renderToFBO(blurScale);
- if (!fbo)
- return;
-
- float height = r.height();
- float width = r.width();
-
- float texWidth = float(tr.width()) / float(fbo->width());
- float texHeight = float(tr.height()) / float(fbo->height());
-
- int steps = int(::ceil(radius));
- int dispSteps = int(::ceil(d->radius));
- float xstep = texWidth * radius / float(steps * fbo->width());
- float xinc = steps / float(fbo->width());
-
- glDisable(GL_BLEND);
-
- // Render x pass
- QSize xSize(tr.width() + 2 * steps, tr.height());
- QGLFramebufferObject *xBlur = acquireFBO(xSize);
- float xWidth = float(xSize.width()) / float(xBlur->width());
- float xHeight = float(xSize.height()) / float(xBlur->height());
- {
- xBlur->bind();
-
- GLSaveViewport sv; GLSaveScissor ss;
- glClearColor(0,0,0,0);
- glDisable(GL_SCISSOR_TEST);
- glViewport(0, 0, xBlur->width(), xBlur->height());
- glClear(GL_COLOR_BUFFER_BIT);
-
- float vert[] = { 0, xHeight,
- xWidth, xHeight,
- 0, 0,
- xWidth, 0 };
- float texVert[] = { -xinc, 0,
- texWidth + xinc, 0,
- -xinc, texHeight,
- texWidth + xinc, texHeight };
-
- QMatrix4x4 trans;
- trans.translate(-1, -1);
- trans.scale(2, 2);
- BlurTextureShader *shader = item->basicShaders()->blurTexture();
- shader->enable();
- shader->setTransform(trans);
- if (steps > 1) {
- shader->setStep(xstep * 2);
- shader->setSteps(steps / 2);
- } else {
- shader->setStep(xstep);
- shader->setSteps(steps);
- }
- shader->setMode(BlurTextureShader::Horizontal);
-
- glBindTexture(GL_TEXTURE_2D, fbo->texture());
-
- shader->setAttributeArray(BlurTextureShader::Vertices, vert, 2);
- shader->setAttributeArray(BlurTextureShader::TextureCoords, texVert, 2);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- shader->disableAttributeArray(BlurTextureShader::Vertices);
- shader->disableAttributeArray(BlurTextureShader::TextureCoords);
- xBlur->release();
- }
-
- // Render y pass
- QSize ySize(xSize.width(), tr.height() + 2 * steps);
- QGLFramebufferObject *yBlur = acquireFBO(ySize);
-
- float yWidth = float(ySize.width()) / float(yBlur->width());
- float yHeight = float(ySize.height()) / float(yBlur->height());
- float ystep = radius / float(steps * xBlur->height());
- float yinc = steps / float(xBlur->height());
- {
- yBlur->bind();
-
- GLSaveViewport sv; GLSaveScissor ss;
- glClearColor(0,0,0,0);
- glDisable(GL_SCISSOR_TEST);
- glViewport(0, 0, yBlur->width(), yBlur->height());
- glClear(GL_COLOR_BUFFER_BIT);
-
- float vert[] = { 0, yHeight,
- yWidth, yHeight,
- 0, 0,
- yWidth, 0 };
- float texVert[] = { 0, -yinc,
- xWidth, -yinc,
- 0, xHeight + yinc,
- xWidth, xHeight + yinc };
-
- QMatrix4x4 trans;
- trans.translate(-1, -1);
- trans.scale(2, 2);
- BlurTextureShader *shader = item->basicShaders()->blurTexture();
- shader->enable();
- shader->setTransform(trans);
- if (steps > 1) {
- shader->setStep(ystep * 2);
- shader->setSteps(steps / 2);
- } else {
- shader->setStep(ystep);
- shader->setSteps(steps);
- }
- shader->setMode(BlurTextureShader::Vertical);
-
- glBindTexture(GL_TEXTURE_2D, xBlur->texture());
-
- shader->setAttributeArray(BlurTextureShader::Vertices, vert, 2);
- shader->setAttributeArray(BlurTextureShader::TextureCoords, texVert, 2);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- shader->disableAttributeArray(BlurTextureShader::Vertices);
- shader->disableAttributeArray(BlurTextureShader::TextureCoords);
- yBlur->release();
- }
-
- glEnable(GL_BLEND);
-
- // Render display pass
- {
- glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- float vert[] = { -dispSteps, height + dispSteps,
- width + dispSteps, height + dispSteps,
- -dispSteps, -dispSteps,
- width + dispSteps, -dispSteps };
- float texVert[] = { 0, 0,
- yWidth, 0,
- 0, yHeight,
- yWidth, yHeight };
- SingleTextureShader *shader = item->basicShaders()->singleTexture();
- shader->enable();
- shader->setTransform(p.activeTransform);
-
- glBindTexture(GL_TEXTURE_2D, yBlur->texture());
-
- shader->setAttributeArray(SingleTextureShader::Vertices, vert, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, texVert, 2);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- shader->disableAttributeArray(SingleTextureShader::Vertices);
- shader->disableAttributeArray(SingleTextureShader::TextureCoords);
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- }
-
- releaseFBO(yBlur);
- releaseFBO(xBlur);
- releaseFBO(fbo);
-#else
-#if 0
- if (d->radius <= 0) {
- renderToScreen();
- return;
- }
- QSimpleCanvasItem *item = this->item();
-
- QRect r = item->itemBoundingRect();
-
- float scale = 0.5;
- float scalePercent = scale / d->radius;
- QGLFramebufferObject *fbo = renderToFBO(scalePercent);
- if (!fbo)
- return;
-
- QGLFramebufferObject *xfbo = acquireFBO(QSize(scale * r.width(), fbo->height()));
- QGLFramebufferObject *yfbo = acquireFBO(QSize(scale * r.width(), scale * r.height()));
-
-
- BlurTextureShader *shader = item->basicShaders()->blurTexture();
- shader->enable();
- shader->setTransform(QMatrix4x4());
-
- // Render up - x
- {
- shader->setMode(BlurTextureShader::Horizontal);
- shader->setStep(1. / float(xfbo->width()));
-
- GLSaveViewport vp;
- xfbo->bind();
- glClearColor(0,0,0,0);
- glViewport(0, 0, xfbo->width(), xfbo->height());
- glClear(GL_COLOR_BUFFER_BIT);
-
- float oWidth = -1. + 2. * float(r.width()) * scale / float(xfbo->width());
- float oHeight = -1. + 2. * float(r.height()) * scalePercent / float(xfbo->height());
- float vert[] = {
- -1, -1,
- oWidth, -1,
- -1, oHeight,
-
- -1, oHeight,
- oWidth, oHeight,
- oWidth, -1
- };
-
- float tWidth = r.width() * scalePercent / fbo->width();
- float tHeight = r.height() * scalePercent / fbo->height();
- float texVert[] = {
- 0, 0,
- tWidth, 0,
- 0, tHeight,
-
- 0, tHeight,
- tWidth, tHeight,
- tWidth, 0
- };
-
- glBindTexture(GL_TEXTURE_2D, fbo->texture());
- shader->setAttributeArray(BlurTextureShader::Vertices, vert, 2);
- shader->setAttributeArray(BlurTextureShader::TextureCoords, texVert, 2);
-
- glDrawArrays(GL_TRIANGLES, 0, 6);
-
- xfbo->release();
- }
-
- // Render up - y
- {
- shader->setMode(BlurTextureShader::Vertical);
- shader->setStep(1. / float(yfbo->height()));
-
- GLSaveViewport vp;
- yfbo->bind();
- glClearColor(0,0,0,0);
- glViewport(0, 0, yfbo->width(), yfbo->height());
- glClear(GL_COLOR_BUFFER_BIT);
-
- float oWidth = -1. + 2. * r.width() * scale / yfbo->width();
- float oHeight = -1. + 2. * r.height() * scale / yfbo->height();
- float vert[] = {
- -1, -1,
- oWidth, -1,
- -1, oHeight,
-
- -1, oHeight,
- oWidth, oHeight,
- oWidth, -1
- };
-
- float tWidth = r.width() * scale / xfbo->width();
- float tHeight = r.height() * scalePercent / xfbo->height();
- float texVert[] = {
- 0, 0,
- tWidth, 0,
- 0, tHeight,
-
- 0, tHeight,
- tWidth, tHeight,
- tWidth, 0
- };
-
- glBindTexture(GL_TEXTURE_2D, xfbo->texture());
- shader->setAttributeArray(BlurTextureShader::Vertices, vert, 2);
- shader->setAttributeArray(BlurTextureShader::TextureCoords, texVert, 2);
-
- glDrawArrays(GL_TRIANGLES, 0, 6);
-
- yfbo->release();
- }
-
- shader->disableAttributeArray(BlurTextureShader::Vertices);
- shader->disableAttributeArray(BlurTextureShader::TextureCoords);
-
- float width = r.width();
- float height = r.height();
- //paint to screen
- {
- float texWidth = r.width() * scale / float(yfbo->width());
- float texHeight = r.height() * scale / float(yfbo->height());
-
- GLfloat vertices[] = { 0, height,
- width, height,
- 0, 0,
- width, 0 };
- GLfloat texVertices[] = { 0, 0,
- texWidth, 0,
- 0, texHeight,
- texWidth, texHeight };
-
- glBindTexture(GL_TEXTURE_2D, yfbo->texture());
-
- SingleTextureOpacityShader *shader =
- item->basicShaders()->singleTextureOpacity();
- shader->enable();
- shader->setTransform(p.activeTransform);
- shader->setOpacity(p.activeOpacity);
- shader->setAttributeArray(SingleTextureVertexOpacityShader::Vertices, vertices, 2);
- shader->setAttributeArray(SingleTextureVertexOpacityShader::TextureCoords, texVertices, 2);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- shader->disableAttributeArray(SingleTextureVertexOpacityShader::Vertices);
- shader->disableAttributeArray(SingleTextureVertexOpacityShader::TextureCoords);
- }
-
-
- releaseFBO(fbo);
- releaseFBO(xfbo);
- releaseFBO(yfbo);
-#endif
-#endif
-#else
- Q_UNUSED(p);
-#endif
-
-}
-
-QML_DEFINE_TYPE(QFxBlurFilter,Blur)
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxblurfilter.h b/src/declarative/fx/qfxblurfilter.h
deleted file mode 100644
index 830663f..0000000
--- a/src/declarative/fx/qfxblurfilter.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFXBLURFILTER_H
-#define QFXBLURFILTER_H
-
-#include <QtDeclarative/qsimplecanvasfilter.h>
-#include <QtDeclarative/qml.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QFxBlurFilterPrivate;
-class Q_DECLARATIVE_EXPORT QFxBlurFilter : public QSimpleCanvasFilter
-{
- Q_OBJECT
- Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged)
-public:
- QFxBlurFilter(QObject *parent=0);
- virtual ~QFxBlurFilter();
-
- qreal radius() const;
- void setRadius(qreal);
-
-Q_SIGNALS:
- void radiusChanged(qreal);
-
-protected:
- virtual QRectF itemBoundingRect(const QRectF &) const;
- virtual void filterGL(QSimpleCanvasItem::GLPainter &p);
-
-private:
- QFxBlurFilterPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QFxBlurFilter)
-
-QT_END_HEADER
-
-#endif // QFXBLURFILTER_H
diff --git a/src/declarative/fx/qfxcomponentinstance.h b/src/declarative/fx/qfxcomponentinstance.h
index f3bf6b3..940fb6d 100644
--- a/src/declarative/fx/qfxcomponentinstance.h
+++ b/src/declarative/fx/qfxcomponentinstance.h
@@ -78,7 +78,7 @@ protected:
QFxComponentInstance(QFxComponentInstancePrivate &dd, QFxItem *parent);
private:
- Q_DECLARE_PRIVATE(QFxComponentInstance)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxComponentInstance)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp
index a82385a..24f6d72 100644
--- a/src/declarative/fx/qfxflickable.cpp
+++ b/src/declarative/fx/qfxflickable.cpp
@@ -111,7 +111,7 @@ void QFxFlickablePrivate::init()
QObject::connect(&_tl, SIGNAL(updated()), q, SLOT(ticked()));
QObject::connect(&_tl, SIGNAL(completed()), q, SLOT(movementEnding()));
q->setAcceptedMouseButtons(Qt::LeftButton);
- q->setOptions(QSimpleCanvasItem::ChildMouseFilter | QSimpleCanvasItem::MouseEvents);
+ q->setOptions(QFxItem::ChildMouseFilter | QFxItem::MouseEvents);
QObject::connect(_flick, SIGNAL(xChanged()), q, SIGNAL(positionChanged()));
QObject::connect(_flick, SIGNAL(yChanged()), q, SIGNAL(positionChanged()));
QObject::connect(&elasticX, SIGNAL(updated()), q, SLOT(ticked()));
@@ -740,6 +740,7 @@ void QFxFlickable::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Q_D(QFxFlickable);
d->handleMouseReleaseEvent(event);
event->accept();
+ ungrabMouse();
}
qreal QFxFlickable::minYExtent() const
@@ -1047,7 +1048,7 @@ bool QFxFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
break;
}
grabber = static_cast<QFxItem*>(mouseGrabberItem());
- if (grabber && d->stealMouse && !grabber->keepMouseGrab())
+ if (grabber && d->stealMouse && !grabber->keepMouseGrab() && grabber != this)
grabMouse();
return d->stealMouse;
diff --git a/src/declarative/fx/qfxflickable.h b/src/declarative/fx/qfxflickable.h
index da38df8..a6c2a6c 100644
--- a/src/declarative/fx/qfxflickable.h
+++ b/src/declarative/fx/qfxflickable.h
@@ -184,7 +184,7 @@ protected:
private:
Q_DISABLE_COPY(QFxFlickable)
- Q_DECLARE_PRIVATE(QFxFlickable)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxFlickable)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp
index 7672858..6089d0a 100644
--- a/src/declarative/fx/qfxflipable.cpp
+++ b/src/declarative/fx/qfxflipable.cpp
@@ -221,22 +221,13 @@ void QFxFlipablePrivate::setBackTransform()
p3 = axisRotation.transform().map(p3);
axisRotation.setAngle(rotation);
- QSimpleCanvas::Matrix mat;
-#ifdef QFX_RENDER_OPENGL
- mat.translate(back->width()/2,back->height()/2, 0);
- if (back->width() && p1.x() >= p2.x())
- mat.rotate(180, 0, 1, 0);
- if (back->height() && p2.y() >= p3.y())
- mat.rotate(180, 1, 0, 0);
- mat.translate(-back->width()/2,-back->height()/2, 0);
-#else
+ QTransform mat;
mat.translate(back->width()/2,back->height()/2);
if (back->width() && p1.x() >= p2.x())
mat.rotate(180, Qt::YAxis);
if (back->height() && p2.y() >= p3.y())
mat.rotate(180, Qt::XAxis);
mat.translate(-back->width()/2,-back->height()/2);
-#endif
back->setTransform(mat);
}
@@ -295,7 +286,7 @@ QFxFlipable::Side QFxFlipable::side() const
//in some cases the user may want to specify a more complex transformation.
//in that case, we still allow the generic use of transform.
//(the logic here should be kept in sync with setBackTransform and setRotation)
-void QFxFlipable::transformChanged(const QSimpleCanvas::Matrix &trans)
+void QFxFlipable::transformChanged(const QTransform &trans)
{
Q_D(QFxFlipable);
QPointF p1(0, 0);
@@ -319,22 +310,13 @@ void QFxFlipable::transformChanged(const QSimpleCanvas::Matrix &trans)
if (newSide != d->current) {
d->current = newSide;
if (d->current==Back) {
- QSimpleCanvas::Matrix mat;
-#ifdef QFX_RENDER_OPENGL
- mat.translate(d->back->width()/2,d->back->height()/2, 0);
- if (d->back->width() && p1.x() >= p2.x())
- mat.rotate(180, 0, 1, 0);
- if (d->back->height() && p2.y() >= p3.y())
- mat.rotate(180, 1, 0, 0);
- mat.translate(-d->back->width()/2,-d->back->height()/2, 0);
-#else
+ QTransform mat;
mat.translate(d->back->width()/2,d->back->height()/2);
if (d->back->width() && p1.x() >= p2.x())
mat.rotate(180, Qt::YAxis);
if (d->back->height() && p2.y() >= p3.y())
mat.rotate(180, Qt::XAxis);
mat.translate(-d->back->width()/2,-d->back->height()/2);
-#endif
d->back->setTransform(mat);
}
if (d->front)
diff --git a/src/declarative/fx/qfxflipable.h b/src/declarative/fx/qfxflipable.h
index 06f8b93..5aa038d 100644
--- a/src/declarative/fx/qfxflipable.h
+++ b/src/declarative/fx/qfxflipable.h
@@ -44,9 +44,6 @@
#include <QtCore/QObject>
#include <QtGui/QTransform>
-#if defined(QFX_RENDER_OPENGL)
-#include <QtGui/qmatrix4x4.h>
-#endif
#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
@@ -87,7 +84,7 @@ public:
Side side() const;
protected:
- virtual void transformChanged(const QSimpleCanvas::Matrix &);
+ virtual void transformChanged(const QTransform &);
Q_SIGNALS:
void sideChanged();
@@ -95,7 +92,7 @@ Q_SIGNALS:
private:
Q_PRIVATE_SLOT(d_func(), void _q_updateAxis())
Q_DISABLE_COPY(QFxFlipable)
- Q_DECLARE_PRIVATE(QFxFlipable)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxFlipable)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxfocuspanel.h b/src/declarative/fx/qfxfocuspanel.h
deleted file mode 100644
index 623c9fb..0000000
--- a/src/declarative/fx/qfxfocuspanel.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFXFOCUSPANEL_H
-#define QFXFOCUSPANEL_H
-
-#include <QtDeclarative/qfxitem.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class Q_DECLARATIVE_EXPORT QFxFocusPanel : public QFxItem
-{
- Q_OBJECT
- Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
-public:
- QFxFocusPanel(QFxItem *parent=0);
- virtual ~QFxFocusPanel();
-
- bool isActive() const;
- void setActive(bool);
-
-Q_SIGNALS:
- void activeChanged();
-
-protected:
- virtual void activePanelInEvent();
- virtual void activePanelOutEvent();
-
-private:
- Q_DISABLE_COPY(QFxFocusPanel)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QFxFocusPanel)
-
-QT_END_HEADER
-
-#endif // QFXFOCUSPANEL_H
diff --git a/src/declarative/fx/qfxfocuspanel.cpp b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp
index 6da8564..479a21d 100644
--- a/src/declarative/fx/qfxfocuspanel.cpp
+++ b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp
@@ -39,66 +39,60 @@
**
****************************************************************************/
-#include "qfxfocuspanel.h"
-
+#include "qfxgraphicsobjectcontainer.h"
+#include <QGraphicsObject>
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(QFxFocusPanel,FocusPanel)
/*!
- \qmlclass FocusPanel
- \brief The FocusPanel object explicitly creates a focus panel.
- \inherits Item
-
- Focus panels assist in keyboard focus handling when building QML
- applications. All the details are covered in the
- \l {qmlfocus}{keyboard focus documentation}.
+ \qmlclass GraphicsObjectContainer QFxGraphicsObjectContainer
+ \brief The GraphicsObjectContainer element allows you to add QGraphicsObjects into Fluid UI elements.
*/
/*!
\internal
- \class QFxFocusPanel
+ \class QFxGraphicsObjectContainer
+ \brief The QFxGraphicsObjectContainer class allows you to add QGraphicsObjects into Fluid UI applications.
*/
-QFxFocusPanel::QFxFocusPanel(QFxItem *parent) :
- QFxItem(parent)
-{
- setOptions(IsFocusPanel);
-}
+QML_DEFINE_TYPE(QFxGraphicsObjectContainer, GraphicsObjectContainer)
-QFxFocusPanel::~QFxFocusPanel()
+QFxGraphicsObjectContainer::QFxGraphicsObjectContainer(QFxItem *parent)
+: QFxItem(parent), _graphicsObject(0)
{
}
-/*!
- \qmlproperty bool FocusPanel::active
-
- Sets whether the object is the active focus panel.
-*/
-
-bool QFxFocusPanel::isActive() const
+QFxGraphicsObjectContainer::~QFxGraphicsObjectContainer()
{
- QSimpleCanvas *canvas = QSimpleCanvasItem::canvas();
- if (canvas)
- return canvas->activeFocusPanel() == this;
- else
- return false;
}
-void QFxFocusPanel::setActive(bool a)
+QGraphicsObject *QFxGraphicsObjectContainer::graphicsObject() const
{
- setActiveFocusPanel(a);
+ return _graphicsObject;
}
-void QFxFocusPanel::activePanelInEvent()
+/*!
+ \qmlproperty QGraphicsObject GraphicsObjectContainer::graphicsObject
+ The QGraphicsObject associated with this element.
+*/
+void QFxGraphicsObjectContainer::setGraphicsObject(QGraphicsObject *object)
{
- QFxItem::activePanelInEvent();
- emit activeChanged();
+ if (object == _graphicsObject)
+ return;
+
+ _graphicsObject = object;
+
+ _graphicsObject->setParentItem(this);
}
-void QFxFocusPanel::activePanelOutEvent()
+QVariant QFxGraphicsObjectContainer::itemChange(GraphicsItemChange change, const QVariant &value)
{
- QFxItem::activePanelOutEvent();
- emit activeChanged();
+ if (change == ItemSceneHasChanged) {
+ QGraphicsObject *o = _graphicsObject;
+ _graphicsObject = 0;
+ setGraphicsObject(o);
+ }
+ return QFxItem::itemChange(change, value);
}
+
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxwidgetcontainer.h b/src/declarative/fx/qfxgraphicsobjectcontainer.h
index 862a280..e118555 100644
--- a/src/declarative/fx/qfxwidgetcontainer.h
+++ b/src/declarative/fx/qfxgraphicsobjectcontainer.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef QFXWIDGETCONTAINER_H
-#define QFXWIDGETCONTAINER_H
+#ifndef QFXGRAPHICSOBJECTCONTAINER_H
+#define QFXGRAPHICSOBJECTCONTAINER_H
#include <QtDeclarative/qfxitem.h>
@@ -50,33 +50,33 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QGraphicsWidget;
+class QGraphicsObject;
-class Q_DECLARATIVE_EXPORT QFxWidgetContainer : public QFxItem
+class Q_DECLARATIVE_EXPORT QFxGraphicsObjectContainer : public QFxItem
{
Q_OBJECT
- Q_CLASSINFO("DefaultProperty", "graphicsWidget")
- Q_PROPERTY(QGraphicsWidget *graphicsWidget READ graphicsWidget WRITE setGraphicsWidget)
+ Q_CLASSINFO("DefaultProperty", "graphicsObject")
+ Q_PROPERTY(QGraphicsObject *graphicsObject READ graphicsObject WRITE setGraphicsObject)
public:
- QFxWidgetContainer(QFxItem *parent = 0);
- ~QFxWidgetContainer();
+ QFxGraphicsObjectContainer(QFxItem *parent = 0);
+ ~QFxGraphicsObjectContainer();
- QGraphicsWidget *graphicsWidget() const;
- void setGraphicsWidget(QGraphicsWidget *);
+ QGraphicsObject *graphicsObject() const;
+ void setGraphicsObject(QGraphicsObject *);
protected:
- virtual void canvasChanged();
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value);
private:
- QGraphicsWidget *_graphicsWidget;
+ QGraphicsObject *_graphicsObject;
};
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QFxWidgetContainer)
+QML_DECLARE_TYPE(QFxGraphicsObjectContainer)
QT_END_HEADER
-#endif // QFXGRAPHICSWIDGET_H
+#endif // QFXGRAPHICSOBJECTCONTAINER_H
diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp
index a43e84c..3c80e98 100644
--- a/src/declarative/fx/qfxgridview.cpp
+++ b/src/declarative/fx/qfxgridview.cpp
@@ -45,6 +45,8 @@
#include "private/qfxflickable_p.h"
#include "qfxgridview.h"
+#include <QKeyEvent>
+
QT_BEGIN_NAMESPACE
class QFxGridViewAttached : public QObject
@@ -811,7 +813,7 @@ QFxItem *QFxGridView::currentItem()
Q_D(QFxGridView);
if (!d->currentItem) {
// Always return something valid
- if (!d->tmpCurrent)
+ if (!d->tmpCurrent)
d->tmpCurrent = new QFxItem(viewport());
return d->tmpCurrent;
}
diff --git a/src/declarative/fx/qfxgridview.h b/src/declarative/fx/qfxgridview.h
index b6d585e..8f443e1 100644
--- a/src/declarative/fx/qfxgridview.h
+++ b/src/declarative/fx/qfxgridview.h
@@ -54,7 +54,7 @@ class QFxGridViewPrivate;
class Q_DECLARATIVE_EXPORT QFxGridView : public QFxFlickable
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QFxGridView)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxGridView)
Q_PROPERTY(QVariant model READ model WRITE setModel)
Q_CLASSINFO("DefaultProperty", "delegate")
diff --git a/src/declarative/fx/qfxhighlightfilter.cpp b/src/declarative/fx/qfxhighlightfilter.cpp
deleted file mode 100644
index 78a91af..0000000
--- a/src/declarative/fx/qfxhighlightfilter.cpp
+++ /dev/null
@@ -1,320 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfxhighlightfilter.h"
-#include <qfxpixmap.h>
-#include <qmlcontext.h>
-
-#if defined(QFX_RENDER_OPENGL2)
-#include <gltexture.h>
-#include <glbasicshaders.h>
-#include <QtOpenGL/qglframebufferobject.h>
-#include <glsave.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QFxHighlightFilterPrivate
-{
-public:
- QFxHighlightFilterPrivate()
- : xOffset(0), yOffset(0), tiled(false) {}
-
- QUrl url;
- int xOffset;
- int yOffset;
- bool tiled;
-#if defined(QFX_RENDER_OPENGL2)
- GLTexture tex;
-#endif
-};
-
-/*!
- \qmlclass Highlight
- \brief The Highlight filter adds a highlight to an item.
- \inherits Filter
-
- \qml
-Text {
- id: highlighttext
- color: "red"
- font.size: 32
- text: "Highlight"
- filter: Highlight {
- source: "pics/highlight.png"
- xOffset: NumberAnimation {
- running: true
- repeat: true
- from: 320
- to: -320
- duration: 2000
- }
- }
-}
- \endqml
- \image highlight.gif
-
- Highlighting is only supported when Qt Declarative is compiled for OpenGL ES 2.0.
- Otherwise the Highlight filter has no effect.
-*/
-
-/*!
- \internal
- \class QFxHighlightFilter
- \ingroup group_effects
- \brief The QFxHightlightFilter class allows you to add a highlight to an item.
-*/
-
-QFxHighlightFilter::QFxHighlightFilter(QObject *parent)
-: QSimpleCanvasFilter(parent), d(new QFxHighlightFilterPrivate)
-{
-#if defined(QFX_RENDER_OPENGL2)
- d->tex.setHorizontalWrap(GLTexture::ClampToEdge);
- d->tex.setVerticalWrap(GLTexture::ClampToEdge);
-#endif
-}
-
-QFxHighlightFilter::~QFxHighlightFilter()
-{
- if (!d->url.isEmpty())
- QFxPixmap::cancelGet(d->url, this);
- delete d;
- d = 0;
-}
-
-/*!
- \qmlproperty string Highlight::source
- This property holds the URL of the image to be used as the highlight.
-*/
-
-/*!
- \property QFxHighlightFilter::source
- \brief the URL of the image to be used as the highlight.
-*/
-QUrl QFxHighlightFilter::source() const
-{
- return d->url;
-}
-
-void QFxHighlightFilter::imageLoaded()
-{
- QPixmap img = QFxPixmap(d->url);
-#if defined(QFX_RENDER_OPENGL2)
- if (!img.isNull())
- d->tex.setImage(img.toImage());
-#endif
- emit sourceChanged(d->url);
- update();
-}
-
-void QFxHighlightFilter::setSource(const QUrl &f)
-{
- if (d->url == f)
- return;
- if (!d->url.isEmpty())
- QFxPixmap::cancelGet(d->url, this);
- Q_ASSERT(!f.isRelative());
- d->url = f;
-#if defined(QFX_RENDER_OPENGL2)
- d->tex.clear();
-#endif
- if (!f.isEmpty())
- QFxPixmap::get(qmlEngine(this), d->url, this, SLOT(imageLoaded()));
- else
- emit sourceChanged(d->url);
-}
-
-/*!
- \qmlproperty bool Highlight::tiled
- This property holds whether or not the highlight should be tiled.
-*/
-
-/*!
- \property QFxHighlightFilter::tiled
- \brief whether or not the highlight should be tiled.
-*/
-bool QFxHighlightFilter::tiled() const
-{
- return d->tiled;
-}
-
-void QFxHighlightFilter::setTiled(bool t)
-{
- if (t == d->tiled)
- return;
-
- d->tiled = t;
-
-#if defined(QFX_RENDER_OPENGL2)
- if (d->tiled) {
- d->tex.setHorizontalWrap(GLTexture::ClampToEdge);
- d->tex.setVerticalWrap(GLTexture::ClampToEdge);
- } else {
- d->tex.setHorizontalWrap(GLTexture::Repeat);
- d->tex.setVerticalWrap(GLTexture::Repeat);
- }
-#endif
-
- emit tiledChanged(d->tiled);
-}
-
-/*!
- \qmlproperty int Highlight::xOffset
- \qmlproperty int Highlight::yOffset
- These properties hold the position of the highlight, relative to the item.
-*/
-
-/*!
- \property QFxHighlightFilter::xOffset
- \brief the x position of the highlight, relative to the item.
-*/
-int QFxHighlightFilter::xOffset() const
-{
- return d->xOffset;
-}
-
-void QFxHighlightFilter::setXOffset(int x)
-{
- if (x == d->xOffset)
- return;
-
- d->xOffset = x;
- emit offsetChanged(d->xOffset, d->yOffset);
-#if defined(QFX_RENDER_OPENGL2)
- update();
-#endif
-}
-
-/*!
- \property QFxHighlightFilter::yOffset
- \brief the y position of the highlight, relative to the item.
-*/
-int QFxHighlightFilter::yOffset() const
-{
- return d->yOffset;
-}
-
-void QFxHighlightFilter::setYOffset(int y)
-{
- if (y == d->yOffset)
- return;
-
- d->yOffset = y;
- emit offsetChanged(d->xOffset, d->yOffset);
-#if defined(QFX_RENDER_OPENGL2)
- update();
-#endif
-}
-
-void QFxHighlightFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
-{
-#if defined(QFX_RENDER_OPENGL2)
- if (d->tex.isNull()) {
- renderToScreen();
- } else {
- QSimpleCanvasItem *item = this->item();
-
- QRect r = item->itemBoundingRect();
-
- QGLFramebufferObject *fbo = renderToFBO();
-
- float width = r.width();
- float height = r.height();
-
- float texWidth = width / float(fbo->width());
- float texHeight = height / float(fbo->height());
-
- GLfloat vert[] = { 0, height,
- width, height,
- 0, 0,
- width, 0 };
- GLfloat texVert[] = { 0, 0,
- texWidth, 0,
- 0, texHeight,
- texWidth, texHeight };
- float texXOffset = 0;
- float texYOffset = 0;
-
- if (xOffset())
- texXOffset = float(xOffset()) / float(d->tex.width());
- if (yOffset())
- texYOffset = float(yOffset()) / float(d->tex.height());
-
- GLfloat addTexVert[] = { texXOffset, texYOffset,
- 1 + texXOffset, texYOffset,
- texXOffset, 1 + texYOffset,
- 1 + texXOffset, 1 + texYOffset };
-
- glBlendFuncSeparate(GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, fbo->texture());
- glActiveTexture(GL_TEXTURE1);
- glBindTexture(GL_TEXTURE_2D, d->tex.texture());
-
- DualTextureAddShader *shader = item->basicShaders()->dualTextureAdd();
- shader->enable();
- shader->setTransform(p.activeTransform);
- shader->setOpacity(p.activeOpacity);
-
- shader->setAttributeArray(DualTextureAddShader::Vertices, vert, 2);
- shader->setAttributeArray(DualTextureAddShader::TextureCoords, texVert, 2);
- shader->setAttributeArray(DualTextureAddShader::AddTextureCoords, addTexVert, 2);
-
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- shader->disableAttributeArray(DualTextureAddShader::Vertices);
- shader->disableAttributeArray(DualTextureAddShader::TextureCoords);
- shader->disableAttributeArray(DualTextureAddShader::AddTextureCoords);
-
- glActiveTexture(GL_TEXTURE0);
- glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-
- releaseFBO(fbo);
- }
-#else
- Q_UNUSED(p);
-#endif
-}
-
-QML_DEFINE_TYPE(QFxHighlightFilter,Highlight)
-
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index 539ad02..027b22a 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -42,14 +42,14 @@
#include "qfximage.h"
#include "qfximage_p.h"
#include <private/qfxperf_p.h>
-#if defined(QFX_RENDER_OPENGL)
-#include <glsave.h>
-#endif
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QFile>
#include <QtDeclarative/qmlengine.h>
+#include <QKeyEvent>
+#include <QPainter>
+
QT_BEGIN_NAMESPACE
@@ -131,12 +131,6 @@ QFxImage::~QFxImage()
QFxPixmap::cancelGet(d->url, this);
if (!d->sciurl.isEmpty())
QFxPixmap::cancelGet(d->sciurl, this);
-#if defined(QFX_RENDER_OPENGL)
- if (d->tex) {
- d->tex->release();
- d->tex = 0;
- }
-#endif
}
/*!
@@ -164,13 +158,6 @@ void QFxImage::setPixmap(const QPixmap &pix)
setImplicitWidth(d->pix.width());
setImplicitHeight(d->pix.height());
-#if defined(QFX_RENDER_OPENGL)
- d->texDirty = true;
- if (d->tex) {
- d->tex->release();
- d->tex = 0;
- }
-#endif
update();
}
@@ -235,44 +222,6 @@ void QFxImage::setTiled(bool tile)
d->tiled = tile;
}
-/*!
- \qmlproperty bool Image::opaque
-
- Set this property if you know that the image is opaque to give your
- application a significant performance boost.
-
- \note
- This is a performance hint to Qt Declarative. Unfortunately whether or not an image
- is opaque is not automatically detected. Setting this property to true when
- the image is not opaque will lead to drawing artifacts. However, leaving it as
- false will always work correctly - although possibly not at maximum performance.
- */
-
-/*!
- \property QFxImage::opaque
- \brief whether the image is opaque (non-transparent).
-
- This property is provided purely for the purpose of optimization. An opaque
- image can be optimized more than a non-opaque one.
-*/
-bool QFxImage::isOpaque() const
-{
- Q_D(const QFxImage);
- return d->opaque;
-}
-
-void QFxImage::setOpaque(bool o)
-{
- Q_D(QFxImage);
- if (o == d->opaque)
- return;
- d->opaque = o;
-
- setOptions(IsOpaque, o);
-
- update();
-}
-
void QFxImage::componentComplete()
{
QFxItem::componentComplete();
@@ -287,12 +236,12 @@ void QFxImage::componentComplete()
\qmlproperty bool Image::smooth
Set this property if you want the image to be smoothly filtered when scaled or
- transformed. Smooth filtering gives better visual quality, but is slower. If
- the Image is displayed at its natural size, this property has no visual or
+ transformed. Smooth filtering gives better visual quality, but is slower. If
+ the Image is displayed at its natural size, this property has no visual or
performance effect.
- \note Generally scaling artifacts are only visible if the image is stationary on
- the screen. A common pattern when animating an image is to disable smooth
+ \note Generally scaling artifacts are only visible if the image is stationary on
+ the screen. A common pattern when animating an image is to disable smooth
filtering at the beginning of the animation and reenable it at the conclusion.
*/
@@ -301,7 +250,7 @@ void QFxImage::componentComplete()
\brief whether the image is smoothly transformed.
This property is provided purely for the purpose of optimization. Turning
- smooth transforms off is faster, but looks worse; turning smooth
+ smooth transforms off is faster, but looks worse; turning smooth
transformations on is slower, but looks better.
By default smooth transformations are off.
@@ -321,15 +270,6 @@ void QFxImage::setSmoothTransform(bool s)
update();
}
-void QFxImage::dump(int depth)
-{
- Q_D(QFxImage);
- QByteArray ba(depth * 4, ' ');
- qWarning() << ba.constData() << "URL:" << d->url;
- QFxItem::dump(depth);
-}
-
-#if defined(QFX_RENDER_QPAINTER)
void QFxImage::paintContents(QPainter &p)
{
Q_D(QFxImage);
@@ -364,9 +304,22 @@ void QFxImage::paintContents(QPainter &p)
p.restore();
} else if (!d->scaleGrid || d->scaleGrid->isNull()) {
if (width() != pix.width() || height() != pix.height()) {
+ qreal widthScale = width() / qreal(pix.width());
+ qreal heightScale = height() / qreal(pix.height());
+
QTransform scale;
- scale.scale(width() / qreal(pix.width()),
- height() / qreal(pix.height()));
+
+ if (d->preserveAspect) {
+ if (widthScale < heightScale) {
+ heightScale = widthScale;
+ scale.translate(0, (height() - heightScale * pix.height()) / 2);
+ } else if(heightScale < widthScale) {
+ widthScale = heightScale;
+ scale.translate((width() - widthScale * pix.width()) / 2, 0);
+ }
+ }
+
+ scale.scale(widthScale, heightScale);
QTransform old = p.transform();
p.setWorldTransform(scale * old);
p.drawPixmap(0, 0, pix);
@@ -398,7 +351,7 @@ void QFxImage::paintContents(QPainter &p)
p.drawPixmap(QRect(sgl, 0, w - xSide, sgt), pix,
QRect(sgl, 0, pix.width() - xSide, sgt));
// Upper right
- if (sgt && pix.width() - sgr)
+ if (sgt && pix.width() - sgr)
p.drawPixmap(QPoint(w-sgr, 0), pix,
QRect(pix.width()-sgr, 0, sgr, sgt));
// Middle left
@@ -409,13 +362,13 @@ void QFxImage::paintContents(QPainter &p)
// Middle
if (pix.width() - xSide && pix.height() - ySide)
p.drawPixmap(QRect(sgl, sgt, w - xSide, h - ySide),
- pix,
+ pix,
QRect(sgl, sgt, pix.width() - xSide, pix.height() - ySide));
// Middle right
if (sgr && pix.height() - ySide)
p.drawPixmap(QRect(w-sgr, sgt, sgr, h - ySide), pix,
QRect(pix.width()-sgr, sgt, sgr, pix.height() - ySide));
- // Lower left
+ // Lower left
if (sgl && sgr)
p.drawPixmap(QPoint(0, h - sgb), pix,
QRect(0, pix.height() - sgb, sgl, sgb));
@@ -434,333 +387,6 @@ void QFxImage::paintContents(QPainter &p)
p.setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
}
}
-#elif defined(QFX_RENDER_OPENGL)
-uint QFxImage::glSimpleItemData(float *vertices, float *texVertices,
- GLTexture **texture, uint count)
-{
- Q_D(QFxImage);
-
- if (d->pix.isNull() || (d->scaleGrid && !d->scaleGrid->isNull()))
- return 0;
-
- if (count < 8)
- return 8;
-
- d->checkDirty();
-
- float widthV = width();
- float heightV = height();
-
- vertices[0] = 0; vertices[1] = heightV;
- vertices[2] = widthV; vertices[3] = heightV;
- vertices[4] = 0; vertices[5] = 0;
- vertices[6] = widthV; vertices[7] = 0;
-
- *texture = d->tex;
-
- if (d->tiled) {
- float tileWidth = widthV / d->pix.width();
- float tileHeight = heightV / d->pix.height();
- texVertices[0] = 0; texVertices[1] = 0;
- texVertices[2] = tileWidth; texVertices[3] = 0;
- texVertices[4] = 0; texVertices[5] = tileHeight;
- texVertices[6] = tileWidth; texVertices[7] = tileHeight;
- } else {
- texVertices[0] = 0; texVertices[1] = 0;
- texVertices[2] = d->tex->glWidth(); texVertices[3] = 0;
- texVertices[4] = 0; texVertices[5] = d->tex->glHeight();
- texVertices[6] = d->tex->glWidth(); texVertices[7] = d->tex->glHeight();
- }
-
- return 8;
-}
-
-void QFxImagePrivate::checkDirty()
-{
- Q_Q(QFxImage);
- if (texDirty && !pix.isNull())
- tex = q->cachedTexture(url.toString(), pix);
- texDirty = false;
-}
-
-#if defined(QFX_RENDER_OPENGL2)
-void QFxImage::paintGLContents(GLPainter &p)
-{
- Q_D(QFxImage);
- if (d->pix.isNull())
- return;
-
- QGLShaderProgram *shader = p.useTextureShader();
-
- bool restoreBlend = false;
- if (p.blendEnabled && isOpaque() && p.activeOpacity == 1) {
- glDisable(GL_BLEND);
- restoreBlend = true;
- }
-
- d->checkDirty();
-
- if (d->tiled || (!d->scaleGrid || d->scaleGrid->isNull())) {
-
- if (!d->tiled) {
-
- float widthV = width();
- float heightV = height();
- float glWidth = d->tex->glWidth();
- float glHeight = d->tex->glHeight();
-
- float deltaX = 0.5 / qreal(d->tex->glSize().width());
- float deltaY = 0.5 / qreal(d->tex->glSize().height());
- glWidth -= deltaX;
- glHeight -= deltaY;
-
-
- float vert[] = {
- 0, heightV,
- widthV, heightV,
- 0, 0,
-
- widthV, heightV,
- 0, 0,
- widthV, 0 };
-
- float tex[] = {
- deltaX, deltaY,
- glWidth, deltaY,
- deltaX, glHeight,
-
- glWidth, deltaY,
- deltaX, glHeight,
- glWidth, glHeight
- };
-
- shader->setAttributeArray(SingleTextureShader::Vertices, vert, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, tex, 2);
- glBindTexture(GL_TEXTURE_2D, d->tex->texture());
- glDrawArrays(GL_TRIANGLES, 0, 6);
-
- } else {
-
- GLfloat vertices[8];
- GLfloat texVertices[8];
- GLTexture *tex = 0;
-
- QFxImage::glSimpleItemData(vertices, texVertices, &tex, 8);
-
- shader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2);
-
- glBindTexture(GL_TEXTURE_2D, tex->texture());
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- }
-
- } else {
-
- float imgWidth = d->pix.width();
- float imgHeight = d->pix.height();
- if (!imgWidth || !imgHeight) {
- if (restoreBlend)
- glEnable(GL_BLEND);
- return;
- }
-
- float widthV = width();
- float heightV = height();
- float glWidth = d->tex->glWidth();
- float glHeight = d->tex->glHeight();
- float deltaX = 0.5 / qreal(d->tex->glSize().width());
- float deltaY = 0.5 / qreal(d->tex->glSize().height());
- glHeight -= deltaY;
- glWidth -= deltaX;
-
- float texleft = deltaX;
- float texright = glWidth;
- float textop = glHeight;
- float texbottom = deltaY;
- float imgleft = 0;
- float imgright = widthV;
- float imgtop = 0;
- float imgbottom = heightV;
-
- const int sgl = d->scaleGrid->left();
- const int sgr = d->scaleGrid->right();
- const int sgt = d->scaleGrid->top();
- const int sgb = d->scaleGrid->bottom();
-
- if (sgl) {
- texleft = deltaX + d->tex->glWidth() * float(sgl) / imgWidth;
- imgleft = sgl;
- }
- if (sgr) {
- texright = d->tex->glWidth() - float(sgr) / imgWidth - deltaX;
- imgright = widthV - sgr;
- }
- if (sgt) {
- textop = d->tex->glHeight() - float(sgb) / imgHeight - deltaY;
- imgtop = sgt;
- }
- if (sgb) {
- texbottom = deltaY + d->tex->glHeight() * float(sgt) / imgHeight;
- imgbottom = heightV - sgb;
- }
-
- float vert1[] = { 0, 0,
- 0, imgtop,
- imgleft, 0,
-
- 0, imgtop,
- imgleft, 0,
- imgleft, imgtop,
-
- imgleft, 0,
- imgleft, imgtop,
- imgright, 0,
-
- imgleft, imgtop,
- imgright, 0,
- imgright, imgtop,
-
- imgright, 0,
- imgright, imgtop,
- widthV, 0,
-
- imgright, imgtop,
- widthV, 0,
- widthV, imgtop,
-
- 0, imgtop,
- 0, imgbottom,
- imgleft, imgtop,
-
- 0, imgbottom,
- imgleft, imgtop,
- imgleft, imgbottom,
-
- imgleft, imgtop,
- imgleft, imgbottom,
- imgright, imgtop,
-
- imgleft, imgbottom,
- imgright, imgtop,
- imgright, imgbottom,
-
- imgright, imgtop,
- imgright, imgbottom,
- widthV, imgtop,
-
- imgright, imgbottom,
- widthV, imgtop,
- widthV, imgbottom,
-
- 0, imgbottom,
- 0, heightV,
- imgleft, imgbottom,
-
- 0, heightV,
- imgleft, imgbottom,
- imgleft, heightV,
-
- imgleft, imgbottom,
- imgleft, heightV,
- imgright, imgbottom,
-
- imgleft, heightV,
- imgright, imgbottom,
- imgright, heightV,
-
- imgright, imgbottom,
- imgright, heightV,
- widthV, imgbottom,
-
- imgright, heightV,
- widthV, imgbottom,
- widthV, heightV };
-
- float tex1[] = { deltaX, glHeight,
- deltaX, textop,
- texleft, glHeight,
-
- deltaX, textop,
- texleft, glHeight,
- texleft, textop,
-
- texleft, glHeight,
- texleft, textop,
- texright, glHeight,
-
- texleft, textop,
- texright, glHeight,
- texright, textop,
-
- texright, glHeight,
- texright, textop,
- glWidth, glHeight,
-
- texright, textop,
- glWidth, glHeight,
- glWidth, textop,
-
- deltaX, textop,
- deltaX, texbottom,
- texleft, textop,
-
- deltaX, texbottom,
- texleft, textop,
- texleft, texbottom,
-
- texleft, textop,
- texleft, texbottom,
- texright, textop,
-
- texleft, texbottom,
- texright, textop,
- texright, texbottom,
-
- texright, textop,
- texright, texbottom,
- glWidth, textop,
-
- texright, texbottom,
- glWidth, textop,
- glWidth, texbottom,
-
- deltaX, texbottom,
- deltaX, deltaY,
- texleft, texbottom,
-
- deltaX, deltaY,
- texleft, texbottom,
- texleft, deltaY,
-
- texleft, texbottom,
- texleft, deltaY,
- texright, texbottom,
-
- texleft, deltaY,
- texright, texbottom,
- texright, deltaY,
-
- texright, texbottom,
- texright, deltaY,
- glWidth, texbottom,
-
- texright, deltaY,
- glWidth, texbottom,
- glWidth, deltaY };
-
- glBindTexture(GL_TEXTURE_2D, d->tex->texture());
-
- shader->setAttributeArray(SingleTextureShader::Vertices, vert1, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, tex1, 2);
- glDrawArrays(GL_TRIANGLES, 0, 54);
- }
-
- if (restoreBlend)
- glEnable(GL_BLEND);
-}
-#endif
-
-#endif
QString QFxImage::propertyInfo() const
{
@@ -838,6 +464,22 @@ QUrl QFxImage::source() const
return d->url;
}
+bool QFxImage::preserveAspect() const
+{
+ Q_D(const QFxImage);
+ return d->preserveAspect;
+}
+
+void QFxImage::setPreserveAspect(bool p)
+{
+ Q_D(QFxImage);
+
+ if (p == d->preserveAspect)
+ return;
+ d->preserveAspect = p;
+ update();
+}
+
void QFxImage::setSource(const QUrl &url)
{
#ifdef Q_ENABLE_PERFORMANCE_LOG
@@ -870,13 +512,6 @@ void QFxImage::setSource(const QUrl &url)
d->progress = 1.0;
setImplicitWidth(0);
setImplicitHeight(0);
-#if defined(QFX_RENDER_OPENGL)
- d->texDirty = true;
- if (d->tex) {
- d->tex->release();
- d->tex = 0;
- }
-#endif
emit statusChanged(d->status);
emit sourceChanged(d->url);
emit progressChanged(1.0);
@@ -934,13 +569,6 @@ void QFxImage::requestFinished()
if (d->status == Loading)
d->status = Idle;
d->progress = 1.0;
-#if defined(QFX_RENDER_OPENGL)
- d->texDirty = true;
- if (d->tex) {
- d->tex->release();
- d->tex = 0;
- }
-#endif
emit statusChanged(d->status);
emit sourceChanged(d->url);
emit progressChanged(1.0);
diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h
index 3071a9e..7b3445c 100644
--- a/src/declarative/fx/qfximage.h
+++ b/src/declarative/fx/qfximage.h
@@ -64,8 +64,8 @@ class Q_DECLARATIVE_EXPORT QFxImage : public QFxItem
Q_PROPERTY(QFxScaleGrid *scaleGrid READ scaleGrid)
Q_PROPERTY(bool tile READ isTiled WRITE setTiled)
Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap DESIGNABLE false)
- Q_PROPERTY(bool opaque READ isOpaque WRITE setOpaque)
Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform)
+ Q_PROPERTY(bool preserveAspect READ preserveAspect WRITE setPreserveAspect);
public:
QFxImage(QFxItem *parent=0);
~QFxImage();
@@ -78,9 +78,6 @@ public:
QPixmap pixmap() const;
void setPixmap(const QPixmap &);
- bool isOpaque() const;
- void setOpaque(bool);
-
bool smoothTransform() const;
void setSmoothTransform(bool);
@@ -88,18 +85,14 @@ public:
Status status() const;
qreal progress() const;
+ bool preserveAspect() const;
+ void setPreserveAspect(bool);
+
QUrl source() const;
virtual void setSource(const QUrl &url);
- virtual void dump(int depth);
virtual QString propertyInfo() const;
-#if defined(QFX_RENDER_QPAINTER)
void paintContents(QPainter &painter);
-#elif defined(QFX_RENDER_OPENGL)
- void paintGLContents(GLPainter &);
- uint glSimpleItemData(float *vertices, float *texVertices,
- GLTexture **texture, uint count);
-#endif
Q_SIGNALS:
void sourceChanged(const QUrl &);
@@ -117,7 +110,7 @@ private Q_SLOTS:
private:
Q_DISABLE_COPY(QFxImage)
- Q_DECLARE_PRIVATE(QFxImage)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxImage)
void setGridScaledImage(const QFxGridScaledImage& sci);
};
diff --git a/src/declarative/fx/qfximage_p.h b/src/declarative/fx/qfximage_p.h
index 1785abb..7792dbf 100644
--- a/src/declarative/fx/qfximage_p.h
+++ b/src/declarative/fx/qfximage_p.h
@@ -55,9 +55,7 @@
#include "qfxitem_p.h"
-#if defined(QFX_RENDER_OPENGL)
-#include "gltexture.h"
-#endif
+#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE
@@ -73,14 +71,12 @@ class QFxImagePrivate : public QFxItemPrivate
public:
QFxImagePrivate()
: scaleGrid(0), tiled(false), smooth(false), opaque(false),
-#if defined(QFX_RENDER_OPENGL)
- texDirty(true), tex(0),
-#endif
- status(QFxImage::Idle), sciReply(0), progress(0.0)
+ preserveAspect(false), status(QFxImage::Idle), sciReply(0),
+ progress(0.0)
{
}
- ~QFxImagePrivate()
+ ~QFxImagePrivate()
{
delete scaleGrid;
}
@@ -89,21 +85,17 @@ public:
QFxScaleGrid *getScaleGrid()
{
- if (!scaleGrid)
+ if (!scaleGrid)
scaleGrid = new QFxScaleGrid;
return scaleGrid;
}
-
+
QFxScaleGrid *scaleGrid;
QPixmap pix;
bool tiled : 1;
bool smooth : 1;
bool opaque : 1;
-#if defined(QFX_RENDER_OPENGL)
- bool texDirty : 1;
- void checkDirty();
- QSimpleCanvasItem::CachedTexture *tex;
-#endif
+ bool preserveAspect : 1;
QFxImage::Status status;
QUrl url;
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index bd4def4..481733b 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -62,7 +62,6 @@
#include "qfxitem_p.h"
#include "qfxitem.h"
#include "qfxevents_p.h"
-#include <qsimplecanvasfilter.h>
#include <qmlcomponent.h>
QT_BEGIN_NAMESPACE
@@ -73,7 +72,6 @@ QT_BEGIN_NAMESPACE
QML_DEFINE_NOCREATE_TYPE(QFxContents)
QML_DEFINE_TYPE(QFxItem,Item)
-QML_DEFINE_NOCREATE_TYPE(QSimpleCanvasFilter)
/*!
\group group_animation
@@ -162,9 +160,9 @@ void QFxContents::calcHeight()
qreal top = FLT_MAX;
qreal bottom = 0;
- const QList<QSimpleCanvasItem *> &children = m_item->QSimpleCanvasItem::children();
+ QList<QGraphicsItem *> children = m_item->childItems();
for (int i = 0; i < children.count(); ++i) {
- const QSimpleCanvasItem *child = children.at(i);
+ QFxItem *child = qobject_cast<QFxItem *>(children.at(i));
qreal y = child->y();
if (y + child->height() > bottom)
bottom = y + child->height();
@@ -185,10 +183,10 @@ void QFxContents::calcWidth()
qreal left = FLT_MAX;
qreal right = 0;
- const QList<QSimpleCanvasItem *> &children = m_item->QSimpleCanvasItem::children();
+ QList<QGraphicsItem *> children = m_item->childItems();
for (int i = 0; i < children.count(); ++i) {
- const QSimpleCanvasItem *child = children.at(i);
- qreal x = int(child->x());
+ QFxItem *child = qobject_cast<QFxItem *>(children.at(i));
+ qreal x = child->x();
if (x + child->width() > right)
right = x + child->width();
if (x < left)
@@ -204,9 +202,9 @@ void QFxContents::setItem(QFxItem *item)
{
m_item = item;
- const QList<QSimpleCanvasItem *> &children = m_item->QSimpleCanvasItem::children();
+ QList<QGraphicsItem *> children = m_item->childItems();
for (int i = 0; i < children.count(); ++i) {
- const QSimpleCanvasItem *child = children.at(i);
+ QFxItem *child = qobject_cast<QFxItem *>(children.at(i));
connect(child, SIGNAL(heightChanged()), this, SLOT(calcHeight()));
connect(child, SIGNAL(yChanged()), this, SLOT(calcHeight()));
connect(child, SIGNAL(widthChanged()), this, SLOT(calcWidth()));
@@ -260,11 +258,6 @@ void QFxContents::setItem(QFxItem *item)
*/
/*!
- \property QFxItem::activeFocus
- This property indicates whether the item has the active focus.
- */
-
-/*!
\fn void QFxItem::activeFocusChanged()
This signal is emitted when this item gains active focus.
@@ -384,7 +377,7 @@ void QFxContents::setItem(QFxItem *item)
This signal is emitted when the item's focus state changes.
- \sa QSimpleCanvasItem::setFocus()
+ \sa QFxItem::setFocus()
*/
/*!
@@ -393,7 +386,7 @@ void QFxContents::setItem(QFxItem *item)
Constructs a QFxItem with the given \a parent.
*/
QFxItem::QFxItem(QFxItem* parent)
- : QSimpleCanvasItem(*(new QFxItemPrivate), parent)
+ : QGraphicsObject(*(new QFxItemPrivate), parent, 0)
{
Q_D(QFxItem);
d->init(parent);
@@ -402,7 +395,7 @@ QFxItem::QFxItem(QFxItem* parent)
/*! \internal
*/
QFxItem::QFxItem(QFxItemPrivate &dd, QFxItem *parent)
- : QSimpleCanvasItem(dd, parent)
+ : QGraphicsObject(dd, parent, 0)
{
Q_D(QFxItem);
d->init(parent);
@@ -535,7 +528,12 @@ void QFxItem::moveToParent(QFxItem *parent)
*/
QFxItem *QFxItem::itemParent() const
{
- return qobject_cast<QFxItem *>(QObject::parent());
+ return qobject_cast<QFxItem *>(QGraphicsItem::parentItem());
+}
+
+QFxItem *QFxItem::parentItem() const
+{
+ return itemParent();
}
/*!
@@ -699,7 +697,7 @@ int QFxItemPrivate::children_count() const
void QFxItemPrivate::children_append(QFxItem *i)
{
Q_Q(QFxItem);
- i->setParent(q);
+ i->setParentItem(q);
}
void QFxItemPrivate::children_insert(int, QFxItem *)
@@ -787,6 +785,16 @@ QFxContents *QFxItem::contents()
return d->_contents;
}
+bool QFxItem::clip() const
+{
+ return flags() & ItemClipsChildrenToShape;
+}
+
+void QFxItem::setClip(bool c)
+{
+ setFlag(ItemClipsChildrenToShape, c);
+}
+
/*!
\internal
\property QFxItem::qmlItem
@@ -1091,52 +1099,6 @@ void QFxItem::geometryChanged(const QRectF &newGeometry,
}
}
-/*!
- \qmlproperty bool Item::flipVertically
- \qmlproperty bool Item::flipHorizontally
-
- When set, the item will be displayed flipped horizontally or vertically
- about its center.
- */
-
-/*!
- \property QFxItem::flipVertically
-
- When set, the item will be displayed flipped horizontally or vertically
- about its center.
- */
-bool QFxItem::flipVertically() const
-{
- return flip() & VerticalFlip;
-}
-
-void QFxItem::setFlipVertically(bool v)
-{
- if (v)
- setFlip((QSimpleCanvasItem::Flip)(flip() | VerticalFlip));
- else
- setFlip((QSimpleCanvasItem::Flip)(flip() & ~VerticalFlip));
-}
-
-/*!
- \property QFxItem::flipHorizontally
-
- When set, the item will be displayed flipped horizontally or vertically
- about its center.
- */
-bool QFxItem::flipHorizontally() const
-{
- return flip() & HorizontalFlip;
-}
-
-void QFxItem::setFlipHorizontally(bool v)
-{
- if (v)
- setFlip((QSimpleCanvasItem::Flip)(flip() | HorizontalFlip));
- else
- setFlip((QSimpleCanvasItem::Flip)(flip() & ~HorizontalFlip));
-}
-
/*! \fn void QFxItem::keyPress(QFxKeyEvent *event)
This signal is emitted by keyPressEvent() for the \a event.
*/
@@ -1503,19 +1465,7 @@ void QFxItem::setRotation(qreal rotation)
if (d->_rotation == rotation)
return;
d->_rotation = rotation;
-#if defined(QFX_RENDER_OPENGL)
- QMatrix4x4 trans;
- QPointF to = transformOriginPoint();
- trans.translate(to.x(), to.y());
- trans.rotate(d->_rotation, 0, 0, 1);
- trans.translate(-to.x(), -to.y());
-#else
- QPointF to = d->transformOrigin();
- QTransform trans = QTransform::fromTranslate(to.x(), to.y());
- trans.rotate(d->_rotation);
- trans.translate(-to.x(), -to.y());
-#endif
- setTransform(trans);
+ setTransform(d->transform);
emit rotationChanged();
}
@@ -1569,18 +1519,6 @@ void QFxItem::setRotation(qreal rotation)
Scaling is from the item's transformOrigin.
*/
-qreal QFxItem::scale() const
-{
- return QSimpleCanvasItem::scale();
-}
-
-void QFxItem::setScale(qreal s)
-{
- if (QSimpleCanvasItem::scale() == s) return;
- QSimpleCanvasItem::setScale(s);
- emit scaleChanged();
- update();
-}
/*!
\qmlproperty real Item::opacity
@@ -1638,19 +1576,12 @@ void QFxItem::setScale(qreal s)
also applied individually to child items.
*/
-qreal QFxItem::opacity() const
-{
- return QSimpleCanvasItem::visible();
-}
-
void QFxItem::setOpacity(qreal v)
{
- if (v == QSimpleCanvasItem::visible())
+ if (v == opacity())
return;
- if (v < 0) v = 0;
- else if (v > 1) v = 1;
- QSimpleCanvasItem::setVisible(v);
+ QGraphicsItem::setOpacity(v);
emit opacityChanged();
}
@@ -1909,16 +1840,6 @@ QList<QFxTransform *> *QFxItem::transform()
}
/*!
- \property QFxItem::focus
- This property holds the item's focus state.
-*/
-
-/*!
- \property QFxItem::focusable
- This property holds whether the item has focus state.
-*/
-
-/*!
Returns true if the item is visible; otherwise returns false.
An item is considered visible if its opacity is not 0.
@@ -1958,14 +1879,6 @@ void QFxItem::setVisible(bool visible)
/*! \internal
*/
-void QFxItem::dump(int depth)
-{
- QByteArray ba(depth * 4, ' ');
- qWarning() << ba.constData() << metaObject()->className() << "(" << (void *)static_cast<QFxItem*>(this) << ", " << (void *)static_cast<QSimpleCanvasItem*>(this) << "):" << x() << y() << width() << height() << (void *) itemParent();
-}
-
-/*! \internal
-*/
QString QFxItem::propertyInfo() const
{
return QString();
@@ -2045,27 +1958,13 @@ void QFxItem::componentComplete()
updateTransform();
}
-/*! \internal
-*/
-void QFxItem::parentChanged(QSimpleCanvasItem *, QSimpleCanvasItem *)
-{
- emit parentChanged();
-}
-
-/*! \internal
-*/
-void QFxItem::reparentItems()
-{
- qFatal("EEK");
-}
-
/*!
\internal
*/
void QFxItem::updateTransform()
{
Q_D(QFxItem);
- QSimpleCanvas::Matrix trans;
+ QTransform trans;
for (int ii = d->_transform.count() - 1; ii >= 0; --ii) {
QFxTransform *a = d->_transform.at(ii);
if (!a->isIdentity())
@@ -2079,7 +1978,7 @@ void QFxItem::updateTransform()
/*!
\internal
*/
-void QFxItem::transformChanged(const QSimpleCanvas::Matrix &)
+void QFxItem::transformChanged(const QTransform &)
{
}
@@ -2115,4 +2014,551 @@ QFxItemPrivate::AnchorLines::AnchorLines(QFxItem *q)
baseline.anchorLine = QFxAnchorLine::Baseline;
}
+QPointF QFxItemPrivate::transformOrigin() const
+{
+ Q_Q(const QFxItem);
+
+ QRectF br = q->boundingRect();
+
+ switch(origin) {
+ default:
+ case QFxItem::TopLeft:
+ return QPointF(0, 0);
+ case QFxItem::TopCenter:
+ return QPointF(br.width() / 2., 0);
+ case QFxItem::TopRight:
+ return QPointF(br.width(), 0);
+ case QFxItem::MiddleLeft:
+ return QPointF(0, br.height() / 2.);
+ case QFxItem::Center:
+ return QPointF(br.width() / 2., br.height() / 2.);
+ case QFxItem::MiddleRight:
+ return QPointF(br.width(), br.height() / 2.);
+ case QFxItem::BottomLeft:
+ return QPointF(0, br.height());
+ case QFxItem::BottomCenter:
+ return QPointF(br.width() / 2., br.height());
+ case QFxItem::BottomRight:
+ return QPointF(br.width(), br.height());
+ }
+}
+
+QFxItem::Options QFxItem::options() const
+{
+ Q_D(const QFxItem);
+ return (QFxItem::Options)d->options;
+}
+
+bool QFxItem::mouseFilter(QGraphicsSceneMouseEvent *)
+{
+ return false;
+}
+
+bool QFxItem::sceneEvent(QEvent *event)
+{
+ bool rv = QGraphicsItem::sceneEvent(event);
+ if (event->type() == QEvent::UngrabMouse)
+ mouseUngrabEvent();
+ return rv;
+}
+
+QVariant QFxItem::itemChange(GraphicsItemChange change,
+ const QVariant &value)
+{
+ Q_D(QFxItem);
+ if (change == ItemSceneHasChanged) {
+ if (options() & QFxItem::MouseFilter)
+ d->gvRemoveMouseFilter();
+
+ d->canvas = qvariant_cast<QGraphicsScene *>(value);
+
+ if (options() & QFxItem::MouseFilter)
+ d->gvAddMouseFilter();
+
+ if (d->canvas && d->isFocusItemForArea)
+ d->canvas->setFocusItem(this);
+ } else if (change == ItemChildAddedChange ||
+ change == ItemChildRemovedChange) {
+ childrenChanged();
+ }
+
+ return QGraphicsItem::itemChange(change, value);
+}
+
+
+void QFxItem::mouseUngrabEvent()
+{
+}
+
+void QFxItem::childrenChanged()
+{
+}
+
+void QFxItem::setPaintMargin(qreal margin)
+{
+ Q_D(QFxItem);
+ if (margin < d->paintmargin)
+ update(); // schedule repaint of old boundingRect
+ d->paintmargin = margin;
+}
+
+QRectF QFxItem::boundingRect() const
+{
+ Q_D(const QFxItem);
+ return QRectF(-d->paintmargin, -d->paintmargin, d->width+d->paintmargin*2, d->height+d->paintmargin*2);
+}
+
+void QFxItem::paintContents(QPainter &)
+{
+}
+
+void QFxItem::parentChanged(QFxItem *, QFxItem *)
+{
+ emit parentChanged();
+}
+
+/*!
+ Returns the item's (0, 0) point relative to its parent.
+ */
+QPointF QFxItem::pos() const
+{
+ return QPointF(x(),y());
+}
+
+/*!
+ Returns the item's (0, 0) point mapped to scene coordinates.
+ */
+QPointF QFxItem::scenePos() const
+{
+ return mapToScene(QPointF(0, 0));
+}
+
+/*!
+ \enum QFxItem::TransformOrigin
+
+ Controls the point about which simple transforms like scale apply.
+
+ \value TopLeft The top-left corner of the item.
+ \value TopCenter The center point of the top of the item.
+ \value TopRight The top-right corner of the item.
+ \value MiddleLeft The left most point of the vertical middle.
+ \value Center The center of the item.
+ \value MiddleRight The right most point of the vertical middle.
+ \value BottomLeft The bottom-left corner of the item.
+ \value BottomCenter The center point of the bottom of the item.
+ \value BottomRight The bottom-right corner of the item.
+*/
+
+/*!
+ Returns the current transform origin.
+*/
+QFxItem::TransformOrigin QFxItem::transformOrigin() const
+{
+ Q_D(const QFxItem);
+ return d->origin;
+}
+
+/*!
+ Set the transform \a origin.
+*/
+void QFxItem::setTransformOrigin(TransformOrigin origin)
+{
+ Q_D(QFxItem);
+ if (origin != d->origin) {
+ d->origin = origin;
+ update();
+ }
+}
+
+QPointF QFxItem::transformOriginPoint() const
+{
+ Q_D(const QFxItem);
+ return d->transformOrigin();
+}
+
+qreal QFxItem::z() const
+{
+ return zValue();
+}
+
+void QFxItem::setX(qreal x)
+{
+ if (x == this->x())
+ return;
+
+ qreal oldX = this->x();
+
+ QGraphicsItem::setPos(x, y());
+
+ geometryChanged(QRectF(this->x(), y(), width(), height()),
+ QRectF(oldX, y(), width(), height()));
+}
+
+void QFxItem::setY(qreal y)
+{
+ if (y == this->y())
+ return;
+
+ qreal oldY = this->y();
+
+ QGraphicsItem::setPos(x(), y);
+
+ geometryChanged(QRectF(x(), this->y(), width(), height()),
+ QRectF(x(), oldY, width(), height()));
+}
+
+void QFxItem::setZ(qreal z)
+{
+ if (z == this->z())
+ return;
+
+ if (z < 0)
+ setFlag(QGraphicsItem::ItemStacksBehindParent, true);
+ else
+ setFlag(QGraphicsItem::ItemStacksBehindParent, false);
+
+ setZValue(z);
+}
+
+qreal QFxItem::width() const
+{
+ Q_D(const QFxItem);
+ return d->width;
+}
+
+void QFxItem::setWidth(qreal w)
+{
+ Q_D(QFxItem);
+ d->widthValid = true;
+ if (d->width == w)
+ return;
+
+ qreal oldWidth = d->width;
+
+ d->width = w;
+ update();
+
+ geometryChanged(QRectF(x(), y(), width(), height()),
+ QRectF(x(), y(), oldWidth, height()));
+}
+
+void QFxItem::setImplicitWidth(qreal w)
+{
+ Q_D(QFxItem);
+ if (d->width == w || widthValid())
+ return;
+
+ qreal oldWidth = d->width;
+
+ d->width = w;
+ update();
+
+ geometryChanged(QRectF(x(), y(), width(), height()),
+ QRectF(x(), y(), oldWidth, height()));
+}
+
+bool QFxItem::widthValid() const
+{
+ Q_D(const QFxItem);
+ return d->widthValid;
+}
+
+qreal QFxItem::height() const
+{
+ Q_D(const QFxItem);
+ return d->height;
+}
+
+void QFxItem::setHeight(qreal h)
+{
+ Q_D(QFxItem);
+ d->heightValid = true;
+ if (d->height == h)
+ return;
+
+ qreal oldHeight = d->height;
+
+ d->height = h;
+ update();
+
+ geometryChanged(QRectF(x(), y(), width(), height()),
+ QRectF(x(), y(), width(), oldHeight));
+}
+
+void QFxItem::setImplicitHeight(qreal h)
+{
+ Q_D(QFxItem);
+ if (d->height == h || heightValid())
+ return;
+
+ qreal oldHeight = d->height;
+
+ d->height = h;
+ update();
+
+ geometryChanged(QRectF(x(), y(), width(), height()),
+ QRectF(x(), y(), width(), oldHeight));
+}
+
+bool QFxItem::heightValid() const
+{
+ Q_D(const QFxItem);
+ return d->heightValid;
+}
+
+void QFxItem::setPos(const QPointF &point)
+{
+ qreal oldX = x();
+ qreal oldY = y();
+
+ QGraphicsItem::setPos(point);
+
+ geometryChanged(QRectF(x(), y(), width(), height()),
+ QRectF(oldX, oldY, width(), height()));
+}
+
+qreal QFxItem::scale() const
+{
+ Q_D(const QFxItem);
+ return d->scale;
+}
+
+void QFxItem::setScale(qreal s)
+{
+ Q_D(QFxItem);
+ if (d->scale == s)
+ return;
+
+ d->scale = s;
+ setTransform(d->transform);
+
+ emit scaleChanged();
+}
+
+QRect QFxItem::itemBoundingRect()
+{
+ return boundingRect().toAlignedRect();
+}
+
+QPointF QFxItem::mapFromScene(const QPointF &p) const
+{
+ return QGraphicsItem::mapFromScene(p);
+}
+
+QRectF QFxItem::mapFromScene(const QRectF &r) const
+{
+ return QGraphicsItem::mapFromScene(r).boundingRect();
+}
+
+QPointF QFxItem::mapToScene(const QPointF &p) const
+{
+ return QGraphicsItem::mapToScene(p);
+}
+
+QRectF QFxItem::mapToScene(const QRectF &r) const
+{
+ return QGraphicsItem::mapToScene(r).boundingRect();
+}
+
+QTransform QFxItem::transform() const
+{
+ Q_D(const QFxItem);
+ return d->transform;
+}
+
+//### optimize (perhaps cache scale and rot transforms, and have dirty flags)
+//### we rely on there not being an "if (d->transform == m) return;" check
+void QFxItem::setTransform(const QTransform &m)
+{
+ Q_D(QFxItem);
+ d->transform = m;
+ QTransform scaleTransform, rotTransform;
+ if (d->scale != 1) {
+ QPointF to = transformOriginPoint();
+ if (to.x() != 0. || to.y() != 0.)
+ scaleTransform.translate(to.x(), to.y());
+ scaleTransform.scale(d->scale, d->scale);
+ if (to.x() != 0. || to.y() != 0.)
+ scaleTransform.translate(-to.x(), -to.y());
+ }
+ if (d->_rotation != 0) {
+ QPointF to = d->transformOrigin();
+ if (to.x() != 0. || to.y() != 0.)
+ rotTransform.translate(to.x(), to.y());
+ rotTransform.rotate(d->_rotation);
+ if (to.x() != 0. || to.y() != 0.)
+ rotTransform.translate(-to.x(), -to.y());
+ }
+ QGraphicsItem::setTransform(scaleTransform * rotTransform * d->transform);
+}
+
+QFxItem *QFxItem::mouseGrabberItem() const
+{
+ QGraphicsScene *s = scene();
+ if (s) {
+ QGraphicsItem *item = s->mouseGrabberItem();
+ return static_cast<QFxItem*>(item); // ###
+ }
+ return 0;
+}
+
+/*!
+ \qmlproperty bool Item::focus
+ This property indicates whether the item has has an active focus request. Set this
+ property to true to request active focus.
+*/
+
+bool QFxItem::hasFocus() const
+{
+ Q_D(const QFxItem);
+ return d->isFocusItemForArea;
+}
+
+void QFxItem::setFocus(bool focus)
+{
+ Q_D(QFxItem);
+ QGraphicsScene *s = scene();
+ if (s) {
+ if (d->hasActiveFocus)
+ s->setFocusItem(focus ? this : 0);
+ else if (focus)
+ s->setFocusItem(this);
+ else {
+ d->isFocusItemForArea = false;
+ focusChanged(false);
+ }
+
+ } else {
+ d->isFocusItemForArea = focus;
+ focusChanged(focus);
+ }
+}
+
+/*!
+ \qmlproperty bool Item::activeFocus
+ This property indicates whether the item has the active focus.
+*/
+
+bool QFxItem::hasActiveFocus() const
+{
+ Q_D(const QFxItem);
+ return d->hasActiveFocus;
+}
+
+bool QFxItem::activeFocusPanel() const
+{
+ return false;
+}
+
+void QFxItem::setActiveFocusPanel(bool b)
+{
+ Q_UNUSED(b)
+}
+
+bool QFxItem::sceneEventFilter(QGraphicsItem *w, QEvent *e)
+{
+ switch(e->type()) {
+ case QEvent::GraphicsSceneMouseDoubleClick:
+ case QEvent::GraphicsSceneMouseMove:
+ case QEvent::GraphicsSceneMousePress:
+ case QEvent::GraphicsSceneMouseRelease:
+ if (mouseFilter(static_cast<QGraphicsSceneMouseEvent *>(e)))
+ return true;
+ break;
+ default:
+ break;
+ }
+
+ return QGraphicsItem::sceneEventFilter(w, e);
+}
+
+void QFxItem::setOptions(Options options, bool set)
+{
+ Q_D(QFxItem);
+ Options old = (Options)d->options;
+
+ if (options & IsFocusRealm) {
+ if (!set) {
+ qWarning("QFxItem::setOptions: Cannot unset IsFocusRealm");
+ return;
+ }
+ }
+
+ if (set)
+ d->options |= options;
+ else
+ d->options &= ~options;
+
+ if ((d->options & IsFocusPanel) && (d->options & IsFocusRealm)) {
+ qWarning("QFxItem::setOptions: Cannot set both IsFocusPanel and IsFocusRealm. IsFocusRealm will be unset.");
+ d->options &= ~IsFocusRealm;
+ }
+
+ setFlag(QGraphicsItem::ItemHasNoContents, !(d->options & HasContents));
+ setFiltersChildEvents(d->options & ChildMouseFilter);
+ setFlag(QGraphicsItem::ItemAcceptsInputMethod, (d->options & AcceptsInputMethods));
+ setAcceptHoverEvents(d->options & HoverEvents);
+ d->isFocusRealm = static_cast<bool>(d->options & IsFocusRealm);
+
+ if ((old & MouseFilter) != (d->options & MouseFilter)) {
+ if (d->options & MouseFilter)
+ d->gvAddMouseFilter();
+ else
+ d->gvRemoveMouseFilter();
+ }
+}
+
+/*!
+ \fn void QFxItem::setParent(QFxItem *parent)
+
+ Sets the parent of the item to \a parent.
+ */
+void QFxItem::setParent(QFxItem *p)
+{
+ if (p == parent() || !p) return;
+
+ QObject::setParent(p);
+
+ QFxItem *oldParent = itemParent();
+ setParentItem(p);
+ parentChanged(p, oldParent);
+}
+
+void QFxItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
+{
+ paintContents(*p);
+}
+
+void QFxItemPrivate::gvRemoveMouseFilter()
+{
+ Q_Q(QFxItem);
+ if (q->scene())
+ q->removeSceneEventFilter(q);
+}
+
+void QFxItemPrivate::gvAddMouseFilter()
+{
+ Q_Q(QFxItem);
+ if (q->scene())
+ q->installSceneEventFilter(q);
+}
+
+QPixmap QFxItem::string(const QString &str, const QColor &c, const QFont &f)
+{
+ QFontMetrics fm(f);
+ QSize size(fm.width(str), fm.height()*(str.count(QLatin1Char('\n'))+1)); //fm.boundingRect(str).size();
+ QPixmap img(size);
+ img.fill(Qt::transparent);
+ QPainter p(&img);
+ p.setPen(c);
+ p.setFont(f);
+ p.drawText(img.rect(), Qt::AlignVCenter, str);
+ return img;
+}
+
+QVariant QFxItem::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+ return QGraphicsItem::inputMethodQuery(query);
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index 5fb4eff..67b60c1 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -49,9 +49,10 @@
#include <QtDeclarative/qfxglobal.h>
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qfxscalegrid.h>
-#include <QtDeclarative/qsimplecanvasitem.h>
#include <QtDeclarative/qmlcomponent.h>
#include <QtDeclarative/qmlstate.h>
+#include <QtGui/qgraphicsitem.h>
+#include <QtGui/qfont.h>
QT_BEGIN_HEADER
@@ -93,58 +94,75 @@ class QmlTransition;
class QFxTransform;
class QFxKeyEvent;
class QFxItemPrivate;
-class Q_DECLARATIVE_EXPORT QFxItem : public QSimpleCanvasItem, public QmlParserStatus
+class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserStatus
{
Q_OBJECT
Q_INTERFACES(QmlParserStatus)
- Q_PROPERTY(QFxItem * parent READ itemParent WRITE setItemParent NOTIFY parentChanged DESIGNABLE false)
+ Q_PROPERTY(QFxItem * parent READ itemParent WRITE setItemParent NOTIFY parentChanged DESIGNABLE false FINAL)
Q_PROPERTY(QFxItem * moveToParent READ itemParent WRITE moveToParent NOTIFY parentChanged DESIGNABLE false)
Q_PROPERTY(QString id READ id WRITE setId)
Q_PROPERTY(QmlList<QFxItem *>* children READ children DESIGNABLE false)
Q_PROPERTY(QmlList<QObject *>* resources READ resources DESIGNABLE false)
- Q_PROPERTY(QFxAnchors * anchors READ anchors DESIGNABLE false CONSTANT)
+ Q_PROPERTY(QFxAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL)
Q_PROPERTY(QmlList<QObject *> *data READ data DESIGNABLE false)
- Q_PROPERTY(QFxContents * contents READ contents DESIGNABLE false CONSTANT)
+ Q_PROPERTY(QFxContents * contents READ contents DESIGNABLE false CONSTANT FINAL)
Q_PROPERTY(QmlList<QmlState *>* states READ states DESIGNABLE false)
Q_PROPERTY(QmlList<QmlTransition *>* transitions READ transitions DESIGNABLE false)
Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
Q_PROPERTY(QUrl qml READ qml WRITE setQml NOTIFY qmlChanged)
Q_PROPERTY(QFxItem *qmlItem READ qmlItem NOTIFY qmlChanged)
- Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged)
- Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
- Q_PROPERTY(qreal z READ z WRITE setZ)
- Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged)
- Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged)
- Q_PROPERTY(QFxAnchorLine left READ left CONSTANT)
- Q_PROPERTY(QFxAnchorLine right READ right CONSTANT)
- Q_PROPERTY(QFxAnchorLine horizontalCenter READ horizontalCenter CONSTANT)
- Q_PROPERTY(QFxAnchorLine top READ top CONSTANT)
- Q_PROPERTY(QFxAnchorLine bottom READ bottom CONSTANT)
- Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter CONSTANT)
- Q_PROPERTY(QFxAnchorLine baseline READ baseline CONSTANT)
+ Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged FINAL)
+ Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged FINAL)
+ Q_PROPERTY(qreal z READ z WRITE setZ FINAL)
+ Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL)
+ Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged FINAL)
+ Q_PROPERTY(QFxAnchorLine left READ left CONSTANT FINAL)
+ Q_PROPERTY(QFxAnchorLine right READ right CONSTANT FINAL)
+ Q_PROPERTY(QFxAnchorLine horizontalCenter READ horizontalCenter CONSTANT FINAL)
+ Q_PROPERTY(QFxAnchorLine top READ top CONSTANT FINAL)
+ Q_PROPERTY(QFxAnchorLine bottom READ bottom CONSTANT FINAL)
+ Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter CONSTANT FINAL)
+ Q_PROPERTY(QFxAnchorLine baseline READ baseline CONSTANT FINAL)
Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged)
- Q_PROPERTY(bool flipVertically READ flipVertically WRITE setFlipVertically)
- Q_PROPERTY(bool flipHorizontally READ flipHorizontally WRITE setFlipHorizontally)
Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
- Q_PROPERTY(QSimpleCanvasFilter *filter READ filter WRITE setFilter)
Q_PROPERTY(bool clip READ clip WRITE setClip)
- Q_PROPERTY(bool focusable READ isFocusable WRITE setFocusable)
- Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged)
- Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged)
+ Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL)
+ Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged FINAL)
Q_PROPERTY(QList<QFxTransform *>* transform READ transform)
- Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged)
+ Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
+ Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin)
+ Q_ENUMS(TransformOrigin)
Q_CLASSINFO("DefaultProperty", "data")
typedef QHash<QString, QFxItem *> QmlChildren;
public:
+ enum Option { NoOption = 0x00000000,
+ MouseFilter = 0x00000001,
+ ChildMouseFilter = 0x00000002,
+ HoverEvents = 0x00000004,
+ MouseEvents = 0x00000008,
+ HasContents = 0x00000010,
+ SimpleItem = 0x00000020,
+ IsFocusPanel = 0x00000040,
+ IsFocusRealm = 0x00000080,
+ AcceptsInputMethods = 0x00000100 };
+ Q_DECLARE_FLAGS(Options, Option)
+
+ enum TransformOrigin {
+ TopLeft, TopCenter, TopRight,
+ MiddleLeft, Center, MiddleRight,
+ BottomLeft, BottomCenter, BottomRight
+ };
+
QFxItem(QFxItem *parent = 0);
virtual ~QFxItem();
QFxItem *itemParent() const;
+ QFxItem *parentItem() const;
void setItemParent(QFxItem *parent);
void moveToParent(QFxItem *parent);
@@ -160,6 +178,9 @@ public:
QFxContents *contents();
+ bool clip() const;
+ void setClip(bool);
+
QmlList<QmlState *>* states();
QmlState *findState(const QString &name) const;
@@ -172,11 +193,6 @@ public:
QUrl qml() const;
void setQml(const QUrl &);
- bool flipVertically() const;
- void setFlipVertically(bool);
- bool flipHorizontally() const;
- void setFlipHorizontally(bool);
-
qreal baselineOffset() const;
void setBaselineOffset(qreal);
@@ -186,15 +202,13 @@ public:
qreal scale() const;
void setScale(qreal);
- qreal opacity() const;
- virtual void setOpacity(qreal);
+ void setOpacity(qreal);
QList<QFxTransform *> *transform();
bool isVisible() const;
void setVisible(bool);
- virtual void dump(int depth = 0);
virtual QString propertyInfo() const;
bool isClassComplete() const;
@@ -207,6 +221,60 @@ public:
bool keepMouseGrab() const;
void setKeepMouseGrab(bool);
+ Options options() const;
+ void setOptions(Options, bool set = true);
+
+ qreal z() const;
+ QPointF pos() const;
+ void setX(qreal);
+ void setY(qreal);
+ virtual void setZ(qreal);
+ void setPos(const QPointF &);
+
+ qreal width() const;
+ void setWidth(qreal);
+ void setImplicitWidth(qreal);
+ bool widthValid() const;
+ qreal height() const;
+ void setHeight(qreal);
+ void setImplicitHeight(qreal);
+ bool heightValid() const;
+
+ QPointF scenePos() const;
+
+ TransformOrigin transformOrigin() const;
+ void setTransformOrigin(TransformOrigin);
+ QPointF transformOriginPoint() const;
+
+ void setParent(QFxItem *);
+
+ QRect itemBoundingRect();
+
+ void setPaintMargin(qreal margin);
+ QRectF boundingRect() const;
+ virtual void paintContents(QPainter &);
+
+ QPointF mapFromScene(const QPointF &) const;
+ QRectF mapFromScene(const QRectF &) const;
+ QPointF mapToScene(const QPointF &) const;
+ QRectF mapToScene(const QRectF &) const;
+
+ QTransform transform() const;
+ void setTransform(const QTransform &);
+
+ QFxItem *mouseGrabberItem() const;
+
+ virtual bool hasFocus() const;
+ void setFocus(bool);
+ bool activeFocusPanel() const;
+ void setActiveFocusPanel(bool);
+
+ bool hasActiveFocus() const;
+
+ static QPixmap string(const QString &, const QColor & = Qt::black, const QFont & = QFont());
+
+ QVariant inputMethodQuery(Qt::InputMethodQuery query) const; //### for KeyProxy
+
public Q_SLOTS:
void newChild(const QString &url);
@@ -230,16 +298,23 @@ Q_SIGNALS:
void newChildCreated(const QString &url, QScriptValue);
protected:
- virtual void transformChanged(const QSimpleCanvas::Matrix &);
+ virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+ virtual void childrenChanged();
+ virtual bool sceneEventFilter(QGraphicsItem *, QEvent *);
+ virtual bool sceneEvent(QEvent *);
+ virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
+ virtual bool mouseFilter(QGraphicsSceneMouseEvent *);
+ virtual void mouseUngrabEvent();
+
+ virtual void transformChanged(const QTransform &);
virtual void classBegin();
virtual void classComplete();
virtual void componentComplete();
- virtual void parentChanged(QSimpleCanvasItem *, QSimpleCanvasItem *);
- virtual void reparentItems();
+ virtual void parentChanged(QFxItem *, QFxItem *);
virtual void focusChanged(bool);
virtual void activeFocusChanged(bool);
- void keyPressEvent(QKeyEvent *event);
- void keyReleaseEvent(QKeyEvent *event);
+ virtual void keyPressEvent(QKeyEvent *event);
+ virtual void keyReleaseEvent(QKeyEvent *event);
virtual void geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry);
@@ -263,14 +338,23 @@ private:
friend class QmlStatePrivate;
friend class QFxAnchors;
Q_DISABLE_COPY(QFxItem)
- Q_DECLARE_PRIVATE(QFxItem)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxItem)
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QFxItem::Options)
+
+template<typename T>
+T qobject_cast(QGraphicsItem *item)
+{
+ if (!item) return 0;
+ QObject *o = item->toGraphicsObject();
+ return qobject_cast<T>(o);
+}
+
QT_END_NAMESPACE
QML_DECLARE_TYPE(QFxContents)
QML_DECLARE_TYPE(QFxItem)
-QML_DECLARE_TYPE(QSimpleCanvasFilter)
QT_END_HEADER
diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h
index 32e8aef..eddeb9b 100644
--- a/src/declarative/fx/qfxitem_p.h
+++ b/src/declarative/fx/qfxitem_p.h
@@ -54,17 +54,18 @@
//
#include <QtDeclarative/qfxitem.h>
-#include <private/qsimplecanvasitem_p.h>
#include <private/qmlnullablevalue_p.h>
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qmlcontext.h>
#include <QtCore/qlist.h>
+#include <private/qgraphicsitem_p.h>
+#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
class QNetworkReply;
-class QFxItemPrivate : public QSimpleCanvasItemPrivate
+class QFxItemPrivate : public QGraphicsItemPrivate
{
Q_DECLARE_PUBLIC(QFxItem)
@@ -75,8 +76,11 @@ public:
: _anchors(0), _contents(0), qmlItem(0), _qmlcomp(0),
_baselineOffset(0), _rotation(0.),
_classComplete(true), _componentComplete(true), _keepMouse(false),
- visible(true), _anchorLines(0), visibleOp(1), reparentedChildren(0),
- _stateGroup(0)
+ visible(true), _anchorLines(0), visibleOp(1),
+ _stateGroup(0), canvas(0), origin(QFxItem::TopLeft),
+ options(QFxItem::NoOption),
+ widthValid(false), heightValid(false), width(0), height(0),
+ paintmargin(0), scale(1)
{}
~QFxItemPrivate()
{ delete _anchors; }
@@ -89,6 +93,9 @@ public:
q->setItemParent(parent);
_baselineOffset.invalidate();
q->setAcceptedMouseButtons(Qt::NoButton);
+ q->setFlag(QGraphicsItem::ItemHasNoContents, true);
+ q->setFlag(QGraphicsItem::ItemIsFocusable, true);
+ mouseSetsFocus = false;
}
QString _id;
@@ -168,10 +175,39 @@ public:
float visibleOp;
- int reparentedChildren;
-
QmlStateGroup *states();
QmlStateGroup *_stateGroup;
+
+
+ QGraphicsScene *canvas;
+
+ QFxItem::TransformOrigin origin:4;
+ int options:10;
+ bool widthValid:1;
+ bool heightValid:1;
+
+ qreal width;
+ qreal height;
+ qreal paintmargin;
+ qreal scale;
+
+ QPointF transformOrigin() const;
+ QTransform transform;
+
+ void gvRemoveMouseFilter();
+ void gvAddMouseFilter();
+
+ virtual void setActiveFocus(bool b) {
+ Q_Q(QFxItem);
+ QGraphicsItemPrivate::setActiveFocus(b);
+ q->activeFocusChanged(b);
+ }
+
+ virtual void setFocusItemForArea(bool b) {
+ Q_Q(QFxItem);
+ QGraphicsItemPrivate::setFocusItemForArea(b);
+ q->focusChanged(b);
+ }
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxkeyactions.cpp b/src/declarative/fx/qfxkeyactions.cpp
index 4aae74f..2c662a6 100644
--- a/src/declarative/fx/qfxkeyactions.cpp
+++ b/src/declarative/fx/qfxkeyactions.cpp
@@ -41,7 +41,7 @@
#include "qfxkeyactions.h"
#include <qmlexpression.h>
-
+#include <QKeyEvent>
QT_BEGIN_NAMESPACE
QML_DEFINE_TYPE(QFxKeyActions,KeyActions)
diff --git a/src/declarative/fx/qfxkeyproxy.cpp b/src/declarative/fx/qfxkeyproxy.cpp
index e80f2c7..e4b4269 100644
--- a/src/declarative/fx/qfxkeyproxy.cpp
+++ b/src/declarative/fx/qfxkeyproxy.cpp
@@ -40,34 +40,63 @@
****************************************************************************/
#include "qfxkeyproxy.h"
-
+#include <QGraphicsScene>
+#include <QKeyEvent>
QT_BEGIN_NAMESPACE
+
QML_DEFINE_TYPE(QFxKeyProxy,KeyProxy)
/*!
\qmlclass KeyProxy
- \brief The KeyProxy item proxies key presses to a number of other items.
+ \brief The KeyProxy item proxies key events to a number of other items.
\inherits Item
+ KeyProxy provides a way to forward key presses, key releases, and keyboard input
+ coming from input methods to other items. This can be useful when you want
+ one item to handle some keys (e.g. the up and down arrow keys), and another item to
+ handle other keys (e.g. the left and right arrow keys).
+
+ To receive key events, the KeyProxy item must be in the current focus chain,
+ just like any other item.
+
+ KeyProxy is an invisible item: it is never painted.
+
+ A simple KeyProxy that forward key events to two lists:
+ \qml
+ ListView { id: List1 ... }
+ ListView { id: List2 ... }
+ KeyProxy {
+ focus: true
+ targets: [List1, List2]
+ }
+ \endqml
*/
/*!
\internal
\class QFxKeyProxy
- \brief The QFxKeyProxy class proxies key presses to a number of other items.
- \ingroup group_utility
+ \brief The QFxKeyProxy class proxies key events to a number of other items.
*/
class QFxKeyProxyPrivate
{
public:
+ QFxKeyProxyPrivate() : inPress(false), inRelease(false), inIM(false), imeItem(0) {}
QList<QFxItem *> targets;
+
+ //loop detection
+ bool inPress:1;
+ bool inRelease:1;
+ bool inIM:1;
+
+ QFxItem *imeItem;
};
QFxKeyProxy::QFxKeyProxy(QFxItem *parent)
: QFxItem(parent), d(new QFxKeyProxyPrivate)
{
+ setOptions(AcceptsInputMethods);
}
QFxKeyProxy::~QFxKeyProxy()
@@ -78,12 +107,10 @@ QFxKeyProxy::~QFxKeyProxy()
/*!
\qmlproperty list<Item> KeyProxy::targets
- The proxy targets.
-*/
+ An ordered list of the items that will be forwarded key events.
-/*!
- \property QFxKeyProxy::targets
- \brief the proxy targets.
+ The events will be forwarded to the targets in turn until one of them
+ accepts the event.
*/
QList<QFxItem *> *QFxKeyProxy::targets() const
@@ -93,24 +120,77 @@ QList<QFxItem *> *QFxKeyProxy::targets() const
void QFxKeyProxy::keyPressEvent(QKeyEvent *e)
{
- for (int ii = 0; ii < d->targets.count(); ++ii) {
- QSimpleCanvasItem *i = canvas()->focusItem(d->targets.at(ii));
- if (i)
- i->keyPressEvent(e);
- if (e->isAccepted())
- return;
+ if (!scene())
+ return;
+ if (!d->inPress) {
+ d->inPress = true;
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
+ QFxItem *i = qobject_cast<QFxItem *>(scene()->focusItem(d->targets.at(ii)));
+ if (i) {
+ scene()->sendEvent(i, e);
+ if (e->isAccepted()) {
+ d->inPress = false;
+ return;
+ }
+ }
+ }
+ d->inPress = false;
}
}
void QFxKeyProxy::keyReleaseEvent(QKeyEvent *e)
{
+ if (!scene())
+ return;
+ if (!d->inRelease) {
+ d->inRelease = true;
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
+ QFxItem *i = qobject_cast<QFxItem *>(scene()->focusItem(d->targets.at(ii)));
+ if (i) {
+ scene()->sendEvent(i, e);
+ if (e->isAccepted()) {
+ d->inRelease = false;
+ return;
+ }
+ }
+ }
+ d->inRelease = false;
+ }
+}
+
+void QFxKeyProxy::inputMethodEvent(QInputMethodEvent *e)
+{
+ if (!scene())
+ return;
+ if (!d->inIM) {
+ d->inIM = true;
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
+ QFxItem *i = qobject_cast<QFxItem *>(scene()->focusItem(d->targets.at(ii)));
+ if (i && (i->options() & AcceptsInputMethods)) {
+ scene()->sendEvent(i, e);
+ if (e->isAccepted()) {
+ d->imeItem = i;
+ d->inIM = false;
+ return;
+ }
+ }
+ }
+ d->inIM = false;
+ }
+}
+
+QVariant QFxKeyProxy::inputMethodQuery(Qt::InputMethodQuery query) const
+{
for (int ii = 0; ii < d->targets.count(); ++ii) {
- QSimpleCanvasItem *i = canvas()->focusItem(d->targets.at(ii));
- if (i)
- i->keyReleaseEvent(e);
- if (e->isAccepted())
- return;
+ QFxItem *i = qobject_cast<QFxItem *>(scene()->focusItem(d->targets.at(ii)));
+ if (i && (i->options() & AcceptsInputMethods) && i == d->imeItem) { //### how robust is i == d->imeItem check?
+ QVariant v = i->inputMethodQuery(query);
+ if (v.type() == QVariant::RectF)
+ v = mapRectFromItem(i, v.toRectF()); //### cost?
+ return v;
+ }
}
+ return QFxItem::inputMethodQuery(query);
}
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxkeyproxy.h b/src/declarative/fx/qfxkeyproxy.h
index d075295..e77ffac 100644
--- a/src/declarative/fx/qfxkeyproxy.h
+++ b/src/declarative/fx/qfxkeyproxy.h
@@ -64,6 +64,8 @@ public:
protected:
virtual void keyPressEvent(QKeyEvent *);
virtual void keyReleaseEvent(QKeyEvent *);
+ virtual void inputMethodEvent(QInputMethodEvent *);
+ virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
private:
Q_DISABLE_COPY(QFxKeyProxy)
diff --git a/src/declarative/fx/qfxlayouts.cpp b/src/declarative/fx/qfxlayouts.cpp
index 20e7c7c..f71b35a 100644
--- a/src/declarative/fx/qfxlayouts.cpp
+++ b/src/declarative/fx/qfxlayouts.cpp
@@ -311,8 +311,9 @@ void QFxBaseLayout::preLayout()
QCoreApplication::postEvent(this, new QEvent(QEvent::User));
}
QSet<QFxItem *> allItems;
- for (int ii = 0; ii < this->QSimpleCanvasItem::children().count(); ++ii) {
- QFxItem *child = qobject_cast<QFxItem *>(this->QSimpleCanvasItem::children().at(ii));
+ QList<QGraphicsItem *> children = childItems();
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QFxItem *child = qobject_cast<QFxItem *>(children.at(ii));
if (!child)
continue;
if (!d->_items.contains(child)){
@@ -618,8 +619,10 @@ void QFxVerticalLayout::doLayout()
applyRemove(changes, item);
}
}
- for (int ii = 0; ii < this->QSimpleCanvasItem::children().count(); ++ii) {
- QFxItem *child = qobject_cast<QFxItem *>(this->QSimpleCanvasItem::children().at(ii));
+
+ QList<QGraphicsItem *> children = childItems();
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QFxItem *child = qobject_cast<QFxItem *>(children.at(ii));
if (!child || !child->isVisible())
continue;
@@ -784,8 +787,9 @@ void QFxHorizontalLayout::doLayout()
applyRemove(changes, item);
}
}
- for (int ii = 0; ii < this->QSimpleCanvasItem::children().count(); ++ii) {
- QFxItem *child = qobject_cast<QFxItem *>(this->QSimpleCanvasItem::children().at(ii));
+ QList<QGraphicsItem *> children = childItems();
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QFxItem *child = qobject_cast<QFxItem *>(children.at(ii));
if (!child || !child->isVisible())
continue;
@@ -1013,15 +1017,17 @@ void QFxGridLayout::doLayout()
QList<int> maxColWidth;
QList<int> maxRowHeight;
int childIndex =0;
+ QList<QGraphicsItem *> children = childItems();
for (int i=0; i<r; i++){
for (int j=0; j<c; j++){
if (j==0)
maxRowHeight << 0;
if (i==0)
maxColWidth << 0;
- if (childIndex == this->QSimpleCanvasItem::children().count())
+
+ if (childIndex == children.count())
continue;
- QFxItem *child = qobject_cast<QFxItem *>(this->QSimpleCanvasItem::children().at(childIndex++));
+ QFxItem *child = qobject_cast<QFxItem *>(children.at(childIndex++));
if (!child || !child->isVisible())
continue;
if (child->width() > maxColWidth[j])
@@ -1041,7 +1047,7 @@ void QFxGridLayout::doLayout()
applyRemove(changes, item);
}
}
- foreach(QSimpleCanvasItem* schild, this->QSimpleCanvasItem::children()){
+ foreach(QGraphicsItem* schild, children){
QFxItem *child = qobject_cast<QFxItem *>(schild);
if (!child || !child->isVisible())
continue;
diff --git a/src/declarative/fx/qfxlayouts.h b/src/declarative/fx/qfxlayouts.h
index 112fe85..5767bc5 100644
--- a/src/declarative/fx/qfxlayouts.h
+++ b/src/declarative/fx/qfxlayouts.h
@@ -115,7 +115,7 @@ private:
void applyTransition(const QList<QPair<QString, QVariant> >& changes, QFxItem* target,
QmlTransition* transition);
Q_DISABLE_COPY(QFxBaseLayout)
- Q_DECLARE_PRIVATE(QFxBaseLayout)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxBaseLayout)
};
class Q_DECLARATIVE_EXPORT QFxVerticalLayout : public QFxBaseLayout
diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp
new file mode 100644
index 0000000..da79979
--- /dev/null
+++ b/src/declarative/fx/qfxlineedit.cpp
@@ -0,0 +1,518 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qfxlineedit.h"
+#include "qfxlineedit_p.h"
+#include <QValidator>
+#include <QApplication>
+#include <QFontMetrics>
+#include <QPainter>
+
+QT_BEGIN_NAMESPACE
+QML_DEFINE_TYPE(QFxLineEdit,LineEdit);
+QML_DEFINE_TYPE(QIntValidator,QIntValidator);
+
+QFxLineEdit::QFxLineEdit(QFxItem* parent)
+ : QFxPaintedItem(*(new QFxLineEditPrivate), parent)
+{
+ Q_D(QFxLineEdit);
+ d->init();
+}
+
+/*
+ \internal
+*/
+QFxLineEdit::QFxLineEdit(QFxLineEditPrivate &dd, QFxItem* parent)
+ : QFxPaintedItem(dd, parent)
+{
+ Q_D(QFxLineEdit);
+ d->init();
+}
+
+QFxLineEdit::~QFxLineEdit()
+{
+}
+
+QString QFxLineEdit::text() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->text();
+}
+
+void QFxLineEdit::setText(const QString &s)
+{
+ Q_D(QFxLineEdit);
+ if(s == text())
+ return;
+ d->control->setText(s);
+ //emit textChanged();
+}
+
+QmlFont *QFxLineEdit::font()
+{
+ Q_D(QFxLineEdit);
+ return d->font;
+}
+
+QColor QFxLineEdit::color() const
+{
+ Q_D(const QFxLineEdit);
+ return d->color;
+}
+
+void QFxLineEdit::setColor(const QColor &c)
+{
+ Q_D(QFxLineEdit);
+ d->color = c;
+}
+
+/*
+QFxText::TextStyle QFxLineEdit::style() const
+{
+ Q_D(const QFxLineEdit);
+ return d->style;
+}
+
+void QFxLineEdit::setStyle(QFxText::TextStyle style)
+{
+ Q_D(QFxLineEdit);
+ d->style = style;
+}
+
+QColor QFxLineEdit::styleColor() const
+{
+ Q_D(const QFxLineEdit);
+ return d->styleColor;
+}
+
+void QFxLineEdit::setStyleColor(const QColor &c)
+{
+ Q_D(QFxLineEdit);
+ d->styleColor = c;
+}
+*/
+
+QFxText::HAlignment QFxLineEdit::hAlign() const
+{
+ Q_D(const QFxLineEdit);
+ return d->hAlign;
+}
+
+void QFxLineEdit::setHAlign(QFxText::HAlignment align)
+{
+ Q_D(QFxLineEdit);
+ d->hAlign = align;
+}
+
+QFxText::VAlignment QFxLineEdit::vAlign() const
+{
+ Q_D(const QFxLineEdit);
+ return d->vAlign;
+}
+
+void QFxLineEdit::setVAlign(QFxText::VAlignment align)
+{
+ Q_D(QFxLineEdit);
+ d->vAlign = align;
+}
+
+//### Should this also toggle cursor visibility?
+bool QFxLineEdit::isReadOnly() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->isReadOnly();
+}
+
+void QFxLineEdit::setReadOnly(bool ro)
+{
+ Q_D(QFxLineEdit);
+ d->control->setReadOnly(ro);
+}
+
+int QFxLineEdit::maxLength() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->maxLength();
+}
+
+void QFxLineEdit::setMaxLength(int ml)
+{
+ Q_D(QFxLineEdit);
+ d->control->setMaxLength(ml);
+}
+
+int QFxLineEdit::cursorPosition() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->cursor();
+}
+void QFxLineEdit::setCursorPosition(int cp)
+{
+ Q_D(QFxLineEdit);
+ d->control->moveCursor(cp);
+}
+
+int QFxLineEdit::selectionLength() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->selectionEnd() - d->control->selectionStart();
+}
+
+void QFxLineEdit::setSelectionLength(int len)
+{
+ Q_D(QFxLineEdit);
+ d->control->setSelection(d->control->cursor(), len);
+}
+
+QString QFxLineEdit::selectedText() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->selectedText();
+}
+
+QObject* QFxLineEdit::validator() const
+{
+ Q_D(const QFxLineEdit);
+ //###const cast isn't good, but needed for property system?
+ //###same should be said about using QObject* as the property type
+ return const_cast<QValidator*>(d->control->validator());
+}
+
+void QFxLineEdit::setValidator(QObject* v)
+{
+ Q_D(QFxLineEdit);
+ QValidator* valid = qobject_cast<QValidator*>(v);
+ if(!valid)
+ return;
+ d->control->setValidator(valid);
+ if(!d->control->hasAcceptableInput()){
+ d->oldValidity = false;
+ emit acceptableInputChanged();
+ }
+}
+
+QString QFxLineEdit::inputMask() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->inputMask();
+}
+
+void QFxLineEdit::setInputMask(const QString &im)
+{
+ Q_D(QFxLineEdit);
+ d->control->setInputMask(im);
+}
+
+bool QFxLineEdit::hasAcceptableInput() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->hasAcceptableInput();
+}
+
+uint QFxLineEdit::echoMode() const
+{
+ Q_D(const QFxLineEdit);
+ return d->control->echoMode();
+}
+
+void QFxLineEdit::setEchoMode(uint echo)
+{
+ Q_D(QFxLineEdit);
+ d->control->setEchoMode(echo);
+}
+
+QmlComponent* QFxLineEdit::cursorDelegate() const
+{
+ Q_D(const QFxLineEdit);
+ return d->cursorComponent;
+}
+
+void QFxLineEdit::setCursorDelegate(QmlComponent* c)
+{
+ Q_D(QFxLineEdit);
+ if(d->cursorComponent)
+ delete d->cursorComponent;
+ d->cursorComponent = c;
+ d->startCreatingCursor();
+}
+
+void QFxLineEditPrivate::startCreatingCursor()
+{
+ Q_Q(QFxLineEdit);
+ if(!cursorComponent){
+ q->disconnect(control, SIGNAL(cursorPositionChanged(int, int)),
+ q, SLOT(moveCursor()));
+ return;
+ }
+ q->connect(control, SIGNAL(cursorPositionChanged(int, int)),
+ q, SLOT(moveCursor()));
+ if(cursorComponent->isReady()){
+ q->createCursor();
+ }else if(cursorComponent->isLoading()){
+ q->connect(cursorComponent, SIGNAL(statusChanged(int)),
+ q, SLOT(createCursor()));
+ }else{//isError
+ qWarning() << "You could really use the error checking for QFxLineEdit. We'll implement it soon.";
+ }
+}
+
+void QFxLineEdit::createCursor()
+{
+ Q_D(QFxLineEdit);
+ //Handle isError too
+ if(!d->cursorComponent->isReady())
+ return;
+
+ if(d->cursorItem)
+ delete d->cursorItem;
+ d->cursorItem = qobject_cast<QFxItem*>(d->cursorComponent->create());
+ if(!d->cursorItem){
+ qWarning() << "You could really use the error reporting for QFxLineEdit. We'll implement it soon.";
+ return;
+ }
+
+ d->cursorItem->setItemParent(this);
+ d->cursorItem->setX(d->control->cursorToX());
+ d->cursorItem->setHeight(d->control->height());
+}
+
+void QFxLineEdit::moveCursor()
+{
+ Q_D(QFxLineEdit);
+ if(!d->cursorItem)
+ return;
+ d->cursorItem->setX(d->control->cursorToX() - d->hscroll);
+}
+
+/*
+int QFxLineEdit::scrollDuration() const
+{
+ Q_D(const QFxLineEdit);
+ return d->scrollDur;
+}
+
+void QFxLineEdit::setScrollDuration(int s)
+{
+ Q_D(QFxLineEdit);
+ d->scrollDur = s;
+ //Need to update cur anims as well
+}
+*/
+int QFxLineEdit::xToPos(int x)
+{
+ Q_D(const QFxLineEdit);
+ return d->control->xToPos(x - d->hscroll);
+}
+
+void QFxLineEdit::focusChanged(bool hasFocus)
+{
+ Q_D(QFxLineEdit);
+ if(d->focused && !hasFocus){
+ d->focused = false;
+ d->control->setCursorBlinkPeriod(0);
+ updateAll();//Only need the cursor rect
+ }else{
+ d->focused = hasFocus;
+ updateAll();//Only need the cursor rect
+ }
+}
+
+void QFxLineEdit::keyPressEvent(QKeyEvent* ev)
+{
+ Q_D(QFxLineEdit);
+ d->control->processKeyEvent(ev);
+}
+
+void QFxLineEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QFxLineEdit);
+ setFocus(true);
+ d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime());
+ d->focused = true;
+ d->control->processEvent(event);
+ //event->accept();
+}
+
+bool QFxLineEdit::event(QEvent* ev)
+{
+ Q_D(QFxLineEdit);
+ //Anything we don't deal with ourselves, pass to the control
+ switch(ev->type()){
+ case QEvent::GraphicsSceneMousePress:
+ break;
+ default:
+ return d->control->processEvent(ev);
+ }
+ return false;
+}
+
+void QFxLineEdit::geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry)
+{
+ if (newGeometry.width() != oldGeometry.width())
+ updateSize();
+ QFxPaintedItem::geometryChanged(newGeometry, oldGeometry);
+}
+
+void QFxLineEdit::drawContents(QPainter *p, const QRect &r)
+{
+ Q_D(QFxLineEdit);
+ p->setRenderHint(QPainter::TextAntialiasing, true);
+ p->save();
+ p->setPen(QPen(d->color));
+ int flags = QLineControl::DrawText;
+ if(!isReadOnly() && d->focused && !d->cursorItem)
+ flags |= QLineControl::DrawCursor;
+ if (d->control->hasSelectedText())
+ flags |= QLineControl::DrawSelections;
+
+ //TODO: Clean up this cut'n'pasted section from QLineEdit
+ QRect lineRect(r);
+
+ int cix = qRound(d->control->cursorToX());
+
+ // horizontal scrolling. d->hscroll is the left indent from the beginning
+ // of the text line to the left edge of lineRect. we update this value
+ // depending on the delta from the last paint event; in effect this means
+ // the below code handles all scrolling based on the textline (widthUsed,
+ // minLB, minRB), the line edit rect (lineRect) and the cursor position
+ // (cix).
+ QFontMetrics fm = QApplication::fontMetrics();
+ int minLB = qMax(0, -fm.minLeftBearing());
+ int minRB = qMax(0, -fm.minRightBearing());
+ int widthUsed = d->control->width() + minRB;
+ if ((minLB + widthUsed) <= lineRect.width()) {
+ // text fits in lineRect; use hscroll for alignment
+ d->hscroll = 0;
+ d->hscroll -= minLB;
+ } else if (cix - d->hscroll >= lineRect.width()) {
+ // text doesn't fit, cursor is to the right of lineRect (scroll right)
+ d->hscroll = cix - lineRect.width() + 1;
+ } else if (cix - d->hscroll < 0 && d->hscroll < widthUsed) {
+ // text doesn't fit, cursor is to the left of lineRect (scroll left)
+ d->hscroll = cix;
+ }
+ // the y offset is there to keep the baseline constant in case we have script changes in the text.
+ QPoint topLeft = lineRect.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent());
+
+ if(d->hscroll != d->oldScroll)
+ moveCursor();
+
+ d->control->draw(p, topLeft, r, flags);
+
+ d->oldScroll = d->hscroll;
+ p->restore();
+}
+
+void QFxLineEditPrivate::init()
+{
+ Q_Q(QFxLineEdit);
+ control->setCursorWidth(1);
+ control->setPasswordCharacter(QLatin1Char('*'));
+ control->setLayoutDirection(Qt::LeftToRight);
+ control->setSelection(0,0);
+ q->setSmooth(true);
+ q->setAcceptedMouseButtons(Qt::LeftButton);
+ q->setOptions(QFxLineEdit::AcceptsInputMethods | QFxLineEdit::SimpleItem
+ | QFxLineEdit::HasContents | QFxLineEdit::MouseEvents);
+ q->connect(control, SIGNAL(cursorPositionChanged(int,int)),
+ q, SIGNAL(cursorPositionChanged()));
+ q->connect(control, SIGNAL(selectionChanged()),
+ q, SLOT(selectionChanged()));
+ q->connect(control, SIGNAL(textChanged(const QString &)),
+ q, SLOT(q_textChanged()));
+ q->connect(control, SIGNAL(accepted()),
+ q, SIGNAL(accepted()));
+ q->connect(control, SIGNAL(updateNeeded(const QRect &)),
+ // q, SLOT(dirtyCache(const QRect &)));
+ q, SLOT(updateAll()));
+ q->connect(control, SIGNAL(cursorPositionChanged(int,int)),
+ q, SLOT(updateAll()));
+ q->connect(control, SIGNAL(selectionChanged()),
+ q, SLOT(updateAll()));
+ if(!font)
+ font = new QmlFont();
+ q->updateSize();
+ oldValidity = control->hasAcceptableInput();
+ oldSelectLength = q->selectionLength();
+}
+
+void QFxLineEdit::selectionChanged()
+{
+ Q_D(QFxLineEdit);
+ emit selectedTextChanged();
+ if(selectionLength() != d->oldSelectLength){
+ d->oldSelectLength = selectionLength();
+ emit selectionLengthChanged();
+ }
+}
+
+void QFxLineEdit::q_textChanged()
+{
+ Q_D(QFxLineEdit);
+ updateAll();
+ emit textChanged();
+ if(hasAcceptableInput() != d->oldValidity){
+ d->oldValidity = hasAcceptableInput();
+ emit acceptableInputChanged();
+ }
+}
+
+//### Please replace this function with proper updating
+void QFxLineEdit::updateAll()
+{
+ clearCache();
+ updateSize();
+ update();
+}
+
+void QFxLineEdit::updateSize()
+{
+ Q_D(QFxLineEdit);
+ setImplicitHeight(d->control->height());
+ //d->control->width() is max width, not current width
+ QFontMetrics fm = QFontMetrics(d->font->font());
+ setImplicitWidth(fm.boundingRect(d->control->text()).width()+1);
+ setContentsSize(QSize(width(), height()));
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/declarative/fx/qfxlineedit.h b/src/declarative/fx/qfxlineedit.h
new file mode 100644
index 0000000..e053c54
--- /dev/null
+++ b/src/declarative/fx/qfxlineedit.h
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFXLINEEDIT_H
+#define QFXLINEEDIT_H
+
+#include "qfxtext.h"
+#include "qfxpainteditem.h"
+#include <QGraphicsSceneMouseEvent>
+#include <QIntValidator>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QFxLineEditPrivate;
+class QValidator;
+class Q_DECLARATIVE_EXPORT QFxLineEdit : public QFxPaintedItem
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
+ Q_PROPERTY(QmlFont *font READ font)
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+ /*
+ Q_PROPERTY(QFxText::TextStyle style READ style WRITE setStyle)
+ Q_PROPERTY(QColor styleColor READ styleColor WRITE setStyleColor)
+ Q_PROPERTY(QFxText::HAlignment hAlign READ hAlign WRITE setHAlign)
+ Q_PROPERTY(QFxText::VAlignment vAlign READ vAlign WRITE setVAlign)
+ */
+
+ Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly);
+ Q_PROPERTY(int maxLength READ maxLength WRITE setMaxLength);
+ Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged);
+ Q_PROPERTY(int selectionLength READ selectionLength WRITE setSelectionLength NOTIFY selectionLengthChanged);
+ Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged);
+
+ Q_PROPERTY(QObject* validator READ validator WRITE setValidator);
+ Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask);
+ Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged);
+ Q_PROPERTY(uint echoMode READ echoMode WRITE setEchoMode);
+
+ Q_PROPERTY(QmlComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate);
+ /*
+ Q_PROPERTY(int scrollDuration READ scrollDuration SET setScrollDuration NOTIFY scrollDurationChanged);
+ */
+
+public:
+ QFxLineEdit(QFxItem* parent=0);
+ ~QFxLineEdit();
+
+ QString text() const;
+ void setText(const QString &);
+
+ QmlFont *font();
+
+ QColor color() const;
+ void setColor(const QColor &c);
+
+ //### Should we have this function or x variants of properties?
+ Q_INVOKABLE int xToPos(int x);
+
+ /*
+ QFxText::TextStyle style() const;
+ void setStyle(QFxText::TextStyle style);
+
+ QColor styleColor() const;
+ void setStyleColor(const QColor &c);
+ */
+
+ QFxText::HAlignment hAlign() const;
+ void setHAlign(QFxText::HAlignment align);
+
+ QFxText::VAlignment vAlign() const;
+ void setVAlign(QFxText::VAlignment align);
+
+ bool isReadOnly() const;
+ void setReadOnly(bool);
+
+ int maxLength() const;
+ void setMaxLength(int ml);
+
+ int cursorPosition() const;
+ void setCursorPosition(int cp);
+
+ int selectionLength() const;
+ void setSelectionLength(int len);
+
+ QString selectedText() const;
+
+ QObject * validator() const;
+ void setValidator(QObject* v);
+
+ QString inputMask() const;
+ void setInputMask(const QString &im);
+
+ uint echoMode() const;
+ void setEchoMode(uint echo);
+
+ QmlComponent* cursorDelegate() const;
+ void setCursorDelegate(QmlComponent*);
+
+ /*
+ int scrollDuration() const;
+ void setScrollDuration(int);
+ */
+
+ bool hasAcceptableInput() const;
+
+ void drawContents(QPainter *p,const QRect &r);
+Q_SIGNALS:
+ void textChanged();
+ void cursorPositionChanged();
+ void selectionLengthChanged();
+ void selectedTextChanged();
+ void accepted();
+ void acceptableInputChanged();
+
+protected:
+ QFxLineEdit(QFxLineEditPrivate &dd, QFxItem *parent);
+ virtual void geometryChanged(const QRectF &newGeometry,
+ const QRectF &oldGeometry);
+
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void keyPressEvent(QKeyEvent* ev);
+ bool event(QEvent *e);
+
+ void focusChanged(bool hasFocus);
+
+private slots:
+ void updateSize();
+ void q_textChanged();
+ void selectionChanged();
+ void updateAll();
+ void createCursor();
+ void moveCursor();
+
+private:
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxLineEdit);
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QFxLineEdit)
+QML_DECLARE_TYPE(QIntValidator)
+
+QT_END_HEADER
+#endif // QFXLINEEDIT_H
diff --git a/src/declarative/fx/qfxhighlightfilter.h b/src/declarative/fx/qfxlineedit_p.h
index 56509a3..a0ab19c 100644
--- a/src/declarative/fx/qfxhighlightfilter.h
+++ b/src/declarative/fx/qfxlineedit_p.h
@@ -39,61 +39,66 @@
**
****************************************************************************/
-#ifndef QFXHIGHLIGHTFILTER_H
-#define QFXHIGHLIGHTFILTER_H
-
-#include <QtDeclarative/qsimplecanvasfilter.h>
-#include <QtDeclarative/qml.h>
-
-QT_BEGIN_HEADER
+#ifndef QFXLINEEDIT_P_H
+#define QFXLINEEDIT_P_H
+
+#include "qfxlineedit.h"
+#include "qml.h"
+#include "qfxpainteditem_p.h"
+#include "private/qlinecontrol_p.h"
+#include <QPointer>
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
QT_BEGIN_NAMESPACE
-QT_MODULE(Declarative)
-
-class QFxHighlightFilterPrivate;
-class Q_DECLARATIVE_EXPORT QFxHighlightFilter : public QSimpleCanvasFilter
+class QFxLineEditPrivate : public QFxPaintedItemPrivate
{
- Q_OBJECT
-
- Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(bool tiled READ tiled WRITE setTiled NOTIFY tiledChanged)
- Q_PROPERTY(int xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged)
- Q_PROPERTY(int yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged)
+ Q_DECLARE_PUBLIC(QFxLineEdit);
public:
- QFxHighlightFilter(QObject *parent=0);
- virtual ~QFxHighlightFilter();
-
- QUrl source() const;
- void setSource(const QUrl &);
-
- bool tiled() const;
- void setTiled(bool);
-
- int xOffset() const;
- void setXOffset(int);
- int yOffset() const;
- void setYOffset(int);
-
-Q_SIGNALS:
- void sourceChanged(const QUrl &);
- void offsetChanged(int x, int y);
- void tiledChanged(bool);
-
-private Q_SLOTS:
- void imageLoaded();
-
-protected:
- virtual void filterGL(QSimpleCanvasItem::GLPainter &p);
-
-private:
- QFxHighlightFilterPrivate *d;
+ QFxLineEditPrivate() : control(new QLineControl(QString())),
+ font(0), color((QRgb)0), style(QFxText::Normal),
+ styleColor((QRgb)0),
+ hAlign(QFxText::AlignLeft), vAlign(QFxText::AlignTop),
+ hscroll(0), oldScroll(0), focused(false)
+ {
+ }
+
+ ~QFxLineEditPrivate()
+ {
+ }
+
+ void init();
+ void startCreatingCursor();
+
+ QLineControl* control;
+
+ QmlFont *font;
+ QColor color;
+ QFxText::TextStyle style;
+ QColor styleColor;
+ QFxText::HAlignment hAlign;
+ QFxText::VAlignment vAlign;
+ QPointer<QmlComponent> cursorComponent;
+ QPointer<QFxItem> cursorItem;
+
+ int oldSelectLength;
+ int oldHeight;
+ int oldWidth;
+ bool oldValidity;
+ int hscroll;
+ int oldScroll;
+ bool focused;
};
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QFxHighlightFilter)
-
-QT_END_HEADER
+#endif
-#endif // QFXHIGHLIGHTFILTER_H
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 8b39773..50564fb 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -46,6 +46,7 @@
#include "qfxlistview.h"
#include <qmlexpression.h>
+#include <QKeyEvent>
QT_BEGIN_NAMESPACE
class QFxListViewAttached : public QObject
@@ -292,7 +293,7 @@ public:
}
return -1; // Not in visibleList
}
-
+
bool mapRangeFromModel(int &index, int &count) const {
if (index + count < visibleIndex)
return false;
diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h
index 6e9451e..2a70af0 100644
--- a/src/declarative/fx/qfxlistview.h
+++ b/src/declarative/fx/qfxlistview.h
@@ -55,7 +55,7 @@ class QFxListViewPrivate;
class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QFxListView)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxListView)
Q_ENUMS(CurrentItemPositioning)
Q_PROPERTY(QVariant model READ model WRITE setModel)
diff --git a/src/declarative/fx/qfxmouseregion.cpp b/src/declarative/fx/qfxmouseregion.cpp
index 6eb358b..af16d4d 100644
--- a/src/declarative/fx/qfxmouseregion.cpp
+++ b/src/declarative/fx/qfxmouseregion.cpp
@@ -173,28 +173,12 @@ void QFxDrag::setYmax(int m)
\qmlsignal MouseRegion::onEntered
This handler is called when the mouse enters the mouse region.
-
- \warning This handler is not yet implemented.
*/
/*!
\qmlsignal MouseRegion::onExited
This handler is called when the mouse exists the mouse region.
-
- \warning This handler is not yet implemented.
-*/
-
-/*!
- \qmlsignal MouseRegion::onReenteredWhilePressed
-
- This handler is called when the mouse reenters the mouse region while pressed.
-*/
-
-/*!
- \qmlsignal MouseRegion::onExitedWhilePressed
-
- This handler is called when the mouse exists the mouse region while pressed.
*/
/*!
@@ -322,10 +306,6 @@ void QFxMouseRegion::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (!d->absorb)
QFxItem::mousePressEvent(event);
else {
- if (!d->inside) {
- d->inside = true;
- emit hoveredChanged();
- }
d->longPress = false;
d->saveEvent(event);
d->dragX = drag()->axis().contains(QLatin1String("x"));
@@ -352,17 +332,13 @@ void QFxMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
d->saveEvent(event);
// ### we should skip this if these signals aren't used
+ // ### can GV handle this for us?
const QRect &bounds = itemBoundingRect();
bool contains = bounds.contains(d->lastPos.toPoint());
- if (d->inside && !contains) {
- d->inside = false;
- emit hoveredChanged();
- emit exitedWhilePressed();
- } else if (!d->inside && contains) {
- d->inside = true;
- emit hoveredChanged();
- emit reenteredWhilePressed();
- }
+ if (d->hovered && !contains)
+ setHovered(false);
+ else if (!d->hovered && contains)
+ setHovered(true);
if (drag()->target()) {
if (!d->moved) {
@@ -373,8 +349,8 @@ void QFxMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QPointF startLocalPos;
QPointF curLocalPos;
if (drag()->target()->parent()) {
- startLocalPos = drag()->target()->parent()->mapFromScene(d->startScene);
- curLocalPos = drag()->target()->parent()->mapFromScene(event->scenePos());
+ startLocalPos = drag()->target()->parentItem()->mapFromScene(d->startScene);
+ curLocalPos = drag()->target()->parentItem()->mapFromScene(event->scenePos());
} else {
startLocalPos = d->startScene;
curLocalPos = event->scenePos();
@@ -424,8 +400,6 @@ void QFxMouseRegion::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
else {
d->saveEvent(event);
setPressed(false);
- //d->inside = false;
- //emit hoveredChanged();
event->accept();
}
}
@@ -436,8 +410,6 @@ void QFxMouseRegion::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
if (!d->absorb)
QFxItem::mouseDoubleClickEvent(event);
else {
- //d->inside = true;
- //emit hoveredChanged();
d->saveEvent(event);
setPressed(true);
QFxMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, true, false);
@@ -453,7 +425,6 @@ void QFxMouseRegion::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
QFxItem::hoverEnterEvent(event);
else {
setHovered(true);
- emit entered();
}
}
@@ -464,7 +435,6 @@ void QFxMouseRegion::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
QFxItem::hoverLeaveEvent(event);
else {
setHovered(false);
- emit exited();
}
}
@@ -475,7 +445,6 @@ void QFxMouseRegion::mouseUngrabEvent()
// if our mouse grab has been removed (probably by Flickable), fix our
// state
d->pressed = false;
- //d->inside = false;
setKeepMouseGrab(false);
emit pressedChanged();
//emit hoveredChanged();
@@ -487,7 +456,7 @@ void QFxMouseRegion::timerEvent(QTimerEvent *event)
Q_D(QFxMouseRegion);
if (event->timerId() == d->pressAndHoldTimer.timerId()) {
d->pressAndHoldTimer.stop();
- if (d->pressed && d->dragged == false && d->inside == true) {
+ if (d->pressed && d->dragged == false && d->hovered == true) {
d->longPress = true;
QFxMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
emit pressAndHold(&me);
@@ -504,7 +473,7 @@ void QFxMouseRegion::timerEvent(QTimerEvent *event)
bool QFxMouseRegion::hovered()
{
Q_D(QFxMouseRegion);
- return d->hovered || d->inside;
+ return d->hovered;
}
/*!
@@ -523,13 +492,14 @@ void QFxMouseRegion::setHovered(bool h)
if (d->hovered != h) {
d->hovered = h;
emit hoveredChanged();
+ d->hovered ? emit entered() : emit exited();
}
}
void QFxMouseRegion::setPressed(bool p)
{
Q_D(QFxMouseRegion);
- bool isclick = d->pressed == true && p == false && d->dragged == false && d->inside == true;
+ bool isclick = d->pressed == true && p == false && d->dragged == false && d->hovered == true;
if (d->pressed != p) {
d->pressed = p;
diff --git a/src/declarative/fx/qfxmouseregion.h b/src/declarative/fx/qfxmouseregion.h
index 429ad00..47929be 100644
--- a/src/declarative/fx/qfxmouseregion.h
+++ b/src/declarative/fx/qfxmouseregion.h
@@ -129,8 +129,6 @@ Q_SIGNALS:
void doubleClicked(QFxMouseEvent *mouse);
void entered();
void exited();
- void exitedWhilePressed();
- void reenteredWhilePressed();
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
@@ -151,7 +149,7 @@ protected:
private:
Q_DISABLE_COPY(QFxMouseRegion)
- Q_DECLARE_PRIVATE(QFxMouseRegion)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxMouseRegion)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxmouseregion_p.h b/src/declarative/fx/qfxmouseregion_p.h
index e444bf2..a41f32a 100644
--- a/src/declarative/fx/qfxmouseregion_p.h
+++ b/src/declarative/fx/qfxmouseregion_p.h
@@ -66,7 +66,7 @@ class QFxMouseRegionPrivate : public QFxItemPrivate
public:
QFxMouseRegionPrivate()
- : absorb(true), hovered(false), inside(true), pressed(false), longPress(false), drag(0)
+ : absorb(true), hovered(false), pressed(false), longPress(false), drag(0)
{
}
@@ -74,7 +74,7 @@ public:
{
Q_Q(QFxMouseRegion);
q->setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton);
- q->setOptions(QSimpleCanvasItem::HoverEvents | QSimpleCanvasItem::MouseEvents);
+ q->setOptions(QFxItem::HoverEvents | QFxItem::MouseEvents);
}
void saveEvent(QGraphicsSceneMouseEvent *event) {
@@ -86,7 +86,6 @@ public:
bool absorb : 1;
bool hovered : 1;
- bool inside : 1;
bool pressed : 1;
bool longPress : 1;
bool moved : 1;
diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp
index 0a13dc4..7ff3361 100644
--- a/src/declarative/fx/qfxpainteditem.cpp
+++ b/src/declarative/fx/qfxpainteditem.cpp
@@ -48,11 +48,7 @@
#include <QEvent>
#include <QApplication>
#include <QGraphicsSceneMouseEvent>
-
-#if defined(QFX_RENDER_OPENGL2)
-#include <QtOpenGL/qglframebufferobject.h>
-#include <glsave.h>
-#endif
+#include <QPainter>
QT_BEGIN_NAMESPACE
@@ -210,26 +206,16 @@ void QFxPaintedItem::init()
connect(this,SIGNAL(visibleChanged()),this,SLOT(clearCache()));
}
-#if defined(QFX_RENDER_QPAINTER)
/*!
\reimp
*/
void QFxPaintedItem::paintContents(QPainter &p)
-#elif defined(QFX_RENDER_OPENGL)
-/*!
- \reimp
-*/
-void QFxPaintedItem::paintGLContents(GLPainter &p)
-#else
-#error "What render?"
-#endif
{
Q_D(QFxPaintedItem);
const QRect content(QPoint(0,0),d->contentsSize);
if (content.width() <= 0 || content.height() <= 0)
return;
-#if defined(QFX_RENDER_QPAINTER)
bool oldAntiAliasing = p.testRenderHint(QPainter::Antialiasing);
bool oldSmoothPixmap = p.testRenderHint(QPainter::SmoothPixmapTransform);
if (oldAntiAliasing)
@@ -242,29 +228,12 @@ void QFxPaintedItem::paintGLContents(GLPainter &p)
else
clipf = mapToScene(clipf);
-#elif defined(QFX_RENDER_OPENGL2)
- p.useTextureShader();
- const QRectF clipf = p.sceneClipRect;
-
-#elif defined(QFX_RENDER_OPENGL1)
- p.useTextureShader();
- const QRectF clipf = p.sceneClipRect;
-#endif
-
const QRect clip = mapFromScene(clipf).toRect();
QRegion topaint(clip);
topaint &= content;
QRegion uncached(content);
-#if defined(QFX_RENDER_OPENGL2)
- glEnableVertexAttribArray(SingleTextureShader::Vertices);
- glEnableVertexAttribArray(SingleTextureShader::TextureCoords);
-#elif defined(QFX_RENDER_OPENGL1)
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-#endif
-
int cachesize=0;
for (int i=0; i<d->imagecache.count(); ++i) {
QRect area = d->imagecache[i]->area;
@@ -312,29 +281,17 @@ void QFxPaintedItem::paintGLContents(GLPainter &p)
}
QFxPaintedItemPrivate::ImageCacheItem *newitem = new QFxPaintedItemPrivate::ImageCacheItem;
newitem->area = r;
-#if defined(QFX_RENDER_QPAINTER)
newitem->image = img;
-#else
- newitem->image.setImage(img.toImage());
-#endif
d->imagecache.append(newitem);
QRectF target(r.x(), r.y(), r.width(), r.height());
p.drawPixmap(target.toRect(), newitem->image);
}
}
-#if defined(QFX_RENDER_OPENGL2)
- glDisableVertexAttribArray(SingleTextureShader::Vertices);
- glDisableVertexAttribArray(SingleTextureShader::TextureCoords);
-#elif defined(QFX_RENDER_OPENGL1)
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-#endif
-#if defined(QFX_RENDER_QPAINTER)
+
if (oldAntiAliasing)
p.setRenderHints(QPainter::Antialiasing, oldAntiAliasing);
if (d->smooth)
p.setRenderHints(QPainter::SmoothPixmapTransform, oldSmoothPixmap);
-#endif
}
/*!
diff --git a/src/declarative/fx/qfxpainteditem.h b/src/declarative/fx/qfxpainteditem.h
index 7a0a9a9..e74ead0 100644
--- a/src/declarative/fx/qfxpainteditem.h
+++ b/src/declarative/fx/qfxpainteditem.h
@@ -66,11 +66,7 @@ public:
QFxPaintedItem(QFxItem *parent=0);
~QFxPaintedItem();
-#if defined(QFX_RENDER_QPAINTER)
void paintContents(QPainter &painter);
-#elif defined(QFX_RENDER_OPENGL)
- void paintGLContents(GLPainter &);
-#endif
bool isSmooth() const;
QSize contentsSize() const;
@@ -99,7 +95,7 @@ protected Q_SLOTS:
private:
void init();
Q_DISABLE_COPY(QFxPaintedItem)
- Q_DECLARE_PRIVATE(QFxPaintedItem)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxPaintedItem)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxpainteditem_p.h b/src/declarative/fx/qfxpainteditem_p.h
index 4e953a0..06e80ff 100644
--- a/src/declarative/fx/qfxpainteditem_p.h
+++ b/src/declarative/fx/qfxpainteditem_p.h
@@ -54,11 +54,6 @@
//
#include <private/qfxitem_p.h>
-#include <QtDeclarative/qsimplecanvas.h>
-
-#if defined(QFX_RENDER_OPENGL)
-#include "gltexture.h"
-#endif
QT_BEGIN_NAMESPACE
@@ -77,11 +72,7 @@ public:
~ImageCacheItem() { }
int age;
QRect area;
-#if defined(QFX_RENDER_QPAINTER)
QPixmap image;
-#else
- GLTexture image;
-#endif
};
QList<ImageCacheItem*> imagecache;
diff --git a/src/declarative/fx/qfxpath.cpp b/src/declarative/fx/qfxpath.cpp
index 4c241d3..a1b6032 100644
--- a/src/declarative/fx/qfxpath.cpp
+++ b/src/declarative/fx/qfxpath.cpp
@@ -43,6 +43,7 @@
#include "qfxpath_p.h"
#include <private/qfxperf_p.h>
#include <private/qbezier_p.h>
+#include <QSet>
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp
index 625d778..f940f68 100644
--- a/src/declarative/fx/qfxpathview.cpp
+++ b/src/declarative/fx/qfxpathview.cpp
@@ -489,6 +489,7 @@ void QFxPathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *)
d->lastPosTime = QTime();
d->stealMouse = false;
+ ungrabMouse();
}
bool QFxPathView::sendMouseEvent(QGraphicsSceneMouseEvent *event)
@@ -524,8 +525,8 @@ bool QFxPathView::sendMouseEvent(QGraphicsSceneMouseEvent *event)
break;
}
grabber = static_cast<QFxItem*>(mouseGrabberItem());
- if (grabber && d->stealMouse && !grabber->keepMouseGrab())
- mouseGrabberItem()->ungrabMouse();
+ if (grabber && d->stealMouse && !grabber->keepMouseGrab() && grabber != this)
+ grabMouse();
return d->stealMouse;
} else if (!d->lastPosTime.isNull()) {
diff --git a/src/declarative/fx/qfxpathview.h b/src/declarative/fx/qfxpathview.h
index 159c865..9d91006 100644
--- a/src/declarative/fx/qfxpathview.h
+++ b/src/declarative/fx/qfxpathview.h
@@ -125,7 +125,7 @@ private:
friend class QFxPathViewAttached;
static QHash<QObject*, QObject*> attachedProperties;
Q_DISABLE_COPY(QFxPathView)
- Q_DECLARE_PRIVATE(QFxPathView)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxPathView)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxpathview_p.h b/src/declarative/fx/qfxpathview_p.h
index b77c2a0..63c8224 100644
--- a/src/declarative/fx/qfxpathview_p.h
+++ b/src/declarative/fx/qfxpathview_p.h
@@ -87,7 +87,7 @@ public:
Q_Q(QFxPathView);
_offset = 0;
q->setAcceptedMouseButtons(Qt::NoButton);
- q->setOptions(QSimpleCanvasItem::MouseFilter | QSimpleCanvasItem::MouseEvents | QSimpleCanvasItem::IsFocusRealm);
+ q->setOptions(QFxItem::ChildMouseFilter | QFxItem::MouseEvents | QFxItem::IsFocusRealm);
q->connect(&tl, SIGNAL(updated()), q, SLOT(ticked()));
}
diff --git a/src/declarative/fx/qfxpixmap.cpp b/src/declarative/fx/qfxpixmap.cpp
index 5ee6528..ac8a701 100644
--- a/src/declarative/fx/qfxpixmap.cpp
+++ b/src/declarative/fx/qfxpixmap.cpp
@@ -46,6 +46,7 @@
#include <private/qfxperf_p.h>
#include <QtDeclarative/qmlengine.h>
#include <QFile>
+#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
class QSharedNetworkReply;
diff --git a/src/declarative/fx/qfxpixmap.h b/src/declarative/fx/qfxpixmap.h
index ae693c1..f63299b 100644
--- a/src/declarative/fx/qfxpixmap.h
+++ b/src/declarative/fx/qfxpixmap.h
@@ -44,9 +44,8 @@
#include <QtCore/QString>
#include <QtGui/QPixmap>
-#include <QtDeclarative/qsimplecanvas.h>
#include <QtDeclarative/qfxglobal.h>
-
+#include <QtCore/qurl.h>
QT_BEGIN_HEADER
diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp
index b521d00..32d3eb4 100644
--- a/src/declarative/fx/qfxrect.cpp
+++ b/src/declarative/fx/qfxrect.cpp
@@ -42,6 +42,7 @@
#include "qfxrect.h"
#include "qfxrect_p.h"
+#include <QPainter>
QT_BEGIN_NAMESPACE
QML_DEFINE_TYPE(QFxPen,Pen)
@@ -251,17 +252,8 @@ QFxRect::QFxRect(QFxRectPrivate &dd, QFxItem *parent)
void QFxRect::doUpdate()
{
-#if defined(QFX_RENDER_QPAINTER)
Q_D(QFxRect);
d->rectImage = QPixmap();
-#endif
-#if defined(QFX_RENDER_OPENGL)
- Q_D(QFxRect);
- if (d->rectTexture) {
- d->rectTexture->release();
- d->rectTexture = 0;
- }
-#endif
const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
setPaintMargin((pw+1)/2);
update();
@@ -340,7 +332,7 @@ void QFxRect::setGradient(QFxGradient *gradient)
This property holds the corner radius used to draw a rounded rect.
If radius is non-zero, the rect will be painted as a rounded rectangle, otherwise it will be
- painted as a normal rectangle. The same radius is used by all 4 corners; there is currently
+ painted as a normal rectangle. The same radius is used by all 4 corners; there is currently
no way to specify different radii for different corners.
*/
@@ -361,25 +353,10 @@ void QFxRect::setRadius(qreal radius)
return;
d->radius = radius;
-#if defined(QFX_RENDER_QPAINTER)
d->rectImage = QPixmap();
-#elif defined(QFX_RENDER_OPENGL)
- if (d->rectTexture) {
- d->rectTexture->release();
- d->rectTexture = 0;
- }
-#endif
update();
}
-void QFxRect::dump(int depth)
-{
- Q_D(QFxRect);
- QByteArray ba(depth * 4, ' ');
- qWarning() << ba.constData() << "QFxRect:" << d->color;
- QFxItem::dump(depth);
-}
-
/*!
\qmlproperty color Rect::color
This property holds the color used to fill the rect.
@@ -412,15 +389,7 @@ void QFxRect::setColor(const QColor &c)
return;
d->color = c;
-#if defined(QFX_RENDER_QPAINTER)
d->rectImage = QPixmap();
-#endif
-#if defined(QFX_RENDER_OPENGL)
- if (d->rectTexture) {
- d->rectTexture->release();
- d->rectTexture = 0;
- }
-#endif
update();
}
@@ -488,7 +457,6 @@ QColor QFxRectPrivate::getColor()
}
-#if defined(QFX_RENDER_QPAINTER)
void QFxRect::generateRoundedRect()
{
Q_D(QFxRect);
@@ -535,72 +503,7 @@ void QFxRect::generateBorderedRect()
p.drawRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw));
}
}
-#elif defined(QFX_RENDER_OPENGL)
-void QFxRect::generateRoundedRect()
-{
- Q_D(QFxRect);
- if (!d->rectTexture) {
- const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
- QString key = QString("QFxRect://r_%1_%2_%3_%4").arg(pw).arg(d->radius).arg((d->pen && d->pen->isValid())?d->pen->color().name():QString()).arg(d->color.name());
-
- d->rectTexture = cachedTexture(key);
-
- if (!d->rectTexture) {
- QPixmap roundRect(d->radius*2 + 4 + pw*2, d->radius*2 + 4 + pw*2);
- roundRect.fill(Qt::transparent);
- QPainter p(&roundRect);
- p.setRenderHint(QPainter::Antialiasing);
- if (d->pen && d->pen->isValid()) {
- QPen pn(QColor(pen()->color()), pen()->width());
- p.setPen(pn);
- } else {
- p.setPen(Qt::NoPen);
- }
- p.setBrush(d->color);
- if (pw%2)
- p.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, roundRect.width()-(pw+1), roundRect.height()-(pw+1)), d->radius, d->radius);
- else
- p.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, roundRect.width()-pw, roundRect.height()-pw), d->radius, d->radius);
-
- d->rectTexture = cachedTexture(key, roundRect);
- }
- }
-}
-
-void QFxRect::generateBorderedRect()
-{
- Q_D(QFxRect);
- if (!d->rectTexture) {
- const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0;
- QString key = QString("QFxRect://b_%1_%2_%3_%4").arg(pw).arg(d->radius).arg((d->pen && d->pen->isValid())?d->pen->color().name():QString()).arg(d->color.name());
-
- d->rectTexture = cachedTexture(key);
-
- if (!d->rectTexture) {
- QPixmap borderedRect(pw*2 + 4, pw*2 + 4);
- borderedRect.fill(Qt::transparent);
- QPainter p(&(borderedRect));
- p.setRenderHint(QPainter::Antialiasing);
- if (d->pen && d->pen->isValid()) {
- QPen pn(QColor(pen()->color()), pen()->width());
- pn.setJoinStyle(Qt::MiterJoin);
- p.setPen(pn);
- } else {
- p.setPen(Qt::NoPen);
- }
- p.setBrush(d->color);
- if (pw%2)
- p.drawRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, borderedRect.width()-(pw+1), borderedRect.height()-(pw+1)));
- else
- p.drawRect(QRectF(qreal(pw)/2, qreal(pw)/2, borderedRect.width()-pw, borderedRect.height()-pw));
- d->rectTexture = cachedTexture(key, borderedRect);
- }
- }
-}
-#endif
-
-#if defined(QFX_RENDER_QPAINTER)
void QFxRect::paintContents(QPainter &p)
{
Q_D(QFxRect);
@@ -689,7 +592,7 @@ void QFxRect::drawRect(QPainter &p)
if (yMiddles)
p.drawPixmap(QRect(width()-xOffset+pw/2, yOffset-pw/2, xOffset, height() - ySide + pw), d->rectImage,
QRect(d->rectImage.width()-xOffset, d->rectImage.height()/2, xOffset, 1));
- // Lower left
+ // Lower left
p.drawPixmap(QPoint(-pw/2, height() - yOffset + pw/2), d->rectImage, QRect(0, d->rectImage.height() - yOffset, xOffset, yOffset));
// Lower Middle
@@ -701,258 +604,5 @@ void QFxRect::drawRect(QPainter &p)
QRect(d->rectImage.width()-xOffset, d->rectImage.height() - yOffset, xOffset, yOffset));
}
}
-#endif
-
-#if defined(QFX_RENDER_OPENGL2)
-#include "glbasicshaders.h"
-
-void QFxRect::paintGLContents(GLPainter &p)
-{
- Q_D(QFxRect);
- if (d->radius == 0 && (!d->pen || !d->pen->isValid())) {
- if (d->gradient) {
- float widthV = width();
- float heightV = height();
-
- GLfloat vertices[] = { 0, heightV,
- widthV, heightV,
- 0, 0,
- widthV, 0 };
-
- int count = d->gradient->stops()->size();
- GLfloat colors[count*8];
- for (int i = 0; i < count; i += 8) {
- QFxGradientStop *g = d->gradient->stops()->at(i);
- QColor c = g->color();
- colors[i] = c.redF(); colors[i+4] = colors[i];
- colors[i+1] = c.greenF(); colors[i+5] = colors[i+1];
- colors[i+2] = c.blueF(); colors[i+6] = colors[i+2];
- colors[i+3] = c.alphaF() * p.activeOpacity; colors[i+7] = colors[i+3];
- }
-
- p.invalidate();
- ColorShader *shader = basicShaders()->color();
- shader->enable();
- shader->setTransform(p.activeTransform);
-
- shader->setAttributeArray(ColorShader::Vertices, vertices, 2);
- shader->setAttributeArray(ColorShader::Colors, colors, 4);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, count*2);
- shader->disableAttributeArray(ColorShader::Vertices);
- shader->disableAttributeArray(ColorShader::Colors);
- } else {
-
- p.fillRect(QRectF(0, 0, width(), height()), d->getColor());
-
- }
- } else {
- qreal offset = 0;
- qreal pw = d->pen && d->pen->isValid() ? d->pen->width() : 0.0;
-
- if (d->radius > 0) {
- generateRoundedRect();
- offset = d->radius + pw+1.5;
- } else {
- generateBorderedRect();
- offset = pw+1.5;
- }
-
- QGLShaderProgram *shader = p.useTextureShader();
-
- float texWidth = d->rectTexture->width();
- float texHeight = d->rectTexture->height();
- if (!texWidth || !texHeight)
- return;
-
- float widthV = qreal(width())+pw/2;
- float heightV = qreal(height())+pw/2;
-
- float xOffset = offset;
- bool xMiddles = true;
- if (xOffset*2 > width()+pw) {
- xMiddles = false;
- xOffset = (width()+pw)/2;
- }
- float yOffset = offset;
- bool yMiddles = true;
- if (yOffset*2 > height()+pw) {
- yMiddles = false;
- yOffset = (height()+pw)/2;
- }
-
- float texleft = xOffset / texWidth;
- float imgleft = xOffset-pw/2;
- float texright = (texWidth-xOffset) / texWidth;
- float imgright = widthV - xOffset;
-
- float textop = yOffset / texHeight;
- float imgtop = yOffset-pw/2;
- float texbottom = (texHeight-yOffset) / texHeight;
- float imgbottom = heightV - yOffset;
-
- //Bug 231768: Inappropriate interpolation was occuring on 3x3 textures
- if (offset==1)
- texleft=texright=textop=texbottom=0.5;
-
- texleft *= d->rectTexture->glWidth();
- texright *= d->rectTexture->glWidth();
- textop *= d->rectTexture->glHeight();
- texbottom *= d->rectTexture->glHeight();
-
- float vert1[] = { -pw/2, -pw/2,
- -pw/2, imgtop,
- imgleft, -pw/2,
-
- -pw/2, imgtop,
- imgleft, -pw/2,
- imgleft, imgtop,
-
- imgleft, -pw/2,
- imgleft, imgtop,
- imgright, -pw/2,
-
- imgleft, imgtop,
- imgright, -pw/2,
- imgright, imgtop,
-
- imgright, -pw/2,
- imgright, imgtop,
- widthV, -pw/2,
-
- imgright, imgtop,
- widthV, -pw/2,
- widthV, imgtop,
-
- -pw/2, heightV,
- -pw/2, imgbottom,
- imgleft, heightV,
-
- -pw/2, imgbottom,
- imgleft, heightV,
- imgleft, imgbottom,
-
- imgleft, heightV,
- imgleft, imgbottom,
- imgright, heightV,
-
- imgleft, imgbottom,
- imgright, heightV,
- imgright, imgbottom,
-
- imgright, heightV,
- imgright, imgbottom,
- widthV, heightV,
-
- imgright, imgbottom,
- widthV, heightV,
- widthV, imgbottom,
-
- -pw/2, imgtop,
- -pw/2, imgbottom,
- imgleft, imgtop,
-
- -pw/2, imgbottom,
- imgleft, imgtop,
- imgleft, imgbottom,
-
- imgleft, imgtop,
- imgleft, imgbottom,
- imgright, imgtop,
-
- imgleft, imgbottom,
- imgright, imgtop,
- imgright, imgbottom,
-
- imgright, imgtop,
- imgright, imgbottom,
- widthV, imgtop,
-
- imgright, imgbottom,
- widthV, imgtop,
- widthV, imgbottom };
-
-
- float tex1[] = { 0, 0,
- 0, textop,
- texleft, 0,
-
- 0, textop,
- texleft, 0,
- texleft, textop,
-
- texleft, 0,
- texleft, textop,
- texright, 0,
-
- texleft, textop,
- texright, 0,
- texright, textop,
-
- texright, 0,
- texright, textop,
- d->rectTexture->glWidth(), 0,
-
- texright, textop,
- d->rectTexture->glWidth(), 0,
- d->rectTexture->glWidth(), textop,
-
- 0, d->rectTexture->glHeight(),
- 0, texbottom,
- texleft, d->rectTexture->glHeight(),
-
- 0, texbottom,
- texleft, d->rectTexture->glHeight(),
- texleft, texbottom,
-
- texleft, d->rectTexture->glHeight(),
- texleft, texbottom,
- texright, d->rectTexture->glHeight(),
-
- texleft, texbottom,
- texright, d->rectTexture->glHeight(),
- texright, texbottom,
-
- texright, d->rectTexture->glHeight(),
- texright, texbottom,
- d->rectTexture->glWidth(), d->rectTexture->glHeight(),
-
- texright, texbottom,
- d->rectTexture->glWidth(), d->rectTexture->glHeight(),
- d->rectTexture->glWidth(), texbottom,
-
- 0, textop,
- 0, texbottom,
- texleft, textop,
-
- 0, texbottom,
- texleft, textop,
- texleft, texbottom,
-
- texleft, textop,
- texleft, texbottom,
- texright, textop,
-
- texleft, texbottom,
- texright, textop,
- texright, texbottom,
-
- texright, textop,
- texright, texbottom,
- d->rectTexture->glWidth(), textop,
-
- texright, texbottom,
- d->rectTexture->glWidth(), textop,
- d->rectTexture->glWidth(), texbottom };
-
-
-
- glBindTexture(GL_TEXTURE_2D, d->rectTexture->texture());
-
- shader->setAttributeArray(SingleTextureShader::Vertices, vert1, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, tex1, 2);
- glDrawArrays(GL_TRIANGLES, 0, 36 + (yMiddles?18:0));
- }
-}
-#endif
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxrect.h b/src/declarative/fx/qfxrect.h
index 2b35d8d..7790af1 100644
--- a/src/declarative/fx/qfxrect.h
+++ b/src/declarative/fx/qfxrect.h
@@ -43,6 +43,7 @@
#define QFXRECT_H
#include <QtDeclarative/qfxitem.h>
+#include <QtGui/qbrush.h>
QT_BEGIN_HEADER
@@ -156,14 +157,7 @@ public:
qreal radius() const;
void setRadius(qreal radius);
- virtual void dump(int depth);
-#if defined(QFX_RENDER_QPAINTER)
void paintContents(QPainter &painter);
-#endif
-
-#if defined(QFX_RENDER_OPENGL)
- void paintGLContents(GLPainter &);
-#endif
private Q_SLOTS:
void doUpdate();
@@ -179,7 +173,7 @@ protected:
private:
Q_DISABLE_COPY(QFxRect)
- Q_DECLARE_PRIVATE(QFxRect)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxRect)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxrect_p.h b/src/declarative/fx/qfxrect_p.h
index 23bb944..3544d36 100644
--- a/src/declarative/fx/qfxrect_p.h
+++ b/src/declarative/fx/qfxrect_p.h
@@ -55,10 +55,6 @@
#include "qfxitem_p.h"
-#if defined(QFX_RENDER_OPENGL)
-#include "gltexture.h"
-#endif
-
QT_BEGIN_NAMESPACE
class QFxGradient;
@@ -69,9 +65,6 @@ class QFxRectPrivate : public QFxItemPrivate
public:
QFxRectPrivate() :
-#if defined(QFX_RENDER_OPENGL)
- rectTexture(0),
-#endif //QFX_RENDER_OPENGL
color(Qt::white), gradient(0), pen(0), radius(0)
{
}
@@ -85,9 +78,6 @@ public:
{
}
-#if defined(QFX_RENDER_OPENGL)
- QSimpleCanvasItem::CachedTexture *rectTexture;
-#endif
QColor getColor();
QColor color;
QFxGradient *gradient;
diff --git a/src/declarative/fx/qfxreflectionfilter.cpp b/src/declarative/fx/qfxreflectionfilter.cpp
deleted file mode 100644
index c66deb7..0000000
--- a/src/declarative/fx/qfxreflectionfilter.cpp
+++ /dev/null
@@ -1,352 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfxreflectionfilter.h"
-
-#if defined(QFX_RENDER_OPENGL2)
-#include <glsave.h>
-#include <QtOpenGL/qglframebufferobject.h>
-#include <glbasicshaders.h>
-#include <gltexture.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-class QFxReflectionFilterPrivate
-{
-public:
- QFxReflectionFilterPrivate()
- : alpha(1), height(-1), offset(0), scale(1)
- {
- }
- qreal alpha;
- int height;
- int offset;
- qreal scale;
-};
-
-/*!
- \qmlclass Reflection
- \inherits Filter
- \brief The Reflection filter reflects an item and its contents.
-
- Here is an example of various Reflections applied to an image.
-
- \qml
-HorizontalLayout {
- Image {
- source: "icon.png"
- filter: Reflection { }
- }
- Image {
- source: "icon.png"
- filter: Reflection { offset: 1 }
- }
- Image {
- source: "icon.png"
- filter: Reflection { offset: 1; alpha: 0.5 }
- }
- Image {
- source: "icon.png"
- filter: Reflection { offset: 1; alpha: 0.5; height: 50 }
- }
- Image {
- source: "icon.png"
- filter: Reflection { offset: 1; alpha: 0.5; height: 50; scale: 0.5 }
- }
-}
- \endqml
-
- \image reflection_example.png
-
- Reflection is only supported when Qt Declarative is compiled for OpenGL ES 2.0.
- Otherwise the Reflection filter has no effect.
-*/
-
-/*!
- \internal
- \class QFxReflectionFilter
- \ingroup group_effects
- \brief The QFxReflectionFilter class allows you to add a reflection to an item.
-*/
-QFxReflectionFilter::QFxReflectionFilter(QObject *parent)
-: QSimpleCanvasFilter(parent), d(new QFxReflectionFilterPrivate)
-{
-}
-
-QFxReflectionFilter::~QFxReflectionFilter()
-{
- delete d; d = 0;
-}
-
-/*!
- \property QFxReflectionFilter::alpha
- \brief the starting opacity of the reflection.
-
- The starting opacity is the opacity closest to the item. The opacity will fade
- from this value to zero over the height of the reflection.
-*/
-qreal QFxReflectionFilter::alpha() const
-{
- return d->alpha;
-}
-
-void QFxReflectionFilter::setAlpha(qreal a)
-{
- if (d->alpha == a) return;
- d->alpha = a;
- emit alphaChanged(a);
- update();
-}
-
-/*!
- \qmlproperty int Reflection::height
-
- The height property controls how much of the item, in pixels, to reflect.
- If it is set to the default value of -1, the whole item is reflected. If
- it is set to 50, the bottom 50 pixels of the item are reflected. Data
- binding could be used to reflect a percentage of the item.
-
- \qml
-Image {
- id: myImage
- source: "album.png"
- filter: Reflection {
- height: myImage.height * 0.5
- }
-}
- \endqml
- */
-/*!
- \qmlproperty int Reflection::offset
-
- The offset controls how far from the base of the item, in pixels, the
- start of the reflection is placed. This can be used to create a nice
- sliver of space between the item and its reflection or for more advanced
- effects.
-
- The default offset is 0 pixels.
-*/
-
-/*!
- \qmlproperty real Reflection::alpha
-
- The alpha value controls the starting opacity of the reflected item. If
- set to the default value of 1, the reflected item starts completely opaque
- and gradually fades to completely transparent. If set to less than one, the
- reflection starts out partially transparent as though the item was sitting
- on a visually less reflective surface.
-
- Valid values are from 0 (which would be silly, but is allowed) to 1.
-*/
-/*!
- \qmlproperty real Reflection::scale
-
- When set to the default value of 1, the reflection is a 1:1 reflection of
- the item. That is, each horizontal pixel in the item corresponds to one
- horizontal pixel in the reflection.
-
- When set a value other than 1, the reflection is scaled acordingly - less
- than 1 scales it down and greater than 1 scales it up. The scale is applied
- after the height parameter and does not effect the reflection offset.
-*/
-
-/*!
- \property QFxReflectionFilter::height
- \brief the height of the reflection, in pixels.
-*/
-int QFxReflectionFilter::height() const
-{
- return d->height;
-}
-
-void QFxReflectionFilter::setHeight(int h)
-{
- if (d->height == h) return;
- d->height = h;
- emit heightChanged(h);
- update();
-}
-
-/*!
- \property QFxReflectionFilter::offset
- \brief the distance of the reflection from the item, in pixels.
-*/
-int QFxReflectionFilter::offset()
-{
- return d->offset;
-}
-
-void QFxReflectionFilter::setOffset(int o)
-{
- if (d->offset == o) return;
- d->offset = o;
- emit offsetChanged(o);
- update();
-}
-
-/*!
- \property QFxReflectionFilter::scale
- \brief the scale of the reflection relative to the item.
-*/
-qreal QFxReflectionFilter::scale() const
-{
- return d->scale;
-}
-
-void QFxReflectionFilter::setScale(qreal s)
-{
- if (d->scale == s) return;
- d->scale = s;
- emit scaleChanged(s);
- update();
-}
-
-static inline float floatmin(float a, float b)
-{
- return (a < b)?a:b;
-}
-
-void QFxReflectionFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
-{
-#if defined(QFX_RENDER_OPENGL2)
- QSimpleCanvasItem *item = this->item();
-
- QRect r = item->itemBoundingRect();
- if (r.isEmpty())
- return;
- float width = r.width();
- float height = r.height();
-
- float refHeight = height;
- if (d->height > 0)
- refHeight = floatmin(height, d->height);
-
- QSimpleCanvas::Matrix simpMat;
- QSimpleCanvasItem *simpItem = 0;
- if (isSimpleItem(&simpItem, &simpMat) &&
- simpItem->glSimpleItemData(0, 0, 0, 0)) {
-
- GLfloat vertices[8];
- GLfloat texVertices[8];
- GLTexture *texture = 0;
-
- simpItem->glSimpleItemData(vertices, texVertices, &texture, 8);
-
- GLfloat opacity[4];
-
- float invRefHeight = 1. / refHeight;
- for (int ii = 0; ii < 4; ++ii) {
- float vertex = vertices[ii * 2 + 1];
- float o = (1. - (height - vertex) * invRefHeight);
- opacity[ii] = o * d->alpha * p.activeOpacity;
- }
-
- QSimpleCanvas::Matrix trans = p.activeTransform;
- trans.rotate(180, 1, 0, 0);
- trans.translate(0, -r.height() - d->offset);
- if (d->scale != 1)
- trans.scale(1, d->scale, 1);
- trans.translate(0, -r.height());
- trans *= simpMat;
-
- glBindTexture(GL_TEXTURE_2D, texture->texture());
-
- SingleTextureVertexOpacityShader *shader =
- item->basicShaders()->singleTextureVertexOpacity();
- shader->enable();
- shader->setTransform(trans);
- shader->setAttributeArray(SingleTextureVertexOpacityShader::Vertices, vertices, 2);
- shader->setAttributeArray(SingleTextureVertexOpacityShader::TextureCoords, texVertices, 2);
- shader->setAttributeArray(SingleTextureVertexOpacityShader::OpacityCoords, opacity, 1);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- shader->disableAttributeArray(SingleTextureVertexOpacityShader::Vertices);
- shader->disableAttributeArray(SingleTextureVertexOpacityShader::TextureCoords);
- shader->disableAttributeArray(SingleTextureVertexOpacityShader::OpacityCoords);
-
- } else {
- QGLFramebufferObject *fbo = renderToFBO();
-
- float texWidth = width / float(fbo->width());
- float texHeight = refHeight / float(fbo->height());
-
- GLfloat invVertices[] = { width, height + d->scale * refHeight + d->offset,
- 0, height + d->scale * refHeight + d->offset,
- width, height + d->offset,
- 0, height + d->offset };
- GLfloat invTexVertices[] = { texWidth, texHeight,
- 0, texHeight,
- texWidth, 0,
- 0, 0 };
- GLfloat invOpacity[] = { 0, 0, d->alpha * p.activeOpacity, d->alpha * p.activeOpacity};
-
- glBindTexture(GL_TEXTURE_2D, fbo->texture());
-
- SingleTextureVertexOpacityShader *shader =
- item->basicShaders()->singleTextureVertexOpacity();
- shader->enable();
- shader->setTransform(p.activeTransform);
- shader->setAttributeArray(SingleTextureVertexOpacityShader::Vertices, invVertices, 2);
- shader->setAttributeArray(SingleTextureVertexOpacityShader::TextureCoords, invTexVertices, 2);
- shader->setAttributeArray(SingleTextureVertexOpacityShader::OpacityCoords, invOpacity, 1);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- shader->disableAttributeArray(SingleTextureVertexOpacityShader::Vertices);
- shader->disableAttributeArray(SingleTextureVertexOpacityShader::TextureCoords);
- shader->disableAttributeArray(SingleTextureVertexOpacityShader::OpacityCoords);
-
- releaseFBO(fbo);
- }
-
- renderToScreen();
-
-#else
- Q_UNUSED(p);
-#endif
-}
-
-QRectF QFxReflectionFilter::itemBoundingRect(const QRectF &r) const
-{
- QRectF rv = r;
- rv |= r.translated(0, r.height() + d->offset);
- return rv;
-}
-
-QML_DEFINE_TYPE(QFxReflectionFilter,Reflection)
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxreflectionfilter.h b/src/declarative/fx/qfxreflectionfilter.h
deleted file mode 100644
index d862040..0000000
--- a/src/declarative/fx/qfxreflectionfilter.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFXREFLECTIONFILTER_H
-#define QFXREFLECTIONFILTER_H
-
-#include <QtDeclarative/qsimplecanvasfilter.h>
-#include <QtDeclarative/qml.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QFxReflectionFilterPrivate;
-class Q_DECLARATIVE_EXPORT QFxReflectionFilter : public QSimpleCanvasFilter
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal alpha READ alpha WRITE setAlpha NOTIFY alphaChanged)
- Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
- Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged)
- Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
-public:
- QFxReflectionFilter(QObject *parent=0);
- virtual ~QFxReflectionFilter();
-
- qreal alpha() const;
- void setAlpha(qreal);
- int height() const;
- void setHeight(int);
- int offset();
- void setOffset(int);
- qreal scale() const;
- void setScale(qreal);
-
-Q_SIGNALS:
- void alphaChanged(qreal);
- void heightChanged(int);
- void offsetChanged(int);
- void scaleChanged(qreal);
-
-protected:
- virtual void filterGL(QSimpleCanvasItem::GLPainter &p);
- virtual QRectF itemBoundingRect(const QRectF &r) const;
-
-private:
- Q_DISABLE_COPY(QFxReflectionFilter)
- QFxReflectionFilterPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QFxReflectionFilter)
-
-QT_END_HEADER
-
-#endif // QFXREFLECTIONFILTER_H
diff --git a/src/declarative/fx/qfxrepeater.cpp b/src/declarative/fx/qfxrepeater.cpp
index 0211ebb..a4dc809 100644
--- a/src/declarative/fx/qfxrepeater.cpp
+++ b/src/declarative/fx/qfxrepeater.cpp
@@ -57,12 +57,13 @@ QFxRepeaterPrivate::~QFxRepeaterPrivate()
QFxItem *QFxRepeaterPrivate::addItem(QmlContext *ctxt, QFxItem *lastItem)
{
+ Q_UNUSED(lastItem)
Q_Q(QFxRepeater);
QObject *nobj = component->create(ctxt);
QFxItem *item = qobject_cast<QFxItem *>(nobj);
if (item) {
item->setParent(q->itemParent());
- item->stackUnder(lastItem);
+// item->stackUnder(lastItem);
deletables << nobj;
} else {
delete nobj;
@@ -243,7 +244,7 @@ void QFxRepeater::componentComplete()
/*!
\internal
*/
-void QFxRepeater::parentChanged(QSimpleCanvasItem *o, QSimpleCanvasItem *n)
+void QFxRepeater::parentChanged(QFxItem *o, QFxItem *n)
{
QFxItem::parentChanged(o, n);
regenerate();
diff --git a/src/declarative/fx/qfxrepeater.h b/src/declarative/fx/qfxrepeater.h
index b82b9b0..6f950d3 100644
--- a/src/declarative/fx/qfxrepeater.h
+++ b/src/declarative/fx/qfxrepeater.h
@@ -73,12 +73,12 @@ private:
protected:
virtual void componentComplete();
- virtual void parentChanged(QSimpleCanvasItem *, QSimpleCanvasItem *);
+ virtual void parentChanged(QFxItem *, QFxItem *);
QFxRepeater(QFxRepeaterPrivate &dd, QFxItem *parent);
private:
Q_DISABLE_COPY(QFxRepeater)
- Q_DECLARE_PRIVATE(QFxRepeater)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxRepeater)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxscalegrid.h b/src/declarative/fx/qfxscalegrid.h
index 03b2dd3..986bcda 100644
--- a/src/declarative/fx/qfxscalegrid.h
+++ b/src/declarative/fx/qfxscalegrid.h
@@ -45,7 +45,6 @@
#include <QtCore/QString>
#include <QtCore/QObject>
#include <QtDeclarative/qfxglobal.h>
-#include <QtDeclarative/qsimplecanvas.h>
#include <QtDeclarative/qfxpixmap.h>
#include <QtDeclarative/qml.h>
diff --git a/src/declarative/fx/qfxshadowfilter.cpp b/src/declarative/fx/qfxshadowfilter.cpp
deleted file mode 100644
index d37d565..0000000
--- a/src/declarative/fx/qfxshadowfilter.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfxshadowfilter.h"
-
-#if defined(QFX_RENDER_OPENGL2)
-#include <glsave.h>
-#include <QtOpenGL/qglframebufferobject.h>
-#include <glbasicshaders.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QFxShadowFilterPrivate
-{
-public:
- QFxShadowFilterPrivate()
- : x(0), y(0)
- {
- }
-
- int x;
- int y;
-};
-
-/*!
- \qmlclass Shadow
- \brief The Shadow filter casts a drop shadow.
- \inherits Filter
-
- Shadows work on all visual elements - including transparent and masked
- images.
-
- \table
- \row
- \o \image shadow_example.png
- \o
- \qml
-Rect {
- radius: 5
- color: "lightsteelblue"
- width: 100
- height: 100
- filter: Shadow {
- yOffset: 8
- xOffset: 8
- }
-}
-
-Image {
- source: "pics/qtlogo.png"
- filter: Shadow {
- yOffset: 8
- xOffset: 8
- }
-}
- \endqml
- \endtable
-
- Shadows are only supported when Qt Qt Declarative is compiled for OpenGL ES 2.0.
- Otherwise the Shadow filter has no effect.
-*/
-
-/*!
- \internal
- \class QFxShadowFilter
- \ingroup group_effects
- \brief The QFxShadowFilter class allows you to add a shadow to an item.
-*/
-
-QFxShadowFilter::QFxShadowFilter(QObject *parent)
-: QSimpleCanvasFilter(parent), d(new QFxShadowFilterPrivate)
-{
-}
-
-QFxShadowFilter::~QFxShadowFilter()
-{
- delete d; d = 0;
-}
-
-/*!
- \qmlproperty int Shadow::xOffset
- \qmlproperty int Shadow::yOffset
-
- Specify the x and y offset of the shadow relative to the item.
-*/
-
-int QFxShadowFilter::xOffset() const
-{
- return d->x;
-}
-
-/*!
- \property QFxShadowFilter::xOffset
- \brief the x offset of the shadow relative to the item.
-*/
-void QFxShadowFilter::setXOffset(int offset)
-{
- if (d->x == offset) return;
- d->x = offset;
- emit offsetChanged(d->x, d->y);
-}
-
-/*!
- \property QFxShadowFilter::yOffset
- \brief the y offset of the shadow relative to the item.
-*/
-int QFxShadowFilter::yOffset() const
-{
- return d->y;
-}
-
-void QFxShadowFilter::setYOffset(int offset)
-{
- if (d->y == offset) return;
- d->y = offset;
- emit offsetChanged(d->x, d->y);
-}
-
-QRectF QFxShadowFilter::itemBoundingRect(const QRectF &r) const
-{
- QRectF rv = r;
- rv |= r.translated(xOffset(), yOffset());
- return rv;
-}
-
-void QFxShadowFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
-{
-#if defined(QFX_RENDER_OPENGL2)
-
- QSimpleCanvasItem *item = this->item();
-
- QRect r = item->itemBoundingRect();
-
- QGLFramebufferObject *fbo = renderToFBO();
-
- float width = r.width();
- float height = r.height();
-
- float texWidth = width / float(fbo->width());
- float texHeight = height / float(fbo->height());
-
- GLfloat vertices[] = { d->x, height + d->y,
- width + d->x, height + d->y,
- d->x, d->y,
- d->x + width, d->y };
- GLfloat texVertices[] = { 0, 0,
- texWidth, 0,
- 0, texHeight,
- texWidth, texHeight };
-
- SingleTextureShadowShader *shader = item->basicShaders()->singleTextureShadow();
- shader->enable();
- shader->setOpacity(0.8 * p.activeOpacity);
- shader->setTransform(p.activeTransform);
-
- shader->setAttributeArray(SingleTextureShadowShader::Vertices, vertices, 2);
- shader->setAttributeArray(SingleTextureShadowShader::TextureCoords, texVertices, 2);
-
- glBindTexture(GL_TEXTURE_2D, fbo->texture());
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- shader->disableAttributeArray(SingleTextureShadowShader::Vertices);
- shader->disableAttributeArray(SingleTextureShadowShader::TextureCoords);
-
- releaseFBO(fbo);
-
- renderToScreen();
-#else
- Q_UNUSED(p);
-#endif
-}
-
-QML_DEFINE_TYPE(QFxShadowFilter,Shadow)
-
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxshadowfilter.h b/src/declarative/fx/qfxshadowfilter.h
deleted file mode 100644
index 1cbe54f..0000000
--- a/src/declarative/fx/qfxshadowfilter.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFXSHADOWFILTER_H
-#define QFXSHADOWFILTER_H
-
-#include <QtDeclarative/qsimplecanvasfilter.h>
-#include <QtDeclarative/qml.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QFxShadowFilterPrivate;
-class Q_DECLARATIVE_EXPORT QFxShadowFilter : public QSimpleCanvasFilter
-{
- Q_OBJECT
- Q_PROPERTY(int xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged)
- Q_PROPERTY(int yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged)
-public:
- QFxShadowFilter(QObject *parent=0);
- virtual ~QFxShadowFilter();
-
- int xOffset() const;
- void setXOffset(int offset);
-
- int yOffset() const;
- void setYOffset(int offset);
-
-Q_SIGNALS:
- void offsetChanged(int, int);
-
-protected:
- virtual QRectF itemBoundingRect(const QRectF &) const;
- virtual void filterGL(QSimpleCanvasItem::GLPainter &p);
-
-private:
- QFxShadowFilterPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QFxShadowFilter)
-
-QT_END_HEADER
-
-#endif // QFXSHADOWFILTER_H
diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp
index 57897ed..2bae53f 100644
--- a/src/declarative/fx/qfxtext.cpp
+++ b/src/declarative/fx/qfxtext.cpp
@@ -43,18 +43,13 @@
#include "qfxtext_p.h"
#include <private/qtextcontrol_p.h>
-
-#if defined(QFX_RENDER_OPENGL2)
-#include "glbasicshaders.h"
-#endif
-
#include <private/qfxperf_p.h>
#include <QTextLayout>
#include <QTextLine>
#include <QTextDocument>
#include <QTextCursor>
#include <QGraphicsSceneMouseEvent>
-
+#include <QPainter>
QT_BEGIN_NAMESPACE
QML_DEFINE_TYPE(QFxText,Text)
@@ -73,7 +68,7 @@ QML_DEFINE_TYPE(QFxText,Text)
\image declarative-text.png
- If height and width are not explicitly set, Text will attempt to determine how
+ If height and width are not explicitly set, Text will attempt to determine how
much room is needed and set it accordingly. Unless \c wrap is set, it will always
prefer width to height (all text will be placed on a single line).
@@ -91,7 +86,7 @@ QML_DEFINE_TYPE(QFxText,Text)
\brief The QFxText class provides a formatted text item that you can add to a QFxView.
- Text was designed for read-only text; it does not allow for any text editing.
+ Text was designed for read-only text; it does not allow for any text editing.
It can display both plain and rich text. For example:
\qml
@@ -101,7 +96,7 @@ QML_DEFINE_TYPE(QFxText,Text)
\image text.png
- If height and width are not explicitly set, Text will attempt to determine how
+ If height and width are not explicitly set, Text will attempt to determine how
much room is needed and set it accordingly. Unless \c wrap is set, it will always
prefer width to height (all text will be placed on a single line).
@@ -166,9 +161,9 @@ void QFxText::setText(const QString &n)
if (d->richText) {
if (!d->doc)
{
- d->control = new QTextControl(this);
+ d->control = new QTextControl(this);
d->control->setTextInteractionFlags(Qt::TextBrowserInteraction);
- d->doc = d->control->document();
+ d->doc = d->control->document();
d->doc->setDocumentMargin(0);
}
d->doc->setHtml(n);
@@ -304,8 +299,8 @@ QColor QFxText::styleColor() const
Sets the horizontal and vertical alignment of the text within the Text items
width and height. By default, the text is top-left aligned.
- The valid values for \c hAlign are \c AlignLeft, \c AlignRight and
- \c AlignHCenter. The valid values for \c vAlign are \c AlignTop, \c AlignBottom
+ The valid values for \c hAlign are \c AlignLeft, \c AlignRight and
+ \c AlignHCenter. The valid values for \c vAlign are \c AlignTop, \c AlignBottom
and \c AlignVCenter.
*/
@@ -484,7 +479,7 @@ QString QFxText::activeLink() const
return d->activeLink;
}
-void QFxText::geometryChanged(const QRectF &newGeometry,
+void QFxText::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
{
Q_D(QFxText);
@@ -521,7 +516,7 @@ void QFxTextPrivate::updateSize()
QSize size(0, 0);
//setup instance of QTextLayout for all cases other than richtext
- if (!richText)
+ if (!richText)
{
tmp = text;
tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
@@ -550,7 +545,7 @@ void QFxTextPrivate::updateSize()
dy -= (int)doc->size().height();
} else {
dy -= size.height();
- }
+ }
int yoff = 0;
if (q->heightValid()) {
@@ -560,7 +555,7 @@ void QFxTextPrivate::updateSize()
yoff = dy/2;
}
q->setBaselineOffset(fm.ascent() + yoff);
-
+
if (!q->widthValid()) {
int newWidth = (richText ? (int)doc->idealWidth() : size.width());
q->setImplicitWidth(newWidth);
@@ -580,13 +575,6 @@ void QFxTextPrivate::updateSize()
// ### text layout handling should be profiled and optimized as needed
// what about QStackTextEngine engine(tmp, d->font.font()); QTextLayout textLayout(&engine);
-void QFxText::dump(int depth)
-{
- QByteArray ba(depth * 4, ' ');
- qWarning() << ba.constData() << propertyInfo();
- QFxItem::dump(depth);
-}
-
QString QFxText::propertyInfo() const
{
Q_D(const QFxText);
@@ -657,7 +645,7 @@ QSize QFxTextPrivate::setupTextLayout(QTextLayout *layout)
QTextLine line = layout->createLine();
if (!line.isValid())
break;
-
+
if ((wrap || elideMode != Qt::ElideNone) && q->widthValid())
line.setLineWidth(lineWidth);
}
@@ -698,7 +686,7 @@ QPixmap QFxTextPrivate::wrappedTextImage(bool drawStyle)
if (drawStyle) {
p.setPen(styleColor);
}
- else
+ else
p.setPen(color);
p.setFont(f);
layout.draw(&p, QPointF(0, 0));
@@ -765,10 +753,6 @@ void QFxTextPrivate::checkImgCache()
break;
}
-#if defined(QFX_RENDER_OPENGL)
- tex.setImage(imgCache.toImage(), GLTexture::PowerOfTwo);
-#endif
-
imgDirty = false;
}
@@ -787,7 +771,6 @@ void QFxText::setSmoothTransform(bool s)
update();
}
-#if defined(QFX_RENDER_QPAINTER)
void QFxText::paintContents(QPainter &p)
{
Q_D(QFxText);
@@ -830,7 +813,7 @@ void QFxText::paintContents(QPainter &p)
break;
}
- bool needClip = !clip() && (d->imgCache.width() > width() ||
+ bool needClip = !clip() && (d->imgCache.width() > width() ||
d->imgCache.height() > height());
if (needClip) {
@@ -847,85 +830,6 @@ void QFxText::paintContents(QPainter &p)
}
}
-#elif defined(QFX_RENDER_OPENGL2)
-void QFxText::paintGLContents(GLPainter &p)
-{
- //return;
- Q_D(QFxText);
- d->checkImgCache();
- if (d->imgCache.isNull())
- return;
-
- int w = width();
- int h = height();
-
- float x = 0;
- float y = 0;
-
- switch (d->hAlign) {
- case AlignLeft:
- x = 0;
- break;
- case AlignRight:
- x = w - d->imgCache.width();
- break;
- case AlignHCenter:
- x = (w - d->imgCache.width()) / 2;
- break;
- }
-
- switch (d->vAlign) {
- case AlignTop:
- y = 0;
- break;
- case AlignBottom:
- y = h - d->imgCache.height();
- break;
- case AlignVCenter:
- y = (h - d->imgCache.height()) / 2;
- break;
- }
-
- float widthV = d->imgCache.width();
- float heightV = d->imgCache.height();
- float glWidth = d->tex.glWidth();
- float glHeight = d->tex.glHeight();
-
- QGLShaderProgram *shader = p.useTextureShader();
-
- float deltaX = 0.5 / qreal(d->tex.glSize().width());
- float deltaY = 0.5 / qreal(d->tex.glSize().height());
- glWidth -= deltaX;
- glHeight -= deltaY;
-
- GLfloat vertices[] = { x, y + heightV,
- x + widthV, y + heightV,
- x, y,
-
- x + widthV, y + heightV,
- x, y,
- x + widthV, y };
-
- GLfloat texVertices[] = { deltaX, deltaY,
- glWidth, deltaY,
- deltaX, glHeight,
-
- glWidth, deltaY,
- deltaX, glHeight,
- glWidth, glHeight };
-
- shader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2);
-
- glBindTexture(GL_TEXTURE_2D, d->tex.texture());
- glDrawArrays(GL_TRIANGLES, 0, 6);
-
- shader->disableAttributeArray(SingleTextureShader::Vertices);
- shader->disableAttributeArray(SingleTextureShader::TextureCoords);
-}
-
-#endif
-
void QFxText::componentComplete()
{
Q_D(QFxText);
@@ -958,7 +862,7 @@ void QFxText::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (!event->isAccepted())
QFxItem::mousePressEvent(event);
-
+
}
/*!
diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h
index bd91f0e..b7ec333 100644
--- a/src/declarative/fx/qfxtext.h
+++ b/src/declarative/fx/qfxtext.h
@@ -125,14 +125,9 @@ public:
bool smoothTransform() const;
void setSmoothTransform(bool);
- virtual void dump(int depth);
virtual QString propertyInfo() const;
-#if defined(QFX_RENDER_QPAINTER)
void paintContents(QPainter &p);
-#elif defined(QFX_RENDER_OPENGL)
- void paintGLContents(GLPainter &);
-#endif
virtual void componentComplete();
@@ -153,7 +148,7 @@ protected:
private:
Q_DISABLE_COPY(QFxText)
- Q_DECLARE_PRIVATE(QFxText)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxText)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxtext_p.h b/src/declarative/fx/qfxtext_p.h
index 670b685..6692d9e 100644
--- a/src/declarative/fx/qfxtext_p.h
+++ b/src/declarative/fx/qfxtext_p.h
@@ -58,10 +58,6 @@
#include "qml.h"
#include <QtGui/qtextlayout.h>
-#if defined(QFX_RENDER_OPENGL)
-#include "gltexture.h"
-#endif
-
QT_BEGIN_NAMESPACE
class QTextLayout;
@@ -116,9 +112,6 @@ public:
QColor styleColor;
QString activeLink;
bool imgDirty;
-#if defined(QFX_RENDER_OPENGL)
- GLTexture tex;
-#endif
QPixmap imgCache;
QPixmap imgStyleCache;
QFxText::HAlignment hAlign;
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index c2bda6f..f9cde7c 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -41,13 +41,7 @@
#include <qfxtextedit.h>
#include "qfxtextedit_p.h"
-
#include <private/qtextcontrol_p.h>
-
-#if defined(QFX_RENDER_OPENGL2)
-#include "glbasicshaders.h"
-#endif
-
#include <private/qfxperf_p.h>
#include "qfxevents_p.h"
#include <QTextLayout>
@@ -56,7 +50,7 @@
#include <QGraphicsSceneMouseEvent>
#include <QDebug>
-
+#include <QPainter>
QT_BEGIN_NAMESPACE
QML_DEFINE_TYPE(QFxTextEdit, TextEdit)
@@ -72,7 +66,6 @@ TextEdit {
id: edit
text: "<b>Hello</b> <i>World!</i>"
focus: true
- focusable: true
font.family: "Helvetica"
font.size: 20
color: "blue"
@@ -360,8 +353,8 @@ void QFxTextEdit::setHighlightedTextColor(const QColor &color)
Sets the horizontal and vertical alignment of the text within the TextEdit items
width and height. By default, the text is top-left aligned.
- The valid values for \c hAlign are \c AlignLeft, \c AlignRight and
- \c AlignHCenter. The valid values for \c vAlign are \c AlignTop, \c AlignBottom
+ The valid values for \c hAlign are \c AlignLeft, \c AlignRight and
+ \c AlignHCenter. The valid values for \c vAlign are \c AlignTop, \c AlignBottom
and \c AlignVCenter.
*/
@@ -542,7 +535,7 @@ void QFxTextEdit::loadCursorDelegate()
d->cursor->setHeight(QFontMetrics(d->font.font()).height());
moveCursorDelegate();
}else{
- qWarning() << "Error loading cursor delegate for TextEdit:" + objectName();
+ qWarning() << QLatin1String("Error loading cursor delegate for TextEdit:") + objectName();
}
}
@@ -677,7 +670,7 @@ void QFxTextEdit::setTextMargin(qreal margin)
d->document->setDocumentMargin(d->textMargin);
}
-void QFxTextEdit::geometryChanged(const QRectF &newGeometry,
+void QFxTextEdit::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
{
if (newGeometry.width() != oldGeometry.width())
@@ -686,16 +679,6 @@ void QFxTextEdit::geometryChanged(const QRectF &newGeometry,
}
/*!
- \internal
-*/
-void QFxTextEdit::dump(int depth)
-{
- QByteArray ba(depth * 4, ' ');
- qWarning() << ba.constData() << propertyInfo();
- QFxPaintedItem::dump(depth);
-}
-
-/*!
\internal
*/
QString QFxTextEdit::propertyInfo() const
@@ -779,7 +762,7 @@ Qt::TextInteractionFlags QFxTextEdit::textInteractionFlags() const
}
/*!
- Returns the cursor for the point at the given \a pos on the
+ Returns the cursor for the point at the given \a pos on the
text edit.
*/
QTextCursor QFxTextEdit::cursorForPosition(const QPoint &pos) const
@@ -1147,9 +1130,9 @@ void QFxTextEdit::updateSize()
if (!heightValid()) {
if (d->text.isEmpty()) {
setImplicitHeight(fm.height());
- } else {
+ } else {
setImplicitHeight((int)d->document->size().height());
- }
+ }
}
setContentsSize(QSize(width(), height()));
} else {
@@ -1163,7 +1146,7 @@ void QFxTextEditPrivate::updateDefaultTextOption()
QTextOption opt = document->defaultTextOption();
int oldAlignment = opt.alignment();
opt.setAlignment((Qt::Alignment)(int)(hAlign | vAlign));
-
+
QTextOption::WrapMode oldWrapMode = opt.wrapMode();
if (wrap)
diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h
index 80636e2..77fac29 100644
--- a/src/declarative/fx/qfxtextedit.h
+++ b/src/declarative/fx/qfxtextedit.h
@@ -161,7 +161,6 @@ public:
qreal textMargin() const;
void setTextMargin(qreal margin);
- virtual void dump(int depth);
virtual QString propertyInfo() const;
virtual void componentComplete();
@@ -229,7 +228,7 @@ private:
friend class QmlFont;
Q_DISABLE_COPY(QFxTextEdit)
- Q_DECLARE_PRIVATE(QFxTextEdit)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxTextEdit)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxtextedit_p.h b/src/declarative/fx/qfxtextedit_p.h
index b7d667e..45a8a60 100644
--- a/src/declarative/fx/qfxtextedit_p.h
+++ b/src/declarative/fx/qfxtextedit_p.h
@@ -71,7 +71,7 @@ public:
: font(0), color("black"), imgDirty(true), hAlign(QFxTextEdit::AlignLeft), vAlign(QFxTextEdit::AlignTop),
dirty(false), wrap(false), richText(false), cursorVisible(false), focusOnPress(false),
preserveSelection(true), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0),
- cursor(0), cursorComponent(0), format(QFxTextEdit::AutoText), document(0)
+ cursorComponent(0), cursor(0), format(QFxTextEdit::AutoText), document(0)
{
}
@@ -89,9 +89,6 @@ public:
QString style;
QColor styleColor;
bool imgDirty;
-#if defined(QFX_RENDER_OPENGL)
- GLTexture texture;
-#endif
QPixmap imgCache;
QPixmap imgStyleCache;
QFxTextEdit::HAlignment hAlign;
diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp
index 0f0ce80..f08d830 100644
--- a/src/declarative/fx/qfxtransform.cpp
+++ b/src/declarative/fx/qfxtransform.cpp
@@ -71,9 +71,9 @@ bool QFxTransform::isIdentity() const
return true;
}
-QSimpleCanvas::Matrix QFxTransform::transform() const
+QTransform QFxTransform::transform() const
{
- return QSimpleCanvas::Matrix();
+ return QTransform();
}
void QFxTransform::update()
@@ -181,7 +181,6 @@ bool QFxScale::isIdentity() const
return (_xScale == 1. && _yScale == 1.);
}
-#if defined(QFX_RENDER_QPAINTER)
QTransform QFxScale::transform() const
{
if (_dirty) {
@@ -193,19 +192,6 @@ QTransform QFxScale::transform() const
}
return _transform;
}
-#elif defined(QFX_RENDER_OPENGL)
-QMatrix4x4 QFxScale::transform() const
-{
- if (_dirty) {
- _transform = QMatrix4x4();
- _dirty = false;
- _transform.translate(_originX, _originY);
- _transform.scale(_xScale, _yScale);
- _transform.translate(-_originX, -_originY);
- }
- return _transform;
-}
-#endif
void QFxScale::update()
{
@@ -387,7 +373,6 @@ bool QFxRotation::isIdentity() const
return (_angle == 0.);
}
-#if defined(QFX_RENDER_QPAINTER)
QTransform QFxRotation::transform() const
{
if (_dirty) {
@@ -399,19 +384,6 @@ QTransform QFxRotation::transform() const
}
return _transform;
}
-#elif defined(QFX_RENDER_OPENGL)
-QMatrix4x4 QFxRotation::transform() const
-{
- if (_dirty) {
- _transform = QMatrix4x4();
- _dirty = false;
- _transform.translate(_originX, _originY);
- _transform.rotate(_angle, 0, 0, 1);
- _transform.translate(-_originX, -_originY);
- }
- return _transform;
-}
-#endif
void QFxRotation::update()
{
@@ -484,7 +456,6 @@ bool QFxRotation3D::isIdentity() const
return (_angle == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX());
}
-#if defined(QFX_RENDER_QPAINTER)
const qreal inv_dist_to_plane = 1. / 1024.;
QTransform QFxRotation3D::transform() const
{
@@ -529,29 +500,6 @@ QTransform QFxRotation3D::transform() const
return _transform;
}
-#elif defined(QFX_RENDER_OPENGL)
-QMatrix4x4 QFxRotation3D::transform() const
-{
- if (_dirty) {
- _dirty = false;
- _transform = QMatrix4x4();
-
- if (!isIdentity()) {
- if (angle() != 0.) {
- qreal x = _axis.endX() - _axis.startX();
- qreal y = _axis.endY() - _axis.startY();
- qreal z = _axis.endZ();
-
- _transform.translate(_axis.startX(), _axis.startY(), 0);
- _transform.rotate(angle(), x, y, z);
- _transform.translate(-_axis.startX(), -_axis.startY(), 0);
- }
- }
- }
-
- return _transform;
-}
-#endif
void QFxRotation3D::update()
{
@@ -639,7 +587,6 @@ bool QFxTranslation3D::isIdentity() const
return (_distance == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX());
}
-#if defined(QFX_RENDER_QPAINTER)
QTransform QFxTranslation3D::transform() const
{
if (_dirty) {
@@ -659,35 +606,14 @@ QTransform QFxTranslation3D::transform() const
return _transform;
}
-#elif defined(QFX_RENDER_OPENGL)
-QMatrix4x4 QFxTranslation3D::transform() const
-{
- if (_dirty) {
- _dirty = false;
- _transform = QMatrix4x4();
-
- if (!isIdentity()) {
- if (distance() != 0.)
- _transform.translate((_axis.endX() - _axis.startX()) * distance(),
- (_axis.endY() - _axis.startY()) * distance(),
- (_axis.endZ()) * distance());
-
- }
- }
-
- return _transform;
-}
-#endif
void QFxTranslation3D::update()
{
_dirty = true;
-#if !defined(QFX_RENDER_OPENGL)
if (_axis.endZ() != 0. && distance() != 0.) {
qmlInfo(this) << "QTransform cannot translate along Z-axis.";
}
-#endif
QFxTransform::update();
}
@@ -712,24 +638,6 @@ QFxPerspective::~QFxPerspective()
{
}
-#if defined(QFX_RENDER_OPENGL)
-bool QFxPerspective::isIdentity() const
-{
- return false;
-}
-
-QMatrix4x4 QFxPerspective::transform() const
-{
- QMatrix4x4 rv;
- rv.translate(_x, _y);
- rv.perspective(_angle, _aspect, 1, 1024 * 1024);
- rv.translate(-_x, -_y, -1);
- rv.scale(1, 1, 1. / _scale);
-
- return rv;
-}
-#endif
-
/*!
\qmlproperty real Perspective::angle
*/
@@ -996,7 +904,6 @@ bool QFxSquish::isIdentity() const
return false;
}
-#if defined(QFX_RENDER_QPAINTER)
QTransform QFxSquish::transform() const
{
QPolygonF poly;
@@ -1008,21 +915,5 @@ QTransform QFxSquish::transform() const
QTransform::quadToQuad(poly, poly2, t);
return t;
}
-#elif defined(QFX_RENDER_OPENGL)
-QMatrix4x4 QFxSquish::transform() const
-{
- QPolygonF poly;
- poly << p << QPointF(p.x() + s.width(), p.y()) << QPointF(p.x() + s.width(), p.y() + s.height()) << QPointF(p.x(), p.y() + s.height());
- QPolygonF poly2;
- poly2 << p1 << p2 << p4 << p3;
-
- QTransform t;
- QMatrix4x4 rv;
- if (QTransform::quadToQuad(poly, poly2, t))
- rv = QMatrix4x4(t);
-
- return rv;
-}
-#endif
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxtransform.h b/src/declarative/fx/qfxtransform.h
index e0bd276..fb49294 100644
--- a/src/declarative/fx/qfxtransform.h
+++ b/src/declarative/fx/qfxtransform.h
@@ -44,9 +44,6 @@
#include <QtCore/QObject>
#include <QtGui/QTransform>
-#if defined(QFX_RENDER_OPENGL)
-#include <QtGui/qmatrix4x4.h>
-#endif
#include <QtDeclarative/qfxitem.h>
QT_BEGIN_HEADER
@@ -65,7 +62,7 @@ public:
void update();
virtual bool isIdentity() const;
- virtual QSimpleCanvas::Matrix transform() const;
+ virtual QTransform transform() const;
};
class Q_DECLARATIVE_EXPORT QFxScale : public QFxTransform
@@ -93,7 +90,7 @@ public:
void setYScale(qreal);
virtual bool isIdentity() const;
- virtual QSimpleCanvas::Matrix transform() const;
+ virtual QTransform transform() const;
Q_SIGNALS:
void scaleChanged();
@@ -107,7 +104,7 @@ private:
qreal _yScale;
mutable bool _dirty;
- mutable QSimpleCanvas::Matrix _transform;
+ mutable QTransform _transform;
};
class Q_DECLARATIVE_EXPORT QFxAxis : public QObject
@@ -170,7 +167,7 @@ public:
void setAngle(qreal);
virtual bool isIdentity() const;
- virtual QSimpleCanvas::Matrix transform() const;
+ virtual QTransform transform() const;
Q_SIGNALS:
void angleChanged();
@@ -183,7 +180,7 @@ private:
qreal _angle;
mutable bool _dirty;
- mutable QSimpleCanvas::Matrix _transform;
+ mutable QTransform _transform;
};
class Q_DECLARATIVE_EXPORT QFxRotation3D : public QFxTransform
@@ -202,7 +199,7 @@ public:
void setAngle(qreal);
virtual bool isIdentity() const;
- virtual QSimpleCanvas::Matrix transform() const;
+ virtual QTransform transform() const;
private Q_SLOTS:
void update();
@@ -211,7 +208,7 @@ private:
qreal _angle;
mutable bool _dirty;
- mutable QSimpleCanvas::Matrix _transform;
+ mutable QTransform _transform;
};
class Q_DECLARATIVE_EXPORT QFxTranslation3D : public QFxTransform
@@ -230,7 +227,7 @@ public:
void setDistance(qreal);
virtual bool isIdentity() const;
- virtual QSimpleCanvas::Matrix transform() const;
+ virtual QTransform transform() const;
private Q_SLOTS:
void update();
@@ -239,7 +236,7 @@ private:
qreal _distance;
mutable bool _dirty;
- mutable QSimpleCanvas::Matrix _transform;
+ mutable QTransform _transform;
};
class Q_DECLARATIVE_EXPORT QFxPerspective : public QFxTransform
@@ -270,10 +267,6 @@ public:
qreal scale() const { return _scale; }
void setScale(qreal v) { _scale = v; update(); }
-#if defined(QFX_RENDER_OPENGL)
- virtual bool isIdentity() const;
- virtual QMatrix4x4 transform() const;
-#endif
private:
qreal _scale;
qreal _x;
@@ -339,7 +332,7 @@ public:
void setbottomRight_x(qreal);
virtual bool isIdentity() const;
- virtual QSimpleCanvas::Matrix transform() const;
+ virtual QTransform transform() const;
private:
QPointF p;
diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp
index 0682294..1b15a48 100644
--- a/src/declarative/fx/qfxvisualitemmodel.cpp
+++ b/src/declarative/fx/qfxvisualitemmodel.cpp
@@ -51,6 +51,7 @@
#include "qmlopenmetaobject.h"
#include "qmllistaccessor.h"
#include "qfxvisualitemmodel.h"
+#include <QtCore/qdebug.h>
QML_DECLARE_TYPE(QListModelInterface)
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index c6a8ebf..a3dca79e 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -43,6 +43,8 @@
#include <QPen>
#include <QFile>
#include <QEvent>
+#include <QMouseEvent>
+#include <QKeyEvent>
#include <QBasicTimer>
#include <QApplication>
#include <QGraphicsSceneMouseEvent>
@@ -56,19 +58,9 @@
#include "qmlstate.h"
#include "qfxtransform.h"
#include "qfxscalegrid.h"
-#include "qsimplecanvas.h"
#include "qlistmodelinterface.h"
-#if defined(QFX_RENDER_OPENGL2)
-#include <QtOpenGL/qglframebufferobject.h>
-#include <glsave.h>
-#endif
-#if defined(QFX_RENDER_OPENGL)
-#include <gltexture.h>
-#endif
-
#include "qfxwebview.h"
-#include <qsimplecanvasfilter.h>
#include <private/qfxpainteditem_p.h>
QT_BEGIN_NAMESPACE
@@ -247,7 +239,6 @@ void QFxWebView::init()
setAcceptedMouseButtons(Qt::LeftButton);
setOptions(HasContents | MouseEvents);
- setFocusable(true);
d->page = 0;
}
@@ -465,11 +456,51 @@ void QFxWebView::paintPage(const QRect& r)
update();
}
-void QFxWebView::dump(int depth)
+/*!
+ \qmlproperty int WebView::cacheSize
+
+ This property holds the maximum number of pixels of image cache to
+ allow. The default is 0.1 megapixels. The cache will not be larger
+ than the (unscaled) size of the WebView.
+*/
+
+/*!
+ \property QFxWebView::cacheSize
+
+ The maximum number of pixels of image cache to allow. The default
+ is 0.1 megapixels. The cache will not be larger than the (unscaled)
+ size of the QFxWebView.
+*/
+int QFxWebView::cacheSize() const
{
- QByteArray ba(depth * 4, ' ');
- qWarning() << ba.constData() << "url:" << url();
- QFxPaintedItem::dump(depth);
+ Q_D(const QFxWebView);
+ return d->max_imagecache_size;
+}
+
+void QFxWebView::setCacheSize(int pixels)
+{
+ Q_D(QFxWebView);
+ if (pixels < d->max_imagecache_size) {
+ int cachesize=0;
+ for (int i=0; i<d->imagecache.count(); ++i) {
+ QRect area = d->imagecache[i]->area;
+ cachesize += area.width()*area.height();
+ }
+ while (d->imagecache.count() && cachesize > pixels) {
+ int oldest=-1;
+ int age=-1;
+ for (int i=0; i<d->imagecache.count(); ++i) {
+ int a = d->imagecache[i]->age;
+ if (a > age) {
+ oldest = i;
+ age = a;
+ }
+ }
+ cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height();
+ d->imagecache.removeAt(oldest);
+ }
+ }
+ d->max_imagecache_size = pixels;
}
void QFxWebView::drawContents(QPainter *p, const QRect &r)
diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h
index f5fd721..ab20281 100644
--- a/src/declarative/fx/qfxwebview.h
+++ b/src/declarative/fx/qfxwebview.h
@@ -139,7 +139,6 @@ public:
QAction *forwardAction() const;
QAction *stopAction() const;
- virtual void dump(int depth);
virtual QString propertyInfo() const;
QWebPage *page() const;
@@ -160,6 +159,9 @@ public:
QString status() const;
+ int cacheSize() const;
+ void setCacheSize(int pixels);
+
Q_SIGNALS:
void idealWidthChanged();
void idealHeightChanged();
@@ -204,7 +206,7 @@ private:
void init();
virtual void componentComplete();
Q_DISABLE_COPY(QFxWebView)
- Q_DECLARE_PRIVATE(QFxWebView)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxWebView)
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxwidgetcontainer.cpp b/src/declarative/fx/qfxwidgetcontainer.cpp
deleted file mode 100644
index 421c2f7..0000000
--- a/src/declarative/fx/qfxwidgetcontainer.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfxwidgetcontainer.h"
-#include <qsimplecanvas.h>
-#include <qgraphicswidget.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \qmlclass WidgetContainer QFxWidgetContainer
- \brief The WidgetContainer element allows you to add QGraphicsWidgets into Fluid UI elements.
-*/
-
-/*!
- \internal
- \class QFxWidgetContainer
- \brief The QFxWidgetContainer class allows you to add QGraphicsWidgets into Fluid UI applications.
-*/
-
-QML_DEFINE_TYPE(QFxWidgetContainer, WidgetContainer)
-
-QFxWidgetContainer::QFxWidgetContainer(QFxItem *parent)
-: QFxItem(parent), _graphicsWidget(0)
-{
-}
-
-QFxWidgetContainer::~QFxWidgetContainer()
-{
-}
-
-QGraphicsWidget *QFxWidgetContainer::graphicsWidget() const
-{
- return _graphicsWidget;
-}
-
-/*!
- \qmlproperty QGraphicsWidget QFxWidgetContainer::graphicsWidget
- The QGraphicsWidget associated with this element.
-*/
-void QFxWidgetContainer::setGraphicsWidget(QGraphicsWidget *widget)
-{
- if (widget == _graphicsWidget)
- return;
-
- _graphicsWidget = widget;
-
- QSimpleCanvas *c = canvas();
- if (!c)
- return;
-
- if (c->canvasMode() != QSimpleCanvas::GraphicsView) {
- qWarning("QFxWidgetContainer: Cannot add a widget to a non-graphicsview canvas. You might need to set QFX_USE_GRAPHICSVIEW=1");
- return;
- }
-
- QGraphicsItem *item = (QGraphicsItem *)(*this);
- _graphicsWidget->setParentItem(item);
-}
-
-void QFxWidgetContainer::canvasChanged()
-{
- if (_graphicsWidget) {
- QGraphicsWidget *w = _graphicsWidget;
- _graphicsWidget = 0;
- setGraphicsWidget(w);
- }
-}
-
-QT_END_NAMESPACE