summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/fx')
-rw-r--r--src/declarative/fx/fx.pri2
-rw-r--r--src/declarative/fx/qfxanchors.cpp10
-rw-r--r--src/declarative/fx/qfxanimatedimageitem.cpp20
-rw-r--r--src/declarative/fx/qfxblendedimage.cpp24
-rw-r--r--src/declarative/fx/qfxblurfilter.cpp16
-rw-r--r--src/declarative/fx/qfxcomponentinstance.cpp14
-rw-r--r--src/declarative/fx/qfxcontentwrapper.cpp2
-rw-r--r--src/declarative/fx/qfxevents.cpp121
-rw-r--r--src/declarative/fx/qfxevents_p.h36
-rw-r--r--src/declarative/fx/qfxflickable.cpp92
-rw-r--r--src/declarative/fx/qfxflipable.cpp220
-rw-r--r--src/declarative/fx/qfxflipable.h96
-rw-r--r--src/declarative/fx/qfxfocuspanel.cpp2
-rw-r--r--src/declarative/fx/qfxgridview.cpp13
-rw-r--r--src/declarative/fx/qfxhighlightfilter.cpp20
-rw-r--r--src/declarative/fx/qfximage.cpp91
-rw-r--r--src/declarative/fx/qfximage_p.h2
-rw-r--r--src/declarative/fx/qfximageitem.cpp21
-rw-r--r--src/declarative/fx/qfxitem.cpp144
-rw-r--r--src/declarative/fx/qfxitem_p.h6
-rw-r--r--src/declarative/fx/qfxkeyactions.cpp51
-rw-r--r--src/declarative/fx/qfxkeyproxy.cpp12
-rw-r--r--src/declarative/fx/qfxlayouts.cpp106
-rw-r--r--src/declarative/fx/qfxlistview.cpp18
-rw-r--r--src/declarative/fx/qfxmouseregion.cpp79
-rw-r--r--src/declarative/fx/qfxmouseregion.h2
-rw-r--r--src/declarative/fx/qfxmouseregion_p.h22
-rw-r--r--src/declarative/fx/qfxpainted.cpp2
-rw-r--r--src/declarative/fx/qfxparticles.cpp14
-rw-r--r--src/declarative/fx/qfxpath.cpp42
-rw-r--r--src/declarative/fx/qfxpathview.cpp60
-rw-r--r--src/declarative/fx/qfxpixmap.cpp20
-rw-r--r--src/declarative/fx/qfxrect.cpp52
-rw-r--r--src/declarative/fx/qfxrect_p.h2
-rw-r--r--src/declarative/fx/qfxreflectionfilter.cpp16
-rw-r--r--src/declarative/fx/qfxrepeater.cpp29
-rw-r--r--src/declarative/fx/qfxrepeater.h1
-rw-r--r--src/declarative/fx/qfxscalegrid.cpp16
-rw-r--r--src/declarative/fx/qfxshadowfilter.cpp4
-rw-r--r--src/declarative/fx/qfxtext.cpp34
-rw-r--r--src/declarative/fx/qfxtext_p.h2
-rw-r--r--src/declarative/fx/qfxtextedit.cpp4
-rw-r--r--src/declarative/fx/qfxtransform.cpp522
-rw-r--r--src/declarative/fx/qfxtransform.h174
-rw-r--r--src/declarative/fx/qfxvisualitemmodel.cpp80
-rw-r--r--src/declarative/fx/qfxwebview.cpp12
-rw-r--r--src/declarative/fx/qfxwidgetcontainer.cpp8
47 files changed, 1425 insertions, 911 deletions
diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri
index 7fe86fe..ef059c7 100644
--- a/src/declarative/fx/fx.pri
+++ b/src/declarative/fx/fx.pri
@@ -11,6 +11,7 @@ HEADERS += \
fx/qfxevents_p.h \
fx/qfxflickable.h \
fx/qfxflickable_p.h \
+ fx/qfxflipable.h \
fx/qfxfocuspanel.h \
fx/qfxfocusrealm.h \
fx/qfxgridview.h \
@@ -60,6 +61,7 @@ SOURCES += \
fx/qfxcontentwrapper.cpp \
fx/qfxevents.cpp \
fx/qfxflickable.cpp \
+ fx/qfxflipable.cpp \
fx/qfxfocuspanel.cpp \
fx/qfxfocusrealm.cpp \
fx/qfxgridview.cpp \
diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp
index 7372866..f537da9 100644
--- a/src/declarative/fx/qfxanchors.cpp
+++ b/src/declarative/fx/qfxanchors.cpp
@@ -165,7 +165,7 @@ QFxItem *QFxAnchors::fill() const
void QFxAnchors::setFill(QFxItem *f)
{
Q_D(QFxAnchors);
- if(d->fill) {
+ if (d->fill) {
QObject::disconnect(d->fill, SIGNAL(leftChanged()), this, SLOT(fillChanged()));
QObject::disconnect(d->fill, SIGNAL(topChanged()), this, SLOT(fillChanged()));
QObject::disconnect(d->fill, SIGNAL(widthChanged()), this, SLOT(fillChanged()));
@@ -214,11 +214,11 @@ QFxItem *QFxAnchors::centeredIn() const
void QFxAnchors::setCenteredIn(QFxItem* c)
{
Q_D(QFxAnchors);
- if(!c){
+ if (!c){
qmlInfo(d->item) << "Cannot center in null item.";
return;
}
- if(c != d->item->itemParent() && c->itemParent() != d->item->itemParent()){
+ if (c != d->item->itemParent() && c->itemParent() != d->item->itemParent()){
qmlInfo(d->item) << "Can't anchor to an item that isn't a parent or sibling.";
return;
}
@@ -822,7 +822,7 @@ bool QFxAnchorsPrivate::checkHAnchorValid(QFxAnchorLine anchor) const
if (anchor.anchorLine & QFxAnchorLine::Vertical_Mask) {
qmlInfo(item) << "Can't anchor a horizontal edge to a vertical edge.";
return false;
- }else if(anchor.item == item){
+ }else if (anchor.item == item){
qmlInfo(item) << "Can't anchor item to self.";
return false;
}
@@ -847,7 +847,7 @@ bool QFxAnchorsPrivate::checkVAnchorValid(QFxAnchorLine anchor) const
if (anchor.anchorLine & QFxAnchorLine::Horizontal_Mask) {
qmlInfo(item) << "Can't anchor a vertical edge to a horizontal edge.";
return false;
- }else if(anchor.item == item){
+ }else if (anchor.item == item){
qmlInfo(item) << "Can't anchor item to self.";
return false;
}
diff --git a/src/declarative/fx/qfxanimatedimageitem.cpp b/src/declarative/fx/qfxanimatedimageitem.cpp
index b5f0cc4..8f930d5 100644
--- a/src/declarative/fx/qfxanimatedimageitem.cpp
+++ b/src/declarative/fx/qfxanimatedimageitem.cpp
@@ -102,7 +102,7 @@ QFxAnimatedImageItem::~QFxAnimatedImageItem()
bool QFxAnimatedImageItem::isPlaying() const
{
Q_D(const QFxAnimatedImageItem);
- if(!d->_movie)
+ if (!d->_movie)
return false;
return d->_movie->state()==QMovie::Running;
}
@@ -110,9 +110,9 @@ bool QFxAnimatedImageItem::isPlaying() const
void QFxAnimatedImageItem::setPlaying(bool play)
{
Q_D(QFxAnimatedImageItem);
- if(!d->_movie)
+ if (!d->_movie)
return;
- if(play)
+ if (play)
d->_movie->start();
else
d->_movie->stop();
@@ -129,7 +129,7 @@ void QFxAnimatedImageItem::setPlaying(bool play)
int QFxAnimatedImageItem::currentFrame() const
{
Q_D(const QFxAnimatedImageItem);
- if(!d->_movie)
+ if (!d->_movie)
return -1;
return d->_movie->currentFrameNumber();
}
@@ -137,7 +137,7 @@ int QFxAnimatedImageItem::currentFrame() const
void QFxAnimatedImageItem::setCurrentFrame(int frame)
{
Q_D(QFxAnimatedImageItem);
- if(!d->_movie)
+ if (!d->_movie)
return;
d->_movie->jumpToFrame(frame);
}
@@ -145,7 +145,7 @@ void QFxAnimatedImageItem::setCurrentFrame(int frame)
int QFxAnimatedImageItem::frameCount() const
{
Q_D(const QFxAnimatedImageItem);
- if(!d->_movie)
+ if (!d->_movie)
return 0;
return d->_movie->frameCount();
}
@@ -153,13 +153,13 @@ int QFxAnimatedImageItem::frameCount() const
void QFxAnimatedImageItem::setSource(const QString &url)
{
Q_D(QFxAnimatedImageItem);
- if(url == d->source)
+ if (url == d->source)
return;
delete d->_movie;
d->_movie = 0;
- if(d->reply) {
+ if (d->reply) {
d->reply->deleteLater();
d->reply = 0;
}
@@ -167,7 +167,7 @@ void QFxAnimatedImageItem::setSource(const QString &url)
d->source = url;
d->url = qmlContext(this)->resolvedUrl(url);
- if(url.isEmpty()) {
+ if (url.isEmpty()) {
delete d->_movie;
d->status = Idle;
} else {
@@ -186,7 +186,7 @@ void QFxAnimatedImageItem::movieRequestFinished()
{
Q_D(QFxAnimatedImageItem);
d->_movie = new QMovie(d->reply);
- if(!d->_movie->isValid()){
+ if (!d->_movie->isValid()){
qWarning() << "Error Reading File " << d->url;
delete d->_movie;
d->_movie = 0;
diff --git a/src/declarative/fx/qfxblendedimage.cpp b/src/declarative/fx/qfxblendedimage.cpp
index ec2b9cc..3326ea8 100644
--- a/src/declarative/fx/qfxblendedimage.cpp
+++ b/src/declarative/fx/qfxblendedimage.cpp
@@ -173,7 +173,7 @@ bool QFxBlendedImage::smoothTransform() const
void QFxBlendedImage::setSmoothTransform(bool s)
{
- if(_smooth == s)
+ if (_smooth == s)
return;
_smooth = s;
update();
@@ -186,7 +186,7 @@ void QFxBlendedImage::paintContents(QPainter &p)
if (primSrc.isNull() && secSrc.isNull())
return;
- if(_smooth) {
+ if (_smooth) {
p.save();
p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, _smooth);
}
@@ -196,7 +196,7 @@ void QFxBlendedImage::paintContents(QPainter &p)
else
p.drawImage(0, 0, secPix);
- if(_smooth) {
+ if (_smooth) {
p.restore();
}
}
@@ -206,10 +206,10 @@ void QFxBlendedImage::paintContents(QPainter &p)
void QFxBlendedImage::paintGLContents(GLPainter &p)
{
static DualTextureBlendShader *shader = 0;
- if(!shader)
+ if (!shader)
shader = new DualTextureBlendShader();
- if(dirty) {
+ if (dirty) {
prim.clear();
sec.clear();
prim.setImage(primPix);
@@ -218,7 +218,7 @@ void QFxBlendedImage::paintGLContents(GLPainter &p)
dirty = false;
}
- if(prim.isNull() || sec.isNull()) {
+ if (prim.isNull() || sec.isNull()) {
return;
}
@@ -228,9 +228,9 @@ void QFxBlendedImage::paintGLContents(GLPainter &p)
float widthV = width();
float heightV = height();
- if(!widthV)
+ if (!widthV)
widthV = qMax(primPix.width(), secPix.width());
- if(!heightV)
+ if (!heightV)
heightV = qMax(primPix.height(), secPix.height());
vertices[0] = 0; vertices[1] = heightV;
@@ -243,12 +243,12 @@ void QFxBlendedImage::paintGLContents(GLPainter &p)
texVertices[4] = 0; texVertices[5] = 1;
texVertices[6] = 1; texVertices[7] = 1;
- if(_blend == 0 || _blend == 1) {
+ if (_blend == 0 || _blend == 1) {
QGLShaderProgram *tshader = p.useTextureShader();
GLTexture *tex = 0;
- if(_blend == 0)
+ if (_blend == 0)
tex = &prim;
else
tex = &sec;
@@ -271,8 +271,8 @@ void QFxBlendedImage::paintGLContents(GLPainter &p)
shader->enable();
shader->setOpacity(1);
qreal b = _blend;
- if(b > 1) b = 1;
- else if(b < 0) b = 0;
+ if (b > 1) b = 1;
+ else if (b < 0) b = 0;
shader->setBlend(b);
shader->setTransform(p.activeTransform);
diff --git a/src/declarative/fx/qfxblurfilter.cpp b/src/declarative/fx/qfxblurfilter.cpp
index 748fd8b..ad3eebc 100644
--- a/src/declarative/fx/qfxblurfilter.cpp
+++ b/src/declarative/fx/qfxblurfilter.cpp
@@ -124,7 +124,7 @@ qreal QFxBlurFilter::radius() const
void QFxBlurFilter::setRadius(qreal radius)
{
- if(d->radius == radius) return;
+ if (d->radius == radius) return;
d->radius = radius;
emit radiusChanged(radius);
update();
@@ -133,7 +133,7 @@ void QFxBlurFilter::setRadius(qreal radius)
QRectF QFxBlurFilter::itemBoundingRect(const QRectF &r) const
{
QRectF rv = r;
- if(d->radius > 0)
+ if (d->radius > 0)
rv.adjust(-d->radius, -d->radius, d->radius, d->radius);
return rv;
}
@@ -143,7 +143,7 @@ void QFxBlurFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
{
#if defined(QFX_RENDER_OPENGL2)
#if 1
- if(d->radius <= 0) {
+ if (d->radius <= 0) {
renderToScreen();
return;
}
@@ -156,7 +156,7 @@ void QFxBlurFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
radius *= blurScale;
QGLFramebufferObject *fbo = renderToFBO(blurScale);
- if(!fbo)
+ if (!fbo)
return;
float height = r.height();
@@ -201,7 +201,7 @@ void QFxBlurFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
BlurTextureShader *shader = item->basicShaders()->blurTexture();
shader->enable();
shader->setTransform(trans);
- if(steps > 1) {
+ if (steps > 1) {
shader->setStep(xstep * 2);
shader->setSteps(steps / 2);
} else {
@@ -252,7 +252,7 @@ void QFxBlurFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
BlurTextureShader *shader = item->basicShaders()->blurTexture();
shader->enable();
shader->setTransform(trans);
- if(steps > 1) {
+ if (steps > 1) {
shader->setStep(ystep * 2);
shader->setSteps(steps / 2);
} else {
@@ -303,7 +303,7 @@ void QFxBlurFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
releaseFBO(fbo);
#else
#if 0
- if(d->radius <= 0) {
+ if (d->radius <= 0) {
renderToScreen();
return;
}
@@ -314,7 +314,7 @@ void QFxBlurFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
float scale = 0.5;
float scalePercent = scale / d->radius;
QGLFramebufferObject *fbo = renderToFBO(scalePercent);
- if(!fbo)
+ if (!fbo)
return;
QGLFramebufferObject *xfbo = acquireFBO(QSize(scale * r.width(), fbo->height()));
diff --git a/src/declarative/fx/qfxcomponentinstance.cpp b/src/declarative/fx/qfxcomponentinstance.cpp
index 02a6c86..951c25d 100644
--- a/src/declarative/fx/qfxcomponentinstance.cpp
+++ b/src/declarative/fx/qfxcomponentinstance.cpp
@@ -97,7 +97,7 @@ QmlComponent *QFxComponentInstance::component() const
void QFxComponentInstance::setComponent(QmlComponent *c)
{
Q_D(QFxComponentInstance);
- if(d->component) {
+ if (d->component) {
qmlInfo(this) << "component is a write-once property.";
return;
}
@@ -108,11 +108,11 @@ void QFxComponentInstance::setComponent(QmlComponent *c)
void QFxComponentInstance::create()
{
Q_D(QFxComponentInstance);
- if(d->component) {
+ if (d->component) {
QObject *obj= d->component->create(qmlContext(this));
- if(obj) {
+ if (obj) {
QFxItem *objitem = qobject_cast<QFxItem *>(obj);
- if(objitem) {
+ if (objitem) {
d->instance = objitem;
objitem->setItemParent(this);
objitem->setFocus(true);
@@ -130,10 +130,10 @@ void QFxComponentInstance::create()
void QFxComponentInstance::updateSize()
{
QFxItem *i = instance();
- if(i) {
- if(!widthValid())
+ if (i) {
+ if (!widthValid())
setImplicitWidth(i->width());
- if(!heightValid())
+ if (!heightValid())
setImplicitHeight(i->height());
}
}
diff --git a/src/declarative/fx/qfxcontentwrapper.cpp b/src/declarative/fx/qfxcontentwrapper.cpp
index 5ce5430..a155d2b 100644
--- a/src/declarative/fx/qfxcontentwrapper.cpp
+++ b/src/declarative/fx/qfxcontentwrapper.cpp
@@ -76,7 +76,7 @@ void QFxContentWrapper::componentComplete()
target = target->itemParent();
QList<QFxItem*> myContent(*content());
- for(int ii = 0; ii < myContent.count(); ++ii)
+ for (int ii = 0; ii < myContent.count(); ++ii)
myContent.at(ii)->setParent(target);
}
diff --git a/src/declarative/fx/qfxevents.cpp b/src/declarative/fx/qfxevents.cpp
index a3fa6af..7d04f5d 100644
--- a/src/declarative/fx/qfxevents.cpp
+++ b/src/declarative/fx/qfxevents.cpp
@@ -42,10 +42,74 @@
#include "qfxevents_p.h"
QT_BEGIN_NAMESPACE
+/*!
+ \qmlclass KeyEvent QFxKeyEvent
+ \brief The KeyEvent element provides information about a key event.
+
+ For example, the following changes the Item's state property when the Enter
+ key is pressed:
+ \code
+ <Item focus="true">
+ <onKeyPress>if (event.key == Qt.Key_Enter) state = 'ShowDetails';</onKeyPress>
+ </Item>
+ \endcode
+
+ The \l KeyActions element could also be used to achieve the above with
+ a clearer syntax.
+
+ \sa KeyActions
+*/
+
+/*!
+ \internal
+ \class QFxKeyEvent
+*/
+
+/*!
+ \qmlproperty int KeyEvent::key
+
+ This property holds the code of the key that was pressed or released.
+
+ See \l {Qt::Key}{Qt.Key} for the list of keyboard codes. These codes are
+ independent of the underlying window system. Note that this
+ function does not distinguish between capital and non-capital
+ letters, use the text() function (returning the Unicode text the
+ key generated) for this purpose.
+
+ A value of either 0 or \l {Qt::Key_unknown}{Qt.Key_Unknown} means that the event is not
+ the result of a known key; for example, it may be the result of
+ a compose sequence, a keyboard macro, or due to key event
+ compression.
+*/
+
+/*!
+ \qmlproperty string KeyEvent::text
+
+ This property holds the Unicode text that the key generated.
+ The text returned can be an empty string in cases where modifier keys,
+ such as Shift, Control, Alt, and Meta, are being pressed or released.
+ In such cases \c key will contain a valid value
+*/
+
+/*!
+ \qmlproperty bool KeyEvent::isAutoRepeat
+
+ This property holds whether this event comes from an auto-repeating key.
+*/
+
+/*!
+ \qmlproperty int KeyEvent::count
+
+ This property holds the number of keys involved in this event. If \l KeyEvent::text
+ is not empty, this is simply the length of the string.
+*/
/*!
\qmlclass MouseEvent QFxMouseEvent
\brief The MouseEvent element provides information about a mouse event.
+
+ The position of the mouse can be found via the x and y properties.
+ The button that caused the event is available via the button property.
*/
/*!
@@ -54,16 +118,65 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlproperty int x
- \qmlproperty int y
+ \qmlproperty int MouseEvent::x
+ \qmlproperty int MouseEvent::y
These properties hold the position of the mouse event.
*/
/*!
- \qmlproperty enum button
+ \qmlproperty enum MouseEvent::button
+
+ This property holds the button that caused the event. It can be one of:
+ \list
+ \o Qt.LeftButton
+ \o Qt.RightButton
+ \o Qt.MidButton
+ \endlist
+*/
+
+/*!
+ \qmlproperty int MouseEvent::buttons
+
+ This property holds the mouse buttons pressed when the event was generated.
+ For mouse move events, this is all buttons that are pressed down. For mouse
+ press and double click events this includes the button that caused the event.
+ For mouse release events this excludes the button that caused the event.
+
+ It contains a bitwise combination of:
+ \list
+ \o Qt.LeftButton
+ \o Qt.RightButton
+ \o Qt.MidButton
+ \endlist
+*/
+
+/*!
+ \qmlproperty int MouseEvent::modifiers
+
+ This property holds the keyboard modifier flags that existed immediately
+ before the event occurred.
+
+ It contains a bitwise combination of:
+ \list
+ \o Qt.NoModifier - No modifier key is pressed.
+ \o Qt.ShiftModifier - A Shift key on the keyboard is pressed.
+ \o Qt.ControlModifier - A Ctrl key on the keyboard is pressed.
+ \o Qt.AltModifier - An Alt key on the keyboard is pressed.
+ \o Qt.MetaModifier - A Meta key on the keyboard is pressed.
+ \o Qt.KeypadModifier - A keypad button is pressed.
+ \endlist
- This property holds the button that caused the event.
+ For example, to react to a Shift key + Left mouse button click:
+ \code
+ <MouseRegion>
+ <onClick>
+ <![CDATA[
+ if (mouse.button == Qt.LeftButton && mouse.modifiers & Qt.ShiftModifier) doSomething();
+ ]]>
+ </onclick>
+ </MouseRegion>
+ \endcode
*/
QML_DEFINE_NOCREATE_TYPE(QFxKeyEvent);
diff --git a/src/declarative/fx/qfxevents_p.h b/src/declarative/fx/qfxevents_p.h
index d096a90..30717ef 100644
--- a/src/declarative/fx/qfxevents_p.h
+++ b/src/declarative/fx/qfxevents_p.h
@@ -52,12 +52,12 @@ QT_BEGIN_NAMESPACE
class QFxKeyEvent : public QObject
{
Q_OBJECT
- Q_PROPERTY(int key READ key);
- Q_PROPERTY(QString text READ text);
- Q_PROPERTY(Qt::KeyboardModifiers modifiers READ modifiers);
- Q_PROPERTY(bool isAutoRepeat READ isAutoRepeat);
- Q_PROPERTY(int count READ count);
- Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted);
+ Q_PROPERTY(int key READ key)
+ Q_PROPERTY(QString text READ text)
+ Q_PROPERTY(int modifiers READ modifiers)
+ Q_PROPERTY(bool isAutoRepeat READ isAutoRepeat)
+ Q_PROPERTY(int count READ count)
+ Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
public:
QFxKeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text=QString(), bool autorep=false, ushort count=1)
@@ -67,7 +67,7 @@ public:
int key() const { return event.key(); }
QString text() const { return event.text(); }
- Qt::KeyboardModifiers modifiers() const { return event.modifiers(); }
+ int modifiers() const { return event.modifiers(); }
bool isAutoRepeat() const { return event.isAutoRepeat(); }
int count() const { return event.count(); }
@@ -83,14 +83,14 @@ QML_DECLARE_TYPE(QFxKeyEvent);
class QFxMouseEvent : public QObject
{
Q_OBJECT
- Q_PROPERTY(int x READ x);
- Q_PROPERTY(int y READ y);
- Q_PROPERTY(Qt::MouseButton button READ button);
- Q_PROPERTY(Qt::MouseButtons buttons READ buttons);
- Q_PROPERTY(Qt::KeyboardModifiers modifiers READ modifiers);
- Q_PROPERTY(bool wasHeld READ wasHeld);
- Q_PROPERTY(bool isClick READ isClick);
- Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted);
+ Q_PROPERTY(int x READ x)
+ Q_PROPERTY(int y READ y)
+ Q_PROPERTY(int button READ button)
+ Q_PROPERTY(int buttons READ buttons)
+ Q_PROPERTY(int modifiers READ modifiers)
+ Q_PROPERTY(bool wasHeld READ wasHeld)
+ Q_PROPERTY(bool isClick READ isClick)
+ Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
public:
QFxMouseEvent(int x, int y, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers
@@ -100,9 +100,9 @@ public:
int x() const { return _x; }
int y() const { return _y; }
- Qt::MouseButton button() const { return _button; }
- Qt::MouseButtons buttons() const { return _buttons; }
- Qt::KeyboardModifiers modifiers() const { return _modifiers; }
+ int button() const { return _button; }
+ int buttons() const { return _buttons; }
+ int modifiers() const { return _modifiers; }
bool wasHeld() const { return _wasHeld; }
bool isClick() const { return _isClick; }
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp
index b6eaa8e..671d65d 100644
--- a/src/declarative/fx/qfxflickable.cpp
+++ b/src/declarative/fx/qfxflickable.cpp
@@ -121,16 +121,16 @@ void QFxFlickablePrivate::init()
void QFxFlickablePrivate::fixupX()
{
Q_Q(QFxFlickable);
- if(!q->xflick() || _moveX.timeLine())
+ if (!q->xflick() || _moveX.timeLine())
return;
vTime = _tl.time();
- if(_moveX.value() > q->minXExtent() || q->maxXExtent() > 0) {
+ if (_moveX.value() > q->minXExtent() || q->maxXExtent() > 0) {
_tl.move(_moveX, q->minXExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
flicked = false;
//emit flickingChanged();
- } else if(_moveX.value() < q->maxXExtent()) {
+ } else if (_moveX.value() < q->maxXExtent()) {
_tl.move(_moveX, q->maxXExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
flicked = false;
//emit flickingChanged();
@@ -140,15 +140,15 @@ void QFxFlickablePrivate::fixupX()
void QFxFlickablePrivate::fixupY()
{
Q_Q(QFxFlickable);
- if(!q->yflick() || _moveY.timeLine())
+ if (!q->yflick() || _moveY.timeLine())
return;
vTime = _tl.time();
- if(_moveY.value() > q->minYExtent() || (q->maxYExtent() > q->minYExtent())) {
+ if (_moveY.value() > q->minYExtent() || (q->maxYExtent() > q->minYExtent())) {
_tl.move(_moveY, q->minYExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
//emit flickingChanged();
- } else if(_moveY.value() < q->maxYExtent()) {
+ } else if (_moveY.value() < q->maxYExtent()) {
_tl.move(_moveY, q->maxYExtent(), QEasingCurve(QEasingCurve::InOutQuad), 200);
//emit flickingChanged();
} else {
@@ -560,17 +560,17 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
bool rejectX = false;
bool moved = false;
- if(q->yflick()) {
+ if (q->yflick()) {
int dy = int(event->pos().y() - pressPos.y());
if (qAbs(dy) > FlickThreshold || pressTime.elapsed() > 200) {
qreal newY = dy + pressY;
const qreal minY = q->minYExtent();
const qreal maxY = q->maxYExtent();
- if(newY > minY)
+ if (newY > minY)
newY = minY + (newY - minY) / 2;
- if(newY < maxY && maxY - minY < 0)
+ if (newY < maxY && maxY - minY < 0)
newY = maxY + (newY - maxY) / 2;
- if(q->overShoot() || (newY <= minY && newY >= maxY)) {
+ if (q->overShoot() || (newY <= minY && newY >= maxY)) {
if (dragMode == QFxFlickable::Hard)
_moveY.setValue(newY);
else
@@ -583,11 +583,11 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
}
- if(q->xflick()) {
+ if (q->xflick()) {
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())) {
+ if (q->overShoot() || (newX <= q->minXExtent() && newX >= q->maxXExtent())) {
if (dragMode == QFxFlickable::Hard)
_moveX.setValue(newX);
else
@@ -600,23 +600,23 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
}
- if(!lastPos.isNull()) {
+ if (!lastPos.isNull()) {
qreal elapsed = qreal(lastPosTime.restart()) / 1000.;
- if(elapsed <= 0)
+ if (elapsed <= 0)
elapsed = 1;
- if(q->yflick()) {
+ if (q->yflick()) {
qreal diff = event->pos().y() - lastPos.y();
velocityY = diff / elapsed;
}
- if(q->xflick()) {
+ if (q->xflick()) {
qreal diff = event->pos().x() - lastPos.x();
velocityX = diff / elapsed;
}
}
- if(rejectY) velocityY = 0;
- if(rejectX) velocityX = 0;
+ if (rejectY) velocityY = 0;
+ if (rejectX) velocityX = 0;
if (moved) {
q->viewportMoved();
@@ -640,20 +640,20 @@ void QFxFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *)
}
vTime = _tl.time();
- if(qAbs(velocityY) > 10) {
+ if (qAbs(velocityY) > 10) {
qreal maxDistance = -1;
// -ve velocity means list is moving up
- if(velocityY > 0) {
- if(_moveY.value() < q->minYExtent())
+ if (velocityY > 0) {
+ if (_moveY.value() < q->minYExtent())
maxDistance = qAbs(q->minYExtent() -_moveY.value() + (overShoot?30:0));
} else {
- if(_moveY.value() > q->maxYExtent())
+ if (_moveY.value() > q->maxYExtent())
maxDistance = qAbs(q->maxYExtent() - _moveY.value()) + (overShoot?30:0);
}
- if(maxDistance > 0) {
+ if (maxDistance > 0) {
qreal v = velocityY;
- if(maxVelocity != -1 && maxVelocity < qAbs(v)) {
- if(v < 0)
+ if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
+ if (v < 0)
v = -maxVelocity;
else
v = maxVelocity;
@@ -669,20 +669,20 @@ void QFxFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *)
} else {
fixupY();
}
- if(qAbs(velocityX) > 10) {
+ if (qAbs(velocityX) > 10) {
qreal maxDistance = -1;
// -ve velocity means list is moving up
- if(velocityX > 0) {
- if(_moveX.value() < q->minXExtent())
+ if (velocityX > 0) {
+ if (_moveX.value() < q->minXExtent())
maxDistance = qAbs(q->minXExtent()) -_moveX.value() + (overShoot?30:0);
} else {
- if(_moveX.value() > q->maxXExtent())
+ if (_moveX.value() > q->maxXExtent())
maxDistance = qAbs(q->maxXExtent() - _moveX.value()) + (overShoot?30:0);
}
- if(maxDistance > 0) {
+ if (maxDistance > 0) {
qreal v = velocityX;
- if(maxVelocity != -1 && maxVelocity < qAbs(v)) {
- if(v < 0)
+ if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
+ if (v < 0)
v = -maxVelocity;
else
v = maxVelocity;
@@ -701,7 +701,7 @@ void QFxFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *)
stealMouse = false;
lastPosTime = QTime();
- if(!_tl.isActive())
+ if (!_tl.isActive())
q->movementEnding();
}
@@ -766,7 +766,7 @@ void QFxFlickable::viewportMoved()
qreal prevY = d->lastFlickablePosition.x();
qreal prevX = d->lastFlickablePosition.y();
d->velocityTimeline.clear();
- if(d->pressed) {
+ if (d->pressed) {
qreal xVelocity = (prevX - d->_moveX.value()) * 1000 / elapsed;
qreal yVelocity = (prevY - d->_moveY.value()) * 1000 / elapsed;
d->velocityTimeline.move(d->xVelocity, xVelocity, d->velocityDecay);
@@ -804,7 +804,7 @@ void QFxFlickablePrivate::data_append(QObject *o)
{
Q_Q(QFxFlickable);
QFxItem *i = qobject_cast<QFxItem *>(o);
- if(i)
+ if (i)
_flick->children()->append(i);
else
o->setParent(q);
@@ -901,7 +901,7 @@ void QFxFlickable::setViewportWidth(int w)
if (d->vWidth == w)
return;
d->vWidth = w;
- if(w < 0)
+ if (w < 0)
d->_flick->setWidth(width());
else
d->_flick->setWidth(w);
@@ -913,7 +913,7 @@ void QFxFlickable::setWidth(int w)
{
Q_D(QFxFlickable);
QFxItem::setWidth(w);
- if(d->vWidth < 0) {
+ if (d->vWidth < 0) {
d->_flick->setWidth(w);
emit viewportWidthChanged();
d->updateBeginningEnd();
@@ -924,7 +924,7 @@ void QFxFlickable::setHeight(int h)
{
Q_D(QFxFlickable);
QFxItem::setHeight(h);
- if(d->vHeight < 0) {
+ if (d->vHeight < 0) {
d->_flick->setHeight(h);
emit viewportHeightChanged();
d->updateBeginningEnd();
@@ -947,7 +947,7 @@ void QFxFlickable::setViewportHeight(int h)
if (d->vHeight == h)
return;
d->vHeight = h;
- if(h < 0)
+ if (h < 0)
d->_flick->setHeight(height());
else
d->_flick->setHeight(h);
@@ -958,7 +958,7 @@ void QFxFlickable::setViewportHeight(int h)
int QFxFlickable::vWidth() const
{
Q_D(const QFxFlickable);
- if(d->vWidth < 0)
+ if (d->vWidth < 0)
return width();
else
return d->vWidth;
@@ -967,7 +967,7 @@ int QFxFlickable::vWidth() const
int QFxFlickable::vHeight() const
{
Q_D(const QFxFlickable);
- if(d->vHeight < 0)
+ if (d->vHeight < 0)
return height();
else
return d->vHeight;
@@ -1028,7 +1028,7 @@ bool QFxFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event)
bool QFxFlickable::mouseFilter(QGraphicsSceneMouseEvent *e)
{
- if(!isVisible())
+ if (!isVisible())
return false;
switch (e->type()) {
case QEvent::GraphicsSceneMousePress:
@@ -1060,7 +1060,7 @@ int QFxFlickable::maximumFlickVelocity() const
void QFxFlickable::setMaximumFlickVelocity(int v)
{
Q_D(QFxFlickable);
- if(v == d->maxVelocity)
+ if (v == d->maxVelocity)
return;
d->maxVelocity = v;
}
@@ -1081,7 +1081,7 @@ void QFxFlickable::setVelocityDecay(int decay)
{
Q_D(QFxFlickable);
Q_ASSERT(decay >= 0);
- if(decay == d->velocityDecay)
+ if (decay == d->velocityDecay)
return;
d->velocityDecay = decay;
emit velocityDecayChanged(decay);
@@ -1096,7 +1096,7 @@ bool QFxFlickable::isMoving() const
void QFxFlickable::movementStarting()
{
Q_D(QFxFlickable);
- if(!d->moving) {
+ if (!d->moving) {
d->moving = true;
emit movingChanged();
emit movementStarted();
@@ -1106,7 +1106,7 @@ void QFxFlickable::movementStarting()
void QFxFlickable::movementEnding()
{
Q_D(QFxFlickable);
- if(d->moving) {
+ if (d->moving) {
d->moving = false;
emit movingChanged();
emit movementEnded();
diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp
new file mode 100644
index 0000000..9db0b57
--- /dev/null
+++ b/src/declarative/fx/qfxflipable.cpp
@@ -0,0 +1,220 @@
+/****************************************************************************
+**
+** 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 "qfxflipable.h"
+#include "private/qfxitem_p.h"
+#include "qfxtransform.h"
+#include <QtDeclarative/qmlinfo.h>
+
+QML_DEFINE_TYPE(QFxFlipable,Flipable);
+
+class QFxFlipablePrivate : public QFxItemPrivate
+{
+public:
+ QFxFlipablePrivate() : current(QFxFlipable::Front), front(0), back(0) {}
+
+ QFxFlipable::Side current;
+ QFxItem *front;
+ QFxItem *back;
+};
+
+/*!
+ \qmlclass Flipable QFxFlipable
+ \brief The Flipable element provides a surface that can be flipped.
+ \inherits Item
+
+ Flipable allows you to specify a front and a back and then flip between those sides.
+
+ \code
+ <Flipable id="flipable" width="40" height="40">
+ <transform>
+ <Axis id="axis" xStart="20" xEnd="20" yStart="20" yEnd="0" />
+ </transform>
+ <front>
+ <Image file="front.png"/>
+ </front>
+ <back>
+ <Image file="back.png"/>
+ </back>
+ <states>
+ <State name="back">
+ <SetProperty target="{axis}" property="rotation" value="180" />
+ </State>
+ </states>
+ <transitions>
+ <Transition>
+ <NumericAnimation easing="easeInOutQuad" properties="rotation"/>
+ </Transition>
+ </transitions>
+ </Flipable>
+ \endcode
+
+ \image flipable.gif
+*/
+
+/*!
+ \internal
+ \class QFxFlipable
+ \brief The QFxFlipable class provides a flipable surface.
+
+ \ingroup group_widgets
+
+ QFxFlipable allows you to specify a front and a back, as well as an
+ axis for the flip.
+*/
+
+QFxFlipable::QFxFlipable(QFxItem *parent)
+: QFxItem(*(new QFxFlipablePrivate), parent)
+{
+}
+
+QFxFlipable::~QFxFlipable()
+{
+}
+
+/*!
+ \qmlproperty Item Flipable::front
+ \qmlproperty Item Flipable::back
+
+ The front and back sides of the flipable.
+*/
+
+QFxItem *QFxFlipable::front()
+{
+ Q_D(const QFxFlipable);
+ return d->front;
+}
+
+void QFxFlipable::setFront(QFxItem *front)
+{
+ Q_D(QFxFlipable);
+ if (d->front) {
+ qmlInfo(this) << "front is a write-once property";
+ return;
+ }
+ d->front = front;
+ children()->append(d->front);
+ if (Back == d->current)
+ d->front->setOpacity(0.);
+}
+
+QFxItem *QFxFlipable::back()
+{
+ Q_D(const QFxFlipable);
+ return d->back;
+}
+
+void QFxFlipable::setBack(QFxItem *back)
+{
+ Q_D(QFxFlipable);
+ if (d->back) {
+ qmlInfo(this) << "back is a write-once property";
+ return;
+ }
+ d->back = back;
+ children()->append(d->back);
+ if (Front == d->current)
+ d->back->setOpacity(0.);
+}
+
+/*!
+ \qmlproperty enumeration Flipable::side
+
+ The side of the Flippable currently visible. Possible values are \c
+ Front and \c Back.
+*/
+QFxFlipable::Side QFxFlipable::side() const
+{
+ Q_D(const QFxFlipable);
+ return d->current;
+}
+
+void QFxFlipable::transformChanged(const QSimpleCanvas::Matrix &trans)
+{
+ Q_D(QFxFlipable);
+ QPointF p1(0, 0);
+ QPointF p2(1, 0);
+ QPointF p3(1, 1);
+
+ p1 = trans.map(p1);
+ p2 = trans.map(p2);
+ p3 = trans.map(p3);
+
+ qreal cross = (p1.x() - p2.x()) * (p3.y() - p2.y()) -
+ (p1.y() - p2.y()) * (p3.x() - p2.x());
+
+ Side newSide;
+ if (cross > 0) {
+ newSide = Back;
+ } else {
+ newSide = Front;
+ }
+
+ if (newSide != d->current) {
+ d->current = newSide;
+ if (d->current==Back) {
+ QSimpleCanvas::Matrix mat;
+#ifdef QFX_RENDER_OPENGL
+ mat.translate(d->back->width()/2,d->back->height()/2, 0);
+ if (d->back->width() && p1.x() >= p2.x())
+ mat.rotate(180, 0, 1, 0);
+ if (d->back->height() && p2.y() >= p3.y())
+ mat.rotate(180, 1, 0, 0);
+ mat.translate(-d->back->width()/2,-d->back->height()/2, 0);
+#else
+ mat.translate(d->back->width()/2,d->back->height()/2);
+ if (d->back->width() && p1.x() >= p2.x())
+ mat.rotate(180, Qt::YAxis);
+ if (d->back->height() && p2.y() >= p3.y())
+ mat.rotate(180, Qt::XAxis);
+ mat.translate(-d->back->width()/2,-d->back->height()/2);
+#endif
+ d->back->setTransform(mat);
+ }
+ if (d->front)
+ d->front->setOpacity((d->current==Front)?1.:0.);
+ if (d->back)
+ d->back->setOpacity((d->current==Back)?1.:0.);
+ emit sideChanged();
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxflipable.h b/src/declarative/fx/qfxflipable.h
new file mode 100644
index 0000000..2c6c849
--- /dev/null
+++ b/src/declarative/fx/qfxflipable.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** 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 QFXFLIPABLE_H
+#define QFXFLIPABLE_H
+
+#include <QObject>
+#include <QTransform>
+#if defined(QFX_RENDER_OPENGL)
+#include <QtGui/qmatrix4x4.h>
+#endif
+#include <qfxitem.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QFxFlipablePrivate;
+class Q_DECLARATIVE_EXPORT QFxFlipable : public QFxItem
+{
+ Q_OBJECT
+
+ Q_ENUMS(Side);
+ Q_PROPERTY(QFxItem *front READ front WRITE setFront)
+ Q_PROPERTY(QFxItem *back READ back WRITE setBack)
+ Q_PROPERTY(Side side READ side NOTIFY sideChanged)
+public:
+ QFxFlipable(QFxItem *parent=0);
+ ~QFxFlipable();
+
+ QFxItem *front();
+ void setFront(QFxItem *);
+
+ QFxItem *back();
+ void setBack(QFxItem *);
+
+ enum Side { Front, Back };
+ Side side() const;
+
+protected:
+ virtual void transformChanged(const QSimpleCanvas::Matrix &);
+
+Q_SIGNALS:
+ void sideChanged();
+
+private:
+ Q_DISABLE_COPY(QFxFlipable)
+ Q_DECLARE_PRIVATE(QFxFlipable)
+};
+QML_DECLARE_TYPE(QFxFlipable);
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QFXFLIPABLE_H
diff --git a/src/declarative/fx/qfxfocuspanel.cpp b/src/declarative/fx/qfxfocuspanel.cpp
index 1bca424..67c456e 100644
--- a/src/declarative/fx/qfxfocuspanel.cpp
+++ b/src/declarative/fx/qfxfocuspanel.cpp
@@ -79,7 +79,7 @@ QFxFocusPanel::~QFxFocusPanel()
bool QFxFocusPanel::isActive() const
{
QSimpleCanvas *canvas = QSimpleCanvasItem::canvas();
- if(canvas)
+ if (canvas)
return canvas->activeFocusPanel() == this;
else
return false;
diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp
index 25c1565..c8b8d27 100644
--- a/src/declarative/fx/qfxgridview.cpp
+++ b/src/declarative/fx/qfxgridview.cpp
@@ -79,8 +79,11 @@ public:
}
static QFxGridViewAttached *properties(QObject *obj) {
- QFxGridViewAttached *rv = new QFxGridViewAttached(obj);
- attachedProperties.insert(obj, rv);
+ QFxGridViewAttached *rv = attachedProperties.value(obj);
+ if (!rv) {
+ rv = new QFxGridViewAttached(obj);
+ attachedProperties.insert(obj, rv);
+ }
return rv;
}
@@ -995,7 +998,7 @@ int QFxGridView::cacheBuffer() const
void QFxGridView::setCacheBuffer(int buffer)
{
Q_D(QFxGridView);
- if(d->buffer != buffer) {
+ if (d->buffer != buffer) {
d->buffer = buffer;
if (isComponentComplete())
refill();
@@ -1327,8 +1330,8 @@ void QFxGridView::itemsInserted(int modelIndex, int count)
}
}
// everything is in order now - emit add() signal
- foreach(FxGridItem *item, added)
- item->attached->emitAdd();
+ for (int j = 0; j < added.count(); ++j)
+ added.at(j)->attached->emitAdd();
d->layout();
emit countChanged();
}
diff --git a/src/declarative/fx/qfxhighlightfilter.cpp b/src/declarative/fx/qfxhighlightfilter.cpp
index d99b9e5..ab0512c 100644
--- a/src/declarative/fx/qfxhighlightfilter.cpp
+++ b/src/declarative/fx/qfxhighlightfilter.cpp
@@ -131,7 +131,7 @@ void QFxHighlightFilter::imageLoaded()
{
QImage img = QFxPixmap(d->url);
#if defined(QFX_RENDER_OPENGL2)
- if(!img.isNull())
+ if (!img.isNull())
d->tex.setImage(img);
#endif
emit sourceChanged(d->source);
@@ -142,14 +142,14 @@ void QFxHighlightFilter::setSource(const QString &f)
{
if (d->source == f)
return;
- if(!d->source.isEmpty())
+ if (!d->source.isEmpty())
QFxPixmap::cancelGet(d->url, this, SLOT(imageLoaded()));
d->source = f;
d->url = qmlContext(this)->resolvedUrl(f);
#if defined(QFX_RENDER_OPENGL2)
d->tex.clear();
#endif
- if(!f.isEmpty())
+ if (!f.isEmpty())
QFxPixmap::get(qmlEngine(this), d->url, this, SLOT(imageLoaded()));
else
emit sourceChanged(d->source);
@@ -171,13 +171,13 @@ bool QFxHighlightFilter::tiled() const
void QFxHighlightFilter::setTiled(bool t)
{
- if(t == d->tiled)
+ if (t == d->tiled)
return;
d->tiled = t;
#if defined(QFX_RENDER_OPENGL2)
- if(d->tiled) {
+ if (d->tiled) {
d->tex.setHorizontalWrap(GLTexture::ClampToEdge);
d->tex.setVerticalWrap(GLTexture::ClampToEdge);
} else {
@@ -206,7 +206,7 @@ int QFxHighlightFilter::xOffset() const
void QFxHighlightFilter::setXOffset(int x)
{
- if(x == d->xOffset)
+ if (x == d->xOffset)
return;
d->xOffset = x;
@@ -227,7 +227,7 @@ int QFxHighlightFilter::yOffset() const
void QFxHighlightFilter::setYOffset(int y)
{
- if(y == d->yOffset)
+ if (y == d->yOffset)
return;
d->yOffset = y;
@@ -240,7 +240,7 @@ void QFxHighlightFilter::setYOffset(int y)
void QFxHighlightFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
{
#if defined(QFX_RENDER_OPENGL2)
- if(d->tex.isNull()) {
+ if (d->tex.isNull()) {
renderToScreen();
} else {
QSimpleCanvasItem *item = this->item();
@@ -266,9 +266,9 @@ void QFxHighlightFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
float texXOffset = 0;
float texYOffset = 0;
- if(xOffset())
+ if (xOffset())
texXOffset = float(xOffset()) / float(d->tex.width());
- if(yOffset())
+ if (yOffset())
texYOffset = float(yOffset()) / float(d->tex.height());
GLfloat addTexVert[] = { texXOffset, texYOffset,
diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp
index 2d0dbc7..a34cd12 100644
--- a/src/declarative/fx/qfximage.cpp
+++ b/src/declarative/fx/qfximage.cpp
@@ -124,7 +124,7 @@ QFxImage::QFxImage(QFxImagePrivate &dd, QFxItem *parent)
QFxImage::~QFxImage()
{
Q_D(const QFxImage);
- if(d->reply)
+ if (d->reply)
d->reply->deleteLater();
}
@@ -183,7 +183,8 @@ void QFxImage::setPixmap(const QPixmap &pix)
Each scale grid property (left, right, top, and bottom) specifies an offset from the respective side. For example, \c scaleGrid.bottom="10" sets the bottom scale grid line 10 pixels up from the bottom of the image.
- A scale grid can also be specified using a \l {Imagexmlpropertysrc}{.sci file}.
+ A scale grid can also be specified using a
+ \l {Image::src}{.sci file}.
*/
QFxScaleGrid *QFxImage::scaleGrid()
{
@@ -250,7 +251,7 @@ bool QFxImage::isOpaque() const
void QFxImage::setOpaque(bool o)
{
Q_D(QFxImage);
- if(o == d->_opaque)
+ if (o == d->_opaque)
return;
d->_opaque = o;
d->_pix.setOpaque(o);
@@ -299,7 +300,7 @@ bool QFxImage::smoothTransform() const
void QFxImage::setSmoothTransform(bool s)
{
Q_D(QFxImage);
- if(d->_smooth == s)
+ if (d->_smooth == s)
return;
d->_smooth = s;
update();
@@ -317,10 +318,10 @@ void QFxImage::dump(int depth)
void QFxImage::paintContents(QPainter &p)
{
Q_D(QFxImage);
- if(d->_pix.isNull())
+ if (d->_pix.isNull())
return;
- if(d->_smooth) {
+ if (d->_smooth) {
p.save();
p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->_smooth);
}
@@ -347,7 +348,7 @@ void QFxImage::paintContents(QPainter &p)
p.restore();
} else if (!d->_scaleGrid || d->_scaleGrid->isNull()) {
- if(width() != pix.width() || height() != pix.height()) {
+ if (width() != pix.width() || height() != pix.height()) {
QTransform scale;
scale.scale(width() / qreal(pix.width()),
height() / qreal(pix.height()));
@@ -367,45 +368,45 @@ void QFxImage::paintContents(QPainter &p)
const int ySide = sgt + sgb;
// Upper left
- if(sgt && sgl)
+ if (sgt && sgl)
p.drawImage(QRect(0, 0, sgl, sgt), pix, QRect(0, 0, sgl, sgt));
// Upper middle
- if(pix.width() - xSide && sgt)
+ if (pix.width() - xSide && sgt)
p.drawImage(QRect(sgl, 0, width() - xSide, sgt), pix,
QRect(sgl, 0, pix.width() - xSide, sgt));
// Upper right
- if(sgt && pix.width() - sgr)
+ if (sgt && pix.width() - sgr)
p.drawImage(QPoint(width()-sgr, 0), pix,
QRect(pix.width()-sgr, 0, sgr, sgt));
// Middle left
- if(sgl && pix.height() - ySide)
+ if (sgl && pix.height() - ySide)
p.drawImage(QRect(0, sgt, sgl, height() - ySide), pix,
QRect(0, sgt, sgl, pix.height() - ySide));
// Middle
- if(pix.width() - xSide && pix.height() - ySide)
+ if (pix.width() - xSide && pix.height() - ySide)
p.drawImage(QRect(sgl, sgt, width() - xSide, height() - ySide),
pix,
QRect(sgl, sgt, pix.width() - xSide, pix.height() - ySide));
// Middle right
- if(sgr && pix.height() - ySide)
+ if (sgr && pix.height() - ySide)
p.drawImage(QRect(width()-sgr, sgt, sgr, height() - ySide), pix,
QRect(pix.width()-sgr, sgt, sgr, pix.height() - ySide));
// Lower left
- if(sgl && sgr)
+ if (sgl && sgr)
p.drawImage(QPoint(0, height() - sgb), pix,
QRect(0, pix.height() - sgb, sgl, sgb));
// Lower Middle
- if(pix.width() - xSide && sgb)
+ if (pix.width() - xSide && sgb)
p.drawImage(QRect(sgl, height() - sgb, width() - xSide, sgb), pix,
QRect(sgl, pix.height() - sgb, pix.width() - xSide, sgb));
// Lower Right
- if(sgr && sgb)
+ if (sgr && sgb)
p.drawImage(QPoint(width()-sgr, height() - sgb), pix,
QRect(pix.width()-sgr, pix.height() - sgb, sgr, sgb));
}
- if(d->_smooth) {
+ if (d->_smooth) {
p.restore();
}
}
@@ -415,10 +416,10 @@ uint QFxImage::glSimpleItemData(float *vertices, float *texVertices,
{
Q_D(QFxImage);
- if(d->_pix.isNull() || (d->_scaleGrid && !d->_scaleGrid->isNull()))
+ if (d->_pix.isNull() || (d->_scaleGrid && !d->_scaleGrid->isNull()))
return 0;
- if(count < 8)
+ if (count < 8)
return 8;
d->checkDirty();
@@ -433,7 +434,7 @@ uint QFxImage::glSimpleItemData(float *vertices, float *texVertices,
*texture = &d->_tex;
- if(d->_tiled) {
+ if (d->_tiled) {
float tileWidth = widthV / d->_pix.width();
float tileHeight = heightV / d->_pix.height();
texVertices[0] = 0; texVertices[1] = 0;
@@ -452,7 +453,7 @@ uint QFxImage::glSimpleItemData(float *vertices, float *texVertices,
void QFxImagePrivate::checkDirty()
{
- if(_texDirty && !_pix.isNull()) {
+ if (_texDirty && !_pix.isNull()) {
_tex.setImage(_pix);
_tex.setHorizontalWrap(GLTexture::Repeat);
_tex.setVerticalWrap(GLTexture::Repeat);
@@ -464,18 +465,18 @@ void QFxImagePrivate::checkDirty()
void QFxImage::paintGLContents(GLPainter &p)
{
Q_D(QFxImage);
- if(d->_pix.isNull())
+ if (d->_pix.isNull())
return;
QGLShaderProgram *shader = p.useTextureShader();
bool restoreBlend = false;
- if(isOpaque() && p.activeOpacity == 1) {
+ if (isOpaque() && p.activeOpacity == 1) {
glDisable(GL_BLEND);
restoreBlend = true;
}
- if(d->_tiled || (!d->_scaleGrid || d->_scaleGrid->isNull())) {
+ if (d->_tiled || (!d->_scaleGrid || d->_scaleGrid->isNull())) {
GLfloat vertices[8];
GLfloat texVertices[8];
@@ -497,7 +498,7 @@ void QFxImage::paintGLContents(GLPainter &p)
float imgWidth = d->_pix.width();
float imgHeight = d->_pix.height();
- if(!imgWidth || !imgHeight) {
+ if (!imgWidth || !imgHeight) {
if (restoreBlend)
glEnable(GL_BLEND);
return;
@@ -520,19 +521,19 @@ void QFxImage::paintGLContents(GLPainter &p)
const int sgt = d->_scaleGrid->top();
const int sgb = d->_scaleGrid->bottom();
- if(sgl) {
+ if (sgl) {
texleft = float(sgl) / imgWidth;
imgleft = sgl;
}
- if(sgr) {
+ if (sgr) {
texright = 1. - float(sgr) / imgWidth;
imgright = widthV - sgr;
}
- if(sgt) {
+ if (sgt) {
textop = 1. - float(sgb) / imgHeight;
imgtop = sgt;
}
- if(sgb) {
+ if (sgb) {
texbottom = float(sgt) / imgHeight;
imgbottom = heightV - sgb;
}
@@ -609,20 +610,20 @@ void QFxImage::paintGLContents(GLPainter &p)
void QFxImage::paintGLContents(GLPainter &p)
{
Q_D(QFxImage);
- if(d->_pix.isNull())
+ if (d->_pix.isNull())
return;
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(p.activeTransform.data());
bool restoreBlend = false;
- if(isOpaque() && p.activeOpacity == 1) {
+ if (isOpaque() && p.activeOpacity == 1) {
glDisable(GL_BLEND);
restoreBlend = true;
}
glEnable(GL_TEXTURE_2D);
- if(p.activeOpacity == 1.) {
+ if (p.activeOpacity == 1.) {
GLint i = GL_REPLACE;
glTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &i);
} else {
@@ -631,7 +632,7 @@ void QFxImage::paintGLContents(GLPainter &p)
glColor4f(1, 1, 1, p.activeOpacity);
}
- if(d->_tiled || !d->_scaleGrid || d->_scaleGrid->isNull()) {
+ if (d->_tiled || !d->_scaleGrid || d->_scaleGrid->isNull()) {
GLfloat vertices[8];
GLfloat texVertices[8];
@@ -659,7 +660,7 @@ void QFxImage::paintGLContents(GLPainter &p)
float imgWidth = d->_pix.width();
float imgHeight = d->_pix.height();
- if(!imgWidth || !imgHeight) {
+ if (!imgWidth || !imgHeight) {
if (restoreBlend)
glEnable(GL_BLEND);
return;
@@ -682,19 +683,19 @@ void QFxImage::paintGLContents(GLPainter &p)
const int sgt = d->_scaleGrid->top();
const int sgb = d->_scaleGrid->bottom();
- if(sgl) {
+ if (sgl) {
texleft = float(sgl) / imgWidth;
imgleft = sgl;
}
- if(sgr) {
+ if (sgr) {
texright = 1. - float(sgr) / imgWidth;
imgright = widthV - sgr;
}
- if(sgt) {
+ if (sgt) {
textop = 1. - float(sgb) / imgHeight;
imgtop = sgt;
}
- if(sgb) {
+ if (sgb) {
texbottom = float(sgt) / imgHeight;
imgbottom = heightV - sgb;
}
@@ -792,11 +793,9 @@ QFxImage::Status QFxImage::status() const
Image can handle any image format supported by Qt, loaded from any URL scheme supported by Qt.
- \target Imagexmlpropertysrc
-
It can also handle .sci files, which are a Qml-specific format. A .sci file uses a simple text-based format that specifies
\list
- \i the grid lines describing a \l {ImagexmlpropertiesscaleGrid}{scale grid}.
+ \i the grid lines describing a \l {Image::scaleGrid.left}{scale grid}.
\i an image file.
\endlist
@@ -828,10 +827,10 @@ QString QFxImage::source() const
void QFxImage::setSource(const QString &url)
{
Q_D(QFxImage);
- if(url == d->source)
+ if (url == d->source)
return;
- if(d->reply) {
+ if (d->reply) {
d->reply->deleteLater();
d->reply = 0;
}
@@ -845,7 +844,7 @@ void QFxImage::setSource(const QString &url)
d->url = qmlContext(this)->resolvedUrl(url);
d->sciurl = QUrl();
- if(url.isEmpty()) {
+ if (url.isEmpty()) {
setPixmap(QPixmap());
d->status = Idle;
} else {
@@ -899,7 +898,7 @@ void QFxImage::requestFinished()
void QFxImage::sciRequestFinished()
{
Q_D(QFxImage);
- if(d->reply->error() != QNetworkReply::NoError) {
+ if (d->reply->error() != QNetworkReply::NoError) {
d->status = Error;
d->reply->deleteLater();
d->reply = 0;
@@ -916,7 +915,7 @@ void QFxImage::sciRequestFinished()
void QFxImage::setGridScaledImage(const QFxGridScaledImage& sci)
{
Q_D(QFxImage);
- if(!sci.isValid()) {
+ if (!sci.isValid()) {
d->status = Error;
emit statusChanged(d->status);
} else {
diff --git a/src/declarative/fx/qfximage_p.h b/src/declarative/fx/qfximage_p.h
index 46aea49..fbb4c44 100644
--- a/src/declarative/fx/qfximage_p.h
+++ b/src/declarative/fx/qfximage_p.h
@@ -89,7 +89,7 @@ public:
QFxScaleGrid *scaleGrid()
{
- if(!_scaleGrid)
+ if (!_scaleGrid)
_scaleGrid = new QFxScaleGrid;
return _scaleGrid;
}
diff --git a/src/declarative/fx/qfximageitem.cpp b/src/declarative/fx/qfximageitem.cpp
index a6f6d8f..52ab009 100644
--- a/src/declarative/fx/qfximageitem.cpp
+++ b/src/declarative/fx/qfximageitem.cpp
@@ -119,8 +119,7 @@ void QFxImageItem::dirtyCache(const QRect& rect)
void QFxImageItem::clearCache()
{
Q_D(QFxImageItem);
- foreach (QFxImageItemPrivate::ImageCacheItem* i, d->imagecache)
- delete i;
+ qDeleteAll(d->imagecache);
d->imagecache.clear();
}
@@ -155,7 +154,7 @@ QSize QFxImageItem::contentsSize() const
void QFxImageItem::setSmooth(bool smooth)
{
Q_D(QFxImageItem);
- if(d->smooth == smooth) return;
+ if (d->smooth == smooth) return;
d->smooth = smooth;
clearCache();
update();
@@ -169,7 +168,7 @@ void QFxImageItem::setSmooth(bool smooth)
void QFxImageItem::setContentsSize(const QSize &size)
{
Q_D(QFxImageItem);
- if(d->contentsSize == size) return;
+ if (d->contentsSize == size) return;
d->contentsSize = size;
clearCache();
update();
@@ -232,8 +231,9 @@ void QFxImageItem::paintGLContents(GLPainter &p)
return;
#if defined(QFX_RENDER_QPAINTER)
- if(d->smooth) {
- p.save();
+ bool oldAntiAliasing = p.testRenderHint(QPainter::Antialiasing);
+ bool oldSmoothPixmap = p.testRenderHint(QPainter::SmoothPixmapTransform);
+ if (d->smooth) {
p.setRenderHints(QPainter::Antialiasing, true);
p.setRenderHints(QPainter::SmoothPixmapTransform, true);
}
@@ -303,7 +303,8 @@ void QFxImageItem::paintGLContents(GLPainter &p)
}
const QRegion bigger = QRegion(biggerrect) & uncached;
const QVector<QRect> rects = bigger.rects();
- foreach (QRect r, rects) {
+ for (int i = 0; i < rects.count(); ++i) {
+ const QRect &r = rects.at(i);
#if defined(QFX_RENDER_QPAINTER)
QImage img(r.size(),QImage::Format_ARGB32_Premultiplied);
#else
@@ -335,8 +336,10 @@ void QFxImageItem::paintGLContents(GLPainter &p)
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
#endif
#if defined(QFX_RENDER_QPAINTER)
- if(d->smooth)
- p.restore();
+ if (d->smooth) {
+ p.setRenderHints(QPainter::Antialiasing, oldAntiAliasing);
+ p.setRenderHints(QPainter::SmoothPixmapTransform, oldSmoothPixmap);
+ }
#endif
}
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index 644e812..11b7dd3 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -151,12 +151,15 @@ void QFxContents::calcHeight()
int top = INT_MAX;
int bottom = 0;
- foreach(const QSimpleCanvasItem *child,
- _item->QSimpleCanvasItem::children()) {
- if (child->y() + child->height() > bottom)
- bottom = (int)child->y() + child->height();
- if (child->y() < top)
- top = (int)child->y();
+
+ const QList<QSimpleCanvasItem *> &children = _item->QSimpleCanvasItem::children();
+ for (int i = 0; i < children.count(); ++i) {
+ const QSimpleCanvasItem *child = children.at(i);
+ int y = int(child->y());
+ if (y + child->height() > bottom)
+ bottom = y + child->height();
+ if (y < top)
+ top = y;
}
_height = bottom - top;
@@ -171,12 +174,14 @@ void QFxContents::calcWidth()
int left = INT_MAX;
int right = 0;
- foreach(const QSimpleCanvasItem *child,
- _item->QSimpleCanvasItem::children()) {
- if (child->x() + child->width() > right)
- right = (int)child->x() + child->width();
- if (child->x() < left)
- left = (int)child->x();
+ const QList<QSimpleCanvasItem *> &children = _item->QSimpleCanvasItem::children();
+ for (int i = 0; i < children.count(); ++i) {
+ const QSimpleCanvasItem *child = children.at(i);
+ int x = int(child->x());
+ if (x + child->width() > right)
+ right = x + child->width();
+ if (x < left)
+ left = x;
}
_width = right - left;
@@ -188,8 +193,9 @@ void QFxContents::setItem(QFxItem *item)
{
_item = item;
- foreach(const QSimpleCanvasItem *child,
- _item->QSimpleCanvasItem::children()) {
+ const QList<QSimpleCanvasItem *> &children = _item->QSimpleCanvasItem::children();
+ for (int i = 0; i < children.count(); ++i) {
+ const QSimpleCanvasItem *child = children.at(i);
connect(child, SIGNAL(bottomChanged()), this, SLOT(calcHeight()));
connect(child, SIGNAL(rightChanged()), this, SLOT(calcWidth()));
}
@@ -322,33 +328,27 @@ void QFxContents::setItem(QFxItem *item)
*/
/*!
- \fn void QFxItem::keyPress(QObject *event)
+ \qmlsignal Item::onKeyPress(event)
- This signal is emitted when a key is pressed.
+ This handler is called when a key is pressed.
- The key event is available in QML via the QFxKeyEvent \a event
- property.
+ The key event is available via the KeyEvent \a event.
\qml
<Item onKeyPress="if (event.key == Qt.Key_Enter) state='Enter'"/>
\endqml
-
- \sa keyRelease()
*/
/*!
- \fn void QFxItem::keyRelease(QObject *event)
+ \qmlsignal Item::onKeyRelease(event)
- This signal is emitted when a key is released.
+ This handler is called when a key is released.
- The key event is available in QML via the QFxKeyEvent \a event
- property.
+ The key event is available in via the KeyEvent \a event.
\qml
<Item onKeyRelease="if (event.key == Qt.Key_Enter) state='Enter'"/>
\endqml
-
- \sa keyPress()
*/
/*!
@@ -380,7 +380,7 @@ void QFxContents::setItem(QFxItem *item)
This signal is emitted when the item's focus state changes.
- \sa setFocus()
+ \sa QSimpleCanvasItem::setFocus()
*/
/*!
@@ -457,7 +457,7 @@ void QFxItem::setItemParent(QFxItem *parent)
*/
void QFxItem::moveToParent(QFxItem *parent)
{
- if(parent && itemParent()) {
+ if (parent && itemParent()) {
QPointF me = itemParent()->mapToScene(QPointF(0,0));
QPointF them = parent->mapToScene(QPointF(0,0));
@@ -482,25 +482,25 @@ void QFxItem::moveToParent(QFxItem *parent)
qreal yDiff = them.y() - me.y();
- if(themx.x() == 0.) {
+ if (themx.x() == 0.) {
ry = xDiff / themy.x();
rx = (yDiff - ry * themy.y()) / themx.y();
- } else if(themy.x() == 0.) {
+ } else if (themy.x() == 0.) {
rx = xDiff / themx.x();
ry = (yDiff - rx * themx.y()) / themy.y();
- } else if(themx.y() == 0.) {
+ } else if (themx.y() == 0.) {
ry = yDiff / themy.y();
rx = (xDiff - ry * themy.x()) / themx.x();
- } else if(themy.y() == 0.) {
+ } else if (themy.y() == 0.) {
rx = yDiff / themx.y();
ry = (xDiff - rx * themx.x()) / themy.x();
} else {
qreal div = (themy.x() * themx.y() - themy.y() * themx.x());
- if(div != 0.)
+ if (div != 0.)
rx = (themx.y() * xDiff - themx.x() * yDiff) / div;
- if(themy.y() != 0.) ry = (yDiff - rx * themx.y()) / themy.y();
+ if (themy.y() != 0.) ry = (yDiff - rx * themx.y()) / themy.y();
}
setX(x() - rx);
@@ -576,7 +576,7 @@ bool QFxItem::isClassComplete() const
It is often desireable to delay some processing until the component is
completed.
- \sa componentComplete().
+ \sa componentComplete()
*/
bool QFxItem::isComponentComplete() const
{
@@ -609,7 +609,7 @@ void QFxItemPrivate::data_append(QObject *o)
{
Q_Q(QFxItem);
QFxItem *i = qobject_cast<QFxItem *>(o);
- if(i)
+ if (i)
q->children()->append(i);
else
resources_append(o);
@@ -806,9 +806,9 @@ void QFxItem::setQml(const QString &qml)
if (d->_qml == qml)
return;
- if(!d->_qml.isEmpty()) {
+ if (!d->_qml.isEmpty()) {
QmlChildren::Iterator iter = d->_qmlChildren.find(d->_qml);
- if(iter != d->_qmlChildren.end())
+ if (iter != d->_qmlChildren.end())
(*iter)->setOpacity(0.);
}
@@ -816,20 +816,20 @@ void QFxItem::setQml(const QString &qml)
d->_qmlurl = qmlContext(this)->resolvedUri(qml);
d->qmlItem = 0;
- if(d->_qml.isEmpty()) {
+ if (d->_qml.isEmpty()) {
emit qmlChanged();
return;
}
QmlChildren::Iterator iter = d->_qmlChildren.find(d->_qml);
- if(iter != d->_qmlChildren.end()) {
+ if (iter != d->_qmlChildren.end()) {
(*iter)->setOpacity(1.);
d->qmlItem = (*iter);
emit qmlChanged();
} else {
d->_qmlcomp =
new QmlComponent(qmlEngine(this), d->_qmlurl, this);
- if(!d->_qmlcomp->isLoading())
+ if (!d->_qmlcomp->isLoading())
qmlLoaded();
else
QObject::connect(d->_qmlcomp, SIGNAL(statusChanged(QmlComponent::Status)),
@@ -846,7 +846,7 @@ void QFxItem::qmlLoaded()
// ###
for (int i=0; i<d->_qmlnewloading.length(); ++i) {
QmlComponent *c = d->_qmlnewcomp.at(i);
- if(c->isLoading())
+ if (c->isLoading())
continue;
QmlContext *ctxt = new QmlContext(qmlContext(this));
@@ -872,7 +872,7 @@ void QFxItem::qmlLoaded()
QObject *obj = d->_qmlcomp->create(ctxt);
QFxItem *qmlChild = qobject_cast<QFxItem *>(obj);
- if(qmlChild) {
+ if (qmlChild) {
qmlChild->setItemParent(this);
d->_qmlChildren.insert(d->_qml, qmlChild);
d->qmlItem = qmlChild;
@@ -990,23 +990,23 @@ void QFxItem::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
{
Q_D(QFxItem);
- if(newGeometry.width() != oldGeometry.width()) {
+ if (newGeometry.width() != oldGeometry.width()) {
int xoffset = oldGeometry.width() - newGeometry.width();
d->handleWidthChange(xoffset);
}
- if(newGeometry.height() != oldGeometry.height()) {
+ if (newGeometry.height() != oldGeometry.height()) {
int yoffset = oldGeometry.height() - newGeometry.height();
d->handleHeightChange(yoffset);
}
- if(newGeometry.x() != oldGeometry.x()) {
+ if (newGeometry.x() != oldGeometry.x()) {
emit leftChanged();
emit hcenterChanged();
emit rightChanged();
}
- if(newGeometry.y() != oldGeometry.y()) {
+ if (newGeometry.y() != oldGeometry.y()) {
emit topChanged();
emit vcenterChanged();
emit bottomChanged();
@@ -1016,7 +1016,7 @@ void QFxItem::geometryChanged(const QRectF &newGeometry,
void QFxItemPrivate::handleWidthChange(int xoffset)
{
Q_Q(QFxItem);
- if(!_anchors) {
+ if (!_anchors) {
emit q->hcenterChanged();
emit q->rightChanged();
} else {
@@ -1032,9 +1032,9 @@ void QFxItemPrivate::handleWidthChange(int xoffset)
emit q->rightChanged();
}
}
- if(q->rotation() && q->transformOrigin() != QFxItem::TopLeft)
+ if (q->rotation() && q->transformOrigin() != QFxItem::TopLeft)
q->setRotation(q->rotation());
- if(q->scale() && q->transformOrigin() != QFxItem::TopLeft)
+ if (q->scale() && q->transformOrigin() != QFxItem::TopLeft)
q->setScale(q->scale());
emit q->widthChanged();
}
@@ -1042,7 +1042,7 @@ void QFxItemPrivate::handleWidthChange(int xoffset)
void QFxItemPrivate::handleHeightChange(int yoffset)
{
Q_Q(QFxItem);
- if(!_anchors) {
+ if (!_anchors) {
emit q->vcenterChanged();
emit q->bottomChanged();
emit q->baselineChanged();
@@ -1064,9 +1064,9 @@ void QFxItemPrivate::handleHeightChange(int yoffset)
emit q->baselineChanged();
}
}
- if(q->rotation() && q->transformOrigin() != QFxItem::TopLeft)
+ if (q->rotation() && q->transformOrigin() != QFxItem::TopLeft)
q->setRotation(q->rotation());
- if(q->scale() && q->transformOrigin() != QFxItem::TopLeft)
+ if (q->scale() && q->transformOrigin() != QFxItem::TopLeft)
q->setScale(q->scale());
emit q->heightChanged();
}
@@ -1092,7 +1092,7 @@ bool QFxItem::flipVertically() const
void QFxItem::setFlipVertically(bool v)
{
- if(v)
+ if (v)
setFlip((QSimpleCanvasItem::Flip)(flip() | VerticalFlip));
else
setFlip((QSimpleCanvasItem::Flip)(flip() & ~VerticalFlip));
@@ -1111,7 +1111,7 @@ bool QFxItem::flipHorizontally() const
void QFxItem::setFlipHorizontally(bool v)
{
- if(v)
+ if (v)
setFlip((QSimpleCanvasItem::Flip)(flip() | HorizontalFlip));
else
setFlip((QSimpleCanvasItem::Flip)(flip() & ~HorizontalFlip));
@@ -1561,11 +1561,11 @@ qreal QFxItem::opacity() const
void QFxItem::setOpacity(qreal v)
{
- if(v == QSimpleCanvasItem::visible())
+ if (v == QSimpleCanvasItem::visible())
return;
- if(v < 0) v = 0;
- else if(v > 1) v = 1;
+ if (v < 0) v = 0;
+ else if (v > 1) v = 1;
QSimpleCanvasItem::setVisible(v);
emit opacityChanged();
@@ -1715,7 +1715,7 @@ QmlList<QmlTransition *>* QFxItem::transitions()
QmlState *QFxItem::findState(const QString &name) const
{
Q_D(const QFxItem);
- if(!d->_stateGroup)
+ if (!d->_stateGroup)
return 0;
else
return d->_stateGroup->findState(name);
@@ -1775,7 +1775,7 @@ QmlState *QFxItem::findState(const QString &name) const
QString QFxItem::state() const
{
Q_D(const QFxItem);
- if(!d->_stateGroup)
+ if (!d->_stateGroup)
return QString();
else
return d->_stateGroup->state();
@@ -1840,11 +1840,11 @@ bool QFxItem::isVisible() const
void QFxItem::setVisible(bool visible)
{
Q_D(QFxItem);
- if(visible == d->visible)
+ if (visible == d->visible)
return;
d->visible = visible;
- if(visible)
+ if (visible)
setOpacity(d->visibleOp);
else {
d->visibleOp = opacity();
@@ -1887,7 +1887,7 @@ void QFxItem::newChild(const QString &type)
d->_qmlnewloading.append(url);
d->_qmlnewcomp.append(new QmlComponent(qmlEngine(this), url, this));
- if(!d->_qmlnewcomp.last()->isLoading())
+ if (!d->_qmlnewcomp.last()->isLoading())
qmlLoaded();
else
connect(d->_qmlnewcomp.last(), SIGNAL(statusChanged(QmlComponent::Status)),
@@ -1905,7 +1905,7 @@ void QFxItem::classBegin()
Q_D(QFxItem);
d->_classComplete = false;
d->_componentComplete = false;
- if(d->_stateGroup)
+ if (d->_stateGroup)
d->_stateGroup->classBegin();
}
@@ -1921,7 +1921,7 @@ void QFxItem::classComplete()
#endif
Q_D(QFxItem);
d->_classComplete = true;
- if(d->_stateGroup)
+ if (d->_stateGroup)
d->_stateGroup->classComplete();
}
@@ -1935,13 +1935,13 @@ void QFxItem::componentComplete()
{
Q_D(QFxItem);
d->_componentComplete = true;
- if(d->_stateGroup)
+ if (d->_stateGroup)
d->_stateGroup->componentComplete();
- if(d->_anchors) {
+ if (d->_anchors) {
d->anchors()->connectHAnchors();
d->anchors()->connectVAnchors();
}
- if(!d->_transform.isEmpty())
+ if (!d->_transform.isEmpty())
updateTransform();
}
@@ -1966,9 +1966,9 @@ void QFxItem::updateTransform()
{
Q_D(QFxItem);
QSimpleCanvas::Matrix trans;
- for(int ii = d->_transform.count() - 1; ii >= 0; --ii) {
+ for (int ii = d->_transform.count() - 1; ii >= 0; --ii) {
QFxTransform *a = d->_transform.at(ii);
- if(!a->isIdentity())
+ if (!a->isIdentity())
trans = a->transform() * trans;
}
@@ -1986,9 +1986,9 @@ void QFxItem::transformChanged(const QSimpleCanvas::Matrix &)
QmlStateGroup *QFxItemPrivate::states()
{
Q_Q(QFxItem);
- if(!_stateGroup) {
+ if (!_stateGroup) {
_stateGroup = new QmlStateGroup(q);
- if(!_classComplete)
+ if (!_classComplete)
_stateGroup->classBegin();
QObject::connect(_stateGroup, SIGNAL(stateChanged(QString)),
q, SIGNAL(stateChanged(QString)));
diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h
index 71fc912..f2da3ba 100644
--- a/src/declarative/fx/qfxitem_p.h
+++ b/src/declarative/fx/qfxitem_p.h
@@ -85,7 +85,7 @@ public:
{
Q_Q(QFxItem);
- if(parent)
+ if (parent)
q->setItemParent(parent);
_baselineOffset.invalidate();
q->setAcceptedMouseButtons(Qt::NoButton);
@@ -122,7 +122,7 @@ public:
QList<QFxTransform *> _transform;
QFxAnchors *anchors() {
- if(!_anchors) {
+ if (!_anchors) {
Q_Q(QFxItem);
_anchors = new QFxAnchors;
_anchors->setItem(q);
@@ -160,7 +160,7 @@ public:
mutable AnchorLines *_anchorLines;
AnchorLines *anchorLines() const {
Q_Q(const QFxItem);
- if(!_anchorLines) _anchorLines =
+ if (!_anchorLines) _anchorLines =
new AnchorLines(const_cast<QFxItem *>(q));
return _anchorLines;
}
diff --git a/src/declarative/fx/qfxkeyactions.cpp b/src/declarative/fx/qfxkeyactions.cpp
index d16c305..69d4679 100644
--- a/src/declarative/fx/qfxkeyactions.cpp
+++ b/src/declarative/fx/qfxkeyactions.cpp
@@ -78,15 +78,15 @@ QFxKeyActionsPrivate::QFxKeyActionsPrivate()
int QFxKeyActionsPrivate::keyToBit(Qt::Key k) const
{
- if(k >= Qt::Key_A && k <= Qt::Key_Z ) {
+ if (k >= Qt::Key_A && k <= Qt::Key_Z ) {
return k - Qt::Key_A;
- } else if(k >= Qt::Key_Left && k <= Qt::Key_Down) {
+ } else if (k >= Qt::Key_Left && k <= Qt::Key_Down) {
return 26 + k - Qt::Key_Left;
- } else if(k >= Qt::Key_0 && k <= Qt::Key_9) {
+ } else if (k >= Qt::Key_0 && k <= Qt::Key_9) {
return 30 + k - Qt::Key_0;
- } else if(k >= Qt::Key_Context1 && k <= Qt::Key_Flip) {
+ } else if (k >= Qt::Key_Context1 && k <= Qt::Key_Flip) {
return 40 + k - Qt::Key_Context1;
- } else if(k >= Qt::Key_Select && k <= Qt::Key_No) {
+ } else if (k >= Qt::Key_Select && k <= Qt::Key_No) {
return 47 + k - Qt::Key_Select;
} else {
const int start = 50;
@@ -117,7 +117,7 @@ bool QFxKeyActionsPrivate::key(Qt::Key k) const
{
int b = keyToBit(k);
bool rv = testBit(b);
- if(!rv && k != Qt::Key_Shift)
+ if (!rv && k != Qt::Key_Shift)
rv = testBit(keyToBit(Qt::Key_unknown));
return rv;
}
@@ -125,7 +125,7 @@ bool QFxKeyActionsPrivate::key(Qt::Key k) const
QString QFxKeyActionsPrivate::action(Qt::Key k) const
{
int b = keyToBit(k);
- if(b != -1 && testBit(b))
+ if (b != -1 && testBit(b))
return actions.value(k);
else
return actions.value(Qt::Key_unknown);
@@ -134,7 +134,7 @@ QString QFxKeyActionsPrivate::action(Qt::Key k) const
void QFxKeyActionsPrivate::setKey(Qt::Key k, bool v)
{
int b = keyToBit(k);
- if(b == -1)
+ if (b == -1)
return;
setBit(b, v);
@@ -142,10 +142,10 @@ void QFxKeyActionsPrivate::setKey(Qt::Key k, bool v)
bool QFxKeyActionsPrivate::testBit(int b) const
{
- if(b < 0)
+ if (b < 0)
return false;
- if(b < 32)
+ if (b < 32)
return keys1 & (1 << b);
else
return keys2 & (1 << (b - 32));
@@ -153,13 +153,13 @@ bool QFxKeyActionsPrivate::testBit(int b) const
void QFxKeyActionsPrivate::setBit(int b, bool v)
{
- if(v) {
- if(b < 32)
+ if (v) {
+ if (b < 32)
keys1 |= (1 << b);
else
keys2 |= (1 << (b - 32));
} else {
- if(b < 32)
+ if (b < 32)
keys1 &= ~(1 << b);
else
keys2 &= ~(1 << (b - 32));
@@ -198,7 +198,7 @@ QFxKeyActions::~QFxKeyActions()
QString QFxKeyActionsPrivate::keyExpr(Qt::Key k) const
{
- if(key(k))
+ if (key(k))
return actions.value(k);
else
return QString();
@@ -206,8 +206,8 @@ QString QFxKeyActionsPrivate::keyExpr(Qt::Key k) const
void QFxKeyActionsPrivate::setKeyExpr(Qt::Key k, const QString &expr)
{
- if(expr.isEmpty()) {
- if(key(k)) {
+ if (expr.isEmpty()) {
+ if (key(k)) {
actions.remove(k);
setKey(k, false);
}
@@ -231,7 +231,7 @@ bool QFxKeyActions::enabled() const
void QFxKeyActions::setEnabled(bool e)
{
- if(d->enabled == e)
+ if (d->enabled == e)
return;
d->enabled = e;
@@ -239,12 +239,7 @@ void QFxKeyActions::setEnabled(bool e)
}
/*!
- \qmlproperty string KeyActions::keyA
- \qmlproperty string KeyActions::keyB
- \qmlproperty string KeyActions::keyC
- \qmlproperty ... KeyActions::...
- \qmlproperty string KeyActions::keyY
- \qmlproperty string KeyActions::keyZ
+ \qmlproperty string KeyActions::keyA...keyZ
The action to take for the given letter.
@@ -569,11 +564,7 @@ void QFxKeyActions::setKey_Down(const QString &s)
}
/*!
- \qmlproperty string KeyActions::digit0
- \qmlproperty string KeyActions::digit1
- \qmlproperty string KeyActions::digit2
- \qmlproperty ... KeyActions::...
- \qmlproperty string KeyActions::digit9
+ \qmlproperty string KeyActions::digit0...digit9
The action to take for the given number key.
@@ -907,7 +898,7 @@ void QFxKeyActions::setKey_Any(const QString &s)
void QFxKeyActions::keyPressEvent(QKeyEvent *event)
{
Qt::Key key = (Qt::Key)event->key();
- if(d->enabled && d->key(key)) {
+ if (d->enabled && d->key(key)) {
QmlExpression b(qmlContext(this), d->action(key), this, false);
b.value();
event->accept();
@@ -919,7 +910,7 @@ void QFxKeyActions::keyPressEvent(QKeyEvent *event)
void QFxKeyActions::keyReleaseEvent(QKeyEvent *event)
{
Qt::Key key = (Qt::Key)event->key();
- if(d->enabled && d->key(key)) {
+ if (d->enabled && d->key(key)) {
event->accept();
} else {
QFxItem::keyReleaseEvent(event);
diff --git a/src/declarative/fx/qfxkeyproxy.cpp b/src/declarative/fx/qfxkeyproxy.cpp
index 7d5726f..6d92441 100644
--- a/src/declarative/fx/qfxkeyproxy.cpp
+++ b/src/declarative/fx/qfxkeyproxy.cpp
@@ -93,22 +93,22 @@ QList<QFxItem *> *QFxKeyProxy::targets() const
void QFxKeyProxy::keyPressEvent(QKeyEvent *e)
{
- for(int ii = 0; ii < d->targets.count(); ++ii) {
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
QSimpleCanvasItem *i = d->targets.at(ii);
- if(i)
+ if (i)
i->keyPressEvent(e);
- if(e->isAccepted())
+ if (e->isAccepted())
return;
}
}
void QFxKeyProxy::keyReleaseEvent(QKeyEvent *e)
{
- for(int ii = 0; ii < d->targets.count(); ++ii) {
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
QSimpleCanvasItem *i = d->targets.at(ii);
- if(i)
+ if (i)
i->keyReleaseEvent(e);
- if(e->isAccepted())
+ if (e->isAccepted())
return;
}
}
diff --git a/src/declarative/fx/qfxlayouts.cpp b/src/declarative/fx/qfxlayouts.cpp
index b89e795..76afeb0 100644
--- a/src/declarative/fx/qfxlayouts.cpp
+++ b/src/declarative/fx/qfxlayouts.cpp
@@ -96,7 +96,7 @@ int QFxBaseLayout::spacing() const
void QFxBaseLayout::setSpacing(int s)
{
Q_D(QFxBaseLayout);
- if(s==d->_spacing)
+ if (s==d->_spacing)
return;
d->_spacing = s;
preLayout();
@@ -116,7 +116,7 @@ int QFxBaseLayout::margin() const
void QFxBaseLayout::setMargin(int s)
{
Q_D(QFxBaseLayout);
- if(s==d->_margin)
+ if (s==d->_margin)
return;
d->_margin = s;
preLayout();
@@ -223,7 +223,7 @@ QFxItem *QFxBaseLayout::layoutItem() const
void QFxBaseLayout::setLayoutItem(QFxItem *li)
{
Q_D(QFxBaseLayout);
- if(li == d->_layoutItem)
+ if (li == d->_layoutItem)
return;
d->_layoutItem = li;
emit layoutItemChanged();
@@ -246,7 +246,7 @@ void QFxBaseLayout::childrenChanged()
bool QFxBaseLayout::event(QEvent *e)
{
Q_D(QFxBaseLayout);
- if(e->type() == QEvent::User) {
+ if (e->type() == QEvent::User) {
d->_ep = false;
d->_stableItems += d->_newItems;
d->_leavingItems.clear();
@@ -288,22 +288,22 @@ QSet<QFxItem *>* QFxBaseLayout::leavingItems()
void QFxBaseLayout::preLayout()
{
Q_D(QFxBaseLayout);
- if(!isComponentComplete() || d->_movingItem)
+ if (!isComponentComplete() || d->_movingItem)
return;
- if(!d->_ep) {
+ if (!d->_ep) {
d->_ep = true;
QCoreApplication::postEvent(this, new QEvent(QEvent::User));
}
- if(d->stateGroup) {
+ if (d->stateGroup) {
delete d->stateGroup; d->stateGroup = 0;
}
QSet<QFxItem *> allItems;
- for(int ii = 0; ii < this->QSimpleCanvasItem::children().count(); ++ii) {
+ for (int ii = 0; ii < this->QSimpleCanvasItem::children().count(); ++ii) {
QFxItem *child = qobject_cast<QFxItem *>(this->QSimpleCanvasItem::children().at(ii));
- if(!child)
+ if (!child)
continue;
- if(!d->_items.contains(child)){
+ if (!d->_items.contains(child)){
QObject::connect(child, SIGNAL(visibleChanged()),
this, SLOT(preLayout()));
QObject::connect(child, SIGNAL(heightChanged()),
@@ -312,20 +312,20 @@ void QFxBaseLayout::preLayout()
this, SLOT(preLayout()));
d->_items += child;
}
- if(!child->isVisible()){
- if(d->_stableItems.contains(child)){
+ if (!child->isVisible()){
+ if (d->_stableItems.contains(child)){
d->_leavingItems += child;
d->_stableItems -= child;
}
- }else if(!d->_stableItems.contains(child)){
+ }else if (!d->_stableItems.contains(child)){
d->_newItems+=child;
}
allItems += child;
}
QSet<QFxItem *> deletedItems = d->_items - allItems;
foreach(QFxItem *child, d->_items){
- if(!allItems.contains(child)){
- if(!deletedItems.contains(child)) {
+ if (!allItems.contains(child)){
+ if (!deletedItems.contains(child)) {
QObject::disconnect(child, SIGNAL(visibleChanged()),
this, SLOT(preLayout()));
QObject::disconnect(child, SIGNAL(heightChanged()),
@@ -343,8 +343,8 @@ void QFxBaseLayout::preLayout()
qreal width=0;
qreal height=0;
foreach(QFxItem *item, d->_items){
- if(item->isVisible()){
- if(!d->_animated.contains(item)){
+ if (item->isVisible()){
+ if (!d->_animated.contains(item)){
setMovingItem(item);
item->setPos(QPointF(item->x()+d->_margin, item->y()+d->_margin));
setMovingItem(0);
@@ -356,11 +356,11 @@ void QFxBaseLayout::preLayout()
width += d->_margin;
height+= d->_margin;
- if(d->aut & Horizontal)
+ if (d->aut & Horizontal)
setWidth(int(width));
else
setImplicitWidth(itemParent()->width());
- if(d->aut & Vertical)
+ if (d->aut & Vertical)
setHeight(int(height));
else
setImplicitHeight(itemParent()->height());
@@ -372,20 +372,20 @@ void QFxBaseLayout::applyTransition(const QList<QPair<QString, QVariant> >& chan
QFxItem* target, QmlTransition* trans)
{
Q_D(QFxBaseLayout);
- if(!trans||!target)//TODO: if !trans, just apply changes
+ if (!trans||!target)//TODO: if !trans, just apply changes
return;
setLayoutItem(target);
- if(d->stateGroup)
+ if (d->stateGroup)
delete d->stateGroup;
d->stateGroup = new QmlStateGroup(this);
QmlState *state = new QmlState;
*(d->stateGroup->statesProperty()) << state;
- for(int ii=0; ii<changes.size(); ++ii){
+ for (int ii=0; ii<changes.size(); ++ii){
QmlSetProperty *sp = new QmlSetProperty(state);
sp->setObject(target);
QVariant val = changes[ii].second;
- if(d->_margin &&
+ if (d->_margin &&
(changes[ii].first == QLatin1String("x") || changes[ii].first == QLatin1String("y"))){
val = QVariant(val.toInt() + d->_margin);
}
@@ -589,14 +589,14 @@ void QFxVerticalLayout::doLayout()
int voffset = 0;
foreach(QFxItem* item, *leavingItems()){
- if(remove()){
+ if (remove()){
QList<QPair<QString,QVariant> > changes;
applyRemove(changes, item);
}
}
- for(int ii = 0; ii < this->QSimpleCanvasItem::children().count(); ++ii) {
+ for (int ii = 0; ii < this->QSimpleCanvasItem::children().count(); ++ii) {
QFxItem *child = qobject_cast<QFxItem *>(this->QSimpleCanvasItem::children().at(ii));
- if(!child || !child->isVisible())
+ if (!child || !child->isVisible())
continue;
bool needMove = (child->y() != voffset || child->x());
@@ -604,11 +604,11 @@ void QFxVerticalLayout::doLayout()
QList<QPair<QString, QVariant> > changes;
changes << qMakePair(QString(QLatin1String("y")),QVariant(voffset));
changes << qMakePair(QString(QLatin1String("x")),QVariant(0));
- if(needMove && items()->contains(child) && move()) {
+ if (needMove && items()->contains(child) && move()) {
applyMove(changes,child);
- } else if(!items()->contains(child) && add()) {
+ } else if (!items()->contains(child) && add()) {
applyAdd(changes,child);
- } else if(needMove) {
+ } else if (needMove) {
setMovingItem(child);
child->setY(voffset);
setMovingItem(0);
@@ -742,14 +742,14 @@ void QFxHorizontalLayout::doLayout()
int hoffset = 0;
foreach(QFxItem* item, *leavingItems()){
- if(remove()){
+ if (remove()){
QList<QPair<QString,QVariant> > changes;
applyRemove(changes, item);
}
}
- for(int ii = 0; ii < this->QSimpleCanvasItem::children().count(); ++ii) {
+ for (int ii = 0; ii < this->QSimpleCanvasItem::children().count(); ++ii) {
QFxItem *child = qobject_cast<QFxItem *>(this->QSimpleCanvasItem::children().at(ii));
- if(!child || !child->isVisible())
+ if (!child || !child->isVisible())
continue;
bool needMove = (child->x() != hoffset || child->y());
@@ -757,11 +757,11 @@ void QFxHorizontalLayout::doLayout()
QList<QPair<QString, QVariant> > changes;
changes << qMakePair(QString(QLatin1String("x")),QVariant(hoffset));
changes << qMakePair(QString(QLatin1String("y")),QVariant(0));
- if(needMove && items()->contains(child) && move()) {
+ if (needMove && items()->contains(child) && move()) {
applyMove(changes,child);
- } else if(!items()->contains(child) && add()) {
+ } else if (!items()->contains(child) && add()) {
applyAdd(changes,child);
- } else if(needMove) {
+ } else if (needMove) {
setMovingItem(child);
child->setX(hoffset);
setMovingItem(0);
@@ -950,32 +950,32 @@ void QFxGridLayout::doLayout()
{
int c=_columns,r=_rows;//Actual number of rows/columns
int numVisible = items()->size() + newItems()->size();
- if(_columns==-1 && _rows==-1){
+ if (_columns==-1 && _rows==-1){
c = 4;
r = (numVisible+2)/3;
- }else if(_rows==-1){
+ }else if (_rows==-1){
r = (numVisible+(_columns-1))/_columns;
- }else if(_columns==-1){
+ }else if (_columns==-1){
c = (numVisible+(_rows-1))/_rows;
}
QList<int> maxColWidth;
QList<int> maxRowHeight;
int childIndex =0;
- for(int i=0; i<r; i++){
- for(int j=0; j<c; j++){
- if(j==0)
+ for (int i=0; i<r; i++){
+ for (int j=0; j<c; j++){
+ if (j==0)
maxRowHeight << 0;
- if(i==0)
+ if (i==0)
maxColWidth << 0;
- if(childIndex == this->QSimpleCanvasItem::children().count())
+ if (childIndex == this->QSimpleCanvasItem::children().count())
continue;
QFxItem *child = qobject_cast<QFxItem *>(this->QSimpleCanvasItem::children().at(childIndex++));
- if(!child || !child->isVisible())
+ if (!child || !child->isVisible())
continue;
- if(child->width() > maxColWidth[j])
+ if (child->width() > maxColWidth[j])
maxColWidth[j] = child->width();
- if(child->height() > maxRowHeight[i])
+ if (child->height() > maxRowHeight[i])
maxRowHeight[i] = child->height();
}
}
@@ -985,23 +985,23 @@ void QFxGridLayout::doLayout()
int curRow =0;
int curCol =0;
foreach(QFxItem* item, *leavingItems()){
- if(remove()){
+ if (remove()){
QList<QPair<QString,QVariant> > changes;
applyRemove(changes, item);
}
}
foreach(QSimpleCanvasItem* schild, this->QSimpleCanvasItem::children()){
QFxItem *child = qobject_cast<QFxItem *>(schild);
- if(!child || !child->isVisible())
+ if (!child || !child->isVisible())
continue;
bool needMove = (child->x()!=xoffset)||(child->y()!=yoffset);
QList<QPair<QString, QVariant> > changes;
changes << qMakePair(QString(QLatin1String("x")),QVariant(xoffset));
changes << qMakePair(QString(QLatin1String("y")),QVariant(yoffset));
- if(newItems()->contains(child) && add()) {
+ if (newItems()->contains(child) && add()) {
applyAdd(changes,child);
- } else if(needMove) {
- if(move()){
+ } else if (needMove) {
+ if (move()){
applyMove(changes,child);
}else{
setMovingItem(child);
@@ -1012,11 +1012,11 @@ void QFxGridLayout::doLayout()
xoffset+=maxColWidth[curCol]+spacing();
curCol++;
curCol%=c;
- if(!curCol){
+ if (!curCol){
yoffset+=maxRowHeight[curRow]+spacing();
xoffset=0;
curRow++;
- if(curRow>=r)
+ if (curRow>=r)
return;
}
}
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index c85d8ce..0724e3a 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -98,8 +98,11 @@ public:
}
static QFxListViewAttached *properties(QObject *obj) {
- QFxListViewAttached *rv = new QFxListViewAttached(obj);
- attachedProperties.insert(obj, rv);
+ QFxListViewAttached *rv = attachedProperties.value(obj);
+ if (!rv) {
+ rv = new QFxListViewAttached(obj);
+ attachedProperties.insert(obj, rv);
+ }
return rv;
}
@@ -582,7 +585,7 @@ void QFxListViewPrivate::createHighlight()
if (nobj) {
highlightContext->setParent(nobj);
item = qobject_cast<QFxItem *>(nobj);
- if(!item) {
+ if (!item) {
delete nobj;
} else {
item->setParent(q->viewport());
@@ -1191,7 +1194,7 @@ int QFxListView::cacheBuffer() const
void QFxListView::setCacheBuffer(int b)
{
Q_D(QFxListView);
- if(d->buffer != b) {
+ if (d->buffer != b) {
d->buffer = b;
if (isComponentComplete())
refill();
@@ -1230,7 +1233,7 @@ QString QFxListView::sectionExpression() const
void QFxListView::setSectionExpression(const QString &expression)
{
Q_D(QFxListView);
- if(d->sectionExpression != expression) {
+ if (d->sectionExpression != expression) {
d->sectionExpression = expression;
emit sectionExpressionChanged();
}
@@ -1543,9 +1546,8 @@ void QFxListView::itemsInserted(int modelIndex, int count)
}
}
// everything is in order now - emit add() signal
- foreach(FxListItem *item, added)
- item->attached->emitAdd();
-
+ for (int j = 0; j < added.count(); ++j)
+ added.at(j)->attached->emitAdd();
emit countChanged();
}
diff --git a/src/declarative/fx/qfxmouseregion.cpp b/src/declarative/fx/qfxmouseregion.cpp
index be56786..d197c9a 100644
--- a/src/declarative/fx/qfxmouseregion.cpp
+++ b/src/declarative/fx/qfxmouseregion.cpp
@@ -155,7 +155,7 @@ void QFxDrag::setYmax(int m)
</Rect>
\endcode
- Many MouseRegion signals pass a \l {qml-mouseevent}{mouse} parameter that contains
+ Many MouseRegion signals pass a \l {MouseEvent}{mouse} parameter that contains
additional information about the mouse event, such as the position, button,
and any key modifiers.
@@ -163,13 +163,15 @@ void QFxDrag::setYmax(int m)
example extended so as to give a different color when you right click.
\code
<Rect width="100" height="100">
- <MouseRegion anchors.fill="{parent}" onClick="if(mouse.button=='Right') { parent.color='blue';} else { parent.color = 'red';}"/>
+ <MouseRegion anchors.fill="{parent}" onClick="if (mouse.button==Qt.RightButton) { parent.color='blue';} else { parent.color = 'red';}"/>
</Rect>
\endcode
For basic key handling, see \l KeyActions.
MouseRegion is an invisible element: it is never painted.
+
+ \sa MouseEvent
*/
/*!
@@ -201,6 +203,15 @@ void QFxDrag::setYmax(int m)
*/
/*!
+ \qmlsignal MouseRegion::onPositionChanged(mouse)
+
+ This handler is called when the mouse position changes.
+
+ The \l {MouseEvent}{mouse} parameter provides information about the mouse, including the x and y
+ position, and any buttons currently pressed.
+*/
+
+/*!
\qmlsignal MouseRegion::onClicked(mouse)
This handler is called when there is a click. A click is defined as a press followed by a release,
@@ -215,8 +226,8 @@ void QFxDrag::setYmax(int m)
\qmlsignal MouseRegion::onPressed(mouse)
This handler is called when there is a press.
- The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y
- position of the release of the click, and whether the click wasHeld.
+ The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y
+ position and which button was pressed.
*/
/*!
@@ -231,8 +242,8 @@ void QFxDrag::setYmax(int m)
\qmlsignal MouseRegion::onPressAndHold(mouse)
This handler is called when there is a long press (currently 800ms).
- The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y
- position of the release of the click, and whether the click wasHeld.
+ The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y
+ position of the press, and which button is pressed.
*/
/*!
@@ -309,29 +320,11 @@ void QFxMouseRegion::setEnabled(bool a)
d->absorb = a;
}
-void QFxMouseRegionPrivate::bindButtonValue(Qt::MouseButton b)
-{
- Q_Q(QFxMouseRegion);
- QString bString;
- switch(b){
- case Qt::LeftButton:
- bString = QLatin1String("Left"); break;
- case Qt::RightButton:
- bString = QLatin1String("Right"); break;
- case Qt::MidButton:
- bString = QLatin1String("Middle"); break;
- default:
- bString = QLatin1String("None"); break;
- }
- // ### is this needed anymore?
- qmlContext(q)->setContextProperty(QLatin1String("mouseButton"), bString);
-}
-
void QFxMouseRegion::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QFxMouseRegion);
d->moved = false;
- if(!d->absorb)
+ if (!d->absorb)
QFxItem::mousePressEvent(event);
else {
if (!d->inside) {
@@ -348,9 +341,7 @@ void QFxMouseRegion::mousePressEvent(QGraphicsSceneMouseEvent *event)
// ### we should only start timer if pressAndHold is connected to (but connectNotify doesn't work)
d->pressAndHoldTimer.start(PressAndHoldDelay, this);
setKeepMouseGrab(false);
- d->bindButtonValue(event->button());
setPressed(true);
- emit positionChanged();
event->accept();
}
}
@@ -358,7 +349,7 @@ void QFxMouseRegion::mousePressEvent(QGraphicsSceneMouseEvent *event)
void QFxMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QFxMouseRegion);
- if(!d->absorb) {
+ if (!d->absorb) {
QFxItem::mouseMoveEvent(event);
return;
}
@@ -378,10 +369,10 @@ void QFxMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
emit reenteredWhilePressed();
}
- if(drag()->target()) {
- if(!d->moved) {
- if(d->dragX) d->startX = int(drag()->target()->x()); //### change startX and startY to qreal?
- if(d->dragY) d->startY = int(drag()->target()->y());
+ if (drag()->target()) {
+ if (!d->moved) {
+ if (d->dragX) d->startX = int(drag()->target()->x()); //### change startX and startY to qreal?
+ if (d->dragY) d->startY = int(drag()->target()->y());
}
QPointF startLocalPos;
@@ -406,7 +397,7 @@ void QFxMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
}
- if(d->dragX) {
+ if (d->dragX) {
qreal x = (curLocalPos.x() - startLocalPos.x()) + d->startX;
if (x < drag()->xmin())
x = drag()->xmin();
@@ -414,7 +405,7 @@ void QFxMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
x = drag()->xmax();
drag()->target()->setX(x);
}
- if(d->dragY) {
+ if (d->dragY) {
qreal y = (curLocalPos.y() - startLocalPos.y()) + d->startY;
if (y < drag()->ymin())
y = drag()->ymin();
@@ -424,7 +415,8 @@ void QFxMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
}
d->moved = true;
- emit positionChanged();
+ QFxMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress);
+ emit positionChanged(&me);
event->accept();
}
@@ -432,7 +424,7 @@ void QFxMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void QFxMouseRegion::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QFxMouseRegion);
- if(!d->absorb)
+ if (!d->absorb)
QFxItem::mouseReleaseEvent(event);
else {
d->saveEvent(event);
@@ -446,7 +438,7 @@ void QFxMouseRegion::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void QFxMouseRegion::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
Q_D(QFxMouseRegion);
- if(!d->absorb)
+ if (!d->absorb)
QFxItem::mouseDoubleClickEvent(event);
else {
//d->inside = true;
@@ -462,7 +454,7 @@ void QFxMouseRegion::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
void QFxMouseRegion::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_D(QFxMouseRegion);
- if(!d->absorb)
+ if (!d->absorb)
QFxItem::hoverEnterEvent(event);
else {
setHovered(true);
@@ -473,7 +465,7 @@ void QFxMouseRegion::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void QFxMouseRegion::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_D(QFxMouseRegion);
- if(!d->absorb)
+ if (!d->absorb)
QFxItem::hoverLeaveEvent(event);
else {
setHovered(false);
@@ -533,7 +525,7 @@ bool QFxMouseRegion::pressed()
void QFxMouseRegion::setHovered(bool h)
{
Q_D(QFxMouseRegion);
- if(d->hovered != h) {
+ if (d->hovered != h) {
d->hovered = h;
emit hoveredChanged();
}
@@ -544,12 +536,13 @@ void QFxMouseRegion::setPressed(bool p)
Q_D(QFxMouseRegion);
bool isclick = d->pressed == true && p == false && d->dragged == false && d->inside == true;
- if(d->pressed != p) {
+ if (d->pressed != p) {
d->pressed = p;
QFxMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, isclick, d->longPress);
- if(d->pressed)
+ if (d->pressed) {
+ emit positionChanged(&me);
emit pressed(&me);
- else {
+ } else {
emit released(&me);
if (isclick)
emit clicked(&me);
diff --git a/src/declarative/fx/qfxmouseregion.h b/src/declarative/fx/qfxmouseregion.h
index 2e2a1d4..2ba4a50 100644
--- a/src/declarative/fx/qfxmouseregion.h
+++ b/src/declarative/fx/qfxmouseregion.h
@@ -121,7 +121,7 @@ public:
Q_SIGNALS:
void hoveredChanged();
void pressedChanged();
- void positionChanged();
+ void positionChanged(QFxMouseEvent *mouse);
void pressed(QFxMouseEvent *mouse);
void pressAndHold(QFxMouseEvent *mouse);
diff --git a/src/declarative/fx/qfxmouseregion_p.h b/src/declarative/fx/qfxmouseregion_p.h
index e9d1986..e444bf2 100644
--- a/src/declarative/fx/qfxmouseregion_p.h
+++ b/src/declarative/fx/qfxmouseregion_p.h
@@ -66,7 +66,7 @@ class QFxMouseRegionPrivate : public QFxItemPrivate
public:
QFxMouseRegionPrivate()
- : absorb(true), hovered(false), inside(true), pressed(false), longPress(0), drag(0)
+ : absorb(true), hovered(false), inside(true), pressed(false), longPress(false), drag(0)
{
}
@@ -77,8 +77,6 @@ public:
q->setOptions(QSimpleCanvasItem::HoverEvents | QSimpleCanvasItem::MouseEvents);
}
- void bindButtonValue(Qt::MouseButton);
-
void saveEvent(QGraphicsSceneMouseEvent *event) {
lastPos = event->pos();
lastButton = event->button();
@@ -86,16 +84,16 @@ public:
lastModifiers = event->modifiers();
}
- bool absorb;
- bool hovered;
- bool inside;
- bool pressed;
- bool longPress;
+ bool absorb : 1;
+ bool hovered : 1;
+ bool inside : 1;
+ bool pressed : 1;
+ bool longPress : 1;
+ bool moved : 1;
+ bool dragX : 1;
+ bool dragY : 1;
+ bool dragged : 1;
QFxDrag drag;
- bool moved;
- bool dragX;
- bool dragY;
- bool dragged;
QPointF start;
QPointF startScene;
int startX;
diff --git a/src/declarative/fx/qfxpainted.cpp b/src/declarative/fx/qfxpainted.cpp
index ad1b3ad..7c88ce3 100644
--- a/src/declarative/fx/qfxpainted.cpp
+++ b/src/declarative/fx/qfxpainted.cpp
@@ -46,7 +46,7 @@
QT_BEGIN_NAMESPACE
/*!
\class QFxPainted
- \brief QFxPainted is an abstract base class for QFxView items that paint using QPainter.
+ \brief The QFxPainted class is an abstract base class for QFxView items that paint using QPainter.
\ingroup group_coreitems
diff --git a/src/declarative/fx/qfxparticles.cpp b/src/declarative/fx/qfxparticles.cpp
index 8b16098..309ebe8 100644
--- a/src/declarative/fx/qfxparticles.cpp
+++ b/src/declarative/fx/qfxparticles.cpp
@@ -268,14 +268,14 @@ void QFxParticleMotionGravity::advance(QFxParticle &p, int interval)
*/
/*!
- \qmlproperty QFxParticleMotionWander::xvariance
- \qmlproperty QFxParticleMotionWander::yvariance
+ \qmlproperty int QFxParticleMotionWander::xvariance
+ \qmlproperty int QFxParticleMotionWander::yvariance
These properties set the amount to wander in the x and y directions.
*/
/*!
- \qmlproperty QFxParticleMotionWander::pace
+ \qmlproperty int QFxParticleMotionWander::pace
This property holds how quickly the paricles will move from side to side.
*/
@@ -413,17 +413,17 @@ void QFxParticlesPrivate::tick(int time)
if (!addParticleTime)
addParticleTime = time;
- if(particles.count() < count && emitting) {
+ 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){
+ if (stream){
+ if (streamDelay > time){
streamWidth = 0;
}else{
int missed = time - streamDelay;
qreal streamWidthReal = qreal(count)/qreal(lifeSpan);
- if(streamWidthReal < 1){
+ if (streamWidthReal < 1){
streamDelay = time + (int)(1.0/streamWidthReal);
streamWidth = 1;
streamWidth += missed/streamDelay;
diff --git a/src/declarative/fx/qfxpath.cpp b/src/declarative/fx/qfxpath.cpp
index 2009237..f08671d 100644
--- a/src/declarative/fx/qfxpath.cpp
+++ b/src/declarative/fx/qfxpath.cpp
@@ -185,7 +185,7 @@ QList<QFxPathElement *>* QFxPath::pathElements()
void QFxPath::interpolate(int idx, const QString &name, qreal value)
{
Q_D(QFxPath);
- if(!idx)
+ if (!idx)
return;
qreal lastValue = 0;
@@ -193,7 +193,7 @@ void QFxPath::interpolate(int idx, const QString &name, qreal value)
int search = idx - 1;
while(search >= 0) {
const AttributePoint &point = d->_attributePoints.at(search);
- if(point.values.contains(name)) {
+ if (point.values.contains(name)) {
lastValue = point.values.value(name);
lastPercent = point.origpercent;
break;
@@ -205,7 +205,7 @@ void QFxPath::interpolate(int idx, const QString &name, qreal value)
const AttributePoint &curPoint = d->_attributePoints.at(idx);
- for(int ii = search; ii < idx; ++ii) {
+ for (int ii = search; ii < idx; ++ii) {
AttributePoint &point = d->_attributePoints[ii];
qreal val = lastValue + (value - lastValue) * (point.origpercent - lastPercent) / (curPoint.origpercent - lastPercent);
@@ -218,10 +218,10 @@ void QFxPath::endpoint(const QString &name)
Q_D(QFxPath);
const AttributePoint &first = d->_attributePoints.first();
qreal val = first.values.value(name);
- for(int ii = d->_attributePoints.count() - 1; ii >= 0; ii--) {
+ for (int ii = d->_attributePoints.count() - 1; ii >= 0; ii--) {
const AttributePoint &point = d->_attributePoints.at(ii);
- if(point.values.contains(name)) {
- for(int jj = ii + 1; jj < d->_attributePoints.count(); ++jj) {
+ if (point.values.contains(name)) {
+ for (int jj = ii + 1; jj < d->_attributePoints.count(); ++jj) {
AttributePoint &setPoint = d->_attributePoints[jj];
setPoint.values.insert(name, val);
}
@@ -239,23 +239,23 @@ void QFxPath::processPath()
d->_path = QPainterPath();
AttributePoint first;
- for(int ii = 0; ii < d->_attributes.count(); ++ii)
+ for (int ii = 0; ii < d->_attributes.count(); ++ii)
first.values[d->_attributes.at(ii)] = 0;
d->_attributePoints << first;
d->_path.moveTo(d->startX, d->startY);
foreach (QFxPathElement *pathElement, d->_pathElements) {
- if(QFxCurve *curve = qobject_cast<QFxCurve *>(pathElement)) {
+ if (QFxCurve *curve = qobject_cast<QFxCurve *>(pathElement)) {
curve->addToPath(d->_path);
AttributePoint p;
p.origpercent = d->_path.length();
d->_attributePoints << p;
- } else if(QFxPathAttribute *attribute = qobject_cast<QFxPathAttribute *>(pathElement)) {
+ } else if (QFxPathAttribute *attribute = qobject_cast<QFxPathAttribute *>(pathElement)) {
AttributePoint &point = d->_attributePoints.last();
point.values[attribute->name()] = attribute->value();
interpolate(d->_attributePoints.count() - 1, attribute->name(), attribute->value());
- } else if(QFxPathPercent *percent = qobject_cast<QFxPathPercent *>(pathElement)) {
+ } else if (QFxPathPercent *percent = qobject_cast<QFxPathPercent *>(pathElement)) {
AttributePoint &point = d->_attributePoints.last();
point.values[QLatin1String("_qfx_percent")] = percent->value();
interpolate(d->_attributePoints.count() - 1, QLatin1String("_qfx_percent"), percent->value());
@@ -264,8 +264,8 @@ void QFxPath::processPath()
// Fixup end points
const AttributePoint &last = d->_attributePoints.last();
- for(int ii = 0; ii < d->_attributes.count(); ++ii) {
- if(!last.values.contains(d->_attributes.at(ii)))
+ for (int ii = 0; ii < d->_attributes.count(); ++ii) {
+ if (!last.values.contains(d->_attributes.at(ii)))
endpoint(d->_attributes.at(ii));
}
@@ -273,9 +273,9 @@ void QFxPath::processPath()
qreal length = d->_path.length();
qreal prevpercent = 0;
qreal prevorigpercent = 0;
- for(int ii = 0; ii < d->_attributePoints.count(); ++ii) {
+ for (int ii = 0; ii < d->_attributePoints.count(); ++ii) {
const AttributePoint &point = d->_attributePoints.at(ii);
- if(point.values.contains(QLatin1String("_qfx_percent"))) { //special string for QFxPathPercent
+ if (point.values.contains(QLatin1String("_qfx_percent"))) { //special string for QFxPathPercent
if ( ii > 0) {
qreal scale = (d->_attributePoints[ii].origpercent/length - prevorigpercent) /
(point.values.value(QLatin1String("_qfx_percent"))-prevpercent);
@@ -300,7 +300,7 @@ void QFxPath::componentComplete()
QSet<QString> attrs;
// First gather up all the attributes
foreach (QFxPathElement *pathElement, d->_pathElements) {
- if(QFxPathAttribute *attribute =
+ if (QFxPathAttribute *attribute =
qobject_cast<QFxPathAttribute *>(pathElement))
attrs.insert(attribute->name());
}
@@ -383,10 +383,10 @@ void QFxPath::createPointCache() const
//find which set we are in
qreal prevPercent = 0;
qreal prevOrigPercent = 0;
- for(int ii = 0; ii < d->_attributePoints.count(); ++ii) {
+ for (int ii = 0; ii < d->_attributePoints.count(); ++ii) {
qreal percent = qreal(i)/points;
const AttributePoint &point = d->_attributePoints.at(ii);
- if(percent < point.percent || ii == d->_attributePoints.count() - 1) { //### || is special case for very last item
+ if (percent < point.percent || ii == d->_attributePoints.count() - 1) { //### || is special case for very last item
qreal elementPercent = (percent - prevPercent);
qreal spc = prevOrigPercent + elementPercent * point.scale;
@@ -430,15 +430,15 @@ QPointF QFxPath::pointAt(qreal p) const
qreal QFxPath::attributeAt(const QString &name, qreal percent) const
{
Q_D(const QFxPath);
- if(percent < 0 || percent > 1)
+ if (percent < 0 || percent > 1)
return 0;
- for(int ii = 0; ii < d->_attributePoints.count(); ++ii) {
+ for (int ii = 0; ii < d->_attributePoints.count(); ++ii) {
const AttributePoint &point = d->_attributePoints.at(ii);
- if(point.percent == percent) {
+ if (point.percent == percent) {
return point.values.value(name);
- } else if(point.percent > percent) {
+ } else if (point.percent > percent) {
qreal lastValue =
ii?(d->_attributePoints.at(ii - 1).values.value(name)):0;
qreal lastPercent =
diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp
index 59c7cd1..c0d3ab2 100644
--- a/src/declarative/fx/qfxpathview.cpp
+++ b/src/declarative/fx/qfxpathview.cpp
@@ -246,7 +246,7 @@ void QFxPathView::setCurrentIndex(int idx)
d->currentIndex = idx;
d->snapToCurrent();
int itemIndex = (idx - d->firstIndex + d->model->count()) % d->model->count();
- if(itemIndex < d->items.count())
+ if (itemIndex < d->items.count())
d->items.at(itemIndex)->setFocus(true);
emit currentIndexChanged();
}
@@ -392,7 +392,7 @@ int QFxPathView::pathItemCount() const
void QFxPathView::setPathItemCount(int i)
{
Q_D(QFxPathView);
- if(i == d->pathItems)
+ if (i == d->pathItems)
return;
d->pathItems = i;
d->regenerate();
@@ -553,7 +553,7 @@ bool QFxPathView::sendMouseEvent(QGraphicsSceneMouseEvent *event)
bool QFxPathView::mouseFilter(QGraphicsSceneMouseEvent *e)
{
- if(!isVisible())
+ if (!isVisible())
return false;
switch (e->type()) {
@@ -579,7 +579,7 @@ void QFxPathViewPrivate::regenerate()
if (!model || model->count() <= 0 || !model->delegate() || !path)
return;
- for(int i=0; i<items.count(); i++){
+ for (int i=0; i<items.count(); i++){
QFxItem *p = items[i];
q->attachedProperties.remove(p);
model->release(p);
@@ -592,7 +592,7 @@ void QFxPathViewPrivate::regenerate()
int numItems = (pathItems>=0 ? pathItems : model->count());
qreal minDiff = 1e9;
int minI = -1;
- for(int i=0; i<numItems; i++){
+ for (int i=0; i<numItems; i++){
QFxItem *item = model->item(i);
if (!item)
return;
@@ -603,7 +603,7 @@ void QFxPathViewPrivate::regenerate()
percent /= 100.0;
updateItem(items.last(), percent);
qreal diff = qAbs(percent - snapPos);
- if(diff < minDiff){
+ if (diff < minDiff){
minDiff = diff;
minI = i;
}
@@ -615,8 +615,8 @@ void QFxPathViewPrivate::regenerate()
void QFxPathViewPrivate::updateItem(QFxItem *item, qreal percent)
{
- if(QObject *obj = QFxPathView::attachedProperties.value(item)) {
- foreach(QString attr, path->attributes())
+ if (QObject *obj = QFxPathView::attachedProperties.value(item)) {
+ foreach(const QString &attr, path->attributes())
static_cast<QFxPathViewAttached *>(obj)->setValue(attr.toLatin1(), path->attributeAt(attr, percent));
}
@@ -632,36 +632,36 @@ void QFxPathView::refill()
return;
QList<qreal> positions;
- for(int i=0; i<d->items.count(); i++){
+ for (int i=0; i<d->items.count(); i++){
qreal percent = i * (100. / d->items.count());
percent = percent + d->_offset;
percent = fmod(percent,100.);
positions << qAbs(percent/100.0);
}
- if(d->pathItems==-1){
- for(int i=0; i<positions.count(); i++){
+ if (d->pathItems==-1){
+ for (int i=0; i<positions.count(); i++){
d->updateItem(d->items.at(i), positions[i]);
}
return;
}
QList<qreal> rotatedPositions;
- for(int i=0; i<d->items.count(); i++)
+ for (int i=0; i<d->items.count(); i++)
rotatedPositions << positions[(i + d->pathOffset + d->items.count()) % d->items.count()];
int firstFind = -1;
int i;
- for(i=0; i<d->items.count()-1; i++)
+ for (i=0; i<d->items.count()-1; i++)
{
- if(rotatedPositions[i] > rotatedPositions[i+1]){
+ if (rotatedPositions[i] > rotatedPositions[i+1]){
firstFind = i;
break;
}
}
- if(firstFind!=-1 ){
+ if (firstFind!=-1 ){
//A wraparound has occured
- if(firstFind<(d->items.count()/2)){
+ if (firstFind<(d->items.count()/2)){
while(firstFind-- >= 0){
QFxItem* p = d->items.takeFirst();
attachedProperties.remove(p);
@@ -681,21 +681,21 @@ void QFxPathView::refill()
attachedProperties.remove(p);
d->model->release(p);
d->firstIndex--;
- if(d->firstIndex<0)
+ if (d->firstIndex<0)
d->firstIndex = d->model->count() - 1;
d->items.prepend(d->model->item(d->firstIndex));
d->items.first()->setZ(d->firstIndex);
d->items.first()->setParent(this);
d->pathOffset--;
- if(d->pathOffset<0)
+ if (d->pathOffset<0)
d->pathOffset = d->items.count() - 1;
}
}
- for(int i=0; i<d->items.count(); i++)
+ for (int i=0; i<d->items.count(); i++)
rotatedPositions[i] = positions[(i + d->pathOffset + d->items.count())
% d->items.count()];
}
- for(int i=0; i<d->items.count(); i++){
+ for (int i=0; i<d->items.count(); i++){
d->updateItem(d->items.at(i), rotatedPositions[i]);
}
}
@@ -712,26 +712,26 @@ int QFxPathViewPrivate::calcCurrentIndex()
int current = -1;
if (model && items.count()) {
_offset = fmod(_offset, 100.0);
- if(_offset < 0)
+ if (_offset < 0)
_offset += 100.0;
- if(pathItems == -1){
+ if (pathItems == -1){
qreal delta = fmod(_offset - snapPos, 100.0);
if (delta < 0)
delta = 100.0 + delta;
int ii = model->count() - qRound(delta * model->count() / 100);
- if(ii < 0)
+ if (ii < 0)
ii = 0;
current = ii;
}else{
qreal bestDiff=1e9;
int bestI=-1;
- for(int i=0; i<items.count(); i++){
+ for (int i=0; i<items.count(); i++){
qreal percent = i * (100. / items.count());
percent = percent + _offset;
percent = fmod(percent,100.);
qreal diff = qAbs(snapPos - (percent/100.0));
- if(diff < bestDiff){
+ if (diff < bestDiff){
bestDiff = diff;
bestI = i;
}
@@ -755,7 +755,7 @@ void QFxPathViewPrivate::updateCurrent()
if (model && idx != currentIndex) {
currentIndex = idx;
int itemIndex = (idx - firstIndex + model->count()) % model->count();
- if(itemIndex < items.count())
+ if (itemIndex < items.count())
items.at(itemIndex)->setFocus(true);
emit q->currentIndexChanged();
}
@@ -783,7 +783,7 @@ void QFxPathViewPrivate::snapToCurrent()
//Rounds is the number of times round to make the current item visible
int rounds = itemIndex / items.count();
int otherWayRounds = (model->count() - (itemIndex))/items.count() + 1;
- if(otherWayRounds < rounds)
+ if (otherWayRounds < rounds)
rounds = -otherWayRounds;
itemIndex += pathOffset;
@@ -799,12 +799,12 @@ void QFxPathViewPrivate::snapToCurrent()
tl.clear();
moveOffset.setValue(_offset);
- if(rounds!=0){
+ if (rounds!=0){
//Compensate if the targetOffset would bring the target it from off the screen
qreal distance = targetOffset - _offset;
- if(distance <= -50)
+ if (distance <= -50)
rounds--;
- if(distance > 50)
+ if (distance > 50)
rounds++;
tl.move(moveOffset, targetOffset + 100.0*(-rounds), QEasingCurve(QEasingCurve::InOutQuad),
int(100*items.count()*qMax((qreal)(2.0/items.count()),(qreal)qAbs(rounds))));
diff --git a/src/declarative/fx/qfxpixmap.cpp b/src/declarative/fx/qfxpixmap.cpp
index 5a08679..0d456c6 100644
--- a/src/declarative/fx/qfxpixmap.cpp
+++ b/src/declarative/fx/qfxpixmap.cpp
@@ -67,7 +67,7 @@ public:
int refCount;
void addRef() { ++refCount; }
- void release() { Q_ASSERT(refCount > 0); --refCount; if(refCount == 0) { qfxPixmapCache.remove(key); delete this; } }
+ void release() { Q_ASSERT(refCount > 0); --refCount; if (refCount == 0) { qfxPixmapCache.remove(key); delete this; } }
};
static QFxPixmapCacheItem qfxPixmapCacheDummyItem;
@@ -104,7 +104,7 @@ QFxPixmap::QFxPixmap(const QUrl &url)
#endif
QString key = url.toString();
QFxPixmapCache::Iterator iter = qfxPixmapCache.find(key);
- if(iter == qfxPixmapCache.end()) {
+ if (iter == qfxPixmapCache.end()) {
qWarning() << "QFxPixmap: URL not loaded" << url;
} else {
QNetworkReply *reply = (*iter)->reply;
@@ -180,10 +180,10 @@ QPixmap QFxPixmap::pixmap() const
void QFxPixmap::setPixmap(const QPixmap &pix)
{
QFxPixmapCache::Iterator iter = qfxPixmapCache.find(QString::number(pix.cacheKey()));
- if(iter == qfxPixmapCache.end()) {
+ if (iter == qfxPixmapCache.end()) {
QFxPixmapCacheItem *item = new QFxPixmapCacheItem;
item->key = QString::number(pix.cacheKey());
- if(d->pixmap)
+ if (d->pixmap)
d->pixmap->release();
d->pixmap = item;
d->pixmap->image = pix.toImage();
@@ -195,7 +195,7 @@ void QFxPixmap::setPixmap(const QPixmap &pix)
#if 0
int size = 0;
- for(QFxPixmapCache::Iterator iter = qfxPixmapCache.begin(); iter != qfxPixmapCache.end(); ++iter) {
+ for (QFxPixmapCache::Iterator iter = qfxPixmapCache.begin(); iter != qfxPixmapCache.end(); ++iter) {
size += (*iter)->image.width() * (*iter)->image.height();
}
qWarning() << qfxPixmapCache.count() << size;
@@ -207,8 +207,8 @@ QFxPixmap::operator const QSimpleCanvasConfig::Image &() const
#if defined(QFX_RENDER_OPENGL)
return d->pixmap->image;
#else
- if(d->opaque) {
- if(!d->pixmap->image.isNull() && d->pixmap->opaqueImage.isNull()) {
+ if (d->opaque) {
+ if (!d->pixmap->image.isNull() && d->pixmap->opaqueImage.isNull()) {
#ifdef Q_ENABLE_PERFORMANCE_LOG
QFxPerfTimer<QFxPerf::PixmapLoad> perf;
#endif
@@ -218,7 +218,7 @@ QFxPixmap::operator const QSimpleCanvasConfig::Image &() const
}
return d->pixmap->opaqueImage;
} else {
- if(!d->pixmap->image.isNull() && d->pixmap->image.format() != QImage::Format_ARGB32_Premultiplied) {
+ if (!d->pixmap->image.isNull() && d->pixmap->image.format() != QImage::Format_ARGB32_Premultiplied) {
#ifdef Q_ENABLE_PERFORMANCE_LOG
QFxPerfTimer<QFxPerf::PixmapLoad> perf;
#endif
@@ -238,7 +238,7 @@ void QFxPixmap::get(QmlEngine *engine, const QUrl& url, QObject* obj, const char
{
QString key = url.toString();
QFxPixmapCache::Iterator iter = qfxPixmapCache.find(key);
- if(iter == qfxPixmapCache.end()) {
+ if (iter == qfxPixmapCache.end()) {
QFxPixmapCacheItem *item = new QFxPixmapCacheItem;
item->addRef(); // XXX - will never get deleted. Need to revisit caching
item->key = key;
@@ -274,7 +274,7 @@ void QFxPixmap::cancelGet(const QUrl& url, QObject* obj, const char* slot)
{
QString key = url.toString();
QFxPixmapCache::Iterator iter = qfxPixmapCache.find(key);
- if(iter == qfxPixmapCache.end())
+ if (iter == qfxPixmapCache.end())
return;
if ((*iter)->reply)
QObject::disconnect((*iter)->reply, SIGNAL(finished()), obj, slot);
diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp
index a761ec5..2bfc149 100644
--- a/src/declarative/fx/qfxrect.cpp
+++ b/src/declarative/fx/qfxrect.cpp
@@ -238,7 +238,7 @@ QColor QFxRect::color() const
void QFxRect::setColor(const QColor &c)
{
Q_D(QFxRect);
- if(d->_color == c)
+ if (d->_color == c)
return;
d->_color = c;
@@ -281,7 +281,7 @@ QColor QFxRect::tintColor() const
void QFxRect::setTintColor(const QColor &c)
{
Q_D(QFxRect);
- if(d->_tintColor == c)
+ if (d->_tintColor == c)
return;
d->_tintColor = c;
@@ -290,11 +290,11 @@ void QFxRect::setTintColor(const QColor &c)
QColor QFxRectPrivate::getColor()
{
- if(_tintColor.isValid()) {
+ if (_tintColor.isValid()) {
int a = _tintColor.alpha();
- if(a == 0xFF)
+ if (a == 0xFF)
return _tintColor;
- else if(a == 0x00)
+ else if (a == 0x00)
return _color;
else {
uint src = _tintColor.rgba();
@@ -304,7 +304,7 @@ QColor QFxRectPrivate::getColor()
((0xFF - a) * (dest & 0xFF00FF))) >> 8) & 0xFF00FF;
res |= (((a * ((src >> 8) & 0xFF00FF)) +
((0xFF - a) * ((dest >> 8) & 0xFF00FF)))) & 0xFF00FF00;
- if((src & 0xFF000000) == 0xFF000000)
+ if ((src & 0xFF000000) == 0xFF000000)
res |= 0xFF000000;
return QColor::fromRgba(res);
@@ -344,7 +344,7 @@ QColor QFxRect::gradientColor() const
void QFxRect::setGradientColor(const QColor &c)
{
Q_D(QFxRect);
- if(d->_gradcolor == c)
+ if (d->_gradcolor == c)
return;
d->_gradcolor = c;
@@ -438,14 +438,14 @@ void QFxRect::paintContents(QPainter &p)
void QFxRect::drawRect(QPainter &p)
{
Q_D(QFxRect);
- if(d->_gradcolor.isValid() /*|| p.usingQt() */) {
+ if (d->_gradcolor.isValid() /*|| p.usingQt() */) {
// XXX This path is still slower than the image path
// Image path won't work for gradients though
p.save();
QPen pn(QColor(pen()->color()), pen()->width());
p.setRenderHint(QPainter::Antialiasing);
p.setPen(pn);
- if(d->_gradcolor.isValid()){
+ if (d->_gradcolor.isValid()){
QLinearGradient grad(0, 0, 0, height());
grad.setColorAt(0, d->_color);
grad.setColorAt(1, d->_gradcolor);
@@ -453,7 +453,7 @@ void QFxRect::drawRect(QPainter &p)
}else{
p.setBrush(d->_color);
}
- if(d->_radius)
+ if (d->_radius)
p.drawRoundedRect(0, 0, width(), height(), d->_radius, d->_radius);
else
p.drawRect(0, 0, width(), height());
@@ -477,36 +477,36 @@ void QFxRect::drawRect(QPainter &p)
p.drawImage(QRect(0, 0, offset, offset), d->_rectImage, QRect(0, 0, offset, offset));
// Upper middle
- if(d->_rectImage.width() - xSide)
+ if (d->_rectImage.width() - xSide)
p.drawImage(QRect(offset, 0, width() - xSide, offset), d->_rectImage,
QRect(offset, 0, d->_rectImage.width() - xSide, offset));
// Upper right
- if(d->_rectImage.width() - offset) {
+ if (d->_rectImage.width() - offset) {
p.drawImage(QPoint(width()-offset, 0), d->_rectImage,
QRect(d->_rectImage.width()-offset, 0, offset, offset));
}
// Middle left
- if(d->_rectImage.height() - ySide)
+ if (d->_rectImage.height() - ySide)
p.drawImage(QRect(0, offset, offset, height() - ySide), d->_rectImage,
QRect(0, offset, offset, d->_rectImage.height() - ySide));
// Middle
- if(d->_rectImage.width() - xSide && d->_rectImage.height() - ySide)
+ if (d->_rectImage.width() - xSide && d->_rectImage.height() - ySide)
p.drawImage(QRect(offset, offset, width() - xSide, height() - ySide), d->_rectImage,
QRect(offset, offset, d->_rectImage.width() - xSide, d->_rectImage.height() - ySide));
// Midlle right
- if(d->_rectImage.height() - ySide)
+ if (d->_rectImage.height() - ySide)
p.drawImage(QRect(width()-offset, offset, offset, height() - ySide), d->_rectImage,
QRect(d->_rectImage.width()-offset, offset, offset, d->_rectImage.height() - ySide));
// Lower left
p.drawImage(QPoint(0, height() - offset), d->_rectImage, QRect(0, d->_rectImage.height() - offset, offset, offset));
// Lower Middle
- if(d->_rectImage.width() - xSide)
+ if (d->_rectImage.width() - xSide)
p.drawImage(QRect(offset, height() - offset, width() - xSide, offset), d->_rectImage,
QRect(offset, d->_rectImage.height() - offset, d->_rectImage.width() - xSide, offset));
// Lower Right
- if(d->_rectImage.width() - offset)
+ if (d->_rectImage.width() - offset)
p.drawImage(QPoint(width()-offset, height() - offset), d->_rectImage,
QRect(d->_rectImage.width()-offset, d->_rectImage.height() - offset, offset, offset));
}
@@ -519,8 +519,8 @@ void QFxRect::drawRect(QPainter &p)
void QFxRect::paintGLContents(GLPainter &p)
{
Q_D(QFxRect);
- if(d->_radius == 0 && (!d->_pen || !d->_pen->isValid())) {
- if(d->_gradcolor.isValid()) {
+ if (d->_radius == 0 && (!d->_pen || !d->_pen->isValid())) {
+ if (d->_gradcolor.isValid()) {
float widthV = width();
float heightV = height();
@@ -582,7 +582,7 @@ void QFxRect::paintGLContents(GLPainter &p)
float imgWidth = d->_rectTexture.width();
float imgHeight = d->_rectTexture.height();
- if(!imgWidth || !imgHeight)
+ if (!imgWidth || !imgHeight)
return;
float widthV = width();
@@ -607,7 +607,7 @@ void QFxRect::paintGLContents(GLPainter &p)
imgbottom = heightV - offset;
//Bug 231768: Inappropriate interpolation was occuring on 3x3 textures
- if(offset==1)
+ if (offset==1)
texleft=texright=textop=texbottom=0.5;
float vert1[] = { 0, 0,
@@ -686,7 +686,7 @@ void QFxRect::paintGLContents(GLPainter &p)
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(p.activeTransform.data());
- if(d->_radius == 0 && (!d->_pen || !d->_pen->isValid())) {
+ if (d->_radius == 0 && (!d->_pen || !d->_pen->isValid())) {
GLfloat vertices[] = { 0, heightV,
widthV, heightV,
0, 0,
@@ -696,7 +696,7 @@ void QFxRect::paintGLContents(GLPainter &p)
glVertexPointer(2,GL_FLOAT,0,vertices);
QColor c;
- if(d->_gradcolor.isValid())
+ if (d->_gradcolor.isValid())
c = d->_color;
else
c = d->getColor();
@@ -707,7 +707,7 @@ void QFxRect::paintGLContents(GLPainter &p)
float r2 = r; float g2 = g; float b2 = b; float a2 = a;
- if(d->_gradcolor.isValid()) {
+ if (d->_gradcolor.isValid()) {
r2 = d->_gradcolor.redF();
g2 = d->_gradcolor.greenF();
b2 = d->_gradcolor.blueF();
@@ -736,7 +736,7 @@ void QFxRect::paintGLContents(GLPainter &p)
offset = d->pen()->width();
}
- if(p.activeOpacity == 1.) {
+ if (p.activeOpacity == 1.) {
GLint i = GL_REPLACE;
glTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &i);
} else {
@@ -747,7 +747,7 @@ void QFxRect::paintGLContents(GLPainter &p)
float imgWidth = d->_rectTexture.width();
float imgHeight = d->_rectTexture.height();
- if(!imgWidth || !imgHeight)
+ if (!imgWidth || !imgHeight)
return;
float widthV = width();
diff --git a/src/declarative/fx/qfxrect_p.h b/src/declarative/fx/qfxrect_p.h
index 3cb46fa..2fd555f 100644
--- a/src/declarative/fx/qfxrect_p.h
+++ b/src/declarative/fx/qfxrect_p.h
@@ -88,7 +88,7 @@ public:
QColor _gradcolor;
QColor _tintColor;
QFxPen *pen() {
- if(!_pen) {
+ if (!_pen) {
Q_Q(QFxRect);
_pen = new QFxPen;
QObject::connect(_pen, SIGNAL(updated()), q, SLOT(doUpdate()));
diff --git a/src/declarative/fx/qfxreflectionfilter.cpp b/src/declarative/fx/qfxreflectionfilter.cpp
index 39342d7..e02bc16 100644
--- a/src/declarative/fx/qfxreflectionfilter.cpp
+++ b/src/declarative/fx/qfxreflectionfilter.cpp
@@ -135,7 +135,7 @@ qreal QFxReflectionFilter::alpha() const
void QFxReflectionFilter::setAlpha(qreal a)
{
- if(d->alpha == a) return;
+ if (d->alpha == a) return;
d->alpha = a;
emit alphaChanged(a);
update();
@@ -202,7 +202,7 @@ int QFxReflectionFilter::height() const
void QFxReflectionFilter::setHeight(int h)
{
- if(d->height == h) return;
+ if (d->height == h) return;
d->height = h;
emit heightChanged(h);
update();
@@ -219,7 +219,7 @@ int QFxReflectionFilter::offset()
void QFxReflectionFilter::setOffset(int o)
{
- if(d->offset == o) return;
+ if (d->offset == o) return;
d->offset = o;
emit offsetChanged(o);
update();
@@ -236,7 +236,7 @@ qreal QFxReflectionFilter::scale() const
void QFxReflectionFilter::setScale(qreal s)
{
- if(d->scale == s) return;
+ if (d->scale == s) return;
d->scale = s;
emit scaleChanged(s);
update();
@@ -259,12 +259,12 @@ void QFxReflectionFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
float height = r.height();
float refHeight = height;
- if(d->height > 0)
+ if (d->height > 0)
refHeight = min(height, d->height);
QSimpleCanvas::Matrix simpMat;
QSimpleCanvasItem *simpItem = 0;
- if(isSimpleItem(&simpItem, &simpMat) &&
+ if (isSimpleItem(&simpItem, &simpMat) &&
simpItem->glSimpleItemData(0, 0, 0, 0)) {
GLfloat vertices[8];
@@ -276,7 +276,7 @@ void QFxReflectionFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
GLfloat opacity[4];
float invRefHeight = 1. / refHeight;
- for(int ii = 0; ii < 4; ++ii) {
+ for (int ii = 0; ii < 4; ++ii) {
float vertex = vertices[ii * 2 + 1];
float o = (1. - (height - vertex) * invRefHeight);
opacity[ii] = o * d->alpha * p.activeOpacity;
@@ -285,7 +285,7 @@ void QFxReflectionFilter::filterGL(QSimpleCanvasItem::GLPainter &p)
QSimpleCanvas::Matrix trans = p.activeTransform;
trans.rotate(180, 1, 0, 0);
trans.translate(0, -r.height() - d->offset);
- if(d->scale != 1)
+ if (d->scale != 1)
trans.scale(1, d->scale, 1);
trans.translate(0, -r.height());
trans *= simpMat;
diff --git a/src/declarative/fx/qfxrepeater.cpp b/src/declarative/fx/qfxrepeater.cpp
index ad4081b..7ee949d 100644
--- a/src/declarative/fx/qfxrepeater.cpp
+++ b/src/declarative/fx/qfxrepeater.cpp
@@ -235,6 +235,15 @@ void QFxRepeater::setComponent(QmlComponent *_c)
/*!
\internal
*/
+void QFxRepeater::componentComplete()
+{
+ QFxItem::componentComplete();
+ regenerate();
+}
+
+/*!
+ \internal
+ */
void QFxRepeater::parentChanged(QSimpleCanvasItem *o, QSimpleCanvasItem *n)
{
QFxItem::parentChanged(o, n);
@@ -250,15 +259,15 @@ void QFxRepeater::regenerate()
qDeleteAll(d->deletables);
d->deletables.clear();
- if(!d->component || !itemParent())
+ if (!d->component || !itemParent() || !isComponentComplete())
return;
QFxItem *lastItem = this;
- if(d->dataSource.type() == QVariant::StringList) {
+ if (d->dataSource.type() == QVariant::StringList) {
QStringList sl = qvariant_cast<QStringList>(d->dataSource);
- for(int ii = 0; ii < sl.size(); ++ii) {
+ for (int ii = 0; ii < sl.size(); ++ii) {
QmlContext *ctxt = new QmlContext(qmlContext(this), this);
d->deletables << ctxt;
@@ -268,12 +277,12 @@ void QFxRepeater::regenerate()
if (QFxItem *item = d->addItem(ctxt, lastItem))
lastItem = item;
}
- } else if(QmlMetaType::isList(d->dataSource)) {
+ } else if (QmlMetaType::isList(d->dataSource)) {
int cnt = QmlMetaType::listCount(d->dataSource);
- if(cnt <= 0)
+ if (cnt <= 0)
return;
- for(int ii = 0; ii < cnt; ++ii) {
+ for (int ii = 0; ii < cnt; ++ii) {
QVariant v = QmlMetaType::listAt(d->dataSource, ii);
QObject *o = QmlMetaType::toQObject(v);
@@ -288,10 +297,10 @@ void QFxRepeater::regenerate()
}
} else if (QListModelInterface *model = qobject_cast<QListModelInterface*>(d->dataSource.value<QObject*>())) {
int cnt = model->count();
- if(cnt <= 0)
+ if (cnt <= 0)
return;
- for(int ii = 0; ii < cnt; ++ii) {
+ for (int ii = 0; ii < cnt; ++ii) {
QmlContext *ctxt = new QmlContext(qmlContext(this), this);
d->deletables << ctxt;
@@ -330,11 +339,11 @@ void QFxRepeater::regenerate()
d->addItem(ctxt, lastItem);
- } else if(d->dataSource.canConvert(QVariant::Int)){
+ } else if (d->dataSource.canConvert(QVariant::Int)){
int count = qvariant_cast<int>(d->dataSource);
- for(int ii = 0; ii < count; ++ii) {
+ for (int ii = 0; ii < count; ++ii) {
QmlContext *ctxt = new QmlContext(qmlContext(this), this);
d->deletables << ctxt;
diff --git a/src/declarative/fx/qfxrepeater.h b/src/declarative/fx/qfxrepeater.h
index f6c4584..8efd281 100644
--- a/src/declarative/fx/qfxrepeater.h
+++ b/src/declarative/fx/qfxrepeater.h
@@ -72,6 +72,7 @@ private:
void regenerate();
protected:
+ virtual void componentComplete();
virtual void parentChanged(QSimpleCanvasItem *, QSimpleCanvasItem *);
QFxRepeater(QFxRepeaterPrivate &dd, QFxItem *parent);
diff --git a/src/declarative/fx/qfxscalegrid.cpp b/src/declarative/fx/qfxscalegrid.cpp
index d84f5e8..325f7d9 100644
--- a/src/declarative/fx/qfxscalegrid.cpp
+++ b/src/declarative/fx/qfxscalegrid.cpp
@@ -153,29 +153,29 @@ QFxGridScaledImage::QFxGridScaledImage(QIODevice *data)
while(!data->atEnd()) {
QString line = QString::fromUtf8(data->readLine().trimmed());
- if(line.isEmpty() || line.startsWith(QLatin1String("#")))
+ if (line.isEmpty() || line.startsWith(QLatin1String("#")))
continue;
QStringList list = line.split(QLatin1Char(':'));
- if(list.count() != 2)
+ if (list.count() != 2)
return;
list[0] = list[0].trimmed();
list[1] = list[1].trimmed();
- if(list[0] == QLatin1String("gridLeft"))
+ if (list[0] == QLatin1String("gridLeft"))
l = list[1].toInt();
- else if(list[0] == QLatin1String("gridRight"))
+ else if (list[0] == QLatin1String("gridRight"))
r = list[1].toInt();
- else if(list[0] == QLatin1String("gridTop"))
+ else if (list[0] == QLatin1String("gridTop"))
t = list[1].toInt();
- else if(list[0] == QLatin1String("gridBottom"))
+ else if (list[0] == QLatin1String("gridBottom"))
b = list[1].toInt();
- else if(list[0] == QLatin1String("imageFile"))
+ else if (list[0] == QLatin1String("imageFile"))
imgFile = list[1];
}
- if(l < 0 || r < 0 || t < 0 || b < 0 || imgFile.isEmpty())
+ if (l < 0 || r < 0 || t < 0 || b < 0 || imgFile.isEmpty())
return;
_l = l; _r = r; _t = t; _b = b;
diff --git a/src/declarative/fx/qfxshadowfilter.cpp b/src/declarative/fx/qfxshadowfilter.cpp
index 3760a4d..38d1c31 100644
--- a/src/declarative/fx/qfxshadowfilter.cpp
+++ b/src/declarative/fx/qfxshadowfilter.cpp
@@ -122,7 +122,7 @@ int QFxShadowFilter::xOffset() const
*/
void QFxShadowFilter::setXOffset(int offset)
{
- if(d->x == offset) return;
+ if (d->x == offset) return;
d->x = offset;
emit offsetChanged(d->x, d->y);
}
@@ -138,7 +138,7 @@ int QFxShadowFilter::yOffset() const
void QFxShadowFilter::setYOffset(int offset)
{
- if(d->y == offset) return;
+ if (d->y == offset) return;
d->y = offset;
emit offsetChanged(d->x, d->y);
}
diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp
index e7085d8..5cb31e1 100644
--- a/src/declarative/fx/qfxtext.cpp
+++ b/src/declarative/fx/qfxtext.cpp
@@ -165,7 +165,7 @@ void QFxText::setText(const QString &n)
QFxPerfTimer<QFxPerf::QFxText_setText> st;
#endif
Q_D(QFxText);
- if(d->text == n)
+ if (d->text == n)
return;
d->richText = Qt::mightBeRichText(n); // ### what's the cost?
@@ -205,7 +205,7 @@ QString QFxText::text() const
void QFxText::setColor(const QColor &color)
{
Q_D(QFxText);
- if(d->color == color)
+ if (d->color == color)
return;
d->imgDirty = true;
@@ -270,7 +270,7 @@ QFxText::TextStyle QFxText::style() const
void QFxText::setStyle(QFxText::TextStyle style)
{
Q_D(QFxText);
- if(d->style == style)
+ if (d->style == style)
return;
d->imgDirty = true;
@@ -281,7 +281,7 @@ void QFxText::setStyle(QFxText::TextStyle style)
void QFxText::setStyleColor(const QColor &color)
{
Q_D(QFxText);
- if(d->styleColor == color)
+ if (d->styleColor == color)
return;
d->imgDirty = true;
@@ -424,7 +424,7 @@ void QFxText::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
{
Q_D(QFxText);
- if(newGeometry.width() != oldGeometry.width()) {
+ if (newGeometry.width() != oldGeometry.width()) {
if (d->wrap || d->elideMode != Qt::ElideNone) {
d->imgDirty = true;
d->updateSize();
@@ -446,10 +446,10 @@ void QFxTextPrivate::updateSize()
{
Q_Q(QFxText);
if (q->isComponentComplete()) {
- if(text.isEmpty()) {
+ if (text.isEmpty()) {
return;
}
- QFont f; if(_font) f = _font->font();
+ QFont f; if (_font) f = _font->font();
QFontMetrics fm(f);
int dy = q->height();
@@ -573,7 +573,7 @@ QSize QFxTextPrivate::setupTextLayout(QTextLayout *layout)
Q_Q(QFxText);
layout->setCacheEnabled(true);
- QFont f; if(_font) f = _font->font();
+ QFont f; if (_font) f = _font->font();
QFontMetrics fm = QFontMetrics(f);
int leading = fm.leading();
@@ -613,7 +613,7 @@ QImage QFxTextPrivate::wrappedTextImage(bool drawStyle)
{
//do layout
Q_Q(const QFxText);
- QFont f; if(_font) f = _font->font();
+ QFont f; if (_font) f = _font->font();
QString tmp = text;
if (singleline && elideMode != Qt::ElideNone && q->widthValid()) {
QFontMetrics fm(f);
@@ -626,11 +626,11 @@ QImage QFxTextPrivate::wrappedTextImage(bool drawStyle)
int x = 0;
for (int i = 0; i < textLayout.lineCount(); ++i) {
QTextLine line = textLayout.lineAt(i);
- if(hAlign == QFxText::AlignLeft) {
+ if (hAlign == QFxText::AlignLeft) {
x = 0;
- } else if(hAlign == QFxText::AlignRight) {
+ } else if (hAlign == QFxText::AlignRight) {
x = size.width() - (int)line.naturalTextWidth();
- } else if(hAlign == QFxText::AlignHCenter) {
+ } else if (hAlign == QFxText::AlignHCenter) {
x = (size.width() - (int)line.naturalTextWidth()) / 2;
}
line.setPosition(QPoint(x, (int)line.y()));
@@ -679,7 +679,7 @@ QImage QFxTextPrivate::richTextImage(bool drawStyle)
void QFxTextPrivate::checkImgCache()
{
- if(!imgDirty)
+ if (!imgDirty)
return;
bool empty = text.isEmpty();
@@ -722,7 +722,7 @@ void QFxText::paintContents(QPainter &p)
{
Q_D(QFxText);
d->checkImgCache();
- if(d->imgCache.isNull())
+ if (d->imgCache.isNull())
return;
int w = width();
@@ -763,7 +763,7 @@ void QFxText::paintGLContents(GLPainter &p)
{
Q_D(QFxText);
d->checkImgCache();
- if(d->imgCache.isNull())
+ if (d->imgCache.isNull())
return;
int w = width();
@@ -826,7 +826,7 @@ void QFxText::paintGLContents(GLPainter &p)
{
Q_D(QFxText);
d->checkImgCache();
- if(d->imgCache.isNull())
+ if (d->imgCache.isNull())
return;
int w = width();
@@ -875,7 +875,7 @@ void QFxText::paintGLContents(GLPainter &p)
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(p.activeTransform.data());
glEnable(GL_TEXTURE_2D);
- if(p.activeOpacity == 1.) {
+ if (p.activeOpacity == 1.) {
GLint i = GL_REPLACE;
glTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &i);
} else {
diff --git a/src/declarative/fx/qfxtext_p.h b/src/declarative/fx/qfxtext_p.h
index 7be4309..4296891 100644
--- a/src/declarative/fx/qfxtext_p.h
+++ b/src/declarative/fx/qfxtext_p.h
@@ -98,7 +98,7 @@ public:
QString text;
QmlFont *font()
{
- if(!_font) {
+ if (!_font) {
Q_Q(QFxText);
_font = new QmlFont;
QObject::connect(_font, SIGNAL(updated()), q, SLOT(fontChanged()));
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index 7efb826..68aea01 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -270,7 +270,7 @@ QColor QFxTextEdit::color() const
void QFxTextEdit::setColor(const QColor &color)
{
Q_D(QFxTextEdit);
- if(d->color == color)
+ if (d->color == color)
return;
clearCache();
@@ -370,7 +370,7 @@ void QFxTextEdit::setWrap(bool w)
void QFxTextEdit::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
{
- if(newGeometry.width() != oldGeometry.width())
+ if (newGeometry.width() != oldGeometry.width())
updateSize();
QFxImageItem::geometryChanged(newGeometry, oldGeometry);
}
diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp
index a001214..9f18413 100644
--- a/src/declarative/fx/qfxtransform.cpp
+++ b/src/declarative/fx/qfxtransform.cpp
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
#define M_PI 3.14159265358979323846
#endif
-QML_DEFINE_TYPE(QFxTransform,Transform);
+QML_DEFINE_NOCREATE_TYPE(QFxTransform);
/*!
\qmlclass Transform
@@ -62,6 +62,10 @@ QFxTransform::QFxTransform(QObject *parent) :
{
}
+QFxTransform::~QFxTransform()
+{
+}
+
bool QFxTransform::isIdentity() const
{
return true;
@@ -75,143 +79,192 @@ QSimpleCanvas::Matrix QFxTransform::transform() const
void QFxTransform::update()
{
QFxItem *item = qobject_cast<QFxItem *>(parent());
- if(item)
+ if (item)
item->updateTransform();
}
-QML_DEFINE_TYPE(QFxAxis,Axis);
+/*!
+ \qmlclass Axis
+ \brief An axis that can be used for rotation or translation.
+*/
+
+QML_DEFINE_TYPE(QFxAxis, Axis);
QFxAxis::QFxAxis(QObject *parent)
-: QFxTransform(parent), _xStart(0), _yStart(0), _xEnd(0), _yEnd(0), _zEnd(0), _rotation(0),
- _translation(0), _distanceToPlane(1024.), _dirty(true)
+: QObject(parent), _startX(0), _startY(0), _endX(0), _endY(0), _endZ(0)
{
}
-qreal QFxAxis::xStart() const
+QFxAxis::~QFxAxis()
{
- return _xStart;
}
-void QFxAxis::setXStart(qreal x)
+qreal QFxAxis::startX() const
{
- _xStart = x;
- update();
+ return _startX;
}
-qreal QFxAxis::yStart() const
+void QFxAxis::setStartX(qreal x)
{
- return _yStart;
+ _startX = x;
+ emit updated();
}
-void QFxAxis::setYStart(qreal y)
+qreal QFxAxis::startY() const
{
- _yStart = y;
- update();
+ return _startY;
}
-qreal QFxAxis::xEnd() const
+void QFxAxis::setStartY(qreal y)
{
- return _xEnd;
+ _startY = y;
+ emit updated();
}
-void QFxAxis::setXEnd(qreal x)
+qreal QFxAxis::endX() const
{
- _xEnd = x;
- update();
+ return _endX;
}
-qreal QFxAxis::yEnd() const
+void QFxAxis::setEndX(qreal x)
{
- return _yEnd;
+ _endX = x;
+ emit updated();
}
-void QFxAxis::setYEnd(qreal y)
+qreal QFxAxis::endY() const
{
- _yEnd = y;
- update();
+ return _endY;
}
-qreal QFxAxis::zEnd() const
+void QFxAxis::setEndY(qreal y)
{
- return _zEnd;
+ _endY = y;
+ emit updated();
}
-void QFxAxis::setZEnd(qreal z)
+qreal QFxAxis::endZ() const
{
-#if !defined(QFX_RENDER_OPENGL)
- if(z != 0. && translation() != 0.) {
- qmlInfo(this) << "QTransform cannot translate along Z-axis";
- return;
- }
-#endif
+ return _endZ;
+}
- _zEnd = z;
- update();
+void QFxAxis::setEndZ(qreal z)
+{
+ _endZ = z;
+ emit updated();
}
-qreal QFxAxis::rotation() const
+/*!
+ \qmlclass AxisRotation
+ \brief The AxisRotation element provides a way to rotate an Item around an axis.
+
+ Here is an example of various rotations applied to an \l Image.
+ \code
+ <HorizontalLayout margin="10" spacing="10">
+ <Image src="qt.png"/>
+ <Image src="qt.png">
+ <transform>
+ <AxisRotation axis.startX="30" axis.endX="30" axis.endY="60" angle="18"/>
+ </transform>
+ </Image>
+ <Image src="qt.png">
+ <transform>
+ <AxisRotation axis.startX="30" axis.endX="30" axis.endY="60" angle="36"/>
+ </transform>
+ </Image>
+ <Image src="qt.png">
+ <transform>
+ <AxisRotation axis.startX="30" axis.endX="30" axis.endY="60" angle="54"/>
+ </transform>
+ </Image>
+ <Image src="qt.png">
+ <transform>
+ <AxisRotation axis.startX="30" axis.endX="30" axis.endY="60" angle="72"/>
+ </transform>
+ </Image>
+ </HorizontalLayout>
+ \endcode
+
+ \image axisrotation.png
+*/
+
+QML_DEFINE_TYPE(QFxRotation,AxisRotation);
+
+QFxRotation::QFxRotation(QObject *parent)
+: QFxTransform(parent), _angle(0), _distanceToPlane(1024.), _dirty(true)
{
- return _rotation;
+ connect(&_axis, SIGNAL(updated()), this, SLOT(update()));
}
-void QFxAxis::setRotation(qreal r)
+QFxRotation::~QFxRotation()
{
- _rotation = r;
- update();
}
-qreal QFxAxis::translation() const
+/*!
+ \qmlproperty real AxisRotation::axis.startX
+ \qmlproperty real AxisRotation::axis.startY
+ \qmlproperty real AxisRotation::axis.endX
+ \qmlproperty real AxisRotation::axis.endY
+ \qmlproperty real AxisRotation::axis.endZ
+
+ A rotation axis is specified by 2 points in 3D space: a start point and
+ an end point. The z-position of the start point is assumed to be 0, and cannot
+ be changed.
+*/
+QFxAxis *QFxRotation::axis()
{
- return _translation;
+ return &_axis;
}
-void QFxAxis::setTranslation(qreal t)
+/*!
+ \qmlproperty real AxisRotation::angle
+
+ The angle, in degrees, to rotate around the specified axis.
+*/
+qreal QFxRotation::angle() const
{
-#if !defined(QFX_RENDER_OPENGL)
- if(zEnd() != 0. && t != 0.) {
- qmlInfo(this) << "QTransform cannot translate along Z-axis";
- return;
- }
-#endif
+ return _angle;
+}
- _translation = t;
+void QFxRotation::setAngle(qreal angle)
+{
+ _angle = angle;
update();
}
-bool QFxAxis::isIdentity() const
+bool QFxRotation::isIdentity() const
{
- return (_rotation == 0. && _translation == 0.) ||
- (zEnd() == 0. && yEnd() == yStart() && xEnd() == xStart());
+ return (_angle == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX());
}
#if defined(QFX_RENDER_QPAINTER)
const qreal inv_dist_to_plane = 1. / 1024.;
-QTransform QFxAxis::transform() const
+QTransform QFxRotation::transform() const
{
- if(_dirty) {
+ if (_dirty) {
_transform = QTransform();
- if(!isIdentity()) {
- if(rotation() != 0.) {
+ if (!isIdentity()) {
+ if (angle() != 0.) {
QTransform rotTrans;
- rotTrans.translate(-xStart(), -yStart());
+ rotTrans.translate(-_axis.startX(), -_axis.startY());
QTransform rotTrans2;
- rotTrans2.translate(xStart(), yStart());
+ rotTrans2.translate(_axis.startX(), _axis.startY());
- qreal rad = rotation() * 2. * M_PI / 360.;
+ qreal rad = angle() * 2. * M_PI / 360.;
qreal c = ::cos(rad);
qreal s = ::sin(rad);
- qreal x = xEnd() - xStart();
- qreal y = yEnd() - yStart();
- qreal z = zEnd();
+ qreal x = _axis.endX() - _axis.startX();
+ qreal y = _axis.endY() - _axis.startY();
+ qreal z = _axis.endZ();
qreal idtp = inv_dist_to_plane;
- if(distanceToPlane() != 1024.)
+ if (distanceToPlane() != 1024.)
idtp = 1. / distanceToPlane();
qreal len = x * x + y * y + z * z;
- if(len != 1.) {
+ if (len != 1.) {
len = ::sqrt(len);
x /= len;
y /= len;
@@ -226,13 +279,6 @@ QTransform QFxAxis::transform() const
_transform *= rot;
_transform *= rotTrans2;
}
-
- if(translation() != 0.) {
- QTransform trans;
- trans.translate((xEnd() - xStart()) * translation(),
- (yEnd() - yStart()) * translation());
- _transform *= trans;
- }
}
_dirty = false;
@@ -241,27 +287,22 @@ QTransform QFxAxis::transform() const
return _transform;
}
#elif defined(QFX_RENDER_OPENGL)
-QMatrix4x4 QFxAxis::transform() const
+QMatrix4x4 QFxRotation::transform() const
{
- if(_dirty) {
+ if (_dirty) {
_dirty = false;
_transform = QMatrix4x4();
- if(!isIdentity()) {
- if(rotation() != 0.) {
- qreal x = xEnd() - xStart();
- qreal y = yEnd() - yStart();
- qreal z = zEnd();
+ if (!isIdentity()) {
+ if (angle() != 0.) {
+ qreal x = _axis.endX() - _axis.startX();
+ qreal y = _axis.endY() - _axis.startY();
+ qreal z = _axis.endZ();
- _transform.translate(xStart(), yStart(), 0);
- _transform.rotate(rotation(), x, y, z);
- _transform.translate(-xStart(), -yStart(), 0);
+ _transform.translate(_axis.startX(), _axis.startY(), 0);
+ _transform.rotate(angle(), x, y, z);
+ _transform.translate(-_axis.startX(), -_axis.startY(), 0);
}
-
- if(translation() != 0.)
- _transform.translate((xEnd() - xStart()) * translation(),
- (yEnd() - yStart()) * translation(),
- (zEnd()) * translation());
}
}
@@ -269,198 +310,161 @@ QMatrix4x4 QFxAxis::transform() const
}
#endif
-qreal QFxAxis::distanceToPlane() const
+/*!
+ \qmlproperty real AxisRotation::distanceToPlane
+*/
+qreal QFxRotation::distanceToPlane() const
{
return _distanceToPlane;
}
-void QFxAxis::setDistanceToPlane(qreal d)
+void QFxRotation::setDistanceToPlane(qreal d)
{
_distanceToPlane = d;
update();
}
-void QFxAxis::update()
+void QFxRotation::update()
{
_dirty = true;
QFxItem *item = qobject_cast<QFxItem *>(parent());
- if(item)
+ if (item)
item->updateTransform();
}
-QML_DEFINE_TYPE(QFxFlipable,Flipable);
-
-class QFxFlipablePrivate : public QFxItemPrivate
-{
-public:
- QFxFlipablePrivate() : current(QFxFlipable::Front), front(0), back(0) {}
-
- QFxFlipable::Side current;
- QFxItem *front;
- QFxItem *back;
-};
-
/*!
- \qmlclass Flipable QFxFlipable
- \brief The Flipable element provides a surface that can be flipped.
- \inherits Item
-
- Flipable allows you to specify a front and a back and then flip between those sides.
+ \qmlclass AxisTranslation
+ \brief The AxisTranslation element provides a way to move an Item along an axis.
+ The following example translates the image to 10, 3.
\code
- <Flipable id="flipable" width="40" height="40">
+ <Image src="logo.png">
<transform>
- <Axis id="axis" xStart="20" xEnd="20" yStart="20" yEnd="0" />
+ <AxisTranslation axis.startX="0" axis.startY="0" axis.endX="1" axis.endY=".3" distance="10"/>
</transform>
- <front>
- <Image file="front.png"/>
- </front>
- <back>
- <Image file="back.png"/>
- </back>
- <states>
- <State name="back">
- <SetProperty target="{axis}" property="rotation" value="180" />
- </State>
- </states>
- <transitions>
- <Transition>
- <NumericAnimation easing="easeInOutQuad" properties="rotation"/>
- </Transition>
- </transitions>
- </Flipable>
+ </Image>
\endcode
-
- \image flipable.gif
*/
-/*!
- \internal
- \class QFxFlipable
- \brief The QFxFlipable class provides a flipable surface.
-
- \ingroup group_widgets
+QML_DEFINE_TYPE(QFxTranslation,AxisTranslation);
- QFxFlipable allows you to specify a front and a back, as well as an
- axis for the flip.
-*/
+QFxTranslation::QFxTranslation(QObject *parent)
+: QFxTransform(parent), _distance(0), _dirty(true)
+{
+ connect(&_axis, SIGNAL(updated()), this, SLOT(update()));
+}
-QFxFlipable::QFxFlipable(QFxItem *parent)
-: QFxItem(*(new QFxFlipablePrivate), parent)
+QFxTranslation::~QFxTranslation()
{
}
-QFxFlipable::~QFxFlipable()
+/*!
+ \qmlproperty real AxisTranslation::axis.startX
+ \qmlproperty real AxisTranslation::axis.startY
+ \qmlproperty real AxisTranslation::axis.endX
+ \qmlproperty real AxisTranslation::axis.endY
+ \qmlproperty real AxisTranslation::axis.endZ
+
+ A translation axis is specified by 2 points in 3D space: a start point and
+ an end point. The z-position of the start point is assumed to be 0, and cannot
+ be changed. Changing the z-position of the end point is only valid when running
+ under OpenGL.
+*/
+QFxAxis *QFxTranslation::axis()
{
+ return &_axis;
}
/*!
- \qmlproperty Item Flipable::front
- \qmlproperty Item Flipable::back
+ \qmlproperty real AxisTranslation::distance
- The front and back sides of the flipable.
-*/
+ The distance to translate along the specified axis. distance is a multiplier;
+ in the example below, a distance of 1 would translate to 100, 50, while a distance
+ of 0.5 would translate to 50, 25.
-QFxItem *QFxFlipable::front()
+ \code
+ <AxisTranslation axis.startX="0" axis.startY="0" axis.endX="100" axis.endY="50"/>
+ \endcode
+*/
+qreal QFxTranslation::distance() const
{
- Q_D(const QFxFlipable);
- return d->front;
+ return _distance;
}
-void QFxFlipable::setFront(QFxItem *front)
+void QFxTranslation::setDistance(qreal distance)
{
- Q_D(QFxFlipable);
- if(d->front) {
- qmlInfo(this) << "front is a write-once property";
- return;
- }
- d->front = front;
- children()->append(d->front);
- if(Back == d->current)
- d->front->setOpacity(0.);
+ _distance = distance;
+ update();
}
-QFxItem *QFxFlipable::back()
+bool QFxTranslation::isIdentity() const
{
- Q_D(const QFxFlipable);
- return d->back;
+ return (_distance == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX());
}
-void QFxFlipable::setBack(QFxItem *back)
+#if defined(QFX_RENDER_QPAINTER)
+QTransform QFxTranslation::transform() const
{
- Q_D(QFxFlipable);
- if(d->back) {
- qmlInfo(this) << "back is a write-once property";
- return;
- }
- d->back = back;
- children()->append(d->back);
- if(Front == d->current)
- d->back->setOpacity(0.);
-}
+ if (_dirty) {
+ _transform = QTransform();
-/*!
- \qmlproperty enumeration Flipable::side
+ if (!isIdentity()) {
+ if (distance() != 0.) {
+ QTransform trans;
+ trans.translate((_axis.endX() - _axis.startX()) * distance(),
+ (_axis.endY() - _axis.startY()) * distance());
+ _transform *= trans;
+ }
+ }
- The side of the Flippable currently visible. Possible values are \c
- Front and \c Back.
-*/
-QFxFlipable::Side QFxFlipable::side() const
-{
- Q_D(const QFxFlipable);
- return d->current;
-}
+ _dirty = false;
+ }
-void QFxFlipable::transformChanged(const QSimpleCanvas::Matrix &trans)
+ return _transform;
+}
+#elif defined(QFX_RENDER_OPENGL)
+QMatrix4x4 QFxRotation::transform() const
{
- Q_D(QFxFlipable);
- QPointF p1(0, 0);
- QPointF p2(1, 0);
- QPointF p3(1, 1);
-
- p1 = trans.map(p1);
- p2 = trans.map(p2);
- p3 = trans.map(p3);
+ if (_dirty) {
+ _dirty = false;
+ _transform = QMatrix4x4();
- qreal cross = (p1.x() - p2.x()) * (p3.y() - p2.y()) -
- (p1.y() - p2.y()) * (p3.x() - p2.x());
+ if (!isIdentity()) {
+ if (distance() != 0.)
+ _transform.translate((_axis.endX() - _axis.startX()) * distance(),
+ (_axis.endY() - _axis.startY()) * distance(),
+ (_axis.endZ()) * distance());
- Side newSide;
- if(cross > 0) {
- newSide = Back;
- } else {
- newSide = Front;
+ }
}
- if(newSide != d->current) {
- d->current = newSide;
- if (d->current==Back) {
- QSimpleCanvas::Matrix mat;
-#ifdef QFX_RENDER_OPENGL
- mat.translate(d->back->width()/2,d->back->height()/2, 0);
- if(d->back->width() && p1.x() >= p2.x())
- mat.rotate(180, 0, 1, 0);
- if(d->back->height() && p2.y() >= p3.y())
- mat.rotate(180, 1, 0, 0);
- mat.translate(-d->back->width()/2,-d->back->height()/2, 0);
-#else
- mat.translate(d->back->width()/2,d->back->height()/2);
- if(d->back->width() && p1.x() >= p2.x())
- mat.rotate(180, Qt::YAxis);
- if(d->back->height() && p2.y() >= p3.y())
- mat.rotate(180, Qt::XAxis);
- mat.translate(-d->back->width()/2,-d->back->height()/2);
+ return _transform;
+}
#endif
- d->back->setTransform(mat);
- }
- if(d->front)
- d->front->setOpacity((d->current==Front)?1.:0.);
- if(d->back)
- d->back->setOpacity((d->current==Back)?1.:0.);
- emit sideChanged();
+
+void QFxTranslation::update()
+{
+ _dirty = true;
+
+#if !defined(QFX_RENDER_OPENGL)
+ if (_axis.endZ() != 0. && distance() != 0.) {
+ qmlInfo(this) << "QTransform cannot translate along Z-axis.";
}
+#endif
+
+ QFxItem *item = qobject_cast<QFxItem *>(parent());
+ if (item)
+ item->updateTransform();
}
+/*!
+ \qmlclass Perspective
+ \brief The Perspective element specifies a perspective transformation.
+
+ A Perspective transform only affects an item when running under OpenGL; when running under software
+ rasterization it has no effect.
+*/
+
QML_DEFINE_TYPE(QFxPerspective,Perspective);
QFxPerspective::QFxPerspective(QObject *parent)
@@ -468,6 +472,10 @@ QFxPerspective::QFxPerspective(QObject *parent)
{
}
+QFxPerspective::~QFxPerspective()
+{
+}
+
#if defined(QFX_RENDER_OPENGL)
bool QFxPerspective::isIdentity() const
{
@@ -486,6 +494,33 @@ QMatrix4x4 QFxPerspective::transform() const
}
#endif
+/*!
+ \qmlproperty real Perspective::angle
+*/
+
+/*!
+ \qmlproperty real Perspective::aspect
+*/
+
+/*!
+ \qmlproperty real Perspective::x
+*/
+
+/*!
+ \qmlproperty real Perspective::y
+*/
+
+/*!
+ \qmlproperty real Perspective::scale
+*/
+
+/*!
+ \qmlclass Squish
+ \brief The Squish element allows you to distort an items appearance by 'squishing' it.
+
+ A Squish transform only affects an item when running under OpenGL; when running under software
+ rasterization it has no effect.
+*/
QML_DEFINE_TYPE(QFxSquish,Squish);
QFxSquish::QFxSquish(QObject *parent)
@@ -493,6 +528,13 @@ QFxSquish::QFxSquish(QObject *parent)
{
}
+QFxSquish::~QFxSquish()
+{
+}
+
+/*!
+ \qmlproperty real Squish::x
+*/
qreal QFxSquish::x() const
{
return p.x();
@@ -504,6 +546,9 @@ void QFxSquish::setX(qreal v)
update();
}
+/*!
+ \qmlproperty real Squish::y
+*/
qreal QFxSquish::y() const
{
return p.y();
@@ -515,6 +560,9 @@ void QFxSquish::setY(qreal v)
update();
}
+/*!
+ \qmlproperty real Squish::width
+*/
qreal QFxSquish::width() const
{
return s.width();
@@ -526,6 +574,9 @@ void QFxSquish::setWidth(qreal v)
update();
}
+/*!
+ \qmlproperty real Squish::height
+*/
qreal QFxSquish::height() const
{
return s.height();
@@ -537,6 +588,10 @@ void QFxSquish::setHeight(qreal v)
update();
}
+/*!
+ \qmlproperty real Squish::topLeftX
+ \qmlproperty real Squish::topLeftY
+*/
qreal QFxSquish::topLeft_x() const
{
return p1.x();
@@ -559,6 +614,10 @@ void QFxSquish::settopLeft_y(qreal v)
update();
}
+/*!
+ \qmlproperty real Squish::topRightX
+ \qmlproperty real Squish::topRightY
+*/
qreal QFxSquish::topRight_x() const
{
return p2.x();
@@ -581,6 +640,10 @@ void QFxSquish::settopRight_y(qreal v)
update();
}
+/*!
+ \qmlproperty real Squish::bottomLeftX
+ \qmlproperty real Squish::bottomLeftY
+*/
qreal QFxSquish::bottomLeft_x() const
{
return p3.x();
@@ -603,6 +666,10 @@ void QFxSquish::setbottomLeft_y(qreal v)
update();
}
+/*!
+ \qmlproperty real Squish::bottomRightX
+ \qmlproperty real Squish::bottomRightY
+*/
qreal QFxSquish::bottomRight_x() const
{
return p4.x();
@@ -628,7 +695,7 @@ void QFxSquish::setbottomRight_y(qreal v)
void QFxSquish::update()
{
QFxItem *item = qobject_cast<QFxItem *>(parent());
- if(item)
+ if (item)
item->updateTransform();
}
@@ -647,10 +714,11 @@ QMatrix4x4 QFxSquish::transform() const
QTransform t;
QMatrix4x4 rv;
- if(QTransform::quadToQuad(poly, poly2, t))
+ if (QTransform::quadToQuad(poly, poly2, t))
rv = QMatrix4x4(t);
return rv;
}
-QT_END_NAMESPACE
#endif
+
+QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxtransform.h b/src/declarative/fx/qfxtransform.h
index 129a4b4..8a4eab1 100644
--- a/src/declarative/fx/qfxtransform.h
+++ b/src/declarative/fx/qfxtransform.h
@@ -49,17 +49,18 @@
#endif
#include <qfxitem.h>
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+
class Q_DECLARATIVE_EXPORT QFxTransform : public QObject
{
Q_OBJECT
public:
QFxTransform(QObject *parent=0);
+ ~QFxTransform();
void update();
@@ -68,37 +69,61 @@ public:
};
QML_DECLARE_TYPE(QFxTransform);
-class Q_DECLARATIVE_EXPORT QFxAxis : public QFxTransform
+class Q_DECLARATIVE_EXPORT QFxAxis : public QObject
{
Q_OBJECT
- Q_PROPERTY(qreal xStart READ xStart WRITE setXStart)
- Q_PROPERTY(qreal yStart READ yStart WRITE setYStart)
- Q_PROPERTY(qreal xEnd READ xEnd WRITE setXEnd)
- Q_PROPERTY(qreal yEnd READ yEnd WRITE setYEnd)
- Q_PROPERTY(qreal zEnd READ zEnd WRITE setZEnd)
- Q_PROPERTY(qreal rotation READ rotation WRITE setRotation)
- Q_PROPERTY(qreal translation READ translation WRITE setTranslation)
- Q_PROPERTY(qreal distanceToPlane READ distanceToPlane WRITE setDistanceToPlane)
+ Q_PROPERTY(qreal startX READ startX WRITE setStartX)
+ Q_PROPERTY(qreal startY READ startY WRITE setStartY)
+ Q_PROPERTY(qreal endX READ endX WRITE setEndX)
+ Q_PROPERTY(qreal endY READ endY WRITE setEndY)
+ Q_PROPERTY(qreal endZ READ endZ WRITE setEndZ)
public:
QFxAxis(QObject *parent=0);
+ ~QFxAxis();
+
+ qreal startX() const;
+ void setStartX(qreal);
+
+ qreal startY() const;
+ void setStartY(qreal);
+
+ qreal endX() const;
+ void setEndX(qreal);
+
+ qreal endY() const;
+ void setEndY(qreal);
+
+ qreal endZ() const;
+ void setEndZ(qreal);
+
+Q_SIGNALS:
+ void updated();
+
+private:
+ qreal _startX;
+ qreal _startY;
+ qreal _endX;
+ qreal _endY;
+ qreal _endZ;
+};
+QML_DECLARE_TYPE(QFxAxis);
+
+class Q_DECLARATIVE_EXPORT QFxRotation : public QFxTransform
+{
+ Q_OBJECT
- qreal xStart() const;
- void setXStart(qreal);
- qreal yStart() const;
- void setYStart(qreal);
+ Q_PROPERTY(QFxAxis *axis READ axis)
+ Q_PROPERTY(qreal angle READ angle WRITE setAngle)
+ Q_PROPERTY(qreal distanceToPlane READ distanceToPlane WRITE setDistanceToPlane)
+public:
+ QFxRotation(QObject *parent=0);
+ ~QFxRotation();
- qreal xEnd() const;
- void setXEnd(qreal);
- qreal yEnd() const;
- void setYEnd(qreal);
- qreal zEnd() const;
- void setZEnd(qreal);
+ QFxAxis *axis();
- qreal rotation() const;
- void setRotation(qreal);
- qreal translation() const;
- void setTranslation(qreal);
+ qreal angle() const;
+ void setAngle(qreal);
qreal distanceToPlane() const;
void setDistanceToPlane(qreal);
@@ -106,22 +131,46 @@ public:
virtual bool isIdentity() const;
virtual QSimpleCanvas::Matrix transform() const;
-private:
+private Q_SLOTS:
void update();
-
- qreal _xStart;
- qreal _yStart;
- qreal _xEnd;
- qreal _yEnd;
- qreal _zEnd;
- qreal _rotation;
- qreal _translation;
+private:
+ QFxAxis _axis;
+ qreal _angle;
qreal _distanceToPlane;
mutable bool _dirty;
mutable QSimpleCanvas::Matrix _transform;
};
-QML_DECLARE_TYPE(QFxAxis);
+QML_DECLARE_TYPE(QFxRotation);
+
+class Q_DECLARATIVE_EXPORT QFxTranslation : public QFxTransform
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QFxAxis *axis READ axis)
+ Q_PROPERTY(qreal distance READ distance WRITE setDistance)
+public:
+ QFxTranslation(QObject *parent=0);
+ ~QFxTranslation();
+
+ QFxAxis *axis();
+
+ qreal distance() const;
+ void setDistance(qreal);
+
+ virtual bool isIdentity() const;
+ virtual QSimpleCanvas::Matrix transform() const;
+
+private Q_SLOTS:
+ void update();
+private:
+ QFxAxis _axis;
+ qreal _distance;
+
+ mutable bool _dirty;
+ mutable QSimpleCanvas::Matrix _transform;
+};
+QML_DECLARE_TYPE(QFxTranslation);
class Q_DECLARATIVE_EXPORT QFxPerspective : public QFxTransform
{
@@ -134,6 +183,7 @@ class Q_DECLARATIVE_EXPORT QFxPerspective : public QFxTransform
Q_PROPERTY(qreal scale READ scale WRITE setScale)
public:
QFxPerspective(QObject *parent=0);
+ ~QFxPerspective();
qreal angle() const { return _angle; }
void setAngle(qreal v) { _angle = v; update(); }
@@ -171,16 +221,17 @@ class Q_DECLARATIVE_EXPORT QFxSquish : public QFxTransform
Q_PROPERTY(qreal y READ y WRITE setY)
Q_PROPERTY(qreal width READ width WRITE setWidth)
Q_PROPERTY(qreal height READ height WRITE setHeight)
- Q_PROPERTY(qreal topLeft_x READ topLeft_x WRITE settopLeft_x)
- Q_PROPERTY(qreal topLeft_y READ topLeft_y WRITE settopLeft_y)
- Q_PROPERTY(qreal topRight_x READ topRight_x WRITE settopRight_x)
- Q_PROPERTY(qreal topRight_y READ topRight_y WRITE settopRight_y)
- Q_PROPERTY(qreal bottomLeft_x READ bottomLeft_x WRITE setbottomLeft_x)
- Q_PROPERTY(qreal bottomLeft_y READ bottomLeft_y WRITE setbottomLeft_y)
- Q_PROPERTY(qreal bottomRight_y READ bottomRight_y WRITE setbottomRight_y)
- Q_PROPERTY(qreal bottomRight_x READ bottomRight_x WRITE setbottomRight_x)
+ Q_PROPERTY(qreal topLeftX READ topLeft_x WRITE settopLeft_x)
+ Q_PROPERTY(qreal topLeftY READ topLeft_y WRITE settopLeft_y)
+ Q_PROPERTY(qreal topRightX READ topRight_x WRITE settopRight_x)
+ Q_PROPERTY(qreal topRightY READ topRight_y WRITE settopRight_y)
+ Q_PROPERTY(qreal bottomLeftX READ bottomLeft_x WRITE setbottomLeft_x)
+ Q_PROPERTY(qreal bottomLeftY READ bottomLeft_y WRITE setbottomLeft_y)
+ Q_PROPERTY(qreal bottomRightX READ bottomRight_x WRITE setbottomRight_x)
+ Q_PROPERTY(qreal bottomRightY READ bottomRight_y WRITE setbottomRight_y)
public:
QFxSquish(QObject *parent=0);
+ ~QFxSquish();
qreal x() const;
void setX(qreal);
@@ -230,45 +281,10 @@ private:
QSizeF s;
QPointF p1, p2, p3, p4;
};
-
QML_DECLARE_TYPE(QFxSquish);
-class QFxFlipablePrivate;
-class Q_DECLARATIVE_EXPORT QFxFlipable : public QFxItem
-{
- Q_OBJECT
-
- Q_ENUMS(Side);
- Q_PROPERTY(QFxItem *front READ front WRITE setFront)
- Q_PROPERTY(QFxItem *back READ back WRITE setBack)
- Q_PROPERTY(Side side READ side NOTIFY sideChanged)
-public:
- QFxFlipable(QFxItem *parent=0);
- ~QFxFlipable();
-
- QFxItem *front();
- void setFront(QFxItem *);
-
- QFxItem *back();
- void setBack(QFxItem *);
-
- enum Side { Front, Back };
- Side side() const;
-
-protected:
- virtual void transformChanged(const QSimpleCanvas::Matrix &);
-
-Q_SIGNALS:
- void sideChanged();
-
-private:
- Q_DISABLE_COPY(QFxFlipable)
- Q_DECLARE_PRIVATE(QFxFlipable)
-};
-QML_DECLARE_TYPE(QFxFlipable);
-
-
QT_END_NAMESPACE
QT_END_HEADER
-#endif // _TRANSFORM_H_
+
+#endif // QFXTRANSFORM_H
diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp
index e851bad..7d0d7a5 100644
--- a/src/declarative/fx/qfxvisualitemmodel.cpp
+++ b/src/declarative/fx/qfxvisualitemmodel.cpp
@@ -85,13 +85,13 @@ public:
QmlListAccessor *m_modelList;
int modelCount() const {
- if(m_visualItemModel)
+ if (m_visualItemModel)
return m_visualItemModel->count();
- if(m_listModelInterface)
+ if (m_listModelInterface)
return m_listModelInterface->count();
- if(m_abstractItemModel)
+ if (m_abstractItemModel)
return m_abstractItemModel->rowCount();
- if(m_modelList)
+ if (m_modelList)
return m_modelList->count();
return 0;
}
@@ -162,10 +162,10 @@ int QFxVisualItemModelDataMetaObject::createProperty(const char *name, const cha
return QmlOpenMetaObject::createProperty(name, type);
} else {
const QLatin1String sname(name);
- for(QHash<int, QString>::ConstIterator iter = data->m_model->m_roleNames.begin();
+ for (QHash<int, QString>::ConstIterator iter = data->m_model->m_roleNames.begin();
iter != data->m_model->m_roleNames.end(); ++iter) {
- if(*iter == sname)
+ if (*iter == sname)
return QmlOpenMetaObject::createProperty(name, type);
}
}
@@ -184,10 +184,10 @@ QFxVisualItemModelDataMetaObject::propertyCreated(int, QMetaPropertyBuilder &pro
&& data->m_model->m_modelList) {
return data->m_model->m_modelList->at(data->m_index);
} else if (data->m_model->m_listModelInterface) {
- for(QHash<int, QString>::ConstIterator iter = data->m_model->m_roleNames.begin();
+ for (QHash<int, QString>::ConstIterator iter = data->m_model->m_roleNames.begin();
iter != data->m_model->m_roleNames.end(); ++iter) {
- if(*iter == name) {
+ if (*iter == name) {
roles.append(iter.key());
QHash<int,QVariant> values = data->m_model->m_listModelInterface->data(data->m_index, QList<int>() << iter.key());
if (values.isEmpty())
@@ -197,10 +197,10 @@ QFxVisualItemModelDataMetaObject::propertyCreated(int, QMetaPropertyBuilder &pro
}
}
} else if (data->m_model->m_abstractItemModel) {
- for(QHash<int, QString>::ConstIterator iter = data->m_model->m_roleNames.begin();
+ for (QHash<int, QString>::ConstIterator iter = data->m_model->m_roleNames.begin();
iter != data->m_model->m_roleNames.end(); ++iter) {
- if(*iter == name) {
+ if (*iter == name) {
roles.append(iter.key());
QModelIndex index = data->m_model->m_abstractItemModel->index(data->m_index, 0);
return data->m_model->m_abstractItemModel->data(index, iter.key());
@@ -297,7 +297,7 @@ QFxVisualItemModel::QFxVisualItemModel(QmlContext *ctxt)
QFxVisualItemModel::~QFxVisualItemModel()
{
Q_D(QFxVisualItemModel);
- if(d->m_modelList)
+ if (d->m_modelList)
delete d->m_modelList;
}
@@ -311,7 +311,7 @@ void QFxVisualItemModel::setModel(const QVariant &model)
{
Q_D(QFxVisualItemModel);
d->m_modelVariant = model;
- if(d->m_listModelInterface) {
+ if (d->m_listModelInterface) {
// Assume caller has released all items.
QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsChanged(int,int,QList<int>)),
this, SLOT(_q_itemsChanged(int,int,QList<int>)));
@@ -329,7 +329,7 @@ void QFxVisualItemModel::setModel(const QVariant &model)
this, SLOT(_q_rowsRemoved(const QModelIndex &,int,int)));
QObject::disconnect(d->m_abstractItemModel, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)),
this, SLOT(_q_dataChanged(const QModelIndex&,const QModelIndex&)));
- } else if(d->m_visualItemModel) {
+ } else if (d->m_visualItemModel) {
QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsInserted(int,int)),
this, SIGNAL(itemsInserted(int,int)));
QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsRemoved(int,int)),
@@ -343,9 +343,9 @@ void QFxVisualItemModel::setModel(const QVariant &model)
if (object && (d->m_listModelInterface = qobject_cast<QListModelInterface *>(object))) {
d->m_roles.clear();
d->m_roleNames.clear();
- if(d->m_listModelInterface) {
+ if (d->m_listModelInterface) {
d->m_roles = d->m_listModelInterface->roles();
- for(int ii = 0; ii < d->m_roles.count(); ++ii)
+ for (int ii = 0; ii < d->m_roles.count(); ++ii)
d->m_roleNames.insert(d->m_roles.at(ii),
d->m_listModelInterface->toString(d->m_roles.at(ii)));
}
@@ -359,7 +359,7 @@ void QFxVisualItemModel::setModel(const QVariant &model)
QObject::connect(d->m_listModelInterface, SIGNAL(itemsMoved(int,int,int)),
this, SLOT(_q_itemsMoved(int,int,int)));
- if(d->m_delegate && d->m_listModelInterface->count())
+ if (d->m_delegate && d->m_listModelInterface->count())
emit itemsInserted(0, d->m_listModelInterface->count());
return;
} else if (object && (d->m_abstractItemModel = qobject_cast<QAbstractItemModel *>(object))) {
@@ -390,7 +390,7 @@ void QFxVisualItemModel::setModel(const QVariant &model)
if (!d->m_modelList)
d->m_modelList = new QmlListAccessor;
d->m_modelList->setList(model);
- if(d->m_delegate && d->modelCount())
+ if (d->m_delegate && d->modelCount())
emit itemsInserted(0, d->modelCount());
}
@@ -405,7 +405,7 @@ void QFxVisualItemModel::setDelegate(QmlComponent *delegate)
Q_D(QFxVisualItemModel);
d->m_delegate = delegate;
- if(d->modelCount())
+ if (d->modelCount())
emit itemsInserted(0, d->modelCount());
}
@@ -430,7 +430,7 @@ int QFxVisualItemModel::count() const
QFxItem *QFxVisualItemModel::item(int index, bool complete)
{
Q_D(QFxVisualItemModel);
- if(d->m_visualItemModel)
+ if (d->m_visualItemModel)
return d->m_visualItemModel->item(index, d->m_part.toLatin1(), complete);
return item(index, QByteArray(), complete);
}
@@ -471,7 +471,7 @@ void QFxVisualItemModel::release(QFxItem *item)
QObject *QFxVisualItemModel::parts()
{
Q_D(QFxVisualItemModel);
- if(!d->m_parts)
+ if (!d->m_parts)
d->m_parts = new QFxVisualItemModelParts(this);
return d->m_parts;
}
@@ -479,18 +479,18 @@ QObject *QFxVisualItemModel::parts()
QFxItem *QFxVisualItemModel::item(int index, const QByteArray &viewId, bool complete)
{
Q_D(QFxVisualItemModel);
- if(d->m_visualItemModel)
+ if (d->m_visualItemModel)
return d->m_visualItemModel->item(index, viewId, complete);
- if(d->modelCount() <= 0 || !d->m_delegate)
+ if (d->modelCount() <= 0 || !d->m_delegate)
return 0;
QObject *nobj = 0;
- if(d->m_cache.contains(index)) {
+ if (d->m_cache.contains(index)) {
nobj = d->m_cache[index];
} else {
QmlContext *ccontext = d->m_context;
- if(!ccontext) ccontext = qmlContext(this);
+ if (!ccontext) ccontext = qmlContext(this);
QmlContext *ctxt = new QmlContext(ccontext);
QFxVisualItemModelData *data = new QFxVisualItemModelData(index, d);
ctxt->setContextProperty(QLatin1String("model"), data);
@@ -507,7 +507,7 @@ QFxItem *QFxVisualItemModel::item(int index, const QByteArray &viewId, bool comp
QFxItem *item = qobject_cast<QFxItem *>(nobj);
if (!item) {
QmlPackage *package = qobject_cast<QmlPackage *>(nobj);
- if(package) {
+ if (package) {
QObject *o = package->part(QLatin1String(viewId));
item = qobject_cast<QFxItem *>(o);
d->m_packaged[o] = package;
@@ -520,7 +520,7 @@ QFxItem *QFxVisualItemModel::item(int index, const QByteArray &viewId, bool comp
void QFxVisualItemModel::completeItem()
{
Q_D(QFxVisualItemModel);
- if(d->m_visualItemModel) {
+ if (d->m_visualItemModel) {
d->m_visualItemModel->completeItem();
return;
}
@@ -534,11 +534,11 @@ QVariant QFxVisualItemModel::evaluate(int index, const QString &expression, QObj
if (d->m_visualItemModel)
return d->m_visualItemModel->evaluate(index, expression, objectContext);
- if((!d->m_listModelInterface && !d->m_abstractItemModel) || !d->m_delegate)
+ if ((!d->m_listModelInterface && !d->m_abstractItemModel) || !d->m_delegate)
return QVariant();
QVariant value;
- if(d->m_cache.contains(index)) {
+ if (d->m_cache.contains(index)) {
QObject *nobj = d->m_cache[index];
QFxItem *item = qobject_cast<QFxItem *>(nobj);
if (item) {
@@ -548,7 +548,7 @@ QVariant QFxVisualItemModel::evaluate(int index, const QString &expression, QObj
}
} else {
QmlContext *ccontext = d->m_context;
- if(!ccontext) ccontext = qmlContext(this);
+ if (!ccontext) ccontext = qmlContext(this);
QmlContext *ctxt = new QmlContext(ccontext);
QFxVisualItemModelData *data = new QFxVisualItemModelData(index, d);
ctxt->addDefaultObject(data);
@@ -567,17 +567,17 @@ void QFxVisualItemModel::_q_itemsChanged(int index, int count,
{
Q_D(QFxVisualItemModel);
// XXX - highly inefficient
- for(int ii = index; ii < index + count; ++ii) {
+ for (int ii = index; ii < index + count; ++ii) {
- if(d->m_cache.contains(ii)) {
+ if (d->m_cache.contains(ii)) {
QObject *item = d->m_cache[ii];
QFxVisualItemModelData *data = d->data(item);
- for(int prop = 0; prop < data->count(); ++prop) {
+ for (int prop = 0; prop < data->count(); ++prop) {
int role = data->role(prop);
- if(roles.contains(role)) {
+ if (roles.contains(role)) {
if (d->m_listModelInterface) {
data->setValue(prop, *d->m_listModelInterface->data(ii, QList<int>() << role).begin());
} else if (d->m_abstractItemModel) {
@@ -596,10 +596,10 @@ void QFxVisualItemModel::_q_itemsInserted(int index, int count)
Q_D(QFxVisualItemModel);
// XXX - highly inefficient
QHash<int, QObject *> items;
- for(QHash<int, QObject *>::Iterator iter = d->m_cache.begin();
+ for (QHash<int, QObject *>::Iterator iter = d->m_cache.begin();
iter != d->m_cache.end(); ) {
- if(iter.key() >= index) {
+ if (iter.key() >= index) {
QObject *item = *iter;
int index = iter.key() + count;
iter = d->m_cache.erase(iter);
@@ -622,15 +622,15 @@ void QFxVisualItemModel::_q_itemsRemoved(int index, int count)
Q_D(QFxVisualItemModel);
// XXX - highly inefficient
QHash<int, QObject *> items;
- for(QHash<int, QObject *>::Iterator iter = d->m_cache.begin();
+ for (QHash<int, QObject *>::Iterator iter = d->m_cache.begin();
iter != d->m_cache.end(); ) {
- if(iter.key() >= index && iter.key() < index + count) {
+ if (iter.key() >= index && iter.key() < index + count) {
QObject *item = *iter;
iter = d->m_cache.erase(iter);
items.insertMulti(-1, item); //XXX perhaps better to maintain separately
QFxVisualItemModelData *data = d->data(item);
data->setIndex(-1);
- } else if(iter.key() >= index + count) {
+ } else if (iter.key() >= index + count) {
QObject *item = *iter;
int index = iter.key() - count;
iter = d->m_cache.erase(iter);
@@ -651,10 +651,10 @@ void QFxVisualItemModel::_q_itemsMoved(int from, int to, int count)
Q_D(QFxVisualItemModel);
// XXX - highly inefficient
QHash<int, QObject *> items;
- for(QHash<int, QObject *>::Iterator iter = d->m_cache.begin();
+ for (QHash<int, QObject *>::Iterator iter = d->m_cache.begin();
iter != d->m_cache.end(); ) {
- if(iter.key() >= from && iter.key() < from + count) {
+ if (iter.key() >= from && iter.key() < from + count) {
QObject *item = *iter;
int index = iter.key() - from + to;
iter = d->m_cache.erase(iter);
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index 8af4158..b2ad06c 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -361,7 +361,7 @@ QString QFxWebView::url() const
void QFxWebView::setUrl(const QString &n)
{
Q_D(QFxWebView);
- if(n == page()->mainFrame()->url().toString())
+ if (n == page()->mainFrame()->url().toString())
return;
page()->setViewportSize(QSize(
@@ -399,7 +399,7 @@ int QFxWebView::idealWidth() const
void QFxWebView::setIdealWidth(int iw)
{
Q_D(QFxWebView);
- if(d->idealwidth == iw) return;
+ if (d->idealwidth == iw) return;
d->idealwidth = iw;
expandToWebPage();
emit idealWidthChanged();
@@ -422,7 +422,7 @@ int QFxWebView::idealHeight() const
void QFxWebView::setIdealHeight(int ih)
{
Q_D(QFxWebView);
- if(d->idealheight == ih) return;
+ if (d->idealheight == ih) return;
d->idealheight = ih;
expandToWebPage();
emit idealHeightChanged();
@@ -449,7 +449,7 @@ bool QFxWebView::interactive() const
void QFxWebView::setInteractive(bool i)
{
Q_D(QFxWebView);
- if(d->interactive == i) return;
+ if (d->interactive == i) return;
d->interactive = i;
emit interactiveChanged();
}
@@ -471,7 +471,7 @@ bool QFxWebView::smooth() const
void QFxWebView::setSmooth(bool i)
{
Q_D(QFxWebView);
- if(d->smooth == i) return;
+ if (d->smooth == i) return;
d->smooth = i;
update();
}
@@ -506,7 +506,7 @@ void QFxWebView::expandToWebPage()
void QFxWebView::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
{
- if(newGeometry.size() != oldGeometry.size())
+ if (newGeometry.size() != oldGeometry.size())
expandToWebPage();
QFxItem::geometryChanged(newGeometry, oldGeometry);
}
diff --git a/src/declarative/fx/qfxwidgetcontainer.cpp b/src/declarative/fx/qfxwidgetcontainer.cpp
index f86c8dc..fccdad1 100644
--- a/src/declarative/fx/qfxwidgetcontainer.cpp
+++ b/src/declarative/fx/qfxwidgetcontainer.cpp
@@ -78,16 +78,16 @@ QGraphicsWidget *QFxWidgetContainer::graphicsWidget() const
*/
void QFxWidgetContainer::setGraphicsWidget(QGraphicsWidget *widget)
{
- if(widget == _graphicsWidget)
+ if (widget == _graphicsWidget)
return;
_graphicsWidget = widget;
QSimpleCanvas *c = canvas();
- if(!c)
+ if (!c)
return;
- if(c->canvasMode() != QSimpleCanvas::GraphicsView) {
+ if (c->canvasMode() != QSimpleCanvas::GraphicsView) {
qWarning("QFxWidgetContainer: Cannot add a widget to a non-graphicsview canvas. You might need to set QFX_USE_GRAPHICSVIEW=1");
return;
}
@@ -98,7 +98,7 @@ void QFxWidgetContainer::setGraphicsWidget(QGraphicsWidget *widget)
void QFxWidgetContainer::canvasChanged()
{
- if(_graphicsWidget) {
+ if (_graphicsWidget) {
QGraphicsWidget *w = _graphicsWidget;
_graphicsWidget = 0;
setGraphicsWidget(w);