forked from qt-creator/qt-creator
TextEditor: Complete transition to Qt5-style connects
Change-Id: I78c84254a5ea56b5f9a478b6e1c9b4ed58937687 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
0170e10af1
commit
a4e23025f0
@@ -51,7 +51,6 @@ public:
|
||||
|
||||
QPointer<QTextDocument> 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<TextDocumentLayout *>(doc->documentLayout()));
|
||||
}
|
||||
}
|
||||
|
@@ -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<SyntaxHighlighterPrivate> d_ptr;
|
||||
};
|
||||
|
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user