summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-02-23 23:31:31 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-02-23 23:31:31 (GMT)
commitec7ac34b4a6b1a330460838acc74a53d29f62a7c (patch)
tree5505189d15ce0a1f3b67f4cd65e4c39766080a1d /src/declarative/graphicsitems
parent8727985d81c793d52d5e24ed6815e7237ae879f1 (diff)
parentd19f691a5646725c69b232e2adde8c2f961eb571 (diff)
downloadQt-ec7ac34b4a6b1a330460838acc74a53d29f62a7c.zip
Qt-ec7ac34b4a6b1a330460838acc74a53d29f62a7c.tar.gz
Qt-ec7ac34b4a6b1a330460838acc74a53d29f62a7c.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
Conflicts: src/declarative/util/qmlanimation.cpp src/declarative/util/qmlxmllistmodel.cpp
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgridview.cpp2
-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/qmlgraphicsvisualitemmodel.cpp167
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h7
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview.cpp20
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview_p.h15
9 files changed, 329 insertions, 50 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
index bf370ae..ab87c03 100644
--- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
@@ -977,7 +977,7 @@ void QmlGraphicsGridView::setHighlight(QmlComponent *highlight)
Component {
id: myHighlight
Rectangle {
- id: wrapper; color: "lightsteelblue"; radius: 4; width: 320; height: 60 >
+ id: wrapper; color: "lightsteelblue"; radius: 4; width: 320; height: 60
y: SpringFollow { source: Wrapper.GridView.view.currentItem.y; spring: 3; damping: 0.2 }
x: SpringFollow { source: Wrapper.GridView.view.currentItem.x; spring: 3; damping: 0.2 }
}
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/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
index 9216793..bf3df03 100644
--- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
@@ -187,7 +187,6 @@ QVariant QmlGraphicsVisualItemModel::evaluate(int index, const QString &expressi
QmlContext *ctxt = new QmlContext(ccontext);
ctxt->addDefaultObject(d->children.at(index));
QmlExpression e(ctxt, expression, objectContext);
- e.setTrackChange(false);
QVariant value = e.value();
delete ctxt;
return value;
@@ -327,7 +326,7 @@ public:
if (m_listModelInterface)
return m_listModelInterface->count();
if (m_abstractItemModel)
- return m_abstractItemModel->rowCount();
+ return m_abstractItemModel->rowCount(m_root);
if (m_listAccessor)
return m_listAccessor->count();
return 0;
@@ -348,6 +347,8 @@ public:
QVariant m_modelVariant;
QmlListAccessor *m_listAccessor;
+
+ QModelIndex m_root;
};
class QmlGraphicsVisualDataModelDataMetaObject : public QmlOpenMetaObject
@@ -461,7 +462,7 @@ QVariant QmlGraphicsVisualDataModelDataMetaObject::initialValue(int propId)
QHash<QByteArray,int>::const_iterator it = model->m_roleNames.find(propName);
if (it != model->m_roleNames.end()) {
roleToProp.insert(*it, propId);
- QModelIndex index = model->m_abstractItemModel->index(data->m_index, 0);
+ QModelIndex index = model->m_abstractItemModel->index(data->m_index, 0, model->m_root);
return model->m_abstractItemModel->data(index, *it);
}
}
@@ -560,6 +561,39 @@ QmlGraphicsVisualDataModelData *QmlGraphicsVisualDataModelPrivate::data(QObject
//---------------------------------------------------------------------------
+/*!
+ \qmlclass VisualDataModel QmlGraphicsVisualDataModel
+ \brief The VisualDataModel encapsulates a model and delegate
+
+ A VisualDataModel encapsulates a model and the delegate that will
+ be instantiated for items in the model.
+
+ It is usually not necessary to create a VisualDataModel directly,
+ since the QML views will create one internally.
+
+ The example below illustrates using a VisualDataModel with a ListView.
+
+ \code
+ VisualDataModel {
+ id: visualModel
+ model: myModel
+ delegate: Component {
+ Rectangle {
+ height: 25
+ width: 100
+ Text { text: "Name:" + name}
+ }
+ }
+ }
+ ListView {
+ width: 100
+ height: 100
+ anchors.fill: parent
+ model: visualModel
+ }
+ \endcode
+*/
+
QmlGraphicsVisualDataModel::QmlGraphicsVisualDataModel()
: QmlGraphicsVisualModel(*(new QmlGraphicsVisualDataModelPrivate(0)))
{
@@ -579,6 +613,20 @@ QmlGraphicsVisualDataModel::~QmlGraphicsVisualDataModel()
d->m_delegateDataType->release();
}
+/*!
+ \qmlproperty model VisualDataModel::model
+ This property holds the model providing data for the VisualDataModel.
+
+ The model provides a set of data that is used to create the items
+ for a view. For large or dynamic datasets the model is usually
+ provided by a C++ model object. The C++ model object must be a \l
+ {QAbstractItemModel} subclass or a simple list.
+
+ Models can also be created directly in QML, using a \l{ListModel} or
+ \l{XmlListModel}.
+
+ \sa {qmlmodels}{Data Models}
+*/
QVariant QmlGraphicsVisualDataModel::model() const
{
Q_D(const QmlGraphicsVisualDataModel);
@@ -682,6 +730,16 @@ void QmlGraphicsVisualDataModel::setModel(const QVariant &model)
}
}
+/*!
+ \qmlproperty component VisualDataModel::delegate
+
+ The delegate provides a template defining each item instantiated by a view.
+ The index is exposed as an accessible \c index property. Properties of the
+ model are also available depending upon the type of \l {qmlmodels}{Data Model}.
+
+ Here is an example delegate:
+ \snippet doc/src/snippets/declarative/listview/listview.qml 0
+*/
QmlComponent *QmlGraphicsVisualDataModel::delegate() const
{
Q_D(const QmlGraphicsVisualDataModel);
@@ -705,6 +763,104 @@ void QmlGraphicsVisualDataModel::setDelegate(QmlComponent *delegate)
}
}
+/*!
+ \qmlproperty QModelIndex VisualDataModel::rootIndex
+
+ QAbstractItemModel provides a heirachical tree of data, whereas
+ QML only operates on list data. rootIndex allows the children of
+ any node in a QAbstractItemModel to be provided by this model.
+
+ This property only affects models of type QAbstractItemModel.
+
+ \code
+ // main.cpp
+ Q_DECLARE_METATYPE(QModelIndex)
+
+ class MyModel : public QDirModel
+ {
+ Q_OBJECT
+ public:
+ MyModel(QmlContext *ctxt) : QDirModel(), context(ctxt) {
+ QHash<int,QByteArray> roles = roleNames();
+ roles.insert(FilePathRole, "path");
+ setRoleNames(roles);
+ context->setContextProperty("myModel", this);
+ context->setContextProperty("myRoot", QVariant::fromValue(index(0,0,QModelIndex())));
+ }
+
+ Q_INVOKABLE void setRoot(const QString &path) {
+ QModelIndex root = index(path);
+ context->setContextProperty("myRoot", QVariant::fromValue(root));
+ }
+
+ QmlContext *context;
+ };
+
+ int main(int argc, char ** argv)
+ {
+ QApplication app(argc, argv);
+
+ QmlView view;
+
+ MyModel model(view.rootContext());
+
+ view.setSource(QUrl("qrc:view.qml"));
+ view.show();
+
+ return app.exec();
+ }
+
+ #include "main.moc"
+ \endcode
+
+ \code
+ // view.qml
+ import Qt 4.6
+
+ ListView {
+ width: 200
+ height: 200
+ model: VisualDataModel {
+ model: myModel
+ rootIndex: myRoot
+ delegate: Component {
+ Rectangle {
+ height: 25; width: 100
+ Text { text: path }
+ MouseRegion {
+ anchors.fill: parent;
+ onClicked: myModel.setRoot(path)
+ }
+ }
+ }
+ }
+ }
+ \endcode
+
+*/
+QModelIndex QmlGraphicsVisualDataModel::rootIndex() const
+{
+ Q_D(const QmlGraphicsVisualDataModel);
+ return d->m_root;
+}
+
+void QmlGraphicsVisualDataModel::setRootIndex(const QModelIndex &root)
+{
+ Q_D(QmlGraphicsVisualDataModel);
+ if (d->m_root != root) {
+ int oldCount = d->modelCount();
+ d->m_root = root;
+ int newCount = d->modelCount();
+ if (d->m_delegate && oldCount)
+ emit itemsRemoved(0, oldCount);
+ if (d->m_delegate && newCount)
+ emit itemsInserted(0, newCount);
+ if (newCount != oldCount)
+ emit countChanged();
+ emit rootIndexChanged();
+ }
+}
+
QString QmlGraphicsVisualDataModel::part() const
{
Q_D(const QmlGraphicsVisualDataModel);
@@ -786,7 +942,6 @@ QmlGraphicsItem *QmlGraphicsVisualDataModel::item(int index, const QByteArray &v
if (d->modelCount() <= 0 || !d->m_delegate)
return 0;
-
QObject *nobj = d->m_cache.getItem(index);
if (!nobj) {
QmlContext *ccontext = d->m_context;
@@ -900,7 +1055,6 @@ QVariant QmlGraphicsVisualDataModel::evaluate(int index, const QString &expressi
QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem *>(nobj);
if (item) {
QmlExpression e(qmlContext(item), expression, objectContext);
- e.setTrackChange(false);
value = e.value();
}
} else {
@@ -910,7 +1064,6 @@ QVariant QmlGraphicsVisualDataModel::evaluate(int index, const QString &expressi
QmlGraphicsVisualDataModelData *data = new QmlGraphicsVisualDataModelData(index, this);
ctxt->addDefaultObject(data);
QmlExpression e(ctxt, expression, objectContext);
- e.setTrackChange(false);
value = e.value();
delete data;
delete ctxt;
@@ -943,7 +1096,7 @@ void QmlGraphicsVisualDataModel::_q_itemsChanged(int index, int count,
if (d->m_listModelInterface) {
data->setValue(propId, d->m_listModelInterface->data(ii, QList<int>() << role).value(role));
} else if (d->m_abstractItemModel) {
- QModelIndex index = d->m_abstractItemModel->index(ii, 0);
+ QModelIndex index = d->m_abstractItemModel->index(ii, 0, d->m_root);
data->setValue(propId, d->m_abstractItemModel->data(index, role));
}
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h
index 49f9b27..7dc41a8 100644
--- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h
@@ -49,6 +49,8 @@
QT_BEGIN_HEADER
+Q_DECLARE_METATYPE(QModelIndex)
+
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
@@ -147,6 +149,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsVisualDataModel : public QmlGraphicsVisual
Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate)
Q_PROPERTY(QString part READ part WRITE setPart)
Q_PROPERTY(QObject *parts READ parts CONSTANT)
+ Q_PROPERTY(QModelIndex rootIndex READ rootIndex WRITE setRootIndex NOTIFY rootIndexChanged)
Q_CLASSINFO("DefaultProperty", "delegate")
public:
QmlGraphicsVisualDataModel();
@@ -159,6 +162,9 @@ public:
QmlComponent *delegate() const;
void setDelegate(QmlComponent *);
+ QModelIndex rootIndex() const;
+ void setRootIndex(const QModelIndex &root);
+
QString part() const;
void setPart(const QString &);
@@ -178,6 +184,7 @@ public:
Q_SIGNALS:
void createdPackage(int index, QmlPackage *package);
void destroyingPackage(QmlPackage *package);
+ void rootIndexChanged();
private Q_SLOTS:
void _q_itemsChanged(int, int, const QList<int> &);
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();