summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/fx')
-rw-r--r--src/declarative/fx/fx.pri9
-rw-r--r--src/declarative/fx/qfxanchors.cpp43
-rw-r--r--src/declarative/fx/qfxanchors.h51
-rw-r--r--src/declarative/fx/qfxanchors_p.h24
-rw-r--r--src/declarative/fx/qfxanimatedimageitem.cpp212
-rw-r--r--src/declarative/fx/qfxanimatedimageitem.h100
-rw-r--r--src/declarative/fx/qfxanimatedimageitem_p.h77
-rw-r--r--src/declarative/fx/qfxcomponentinstance.cpp3
-rw-r--r--src/declarative/fx/qfxcomponentinstance.h5
-rw-r--r--src/declarative/fx/qfxcontentwrapper.cpp144
-rw-r--r--src/declarative/fx/qfxcontentwrapper.h90
-rw-r--r--src/declarative/fx/qfxcontentwrapper_p.h71
-rw-r--r--src/declarative/fx/qfxevents_p.h18
-rw-r--r--src/declarative/fx/qfxflickable.cpp12
-rw-r--r--src/declarative/fx/qfxflickable.h7
-rw-r--r--src/declarative/fx/qfxflickable_p.h2
-rw-r--r--src/declarative/fx/qfxflipable.cpp4
-rw-r--r--src/declarative/fx/qfxflipable.h3
-rw-r--r--src/declarative/fx/qfxflowview.cpp380
-rw-r--r--src/declarative/fx/qfxflowview.h106
-rw-r--r--src/declarative/fx/qfxgridview.cpp16
-rw-r--r--src/declarative/fx/qfxgridview.h4
-rw-r--r--src/declarative/fx/qfximage.cpp2
-rw-r--r--src/declarative/fx/qfximage.h3
-rw-r--r--src/declarative/fx/qfxitem.cpp110
-rw-r--r--src/declarative/fx/qfxitem.h58
-rw-r--r--src/declarative/fx/qfxitem_p.h2
-rw-r--r--src/declarative/fx/qfxkeyactions.h6
-rw-r--r--src/declarative/fx/qfxkeyproxy.h5
-rw-r--r--src/declarative/fx/qfxlayouts.cpp60
-rw-r--r--src/declarative/fx/qfxlayouts.h8
-rw-r--r--src/declarative/fx/qfxlayouts_p.h7
-rw-r--r--src/declarative/fx/qfxlistview.cpp4
-rw-r--r--src/declarative/fx/qfxlistview.h6
-rw-r--r--src/declarative/fx/qfxmouseregion.h5
-rw-r--r--src/declarative/fx/qfxpainteditem.cpp30
-rw-r--r--src/declarative/fx/qfxpainteditem.h12
-rw-r--r--src/declarative/fx/qfxpainteditem_p.h3
-rw-r--r--src/declarative/fx/qfxparticles.cpp1112
-rw-r--r--src/declarative/fx/qfxparticles.h231
-rw-r--r--src/declarative/fx/qfxpath.cpp2
-rw-r--r--src/declarative/fx/qfxpath.h18
-rw-r--r--src/declarative/fx/qfxpathview.h3
-rw-r--r--src/declarative/fx/qfxpathview_p.h1
-rw-r--r--src/declarative/fx/qfxpixmap.cpp2
-rw-r--r--src/declarative/fx/qfxrect.cpp31
-rw-r--r--src/declarative/fx/qfxrect.h11
-rw-r--r--src/declarative/fx/qfxrepeater.h7
-rw-r--r--src/declarative/fx/qfxscalegrid.h5
-rw-r--r--src/declarative/fx/qfxtext.cpp103
-rw-r--r--src/declarative/fx/qfxtext.h19
-rw-r--r--src/declarative/fx/qfxtext_p.h5
-rw-r--r--src/declarative/fx/qfxtextedit.cpp248
-rw-r--r--src/declarative/fx/qfxtextedit.h34
-rw-r--r--src/declarative/fx/qfxtextedit_p.h11
-rw-r--r--src/declarative/fx/qfxtransform.cpp123
-rw-r--r--src/declarative/fx/qfxtransform.h58
-rw-r--r--src/declarative/fx/qfxvisualitemmodel.cpp2
-rw-r--r--src/declarative/fx/qfxvisualitemmodel.h5
-rw-r--r--src/declarative/fx/qfxwebview.cpp11
-rw-r--r--src/declarative/fx/qfxwebview.h12
-rw-r--r--src/declarative/fx/qfxwidgetcontainer.h3
62 files changed, 932 insertions, 2827 deletions
diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri
index 7d8f565..71517fd 100644
--- a/src/declarative/fx/fx.pri
+++ b/src/declarative/fx/fx.pri
@@ -1,17 +1,13 @@
HEADERS += \
fx/qfxanchors.h \
fx/qfxanchors_p.h \
- fx/qfxanimatedimageitem.h \
fx/qfxcomponentinstance.h \
fx/qfxcomponentinstance_p.h \
- fx/qfxcontentwrapper.h \
- fx/qfxcontentwrapper_p.h \
fx/qfxevents_p.h \
fx/qfxflickable.h \
fx/qfxflickable_p.h \
fx/qfxflipable.h \
fx/qfxgridview.h \
- fx/qfxflowview.h \
fx/qfximage.h \
fx/qfxpainteditem.h \
fx/qfxpainteditem_p.h \
@@ -24,7 +20,6 @@ HEADERS += \
fx/qfxlayouts_p.h \
fx/qfxmouseregion.h \
fx/qfxmouseregion_p.h \
- fx/qfxparticles.h \
fx/qfxpath.h \
fx/qfxpath_p.h \
fx/qfxpathview.h \
@@ -46,14 +41,11 @@ HEADERS += \
SOURCES += \
fx/qfxanchors.cpp \
- fx/qfxanimatedimageitem.cpp \
fx/qfxcomponentinstance.cpp \
- fx/qfxcontentwrapper.cpp \
fx/qfxevents.cpp \
fx/qfxflickable.cpp \
fx/qfxflipable.cpp \
fx/qfxgridview.cpp \
- fx/qfxflowview.cpp \
fx/qfximage.cpp \
fx/qfxpainteditem.cpp \
fx/qfxitem.cpp \
@@ -61,7 +53,6 @@ SOURCES += \
fx/qfxkeyproxy.cpp \
fx/qfxlayouts.cpp \
fx/qfxmouseregion.cpp \
- fx/qfxparticles.cpp \
fx/qfxpath.cpp \
fx/qfxpathview.cpp \
fx/qfxrect.cpp \
diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp
index 509e2c8..22b9b08 100644
--- a/src/declarative/fx/qfxanchors.cpp
+++ b/src/declarative/fx/qfxanchors.cpp
@@ -51,7 +51,6 @@ QT_BEGIN_NAMESPACE
QML_DEFINE_TYPE(QFxAnchors,Anchors)
//TODO: should we cache relationships, so we don't have to check each time (parent-child or sibling)?
-//TODO: baseline support
//TODO: support non-parent, non-sibling (need to find lowest common ancestor)
//### const item?
@@ -402,8 +401,8 @@ void QFxAnchorsPrivate::updateVerticalAnchors()
if (fill || centeredIn || !isItemComplete())
return;
- if (!updatingVerticalAnchor) {
- updatingVerticalAnchor = true;
+ if (updatingVerticalAnchor < 2) {
+ ++updatingVerticalAnchor;
if (usedAnchors & QFxAnchors::HasTopAnchor) {
//Handle stretching
bool invalid = true;
@@ -455,7 +454,7 @@ void QFxAnchorsPrivate::updateVerticalAnchors()
setItemY(position(baseline.item, baseline.anchorLine) - item->baselineOffset());
}
}
- updatingVerticalAnchor = false;
+ --updatingVerticalAnchor;
} else {
// ### Make this certain :)
qmlInfo(item) << "Possible anchor loop detected on vertical anchor.";
@@ -467,8 +466,8 @@ void QFxAnchorsPrivate::updateHorizontalAnchors()
if (fill || centeredIn || !isItemComplete())
return;
- if (!updatingHorizontalAnchor) {
- updatingHorizontalAnchor = true;
+ if (updatingHorizontalAnchor < 2) {
+ ++updatingHorizontalAnchor;
if (usedAnchors & QFxAnchors::HasLeftAnchor) {
//Handle stretching
@@ -514,7 +513,7 @@ void QFxAnchorsPrivate::updateHorizontalAnchors()
}
}
- updatingHorizontalAnchor = false;
+ --updatingHorizontalAnchor;
} else {
// ### Make this certain :)
qmlInfo(item) << "Possible anchor loop detected on horizontal anchor.";
@@ -760,93 +759,99 @@ void QFxAnchors::resetHorizontalCenter()
d->updateHorizontalAnchors();
}
-int QFxAnchors::leftMargin() const
+qreal QFxAnchors::leftMargin() const
{
Q_D(const QFxAnchors);
return d->leftMargin;
}
-void QFxAnchors::setLeftMargin(int offset)
+void QFxAnchors::setLeftMargin(qreal offset)
{
Q_D(QFxAnchors);
if (d->leftMargin == offset)
return;
d->leftMargin = offset;
+ d->updateHorizontalAnchors();
emit leftMarginChanged();
}
-int QFxAnchors::rightMargin() const
+qreal QFxAnchors::rightMargin() const
{
Q_D(const QFxAnchors);
return d->rightMargin;
}
-void QFxAnchors::setRightMargin(int offset)
+void QFxAnchors::setRightMargin(qreal offset)
{
Q_D(QFxAnchors);
if (d->rightMargin == offset)
return;
d->rightMargin = offset;
+ d->updateHorizontalAnchors();
emit rightMarginChanged();
}
-int QFxAnchors::horizontalCenterOffset() const
+qreal QFxAnchors::horizontalCenterOffset() const
{
Q_D(const QFxAnchors);
return d->hCenterOffset;
}
-void QFxAnchors::setHorizontalCenterOffset(int offset)
+void QFxAnchors::setHorizontalCenterOffset(qreal offset)
{
Q_D(QFxAnchors);
if (d->hCenterOffset == offset)
return;
d->hCenterOffset = offset;
+ d->updateHorizontalAnchors();
emit horizontalCenterOffsetChanged();
}
-int QFxAnchors::topMargin() const
+qreal QFxAnchors::topMargin() const
{
Q_D(const QFxAnchors);
return d->topMargin;
}
-void QFxAnchors::setTopMargin(int offset)
+void QFxAnchors::setTopMargin(qreal offset)
{
Q_D(QFxAnchors);
if (d->topMargin == offset)
return;
d->topMargin = offset;
+ d->updateVerticalAnchors();
emit topMarginChanged();
}
-int QFxAnchors::bottomMargin() const
+qreal QFxAnchors::bottomMargin() const
{
Q_D(const QFxAnchors);
return d->bottomMargin;
}
-void QFxAnchors::setBottomMargin(int offset)
+void QFxAnchors::setBottomMargin(qreal offset)
{
Q_D(QFxAnchors);
if (d->bottomMargin == offset)
return;
d->bottomMargin = offset;
+ d->updateVerticalAnchors();
emit bottomMarginChanged();
}
-int QFxAnchors::verticalCenterOffset() const
+qreal QFxAnchors::verticalCenterOffset() const
{
Q_D(const QFxAnchors);
return d->vCenterOffset;
}
-void QFxAnchors::setVerticalCenterOffset(int offset)
+void QFxAnchors::setVerticalCenterOffset(qreal offset)
{
Q_D(QFxAnchors);
if (d->vCenterOffset == offset)
return;
d->vCenterOffset = offset;
+ d->updateVerticalAnchors();
emit verticalCenterOffsetChanged();
}
diff --git a/src/declarative/fx/qfxanchors.h b/src/declarative/fx/qfxanchors.h
index 206a05c..dcd5d79 100644
--- a/src/declarative/fx/qfxanchors.h
+++ b/src/declarative/fx/qfxanchors.h
@@ -46,15 +46,13 @@
#include <QtDeclarative/qfxglobal.h>
#include <QtDeclarative/qml.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QFxItem;
-class QFxAnchorsPrivate;
+class QFxItem;
class QFxAnchorLine
{
public:
@@ -79,8 +77,6 @@ public:
AnchorLine anchorLine;
};
-Q_DECLARE_METATYPE(QFxAnchorLine)
-
class QFxAnchorsPrivate;
class Q_DECLARATIVE_EXPORT QFxAnchors : public QObject
{
@@ -93,12 +89,12 @@ class Q_DECLARATIVE_EXPORT QFxAnchors : public QObject
Q_PROPERTY(QFxAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom)
Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter)
Q_PROPERTY(QFxAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline)
- Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged)
- Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged)
- Q_PROPERTY(int horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged())
- Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged)
- Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged)
- Q_PROPERTY(int verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged())
+ Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged)
+ Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged)
+ Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged())
+ Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged)
+ Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged)
+ Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged())
Q_PROPERTY(QFxItem *fill READ fill WRITE setFill)
Q_PROPERTY(QFxItem *centeredIn READ centeredIn WRITE setCenteredIn)
@@ -121,7 +117,7 @@ public:
QFxAnchorLine left() const;
void setLeft(const QFxAnchorLine &edge);
- Q_INVOKABLE void resetLeft(); //### temporarily invokable for testing
+ void resetLeft();
QFxAnchorLine right() const;
void setRight(const QFxAnchorLine &edge);
@@ -147,23 +143,23 @@ public:
void setBaseline(const QFxAnchorLine &edge);
void resetBaseline();
- int leftMargin() const;
- void setLeftMargin(int);
+ qreal leftMargin() const;
+ void setLeftMargin(qreal);
- int rightMargin() const;
- void setRightMargin(int);
+ qreal rightMargin() const;
+ void setRightMargin(qreal);
- int horizontalCenterOffset() const;
- void setHorizontalCenterOffset(int);
+ qreal horizontalCenterOffset() const;
+ void setHorizontalCenterOffset(qreal);
- int topMargin() const;
- void setTopMargin(int);
+ qreal topMargin() const;
+ void setTopMargin(qreal);
- int bottomMargin() const;
- void setBottomMargin(int);
+ qreal bottomMargin() const;
+ void setBottomMargin(qreal);
- int verticalCenterOffset() const;
- void setVerticalCenterOffset(int);
+ qreal verticalCenterOffset() const;
+ void setVerticalCenterOffset(qreal);
QFxItem *fill() const;
void setFill(QFxItem *);
@@ -189,10 +185,11 @@ private:
Q_DECLARE_PRIVATE(QFxAnchors)
};
-QML_DECLARE_TYPE(QFxAnchors)
-
-
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QFxAnchorLine)
+QML_DECLARE_TYPE(QFxAnchors)
+
QT_END_HEADER
+
#endif
diff --git a/src/declarative/fx/qfxanchors_p.h b/src/declarative/fx/qfxanchors_p.h
index 32d8b75..a7c904b 100644
--- a/src/declarative/fx/qfxanchors_p.h
+++ b/src/declarative/fx/qfxanchors_p.h
@@ -56,15 +56,15 @@
#include "qfxanchors.h"
#include "private/qobject_p.h"
-
QT_BEGIN_NAMESPACE
+
class QFxAnchorsPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QFxAnchors)
public:
QFxAnchorsPrivate()
- : updatingMe(false), updatingHorizontalAnchor(false),
- updatingVerticalAnchor(false), item(0), usedAnchors(0), fill(0),
+ : updatingMe(false), updatingHorizontalAnchor(0),
+ updatingVerticalAnchor(0), item(0), usedAnchors(0), fill(0),
centeredIn(0), leftMargin(0), rightMargin(0), topMargin(0),
bottomMargin(0), vCenterOffset(0), hCenterOffset(0)
{
@@ -80,9 +80,9 @@ public:
void remDepend(QFxItem *);
bool isItemComplete() const;
- bool updatingMe:1;
- bool updatingHorizontalAnchor:1;
- bool updatingVerticalAnchor:1;
+ bool updatingMe;
+ int updatingHorizontalAnchor;
+ int updatingVerticalAnchor;
void setItemHeight(qreal);
void setItemWidth(qreal);
@@ -119,12 +119,12 @@ public:
QFxAnchorLine hCenter;
QFxAnchorLine baseline;
- int leftMargin;
- int rightMargin;
- int topMargin;
- int bottomMargin;
- int vCenterOffset;
- int hCenterOffset;
+ qreal leftMargin;
+ qreal rightMargin;
+ qreal topMargin;
+ qreal bottomMargin;
+ qreal vCenterOffset;
+ qreal hCenterOffset;
};
diff --git a/src/declarative/fx/qfxanimatedimageitem.cpp b/src/declarative/fx/qfxanimatedimageitem.cpp
deleted file mode 100644
index d22959a..0000000
--- a/src/declarative/fx/qfxanimatedimageitem.cpp
+++ /dev/null
@@ -1,212 +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 <QMovie>
-#include <QtDeclarative/qmlcontext.h>
-#include <QtDeclarative/qmlengine.h>
-#include "qfxanimatedimageitem.h"
-#include "qfxanimatedimageitem_p.h"
-#include <QNetworkRequest>
-#include <QNetworkReply>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QFxAnimatedImageItem
- \internal
-*/
-
-/*!
- \qmlclass AnimatedImage
- \inherits Image
-
- This item provides for playing animations stored as images containing a series of frames,
- such as GIF files. The full list of supported formats can be determined with
- QMovie::supportedFormats().
-
- \table
- \row
- \o \image animatedimageitem.gif
- \o
- \qml
-Item {
- width: anim.width; height: anim.height+8
- AnimatedImage { id: anim; source: "pics/games-anim.gif" }
- Rect { color: "red"; width: 4; height: 8; y: anim.height
- x: (anim.width-width)*anim.currentFrame/(anim.frameCount-1)
- }
-}
- \endqml
- \endtable
-*/
-QML_DEFINE_TYPE(QFxAnimatedImageItem, AnimatedImage)
-
-QFxAnimatedImageItem::QFxAnimatedImageItem(QFxItem *parent)
- : QFxImage(*(new QFxAnimatedImageItemPrivate), parent)
-{
-}
-
-QFxAnimatedImageItem::QFxAnimatedImageItem(QFxAnimatedImageItemPrivate &dd, QFxItem *parent)
- : QFxImage(dd, parent)
-{
-}
-
-QFxAnimatedImageItem::~QFxAnimatedImageItem()
-{
- Q_D(QFxAnimatedImageItem);
- delete d->_movie;
-}
-
-/*!
- \qmlproperty bool AnimatedImage::playing
- This property holds whether the animated image is playing or not
-
- Defaults to true, so as to start playing immediately.
-*/
-bool QFxAnimatedImageItem::isPlaying() const
-{
- Q_D(const QFxAnimatedImageItem);
- if (!d->_movie)
- return false;
- return d->_movie->state()==QMovie::Running;
-}
-
-void QFxAnimatedImageItem::setPlaying(bool play)
-{
- Q_D(QFxAnimatedImageItem);
- if (!d->_movie)
- return;
- if (play)
- d->_movie->start();
- else
- d->_movie->stop();
-}
-
-/*!
- \qmlproperty int AnimatedImage::currentFrame
- \qmlproperty int AnimatedImage::frameCount
-
- currentFrame is the frame that is currently visible. Watching when this changes can
- allow other things to animate at the same time as the image. frameCount is the number
- of frames in the animation. For some animation formats, frameCount is unknown and set to zero.
-*/
-int QFxAnimatedImageItem::currentFrame() const
-{
- Q_D(const QFxAnimatedImageItem);
- if (!d->_movie)
- return -1;
- return d->_movie->currentFrameNumber();
-}
-
-void QFxAnimatedImageItem::setCurrentFrame(int frame)
-{
- Q_D(QFxAnimatedImageItem);
- if (!d->_movie)
- return;
- d->_movie->jumpToFrame(frame);
-}
-
-int QFxAnimatedImageItem::frameCount() const
-{
- Q_D(const QFxAnimatedImageItem);
- if (!d->_movie)
- return 0;
- return d->_movie->frameCount();
-}
-
-void QFxAnimatedImageItem::setSource(const QUrl &url)
-{
- Q_D(QFxAnimatedImageItem);
- if (url == d->url)
- return;
-
- delete d->_movie;
- d->_movie = 0;
-
- if (d->reply) {
- d->reply->deleteLater();
- d->reply = 0;
- }
-
- d->url = url;
-
- if (url.isEmpty()) {
- delete d->_movie;
- d->status = Idle;
- } else {
- d->status = Loading;
- QNetworkRequest req(d->url);
- req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
- d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req);
- QObject::connect(d->reply, SIGNAL(finished()),
- this, SLOT(movieRequestFinished()));
- }
-
- emit statusChanged(d->status);
-}
-
-void QFxAnimatedImageItem::movieRequestFinished()
-{
- Q_D(QFxAnimatedImageItem);
- d->_movie = new QMovie(d->reply);
- if (!d->_movie->isValid()){
- qWarning() << "Error Reading File " << d->url;
- delete d->_movie;
- d->_movie = 0;
- return;
- }
- connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)),
- this, SIGNAL(playingChanged()));
- connect(d->_movie, SIGNAL(frameChanged(int)),
- this, SLOT(movieUpdate()));
- d->_movie->setCacheMode(QMovie::CacheAll);
- d->_movie->start();
- setPixmap(d->_movie->currentPixmap());
-}
-
-void QFxAnimatedImageItem::movieUpdate()
-{
- Q_D(QFxAnimatedImageItem);
- setPixmap(d->_movie->currentPixmap());
- emit frameChanged();
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxanimatedimageitem.h b/src/declarative/fx/qfxanimatedimageitem.h
deleted file mode 100644
index 8ef2b1c..0000000
--- a/src/declarative/fx/qfxanimatedimageitem.h
+++ /dev/null
@@ -1,100 +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 QFXANIMATEDIMAGEITEM_H
-#define QFXANIMATEDIMAGEITEM_H
-
-#include <QtDeclarative/qfximage.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QMovie;
-class QFxAnimatedImageItemPrivate;
-
-class Q_DECLARATIVE_EXPORT QFxAnimatedImageItem : public QFxImage
-{
- Q_OBJECT
-
- Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
- Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY frameChanged)
- Q_PROPERTY(int frameCount READ frameCount)
-public:
- QFxAnimatedImageItem(QFxItem *parent=0);
- ~QFxAnimatedImageItem();
-
- bool isPlaying() const;
- void setPlaying(bool play);
-
- int currentFrame() const;
- void setCurrentFrame(int frame);
-
- int frameCount() const;
-
- // Extends QFxImage's src property*/
- virtual void setSource(const QUrl&);
-
-Q_SIGNALS:
- void playingChanged();
- void frameChanged();
-
-private Q_SLOTS:
- void movieUpdate();
- void movieRequestFinished();
-
-protected:
- QFxAnimatedImageItem(QFxAnimatedImageItemPrivate &dd, QFxItem *parent);
-
-private:
- Q_DISABLE_COPY(QFxAnimatedImageItem)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxAnimatedImageItem)
-};
-
-QML_DECLARE_TYPE(QFxAnimatedImageItem)
-
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-#endif
diff --git a/src/declarative/fx/qfxanimatedimageitem_p.h b/src/declarative/fx/qfxanimatedimageitem_p.h
deleted file mode 100644
index cb5da63..0000000
--- a/src/declarative/fx/qfxanimatedimageitem_p.h
+++ /dev/null
@@ -1,77 +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 QFXANIMATEDIMAGE_P_H
-#define QFXANIMATEDIMAGE_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 "qfximage_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QMovie;
-
-class QFxAnimatedImageItemPrivate : public QFxImagePrivate
-{
- Q_DECLARE_PUBLIC(QFxAnimatedImageItem)
-
-public:
- QFxAnimatedImageItemPrivate()
- : _movie(0)
- {
- }
-
- QMovie *_movie;
-};
-
-QT_END_NAMESPACE
-
-#endif // QFXANIMATEDIMAGE_P_H
diff --git a/src/declarative/fx/qfxcomponentinstance.cpp b/src/declarative/fx/qfxcomponentinstance.cpp
index d3f7061..6cf8e74 100644
--- a/src/declarative/fx/qfxcomponentinstance.cpp
+++ b/src/declarative/fx/qfxcomponentinstance.cpp
@@ -41,8 +41,7 @@
#include "qfxcomponentinstance.h"
#include "qfxcomponentinstance_p.h"
-#include <qfxperf.h>
-#include <qfxcontentwrapper.h>
+#include <private/qfxperf_p.h>
#include <QtDeclarative/qmlinfo.h>
diff --git a/src/declarative/fx/qfxcomponentinstance.h b/src/declarative/fx/qfxcomponentinstance.h
index 97b8b7b..940fb6d 100644
--- a/src/declarative/fx/qfxcomponentinstance.h
+++ b/src/declarative/fx/qfxcomponentinstance.h
@@ -44,12 +44,12 @@
#include <QtDeclarative/qfxitem.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class QFxComponentInstancePrivate;
class Q_DECLARATIVE_EXPORT QFxComponentInstance : public QFxItem
{
@@ -80,10 +80,11 @@ protected:
private:
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxComponentInstance)
};
-QML_DECLARE_TYPE(QFxComponentInstance)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxComponentInstance)
+
QT_END_HEADER
#endif // QFXCOMPONENTINSTANCE_H
diff --git a/src/declarative/fx/qfxcontentwrapper.cpp b/src/declarative/fx/qfxcontentwrapper.cpp
deleted file mode 100644
index 1fa0fde..0000000
--- a/src/declarative/fx/qfxcontentwrapper.cpp
+++ /dev/null
@@ -1,144 +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 "qfxcontentwrapper.h"
-#include "qfxcontentwrapper_p.h"
-
-
-QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(QFxContentWrapper,ContentWrapper)
-
-/*!
- \qmlclass ContentWrapper QFxContentWrapper
- \ingroup group_utility
- \brief ContentWrapper provides a component which contains content.
- \inherits Item
-
- In some cases the content of a component is not defined by the component itself.
- For example, the items placed in a group box need to be specified external to
- group box component definition itself.
- In cases like these \l Content can be used to specify at what location in the component
- the content should be placed. It is used in conjuntion with the \e content property of
- ContentWrapper: any items listed as content will be placed in the location
- specified by Content. The component containing the Content must be of type
- ContentWrapper.
-
- GroupBox component definition:
- \quotefile doc/src/snippets/declarative/GroupBox.qml
-
- \bold Note that in the above component definition ContentWrapper's \e children
- property is specified explicitly since \e content is the default property.
-
- Component use:
- \table
- \row \o \image content.png
- \o \quotefile doc/src/snippets/declarative/content.qml
- \endtable
-
- \sa Content
-*/
-
-QFxContentWrapper::QFxContentWrapper(QFxItem *parent)
-: QFxItem(*(new QFxContentWrapperPrivate), parent)
-{
-}
-
-QFxContentWrapper::QFxContentWrapper(QFxContentWrapperPrivate &dd, QFxItem *parent)
- : QFxItem(dd, parent)
-{
-}
-
-/*!
- \qmlproperty list<Item> ContentWrapper::content
-
- Contains the list of elements to replace the \l Content
- placeholder.
-
- \sa Content
-*/
-QList<QFxItem *> *QFxContentWrapper::content()
-{
- Q_D(QFxContentWrapper);
- return &(d->_content);
-}
-
-void QFxContentWrapper::componentComplete()
-{
- QFxItem::componentComplete();
- if (content()->size() < 1)
- return;
-
- QList<QGraphicsItem *> nodes;
- nodes.append(this);
- QFxItem *target = findContent(nodes);
- if (!target)
- return;
- target = target->itemParent();
-
- QList<QFxItem*> myContent(*content());
- for (int ii = 0; ii < myContent.count(); ++ii)
- myContent.at(ii)->setParent(target);
-}
-
-QFxItem *QFxContentWrapper::findContent(QList<QGraphicsItem *> &nodes)
-{
- QGraphicsItem *item = nodes.takeFirst();
- if (qobject_cast<QFxContent*>(item))
- return static_cast<QFxItem *>(item);
- nodes << item->children();
- if (nodes.isEmpty())
- return 0;
- return findContent(nodes);
-}
-
-QML_DEFINE_TYPE(QFxContent,Content)
-
-/*!
- \qmlclass Content QFxContent
- \ingroup group_utility
- \brief Content is used as a placeholder for the content of a component.
- \inherits Item
-
- The Content element is used to place content within a component.
- See \l ContentWrapper for usage.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxcontentwrapper.h b/src/declarative/fx/qfxcontentwrapper.h
deleted file mode 100644
index 898d695..0000000
--- a/src/declarative/fx/qfxcontentwrapper.h
+++ /dev/null
@@ -1,90 +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 QFXCONTENTWRAPPER_H
-#define QFXCONTENTWRAPPER_H
-
-#include <QtDeclarative/qfxitem.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QFxContentWrapperPrivate;
-class Q_DECLARATIVE_EXPORT QFxContentWrapper : public QFxItem
-{
- Q_OBJECT
-
- Q_PROPERTY(QList<QFxItem *>* content READ content DESIGNABLE false)
- Q_CLASSINFO("DefaultProperty", "content")
-public:
- QFxContentWrapper(QFxItem *parent=0);
-
- QList<QFxItem *> *content();
-
-private:
- void create();
- QFxItem *findContent(QList<QGraphicsItem *> &nodes);
-
-protected:
- void componentComplete();
- QFxContentWrapper(QFxContentWrapperPrivate &dd, QFxItem *parent);
-
-private:
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxContentWrapper)
-};
-QML_DECLARE_TYPE(QFxContentWrapper)
-
-class Q_DECLARATIVE_EXPORT QFxContent : public QFxItem
-{
- Q_OBJECT
-public:
- QFxContent(QFxItem *parent=0) : QFxItem(parent) {}
-};
-QML_DECLARE_TYPE(QFxContent)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QFXCONTENTWRAPPER_H
diff --git a/src/declarative/fx/qfxcontentwrapper_p.h b/src/declarative/fx/qfxcontentwrapper_p.h
deleted file mode 100644
index a75fa1e..0000000
--- a/src/declarative/fx/qfxcontentwrapper_p.h
+++ /dev/null
@@ -1,71 +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 QFXCONTENTWRAPPER_P_H
-#define QFXCONTENTWRAPPER_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"
-#include "qfxcontentwrapper.h"
-
-
-QT_BEGIN_NAMESPACE
-class QFxContentWrapperPrivate : public QFxItemPrivate
-{
- Q_DECLARE_PUBLIC(QFxContentWrapper)
-public:
- QFxContentWrapperPrivate() { }
-
- QList<QFxItem *> _content;
-};
-
-QT_END_NAMESPACE
-#endif // QFXCONTENTWRAPPER_P_H
diff --git a/src/declarative/fx/qfxevents_p.h b/src/declarative/fx/qfxevents_p.h
index 2eb29af..fbf0c5f 100644
--- a/src/declarative/fx/qfxevents_p.h
+++ b/src/declarative/fx/qfxevents_p.h
@@ -42,6 +42,17 @@
#ifndef QFXEVENTS_P_H
#define QFXEVENTS_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 <QtDeclarative/qfxglobal.h>
#include <QtDeclarative/qml.h>
#include <QtCore/qobject.h>
@@ -78,8 +89,6 @@ private:
QKeyEvent event;
};
-QML_DECLARE_TYPE(QFxKeyEvent)
-
class QFxMouseEvent : public QObject
{
Q_OBJECT
@@ -120,8 +129,9 @@ private:
bool _accepted;
};
-QML_DECLARE_TYPE(QFxMouseEvent)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxKeyEvent)
+QML_DECLARE_TYPE(QFxMouseEvent)
+
#endif // QFXEVENTS_P_H
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp
index f85f3dc..59191c9 100644
--- a/src/declarative/fx/qfxflickable.cpp
+++ b/src/declarative/fx/qfxflickable.cpp
@@ -112,8 +112,8 @@ void QFxFlickablePrivate::init()
QObject::connect(&_tl, SIGNAL(completed()), q, SLOT(movementEnding()));
q->setAcceptedMouseButtons(Qt::LeftButton);
q->setOptions(QFxItem::ChildMouseFilter | QFxItem::MouseEvents);
- QObject::connect(_flick, SIGNAL(leftChanged()), q, SIGNAL(positionChanged()));
- QObject::connect(_flick, SIGNAL(topChanged()), q, SIGNAL(positionChanged()));
+ QObject::connect(_flick, SIGNAL(xChanged()), q, SIGNAL(positionChanged()));
+ QObject::connect(_flick, SIGNAL(yChanged()), q, SIGNAL(positionChanged()));
QObject::connect(&elasticX, SIGNAL(updated()), q, SLOT(ticked()));
QObject::connect(&elasticY, SIGNAL(updated()), q, SLOT(ticked()));
QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(heightChange()));
@@ -597,7 +597,13 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
int dx = int(event->pos().x() - pressPos.x());
if (qAbs(dx) > FlickThreshold || pressTime.elapsed() > 200) {
qreal newX = dx + pressX;
- if (q->overShoot() || (newX <= q->minXExtent() && newX >= q->maxXExtent())) {
+ const qreal minX = q->minXExtent();
+ const qreal maxX = q->maxXExtent();
+ if (newX > minX)
+ newX = minX + (newX - minX) / 2;
+ if (newX < maxX && maxX - minX < 0)
+ newX = maxX + (newX - maxX) / 2;
+ if (q->overShoot() || (newX <= minX && newX >= maxX)) {
if (dragMode == QFxFlickable::Hard)
_moveX.setValue(newX);
else
diff --git a/src/declarative/fx/qfxflickable.h b/src/declarative/fx/qfxflickable.h
index a08e814..a6c2a6c 100644
--- a/src/declarative/fx/qfxflickable.h
+++ b/src/declarative/fx/qfxflickable.h
@@ -44,12 +44,12 @@
#include <QtDeclarative/qfxitem.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class QFxFlickablePrivate;
class Q_DECLARATIVE_EXPORT QFxFlickable : public QFxItem
{
@@ -186,10 +186,11 @@ private:
Q_DISABLE_COPY(QFxFlickable)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxFlickable)
};
-QML_DECLARE_TYPE(QFxFlickable)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxFlickable)
+
QT_END_HEADER
+
#endif
diff --git a/src/declarative/fx/qfxflickable_p.h b/src/declarative/fx/qfxflickable_p.h
index a3b1500..28ec6d8 100644
--- a/src/declarative/fx/qfxflickable_p.h
+++ b/src/declarative/fx/qfxflickable_p.h
@@ -57,7 +57,7 @@
#include "qfxflickable.h"
#include "qfxitem_p.h"
#include "qml.h"
-#include "qmltimelinevalueproxy.h"
+#include "private/qmltimeline_p.h"
#include "private/qmlanimation_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp
index d6222f3..6089d0a 100644
--- a/src/declarative/fx/qfxflipable.cpp
+++ b/src/declarative/fx/qfxflipable.cpp
@@ -44,6 +44,8 @@
#include "qfxtransform.h"
#include <QtDeclarative/qmlinfo.h>
+QT_BEGIN_NAMESPACE
+
QML_DEFINE_TYPE(QFxFlipable,Flipable)
class QFxFlipablePrivate : public QFxItemPrivate
@@ -94,7 +96,7 @@ Flipable {
]
transitions: [
Transition {
- NumericAnimation {
+ NumberAnimation {
easing: "easeInOutQuad"
properties: "rotation"
}
diff --git a/src/declarative/fx/qfxflipable.h b/src/declarative/fx/qfxflipable.h
index 5a6271b..5aa038d 100644
--- a/src/declarative/fx/qfxflipable.h
+++ b/src/declarative/fx/qfxflipable.h
@@ -94,10 +94,11 @@ private:
Q_DISABLE_COPY(QFxFlipable)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxFlipable)
};
-QML_DECLARE_TYPE(QFxFlipable)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxFlipable)
+
QT_END_HEADER
#endif // QFXFLIPABLE_H
diff --git a/src/declarative/fx/qfxflowview.cpp b/src/declarative/fx/qfxflowview.cpp
deleted file mode 100644
index e02e186..0000000
--- a/src/declarative/fx/qfxflowview.cpp
+++ /dev/null
@@ -1,380 +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 "qfxvisualitemmodel.h"
-#include "qfxflowview.h"
-
-QT_BEGIN_NAMESPACE
-
-class QFxFlowViewAttached : public QObject
-{
-Q_OBJECT
-Q_PROPERTY(int row READ row NOTIFY posChanged);
-Q_PROPERTY(int column READ column NOTIFY posChanged);
-public:
- QFxFlowViewAttached(QObject *parent);
-
- int row() const;
- int column() const;
-
-signals:
- void posChanged();
-
-private:
- friend class QFxFlowView;
- int m_row;
- int m_column;
-};
-
-
-QFxFlowView::QFxFlowView()
-: m_columns(0), m_model(0), m_vertical(false), m_dragItem(0), m_dragIdx(-1)
-{
- setAcceptedMouseButtons(Qt::LeftButton);
- setOptions(MouseEvents);
-}
-
-QFxVisualItemModel *QFxFlowView::model() const
-{
- return m_model;
-}
-
-void QFxFlowView::setModel(QFxVisualItemModel *m)
-{
- m_model = m;
- refresh();
-}
-
-int QFxFlowView::columns() const
-{
- return m_columns;
-}
-
-void QFxFlowView::setColumns(int c)
-{
- m_columns = c;
- refresh();
-}
-
-bool QFxFlowView::vertical() const
-{
- return m_vertical;
-}
-
-void QFxFlowView::setVertical(bool v)
-{
- m_vertical = v;
-}
-
-class QFxFlowViewValue : public QmlTimeLineValue
-{
-public:
- enum Property { xProperty, yProperty };
-
- QFxFlowViewValue(QFxItem *item, Property p)
- : m_item(item), m_property(p) {}
-
- qreal value() const {
- return (m_property == xProperty)?m_item->x():m_item->y();
- }
- void setValue(qreal v) {
- if (m_property == xProperty) m_item->setX(v);
- else m_item->setY(v);
- }
-private:
- QFxItem *m_item;
- Property m_property;
-};
-
-void QFxFlowView::refresh()
-{
- if (m_model && m_columns >= 1) {
- for (int ii = 0; ii < m_model->count(); ++ii) {
- QFxItem *item = m_model->item(ii);
- item->setParent(this);
- item->setZ(0);
- m_items << item;
- }
-
- reflow();
- }
-}
-
-void QFxFlowView::reflow(bool animate)
-{
- qreal y = 0;
- qreal maxY = 0;
- qreal x = 0;
- int row = 0;
- int column = -1;
- if (animate)
- clearTimeLine();
-
- for (int ii = 0; ii < m_items.count(); ++ii) {
- if (0 == (ii % m_columns)) {
- y += maxY;
- maxY = 0;
- x = 0;
- row = 0;
- column++;
- }
-
- QFxItem *item = m_items.at(ii);
- QFxFlowViewAttached *att =
- (QFxFlowViewAttached *)qmlAttachedPropertiesObject<QFxFlowView>(item);
- att->m_row = row;
- att->m_column = column;
- emit att->posChanged();
-
-
- if (animate) {
- if (vertical())
- moveItem(item, QPointF(y, x));
- else
- moveItem(item, QPointF(x, y));
- } else {
- if (vertical()) {
- item->setX(y);
- item->setY(x);
- } else {
- item->setX(x);
- item->setY(y);
- }
- }
- if (vertical()) {
- x += item->height();
- maxY = qMax(maxY, item->width());
- } else {
- x += item->width();
- maxY = qMax(maxY, item->height());
- }
- ++row;
- }
-}
-
-void QFxFlowView::reflowDrag(const QPointF &dp)
-{
- qreal y = 0;
- qreal maxY = 0;
- qreal x = 0;
-
- int flowedItems = 0;
-
- clearTimeLine();
-
- QList<QFxItem *> items;
-
- bool dragUsed = false;
- bool dragSeen = false;
- for (int ii = 0; ii < m_items.count(); ++ii) {
- if (0 == (ii % m_columns)) {
- y += maxY;
- maxY = 0;
- x = 0;
- }
-
- QFxItem *item = m_items.at(ii);
- if (item == m_dragItem)
- dragSeen = true;
- if (item == m_dragItem && dragUsed)
- continue;
- QRectF r;
- if (vertical())
- r = QRectF(y, x, item->width(), item->height());
- else
- r = QRectF(x, y, item->width(), item->height());
- if (r.contains(dp)) {
- dragUsed = true;
- if (dragSeen)
- m_dragIdx = items.count() + 1;
- else
- m_dragIdx = items.count();
-
- items.append(m_dragItem);
- if (m_dragItem != item) {
- if (dragSeen)
- items.insert(items.count() - 1, item);
- else
- items.append(item);
- }
- } else {
- if (m_dragItem != item)
- items.append(item);
- }
-
- if (vertical()) {
- x += item->height();
- maxY = qMax(maxY, item->width());
- } else {
- x += item->width();
- maxY = qMax(maxY, item->height());
- }
- }
-
- y = 0;
- maxY = 0;
- x = 0;
- clearTimeLine();
- for (int ii = 0; ii < items.count(); ++ii) {
- if (0 == (ii % m_columns)) {
- y += maxY;
- maxY = 0;
- x = 0;
- }
-
- QFxItem *item = items.at(ii);
- if (item != m_dragItem) {
- if (vertical())
- moveItem(item, QPointF(y, x));
- else
- moveItem(item, QPointF(x, y));
- }
- if (vertical()) {
- x += item->height();
- maxY = qMax(maxY, item->width());
- } else {
- x += item->width();
- maxY = qMax(maxY, item->height());
- }
- }
-
-}
-
-void QFxFlowView::moveItem(QFxItem *item, const QPointF &p)
-{
- QFxFlowViewValue *xv = new QFxFlowViewValue(item, QFxFlowViewValue::xProperty);
- QFxFlowViewValue *yv = new QFxFlowViewValue(item, QFxFlowViewValue::yProperty);
- m_values << xv << yv;
- m_timeline.move(*xv, p.x(), 100);
- m_timeline.move(*yv, p.y(), 100);
-}
-
-#include <QGraphicsSceneMouseEvent>
-
-void QFxFlowView::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- for (int ii = 0; ii < m_items.count(); ++ii) {
- QFxItem *item = m_items.at(ii);
- QRectF r = rectForItem(ii);
-
- if (r.contains(event->pos())) {
- m_dragItem = item;
- m_dragItem->setZ(1);
- m_dragOffset = r.topLeft() - event->pos();
- event->accept();
- return;
- }
- }
- event->ignore();
-}
-
-QRectF QFxFlowView::rectForItem(int idx) const
-{
- QFxItem *item = m_items.at(idx);
- QRectF r(item->x(), item->y(), item->width(), item->height());
- return r;
-}
-
-void QFxFlowView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- if (m_dragItem) {
- m_dragItem->setZ(0);
-
- clearTimeLine();
-
- if (m_dragIdx != -1) {
- m_items.removeAll(m_dragItem);
- m_items.insert(m_dragIdx, m_dragItem);
- }
-
- reflow(true);
- m_dragItem = 0;
- m_dragIdx = -1;
- }
-}
-
-QFxFlowViewAttached::QFxFlowViewAttached(QObject *parent)
-: QObject(parent), m_row(0), m_column(0)
-{
-}
-
-int QFxFlowViewAttached::row() const
-{
- return m_row;
-}
-
-int QFxFlowViewAttached::column() const
-{
- return m_column;
-}
-
-QFxFlowViewAttached *QFxFlowView::qmlAttachedProperties(QObject *obj)
-{
- return new QFxFlowViewAttached(obj);
-}
-
-void QFxFlowView::clearTimeLine()
-{
- m_timeline.clear();
- qDeleteAll(m_values);
- m_values.clear();
-}
-
-void QFxFlowView::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- if (m_dragItem) {
- QPointF p = event->pos() + m_dragOffset;
- m_dragItem->setX(p.x());
- m_dragItem->setY(p.y());
-
- for (int ii = 0; ii < m_items.count(); ++ii) {
- if (m_items.at(ii) != m_dragItem && rectForItem(ii).contains(event->pos())) {
- reflowDrag(event->pos());
- }
- }
- }
-}
-
-QML_DEFINE_TYPE(QFxFlowView,FlowView);
-
-#include "qfxflowview.moc"
-
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxflowview.h b/src/declarative/fx/qfxflowview.h
deleted file mode 100644
index 0e7c2d3..0000000
--- a/src/declarative/fx/qfxflowview.h
+++ /dev/null
@@ -1,106 +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 QFXFLOWVIEW_H
-#define QFXFLOWVIEW_H
-
-#include <QtDeclarative/QmlTimeLine>
-#include <QtDeclarative/qfxitem.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-class QFxVisualItemModel;
-class QFxFlowViewValue;
-class QFxFlowViewAttached;
-class Q_DECLARATIVE_EXPORT QFxFlowView : public QFxItem
-{
- Q_OBJECT
- Q_PROPERTY(QFxVisualItemModel *model READ model WRITE setModel)
- Q_PROPERTY(int column READ columns WRITE setColumns);
- Q_PROPERTY(bool vertical READ vertical WRITE setVertical);
-
-public:
- QFxFlowView();
-
- QFxVisualItemModel *model() const;
- void setModel(QFxVisualItemModel *);
-
- int columns() const;
- void setColumns(int);
-
- bool vertical() const;
- void setVertical(bool);
-
- virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
- virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
-
- static QFxFlowViewAttached *qmlAttachedProperties(QObject *);
-
-private:
- QRectF rectForItem(int idx) const;
- void refresh();
- void reflow(bool animate = false);
- void reflowDrag(const QPointF &);
- void clearTimeLine();
- int m_columns;
- QFxVisualItemModel *m_model;
- QList<QFxItem *> m_items;
- bool m_vertical;
- void moveItem(QFxItem *item, const QPointF &);
-
- QPointF m_dragOffset;
- QFxItem *m_dragItem;
-
- QmlTimeLine m_timeline;
- QList<QFxFlowViewValue *> m_values;
- int m_dragIdx;
-};
-QML_DECLARE_TYPE(QFxFlowView);
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QFXFLOWVIEW_H
diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp
index 0ca9393..11b630a 100644
--- a/src/declarative/fx/qfxgridview.cpp
+++ b/src/declarative/fx/qfxgridview.cpp
@@ -234,6 +234,8 @@ public:
int count = columns - 1 - (modelIndex - visibleItems.last()->index - 1) % columns;
return visibleItems.last()->colPos() - count * colSize();
}
+ } else {
+ return (modelIndex % columns) * colSize();
}
return 0;
}
@@ -252,6 +254,8 @@ public:
int rows = col / (columns * colSize());
return visibleItems.last()->rowPos() + rows * rowSize();
}
+ } else {
+ return (modelIndex / columns) * rowSize();
}
return 0;
}
@@ -364,8 +368,8 @@ void QFxGridViewPrivate::releaseItem(FxGridItem *item)
if (!item)
return;
if (trackedItem == item) {
- QObject::disconnect(trackedItem->item, SIGNAL(topChanged()), q, SLOT(trackedPositionChanged()));
- QObject::disconnect(trackedItem->item, SIGNAL(leftChanged()), q, SLOT(trackedPositionChanged()));
+ QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged()));
+ QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged()));
trackedItem = 0;
}
if (model->release(item->item) == 0) {
@@ -544,15 +548,15 @@ void QFxGridViewPrivate::updateTrackedItem()
item = highlight;
if (trackedItem && item != trackedItem) {
- QObject::disconnect(trackedItem->item, SIGNAL(topChanged()), q, SLOT(trackedPositionChanged()));
- QObject::disconnect(trackedItem->item, SIGNAL(leftChanged()), q, SLOT(trackedPositionChanged()));
+ QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged()));
+ QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged()));
trackedItem = 0;
}
if (!trackedItem && item) {
trackedItem = item;
- QObject::connect(trackedItem->item, SIGNAL(topChanged()), q, SLOT(trackedPositionChanged()));
- QObject::connect(trackedItem->item, SIGNAL(leftChanged()), q, SLOT(trackedPositionChanged()));
+ QObject::connect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged()));
+ QObject::connect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged()));
q->trackedPositionChanged();
}
if (trackedItem)
diff --git a/src/declarative/fx/qfxgridview.h b/src/declarative/fx/qfxgridview.h
index d561965..8f443e1 100644
--- a/src/declarative/fx/qfxgridview.h
+++ b/src/declarative/fx/qfxgridview.h
@@ -139,10 +139,10 @@ private:
void refill();
};
-QML_DECLARE_TYPE(QFxGridView)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxGridView)
+
QT_END_HEADER
#endif
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index fa56ee1..148c269 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -41,7 +41,7 @@
#include "qfximage.h"
#include "qfximage_p.h"
-#include <qfxperf.h>
+#include <private/qfxperf_p.h>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QFile>
diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h
index 72530ee..925a520 100644
--- a/src/declarative/fx/qfximage.h
+++ b/src/declarative/fx/qfximage.h
@@ -113,10 +113,11 @@ private:
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxImage)
void setGridScaledImage(const QFxGridScaledImage& sci);
};
-QML_DECLARE_TYPE(QFxImage)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxImage)
+
QT_END_HEADER
#endif // QFXIMAGE_H
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index cd8cabd..da4f1b3 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -47,7 +47,7 @@
#include <QNetworkRequest>
#include <QGraphicsSceneMouseEvent>
#include <QtScript/qscriptengine.h>
-#include <qfxperf.h>
+#include <private/qfxperf_p.h>
#include "qmlengine.h"
#include "qmlstate.h"
@@ -64,10 +64,10 @@
#include "qfxevents_p.h"
#include <qmlcomponent.h>
-
QT_BEGIN_NAMESPACE
-#ifndef INT_MAX
-#define INT_MAX 2147483647
+
+#ifndef FLT_MAX
+#define FLT_MAX 1E+37
#endif
QML_DEFINE_NOCREATE_TYPE(QFxContents)
@@ -121,86 +121,94 @@ QML_DEFINE_TYPE(QFxItem,Item)
*/
-QFxContents::QFxContents() : _height(0), _width(0)
+QFxContents::QFxContents() : m_height(0), m_width(0)
{
}
/*!
+ \qmlproperty qreal Item::contents.width
+ \qmlproperty qreal Item::contents.height
+
+ The contents properties allow an item access to the size of its
+ children. This property is useful if you have an item that needs to be
+ sized to fit its children.
+*/
+
+/*!
\property QFxContents::height
\brief The height of the contents.
*/
-int QFxContents::height() const
+qreal QFxContents::height() const
{
- return _height;
+ return m_height;
}
/*!
\property QFxContents::width
\brief The width of the contents.
*/
-int QFxContents::width() const
+qreal QFxContents::width() const
{
- return _width;
+ return m_width;
}
//TODO: optimization: only check sender(), if there is one
void QFxContents::calcHeight()
{
- int oldheight = _height;
-
- int top = INT_MAX;
- int bottom = 0;
+ qreal oldheight = m_height;
- QList<QGraphicsItem *> children = _item->childItems();
+ qreal top = FLT_MAX;
+ qreal bottom = 0;
+ QList<QGraphicsItem *> children = m_item->childItems();
for (int i = 0; i < children.count(); ++i) {
QFxItem *child = qobject_cast<QFxItem *>(children.at(i));
- int y = int(child->y());
+ qreal y = child->y();
if (y + child->height() > bottom)
bottom = y + child->height();
if (y < top)
top = y;
}
- _height = bottom - top;
+ m_height = qMax(bottom - top, qreal(0.0));
- if (_height != oldheight)
+ if (m_height != oldheight)
emit heightChanged();
}
//TODO: optimization: only check sender(), if there is one
void QFxContents::calcWidth()
{
- int oldwidth = _width;
+ qreal oldwidth = m_width;
- int left = INT_MAX;
- int right = 0;
- QList<QGraphicsItem *> children = _item->childItems();
+ qreal left = FLT_MAX;
+ qreal right = 0;
+ QList<QGraphicsItem *> children = m_item->childItems();
for (int i = 0; i < children.count(); ++i) {
QFxItem *child = qobject_cast<QFxItem *>(children.at(i));
- int x = int(child->x());
+ qreal x = child->x();
if (x + child->width() > right)
right = x + child->width();
if (x < left)
left = x;
}
- _width = right - left;
+ m_width = qMax(right - left, qreal(0.0));
- if (_width != oldwidth)
+ if (m_width != oldwidth)
emit widthChanged();
}
void QFxContents::setItem(QFxItem *item)
{
- _item = item;
+ m_item = item;
- QList<QGraphicsItem *> children = _item->childItems();
+ QList<QGraphicsItem *> children = m_item->childItems();
for (int i = 0; i < children.count(); ++i) {
QFxItem *child = qobject_cast<QFxItem *>(children.at(i));
connect(child, SIGNAL(heightChanged()), this, SLOT(calcHeight()));
- connect(child, SIGNAL(topChanged()), this, SLOT(calcHeight()));
+ connect(child, SIGNAL(yChanged()), this, SLOT(calcHeight()));
connect(child, SIGNAL(widthChanged()), this, SLOT(calcWidth()));
- connect(child, SIGNAL(leftChanged()), this, SLOT(calcWidth()));
+ connect(child, SIGNAL(xChanged()), this, SLOT(calcWidth()));
}
calcHeight();
@@ -268,15 +276,15 @@ void QFxContents::setItem(QFxItem *item)
*/
/*!
- \fn void QFxItem::leftChanged()
+ \fn void QFxItem::xChanged()
- This signal is emitted when the left coordinate of the item changes.
+ This signal is emitted when the x coordinate of the item changes.
*/
/*!
- \fn void QFxItem::topChanged()
+ \fn void QFxItem::yChanged()
- This signal is emitted when the top coordinate of the item changes.
+ This signal is emitted when the y coordinate of the item changes.
*/
/*!
@@ -912,7 +920,16 @@ void QFxItem::qmlLoaded()
QmlContext *ctxt = new QmlContext(qmlContext(this));
ctxt->addDefaultObject(this);
+ if (!d->_qmlcomp->errors().isEmpty()) {
+ qWarning() << d->_qmlcomp->errors();
+ delete d->_qmlcomp;
+ d->_qmlcomp = 0;
+ emit qmlChanged();
+ return;
+ }
QObject *obj = d->_qmlcomp->create(ctxt);
+ if (!d->_qmlcomp->errors().isEmpty())
+ qWarning() << d->_qmlcomp->errors();
QFxItem *qmlChild = qobject_cast<QFxItem *>(obj);
if (qmlChild) {
qmlChild->setItemParent(this);
@@ -931,8 +948,8 @@ void QFxItem::qmlLoaded()
/*!
\qmlproperty real Item::x
\qmlproperty real Item::y
- \qmlproperty int Item::width
- \qmlproperty int Item::height
+ \qmlproperty real Item::width
+ \qmlproperty real Item::height
Defines the item's position and size relative to its parent.
@@ -1073,11 +1090,11 @@ void QFxItem::geometryChanged(const QRectF &newGeometry,
}
if (newGeometry.x() != oldGeometry.x())
- emit leftChanged();
+ emit xChanged();
if (newGeometry.width() != oldGeometry.width())
emit widthChanged();
if (newGeometry.y() != oldGeometry.y())
- emit topChanged();
+ emit yChanged();
if (newGeometry.height() != oldGeometry.height())
emit heightChanged();
@@ -1306,13 +1323,14 @@ QFxAnchorLine QFxItem::baseline() const
\qmlproperty AnchorLine Item::anchors.baseline
\qmlproperty Item Item::anchors.fill
-
- \qmlproperty int Item::anchors.topMargin
- \qmlproperty int Item::anchors.bottomMargin
- \qmlproperty int Item::anchors.leftMargin
- \qmlproperty int Item::anchors.rightMargin
- \qmlproperty int Item::anchors.horizontalCenterOffset
- \qmlproperty int Item::anchors.verticalCenterOffset
+ \qmlproperty Item Item::anchors.centeredIn
+
+ \qmlproperty real Item::anchors.topMargin
+ \qmlproperty real Item::anchors.bottomMargin
+ \qmlproperty real Item::anchors.leftMargin
+ \qmlproperty real Item::anchors.rightMargin
+ \qmlproperty real Item::anchors.horizontalCenterOffset
+ \qmlproperty real Item::anchors.verticalCenterOffset
Anchors provide a way to position an item by specifying its
relationship with other items.
@@ -1371,11 +1389,11 @@ QFxAnchorLine QFxItem::baseline() const
For non-text items, a default baseline offset of 0 is used.
*/
-int QFxItem::baselineOffset() const
+qreal QFxItem::baselineOffset() const
{
Q_D(const QFxItem);
if (!d->_baselineOffset.isValid()) {
- return 0;
+ return 0.0;
} else
return d->_baselineOffset;
}
@@ -1383,7 +1401,7 @@ int QFxItem::baselineOffset() const
/*!
\internal
*/
-void QFxItem::setBaselineOffset(int offset)
+void QFxItem::setBaselineOffset(qreal offset)
{
Q_D(QFxItem);
if (offset == d->_baselineOffset)
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index 050cc3e..bb48d16 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -63,14 +63,14 @@ QT_MODULE(Declarative)
class Q_DECLARATIVE_EXPORT QFxContents : public QObject
{
Q_OBJECT
- Q_PROPERTY(int height READ height NOTIFY heightChanged)
- Q_PROPERTY(int width READ width NOTIFY widthChanged)
+ Q_PROPERTY(qreal height READ height NOTIFY heightChanged)
+ Q_PROPERTY(qreal width READ width NOTIFY widthChanged)
public:
QFxContents();
- int height() const;
+ qreal height() const;
- int width() const;
+ qreal width() const;
void setItem(QFxItem *item);
@@ -83,11 +83,10 @@ Q_SIGNALS:
void widthChanged();
private:
- QFxItem *_item;
- int _height;
- int _width;
+ QFxItem *m_item;
+ qreal m_height;
+ qreal m_width;
};
-QML_DECLARE_TYPE(QFxContents)
Q_DECLARE_OPERATORS_FOR_FLAGS(QFxAnchors::UsedAnchors)
class QmlState;
@@ -105,27 +104,27 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta
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)
+ Q_PROPERTY(QFxAnchors * anchors READ anchors DESIGNABLE false CONSTANT)
Q_PROPERTY(QmlList<QObject *> *data READ data DESIGNABLE false)
- Q_PROPERTY(QFxContents * contents READ contents DESIGNABLE false)
+ Q_PROPERTY(QFxContents * contents READ contents DESIGNABLE false CONSTANT)
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 leftChanged)
- Q_PROPERTY(qreal y READ y WRITE setY NOTIFY topChanged)
+ 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(int width READ width WRITE setWidth NOTIFY widthChanged)
- Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
- Q_PROPERTY(int baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged)
- Q_PROPERTY(QFxAnchorLine left READ left)
- Q_PROPERTY(QFxAnchorLine right READ right)
- Q_PROPERTY(QFxAnchorLine horizontalCenter READ horizontalCenter)
- Q_PROPERTY(QFxAnchorLine top READ top)
- Q_PROPERTY(QFxAnchorLine bottom READ bottom)
- Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter)
- Q_PROPERTY(QFxAnchorLine baseline READ baseline)
+ 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 baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged)
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)
@@ -196,8 +195,8 @@ public:
QUrl qml() const;
void setQml(const QUrl &);
- int baselineOffset() const;
- void setBaselineOffset(int);
+ qreal baselineOffset() const;
+ void setBaselineOffset(qreal);
qreal rotation() const;
void setRotation(qreal);
@@ -282,10 +281,10 @@ public Q_SLOTS:
void newChild(const QString &url);
Q_SIGNALS:
- void leftChanged();
+ void xChanged();
+ void yChanged();
void widthChanged();
void heightChanged();
- void topChanged();
void baselineOffsetChanged();
void stateChanged(const QString &);
void focusChanged();
@@ -343,7 +342,7 @@ private:
Q_DISABLE_COPY(QFxItem)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxItem)
};
-QML_DECLARE_TYPE(QFxItem)
+
Q_DECLARE_OPERATORS_FOR_FLAGS(QFxItem::Options)
template<typename T>
@@ -354,8 +353,11 @@ T qobject_cast(QGraphicsItem *item)
return qobject_cast<T>(o);
}
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxContents)
+QML_DECLARE_TYPE(QFxItem)
+
QT_END_HEADER
+
#endif // QFXITEM_H
diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h
index 113c860..93bcf6c 100644
--- a/src/declarative/fx/qfxitem_p.h
+++ b/src/declarative/fx/qfxitem_p.h
@@ -143,7 +143,7 @@ public:
QList<QUrl> _qmlnewloading;
QList<QmlComponent*> _qmlnewcomp;
- QmlNullableValue<int> _baselineOffset;
+ QmlNullableValue<qreal> _baselineOffset;
float _rotation;
bool _classComplete:1;
diff --git a/src/declarative/fx/qfxkeyactions.h b/src/declarative/fx/qfxkeyactions.h
index cea992a..91c2806 100644
--- a/src/declarative/fx/qfxkeyactions.h
+++ b/src/declarative/fx/qfxkeyactions.h
@@ -47,12 +47,12 @@
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qfxitem.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class QFxKeyActionsPrivate;
class Q_DECLARATIVE_EXPORT QFxKeyActions : public QFxItem
{
@@ -310,10 +310,10 @@ private:
QFxKeyActionsPrivate *d;
};
-QML_DECLARE_TYPE(QFxKeyActions)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxKeyActions)
+
QT_END_HEADER
#endif // QFXKEYACTIONS_H
diff --git a/src/declarative/fx/qfxkeyproxy.h b/src/declarative/fx/qfxkeyproxy.h
index 38cff7a..d075295 100644
--- a/src/declarative/fx/qfxkeyproxy.h
+++ b/src/declarative/fx/qfxkeyproxy.h
@@ -49,6 +49,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class QFxKeyProxyPrivate;
class Q_DECLARATIVE_EXPORT QFxKeyProxy : public QFxItem
{
@@ -69,10 +70,10 @@ private:
QFxKeyProxyPrivate *d;
};
-QML_DECLARE_TYPE(QFxKeyProxy)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxKeyProxy)
+
QT_END_HEADER
#endif // QFXKEYPROXY_H
diff --git a/src/declarative/fx/qfxlayouts.cpp b/src/declarative/fx/qfxlayouts.cpp
index 67cf00a..f71b35a 100644
--- a/src/declarative/fx/qfxlayouts.cpp
+++ b/src/declarative/fx/qfxlayouts.cpp
@@ -45,7 +45,7 @@
#include "qmlstate.h"
#include "qmlstategroup.h"
#include "qmlstateoperations.h"
-#include "qfxperf.h"
+#include "private/qfxperf_p.h"
#include "qfxlayouts.h"
#include "qfxlayouts_p.h"
@@ -132,7 +132,7 @@ BaseLayout {
id: layout
y: 0
move: Transition {
- NumericAnimation {
+ NumberAnimation {
properties: "y"
ease: "easeOutBounce"
}
@@ -161,7 +161,7 @@ BaseLayout {
id: layout
y: 0
add: Transition {
- NumericAnimation {
+ NumberAnimation {
target: layout.item
properties: "opacity"
from: 0
@@ -196,7 +196,7 @@ BaseLayout {
id: layout
y: 0
remove: Transition {
- NumericAnimation {
+ NumberAnimation {
target: layout.item
properties: "opacity"
from: 1
@@ -310,9 +310,6 @@ void QFxBaseLayout::preLayout()
d->_ep = true;
QCoreApplication::postEvent(this, new QEvent(QEvent::User));
}
- if (d->stateGroup) {
- delete d->stateGroup; d->stateGroup = 0;
- }
QSet<QFxItem *> allItems;
QList<QGraphicsItem *> children = childItems();
for (int ii = 0; ii < children.count(); ++ii) {
@@ -389,32 +386,29 @@ void QFxBaseLayout::preLayout()
}
//###This should be considered to move more centrally, as it seems useful
-void QFxBaseLayout::applyTransition(const QList<QPair<QString, QVariant> >& changes,
- QFxItem* target, QmlTransition* trans)
+void QFxBaseLayout::applyTransition(const QList<QPair<QString, QVariant> >& changes, QFxItem* target, QmlTransition* trans)
{
Q_D(QFxBaseLayout);
if (!trans||!target)//TODO: if !trans, just apply changes
return;
setLayoutItem(target);
- if (d->stateGroup)
- delete d->stateGroup;
- d->stateGroup = new QmlStateGroup(this);
- QmlState *state = new QmlState;
- *(d->stateGroup->statesProperty()) << state;
+ QmlStateOperation::ActionList actions;
+
for (int ii=0; ii<changes.size(); ++ii){
- QmlSetProperty *sp = new QmlSetProperty(state);
- sp->setObject(target);
- QVariant val = changes[ii].second;
- if (d->_margin &&
- (changes[ii].first == QLatin1String("x") || changes[ii].first == QLatin1String("y"))){
+
+ QVariant val = changes[ii].second;
+ if (d->_margin &&
+ (changes[ii].first == QLatin1String("x") ||
+ changes[ii].first == QLatin1String("y"))) {
val = QVariant(val.toInt() + d->_margin);
- }
- sp->setValue(val);
- sp->setProperty(changes[ii].first);
- *state << sp;
+ }
+
+ actions << Action(target, changes[ii].first, val);
+
}
- state->apply(d->stateGroup, trans, 0);
+
+ d->transitionManager.transition(actions, trans);
d->_animated << target;
}
@@ -513,7 +507,7 @@ VerticalLayout {
VerticalLayout {
id: layout
remove: Transition {
- NumericAnimation {
+ NumberAnimation {
target: layout.item
properties: "opacity"
from: 1
@@ -540,7 +534,7 @@ VerticalLayout {
VerticalLayout {
id: layout
add: Transition {
- NumericAnimation {
+ NumberAnimation {
target: layout.item
properties: "opacity"
from: 0
@@ -567,7 +561,7 @@ VerticalLayout {
VerticalLayout {
id: layout
move: Transition {
- NumericAnimation {
+ NumberAnimation {
properties: "y"
ease: "easeOutBounce"
}
@@ -686,7 +680,7 @@ HorizontalLayout {
HorizontalLayout {
id: layout
remove: Transition {
- NumericAnimation {
+ NumberAnimation {
target: layout.item
properties: "opacity"
from: 1
@@ -708,7 +702,7 @@ HorizontalLayout {
HorizontalLayout {
id: layout
add: Transition {
- NumericAnimation {
+ NumberAnimation {
target: layout.item
properties: "opacity"
from: 0
@@ -730,7 +724,7 @@ HorizontalLayout {
HorizontalLayout {
id: layout
move: Transition {
- NumericAnimation {
+ NumberAnimation {
properties: "x"
ease: "easeOutBounce"
}
@@ -879,7 +873,7 @@ GridLayout {
GridLayout {
id: layout
remove: Transition {
- NumericAnimation {
+ NumberAnimation {
target: layout.item
properties: "opacity"
from: 1
@@ -904,7 +898,7 @@ GridLayout {
GridLayout {
id: layout
add: Transition {
- NumericAnimation {
+ NumberAnimation {
target: layout.item
properties: "opacity"
from: 0
@@ -927,7 +921,7 @@ GridLayout {
GridLayout {
id: layout
move: Transition {
- NumericAnimation {
+ NumberAnimation {
properties: "x,y"
ease: "easeOutBounce"
}
diff --git a/src/declarative/fx/qfxlayouts.h b/src/declarative/fx/qfxlayouts.h
index abf4bb2..5767bc5 100644
--- a/src/declarative/fx/qfxlayouts.h
+++ b/src/declarative/fx/qfxlayouts.h
@@ -128,7 +128,6 @@ protected Q_SLOTS:
private:
Q_DISABLE_COPY(QFxVerticalLayout)
};
-QML_DECLARE_TYPE(QFxVerticalLayout)
class Q_DECLARATIVE_EXPORT QFxHorizontalLayout: public QFxBaseLayout
{
@@ -140,7 +139,6 @@ protected Q_SLOTS:
private:
Q_DISABLE_COPY(QFxHorizontalLayout)
};
-QML_DECLARE_TYPE(QFxHorizontalLayout)
class Q_DECLARATIVE_EXPORT QFxGridLayout : public QFxBaseLayout
{
@@ -163,9 +161,13 @@ private:
int _columns;
Q_DISABLE_COPY(QFxGridLayout)
};
-QML_DECLARE_TYPE(QFxGridLayout)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxVerticalLayout)
+QML_DECLARE_TYPE(QFxHorizontalLayout)
+QML_DECLARE_TYPE(QFxGridLayout)
+
QT_END_HEADER
+
#endif
diff --git a/src/declarative/fx/qfxlayouts_p.h b/src/declarative/fx/qfxlayouts_p.h
index 77b0ea1..5ffe70e 100644
--- a/src/declarative/fx/qfxlayouts_p.h
+++ b/src/declarative/fx/qfxlayouts_p.h
@@ -58,7 +58,7 @@
#include <QtCore/QString>
#include <QtDeclarative/qfxlayouts.h>
#include <QtDeclarative/qmlstate.h>
-
+#include <private/qmltransitionmanager_p.h>
QT_BEGIN_NAMESPACE
class QFxBaseLayoutPrivate : public QFxItemPrivate
@@ -69,7 +69,7 @@ public:
QFxBaseLayoutPrivate()
: _ep(false), _componentComplete(false), _spacing(0),
_margin(0), aut(QFxBaseLayout::None), moveTransition(0), addTransition(0),
- removeTransition(0), _layoutItem(0), stateGroup(0), _movingItem(0)
+ removeTransition(0), _layoutItem(0), _movingItem(0)
{
}
@@ -92,7 +92,8 @@ public:
QSet<QFxItem *> _newItems;
QSet<QFxItem *> _animated;
QFxItem *_layoutItem;
- QmlStateGroup *stateGroup;
+ QmlTransitionManager transitionManager;
+// QmlStateGroup *stateGroup;
QFxItem *_movingItem;
};
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index a8c0747..889cfdd 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -444,7 +444,7 @@ void QFxListViewPrivate::releaseItem(FxListItem *item)
else
QObject::disconnect(item->item, SIGNAL(widthChanged()), q, SLOT(itemResized()));
if (trackedItem == item) {
- const char *notifier1 = orient == Qt::Vertical ? SIGNAL(topChanged()) : SIGNAL(leftChanged());
+ const char *notifier1 = orient == Qt::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());
const char *notifier2 = orient == Qt::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged());
QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged()));
QObject::disconnect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged()));
@@ -588,7 +588,7 @@ void QFxListViewPrivate::updateTrackedItem()
if (highlight)
item = highlight;
- const char *notifier1 = orient == Qt::Vertical ? SIGNAL(topChanged()) : SIGNAL(leftChanged());
+ const char *notifier1 = orient == Qt::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());
const char *notifier2 = orient == Qt::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged());
if (trackedItem && item != trackedItem) {
diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h
index 7fa2050..2a70af0 100644
--- a/src/declarative/fx/qfxlistview.h
+++ b/src/declarative/fx/qfxlistview.h
@@ -44,12 +44,12 @@
#include <QtDeclarative/qfxflickable.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class QFxVisualItemModel;
class QFxListViewPrivate;
class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable
@@ -145,10 +145,10 @@ private Q_SLOTS:
void destroyingItem(QFxItem *item);
};
-QML_DECLARE_TYPE(QFxListView)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxListView)
+
QT_END_HEADER
#endif
diff --git a/src/declarative/fx/qfxmouseregion.h b/src/declarative/fx/qfxmouseregion.h
index d8586e9..224dd54 100644
--- a/src/declarative/fx/qfxmouseregion.h
+++ b/src/declarative/fx/qfxmouseregion.h
@@ -86,7 +86,6 @@ private:
int _ymax;
Q_DISABLE_COPY(QFxDrag)
};
-QML_DECLARE_TYPE(QFxDrag)
class QFxMouseEvent;
class QFxMouseRegionPrivate;
@@ -154,10 +153,12 @@ private:
Q_DISABLE_COPY(QFxMouseRegion)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxMouseRegion)
};
-QML_DECLARE_TYPE(QFxMouseRegion)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxDrag)
+QML_DECLARE_TYPE(QFxMouseRegion)
+
QT_END_HEADER
#endif // QFXMOUSEREGION_H
diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp
index d88f4f0..8323628 100644
--- a/src/declarative/fx/qfxpainteditem.cpp
+++ b/src/declarative/fx/qfxpainteditem.cpp
@@ -151,7 +151,6 @@ void QFxPaintedItem::setSmooth(bool smooth)
Q_D(QFxPaintedItem);
if (d->smooth == smooth) return;
d->smooth = smooth;
- clearCache();
update();
}
@@ -272,7 +271,8 @@ void QFxPaintedItem::paintContents(QPainter &p)
for (int i = 0; i < rects.count(); ++i) {
const QRect &r = rects.at(i);
QPixmap img(r.size());
- img.fill(Qt::transparent);
+ if (d->fillColor.isValid())
+ img.fill(d->fillColor);
{
QPainter qp(&img);
qp.translate(-r.x(),-r.y());
@@ -339,4 +339,30 @@ void QFxPaintedItem::setCacheSize(int pixels)
d->max_imagecache_size = pixels;
}
+/*!
+ \property QFxPaintedItem::fillColor
+
+ The color to be used to fill the item prior to calling drawContents().
+ By default, this is Qt::transparent.
+
+ Performance improvements can be achieved if subclasses call this with either an
+ invalid color (QColor()), or an appropriate solid color.
+*/
+void QFxPaintedItem::setFillColor(const QColor& c)
+{
+ Q_D(QFxPaintedItem);
+ if (d->fillColor == c)
+ return;
+ d->fillColor = c;
+ emit fillColorChanged();
+ update();
+}
+
+QColor QFxPaintedItem::fillColor() const
+{
+ Q_D(const QFxPaintedItem);
+ return d->fillColor;
+}
+
+
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxpainteditem.h b/src/declarative/fx/qfxpainteditem.h
index 566e8a4..e74ead0 100644
--- a/src/declarative/fx/qfxpainteditem.h
+++ b/src/declarative/fx/qfxpainteditem.h
@@ -59,6 +59,7 @@ class Q_DECLARATIVE_EXPORT QFxPaintedItem : public QFxItem
Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize)
Q_PROPERTY(bool smooth READ isSmooth WRITE setSmooth)
+ Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged)
Q_PROPERTY(int cacheSize READ cacheSize WRITE setCacheSize)
public:
@@ -76,11 +77,17 @@ public:
int cacheSize() const;
void setCacheSize(int pixels);
+ QColor fillColor() const;
+ void setFillColor(const QColor&);
+
protected:
QFxPaintedItem(QFxPaintedItemPrivate &dd, QFxItem *parent);
virtual void drawContents(QPainter *p, const QRect &) = 0;
+Q_SIGNALS:
+ void fillColorChanged();
+
protected Q_SLOTS:
void dirtyCache(const QRect &);
void clearCache();
@@ -90,10 +97,11 @@ private:
Q_DISABLE_COPY(QFxPaintedItem)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxPaintedItem)
};
-QML_DECLARE_TYPE(QFxPaintedItem)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxPaintedItem)
+
QT_END_HEADER
+
#endif
diff --git a/src/declarative/fx/qfxpainteditem_p.h b/src/declarative/fx/qfxpainteditem_p.h
index 5c79cd5..06e80ff 100644
--- a/src/declarative/fx/qfxpainteditem_p.h
+++ b/src/declarative/fx/qfxpainteditem_p.h
@@ -63,7 +63,7 @@ class QFxPaintedItemPrivate : public QFxItemPrivate
public:
QFxPaintedItemPrivate()
- : max_imagecache_size(100000), smooth(false)
+ : max_imagecache_size(100000), smooth(false), fillColor(Qt::transparent)
{
}
@@ -80,6 +80,7 @@ public:
int max_imagecache_size;
bool smooth;
QSize contentsSize;
+ QColor fillColor;
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxparticles.cpp b/src/declarative/fx/qfxparticles.cpp
deleted file mode 100644
index 0a6a628..0000000
--- a/src/declarative/fx/qfxparticles.cpp
+++ /dev/null
@@ -1,1112 +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 "qfxitem_p.h"
-
-#include <stdlib.h>
-#include <math.h>
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#define M_PI_2 (M_PI / 2.)
-#endif
-#ifndef INT_MAX
-#define INT_MAX 2147483647
-#endif
-#include <qfxpixmap.h>
-#include <qfxperf.h>
-#include <private/qmlanimation_p.h>
-
-#include "qfxparticles.h"
-
-
-QT_BEGIN_NAMESPACE
-#define PI_SQR 9.8696044
-// parabolic approximation
-inline qreal fastSin(qreal theta)
-{
- const qreal b = 4 / M_PI;
- const qreal c = -4 / PI_SQR;
-
- qreal y = b * theta + c * theta * qAbs(theta);
- return y;
-}
-
-inline qreal fastCos(qreal theta)
-{
- theta += M_PI_2;
- if (theta > M_PI)
- theta -= 2 * M_PI;
-
- return fastSin(theta);
-}
-
-class QFxParticle
-{
-public:
- QFxParticle(int time) : lifeSpan(1000), fadeOutAge(800)
- , opacity(0), birthTime(time), x_velocity(0), y_velocity(0)
- , state(FadeIn), data(0)
- {
- }
-
- int lifeSpan;
- int fadeOutAge;
- qreal x;
- qreal y;
- qreal opacity;
- int birthTime;
- qreal x_velocity;
- qreal y_velocity;
- enum State { FadeIn, Solid, FadeOut };
- State state;
- void *data;
-};
-
-//---------------------------------------------------------------------------
-
-QML_DEFINE_TYPE(QFxParticleMotion,ParticleMotion)
-
-/*!
- \class QFxParticleMotion
- \ingroup group_effects
- \brief The QFxParticleMotion class is the base class for particle motion.
-
- This class causes the particles to remain static.
-*/
-
-/*!
- Constructs a QFxParticleMotion with parent object \a parent.
-*/
-QFxParticleMotion::QFxParticleMotion(QObject *parent) :
- QObject(parent)
-{
-}
-
-/*!
- Move the \a particle to its new position. \a interval is the number of
- milliseconds elapsed since it was last moved.
-*/
-void QFxParticleMotion::advance(QFxParticle &particle, int interval)
-{
- Q_UNUSED(particle);
- Q_UNUSED(interval);
-}
-
-/*!
- The \a particle has just been created. Some motion strategies require
- additional state information. This can be allocated by this function.
-*/
-void QFxParticleMotion::created(QFxParticle &particle)
-{
- Q_UNUSED(particle);
-}
-
-/*!
- The \a particle is about to be destroyed. Any additional memory
- that has been allocated for the particle should be freed.
-*/
-void QFxParticleMotion::destroy(QFxParticle &particle)
-{
- Q_UNUSED(particle);
-}
-
-/*!
- \qmlclass ParticleMotionLinear
- \brief The ParticleMotionLinear object moves particles linearly.
-
- \sa Particles
-*/
-
-/*!
- \internal
- \class QFxParticleMotionLinear
- \ingroup group_effects
- \brief The QFxParticleMotionLinear class moves the particles linearly.
-*/
-
-QML_DEFINE_TYPE(QFxParticleMotionLinear,ParticleMotionLinear)
-
-void QFxParticleMotionLinear::advance(QFxParticle &p, int interval)
-{
- p.x += interval * p.x_velocity;
- p.y += interval * p.y_velocity;
-}
-
-/*!
- \qmlclass ParticleMotionGravity
- \brief The ParticleMotionGravity object moves particles towards a point.
-
- \sa Particles
-*/
-
-/*!
- \internal
- \class QFxParticleMotionGravity
- \ingroup group_effects
- \brief The QFxParticleMotionGravity class moves the particles towards a point.
-*/
-
-QML_DEFINE_TYPE(QFxParticleMotionGravity,ParticleMotionGravity)
-
-/*!
- \qmlproperty int ParticleMotionGravity::xattractor
- \qmlproperty int ParticleMotionGravity::yattractor
- These properties hold the x and y coordinates of the point attracting the particles.
-*/
-
-/*!
- \qmlproperty int ParticleMotionGravity::acceleration
- This property holds the acceleration to apply to the particles.
-*/
-
-/*!
- \property QFxParticleMotionGravity::xattractor
- \brief the x coordinate of the point attracting the particles.
-*/
-
-/*!
- \property QFxParticleMotionGravity::yattractor
- \brief the y coordinate of the point attracting the particles.
-*/
-
-/*!
- \property QFxParticleMotionGravity::acceleration
- \brief the acceleration to apply to the particles.
-*/
-
-void QFxParticleMotionGravity::advance(QFxParticle &p, int interval)
-{
- qreal xdiff = p.x - _xAttr;
- qreal ydiff = p.y - _yAttr;
-
- qreal xcomp = xdiff / (xdiff + ydiff);
- qreal ycomp = ydiff / (xdiff + ydiff);
-
- p.x_velocity += xcomp * _accel * interval;
- p.y_velocity += ycomp * _accel * interval;
-
- p.x += interval * p.x_velocity;
- p.y += interval * p.y_velocity;
-}
-
-/*!
- \qmlclass ParticleMotionWander
- \brief The ParticleMotionWander object moves particles in a somewhat random fashion.
-
- The particles will continue roughly in the original direction, however will randomly
- drift to each side.
-
- The code below produces an effect similar to falling snow.
-
- \qml
-Rect {
- width: 240
- height: 320
- color: "black"
-
- Particles {
- y: 0
- width: parent.width
- height: 30
- source: "star.png"
- lifeSpan: 5000
- count: 50
- angle: 70
- angleDeviation: 36
- velocity: 30
- velocityDeviation: 10
- ParticleMotionWander {
- xvariance: 30
- pace: 100
- }
- }
-}
- \endqml
-
- \sa Particles
-*/
-
-/*!
- \internal
- \class QFxParticleMotionWander
- \ingroup group_effects
- \brief The QFxParticleMotionWander class moves particles in a somewhat random fashion.
-
- The particles will continue roughly in the original direction, however will randomly
- drift to each side.
-*/
-
-/*!
- \qmlproperty int QFxParticleMotionWander::xvariance
- \qmlproperty int QFxParticleMotionWander::yvariance
-
- These properties set the amount to wander in the x and y directions.
-*/
-
-/*!
- \qmlproperty int QFxParticleMotionWander::pace
- This property holds how quickly the paricles will move from side to side.
-*/
-
-QML_DEFINE_TYPE(QFxParticleMotionWander,ParticleMotionWander)
-
-void QFxParticleMotionWander::advance(QFxParticle &p, int interval)
-{
- if (!particles)
- particles = qobject_cast<QFxParticles*>(parent());
- if (particles) {
- Data *d = (Data*)p.data;
- if (_xvariance != 0.) {
- qreal xdiff = p.x_velocity - d->x_targetV;
- if ((xdiff > d->x_peak && d->x_var > 0.0) || (xdiff < -d->x_peak && d->x_var < 0.0)) {
- d->x_var = -d->x_var;
- d->x_peak = _xvariance + _xvariance * qreal(rand()) / RAND_MAX;
- }
- p.x_velocity += d->x_var * interval;
- }
- p.x += interval * p.x_velocity;
-
- if (_yvariance != 0.) {
- qreal ydiff = p.y_velocity - d->y_targetV;
- if ((ydiff > d->y_peak && d->y_var > 0.0) || (ydiff < -d->y_peak && d->y_var < 0.0)) {
- d->y_var = -d->y_var;
- d->y_peak = _yvariance + _yvariance * qreal(rand()) / RAND_MAX;
- }
- p.y_velocity += d->y_var * interval;
- }
- p.y += interval * p.y_velocity;
- }
-}
-
-void QFxParticleMotionWander::created(QFxParticle &p)
-{
- if (!p.data) {
- Data *d = new Data;
- p.data = (void*)d;
- d->x_targetV = p.x_velocity;
- d->y_targetV = p.y_velocity;
- d->x_peak = _xvariance;
- d->y_peak = _yvariance;
- d->x_var = _pace * qreal(rand()) / RAND_MAX / 1000.0;
- d->y_var = _pace * qreal(rand()) / RAND_MAX / 1000.0;
- }
-}
-
-void QFxParticleMotionWander::destroy(QFxParticle &p)
-{
- if (p.data)
- delete (Data*)p.data;
-}
-
-//---------------------------------------------------------------------------
-class QFxParticlesPainter : public QFxItem
-{
-public:
- QFxParticlesPainter(QFxParticlesPrivate *p, QFxItem* parent)
- : QFxItem(parent), d(p)
- {
- setOptions(HasContents);
- maxX = minX = maxY = minY = 0;
- }
-
- void paintContents(QPainter &p);
-
- void updateSize();
-
- qreal maxX;
- qreal minX;
- qreal maxY;
- qreal minY;
- QFxParticlesPrivate* d;
-};
-
-//---------------------------------------------------------------------------
-class QFxParticlesPrivate : public QFxItemPrivate
-{
- Q_DECLARE_PUBLIC(QFxParticles)
-public:
- QFxParticlesPrivate()
- : count(1), lifeSpan(1000), lifeSpanDev(1000), fadeInDur(200), fadeOutDur(300)
- , angle(0), angleDev(0), velocity(0), velocityDev(0)
- , addParticleTime(0), addParticleCount(0), lastAdvTime(0), stream(false), streamDelay(0)
- , emitting(true), motion(0), clock(this)
- {
- }
-
- ~QFxParticlesPrivate()
- {
- }
-
- void init()
- {
- Q_Q(QFxParticles);
- paintItem = new QFxParticlesPainter(this, q);
- }
-
- void tick(int time);
- void createParticle(int time);
- void updateOpacity(QFxParticle &p, int age);
-
- QUrl url;
- QPixmap image;
- int count;
- int lifeSpan;
- int lifeSpanDev;
- int fadeInDur;
- int fadeOutDur;
- qreal angle;
- qreal angleDev;
- qreal velocity;
- qreal velocityDev;
- int addParticleTime;
- int addParticleCount;
- int lastAdvTime;
- bool stream;
- int streamDelay;
- bool emitting;
- QFxParticleMotion *motion;
- QFxParticlesPainter *paintItem;
-
- QList<QFxParticle> particles;
- QTickAnimationProxy<QFxParticlesPrivate, &QFxParticlesPrivate::tick> clock;
-
-};
-
-//TODO: Stop the clock if no visible particles and not emitting (restart on emittingChanged)
-void QFxParticlesPrivate::tick(int time)
-{
- Q_Q(QFxParticles);
- if (!motion)
- motion = new QFxParticleMotionLinear(q);
-
- int oldCount = particles.count();
- int removed = 0;
- int interval = time - lastAdvTime;
- for (int i = 0; i < particles.count(); ) {
- QFxParticle &particle = particles[i];
- int age = time - particle.birthTime;
- if (age >= particle.lifeSpan) {
- QFxParticle part = particles.takeAt(i);
- motion->destroy(part);
- ++removed;
- } else {
- updateOpacity(particle, age);
- motion->advance(particle, interval);
- ++i;
- }
- }
-
- while(removed-- && particles.count() < count && emitting)
- createParticle(time);
-
- if (!addParticleTime)
- addParticleTime = time;
-
- if (particles.count() < count && emitting) {
- qreal perc = (lifeSpanDev <= 0)?(1.):(qreal(time - addParticleTime) / qreal(lifeSpanDev));
- int percCount = addParticleCount + (int)perc * (count - addParticleCount);
- int streamWidth = -1;
- if (stream){
- if (streamDelay > time){
- streamWidth = 0;
- }else{
- int missed = time - streamDelay;
- qreal streamWidthReal = qreal(count)/qreal(lifeSpan);
- if (streamWidthReal < 1){
- streamDelay = time + (int)(1.0/streamWidthReal);
- streamWidth = 1;
- streamWidth += missed/streamDelay;
- }else{
- streamWidth = qRound(streamWidthReal * (time-lastAdvTime));
- }
- }
- }
- while(particles.count() < count && particles.count() < percCount && streamWidth--)
- createParticle(time);
- }
-
- lastAdvTime = time;
- if (oldCount || particles.count()) {
- if (q->itemParent())
- q->itemParent()->update();
- else
- q->update();
- } else if (!count) {
- lastAdvTime = 0;
- clock.stop();
- }
-}
-
-void QFxParticlesPrivate::createParticle(int time)
-{
-#ifdef Q_ENABLE_PERFORMANCE_LOG
- QFxPerfTimer<QFxPerf::CreateParticle> x;
-#endif
- Q_Q(QFxParticles);
- QFxParticle p(time);
- p.x = q->x() + q->width() * qreal(rand()) / RAND_MAX - image.width()/2.0;
- p.y = q->y() + q->height() * qreal(rand()) / RAND_MAX - image.height()/2.0;
- p.lifeSpan = lifeSpan;
- if (lifeSpanDev)
- p.lifeSpan += int(lifeSpanDev/2 - lifeSpanDev * qreal(rand()) / RAND_MAX);
- p.fadeOutAge = p.lifeSpan - fadeOutDur;
- if (fadeInDur == 0.) {
- p.state= QFxParticle::Solid;
- p.opacity = 1.0;
- }
- qreal a = angle;
- if (angleDev)
- a += angleDev/2 - angleDev * qreal(rand()) / RAND_MAX;
- if (a > M_PI)
- a = a - 2 * M_PI;
- qreal v = velocity;
- if (velocityDev)
- v += velocityDev/2 - velocityDev * qreal(rand()) / RAND_MAX;
- p.x_velocity = v * fastCos(a);
- p.y_velocity = v * fastSin(a);
- particles.append(p);
- motion->created(particles.last());
-}
-
-void QFxParticlesPrivate::updateOpacity(QFxParticle &p, int age)
-{
- switch (p.state) {
- case QFxParticle::FadeIn:
- if (age <= fadeInDur) {
- p.opacity = qreal(age) / fadeInDur;
- break;
- } else {
- p.opacity = 1.0;
- p.state = QFxParticle::Solid;
- // Fall through
- }
- case QFxParticle::Solid:
- if (age <= p.fadeOutAge) {
- break;
- } else {
- p.state = QFxParticle::FadeOut;
- // Fall through
- }
- case QFxParticle::FadeOut:
- p.opacity = qreal(p.lifeSpan - age) / fadeOutDur;
- break;
- }
-}
-
-QML_DEFINE_TYPE(QFxParticles,Particles)
-
-/*!
- \qmlclass Particles
- \brief The Particles object generates and moves particles.
- \inherits Item
-
- The particles created by this object cannot be dealt with directly, they can only be controlled through the parameters of the Particles object. The particles are all the same pixmap, specified by the user.
-
- The particles are painted relative to the parent of the Particles object. Moving the
- Particles object will not move the particles already emitted.
-
- The below example creates two differently behaving particle sources.
- The top one has particles falling from the top like snow,
- the lower one has particles expelled up like a fountain.
-
- \qml
-Rect {
- width: 240
- height: 320
- color: "black"
- Particles {
- y: 0
- width: parent.width
- height: 30
- source: "star.png"
- lifeSpan: 5000
- count: 50
- angle: 70
- angleDeviation: 36
- velocity: 30
- velocityDeviation: 10
- ParticleMotionWander {
- xvariance: 30
- pace: 100
- }
- }
- Particles {
- y: 300
- x: 120
- width: 1
- height: 1
- source: "star.png"
- lifeSpan: 5000
- count: 200
- angle: 270
- angleDeviation: 45
- velocity: 50
- velocityDeviation: 30
- ParticleMotionGravity {
- yattractor: 1000
- xattractor: 0
- acceleration: 25
- }
- }
-}
- \endqml
- \image particles.gif
-*/
-
-/*!
- \internal
- \class QFxParticles
- \ingroup group_effects
- \brief The QFxParticles class generates and moves particles.
-*/
-
-QFxParticles::QFxParticles(QFxItem *parent)
- : QFxItem(*(new QFxParticlesPrivate), parent)
-{
- Q_D(QFxParticles);
- d->init();
- setOptions(HasContents);
-}
-
-QFxParticles::QFxParticles(QFxParticlesPrivate &dd, QFxItem *parent)
- : QFxItem(dd, parent)
-{
- Q_D(QFxParticles);
- d->init();
- setOptions(HasContents);
-}
-
-QFxParticles::~QFxParticles()
-{
- Q_D(QFxParticles);
- if (!d->url.isEmpty())
- QFxPixmap::cancelGet(d->url, this);
-}
-
-/*!
- \qmlproperty string Particles::src
- This property holds the URL of the particle image.
-*/
-
-/*!
- \property QFxParticles::source
- \brief the URL of the particle image.
-*/
-QUrl QFxParticles::source() const
-{
- Q_D(const QFxParticles);
- return d->url;
-}
-
-void QFxParticles::imageLoaded()
-{
- Q_D(QFxParticles);
- d->image = QFxPixmap(d->url);
- update();
-}
-
-void QFxParticles::setSource(const QUrl &name)
-{
- Q_D(QFxParticles);
-
- if (name == d->url)
- return;
-
- if (!d->url.isEmpty())
- QFxPixmap::cancelGet(d->url, this);
- if (name.isEmpty()) {
- d->url = name;
- d->image = QPixmap();
- update();
- } else {
- d->url = name;
- Q_ASSERT(!name.isRelative());
- QFxPixmap::get(qmlEngine(this), d->url, this, SLOT(imageLoaded()));
- }
-}
-
-/*!
- \qmlproperty int Particles::count
- This property holds the target number of particles
-*/
-
-/*!
- \property QFxParticles::count
- \brief the target number of particles
-*/
-int QFxParticles::count() const
-{
- Q_D(const QFxParticles);
- return d->count;
-}
-
-void QFxParticles::setCount(int cnt)
-{
- Q_D(QFxParticles);
- if (cnt != d->count) {
- if (!d->count && d->clock.state() != QAbstractAnimation::Running)
- d->clock.start(); // infinity??
- d->count = cnt;
- d->addParticleTime = 0;
- d->addParticleCount = d->particles.count();
- update();
- }
-}
-
-/*!
- \qmlproperty int Particles::lifeSpan
- \qmlproperty int Particles::lifeSpanDeviation
-
- These properties describe the life span of each particle.
-
- The default lifespan for a particle is 1000ms.
-
- lifeSpanDeviation randomly varies the lifeSpan up to the specified variation. For
- example, the following creates particles whose lifeSpan will vary
- from 150ms to 250ms:
-
- \qml
-Particles {
- source: "star.png"
- lifeSpan: 200
- lifeSpanDeviation: 100
-}
- \endqml
-*/
-
-/*!
- \property QFxParticles::lifeSpan
- \brief the life span of each particle.
-
- Default value is 1000ms.
-
- \sa QFxParticles::lifeSpanDeviation
-*/
-int QFxParticles::lifeSpan() const
-{
- Q_D(const QFxParticles);
- return d->lifeSpan;
-}
-
-void QFxParticles::setLifeSpan(int ls)
-{
- Q_D(QFxParticles);
- d->lifeSpan = ls;
-}
-
-/*!
- \property QFxParticles::lifeSpanDeviation
- \brief the maximum possible deviation from the set lifeSpan.
-
- Randomly varies the lifeSpan up to the specified variation. For
- example, the following creates particles whose lifeSpan will vary
- from 150ms to 250ms:
-
-\qml
-Particles {
- source: "star.png"
- lifeSpan: 200
- lifeSpanDeviation: 100
-}
-\endqml
-
- \sa QFxParticles::lifeSpan
-*/
-int QFxParticles::lifeSpanDeviation() const
-{
- Q_D(const QFxParticles);
- return d->lifeSpanDev;
-}
-
-void QFxParticles::setLifeSpanDeviation(int dev)
-{
- Q_D(QFxParticles);
- d->lifeSpanDev = dev;
-}
-
-/*!
- \qmlproperty int Particles::fadeInDuration
- \qmlproperty int Particles::fadeOutDuration
- These properties hold the time taken to fade the particles in and out.
-
- By default fade in is 200ms and fade out is 300ms.
-*/
-
-/*!
- \property QFxParticles::fadeInDuration
- \brief the time taken to fade in the particles.
-
- Default value is 200ms.
-*/
-int QFxParticles::fadeInDuration() const
-{
- Q_D(const QFxParticles);
- return d->fadeInDur;
-}
-
-void QFxParticles::setFadeInDuration(int dur)
-{
- Q_D(QFxParticles);
- if (dur >= 0.0)
- d->fadeInDur = dur;
-}
-
-/*!
- \property QFxParticles::fadeOutDuration
- \brief the time taken to fade out the particles.
-
- Default value is 300ms.
-*/
-int QFxParticles::fadeOutDuration() const
-{
- Q_D(const QFxParticles);
- return d->fadeOutDur;
-}
-
-void QFxParticles::setFadeOutDuration(int dur)
-{
- Q_D(QFxParticles);
- if (dur >= 0.0)
- d->fadeOutDur = dur;
-}
-
-/*!
- \qmlproperty real Particles::angle
- \qmlproperty real Particles::angleDeviation
-
- These properties control particle direction.
-
- angleDeviation randomly varies the direction up to the specified variation. For
- example, the following creates particles whose initial direction will
- vary from 15 degrees to 105 degrees:
-
- \qml
-Particles {
- source: "star.png"
- angle: 60
- angleDeviation: 90
-}
- \endqml
-*/
-
-/*!
- \property QFxParticles::angle
- \brief the initial angle of direction.
-
- \sa QFxParticles::angleDeviation
-*/
-qreal QFxParticles::angle() const
-{
- Q_D(const QFxParticles);
- return d->angle * 180.0 / M_PI;
-}
-
-void QFxParticles::setAngle(qreal angle)
-{
- Q_D(QFxParticles);
- d->angle = angle * M_PI / 180.0;
-}
-
-/*!
- \property QFxParticles::angleDeviation
- \brief the maximum possible deviation from the set angle.
-
- Randomly varies the direction up to the specified variation. For
- example, the following creates particles whose initial direction will
- vary from 15 degrees to 105 degrees:
-
-\qml
-Particles {
- source: "star.png"
- angle: 60
- angleDeviation: 90
-}
-\endqml
-
- \sa QFxParticles::angle
-*/
-qreal QFxParticles::angleDeviation() const
-{
- Q_D(const QFxParticles);
- return d->angleDev * 180.0 / M_PI;
-}
-
-void QFxParticles::setAngleDeviation(qreal dev)
-{
- Q_D(QFxParticles);
- d->angleDev = dev * M_PI / 180.0;;
-}
-
-/*!
- \qmlproperty real Particles::velocity
- \qmlproperty real Particles::velocityDeviation
-
- These properties control the velocity of the particles.
-
- velocityDeviation randomly varies the velocity up to the specified variation. For
- example, the following creates particles whose initial velocity will
- vary from 40 to 60.
-
- \qml
-Particles {
- source: "star.png"
- velocity: 50
- velocityDeviation: 20
-}
- \endqml
-*/
-
-/*!
- \property QFxParticles::velocity
- \brief the initial velocity of the particles.
-
- \sa QFxParticles::velocityDeviation
-*/
-qreal QFxParticles::velocity() const
-{
- Q_D(const QFxParticles);
- return d->velocity * 1000.0;
-}
-
-void QFxParticles::setVelocity(qreal velocity)
-{
- Q_D(QFxParticles);
- d->velocity = velocity / 1000.0;
-}
-
-/*!
- \property QFxParticles::velocityDeviation
- \brief the maximum possible deviation from the set velocity.
-
- Randomly varies the velocity up to the specified variation. For
- example, the following creates particles whose initial velocity will
- vary from 40 to 60.
-
-\qml
-Particles {
- source: "star.png"
- velocity: 50
- velocityDeviation: 20
-}
-\endqml
-
- \sa QFxParticles::velocity
-*/
-qreal QFxParticles::velocityDeviation() const
-{
- Q_D(const QFxParticles);
- return d->velocityDev * 1000.0;
-}
-
-void QFxParticles::setVelocityDeviation(qreal velocity)
-{
- Q_D(QFxParticles);
- d->velocityDev = velocity / 1000.0;
-}
-
-/*!
- \qmlproperty bool Particles::streamIn
- This property determines whether the particles stream in at a constant rate
-
- When stream is set to true the particles will stream in at a constant rate.
- Otherwise the particles will appear as a clump. Note that this only affects the
- start of the particle effect, variables such as lifespan deviation can cause the
- particles to unclump over time.
-*/
-/*!
- \property QFxParticles::streamIn
- \brief determines whether the particles stream in at a constant rate
-
- When stream is set to true the particles will stream in at a constant rate.
- Otherwise the particles will appear as a clump. Note that this only affects the
- start of the particle effect, variables such as lifespan deviation can cause the
-
-*/
-//The name may need a rethink
-bool QFxParticles::streamIn() const
-{
- Q_D(const QFxParticles);
- return d->stream;
-}
-
-void QFxParticles::setStreamIn(bool b)
-{
- Q_D(QFxParticles);
- d->stream = b;
-}
-
-/*!
- \qmlproperty bool Particles::emitting
- This property determines whether new particles are created
-
- If emitting is set to false no new particles will be created. This means that
- when a particle reaches the end of its lifespan it is not replaced. This
- property can be used to turn particles on and off with a more natural look.
-
- The default setting is true. Note that if it initialized to false no particles
- will be produced until it is set to true.
-*/
-/*!
- \property QFxParticles::emitting
- If emitting is set to false no new particles will be created. This means that
- when a particle reaches the end of its lifespan it is not replaced. This
- property can be used to turn particles on and off with a more natural look.
-
- The default setting is true. Note that if it initialized to false no particles
- will be produced until it is set to true.
-*/
-bool QFxParticles::emitting() const
-{
- Q_D(const QFxParticles);
- return d->emitting;
-}
-
-void QFxParticles::setEmitting(bool r)
-{
- Q_D(QFxParticles);
- d->emitting = r;
-}
-/*!
- \qmlproperty ParticleMotion Particles::motion
- This property sets the type of motion to apply to the particles.
-
- When a particle is created it will have an initial direction and velocity.
- The motion of the particle during its lifeSpan is then influenced by the
- motion property.
-
- Default motion is ParticleMotionLinear.
-*/
-
-/*!
- \property QFxParticles::motion
- \brief sets the type of motion to apply to the particles.
-
- When a particle is created it will have an initial direction and velocity.
- The motion of the particle during its lifeSpan is then influenced by the
- motion property.
-
- Default motion is QFxParticleMotionLinear.
-*/
-QFxParticleMotion *QFxParticles::motion() const
-{
- Q_D(const QFxParticles);
- return d->motion;
-}
-
-void QFxParticles::setMotion(QFxParticleMotion *motion)
-{
- Q_D(QFxParticles);
- d->motion = motion;
-}
-
-QString QFxParticles::propertyInfo() const
-{
- Q_D(const QFxParticles);
- return d->url.toString();
-}
-
-void QFxParticlesPainter::updateSize(){
- setX(-500);
- setY(-500);
- setWidth(1000);
- setHeight(1000);
- return ;
- const int parentX = parentItem()->x();
- const int parentY = parentItem()->y();
- //Have to use statistical approach to needed size as arbitrary particle
- //motions make it impossible to calculate.
- //max/min vars stored to give a never shrinking rect
- for (int i = 0; i < d->particles.count(); ++i) {
- const QFxParticle &particle = d->particles.at(i);
- if(particle.x > maxX)
- maxX = particle.x;
- if(particle.x < minX)
- minX = particle.x;
- if(particle.y > maxY)
- maxY = particle.y;
- if(particle.y < minY)
- minY = particle.y;
- }
-
- int myWidth = (int)(maxX-minX+0.5)+d->image.width();
- int myX = (int)(minX - parentX);
- int myHeight = (int)(maxY-minY+0.5)+d->image.height();
- int myY = (int)(minY - parentY);
- setWidth(myWidth);
- setHeight(myHeight);
- setX(myX);
- setY(myY);
-}
-
-void QFxParticles::paintContents(QPainter &p)
-{
- Q_UNUSED(p);
- //painting is done by the ParticlesPainter, so it can have the right size
-}
-
-void QFxParticlesPainter::paintContents(QPainter &p)
-{
- if (d->image.isNull())
- return;
-
- updateSize();
- const int myX = x() + parentItem()->x();
- const int myY = y() + parentItem()->y();
-
- for (int i = 0; i < d->particles.count(); ++i) {
- const QFxParticle &particle = d->particles.at(i);
- p.setOpacity(particle.opacity);
- p.drawPixmap(particle.x - myX, particle.y - myY, d->image);
- }
- update();//Should I need this? (GV does)
-}
-
-void QFxParticles::componentComplete()
-{
- Q_D(QFxParticles);
- QFxItem::componentComplete();
- if (d->count)
- d->clock.start(); // infinity??
- if (d->lifeSpanDev > d->lifeSpan)
- d->lifeSpanDev = d->lifeSpan;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxparticles.h b/src/declarative/fx/qfxparticles.h
deleted file mode 100644
index be4dc91..0000000
--- a/src/declarative/fx/qfxparticles.h
+++ /dev/null
@@ -1,231 +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 QFXPARTICLES_H
-#define QFXPARTICLES_H
-
-#include <QtDeclarative/qfxitem.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QFxParticle;
-class QFxParticles;
-class Q_DECLARATIVE_EXPORT QFxParticleMotion : public QObject
-{
- Q_OBJECT
-public:
- QFxParticleMotion(QObject *parent=0);
-
- virtual void advance(QFxParticle &, int interval);
- virtual void created(QFxParticle &);
- virtual void destroy(QFxParticle &);
-};
-QML_DECLARE_TYPE(QFxParticleMotion)
-
-class Q_DECLARATIVE_EXPORT QFxParticleMotionLinear : public QFxParticleMotion
-{
- Q_OBJECT
-public:
- QFxParticleMotionLinear(QObject *parent=0)
- : QFxParticleMotion(parent) {}
-
- virtual void advance(QFxParticle &, int interval);
-};
-QML_DECLARE_TYPE(QFxParticleMotionLinear)
-
-class Q_DECLARATIVE_EXPORT QFxParticleMotionGravity : public QFxParticleMotion
-{
- Q_OBJECT
-
- Q_PROPERTY(int xattractor READ xAttractor WRITE setXAttractor)
- Q_PROPERTY(int yattractor READ yAttractor WRITE setYAttractor)
- Q_PROPERTY(int acceleration READ acceleration WRITE setAcceleration)
-public:
- QFxParticleMotionGravity(QObject *parent=0)
- : QFxParticleMotion(parent), _xAttr(0), _yAttr(0), _accel(0.00005) {}
-
- int xAttractor() const { return _xAttr; }
- void setXAttractor(int x) { _xAttr = x; }
-
- int yAttractor() const { return _yAttr; }
- void setYAttractor(int y) { _yAttr = y; }
-
- int acceleration() const { return int(_accel * 1000000); }
- void setAcceleration(int accel) { _accel = qreal(accel)/1000000.0; }
-
- virtual void advance(QFxParticle &, int interval);
-
-private:
- int _xAttr;
- int _yAttr;
- qreal _accel;
-};
-QML_DECLARE_TYPE(QFxParticleMotionGravity)
-
-class Q_DECLARATIVE_EXPORT QFxParticleMotionWander : public QFxParticleMotion
-{
- Q_OBJECT
-public:
- QFxParticleMotionWander()
- : QFxParticleMotion(), particles(0), _xvariance(0), _yvariance(0) {}
-
- virtual void advance(QFxParticle &, int interval);
- virtual void created(QFxParticle &);
- virtual void destroy(QFxParticle &);
-
- struct Data {
- qreal x_targetV;
- qreal y_targetV;
- qreal x_peak;
- qreal y_peak;
- qreal x_var;
- qreal y_var;
- };
-
- Q_PROPERTY(int xvariance READ xVariance WRITE setXVariance)
- int xVariance() const { return int(_xvariance * 1000); }
- void setXVariance(int var) { _xvariance = var / 1000.0; }
-
- Q_PROPERTY(int yvariance READ yVariance WRITE setYVariance)
- int yVariance() const { return int(_yvariance * 1000); }
- void setYVariance(int var) { _yvariance = var / 1000.0; }
-
- Q_PROPERTY(int pace READ pace WRITE setPace)
- int pace() const { return int(_pace * 1000); }
- void setPace(int pace) { _pace = pace / 1000.0; }
-
-private:
- QFxParticles *particles;
- qreal _xvariance;
- qreal _yvariance;
- qreal _pace;
-};
-QML_DECLARE_TYPE(QFxParticleMotionWander)
-
-class QFxParticlesPrivate;
-class Q_DECLARATIVE_EXPORT QFxParticles : public QFxItem
-{
- Q_OBJECT
-
- Q_PROPERTY(QUrl source READ source WRITE setSource)
- Q_PROPERTY(int count READ count WRITE setCount)
- Q_PROPERTY(int lifeSpan READ lifeSpan WRITE setLifeSpan)
- Q_PROPERTY(int lifeSpanDeviation READ lifeSpanDeviation WRITE setLifeSpanDeviation)
- Q_PROPERTY(int fadeInDuration READ fadeInDuration WRITE setFadeInDuration)
- Q_PROPERTY(int fadeOutDuration READ fadeOutDuration WRITE setFadeOutDuration)
- Q_PROPERTY(qreal angle READ angle WRITE setAngle)
- Q_PROPERTY(qreal angleDeviation READ angleDeviation WRITE setAngleDeviation)
- Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity)
- Q_PROPERTY(qreal velocityDeviation READ velocityDeviation WRITE setVelocityDeviation)
- Q_PROPERTY(bool streamIn READ streamIn WRITE setStreamIn)
- Q_PROPERTY(bool emitting READ emitting WRITE setEmitting)
- Q_PROPERTY(QFxParticleMotion *motion READ motion WRITE setMotion)
- Q_CLASSINFO("DefaultProperty", "motion")
-
-public:
- QFxParticles(QFxItem *parent=0);
- ~QFxParticles();
-
- QUrl source() const;
- void setSource(const QUrl &);
-
- int count() const;
- void setCount(int cnt);
-
- int lifeSpan() const;
- void setLifeSpan(int);
-
- int lifeSpanDeviation() const;
- void setLifeSpanDeviation(int);
-
- int fadeInDuration() const;
- void setFadeInDuration(int);
-
- int fadeOutDuration() const;
- void setFadeOutDuration(int);
-
- qreal angle() const;
- void setAngle(qreal);
-
- qreal angleDeviation() const;
- void setAngleDeviation(qreal);
-
- qreal velocity() const;
- void setVelocity(qreal);
-
- qreal velocityDeviation() const;
- void setVelocityDeviation(qreal);
-
- bool streamIn() const;
- void setStreamIn(bool);
-
- bool emitting() const;
- void setEmitting(bool);
-
- QFxParticleMotion *motion() const;
- void setMotion(QFxParticleMotion *);
-
- virtual QString propertyInfo() const;
-
- void paintContents(QPainter &p);
-
-protected:
- virtual void componentComplete();
- QFxParticles(QFxParticlesPrivate &dd, QFxItem *parent);
-
-private Q_SLOTS:
- void imageLoaded();
-
-private:
- Q_DISABLE_COPY(QFxParticles)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxParticles)
-};
-QML_DECLARE_TYPE(QFxParticles)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/fx/qfxpath.cpp b/src/declarative/fx/qfxpath.cpp
index ee2a272..a1b6032 100644
--- a/src/declarative/fx/qfxpath.cpp
+++ b/src/declarative/fx/qfxpath.cpp
@@ -41,7 +41,7 @@
#include "qfxpath.h"
#include "qfxpath_p.h"
-#include <qfxperf.h>
+#include <private/qfxperf_p.h>
#include <private/qbezier_p.h>
#include <QSet>
diff --git a/src/declarative/fx/qfxpath.h b/src/declarative/fx/qfxpath.h
index 39b9d01..04d24c6 100644
--- a/src/declarative/fx/qfxpath.h
+++ b/src/declarative/fx/qfxpath.h
@@ -61,7 +61,6 @@ public:
Q_SIGNALS:
void changed();
};
-QML_DECLARE_TYPE(QFxPathElement)
class Q_DECLARATIVE_EXPORT QFxPathAttribute : public QFxPathElement
{
@@ -83,7 +82,6 @@ private:
QString _name;
qreal _value;
};
-QML_DECLARE_TYPE(QFxPathAttribute)
class Q_DECLARATIVE_EXPORT QFxCurve : public QFxPathElement
{
@@ -106,7 +104,6 @@ private:
qreal _x;
qreal _y;
};
-QML_DECLARE_TYPE(QFxCurve)
class Q_DECLARATIVE_EXPORT QFxPathLine : public QFxCurve
{
@@ -116,7 +113,6 @@ public:
void addToPath(QPainterPath &path);
};
-QML_DECLARE_TYPE(QFxPathLine)
class Q_DECLARATIVE_EXPORT QFxPathQuad : public QFxCurve
{
@@ -139,7 +135,6 @@ private:
qreal _controlX;
qreal _controlY;
};
-QML_DECLARE_TYPE(QFxPathQuad)
class Q_DECLARATIVE_EXPORT QFxPathCubic : public QFxCurve
{
@@ -172,7 +167,6 @@ private:
int _control2X;
int _control2Y;
};
-QML_DECLARE_TYPE(QFxPathCubic)
class Q_DECLARATIVE_EXPORT QFxPathPercent : public QFxPathElement
{
@@ -187,7 +181,6 @@ public:
private:
qreal _value;
};
-QML_DECLARE_TYPE(QFxPathPercent)
class QFxPathPrivate;
class Q_DECLARATIVE_EXPORT QFxPath : public QObject, public QmlParserStatus
@@ -249,9 +242,18 @@ private:
Q_DISABLE_COPY(QFxPath)
Q_DECLARE_PRIVATE(QFxPath)
};
-QML_DECLARE_TYPE(QFxPath)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxPathElement)
+QML_DECLARE_TYPE(QFxPathAttribute)
+QML_DECLARE_TYPE(QFxCurve)
+QML_DECLARE_TYPE(QFxPathLine)
+QML_DECLARE_TYPE(QFxPathQuad)
+QML_DECLARE_TYPE(QFxPathCubic)
+QML_DECLARE_TYPE(QFxPathPercent)
+QML_DECLARE_TYPE(QFxPath)
+
QT_END_HEADER
+
#endif // QFXPATH_H
diff --git a/src/declarative/fx/qfxpathview.h b/src/declarative/fx/qfxpathview.h
index a40f1f2..9d91006 100644
--- a/src/declarative/fx/qfxpathview.h
+++ b/src/declarative/fx/qfxpathview.h
@@ -127,10 +127,11 @@ private:
Q_DISABLE_COPY(QFxPathView)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxPathView)
};
-QML_DECLARE_TYPE(QFxPathView)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxPathView)
+
QT_END_HEADER
#endif // QFXPATHVIEW_H
diff --git a/src/declarative/fx/qfxpathview_p.h b/src/declarative/fx/qfxpathview_p.h
index fea207f..f996d1d 100644
--- a/src/declarative/fx/qfxpathview_p.h
+++ b/src/declarative/fx/qfxpathview_p.h
@@ -58,7 +58,6 @@
#include "qfxitem_p.h"
#include "qfxvisualitemmodel.h"
#include "qml.h"
-#include "qmltimelinevalueproxy.h"
#include "private/qmlanimation_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/fx/qfxpixmap.cpp b/src/declarative/fx/qfxpixmap.cpp
index f2c6217..ac8a701 100644
--- a/src/declarative/fx/qfxpixmap.cpp
+++ b/src/declarative/fx/qfxpixmap.cpp
@@ -43,7 +43,7 @@
#include <QHash>
#include <QNetworkReply>
#include <QPixmapCache>
-#include <qfxperf.h>
+#include <private/qfxperf_p.h>
#include <QtDeclarative/qmlengine.h>
#include <QFile>
#include <QtCore/qdebug.h>
diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp
index a068fd4..2ad8536 100644
--- a/src/declarative/fx/qfxrect.cpp
+++ b/src/declarative/fx/qfxrect.cpp
@@ -55,9 +55,9 @@ QML_DEFINE_TYPE(QFxGradient,Gradient)
\brief The QFxPen class provides a pen used for drawing rect borders on a QFxView.
By default, the pen is invalid and nothing is drawn. You must either set a color (then the default
- width is 0) or a width (then the default color is black).
+ width is 1) or a width (then the default color is black).
- A width of 0 indicates a cosmetic pen, a single-pixel line on the border of the item being painted.
+ A width of 1 indicates is a single-pixel line on the border of the item being painted.
Example:
\qml
@@ -68,9 +68,9 @@ QML_DEFINE_TYPE(QFxGradient,Gradient)
/*! \property QFxPen::width
\brief the width of the pen.
- A width of 0 is a single-pixel line on the border of the item being painted.
+ A width of 1 is a single-pixel line on the border of the item being painted.
- If the width is less than 0 the pen is considered invalid and won't be used.
+ If the width is less than 1 the pen is considered invalid and won't be used.
*/
/*!
@@ -103,18 +103,18 @@ void QFxPen::setColor(const QColor &c)
\brief the width of the pen.
\qml
- // rect with green border using hexidecimal notation
Rect { pen.width: 4 }
\endqml
- A width of 0 creates a thin line. For no line, use a negative width or a transparent color.
+ A width of 1 creates a thin line. For no line, use a width of 0 or a transparent color.
- Odd pen widths generally lead to half-pixel painting.
+ To keep the border smooth (rather than blurry), odd pen widths cause the rect to be painted at
+ a half-pixel offset;
*/
void QFxPen::setWidth(int w)
{
_width = w;
- _valid = (_width < 0) ? false : true;
+ _valid = (_width < 1) ? false : true;
emit updated();
}
@@ -472,7 +472,10 @@ void QFxRect::generateRoundedRect()
p.setPen(Qt::NoPen);
}
p.setBrush(d->color);
- p.drawRoundedRect((pw+1)/2, (pw+1)/2, d->rectImage.width()-(pw+1)/2*2, d->rectImage.height()-(pw+1)/2*2, d->radius, d->radius);
+ if (pw%2)
+ p.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, d->rectImage.width()-(pw+1), d->rectImage.height()-(pw+1)), d->radius, d->radius);
+ else
+ p.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw), d->radius, d->radius);
}
}
@@ -487,12 +490,16 @@ void QFxRect::generateBorderedRect()
p.setRenderHint(QPainter::Antialiasing);
if (d->pen && d->pen->isValid()) {
QPen pn(QColor(d->pen->color()), d->pen->width());
+ pn.setJoinStyle(Qt::MiterJoin);
p.setPen(pn);
} else {
p.setPen(Qt::NoPen);
}
p.setBrush(d->color);
- p.drawRect(qreal(pw+1)/2, qreal(pw+1)/2, d->rectImage.width()-(pw+1)/2*2, d->rectImage.height()-(pw+1)/2*2);
+ if (pw%2)
+ p.drawRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, d->rectImage.width()-(pw+1), d->rectImage.height()-(pw+1)));
+ else
+ p.drawRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw));
}
}
@@ -512,7 +519,7 @@ void QFxRect::drawRect(QPainter &p)
if (d->gradient && d->gradient->gradient() /*|| p.usingQt() */) {
// XXX This path is still slower than the image path
// Image path won't work for gradients though
- QPainter::RenderHints oldHints = p.renderHints();
+ bool oldAA = p.testRenderHint(QPainter::Antialiasing);
p.setRenderHint(QPainter::Antialiasing);
if (d->pen && d->pen->isValid()) {
QPen pn(QColor(d->pen->color()), d->pen->width());
@@ -525,7 +532,7 @@ void QFxRect::drawRect(QPainter &p)
p.drawRoundedRect(0, 0, width(), height(), d->radius, d->radius);
else
p.drawRect(0, 0, width(), height());
- p.setRenderHints(oldHints);
+ p.setRenderHint(QPainter::Antialiasing, oldAA);
} else {
int offset = 0;
const int pw = d->pen && d->pen->isValid() ? (d->pen->width()+1)/2*2 : 0;
diff --git a/src/declarative/fx/qfxrect.h b/src/declarative/fx/qfxrect.h
index 46f918b..7790af1 100644
--- a/src/declarative/fx/qfxrect.h
+++ b/src/declarative/fx/qfxrect.h
@@ -59,7 +59,7 @@ class Q_DECLARATIVE_EXPORT QFxPen : public QObject
Q_PROPERTY(QColor color READ color WRITE setColor)
public:
QFxPen(QObject *parent=0)
- : QObject(parent), _width(0), _color("#000000"), _valid(false)
+ : QObject(parent), _width(1), _color("#000000"), _valid(false)
{}
int width() const { return _width; }
@@ -78,7 +78,6 @@ private:
QColor _color;
bool _valid;
};
-QML_DECLARE_TYPE(QFxPen)
class Q_DECLARATIVE_EXPORT QFxGradientStop : public QObject
{
@@ -103,7 +102,6 @@ private:
qreal m_position;
QColor m_color;
};
-QML_DECLARE_TYPE(QFxGradientStop)
class Q_DECLARATIVE_EXPORT QFxGradient : public QObject
{
@@ -131,7 +129,6 @@ private:
mutable QGradient *m_gradient;
friend class QFxGradientStop;
};
-QML_DECLARE_TYPE(QFxGradient)
class QFxRectPrivate;
class Q_DECLARATIVE_EXPORT QFxRect : public QFxItem
@@ -178,10 +175,14 @@ private:
Q_DISABLE_COPY(QFxRect)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxRect)
};
-QML_DECLARE_TYPE(QFxRect)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxPen)
+QML_DECLARE_TYPE(QFxGradientStop)
+QML_DECLARE_TYPE(QFxGradient)
+QML_DECLARE_TYPE(QFxRect)
+
QT_END_HEADER
#endif // QFXRECT_H
diff --git a/src/declarative/fx/qfxrepeater.h b/src/declarative/fx/qfxrepeater.h
index 2c903d1..6f950d3 100644
--- a/src/declarative/fx/qfxrepeater.h
+++ b/src/declarative/fx/qfxrepeater.h
@@ -44,12 +44,12 @@
#include <QtDeclarative/qfxitem.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class QFxRepeaterPrivate;
class Q_DECLARATIVE_EXPORT QFxRepeater : public QFxItem
{
@@ -80,10 +80,11 @@ private:
Q_DISABLE_COPY(QFxRepeater)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxRepeater)
};
-QML_DECLARE_TYPE(QFxRepeater)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxRepeater)
+
QT_END_HEADER
-#endif // _QFXREPEATER_H_
+#endif // QFXREPEATER_H
diff --git a/src/declarative/fx/qfxscalegrid.h b/src/declarative/fx/qfxscalegrid.h
index 4a9a72f..986bcda 100644
--- a/src/declarative/fx/qfxscalegrid.h
+++ b/src/declarative/fx/qfxscalegrid.h
@@ -109,10 +109,11 @@ private:
int _b;
QString _pix;
};
-QML_DECLARE_TYPE(QFxScaleGrid)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxScaleGrid)
+
QT_END_HEADER
+
#endif // QFXSCALEGRID_H
diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp
index 1f6890d..8618b87 100644
--- a/src/declarative/fx/qfxtext.cpp
+++ b/src/declarative/fx/qfxtext.cpp
@@ -43,8 +43,7 @@
#include "qfxtext_p.h"
#include <private/qtextcontrol_p.h>
-
-#include <qfxperf.h>
+#include <private/qfxperf_p.h>
#include <QTextLayout>
#include <QTextLine>
#include <QTextDocument>
@@ -158,7 +157,7 @@ void QFxText::setText(const QString &n)
if (d->text == n)
return;
- d->richText = Qt::mightBeRichText(n); // ### what's the cost?
+ d->richText = d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(n));
if (d->richText) {
if (!d->doc)
{
@@ -166,7 +165,7 @@ void QFxText::setText(const QString &n)
d->control->setTextInteractionFlags(Qt::TextBrowserInteraction);
d->doc = d->control->document();
d->doc->setDocumentMargin(0);
- }
+ }
d->doc->setHtml(n);
}
@@ -373,6 +372,77 @@ void QFxText::setWrap(bool w)
}
/*!
+ \qmlproperty enumeration Text::textFormat
+
+ The way the text property should be displayed.
+
+ Supported text formats are \c AutoText, \c PlainText and \c RichText.
+
+ The default is AutoText. If the text format is AutoText the text element
+ will automatically determine whether the text should be treated as
+ rich text. This determination is made using Qt::mightBeRichText().
+
+ \table
+ \row
+ \o
+ \qml
+VerticalLayout {
+ TextEdit {
+ font.size: 24
+ text: "<b>Hello</b> <i>World!</i>"
+ }
+ TextEdit {
+ font.size: 24
+ textFormat: "RichText"
+ text: "<b>Hello</b> <i>World!</i>"
+ }
+ TextEdit {
+ font.size: 24
+ textFormat: "PlainText"
+ text: "<b>Hello</b> <i>World!</i>"
+ }
+}
+ \endqml
+ \o \image declarative-textformat.png
+ \endtable
+*/
+
+QFxText::TextFormat QFxText::textFormat() const
+{
+ Q_D(const QFxText);
+ return d->format;
+}
+
+void QFxText::setTextFormat(TextFormat format)
+{
+ Q_D(QFxText);
+ if (format == d->format)
+ return;
+ bool wasRich = d->richText;
+ d->richText = format == RichText || (format == AutoText && Qt::mightBeRichText(d->text));
+
+ if (wasRich && !d->richText) {
+ //### delete control? (and vice-versa below)
+ d->imgDirty = true;
+ d->updateSize();
+ update();
+ } else if (!wasRich && d->richText) {
+ if (!d->doc)
+ {
+ d->control = new QTextControl(this);
+ d->control->setTextInteractionFlags(Qt::TextBrowserInteraction);
+ d->doc = d->control->document();
+ d->doc->setDocumentMargin(0);
+ }
+ d->doc->setHtml(d->text);
+ d->imgDirty = true;
+ d->updateSize();
+ update();
+ }
+ d->format = format;
+}
+
+/*!
\qmlproperty Qt::TextElideMode Text::elide
Set this property to elide parts of the text fit to the Text item's width.
@@ -686,6 +756,21 @@ void QFxTextPrivate::checkImgCache()
imgDirty = false;
}
+bool QFxText::smoothTransform() const
+{
+ Q_D(const QFxText);
+ return d->smooth;
+}
+
+void QFxText::setSmoothTransform(bool s)
+{
+ Q_D(QFxText);
+ if (d->smooth == s)
+ return;
+ d->smooth = s;
+ update();
+}
+
void QFxText::paintContents(QPainter &p)
{
Q_D(QFxText);
@@ -693,6 +778,11 @@ void QFxText::paintContents(QPainter &p)
if (d->imgCache.isNull())
return;
+ bool oldAA = p.testRenderHint(QPainter::Antialiasing);
+ bool oldSmooth = p.testRenderHint(QPainter::SmoothPixmapTransform);
+ if (d->smooth)
+ p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
+
int w = width();
int h = height();
@@ -733,6 +823,11 @@ void QFxText::paintContents(QPainter &p)
p.drawPixmap(x, y, d->imgCache);
if (needClip)
p.restore();
+
+ if (d->smooth) {
+ p.setRenderHint(QPainter::Antialiasing, oldAA);
+ p.setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
+ }
}
void QFxText::componentComplete()
diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h
index 2358fe3..b7ec333 100644
--- a/src/declarative/fx/qfxtext.h
+++ b/src/declarative/fx/qfxtext.h
@@ -58,17 +58,20 @@ class Q_DECLARATIVE_EXPORT QFxText : public QFxItem
Q_ENUMS(HAlignment)
Q_ENUMS(VAlignment)
Q_ENUMS(TextStyle)
+ Q_ENUMS(TextFormat)
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
- Q_PROPERTY(QmlFont *font READ font)
+ Q_PROPERTY(QmlFont *font READ font CONSTANT)
Q_PROPERTY(QColor color READ color WRITE setColor)
Q_PROPERTY(TextStyle style READ style WRITE setStyle)
Q_PROPERTY(QColor styleColor READ styleColor WRITE setStyleColor)
Q_PROPERTY(HAlignment hAlign READ hAlign WRITE setHAlign)
Q_PROPERTY(VAlignment vAlign READ vAlign WRITE setVAlign)
Q_PROPERTY(bool wrap READ wrap WRITE setWrap)
+ Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat)
Q_PROPERTY(Qt::TextElideMode elide READ elideMode WRITE setElideMode)
Q_PROPERTY(QString activeLink READ activeLink)
+ Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform)
public:
QFxText(QFxItem *parent=0);
@@ -84,6 +87,9 @@ public:
Outline,
Raised,
Sunken };
+ enum TextFormat { AutoText,
+ PlainText,
+ RichText };
QString text() const;
void setText(const QString &);
@@ -108,11 +114,17 @@ public:
bool wrap() const;
void setWrap(bool w);
+ TextFormat textFormat() const;
+ void setTextFormat(TextFormat format);
+
Qt::TextElideMode elideMode() const;
void setElideMode(Qt::TextElideMode);
QString activeLink() const;
+ bool smoothTransform() const;
+ void setSmoothTransform(bool);
+
virtual QString propertyInfo() const;
void paintContents(QPainter &p);
@@ -138,10 +150,11 @@ private:
Q_DISABLE_COPY(QFxText)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxText)
};
-QML_DECLARE_TYPE(QFxText)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxText)
+
QT_END_HEADER
+
#endif
diff --git a/src/declarative/fx/qfxtext_p.h b/src/declarative/fx/qfxtext_p.h
index e0b1909..6692d9e 100644
--- a/src/declarative/fx/qfxtext_p.h
+++ b/src/declarative/fx/qfxtext_p.h
@@ -71,7 +71,8 @@ public:
QFxTextPrivate()
: _font(0), color((QRgb)0), style(QFxText::Normal), imgDirty(true),
hAlign(QFxText::AlignLeft), vAlign(QFxText::AlignTop), elideMode(Qt::ElideNone),
- dirty(false), wrap(false), richText(false), singleline(false), control(0), doc(0)
+ dirty(false), wrap(false), smooth(false), richText(false), singleline(false), control(0), doc(0),
+ format(QFxText::AutoText)
{
}
@@ -118,12 +119,14 @@ public:
Qt::TextElideMode elideMode;
bool dirty;
bool wrap;
+ bool smooth;
bool richText;
bool singleline;
QTextControl *control;
QTextDocument *doc;
QTextLayout layout;
QSize cachedLayoutSize;
+ QFxText::TextFormat format;
};
QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index 7a42bdf..cdd94b5 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -41,10 +41,8 @@
#include <qfxtextedit.h>
#include "qfxtextedit_p.h"
-
#include <private/qtextcontrol_p.h>
-
-#include <qfxperf.h>
+#include <private/qfxperf_p.h>
#include "qfxevents_p.h"
#include <QTextLayout>
#include <QTextLine>
@@ -175,7 +173,7 @@ void QFxTextEdit::setText(const QString &text)
Supported text formats are \c AutoText, \c PlainText and \c RichText.
The default is AutoText. If the text format is AutoText the text edit
- edit will automatically determine whether the text should be treated as
+ will automatically determine whether the text should be treated as
rich text. This determination is made using Qt::mightBeRichText().
\table
@@ -320,6 +318,36 @@ void QFxTextEdit::setHighlightColor(const QColor &color)
}
/*!
+ \qmlproperty color TextEdit::highlightedTextColor
+
+ The highlighted text color, used in selections.
+*/
+
+/*!
+ \property QFxTextEdit::highlightedTextColor
+ \brief the text edit's default highlighted text color
+*/
+QColor QFxTextEdit::highlightedTextColor() const
+{
+ Q_D(const QFxTextEdit);
+ return d->highlightColor;
+}
+
+void QFxTextEdit::setHighlightedTextColor(const QColor &color)
+{
+ Q_D(QFxTextEdit);
+ if (d->highlightedTextColor == color)
+ return;
+
+ clearCache();
+ d->highlightedTextColor = color;
+ QPalette pal = d->control->palette();
+ pal.setColor(QPalette::HighlightedText, color);
+ d->control->setPalette(pal);
+ update();
+}
+
+/*!
\qmlproperty enumeration TextEdit::hAlign
\qmlproperty enumeration TextEdit::vAlign
@@ -406,7 +434,7 @@ void QFxTextEdit::setWrap(bool w)
}
/*!
- \property QFxTextEdit::cursorVisible
+ \qmlproperty TextEdit::cursorVisible
\brief If true the text edit shows a cursor.
This property is set and unset when the text edit gets focus, but it can also
@@ -431,6 +459,164 @@ void QFxTextEdit::setCursorVisible(bool on)
}
/*!
+ \qmlproperty TextEdit::cursorPosition
+ \brief The position of the cursor in the TextEdit.
+*/
+int QFxTextEdit::cursorPosition() const
+{
+ Q_D(const QFxTextEdit);
+ return d->control->textCursor().position();
+}
+
+void QFxTextEdit::setCursorPosition(int pos)
+{
+ Q_D(QFxTextEdit);
+ QTextCursor cursor = d->control->textCursor();
+ if (cursor.position() == pos)
+ return;
+ cursor.setPosition(pos);
+ d->control->setTextCursor(cursor);
+}
+
+/*!
+ \qmlproperty TextEdit::cursorDelegate
+ \brief The delegate for the cursor in the TextEdit.
+
+ If you set a cursorDelegate for a TextEdit, this delegate will be used for
+ drawing the cursor instead of the standard cursor. An instance of the
+ delegate will be created and managed by the text edit when a cursor is
+ needed, and the x and y properties of delegate instance will be set so as
+ to be one pixel before the top left of the current character.
+
+ Note that the root item of the delegate component must be a QFxItem or
+ QFxItem derived item.
+*/
+QmlComponent* QFxTextEdit::cursorDelegate() const
+{
+ Q_D(const QFxTextEdit);
+ return d->cursorComponent;
+}
+
+void QFxTextEdit::setCursorDelegate(QmlComponent* c)
+{
+ Q_D(QFxTextEdit);
+ if(d->cursorComponent){
+ delete d->cursorComponent;
+ if(d->cursor){
+ disconnect(d->control, SIGNAL(cursorPositionChanged()),
+ this, SLOT(moveCursorDelegate()));
+ d->control->setCursorWidth(-1);
+ dirtyCache(cursorRect());
+ delete d->cursor;
+ d->cursor = 0;
+ }
+ }
+ d->cursorComponent = c;
+ if(c && c->isReady()){
+ loadCursorDelegate();
+ }else{
+ if(c)
+ connect(c, SIGNAL(statusChanged()),
+ this, SLOT(loadCursorDelegate()));
+ }
+}
+
+void QFxTextEdit::loadCursorDelegate()
+{
+ Q_D(QFxTextEdit);
+ if(d->cursorComponent->isLoading())
+ return;
+ d->cursor = qobject_cast<QFxItem*>(d->cursorComponent->create(qmlContext(this)));
+ if(d->cursor){
+ connect(d->control, SIGNAL(cursorPositionChanged()),
+ this, SLOT(moveCursorDelegate()));
+ d->control->setCursorWidth(0);
+ dirtyCache(cursorRect());
+ d->cursor->setItemParent(this);
+ d->cursor->setHeight(QFontMetrics(d->font.font()).height());
+ moveCursorDelegate();
+ }else{
+ qWarning() << "Error loading cursor delegate for TextEdit:" + objectName();
+ }
+}
+
+/*!
+ \qmlproperty int TextEdit::selectionStart
+
+ The cursor position before the first character in the current selection.
+ Setting this and selectionEnd allows you to specify a selection in the
+ text edit.
+
+ Note that if selectionStart == selectionEnd then there is no current
+ selection. If you attempt to set selectionStart to a value outside of
+ the current text, selectionStart will not be changed.
+
+ \sa selectionEnd, cursorPosition, selectedText
+*/
+int QFxTextEdit::selectionStart() const
+{
+ Q_D(const QFxTextEdit);
+ return d->control->textCursor().selectionStart();
+}
+
+void QFxTextEdit::setSelectionStart(int s)
+{
+ Q_D(QFxTextEdit);
+ if(d->lastSelectionStart == s || s < 0 || s > text().length())
+ return;
+ d->lastSelectionStart = s;
+ d->updateSelection();// Will emit the relevant signals
+}
+
+/*!
+ \qmlproperty int TextEdit::selectionEnd
+
+ The cursor position after the last character in the current selection.
+ Setting this and selectionStart allows you to specify a selection in the
+ text edit.
+
+ Note that if selectionStart == selectionEnd then there is no current
+ selection. If you attempt to set selectionEnd to a value outside of
+ the current text, selectionEnd will not be changed.
+
+ \sa selectionStart, cursorPosition, selectedText
+*/
+int QFxTextEdit::selectionEnd() const
+{
+ Q_D(const QFxTextEdit);
+ return d->control->textCursor().selectionEnd();
+}
+
+void QFxTextEdit::setSelectionEnd(int s)
+{
+ Q_D(QFxTextEdit);
+ if(d->lastSelectionEnd == s || s < 0 || s > text().length())
+ return;
+ d->lastSelectionEnd = s;
+ d->updateSelection();// Will emit the relevant signals
+}
+
+/*!
+ \qmlproperty string TextEdit::selectedText
+
+ This read-only property provides the text currently selected in the
+ text edit.
+
+ It is equivalent to the following snippet, but is faster and easier
+ to use.
+ \code
+ //myTextEdit is the id of the TextEdit
+ myTextEdit.text.toString().substring(myTextEdit.selectionStart,
+ myTextEdit.selectionEnd);
+ \endcode
+*/
+QString QFxTextEdit::selectedText() const
+{
+ Q_D(const QFxTextEdit);
+ return d->control->textCursor().selectedText();
+}
+
+/*!
\qmlproperty bool TextEdit::focusOnPress
Whether the TextEdit should gain focus on a mouse press. By default this is
@@ -820,6 +1006,10 @@ void QFxTextEdit::fontChanged()
Q_D(QFxTextEdit);
clearCache();
d->document->setDefaultFont(d->font.font());
+ if(d->cursor){
+ d->cursor->setHeight(QFontMetrics(d->font.font()).height());
+ moveCursorDelegate();
+ }
updateSize();
emit update();
}
@@ -846,6 +1036,9 @@ void QFxTextEditPrivate::init()
QObject::connect(control, SIGNAL(updateRequest(QRectF)), q, SLOT(updateImgCache(QRectF)));
QObject::connect(control, SIGNAL(textChanged()), q, SLOT(q_textChanged()));
+ QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged()));
+ QObject::connect(control, SIGNAL(selectionChanged()), q, SLOT(updateSelectionMarkers()));
+ QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(updateSelectionMarkers()));
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged()));
document = control->document();
@@ -863,6 +1056,51 @@ void QFxTextEdit::q_textChanged()
emit textChanged(text());
}
+void QFxTextEdit::moveCursorDelegate()
+{
+ Q_D(QFxTextEdit);
+ if(!d->cursor)
+ return;
+ QRectF cursorRect = d->control->cursorRect();
+ d->cursor->setX(cursorRect.x());
+ d->cursor->setY(cursorRect.y());
+}
+
+void QFxTextEditPrivate::updateSelection()
+{
+ Q_Q(QFxTextEdit);
+ QTextCursor cursor = control->textCursor();
+ bool startChange = (lastSelectionStart != cursor.selectionStart());
+ bool endChange = (lastSelectionEnd != cursor.selectionEnd());
+ //### Is it worth calculating a more minimal set of movements?
+ cursor.beginEditBlock();
+ cursor.setPosition(lastSelectionStart, QTextCursor::MoveAnchor);
+ cursor.setPosition(lastSelectionEnd, QTextCursor::KeepAnchor);
+ cursor.endEditBlock();
+ control->setTextCursor(cursor);
+ if(startChange)
+ q->selectionStartChanged();
+ if(endChange)
+ q->selectionEndChanged();
+ startChange = (lastSelectionStart != control->textCursor().selectionStart());
+ endChange = (lastSelectionEnd != control->textCursor().selectionEnd());
+ if(startChange || endChange)
+ qWarning() << "QFxTextEditPrivate::updateSelection() has failed you.";
+}
+
+void QFxTextEdit::updateSelectionMarkers()
+{
+ Q_D(QFxTextEdit);
+ if(d->lastSelectionStart != d->control->textCursor().selectionStart()){
+ d->lastSelectionStart = d->control->textCursor().selectionStart();
+ emit selectionStartChanged();
+ }
+ if(d->lastSelectionEnd != d->control->textCursor().selectionEnd()){
+ d->lastSelectionEnd = d->control->textCursor().selectionEnd();
+ emit selectionEndChanged();
+ }
+}
+
//### we should perhaps be a bit smarter here -- depending on what has changed, we shouldn't
// need to do all the calculations each time
void QFxTextEdit::updateSize()
diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h
index 93540a4..77fac29 100644
--- a/src/declarative/fx/qfxtextedit.h
+++ b/src/declarative/fx/qfxtextedit.h
@@ -70,6 +70,7 @@ class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxPaintedItem
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(QColor color READ color WRITE setColor)
Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setHighlightColor)
+ Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor WRITE setHighlightedTextColor)
Q_PROPERTY(QmlFont * font READ font)
Q_PROPERTY(HAlignment hAlign READ hAlign WRITE setHAlign)
Q_PROPERTY(VAlignment vAlign READ vAlign WRITE setVAlign)
@@ -77,6 +78,11 @@ class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxPaintedItem
Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat)
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible)
+ Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
+ Q_PROPERTY(QmlComponent* cursorDelegate READ cursorDelegate WRITE setCursorDelegate)
+ Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged)
+ Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged)
+ Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectionChanged)
Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress)
Q_PROPERTY(bool preserveSelection READ preserveSelection WRITE setPreserveSelection)
Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin)
@@ -117,6 +123,9 @@ public:
QColor highlightColor() const;
void setHighlightColor(const QColor &c);
+ QColor highlightedTextColor() const;
+ void setHighlightedTextColor(const QColor &c);
+
HAlignment hAlign() const;
void setHAlign(HAlignment align);
@@ -129,6 +138,20 @@ public:
bool isCursorVisible() const;
void setCursorVisible(bool on);
+ int cursorPosition() const;
+ void setCursorPosition(int pos);
+
+ QmlComponent* cursorDelegate() const;
+ void setCursorDelegate(QmlComponent*);
+
+ int selectionStart() const;
+ void setSelectionStart(int);
+
+ int selectionEnd() const;
+ void setSelectionEnd(int);
+
+ QString selectedText() const;
+
bool focusOnPress() const;
void setFocusOnPress(bool on);
@@ -163,6 +186,9 @@ public:
Q_SIGNALS:
void textChanged(const QString &);
void cursorPositionChanged();
+ void selectionStartChanged();
+ void selectionEndChanged();
+ void selectionChanged();
public Q_SLOTS:
void selectAll();
@@ -171,6 +197,9 @@ private Q_SLOTS:
void fontChanged();
void updateImgCache(const QRectF &rect);
void q_textChanged();
+ void updateSelectionMarkers();
+ void moveCursorDelegate();
+ void loadCursorDelegate();
private:
void updateSize();
@@ -201,10 +230,11 @@ private:
Q_DISABLE_COPY(QFxTextEdit)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxTextEdit)
};
-QML_DECLARE_TYPE(QFxTextEdit)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxTextEdit)
+
QT_END_HEADER
+
#endif
diff --git a/src/declarative/fx/qfxtextedit_p.h b/src/declarative/fx/qfxtextedit_p.h
index 403bd18..267e48b 100644
--- a/src/declarative/fx/qfxtextedit_p.h
+++ b/src/declarative/fx/qfxtextedit_p.h
@@ -69,8 +69,9 @@ class QFxTextEditPrivate : public QFxPaintedItemPrivate
public:
QFxTextEditPrivate()
: 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), format(QFxTextEdit::AutoText), document(0)
+ 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)
{
}
@@ -78,11 +79,13 @@ public:
void updateDefaultTextOption();
void relayoutDocument();
+ void updateSelection();
QString text;
QmlFont font;
QColor color;
QColor highlightColor;
+ QColor highlightedTextColor;
QString style;
QColor styleColor;
bool imgDirty;
@@ -97,6 +100,10 @@ public:
bool focusOnPress;
bool preserveSelection;
qreal textMargin;
+ int lastSelectionStart;
+ int lastSelectionEnd;
+ QmlComponent* cursorComponent;
+ QFxItem* cursor;
QFxTextEdit::TextFormat format;
QTextDocument *document;
QTextControl *control;
diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp
index 8973295..f08d830 100644
--- a/src/declarative/fx/qfxtransform.cpp
+++ b/src/declarative/fx/qfxtransform.cpp
@@ -46,11 +46,11 @@
#include <math.h>
#ifndef M_PI
-
-QT_BEGIN_NAMESPACE
#define M_PI 3.14159265358979323846
#endif
+QT_BEGIN_NAMESPACE
+
QML_DEFINE_NOCREATE_TYPE(QFxTransform);
/*!
@@ -84,6 +84,125 @@ void QFxTransform::update()
}
/*!
+ \qmlclass Scale
+ \brief A Scale object provides a way to scale an Item.
+
+ The scale object gives more control over scaling than using Item's scale property. Specifically,
+ it allows a different scale for the x and y axes, and allows the scale to be relative to an
+ arbitrary point.
+
+ The following example scales the X axis of the Rect, relative to its interior point 25, 25:
+ \qml
+ Rect {
+ width: 100; height: 100
+ color: "blue"
+ transform: Scale { originX: 25; originY: 25; xScale: 3}
+ }
+ \endqml
+*/
+
+QFxScale::QFxScale(QObject *parent)
+: QFxTransform(parent), _originX(0), _originY(0), _xScale(1), _yScale(1), _dirty(true)
+{
+}
+
+QFxScale::~QFxScale()
+{
+}
+
+/*!
+ \qmlproperty real Scale::originX
+ \qmlproperty real Scale::originY
+
+ The origin point for the scale. The scale will be relative to this point.
+*/
+qreal QFxScale::originX() const
+{
+ return _originX;
+}
+
+void QFxScale::setOriginX(qreal ox)
+{
+ _originX = ox;
+ update();
+}
+
+qreal QFxScale::originY() const
+{
+ return _originY;
+}
+
+void QFxScale::setOriginY(qreal oy)
+{
+ _originY = oy;
+ update();
+}
+
+/*!
+ \qmlproperty real Scale::xScale
+
+ The scaling factor for the X axis.
+*/
+qreal QFxScale::xScale() const
+{
+ return _xScale;
+}
+
+void QFxScale::setXScale(qreal scale)
+{
+ if (_xScale == scale)
+ return;
+ _xScale = scale;
+ update();
+ emit scaleChanged();
+}
+
+/*!
+ \qmlproperty real Scale::yScale
+
+ The scaling factor for the Y axis.
+*/
+qreal QFxScale::yScale() const
+{
+ return _yScale;
+}
+
+void QFxScale::setYScale(qreal scale)
+{
+ if (_yScale == scale)
+ return;
+ _yScale = scale;
+ update();
+ emit scaleChanged();
+}
+
+bool QFxScale::isIdentity() const
+{
+ return (_xScale == 1. && _yScale == 1.);
+}
+
+QTransform QFxScale::transform() const
+{
+ if (_dirty) {
+ _transform = QTransform();
+ _dirty = false;
+ _transform.translate(_originX, _originY);
+ _transform.scale(_xScale, _yScale);
+ _transform.translate(-_originX, -_originY);
+ }
+ return _transform;
+}
+
+void QFxScale::update()
+{
+ _dirty = true;
+ QFxTransform::update();
+}
+
+QML_DEFINE_TYPE(QFxScale, Scale)
+
+
+/*!
\qmlclass Axis
\brief A Axis object defines an axis that can be used for rotation or translation.
diff --git a/src/declarative/fx/qfxtransform.h b/src/declarative/fx/qfxtransform.h
index a549b30..fb49294 100644
--- a/src/declarative/fx/qfxtransform.h
+++ b/src/declarative/fx/qfxtransform.h
@@ -64,7 +64,48 @@ public:
virtual bool isIdentity() const;
virtual QTransform transform() const;
};
-QML_DECLARE_TYPE(QFxTransform)
+
+class Q_DECLARATIVE_EXPORT QFxScale : public QFxTransform
+{
+ Q_OBJECT
+
+ Q_PROPERTY(qreal originX READ originX WRITE setOriginX)
+ Q_PROPERTY(qreal originY READ originY WRITE setOriginY)
+ Q_PROPERTY(qreal xScale READ xScale WRITE setXScale NOTIFY scaleChanged())
+ Q_PROPERTY(qreal yScale READ yScale WRITE setYScale NOTIFY scaleChanged())
+public:
+ QFxScale(QObject *parent=0);
+ ~QFxScale();
+
+ qreal originX() const;
+ void setOriginX(qreal);
+
+ qreal originY() const;
+ void setOriginY(qreal);
+
+ qreal xScale() const;
+ void setXScale(qreal);
+
+ qreal yScale() const;
+ void setYScale(qreal);
+
+ virtual bool isIdentity() const;
+ virtual QTransform transform() const;
+
+Q_SIGNALS:
+ void scaleChanged();
+
+private Q_SLOTS:
+ void update();
+private:
+ qreal _originX;
+ qreal _originY;
+ qreal _xScale;
+ qreal _yScale;
+
+ mutable bool _dirty;
+ mutable QTransform _transform;
+};
class Q_DECLARATIVE_EXPORT QFxAxis : public QObject
{
@@ -104,7 +145,6 @@ private:
qreal _endY;
qreal _endZ;
};
-QML_DECLARE_TYPE(QFxAxis)
class Q_DECLARATIVE_EXPORT QFxRotation : public QFxTransform
{
@@ -142,7 +182,6 @@ private:
mutable bool _dirty;
mutable QTransform _transform;
};
-QML_DECLARE_TYPE(QFxRotation)
class Q_DECLARATIVE_EXPORT QFxRotation3D : public QFxTransform
{
@@ -171,7 +210,6 @@ private:
mutable bool _dirty;
mutable QTransform _transform;
};
-QML_DECLARE_TYPE(QFxRotation3D)
class Q_DECLARATIVE_EXPORT QFxTranslation3D : public QFxTransform
{
@@ -200,7 +238,6 @@ private:
mutable bool _dirty;
mutable QTransform _transform;
};
-QML_DECLARE_TYPE(QFxTranslation3D)
class Q_DECLARATIVE_EXPORT QFxPerspective : public QFxTransform
{
@@ -237,7 +274,6 @@ private:
qreal _angle;
qreal _aspect;
};
-QML_DECLARE_TYPE(QFxPerspective)
class Q_DECLARATIVE_EXPORT QFxSquish : public QFxTransform
{
@@ -303,10 +339,18 @@ private:
QSizeF s;
QPointF p1, p2, p3, p4;
};
-QML_DECLARE_TYPE(QFxSquish)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxTransform)
+QML_DECLARE_TYPE(QFxScale)
+QML_DECLARE_TYPE(QFxAxis)
+QML_DECLARE_TYPE(QFxRotation)
+QML_DECLARE_TYPE(QFxRotation3D)
+QML_DECLARE_TYPE(QFxTranslation3D)
+QML_DECLARE_TYPE(QFxPerspective)
+QML_DECLARE_TYPE(QFxSquish)
+
QT_END_HEADER
#endif // QFXTRANSFORM_H
diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp
index 7d260ab..eb10df3 100644
--- a/src/declarative/fx/qfxvisualitemmodel.cpp
+++ b/src/declarative/fx/qfxvisualitemmodel.cpp
@@ -53,9 +53,9 @@
#include "qfxvisualitemmodel.h"
#include <QtCore/qdebug.h>
+QML_DECLARE_TYPE(QListModelInterface)
QT_BEGIN_NAMESPACE
-QML_DECLARE_TYPE(QListModelInterface)
class QFxVisualItemModelParts;
class QFxVisualItemModelData;
diff --git a/src/declarative/fx/qfxvisualitemmodel.h b/src/declarative/fx/qfxvisualitemmodel.h
index 968cc2e..551c08d 100644
--- a/src/declarative/fx/qfxvisualitemmodel.h
+++ b/src/declarative/fx/qfxvisualitemmodel.h
@@ -70,7 +70,7 @@ class Q_DECLARATIVE_EXPORT QFxVisualItemModel : public QObject
Q_PROPERTY(QVariant model READ model WRITE setModel)
Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate)
Q_PROPERTY(QString part READ part WRITE setPart)
- Q_PROPERTY(QObject *parts READ parts)
+ Q_PROPERTY(QObject *parts READ parts CONSTANT)
Q_CLASSINFO("DefaultProperty", "delegate")
public:
QFxVisualItemModel();
@@ -123,10 +123,11 @@ private Q_SLOTS:
private:
Q_DISABLE_COPY(QFxVisualItemModel)
};
-QML_DECLARE_TYPE(QFxVisualItemModel)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxVisualItemModel)
+
QT_END_HEADER
#endif // QFXVISUALITEMMODEL_H
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index ec7c548..da10004 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -418,12 +418,6 @@ void QFxWebView::setInteractive(bool i)
emit interactiveChanged();
}
-void QFxWebView::updateCacheForVisibility()
-{
- if (!isVisible())
- clearCache();
-}
-
void QFxWebView::expandToWebPage()
{
Q_D(QFxWebView);
@@ -875,7 +869,6 @@ void QFxWebView::setPage(QWebPage *page)
d->idealheight>0 ? d->idealheight : -1));
d->page->mainFrame()->setScrollBarPolicy(Qt::Horizontal,Qt::ScrollBarAlwaysOff);
d->page->mainFrame()->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff);
- connect(this,SIGNAL(visibleChanged()),this,SLOT(updateCacheForVisibility()));
connect(d->page,SIGNAL(repaintRequested(QRect)),this,SLOT(paintPage(QRect)));
connect(d->page->mainFrame(),SIGNAL(urlChanged(QUrl)),this,SIGNAL(urlChanged()));
connect(d->page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString)));
@@ -1047,6 +1040,6 @@ QObject *QFxWebPage::createPlugin(const QString &, const QUrl &url, const QStrin
return new QWidget_Dummy_Plugin(comp,view(),paramNames,paramValues);
}
-#include "qfxwebview.moc"
-
QT_END_NAMESPACE
+
+#include "qfxwebview.moc"
diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h
index d4b70d3..ab20281 100644
--- a/src/declarative/fx/qfxwebview.h
+++ b/src/declarative/fx/qfxwebview.h
@@ -49,14 +49,14 @@
#include <QtNetwork/qnetworkaccessmanager.h>
#include <QtWebKit/QWebPage>
-
QT_BEGIN_HEADER
+class QWebHistory;
+class QWebSettings;
+
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QWebHistory;
-class QWebSettings;
class QFxWebViewPrivate;
class QNetworkRequest;
class QFxWebView;
@@ -181,7 +181,6 @@ Q_SIGNALS:
void doubleClick();
private Q_SLOTS:
- void updateCacheForVisibility();
void expandToWebPage();
void paintPage(const QRect&);
void doLoadProgress(int p);
@@ -209,10 +208,11 @@ private:
Q_DISABLE_COPY(QFxWebView)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxWebView)
};
-QML_DECLARE_TYPE(QFxWebView)
-
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxWebView)
+
QT_END_HEADER
+
#endif
diff --git a/src/declarative/fx/qfxwidgetcontainer.h b/src/declarative/fx/qfxwidgetcontainer.h
index cc36010..862a280 100644
--- a/src/declarative/fx/qfxwidgetcontainer.h
+++ b/src/declarative/fx/qfxwidgetcontainer.h
@@ -72,10 +72,11 @@ protected:
private:
QGraphicsWidget *_graphicsWidget;
};
-QML_DECLARE_TYPE(QFxWidgetContainer)
QT_END_NAMESPACE
+QML_DECLARE_TYPE(QFxWidgetContainer)
+
QT_END_HEADER
#endif // QFXGRAPHICSWIDGET_H