Commit 18313bdb authored by Eike Ziller's avatar Eike Ziller

Move markableInterface() to ITextEditorDocument

And remove the indirection over BaseTextEditorWidget.

Change-Id: I2c570edf46b9ca72a11704ce27d8ae3f2218dcf0
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent 890f7216
......@@ -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);
}
}
......
......@@ -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<QPlainTextEdit *>(d->editor->widget());
QTC_ASSERT(plainTextEdit, return);
QTextCursor tc = plainTextEdit->textCursor();
......
......@@ -195,7 +195,7 @@ SyntaxHighlighter *BaseTextDocument::syntaxHighlighter() const
return d->m_highlighter;
}
ITextMarkable *BaseTextDocument::documentMarker() const
ITextMarkable *BaseTextDocument::markableInterface() const
{
BaseTextDocumentLayout *documentLayout =
qobject_cast<BaseTextDocumentLayout *>(d->m_document->documentLayout());
......
......@@ -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);
......
......@@ -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) {
......
......@@ -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
......
......@@ -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<ITextEditorDocument*>(documentModel->documentForFilePath(mark->fileName()));
if (!document)
return;
// TODO: markableInterface should be moved to ITextEditorDocument
if (ITextEditor *textEditor
= qobject_cast<ITextEditor *>(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<ITextEditor *>(editor);
if (!textEditor)
ITextEditorDocument *document = qobject_cast<ITextEditorDocument *>(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<BaseTextMark *> toBeMoved;
foreach (ITextMark *mark, baseTextDocument->documentMarker()->marks())
foreach (ITextMark *mark, baseTextDocument->markableInterface()->marks())
if (BaseTextMark *baseTextMark = dynamic_cast<BaseTextMark *>(mark))
toBeMoved.insert(baseTextMark);
......
......@@ -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<QString, QString> openedTextDocumentContents();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment