summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-02-23 05:41:25 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2010-02-23 07:34:07 (GMT)
commit23fb8f6e4f3f6fe4ae7611de84f09cc0095e240c (patch)
tree1a750425c167e2184c565345ff76886ab1871d8c /src/declarative
parentcb3cd645082bda7b5142ceff31e5795f2d047c39 (diff)
downloadQt-23fb8f6e4f3f6fe4ae7611de84f09cc0095e240c.zip
Qt-23fb8f6e4f3f6fe4ae7611de84f09cc0095e240c.tar.gz
Qt-23fb8f6e4f3f6fe4ae7611de84f09cc0095e240c.tar.bz2
Add missing NOTIFY signals to positioners, particles and webview
Reviewed-by: Aaron Kennedy
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsparticles.cpp67
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsparticles_p.h55
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners.cpp27
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners_p.h19
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview.cpp20
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview_p.h15
6 files changed, 161 insertions, 42 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
index 08fce74..e23f6f0 100644
--- a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
@@ -188,13 +188,13 @@ void QmlGraphicsParticleMotionLinear::advance(QmlGraphicsParticle &p, int interv
*/
/*!
- \qmlproperty int ParticleMotionGravity::xattractor
- \qmlproperty int ParticleMotionGravity::yattractor
+ \qmlproperty qreal ParticleMotionGravity::xattractor
+ \qmlproperty qreal ParticleMotionGravity::yattractor
These properties hold the x and y coordinates of the point attracting the particles.
*/
/*!
- \qmlproperty int ParticleMotionGravity::acceleration
+ \qmlproperty qreal ParticleMotionGravity::acceleration
This property holds the acceleration to apply to the particles.
*/
@@ -213,6 +213,31 @@ void QmlGraphicsParticleMotionLinear::advance(QmlGraphicsParticle &p, int interv
\brief the acceleration to apply to the particles.
*/
+void QmlGraphicsParticleMotionGravity::setXAttractor(qreal x)
+{
+ if (qFuzzyCompare(x, _xAttr))
+ return;
+ _xAttr = x;
+ emit xattractorChanged();
+}
+
+void QmlGraphicsParticleMotionGravity::setYAttractor(qreal y)
+{
+ if (qFuzzyCompare(y, _yAttr))
+ return;
+ _yAttr = y;
+ emit yattractorChanged();
+}
+
+void QmlGraphicsParticleMotionGravity::setAcceleration(qreal accel)
+{
+ qreal scaledAccel = accel/1000000.0;
+ if (qFuzzyCompare(scaledAccel, _accel))
+ return;
+ _accel = scaledAccel;
+ emit accelerationChanged();
+}
+
void QmlGraphicsParticleMotionGravity::advance(QmlGraphicsParticle &p, int interval)
{
qreal xdiff = p.x - _xAttr;
@@ -276,14 +301,14 @@ Rectangle {
*/
/*!
- \qmlproperty int QmlGraphicsParticleMotionWander::xvariance
- \qmlproperty int QmlGraphicsParticleMotionWander::yvariance
+ \qmlproperty qreal QmlGraphicsParticleMotionWander::xvariance
+ \qmlproperty qreal QmlGraphicsParticleMotionWander::yvariance
These properties set the amount to wander in the x and y directions.
*/
/*!
- \qmlproperty int QmlGraphicsParticleMotionWander::pace
+ \qmlproperty qreal QmlGraphicsParticleMotionWander::pace
This property holds how quickly the paricles will move from side to side.
*/
@@ -335,6 +360,33 @@ void QmlGraphicsParticleMotionWander::destroy(QmlGraphicsParticle &p)
delete (Data*)p.data;
}
+void QmlGraphicsParticleMotionWander::setXVariance(qreal var)
+{
+ qreal scaledVar = var / 1000.0;
+ if (qFuzzyCompare(scaledVar, _xvariance))
+ return;
+ _xvariance = scaledVar;
+ emit xvarianceChanged();
+}
+
+void QmlGraphicsParticleMotionWander::setYVariance(qreal var)
+{
+ qreal scaledVar = var / 1000.0;
+ if (qFuzzyCompare(scaledVar, _yvariance))
+ return;
+ _yvariance = scaledVar;
+ emit yvarianceChanged();
+}
+
+void QmlGraphicsParticleMotionWander::setPace(qreal pace)
+{
+ qreal scaledPace = pace / 1000.0;
+ if (qFuzzyCompare(scaledPace, _pace))
+ return;
+ _pace = scaledPace;
+ emit paceChanged();
+}
+
//---------------------------------------------------------------------------
class QmlGraphicsParticlesPainter : public QmlGraphicsItem
{
@@ -1125,7 +1177,10 @@ QmlGraphicsParticleMotion *QmlGraphicsParticles::motion() const
void QmlGraphicsParticles::setMotion(QmlGraphicsParticleMotion *motion)
{
Q_D(QmlGraphicsParticles);
+ if (motion == d->motion)
+ return;
d->motion = motion;
+ emit motionChanged();
}
/*!
diff --git a/src/declarative/graphicsitems/qmlgraphicsparticles_p.h b/src/declarative/graphicsitems/qmlgraphicsparticles_p.h
index 7f0f9cd..8e66335 100644
--- a/src/declarative/graphicsitems/qmlgraphicsparticles_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsparticles_p.h
@@ -77,27 +77,32 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsParticleMotionGravity : public QmlGraphics
{
Q_OBJECT
- Q_PROPERTY(int xattractor READ xAttractor WRITE setXAttractor)
- Q_PROPERTY(int yattractor READ yAttractor WRITE setYAttractor)
- Q_PROPERTY(int acceleration READ acceleration WRITE setAcceleration)
+ Q_PROPERTY(qreal xattractor READ xAttractor WRITE setXAttractor NOTIFY xattractorChanged)
+ Q_PROPERTY(qreal yattractor READ yAttractor WRITE setYAttractor NOTIFY yattractorChanged)
+ Q_PROPERTY(qreal acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged)
public:
QmlGraphicsParticleMotionGravity(QObject *parent=0)
- : QmlGraphicsParticleMotion(parent), _xAttr(0), _yAttr(0), _accel(0.00005) {}
+ : QmlGraphicsParticleMotion(parent), _xAttr(0.0), _yAttr(0.0), _accel(0.00005) {}
- int xAttractor() const { return _xAttr; }
- void setXAttractor(int x) { _xAttr = x; }
+ qreal xAttractor() const { return _xAttr; }
+ void setXAttractor(qreal x);
- int yAttractor() const { return _yAttr; }
- void setYAttractor(int y) { _yAttr = y; }
+ qreal yAttractor() const { return _yAttr; }
+ void setYAttractor(qreal y);
- int acceleration() const { return int(_accel * 1000000); }
- void setAcceleration(int accel) { _accel = qreal(accel)/1000000.0; }
+ qreal acceleration() const { return _accel * 1000000; }
+ void setAcceleration(qreal accel);
virtual void advance(QmlGraphicsParticle &, int interval);
+Q_SIGNALS:
+ void xattractorChanged();
+ void yattractorChanged();
+ void accelerationChanged();
+
private:
- int _xAttr;
- int _yAttr;
+ qreal _xAttr;
+ qreal _yAttr;
qreal _accel;
};
@@ -121,18 +126,23 @@ public:
qreal y_var;
};
- Q_PROPERTY(int xvariance READ xVariance WRITE setXVariance)
- int xVariance() const { return int(_xvariance * 1000); }
- void setXVariance(int var) { _xvariance = var / 1000.0; }
+ Q_PROPERTY(qreal xvariance READ xVariance WRITE setXVariance NOTIFY xvarianceChanged)
+ qreal xVariance() const { return _xvariance * 1000.0; }
+ void setXVariance(qreal var);
- Q_PROPERTY(int yvariance READ yVariance WRITE setYVariance)
- int yVariance() const { return int(_yvariance * 1000); }
- void setYVariance(int var) { _yvariance = var / 1000.0; }
+ Q_PROPERTY(qreal yvariance READ yVariance WRITE setYVariance NOTIFY yvarianceChanged)
+ qreal yVariance() const { return _yvariance * 1000.0; }
+ void setYVariance(qreal var);
- Q_PROPERTY(int pace READ pace WRITE setPace)
- int pace() const { return int(_pace * 1000); }
- void setPace(int pace) { _pace = pace / 1000.0; }
+ Q_PROPERTY(qreal pace READ pace WRITE setPace NOTIFY paceChanged)
+ qreal pace() const { return _pace * 1000.0; }
+ void setPace(qreal pace);
+Q_SIGNALS:
+ void xvarianceChanged();
+ void yvarianceChanged();
+ void paceChanged();
+
private:
QmlGraphicsParticles *particles;
qreal _xvariance;
@@ -157,7 +167,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsParticles : public QmlGraphicsItem
Q_PROPERTY(qreal angleDeviation READ angleDeviation WRITE setAngleDeviation NOTIFY angleDeviationChanged)
Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged)
Q_PROPERTY(qreal velocityDeviation READ velocityDeviation WRITE setVelocityDeviation NOTIFY velocityDeviationChanged)
- Q_PROPERTY(QmlGraphicsParticleMotion *motion READ motion WRITE setMotion)
+ Q_PROPERTY(QmlGraphicsParticleMotion *motion READ motion WRITE setMotion NOTIFY motionChanged)
Q_CLASSINFO("DefaultProperty", "motion")
public:
@@ -225,6 +235,7 @@ Q_SIGNALS:
void velocityChanged();
void velocityDeviationChanged();
void emittingChanged();
+ void motionChanged();
private Q_SLOTS:
void imageLoaded();
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
index 8adf239..805c912 100644
--- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
@@ -138,7 +138,10 @@ QmlTransition *QmlGraphicsBasePositioner::move() const
void QmlGraphicsBasePositioner::setMove(QmlTransition *mt)
{
Q_D(QmlGraphicsBasePositioner);
+ if (mt == d->moveTransition)
+ return;
d->moveTransition = mt;
+ emit moveChanged();
}
QmlTransition *QmlGraphicsBasePositioner::add() const
@@ -150,7 +153,11 @@ QmlTransition *QmlGraphicsBasePositioner::add() const
void QmlGraphicsBasePositioner::setAdd(QmlTransition *add)
{
Q_D(QmlGraphicsBasePositioner);
+ if (add == d->addTransition)
+ return;
+
d->addTransition = add;
+ emit addChanged();
}
void QmlGraphicsBasePositioner::componentComplete()
@@ -362,7 +369,7 @@ Column {
move: Transition {
NumberAnimation {
properties: "y"
- ease: "easeOutBounce"
+ easing: "easeOutBounce"
}
}
}
@@ -647,6 +654,24 @@ QmlGraphicsGrid::QmlGraphicsGrid(QmlGraphicsItem *parent) :
many rows some rows will be of zero width.
*/
+void QmlGraphicsGrid::setColumns(const int columns)
+{
+ if (columns == _columns)
+ return;
+ _columns = columns;
+ prePositioning();
+ emit columnsChanged();
+}
+
+void QmlGraphicsGrid::setRows(const int rows)
+{
+ if (rows == _rows)
+ return;
+ _rows = rows;
+ prePositioning();
+ emit rowsChanged();
+}
+
void QmlGraphicsGrid::doPositioning()
{
int c=_columns,r=_rows;//Actual number of rows/columns
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners_p.h b/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
index 1fb687a..2f905e5 100644
--- a/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
@@ -62,8 +62,8 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsBasePositioner : public QmlGraphicsItem
Q_OBJECT
Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
- Q_PROPERTY(QmlTransition *move READ move WRITE setMove)
- Q_PROPERTY(QmlTransition *add READ add WRITE setAdd)
+ Q_PROPERTY(QmlTransition *move READ move WRITE setMove NOTIFY moveChanged)
+ Q_PROPERTY(QmlTransition *add READ add WRITE setAdd NOTIFY addChanged)
public:
enum PositionerType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 };
QmlGraphicsBasePositioner(PositionerType, QmlGraphicsItem *parent);
@@ -86,6 +86,8 @@ protected:
Q_SIGNALS:
void spacingChanged();
+ void moveChanged();
+ void addChanged();
protected Q_SLOTS:
virtual void doPositioning()=0;
@@ -134,16 +136,21 @@ private:
class Q_DECLARATIVE_EXPORT QmlGraphicsGrid : public QmlGraphicsBasePositioner
{
Q_OBJECT
- Q_PROPERTY(int rows READ rows WRITE setRows)
- Q_PROPERTY(int columns READ columns WRITE setcolumns)
+ Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowChanged)
+ Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged)
public:
QmlGraphicsGrid(QmlGraphicsItem *parent=0);
int rows() const {return _rows;}
- void setRows(const int rows){_rows = rows;}
+ void setRows(const int rows);
int columns() const {return _columns;}
- void setcolumns(const int columns){_columns = columns;}
+ void setColumns(const int columns);
+
+Q_SIGNALS:
+ void rowsChanged();
+ void columnsChanged();
+
protected Q_SLOTS:
virtual void doPositioning();
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp
index 0c21f75..f9bbb22 100644
--- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp
@@ -483,6 +483,8 @@ void QmlGraphicsWebView::setRenderingEnabled(bool enabled)
if (d->rendering == enabled)
return;
d->rendering = enabled;
+ emit renderingEnabledChanged();
+
setCacheFrozen(!enabled);
if (enabled)
clearCache();
@@ -596,7 +598,10 @@ int QmlGraphicsWebView::pressGrabTime() const
void QmlGraphicsWebView::setPressGrabTime(int ms)
{
Q_D(QmlGraphicsWebView);
+ if (d->pressTime == ms)
+ return;
d->pressTime = ms;
+ emit pressGrabTimeChanged();
}
void QmlGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
@@ -1024,6 +1029,7 @@ void QmlGraphicsWebView::setHtml(const QString &html, const QUrl &baseUrl)
d->pending_url = baseUrl;
d->pending_string = html;
}
+ emit htmlChanged();
}
void QmlGraphicsWebView::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
@@ -1116,8 +1122,10 @@ QmlComponent *QmlGraphicsWebView::newWindowComponent() const
void QmlGraphicsWebView::setNewWindowComponent(QmlComponent *newWindow)
{
Q_D(QmlGraphicsWebView);
- delete d->newWindowComponent;
+ if (newWindow == d->newWindowComponent)
+ return;
d->newWindowComponent = newWindow;
+ emit newWindowComponentChanged();
}
@@ -1137,8 +1145,16 @@ QmlGraphicsItem *QmlGraphicsWebView::newWindowParent() const
void QmlGraphicsWebView::setNewWindowParent(QmlGraphicsItem *parent)
{
Q_D(QmlGraphicsWebView);
- delete d->newWindowParent;
+ if (parent == d->newWindowParent)
+ return;
+ if (d->newWindowParent && parent) {
+ QList<QGraphicsItem *> children = d->newWindowParent->childItems();
+ for (int i = 0; i < children.count(); ++i) {
+ children.at(i)->setParentItem(parent);
+ }
+ }
d->newWindowParent = parent;
+ emit newWindowParentChanged();
}
/*!
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h
index 30ba0e4..ca63be9 100644
--- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicswebview_p.h
@@ -97,9 +97,9 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsWebView : public QmlGraphicsPaintedItem
Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged)
Q_PROPERTY(QString statusText READ statusText NOTIFY statusTextChanged)
- Q_PROPERTY(QString html READ html WRITE setHtml)
+ Q_PROPERTY(QString html READ html WRITE setHtml NOTIFY htmlChanged)
- Q_PROPERTY(int pressGrabTime READ pressGrabTime WRITE setPressGrabTime)
+ Q_PROPERTY(int pressGrabTime READ pressGrabTime WRITE setPressGrabTime NOTIFY pressGrabTimeChanged)
Q_PROPERTY(int preferredWidth READ preferredWidth WRITE setPreferredWidth NOTIFY preferredWidthChanged)
Q_PROPERTY(int preferredHeight READ preferredHeight WRITE setPreferredHeight NOTIFY preferredHeightChanged)
@@ -116,10 +116,10 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsWebView : public QmlGraphicsPaintedItem
Q_PROPERTY(QmlListProperty<QObject> javaScriptWindowObjects READ javaScriptWindowObjects CONSTANT)
- Q_PROPERTY(QmlComponent* newWindowComponent READ newWindowComponent WRITE setNewWindowComponent)
- Q_PROPERTY(QmlGraphicsItem* newWindowParent READ newWindowParent WRITE setNewWindowParent)
+ Q_PROPERTY(QmlComponent* newWindowComponent READ newWindowComponent WRITE setNewWindowComponent NOTIFY newWindowComponentChanged)
+ Q_PROPERTY(QmlGraphicsItem* newWindowParent READ newWindowParent WRITE setNewWindowParent NOTIFY newWindowParentChanged)
- Q_PROPERTY(bool renderingEnabled READ renderingEnabled WRITE setRenderingEnabled)
+ Q_PROPERTY(bool renderingEnabled READ renderingEnabled WRITE setRenderingEnabled NOTIFY renderingEnabledChanged)
public:
QmlGraphicsWebView(QmlGraphicsItem *parent=0);
@@ -192,7 +192,12 @@ Q_SIGNALS:
void titleChanged(const QString&);
void iconChanged();
void statusTextChanged();
+ void htmlChanged();
+ void pressGrabTimeChanged();
void zoomFactorChanged();
+ void newWindowComponentChanged();
+ void newWindowParentChanged();
+ void renderingEnabledChanged();
void loadStarted();
void loadFinished();