summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-08-24 07:05:49 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-08-24 07:05:49 (GMT)
commit6536f950bb4eb21f769086a9e95bb76e81a39e3c (patch)
tree2992dd868b3ae491961da535c48cb85b4507f29e
parent2cb91f6371a7918cfe54cc31efe61a39df89ab9e (diff)
parent0f3d7560855dd83b63ee090ee74b8770163e806c (diff)
downloadQt-6536f950bb4eb21f769086a9e95bb76e81a39e3c.zip
Qt-6536f950bb4eb21f769086a9e95bb76e81a39e3c.tar.gz
Qt-6536f950bb4eb21f769086a9e95bb76e81a39e3c.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
-rw-r--r--examples/declarative/toys/clocks/content/Clock.qml6
-rw-r--r--examples/declarative/toys/tvtennis/tvtennis.qml4
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp3
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp47
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h3
-rw-r--r--src/declarative/qml/parser/qdeclarativejslexer.cpp2
-rw-r--r--src/declarative/qml/qdeclarativecompositetypemanager.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeimport.cpp2
-rw-r--r--src/declarative/qml/qdeclarativescriptparser.cpp2
-rw-r--r--src/declarative/qml/qmetaobjectbuilder.cpp2
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp4
-rw-r--r--src/declarative/util/qdeclarativestategroup.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativepathview/data/emptymodel.qml5
-rw-r--r--tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp24
17 files changed, 48 insertions, 68 deletions
diff --git a/examples/declarative/toys/clocks/content/Clock.qml b/examples/declarative/toys/clocks/content/Clock.qml
index eaa14c6..765e8b8 100644
--- a/examples/declarative/toys/clocks/content/Clock.qml
+++ b/examples/declarative/toys/clocks/content/Clock.qml
@@ -77,7 +77,7 @@ Item {
origin.x: 7.5; origin.y: 73;
angle: (clock.hours * 30) + (clock.minutes * 0.5)
Behavior on angle {
- RotationAnimation{ direction: RotationAnimation.Clockwise }
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
}
}
}
@@ -91,7 +91,7 @@ Item {
origin.x: 6.5; origin.y: 83;
angle: clock.minutes * 6
Behavior on angle {
- RotationAnimation{ direction: RotationAnimation.Clockwise }
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
}
}
}
@@ -105,7 +105,7 @@ Item {
origin.x: 2.5; origin.y: 80;
angle: clock.seconds * 6
Behavior on angle {
- RotationAnimation{ direction: RotationAnimation.Clockwise }
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
}
}
}
diff --git a/examples/declarative/toys/tvtennis/tvtennis.qml b/examples/declarative/toys/tvtennis/tvtennis.qml
index 2e144ed..4080c87 100644
--- a/examples/declarative/toys/tvtennis/tvtennis.qml
+++ b/examples/declarative/toys/tvtennis/tvtennis.qml
@@ -87,14 +87,14 @@ Rectangle {
color: "Lime"
x: 2; width: 20; height: 90
y: ball.direction == 'left' ? ball.y - 45 : page.height/2 -45;
- Behavior on y { SpringAnimation{ spring: 1; damping: .1; } }
+ Behavior on y { SpringAnimation{ velocity: 300 } }
}
Rectangle {
id: rightBat
color: "Lime"
x: page.width - 22; width: 20; height: 90
y: ball.direction == 'right' ? ball.y - 45 : page.height/2 -45;
- Behavior on y { SpringAnimation{ spring: 1; damping: .1; } }
+ Behavior on y { SpringAnimation{ velocity: 300 } }
}
// The rest, to make it look realistic, if neither ever scores...
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index ec1b6cf..2e2e08c 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -983,7 +983,7 @@ void QDeclarativeListViewPrivate::updateSections()
void QDeclarativeListViewPrivate::updateCurrentSection()
{
if (!sectionCriteria || visibleItems.isEmpty()) {
- currentSection = QString();
+ currentSection.clear();
return;
}
int index = 0;
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index 535fb90..4b97505 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -480,7 +480,8 @@ void QDeclarativePathView::setModel(const QVariant &model)
connect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset()));
connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*)));
}
- d->offset = qmlMod(d->offset, qreal(d->model->count()));
+ if (d->model->count())
+ d->offset = qmlMod(d->offset, qreal(d->model->count()));
if (d->offset < 0)
d->offset = d->model->count() + d->offset;
d->regenerate();
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index fcd112e..b96b43c 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -1218,7 +1218,7 @@ void QDeclarativeText::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (!d->richText || !d->doc || d->doc->documentLayout()->anchorAt(event->pos()).isEmpty()) {
event->setAccepted(false);
- d->activeLink = QString();
+ d->activeLink.clear();
} else {
d->activeLink = d->doc->documentLayout()->anchorAt(event->pos());
}
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 764676a..50a0a33 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -238,20 +238,6 @@ QString QDeclarativeVisualItemModel::stringValue(int index, const QString &name)
return QDeclarativeEngine::contextForObject(d->children.at(index).item)->contextProperty(name).toString();
}
-QVariant QDeclarativeVisualItemModel::evaluate(int index, const QString &expression, QObject *objectContext)
-{
- Q_D(QDeclarativeVisualItemModel);
- if (index < 0 || index >= d->children.count())
- return QVariant();
- QDeclarativeContext *ccontext = qmlContext(this);
- QDeclarativeContext *ctxt = new QDeclarativeContext(ccontext);
- ctxt->setContextObject(d->children.at(index).item);
- QDeclarativeExpression e(ctxt, objectContext, expression);
- QVariant value = e.evaluate();
- delete ctxt;
- return value;
-}
-
int QDeclarativeVisualItemModel::indexOf(QDeclarativeItem *item, QObject *) const
{
Q_D(const QDeclarativeVisualItemModel);
@@ -728,6 +714,7 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model)
QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)),
this, SLOT(_q_rowsMoved(const QModelIndex&,int,int,const QModelIndex&,int)));
QObject::disconnect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset()));
+ d->m_abstractItemModel = 0;
} else if (d->m_visualItemModel) {
QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsInserted(int,int)),
this, SIGNAL(itemsInserted(int,int)));
@@ -1167,38 +1154,6 @@ QString QDeclarativeVisualDataModel::stringValue(int index, const QString &name)
return val;
}
-QVariant QDeclarativeVisualDataModel::evaluate(int index, const QString &expression, QObject *objectContext)
-{
- Q_D(QDeclarativeVisualDataModel);
- if (d->m_visualItemModel)
- return d->m_visualItemModel->evaluate(index, expression, objectContext);
-
- if ((!d->m_listModelInterface && !d->m_abstractItemModel) || !d->m_delegate)
- return QVariant();
-
- QVariant value;
- QObject *nobj = d->m_cache.item(index);
- if (nobj) {
- QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(nobj);
- if (item) {
- QDeclarativeExpression e(qmlContext(item), objectContext, expression);
- value = e.evaluate();
- }
- } else {
- QDeclarativeContext *ccontext = d->m_context;
- if (!ccontext) ccontext = qmlContext(this);
- QDeclarativeContext *ctxt = new QDeclarativeContext(ccontext);
- QDeclarativeVisualDataModelData *data = new QDeclarativeVisualDataModelData(index, this);
- ctxt->setContextObject(data);
- QDeclarativeExpression e(ctxt, objectContext, expression);
- value = e.evaluate();
- delete data;
- delete ctxt;
- }
-
- return value;
-}
-
int QDeclarativeVisualDataModel::indexOf(QDeclarativeItem *item, QObject *) const
{
QVariant val = QDeclarativeEngine::contextForObject(item)->contextProperty(QLatin1String("index"));
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
index d5c0de2..50d2c53 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
@@ -79,7 +79,6 @@ public:
virtual ReleaseFlags release(QDeclarativeItem *item) = 0;
virtual bool completePending() const = 0;
virtual void completeItem() = 0;
- virtual QVariant evaluate(int index, const QString &expression, QObject *objectContext) = 0;
virtual QString stringValue(int, const QString &) { return QString(); }
virtual int indexOf(QDeclarativeItem *item, QObject *objectContext) const = 0;
@@ -122,7 +121,6 @@ public:
virtual bool completePending() const;
virtual void completeItem();
virtual QString stringValue(int index, const QString &role);
- virtual QVariant evaluate(int index, const QString &expression, QObject *objectContext);
virtual int indexOf(QDeclarativeItem *item, QObject *objectContext) const;
@@ -177,7 +175,6 @@ public:
bool completePending() const;
void completeItem();
virtual QString stringValue(int index, const QString &role);
- QVariant evaluate(int index, const QString &expression, QObject *objectContext);
int indexOf(QDeclarativeItem *item, QObject *objectContext) const;
diff --git a/src/declarative/qml/parser/qdeclarativejslexer.cpp b/src/declarative/qml/parser/qdeclarativejslexer.cpp
index 65a6af2..cd08658 100644
--- a/src/declarative/qml/parser/qdeclarativejslexer.cpp
+++ b/src/declarative/qml/parser/qdeclarativejslexer.cpp
@@ -120,7 +120,7 @@ Lexer::~Lexer()
void Lexer::setCode(const QString &c, int lineno)
{
- errmsg = QString();
+ errmsg.clear();
yylineno = lineno;
yycolumn = 1;
restrKeyword = false;
diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
index 26b2a9b..2e77534 100644
--- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp
+++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
@@ -544,7 +544,7 @@ int QDeclarativeCompositeTypeManager::resolveTypes(QDeclarativeCompositeTypeData
}
- foreach (QDeclarativeScriptParser::Import imp, unit->data.imports()) {
+ foreach (const QDeclarativeScriptParser::Import &imp, unit->data.imports()) {
QDeclarativeDirComponents qmldircomponentsnetwork;
if (imp.type == QDeclarativeScriptParser::Import::Script)
continue;
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index cedf9d5..4e45636 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -2079,7 +2079,7 @@ void QDeclarativeEnginePrivate::registerCompositeType(QDeclarativeCompiledData *
QByteArray name = data->root->className();
QByteArray ptr = name + '*';
- QByteArray lst = "QDeclarativeListProperty<" + name + ">";
+ QByteArray lst = "QDeclarativeListProperty<" + name + '>';
int ptr_type = QMetaType::registerType(ptr.constData(), voidptr_destructor,
voidptr_constructor);
diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp
index 8d81b34..5c21ebc 100644
--- a/src/declarative/qml/qdeclarativeimport.cpp
+++ b/src/declarative/qml/qdeclarativeimport.cpp
@@ -338,7 +338,7 @@ QString QDeclarativeImportsPrivate::resolvedUri(const QString &dir_arg, QDeclara
qSort(paths.begin(), paths.end(), greaterThan); // Ensure subdirs preceed their parents.
QString stableRelativePath = dir;
- foreach( QString path, paths) {
+ foreach(const QString &path, paths) {
if (dir.startsWith(path)) {
stableRelativePath = dir.mid(path.length()+1);
break;
diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp
index 0657f49..0b3b35f 100644
--- a/src/declarative/qml/qdeclarativescriptparser.cpp
+++ b/src/declarative/qml/qdeclarativescriptparser.cpp
@@ -543,7 +543,7 @@ bool ProcessAST::visit(AST::UiPublicMember *node)
QString typemodifier;
if(node->typeModifier)
typemodifier = node->typeModifier->asString();
- if (typemodifier == QString()) {
+ if (typemodifier.isEmpty()) {
type = Object::DynamicProperty::Custom;
} else if(typemodifier == QLatin1String("list")) {
type = Object::DynamicProperty::CustomList;
diff --git a/src/declarative/qml/qmetaobjectbuilder.cpp b/src/declarative/qml/qmetaobjectbuilder.cpp
index 6e4d7b8..0954248 100644
--- a/src/declarative/qml/qmetaobjectbuilder.cpp
+++ b/src/declarative/qml/qmetaobjectbuilder.cpp
@@ -1142,7 +1142,7 @@ static QByteArray buildParameterNames
if (!parameterNames.isEmpty()) {
QByteArray names;
bool first = true;
- foreach (QByteArray name, parameterNames) {
+ foreach (const QByteArray &name, parameterNames) {
if (first)
first = false;
else
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index 1f66f0f..0162beb 100644
--- a/src/declarative/util/qdeclarativelistmodel.cpp
+++ b/src/declarative/util/qdeclarativelistmodel.cpp
@@ -570,7 +570,7 @@ bool QDeclarativeListModelParser::compileProperty(const QDeclarativeCustomParser
QList<QDeclarativeCustomParserProperty> props = node.properties();
for(int jj = 0; jj < props.count(); ++jj) {
const QDeclarativeCustomParserProperty &nodeProp = props.at(jj);
- if (nodeProp.name() == "") {
+ if (nodeProp.name().isEmpty()) {
error(nodeProp, QDeclarativeListModel::tr("ListElement: cannot contain nested elements"));
return false;
}
@@ -658,7 +658,7 @@ QByteArray QDeclarativeListModelParser::compile(const QList<QDeclarativeCustomPa
for(int ii = 0; ii < customProps.count(); ++ii) {
const QDeclarativeCustomParserProperty &prop = customProps.at(ii);
- if(prop.name() != "") { // isn't default property
+ if(!prop.name().isEmpty()) { // isn't default property
error(prop, QDeclarativeListModel::tr("ListModel: undefined property '%1'").arg(QString::fromUtf8(prop.name())));
return QByteArray();
}
diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp
index fc90baa..6d9563e 100644
--- a/src/declarative/util/qdeclarativestategroup.cpp
+++ b/src/declarative/util/qdeclarativestategroup.cpp
@@ -272,7 +272,7 @@ void QDeclarativeStateGroup::componentComplete()
return;
} else if (!d->currentState.isEmpty()) {
QString cs = d->currentState;
- d->currentState = QString();
+ d->currentState.clear();
d->setCurrentStateInternal(cs, true);
}
}
@@ -314,7 +314,7 @@ bool QDeclarativeStateGroupPrivate::updateAutoState()
}
}
if (revert) {
- bool rv = currentState != QString();
+ bool rv = !currentState.isEmpty();
q->setState(QString());
return rv;
} else {
diff --git a/tests/auto/declarative/qdeclarativepathview/data/emptymodel.qml b/tests/auto/declarative/qdeclarativepathview/data/emptymodel.qml
new file mode 100644
index 0000000..177c405
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativepathview/data/emptymodel.qml
@@ -0,0 +1,5 @@
+import Qt 4.7
+
+PathView {
+ model: emptyModel
+}
diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
index fdbb16d..e2ccfd2 100644
--- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
+++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp
@@ -84,7 +84,7 @@ private slots:
void modelChanges();
void pathUpdateOnStartChanged();
void package();
-
+ void emptyModel();
private:
QDeclarativeView *createView();
@@ -755,6 +755,28 @@ void tst_QDeclarativePathView::package()
delete canvas;
}
+//QTBUG-13017
+void tst_QDeclarativePathView::emptyModel()
+{
+ QDeclarativeView *canvas = createView();
+
+ QStringListModel model;
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("emptyModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/emptymodel.qml"));
+ qApp->processEvents();
+
+ QDeclarativePathView *pathview = qobject_cast<QDeclarativePathView*>(canvas->rootObject());
+ QVERIFY(pathview != 0);
+
+ QCOMPARE(pathview->offset(), qreal(0.0));
+
+ delete canvas;
+}
+
+
QDeclarativeView *tst_QDeclarativePathView::createView()
{
QDeclarativeView *canvas = new QDeclarativeView(0);