Commit 03eb2f97 authored by hjk's avatar hjk
Browse files

TextEditor: Configure code assistant properly in new scheme



No need for the extra indirection here.

Change-Id: I21a303423ba52724551cca0bc82d4e4b08ab4e52
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent 87afa472
...@@ -382,7 +382,7 @@ public: ...@@ -382,7 +382,7 @@ public:
BaseTextEditorPrivateHighlightBlocks m_highlightBlocksInfo; BaseTextEditorPrivateHighlightBlocks m_highlightBlocksInfo;
QTimer m_highlightBlocksTimer; QTimer m_highlightBlocksTimer;
QScopedPointer<CodeAssistant> m_codeAssistant; CodeAssistant m_codeAssistant;
bool m_assistRelevantContentAdded; bool m_assistRelevantContentAdded;
QPointer<BaseTextEditorAnimator> m_animator; QPointer<BaseTextEditorAnimator> m_animator;
...@@ -443,7 +443,6 @@ BaseTextEditorWidgetPrivate::BaseTextEditorWidgetPrivate(BaseTextEditorWidget *p ...@@ -443,7 +443,6 @@ BaseTextEditorWidgetPrivate::BaseTextEditorWidgetPrivate(BaseTextEditorWidget *p
m_findScopeVerticalBlockSelectionFirstColumn(-1), m_findScopeVerticalBlockSelectionFirstColumn(-1),
m_findScopeVerticalBlockSelectionLastColumn(-1), m_findScopeVerticalBlockSelectionLastColumn(-1),
m_highlightBlocksTimer(0), m_highlightBlocksTimer(0),
m_codeAssistant(new CodeAssistant),
m_assistRelevantContentAdded(false), m_assistRelevantContentAdded(false),
m_cursorBlockNumber(-1), m_cursorBlockNumber(-1),
m_blockCount(0), m_blockCount(0),
...@@ -600,7 +599,7 @@ void BaseTextEditorWidgetPrivate::ctor(const QSharedPointer<BaseTextDocument> &d ...@@ -600,7 +599,7 @@ void BaseTextEditorWidgetPrivate::ctor(const QSharedPointer<BaseTextDocument> &d
visibleFoldedBlockNumber = -1; visibleFoldedBlockNumber = -1;
suggestedVisibleFoldedBlockNumber = -1; suggestedVisibleFoldedBlockNumber = -1;
QObject::connect(m_codeAssistant.data(), &CodeAssistant::finished, QObject::connect(&m_codeAssistant, &CodeAssistant::finished,
q, &BaseTextEditorWidget::assistFinished); q, &BaseTextEditorWidget::assistFinished);
QObject::connect(q, &QPlainTextEdit::blockCountChanged, QObject::connect(q, &QPlainTextEdit::blockCountChanged,
...@@ -881,12 +880,11 @@ BaseTextEditor *BaseTextEditorWidget::editor() const ...@@ -881,12 +880,11 @@ BaseTextEditor *BaseTextEditorWidget::editor() const
d->m_editor = that->createEditor(); d->m_editor = that->createEditor();
if (!d->m_editor->m_widget) if (!d->m_editor->m_widget)
d->m_editor->setEditorWidget(that); d->m_editor->setEditorWidget(that);
d->m_codeAssistant->configure(d->m_editor); d->m_codeAssistant.configure(d->m_editor);
} }
return d->m_editor; return d->m_editor;
} }
void BaseTextEditorWidget::selectEncoding() void BaseTextEditorWidget::selectEncoding()
{ {
BaseTextDocument *doc = d->m_document.data(); BaseTextDocument *doc = d->m_document.data();
...@@ -1442,7 +1440,7 @@ void BaseTextEditorWidget::openLinkUnderCursorInNextSplit() ...@@ -1442,7 +1440,7 @@ void BaseTextEditorWidget::openLinkUnderCursorInNextSplit()
void BaseTextEditorWidget::abortAssist() void BaseTextEditorWidget::abortAssist()
{ {
d->m_codeAssistant->destroyContext(); d->m_codeAssistant.destroyContext();
} }
void BaseTextEditorWidgetPrivate::moveLineUpDown(bool up) void BaseTextEditorWidgetPrivate::moveLineUpDown(bool up)
...@@ -2343,7 +2341,7 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e) ...@@ -2343,7 +2341,7 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
d->m_parenthesesMatchingTimer.start(50); d->m_parenthesesMatchingTimer.start(50);
if (!ro && d->m_contentsChanged && isPrintableText(eventText) && !inOverwriteMode) if (!ro && d->m_contentsChanged && isPrintableText(eventText) && !inOverwriteMode)
d->m_codeAssistant->process(); d->m_codeAssistant.process();
} }
void BaseTextEditorWidget::insertCodeSnippet(const QTextCursor &cursor_arg, const QString &snippet) void BaseTextEditorWidget::insertCodeSnippet(const QTextCursor &cursor_arg, const QString &snippet)
...@@ -6392,8 +6390,8 @@ void BaseTextEditorWidget::insertFromMimeData(const QMimeData *source) ...@@ -6392,8 +6390,8 @@ void BaseTextEditorWidget::insertFromMimeData(const QMimeData *source)
if (text.isEmpty()) if (text.isEmpty())
return; return;
if (d->m_codeAssistant->hasContext()) if (d->m_codeAssistant.hasContext())
d->m_codeAssistant->destroyContext(); d->m_codeAssistant.destroyContext();
if (d->m_inBlockSelectionMode) { if (d->m_inBlockSelectionMode) {
d->insertIntoBlockSelection(text); d->insertIntoBlockSelection(text);
...@@ -7036,7 +7034,7 @@ void BaseTextEditorWidget::invokeAssist(AssistKind kind, IAssistProvider *provid ...@@ -7036,7 +7034,7 @@ void BaseTextEditorWidget::invokeAssist(AssistKind kind, IAssistProvider *provid
bool previousMode = overwriteMode(); bool previousMode = overwriteMode();
setOverwriteMode(false); setOverwriteMode(false);
ensureCursorVisible(); ensureCursorVisible();
d->m_codeAssistant->invoke(kind, provider); d->m_codeAssistant.invoke(kind, provider);
setOverwriteMode(previousMode); setOverwriteMode(previousMode);
} }
...@@ -7197,6 +7195,7 @@ BaseTextEditorWidget *BaseTextEditor::ensureWidget() const ...@@ -7197,6 +7195,7 @@ BaseTextEditorWidget *BaseTextEditor::ensureWidget() const
auto that = const_cast<BaseTextEditor *>(this); auto that = const_cast<BaseTextEditor *>(this);
widget->d->m_editor = that; widget->d->m_editor = that;
that->m_widget = widget; that->m_widget = widget;
widget->d->m_codeAssistant.configure(that);
} }
return editorWidget(); return editorWidget();
} }
......
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