Commit 5dd8d7cd authored by Eike Ziller's avatar Eike Ziller

Editors: Move id() from editor to document.

Change-Id: Ib81076842ab1c16832224790194b001206404d64
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 424a5c14
......@@ -44,6 +44,7 @@ AndroidManifestDocument::AndroidManifestDocument(AndroidManifestEditorWidget *ed
: TextEditor::PlainTextDocument(),
m_editorWidget(editorWidget)
{
setId(Constants::ANDROID_MANIFEST_EDITOR_ID);
setMimeType(QLatin1String(Constants::ANDROID_MANIFEST_MIME_TYPE));
connect(editorWidget, SIGNAL(guiChanged()),
this, SIGNAL(changed()));
......
......@@ -44,8 +44,6 @@ using namespace Internal;
Android::Internal::AndroidManifestEditor::AndroidManifestEditor(AndroidManifestEditorWidget *editorWidget)
: Core::IEditor(editorWidget), m_toolBar(0)
{
setId(Constants::ANDROID_MANIFEST_EDITOR_ID);
m_toolBar = new QToolBar(editorWidget);
m_actionGroup = new QActionGroup(this);
connect(m_actionGroup, SIGNAL(triggered(QAction*)), this, SLOT(changeEditorPage(QAction*)));
......
......@@ -52,7 +52,6 @@ using namespace Android::Internal;
JavaEditor::JavaEditor(JavaEditorWidget *editor)
: BaseTextEditor(editor)
{
setId(Constants::JAVA_EDITOR_ID);
setContext(Core::Context(Constants::C_JAVA_EDITOR,
TextEditor::Constants::C_TEXTEDITOR));
}
......@@ -112,6 +111,7 @@ TextEditor::BaseTextEditor *JavaEditorWidget::createEditor()
JavaDocument::JavaDocument()
: TextEditor::BaseTextDocument()
{
setId(Constants::JAVA_EDITOR_ID);
setMimeType(QLatin1String(Constants::JAVA_MIMETYPE));
setSyntaxHighlighter(TextEditor::createGenericSyntaxHighlighter(Core::MimeDatabase::findByType(QLatin1String(Constants::JAVA_MIMETYPE))));
setIndenter(new JavaIndenter);
......
......@@ -40,6 +40,7 @@ AutotoolsProjectFile::AutotoolsProjectFile(AutotoolsProject *project, const QStr
Core::IDocument(project),
m_project(project)
{
setId("Autotools.ProjectFile");
setFilePath(fileName);
}
......
......@@ -43,6 +43,7 @@
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
#include <cppeditor/cppeditorconstants.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/project.h>
......@@ -86,7 +87,7 @@ bool ArtisticStyle::initialize()
void ArtisticStyle::updateActions(Core::IEditor *editor)
{
m_formatFile->setEnabled(editor && editor->id() == CppEditor::Constants::CPPEDITOR_ID);
m_formatFile->setEnabled(editor && editor->document()->id() == CppEditor::Constants::CPPEDITOR_ID);
}
QList<QObject *> ArtisticStyle::autoReleaseObjects()
......
......@@ -43,6 +43,7 @@
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
#include <cppeditor/cppeditorconstants.h>
#include <texteditor/basetexteditor.h>
......@@ -91,7 +92,7 @@ bool ClangFormat::initialize()
void ClangFormat::updateActions(Core::IEditor *editor)
{
const bool enabled = (editor && editor->id() == CppEditor::Constants::CPPEDITOR_ID);
const bool enabled = (editor && editor->document()->id() == CppEditor::Constants::CPPEDITOR_ID);
m_formatFile->setEnabled(enabled);
m_formatRange->setEnabled(enabled);
}
......
......@@ -43,6 +43,7 @@
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
#include <cppeditor/cppeditorconstants.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/project.h>
......@@ -86,7 +87,7 @@ bool Uncrustify::initialize()
void Uncrustify::updateActions(Core::IEditor *editor)
{
m_formatFile->setEnabled(editor && editor->id() == CppEditor::Constants::CPPEDITOR_ID);
m_formatFile->setEnabled(editor && editor->document()->id() == CppEditor::Constants::CPPEDITOR_ID);
}
QList<QObject *> Uncrustify::autoReleaseObjects()
......
......@@ -205,6 +205,7 @@ public:
BinEditorDocument(BinEditorWidget *parent) :
Core::IDocument(parent)
{
setId(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID);
m_widget = parent;
connect(m_widget, SIGNAL(dataRequested(quint64)),
this, SLOT(provideData(quint64)));
......@@ -340,7 +341,6 @@ class BinEditor : public Core::IEditor
public:
BinEditor(BinEditorWidget *widget)
{
setId(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID);
setWidget(widget);
m_widget = widget;
m_file = new BinEditorDocument(m_widget);
......
......@@ -59,7 +59,6 @@ using namespace CMakeProjectManager::Internal;
CMakeEditor::CMakeEditor(CMakeEditorWidget *editor)
: BaseTextEditor(editor)
{
setId(CMakeProjectManager::Constants::CMAKE_EDITOR_ID);
setContext(Core::Context(CMakeProjectManager::Constants::C_CMAKEEDITOR,
TextEditor::Constants::C_TEXTEDITOR));
connect(document(), SIGNAL(changed()), this, SLOT(markAsChanged()));
......@@ -227,6 +226,7 @@ CMakeEditorWidget::Link CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
CMakeDocument::CMakeDocument()
: TextEditor::BaseTextDocument()
{
setId(CMakeProjectManager::Constants::CMAKE_EDITOR_ID);
setMimeType(QLatin1String(CMakeProjectManager::Constants::CMAKEMIMETYPE));
setSyntaxHighlighter(new CMakeHighlighter);
}
......
......@@ -763,6 +763,7 @@ void CMakeProject::createUiCodeModelSupport()
CMakeFile::CMakeFile(CMakeProject *parent, QString fileName)
: Core::IDocument(parent), m_project(parent)
{
setId("Cmake.ProjectFile");
setFilePath(fileName);
}
......
......@@ -1432,7 +1432,7 @@ void DocumentManager::executeOpenWithMenuAction(QAction *action)
= EditorManager::documentModel()->editorsForFilePath(entry.fileName);
if (!editorsOpenForFile.isEmpty()) {
foreach (IEditor *openEditor, editorsOpenForFile) {
if (entry.editorFactory->id() == openEditor->id())
if (entry.editorFactory->id() == openEditor->document()->id())
editorsOpenForFile.removeAll(openEditor);
}
if (!EditorManager::closeEditors(editorsOpenForFile)) // don't open if cancel was pressed
......
......@@ -137,7 +137,7 @@ void DocumentModel::addEditor(IEditor *editor, bool *isNewDocument)
if (isNew) {
Entry *entry = new Entry;
entry->document = editor->document();
entry->m_id = editor->id();
entry->m_id = editor->document()->id();
addEntry(entry);
}
}
......
......@@ -1419,7 +1419,7 @@ IEditor *EditorManager::createEditor(const Id &editorId, const QString &fileName
IEditor *editor = factories.front()->createEditor();
if (editor) {
QTC_CHECK(editor->id().isValid()); // sanity check that the editor has an id set
QTC_CHECK(editor->document()->id().isValid()); // sanity check that the editor has an id set
connect(editor->document(), SIGNAL(changed()), m_instance, SLOT(handleDocumentStateChange()));
emit m_instance->editorCreated(editor, fileName);
}
......@@ -1440,7 +1440,8 @@ void EditorManager::addEditor(IEditor *editor)
const bool addWatcher = !isTemporary;
DocumentManager::addDocument(editor->document(), addWatcher);
if (!isTemporary)
DocumentManager::addToRecentFiles(editor->document()->filePath(), editor->id());
DocumentManager::addToRecentFiles(editor->document()->filePath(),
editor->document()->id());
}
emit m_instance->editorOpened(editor);
}
......
......@@ -209,7 +209,7 @@ void EditorView::updateEditorHistory(IEditor *editor, QList<EditLocation> &histo
EditLocation location;
location.document = document;
location.fileName = document->filePath();
location.id = editor->id();
location.id = document->id();
location.state = QVariant(state);
for (int i = 0; i < history.size(); ++i) {
......@@ -405,7 +405,7 @@ void EditorView::addCurrentPositionToNavigationHistory(IEditor *editor, const QB
EditLocation location;
location.document = document;
location.fileName = document->filePath();
location.id = editor->id();
location.id = document->id();
location.state = QVariant(state);
m_currentNavigationHistoryPosition = qMin(m_currentNavigationHistoryPosition, m_navigationHistory.size()); // paranoia
m_navigationHistory.insert(m_currentNavigationHistoryPosition, location);
......@@ -460,7 +460,7 @@ void EditorView::updateCurrentPositionInNavigationHistory()
}
location->document = document;
location->fileName = document->filePath();
location->id = editor->id();
location->id = document->id();
location->state = QVariant(editor->saveState());
}
......@@ -769,10 +769,10 @@ QByteArray SplitterOrView::saveState() const
stream << QByteArray("empty");
} else if (e == EditorManager::currentEditor()) {
stream << QByteArray("currenteditor")
<< e->document()->filePath() << e->id().toString() << e->saveState();
<< e->document()->filePath() << e->document()->id().toString() << e->saveState();
} else {
stream << QByteArray("editor")
<< e->document()->filePath() << e->id().toString() << e->saveState();
<< e->document()->filePath() << e->document()->id().toString() << e->saveState();
}
}
return bytes;
......
......@@ -56,14 +56,3 @@
\sa Core::EditorFactoryInterface Core::IContext
*/
void Core::IEditor::setId(Core::Id id)
{
m_id = id;
}
Core::Id Core::IEditor::id() const
{
return m_id;
}
......@@ -47,9 +47,6 @@ public:
IEditor(QObject *parent = 0) : IContext(parent) {}
virtual ~IEditor() {}
void setId(Core::Id id);
Core::Id id() const;
virtual bool open(QString *errorString, const QString &fileName, const QString &realFileName) = 0;
virtual IDocument *document() = 0;
......
......@@ -31,6 +31,8 @@
#include "infobar.h"
#include <utils/qtcassert.h>
#include <QFile>
#include <QFileInfo>
......@@ -73,6 +75,17 @@ IDocument::~IDocument()
delete m_infoBar;
}
void IDocument::setId(Id id)
{
m_id = id;
}
Id IDocument::id() const
{
QTC_CHECK(m_id.isValid());
return m_id;
}
/*!
Used for example by EditorManager::openEditorWithContents() to set the contents
of this document.
......
......@@ -31,6 +31,8 @@
#define IDOCUMENT_H
#include "core_global.h"
#include "id.h"
#include <QObject>
namespace Core {
......@@ -75,6 +77,9 @@ public:
IDocument(QObject *parent = 0);
virtual ~IDocument();
void setId(Core::Id id);
Core::Id id() const;
virtual bool save(QString *errorString, const QString &fileName = QString(), bool autoSave = false) = 0;
virtual bool setContents(const QByteArray &contents);
......@@ -118,6 +123,7 @@ signals:
void filePathChanged(const QString &oldName, const QString &newName);
private:
Id m_id;
QString m_filePath;
QString m_displayName;
bool m_temporary;
......
......@@ -504,7 +504,6 @@ bool handleDoxygenContinuation(QTextCursor &cursor,
CPPEditor::CPPEditor(CPPEditorWidget *editor)
: BaseTextEditor(editor)
{
setId(CppEditor::Constants::CPPEDITOR_ID);
m_context.add(CppEditor::Constants::C_CPPEDITOR);
m_context.add(ProjectExplorer::Constants::LANG_CXX);
m_context.add(TextEditor::Constants::C_TEXTEDITOR);
......@@ -1966,6 +1965,7 @@ void CPPEditorWidget::showPreProcessorWidget()
CPPEditorDocument::CPPEditorDocument()
{
setId(CppEditor::Constants::CPPEDITOR_ID);
connect(this, SIGNAL(tabSettingsChanged()),
this, SLOT(invalidateFormatterCache()));
connect(this, SIGNAL(mimeTypeChanged()),
......
......@@ -111,10 +111,11 @@ bool QmlCppEngine::canDisplayTooltip() const
bool QmlCppEngine::setToolTipExpression(const QPoint & mousePos,
TextEditor::ITextEditor *editor, const DebuggerToolTipContext &ctx)
{
QTC_ASSERT(editor, return false);
bool success = false;
if (editor->id() == CppEditor::Constants::CPPEDITOR_ID)
if (editor->document()->id() == CppEditor::Constants::CPPEDITOR_ID)
success = d->m_cppEngine->setToolTipExpression(mousePos, editor, ctx);
else if (editor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID)
else if (editor->document()->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID)
success = d->m_qmlEngine->setToolTipExpression(mousePos, editor, ctx);
return success;
}
......
......@@ -294,7 +294,7 @@ void QmlInspectorAdapter::createPreviewForEditor(Core::IEditor *newEditor)
if (!m_engineClientConnected)
return;
if (!newEditor || newEditor->id()
if (!newEditor || newEditor->document()->id()
!= QmlJSEditor::Constants::C_QMLJSEDITOR_ID)
return;
......
......@@ -384,8 +384,9 @@ QmlLiveTextPreview::~QmlLiveTextPreview()
void QmlLiveTextPreview::associateEditor(Core::IEditor *editor)
{
QTC_ASSERT(editor, return);
using namespace TextEditor;
if (editor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
if (editor->document()->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
QTC_ASSERT(QLatin1String(editor->widget()->metaObject()->className()) ==
QLatin1String("QmlJSEditor::Internal::QmlJSTextEditorWidget"),
return);
......@@ -409,7 +410,7 @@ void QmlLiveTextPreview::associateEditor(Core::IEditor *editor)
void QmlLiveTextPreview::unassociateEditor(Core::IEditor *oldEditor)
{
using namespace TextEditor;
if (oldEditor && oldEditor->id()
if (oldEditor && oldEditor->document()->id()
== QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
BaseTextEditorWidget *editWidget
= qobject_cast<BaseTextEditorWidget*>(oldEditor->widget());
......
......@@ -728,7 +728,7 @@ void FormEditorW::currentEditorChanged(IEditor *editor)
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << editor << " of " << m_fwm->formWindowCount();
if (editor && editor->id() == Constants::K_DESIGNER_XML_EDITOR_ID) {
if (editor && editor->document()->id() == Constants::K_DESIGNER_XML_EDITOR_ID) {
FormWindowEditor *xmlEditor = qobject_cast<FormWindowEditor *>(editor);
QTC_ASSERT(xmlEditor, return);
ensureInitStage(FullyInitialized);
......
......@@ -54,7 +54,6 @@ FormWindowEditor::FormWindowEditor(Internal::DesignerXmlEditorWidget *editor) :
TextEditor::PlainTextEditor(editor),
d(new FormWindowEditorPrivate)
{
setId(Core::Id(Designer::Constants::K_DESIGNER_XML_EDITOR_ID));
d->m_widget = editor;
setContext(Core::Context(Designer::Constants::K_DESIGNER_XML_EDITOR_ID,
Designer::Constants::C_DESIGNER_XML_EDITOR));
......
......@@ -58,6 +58,7 @@ FormWindowFile::FormWindowFile(QDesignerFormWindowInterface *form, QObject *pare
m_isModified(false)
{
setParent(parent);
setId(Core::Id(Designer::Constants::K_DESIGNER_XML_EDITOR_ID));
// Designer needs UTF-8 regardless of settings.
setCodec(QTextCodec::codecForName("UTF-8"));
connect(m_formWindow->core()->formWindowManager(), SIGNAL(formWindowRemoved(QDesignerFormWindowInterface*)),
......
......@@ -70,7 +70,7 @@ protected:
BaseTextEditor *createEditor()
{
BaseTextEditor *editor = new BaseTextEditor(this);
editor->setId("DescriptionEditor");
editor->document()->setId("DiffEditor.DescriptionEditor");
return editor;
}
};
......@@ -141,7 +141,6 @@ DiffEditor::DiffEditor(DiffEditor *other)
void DiffEditor::ctor()
{
setId(Constants::DIFF_EDITOR_ID);
QSplitter *splitter = new Core::MiniSplitter(Qt::Vertical);
m_descriptionWidget = new Internal::DescriptionEditorWidget(splitter);
......
......@@ -40,6 +40,7 @@ DiffEditorDocument::DiffEditorDocument(const QString &mimeType) :
m_mimeType(mimeType),
m_diffEditorController(new DiffEditorController(this))
{
setId(Constants::DIFF_EDITOR_ID);
setDisplayName(QCoreApplication::translate("DiffEditor", Constants::DIFF_EDITOR_DISPLAY_NAME));
setTemporary(true);
}
......
......@@ -78,7 +78,7 @@ public:
SideDiffEditor(BaseTextEditorWidget *editorWidget)
: BaseTextEditor(editorWidget)
{
setId("SideDiffEditor");
document()->setId("DiffEditor.SideDiffEditor");
connect(this, SIGNAL(tooltipRequested(TextEditor::ITextEditor*,QPoint,int)),
this, SLOT(slotTooltipRequested(TextEditor::ITextEditor*,QPoint,int)));
}
......
......@@ -408,6 +408,7 @@ GenericProjectFile::GenericProjectFile(GenericProject *parent, QString fileName,
m_project(parent),
m_options(options)
{
setId("Generic.ProjectFile");
setFilePath(fileName);
}
......
......@@ -78,7 +78,7 @@ Core::IEditor *ProjectFilesFactory::createEditor()
ProjectFilesEditor::ProjectFilesEditor(ProjectFilesEditorWidget *editor)
: BaseTextEditor(editor)
{
setId(Constants::FILES_EDITOR_ID);
document()->setId(Constants::FILES_EDITOR_ID);
setContext(Core::Context(Constants::C_FILESEDITOR));
}
......
......@@ -303,7 +303,7 @@ void GitEditor::applyDiffChunk(const VcsBase::DiffChunk& chunk, bool revert)
void GitEditor::init()
{
VcsBase::VcsBaseEditorWidget::init();
Core::Id editorId = editor()->id();
Core::Id editorId = editor()->document()->id();
if (editorId == Git::Constants::GIT_COMMIT_TEXT_EDITOR_ID)
new GitSubmitHighlighter(baseTextDocument());
else if (editorId == Git::Constants::GIT_REBASE_EDITOR_ID)
......@@ -326,7 +326,7 @@ void GitEditor::addDiffActions(QMenu *menu, const VcsBase::DiffChunk &chunk)
bool GitEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
{
bool res = VcsBaseEditorWidget::open(errorString, fileName, realFileName);
Core::Id editorId = editor()->id();
Core::Id editorId = editor()->document()->id();
if (editorId == Git::Constants::GIT_COMMIT_TEXT_EDITOR_ID
|| editorId == Git::Constants::GIT_REBASE_EDITOR_ID) {
QFileInfo fi(fileName);
......@@ -391,8 +391,8 @@ QString GitEditor::revisionSubject(const QTextBlock &inBlock) const
bool GitEditor::supportChangeLinks() const
{
return VcsBaseEditorWidget::supportChangeLinks()
|| (editor()->id() == Git::Constants::GIT_COMMIT_TEXT_EDITOR_ID)
|| (editor()->id() == Git::Constants::GIT_REBASE_EDITOR_ID);
|| (editor()->document()->id() == Git::Constants::GIT_COMMIT_TEXT_EDITOR_ID)
|| (editor()->document()->id() == Git::Constants::GIT_REBASE_EDITOR_ID);
}
QString GitEditor::fileNameForLine(int line) const
......
......@@ -143,6 +143,7 @@ void Document::addRange(const QTextCursor &cursor, GLSL::Scope *scope)
GLSLTextEditorWidget::GLSLTextEditorWidget(QWidget *parent)
: TextEditor::BaseTextEditorWidget(parent)
{
baseTextDocument()->setId(GLSLEditor::Constants::C_GLSLEDITOR_ID);
baseTextDocument()->setIndenter(new GLSLIndenter());
ctor();
}
......
......@@ -46,7 +46,6 @@ namespace Internal {
GLSLEditorEditable::GLSLEditorEditable(GLSLTextEditorWidget *editor)
: BaseTextEditor(editor)
{
setId(GLSLEditor::Constants::C_GLSLEDITOR_ID);
setContext(Core::Context(GLSLEditor::Constants::C_GLSLEDITOR_ID,
TextEditor::Constants::C_TEXTEDITOR));
}
......
......@@ -62,8 +62,6 @@ ImageViewer::ImageViewer(QWidget *parent)
: IEditor(parent),
d(new ImageViewerPrivate)
{
setId(Constants::IMAGEVIEWER_ID);
d->file = new ImageViewerFile(this);
d->imageView = new ImageView();
......
......@@ -30,6 +30,7 @@
#include "imageviewerfile.h"
#include "imageviewer.h"
#include "imageviewerconstants.h"
#include <QFileInfo>
......@@ -39,6 +40,7 @@ namespace Internal {
ImageViewerFile::ImageViewerFile(ImageViewer *parent)
: Core::IDocument(parent)
{
setId(Constants::IMAGEVIEWER_ID);
m_editor = parent;
}
......
......@@ -50,7 +50,6 @@ namespace Internal {
PythonEditor::PythonEditor(EditorWidget *editorWidget)
:BaseTextEditor(editorWidget)
{
setId(Constants::C_PYTHONEDITOR_ID);
setContext(Core::Context(Constants::C_PYTHONEDITOR_ID,
TextEditor::Constants::C_TEXTEDITOR));
}
......
......@@ -37,6 +37,7 @@
#include "tools/pythonhighlighter.h"
#include "tools/pythonindenter.h"
#include "pythoneditor.h"
#include "pythoneditorconstants.h"
#include <texteditor/fontsettings.h>
#include <texteditor/texteditorconstants.h>
......@@ -50,6 +51,7 @@ namespace Internal {
EditorWidget::EditorWidget(QWidget *parent)
: TextEditor::BaseTextEditorWidget(parent)
{
baseTextDocument()->setId(Constants::C_PYTHONEDITOR_ID);
baseTextDocument()->setIndenter(new PythonIndenter());
ctor();
}
......
......@@ -38,6 +38,7 @@ namespace Internal {
QbsProjectFile::QbsProjectFile(QbsProject *parent, QString fileName) : Core::IDocument(parent),
m_project(parent)
{
setId("Qbs.ProjectFile");
setFilePath(fileName);
}
......
......@@ -55,7 +55,6 @@ namespace Internal {
ProFileEditor::ProFileEditor(ProFileEditorWidget *editor)
: BaseTextEditor(editor)
{
setId(Constants::PROFILE_EDITOR_ID);
setContext(Core::Context(Constants::C_PROFILEEDITOR,
TextEditor::Constants::C_TEXTEDITOR));
}
......@@ -205,6 +204,7 @@ void ProFileEditorWidget::contextMenuEvent(QContextMenuEvent *e)
ProFileDocument::ProFileDocument()
: TextEditor::BaseTextDocument()
{
setId(Constants::PROFILE_EDITOR_ID);
setMimeType(QLatin1String(Constants::PROFILE_MIMETYPE));
setSyntaxHighlighter(new ProFileHighlighter);
}
......
......@@ -183,6 +183,7 @@ using namespace QmakeProjectManager::Internal;
QmakePriFile::QmakePriFile(QmakeProjectManager::QmakePriFileNode *qmakePriFile)
: IDocument(qmakePriFile), m_priFile(qmakePriFile)
{
setId("Qmake.PriFile");
setFilePath(m_priFile->path());
}
......
......@@ -271,6 +271,7 @@ QmakeProjectFile::QmakeProjectFile(const QString &filePath, QObject *parent)
: Core::IDocument(parent),
m_mimeType(QLatin1String(QmakeProjectManager::Constants::PROFILE_MIMETYPE))
{
setId("Qmake.ProFile");
setFilePath(filePath);
}
......
......@@ -60,7 +60,7 @@ QmlDesignerPlugin *QmlDesignerPlugin::m_instance = 0;
static bool isQmlFile(Core::IEditor *editor)
{
return editor && editor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID;
return editor && editor->document()->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID;
}
static bool isInDesignerMode()
......@@ -324,9 +324,7 @@ void QmlDesignerPlugin::resetModelSelection()
void QmlDesignerPlugin::onCurrentEditorChanged(Core::IEditor *editor)
{
if (editor
&& editor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID
&& isInDesignerMode())
if (isQmlFile(editor) && isInDesignerMode())
{
m_shortCutManager.updateActions(editor);
changeEditor();
......@@ -340,11 +338,7 @@ static bool isDesignerMode(Core::IMode *mode)
void QmlDesignerPlugin::onCurrentModeChanged(Core::IMode *newMode, Core::IMode *oldMode)
{
if (!Core::EditorManager::currentEditor())
return;
if (Core::EditorManager::currentEditor()
&& Core::EditorManager::currentEditor()->id() != QmlJSEditor::Constants::C_QMLJSEDITOR_ID)
if (!isQmlFile(Core::EditorManager::currentEditor()))
return;