From 18313bdb3306e1f26965bd6f488eb48b57511674 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 9 Dec 2013 16:54:31 +0100 Subject: Move markableInterface() to ITextEditorDocument And remove the indirection over BaseTextEditorWidget. Change-Id: I2c570edf46b9ca72a11704ce27d8ae3f2218dcf0 Reviewed-by: David Schulz --- src/plugins/debugger/disassembleragent.cpp | 10 +++++----- src/plugins/debugger/sourceagent.cpp | 4 ++-- src/plugins/texteditor/basetextdocument.cpp | 2 +- src/plugins/texteditor/basetextdocument.h | 2 +- src/plugins/texteditor/basetexteditor.cpp | 5 ----- src/plugins/texteditor/basetexteditor.h | 3 --- src/plugins/texteditor/basetextmark.cpp | 23 +++++++++-------------- src/plugins/texteditor/itexteditor.h | 4 ++-- 8 files changed, 20 insertions(+), 33 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/debugger/disassembleragent.cpp b/src/plugins/debugger/disassembleragent.cpp index 3dd14440bb..95bda62afd 100644 --- a/src/plugins/debugger/disassembleragent.cpp +++ b/src/plugins/debugger/disassembleragent.cpp @@ -192,7 +192,7 @@ void DisassemblerAgent::resetLocation() if (d->resetLocationScheduled) { d->resetLocationScheduled = false; if (d->locationMark) - d->editor->markableInterface()->removeMark(d->locationMark); + d->editor->textDocument()->markableInterface()->removeMark(d->locationMark); } } @@ -346,14 +346,14 @@ void DisassemblerAgent::updateLocationMarker() int lineNumber = contents.lineForAddress(d->location.address()); if (d->location.needsMarker()) { if (d->locationMark) - d->editor->markableInterface()->removeMark(d->locationMark); + d->editor->textDocument()->markableInterface()->removeMark(d->locationMark); delete d->locationMark; d->locationMark = 0; if (lineNumber) { d->locationMark = new ITextMark(lineNumber); d->locationMark->setIcon(debuggerCore()->locationMarkIcon()); d->locationMark->setPriority(TextEditor::ITextMark::HighPriority); - d->editor->markableInterface()->addMark(d->locationMark); + d->editor->textDocument()->markableInterface()->addMark(d->locationMark); } } @@ -379,7 +379,7 @@ void DisassemblerAgent::updateBreakpointMarkers() const DisassemblerLines contents = d->contentsAtCurrentLocation(); foreach (TextEditor::ITextMark *marker, d->breakpointMarks) - d->editor->markableInterface()->removeMark(marker); + d->editor->textDocument()->markableInterface()->removeMark(marker); qDeleteAll(d->breakpointMarks); d->breakpointMarks.clear(); foreach (BreakpointModelId id, ids) { @@ -393,7 +393,7 @@ void DisassemblerAgent::updateBreakpointMarkers() marker->setIcon(handler->icon(id)); marker->setPriority(ITextMark::NormalPriority); d->breakpointMarks.append(marker); - d->editor->markableInterface()->addMark(marker); + d->editor->textDocument()->markableInterface()->addMark(marker); } } diff --git a/src/plugins/debugger/sourceagent.cpp b/src/plugins/debugger/sourceagent.cpp index 210528bf13..d944a20b1c 100644 --- a/src/plugins/debugger/sourceagent.cpp +++ b/src/plugins/debugger/sourceagent.cpp @@ -137,7 +137,7 @@ void SourceAgent::updateLocationMarker() QTC_ASSERT(d->editor, return); if (d->locationMark) - d->editor->markableInterface()->removeMark(d->locationMark); + d->editor->textDocument()->markableInterface()->removeMark(d->locationMark); delete d->locationMark; d->locationMark = 0; if (d->engine->stackHandler()->currentFrame().file == d->path) { @@ -145,7 +145,7 @@ void SourceAgent::updateLocationMarker() d->locationMark = new TextEditor::ITextMark(lineNumber); d->locationMark->setIcon(debuggerCore()->locationMarkIcon()); d->locationMark->setPriority(TextEditor::ITextMark::HighPriority); - d->editor->markableInterface()->addMark(d->locationMark); + d->editor->textDocument()->markableInterface()->addMark(d->locationMark); QPlainTextEdit *plainTextEdit = qobject_cast(d->editor->widget()); QTC_ASSERT(plainTextEdit, return); QTextCursor tc = plainTextEdit->textCursor(); diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp index b9efca80b2..adf2e2364d 100644 --- a/src/plugins/texteditor/basetextdocument.cpp +++ b/src/plugins/texteditor/basetextdocument.cpp @@ -195,7 +195,7 @@ SyntaxHighlighter *BaseTextDocument::syntaxHighlighter() const return d->m_highlighter; } -ITextMarkable *BaseTextDocument::documentMarker() const +ITextMarkable *BaseTextDocument::markableInterface() const { BaseTextDocumentLayout *documentLayout = qobject_cast(d->m_document->documentLayout()); diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/basetextdocument.h index 9b85c7c3d5..1a0a8ff3f5 100644 --- a/src/plugins/texteditor/basetextdocument.h +++ b/src/plugins/texteditor/basetextdocument.h @@ -72,7 +72,7 @@ public: const TabSettings &tabSettings() const; const ExtraEncodingSettings &extraEncodingSettings() const; - ITextMarkable *documentMarker() const; + ITextMarkable *markableInterface() const; // IDocument implementation. bool save(QString *errorString, const QString &fileName, bool autoSave); diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 6b9ba965e1..268f265f2e 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -486,11 +486,6 @@ int BaseTextEditorWidgetPrivate::visualIndent(const QTextBlock &block) const return 0; } -ITextMarkable *BaseTextEditorWidget::markableInterface() const -{ - return baseTextDocument()->documentMarker(); -} - BaseTextEditor *BaseTextEditorWidget::editor() const { if (!d->m_editor) { diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index 6994a90e97..9ce78d7783 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -148,7 +148,6 @@ public: void convertPosition(int pos, int *line, int *column) const; BaseTextEditor *editor() const; - ITextMarkable *markableInterface() const; void print(QPrinter *); @@ -624,8 +623,6 @@ public: QString selectedText() const; - ITextMarkable *markableInterface() { return m_editorWidget->markableInterface(); } - QString contextHelpId() const; // from IContext // ITextEditor diff --git a/src/plugins/texteditor/basetextmark.cpp b/src/plugins/texteditor/basetextmark.cpp index dd5832a7bb..f0f045dd4a 100644 --- a/src/plugins/texteditor/basetextmark.cpp +++ b/src/plugins/texteditor/basetextmark.cpp @@ -60,14 +60,11 @@ void BaseTextMarkRegistry::add(BaseTextMark *mark) { m_marks[FileName::fromString(mark->fileName())].insert(mark); DocumentModel *documentModel = EditorManager::documentModel(); - IDocument *document = documentModel->documentForFilePath(mark->fileName()); + ITextEditorDocument *document + = qobject_cast(documentModel->documentForFilePath(mark->fileName())); if (!document) return; - // TODO: markableInterface should be moved to ITextEditorDocument - if (ITextEditor *textEditor - = qobject_cast(documentModel->editorsForDocument(document).first())) { - textEditor->markableInterface()->addMark(mark); - } + document->markableInterface()->addMark(mark); } bool BaseTextMarkRegistry::remove(BaseTextMark *mark) @@ -77,16 +74,14 @@ bool BaseTextMarkRegistry::remove(BaseTextMark *mark) void BaseTextMarkRegistry::editorOpened(Core::IEditor *editor) { - ITextEditor *textEditor = qobject_cast(editor); - if (!textEditor) + ITextEditorDocument *document = qobject_cast(editor ? editor->document() : 0); + if (!document) return; - if (!m_marks.contains(FileName::fromString(editor->document()->filePath()))) + if (!m_marks.contains(FileName::fromString(document->filePath()))) return; - foreach (BaseTextMark *mark, m_marks.value(FileName::fromString(editor->document()->filePath()))) { - ITextMarkable *markableInterface = textEditor->markableInterface(); - markableInterface->addMark(mark); - } + foreach (BaseTextMark *mark, m_marks.value(FileName::fromString(document->filePath()))) + document->markableInterface()->addMark(mark); } void BaseTextMarkRegistry::documentRenamed(IDocument *document, const @@ -102,7 +97,7 @@ void BaseTextMarkRegistry::documentRenamed(IDocument *document, const return; QSet toBeMoved; - foreach (ITextMark *mark, baseTextDocument->documentMarker()->marks()) + foreach (ITextMark *mark, baseTextDocument->markableInterface()->marks()) if (BaseTextMark *baseTextMark = dynamic_cast(mark)) toBeMoved.insert(baseTextMark); diff --git a/src/plugins/texteditor/itexteditor.h b/src/plugins/texteditor/itexteditor.h index 3a85676d60..a3ac48bd48 100644 --- a/src/plugins/texteditor/itexteditor.h +++ b/src/plugins/texteditor/itexteditor.h @@ -84,6 +84,8 @@ public: virtual QString plainText() const = 0; virtual QString textAt(int pos, int length) const = 0; virtual QChar characterAt(int pos) const = 0; + + virtual ITextMarkable *markableInterface() const = 0; }; class TEXTEDITOR_EXPORT ITextEditor : public Core::IEditor @@ -126,8 +128,6 @@ public: /*! Selects text between current cursor position and \a toPos. */ virtual void select(int toPos) = 0; - virtual ITextMarkable *markableInterface() = 0; - virtual const Utils::CommentDefinition* commentDefinition() const = 0; static QMap openedTextDocumentContents(); -- cgit v1.2.1