Commit cfad9bdc authored by Eike Ziller's avatar Eike Ziller

TextEditors: Move contentsChanged signal from editor to document

Change-Id: Ic935a8971705cb3238deda71aa2b5d19e4f62593
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent ad4b5892
......@@ -1855,8 +1855,8 @@ void CPPEditorWidget::onFunctionDeclDefLinkFound(QSharedPointer<FunctionDeclDefL
Core::IDocument *targetDocument = Core::EditorManager::documentModel()->documentForFilePath(
m_declDefLink->targetFile->fileName());
if (baseTextDocument() != targetDocument) {
if (TextEditor::BaseTextDocument *baseTextDocument = qobject_cast<TextEditor::BaseTextDocument *>(targetDocument))
connect(baseTextDocument->document(), SIGNAL(contentsChanged()),
if (TextEditor::ITextEditorDocument *textEditorDocument = qobject_cast<TextEditor::ITextEditorDocument *>(targetDocument))
connect(textEditorDocument, SIGNAL(contentsChanged()),
this, SLOT(abortDeclDefLink()));
}
......@@ -1884,8 +1884,8 @@ void CPPEditorWidget::abortDeclDefLink()
Core::IDocument *targetDocument = Core::EditorManager::documentModel()->documentForFilePath(
m_declDefLink->targetFile->fileName());
if (baseTextDocument() != targetDocument) {
if (TextEditor::BaseTextDocument *baseTextDocument = qobject_cast<TextEditor::BaseTextDocument *>(targetDocument))
disconnect(baseTextDocument->document(), SIGNAL(contentsChanged()),
if (TextEditor::ITextEditorDocument *textEditorDocument = qobject_cast<TextEditor::ITextEditorDocument *>(targetDocument))
disconnect(textEditorDocument, SIGNAL(contentsChanged()),
this, SLOT(abortDeclDefLink()));
}
......
......@@ -142,7 +142,7 @@ CppEditorSupport::CppEditorSupport(CppModelManager *modelManager, BaseTextEditor
connect(m_updateEditorTimer, SIGNAL(timeout()),
this, SLOT(updateEditorNow()));
connect(m_textEditor, SIGNAL(contentsChanged()), this, SLOT(updateDocument()));
connect(m_textEditor->document(), SIGNAL(contentsChanged()), this, SLOT(updateDocument()));
connect(this, SIGNAL(diagnosticsChanged()), this, SLOT(onDiagnosticsChanged()));
connect(m_textEditor->document(), SIGNAL(mimeTypeChanged()),
......
......@@ -59,7 +59,7 @@ class CppCompletionAssistProvider;
* its document.
*
* The following steps are taken:
* 1. the text editor fires a contentsChanged() signal that triggers updateDocument
* 1. the text editor document fires a contentsChanged() signal that triggers updateDocument
* 2. update document will start a timer, or reset the timer if it was already running. This way
* subsequent updates (e.g. keypresses) get bunched together instead of running the subsequent
* actions for every key press
......
......@@ -311,14 +311,12 @@ void QmlJSEditorPlugin::currentEditorChanged(Core::IEditor *editor)
newTextEditor = qobject_cast<QmlJSTextEditorWidget *>(editor->widget());
if (m_currentEditor) {
disconnect(m_currentEditor.data(), SIGNAL(contentsChanged()),
this, SLOT(checkCurrentEditorSemanticInfoUpToDate()));
disconnect(m_currentEditor.data(), SIGNAL(semanticInfoUpdated()),
this, SLOT(checkCurrentEditorSemanticInfoUpToDate()));
m_currentEditor->baseTextDocument()->disconnect(this);
m_currentEditor->disconnect(this);
}
m_currentEditor = newTextEditor;
if (newTextEditor) {
connect(newTextEditor, SIGNAL(contentsChanged()),
connect(newTextEditor->baseTextDocument(), SIGNAL(contentsChanged()),
this, SLOT(checkCurrentEditorSemanticInfoUpToDate()));
connect(newTextEditor, SIGNAL(semanticInfoUpdated()),
this, SLOT(checkCurrentEditorSemanticInfoUpToDate()));
......
......@@ -84,6 +84,7 @@ BaseTextDocumentPrivate::BaseTextDocumentPrivate(BaseTextDocument *q) :
BaseTextDocument::BaseTextDocument() : d(new BaseTextDocumentPrivate(this))
{
connect(d->m_document, SIGNAL(modificationChanged(bool)), this, SIGNAL(changed()));
connect(d->m_document, SIGNAL(contentsChanged()), this, SIGNAL(contentsChanged()));
// set new document layout
QTextOption opt = d->m_document->defaultTextOption();
......
......@@ -509,8 +509,6 @@ BaseTextEditor *BaseTextEditorWidget::editor() const
if (!d->m_editor) {
d->m_editor = const_cast<BaseTextEditorWidget *>(this)->createEditor();
d->m_codeAssistant->configure(d->m_editor);
connect(this, SIGNAL(textChanged()),
d->m_editor, SIGNAL(contentsChanged()));
}
return d->m_editor;
}
......
......@@ -326,9 +326,6 @@ signals:
void assistFinished();
void readOnlyChanged();
// ITextEditor
void contentsChanged();
protected:
bool event(QEvent *e);
void keyPressEvent(QKeyEvent *e);
......
......@@ -86,6 +86,9 @@ public:
virtual QChar characterAt(int pos) const = 0;
virtual ITextMarkable *markableInterface() const = 0;
signals:
void contentsChanged();
};
class TEXTEDITOR_EXPORT ITextEditor : public Core::IEditor
......@@ -140,7 +143,6 @@ public:
};
signals:
void contentsChanged();
void markRequested(TextEditor::ITextEditor *editor, int line, TextEditor::ITextEditor::MarkRequestKind kind);
void markContextMenuRequested(TextEditor::ITextEditor *editor, int line, QMenu *menu);
void tooltipOverrideRequested(TextEditor::ITextEditor *editor, const QPoint &globalPos, int position, bool *handled);
......
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