diff --git a/src/plugins/coreplugin/basefilewizard.cpp b/src/plugins/coreplugin/basefilewizard.cpp index 7fb0295bb62..f909c064f5d 100644 --- a/src/plugins/coreplugin/basefilewizard.cpp +++ b/src/plugins/coreplugin/basefilewizard.cpp @@ -578,26 +578,6 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QString &l return yes ? OverwriteOk : OverwriteCanceled; } -QList BaseFileWizard::allWizards() -{ - return ExtensionSystem::PluginManager::instance()->getObjects(); -} - -// Utility to find all registered wizards of a certain kind - -class WizardKindPredicate { -public: - WizardKindPredicate(IWizard::Kind kind) : m_kind(kind) {} - bool operator()(const IWizard &w) const { return w.kind() == m_kind; } -private: - const IWizard::Kind m_kind; -}; - -QList BaseFileWizard::findWizardsOfKind(Kind kind) -{ - return findWizards(WizardKindPredicate(kind)); -} - QString BaseFileWizard::buildFileName(const QString &path, const QString &baseName, const QString &extension) diff --git a/src/plugins/coreplugin/basefilewizard.h b/src/plugins/coreplugin/basefilewizard.h index 708aad23c45..c5dac78009c 100644 --- a/src/plugins/coreplugin/basefilewizard.h +++ b/src/plugins/coreplugin/basefilewizard.h @@ -151,11 +151,6 @@ public: virtual QStringList runWizard(const QString &path, QWidget *parent); - // Utility to find all registered wizards - static QList allWizards(); - // Utility to find all registered wizards of a certain kind - static QList findWizardsOfKind(Kind kind); - // Build a file name, adding the extension unless baseName already has one static QString buildFileName(const QString &path, const QString &baseName, const QString &extension); @@ -222,20 +217,6 @@ protected: QString *errorMessage) const = 0; }; -/* A utility to find all wizards supporting a view mode and matching a predicate */ -template - QList findWizards(Predicate predicate) -{ - // Filter all wizards - const QList allWizards = BaseFileWizard::allWizards(); - QList rc; - const QList::const_iterator cend = allWizards.constEnd(); - for (QList::const_iterator it = allWizards.constBegin(); it != cend; ++it) - if (predicate(*(*it))) - rc.push_back(*it); - return rc; -} - } // namespace Core #endif // BASEFILEWIZARD_H diff --git a/src/plugins/coreplugin/dialogs/iwizard.cpp b/src/plugins/coreplugin/dialogs/iwizard.cpp index a73a30f0bc8..d1e4067c535 100644 --- a/src/plugins/coreplugin/dialogs/iwizard.cpp +++ b/src/plugins/coreplugin/dialogs/iwizard.cpp @@ -1,5 +1,36 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +**************************************************************************/ + #include "iwizard.h" +#include + /*! \class Core::IWizard \mainclass @@ -95,3 +126,40 @@ default path. Returns a list of files (absolute paths) that have been created, if any. */ + +using namespace Core; + +/* A utility to find all wizards supporting a view mode and matching a predicate */ +template + QList findWizards(Predicate predicate) +{ + // Filter all wizards + const QList allWizards = IWizard::allWizards(); + QList rc; + const QList::const_iterator cend = allWizards.constEnd(); + for (QList::const_iterator it = allWizards.constBegin(); it != cend; ++it) + if (predicate(*(*it))) + rc.push_back(*it); + return rc; +} + +QList IWizard::allWizards() +{ + return ExtensionSystem::PluginManager::instance()->getObjects(); +} + +// Utility to find all registered wizards of a certain kind + +class WizardKindPredicate { +public: + WizardKindPredicate(IWizard::Kind kind) : m_kind(kind) {} + bool operator()(const IWizard &w) const { return w.kind() == m_kind; } +private: + const IWizard::Kind m_kind; +}; + +QList IWizard::wizardsOfKind(Kind kind) +{ + return findWizards(WizardKindPredicate(kind)); +} + diff --git a/src/plugins/coreplugin/dialogs/iwizard.h b/src/plugins/coreplugin/dialogs/iwizard.h index 00f292ce6db..5061382bf6d 100644 --- a/src/plugins/coreplugin/dialogs/iwizard.h +++ b/src/plugins/coreplugin/dialogs/iwizard.h @@ -62,6 +62,11 @@ public: virtual QString trCategory() const = 0; virtual QStringList runWizard(const QString &path, QWidget *parent) = 0; + + // Utility to find all registered wizards + static QList allWizards(); + // Utility to find all registered wizards of a certain kind + static QList wizardsOfKind(Kind kind); }; } // namespace Core diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 3ddf4fc75c2..f808c63acd2 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -760,7 +760,7 @@ void MainWindow::registerDefaultActions() void MainWindow::newFile() { - showNewItemDialog(tr("New", "Title of dialog"),BaseFileWizard::allWizards()); + showNewItemDialog(tr("New", "Title of dialog"), IWizard::allWizards()); } void MainWindow::openFile() diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index a4eba076f30..46e8c7568f6 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -797,7 +797,7 @@ void ProjectExplorerPlugin::newProject() } Core::ICore::instance()->showNewItemDialog(tr("New Project", "Title of dialog"), - Core::BaseFileWizard::findWizardsOfKind(Core::IWizard::ProjectWizard), + Core::IWizard::wizardsOfKind(Core::IWizard::ProjectWizard), defaultLocation); updateActions(); } @@ -1641,8 +1641,8 @@ void ProjectExplorerPlugin::addNewFile() return; const QString location = QFileInfo(m_currentNode->path()).dir().absolutePath(); Core::ICore::instance()->showNewItemDialog(tr("New File", "Title of dialog"), - Core::BaseFileWizard::findWizardsOfKind(Core::IWizard::FileWizard) - + Core::BaseFileWizard::findWizardsOfKind(Core::IWizard::ClassWizard), + Core::IWizard::wizardsOfKind(Core::IWizard::FileWizard) + + Core::IWizard::wizardsOfKind(Core::IWizard::ClassWizard), location); }