diff --git a/src/libs/qmljs/qmljsdocument.cpp b/src/libs/qmljs/qmljsdocument.cpp index 88c8caaa51b3d7429a68b9ea3342d337aaf79398..38b9f133cc30d849be36d3e09806a2f692dc7d6f 100644 --- a/src/libs/qmljs/qmljsdocument.cpp +++ b/src/libs/qmljs/qmljsdocument.cpp @@ -35,6 +35,7 @@ #include <qmljs/parser/qmljsnodepool_p.h> #include <qmljs/parser/qmljsastfwd_p.h> #include <QtCore/QDir> +#include <QtCore/QDebug> using namespace QmlJS; using namespace QmlJS::AST; @@ -57,6 +58,7 @@ Document::Document(const QString &fileName) || fileInfo.suffix() == QLatin1String("qmlproject")) { _isQmlDocument = true; _componentName = fileInfo.baseName(); + qDebug() << _componentName; if (! _componentName.isEmpty()) { // ### TODO: check the component name. diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp index 072710bac827fc70b9bae0397e6dbdba16b926e2..57f3dd990768d5474cee21e745b6814d16580524 100644 --- a/src/libs/qmljs/qmljslink.cpp +++ b/src/libs/qmljs/qmljslink.cpp @@ -149,19 +149,6 @@ void Link::linkImports() } } -static QString componentName(const QString &fileName) -{ - QString componentName = fileName; - int sepIndex = componentName.lastIndexOf(QDir::separator()); - if (sepIndex != -1) - componentName.remove(0, sepIndex + 1); - int dotIndex = componentName.indexOf(QLatin1Char('.')); - if (dotIndex != -1) - componentName.truncate(dotIndex); - componentName[0] = componentName[0].toUpper(); - return componentName; -} - void Link::populateImportedTypes(Interpreter::ObjectValue *typeEnv, Document::Ptr doc) { if (! (doc->qmlProgram() && doc->qmlProgram()->imports)) @@ -178,7 +165,7 @@ void Link::populateImportedTypes(Interpreter::ObjectValue *typeEnv, Document::Pt if (otherDoc == doc) continue; - typeEnv->setProperty(componentName(otherDoc->fileName()), + typeEnv->setProperty(otherDoc->componentName(), otherDoc->bind()->rootObjectValue()); } @@ -226,7 +213,7 @@ void Link::importFile(Interpreter::ObjectValue *typeEnv, Document::Ptr doc, } foreach (Document::Ptr importedDoc, _documentByPath.values(path)) { - const QString targetName = componentName(importedDoc->fileName()); + const QString targetName = importedDoc->componentName(); importNamespace->setProperty(targetName, importedDoc->bind()->rootObjectValue()); } } @@ -236,7 +223,7 @@ void Link::importFile(Interpreter::ObjectValue *typeEnv, Document::Ptr doc, if (import->importId) { targetName = import->importId->asString(); } else { - targetName = componentName(importedDoc->fileName()); + targetName = importedDoc->componentName(); } importNamespace->setProperty(targetName, importedDoc->bind()->rootObjectValue()); diff --git a/tests/manual/qml/testfiles/usingbutton.qml b/tests/manual/qml/testfiles/usingbutton.qml index 27375c89574fe2b1c951dd0325e12efdcb6ba6a2..de1d033cbd35876dba3629b11e430bbeab247f02 100644 --- a/tests/manual/qml/testfiles/usingbutton.qml +++ b/tests/manual/qml/testfiles/usingbutton.qml @@ -1,11 +1,11 @@ import Qt 4.6 -import "components" +import "components" as X Rectangle { width: 640 height: 480 - MyButton { + X.MyButton { } -} \ No newline at end of file +}