diff --git a/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp b/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp index 91849d5ab37..9753ebe3a1f 100644 --- a/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp +++ b/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp @@ -43,58 +43,12 @@ namespace Qt4ProjectManager { namespace Internal { -const QString qmldir(QLatin1String("qmldir")); -const QString qmldir_plugin(QLatin1String("plugin")); const QString appViewerBaseName(QLatin1String("qmlapplicationviewer")); const QString appViewerPriFileName(appViewerBaseName + QLatin1String(".pri")); const QString appViewerCppFileName(appViewerBaseName + QLatin1String(".cpp")); const QString appViewerHFileName(appViewerBaseName + QLatin1String(".h")); const QString appViewerOriginsSubDir(appViewerBaseName + QLatin1Char('/')); -QmlModule::QmlModule(const QString &uri, const QFileInfo &rootDir, const QFileInfo &qmldir, - bool isExternal, QtQuickApp *qtQuickApp) - : uri(uri) - , rootDir(rootDir) - , qmldir(qmldir) - , isExternal(isExternal) - , qtQuickApp(qtQuickApp) -{} - -QString QmlModule::path(Path path) const -{ - switch (path) { - case Root: { - return rootDir.canonicalFilePath(); - } - case ContentDir: { - const QDir proFile(qtQuickApp->path(QtQuickApp::AppProPath)); - return proFile.relativeFilePath(qmldir.canonicalPath()); - } - case ContentBase: { - const QString localRoot = rootDir.canonicalFilePath() + QLatin1Char('/'); - QDir contentDir = qmldir.dir(); - contentDir.cdUp(); - const QString localContentDir = contentDir.canonicalPath(); - return localContentDir.right(localContentDir.length() - localRoot.length()); - } - case DeployedContentBase: { - const QString modulesDir = qtQuickApp->path(QtQuickApp::ModulesDir); - return modulesDir + QLatin1Char('/') + this->path(ContentBase); - } - default: qFatal("QmlModule::path() needs more work"); - } - return QString(); -} - -QmlCppPlugin::QmlCppPlugin(const QString &name, const QFileInfo &path, - const QmlModule *module, const QFileInfo &proFile) - : name(name) - , path(path) - , module(module) - , proFile(proFile) -{ -} - QtQuickApp::QtQuickApp() : AbstractMobileApp() , m_mainQmlMode(ModeGenerate) @@ -103,11 +57,6 @@ QtQuickApp::QtQuickApp() m_canSupportMeegoBooster = true; } -QtQuickApp::~QtQuickApp() -{ - clearModulesAndPlugins(); -} - void QtQuickApp::setComponentSet(ComponentSet componentSet) { m_componentSet = componentSet; @@ -130,47 +79,6 @@ QtQuickApp::Mode QtQuickApp::mainQmlMode() const return m_mainQmlMode; } -bool QtQuickApp::setExternalModules(const QStringList &uris, - const QStringList &importPaths) -{ - clearModulesAndPlugins(); - m_importPaths.clear(); - foreach (const QFileInfo &importPath, importPaths) { - if (!importPath.exists()) { - m_error = QCoreApplication::translate( - "Qt4ProjectManager::Internal::QtQuickApp", - "The QML import path '%1' cannot be found.") - .arg(QDir::toNativeSeparators(importPath.filePath())); - return false; - } else { - m_importPaths.append(importPath.canonicalFilePath()); - } - } - foreach (const QString &uri, uris) { - QString uriPath = uri; - uriPath.replace(QLatin1Char('.'), QLatin1Char('/')); - const int modulesCount = m_modules.count(); - foreach (const QFileInfo &importPath, m_importPaths) { - const QFileInfo qmlDirFile( - importPath.absoluteFilePath() + QLatin1Char('/') - + uriPath + QLatin1Char('/') + qmldir); - if (qmlDirFile.exists()) { - if (!addExternalModule(uri, importPath, qmlDirFile)) - return false; - break; - } - } - if (modulesCount == m_modules.count()) { // no module was added - m_error = QCoreApplication::translate( - "Qt4ProjectManager::Internal::QtQuickApp", - "The QML module '%1' cannot be found.").arg(uri); - return false; - } - } - m_error.clear(); - return true; -} - QString QtQuickApp::pathExtended(int fileType) const { const bool importQmlFile = m_mainQmlMode == ModeImport; @@ -205,7 +113,6 @@ QString QtQuickApp::pathExtended(int fileType) const case QmlDir: return pathBase + qmlSubDir; case QmlDirProFileRelative: return importQmlFile ? appProFilePath.relativeFilePath(m_mainQmlFile.canonicalPath()) : QString(qmlSubDir).remove(qmlSubDir.length() - 1, 1); - case ModulesDir: return QLatin1String("modules"); default: qFatal("QtQuickApp::pathExtended() needs more work"); } return QString(); @@ -225,14 +132,9 @@ bool QtQuickApp::adaptCurrentMainCppTemplateLine(QString &line) const { const QLatin1Char quote('"'); - if (line.contains(QLatin1String("// MAINQML"))) { + if (line.contains(QLatin1String("// MAINQML"))) insertParameter(line, quote + path(MainQmlDeployed) + quote); - } else if (line.contains(QLatin1String("// ADDIMPORTPATH"))) { - if (m_modules.isEmpty()) - return false; - else - insertParameter(line, quote + path(ModulesDir) + quote); - } + return true; } @@ -245,17 +147,7 @@ void QtQuickApp::handleCurrentProFileTemplateLine(const QString &line, QString nextLine = proFileTemplate.readLine(); // eats 'QML_IMPORT_PATH =' if (!nextLine.startsWith(QLatin1String("QML_IMPORT_PATH ="))) return; - - proFile << nextLine; - - const QLatin1String separator(" \\\n "); - const QDir proPath(path(AppProPath)); - foreach (const QString &importPath, m_importPaths) { - const QString relativePath = proPath.relativeFilePath(importPath); - proFile << separator << relativePath; - } - - proFile << endl; + proFile << nextLine << endl; } else if (line.contains(QLatin1String("# HARMATTAN_BOOSTABLE"))) { QString nextLine = proFileTemplate.readLine(); // eats '# CONFIG += qdeclarative-boostable' if (supportsMeegoBooster()) @@ -264,83 +156,6 @@ void QtQuickApp::handleCurrentProFileTemplateLine(const QString &line, } } -void QtQuickApp::clearModulesAndPlugins() -{ - qDeleteAll(m_modules); - m_modules.clear(); - qDeleteAll(m_cppPlugins); - m_cppPlugins.clear(); -} - -bool QtQuickApp::addCppPlugin(const QString &qmldirLine, QmlModule *module) -{ - const QStringList qmldirLineElements = - qmldirLine.split(QLatin1Char(' '), QString::SkipEmptyParts); - if (qmldirLineElements.count() < 2) { - m_error = QCoreApplication::translate( - "Qt4ProjectManager::Internal::QtQuickApp", - "Invalid '%1' entry in '%2' of module '%3'.") - .arg(qmldir_plugin).arg(qmldir).arg(module->uri); - return false; - } - const QString name = qmldirLineElements.at(1); - const QFileInfo path(module->qmldir.dir(), qmldirLineElements.value(2, QString())); - - // TODO: Add more magic to find a good .pro file.. - const QString proFileName = name + QLatin1String(".pro"); - const QFileInfo proFile_guess1(module->qmldir.dir(), proFileName); - const QFileInfo proFile_guess2(QString(module->qmldir.dir().absolutePath() + QLatin1String("/../")), - proFileName); - const QFileInfo proFile_guess3(module->qmldir.dir(), - QFileInfo(module->qmldir.path()).fileName() + QLatin1String(".pro")); - const QFileInfo proFile_guess4(proFile_guess3.absolutePath() + QLatin1String("/../") - + proFile_guess3.fileName()); - - QFileInfo foundProFile; - if (proFile_guess1.exists()) { - foundProFile = proFile_guess1.canonicalFilePath(); - } else if (proFile_guess2.exists()) { - foundProFile = proFile_guess2.canonicalFilePath(); - } else if (proFile_guess3.exists()) { - foundProFile = proFile_guess3.canonicalFilePath(); - } else if (proFile_guess4.exists()) { - foundProFile = proFile_guess4.canonicalFilePath(); - } else { - m_error = QCoreApplication::translate( - "Qt4ProjectManager::Internal::QtQuickApp", - "No .pro file for plugin '%1' can be found.").arg(name); - return false; - } - QmlCppPlugin *plugin = - new QmlCppPlugin(name, path, module, foundProFile); - m_cppPlugins.append(plugin); - module->cppPlugins.insert(name, plugin); - return true; -} - -bool QtQuickApp::addCppPlugins(QmlModule *module) -{ - QFile qmlDirFile(module->qmldir.absoluteFilePath()); - if (qmlDirFile.open(QIODevice::ReadOnly)) { - QTextStream in(&qmlDirFile); - QString line; - while (!(line = in.readLine()).isNull()) { - line = line.trimmed(); - if (line.startsWith(qmldir_plugin) && !addCppPlugin(line, module)) - return false; - }; - } - return true; -} - -bool QtQuickApp::addExternalModule(const QString &name, const QFileInfo &dir, - const QFileInfo &contentDir) -{ - QmlModule *module = new QmlModule(name, dir, contentDir, true, this); - m_modules.append(module); - return addCppPlugins(module); -} - #ifndef CREATORLESSTEST Core::GeneratedFiles QtQuickApp::generateFiles(QString *errorMessage) const { @@ -365,11 +180,6 @@ bool QtQuickApp::useExistingMainQml() const return !m_mainQmlFile.filePath().isEmpty(); } -const QList QtQuickApp::modules() const -{ - return m_modules; -} - QByteArray QtQuickApp::generateFileExtended(int fileType, bool *versionAndCheckSum, QString *comment, QString *errorMessage) const { @@ -438,9 +248,6 @@ QList QtQuickApp::deploymentFolders() const { QList result; result.append(DeploymentFolder(path(QmlDirProFileRelative), QLatin1String("qml"))); - foreach (const QmlModule *module, m_modules) - if (module->isExternal) - result.append(DeploymentFolder(module->path(QmlModule::ContentDir), module->path(QmlModule::DeployedContentBase))); return result; } diff --git a/src/plugins/qt4projectmanager/wizards/qtquickapp.h b/src/plugins/qt4projectmanager/wizards/qtquickapp.h index 6696aafa492..e4531664faa 100644 --- a/src/plugins/qt4projectmanager/wizards/qtquickapp.h +++ b/src/plugins/qt4projectmanager/wizards/qtquickapp.h @@ -39,42 +39,6 @@ namespace Qt4ProjectManager { namespace Internal { -class QtQuickApp; -struct QmlCppPlugin; - -struct QmlModule -{ - enum Path { - // Example: Module "com.foo.bar" in "c:/modules/". - // "qmldir" file is in "c:/modules/com/foo/bar/". - // Application .pro file is "c:/app/app.pro". - Root, // "c:/modules/" (absolute) - ContentDir, // "../modules/com/foo/bar" (relative form .pro file) - ContentBase, // "com/foo/" - DeployedContentBase // "/com/foo" (on deploy target) - }; - - QmlModule(const QString &name, const QFileInfo &rootDir, const QFileInfo &qmldir, - bool isExternal, QtQuickApp *qtQuickApp); - QString path(Path path) const; - const QString uri; // "com.foo.bar" - const QFileInfo rootDir; // Location of "com/" - const QFileInfo qmldir; // 'qmldir' file. - const bool isExternal; // Either external or inside a source paths - const QtQuickApp *qtQuickApp; - QHash cppPlugins; // Just as info. No ownership. -}; - -struct QmlCppPlugin -{ - QmlCppPlugin(const QString &name, const QFileInfo &path, - const QmlModule *module, const QFileInfo &proFile); - const QString name; // Original name - const QFileInfo path; // Plugin path where qmldir points to - const QmlModule *module; - const QFileInfo proFile; // .pro file for the plugin -}; - struct QtQuickAppGeneratedFileInfo : public AbstractGeneratedFileInfo { enum ExtendedFileType { @@ -103,7 +67,6 @@ public: AppViewerHOrigin, QmlDir, QmlDirProFileRelative, - ModulesDir, MainPageQml, MainPageQmlOrigin }; @@ -119,14 +82,12 @@ public: }; QtQuickApp(); - virtual ~QtQuickApp(); void setComponentSet(ComponentSet componentSet); ComponentSet componentSet() const; void setMainQml(Mode mode, const QString &file = QString()); Mode mainQmlMode() const; - bool setExternalModules(const QStringList &uris, const QStringList &importPaths); #ifndef CREATORLESSTEST virtual Core::GeneratedFiles generateFiles(QString *errorMessage) const; @@ -134,7 +95,6 @@ public: bool generateFiles(QString *errorMessage) const; #endif // CREATORLESSTEST bool useExistingMainQml() const; - const QList modules() const; static const int StubVersion; @@ -152,18 +112,10 @@ private: QList updateableFiles(const QString &mainProFile) const; QList deploymentFolders() const; - bool addExternalModule(const QString &uri, const QFileInfo &dir, - const QFileInfo &contentDir); - bool addCppPlugins(QmlModule *module); - bool addCppPlugin(const QString &qmldirLine, QmlModule *module); - void clearModulesAndPlugins(); QString componentSetDir(ComponentSet componentSet) const; QFileInfo m_mainQmlFile; Mode m_mainQmlMode; - QStringList m_importPaths; - QList m_modules; - QList m_cppPlugins; ComponentSet m_componentSet; }; diff --git a/tests/manual/appwizards/main.cpp b/tests/manual/appwizards/main.cpp index 532aecdb829..3e8c03276eb 100644 --- a/tests/manual/appwizards/main.cpp +++ b/tests/manual/appwizards/main.cpp @@ -59,26 +59,6 @@ int main(int argc, char *argv[]) return 1; } - { - const QString rootPath = QLatin1String("../appwizards/qmlimportscenario_02/"); - QtQuickApp sAppImport02; - sAppImport02.setProjectPath(projectPath); - sAppImport02.setProjectName(QLatin1String("qml_imported_scenario_02")); - sAppImport02.setMainQml(QtQuickApp::ModeImport, rootPath + QLatin1String("subfolder1/myqmlapp.qml")); - QStringList moduleNames; - moduleNames.append(QLatin1String("no.trolltech.QmlModule01")); - moduleNames.append(QLatin1String("com.nokia.QmlModule02")); - QStringList importPaths; - importPaths.append(rootPath + QLatin1String("subfolder2/")); - importPaths.append(rootPath + QLatin1String("subfolder3/")); - if (!sAppImport02.setExternalModules(moduleNames, importPaths)) { - qDebug() << sAppImport02.error(); - return 2; - } - if (!sAppImport02.generateFiles(&errorMessage)) - return 1; - } - { Html5App sAppNew; sAppNew.setProjectPath(projectPath); diff --git a/tests/manual/appwizards/qmlimportscenario_02/myqmlapp.qmlproject b/tests/manual/appwizards/qmlimportscenario_02/myqmlapp.qmlproject deleted file mode 100644 index 1040b01e313..00000000000 --- a/tests/manual/appwizards/qmlimportscenario_02/myqmlapp.qmlproject +++ /dev/null @@ -1,17 +0,0 @@ -import QmlProject 1.0 - -Project { - QmlFiles { - directory: "subfolder1" - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - importPaths: [ - "subfolder2", - "subfolder3" - ] -} diff --git a/tests/manual/appwizards/qmlimportscenario_02/subfolder1/myqmlapp.qml b/tests/manual/appwizards/qmlimportscenario_02/subfolder1/myqmlapp.qml deleted file mode 100644 index d087bd9869f..00000000000 --- a/tests/manual/appwizards/qmlimportscenario_02/subfolder1/myqmlapp.qml +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - width: 360 - height: 360 - Text { - text: "Hello World" - anchors.centerIn: parent - } - MouseArea { - anchors.fill: parent - onClicked: { - Qt.quit(); - } - } -} diff --git a/tests/manual/appwizards/qmlimportscenario_02/subfolder2/no/trolltech/QmlModule01/QmlComponent01.qml b/tests/manual/appwizards/qmlimportscenario_02/subfolder2/no/trolltech/QmlModule01/QmlComponent01.qml deleted file mode 100644 index 5b0585dac7d..00000000000 --- a/tests/manual/appwizards/qmlimportscenario_02/subfolder2/no/trolltech/QmlModule01/QmlComponent01.qml +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -import Qt 4.7 - -Rectangle { - color: "#ddffdd" - - Image { - source: "apple.svg" - anchors.right: parent.right - anchors.bottom: parent.bottom - } - - Text { - text: "QmlComponent01" - font.pointSize: 14 - } -} diff --git a/tests/manual/appwizards/qmlimportscenario_02/subfolder2/no/trolltech/QmlModule01/apple.svg b/tests/manual/appwizards/qmlimportscenario_02/subfolder2/no/trolltech/QmlModule01/apple.svg deleted file mode 100644 index 31288ecce45..00000000000 --- a/tests/manual/appwizards/qmlimportscenario_02/subfolder2/no/trolltech/QmlModule01/apple.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - \ No newline at end of file diff --git a/tests/manual/appwizards/qmlimportscenario_02/subfolder2/no/trolltech/QmlModule01/qmldir b/tests/manual/appwizards/qmlimportscenario_02/subfolder2/no/trolltech/QmlModule01/qmldir deleted file mode 100644 index 3a36c143306..00000000000 --- a/tests/manual/appwizards/qmlimportscenario_02/subfolder2/no/trolltech/QmlModule01/qmldir +++ /dev/null @@ -1 +0,0 @@ -QmlComponent01 1.0 QmlComponent01.qml \ No newline at end of file diff --git a/tests/manual/appwizards/qmlimportscenario_02/subfolder3/com/nokia/QmlModule02/QmlComponent02.qml b/tests/manual/appwizards/qmlimportscenario_02/subfolder3/com/nokia/QmlModule02/QmlComponent02.qml deleted file mode 100644 index c6a05ba6f78..00000000000 --- a/tests/manual/appwizards/qmlimportscenario_02/subfolder3/com/nokia/QmlModule02/QmlComponent02.qml +++ /dev/null @@ -1,46 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: http://www.qt-project.org/ -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -**************************************************************************/ - -import Qt 4.7 - -Rectangle { - color: "#ffdddd" - - Image { - source: "tomato.svg" - anchors.right: parent.right - anchors.bottom: parent.bottom - } - - Text { - text: "QmlComponent02" - font.pointSize: 14 - } -} diff --git a/tests/manual/appwizards/qmlimportscenario_02/subfolder3/com/nokia/QmlModule02/qmldir b/tests/manual/appwizards/qmlimportscenario_02/subfolder3/com/nokia/QmlModule02/qmldir deleted file mode 100644 index 33f694a57e4..00000000000 --- a/tests/manual/appwizards/qmlimportscenario_02/subfolder3/com/nokia/QmlModule02/qmldir +++ /dev/null @@ -1 +0,0 @@ -QmlComponent02 1.0 QmlComponent02.qml \ No newline at end of file diff --git a/tests/manual/appwizards/qmlimportscenario_02/subfolder3/com/nokia/QmlModule02/tomato.svg b/tests/manual/appwizards/qmlimportscenario_02/subfolder3/com/nokia/QmlModule02/tomato.svg deleted file mode 100644 index c0df58c20bb..00000000000 --- a/tests/manual/appwizards/qmlimportscenario_02/subfolder3/com/nokia/QmlModule02/tomato.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - \ No newline at end of file