diff --git a/share/qtcreator/templates/wizards/README.txt b/share/qtcreator/templates/wizards/README.txt index 891ad644062f815d8327d9fbc9fb5e70c52de9f1..695c1ef7e969a5f02300a9e01adbd30e84703675 100644 --- a/share/qtcreator/templates/wizards/README.txt +++ b/share/qtcreator/templates/wizards/README.txt @@ -3,3 +3,6 @@ Qt Creator custom wizard are located in this directory. The subdirectories 'helloworld' and 'listmodel' are provided as examples. To see how they work in Qt Creator, rename the 'wizard_sample.xml' files to 'wizard.xml'. + +The command line option -customwizard-verbose can be used to obtain +verbose information while loading the custom wizards. diff --git a/src/plugins/projectexplorer/ProjectExplorer.pluginspec b/src/plugins/projectexplorer/ProjectExplorer.pluginspec index 772f357b4e1519eaa96ff45610259d547cec0e10..a234f76671cae523b78a971baa404cd3e7673346 100644 --- a/src/plugins/projectexplorer/ProjectExplorer.pluginspec +++ b/src/plugins/projectexplorer/ProjectExplorer.pluginspec @@ -19,4 +19,7 @@ Alternatively, this plugin may be used under the terms of the GNU Lesser General <dependency name="Locator" version="1.3.82"/> <dependency name="TextEditor" version="1.3.82"/> </dependencyList> + <argumentList> + <argument name="-customwizard-verbose">Verbose loading of custom wizards</argument> + </argumentList> </plugin> diff --git a/src/plugins/projectexplorer/customwizard/customwizard.cpp b/src/plugins/projectexplorer/customwizard/customwizard.cpp index 7f36a7a450d1ae64a7787edd6567910a6b93a25b..0a7e90edb307c4b13bf978178a870df4c22d5899 100644 --- a/src/plugins/projectexplorer/customwizard/customwizard.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizard.cpp @@ -44,8 +44,6 @@ #include <QtCore/QDir> #include <QtCore/QFileInfo> -enum { debug = 0 }; - static const char templatePathC[] = "templates/wizards"; static const char configFileC[] = "wizard.xml"; @@ -53,8 +51,11 @@ namespace ProjectExplorer { struct CustomWizardPrivate { QSharedPointer<Internal::CustomWizardParameters> m_parameters; + static int verbose; }; +int CustomWizardPrivate::verbose = 0; + CustomWizard::CustomWizard(const Core::BaseFileWizardParameters& baseFileParameters, QObject *parent) : Core::BaseFileWizard(baseFileParameters, parent), @@ -67,6 +68,16 @@ CustomWizard::~CustomWizard() delete d; } +void CustomWizard::setVerbose(int v) +{ + CustomWizardPrivate::verbose = v; +} + +int CustomWizard::verbose() +{ + return CustomWizardPrivate::verbose; +} + void CustomWizard::setParameters(const CustomWizardParametersPtr &p) { d->m_parameters = p; @@ -100,7 +111,7 @@ void CustomWizard::initWizardDialog(QWizard *wizard, const QString &defaultPath, foreach(QWizardPage *ep, extensionPages) wizard->addPage(ep); Core::BaseFileWizard::setupWizard(wizard); - if (debug) + if (CustomWizardPrivate::verbose) qDebug() << "initWizardDialog" << wizard << wizard->pageIds(); } @@ -177,7 +188,7 @@ static inline bool createFile(Internal::CustomWizardFile cwFile, const QString sourcePath = sourceDirectory + slash + cwFile.source; replaceFields(fm, &cwFile.target); const QString targetPath = QDir::toNativeSeparators(targetDirectory + slash + cwFile.target); - if (debug) + if (CustomWizardPrivate::verbose) qDebug() << "generating " << targetPath << sourcePath << fm; QFile file(sourcePath); if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) { @@ -211,7 +222,7 @@ Core::GeneratedFiles CustomWizard::generateFiles(const QWizard *dialog, QString QTC_ASSERT(cwp, return Core::GeneratedFiles()) QString path = cwp->path(); const FieldReplacementMap fieldMap = defaultReplacementMap(dialog); - if (debug) + if (CustomWizardPrivate::verbose) qDebug() << "CustomWizard::generateFiles" << dialog << path << fieldMap; return generateWizardFiles(path, fieldMap, errorMessage); } @@ -220,7 +231,7 @@ Core::GeneratedFiles CustomWizard::generateWizardFiles(const QString &targetPath const FieldReplacementMap &fieldReplacementMap, QString *errorMessage) const { - if (debug) + if (CustomWizardPrivate::verbose) qDebug() << "Replacements" << fieldReplacementMap; // Create files Core::GeneratedFiles rc; @@ -299,7 +310,7 @@ QList<CustomWizard*> CustomWizard::createWizards() QLatin1Char('/') + QLatin1String(templatePathC); const QDir templateDir(templateDirName); if (!templateDir.exists()) { - if (debug) + if (CustomWizardPrivate::verbose) qWarning("Custom project template path %s does not exist.", qPrintable(templateDir.absolutePath())); return rc; } @@ -311,19 +322,24 @@ QList<CustomWizard*> CustomWizard::createWizards() foreach(const QFileInfo &dirFi, dirs) { const QDir dir(dirFi.absoluteFilePath()); + if (CustomWizardPrivate::verbose) + qDebug("CustomWizard: Scanning %s", qPrintable(dirFi.absoluteFilePath())); if (dir.exists(configFile)) { CustomWizardParametersPtr parameters(new Internal::CustomWizardParameters); Core::BaseFileWizardParameters baseFileParameters; if (parameters->parse(dir.absoluteFilePath(configFile), &baseFileParameters, &errorMessage)) { parameters->directory = dir.absolutePath(); - if (debug) - qDebug() << (*parameters); + if (CustomWizardPrivate::verbose) + qDebug("%s\n", qPrintable(parameters->toString())); if (CustomWizard *w = createWizard(parameters, baseFileParameters)) rc.push_back(w); } else { qWarning("Failed to initialize custom project wizard in %s: %s", qPrintable(dir.absolutePath()), qPrintable(errorMessage)); } + } else { + if (CustomWizardPrivate::verbose) + qDebug("CustomWizard: '%s' not found\n", qPrintable(configFile)); } } return rc; @@ -362,7 +378,7 @@ void CustomProjectWizard::initProjectWizardDialog(BaseProjectWizardDialog *w, w->addPage(ep); w->setPath(defaultPath); w->setProjectName(BaseProjectWizardDialog::uniqueProjectName(defaultPath)); - if (debug) + if (CustomWizardPrivate::verbose) qDebug() << "initProjectWizardDialog" << w << w->pageIds(); } @@ -374,7 +390,7 @@ Core::GeneratedFiles CustomProjectWizard::generateFiles(const QWizard *w, QStrin // Add project name as macro. FieldReplacementMap fieldReplacementMap = defaultReplacementMap(dialog); fieldReplacementMap.insert(QLatin1String("ProjectName"), dialog->projectName()); - if (debug) + if (CustomWizardPrivate::verbose) qDebug() << "CustomProjectWizard::generateFiles" << dialog << targetPath << fieldReplacementMap; return generateWizardFiles(targetPath, fieldReplacementMap, errorMessage); } @@ -384,7 +400,7 @@ bool CustomProjectWizard::postGenerateFiles(const QWizard *, const Core::Generat // Post-Generate: Open the project const QString proFileName = l.back().path(); const bool opened = ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFileName); - if (debug) + if (CustomWizardPrivate::verbose) qDebug() << "CustomProjectWizard::postGenerateFiles: opened " << proFileName << opened; if (opened) { *errorMessage = tr("The project %1 could not be opened.").arg(proFileName); diff --git a/src/plugins/projectexplorer/customwizard/customwizard.h b/src/plugins/projectexplorer/customwizard/customwizard.h index 2b14e4043544c9a0be9b95cbf70ed6192355156b..de910b04fe3d54908a2bd8c34c8778af3fc1be27 100644 --- a/src/plugins/projectexplorer/customwizard/customwizard.h +++ b/src/plugins/projectexplorer/customwizard/customwizard.h @@ -99,6 +99,9 @@ public: // classes, call it in extensionsInitialized(). static QList<CustomWizard*> createWizards(); + static void setVerbose(int); + static int verbose(); + protected: typedef QSharedPointer<Internal::CustomWizardParameters> CustomWizardParametersPtr; diff --git a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp index 5c63f30717effb5366af8d7bea66f45c6c439404..716b843c3a35b632cb66c4c3df5532028a1818b6 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp @@ -68,7 +68,7 @@ CustomWizardFieldPage::CustomWizardFieldPage(const FieldList &fields, m_formLayout(new QFormLayout) { if (debug) - qDebug() << Q_FUNC_INFO << fields; + qDebug() << Q_FUNC_INFO << fields.size(); foreach(const CustomWizardField &f, fields) addField(f); setLayout(m_formLayout); diff --git a/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp b/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp index bc9bcc2acbc067f4059f3df5bf073d57fafdd645..bf89b9fe90287cb42a338c5c73f38dcaf3901440 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp @@ -442,30 +442,29 @@ bool CustomWizardParameters::parse(const QString &configFileFullPath, return parse(configFile, configFileFullPath, bp, errorMessage); } -QDebug operator<<(QDebug d, const CustomWizardField &m) +QString CustomWizardParameters::toString() const { - QDebug nsp = d.nospace(); - nsp << "Name: " << m.name; - if (m.mandatory) - nsp << '*'; - nsp << " Desc: " << m.description << " Control: " << m.controlAttributes; - return d; -} - -QDebug operator<<(QDebug d, const CustomWizardFile &f) -{ - d.nospace() << "source: " << f.source << " target: " << f.target; - return d; -} - -QDebug operator<<(QDebug d, const CustomWizardParameters &p) -{ - QDebug nsp = d.nospace(); - nsp << "Dir: " << p.directory << " klass:" << p.klass << " Files: " << p.files; - if (!p.fields.isEmpty()) - nsp << " Fields: " << p.fields; - nsp << "First page: " << p.firstPageId; - return d; + QString rc; + QTextStream str(&rc); + str << "Directory: " << directory << " Klass: '" << klass << "'\n"; + foreach(const CustomWizardFile &f, files) { + str << " File source: " << f.source << " Target: " << f.target << '\n'; + } + foreach(const CustomWizardField &f, fields) { + str << " Field name: " << f.name; + if (f.mandatory) + str << '*'; + str << " Description: '" << f.description << '\''; + if (!f.controlAttributes.isEmpty()) { + typedef CustomWizardField::ControlAttributeMap::const_iterator AttrMapConstIt; + str << " Control: "; + const AttrMapConstIt cend = f.controlAttributes.constEnd(); + for (AttrMapConstIt it = f.controlAttributes.constBegin(); it != cend; ++it) + str << '\'' << it.key() << "' -> '" << it.value() << "' "; + } + str << '\n'; + } + return rc; } } // namespace Internal diff --git a/src/plugins/projectexplorer/customwizard/customwizardparameters.h b/src/plugins/projectexplorer/customwizard/customwizardparameters.h index e526da0d0f11db91807b9cd801ec813fdff990c2..3ee6a19b23d9d6d0065247633fab7d1b4ca5fee0 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardparameters.h +++ b/src/plugins/projectexplorer/customwizard/customwizardparameters.h @@ -69,6 +69,7 @@ public: Core::BaseFileWizardParameters *bp, QString *errorMessage); bool parse(const QString &configFileFullPath, Core::BaseFileWizardParameters *bp, QString *errorMessage); + QString toString() const; QString directory; QString klass; @@ -78,10 +79,6 @@ public: int firstPageId; }; -QDebug operator<<(QDebug d, const CustomWizardField &); -QDebug operator<<(QDebug d, const CustomWizardFile &); -QDebug operator<<(QDebug d, const CustomWizardParameters &); - } // namespace Internal } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 8ac706e45021c8def5973ad9601f7e617e840b7a..144f2b19484ccc799fff7c4974056960ec417021 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -226,10 +226,16 @@ ProjectExplorerPlugin *ProjectExplorerPlugin::instance() return m_instance; } +bool ProjectExplorerPlugin::parseArguments(const QStringList &arguments, QString * /* error */) +{ + CustomWizard::setVerbose(arguments.count(QLatin1String("-customwizard-verbose"))); + return true; +} + bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *error) { - Q_UNUSED(arguments) - Q_UNUSED(error) + if (!parseArguments(arguments, error)) + return false; Core::ICore *core = Core::ICore::instance(); Core::ActionManager *am = core->actionManager(); diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index bc4e7ff35128a8524ab0183dafe31fb511b227c0..43b541cd941674ea0f4f9d6e1c23d5897da3dd8b 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -231,6 +231,7 @@ private slots: #endif private: + bool parseArguments(const QStringList &arguments, QString *error); void runProjectImpl(Project *pro, QString mode); void executeRunConfiguration(RunConfiguration *, const QString &mode); bool showBuildConfigDialog();