diff --git a/src/plugins/cppeditor/cppeditordocument.cpp b/src/plugins/cppeditor/cppeditordocument.cpp index b0583011e00..00ff24aca9b 100644 --- a/src/plugins/cppeditor/cppeditordocument.cpp +++ b/src/plugins/cppeditor/cppeditordocument.cpp @@ -165,8 +165,8 @@ void CppEditorDocument::applyFontSettings() // Clear all additional formats since they may have changed QTextBlock b = document()->firstBlock(); while (b.isValid()) { - QList noFormats; - highlighter->setExtraAdditionalFormats(b, noFormats); + QVector noFormats; + highlighter->setExtraFormats(b, noFormats); b = b.next(); } } diff --git a/src/plugins/projectexplorer/task.h b/src/plugins/projectexplorer/task.h index af8126c40eb..5f059180241 100644 --- a/src/plugins/projectexplorer/task.h +++ b/src/plugins/projectexplorer/task.h @@ -77,7 +77,7 @@ public: // But then again, the wording of the text most likely // doesn't work if you split it up, nor are our parsers // anywhere near being that good - QList formats; + QVector formats; private: void setMark(TextEditor::TextMark *mark); diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp index 79032312e1b..f3820842c30 100644 --- a/src/plugins/projectexplorer/taskwindow.cpp +++ b/src/plugins/projectexplorer/taskwindow.cpp @@ -694,7 +694,7 @@ QSize TaskDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelInd int height = 0; description.replace(QLatin1Char('\n'), QChar::LineSeparator); QTextLayout tl(description); - tl.setAdditionalFormats(index.data(TaskModel::Task_t).value().formats); + tl.setFormats(index.data(TaskModel::Task_t).value().formats); tl.beginLayout(); while (true) { QTextLine line = tl.createLine(); @@ -794,7 +794,7 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, int height = 0; description.replace(QLatin1Char('\n'), QChar::LineSeparator); QTextLayout tl(description); - tl.setAdditionalFormats(index.data(TaskModel::Task_t).value().formats); + tl.setFormats(index.data(TaskModel::Task_t).value().formats); tl.beginLayout(); while (true) { QTextLine line = tl.createLine(); diff --git a/src/plugins/texteditor/semantichighlighter.cpp b/src/plugins/texteditor/semantichighlighter.cpp index 0af085b082b..3e7d7e1fbbd 100644 --- a/src/plugins/texteditor/semantichighlighter.cpp +++ b/src/plugins/texteditor/semantichighlighter.cpp @@ -86,14 +86,14 @@ void SemanticHighlighter::incrementalApplyExtraAdditionalFormats( // clear formats of blocks until blockNumber while (currentBlockNumber < blockNumber) { - QList noFormats; - highlighter->setExtraAdditionalFormats(b, noFormats); + QVector noFormats; + highlighter->setExtraFormats(b, noFormats); b = b.next(); ++currentBlockNumber; } // collect all the formats for the current line - QList formats; + QVector formats; formats.reserve(to - from); forever { QTextLayout::FormatRange formatRange; @@ -113,7 +113,7 @@ void SemanticHighlighter::incrementalApplyExtraAdditionalFormats( if (nextBlockNumber != blockNumber) break; } - highlighter->setExtraAdditionalFormats(b, formats); + highlighter->setExtraFormats(b, formats); b = b.next(); ++currentBlockNumber; } @@ -143,8 +143,8 @@ void SemanticHighlighter::clearExtraAdditionalFormatsUntilEnd( QTextBlock b = doc->findBlockByNumber(firstBlockToClear); while (b.isValid()) { - QList noFormats; - highlighter->setExtraAdditionalFormats(b, noFormats); + QVector noFormats; + highlighter->setExtraFormats(b, noFormats); b = b.next(); } } diff --git a/src/plugins/texteditor/syntaxhighlighter.cpp b/src/plugins/texteditor/syntaxhighlighter.cpp index e26816e914c..2c625f0303a 100644 --- a/src/plugins/texteditor/syntaxhighlighter.cpp +++ b/src/plugins/texteditor/syntaxhighlighter.cpp @@ -100,14 +100,14 @@ void SyntaxHighlighterPrivate::applyFormatChanges(int from, int charsRemoved, in QTextLayout *layout = currentBlock.layout(); - QList ranges = layout->additionalFormats(); + QVector ranges = layout->formats(); bool doAdjustRange = currentBlock.contains(from); - QList old_ranges; + QVector old_ranges; if (!ranges.isEmpty()) { - QList::Iterator it = ranges.begin(); + auto it = ranges.begin(); while (it != ranges.end()) { if (it->format.property(QTextFormat::UserProperty).toBool()) { if (doAdjustRange) @@ -126,7 +126,7 @@ void SyntaxHighlighterPrivate::applyFormatChanges(int from, int charsRemoved, in QTextLayout::FormatRange r; r.start = -1; - QList new_ranges; + QVector new_ranges; int i = 0; while (i < formatChanges.count()) { @@ -167,7 +167,7 @@ void SyntaxHighlighterPrivate::applyFormatChanges(int from, int charsRemoved, in if (formatsChanged) { ranges.append(new_ranges); - layout->setAdditionalFormats(ranges); + layout->setFormats(ranges); doc->markContentsDirty(currentBlock.position(), currentBlock.length()); } } @@ -238,10 +238,10 @@ void SyntaxHighlighterPrivate::reformatBlock(const QTextBlock &block, int from, The SyntaxHighlighter class is a copied and forked version of the QSyntaxHighlighter. There are a couple of binary incompatible changes that prevent doing this directly in Qt. - The main difference from the QSyntaxHighlighter is the addition of setExtraAdditionalFormats. - This method prevents redoing syntax highlighting when setting the additionalFormats on the + The main difference from the QSyntaxHighlighter is the addition of setExtraFormats. + This method prevents redoing syntax highlighting when setting the formats on the layout and subsequently marking the document contents dirty. It thus prevents the redoing of the - semantic highlighting, which sets extra additionalFormats, and so on. + semantic highlighting, which sets extra formats, and so on. Another way to implement the semantic highlighting is to use ExtraSelections on Q(Plain)TextEdit. The drawback of QTextEdit::setExtraSelections is that ExtraSelection uses a @@ -255,7 +255,7 @@ void SyntaxHighlighterPrivate::reformatBlock(const QTextBlock &block, int from, document. This means that every editor needs a highlighter, instead of every document. This could become expensive when multiple editors with the same document are opened. - So, we use AdditionalFormats, because all those highlights should get removed or redone soon + So, we use formats, because all those highlights should get removed or redone soon after the change happens. */ @@ -316,7 +316,7 @@ void SyntaxHighlighter::setDocument(QTextDocument *doc) QTextCursor cursor(d->doc); cursor.beginEditBlock(); for (QTextBlock blk = d->doc->begin(); blk.isValid(); blk = blk.next()) - blk.layout()->clearAdditionalFormats(); + blk.layout()->clearFormats(); cursor.endEditBlock(); } d->doc = doc; @@ -635,10 +635,10 @@ static bool byStartOfRange(const QTextLayout::FormatRange &range, const QTextLay // The formats is passed in by reference in order to prevent unnecessary copying of its items. // After this function returns, the list is modified, and should be considered invalidated! -void SyntaxHighlighter::setExtraAdditionalFormats(const QTextBlock& block, - QList &formats) +void SyntaxHighlighter::setExtraFormats(const QTextBlock &block, + QVector &formats) { -// qDebug() << "setAdditionalFormats() on block" << block.blockNumber(); +// qDebug() << "setFormats() on block" << block.blockNumber(); // qDebug() << " is valid:" << (block.isValid() ? "Yes" : "No"); // qDebug() << " has layout:" << (block.layout() ? "Yes" : "No"); // if (block.layout()) qDebug() << " has text:" << (block.text().isEmpty() ? "No" : "Yes"); @@ -655,9 +655,9 @@ void SyntaxHighlighter::setExtraAdditionalFormats(const QTextBlock& block, Utils::sort(formats, byStartOfRange); - const QList all = block.layout()->additionalFormats(); - QList previousSemanticFormats; - QList formatsToApply; + const QVector all = block.layout()->formats(); + QVector previousSemanticFormats; + QVector formatsToApply; previousSemanticFormats.reserve(all.size()); formatsToApply.reserve(all.size() + formats.size()); @@ -693,7 +693,7 @@ void SyntaxHighlighter::setExtraAdditionalFormats(const QTextBlock& block, bool wasInReformatBlocks = d->inReformatBlocks; d->inReformatBlocks = true; - block.layout()->setAdditionalFormats(formatsToApply); + block.layout()->setFormats(formatsToApply); document()->markContentsDirty(block.position(), blockLength - 1); d->inReformatBlocks = wasInReformatBlocks; } diff --git a/src/plugins/texteditor/syntaxhighlighter.h b/src/plugins/texteditor/syntaxhighlighter.h index 8da2a908c79..32593134d1d 100644 --- a/src/plugins/texteditor/syntaxhighlighter.h +++ b/src/plugins/texteditor/syntaxhighlighter.h @@ -58,7 +58,7 @@ public: void setDocument(QTextDocument *doc); QTextDocument *document() const; - void setExtraAdditionalFormats(const QTextBlock& block, QList &formats); + void setExtraFormats(const QTextBlock &block, QVector &formats); static QList generateColors(int n, const QColor &background); diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 4d22e9115e0..da9b820d4dd 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -867,7 +867,7 @@ void TextEditorWidgetPrivate::print(QPrinter *printer) srcBlock = srcBlock.next(), dstBlock = dstBlock.next()) { - QList formatList = srcBlock.layout()->additionalFormats(); + QVector formatList = srcBlock.layout()->formats(); if (backgroundIsDark) { // adjust syntax highlighting colors for better contrast for (int i = formatList.count() - 1; i >= 0; --i) { @@ -885,7 +885,7 @@ void TextEditorWidgetPrivate::print(QPrinter *printer) } } - dstBlock.layout()->setAdditionalFormats(formatList); + dstBlock.layout()->setFormats(formatList); } QAbstractTextDocumentLayout *layout = doc->documentLayout(); @@ -6775,7 +6775,7 @@ QMimeData *TextEditorWidget::createMimeDataFromSelection() const for (QTextBlock current = start; current.isValid() && current != end; current = current.next()) { if (selectionVisible(current.blockNumber())) { const QTextLayout *layout = current.layout(); - foreach (const QTextLayout::FormatRange &range, layout->additionalFormats()) { + foreach (const QTextLayout::FormatRange &range, layout->formats()) { const int startPosition = current.position() + range.start - selectionStart - removedCount; const int endPosition = startPosition + range.length; if (endPosition <= 0 || startPosition >= endOfDocument - removedCount)