summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-05-05 06:31:24 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-05-05 06:31:24 (GMT)
commit9f67de1530cc13344109cf9c3b6eba937f4a75de (patch)
tree34f160916ef4056083fc6b9c893659768fe11c06 /src/declarative/fx
parentc814652c4276f7fba18243c1e3abff6557375582 (diff)
parent61b44e83eab8631ea38155082ebe9fde7490eb55 (diff)
downloadQt-9f67de1530cc13344109cf9c3b6eba937f4a75de.zip
Qt-9f67de1530cc13344109cf9c3b6eba937f4a75de.tar.gz
Qt-9f67de1530cc13344109cf9c3b6eba937f4a75de.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/fx')
-rw-r--r--src/declarative/fx/fx.pri9
-rw-r--r--src/declarative/fx/qfxpainted.cpp194
-rw-r--r--src/declarative/fx/qfxpainted.h87
-rw-r--r--src/declarative/fx/qfxpainted_p.h84
-rw-r--r--src/declarative/fx/qfxpainteditem.cpp (renamed from src/declarative/fx/qfximageitem.cpp)68
-rw-r--r--src/declarative/fx/qfxpainteditem.h (renamed from src/declarative/fx/qfximageitem.h)19
-rw-r--r--src/declarative/fx/qfxpainteditem_p.h (renamed from src/declarative/fx/qfximageitem_p.h)6
-rw-r--r--src/declarative/fx/qfxtextedit.cpp20
-rw-r--r--src/declarative/fx/qfxtextedit.h4
-rw-r--r--src/declarative/fx/qfxtextedit_p.h4
-rw-r--r--src/declarative/fx/qfxwebview.cpp143
-rw-r--r--src/declarative/fx/qfxwebview.h16
12 files changed, 86 insertions, 568 deletions
diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri
index ef059c7..90820fa 100644
--- a/src/declarative/fx/fx.pri
+++ b/src/declarative/fx/fx.pri
@@ -17,8 +17,8 @@ HEADERS += \
fx/qfxgridview.h \
fx/qfxhighlightfilter.h \
fx/qfximage.h \
- fx/qfximageitem.h \
- fx/qfximageitem_p.h \
+ fx/qfxpainteditem.h \
+ fx/qfxpainteditem_p.h \
fx/qfximage_p.h \
fx/qfxitem.h \
fx/qfxitem_p.h \
@@ -28,8 +28,6 @@ HEADERS += \
fx/qfxlayouts_p.h \
fx/qfxmouseregion.h \
fx/qfxmouseregion_p.h \
- fx/qfxpainted.h \
- fx/qfxpainted_p.h \
fx/qfxparticles.h \
fx/qfxpath.h \
fx/qfxpath_p.h \
@@ -67,13 +65,12 @@ SOURCES += \
fx/qfxgridview.cpp \
fx/qfxhighlightfilter.cpp \
fx/qfximage.cpp \
- fx/qfximageitem.cpp \
+ fx/qfxpainteditem.cpp \
fx/qfxitem.cpp \
fx/qfxkeyactions.cpp \
fx/qfxkeyproxy.cpp \
fx/qfxlayouts.cpp \
fx/qfxmouseregion.cpp \
- fx/qfxpainted.cpp \
fx/qfxparticles.cpp \
fx/qfxpath.cpp \
fx/qfxpathview.cpp \
diff --git a/src/declarative/fx/qfxpainted.cpp b/src/declarative/fx/qfxpainted.cpp
deleted file mode 100644
index 68918c3..0000000
--- a/src/declarative/fx/qfxpainted.cpp
+++ /dev/null
@@ -1,194 +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 "qfxpainted.h"
-#include "qfxpainted_p.h"
-
-
-QT_BEGIN_NAMESPACE
-/*!
- \internal
- \class QFxPainted
- \brief The QFxPainted class is an abstract base class for QFxView items that want cached painting.
-
- \ingroup group_coreitems
-
- This is a convenience class allowing easy use of cached painting within a custom item.
- The contents of the item are cached behind the scenes. Any time you change the contents
- you should call markDirty to make sure the cache is refreshed the next time painting occurs.
-
- \code
- class GradientRect : public QFxPainted
- {
- Q_OBJECT
- public:
- GradientRect() : QFxPainted()
- {
- connect(this, SIGNAL(widthChanged()), this, SLOT(markDirty()));
- connect(this, SIGNAL(heightChanged()), this, SLOT(markDirty()));
- }
-
- void paint(QPainter *painter)
- {
- painter->fillRect(0, 0, width(), height(), QBrush(QLinearGradient(0,0,width(),height())));
- }
- };
- \endcode
-
- \warning Dirty is only ever automatically set by QFxPainted at construction. Any other changes (including resizes) to the item need to be handled by the subclass (as in the example above).
- \warning Frequent calls to markDirty will result in sub-optimal painting performance.
-*/
-
-/*!
- Constructs a painted item with parent object \a parent.
-*/
-QFxPainted::QFxPainted(QFxItem *parent)
- : QFxItem(*(new QFxPaintedPrivate), parent)
-{
- //### what options do we need to set?
- setOptions(HasContents, true);
-}
-
-/*!
- Destroys the item.
-*/
-QFxPainted::~QFxPainted()
-{
-}
-
-/*! \internal
-*/
-QFxPainted::QFxPainted(QFxPaintedPrivate &dd, QFxItem *parent)
- : QFxItem(dd, parent)
-{
- setOptions(HasContents, true);
-}
-
-/*!
- \fn QFxPainted::paint(QPainter *painter)
-
- Implement this method to paint the item using \a painter.
- The painting will be cached and paint() will only be called again
- if \l markDirty() has been called.
-
- \sa markDirty()
-*/
-
-/*!
- The contents of the item are cached behind the scenes. Any time you change the contents
- you should call markDirty to make sure the cache is refreshed the next time painting occurs.
-*/
-void QFxPainted::markDirty()
-{
- Q_D(QFxPainted);
- if (d->dirty)
- return;
- d->dirty = true;
-
- // release cache memory (will be reallocated upon paintContents, if visible)
-#if defined(QFX_RENDER_QPAINTER)
- d->cachedImage = QImage();
-#elif defined(QFX_RENDER_OPENGL)
- d->cachedTexture.clear();
-#endif
-
- update();
-}
-
-#if defined(QFX_RENDER_QPAINTER)
-void QFxPainted::paintContents(QPainter &p)
-{
- Q_D(QFxPainted);
- if (d->dirty) {
- d->cachedImage = QImage(width(), height(), QImage::Format_ARGB32_Premultiplied);
- d->cachedImage.fill(0);
- QPainter painter(&(d->cachedImage));
- paint(&painter);
- d->dirty = false;
- }
- p.drawImage(0, 0, d->cachedImage);
-}
-#elif defined(QFX_RENDER_OPENGL2)
-void QFxPainted::paintGLContents(GLPainter &painter)
-{
- Q_D(QFxPainted);
- if (d->dirty) {
- QImage img = QImage(width(), height(), QImage::Format_ARGB32);
- img.fill(0);
- QPainter p(&(img));
- paint(&p);
- d->cachedTexture.setImage(img);
- d->dirty = false;
- }
-
- //### mainly copied from QFxImage code
- QGLShaderProgram *shader = painter.useTextureShader();
-
- GLfloat vertices[8];
- GLfloat texVertices[8];
- GLTexture *tex = &d->cachedTexture;
-
- float widthV = d->cachedTexture.width();
- float heightV = d->cachedTexture.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;
-
- texVertices[0] = 0; texVertices[1] = 0;
- texVertices[2] = 1; texVertices[3] = 0;
- texVertices[4] = 0; texVertices[5] = 1;
- texVertices[6] = 1; texVertices[7] = 1;
-
- shader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2);
- shader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2);
-
- glBindTexture(GL_TEXTURE_2D, tex->texture());
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- shader->disableAttributeArray(SingleTextureShader::Vertices);
- shader->disableAttributeArray(SingleTextureShader::TextureCoords);
-}
-
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxpainted.h b/src/declarative/fx/qfxpainted.h
deleted file mode 100644
index 1f22414..0000000
--- a/src/declarative/fx/qfxpainted.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 QFXPAINTED_H
-#define QFXPAINTED_H
-
-#include <qfxitem.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-/*
-WARNING: INTENDED TO MERGE WITH QFxImageItem
-*/
-
-class QFxPaintedPrivate;
-class Q_DECLARATIVE_EXPORT QFxPainted : public QFxItem
-{
-Q_OBJECT
-public:
- QFxPainted(QFxItem *parent);
- ~QFxPainted();
-
- virtual void paint(QPainter *painter) = 0;
-
-#if defined(QFX_RENDER_QPAINTER)
- void paintContents(QPainter &painter);
-#elif defined(QFX_RENDER_OPENGL2)
- void paintGLContents(GLPainter &);
-#endif
-
-protected Q_SLOTS:
- void markDirty();
-
-protected:
- QFxPainted(QFxPaintedPrivate &dd, QFxItem *parent);
-
-private:
- Q_DISABLE_COPY(QFxPainted)
- Q_DECLARE_PRIVATE(QFxPainted)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QFXPAINTED_H
diff --git a/src/declarative/fx/qfxpainted_p.h b/src/declarative/fx/qfxpainted_p.h
deleted file mode 100644
index 68ac83e..0000000
--- a/src/declarative/fx/qfxpainted_p.h
+++ /dev/null
@@ -1,84 +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 QFXPAINTED_P_H
-#define QFXPAINTED_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qfxitem_p.h"
-#if defined(QFX_RENDER_OPENGL)
-#include "gltexture.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QFxPaintedPrivate : public QFxItemPrivate
-{
- Q_DECLARE_PUBLIC(QFxPainted)
-
-public:
- QFxPaintedPrivate()
- : dirty(true)
- {
- }
-
- bool dirty;
-
-#if defined(QFX_RENDER_QPAINTER)
- QSimpleCanvasConfig::Image cachedImage;
-#elif defined(QFX_RENDER_OPENGL)
- GLTexture cachedTexture;
-#endif
-};
-
-QT_END_NAMESPACE
-
-#endif // QFXPAINTED_P_H
diff --git a/src/declarative/fx/qfximageitem.cpp b/src/declarative/fx/qfxpainteditem.cpp
index d751845..950b468 100644
--- a/src/declarative/fx/qfximageitem.cpp
+++ b/src/declarative/fx/qfxpainteditem.cpp
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#include "qfximageitem.h"
-#include "qfximageitem_p.h"
+#include "qfxpainteditem.h"
+#include "qfxpainteditem_p.h"
#include <QDebug>
#include <QPen>
@@ -57,30 +57,30 @@
QT_BEGIN_NAMESPACE
/*!
- \class QFxImageItem
- \brief The QFxImageItem class is an abstract base class for QFxView items that want cached painting.
+ \class QFxPaintedItem
+ \brief The QFxPaintedItem class is an abstract base class for QFxView items that want cached painting.
\ingroup group_coreitems
- This is a convenience class allowing easy use of cached painting within a custom
- item. The contents of the item are are cached behind the scenes.
+ This is a convenience class for implementing items that paint their contents
+ using a QPainter. The contents of the item are are cached behind the scenes.
The dirtyCache() function should be called if the contents change to
ensure the cache is refreshed the next time painting occurs.
- To subclass QFxImageItem, you must reimplement drawContents() to draw
+ To subclass QFxPaintedItem, you must reimplement drawContents() to draw
the contents of the item.
*/
/*!
- \fn void QFxImageItem::drawContents(QPainter *painter, const QRect &rect)
+ \fn void QFxPaintedItem::drawContents(QPainter *painter, const QRect &rect)
This function is called when the cache needs to be refreshed. When
- sub-classing QFxImageItem this function should be implemented so as to
+ sub-classing QFxPaintedItem this function should be implemented so as to
paint the contents of the item using the given \a painter for the
area of the contents specified by \a rect.
*/
/*!
- \property QFxImageItem::contentsSize
+ \property QFxPaintedItem::contentsSize
\brief The size of the contents
The contents size is the size of the item in regards to how it is painted
@@ -89,7 +89,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \property QFxImageItem::smooth
+ \property QFxPaintedItem::smooth
\brief Setting for whether smooth scaling is enabled.
*/
@@ -99,9 +99,9 @@ QT_BEGIN_NAMESPACE
\sa clearCache()
*/
-void QFxImageItem::dirtyCache(const QRect& rect)
+void QFxPaintedItem::dirtyCache(const QRect& rect)
{
- Q_D(QFxImageItem);
+ Q_D(QFxPaintedItem);
for (int i=0; i < d->imagecache.count(); ) {
if (d->imagecache[i]->area.intersects(rect)) {
d->imagecache.removeAt(i);
@@ -116,9 +116,9 @@ void QFxImageItem::dirtyCache(const QRect& rect)
\sa dirtyCache()
*/
-void QFxImageItem::clearCache()
+void QFxPaintedItem::clearCache()
{
- Q_D(QFxImageItem);
+ Q_D(QFxPaintedItem);
qDeleteAll(d->imagecache);
d->imagecache.clear();
}
@@ -128,9 +128,9 @@ void QFxImageItem::clearCache()
\sa setSmooth()
*/
-bool QFxImageItem::isSmooth() const
+bool QFxPaintedItem::isSmooth() const
{
- Q_D(const QFxImageItem);
+ Q_D(const QFxPaintedItem);
return d->smooth;
}
@@ -139,9 +139,9 @@ bool QFxImageItem::isSmooth() const
\sa setContentsSize()
*/
-QSize QFxImageItem::contentsSize() const
+QSize QFxPaintedItem::contentsSize() const
{
- Q_D(const QFxImageItem);
+ Q_D(const QFxPaintedItem);
return d->contentsSize;
}
@@ -151,9 +151,9 @@ QSize QFxImageItem::contentsSize() const
\sa isSmooth()
*/
-void QFxImageItem::setSmooth(bool smooth)
+void QFxPaintedItem::setSmooth(bool smooth)
{
- Q_D(QFxImageItem);
+ Q_D(QFxPaintedItem);
if (d->smooth == smooth) return;
d->smooth = smooth;
clearCache();
@@ -165,9 +165,9 @@ void QFxImageItem::setSmooth(bool smooth)
\sa contentsSize()
*/
-void QFxImageItem::setContentsSize(const QSize &size)
+void QFxPaintedItem::setContentsSize(const QSize &size)
{
- Q_D(QFxImageItem);
+ Q_D(QFxPaintedItem);
if (d->contentsSize == size) return;
d->contentsSize = size;
clearCache();
@@ -175,20 +175,20 @@ void QFxImageItem::setContentsSize(const QSize &size)
}
/*!
- Constructs a new QFxImageItem with the given \a parent.
+ Constructs a new QFxPaintedItem with the given \a parent.
*/
-QFxImageItem::QFxImageItem(QFxItem *parent)
- : QFxItem(*(new QFxImageItemPrivate), parent)
+QFxPaintedItem::QFxPaintedItem(QFxItem *parent)
+ : QFxItem(*(new QFxPaintedItemPrivate), parent)
{
init();
}
/*!
\internal
- Constructs a new QFxImageItem with the given \a parent and
+ Constructs a new QFxPaintedItem with the given \a parent and
initialized private data member \a dd.
*/
-QFxImageItem::QFxImageItem(QFxImageItemPrivate &dd, QFxItem *parent)
+QFxPaintedItem::QFxPaintedItem(QFxPaintedItemPrivate &dd, QFxItem *parent)
: QFxItem(dd, parent)
{
init();
@@ -197,14 +197,14 @@ QFxImageItem::QFxImageItem(QFxImageItemPrivate &dd, QFxItem *parent)
/*!
Destroys the image item.
*/
-QFxImageItem::~QFxImageItem()
+QFxPaintedItem::~QFxPaintedItem()
{
}
/*!
\internal
*/
-void QFxImageItem::init()
+void QFxPaintedItem::init()
{
connect(this,SIGNAL(widthChanged()),this,SLOT(clearCache()));
connect(this,SIGNAL(heightChanged()),this,SLOT(clearCache()));
@@ -215,17 +215,17 @@ void QFxImageItem::init()
/*!
\reimp
*/
-void QFxImageItem::paintContents(QPainter &p)
+void QFxPaintedItem::paintContents(QPainter &p)
#elif defined(QFX_RENDER_OPENGL)
/*!
\reimp
*/
-void QFxImageItem::paintGLContents(GLPainter &p)
+void QFxPaintedItem::paintGLContents(GLPainter &p)
#else
#error "What render?"
#endif
{
- Q_D(QFxImageItem);
+ Q_D(QFxPaintedItem);
const QRect content(QPoint(0,0),d->contentsSize);
if (content.width() <= 0 || content.height() <= 0)
return;
@@ -316,7 +316,7 @@ void QFxImageItem::paintGLContents(GLPainter &p)
qp.translate(-r.x(),-r.y());
drawContents(&qp, r);
}
- QFxImageItemPrivate::ImageCacheItem *newitem = new QFxImageItemPrivate::ImageCacheItem;
+ QFxPaintedItemPrivate::ImageCacheItem *newitem = new QFxPaintedItemPrivate::ImageCacheItem;
newitem->area = r;
#if defined(QFX_RENDER_QPAINTER)
newitem->image = QSimpleCanvasConfig::Image(QSimpleCanvasConfig::toImage(img));
diff --git a/src/declarative/fx/qfximageitem.h b/src/declarative/fx/qfxpainteditem.h
index 9ffd44e..015a035 100644
--- a/src/declarative/fx/qfximageitem.h
+++ b/src/declarative/fx/qfxpainteditem.h
@@ -51,17 +51,14 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-/*
-WARNING: SHORT TERM CLASS. INTENDED TO MERGE INTO QFxPainted
-*/
-class QFxImageItemPrivate;
-class Q_DECLARATIVE_EXPORT QFxImageItem : public QFxItem
+class QFxPaintedItemPrivate;
+class Q_DECLARATIVE_EXPORT QFxPaintedItem : public QFxItem
{
Q_OBJECT
public:
- QFxImageItem(QFxItem *parent=0);
- ~QFxImageItem();
+ QFxPaintedItem(QFxItem *parent=0);
+ ~QFxPaintedItem();
Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize);
Q_PROPERTY(bool smooth READ isSmooth WRITE setSmooth);
@@ -78,7 +75,7 @@ public:
void setSmooth(bool);
void setContentsSize(const QSize &);
protected:
- QFxImageItem(QFxImageItemPrivate &dd, QFxItem *parent);
+ QFxPaintedItem(QFxPaintedItemPrivate &dd, QFxItem *parent);
virtual void drawContents(QPainter *p, const QRect &) = 0;
@@ -88,10 +85,10 @@ protected Q_SLOTS:
private:
void init();
- Q_DISABLE_COPY(QFxImageItem)
- Q_DECLARE_PRIVATE(QFxImageItem)
+ Q_DISABLE_COPY(QFxPaintedItem)
+ Q_DECLARE_PRIVATE(QFxPaintedItem)
};
-QML_DECLARE_TYPE(QFxImageItem);
+QML_DECLARE_TYPE(QFxPaintedItem);
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfximageitem_p.h b/src/declarative/fx/qfxpainteditem_p.h
index 80450ec..b0432ac 100644
--- a/src/declarative/fx/qfximageitem_p.h
+++ b/src/declarative/fx/qfxpainteditem_p.h
@@ -62,12 +62,12 @@
QT_BEGIN_NAMESPACE
-class QFxImageItemPrivate : public QFxItemPrivate
+class QFxPaintedItemPrivate : public QFxItemPrivate
{
- Q_DECLARE_PUBLIC(QFxImageItem)
+ Q_DECLARE_PUBLIC(QFxPaintedItem)
public:
- QFxImageItemPrivate()
+ QFxPaintedItemPrivate()
: max_imagecache_size(1000*1000), smooth(false)
{
}
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index 84e209b..a1b5484 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -103,7 +103,7 @@ TextEdit {
Constructs a new QFxTextEdit.
*/
QFxTextEdit::QFxTextEdit(QFxItem *parent)
-: QFxImageItem(*(new QFxTextEditPrivate), parent)
+: QFxPaintedItem(*(new QFxTextEditPrivate), parent)
{
Q_D(QFxTextEdit);
d->init();
@@ -113,7 +113,7 @@ QFxTextEdit::QFxTextEdit(QFxItem *parent)
\internal
*/
QFxTextEdit::QFxTextEdit(QFxTextEditPrivate &dd, QFxItem *parent)
- : QFxImageItem(dd, parent)
+ : QFxPaintedItem(dd, parent)
{
Q_D(QFxTextEdit);
d->init();
@@ -383,7 +383,7 @@ void QFxTextEdit::geometryChanged(const QRectF &newGeometry,
{
if (newGeometry.width() != oldGeometry.width())
updateSize();
- QFxImageItem::geometryChanged(newGeometry, oldGeometry);
+ QFxPaintedItem::geometryChanged(newGeometry, oldGeometry);
}
/*!
@@ -393,7 +393,7 @@ void QFxTextEdit::dump(int depth)
{
QByteArray ba(depth * 4, ' ');
qWarning() << ba.constData() << propertyInfo();
- QFxImageItem::dump(depth);
+ QFxPaintedItem::dump(depth);
}
/*!
@@ -412,7 +412,7 @@ QString QFxTextEdit::propertyInfo() const
void QFxTextEdit::componentComplete()
{
Q_D(QFxTextEdit);
- QFxImageItem::componentComplete();
+ QFxPaintedItem::componentComplete();
if (d->dirty) {
updateSize();
d->dirty = false;
@@ -588,7 +588,7 @@ Handles the given focus \a event.
void QFxTextEdit::focusInEvent(QFocusEvent *event)
{
Q_D(QFxTextEdit);
- QFxImageItem::focusInEvent(event);
+ QFxPaintedItem::focusInEvent(event);
d->control->processEvent(event, QPointF(0, 0));
}
@@ -599,7 +599,7 @@ Handles the given focus \a event.
void QFxTextEdit::focusOutEvent(QFocusEvent *event)
{
Q_D(QFxTextEdit);
- QFxImageItem::focusOutEvent(event);
+ QFxPaintedItem::focusOutEvent(event);
d->control->processEvent(event, QPointF(0, 0));
}
@@ -638,7 +638,7 @@ void QFxTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
event->setAccepted(me->isAccepted());
delete me;
if (!event->isAccepted())
- QFxImageItem::mousePressEvent(event);
+ QFxPaintedItem::mousePressEvent(event);
}
/*!
@@ -653,7 +653,7 @@ void QFxTextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
event->setAccepted(me->isAccepted());
delete me;
if (!event->isAccepted())
- QFxImageItem::mousePressEvent(event);
+ QFxPaintedItem::mousePressEvent(event);
}
/*!
@@ -668,7 +668,7 @@ void QFxTextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
event->setAccepted(me->isAccepted());
delete me;
if (!event->isAccepted())
- QFxImageItem::mousePressEvent(event);
+ QFxPaintedItem::mousePressEvent(event);
}
/*!
diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h
index be84a3c..b017635 100644
--- a/src/declarative/fx/qfxtextedit.h
+++ b/src/declarative/fx/qfxtextedit.h
@@ -43,7 +43,7 @@
#define QFXTEXTEDIT_H
#include <qfxtext.h>
-#include <qfximageitem.h>
+#include <qfxpainteditem.h>
#include <QtGui/qtextdocument.h>
#include <QtGui/qtextoption.h>
@@ -60,7 +60,7 @@ QT_MODULE(Declarative)
WARNING: SHORT TERM CLASS. INTENDED TO MERGE INTO QFxTextItem
*/
class QFxTextEditPrivate;
-class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxImageItem
+class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxPaintedItem
{
Q_OBJECT
Q_ENUMS(VAlignment)
diff --git a/src/declarative/fx/qfxtextedit_p.h b/src/declarative/fx/qfxtextedit_p.h
index aa07484..b583dbe 100644
--- a/src/declarative/fx/qfxtextedit_p.h
+++ b/src/declarative/fx/qfxtextedit_p.h
@@ -54,7 +54,7 @@
//
#include "qfxitem.h"
-#include "qfximageitem_p.h"
+#include "qfxpainteditem_p.h"
#include "qml.h"
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
class QTextLayout;
class QTextDocument;
class QTextControl;
-class QFxTextEditPrivate : public QFxImageItemPrivate
+class QFxTextEditPrivate : public QFxPaintedItemPrivate
{
Q_DECLARE_PUBLIC(QFxTextEdit)
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index dac8ced..3f05846 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -68,7 +68,7 @@
#include "qfxwebview.h"
#include <qsimplecanvasfilter.h>
-#include <private/qfxitem_p.h>
+#include <private/qfxpainteditem_p.h>
QT_BEGIN_NAMESPACE
QML_DEFINE_TYPE(QFxWebView,WebView);
@@ -142,14 +142,14 @@ public:
};
-class QFxWebViewPrivate : public QFxItemPrivate
+class QFxWebViewPrivate : public QFxPaintedItemPrivate
{
Q_DECLARE_PUBLIC(QFxWebView)
public:
QFxWebViewPrivate()
- : page(0), idealwidth(0), idealheight(0), interactive(true), lastPress(0), lastRelease(0), mouseX(0), mouseY(0),
- smooth(true), max_imagecache_size(100000), progress(1.0), pending(PendingNone)
+ : QFxPaintedItemPrivate(), page(0), idealwidth(0), idealheight(0), interactive(true), lastPress(0), lastRelease(0), mouseX(0), mouseY(0),
+ max_imagecache_size(100000), progress(1.0), pending(PendingNone)
{
}
@@ -189,7 +189,6 @@ public:
bool interactive;
QMouseEvent *lastPress, *lastRelease;
int mouseX, mouseY;
- bool smooth;
int max_imagecache_size;
qreal progress;
QBasicTimer dcTimer;
@@ -254,13 +253,13 @@ public:
*/
QFxWebView::QFxWebView(QFxItem *parent)
- : QFxItem(*(new QFxWebViewPrivate), parent)
+ : QFxPaintedItem(*(new QFxWebViewPrivate), parent)
{
init();
}
QFxWebView::QFxWebView(QFxWebViewPrivate &dd, QFxItem *parent)
- : QFxItem(dd, parent)
+ : QFxPaintedItem(dd, parent)
{
init();
}
@@ -284,7 +283,7 @@ void QFxWebView::init()
void QFxWebView::componentComplete()
{
- QFxItem::componentComplete();
+ QFxPaintedItem::componentComplete();
Q_D(QFxWebView);
switch (d->pending) {
case QFxWebViewPrivate::PendingUrl:
@@ -460,28 +459,6 @@ void QFxWebView::setInteractive(bool i)
emit interactiveChanged();
}
-/*!
- \qmlproperty bool WebView::smooth
- This property holds hints as to whether the item should be drawn anti-aliased.
-*/
-/*!
- \property QFxWebView::smooth
- \brief hints as to whether the item should be drawn anti-aliased.
-*/
-bool QFxWebView::smooth() const
-{
- Q_D(const QFxWebView);
- return d->smooth;
-}
-
-void QFxWebView::setSmooth(bool i)
-{
- Q_D(QFxWebView);
- if (d->smooth == i) return;
- d->smooth = i;
- update();
-}
-
void QFxWebView::updateCacheForVisibility()
{
Q_D(QFxWebView);
@@ -514,13 +491,15 @@ void QFxWebView::geometryChanged(const QRectF &newGeometry,
{
if (newGeometry.size() != oldGeometry.size())
expandToWebPage();
- QFxItem::geometryChanged(newGeometry, oldGeometry);
+ QFxPaintedItem::geometryChanged(newGeometry, oldGeometry);
}
void QFxWebView::paintPage(const QRect& r)
{
Q_D(QFxWebView);
- d->dirtyCache(r);
+ if (d->page->mainFrame()->contentsSize() != contentsSize())
+ setContentsSize(d->page->mainFrame()->contentsSize());
+ dirtyCache(r);
update();
}
@@ -575,96 +554,12 @@ void QFxWebView::dump(int depth)
{
QByteArray ba(depth * 4, ' ');
qWarning() << ba.constData() << "url:" << url();
- QFxItem::dump(depth);
+ QFxPaintedItem::dump(depth);
}
-#if defined(QFX_RENDER_QPAINTER)
-void QFxWebView::paintContents(QPainter &p)
-#elif defined(QFX_RENDER_OPENGL)
-void QFxWebView::paintGLContents(GLPainter &p)
-#else
-#error "What render?"
-#endif
+void QFxWebView::drawContents(QPainter *p, const QRect &r)
{
- Q_D(QFxWebView);
- QWebFrame *frame = page()->mainFrame();
- const QRect content(QPoint(0,0),frame->contentsSize());
-
- if (content.width() <= 0 || content.height() <= 0)
- return;
-
-#if defined(QFX_RENDER_QPAINTER)
- bool wasAA = p.testRenderHint(QPainter::Antialiasing);
- bool wasSM = p.testRenderHint(QPainter::SmoothPixmapTransform);
- p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
- QRectF clipf = p.clipRegion().boundingRect();
- const QRect clip = p.clipRegion().isEmpty() ? content : clipf.toRect();
-#elif defined(QFX_RENDER_OPENGL)
- const QRectF clipf = p.sceneClipRect;
- const QRect clip = mapFromScene(clipf).toRect();
-#endif
-
- QRegion topaint(clip);
- topaint &= content;
- QRegion uncached(content);
-
- int cachesize=0;
- for (int i=0; i<d->imagecache.count(); ++i) {
- QRect area = d->imagecache[i]->area;
- if (topaint.contains(area)) {
- p.drawImage(area, d->imagecache[i]->image);
- topaint -= area;
- d->imagecache[i]->age=0;
- } else {
- d->imagecache[i]->age++;
- }
- cachesize += area.width()*area.height();
- uncached -= area;
- }
-
- if (!topaint.isEmpty()) {
- // Find a sensible larger area, otherwise will paint lots of tiny images.
- QRect biggerrect = topaint.boundingRect().adjusted(-64,-64,128,128);
- cachesize += biggerrect.width() * biggerrect.height();
- while (d->imagecache.count() && cachesize > d->max_imagecache_size) {
- 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();
- uncached += d->imagecache[oldest]->area;
- d->imagecache.removeAt(oldest);
- }
- const QRegion bigger = QRegion(biggerrect) & uncached;
- const QVector<QRect> rects = bigger.rects();
- foreach (QRect r, rects) {
- QImage img(r.size(),QImage::Format_ARGB32_Premultiplied);
- img.fill(0);
- {
- QPainter qp(&img);
- qp.translate(-r.x(),-r.y());
- frame->render(&qp,r);
- }
- QFxWebViewPrivate::ImageCacheItem *newitem = new QFxWebViewPrivate::ImageCacheItem;
- newitem->area = r;
-#if defined(QFX_RENDER_QPAINTER)
- newitem->image = QSimpleCanvasConfig::Image(QSimpleCanvasConfig::toImage(img));
-#else
- newitem->image.setImage(img);
-#endif
- d->imagecache.append(newitem);
- p.drawImage(r, newitem->image);
- }
- }
-#if defined(QFX_RENDER_QPAINTER)
- p.setRenderHints(QPainter::Antialiasing, wasAA);
- p.setRenderHints(QPainter::SmoothPixmapTransform, wasSM);
-#endif
+ page()->mainFrame()->render(p,r);
}
QString QFxWebView::propertyInfo() const
@@ -761,7 +656,7 @@ void QFxWebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
event->setAccepted(false);
}
if (!event->isAccepted())
- QFxItem::mousePressEvent(event);
+ QFxPaintedItem::mousePressEvent(event);
}
void QFxWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
@@ -775,7 +670,7 @@ void QFxWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
event->setAccepted(false);
}
if (!event->isAccepted())
- QFxItem::mouseReleaseEvent(event);
+ QFxPaintedItem::mouseReleaseEvent(event);
}
void QFxWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
@@ -796,7 +691,7 @@ void QFxWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
event->setAccepted(false);
}
if (!event->isAccepted())
- QFxItem::mouseMoveEvent(event);
+ QFxPaintedItem::mouseMoveEvent(event);
}
void QFxWebView::keyPressEvent(QKeyEvent* event)
@@ -805,7 +700,7 @@ void QFxWebView::keyPressEvent(QKeyEvent* event)
if (d->interactive)
page()->event(event);
if (!event->isAccepted())
- QFxItem::keyPressEvent(event);
+ QFxPaintedItem::keyPressEvent(event);
}
void QFxWebView::keyReleaseEvent(QKeyEvent* event)
@@ -814,7 +709,7 @@ void QFxWebView::keyReleaseEvent(QKeyEvent* event)
if (d->interactive)
page()->event(event);
if (!event->isAccepted())
- QFxItem::keyReleaseEvent(event);
+ QFxPaintedItem::keyReleaseEvent(event);
}
/*!
diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h
index 6ba4601..afd5b0f 100644
--- a/src/declarative/fx/qfxwebview.h
+++ b/src/declarative/fx/qfxwebview.h
@@ -45,7 +45,7 @@
#include <QAction>
#include <QUrl>
#include <qfxglobal.h>
-#include <qfxitem.h>
+#include <qfxpainteditem.h>
#include <QtNetwork/qnetworkaccessmanager.h>
#include <QWebPage>
@@ -74,7 +74,7 @@ private:
};
-class Q_DECLARATIVE_EXPORT QFxWebView : public QFxItem
+class Q_DECLARATIVE_EXPORT QFxWebView : public QFxPaintedItem
{
Q_OBJECT
@@ -91,7 +91,6 @@ class Q_DECLARATIVE_EXPORT QFxWebView : public QFxItem
Q_PROPERTY(int idealWidth READ idealWidth WRITE setIdealWidth NOTIFY idealWidthChanged)
Q_PROPERTY(int idealHeight READ idealHeight WRITE setIdealHeight NOTIFY idealHeightChanged)
Q_PROPERTY(QString url READ url WRITE setUrl NOTIFY urlChanged)
- Q_PROPERTY(bool smooth READ smooth WRITE setSmooth)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(bool interactive READ interactive WRITE setInteractive NOTIFY interactiveChanged)
@@ -128,9 +127,6 @@ public:
int mouseX() const;
int mouseY() const;
- bool smooth() const;
- void setSmooth(bool);
-
int idealWidth() const;
void setIdealWidth(int);
int idealHeight() const;
@@ -146,11 +142,6 @@ public:
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 &);
-#endif
QWebPage *page() const;
void setPage(QWebPage *page);
@@ -197,6 +188,9 @@ private Q_SLOTS:
protected:
QFxWebView(QFxWebViewPrivate &dd, QFxItem *parent);
+
+ void drawContents(QPainter *, const QRect &);
+
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);