From a4e23025f0ae34ca3f96474b28aefd51a668b8ad Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sun, 19 Mar 2017 19:57:04 +0200 Subject: TextEditor: Complete transition to Qt5-style connects Change-Id: I78c84254a5ea56b5f9a478b6e1c9b4ed58937687 Reviewed-by: Tobias Hunger --- src/plugins/texteditor/syntaxhighlighter.cpp | 32 ++++++++++++++-------------- src/plugins/texteditor/syntaxhighlighter.h | 7 +++--- src/plugins/texteditor/texteditor.h | 4 +--- 3 files changed, 21 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/plugins/texteditor/syntaxhighlighter.cpp b/src/plugins/texteditor/syntaxhighlighter.cpp index 2c625f0303..e038ecf4f8 100644 --- a/src/plugins/texteditor/syntaxhighlighter.cpp +++ b/src/plugins/texteditor/syntaxhighlighter.cpp @@ -51,7 +51,6 @@ public: QPointer doc; - void _q_reformatBlocks(int from, int charsRemoved, int charsAdded); void reformatBlocks(int from, int charsRemoved, int charsAdded); void reformatBlock(const QTextBlock &block, int from, int charsRemoved, int charsAdded); @@ -63,13 +62,6 @@ public: inReformatBlocks = false; } - inline void _q_delayedRehighlight() { - if (!rehighlightPending) - return; - rehighlightPending = false; - q_func()->rehighlight(); - } - void applyFormatChanges(int from, int charsRemoved, int charsAdded); void updateFormatsForCategories(const FontSettings &fontSettings); @@ -94,6 +86,15 @@ static bool adjustRange(QTextLayout::FormatRange &range, int from, int charsRemo return false; } +void SyntaxHighlighter::delayedRehighlight() +{ + Q_D(SyntaxHighlighter); + if (!d->rehighlightPending) + return; + d->rehighlightPending = false; + rehighlight(); +} + void SyntaxHighlighterPrivate::applyFormatChanges(int from, int charsRemoved, int charsAdded) { bool formatsChanged = false; @@ -172,10 +173,11 @@ void SyntaxHighlighterPrivate::applyFormatChanges(int from, int charsRemoved, in } } -void SyntaxHighlighterPrivate::_q_reformatBlocks(int from, int charsRemoved, int charsAdded) +void SyntaxHighlighter::reformatBlocks(int from, int charsRemoved, int charsAdded) { - if (!inReformatBlocks) - reformatBlocks(from, charsRemoved, charsAdded); + Q_D(SyntaxHighlighter); + if (!d->inReformatBlocks) + d->reformatBlocks(from, charsRemoved, charsAdded); } void SyntaxHighlighterPrivate::reformatBlocks(int from, int charsRemoved, int charsAdded) @@ -310,8 +312,7 @@ void SyntaxHighlighter::setDocument(QTextDocument *doc) { Q_D(SyntaxHighlighter); if (d->doc) { - disconnect(d->doc, SIGNAL(contentsChange(int,int,int)), - this, SLOT(_q_reformatBlocks(int,int,int))); + disconnect(d->doc, &QTextDocument::contentsChange, this, &SyntaxHighlighter::reformatBlocks); QTextCursor cursor(d->doc); cursor.beginEditBlock(); @@ -321,10 +322,9 @@ void SyntaxHighlighter::setDocument(QTextDocument *doc) } d->doc = doc; if (d->doc) { - connect(d->doc, SIGNAL(contentsChange(int,int,int)), - this, SLOT(_q_reformatBlocks(int,int,int))); + connect(d->doc, &QTextDocument::contentsChange, this, &SyntaxHighlighter::reformatBlocks); d->rehighlightPending = true; - QTimer::singleShot(0, this, SLOT(_q_delayedRehighlight())); + QTimer::singleShot(0, this, &SyntaxHighlighter::delayedRehighlight); d->foldValidator.setup(qobject_cast(doc->documentLayout())); } } diff --git a/src/plugins/texteditor/syntaxhighlighter.h b/src/plugins/texteditor/syntaxhighlighter.h index 32593134d1..064c5aaa77 100644 --- a/src/plugins/texteditor/syntaxhighlighter.h +++ b/src/plugins/texteditor/syntaxhighlighter.h @@ -64,7 +64,8 @@ public: // Don't call in constructors of derived classes virtual void setFontSettings(const TextEditor::FontSettings &fontSettings); -public Q_SLOTS: + +public slots: void rehighlight(); void rehighlightBlock(const QTextBlock &block); @@ -90,8 +91,8 @@ protected: QTextBlock currentBlock() const; private: - Q_PRIVATE_SLOT(d_ptr, void _q_reformatBlocks(int from, int charsRemoved, int charsAdded)) - Q_PRIVATE_SLOT(d_ptr, void _q_delayedRehighlight()) + void reformatBlocks(int from, int charsRemoved, int charsAdded); + void delayedRehighlight(); QScopedPointer d_ptr; }; diff --git a/src/plugins/texteditor/texteditor.h b/src/plugins/texteditor/texteditor.h index 880df92b44..d4caffc0f6 100644 --- a/src/plugins/texteditor/texteditor.h +++ b/src/plugins/texteditor/texteditor.h @@ -340,7 +340,6 @@ public: virtual void encourageApply(); -public slots: // Qt4-style connect used in EditorConfiguration virtual void setDisplaySettings(const TextEditor::DisplaySettings &); virtual void setMarginSettings(const TextEditor::MarginSettings &); void setBehaviorSettings(const TextEditor::BehaviorSettings &); @@ -349,7 +348,6 @@ public slots: // Qt4-style connect used in EditorConfiguration void setCompletionSettings(const TextEditor::CompletionSettings &); void setExtraEncodingSettings(const TextEditor::ExtraEncodingSettings &); -public: void circularPaste(); void switchUtf8bom(); @@ -589,7 +587,7 @@ signals: void tooltipRequested(const QPoint &globalPos, int position); void activateEditor(); -protected slots: +protected: virtual void slotCursorPositionChanged(); // Used in VcsBase virtual void slotCodeStyleSettingsChanged(const QVariant &); // Used in CppEditor -- cgit v1.2.1