Commit 0a02b85e authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner: get rid of Qt/ - use QtQuick/ instead

Qt 4.7 imports are converted to QtQuick 1.0 imports.
parent 26a3014e
......@@ -327,7 +327,7 @@ QString FormEditorWidget::contextHelpId() const
QString helpId;
if (!nodes.isEmpty()) {
helpId = nodes.first().type();
helpId.replace("Qt/", "QML.");
helpId.replace("QtQuick/", "QML.");
}
return helpId;
......
......@@ -275,7 +275,7 @@ QList<RewriterView::Error> DesignDocumentController::loadMaster(QPlainTextEdit *
//m_d->masterModel = Model::create(m_d->textModifier, m_d->searchPath, errors);
m_d->masterModel = Model::create("Qt/Rectangle", 4, 7);
m_d->masterModel = Model::create("QtQuick/Rectangle", 1, 0);
#if defined(VIEWLOGGER)
m_d->viewLogger = new Internal::ViewLogger(m_d->model.data());
......@@ -284,7 +284,7 @@ QList<RewriterView::Error> DesignDocumentController::loadMaster(QPlainTextEdit *
m_d->masterModel->setFileUrl(m_d->searchPath);
m_d->subComponentModel = Model::create("Qt/Rectangle", 4, 7);
m_d->subComponentModel = Model::create("QtQuick/Rectangle", 1, 0);
m_d->subComponentModel->setFileUrl(m_d->searchPath);
m_d->subComponentManager = new SubComponentManager(m_d->masterModel->metaInfo(), this);
......@@ -775,7 +775,7 @@ QString DesignDocumentController::contextHelpId() const
QString helpId;
if (!nodes.isEmpty()) {
helpId = nodes.first().type();
helpId.replace("Qt/", "QML.");
helpId.replace("QtQuick/", "QML.");
}
return helpId;
......
......@@ -155,7 +155,7 @@ void DesignDocumentControllerView::fromClipboard()
QString DesignDocumentControllerView::toText() const
{
QScopedPointer<Model> outputModel(Model::create("Qt/Rectangle"));
QScopedPointer<Model> outputModel(Model::create("QtQuick/Rectangle", 1, 0));
outputModel->setMetaInfo(model()->metaInfo());
QPlainTextEdit textEdit;
textEdit.setPlainText("import Qt 4.7; Item {}");
......@@ -177,7 +177,7 @@ QString DesignDocumentControllerView::toText() const
void DesignDocumentControllerView::fromText(QString text)
{
QScopedPointer<Model> inputModel(Model::create("Qt/Rectangle"));
QScopedPointer<Model> inputModel(Model::create("QtQuick/Rectangle", 1, 0));
inputModel->setMetaInfo(model()->metaInfo());
inputModel->setFileUrl(model()->fileUrl());
QPlainTextEdit textEdit;
......
......@@ -131,13 +131,13 @@ void GradientLineQmlAdaptor::writeGradient()
modelNode.removeProperty(gradientName());
}
ModelNode gradientNode = modelNode.view()->createModelNode("Qt/Gradient", 4, 7);
ModelNode gradientNode = modelNode.view()->createModelNode("QtQuick/Gradient", 1, 0);
if (!oldId.isNull())
gradientNode.setId(oldId);
for (int i = 0;i < stops.size(); i++) {
ModelNode gradientStopNode = modelNode.view()->createModelNode("Qt/GradientStop", 4, 7);
ModelNode gradientStopNode = modelNode.view()->createModelNode("QtQuick/GradientStop", 1, 0);
gradientStopNode.variantProperty("position") = roundReal(stops.at(i).first);
gradientStopNode.variantProperty("color") = normalizeColor(stops.at(i).second);
gradientNode.nodeListProperty("stops").reparentHere(gradientStopNode);
......
......@@ -509,8 +509,8 @@ void PropertyEditor::updateSize()
void PropertyEditor::setupPanes()
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
setupPane("Qt/Rectangle");
setupPane("Qt/Text");
setupPane("QtQuick/Rectangle");
setupPane("QtQuick/Text");
resetView();
m_setupCompleted = true;
QApplication::restoreOverrideCursor();
......@@ -884,7 +884,8 @@ QString PropertyEditor::qmlFileName(const NodeMetaInfo &nodeInfo) const
{
if (nodeInfo.typeName().split('/').last() == "QDeclarativeItem")
return "Qt/ItemPane.qml";
return nodeInfo.typeName() + QLatin1String("Pane.qml");
const QString fixedTypeName = nodeInfo.typeName().replace("QtQuick/", "Qt/");
return fixedTypeName + QLatin1String("Pane.qml");
}
QUrl PropertyEditor::fileToUrl(const QString &filePath) const {
......
......@@ -76,7 +76,7 @@ void StatesEditorView::removeState(int nodeId)
try {
if (nodeId > 0 && hasModelNodeForInternalId(nodeId)) {
ModelNode stateNode(modelNodeForInternalId(nodeId));
Q_ASSERT(stateNode.metaInfo().isSubclassOf("QtQuick/State", 4, 7));
Q_ASSERT(stateNode.metaInfo().isSubclassOf("QtQuick/State", -1, -1));
NodeListProperty parentProperty = stateNode.parentProperty().toNodeListProperty();
if (parentProperty.count() <= 1) {
......
......@@ -612,7 +612,7 @@ void NodeInstanceServer::resetInstanceProperty(const PropertyAbstractContainer &
const QString name = propertyContainer.name();
if (activeStateInstance().isValid() && !instance.isSubclassOf("Qt/PropertyChanges")) {
if (activeStateInstance().isValid() && !instance.isSubclassOf("QtQuick/PropertyChanges")) {
bool statePropertyWasReseted = activeStateInstance().resetStateProperty(instance, name, instance.resetVariant(name));
if (!statePropertyWasReseted)
instance.resetProperty(name);
......@@ -632,7 +632,7 @@ void NodeInstanceServer::setInstancePropertyBinding(const PropertyBindingContain
const QString expression = bindingContainer.expression();
if (activeStateInstance().isValid() && !instance.isSubclassOf("Qt/PropertyChanges")) {
if (activeStateInstance().isValid() && !instance.isSubclassOf("QtQuick/PropertyChanges")) {
bool stateBindingWasUpdated = activeStateInstance().updateStateBinding(instance, name, expression);
if (!stateBindingWasUpdated) {
if (bindingContainer.isDynamic())
......@@ -666,7 +666,7 @@ void NodeInstanceServer::setInstancePropertyVariant(const PropertyValueContainer
const QVariant value = valueContainer.value();
if (activeStateInstance().isValid() && !instance.isSubclassOf("Qt/PropertyChanges")) {
if (activeStateInstance().isValid() && !instance.isSubclassOf("QtQuick/PropertyChanges")) {
bool stateValueWasUpdated = activeStateInstance().updateStateVariant(instance, name, value);
if (!stateValueWasUpdated) {
if (valueContainer.isDynamic())
......
......@@ -95,7 +95,7 @@ ModelPrivate::ModelPrivate(Model *model) :
m_writeLock(false),
m_internalIdCounter(1)
{
m_rootInternalNode = createNode("Qt/Item", 4, 7, PropertyListType(), true);
m_rootInternalNode = createNode("QtQuick/Item", 1, 0, PropertyListType(), true);
}
ModelPrivate::~ModelPrivate()
......
......@@ -55,12 +55,12 @@ void QmlModelStateOperation::setTarget(const ModelNode &target)
bool QmlPropertyChanges::isValid() const
{
return QmlModelNodeFacade::isValid() && modelNode().metaInfo().isSubclassOf("Qt/PropertyChanges", 4, 7);
return QmlModelNodeFacade::isValid() && modelNode().metaInfo().isSubclassOf("QtQuick/PropertyChanges", -1, -1);
}
bool QmlModelStateOperation::isValid() const
{
return QmlModelNodeFacade::isValid() && modelNode().metaInfo().isSubclassOf("QDeclarativeStateOperation", 4, 7);
return QmlModelNodeFacade::isValid() && modelNode().metaInfo().isSubclassOf("Qt/QDeclarativeStateOperation", -1, -1);
}
void QmlPropertyChanges::removeProperty(const QString &name)
......
......@@ -50,7 +50,7 @@ namespace QmlDesigner {
bool QmlItemNode::isValid() const
{
return QmlModelNodeFacade::isValid() && modelNode().metaInfo().isValid() && modelNode().metaInfo().isSubclassOf("Qt/Item", 4, 7);
return QmlModelNodeFacade::isValid() && modelNode().metaInfo().isValid() && modelNode().metaInfo().isSubclassOf("QtQuick/Item", -1, -1);
}
bool QmlItemNode::isRootNode() const
......@@ -306,7 +306,7 @@ QmlModelState QmlModelStateGroup::addState(const QString &name)
PropertyListType propertyList;
propertyList.append(qMakePair(QString("name"), QVariant(name)));
ModelNode newState = modelNode().view()->createModelNode("Qt/State", 4, 7, propertyList);
ModelNode newState = modelNode().view()->createModelNode("QtQuick/State", 1, 0, propertyList);
modelNode().nodeListProperty("states").reparentHere(newState);
return newState;
......
......@@ -133,7 +133,7 @@ QmlItemNode QmlModelView::createQmlItemNodeFromImage(const QString &imageName, c
}
propertyPairList.append(qMakePair(QString("source"), QVariant(relativeImageName)));
newNode = createQmlItemNode("Qt/Image", 4, 7, propertyPairList);
newNode = createQmlItemNode("QtQuick/Image", 1, 0, propertyPairList);
parentNode.nodeAbstractProperty("data").reparentHere(newNode);
Q_ASSERT(newNode.isValid());
......
......@@ -183,7 +183,7 @@ void QmlModelState::addChangeSetIfNotExists(const ModelNode &node)
return; //changeSet already there
}
ModelNode newChangeSet = modelNode().view()->createModelNode("Qt/PropertyChanges", 4, 7);
ModelNode newChangeSet = modelNode().view()->createModelNode("QtQuick/PropertyChanges", 1, 0);
modelNode().nodeListProperty("changes").reparentHere(newChangeSet);
QmlPropertyChanges(newChangeSet).setTarget(node);
......@@ -250,7 +250,7 @@ bool QmlModelState::isValid() const
{
return QmlModelNodeFacade::isValid() &&
modelNode().metaInfo().isValid() &&
(modelNode().metaInfo().isSubclassOf("Qt/State", 4, 7) || isBaseState());
(modelNode().metaInfo().isSubclassOf("QtQuick/State", 1, 0) || isBaseState());
}
/**
......@@ -284,7 +284,7 @@ QmlModelState QmlModelState::duplicate(const QString &name) const
// QmlModelState newState(stateGroup().addState(name));
PropertyListType propertyList;
propertyList.append(qMakePair(QString("name"), QVariant(name)));
QmlModelState newState ( qmlModelView()->createModelNode("Qt/State", 4, 7, propertyList) );
QmlModelState newState ( qmlModelView()->createModelNode("QtQuick/State", 1, 0, propertyList) );
foreach (const ModelNode &childNode, modelNode().nodeListProperty("changes").toModelNodeList()) {
ModelNode newModelNode(qmlModelView()->createModelNode(childNode.type(), childNode.majorVersion(), childNode.minorVersion()));
......
......@@ -83,24 +83,24 @@ static inline QString deEscape(const QString &value)
return result;
}
static inline int fixUpMajorVersionForQtQuick(const QString &value, int i)
static inline int fixUpMajorVersionForQt(const QString &value, int i)
{
if (i == 1 && value == "QtQuick")
return 4;
if (i == 4 && value == "Qt")
return 1;
else return i;
}
static inline int fixUpMinorVersionForQtQuick(const QString &value, int i)
static inline int fixUpMinorVersionForQt(const QString &value, int i)
{
if (i == 0 && value == "QtQuick")
return 7;
if (i == 7 && value == "Qt")
return 0;
else return i;
}
static inline QString fixUpPackeNameForQtQuick(const QString &value)
static inline QString fixUpPackeNameForQt(const QString &value)
{
if (value == "QtQuick")
return "Qt";
if (value == "Qt")
return "QtQuick";
return value;
}
......@@ -224,6 +224,12 @@ static bool isComponentType(const QString &type)
return type == QLatin1String("Component") || type == QLatin1String("Qt/Component") || type == QLatin1String("QtQuick/Component");
}
static bool isPropertyChangesType(const QString &type)
{
return type == QLatin1String("PropertyChanges") || type == QLatin1String("QtQuick/PropertyChanges") || type == QLatin1String("Qt/PropertyChanges");
}
} // anonymous namespace
namespace QmlDesigner {
......@@ -263,11 +269,11 @@ public:
const Interpreter::QmlObjectValue * qmlValue = dynamic_cast<const Interpreter::QmlObjectValue *>(value);
if (qmlValue) {
typeName = fixUpPackeNameForQtQuick(qmlValue->packageName()) + QLatin1String("/") + qmlValue->className();
typeName = fixUpPackeNameForQt(qmlValue->packageName()) + QLatin1String("/") + qmlValue->className();
//### todo this is just a hack to support QtQuick 1.0
majorVersion = fixUpMajorVersionForQtQuick(qmlValue->packageName(), qmlValue->version().majorVersion());
minorVersion = fixUpMinorVersionForQtQuick(qmlValue->packageName(), qmlValue->version().minorVersion());
majorVersion = fixUpMajorVersionForQt(qmlValue->packageName(), qmlValue->version().majorVersion());
minorVersion = fixUpMinorVersionForQt(qmlValue->packageName(), qmlValue->version().minorVersion());
} else {
for (UiQualifiedId *iter = astTypeNode; iter; iter = iter->next)
if (!iter->next && iter->name)
......@@ -561,9 +567,9 @@ void TextToModelMerger::setupImports(const Document::Ptr &doc,
differenceHandler.modelMissesImport(newImport);
} else {
QString importUri = flatten(import->importUri);
if (importUri == QLatin1String("QtQuick") && version == QLatin1String("1.0")) {
importUri = QLatin1String("Qt");
version = QLatin1String("4.7");
if (importUri == QLatin1String("Qt") && version == QLatin1String("4.7")) {
importUri = QLatin1String("QtQuick");
version = QLatin1String("1.0");
}
const Import newImport =
......@@ -707,7 +713,7 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
if (UiArrayBinding *array = cast<UiArrayBinding *>(member)) {
const QString astPropertyName = flatten(array->qualifiedId);
if (typeName == QLatin1String("Qt/PropertyChanges") || context->lookupProperty(QString(), array->qualifiedId)) {
if (isPropertyChangesType(typeName) || context->lookupProperty(QString(), array->qualifiedId)) {
AbstractProperty modelProperty = modelNode.property(astPropertyName);
QList<UiObjectMember *> arrayMembers;
for (UiArrayMemberList *iter = array->members; iter; iter = iter->next)
......@@ -741,7 +747,7 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
const Interpreter::Value *propertyType = 0;
const Interpreter::ObjectValue *containingObject = 0;
QString name;
if (context->lookupProperty(QString(), binding->qualifiedId, &propertyType, &containingObject, &name) || typeName == QLatin1String("Qt/PropertyChanges")) {
if (context->lookupProperty(QString(), binding->qualifiedId, &propertyType, &containingObject, &name) || isPropertyChangesType(typeName)) {
AbstractProperty modelProperty = modelNode.property(astPropertyName);
if (context->isArrayProperty(propertyType, containingObject, name)) {
syncArrayProperty(modelProperty, QList<QmlJS::AST::UiObjectMember*>() << member, context, differenceHandler);
......@@ -849,7 +855,7 @@ QString TextToModelMerger::syncScriptBinding(ModelNode &modelNode,
return QString();
if (isLiteralValue(script)) {
if (modelNode.type() == QLatin1String("Qt/PropertyChanges")) {
if (isPropertyChangesType(modelNode.type())) {
AbstractProperty modelProperty = modelNode.property(astPropertyName);
const QVariant variantValue(deEscape(stripQuotes(astValue)));
syncVariantProperty(modelProperty, variantValue, QString(), differenceHandler);
......@@ -874,7 +880,7 @@ QString TextToModelMerger::syncScriptBinding(ModelNode &modelNode,
syncVariantProperty(modelProperty, enumValue, QString(), differenceHandler); // TODO: parse type
return astPropertyName;
} else { // Not an enum, so:
if (modelNode.type() == QLatin1String("Qt/PropertyChanges") || context->lookupProperty(prefix, script->qualifiedId)) {
if (isPropertyChangesType(modelNode.type()) || context->lookupProperty(prefix, script->qualifiedId)) {
AbstractProperty modelProperty = modelNode.property(astPropertyName);
syncExpressionProperty(modelProperty, astValue, QString(), differenceHandler); // TODO: parse type
return astPropertyName;
......
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