forked from qt-creator/qt-creator
Editors: Move id() from editor to document.
Change-Id: Ib81076842ab1c16832224790194b001206404d64 Reviewed-by: hjk <hjk121@nokiamail.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
if ((currentDesignDocument()
|
||||
@@ -437,8 +431,7 @@ const DesignerActionManager &QmlDesignerPlugin::designerActionManager() const
|
||||
void QmlDesignerPlugin::switchTextDesign()
|
||||
{
|
||||
if (Core::ModeManager::currentMode()->id() == Core::Constants::MODE_EDIT) {
|
||||
Core::IEditor *editor = Core::EditorManager::currentEditor();
|
||||
if (editor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID)
|
||||
if (isQmlFile(Core::EditorManager::currentEditor()))
|
||||
Core::ModeManager::activateMode(Core::Constants::MODE_DESIGN);
|
||||
} else if (Core::ModeManager::currentMode()->id() == Core::Constants::MODE_DESIGN) {
|
||||
Core::ModeManager::activateMode(Core::Constants::MODE_EDIT);
|
||||
|
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "qmljseditordocument.h"
|
||||
|
||||
#include "qmljseditorconstants.h"
|
||||
#include "qmljseditordocument_p.h"
|
||||
#include "qmljshighlighter.h"
|
||||
#include "qmljssemantichighlighter.h"
|
||||
@@ -532,6 +533,7 @@ void QmlJSEditorDocumentPrivate::updateOutlineModel()
|
||||
QmlJSEditorDocument::QmlJSEditorDocument()
|
||||
: d(new Internal::QmlJSEditorDocumentPrivate(this))
|
||||
{
|
||||
setId(Constants::C_QMLJSEDITOR_ID);
|
||||
connect(this, SIGNAL(tabSettingsChanged()),
|
||||
d, SLOT(invalidateFormatterCache()));
|
||||
setSyntaxHighlighter(new Highlighter(document()));
|
||||
|
@@ -50,7 +50,6 @@ namespace Internal {
|
||||
QmlJSEditor::QmlJSEditor(QmlJSTextEditorWidget *editor)
|
||||
: BaseTextEditor(editor)
|
||||
{
|
||||
setId(Constants::C_QMLJSEDITOR_ID);
|
||||
m_context.add(Constants::C_QMLJSEDITOR_ID);
|
||||
m_context.add(TextEditor::Constants::C_TEXTEDITOR);
|
||||
m_context.add(ProjectExplorer::Constants::LANG_QMLJS);
|
||||
|
@@ -41,6 +41,7 @@ QmlProjectFile::QmlProjectFile(QmlProject *parent, QString fileName)
|
||||
{
|
||||
QTC_CHECK(m_project);
|
||||
QTC_CHECK(!fileName.isEmpty());
|
||||
setId("Qml.ProjectFile");
|
||||
setFilePath(fileName);
|
||||
}
|
||||
|
||||
|
@@ -48,6 +48,7 @@ using namespace Qnx::Internal;
|
||||
BarDescriptorDocument::BarDescriptorDocument(QObject *parent)
|
||||
: Core::TextDocument(parent)
|
||||
{
|
||||
setId(Constants::QNX_BAR_DESCRIPTOR_EDITOR_ID);
|
||||
// blackberry-nativepackager requires the XML file to be in UTF-8 encoding,
|
||||
// force if possible
|
||||
if (QTextCodec *defaultUTF8 = QTextCodec::codecForName("UTF-8"))
|
||||
|
@@ -56,7 +56,6 @@ namespace Internal {
|
||||
|
||||
BarDescriptorEditor::BarDescriptorEditor()
|
||||
{
|
||||
setId(Constants::QNX_BAR_DESCRIPTOR_EDITOR_ID);
|
||||
m_file = new BarDescriptorDocument(this);
|
||||
|
||||
BarDescriptorEditorWidget *editorWidget = new BarDescriptorEditorWidget(this);
|
||||
|
@@ -66,6 +66,7 @@ ResourceEditorDocument::ResourceEditorDocument(ResourceEditorW *parent) :
|
||||
m_blockDirtyChanged(false),
|
||||
m_parent(parent)
|
||||
{
|
||||
setId(ResourceEditor::Constants::RESOURCEEDITOR_ID);
|
||||
setFilePath(parent->m_resourceEditor->fileName());
|
||||
if (debugResourceEditorW)
|
||||
qDebug() << "ResourceEditorFile::ResourceEditorFile()";
|
||||
@@ -87,7 +88,6 @@ ResourceEditorW::ResourceEditorW(const Core::Context &context,
|
||||
m_contextMenu(new QMenu),
|
||||
m_toolBar(new QToolBar)
|
||||
{
|
||||
setId(ResourceEditor::Constants::RESOURCEEDITOR_ID);
|
||||
setContext(context);
|
||||
setWidget(m_resourceEditor);
|
||||
|
||||
|
@@ -407,6 +407,7 @@ void ResourceFolderNode::updateFiles(QList<ProjectExplorer::FileNode *> newList)
|
||||
ResourceFileWatcher::ResourceFileWatcher(ResourceTopLevelNode *node)
|
||||
: IDocument(node), m_node(node)
|
||||
{
|
||||
setId("ResourceNodeWatcher");
|
||||
setFilePath(node->path());
|
||||
}
|
||||
|
||||
|
@@ -39,7 +39,9 @@ using namespace TaskList::Internal;
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
TaskFile::TaskFile(QObject *parent) : Core::IDocument(parent)
|
||||
{ }
|
||||
{
|
||||
setId("TaskList.TaskFile");
|
||||
}
|
||||
|
||||
TaskFile::~TaskFile()
|
||||
{ }
|
||||
|
@@ -182,7 +182,7 @@ void CodeAssistantPrivate::configure(BaseTextEditor *textEditor)
|
||||
m_completionProvider = textEditor->completionAssistProvider();
|
||||
m_quickFixProviders =
|
||||
ExtensionSystem::PluginManager::getObjects<QuickFixAssistProvider>();
|
||||
filterEditorSpecificProviders(&m_quickFixProviders, m_textEditor->id());
|
||||
filterEditorSpecificProviders(&m_quickFixProviders, m_textEditor->document()->id());
|
||||
|
||||
m_textEditor->editorWidget()->installEventFilter(this);
|
||||
connect(m_textEditor->baseTextDocument(),SIGNAL(mimeTypeChanged()),
|
||||
|
@@ -63,7 +63,6 @@ namespace TextEditor {
|
||||
PlainTextEditor::PlainTextEditor(PlainTextEditorWidget *editor)
|
||||
: BaseTextEditor(editor)
|
||||
{
|
||||
setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
|
||||
setContext(Core::Context(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID,
|
||||
TextEditor::Constants::C_TEXTEDITOR));
|
||||
}
|
||||
@@ -185,6 +184,7 @@ void PlainTextEditorWidget::acceptMissingSyntaxDefinitionInfo()
|
||||
|
||||
PlainTextDocument::PlainTextDocument()
|
||||
{
|
||||
setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
|
||||
connect(this, SIGNAL(tabSettingsChanged()), this, SLOT(updateTabSettings()));
|
||||
}
|
||||
|
||||
|
@@ -47,11 +47,11 @@ SnippetEditor::SnippetEditor(SnippetEditorWidget *editor)
|
||||
: BaseTextEditor(editor)
|
||||
{
|
||||
setContext(Core::Context(Constants::SNIPPET_EDITOR_ID, Constants::C_TEXTEDITOR));
|
||||
setId(Constants::SNIPPET_EDITOR_ID);
|
||||
}
|
||||
|
||||
SnippetEditorWidget::SnippetEditorWidget(QWidget *parent) : BaseTextEditorWidget(parent)
|
||||
{
|
||||
baseTextDocument()->setId(Constants::SNIPPET_EDITOR_ID);
|
||||
setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
||||
setHighlightCurrentLine(false);
|
||||
setLineNumbersVisible(false);
|
||||
|
@@ -45,12 +45,13 @@ using namespace VcsBase::Internal;
|
||||
submit editor files.
|
||||
*/
|
||||
|
||||
SubmitEditorFile::SubmitEditorFile(const QString &mimeType, VcsBaseSubmitEditor *parent) :
|
||||
SubmitEditorFile::SubmitEditorFile(const VcsBaseSubmitEditorParameters *parameters, VcsBaseSubmitEditor *parent) :
|
||||
Core::IDocument(parent),
|
||||
m_mimeType(mimeType),
|
||||
m_mimeType(QLatin1String(parameters->mimeType)),
|
||||
m_modified(false),
|
||||
m_editor(parent)
|
||||
{
|
||||
setId(parameters->id);
|
||||
setTemporary(true);
|
||||
}
|
||||
|
||||
|
@@ -30,6 +30,8 @@
|
||||
#ifndef SUBMITEDITORFILE_H
|
||||
#define SUBMITEDITORFILE_H
|
||||
|
||||
#include "vcsbasesubmiteditor.h"
|
||||
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
namespace VcsBase {
|
||||
@@ -41,7 +43,7 @@ class SubmitEditorFile : public Core::IDocument
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SubmitEditorFile(const QString &mimeType,
|
||||
explicit SubmitEditorFile(const VcsBaseSubmitEditorParameters *parameters,
|
||||
VcsBaseSubmitEditor *parent = 0);
|
||||
|
||||
bool setContents(const QByteArray &contents);
|
||||
|
@@ -164,7 +164,6 @@ VcsBaseEditor::VcsBaseEditor(VcsBaseEditorWidget *widget,
|
||||
const VcsBaseEditorParameters *type) :
|
||||
BaseTextEditor(widget)
|
||||
{
|
||||
setId(type->id);
|
||||
setContext(Core::Context(type->context, TextEditor::Constants::C_TEXTEDITOR));
|
||||
}
|
||||
|
||||
@@ -652,6 +651,7 @@ VcsBaseEditorWidget::VcsBaseEditorWidget(const VcsBaseEditorParameters *type, QW
|
||||
d(new Internal::VcsBaseEditorWidgetPrivate(this, type))
|
||||
{
|
||||
viewport()->setMouseTracking(true);
|
||||
baseTextDocument()->setId(type->id);
|
||||
baseTextDocument()->setMimeType(QLatin1String(d->m_parameters->mimeType));
|
||||
}
|
||||
|
||||
|
@@ -567,8 +567,9 @@ void VcsBasePlugin::slotSubmitEditorAboutToClose(VcsBaseSubmitEditor *submitEdit
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << this << "plugin's submit editor"
|
||||
<< d->m_submitEditor << (d->m_submitEditor ? d->m_submitEditor->id().name() : "")
|
||||
<< "closing submit editor" << submitEditor << submitEditor->id().name();
|
||||
<< d->m_submitEditor << (d->m_submitEditor ? d->m_submitEditor->document()->id().name() : "")
|
||||
<< "closing submit editor" << submitEditor
|
||||
<< (submitEditor ? submitEditor->document()->id().name() : "");
|
||||
if (submitEditor == d->m_submitEditor)
|
||||
*result = submitEditorAboutToClose();
|
||||
}
|
||||
|
@@ -167,7 +167,7 @@ VcsBaseSubmitEditorPrivate::VcsBaseSubmitEditorPrivate(const VcsBaseSubmitEditor
|
||||
m_widget(editorWidget),
|
||||
m_toolWidget(0),
|
||||
m_parameters(parameters),
|
||||
m_file(new SubmitEditorFile(QLatin1String(parameters->mimeType), q)),
|
||||
m_file(new SubmitEditorFile(parameters, q)),
|
||||
m_nickNameDialog(0)
|
||||
{
|
||||
QCompleter *completer = new QCompleter(q);
|
||||
@@ -181,7 +181,6 @@ VcsBaseSubmitEditor::VcsBaseSubmitEditor(const VcsBaseSubmitEditorParameters *pa
|
||||
SubmitEditorWidget *editorWidget) :
|
||||
d(new VcsBaseSubmitEditorPrivate(parameters, editorWidget, this))
|
||||
{
|
||||
setId(parameters->id);
|
||||
setContext(Core::Context(parameters->context));
|
||||
setWidget(d->m_widget);
|
||||
document()->setDisplayName(QCoreApplication::translate("VCS", d->m_parameters->displayName));
|
||||
|
Reference in New Issue
Block a user