Commit a89bac3c authored by Alessandro Portale's avatar Alessandro Portale

Refactoring. Move post generation file open to base class.

parent f07aec60
...@@ -41,6 +41,9 @@ ...@@ -41,6 +41,9 @@
#include <qt4projectmanager/qt4project.h> #include <qt4projectmanager/qt4project.h>
#include <qt4projectmanager/qt4projectmanager.h> #include <qt4projectmanager/qt4projectmanager.h>
#include <qt4projectmanager/qt4projectmanagerconstants.h> #include <qt4projectmanager/qt4projectmanagerconstants.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/customwizard/customwizard.h>
#include <coreplugin/editormanager/editormanager.h>
#include <QtGui/QIcon> #include <QtGui/QIcon>
...@@ -196,10 +199,27 @@ Core::GeneratedFiles AbstractMobileAppWizard::generateFiles(const QWizard *wizar ...@@ -196,10 +199,27 @@ Core::GeneratedFiles AbstractMobileAppWizard::generateFiles(const QWizard *wizar
return app()->generateFiles(errorMessage); return app()->generateFiles(errorMessage);
} }
// TODO remove this workaround:
// SessionManager::projectContainsFile() incorrectly returns false if the
// file name in the .pro file (and thus also in m_projectFileCache)
// contains relative path segments ("../").
inline static QString fileInCurrentProject(const QString &file)
{
const QStringList filesInProject =
ProjectExplorer::ProjectExplorerPlugin::instance()->currentProject()->files(
ProjectExplorer::Project::ExcludeGeneratedFiles);
foreach (const QString &uncleanFile, filesInProject)
if (QDir::cleanPath(uncleanFile) == file)
return uncleanFile;
return QString();
}
bool AbstractMobileAppWizard::postGenerateFiles(const QWizard *w, bool AbstractMobileAppWizard::postGenerateFiles(const QWizard *w,
const Core::GeneratedFiles &l, QString *errorMessage) const Core::GeneratedFiles &l, QString *errorMessage)
{ {
Q_UNUSED(w); Q_UNUSED(w)
Q_UNUSED(l)
Q_UNUSED(errorMessage)
Qt4Manager * const manager Qt4Manager * const manager
= ExtensionSystem::PluginManager::instance()->getObject<Qt4Manager>(); = ExtensionSystem::PluginManager::instance()->getObject<Qt4Manager>();
Q_ASSERT(manager); Q_ASSERT(manager);
...@@ -207,7 +227,14 @@ bool AbstractMobileAppWizard::postGenerateFiles(const QWizard *w, ...@@ -207,7 +227,14 @@ bool AbstractMobileAppWizard::postGenerateFiles(const QWizard *w,
bool success = wizardDialog()->m_targetsPage->setupProject(&project); bool success = wizardDialog()->m_targetsPage->setupProject(&project);
if (success) { if (success) {
project.saveSettings(); project.saveSettings();
success = postGenerateFilesInternal(l, errorMessage); success = ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage);
if (success) {
const QString fileToOpen = fileInCurrentProject(fileToOpenPostGeneration());
if (!fileToOpen.isEmpty()) {
Core::EditorManager::instance()->openEditor(fileToOpen, QString(), Core::EditorManager::ModeSwitch);
ProjectExplorer::ProjectExplorerPlugin::instance()->setCurrentFile(0, fileToOpen);
}
}
} }
return success; return success;
} }
......
...@@ -88,6 +88,9 @@ protected: ...@@ -88,6 +88,9 @@ protected:
private slots: private slots:
void useProjectPath(const QString &projectName, const QString &projectPath); void useProjectPath(const QString &projectName, const QString &projectPath);
protected:
virtual QString fileToOpenPostGeneration() const = 0;
private: private:
virtual QWizard *createWizardDialog(QWidget *parent, virtual QWizard *createWizardDialog(QWidget *parent,
const QString &defaultPath, const WizardPageList &extensionPages) const; const QString &defaultPath, const WizardPageList &extensionPages) const;
...@@ -102,8 +105,6 @@ private: ...@@ -102,8 +105,6 @@ private:
virtual void projectPathChanged(const QString &path) const=0; virtual void projectPathChanged(const QString &path) const=0;
virtual void prepareGenerateFiles(const QWizard *wizard, virtual void prepareGenerateFiles(const QWizard *wizard,
QString *errorMessage) const=0; QString *errorMessage) const=0;
virtual bool postGenerateFilesInternal(const Core::GeneratedFiles &l,
QString *errorMessage)=0;
}; };
} // namespace Internal } // namespace Internal
......
...@@ -40,11 +40,6 @@ ...@@ -40,11 +40,6 @@
#include "qt4projectmanagerconstants.h" #include "qt4projectmanagerconstants.h"
#include <projectexplorer/baseprojectwizarddialog.h>
#include <projectexplorer/customwizard/customwizard.h>
#include <projectexplorer/projectexplorer.h>
#include <coreplugin/editormanager/editormanager.h>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtGui/QIcon> #include <QtGui/QIcon>
...@@ -134,16 +129,11 @@ void Html5AppWizard::prepareGenerateFiles(const QWizard *w, ...@@ -134,16 +129,11 @@ void Html5AppWizard::prepareGenerateFiles(const QWizard *w,
wizard->m_htmlSourcesPage->mainHtmlData()); wizard->m_htmlSourcesPage->mainHtmlData());
} }
bool Html5AppWizard::postGenerateFilesInternal(const Core::GeneratedFiles &l, QString Html5AppWizard::fileToOpenPostGeneration() const
QString *errorMessage)
{ {
const bool success = ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage); return m_d->app->mainHtmlMode() == Html5App::ModeUrl ?
const QString mainHtmlFile = m_d->app->path(Html5App::MainHtml); m_d->app->path(AbstractMobileApp::MainCpp)
if (success && !mainHtmlFile.isEmpty()) { : m_d->app->path(Html5App::MainHtml);
ProjectExplorer::ProjectExplorerPlugin::instance()->setCurrentFile(0, mainHtmlFile);
Core::EditorManager::instance()->openEditor(mainHtmlFile, QString(), Core::EditorManager::ModeSwitch);
}
return success;
} }
AbstractMobileApp *Html5AppWizard::app() const AbstractMobileApp *Html5AppWizard::app() const
......
...@@ -47,6 +47,9 @@ public: ...@@ -47,6 +47,9 @@ public:
Html5AppWizard(); Html5AppWizard();
virtual ~Html5AppWizard(); virtual ~Html5AppWizard();
protected:
QString fileToOpenPostGeneration() const;
private: private:
static Core::BaseFileWizardParameters parameters(); static Core::BaseFileWizardParameters parameters();
...@@ -56,8 +59,6 @@ private: ...@@ -56,8 +59,6 @@ private:
virtual void projectPathChanged(const QString &path) const; virtual void projectPathChanged(const QString &path) const;
virtual void prepareGenerateFiles(const QWizard *wizard, virtual void prepareGenerateFiles(const QWizard *wizard,
QString *errorMessage) const; QString *errorMessage) const;
virtual bool postGenerateFilesInternal(const Core::GeneratedFiles &l,
QString *errorMessage);
class Html5AppWizardPrivate *m_d; class Html5AppWizardPrivate *m_d;
}; };
......
...@@ -39,10 +39,6 @@ ...@@ -39,10 +39,6 @@
#include "qt4projectmanagerconstants.h" #include "qt4projectmanagerconstants.h"
#include <projectexplorer/customwizard/customwizard.h>
#include <projectexplorer/projectexplorer.h>
#include <coreplugin/editormanager/editormanager.h>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtGui/QIcon> #include <QtGui/QIcon>
...@@ -123,10 +119,9 @@ void MobileAppWizard::prepareGenerateFiles(const QWizard *w, ...@@ -123,10 +119,9 @@ void MobileAppWizard::prepareGenerateFiles(const QWizard *w,
Q_UNUSED(errorMessage) Q_UNUSED(errorMessage)
} }
bool MobileAppWizard::postGenerateFilesInternal(const Core::GeneratedFiles &l, QString MobileAppWizard::fileToOpenPostGeneration() const
QString *errorMessage)
{ {
return ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage); return QString();
} }
AbstractMobileApp *MobileAppWizard::app() const AbstractMobileApp *MobileAppWizard::app() const
......
...@@ -47,6 +47,9 @@ public: ...@@ -47,6 +47,9 @@ public:
MobileAppWizard(); MobileAppWizard();
virtual ~MobileAppWizard(); virtual ~MobileAppWizard();
protected:
QString fileToOpenPostGeneration() const;
private: private:
static Core::BaseFileWizardParameters parameters(); static Core::BaseFileWizardParameters parameters();
...@@ -56,8 +59,6 @@ private: ...@@ -56,8 +59,6 @@ private:
virtual void projectPathChanged(const QString &path) const; virtual void projectPathChanged(const QString &path) const;
virtual void prepareGenerateFiles(const QWizard *wizard, virtual void prepareGenerateFiles(const QWizard *wizard,
QString *errorMessage) const; QString *errorMessage) const;
virtual bool postGenerateFilesInternal(const Core::GeneratedFiles &l,
QString *errorMessage);
class MobileAppWizardPrivate *m_d; class MobileAppWizardPrivate *m_d;
}; };
......
...@@ -40,11 +40,6 @@ ...@@ -40,11 +40,6 @@
#include "qt4projectmanagerconstants.h" #include "qt4projectmanagerconstants.h"
#include <projectexplorer/baseprojectwizarddialog.h>
#include <projectexplorer/customwizard/customwizard.h>
#include <projectexplorer/projectexplorer.h>
#include <coreplugin/editormanager/editormanager.h>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtGui/QIcon> #include <QtGui/QIcon>
...@@ -152,16 +147,9 @@ void QtQuickAppWizard::prepareGenerateFiles(const QWizard *w, ...@@ -152,16 +147,9 @@ void QtQuickAppWizard::prepareGenerateFiles(const QWizard *w,
} }
} }
bool QtQuickAppWizard::postGenerateFilesInternal(const Core::GeneratedFiles &l, QString QtQuickAppWizard::fileToOpenPostGeneration() const
QString *errorMessage)
{ {
const bool success = ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage); return m_d->app->path(QtQuickApp::MainQml);
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;
} }
AbstractMobileApp *QtQuickAppWizard::app() const AbstractMobileApp *QtQuickAppWizard::app() const
......
...@@ -47,6 +47,9 @@ public: ...@@ -47,6 +47,9 @@ public:
QtQuickAppWizard(); QtQuickAppWizard();
virtual ~QtQuickAppWizard(); virtual ~QtQuickAppWizard();
protected:
QString fileToOpenPostGeneration() const;
private: private:
static Core::BaseFileWizardParameters parameters(); static Core::BaseFileWizardParameters parameters();
...@@ -56,8 +59,6 @@ private: ...@@ -56,8 +59,6 @@ private:
virtual void projectPathChanged(const QString &path) const; virtual void projectPathChanged(const QString &path) const;
virtual void prepareGenerateFiles(const QWizard *wizard, virtual void prepareGenerateFiles(const QWizard *wizard,
QString *errorMessage) const; QString *errorMessage) const;
virtual bool postGenerateFilesInternal(const Core::GeneratedFiles &l,
QString *errorMessage);
class QtQuickAppWizardPrivate *m_d; class QtQuickAppWizardPrivate *m_d;
}; };
......
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