Commit 897c05f5 authored by hjk's avatar hjk
Browse files

replace Core::ICore::instance()->pluginManager() by ExtensionSystem::PluginManager::instance()

parent 67437acf
...@@ -346,28 +346,19 @@ void WizardEventLoop::rejected() ...@@ -346,28 +346,19 @@ void WizardEventLoop::rejected()
// ---------------- BaseFileWizardPrivate // ---------------- BaseFileWizardPrivate
struct BaseFileWizardPrivate struct BaseFileWizardPrivate
{ {
explicit BaseFileWizardPrivate(const Core::BaseFileWizardParameters &parameters, explicit BaseFileWizardPrivate(const Core::BaseFileWizardParameters &parameters)
Core::ICore *core); : m_parameters(parameters), m_wizardDialog(0)
{}
const Core::BaseFileWizardParameters m_parameters; const Core::BaseFileWizardParameters m_parameters;
QWizard *m_wizardDialog; QWizard *m_wizardDialog;
Core::ICore *m_core;
}; };
Core::BaseFileWizardPrivate::BaseFileWizardPrivate(const BaseFileWizardParameters &parameters,
Core::ICore *core) :
m_parameters(parameters),
m_wizardDialog(0),
m_core(core)
{
}
// ---------------- Wizard // ---------------- Wizard
BaseFileWizard::BaseFileWizard(const BaseFileWizardParameters &parameters, BaseFileWizard::BaseFileWizard(const BaseFileWizardParameters &parameters,
Core::ICore *core,
QObject *parent) : QObject *parent) :
IWizard(parent), IWizard(parent),
m_d(new BaseFileWizardPrivate(parameters, core)) m_d(new BaseFileWizardPrivate(parameters))
{ {
} }
...@@ -518,13 +509,14 @@ bool BaseFileWizard::postGenerateFiles(const GeneratedFiles &l, QString *errorMe ...@@ -518,13 +509,14 @@ bool BaseFileWizard::postGenerateFiles(const GeneratedFiles &l, QString *errorMe
{ {
// File mode: open the editors in file mode and ensure editor pane // File mode: open the editors in file mode and ensure editor pane
const Core::GeneratedFiles::const_iterator cend = l.constEnd(); const Core::GeneratedFiles::const_iterator cend = l.constEnd();
Core::EditorManager *em = Core::ICore::instance()->editorManager();
for (Core::GeneratedFiles::const_iterator it = l.constBegin(); it != cend; ++it) { for (Core::GeneratedFiles::const_iterator it = l.constBegin(); it != cend; ++it) {
if (!m_d->m_core->editorManager()->openEditor(it->path(), it->editorKind())) { if (!em->openEditor(it->path(), it->editorKind())) {
*errorMessage = tr("Failed to open an editor for %1").arg(it->path()); *errorMessage = tr("Failed to open an editor for %1").arg(it->path());
return false; return false;
} }
} }
m_d->m_core->editorManager()->ensureEditorManagerVisible(); em->ensureEditorManagerVisible();
return true; return true;
} }
...@@ -535,7 +527,6 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QString &l ...@@ -535,7 +527,6 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QString &l
if (debugWizard) if (debugWizard)
qDebug() << Q_FUNC_INFO << location << files; qDebug() << Q_FUNC_INFO << location << files;
bool existingFilesFound = false; bool existingFilesFound = false;
bool oddStuffFound = false; bool oddStuffFound = false;
...@@ -582,7 +573,7 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QString &l ...@@ -582,7 +573,7 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QString &l
const QString messageFormat = tr("The following files already exist in the directory %1:\n" const QString messageFormat = tr("The following files already exist in the directory %1:\n"
"%2.\nWould you like to overwrite them?"); "%2.\nWould you like to overwrite them?");
const QString message = messageFormat.arg(location).arg(fileNamesMsgPart); const QString message = messageFormat.arg(location).arg(fileNamesMsgPart);
const bool yes = (QMessageBox::question(core()->mainWindow(), const bool yes = (QMessageBox::question(Core::ICore::instance()->mainWindow(),
tr("Existing files"), message, tr("Existing files"), message,
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes | QMessageBox::No,
QMessageBox::No) QMessageBox::No)
...@@ -590,11 +581,6 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QString &l ...@@ -590,11 +581,6 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QString &l
return yes ? OverwriteOk : OverwriteCanceled; return yes ? OverwriteOk : OverwriteCanceled;
} }
Core::ICore *BaseFileWizard::core() const
{
return m_d->m_core;
}
QList<IWizard*> BaseFileWizard::allWizards() QList<IWizard*> BaseFileWizard::allWizards()
{ {
return ExtensionSystem::PluginManager::instance()->getObjects<IWizard>(); return ExtensionSystem::PluginManager::instance()->getObjects<IWizard>();
...@@ -637,19 +623,18 @@ QString BaseFileWizard::buildFileName(const QString &path, ...@@ -637,19 +623,18 @@ QString BaseFileWizard::buildFileName(const QString &path,
QString BaseFileWizard::preferredSuffix(const QString &mimeType) const QString BaseFileWizard::preferredSuffix(const QString &mimeType) const
{ {
const QString rc = m_d->m_core->mimeDatabase()->preferredSuffixByType(mimeType); const QString rc = Core::ICore::instance()->mimeDatabase()->preferredSuffixByType(mimeType);
if (rc.isEmpty()) if (rc.isEmpty())
qWarning("%s: WARNING: Unable to find a preferred suffix for %s.", qWarning("%s: WARNING: Unable to find a preferred suffix for %s.",
Q_FUNC_INFO, mimeType.toUtf8().constData()); Q_FUNC_INFO, mimeType.toUtf8().constData());
return rc; return rc;
} }
// ------------- StandardFileWizard( // ------------- StandardFileWizard
StandardFileWizard::StandardFileWizard(const BaseFileWizardParameters &parameters, StandardFileWizard::StandardFileWizard(const BaseFileWizardParameters &parameters,
Core::ICore *core,
QObject *parent) : QObject *parent) :
BaseFileWizard(parameters, core, parent) BaseFileWizard(parameters, parent)
{ {
} }
......
...@@ -50,7 +50,6 @@ QT_END_NAMESPACE ...@@ -50,7 +50,6 @@ QT_END_NAMESPACE
namespace Core { namespace Core {
class ICore;
class IEditor; class IEditor;
class IFileWizardExtension; class IFileWizardExtension;
...@@ -69,7 +68,7 @@ public: ...@@ -69,7 +68,7 @@ public:
GeneratedFile(); GeneratedFile();
explicit GeneratedFile(const QString &path); explicit GeneratedFile(const QString &path);
GeneratedFile(const GeneratedFile &); GeneratedFile(const GeneratedFile &);
GeneratedFile &operator=(const GeneratedFile&); GeneratedFile &operator=(const GeneratedFile &);
~GeneratedFile(); ~GeneratedFile();
// Full path of the file should be created, or the suggested file name // Full path of the file should be created, or the suggested file name
...@@ -107,19 +106,19 @@ public: ...@@ -107,19 +106,19 @@ public:
void setKind(IWizard::Kind k); void setKind(IWizard::Kind k);
QIcon icon() const; QIcon icon() const;
void setIcon(const QIcon&); void setIcon(const QIcon &icon);
QString description() const; QString description() const;
void setDescription(const QString &); void setDescription(const QString &description);
QString name() const; QString name() const;
void setName(const QString &); void setName(const QString &name);
QString category() const; QString category() const;
void setCategory(const QString &); void setCategory(const QString &category);
QString trCategory() const; QString trCategory() const;
void setTrCategory(const QString &); void setTrCategory(const QString &trCategory);
private: private:
QSharedDataPointer<BaseFileWizardParameterData> m_d; QSharedDataPointer<BaseFileWizardParameterData> m_d;
...@@ -172,7 +171,7 @@ public: ...@@ -172,7 +171,7 @@ public:
protected: protected:
typedef QList<QWizardPage *> WizardPageList; typedef QList<QWizardPage *> WizardPageList;
explicit BaseFileWizard(const BaseFileWizardParameters &parameters, Core::ICore *core, QObject *parent = 0); explicit BaseFileWizard(const BaseFileWizardParameters &parameters, QObject *parent = 0);
// Overwrite to create the wizard dialog on the parent, adding // Overwrite to create the wizard dialog on the parent, adding
// the extension pages. // the extension pages.
...@@ -197,8 +196,6 @@ protected: ...@@ -197,8 +196,6 @@ protected:
OverwriteResult promptOverwrite(const QString &location, OverwriteResult promptOverwrite(const QString &location,
const QStringList &files, const QStringList &files,
QString *errorMessage) const; QString *errorMessage) const;
Core::ICore *core() const;
private: private:
BaseFileWizardPrivate *m_d; BaseFileWizardPrivate *m_d;
}; };
...@@ -213,7 +210,7 @@ class CORE_EXPORT StandardFileWizard : public BaseFileWizard ...@@ -213,7 +210,7 @@ class CORE_EXPORT StandardFileWizard : public BaseFileWizard
Q_OBJECT Q_OBJECT
protected: protected:
explicit StandardFileWizard(const BaseFileWizardParameters &parameters, Core::ICore *core, QObject *parent = 0); explicit StandardFileWizard(const BaseFileWizardParameters &parameters, QObject *parent = 0);
// Implemented to create a Core::Utils::FileWizardDialog // Implemented to create a Core::Utils::FileWizardDialog
virtual QWizard *createWizardDialog(QWidget *parent, virtual QWizard *createWizardDialog(QWidget *parent,
......
...@@ -60,7 +60,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &initialCategory, ...@@ -60,7 +60,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &initialCategory,
QMap<QString, QTreeWidgetItem *> categories; QMap<QString, QTreeWidgetItem *> categories;
QList<IOptionsPage*> pages = QList<IOptionsPage*> pages =
CoreImpl::instance()->pluginManager()->getObjects<IOptionsPage>(); ExtensionSystem::PluginManager::instance()->getObjects<IOptionsPage>();
int index = 0; int index = 0;
foreach (IOptionsPage *page, pages) { foreach (IOptionsPage *page, pages) {
......
...@@ -78,6 +78,11 @@ using namespace Core::Internal; ...@@ -78,6 +78,11 @@ using namespace Core::Internal;
enum { debugEditorManager=0 }; enum { debugEditorManager=0 };
static inline ExtensionSystem::PluginManager *pluginManager()
{
return ExtensionSystem::PluginManager::instance();
}
//===================EditorManager===================== //===================EditorManager=====================
EditorManagerPlaceHolder *EditorManagerPlaceHolder::m_current = 0; EditorManagerPlaceHolder *EditorManagerPlaceHolder::m_current = 0;
...@@ -374,11 +379,12 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) : ...@@ -374,11 +379,12 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
EditorManager::~EditorManager() EditorManager::~EditorManager()
{ {
if (m_d->m_core) { if (m_d->m_core) {
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
if (m_d->m_coreListener) { if (m_d->m_coreListener) {
m_d->m_core->pluginManager()->removeObject(m_d->m_coreListener); pm->removeObject(m_d->m_coreListener);
delete m_d->m_coreListener; delete m_d->m_coreListener;
} }
m_d->m_core->pluginManager()->removeObject(m_d->m_openEditorsFactory); pm->removeObject(m_d->m_openEditorsFactory);
delete m_d->m_openEditorsFactory; delete m_d->m_openEditorsFactory;
} }
delete m_d; delete m_d;
...@@ -390,10 +396,11 @@ void EditorManager::init() ...@@ -390,10 +396,11 @@ void EditorManager::init()
context << m_d->m_core->uniqueIDManager()->uniqueIdentifier("QtCreator.OpenDocumentsView"); context << m_d->m_core->uniqueIDManager()->uniqueIdentifier("QtCreator.OpenDocumentsView");
m_d->m_coreListener = new EditorClosingCoreListener(this); m_d->m_coreListener = new EditorClosingCoreListener(this);
m_d->m_core->pluginManager()->addObject(m_d->m_coreListener);
pluginManager()->addObject(m_d->m_coreListener);
m_d->m_openEditorsFactory = new OpenEditorsViewFactory(); m_d->m_openEditorsFactory = new OpenEditorsViewFactory();
m_d->m_core->pluginManager()->addObject(m_d->m_openEditorsFactory); pluginManager()->addObject(m_d->m_openEditorsFactory);
} }
QSize EditorManager::minimumSizeHint() const QSize EditorManager::minimumSizeHint() const
...@@ -624,7 +631,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> editorsToClose, bool askA ...@@ -624,7 +631,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> editorsToClose, bool askA
QList<IEditor*> acceptedEditors; QList<IEditor*> acceptedEditors;
//ask all core listeners to check whether the editor can be closed //ask all core listeners to check whether the editor can be closed
const QList<ICoreListener *> listeners = const QList<ICoreListener *> listeners =
m_d->m_core->pluginManager()->getObjects<ICoreListener>(); pluginManager()->getObjects<ICoreListener>();
foreach (IEditor *editor, editorsToClose) { foreach (IEditor *editor, editorsToClose) {
bool editorAccepted = true; bool editorAccepted = true;
foreach (ICoreListener *listener, listeners) { foreach (ICoreListener *listener, listeners) {
...@@ -740,7 +747,7 @@ EditorManager::EditorFactoryList ...@@ -740,7 +747,7 @@ EditorManager::EditorFactoryList
EditorManager::editorFactories(const MimeType &mimeType, bool bestMatchOnly) const EditorManager::editorFactories(const MimeType &mimeType, bool bestMatchOnly) const
{ {
EditorFactoryList rc; EditorFactoryList rc;
const EditorFactoryList allFactories = m_d->m_core->pluginManager()->getObjects<IEditorFactory>(); const EditorFactoryList allFactories = pluginManager()->getObjects<IEditorFactory>();
mimeTypeFactoryRecursion(m_d->m_core->mimeDatabase(), mimeType, allFactories, bestMatchOnly, &rc); mimeTypeFactoryRecursion(m_d->m_core->mimeDatabase(), mimeType, allFactories, bestMatchOnly, &rc);
if (debugEditorManager) if (debugEditorManager)
qDebug() << Q_FUNC_INFO << mimeType.type() << " returns " << rc; qDebug() << Q_FUNC_INFO << mimeType.type() << " returns " << rc;
...@@ -767,7 +774,7 @@ IEditor *EditorManager::createEditor(const QString &editorKind, ...@@ -767,7 +774,7 @@ IEditor *EditorManager::createEditor(const QString &editorKind,
factories = editorFactories(mimeType, true); factories = editorFactories(mimeType, true);
} else { } else {
// Find by editor kind // Find by editor kind
const EditorFactoryList allFactories = m_d->m_core->pluginManager()->getObjects<IEditorFactory>(); const EditorFactoryList allFactories = pluginManager()->getObjects<IEditorFactory>();
const EditorFactoryList::const_iterator acend = allFactories.constEnd(); const EditorFactoryList::const_iterator acend = allFactories.constEnd();
for (EditorFactoryList::const_iterator ait = allFactories.constBegin(); ait != acend; ++ait) { for (EditorFactoryList::const_iterator ait = allFactories.constBegin(); ait != acend; ++ait) {
if (editorKind == (*ait)->kind()) { if (editorKind == (*ait)->kind()) {
......
...@@ -44,12 +44,6 @@ class QSettings; ...@@ -44,12 +44,6 @@ class QSettings;
template <class T> class QList; template <class T> class QList;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace ExtensionSystem {
class PluginManager;
} // namespace ExtensionSystem
namespace Core { namespace Core {
class ActionManager; class ActionManager;
...@@ -87,7 +81,6 @@ public: ...@@ -87,7 +81,6 @@ public:
virtual FileManager *fileManager() const = 0; virtual FileManager *fileManager() const = 0;
virtual UniqueIDManager *uniqueIDManager() const = 0; virtual UniqueIDManager *uniqueIDManager() const = 0;
virtual MessageManager *messageManager() const = 0; virtual MessageManager *messageManager() const = 0;
virtual ExtensionSystem::PluginManager *pluginManager() const = 0;
virtual EditorManager *editorManager() const = 0; virtual EditorManager *editorManager() const = 0;
virtual ProgressManager *progressManager() const = 0; virtual ProgressManager *progressManager() const = 0;
virtual ScriptManager *scriptManager() const = 0; virtual ScriptManager *scriptManager() const = 0;
......
...@@ -698,8 +698,8 @@ void MainWindow::openFile() ...@@ -698,8 +698,8 @@ void MainWindow::openFile()
static QList<IFileFactory*> getNonEditorFileFactories() static QList<IFileFactory*> getNonEditorFileFactories()
{ {
const ICore *core = CoreImpl::instance(); const QList<IFileFactory*> allFileFactories =
const QList<IFileFactory*> allFileFactories = core->pluginManager()->getObjects<IFileFactory>(); ExtensionSystem::PluginManager::instance()->getObjects<IFileFactory>();
QList<IFileFactory*> nonEditorFileFactories; QList<IFileFactory*> nonEditorFileFactories;
foreach (IFileFactory *factory, allFileFactories) { foreach (IFileFactory *factory, allFileFactories) {
if (!qobject_cast<IEditorFactory *>(factory)) if (!qobject_cast<IEditorFactory *>(factory))
......
...@@ -42,9 +42,6 @@ ...@@ -42,9 +42,6 @@
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtCore/QTextStream> #include <QtCore/QTextStream>
#include <QtGui/QCheckBox>
#include <QtGui/QComboBox>
#include <QtGui/QLabel>
#include <QtGui/QVBoxLayout> #include <QtGui/QVBoxLayout>
#include <QtGui/QWizard> #include <QtGui/QWizard>
...@@ -124,8 +121,8 @@ CppClassWizardParameters CppClassWizardDialog::parameters() const ...@@ -124,8 +121,8 @@ CppClassWizardParameters CppClassWizardDialog::parameters() const
// ========= CppClassWizard ========= // ========= CppClassWizard =========
CppClassWizard::CppClassWizard(const Core::BaseFileWizardParameters &parameters, CppClassWizard::CppClassWizard(const Core::BaseFileWizardParameters &parameters,
Core::ICore *core, QObject *parent) : QObject *parent)
Core::BaseFileWizard(parameters, core, parent) : Core::BaseFileWizard(parameters, parent)
{ {
} }
......
...@@ -40,16 +40,13 @@ ...@@ -40,16 +40,13 @@
#include <QtGui/QWizardPage> #include <QtGui/QWizardPage>
#include <QtGui/QWizard> #include <QtGui/QWizard>
QT_BEGIN_NAMESPACE
class QCheckBox;
class QComboBox;
QT_END_NAMESPACE
namespace Core { namespace Core {
namespace Utils { namespace Utils {
class NewClassWidget;
} class NewClassWidget;
}
} // namespace Utils
} // namespace Core
namespace CppEditor { namespace CppEditor {
namespace Internal { namespace Internal {
...@@ -75,7 +72,8 @@ private: ...@@ -75,7 +72,8 @@ private:
}; };
struct CppClassWizardParameters { struct CppClassWizardParameters
{
QString className; QString className;
QString headerFile; QString headerFile;
QString sourceFile; QString sourceFile;
...@@ -83,9 +81,10 @@ struct CppClassWizardParameters { ...@@ -83,9 +81,10 @@ struct CppClassWizardParameters {
QString path; QString path;
}; };
class CppClassWizardDialog : public QWizard { class CppClassWizardDialog : public QWizard
Q_DISABLE_COPY(CppClassWizardDialog) {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(CppClassWizardDialog)
public: public:
explicit CppClassWizardDialog(const QString &sourceSuffix, explicit CppClassWizardDialog(const QString &sourceSuffix,
const QString &headerSuffix, const QString &headerSuffix,
...@@ -104,7 +103,7 @@ class CppClassWizard : public Core::BaseFileWizard ...@@ -104,7 +103,7 @@ class CppClassWizard : public Core::BaseFileWizard
Q_OBJECT Q_OBJECT
public: public:
explicit CppClassWizard(const Core::BaseFileWizardParameters &parameters, explicit CppClassWizard(const Core::BaseFileWizardParameters &parameters,
Core::ICore *core, QObject *parent = 0); QObject *parent = 0);
protected: protected:
virtual QWizard *createWizardDialog(QWidget *parent, virtual QWizard *createWizardDialog(QWidget *parent,
......
...@@ -38,10 +38,9 @@ ...@@ -38,10 +38,9 @@
using namespace CppEditor::Internal; using namespace CppEditor::Internal;
CPPEditorActionHandler::CPPEditorActionHandler(Core::ICore *core, CPPEditorActionHandler::CPPEditorActionHandler(const QString &context,
const QString &context,
uint optionalActions) uint optionalActions)
: TextEditor::TextEditorActionHandler(core, context, optionalActions) : TextEditor::TextEditorActionHandler(context, optionalActions)
{ } { }
CPPEditorActionHandler::~CPPEditorActionHandler() CPPEditorActionHandler::~CPPEditorActionHandler()
......
...@@ -44,8 +44,7 @@ class CPPEditorActionHandler : public TextEditor::TextEditorActionHandler ...@@ -44,8 +44,7 @@ class CPPEditorActionHandler : public TextEditor::TextEditorActionHandler
Q_OBJECT Q_OBJECT
public: public:
CPPEditorActionHandler(Core::ICore *core, CPPEditorActionHandler(const QString &context,
const QString &context,
uint optionalActions = None); uint optionalActions = None);
virtual ~CPPEditorActionHandler(); virtual ~CPPEditorActionHandler();
......
...@@ -46,9 +46,8 @@ enum { debugWizard = 0 }; ...@@ -46,9 +46,8 @@ enum { debugWizard = 0 };
CppFileWizard::CppFileWizard(const BaseFileWizardParameters &parameters, CppFileWizard::CppFileWizard(const BaseFileWizardParameters &parameters,
FileType type, FileType type,
Core::ICore *core,
QObject *parent) : QObject *parent) :
Core::StandardFileWizard(parameters, core, parent), Core::StandardFileWizard(parameters, parent),
m_type(type) m_type(type)
{ {
} }
......
...@@ -48,9 +48,9 @@ class CppFileWizard : public Core::StandardFileWizard ...@@ -48,9 +48,9 @@ class CppFileWizard : public Core::StandardFileWizard
public: public:
typedef Core::BaseFileWizardParameters BaseFileWizardParameters; typedef Core::BaseFileWizardParameters BaseFileWizardParameters;
explicit CppFileWizard(const BaseFileWizardParameters &parameters, CppFileWizard(const BaseFileWizardParameters &parameters,
FileType type, FileType type,
Core::ICore *core, QObject *parent = 0); QObject *parent = 0);
protected: protected:
static QString toAlphaNum(const QString &s); static QString toAlphaNum(const QString &s);
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "cppfilewizard.h" #include "cppfilewizard.h"
#include "cpphoverhandler.h" #include "cpphoverhandler.h"
#include <coreplugin/icore.h>