forked from qt-creator/qt-creator
Core::ModeManager: make some functions static
Change-Id: I5c1275ba3f596d8911fd2e4404181bf57b58f494 Reviewed-by: Daniel Teske <daniel.teske@nokia.com> Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
@@ -236,8 +236,8 @@ void DesignMode::currentEditorChanged(Core::IEditor *editor)
|
||||
|
||||
if (!mimeEditorAvailable) {
|
||||
setActiveContext(Context());
|
||||
if (ModeManager::instance()->currentMode() == this)
|
||||
ModeManager::instance()->activateMode(QLatin1String(Core::Constants::MODE_EDIT));
|
||||
if (ModeManager::currentMode() == this)
|
||||
ModeManager::activateMode(QLatin1String(Core::Constants::MODE_EDIT));
|
||||
setEnabled(false);
|
||||
d->m_currentEditor = QWeakPointer<Core::IEditor>();
|
||||
emit actionsUpdated(d->m_currentEditor.data());
|
||||
@@ -272,7 +272,7 @@ void DesignMode::setActiveContext(const Context &context)
|
||||
if (d->m_activeContext == context)
|
||||
return;
|
||||
|
||||
if (ModeManager::instance()->currentMode() == this)
|
||||
if (ModeManager::currentMode() == this)
|
||||
Core::ICore::updateAdditionalContexts(d->m_activeContext, context);
|
||||
|
||||
d->m_activeContext = context;
|
||||
|
||||
@@ -89,8 +89,7 @@ EditMode::EditMode() :
|
||||
m_splitter->setStretchFactor(0, 0);
|
||||
m_splitter->setStretchFactor(1, 1);
|
||||
|
||||
ModeManager *modeManager = ModeManager::instance();
|
||||
connect(modeManager, SIGNAL(currentModeChanged(Core::IMode*)),
|
||||
connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
|
||||
this, SLOT(grabEditorManager(Core::IMode*)));
|
||||
m_splitter->setFocusProxy(m_editorManager);
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ EditorManagerPlaceHolder::EditorManagerPlaceHolder(Core::IMode *mode, QWidget *p
|
||||
connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode *)),
|
||||
this, SLOT(currentModeChanged(Core::IMode *)));
|
||||
|
||||
currentModeChanged(Core::ModeManager::instance()->currentMode());
|
||||
currentModeChanged(ModeManager::currentMode());
|
||||
}
|
||||
|
||||
EditorManagerPlaceHolder::~EditorManagerPlaceHolder()
|
||||
@@ -1382,7 +1382,7 @@ void EditorManager::switchToPreferedMode()
|
||||
if (preferedMode.isEmpty())
|
||||
preferedMode = QLatin1String(Constants::MODE_EDIT_TYPE);
|
||||
|
||||
ModeManager::instance()->activateModeType(preferedMode);
|
||||
ModeManager::activateModeType(preferedMode);
|
||||
}
|
||||
|
||||
IEditor *EditorManager::openEditorWithContents(const Id &editorId,
|
||||
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
static ScriptManager *scriptManager();
|
||||
static VariableManager *variableManager();
|
||||
static VcsManager *vcsManager();
|
||||
static ModeManager *modeManager();
|
||||
static QT_DEPRECATED ModeManager *modeManager(); // Use ModeManager::... directly.
|
||||
static MimeDatabase *mimeDatabase();
|
||||
static HelpManager *helpManager();
|
||||
|
||||
|
||||
@@ -875,7 +875,7 @@ void MainWindow::openFiles(const QStringList &fileNames, ICore::OpenFilesFlags f
|
||||
if (!file && (flags & ICore::StopOnLoadFail))
|
||||
return;
|
||||
if (file && (flags & ICore::SwitchMode))
|
||||
Core::ModeManager::instance()->activateMode(QLatin1String(Core::Constants::MODE_EDIT));
|
||||
ModeManager::activateMode(QLatin1String(Core::Constants::MODE_EDIT));
|
||||
} else {
|
||||
QFlags<EditorManager::OpenEditorFlag> emFlags;
|
||||
if (flags & ICore::SwitchMode)
|
||||
@@ -932,7 +932,7 @@ void MainWindow::setFocusToEditor()
|
||||
}
|
||||
|
||||
// switch to edit mode if necessary
|
||||
m_coreImpl->modeManager()->activateMode(QLatin1String(Constants::MODE_EDIT));
|
||||
ModeManager::activateMode(QLatin1String(Constants::MODE_EDIT));
|
||||
}
|
||||
|
||||
void MainWindow::showNewItemDialog(const QString &title,
|
||||
|
||||
@@ -71,11 +71,6 @@ namespace Core {
|
||||
|
||||
struct ModeManagerPrivate
|
||||
{
|
||||
explicit ModeManagerPrivate(Internal::MainWindow *mainWindow,
|
||||
Internal::FancyTabWidget *modeStack,
|
||||
ModeManager *q);
|
||||
|
||||
static ModeManager *m_instance;
|
||||
Internal::MainWindow *m_mainWindow;
|
||||
Internal::FancyTabWidget *m_modeStack;
|
||||
Internal::FancyActionBar *m_actionBar;
|
||||
@@ -87,44 +82,49 @@ struct ModeManagerPrivate
|
||||
int m_oldCurrent;
|
||||
};
|
||||
|
||||
ModeManager *ModeManagerPrivate::m_instance = 0;
|
||||
static ModeManagerPrivate *d;
|
||||
static ModeManager *m_instance = 0;
|
||||
|
||||
ModeManagerPrivate::ModeManagerPrivate(Internal::MainWindow *mainWindow,
|
||||
Internal::FancyTabWidget *modeStack,
|
||||
ModeManager *q) :
|
||||
m_mainWindow(mainWindow),
|
||||
m_modeStack(modeStack),
|
||||
m_signalMapper(new QSignalMapper(q)),
|
||||
m_oldCurrent(-1)
|
||||
static int indexOf(const QString &id)
|
||||
{
|
||||
for (int i = 0; i < d->m_modes.count(); ++i) {
|
||||
if (d->m_modes.at(i)->id() == id)
|
||||
return i;
|
||||
}
|
||||
qDebug() << "Warning, no such mode:" << id;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ModeManager::ModeManager(Internal::MainWindow *mainWindow,
|
||||
Internal::FancyTabWidget *modeStack) :
|
||||
d(new ModeManagerPrivate(mainWindow, modeStack, this))
|
||||
Internal::FancyTabWidget *modeStack)
|
||||
{
|
||||
ModeManagerPrivate::m_instance = this;
|
||||
|
||||
m_instance = this;
|
||||
d = new ModeManagerPrivate();
|
||||
d->m_mainWindow = mainWindow;
|
||||
d->m_modeStack = modeStack;
|
||||
d->m_signalMapper = new QSignalMapper(this);
|
||||
d->m_oldCurrent = -1;
|
||||
d->m_actionBar = new Internal::FancyActionBar(modeStack);
|
||||
d->m_modeStack->addCornerWidget(d->m_actionBar);
|
||||
|
||||
connect(d->m_modeStack, SIGNAL(currentAboutToShow(int)), SLOT(currentTabAboutToChange(int)));
|
||||
connect(d->m_modeStack, SIGNAL(currentChanged(int)), SLOT(currentTabChanged(int)));
|
||||
connect(d->m_signalMapper, SIGNAL(mapped(QString)), this, SLOT(activateMode(QString)));
|
||||
connect(d->m_signalMapper, SIGNAL(mapped(QString)), this, SLOT(slotActivateMode(QString)));
|
||||
}
|
||||
|
||||
void ModeManager::init()
|
||||
{
|
||||
QObject::connect(ExtensionSystem::PluginManager::instance(), SIGNAL(objectAdded(QObject*)),
|
||||
this, SLOT(objectAdded(QObject*)));
|
||||
m_instance, SLOT(objectAdded(QObject*)));
|
||||
QObject::connect(ExtensionSystem::PluginManager::instance(), SIGNAL(aboutToRemoveObject(QObject*)),
|
||||
this, SLOT(aboutToRemoveObject(QObject*)));
|
||||
m_instance, SLOT(aboutToRemoveObject(QObject*)));
|
||||
}
|
||||
|
||||
ModeManager::~ModeManager()
|
||||
{
|
||||
delete d;
|
||||
ModeManagerPrivate::m_instance = 0;
|
||||
d = 0;
|
||||
m_instance = 0;
|
||||
}
|
||||
|
||||
void ModeManager::addWidget(QWidget *widget)
|
||||
@@ -135,7 +135,7 @@ void ModeManager::addWidget(QWidget *widget)
|
||||
d->m_modeStack->insertCornerWidget(d->m_modeStack->cornerWidgetCount() -1, widget);
|
||||
}
|
||||
|
||||
IMode *ModeManager::currentMode() const
|
||||
IMode *ModeManager::currentMode()
|
||||
{
|
||||
int currentIndex = d->m_modeStack->currentIndex();
|
||||
if (currentIndex < 0)
|
||||
@@ -143,17 +143,7 @@ IMode *ModeManager::currentMode() const
|
||||
return d->m_modes.at(currentIndex);
|
||||
}
|
||||
|
||||
int ModeManager::indexOf(const QString &id) const
|
||||
{
|
||||
for (int i = 0; i < d->m_modes.count(); ++i) {
|
||||
if (d->m_modes.at(i)->id() == id)
|
||||
return i;
|
||||
}
|
||||
qDebug() << "Warning, no such mode:" << id;
|
||||
return -1;
|
||||
}
|
||||
|
||||
IMode *ModeManager::mode(const QString &id) const
|
||||
IMode *ModeManager::mode(const QString &id)
|
||||
{
|
||||
const int index = indexOf(id);
|
||||
if (index >= 0)
|
||||
@@ -176,6 +166,11 @@ void ModeManager::activateModeType(const QString &type)
|
||||
d->m_modeStack->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void ModeManager::slotActivateMode(const QString &id)
|
||||
{
|
||||
m_instance->activateMode(id);
|
||||
}
|
||||
|
||||
void ModeManager::activateMode(const QString &id)
|
||||
{
|
||||
const int index = indexOf(id);
|
||||
@@ -347,7 +342,7 @@ void ModeManager::setModeBarHidden(bool hidden)
|
||||
|
||||
ModeManager *ModeManager::instance()
|
||||
{
|
||||
return ModeManagerPrivate::m_instance;
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
||||
@@ -49,8 +49,6 @@ namespace Internal {
|
||||
class FancyTabWidget;
|
||||
}
|
||||
|
||||
struct ModeManagerPrivate;
|
||||
|
||||
class CORE_EXPORT ModeManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -59,18 +57,20 @@ public:
|
||||
explicit ModeManager(Internal::MainWindow *mainWindow, Internal::FancyTabWidget *modeStack);
|
||||
virtual ~ModeManager();
|
||||
|
||||
void init();
|
||||
static void init();
|
||||
static ModeManager *instance();
|
||||
|
||||
IMode *currentMode() const;
|
||||
IMode *mode(const QString &id) const;
|
||||
static IMode *currentMode();
|
||||
static IMode *mode(const QString &id);
|
||||
|
||||
void addAction(QAction *action, int priority);
|
||||
void addProjectSelector(QAction *action);
|
||||
void addWidget(QWidget *widget);
|
||||
static void addAction(QAction *action, int priority);
|
||||
static void addProjectSelector(QAction *action);
|
||||
static void addWidget(QWidget *widget);
|
||||
|
||||
void activateModeType(const QString &type);
|
||||
void setModeBarHidden(bool hidden);
|
||||
static void activateModeType(const QString &type);
|
||||
static void setModeBarHidden(bool hidden);
|
||||
static void activateMode(const QString &id);
|
||||
static void setFocusToCurrentMode();
|
||||
|
||||
signals:
|
||||
void currentModeAboutToChange(Core::IMode *mode);
|
||||
@@ -78,22 +78,14 @@ signals:
|
||||
// the default argument '=0' is important for connects without the oldMode argument.
|
||||
void currentModeChanged(Core::IMode *mode, Core::IMode *oldMode = 0);
|
||||
|
||||
public slots:
|
||||
void activateMode(const QString &id);
|
||||
void setFocusToCurrentMode();
|
||||
|
||||
private slots:
|
||||
void slotActivateMode(const QString &id);
|
||||
void objectAdded(QObject *obj);
|
||||
void aboutToRemoveObject(QObject *obj);
|
||||
void currentTabAboutToChange(int index);
|
||||
void currentTabChanged(int index);
|
||||
void updateModeToolTip();
|
||||
void enabledStateChanged();
|
||||
|
||||
private:
|
||||
int indexOf(const QString &id) const;
|
||||
|
||||
ModeManagerPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
@@ -450,7 +450,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
|
||||
ModeManager::instance()->activateMode(QLatin1String(Constants::MODE_EDIT));
|
||||
ModeManager::activateMode(QLatin1String(Constants::MODE_EDIT));
|
||||
}
|
||||
if (OutputPanePlaceHolder::getCurrent()) {
|
||||
// make the page visible
|
||||
|
||||
Reference in New Issue
Block a user