forked from qt-creator/qt-creator
Wizards: Open a relevant file in editor after the wizard run
Remove all hacks/conventions of considering the last generated file as project file, etc. and instead add attributes flags to Core::GeneratedFile, giving fine-grained control of what to do with the file. Implement static utility functions in wizards that handle it. Add boolean XML-attributes "openeditor"/"openproject" to the file elements used by the CustomWizard XML-specification. Manually set the attributes in all wizards. Task-number: QTCREATORBUG-1166
This commit is contained in:
@@ -42,8 +42,8 @@ leave room for the Qt 4 target page.
|
||||
<displayname>Hello World</displayname>;
|
||||
<displaycategory>Custom Projects</displaycategory>
|
||||
<files>
|
||||
<file source="main.cpp"/>
|
||||
<file source="project.pro" target="%ProjectName%.pro"/>
|
||||
<file source="main.cpp" openeditor="true"/>
|
||||
<file source="project.pro" target="%ProjectName%.pro" openproject="true"/>
|
||||
</files>
|
||||
<!-- Create a 2nd wizard page with parameters -->
|
||||
<fieldpagetitle>Hello World Parameters</fieldpagetitle>
|
||||
|
@@ -38,8 +38,8 @@ Custom class wizard example configuration file. -->
|
||||
<displaycategory>Custom Classes</displaycategory>
|
||||
<displaycategory xml:lang="de">Benutzerdefinierte Klassen</displaycategory>
|
||||
<files>
|
||||
<file source="listmodel.cpp" target="%ClassName:l%.%CppSourceSuffix%"/>
|
||||
<file source="listmodel.h" target="%ClassName:l%.%CppHeaderSuffix%"/>
|
||||
<file source="listmodel.cpp" target="%ClassName:l%.%CppSourceSuffix%" openeditor="true"/>
|
||||
<file source="listmodel.h" target="%ClassName:l%.%CppHeaderSuffix%" openeditor="true"/>
|
||||
</files>
|
||||
<!-- Create parameter wizard page -->
|
||||
<fieldpagetitle>ListModel parameters</fieldpagetitle>
|
||||
|
@@ -45,8 +45,8 @@ leave room for the Qt 4 target page.
|
||||
<file source="plugin.h" target="%ProjectName%.h"/>
|
||||
<file source="plugin.cpp" target="%ProjectName%.cpp"/>
|
||||
<file source="object.h" target="%ObjectName%.h"/>
|
||||
<file source="object.cpp" target="%ObjectName%.cpp"/>
|
||||
<file source="project.pro" target="%ProjectName%.pro"/>
|
||||
<file source="object.cpp" target="%ObjectName%.cpp" openeditor="true"/>
|
||||
<file source="project.pro" target="%ProjectName%.pro" openproject="true"/>
|
||||
</files>
|
||||
<!-- Create a 2nd wizard page with parameters -->
|
||||
<fieldpagetitle>QML Runtime Plug-in Parameters</fieldpagetitle>
|
||||
|
@@ -66,11 +66,13 @@ public:
|
||||
QByteArray contents;
|
||||
QString editorId;
|
||||
bool binary;
|
||||
GeneratedFile::Attributes attributes;
|
||||
};
|
||||
|
||||
GeneratedFilePrivate::GeneratedFilePrivate(const QString &p) :
|
||||
path(p),
|
||||
binary(false)
|
||||
binary(false),
|
||||
attributes(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -180,6 +182,15 @@ bool GeneratedFile::write(QString *errorMessage) const
|
||||
return true;
|
||||
}
|
||||
|
||||
GeneratedFile::Attributes GeneratedFile::attributes() const
|
||||
{
|
||||
return m_d->attributes;
|
||||
}
|
||||
|
||||
void GeneratedFile::setAttributes(Attributes a)
|
||||
{
|
||||
m_d->attributes = a;
|
||||
}
|
||||
|
||||
// ------------ BaseFileWizardParameterData
|
||||
class BaseFileWizardParameterData : public QSharedData
|
||||
@@ -584,18 +595,23 @@ void BaseFileWizard::applyExtensionPageShortTitle(Utils::Wizard *wizard, int pag
|
||||
item->setTitle(shortTitle);
|
||||
}
|
||||
|
||||
bool BaseFileWizard::postGenerateFiles(const QWizard *w, const GeneratedFiles &l, QString *errorMessage)
|
||||
bool BaseFileWizard::postGenerateFiles(const QWizard *, const GeneratedFiles &l, QString *errorMessage)
|
||||
{
|
||||
return BaseFileWizard::postGenerateOpenEditors(l, errorMessage);
|
||||
}
|
||||
|
||||
bool BaseFileWizard::postGenerateOpenEditors(const GeneratedFiles &l, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(w);
|
||||
// File mode: open the editors in file mode and ensure editor pane
|
||||
const Core::GeneratedFiles::const_iterator cend = l.constEnd();
|
||||
Core::EditorManager *em = Core::EditorManager::instance();
|
||||
for (Core::GeneratedFiles::const_iterator it = l.constBegin(); it != cend; ++it) {
|
||||
if (!em->openEditor(it->path(), it->editorId())) {
|
||||
*errorMessage = tr("Failed to open an editor for '%1'.").arg(it->path());
|
||||
foreach(const Core::GeneratedFile &file, l) {
|
||||
if (file.attributes() & Core::GeneratedFile::OpenEditorAttribute) {
|
||||
if (!em->openEditor(file.path(), file.editorId())) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("Failed to open an editor for '%1'.").arg(file.path());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -65,6 +65,9 @@ class GeneratedFilePrivate;
|
||||
class CORE_EXPORT GeneratedFile
|
||||
{
|
||||
public:
|
||||
enum Attribute { OpenEditorAttribute = 0x01, OpenProjectAttribute = 0x02 };
|
||||
Q_DECLARE_FLAGS(Attributes, Attribute)
|
||||
|
||||
GeneratedFile();
|
||||
explicit GeneratedFile(const QString &path);
|
||||
GeneratedFile(const GeneratedFile &);
|
||||
@@ -92,6 +95,9 @@ public:
|
||||
|
||||
bool write(QString *errorMessage) const;
|
||||
|
||||
Attributes attributes() const;
|
||||
void setAttributes(Attributes a);
|
||||
|
||||
private:
|
||||
QSharedDataPointer<GeneratedFilePrivate> m_d;
|
||||
};
|
||||
@@ -207,6 +213,10 @@ protected:
|
||||
OverwriteResult promptOverwrite(const QString &location,
|
||||
const QStringList &files,
|
||||
QString *errorMessage) const;
|
||||
|
||||
// Utility to open the editors for the files whose attribute is set accordingly.
|
||||
static bool postGenerateOpenEditors(const GeneratedFiles &l, QString *errorMessage = 0);
|
||||
|
||||
private:
|
||||
BaseFileWizardPrivate *m_d;
|
||||
};
|
||||
@@ -239,4 +249,6 @@ protected:
|
||||
|
||||
} // namespace Core
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::GeneratedFile::Attributes)
|
||||
|
||||
#endif // BASEFILEWIZARD_H
|
||||
|
@@ -209,7 +209,10 @@ Core::GeneratedFiles CppClassWizard::generateFiles(const QWizard *w, QString *er
|
||||
return Core::GeneratedFiles();
|
||||
}
|
||||
headerFile.setContents(header);
|
||||
headerFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
|
||||
sourceFile.setContents(source);
|
||||
sourceFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
return Core::GeneratedFiles() << headerFile << sourceFile;
|
||||
}
|
||||
|
||||
|
@@ -62,7 +62,7 @@ Core::GeneratedFiles CppFileWizard::generateFilesFromPath(const QString &path,
|
||||
Core::GeneratedFile file(fileName);
|
||||
file.setEditorId(QLatin1String(Constants::CPPEDITOR_ID));
|
||||
file.setContents(fileContents(m_type, fileName));
|
||||
|
||||
file.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
return Core::GeneratedFiles() << file;
|
||||
}
|
||||
|
||||
|
@@ -88,15 +88,18 @@ Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *e
|
||||
|
||||
Core::GeneratedFile headerFile(headerFileName);
|
||||
headerFile.setEditorId(QLatin1String(CppEditor::Constants::CPPEDITOR_ID));
|
||||
headerFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
|
||||
// Source
|
||||
Core::GeneratedFile sourceFile(sourceFileName);
|
||||
sourceFile.setEditorId(QLatin1String(CppEditor::Constants::CPPEDITOR_ID));
|
||||
sourceFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
|
||||
// UI
|
||||
Core::GeneratedFile uiFile(formFileName);
|
||||
uiFile.setContents(params.uiTemplate());
|
||||
uiFile.setEditorId(QLatin1String(Constants::DESIGNER_XML_EDITOR_ID));
|
||||
uiFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
|
||||
QString source, header;
|
||||
Designer::FormClassWizardGenerationParameters generationParameters;
|
||||
|
@@ -67,5 +67,6 @@ Core::GeneratedFiles FormWizard::generateFiles(const QWizard *w,
|
||||
Core::GeneratedFile file(fileName);
|
||||
file.setContents(formTemplate);
|
||||
file.setEditorId(QLatin1String(Constants::DESIGNER_XML_EDITOR_ID));
|
||||
file.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
return Core::GeneratedFiles() << file;
|
||||
}
|
||||
|
@@ -31,8 +31,8 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/customwizard/customwizard.h>
|
||||
|
||||
#include <utils/filewizardpage.h>
|
||||
|
||||
@@ -198,6 +198,7 @@ Core::GeneratedFiles GenericProjectWizard::generateFiles(const QWizard *w,
|
||||
|
||||
Core::GeneratedFile generatedCreatorFile(creatorFileName);
|
||||
generatedCreatorFile.setContents(QLatin1String("[General]\n"));
|
||||
generatedCreatorFile.setAttributes(Core::GeneratedFile::OpenProjectAttribute);
|
||||
|
||||
Core::GeneratedFile generatedFilesFile(filesFileName);
|
||||
generatedFilesFile.setContents(sources.join(QLatin1String("\n")));
|
||||
@@ -220,12 +221,5 @@ Core::GeneratedFiles GenericProjectWizard::generateFiles(const QWizard *w,
|
||||
bool GenericProjectWizard::postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(w);
|
||||
// Post-Generate: Open the project
|
||||
const QString proFileName = l.back().path();
|
||||
if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFileName)) {
|
||||
*errorMessage = tr("The project %1 could not be opened.").arg(proFileName);
|
||||
return false;
|
||||
return ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -161,6 +161,12 @@ static inline bool createFile(Internal::CustomWizardFile cwFile,
|
||||
Core::GeneratedFile generatedFile;
|
||||
generatedFile.setContents(contents);
|
||||
generatedFile.setPath(targetPath);
|
||||
Core::GeneratedFile::Attributes attributes = 0;
|
||||
if (cwFile.openEditor)
|
||||
attributes |= Core::GeneratedFile::OpenEditorAttribute;
|
||||
if (cwFile.openProject)
|
||||
attributes |= Core::GeneratedFile::OpenProjectAttribute;
|
||||
generatedFile.setAttributes(attributes);
|
||||
files->push_back(generatedFile);
|
||||
return true;
|
||||
}
|
||||
@@ -410,18 +416,26 @@ Core::GeneratedFiles CustomProjectWizard::generateFiles(const QWizard *w, QStrin
|
||||
return generateWizardFiles(targetPath, fieldReplacementMap, errorMessage);
|
||||
}
|
||||
|
||||
bool CustomProjectWizard::postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage)
|
||||
bool CustomProjectWizard::postGenerateOpen(const Core::GeneratedFiles &l, QString *errorMessage)
|
||||
{
|
||||
// Post-Generate: Open the project
|
||||
const QString proFileName = l.back().path();
|
||||
const bool opened = ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFileName);
|
||||
if (CustomWizardPrivate::verbose)
|
||||
qDebug() << "CustomProjectWizard::postGenerateFiles: opened " << proFileName << opened;
|
||||
if (opened) {
|
||||
*errorMessage = tr("The project %1 could not be opened.").arg(proFileName);
|
||||
// Post-Generate: Open the project and the editors as desired
|
||||
foreach(const Core::GeneratedFile &file, l) {
|
||||
if (file.attributes() & Core::GeneratedFile::OpenProjectAttribute) {
|
||||
if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(file.path())) {
|
||||
if (errorMessage)
|
||||
*errorMessage = tr("The project %1 could not be opened.").arg(file.path());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return BaseFileWizard::postGenerateOpenEditors(l, errorMessage);
|
||||
}
|
||||
|
||||
bool CustomProjectWizard::postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage)
|
||||
{
|
||||
if (CustomWizardPrivate::verbose)
|
||||
qDebug() << "CustomProjectWizard::postGenerateFiles()";
|
||||
return CustomProjectWizard::postGenerateOpen(l, errorMessage);
|
||||
}
|
||||
|
||||
void CustomProjectWizard::introPageLeft(const QString &project, const QString & /* path */)
|
||||
|
@@ -154,6 +154,10 @@ public:
|
||||
|
||||
virtual Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const;
|
||||
|
||||
// Utility to open the projects and editors for the files that have
|
||||
// the respective attributes set.
|
||||
static bool postGenerateOpen(const Core::GeneratedFiles &l, QString *errorMessage = 0);
|
||||
|
||||
protected:
|
||||
virtual bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage);
|
||||
|
||||
|
@@ -68,6 +68,9 @@ static const char filesElementC[] = "files";
|
||||
static const char fileElementC[] = "file";
|
||||
static const char fileNameSourceAttributeC[] = "source";
|
||||
static const char fileNameTargetAttributeC[] = "target";
|
||||
static const char fileNameOpenEditorAttributeC[] = "openeditor";
|
||||
static const char fileNameOpenProjectAttributeC[] = "openproject";
|
||||
|
||||
|
||||
enum ParseState {
|
||||
ParseBeginning,
|
||||
@@ -95,6 +98,11 @@ void CustomWizardField::clear()
|
||||
controlAttributes.clear();
|
||||
}
|
||||
|
||||
CustomWizardFile::CustomWizardFile() :
|
||||
openEditor(false), openProject(false)
|
||||
{
|
||||
}
|
||||
|
||||
CustomWizardParameters::CustomWizardParameters() :
|
||||
firstPageId(-1)
|
||||
{
|
||||
@@ -409,6 +417,8 @@ bool CustomWizardParameters::parse(QIODevice &device,
|
||||
CustomWizardFile file;
|
||||
file.source = attributeValue(reader, fileNameSourceAttributeC);
|
||||
file.target = attributeValue(reader, fileNameTargetAttributeC);
|
||||
file.openEditor = booleanAttributeValue(reader, fileNameOpenEditorAttributeC);
|
||||
file.openProject = booleanAttributeValue(reader, fileNameOpenProjectAttributeC);
|
||||
if (file.target.isEmpty())
|
||||
file.target = file.source;
|
||||
if (file.source.isEmpty()) {
|
||||
@@ -460,7 +470,12 @@ QString CustomWizardParameters::toString() const
|
||||
QTextStream str(&rc);
|
||||
str << "Directory: " << directory << " Klass: '" << klass << "'\n";
|
||||
foreach(const CustomWizardFile &f, files) {
|
||||
str << " File source: " << f.source << " Target: " << f.target << '\n';
|
||||
str << " File source: " << f.source << " Target: " << f.target;
|
||||
if (f.openEditor)
|
||||
str << " [editor]";
|
||||
if (f.openProject)
|
||||
str << " [project]";
|
||||
str << '\n';
|
||||
}
|
||||
foreach(const CustomWizardField &f, fields) {
|
||||
str << " Field name: " << f.name;
|
||||
|
@@ -56,8 +56,12 @@ struct CustomWizardField {
|
||||
};
|
||||
|
||||
struct CustomWizardFile {
|
||||
CustomWizardFile();
|
||||
|
||||
QString source;
|
||||
QString target;
|
||||
bool openEditor;
|
||||
bool openProject;
|
||||
};
|
||||
|
||||
struct CustomWizardParameters
|
||||
|
@@ -52,7 +52,7 @@ Core::GeneratedFiles QmlFileWizard::generateFilesFromPath(const QString &path,
|
||||
Core::GeneratedFile file(fileName);
|
||||
file.setEditorId(QLatin1String(Constants::C_QMLJSEDITOR_ID));
|
||||
file.setContents(fileContents(fileName));
|
||||
|
||||
file.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
return Core::GeneratedFiles() << file;
|
||||
}
|
||||
|
||||
|
@@ -31,8 +31,7 @@
|
||||
|
||||
#include "qmlprojectconstants.h"
|
||||
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/customwizard/customwizard.h>
|
||||
|
||||
#include <QtGui/QIcon>
|
||||
|
||||
@@ -120,6 +119,7 @@ Core::GeneratedFiles QmlProjectApplicationWizard::generateFiles(const QWizard *w
|
||||
}
|
||||
Core::GeneratedFile generatedMainFile(mainFileName);
|
||||
generatedMainFile.setContents(contents);
|
||||
generatedMainFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
|
||||
QString projectContents;
|
||||
{
|
||||
@@ -150,6 +150,7 @@ Core::GeneratedFiles QmlProjectApplicationWizard::generateFiles(const QWizard *w
|
||||
}
|
||||
Core::GeneratedFile generatedCreatorFile(creatorFileName);
|
||||
generatedCreatorFile.setContents(projectContents);
|
||||
generatedCreatorFile.setAttributes(Core::GeneratedFile::OpenProjectAttribute);
|
||||
|
||||
Core::GeneratedFiles files;
|
||||
files.append(generatedMainFile);
|
||||
@@ -158,16 +159,10 @@ Core::GeneratedFiles QmlProjectApplicationWizard::generateFiles(const QWizard *w
|
||||
return files;
|
||||
}
|
||||
|
||||
bool QmlProjectApplicationWizard::postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage)
|
||||
bool QmlProjectApplicationWizard::postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(w);
|
||||
// Post-Generate: Open the project
|
||||
const QString proFileName = l.back().path();
|
||||
if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFileName)) {
|
||||
*errorMessage = tr("The project %1 could not be opened.").arg(proFileName);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage);
|
||||
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -33,8 +33,7 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/customwizard/customwizard.h>
|
||||
|
||||
#include <utils/filenamevalidatinglineedit.h>
|
||||
#include <utils/filewizardpage.h>
|
||||
@@ -166,6 +165,7 @@ Core::GeneratedFiles QmlProjectImportWizard::generateFiles(const QWizard *w,
|
||||
}
|
||||
Core::GeneratedFile generatedCreatorFile(creatorFileName);
|
||||
generatedCreatorFile.setContents(projectContents);
|
||||
generatedCreatorFile.setAttributes(Core::GeneratedFile::OpenProjectAttribute);
|
||||
|
||||
Core::GeneratedFiles files;
|
||||
files.append(generatedCreatorFile);
|
||||
@@ -173,16 +173,9 @@ Core::GeneratedFiles QmlProjectImportWizard::generateFiles(const QWizard *w,
|
||||
return files;
|
||||
}
|
||||
|
||||
bool QmlProjectImportWizard::postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage)
|
||||
bool QmlProjectImportWizard::postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(w);
|
||||
// Post-Generate: Open the project
|
||||
const QString proFileName = l.back().path();
|
||||
if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFileName)) {
|
||||
*errorMessage = tr("The project %1 could not be opened.").arg(proFileName);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return ProjectExplorer::CustomProjectWizard::postGenerateOpen(l ,errorMessage);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -93,7 +93,9 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
|
||||
|
||||
// First create the widget wrappers (plugins) and - if requested - skeletons
|
||||
// for the widgets.
|
||||
foreach (const PluginOptions::WidgetOptions &wo, options.widgetOptions) {
|
||||
const int widgetCount = options.widgetOptions.size();
|
||||
for (int i = 0; i < widgetCount; i++) {
|
||||
const PluginOptions::WidgetOptions &wo = options.widgetOptions.at(i);
|
||||
sm.clear();
|
||||
sm.insert(QLatin1String("SINGLE_INCLUDE_GUARD"), headerGuard(wo.pluginHeaderFile));
|
||||
sm.insert(QLatin1String("PLUGIN_CLASS"), wo.pluginClassName);
|
||||
@@ -133,6 +135,8 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
|
||||
return QList<Core::GeneratedFile>();
|
||||
Core::GeneratedFile pluginSource(baseDir + wo.pluginSourceFile);
|
||||
pluginSource.setContents(p.license + pluginSourceContents);
|
||||
if (i == 0 && widgetCount == 1) // Open first widget unless collection
|
||||
pluginSource.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
rc.push_back(pluginSource);
|
||||
|
||||
if (wo.sourceType == PluginOptions::WidgetOptions::LinkLibrary)
|
||||
@@ -209,7 +213,7 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
|
||||
}
|
||||
|
||||
// Create the sources for the collection if necessary.
|
||||
if (options.widgetOptions.count() > 1) {
|
||||
if (widgetCount > 1) {
|
||||
sm.clear();
|
||||
sm.insert(QLatin1String("COLLECTION_INCLUDE_GUARD"), headerGuard(options.collectionHeaderFile));
|
||||
sm.insert(QLatin1String("COLLECTION_PLUGIN_CLASS"), options.collectionClassName);
|
||||
@@ -238,6 +242,7 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
|
||||
return QList<Core::GeneratedFile>();
|
||||
Core::GeneratedFile collectionSource(baseDir + options.collectionSourceFile);
|
||||
collectionSource.setContents(p.license + collectionSourceFileContents);
|
||||
collectionSource.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
rc.push_back(collectionSource);
|
||||
|
||||
pluginHeaders += blank + options.collectionHeaderFile;
|
||||
@@ -282,6 +287,7 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
|
||||
return QList<Core::GeneratedFile>();
|
||||
Core::GeneratedFile proFile(baseDir + p.fileName + QLatin1String(".pro"));
|
||||
proFile.setContents(proFileContents);
|
||||
proFile.setAttributes(Core::GeneratedFile::OpenProjectAttribute);
|
||||
rc.push_back(proFile);
|
||||
return rc;
|
||||
}
|
||||
|
@@ -87,10 +87,12 @@ Core::GeneratedFiles
|
||||
const QString sourceFileName = Core::BaseFileWizard::buildFileName(projectPath, QLatin1String(mainSourceFileC), sourceSuffix());
|
||||
Core::GeneratedFile source(sourceFileName);
|
||||
source.setContents(license + QLatin1String(mainCppC));
|
||||
source.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
// Create files: Profile
|
||||
const QString profileName = Core::BaseFileWizard::buildFileName(projectPath, params.fileName, profileSuffix());
|
||||
|
||||
Core::GeneratedFile profile(profileName);
|
||||
profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute);
|
||||
QString contents;
|
||||
{
|
||||
QTextStream proStr(&contents);
|
||||
|
@@ -69,6 +69,7 @@ Core::GeneratedFiles
|
||||
const QString profileName = Core::BaseFileWizard::buildFileName(projectPath, params.fileName, profileSuffix());
|
||||
|
||||
Core::GeneratedFile profile(profileName);
|
||||
profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute);
|
||||
return Core::GeneratedFiles() << profile;
|
||||
}
|
||||
|
||||
|
@@ -175,6 +175,7 @@ Core::GeneratedFiles GuiAppWizard::generateFiles(const QWizard *w,
|
||||
// Create files: form
|
||||
const QString formName = buildFileName(projectPath, params.formFileName, formSuffix());
|
||||
form = QSharedPointer<Core::GeneratedFile>(new Core::GeneratedFile(formName));
|
||||
form->setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
if (!parametrizeTemplate(templatePath, QLatin1String("widget.ui"), params, &contents, errorMessage))
|
||||
return Core::GeneratedFiles();
|
||||
form->setContents(contents);
|
||||
@@ -185,6 +186,7 @@ Core::GeneratedFiles GuiAppWizard::generateFiles(const QWizard *w,
|
||||
if (!parametrizeTemplate(templatePath, formSourceTemplate, params, &contents, errorMessage))
|
||||
return Core::GeneratedFiles();
|
||||
formSource.setContents(license + contents);
|
||||
formSource.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
// Create files: form header
|
||||
const QString formHeaderTemplate = QLatin1String("mywidget.h");
|
||||
if (!parametrizeTemplate(templatePath, formHeaderTemplate, params, &contents, errorMessage))
|
||||
@@ -194,6 +196,7 @@ Core::GeneratedFiles GuiAppWizard::generateFiles(const QWizard *w,
|
||||
// Create files: profile
|
||||
const QString profileName = buildFileName(projectPath, projectParams.fileName, profileSuffix());
|
||||
Core::GeneratedFile profile(profileName);
|
||||
profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute);
|
||||
contents.clear();
|
||||
{
|
||||
QTextStream proStr(&contents);
|
||||
|
@@ -88,6 +88,7 @@ Core::GeneratedFiles LibraryWizard::generateFiles(const QWizard *w,
|
||||
// Class header + source
|
||||
const QString sourceFileName = buildFileName(projectPath, params.sourceFileName, sourceSuffix());
|
||||
Core::GeneratedFile source(sourceFileName);
|
||||
source.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
|
||||
const QString headerFileFullName = buildFileName(projectPath, params.headerFileName, headerSuffix());
|
||||
const QString headerFileName = QFileInfo(headerFileFullName).fileName();
|
||||
@@ -116,6 +117,7 @@ Core::GeneratedFiles LibraryWizard::generateFiles(const QWizard *w,
|
||||
// Create files: profile
|
||||
const QString profileName = buildFileName(projectPath, projectParams.fileName, profileSuffix());
|
||||
Core::GeneratedFile profile(profileName);
|
||||
profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute);
|
||||
QString profileContents;
|
||||
{
|
||||
QTextStream proStr(&profileContents);
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#include "targetsetuppage.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <cpptools/cpptoolsconstants.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
@@ -108,20 +109,21 @@ bool QtWizard::postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l
|
||||
return QtWizard::qt4ProjectPostGenerateFiles(w, l, errorMessage);
|
||||
}
|
||||
|
||||
bool QtWizard::qt4ProjectPostGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage)
|
||||
bool QtWizard::qt4ProjectPostGenerateFiles(const QWizard *w,
|
||||
const Core::GeneratedFiles &generatedFiles,
|
||||
QString *errorMessage)
|
||||
{
|
||||
const QString proFileName = l.back().path();
|
||||
const BaseQt4ProjectWizardDialog *dialog = qobject_cast<const BaseQt4ProjectWizardDialog *>(w);
|
||||
|
||||
// Generate user settings:
|
||||
dialog->writeUserFile(proFileName);
|
||||
|
||||
// Post-Generate: Open the project
|
||||
if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFileName)) {
|
||||
*errorMessage = tr("The project %1 could not be opened.").arg(proFileName);
|
||||
return false;
|
||||
// Generate user settings
|
||||
foreach (const Core::GeneratedFile &file, generatedFiles)
|
||||
if (file.attributes() & Core::GeneratedFile::OpenProjectAttribute) {
|
||||
dialog->writeUserFile(file.path());
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
||||
// Post-Generate: Open the projects/editors
|
||||
return ProjectExplorer::CustomProjectWizard::postGenerateOpen(generatedFiles ,errorMessage);
|
||||
}
|
||||
|
||||
QString QtWizard::templateDir()
|
||||
|
@@ -162,11 +162,13 @@ Core::GeneratedFiles TestWizard::generateFiles(const QWizard *w, QString *errorM
|
||||
const QFileInfo sourceFileInfo(sourceFilePath);
|
||||
|
||||
Core::GeneratedFile source(sourceFilePath);
|
||||
source.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
source.setContents(generateTestCode(testParams, sourceFileInfo.baseName()));
|
||||
|
||||
// Create profile with define for base dir to find test data
|
||||
const QString profileName = Core::BaseFileWizard::buildFileName(projectPath, projectParams.fileName, profileSuffix());
|
||||
Core::GeneratedFile profile(profileName);
|
||||
profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute);
|
||||
QString contents;
|
||||
{
|
||||
QTextStream proStr(&contents);
|
||||
|
@@ -50,5 +50,6 @@ ResourceWizard::generateFilesFromPath(const QString &path,
|
||||
Core::GeneratedFile file(fileName);
|
||||
file.setContents(QLatin1String("<RCC/>"));
|
||||
file.setEditorId(QLatin1String(Constants::RESOURCEEDITOR_ID));
|
||||
file.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
return Core::GeneratedFiles() << file;
|
||||
}
|
||||
|
@@ -54,5 +54,6 @@ Core::GeneratedFiles
|
||||
const QString fileName = Core::BaseFileWizard::buildFileName(path, name, suffix);
|
||||
Core::GeneratedFile file(fileName);
|
||||
file.setEditorId(m_editorId);
|
||||
file.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
||||
return Core::GeneratedFiles() << file;
|
||||
}
|
||||
|
Reference in New Issue
Block a user