Skip to content
Snippets Groups Projects
Commit a89bac3c authored by Alessandro Portale's avatar Alessandro Portale
Browse files

Refactoring. Move post generation file open to base class.

parent f07aec60
No related branches found
No related tags found
No related merge requests found
......@@ -41,6 +41,9 @@
#include <qt4projectmanager/qt4project.h>
#include <qt4projectmanager/qt4projectmanager.h>
#include <qt4projectmanager/qt4projectmanagerconstants.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/customwizard/customwizard.h>
#include <coreplugin/editormanager/editormanager.h>
#include <QtGui/QIcon>
......@@ -196,10 +199,27 @@ Core::GeneratedFiles AbstractMobileAppWizard::generateFiles(const QWizard *wizar
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,
const Core::GeneratedFiles &l, QString *errorMessage)
{
Q_UNUSED(w);
Q_UNUSED(w)
Q_UNUSED(l)
Q_UNUSED(errorMessage)
Qt4Manager * const manager
= ExtensionSystem::PluginManager::instance()->getObject<Qt4Manager>();
Q_ASSERT(manager);
......@@ -207,7 +227,14 @@ bool AbstractMobileAppWizard::postGenerateFiles(const QWizard *w,
bool success = wizardDialog()->m_targetsPage->setupProject(&project);
if (success) {
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;
}
......
......@@ -88,6 +88,9 @@ protected:
private slots:
void useProjectPath(const QString &projectName, const QString &projectPath);
protected:
virtual QString fileToOpenPostGeneration() const = 0;
private:
virtual QWizard *createWizardDialog(QWidget *parent,
const QString &defaultPath, const WizardPageList &extensionPages) const;
......@@ -102,8 +105,6 @@ private:
virtual void projectPathChanged(const QString &path) const=0;
virtual void prepareGenerateFiles(const QWizard *wizard,
QString *errorMessage) const=0;
virtual bool postGenerateFilesInternal(const Core::GeneratedFiles &l,
QString *errorMessage)=0;
};
} // namespace Internal
......
......@@ -40,11 +40,6 @@
#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 <QtGui/QIcon>
......@@ -134,16 +129,11 @@ void Html5AppWizard::prepareGenerateFiles(const QWizard *w,
wizard->m_htmlSourcesPage->mainHtmlData());
}
bool Html5AppWizard::postGenerateFilesInternal(const Core::GeneratedFiles &l,
QString *errorMessage)
QString Html5AppWizard::fileToOpenPostGeneration() const
{
const bool success = ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage);
const QString mainHtmlFile = m_d->app->path(Html5App::MainHtml);
if (success && !mainHtmlFile.isEmpty()) {
ProjectExplorer::ProjectExplorerPlugin::instance()->setCurrentFile(0, mainHtmlFile);
Core::EditorManager::instance()->openEditor(mainHtmlFile, QString(), Core::EditorManager::ModeSwitch);
}
return success;
return m_d->app->mainHtmlMode() == Html5App::ModeUrl ?
m_d->app->path(AbstractMobileApp::MainCpp)
: m_d->app->path(Html5App::MainHtml);
}
AbstractMobileApp *Html5AppWizard::app() const
......
......@@ -47,6 +47,9 @@ public:
Html5AppWizard();
virtual ~Html5AppWizard();
protected:
QString fileToOpenPostGeneration() const;
private:
static Core::BaseFileWizardParameters parameters();
......@@ -56,8 +59,6 @@ private:
virtual void projectPathChanged(const QString &path) const;
virtual void prepareGenerateFiles(const QWizard *wizard,
QString *errorMessage) const;
virtual bool postGenerateFilesInternal(const Core::GeneratedFiles &l,
QString *errorMessage);
class Html5AppWizardPrivate *m_d;
};
......
......@@ -39,10 +39,6 @@
#include "qt4projectmanagerconstants.h"
#include <projectexplorer/customwizard/customwizard.h>
#include <projectexplorer/projectexplorer.h>
#include <coreplugin/editormanager/editormanager.h>
#include <QtCore/QCoreApplication>
#include <QtGui/QIcon>
......@@ -123,10 +119,9 @@ void MobileAppWizard::prepareGenerateFiles(const QWizard *w,
Q_UNUSED(errorMessage)
}
bool MobileAppWizard::postGenerateFilesInternal(const Core::GeneratedFiles &l,
QString *errorMessage)
QString MobileAppWizard::fileToOpenPostGeneration() const
{
return ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage);
return QString();
}
AbstractMobileApp *MobileAppWizard::app() const
......
......@@ -47,6 +47,9 @@ public:
MobileAppWizard();
virtual ~MobileAppWizard();
protected:
QString fileToOpenPostGeneration() const;
private:
static Core::BaseFileWizardParameters parameters();
......@@ -56,8 +59,6 @@ private:
virtual void projectPathChanged(const QString &path) const;
virtual void prepareGenerateFiles(const QWizard *wizard,
QString *errorMessage) const;
virtual bool postGenerateFilesInternal(const Core::GeneratedFiles &l,
QString *errorMessage);
class MobileAppWizardPrivate *m_d;
};
......
......@@ -40,11 +40,6 @@
#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 <QtGui/QIcon>
......@@ -152,16 +147,9 @@ void QtQuickAppWizard::prepareGenerateFiles(const QWizard *w,
}
}
bool QtQuickAppWizard::postGenerateFilesInternal(const Core::GeneratedFiles &l,
QString *errorMessage)
QString QtQuickAppWizard::fileToOpenPostGeneration() const
{
const bool success = ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage);
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;
return m_d->app->path(QtQuickApp::MainQml);
}
AbstractMobileApp *QtQuickAppWizard::app() const
......
......@@ -47,6 +47,9 @@ public:
QtQuickAppWizard();
virtual ~QtQuickAppWizard();
protected:
QString fileToOpenPostGeneration() const;
private:
static Core::BaseFileWizardParameters parameters();
......@@ -56,8 +59,6 @@ private:
virtual void projectPathChanged(const QString &path) const;
virtual void prepareGenerateFiles(const QWizard *wizard,
QString *errorMessage) const;
virtual bool postGenerateFilesInternal(const Core::GeneratedFiles &l,
QString *errorMessage);
class QtQuickAppWizardPrivate *m_d;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment