Commit 583cf298 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner: use '.' instead of '/' for package names

Using '/' was legacy and is just confusing.
The code is way more consistent now with QmlJS and does not require
conversions.
parent 0200927d
......@@ -327,7 +327,7 @@ QString FormEditorWidget::contextHelpId() const
QString helpId;
if (!nodes.isEmpty()) {
helpId = nodes.first().type();
helpId.replace("QtQuick/", "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("QtQuick/Rectangle", 1, 0);
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("QtQuick/Rectangle", 1, 0);
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("QtQuick/", "QML.");
helpId.replace("QtQuick", "QML");
}
return helpId;
......
......@@ -155,7 +155,7 @@ void DesignDocumentControllerView::fromClipboard()
QString DesignDocumentControllerView::toText() const
{
QScopedPointer<Model> outputModel(Model::create("QtQuick/Rectangle", 1, 0));
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("QtQuick/Rectangle", 1, 0));
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("QtQuick/Gradient", 1, 0);
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("QtQuick/GradientStop", 1, 0);
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);
......
......@@ -313,13 +313,21 @@ PropertyEditor::~PropertyEditor()
qDeleteAll(m_typeHash);
}
static inline QString fixTypeNameForPanes(const QString &typeName)
{
QString fixedTypeName = typeName;
fixedTypeName.replace(".", "/");
fixedTypeName.replace("QtQuick/", "Qt/");
return fixedTypeName;
}
void PropertyEditor::setupPane(const QString &typeName)
{
QUrl qmlFile = fileToUrl(locateQmlFile(QLatin1String("Qt/ItemPane.qml")));
QUrl qmlSpecificsFile;
qmlSpecificsFile = fileToUrl(locateQmlFile(typeName + "Specifics.qml"));
qmlSpecificsFile = fileToUrl(locateQmlFile(fixTypeNameForPanes(typeName) + "Specifics.qml"));
NodeType *type = m_typeHash.value(qmlFile.toString());
if (!type) {
......@@ -509,8 +517,8 @@ void PropertyEditor::updateSize()
void PropertyEditor::setupPanes()
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
setupPane("QtQuick/Rectangle");
setupPane("QtQuick/Text");
setupPane("QtQuick.Rectangle");
setupPane("QtQuick.Text");
resetView();
m_setupCompleted = true;
QApplication::restoreOverrideCursor();
......@@ -642,7 +650,7 @@ void PropertyEditor::resetView()
QUrl qmlFile(qmlForNode(m_selectedNode, specificsClassName));
QUrl qmlSpecificsFile;
if (m_selectedNode.isValid())
qmlSpecificsFile = fileToUrl(locateQmlFile(m_selectedNode.type() + "Specifics.qml"));
qmlSpecificsFile = fileToUrl(locateQmlFile(fixTypeNameForPanes(m_selectedNode.type()) + "Specifics.qml"));
QString specificQmlData;
......@@ -882,9 +890,9 @@ void PropertyEditor::reloadQml()
QString PropertyEditor::qmlFileName(const NodeMetaInfo &nodeInfo) const
{
if (nodeInfo.typeName().split('/').last() == "QDeclarativeItem")
return "Qt/ItemPane.qml";
const QString fixedTypeName = nodeInfo.typeName().replace("QtQuick/", "Qt/");
if (nodeInfo.typeName().split('.').last() == "QDeclarativeItem")
return "Qt/ItemPane.qml";
const QString fixedTypeName = fixTypeNameForPanes(nodeInfo.typeName());
return fixedTypeName + QLatin1String("Pane.qml");
}
......
......@@ -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", -1, -1));
Q_ASSERT(stateNode.metaInfo().isSubclassOf("QtQuick.State", -1, -1));
NodeListProperty parentProperty = stateNode.parentProperty().toNodeListProperty();
if (parentProperty.count() <= 1) {
......
......@@ -43,6 +43,7 @@ InstanceContainer::InstanceContainer()
InstanceContainer::InstanceContainer(qint32 instanceId, const QString &type, int majorNumber, int minorNumber, const QString &componentPath)
: m_instanceId(instanceId), m_type(type), m_majorNumber(majorNumber), m_minorNumber(minorNumber), m_componentPath(componentPath)
{
m_type.replace(".", "/");
}
qint32 InstanceContainer::instanceId() const
......
......@@ -142,7 +142,7 @@ NodeInstanceView::~NodeInstanceView()
bool isSkippedNode(const ModelNode &node)
{
static QStringList skipList = QStringList() << "Qt/ListModel" << "QtQuick/ListModel";
static QStringList skipList = QStringList() << "Qt.ListModel" << "QtQuick.ListModel";
if (skipList.contains(node.type()))
return true;
......
......@@ -98,7 +98,7 @@ void MetaInfoPrivate::initialize()
QString static inline stripPrefix(const QString &typeName)
{
QStringList list = typeName.split('/');
QStringList list = typeName.split('.');
if (list.count() == 2)
return list.last();
return typeName;
......@@ -109,7 +109,7 @@ static inline bool isDepricatedQtType(const QString &typeName)
if (typeName.length() < 8)
return false;
return typeName.contains("QtQuick/");
return typeName.contains("Qt.");
}
void MetaInfoPrivate::parseXmlFiles()
......
......@@ -104,8 +104,8 @@ public:
type = ref->ast()->memberType->asString();
m_properties.append(qMakePair(name, type));
} else {
if (const Interpreter::QmlObjectValue * ov = dynamic_cast<const Interpreter::QmlObjectValue *>(value)) {
QString qualifiedTypeName = ov->packageName().isEmpty() ? ov->className() : ov->packageName() + '/' + ov->className();
if (const Interpreter::QmlObjectValue * ov = dynamic_cast<const Interpreter::QmlObjectValue *>(value)) {
QString qualifiedTypeName = ov->packageName().isEmpty() ? ov->className() : ov->packageName() + "." + ov->className();
m_properties.append(qMakePair(name, qualifiedTypeName));
} else {
Interpreter::TypeId typeId;
......@@ -158,11 +158,11 @@ QStringList prototypes(const Interpreter::ObjectValue *ov, LookupContext::Ptr co
const Interpreter::QmlObjectValue * qmlValue = dynamic_cast<const Interpreter::QmlObjectValue *>(ov);
if (qmlValue) {
if (versions) {
list << qmlValue->packageName() + '/' + qmlValue->className() +
' ' + QString::number(qmlValue->version().majorVersion()) +
'.' + QString::number(qmlValue->version().minorVersion());
list << qmlValue->packageName() + "." + qmlValue->className() +
" " + QString::number(qmlValue->version().majorVersion()) +
"." + QString::number(qmlValue->version().minorVersion());
} else {
list << qmlValue->packageName() + '/' + qmlValue->className();
list << qmlValue->packageName() + "." + qmlValue->className();
}
} else {
if (versions) {
......@@ -424,14 +424,14 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, QString type, int maj, in
setupPrototypes();
m_isValid = true;
} else {
m_qualfiedTypeName = m_qualfiedTypeName.split('/').last();
m_qualfiedTypeName = m_qualfiedTypeName.split('.').last();
const Interpreter::ObjectValue *objectValue = getObjectValue();
if (objectValue) {
const Interpreter::QmlObjectValue *qmlValue = dynamic_cast<const Interpreter::QmlObjectValue *>(objectValue);
if (qmlValue) {
m_majorVersion = qmlValue->version().majorVersion();
m_minorVersion = qmlValue->version().minorVersion();
m_qualfiedTypeName = qmlValue->packageName() + '/' + qmlValue->className();
m_qualfiedTypeName = qmlValue->packageName() + '.' + qmlValue->className();
} else {
m_isComponent = true;
}
......@@ -654,7 +654,7 @@ bool NodeMetaInfoPrivate::cleverCheckType(const QString &otherType) const
if (isComponent())
return false;
QStringList split = otherType.split('/');
QStringList split = otherType.split('.');
QString package;
QString typeName = otherType;
if (split.count() > 1) {
......@@ -662,7 +662,7 @@ bool NodeMetaInfoPrivate::cleverCheckType(const QString &otherType) const
typeName = split.at(1);
}
if (packageName() == package)
return QString(package + "/" + typeName) == qualfiedTypeName();
return QString(package + "." + typeName) == qualfiedTypeName();
const LanguageUtils::FakeMetaObject::Export exp =
getQmlObjectValue()->metaObject()->exportInPackage(package);
......@@ -755,7 +755,7 @@ QString NodeMetaInfoPrivate::lookupName() const
QString className = m_qualfiedTypeName;
QString packageName;
QStringList packageClassName = m_qualfiedTypeName.split(QLatin1Char('/'));
QStringList packageClassName = m_qualfiedTypeName.split(QLatin1Char('.'));
if (packageClassName.size() > 1) {
className = packageClassName.takeLast();
packageName = packageClassName.join(QLatin1String("."));
......@@ -770,8 +770,6 @@ QString NodeMetaInfoPrivate::lookupName() const
QStringList NodeMetaInfoPrivate::lookupNameComponent() const
{
QString tempString = m_qualfiedTypeName;
tempString.replace('/', '.');
return tempString.split(".");
}
......@@ -803,7 +801,7 @@ void NodeMetaInfoPrivate::setupPrototypes()
description.minorVersion = qmlValue->version().minorVersion();
description.majorVersion = qmlValue->version().majorVersion();
if (!qmlValue->packageName().isEmpty())
description.className = qmlValue->packageName() + '/' + description.className;
description.className = qmlValue->packageName() + "." + description.className;
m_prototypes.append(description);
} else {
if (lookupContext()->context()->lookupType(document(), QStringList() << ov->className()))
......
......@@ -317,7 +317,7 @@ void SubComponentManagerPrivate::unregisterQmlFile(const QFileInfo &fileInfo, co
{
QString componentName = fileInfo.baseName();
if (!qualifier.isEmpty())
componentName = qualifier + '/' + componentName;
componentName = qualifier + '.' + componentName;
}
static inline bool isDepricatedQtType(const QString &typeName)
......@@ -325,7 +325,7 @@ static inline bool isDepricatedQtType(const QString &typeName)
if (typeName.length() < 8)
return false;
return typeName.contains("QtQuick/");
return typeName.contains("Qt.");
}
......@@ -338,7 +338,7 @@ void SubComponentManagerPrivate::registerQmlFile(const QFileInfo &fileInfo, cons
QString fixedQualifier = qualifier;
if (qualifier.right(1) == QLatin1String("."))
fixedQualifier.chop(1); //remove last char if it is a dot
componentName = fixedQualifier + '/' + componentName;
componentName = fixedQualifier + '.' + componentName;
}
if (debug)
......
......@@ -248,7 +248,7 @@ QString ModelNode::simplifiedTypeName() const
throw InvalidModelNodeException(__LINE__, __FUNCTION__, __FILE__);
}
return type().split(QLatin1Char('/')).last();
return type().split(QLatin1Char('.')).last();
}
/*! \brief Returns whether the node is valid
......
......@@ -55,12 +55,12 @@ void QmlModelStateOperation::setTarget(const ModelNode &target)
bool QmlPropertyChanges::isValid() const
{
return QmlModelNodeFacade::isValid() && modelNode().metaInfo().isSubclassOf("QtQuick/PropertyChanges", -1, -1);
return QmlModelNodeFacade::isValid() && modelNode().metaInfo().isSubclassOf("QtQuick.PropertyChanges", -1, -1);
}
bool QmlModelStateOperation::isValid() const
{
return QmlModelNodeFacade::isValid() && modelNode().metaInfo().isSubclassOf("Qt/QDeclarativeStateOperation", -1, -1);
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("QtQuick/Item", -1, -1);
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("QtQuick/State", 1, 0, 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("QtQuick/Image", 1, 0, propertyPairList);
newNode = createQmlItemNode("QtQuick.Image", 1, 0, propertyPairList);
parentNode.nodeAbstractProperty("data").reparentHere(newNode);
Q_ASSERT(newNode.isValid());
......@@ -171,8 +171,8 @@ QmlItemNode QmlModelView::createQmlItemNode(const ItemLibraryEntry &itemLibraryE
QmlItemNode newNode;
RewriterTransaction transaction = beginRewriterTransaction();
{
if (itemLibraryEntry.typeName().contains('/')) {
const QString newImportUrl = itemLibraryEntry.typeName().split('/').first();
if (itemLibraryEntry.typeName().contains('.')) {
const QString newImportUrl = itemLibraryEntry.typeName().split('.').first();
const QString newImportVersion = QString("%1.%2").arg(QString::number(itemLibraryEntry.majorVersion()), QString::number(itemLibraryEntry.minorVersion()));
Import newImport = Import::createLibraryImport(newImportUrl, newImportVersion);
......
......@@ -183,7 +183,7 @@ void QmlModelState::addChangeSetIfNotExists(const ModelNode &node)
return; //changeSet already there
}
ModelNode newChangeSet = modelNode().view()->createModelNode("QtQuick/PropertyChanges", 1, 0);
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("QtQuick/State", 1, 0) || 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("QtQuick/State", 1, 0, 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()));
......
......@@ -137,8 +137,8 @@ QString QmlTextGenerator::toQml(const ModelNode &node, int indentDepth) const
{
QString type = node.type();
QString url;
if (type.contains('/')) {
const QStringList nameComponents = type.split('/');
if (type.contains('.')) {
QStringList nameComponents = type.split(".");
url = nameComponents.first();
type = nameComponents.last();
}
......
......@@ -231,7 +231,7 @@ bool ChangeTypeRewriteAction::execute(QmlDesigner::QmlRefactoring &refactoring,
bool result = false;
QString newNodeType = m_node.type();
const int slashIdx = newNodeType.lastIndexOf('/');
const int slashIdx = newNodeType.lastIndexOf('.');
if (slashIdx != -1)
newNodeType = newNodeType.mid(slashIdx + 1);
......
......@@ -221,12 +221,12 @@ static inline QVariant convertDynamicPropertyValueToVariant(const QString &astVa
static bool isComponentType(const QString &type)
{
return type == QLatin1String("Component") || type == QLatin1String("Qt/Component") || type == QLatin1String("QtQuick/Component");
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");
return type == QLatin1String("PropertyChanges") || type == QLatin1String("QtQuick.PropertyChanges") || type == QLatin1String("Qt.PropertyChanges");
}
......@@ -269,7 +269,7 @@ public:
const Interpreter::QmlObjectValue * qmlValue = dynamic_cast<const Interpreter::QmlObjectValue *>(value);
if (qmlValue) {
typeName = fixUpPackeNameForQt(qmlValue->packageName()) + QLatin1String("/") + qmlValue->className();
typeName = fixUpPackeNameForQt(qmlValue->packageName()) + QLatin1String(".") + qmlValue->className();
//### todo this is just a hack to support QtQuick 1.0
majorVersion = fixUpMajorVersionForQt(qmlValue->packageName(), qmlValue->version().majorVersion());
......
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