UnifiedDiffEditor: Move polishing selections into working thread

In case of big commit (like 05c35356ab)
polishing selections took about 200 ms. Move this work into
thread to avoid extra 200 ms freeze of GUI thread.

Change-Id: If159e3f0869264f467c4c015f944a3054609f812
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-09-27 13:20:26 +02:00
parent 2f0ec75284
commit e67e2121a7
5 changed files with 27 additions and 19 deletions

View File

@@ -20,14 +20,20 @@ public:
QTextCharFormat *format = nullptr;
};
// block number, list of ranges
// DiffSelection.start - can be -1 (continues from the previous line)
// DiffSelection.end - can be -1 (spans to the end of line, even after the last character in line)
using DiffSelections = QMap<int, QList<DiffSelection>>;
class SelectableTextEditorWidget : public TextEditor::TextEditorWidget
{
Q_OBJECT
public:
SelectableTextEditorWidget(Utils::Id id, QWidget *parent = nullptr);
~SelectableTextEditorWidget() override;
void setSelections(const QMap<int, QList<DiffSelection> > &selections);
void setSelections(const DiffSelections &selections);
static DiffSelections polishedSelections(const DiffSelections &selections);
static void setFoldingIndent(const QTextBlock &block, int indent);
private:
@@ -37,10 +43,7 @@ private:
const QVector<QTextLayout::FormatRange> &selections,
const QRect &clipRect) const override;
// block number, list of ranges
// DiffSelection.start - can be -1 (continues from the previous line)
// DiffSelection.end - can be -1 (spans to the end of line, even after the last character in line)
QMap<int, QList<DiffSelection> > m_diffSelections;
DiffSelections m_diffSelections;
};
} // namespace Internal