Commit 667255c4 authored by hjk's avatar hjk
Browse files

some more ICore related cleanup

parent 897c05f5
...@@ -85,18 +85,17 @@ using namespace Core::Internal; ...@@ -85,18 +85,17 @@ using namespace Core::Internal;
static const char *settingsGroup = "RecentFiles"; static const char *settingsGroup = "RecentFiles";
static const char *filesKey = "Files"; static const char *filesKey = "Files";
FileManager::FileManager(Core::ICore *core, MainWindow *mw) : FileManager::FileManager(MainWindow *mw)
QObject(mw), : QObject(mw),
m_core(core),
m_mainWindow(mw), m_mainWindow(mw),
m_fileWatcher(new QFileSystemWatcher(this)), m_fileWatcher(new QFileSystemWatcher(this)),
m_blockActivated(false) m_blockActivated(false)
{ {
connect(m_fileWatcher, SIGNAL(fileChanged(const QString&)), connect(m_fileWatcher, SIGNAL(fileChanged(QString)),
this, SLOT(changedFile(const QString&))); this, SLOT(changedFile(QString)));
connect(m_mainWindow, SIGNAL(windowActivated()), connect(m_mainWindow, SIGNAL(windowActivated()),
this, SLOT(mainWindowActivated())); this, SLOT(mainWindowActivated()));
connect(m_core, SIGNAL(contextChanged(Core::IContext*)), connect(Core::ICore::instance(), SIGNAL(contextChanged(Core::IContext*)),
this, SLOT(syncWithEditor(Core::IContext*))); this, SLOT(syncWithEditor(Core::IContext*)));
QSettings *s = m_mainWindow->settings(); QSettings *s = m_mainWindow->settings();
...@@ -440,7 +439,7 @@ QString FileManager::getSaveAsFileName(IFile *file) ...@@ -440,7 +439,7 @@ QString FileManager::getSaveAsFileName(IFile *file)
} }
QString filterString; QString filterString;
QString preferredSuffix; QString preferredSuffix;
if (const MimeType mt = m_core->mimeDatabase()->findByFile(fi)) { if (const MimeType mt = Core::ICore::instance()->mimeDatabase()->findByFile(fi)) {
filterString = mt.filterString(); filterString = mt.filterString();
preferredSuffix = mt.preferredSuffix(); preferredSuffix = mt.preferredSuffix();
} }
...@@ -510,7 +509,7 @@ void FileManager::syncWithEditor(Core::IContext *context) ...@@ -510,7 +509,7 @@ void FileManager::syncWithEditor(Core::IContext *context)
if (!context) if (!context)
return; return;
Core::IEditor *editor = m_core->editorManager()->currentEditor(); Core::IEditor *editor = Core::ICore::instance()->editorManager()->currentEditor();
if (editor && (editor->widget() == context->widget())) if (editor && (editor->widget() == context->widget()))
setCurrentFile(editor->file()->fileName()); setCurrentFile(editor->file()->fileName());
} }
......
...@@ -69,7 +69,7 @@ class CORE_EXPORT FileManager : public QObject ...@@ -69,7 +69,7 @@ class CORE_EXPORT FileManager : public QObject
}; };
public: public:
FileManager(Core::ICore *core, Internal::MainWindow *ew); explicit FileManager(Internal::MainWindow *ew);
// file pool to monitor // file pool to monitor
bool addFiles(const QList<IFile *> &files); bool addFiles(const QList<IFile *> &files);
...@@ -99,10 +99,9 @@ public: ...@@ -99,10 +99,9 @@ public:
QString getSaveAsFileName(IFile *file); QString getSaveAsFileName(IFile *file);
QList<IFile *> saveModifiedFilesSilently(const QList<IFile *> &files); QList<IFile *> saveModifiedFilesSilently(const QList<IFile *> &files);
QList<IFile *> saveModifiedFiles( QList<IFile *> saveModifiedFiles(const QList<IFile *> &files,
const QList<IFile *> &files, bool *cancelled = 0,
bool *cancelled = 0, const QString &message = QString());
const QString &message = QString());
signals: signals:
void currentFileChanged(const QString &filePath); void currentFileChanged(const QString &filePath);
...@@ -130,7 +129,6 @@ private: ...@@ -130,7 +129,6 @@ private:
QString m_currentFile; QString m_currentFile;
Core::ICore *m_core;
Internal::MainWindow *m_mainWindow; Internal::MainWindow *m_mainWindow;
QFileSystemWatcher *m_fileWatcher; QFileSystemWatcher *m_fileWatcher;
QList<QPointer<IFile> > m_changedFiles; QList<QPointer<IFile> > m_changedFiles;
......
...@@ -118,7 +118,7 @@ MainWindow::MainWindow() : ...@@ -118,7 +118,7 @@ MainWindow::MainWindow() :
m_printer(0), m_printer(0),
m_actionManager(new ActionManagerPrivate(this, m_uniqueIDManager)), m_actionManager(new ActionManagerPrivate(this, m_uniqueIDManager)),
m_editorManager(0), m_editorManager(0),
m_fileManager(new FileManager(m_coreImpl, this)), m_fileManager(new FileManager(this)),
m_progressManager(new ProgressManagerPrivate()), m_progressManager(new ProgressManagerPrivate()),
m_scriptManager(new ScriptManagerPrivate(this, m_coreImpl)), m_scriptManager(new ScriptManagerPrivate(this, m_coreImpl)),
m_variableManager(new VariableManager(this)), m_variableManager(new VariableManager(this)),
...@@ -217,9 +217,8 @@ void MainWindow::toggleNavigation() ...@@ -217,9 +217,8 @@ void MainWindow::toggleNavigation()
void MainWindow::setSuppressNavigationWidget(bool suppress) void MainWindow::setSuppressNavigationWidget(bool suppress)
{ {
if (NavigationWidgetPlaceHolder::current()) { if (NavigationWidgetPlaceHolder::current())
m_navigationWidget->setSuppressed(suppress); m_navigationWidget->setSuppressed(suppress);
}
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
...@@ -319,7 +318,7 @@ void MainWindow::extensionsInitialized() ...@@ -319,7 +318,7 @@ void MainWindow::extensionsInitialized()
m_viewManager->extensionsInitalized(); m_viewManager->extensionsInitalized();
m_messageManager->init(m_pluginManager); m_messageManager->init(m_pluginManager);
m_outputPane->init(m_coreImpl, m_pluginManager); m_outputPane->init(m_pluginManager);
m_actionManager->initialize(); m_actionManager->initialize();
readSettings(); readSettings();
......
...@@ -156,7 +156,6 @@ OutputPane::OutputPane(const QList<int> &context, QWidget *parent) : ...@@ -156,7 +156,6 @@ OutputPane::OutputPane(const QList<int> &context, QWidget *parent) :
m_closeButton(new QToolButton), m_closeButton(new QToolButton),
m_closeAction(0), m_closeAction(0),
m_pluginManager(0), m_pluginManager(0),
m_core(0),
m_lastIndex(-1), m_lastIndex(-1),
m_outputWidgetPane(new QStackedWidget), m_outputWidgetPane(new QStackedWidget),
m_opToolBarWidgets(new QStackedWidget) m_opToolBarWidgets(new QStackedWidget)
...@@ -206,12 +205,11 @@ QWidget *OutputPane::buttonsWidget() ...@@ -206,12 +205,11 @@ QWidget *OutputPane::buttonsWidget()
return m_buttonsWidget; return m_buttonsWidget;
} }
void OutputPane::init(ICore *core, ExtensionSystem::PluginManager *pm) void OutputPane::init(ExtensionSystem::PluginManager *pm)
{ {
m_pluginManager = pm; m_pluginManager = pm;
m_core = core;
ActionManager *am = m_core->actionManager(); ActionManager *am = Core::ICore::instance()->actionManager();
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW); ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
// Window->Output Panes // Window->Output Panes
......
...@@ -51,7 +51,6 @@ namespace ExtensionSystem { class PluginManager; } ...@@ -51,7 +51,6 @@ namespace ExtensionSystem { class PluginManager; }
namespace Core { namespace Core {
class ICore;
class IMode; class IMode;
class IOutputPane; class IOutputPane;
...@@ -89,7 +88,7 @@ class OutputPane ...@@ -89,7 +88,7 @@ class OutputPane
public: public:
OutputPane(const QList<int> &context, QWidget *parent = 0); OutputPane(const QList<int> &context, QWidget *parent = 0);
~OutputPane(); ~OutputPane();
void init(Core::ICore *core, ExtensionSystem::PluginManager *pm); void init(ExtensionSystem::PluginManager *pm);
static OutputPane *instance(); static OutputPane *instance();
const QList<int> &context() const { return m_context; } const QList<int> &context() const { return m_context; }
void setCloseable(bool b); void setCloseable(bool b);
...@@ -123,7 +122,6 @@ private: ...@@ -123,7 +122,6 @@ private:
QAction *m_closeAction; QAction *m_closeAction;
ExtensionSystem::PluginManager *m_pluginManager; ExtensionSystem::PluginManager *m_pluginManager;
Core::ICore *m_core;
QMap<int, Core::IOutputPane*> m_pageMap; QMap<int, Core::IOutputPane*> m_pageMap;
int m_lastIndex; int m_lastIndex;
......
...@@ -46,11 +46,10 @@ ...@@ -46,11 +46,10 @@
using namespace Designer::Internal; using namespace Designer::Internal;
using namespace Designer::Constants; using namespace Designer::Constants;
FormEditorFactory::FormEditorFactory(Core::ICore *core) : FormEditorFactory::FormEditorFactory()
Core::IEditorFactory(core), : Core::IEditorFactory(Core::ICore::instance()),
m_kind(QLatin1String(C_FORMEDITOR)), m_kind(QLatin1String(C_FORMEDITOR)),
m_mimeTypes(QLatin1String(FORM_MIMETYPE)), m_mimeTypes(QLatin1String(FORM_MIMETYPE))
m_core(core)
{ {
Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance(); Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance();
iconProvider->registerIconForSuffix(QIcon(":/formeditor/images/qt_ui.png"), iconProvider->registerIconForSuffix(QIcon(":/formeditor/images/qt_ui.png"),
...@@ -64,7 +63,7 @@ QString FormEditorFactory::kind() const ...@@ -64,7 +63,7 @@ QString FormEditorFactory::kind() const
Core::IFile *FormEditorFactory::open(const QString &fileName) Core::IFile *FormEditorFactory::open(const QString &fileName)
{ {
Core::IEditor *iface = m_core->editorManager()->openEditor(fileName, kind()); Core::IEditor *iface = Core::ICore::instance()->editorManager()->openEditor(fileName, kind());
return iface ? iface->file() : 0; return iface ? iface->file() : 0;
} }
......
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
#include <QtCore/QStringList> #include <QtCore/QStringList>
namespace Core { namespace Core {
class ICore;
class IEditor; class IEditor;
class IFile; class IFile;
} }
...@@ -52,10 +51,11 @@ class FormEditorFactory : public Core::IEditorFactory ...@@ -52,10 +51,11 @@ class FormEditorFactory : public Core::IEditorFactory
Q_OBJECT Q_OBJECT
public: public:
FormEditorFactory(Core::ICore *core); FormEditorFactory();
virtual QStringList mimeTypes() const; virtual QStringList mimeTypes() const;
//EditorFactory
// IEditorFactory
virtual QString kind() const; virtual QString kind() const;
Core::IFile *open(const QString &fileName); Core::IFile *open(const QString &fileName);
Core::IEditor *createEditor(QWidget *parent); Core::IEditor *createEditor(QWidget *parent);
...@@ -63,7 +63,6 @@ public: ...@@ -63,7 +63,6 @@ public:
private: private:
const QString m_kind; const QString m_kind;
const QStringList m_mimeTypes; const QStringList m_mimeTypes;
Core::ICore *m_core;
}; };
} // namespace Internal } // namespace Internal
......
...@@ -104,7 +104,7 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error) ...@@ -104,7 +104,7 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
const int uid = core->uniqueIDManager()->uniqueIdentifier(QLatin1String(C_FORMEDITOR)); const int uid = core->uniqueIDManager()->uniqueIdentifier(QLatin1String(C_FORMEDITOR));
const QList<int> context = QList<int>() << uid; const QList<int> context = QList<int>() << uid;
m_factory = new FormEditorFactory(core); m_factory = new FormEditorFactory;
addObject(m_factory); addObject(m_factory);
// Make sure settings pages and action shortcuts are registered // Make sure settings pages and action shortcuts are registered
......
...@@ -561,8 +561,9 @@ FormWindowEditor *FormEditorW::createFormWindowEditor(QWidget* parentWidget) ...@@ -561,8 +561,9 @@ FormWindowEditor *FormEditorW::createFormWindowEditor(QWidget* parentWidget)
QDesignerFormWindowInterface *form = m_fwm->createFormWindow(0); QDesignerFormWindowInterface *form = m_fwm->createFormWindow(0);
connect(form, SIGNAL(toolChanged(int)), this, SLOT(toolChanged(int))); connect(form, SIGNAL(toolChanged(int)), this, SLOT(toolChanged(int)));
qdesigner_internal::FormWindowBase::setupDefaultAction(form); qdesigner_internal::FormWindowBase::setupDefaultAction(form);
FormWindowEditor *fww = new FormWindowEditor(m_core, m_context, form, parentWidget); FormWindowEditor *fww = new FormWindowEditor(m_context, form, parentWidget);
// Store a pointer to all form windows so we can unselect all other formwindows except the active one. // Store a pointer to all form windows so we can unselect
// all other formwindows except the active one.
m_formWindows.append(fww); m_formWindows.append(fww);
connect(fww, SIGNAL(destroyed()), this, SLOT(editorDestroyed())); connect(fww, SIGNAL(destroyed()), this, SLOT(editorDestroyed()));
return fww; return fww;
...@@ -604,7 +605,8 @@ void FormEditorW::currentEditorChanged(Core::IEditor *editor) ...@@ -604,7 +605,8 @@ void FormEditorW::currentEditorChanged(Core::IEditor *editor)
void FormEditorW::activeFormWindowChanged(QDesignerFormWindowInterface *afw) void FormEditorW::activeFormWindowChanged(QDesignerFormWindowInterface *afw)
{ {
if (debugFormEditor) if (debugFormEditor)
qDebug() << "FormEditorW::activeFormWindowChanged" << afw << " of " << m_fwm->formWindowCount() << m_formWindows; qDebug() << "FormEditorW::activeFormWindowChanged" << afw
<< " of " << m_fwm->formWindowCount() << m_formWindows;
m_fwm->closeAllPreviews(); m_fwm->closeAllPreviews();
......
...@@ -96,14 +96,13 @@ void QrcFilesVisitor::visitFolderNode(FolderNode *folderNode) ...@@ -96,14 +96,13 @@ void QrcFilesVisitor::visitFolderNode(FolderNode *folderNode)
} }
FormWindowEditor::FormWindowEditor(Core::ICore *core, FormWindowEditor::FormWindowEditor(const QList<int> &context,
const QList<int> &context,
QDesignerFormWindowInterface *form, QDesignerFormWindowInterface *form,
QObject *parent) : QObject *parent)
Core::IEditor(parent), : Core::IEditor(parent),
m_context(context), m_context(context),
m_formWindow(form), m_formWindow(form),
m_file(new FormWindowFile(core, form, this)), m_file(new FormWindowFile(form, this)),
m_host(new FormWindowHost(form)), m_host(new FormWindowHost(form)),
m_editorWidget(new EditorWidget(m_host)), m_editorWidget(new EditorWidget(m_host)),
m_toolBar(0), m_toolBar(0),
......
...@@ -45,10 +45,6 @@ class QDesignerFormWindowManagerInterface; ...@@ -45,10 +45,6 @@ class QDesignerFormWindowManagerInterface;
class QFile; class QFile;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Core {
class ICore;
}
namespace ProjectExplorer { namespace ProjectExplorer {
class SessionNode; class SessionNode;
class NodesWatcher; class NodesWatcher;
...@@ -60,6 +56,7 @@ namespace Internal { ...@@ -60,6 +56,7 @@ namespace Internal {
class FormWindowFile; class FormWindowFile;
class FormWindowHost; class FormWindowHost;
class EditorWidget; class EditorWidget;
// Master class maintaining a form window editor, // Master class maintaining a form window editor,
// containing file and widget host // containing file and widget host
...@@ -68,8 +65,7 @@ class FormWindowEditor : public Core::IEditor ...@@ -68,8 +65,7 @@ class FormWindowEditor : public Core::IEditor
Q_OBJECT Q_OBJECT
public: public:
FormWindowEditor(Core::ICore *core, FormWindowEditor(const QList<int> &context,
const QList<int> &context,
QDesignerFormWindowInterface *form, QDesignerFormWindowInterface *form,
QObject *parent = 0); QObject *parent = 0);
~FormWindowEditor(); ~FormWindowEditor();
...@@ -85,7 +81,7 @@ public: ...@@ -85,7 +81,7 @@ public:
void setDisplayName(const QString &title); void setDisplayName(const QString &title);
QToolBar *toolBar(); QToolBar *toolBar();
QByteArray saveState() const; QByteArray saveState() const;
bool restoreState(const QByteArray &/*state*/); bool restoreState(const QByteArray &state);
// ContextInterface // ContextInterface
QList<int> context() const; QList<int> context() const;
......
...@@ -56,17 +56,10 @@ using namespace SharedTools; ...@@ -56,17 +56,10 @@ using namespace SharedTools;
enum { debugFormWindowFile = 0 }; enum { debugFormWindowFile = 0 };
FormWindowFile::FormWindowFile(Core::ICore *core, FormWindowFile::FormWindowFile(QDesignerFormWindowInterface *form, QObject *parent)
QDesignerFormWindowInterface *form, : Core::IFile(parent),
QObject *parent) :
Core::IFile(parent),
m_mimeType(QLatin1String(FORM_MIMETYPE)), m_mimeType(QLatin1String(FORM_MIMETYPE)),
m_formWindow(form), m_formWindow(form)
m_core(core)
{
}
FormWindowFile::~FormWindowFile()
{ {
} }
...@@ -141,7 +134,7 @@ void FormWindowFile::modified(Core::IFile::ReloadBehavior *behavior) ...@@ -141,7 +134,7 @@ void FormWindowFile::modified(Core::IFile::ReloadBehavior *behavior)
break; break;
} }
switch (Core::Utils::reloadPrompt(m_fileName, m_core->mainWindow())) { switch (Core::Utils::reloadPrompt(m_fileName, Core::ICore::instance()->mainWindow())) {
case Core::Utils::ReloadCurrent: case Core::Utils::ReloadCurrent:
emit reload(m_fileName); emit reload(m_fileName);
break; break;
......
...@@ -41,31 +41,22 @@ ...@@ -41,31 +41,22 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QDesignerFormWindowInterface; class QDesignerFormWindowInterface;
class QDesignerFormWindowManagerInterface;
class QFile; class QFile;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Core {
class ICore;
}
namespace Designer { namespace Designer {
namespace Internal { namespace Internal {
class FormWindowSelection; class FormWindowSelection;
class FormWindowFile class FormWindowFile : public Core::IFile
: public Core::IFile
{ {
Q_OBJECT Q_OBJECT
public: public:
FormWindowFile(Core::ICore *core, FormWindowFile(QDesignerFormWindowInterface *form, QObject *parent = 0);
QDesignerFormWindowInterface *form,
QObject *parent = 0);
~FormWindowFile();
//IFile // IFile
bool save(const QString &fileName = QString()); bool save(const QString &fileName = QString());
QString fileName() const; QString fileName() const;
bool isModified() const; bool isModified() const;
...@@ -97,7 +88,6 @@ private: ...@@ -97,7 +88,6 @@ private:
QString m_suggestedName; QString m_suggestedName;
QDesignerFormWindowInterface *m_formWindow; QDesignerFormWindowInterface *m_formWindow;
Core::ICore *m_core;
}; };
} // namespace Internal } // namespace Internal
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
#include <vcsbase/basevcssubmiteditorfactory.h> #include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsbaseeditor.h> #include <vcsbase/vcsbaseeditor.h>
#include <QtCore/qplugin.h> #include <QtCore/QtPlugin>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
......
...@@ -95,7 +95,7 @@ QString PromptDialog::input() const ...@@ -95,7 +95,7 @@ QString PromptDialog::input() const
WorkbenchClientUser::WorkbenchClientUser(PerforceOutputWindow *out, PerforcePlugin *plugin) : WorkbenchClientUser::WorkbenchClientUser(PerforceOutputWindow *out, PerforcePlugin *plugin) :
QObject(out), QObject(out),
m_plugin(plugin), m_plugin(plugin),
m_coreIFace(PerforcePlugin::coreInstance()), m_core(Core::ICore::instance()),
m_currentEditorIface(0), m_currentEditorIface(0),
m_userCancelled(false), m_userCancelled(false),
m_mode(Submit), m_mode(Submit),
...@@ -103,7 +103,7 @@ WorkbenchClientUser::WorkbenchClientUser(PerforceOutputWindow *out, PerforcePlug ...@@ -103,7 +103,7 @@ WorkbenchClientUser::WorkbenchClientUser(PerforceOutputWindow *out, PerforcePlug
m_skipNextMsg(false), m_skipNextMsg(false),
m_eventLoop(new QEventLoop(this)) m_eventLoop(new QEventLoop(this))
{ {
connect(m_coreIFace, SIGNAL(coreAboutToClose()), connect(m_core, SIGNAL(coreAboutToClose()),
this, SLOT(cancelP4Command())); this, SLOT(cancelP4Command()));
} }
...@@ -147,13 +147,13 @@ void WorkbenchClientUser::displayErrorMsg(const QString &msg) ...@@ -147,13 +147,13 @@ void WorkbenchClientUser::displayErrorMsg(const QString &msg)
const QString title = tr("Perforce Error"); const QString title = tr("Perforce Error");
switch (m_mode) { switch (m_mode) {
case Submit: { case Submit: {
QMessageBox msgBox(QMessageBox::Critical, title, msg, QMessageBox::Ok, m_coreIFace->mainWindow()); QMessageBox msgBox(QMessageBox::Critical, title, msg, QMessageBox::Ok, m_core->mainWindow());
msgBox.setDetailedText(m_msg); msgBox.setDetailedText(m_msg);
msgBox.exec(); msgBox.exec();
} }
break; break;
default: default:
QMessageBox::critical(m_coreIFace->mainWindow(), title, msg); QMessageBox::critical(m_core->mainWindow(), title, msg);