summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@nokia.com>2011-02-09 21:39:46 +0100
committerAlessandro Portale <alessandro.portale@nokia.com>2011-02-09 21:39:46 +0100
commit8678af3240ded3b77162ab8e6dd574d06940c69b (patch)
tree967621f12e31c146ae1c54e4012b8ad9518233db /src
parent8eb0bb750776c13d21245dd4db2e3ffbe155c6ba (diff)
downloadqt-creator-8678af3240ded3b77162ab8e6dd574d06940c69b.tar.gz
Refacoring. Saner Api for QtQuickApp.
Now using an explicit Mode (generated, imported) instead of empty or set filename convention. Just like in Html5App.
Diffstat (limited to 'src')
-rw-r--r--src/plugins/qt4projectmanager/wizards/qtquickapp.cpp33
-rw-r--r--src/plugins/qt4projectmanager/wizards/qtquickapp.h10
-rw-r--r--src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp16
-rw-r--r--src/plugins/qt4projectmanager/wizards/qtquickappwizardpages.cpp30
-rw-r--r--src/plugins/qt4projectmanager/wizards/qtquickappwizardpages.h2
-rw-r--r--src/plugins/qt4projectmanager/wizards/qtquickappwizardsourcespage.ui6
6 files changed, 60 insertions, 37 deletions
diff --git a/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp b/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp
index 1c6653142d..acd18db5c0 100644
--- a/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp
+++ b/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp
@@ -98,7 +98,9 @@ QmlCppPlugin::QmlCppPlugin(const QString &name, const QFileInfo &path,
{
}
-QtQuickApp::QtQuickApp() : AbstractMobileApp()
+QtQuickApp::QtQuickApp()
+ : AbstractMobileApp()
+ , m_mainQmlMode(ModeGenerate)
{
}
@@ -107,18 +109,20 @@ QtQuickApp::~QtQuickApp()
clearModulesAndPlugins();
}
-void QtQuickApp::setMainQmlFile(const QString &qmlFile)
+void QtQuickApp::setMainQml(Mode mode, const QString &file)
{
- m_mainQmlFile.setFile(qmlFile);
+ Q_ASSERT(mode != ModeGenerate || file.isEmpty());
+ m_mainQmlMode = mode;
+ m_mainQmlFile.setFile(file);
}
-QString QtQuickApp::mainQmlFile() const
+QtQuickApp::Mode QtQuickApp::mainQmlMode() const
{
- return path(MainQml);
+ return m_mainQmlMode;
}
bool QtQuickApp::setExternalModules(const QStringList &uris,
- const QStringList &importPaths)
+ const QStringList &importPaths)
{
clearModulesAndPlugins();
m_importPaths.clear();
@@ -161,19 +165,20 @@ bool QtQuickApp::setExternalModules(const QStringList &uris,
QString QtQuickApp::pathExtended(int fileType) const
{
QString cleanProjectName = projectName().replace(QLatin1Char('-'), QString());
+ const bool importQmlFile = m_mainQmlMode == ModeImport;
const QString qmlSubDir = QLatin1String("qml/")
- + (useExistingMainQml() ? m_mainQmlFile.dir().dirName() : cleanProjectName)
- + QLatin1Char('/');
+ + (importQmlFile ? m_mainQmlFile.dir().dirName() : cleanProjectName)
+ + QLatin1Char('/');
const QString appViewerTargetSubDir = appViewerOriginsSubDir;
const QString mainQml = QLatin1String("main.qml");
const QString pathBase = outputPathBase();
const QDir appProFilePath(pathBase);
switch (fileType) {
- case MainQml: return useExistingMainQml() ? m_mainQmlFile.canonicalFilePath()
- : pathBase + qmlSubDir + mainQml;
- case MainQmlDeployed: return useExistingMainQml() ? qmlSubDir + m_mainQmlFile.fileName()
- : QString(qmlSubDir + mainQml);
+ case MainQml: return importQmlFile ? m_mainQmlFile.canonicalFilePath()
+ : pathBase + qmlSubDir + mainQml;
+ case MainQmlDeployed: return importQmlFile ? qmlSubDir + m_mainQmlFile.fileName()
+ : QString(qmlSubDir + mainQml);
case MainQmlOrigin: return originsRoot() + QLatin1String("qml/app/") + mainQml;
case AppViewerPri: return pathBase + appViewerTargetSubDir + appViewerPriFileName;
case AppViewerPriOrigin: return originsRoot() + appViewerOriginsSubDir + appViewerPriFileName;
@@ -182,8 +187,8 @@ QString QtQuickApp::pathExtended(int fileType) const
case AppViewerH: return pathBase + appViewerTargetSubDir + appViewerHFileName;
case AppViewerHOrigin: return originsRoot() + appViewerOriginsSubDir + appViewerHFileName;
case QmlDir: return pathBase + qmlSubDir;
- case QmlDirProFileRelative: return useExistingMainQml() ? appProFilePath.relativeFilePath(m_mainQmlFile.canonicalPath())
- : QString(qmlSubDir).remove(qmlSubDir.length() - 1, 1);
+ 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");
}
diff --git a/src/plugins/qt4projectmanager/wizards/qtquickapp.h b/src/plugins/qt4projectmanager/wizards/qtquickapp.h
index 88a2f11d2a..d4117dcae8 100644
--- a/src/plugins/qt4projectmanager/wizards/qtquickapp.h
+++ b/src/plugins/qt4projectmanager/wizards/qtquickapp.h
@@ -107,11 +107,16 @@ public:
ModulesDir
};
+ enum Mode {
+ ModeGenerate,
+ ModeImport
+ };
+
QtQuickApp();
virtual ~QtQuickApp();
- void setMainQmlFile(const QString &qmlFile);
- QString mainQmlFile() const;
+ void setMainQml(Mode mode, const QString &file = QString());
+ Mode mainQmlMode() const;
bool setExternalModules(const QStringList &uris, const QStringList &importPaths);
#ifndef CREATORLESSTEST
@@ -145,6 +150,7 @@ private:
void clearModulesAndPlugins();
QFileInfo m_mainQmlFile;
+ Mode m_mainQmlMode;
QStringList m_importPaths;
QList <QmlModule*> m_modules;
QList <QmlCppPlugin*> m_cppPlugins;
diff --git a/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp b/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp
index 52c146fd14..2c216bdaa8 100644
--- a/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp
+++ b/src/plugins/qt4projectmanager/wizards/qtquickappwizard.cpp
@@ -144,18 +144,22 @@ void QtQuickAppWizard::prepareGenerateFiles(const QWizard *w,
{
Q_UNUSED(errorMessage)
const QtQuickAppWizardDialog *wizard = qobject_cast<const QtQuickAppWizardDialog*>(w);
- const QString mainQmlFile = wizard->m_qmlSourcesPage->mainQmlFile();
- m_d->app->setMainQmlFile(mainQmlFile);
+ if (wizard->m_qmlSourcesPage->mainQmlMode() == QtQuickApp::ModeGenerate) {
+ m_d->app->setMainQml(QtQuickApp::ModeGenerate);
+ } else {
+ const QString mainQmlFile = wizard->m_qmlSourcesPage->mainQmlFile();
+ m_d->app->setMainQml(QtQuickApp::ModeImport, mainQmlFile);
+ }
}
bool QtQuickAppWizard::postGenerateFilesInternal(const Core::GeneratedFiles &l,
QString *errorMessage)
{
const bool success = ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage);
- if (success && !m_d->app->mainQmlFile().isEmpty()) {
- ProjectExplorer::ProjectExplorerPlugin::instance()->setCurrentFile(0, m_d->app->mainQmlFile());
- Core::EditorManager::instance()->openEditor(m_d->app->mainQmlFile(),
- QString(), Core::EditorManager::ModeSwitch);
+ const QString mainQmlFile = m_d->app->path(QtQuickApp::MainQml);
+ if (success && !mainQmlFile.isEmpty()) {
+ ProjectExplorer::ProjectExplorerPlugin::instance()->setCurrentFile(0, mainQmlFile);
+ Core::EditorManager::instance()->openEditor(mainQmlFile, QString(), Core::EditorManager::ModeSwitch);
}
return success;
}
diff --git a/src/plugins/qt4projectmanager/wizards/qtquickappwizardpages.cpp b/src/plugins/qt4projectmanager/wizards/qtquickappwizardpages.cpp
index 7769100cca..7bfaeb9709 100644
--- a/src/plugins/qt4projectmanager/wizards/qtquickappwizardpages.cpp
+++ b/src/plugins/qt4projectmanager/wizards/qtquickappwizardpages.cpp
@@ -54,15 +54,15 @@ QtQuickAppWizardSourcesPage::QtQuickAppWizardSourcesPage(QWidget *parent)
, m_d(new QtQuickAppWizardSourcesPagePrivate)
{
m_d->ui.setupUi(this);
- m_d->ui.mainQmlFileLineEdit->setExpectedKind(Utils::PathChooser::File);
- m_d->ui.mainQmlFileLineEdit->setPromptDialogFilter(QLatin1String("*.qml"));
- m_d->ui.mainQmlFileLineEdit->setPromptDialogTitle(tr("Select QML File"));
- connect(m_d->ui.mainQmlFileLineEdit, SIGNAL(changed(QString)), SIGNAL(completeChanged()));
- connect(m_d->ui.importExistingQmlRadioButton,
+ m_d->ui.importLineEdit->setExpectedKind(Utils::PathChooser::File);
+ m_d->ui.importLineEdit->setPromptDialogFilter(QLatin1String("*.qml"));
+ m_d->ui.importLineEdit->setPromptDialogTitle(tr("Select QML File"));
+ connect(m_d->ui.importLineEdit, SIGNAL(changed(QString)), SIGNAL(completeChanged()));
+ connect(m_d->ui.importRadioButton,
SIGNAL(toggled(bool)), SIGNAL(completeChanged()));
- connect(m_d->ui.newQmlRadioButton, SIGNAL(toggled(bool)),
- m_d->ui.mainQmlFileLineEdit, SLOT(setDisabled(bool)));
- m_d->ui.newQmlRadioButton->setChecked(true);
+ connect(m_d->ui.generateRadioButton, SIGNAL(toggled(bool)),
+ m_d->ui.importLineEdit, SLOT(setDisabled(bool)));
+ m_d->ui.generateRadioButton->setChecked(true);
}
QtQuickAppWizardSourcesPage::~QtQuickAppWizardSourcesPage()
@@ -70,16 +70,22 @@ QtQuickAppWizardSourcesPage::~QtQuickAppWizardSourcesPage()
delete m_d;
}
+QtQuickApp::Mode QtQuickAppWizardSourcesPage::mainQmlMode() const
+{
+ return m_d->ui.generateRadioButton->isChecked() ? QtQuickApp::ModeGenerate
+ : QtQuickApp::ModeImport;
+}
+
QString QtQuickAppWizardSourcesPage::mainQmlFile() const
{
- return m_d->ui.importExistingQmlRadioButton->isChecked() ?
- m_d->ui.mainQmlFileLineEdit->path() : QString();
+ return mainQmlMode() == QtQuickApp::ModeImport ?
+ m_d->ui.importLineEdit->path() : QString();
}
bool QtQuickAppWizardSourcesPage::isComplete() const
{
- return !m_d->ui.importExistingQmlRadioButton->isChecked()
- || m_d->ui.mainQmlFileLineEdit->isValid();
+ return mainQmlMode() != QtQuickApp::ModeImport
+ || m_d->ui.importLineEdit->isValid();
}
} // namespace Internal
diff --git a/src/plugins/qt4projectmanager/wizards/qtquickappwizardpages.h b/src/plugins/qt4projectmanager/wizards/qtquickappwizardpages.h
index 1d7a2976d4..51b2a39adf 100644
--- a/src/plugins/qt4projectmanager/wizards/qtquickappwizardpages.h
+++ b/src/plugins/qt4projectmanager/wizards/qtquickappwizardpages.h
@@ -35,6 +35,7 @@
#define QTQUICKAPPWIZARDPAGES_H
#include <QtGui/QWizardPage>
+#include "qtquickapp.h"
namespace Qt4ProjectManager {
namespace Internal {
@@ -48,6 +49,7 @@ public:
explicit QtQuickAppWizardSourcesPage(QWidget *parent = 0);
virtual ~QtQuickAppWizardSourcesPage();
+ QtQuickApp::Mode mainQmlMode() const;
QString mainQmlFile() const;
virtual bool isComplete() const;
diff --git a/src/plugins/qt4projectmanager/wizards/qtquickappwizardsourcespage.ui b/src/plugins/qt4projectmanager/wizards/qtquickappwizardsourcespage.ui
index 5e916c556f..e451920b63 100644
--- a/src/plugins/qt4projectmanager/wizards/qtquickappwizardsourcespage.ui
+++ b/src/plugins/qt4projectmanager/wizards/qtquickappwizardsourcespage.ui
@@ -21,21 +21,21 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
- <widget class="QRadioButton" name="newQmlRadioButton">
+ <widget class="QRadioButton" name="generateRadioButton">
<property name="text">
<string>Generate a main.qml file</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
- <widget class="QRadioButton" name="importExistingQmlRadioButton">
+ <widget class="QRadioButton" name="importRadioButton">
<property name="text">
<string>Import an existing .qml file</string>
</property>
</widget>
</item>
<item row="2" column="1">
- <widget class="Utils::PathChooser" name="mainQmlFileLineEdit"/>
+ <widget class="Utils::PathChooser" name="importLineEdit"/>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer">