Commit e4114505 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner: fix regression uncovered by tests

Fixing a regression in the meta info system.

We follow now Qthe Declarative1StateOperation convention (note the 1).
Since this data is provided by Qt Creator it is independent from any Qt
version. (4.8/5.1)

Also the type comparison was broken in NodeMetaInfo for <cpp> types.
PackageName() does retrieve the package name of the cpp type which might
be different from the one used in qualfiedTypeName().

Change-Id: I5cdae37c2024cdc89824e68168c16e2050051d06
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent 73d119f3
......@@ -339,7 +339,7 @@ public:
Model *model() const
{ return m_model; }
QString packageName() const;
QString cppPackageName() const;
QString componentSource() const;
QString componentFileName() const;
......@@ -674,6 +674,14 @@ QString NodeMetaInfoPrivate::propertyEnumScope(const QString &propertyName) cons
return QString();
}
static QString getUnqualifiedName(const QString &name)
{
const QStringList nameComponents = name.split('.');
if (nameComponents.size() < 2)
return QString();
return nameComponents.last();
}
bool NodeMetaInfoPrivate::cleverCheckType(const QString &otherType) const
{
if (otherType == qualfiedTypeName())
......@@ -689,8 +697,8 @@ bool NodeMetaInfoPrivate::cleverCheckType(const QString &otherType) const
package = split.first();
typeName = split.at(1);
}
if (packageName() == package)
return QString(package + '.' + typeName) == qualfiedTypeName();
if (cppPackageName() == package)
return QString(package + '.' + typeName) == cppPackageName() + '.' + getUnqualifiedName(qualfiedTypeName());
const CppComponentValue *qmlObjectValue = getCppComponentValue();
if (!qmlObjectValue)
......@@ -753,7 +761,7 @@ QStringList NodeMetaInfoPrivate::keysForEnum(const QString &enumName) const
return qmlObjectValue->getEnum(enumName).keys();
}
QString NodeMetaInfoPrivate::packageName() const
QString NodeMetaInfoPrivate::cppPackageName() const
{
if (!isComponent()) {
if (const CppComponentValue *qmlObject = getCppComponentValue())
......
......@@ -57,7 +57,7 @@ bool QmlPropertyChanges::isValid() const
bool QmlModelStateOperation::isValid() const
{
return QmlModelNodeFacade::isValid() && modelNode().metaInfo().isSubclassOf("<cpp>.QDeclarativeStateOperation", -1, -1);
return QmlModelNodeFacade::isValid() && modelNode().metaInfo().isSubclassOf("<cpp>.QDeclarative1StateOperation", -1, -1);
}
void QmlPropertyChanges::removeProperty(const QString &name)
......
......@@ -1259,6 +1259,7 @@ void tst_TestCore::testBasicStates()
QCOMPARE(state1.propertyChanges().count(), 2);
QCOMPARE(state2.propertyChanges().count(), 2);
QVERIFY(state1.propertyChanges().first().modelNode().metaInfo().isSubclassOf("<cpp>.QDeclarative1StateOperation", -1, -1));
QVERIFY(!state1.hasPropertyChanges(rootModelNode));
QVERIFY(state1.propertyChanges(rect1).isValid());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment