Commit 897c05f5 authored by hjk's avatar hjk

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

parent 67437acf
......@@ -346,28 +346,19 @@ void WizardEventLoop::rejected()
// ---------------- BaseFileWizardPrivate
struct BaseFileWizardPrivate
{
explicit BaseFileWizardPrivate(const Core::BaseFileWizardParameters &parameters,
Core::ICore *core);
explicit BaseFileWizardPrivate(const Core::BaseFileWizardParameters &parameters)
: m_parameters(parameters), m_wizardDialog(0)
{}
const Core::BaseFileWizardParameters m_parameters;
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
BaseFileWizard::BaseFileWizard(const BaseFileWizardParameters &parameters,
Core::ICore *core,
QObject *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
{
// File mode: open the editors in file mode and ensure editor pane
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) {
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());
return false;
}
}
m_d->m_core->editorManager()->ensureEditorManagerVisible();
em->ensureEditorManagerVisible();
return true;
}
......@@ -535,7 +527,6 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QString &l
if (debugWizard)
qDebug() << Q_FUNC_INFO << location << files;
bool existingFilesFound = false;
bool oddStuffFound = false;
......@@ -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"
"%2.\nWould you like to overwrite them?");
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,
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No)
......@@ -590,11 +581,6 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QString &l
return yes ? OverwriteOk : OverwriteCanceled;
}
Core::ICore *BaseFileWizard::core() const
{
return m_d->m_core;
}
QList<IWizard*> BaseFileWizard::allWizards()
{
return ExtensionSystem::PluginManager::instance()->getObjects<IWizard>();
......@@ -637,19 +623,18 @@ QString BaseFileWizard::buildFileName(const QString &path,
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())
qWarning("%s: WARNING: Unable to find a preferred suffix for %s.",
Q_FUNC_INFO, mimeType.toUtf8().constData());
return rc;
}
// ------------- StandardFileWizard(
// ------------- StandardFileWizard
StandardFileWizard::StandardFileWizard(const BaseFileWizardParameters &parameters,
Core::ICore *core,
QObject *parent) :
BaseFileWizard(parameters, core, parent)
BaseFileWizard(parameters, parent)
{
}
......
......@@ -50,7 +50,6 @@ QT_END_NAMESPACE
namespace Core {
class ICore;
class IEditor;
class IFileWizardExtension;
......@@ -69,7 +68,7 @@ public:
GeneratedFile();
explicit GeneratedFile(const QString &path);
GeneratedFile(const GeneratedFile &);
GeneratedFile &operator=(const GeneratedFile&);
GeneratedFile &operator=(const GeneratedFile &);
~GeneratedFile();
// Full path of the file should be created, or the suggested file name
......@@ -107,19 +106,19 @@ public:
void setKind(IWizard::Kind k);
QIcon icon() const;
void setIcon(const QIcon&);
void setIcon(const QIcon &icon);
QString description() const;
void setDescription(const QString &);
void setDescription(const QString &description);
QString name() const;
void setName(const QString &);
void setName(const QString &name);
QString category() const;
void setCategory(const QString &);
void setCategory(const QString &category);
QString trCategory() const;
void setTrCategory(const QString &);
void setTrCategory(const QString &trCategory);
private:
QSharedDataPointer<BaseFileWizardParameterData> m_d;
......@@ -172,7 +171,7 @@ public:
protected:
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
// the extension pages.
......@@ -197,8 +196,6 @@ protected:
OverwriteResult promptOverwrite(const QString &location,
const QStringList &files,
QString *errorMessage) const;
Core::ICore *core() const;
private:
BaseFileWizardPrivate *m_d;
};
......@@ -213,7 +210,7 @@ class CORE_EXPORT StandardFileWizard : public BaseFileWizard
Q_OBJECT
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
virtual QWizard *createWizardDialog(QWidget *parent,
......
......@@ -60,7 +60,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &initialCategory,
QMap<QString, QTreeWidgetItem *> categories;
QList<IOptionsPage*> pages =
CoreImpl::instance()->pluginManager()->getObjects<IOptionsPage>();
ExtensionSystem::PluginManager::instance()->getObjects<IOptionsPage>();
int index = 0;
foreach (IOptionsPage *page, pages) {
......
......@@ -78,6 +78,11 @@ using namespace Core::Internal;
enum { debugEditorManager=0 };
static inline ExtensionSystem::PluginManager *pluginManager()
{
return ExtensionSystem::PluginManager::instance();
}
//===================EditorManager=====================
EditorManagerPlaceHolder *EditorManagerPlaceHolder::m_current = 0;
......@@ -374,11 +379,12 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
EditorManager::~EditorManager()
{
if (m_d->m_core) {
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
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;
}
m_d->m_core->pluginManager()->removeObject(m_d->m_openEditorsFactory);
pm->removeObject(m_d->m_openEditorsFactory);
delete m_d->m_openEditorsFactory;
}
delete m_d;
......@@ -390,10 +396,11 @@ void EditorManager::init()
context << m_d->m_core->uniqueIDManager()->uniqueIdentifier("QtCreator.OpenDocumentsView");
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_core->pluginManager()->addObject(m_d->m_openEditorsFactory);
pluginManager()->addObject(m_d->m_openEditorsFactory);
}
QSize EditorManager::minimumSizeHint() const
......@@ -624,7 +631,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> editorsToClose, bool askA
QList<IEditor*> acceptedEditors;
//ask all core listeners to check whether the editor can be closed
const QList<ICoreListener *> listeners =
m_d->m_core->pluginManager()->getObjects<ICoreListener>();
pluginManager()->getObjects<ICoreListener>();
foreach (IEditor *editor, editorsToClose) {
bool editorAccepted = true;
foreach (ICoreListener *listener, listeners) {
......@@ -740,7 +747,7 @@ EditorManager::EditorFactoryList
EditorManager::editorFactories(const MimeType &mimeType, bool bestMatchOnly) const
{
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);
if (debugEditorManager)
qDebug() << Q_FUNC_INFO << mimeType.type() << " returns " << rc;
......@@ -767,7 +774,7 @@ IEditor *EditorManager::createEditor(const QString &editorKind,
factories = editorFactories(mimeType, true);
} else {
// 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();
for (EditorFactoryList::const_iterator ait = allFactories.constBegin(); ait != acend; ++ait) {
if (editorKind == (*ait)->kind()) {
......
......@@ -44,12 +44,6 @@ class QSettings;
template <class T> class QList;
QT_END_NAMESPACE
namespace ExtensionSystem {
class PluginManager;
} // namespace ExtensionSystem
namespace Core {
class ActionManager;
......@@ -87,7 +81,6 @@ public:
virtual FileManager *fileManager() const = 0;
virtual UniqueIDManager *uniqueIDManager() const = 0;
virtual MessageManager *messageManager() const = 0;
virtual ExtensionSystem::PluginManager *pluginManager() const = 0;
virtual EditorManager *editorManager() const = 0;
virtual ProgressManager *progressManager() const = 0;
virtual ScriptManager *scriptManager() const = 0;
......
......@@ -698,8 +698,8 @@ void MainWindow::openFile()
static QList<IFileFactory*> getNonEditorFileFactories()
{
const ICore *core = CoreImpl::instance();
const QList<IFileFactory*> allFileFactories = core->pluginManager()->getObjects<IFileFactory>();
const QList<IFileFactory*> allFileFactories =
ExtensionSystem::PluginManager::instance()->getObjects<IFileFactory>();
QList<IFileFactory*> nonEditorFileFactories;
foreach (IFileFactory *factory, allFileFactories) {
if (!qobject_cast<IEditorFactory *>(factory))
......
......@@ -42,9 +42,6 @@
#include <QtCore/QDir>
#include <QtCore/QTextStream>
#include <QtGui/QCheckBox>
#include <QtGui/QComboBox>
#include <QtGui/QLabel>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWizard>
......@@ -124,8 +121,8 @@ CppClassWizardParameters CppClassWizardDialog::parameters() const
// ========= CppClassWizard =========
CppClassWizard::CppClassWizard(const Core::BaseFileWizardParameters &parameters,
Core::ICore *core, QObject *parent) :
Core::BaseFileWizard(parameters, core, parent)
QObject *parent)
: Core::BaseFileWizard(parameters, parent)
{
}
......
......@@ -40,16 +40,13 @@
#include <QtGui/QWizardPage>
#include <QtGui/QWizard>
QT_BEGIN_NAMESPACE
class QCheckBox;
class QComboBox;
QT_END_NAMESPACE
namespace Core {
namespace Utils {
class NewClassWidget;
}
}
class NewClassWidget;
} // namespace Utils
} // namespace Core
namespace CppEditor {
namespace Internal {
......@@ -75,7 +72,8 @@ private:
};
struct CppClassWizardParameters {
struct CppClassWizardParameters
{
QString className;
QString headerFile;
QString sourceFile;
......@@ -83,9 +81,10 @@ struct CppClassWizardParameters {
QString path;
};
class CppClassWizardDialog : public QWizard {
Q_DISABLE_COPY(CppClassWizardDialog)
class CppClassWizardDialog : public QWizard
{
Q_OBJECT
Q_DISABLE_COPY(CppClassWizardDialog)
public:
explicit CppClassWizardDialog(const QString &sourceSuffix,
const QString &headerSuffix,
......@@ -104,7 +103,7 @@ class CppClassWizard : public Core::BaseFileWizard
Q_OBJECT
public:
explicit CppClassWizard(const Core::BaseFileWizardParameters &parameters,
Core::ICore *core, QObject *parent = 0);
QObject *parent = 0);
protected:
virtual QWizard *createWizardDialog(QWidget *parent,
......
......@@ -38,10 +38,9 @@
using namespace CppEditor::Internal;
CPPEditorActionHandler::CPPEditorActionHandler(Core::ICore *core,
const QString &context,
CPPEditorActionHandler::CPPEditorActionHandler(const QString &context,
uint optionalActions)
: TextEditor::TextEditorActionHandler(core, context, optionalActions)
: TextEditor::TextEditorActionHandler(context, optionalActions)
{ }
CPPEditorActionHandler::~CPPEditorActionHandler()
......
......@@ -44,8 +44,7 @@ class CPPEditorActionHandler : public TextEditor::TextEditorActionHandler
Q_OBJECT
public:
CPPEditorActionHandler(Core::ICore *core,
const QString &context,
CPPEditorActionHandler(const QString &context,
uint optionalActions = None);
virtual ~CPPEditorActionHandler();
......
......@@ -46,9 +46,8 @@ enum { debugWizard = 0 };
CppFileWizard::CppFileWizard(const BaseFileWizardParameters &parameters,
FileType type,
Core::ICore *core,
QObject *parent) :
Core::StandardFileWizard(parameters, core, parent),
Core::StandardFileWizard(parameters, parent),
m_type(type)
{
}
......
......@@ -48,9 +48,9 @@ class CppFileWizard : public Core::StandardFileWizard
public:
typedef Core::BaseFileWizardParameters BaseFileWizardParameters;
explicit CppFileWizard(const BaseFileWizardParameters &parameters,
FileType type,
Core::ICore *core, QObject *parent = 0);
CppFileWizard(const BaseFileWizardParameters &parameters,
FileType type,
QObject *parent = 0);
protected:
static QString toAlphaNum(const QString &s);
......
......@@ -40,6 +40,7 @@
#include "cppfilewizard.h"
#include "cpphoverhandler.h"
#include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/uniqueidmanager.h>
......@@ -47,7 +48,6 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/editormanager/editormanager.h>
#include <extensionsystem/pluginmanager.h>
#include <texteditor/completionsupport.h>
#include <texteditor/fontsettings.h>
#include <texteditor/storagesettings.h>
......@@ -211,8 +211,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
am->actionContainer(CppEditor::Constants::M_CONTEXT)->addAction(cmd);
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
m_actionHandler = new CPPEditorActionHandler(core,
CppEditor::Constants::C_CPPEDITOR,
m_actionHandler = new CPPEditorActionHandler(CppEditor::Constants::C_CPPEDITOR,
TextEditor::TextEditorActionHandler::Format
| TextEditor::TextEditorActionHandler::UnCommentSelection
| TextEditor::TextEditorActionHandler::UnCollapseAll);
......
......@@ -48,8 +48,8 @@ enum { debugFormClassWizard = 0 };
using namespace Designer;
using namespace Designer::Internal;
FormClassWizard::FormClassWizard(const BaseFileWizardParameters &parameters, Core::ICore *core, QObject *parent) :
Core::BaseFileWizard(parameters, core, parent)
FormClassWizard::FormClassWizard(const BaseFileWizardParameters &parameters, QObject *parent)
: Core::BaseFileWizard(parameters, parent)
{
}
......
......@@ -38,10 +38,6 @@
#include <coreplugin/basefilewizard.h>
QT_BEGIN_NAMESPACE
class QWizard;
QT_END_NAMESPACE
namespace Designer {
namespace Internal {
......@@ -55,7 +51,7 @@ class FormClassWizard : public Core::BaseFileWizard
public:
typedef Core::BaseFileWizardParameters BaseFileWizardParameters;
FormClassWizard(const BaseFileWizardParameters &parameters, Core::ICore *core, QObject *parent);
FormClassWizard(const BaseFileWizardParameters &parameters, QObject *parent);
QString headerSuffix() const;
QString sourceSuffix() const;
......
......@@ -127,21 +127,20 @@ void FormEditorPlugin::extensionsInitialized()
bool FormEditorPlugin::initializeTemplates(QString *error)
{
Q_UNUSED(error);
Core::ICore *core = Core::ICore::instance();
FormWizard::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard);
wizardParameters.setCategory(QLatin1String("Qt"));
wizardParameters.setTrCategory(tr("Qt"));
const QString formFileType = QLatin1String(Constants::FORM_FILE_TYPE);
wizardParameters.setName(tr("Qt Designer Form"));
wizardParameters.setDescription(tr("This creates a new Qt Designer form file."));
m_formWizard = new FormWizard(wizardParameters, core, this);
m_formWizard = new FormWizard(wizardParameters, this);
addObject(m_formWizard);
#ifdef CPP_ENABLED
wizardParameters.setKind(Core::IWizard::ClassWizard);
wizardParameters.setName(tr("Qt Designer Form Class"));
wizardParameters.setDescription(tr("This creates a new Qt Designer form class."));
m_formClassWizard = new FormClassWizard(wizardParameters, core, this);
m_formClassWizard = new FormClassWizard(wizardParameters, this);
addObject(m_formClassWizard);
#endif
return true;
......
......@@ -36,8 +36,6 @@
#include "formwindoweditor.h"
#include "designerconstants.h"
#include <coreplugin/icore.h>
#include <QtCore/QFile>
#include <QtCore/QDebug>
......@@ -46,8 +44,8 @@ enum { debugFormWizard = 0 };
using namespace Designer;
using namespace Designer::Internal;
FormWizard::FormWizard(const BaseFileWizardParameters &parameters, Core::ICore *core, QObject *parent) :
Core::BaseFileWizard(parameters, core, parent)
FormWizard::FormWizard(const BaseFileWizardParameters &parameters, QObject *parent)
: Core::BaseFileWizard(parameters, parent)
{
}
......@@ -55,7 +53,7 @@ QWizard *FormWizard::createWizardDialog(QWidget *parent,
const QString &defaultPath,
const WizardPageList &extensionPages) const
{
FormFileWizardDialog *wizardDialog = new FormFileWizardDialog(core(), extensionPages, parent);
FormFileWizardDialog *wizardDialog = new FormFileWizardDialog(extensionPages, parent);
wizardDialog->setPath(defaultPath);
return wizardDialog;
}
......
......@@ -36,15 +36,9 @@
#include <coreplugin/basefilewizard.h>
QT_BEGIN_NAMESPACE
class QWizard;
QT_END_NAMESPACE
namespace Designer {
namespace Internal {
class FormFileWizardDialog;
class FormWizard : public Core::BaseFileWizard
{
Q_DISABLE_COPY(FormWizard)
......@@ -53,7 +47,7 @@ class FormWizard : public Core::BaseFileWizard
public:
typedef Core::BaseFileWizardParameters BaseFileWizardParameters;
explicit FormWizard(const BaseFileWizardParameters &parameters, Core::ICore *core, QObject *parent);
FormWizard(const BaseFileWizardParameters &parameters, QObject *parent);
protected:
virtual QWizard *createWizardDialog(QWidget *parent,
......
......@@ -50,12 +50,10 @@ namespace Designer {
namespace Internal {
// ----------------- FormWizardDialog
FormWizardDialog::FormWizardDialog(Core::ICore *core,
const WizardPageList &extensionPages,
QWidget *parent) :
QWizard(parent),
m_formPage(new FormTemplateWizardPagePage),
m_core(core)
FormWizardDialog::FormWizardDialog(const WizardPageList &extensionPages,
QWidget *parent)
: QWizard(parent),
m_formPage(new FormTemplateWizardPagePage)
{
init(extensionPages);
}
......@@ -82,10 +80,9 @@ QString FormWizardDialog::templateContents() const
}
// ----------------- FormFileWizardDialog
FormFileWizardDialog::FormFileWizardDialog(Core::ICore *core,
const WizardPageList &extensionPages,
QWidget *parent) :
FormWizardDialog(core, extensionPages, parent),
FormFileWizardDialog::FormFileWizardDialog(const WizardPageList &extensionPages,
QWidget *parent)
: FormWizardDialog(extensionPages, parent),
m_filePage(new Core::Utils::FileWizardPage)
{
setPage(FilePageId, m_filePage);
......
......@@ -37,10 +37,9 @@
#include <QtGui/QWizard>
namespace Core {
class ICore;
namespace Utils {
class FileWizardPage;
}
namespace Utils {
class FileWizardPage;
}
}
namespace Designer {
......@@ -58,8 +57,7 @@ class FormWizardDialog : public QWizard
public:
typedef QList<QWizardPage *> WizardPageList;
explicit FormWizardDialog(Core::ICore *core,
const WizardPageList &extensionPages,
explicit FormWizardDialog(const WizardPageList &extensionPages,
QWidget *parent = 0);
QString templateContents() const;
......@@ -68,7 +66,6 @@ private:
void init(const WizardPageList &extensionPages);