Commit 08ccda58 authored by dt's avatar dt

EditorManager: Change openEditor/activateEditor to not do mode switching

Also introduce a indirection, modes have now types, edit and debug have
the same type, and editors do have a prefered type of modes instead of a
prefered mode.

That fixes the bug that if the prefered qml editing mode was set to
design, then in switching between qml editors would
- in Edit Mode: stay in edit mode
- in Debug Mode: switch to debug mode
parent f068e115
......@@ -58,6 +58,7 @@ public:
int priority() const { return m_priority; }
QWidget *widget() { return m_widget; }
QString id() const { return m_id; }
QString type() const { return m_type; }
Context context() const { return m_context; }
QString contextHelpId() const { return m_helpId; }
......@@ -66,6 +67,7 @@ public:
void setPriority(int priority) { m_priority = priority; }
void setWidget(QWidget *widget) { m_widget = widget; }
void setId(const QString &id) { m_id = id; }
void setType(const QString &type) { m_type = type; }
void setContextHelpId(const QString &helpId) { m_helpId = helpId; }
void setContext(const Context &context) { m_context = context; }
......@@ -75,6 +77,7 @@ private:
int m_priority;
QWidget *m_widget;
QString m_id;
QString m_type;
QString m_helpId;
Context m_context;
};
......
......@@ -68,8 +68,11 @@ const char * const IDE_REVISION_STR = "";
//modes
const char * const MODE_WELCOME = "Welcome";
const char * const MODE_WELCOME_TYPE = "Type.Welcome";
const char * const MODE_EDIT = "Edit";
const char * const MODE_EDIT_TYPE = "Type.Edit";
const char * const MODE_DESIGN = "Design";
const char * const MODE_DESIGN_TYPE = "Type.Design";
const int P_MODE_WELCOME = 100;
const int P_MODE_EDIT = 90;
const int P_MODE_DESIGN = 89;
......
......@@ -164,6 +164,11 @@ QString DesignMode::id() const
return QLatin1String(Constants::MODE_DESIGN);
}
QString DesignMode::type() const
{
return QLatin1String(Constants::MODE_DESIGN_TYPE);
}
QStringList DesignMode::registeredMimeTypes() const
{
QStringList rc;
......
......@@ -73,6 +73,7 @@ public:
QIcon icon() const;
int priority() const;
QString id() const;
QString type() const;
signals:
void actionsUpdated(Core::IEditor *editor);
......
......@@ -114,6 +114,11 @@ QString EditMode::id() const
return QLatin1String(Constants::MODE_EDIT);
}
QString EditMode::type() const
{
return QLatin1String(Constants::MODE_EDIT_TYPE);
}
Context EditMode::context() const
{
static Context contexts(Constants::C_EDIT_MODE,
......
......@@ -58,6 +58,7 @@ public:
int priority() const;
QWidget* widget();
QString id() const;
QString type() const;
Context context() const;
private slots:
......
......@@ -970,7 +970,7 @@ Core::IEditor *EditorManager::activateEditor(Core::Internal::EditorView *view, C
if (!(flags & NoActivate)) {
setCurrentEditor(editor, (flags & IgnoreNavigationHistory));
if (!(flags & NoModeSwitch)) {
if (flags & ModeSwitch) {
switchToPreferedMode();
}
if (isVisible())
......@@ -1254,13 +1254,14 @@ void EditorManager::switchToPreferedMode()
QString preferedMode;
// Figure out prefered mode for editor
if (m_d->m_currentEditor)
preferedMode = m_d->m_currentEditor->preferredMode();
preferedMode = m_d->m_currentEditor->preferredModeType();
if (preferedMode.isEmpty())
preferedMode = Constants::MODE_EDIT;
preferedMode = Constants::MODE_EDIT_TYPE;
if (m_d->m_core->modeManager()->currentMode()->id() != preferedMode)
m_d->m_core->modeManager()->activateMode(preferedMode);
if (m_d->m_core->modeManager()->currentMode()->type() != preferedMode) {
m_d->m_core->modeManager()->activateModeType(preferedMode);
}
}
IEditor *EditorManager::openEditorWithContents(const QString &editorId,
......
......@@ -109,7 +109,7 @@ public:
enum OpenEditorFlag {
NoActivate = 1,
IgnoreNavigationHistory = 2,
NoModeSwitch = 4
ModeSwitch = 4
};
Q_DECLARE_FLAGS(OpenEditorFlags, OpenEditorFlag)
......
......@@ -276,9 +276,9 @@ void EditorView::listSelectionActivated(int index)
EditorManager *em = CoreImpl::instance()->editorManager();
QAbstractItemModel *model = EditorManager::instance()->openedEditorsModel();
if (IEditor *editor = model->data(model->index(index, 0), Qt::UserRole).value<IEditor*>()) {
em->activateEditor(this, editor);
em->activateEditor(this, editor, Core::EditorManager::ModeSwitch);
} else {
em->activateEditor(model->index(index, 0), this);
em->activateEditor(model->index(index, 0), this, Core::EditorManager::ModeSwitch);
}
}
......@@ -445,9 +445,11 @@ void EditorView::goBackInNavigationHistory()
EditLocation location = m_navigationHistory.at(m_currentNavigationHistoryPosition);
IEditor *editor;
if (location.file) {
editor = em->activateEditor(this, location.file, EditorManager::IgnoreNavigationHistory);
editor = em->activateEditor(this, location.file,
EditorManager::IgnoreNavigationHistory | EditorManager::ModeSwitch);
} else {
editor = em->openEditor(this, location.fileName, location.id, EditorManager::IgnoreNavigationHistory);
editor = em->openEditor(this, location.fileName, location.id,
EditorManager::IgnoreNavigationHistory | EditorManager::ModeSwitch);
if (!editor) {
m_navigationHistory.removeAt(m_currentNavigationHistoryPosition);
continue;
......@@ -469,7 +471,8 @@ void EditorView::goForwardInNavigationHistory()
EditLocation location = m_navigationHistory.at(m_currentNavigationHistoryPosition);
IEditor *editor;
if (location.file) {
editor = em->activateEditor(this, location.file, EditorManager::IgnoreNavigationHistory);
editor = em->activateEditor(this, location.file,
EditorManager::IgnoreNavigationHistory | EditorManager::ModeSwitch);
} else {
editor = em->openEditor(this, location.fileName, location.id, EditorManager::IgnoreNavigationHistory);
if (!editor) {
......
......@@ -65,7 +65,7 @@ public:
virtual QWidget *toolBar() = 0;
virtual QString preferredMode() const { return QString(); }
virtual QString preferredModeType() const { return QString(); }
signals:
void changed();
......
......@@ -190,7 +190,7 @@ void OpenEditorsWidget::handleClicked(const QModelIndex &index)
void OpenEditorsWidget::activateEditor(const QModelIndex &index)
{
m_ui.editorList->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
EditorManager::instance()->activateEditor(index);
EditorManager::instance()->activateEditor(index, 0, EditorManager::ModeSwitch);
}
void OpenEditorsWidget::closeEditor(const QModelIndex &index)
......
......@@ -277,9 +277,10 @@ void OpenEditorsWindow::selectEditor(QTreeWidgetItem *item)
return;
if (IFile *file = item->data(0, Qt::UserRole).value<IFile*>()) {
EditorView *view = item->data(0, Qt::UserRole+1).value<EditorView*>();
EditorManager::instance()->activateEditor(view, file);
EditorManager::instance()->activateEditor(view, file, Core::EditorManager::ModeSwitch);
} else {
EditorManager::instance()->openEditor(item->toolTip(0), item->data(0, Qt::UserRole+2).toByteArray());
EditorManager::instance()->openEditor(item->toolTip(0), item->data(0, Qt::UserRole+2).toByteArray(),
Core::EditorManager::ModeSwitch);
}
}
......
......@@ -256,12 +256,12 @@ void EditorToolBar::changeActiveEditor(int row)
if (editor) {
if (editor != em->currentEditor())
em->activateEditor(editor, EditorManager::NoModeSwitch);
em->activateEditor(editor);
} else {
//em->activateEditor(model->index(index, 0), this);
QString fileName = model->data(modelIndex, Qt::UserRole + 1).toString();
QByteArray kind = model->data(modelIndex, Qt::UserRole + 2).toByteArray();
editor = em->openEditor(fileName, kind, EditorManager::NoModeSwitch);
editor = em->openEditor(fileName, kind);
}
if (editor) {
m_editorList->setCurrentIndex(m_editorsListModel->indexOf(editor).row());
......
......@@ -52,6 +52,7 @@ public:
virtual QIcon icon() const = 0;
virtual int priority() const = 0;
virtual QString id() const = 0;
virtual QString type() const = 0;
void setEnabled(bool enabled);
bool isEnabled() const;
......
......@@ -964,7 +964,7 @@ void MainWindow::openFileWith()
if (isExternal) {
editorManager()->openExternalEditor(fileName, editorId);
} else {
editorManager()->openEditor(fileName, editorId);
editorManager()->openEditor(fileName, editorId, Core::EditorManager::ModeSwitch);
}
}
}
......@@ -1272,7 +1272,7 @@ void MainWindow::openRecentFile()
if (const QAction *action = qobject_cast<const QAction*>(sender())) {
const QString fileName = action->data().toString();
if (!fileName.isEmpty())
editorManager()->openEditor(fileName);
editorManager()->openEditor(fileName, QString(), Core::EditorManager::ModeSwitch);
}
}
......
......@@ -149,6 +149,19 @@ IMode *ModeManager::mode(const QString &id) const
return 0;
}
void ModeManager::activateModeType(const QString &type)
{
int index = -1;
for (int i = 0; i < d->m_modes.count(); ++i) {
if (d->m_modes.at(i)->type() == type) {
index = i;
break;
}
}
if (index != -1)
d->m_modeStack->setCurrentIndex(index);
}
void ModeManager::activateMode(const QString &id)
{
const int index = indexOf(id);
......
......@@ -66,6 +66,8 @@ public:
void addProjectSelector(QAction *action);
void addWidget(QWidget *widget);
void activateModeType(const QString &type);
signals:
void currentModeAboutToChange(Core::IMode *mode);
......
......@@ -342,7 +342,7 @@ void CodepasterPlugin::finishFetch(const QString &titleDescription,
Core::IEditor* editor = EditorManager::instance()->openEditor(fileName);
QTC_ASSERT(editor, return)
editor->setDisplayName(titleDescription);
EditorManager::instance()->activateEditor(editor);
EditorManager::instance()->activateEditor(editor, Core::EditorManager::ModeSwitch);
}
Q_EXPORT_PLUGIN(CodepasterPlugin)
......@@ -285,7 +285,8 @@ void CppFileSettingsWidget::slotEdit()
QString path = licenseTemplatePath();
// Edit existing file with C++
if (!path.isEmpty()) {
Core::EditorManager::instance()->openEditor(path, QLatin1String(CppEditor::Constants::CPPEDITOR_ID));
Core::EditorManager::instance()->openEditor(path, QLatin1String(CppEditor::Constants::CPPEDITOR_ID),
Core::EditorManager::ModeSwitch);
return;
}
// Pick a file name and write new template, edit with C++
......@@ -301,7 +302,8 @@ void CppFileSettingsWidget::slotEdit()
file.write(tr(licenseTemplateTemplate).toUtf8());
file.close();
setLicenseTemplatePath(path);
Core::EditorManager::instance()->openEditor(path, QLatin1String(CppEditor::Constants::CPPEDITOR_ID));
Core::EditorManager::instance()->openEditor(path, QLatin1String(CppEditor::Constants::CPPEDITOR_ID),
Core::EditorManager::ModeSwitch);
}
// --------------- CppFileSettingsPage
......
......@@ -304,9 +304,11 @@ void CppFindReferences::searchFinished()
void CppFindReferences::openEditor(const Find::SearchResultItem &item)
{
if (item.path.size() > 0) {
TextEditor::BaseTextEditor::openEditorAt(item.path.first(), item.lineNumber, item.textMarkPos);
TextEditor::BaseTextEditor::openEditorAt(item.path.first(), item.lineNumber, item.textMarkPos,
QString(),
Core::EditorManager::ModeSwitch);
} else {
Core::EditorManager::instance()->openEditor(item.text);
Core::EditorManager::instance()->openEditor(item.text, QString(), Core::EditorManager::ModeSwitch);
}
}
......
......@@ -557,7 +557,7 @@ void CVSPlugin::cvsDiff(const QString &workingDir, const QStringList &files)
// Show in the same editor if diff has been executed before
if (Core::IEditor *editor = locateEditor("originalFileName", id)) {
editor->createNew(output);
Core::EditorManager::instance()->activateEditor(editor);
Core::EditorManager::instance()->activateEditor(editor, Core::EditorManager::ModeSwitch);
setDiffBaseDirectory(editor, workingDir);
return;
}
......@@ -571,7 +571,8 @@ void CVSPlugin::cvsDiff(const QString &workingDir, const QStringList &files)
CVSSubmitEditor *CVSPlugin::openCVSSubmitEditor(const QString &fileName)
{
Core::IEditor *editor = Core::EditorManager::instance()->openEditor(fileName, QLatin1String(Constants::CVSCOMMITEDITOR_ID));
Core::IEditor *editor = Core::EditorManager::instance()->openEditor(fileName, QLatin1String(Constants::CVSCOMMITEDITOR_ID),
Core::EditorManager::ModeSwitch);
CVSSubmitEditor *submitEditor = qobject_cast<CVSSubmitEditor*>(editor);
QTC_ASSERT(submitEditor, /**/);
submitEditor->registerActions(m_submitUndoAction, m_submitRedoAction, m_submitCurrentLogAction, m_submitDiffAction);
......@@ -819,7 +820,7 @@ void CVSPlugin::filelog(const QString &workingDir,
// the common usage pattern of continuously changing and diffing a file
if (Core::IEditor *editor = locateEditor("logFileName", id)) {
editor->createNew(response.stdOut);
Core::EditorManager::instance()->activateEditor(editor);
Core::EditorManager::instance()->activateEditor(editor, Core::EditorManager::ModeSwitch);
} else {
const QString title = QString::fromLatin1("cvs log %1").arg(id);
Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::LogOutput, source, codec);
......@@ -961,7 +962,7 @@ void CVSPlugin::annotate(const QString &workingDir, const QString &file,
if (Core::IEditor *editor = locateEditor("annotateFileName", id)) {
editor->createNew(response.stdOut);
VCSBase::VCSBaseEditor::gotoLineOfEditor(editor, lineNumber);
Core::EditorManager::instance()->activateEditor(editor);
Core::EditorManager::instance()->activateEditor(editor, Core::EditorManager::ModeSwitch);
} else {
const QString title = QString::fromLatin1("cvs annotate %1").arg(id);
Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::AnnotateOutput, source, codec);
......@@ -1156,7 +1157,7 @@ bool CVSPlugin::describe(const QString &repositoryPath,
const QString commitId = entries.front().revisions.front().commitId;
if (Core::IEditor *editor = locateEditor("describeChange", commitId)) {
editor->createNew(output);
Core::EditorManager::instance()->activateEditor(editor);
Core::EditorManager::instance()->activateEditor(editor, Core::EditorManager::ModeSwitch);
setDiffBaseDirectory(editor, repositoryPath);
} else {
const QString title = QString::fromLatin1("cvs describe %1").arg(commitId);
......@@ -1241,7 +1242,7 @@ Core::IEditor * CVSPlugin::showOutputInEditor(const QString& title, const QStrin
if (codec)
e->setCodec(codec);
Core::IEditor *ie = e->editableInterface();
Core::EditorManager::instance()->activateEditor(ie);
Core::EditorManager::instance()->activateEditor(ie, Core::EditorManager::ModeSwitch);
return ie;
}
......
......@@ -129,7 +129,7 @@ void MemoryViewAgent::createBinEditor(quint64 addr)
SIGNAL(endOfFileRequested(Core::IEditor *)),
SLOT(handleEndOfFileRequested(Core::IEditor*)));
m_editors << editor;
editorManager->activateEditor(editor, EditorManager::NoModeSwitch);
editorManager->activateEditor(editor);
QMetaObject::invokeMethod(editor->widget(), "setNewWindowRequestAllowed");
QMetaObject::invokeMethod(editor->widget(), "setLazyData",
Q_ARG(quint64, addr), Q_ARG(int, DataRange), Q_ARG(int, BinBlockSize));
......@@ -153,7 +153,7 @@ void MemoryViewAgent::addLazyData(QObject *editorToken, quint64 addr,
{
IEditor *editor = qobject_cast<IEditor *>(editorToken);
if (editor && editor->widget()) {
EditorManager::instance()->activateEditor(editor, EditorManager::NoModeSwitch);
Core::EditorManager::instance()->activateEditor(editor);
QMetaObject::invokeMethod(editor->widget(), "addLazyData",
Q_ARG(quint64, addr / BinBlockSize), Q_ARG(QByteArray, ba));
}
......@@ -349,7 +349,7 @@ void DisassemblerViewAgent::setContents(const QString &contents)
d->configureMimeType();
}
editorManager->activateEditor(d->editor, EditorManager::NoModeSwitch);
editorManager->activateEditor(d->editor);
plainTextEdit = qobject_cast<QPlainTextEdit *>(d->editor->widget());
if (plainTextEdit) {
......
......@@ -479,6 +479,7 @@ public:
DebugMode(QObject *parent = 0) : BaseMode(parent)
{
setDisplayName(QCoreApplication::translate("Debugger::Internal::DebugMode", "Debug"));
setType(Core::Constants::MODE_EDIT_TYPE);
setId(MODE_DEBUG);
setIcon(QIcon(__(":/fancyactionbar/images/mode_Debug.png")));
setPriority(P_MODE_DEBUG);
......@@ -2587,7 +2588,7 @@ void DebuggerPlugin::gotoLocation(const QString &file, int line, bool setMarker)
bool newEditor = false;
ITextEditor *editor =
BaseTextEditor::openEditorAt(file, line, 0, QString(),
EditorManager::IgnoreNavigationHistory | EditorManager::NoModeSwitch,
EditorManager::IgnoreNavigationHistory,
&newEditor);
if (!editor)
return;
......@@ -2608,8 +2609,7 @@ void DebuggerPlugin::openTextEditor(const QString &titlePattern0,
IEditor *editor = editorManager->openEditorWithContents(
Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, &titlePattern, contents);
QTC_ASSERT(editor, return);
editorManager->activateEditor(editor,
EditorManager::IgnoreNavigationHistory|EditorManager::NoModeSwitch);
editorManager->activateEditor(editor, EditorManager::IgnoreNavigationHistory);
}
void DebuggerPlugin::writeSettings() const
......
......@@ -903,7 +903,7 @@ void FormEditorW::switchSourceForm()
Core::EditorManager *em = Core::EditorManager::instance();
const QString fileToOpen = otherFile(em);
if (!fileToOpen.isEmpty())
em->openEditor(fileToOpen);
em->openEditor(fileToOpen, QString(), Core::EditorManager::ModeSwitch);
}
} // namespace Internal
......
......@@ -257,9 +257,9 @@ TextEditor::PlainTextEditorEditable *FormWindowEditor::textEditable()
return &d->m_textEditable;
}
QString FormWindowEditor::preferredMode() const
QString FormWindowEditor::preferredModeType() const
{
return QLatin1String(Core::Constants::MODE_DESIGN);
return QLatin1String(Core::Constants::MODE_DESIGN_TYPE);
}
} // namespace Designer
......
......@@ -88,7 +88,7 @@ public:
virtual QWidget *toolBar();
virtual QString preferredMode() const;
virtual QString preferredModeType() const;
// IContext
virtual Core::Context context() const;
......
......@@ -187,7 +187,7 @@ VCSBase::VCSBaseEditor
if (setSourceCodec)
rc->setCodec(VCSBase::VCSBaseEditor::getCodec(source));
}
m_core->editorManager()->activateEditor(outputEditor);
m_core->editorManager()->activateEditor(outputEditor, Core::EditorManager::ModeSwitch);
rc->setForceReadOnly(true);
return rc;
}
......
......@@ -676,7 +676,8 @@ void GitPlugin::startCommit(bool amend)
Core::IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const CommitData &cd, bool amend)
{
Core::IEditor *editor = m_core->editorManager()->openEditor(fileName, QLatin1String(Constants::GITSUBMITEDITOR_ID));
Core::IEditor *editor = m_core->editorManager()->openEditor(fileName, QLatin1String(Constants::GITSUBMITEDITOR_ID),
Core::EditorManager::ModeSwitch);
if (Git::Constants::debug)
qDebug() << Q_FUNC_INFO << fileName << editor;
GitSubmitEditor *submitEditor = qobject_cast<GitSubmitEditor*>(editor);
......
......@@ -109,6 +109,7 @@ bool HelloWorldPlugin::initialize(const QStringList &arguments, QString *error_m
// it will unregister itself from the plugin manager when it is deleted.
Core::BaseMode *baseMode = new Core::BaseMode;
baseMode->setId(QLatin1String("HelloWorld.HelloWorldMode"));
baseMode->setType(QLatin1String("HelloWorld.HelloWorldMode"));
baseMode->setDisplayName(tr("Hello world!"));
baseMode->setIcon(QIcon());
baseMode->setPriority(0);
......
......@@ -97,7 +97,7 @@ QList<FilterEntry> BaseFileFilter::matchesFor(QFutureInterface<Locator::FilterEn
void BaseFileFilter::accept(Locator::FilterEntry selection) const
{
Core::EditorManager *em = Core::EditorManager::instance();
em->openEditor(selection.internalData.toString());
em->openEditor(selection.internalData.toString(), QString(), Core::EditorManager::ModeSwitch);
}
void BaseFileFilter::generateFileNames()
......
......@@ -106,7 +106,8 @@ void FileSystemFilter::accept(FilterEntry selection) const
m_locatorWidget->show(value, value.length());
return;
}
m_editorManager->openEditor(selection.internalData.toString());
m_editorManager->openEditor(selection.internalData.toString(), QString(),
Core::EditorManager::ModeSwitch);
}
bool FileSystemFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
......
......@@ -101,8 +101,8 @@ void OpenDocumentsFilter::accept(FilterEntry selection) const
{
IEditor *editor = selection.internalData.value<IEditor *>();
if (editor) {
m_editorManager->activateEditor(editor);
m_editorManager->activateEditor(editor, Core::EditorManager::ModeSwitch);
return;
}
m_editorManager->openEditor(selection.internalData.toString());
m_editorManager->openEditor(selection.internalData.toString(), QString(), Core::EditorManager::ModeSwitch);
}
......@@ -628,7 +628,7 @@ VCSBase::VCSBaseEditor *MercurialClient::createVCSEditor(const QString &kind, QS
baseEditor->setCodec(VCSBase::VCSBaseEditor::getCodec(source));
}
core->editorManager()->activateEditor(outputEditor);
core->editorManager()->activateEditor(outputEditor, Core::EditorManager::ModeSwitch);
baseEditor->setForceReadOnly(true);
return baseEditor;
}
......
......@@ -593,7 +593,8 @@ void MercurialPlugin::showCommitWidget(const QList<QPair<QString, QString> > &st
}
Core::IEditor *editor = core->editorManager()->openEditor(changeLog->fileName(),
QLatin1String(Constants::COMMIT_ID));
QLatin1String(Constants::COMMIT_ID),
Core::EditorManager::ModeSwitch);
if (!editor) {
outputWindow->appendError(tr("Unable to create an editor for the commit."));
return;
......
......@@ -673,7 +673,8 @@ void PerforcePlugin::startSubmitProject()
Core::IEditor *PerforcePlugin::openPerforceSubmitEditor(const QString &fileName, const QStringList &depotFileNames)
{
Core::EditorManager *editorManager = Core::EditorManager::instance();
Core::IEditor *editor = editorManager->openEditor(fileName, Constants::PERFORCE_SUBMIT_EDITOR_ID);
Core::IEditor *editor = editorManager->openEditor(fileName, Constants::PERFORCE_SUBMIT_EDITOR_ID,
Core::EditorManager::ModeSwitch);
PerforceSubmitEditor *submitEditor = static_cast<PerforceSubmitEditor*>(editor);
submitEditor->restrictToProjectFiles(depotFileNames);
submitEditor->registerActions(m_undoAction, m_redoAction, m_submitCurrentLogAction, m_diffSelectedFiles);
......@@ -1198,7 +1199,7 @@ Core::IEditor * PerforcePlugin::showOutputInEditor(const QString& title, const Q
if (codec)
e->setCodec(codec);
Core::IEditor *ie = e->editableInterface();
Core::EditorManager::instance()->activateEditor(ie);
Core::EditorManager::instance()->activateEditor(ie, Core::EditorManager::ModeSwitch);
return ie;
}
......@@ -1239,7 +1240,7 @@ void PerforcePlugin::p4Diff(const QString &workingDir, const QStringList &files)
if (existingEditor) {
existingEditor->createNew(result.stdOut);
Core::EditorManager::instance()->activateEditor(existingEditor);
Core::EditorManager::instance()->activateEditor(existingEditor, Core::EditorManager::ModeSwitch);
} else {
Core::IEditor *editor = showOutputInEditor(tr("p4 diff %1").arg(id), result.stdOut, VCSBase::DiffOutput,
VCSBase::VCSBaseEditor::getSource(workingDir, files),
......
......@@ -267,7 +267,7 @@ void FolderNavigationWidget::openItem(const QModelIndex &srcIndex)
}
// Open file.
Core::EditorManager *editorManager = Core::EditorManager::instance();
editorManager->openEditor(m_fileSystemModel->filePath(srcIndex));
editorManager->openEditor(m_fileSystemModel->filePath(srcIndex), QString(), Core::EditorManager::ModeSwitch);
}
void FolderNavigationWidget::setCurrentTitle(QString dirName, const QString &fullPath)
......
......@@ -2102,7 +2102,7 @@ void ProjectExplorerPlugin::openFile()
{
QTC_ASSERT(d->m_currentNode, return)
Core::EditorManager *em = Core::EditorManager::instance();
em->openEditor(d->m_currentNode->path());
em->openEditor(d->m_currentNode->path(), QString(), Core::EditorManager::ModeSwitch);
}
void ProjectExplorerPlugin::showInGraphicalShell()
......@@ -2297,7 +2297,7 @@ void ProjectExplorerPlugin::openEditorFromAction(QAction *action, const QString
return;
}
em->openEditor(fileName, factory->id());
em->openEditor(fileName, factory->id(), Core::EditorManager::ModeSwitch);
return;
}
if (qVariantCanConvert<Core::IExternalEditor *>(data)) {
......
......@@ -300,7 +300,7 @@ void ProjectTreeWidget::openItem(const QModelIndex &mainIndex)
Node *node = m_model->nodeForIndex(mainIndex);
if (node->nodeType() == FileNodeType) {
Core::EditorManager *editorManager = Core::EditorManager::instance();
editorManager->openEditor(node->path());
editorManager->openEditor(node->path(), QString(), Core::EditorManager::ModeSwitch);
}
}
......
......@@ -657,14 +657,14 @@ static bool openInDesignMode()
return bool(QmlDesigner::Constants::QML_OPENDESIGNMODE_DEFAULT);
}
QString QmlJSEditorEditable::preferredMode() const
QString QmlJSEditorEditable::preferredModeType() const
{
Core::ModeManager *modeManager = Core::ModeManager::instance();
if (modeManager->currentMode()
&& (modeManager->currentMode()->id() == Core::Constants::MODE_DESIGN
|| modeManager->currentMode()->id() == Core::Constants::MODE_EDIT))
&& (modeManager->currentMode()->type() == Core::Constants::MODE_DESIGN_TYPE
|| modeManager->currentMode()->type() == Core::Constants::MODE_EDIT_TYPE))
{
return modeManager->currentMode()->id();
return modeManager->currentMode()->type();
}
// if we are in other mode than edit or design, use the hard-coded default.
......@@ -672,7 +672,7 @@ QString QmlJSEditorEditable::preferredMode() const
// have the user also access to this failsafe setting.
if (editor()->mimeType() == QLatin1String(QmlJSEditor::Constants::QML_MIMETYPE)
&& openInDesignMode())
return QLatin1String(Core::Constants::MODE_DESIGN);
return QLatin1String(Core::Constants::MODE_DESIGN_TYPE);
return QString();
}
......
......@@ -81,7 +81,7 @@ public:
QString id() const;
bool isTemporary() const { return false; }
virtual bool open(const QString & fileName);
virtual QString preferredMode() const;
virtual QString preferredModeType() const;
private:
Core::Context m_context;
......
......@@ -519,7 +519,7 @@ void InspectorUi::gotoObjectReferenceDefinition(const QDeclarativeDebugObjectRef
}
Core::EditorManager *editorManager = Core::EditorManager::instance();
Core::IEditor *editor = editorManager->openEditor(fileName, QString(), Core::EditorManager::NoModeSwitch);
Core::IEditor *editor = editorManager->openEditor(fileName);
TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
if (textEditor) {
......
......@@ -210,7 +210,9 @@ void MaemoPackageCreationWidget::editDebianFile()
const QString debianFilePath = MaemoTemplatesManager::instance()
->debianDirPath(m_step->buildConfiguration()->target()->project())
+ QLatin1Char('/') + m_ui->debianFilesComboBox->currentText();
Core::EditorManager::instance()->openEditor(debianFilePath);
Core::EditorManager::instance()->openEditor(debianFilePath,
QString(),
Core::EditorManager::ModeSwitch);
}
} // namespace Internal
......
......@@ -190,7 +190,8 @@ bool QmlStandaloneAppWizard::postGenerateFiles(const QWizard *wizard, const Core