Commit e6849605 authored by hjk's avatar hjk Committed by hjk
Browse files

core: remove usages of Core::ICore::instance()->modeManager()

The function is still there but should be remove in my opinion.

Change-Id: I739fe942e74f459faccb80b5bcb8a5721c6bb9bf
Reviewed-on: http://codereview.qt.nokia.com/4200

Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 65f5c42b
......@@ -191,7 +191,6 @@ void DesignMode::currentEditorChanged(Core::IEditor *editor)
return;
bool mimeEditorAvailable = false;
Core::ICore *core = Core::ICore::instance();
if (editor && editor->file()) {
const QString mimeType = editor->file()->mimeType();
......@@ -216,8 +215,8 @@ void DesignMode::currentEditorChanged(Core::IEditor *editor)
if (!mimeEditorAvailable) {
setActiveContext(Context());
if (core->modeManager()->currentMode() == this)
core->modeManager()->activateMode(Core::Constants::MODE_EDIT);
if (ModeManager::instance()->currentMode() == this)
ModeManager::instance()->activateMode(Core::Constants::MODE_EDIT);
setEnabled(false);
d->m_currentEditor = QWeakPointer<Core::IEditor>();
emit actionsUpdated(d->m_currentEditor.data());
......
......@@ -1384,7 +1384,7 @@ void EditorManager::switchToPreferedMode()
if (preferedMode.isEmpty())
preferedMode = Constants::MODE_EDIT_TYPE;
m_d->m_core->modeManager()->activateModeType(preferedMode);
ModeManager::instance()->activateModeType(preferedMode);
}
IEditor *EditorManager::openEditorWithContents(const QString &editorId,
......
......@@ -60,6 +60,15 @@
namespace Core {
/*!
\class Core::ModeManager
The mode manager handles everything related to the instances of IMode
that were added to the plugin manager's object pool as well as their
buttons and the tool bar with the round buttons in the lower left
corner of Qt Creator.
*/
struct ModeManagerPrivate
{
explicit ModeManagerPrivate(Internal::MainWindow *mainWindow,
......
......@@ -444,7 +444,7 @@ void OutputPaneManager::showPage(int idx, bool focus)
if (!OutputPanePlaceHolder::getCurrent()) {
// In this mode we don't have a placeholder
// switch to the output mode and switch the page
ICore::instance()->modeManager()->activateMode(Constants::MODE_EDIT);
ModeManager::instance()->activateMode(Constants::MODE_EDIT);
}
if (OutputPanePlaceHolder::getCurrent()) {
// make the page visible
......
......@@ -98,7 +98,7 @@ QStringList FormEditorFactory::mimeTypes() const
void FormEditorFactory::designerModeClicked()
{
Core::ICore::instance()->modeManager()->activateMode(QLatin1String(Core::Constants::MODE_DESIGN));
Core::ModeManager::instance()->activateMode(QLatin1String(Core::Constants::MODE_DESIGN));
}
} // namespace Internal
......
......@@ -112,14 +112,14 @@ const char * const SB_OPENPAGES = "OpenPages";
# define DOCPATH "/../share/doc/qtcreator/"
#endif
namespace {
QToolButton* toolButton(QAction *action)
{
QToolButton *button = new QToolButton;
button->setDefaultAction(action);
button->setPopupMode(QToolButton::DelayedPopup);
return button;
}
using namespace Core;
static QToolButton *toolButton(QAction *action)
{
QToolButton *button = new QToolButton;
button->setDefaultAction(action);
button->setPopupMode(QToolButton::DelayedPopup);
return button;
}
HelpPlugin::HelpPlugin()
......@@ -361,7 +361,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
SLOT(switchToHelpMode(QUrl)));
QDesktopServices::setUrlHandler("qthelp", this, "handleHelpRequest");
connect(m_core->modeManager(), SIGNAL(currentModeChanged(Core::IMode*,
connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*,
Core::IMode*)), this, SLOT(modeChanged(Core::IMode*, Core::IMode*)));
m_externalWindow = new ExternalHelpWindow;
......@@ -665,7 +665,7 @@ void HelpPlugin::resetRightPaneScale()
void HelpPlugin::activateHelpMode()
{
if (contextHelpOption() != Help::Constants::ExternalHelpAlways)
m_core->modeManager()->activateMode(QLatin1String(Constants::ID_MODE_HELP));
Core::ModeManager::instance()->activateMode(QLatin1String(Constants::ID_MODE_HELP));
else
showExternalWindow();
}
......@@ -787,8 +787,8 @@ void HelpPlugin::contextHelpOptionChanged()
m_externalWindow->show();
connectExternalHelpWindow();
if (m_oldMode && m_mode == m_core->modeManager()->currentMode())
m_core->modeManager()->activateMode(m_oldMode->id());
if (m_oldMode && m_mode == ModeManager::instance()->currentMode())
ModeManager::instance()->activateMode(m_oldMode->id());
}
}
} else if (modeWidget != m_splitter
......@@ -822,12 +822,10 @@ void HelpPlugin::setupHelpEngineIfNeeded()
m_helpManager->setupGuiHelpEngine();
}
HelpViewer* HelpPlugin::viewerForContextMode()
HelpViewer *HelpPlugin::viewerForContextMode()
{
using namespace Core;
if (m_core->modeManager()->currentMode()->id() == Core::Constants::MODE_WELCOME)
m_core->modeManager()->activateMode(Core::Constants::MODE_EDIT);
if (ModeManager::instance()->currentMode()->id() == Core::Constants::MODE_WELCOME)
ModeManager::instance()->activateMode(Core::Constants::MODE_EDIT);
bool showSideBySide = false;
RightPanePlaceHolder *placeHolder = RightPanePlaceHolder::current();
......@@ -870,14 +868,14 @@ HelpViewer* HelpPlugin::viewerForContextMode()
void HelpPlugin::activateContext()
{
using namespace Core;
createRightPaneContextViewer();
RightPanePlaceHolder* placeHolder = RightPanePlaceHolder::current();
RightPanePlaceHolder *placeHolder = RightPanePlaceHolder::current();
if (placeHolder && m_helpViewerForSideBar->hasFocus()) {
switchToHelpMode();
return;
} else if (m_core->modeManager()->currentMode() == m_mode)
}
if (ModeManager::instance()->currentMode() == m_mode)
return;
// Find out what to show
......
......@@ -439,9 +439,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
Core::ActionContainer *menubar =
am->actionContainer(Core::Constants::MENU_BAR);
// mode manager (for fancy actions)
Core::ModeManager *modeManager = core->modeManager();
// build menu
Core::ActionContainer *mbuild =
am->createMenu(Constants::M_BUILDPROJECT);
......@@ -689,7 +686,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);
// Add to mode bar
modeManager->addAction(cmd->action(), Constants::P_ACTION_BUILDPROJECT);
Core::ModeManager::instance()->addAction(cmd->action(), Constants::P_ACTION_BUILDPROJECT);
// rebuild action
d->m_rebuildAction = new Utils::ParameterAction(tr("Rebuild Project"), tr("Rebuild Project \"%1\""),
......@@ -779,7 +776,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+R")));
mbuild->addAction(cmd, Constants::G_BUILD_RUN);
modeManager->addAction(cmd->action(), Constants::P_ACTION_RUN);
Core::ModeManager::instance()->addAction(cmd->action(), Constants::P_ACTION_RUN);
d->m_runActionContextMenu = new QAction(runIcon, tr("Run"), this);
cmd = am->registerAction(d->m_runActionContextMenu, Constants::RUNCONTEXTMENU, projecTreeContext);
......@@ -880,7 +877,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
QWidget *mainWindow = Core::ICore::instance()->mainWindow();
d->m_targetSelector = new Internal::MiniProjectTargetSelector(d->m_projectSelectorAction, mainWindow);
connect(d->m_projectSelectorAction, SIGNAL(triggered()), d->m_targetSelector, SLOT(show()));
modeManager->addProjectSelector(d->m_projectSelectorAction);
Core::ModeManager::instance()->addProjectSelector(d->m_projectSelectorAction);
d->m_projectSelectorActionMenu = new QAction(this);
d->m_projectSelectorActionMenu->setEnabled(false);
......@@ -1392,7 +1389,7 @@ void ProjectExplorerPlugin::determineSessionToRestoreAtStartup()
d->m_sessionToRestoreAtStartup = d->m_session->lastSession();
if (!d->m_sessionToRestoreAtStartup.isNull())
Core::ICore::instance()->modeManager()->activateMode(Core::Constants::MODE_EDIT);
Core::ModeManager::instance()->activateMode(Core::Constants::MODE_EDIT);
}
/*!
......@@ -1420,9 +1417,9 @@ void ProjectExplorerPlugin::restoreSession()
}
// update welcome page
Core::ModeManager *modeManager = Core::ModeManager::instance();
connect(modeManager, SIGNAL(currentModeChanged(Core::IMode*, Core::IMode*)),
this, SLOT(currentModeChanged(Core::IMode*, Core::IMode*)));
connect(Core::ModeManager::instance(),
SIGNAL(currentModeChanged(Core::IMode*, Core::IMode*)),
SLOT(currentModeChanged(Core::IMode*, Core::IMode*)));
connect(d->m_welcomePage, SIGNAL(requestSession(QString)), this, SLOT(loadSession(QString)));
connect(d->m_welcomePage, SIGNAL(requestProject(QString)), this, SLOT(openProjectWelcomePage(QString)));
......
......@@ -71,6 +71,8 @@ namespace {
bool debug = false;
}
using namespace Core;
/* SessionFile definitions */
namespace ProjectExplorer {
namespace Internal {
......@@ -323,7 +325,7 @@ SessionManager::SessionManager(QObject *parent)
m_sessionNode(new Internal::SessionNodeImpl(this)),
m_virginSession(true)
{
connect(m_core->modeManager(), SIGNAL(currentModeChanged(Core::IMode*)),
connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
this, SLOT(saveActiveMode(Core::IMode*)));
Core::EditorManager *em = m_core->editorManager();
......@@ -554,8 +556,8 @@ bool SessionManager::createImpl(const QString &fileName)
setStartupProject(0);
if (!isDefaultVirgin()) {
m_core->modeManager()->activateMode(Core::Constants::MODE_EDIT);
m_core->modeManager()->setFocusToCurrentMode();
ModeManager::instance()->activateMode(Core::Constants::MODE_EDIT);
ModeManager::instance()->setFocusToCurrentMode();
}
}
......@@ -625,8 +627,8 @@ bool SessionManager::loadImpl(const QString &fileName)
if (modeIdentifier.isEmpty())
modeIdentifier = Core::Constants::MODE_EDIT;
m_core->modeManager()->activateMode(modeIdentifier);
m_core->modeManager()->setFocusToCurrentMode();
ModeManager::instance()->activateMode(modeIdentifier);
ModeManager::instance()->setFocusToCurrentMode();
}
if (debug)
......
......@@ -290,9 +290,8 @@ void BauhausPlugin::createDesignModeWidget()
void BauhausPlugin::updateEditor(Core::IEditor *editor)
{
Core::ICore *creatorCore = Core::ICore::instance();
if (editor && editor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID
&& creatorCore->modeManager()->currentMode() == m_designMode)
&& Core::ModeManager::instance()->currentMode() == m_designMode)
{
m_mainWidget->showEditor(editor);
}
......
......@@ -102,9 +102,7 @@ void InspectorPlugin::extensionsInitialized()
connect(pluginManager, SIGNAL(objectAdded(QObject*)), SLOT(objectAdded(QObject*)));
connect(pluginManager, SIGNAL(aboutToRemoveObject(QObject*)), SLOT(aboutToRemoveObject(QObject*)));
Core::ICore *core = Core::ICore::instance();
connect(core->modeManager(), SIGNAL(currentModeAboutToChange(Core::IMode*)),
connect(Core::ModeManager::instance(), SIGNAL(currentModeAboutToChange(Core::IMode*)),
this, SLOT(modeAboutToChange(Core::IMode*)));
}
......@@ -151,9 +149,8 @@ void InspectorPlugin::modeAboutToChange(Core::IMode *newMode)
if (newMode->id() == Debugger::Constants::MODE_DEBUG) {
m_inspectorUi->setupUi();
// make sure we're not called again
Core::ICore *core = Core::ICore::instance();
disconnect(core->modeManager(), SIGNAL(currentModeAboutToChange(Core::IMode*)),
// Make sure we're not called again.
disconnect(Core::ModeManager::instance(), SIGNAL(currentModeAboutToChange(Core::IMode*)),
this, SLOT(modeAboutToChange(Core::IMode*)));
}
}
......
......@@ -938,8 +938,7 @@ void TestConfig::onProjectSettingsChanged()
if (!m_activeProject)
return;
Core::ICore *core = Core::ICore::instance();
Core::ModeManager *mgr = core->modeManager();
Core::ModeManager *mgr = Core::ModeManager::instance();
if ((mgr && (mgr->currentMode()->id() != QLatin1String("Edit"))) || TestConfigurations::instance().updatesDelayed()) {
// Try again later.
emitConfigChanged();
......
......@@ -738,8 +738,7 @@ void TestSelector::showSystemTests(bool show)
void TestSelector::init()
{
Core::ICore *core = Core::ICore::instance();
Core::ModeManager *mgr = core->modeManager();
Core::ModeManager *mgr = Core::ModeManager::instance();
if (mgr && mgr->currentMode()->id() == "Edit") {
TestConfigurations *tc = &TestConfigurations::instance();
if (tc->activeConfiguration()) {
......
......@@ -102,8 +102,7 @@ MaemoQemuManager::MaemoQemuManager(QObject *parent)
qemuCommand->setAttribute(Core::Command::CA_UpdateText);
qemuCommand->setAttribute(Core::Command::CA_UpdateIcon);
Core::ModeManager *modeManager = core->modeManager();
modeManager->addAction(qemuCommand->action(), 1);
Core::ModeManager::instance()->addAction(qemuCommand->action(), 1);
m_qemuAction->setEnabled(false);
m_qemuAction->setVisible(false);
......
......@@ -161,7 +161,7 @@ WelcomeMode::WelcomeMode() :
PluginManager *pluginManager = PluginManager::instance();
connect(pluginManager, SIGNAL(objectAdded(QObject*)), SLOT(welcomePluginAdded(QObject*)));
Core::ModeManager *modeManager = Core::ICore::instance()->modeManager();
Core::ModeManager *modeManager = Core::ModeManager::instance();
connect(modeManager, SIGNAL(currentModeChanged(Core::IMode*)), SLOT(modeChanged(Core::IMode*)));
setWidget(m_modeWidget);
......@@ -174,7 +174,6 @@ bool WelcomeMode::eventFilter(QObject *, QEvent *e)
return true;
}
return false;
}
WelcomeMode::~WelcomeMode()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment