diff options
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qcssparser.cpp | 10 | ||||
-rw-r--r-- | src/gui/text/qfont.cpp | 4 | ||||
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 17 | ||||
-rw-r--r-- | src/gui/text/qfontengine.cpp | 3 | ||||
-rw-r--r-- | src/gui/text/qfragmentmap_p.h | 9 | ||||
-rw-r--r-- | src/gui/text/qtextdocument.cpp | 15 | ||||
-rw-r--r-- | src/gui/text/qtextdocument_p.cpp | 21 | ||||
-rw-r--r-- | src/gui/text/qtextdocumentfragment.cpp | 6 | ||||
-rw-r--r-- | src/gui/text/qtextdocumentlayout.cpp | 24 | ||||
-rw-r--r-- | src/gui/text/qtextengine.cpp | 12 | ||||
-rw-r--r-- | src/gui/text/qtextformat.cpp | 9 | ||||
-rw-r--r-- | src/gui/text/qtextformat.h | 4 | ||||
-rw-r--r-- | src/gui/text/qtexthtmlparser.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qtextodfwriter.cpp | 8 | ||||
-rw-r--r-- | src/gui/text/qtexttable.cpp | 20 |
15 files changed, 79 insertions, 85 deletions
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index bb92e6bfba..940de87eee 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -1507,10 +1507,10 @@ QRect Declaration::rectValue() const const QCss::Value &v = d->values.at(0); if (v.type != Value::Function) return QRect(); - QStringList func = v.variant.toStringList(); + const QStringList func = v.variant.toStringList(); if (func.count() != 2 || func.at(0).compare(QLatin1String("rect")) != 0) return QRect(); - QStringList args = func[1].split(QLatin1Char(' '), QString::SkipEmptyParts); + const auto args = func[1].splitRef(QLatin1Char(' '), QString::SkipEmptyParts); if (args.count() != 4) return QRect(); QRect rect(args[0].toInt(), args[1].toInt(), args[2].toInt(), args[3].toInt()); @@ -1653,6 +1653,7 @@ Qt::Alignment Declaration::alignmentValue() const void Declaration::borderImageValue(QString *image, int *cuts, TileMode *h, TileMode *v) const { + const DeclarationData *d = this->d.data(); // make it const and shadow d *image = uriValue(); for (int i = 0; i < 4; i++) cuts[i] = -1; @@ -1914,9 +1915,8 @@ bool StyleSelector::basicSelectorMatches(const BasicSelector &sel, NodePtr node) return false; if (a.valueMatchCriterium == QCss::AttributeSelector::MatchContains) { - - QStringList lst = attrValue.split(QLatin1Char(' ')); - if (!lst.contains(a.value)) + const auto lst = attrValue.splitRef(QLatin1Char(' ')); + if (!lst.contains(QStringRef(&a.value))) return false; } else if ( (a.valueMatchCriterium == QCss::AttributeSelector::MatchEqual diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index f92e4ab457..828dbc318c 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2033,7 +2033,7 @@ uint qHash(const QFont &font, uint seed) Q_DECL_NOTHROW */ bool QFont::fromString(const QString &descrip) { - QStringList l(descrip.split(QLatin1Char(','))); + const auto l = descrip.splitRef(QLatin1Char(',')); int count = l.count(); if (!count || (count > 2 && count < 9) || count > 11) { @@ -2042,7 +2042,7 @@ bool QFont::fromString(const QString &descrip) return false; } - setFamily(l[0]); + setFamily(l[0].toString()); if (count > 1 && l[1].toDouble() > 0.0) setPointSizeF(l[1].toDouble()); if (count == 9) { diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index e4c9b45dc2..cdfcdec80c 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -697,25 +697,20 @@ static QStringList familyList(const QFontDef &req) if (req.family.isEmpty()) return family_list; - QStringList list = req.family.split(QLatin1Char(',')); + const auto list = req.family.splitRef(QLatin1Char(',')); const int numFamilies = list.size(); family_list.reserve(numFamilies); for (int i = 0; i < numFamilies; ++i) { - QString str = list.at(i).trimmed(); + QStringRef str = list.at(i).trimmed(); if ((str.startsWith(QLatin1Char('"')) && str.endsWith(QLatin1Char('"'))) || (str.startsWith(QLatin1Char('\'')) && str.endsWith(QLatin1Char('\'')))) str = str.mid(1, str.length() - 2); - family_list << str; + family_list << str.toString(); } // append the substitute list for each family in family_list - QStringList subs_list; - QStringList::ConstIterator it = family_list.constBegin(), end = family_list.constEnd(); - for (; it != end; ++it) - subs_list += QFont::substitutes(*it); -// qDebug() << "adding substs: " << subs_list; - - family_list += subs_list; + for (int i = 0, size = family_list.size(); i < size; ++i) + family_list += QFont::substitutes(family_list.at(i)); return family_list; } @@ -2737,8 +2732,6 @@ void QFontDatabase::load(const QFontPrivate *d, int script) } if (req.pointSize < 0) req.pointSize = req.pixelSize*72.0/d->dpi; - if (req.weight == 0) - req.weight = QFont::Normal; if (req.stretch == 0) req.stretch = 100; diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 16c654dcb7..adc8f634dc 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1833,8 +1833,7 @@ QFontEngine *QFontEngineMulti::loadEngine(int at) request.family = fallbackFamilyAt(at - 1); if (QFontEngine *engine = QFontDatabase::findFont(request, m_script)) { - if (request.weight > QFont::Normal) - engine->fontDef.weight = request.weight; + engine->fontDef.weight = request.weight; if (request.style > QFont::StyleNormal) engine->fontDef.style = request.style; return engine; diff --git a/src/gui/text/qfragmentmap_p.h b/src/gui/text/qfragmentmap_p.h index 4cf17aadc7..b54d7261d0 100644 --- a/src/gui/text/qfragmentmap_p.h +++ b/src/gui/text/qfragmentmap_p.h @@ -255,14 +255,11 @@ uint QFragmentMapData<Fragment>::createFragment() uint freePos = head->freelist; if (freePos == head->allocated) { // need to create some free space - if (freePos >= uint(MaxAllocSize) / fragmentSize) - qBadAlloc(); - uint needed = qAllocMore((freePos+1)*fragmentSize, 0); - Q_ASSERT(needed/fragmentSize > head->allocated); - Fragment *newFragments = (Fragment *)realloc(fragments, needed); + auto blockInfo = qCalculateGrowingBlockSize(freePos + 1, fragmentSize); + Fragment *newFragments = (Fragment *)realloc(fragments, blockInfo.size); Q_CHECK_PTR(newFragments); fragments = newFragments; - head->allocated = needed/fragmentSize; + head->allocated = quint32(blockInfo.elementCount); F(freePos).right = 0; } diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 8e4fa8a730..a3dbf455cf 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -2430,7 +2430,7 @@ bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format) html += QLatin1Char(';'); attributesEmitted = true; } else { - html.chop(qstrlen(decorationTag.latin1())); + html.chop(decorationTag.size()); } if (format.foreground() != defaultCharFormat.foreground() @@ -2665,7 +2665,7 @@ void QTextHtmlExporter::emitFragment(const QTextFragment &fragment) if (attributesEmitted) html += QLatin1String("\">"); else - html.chop(qstrlen(styleTag.latin1())); + html.chop(styleTag.size()); if (isObject) { for (int i = 0; isImage && i < txt.length(); ++i) { @@ -2700,13 +2700,8 @@ void QTextHtmlExporter::emitFragment(const QTextFragment &fragment) // split for [\n{LineSeparator}] QString forcedLineBreakRegExp = QString::fromLatin1("[\\na]"); forcedLineBreakRegExp[3] = QChar::LineSeparator; - - const QStringList lines = txt.split(QRegExp(forcedLineBreakRegExp)); - for (int i = 0; i < lines.count(); ++i) { - if (i > 0) - html += QLatin1String("<br />"); // space on purpose for compatibility with Netscape, Lynx & Co. - html += lines.at(i); - } + // space in BR on purpose for compatibility with old-fashioned browsers + html += txt.replace(QRegExp(forcedLineBreakRegExp), QLatin1String("<br />")); } if (attributesEmitted) @@ -3227,7 +3222,7 @@ void QTextHtmlExporter::emitFrameStyle(const QTextFrameFormat &format, FrameType QString::number(format.rightMargin())); if (html.length() == originalHtmlLength) // nothing emitted? - html.chop(qstrlen(styleAttribute.latin1())); + html.chop(styleAttribute.size()); else html += QLatin1Char('\"'); } diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index df0d52d8e9..3537adba9e 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -1006,9 +1006,9 @@ int QTextDocumentPrivate::undoRedo(bool undo) bool inBlock = ( undoState > 0 && undoState < undoStack.size() - && undoStack[undoState].block_part - && undoStack[undoState-1].block_part - && !undoStack[undoState-1].block_end + && undoStack.at(undoState).block_part + && undoStack.at(undoState - 1).block_part + && !undoStack.at(undoState - 1).block_end ); if (!inBlock) break; @@ -1074,13 +1074,14 @@ void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c) if (!undoStack.isEmpty() && modified) { - QTextUndoCommand &last = undoStack[undoState - 1]; + const int lastIdx = undoState - 1; + const QTextUndoCommand &last = undoStack.at(lastIdx); if ( (last.block_part && c.block_part && !last.block_end) // part of the same block => can merge || (!c.block_part && !last.block_part) // two single undo items => can merge || (c.command == QTextUndoCommand::Inserted && last.command == c.command && (last.block_part && !c.block_part))) { // two sequential inserts that are not part of the same block => can merge - if (last.tryMerge(c)) + if (undoStack[lastIdx].tryMerge(c)) return; } } @@ -1102,7 +1103,7 @@ void QTextDocumentPrivate::clearUndoRedoStacks(QTextDocument::Stacks stacksToCle bool redoCommandsAvailable = undoState != undoStack.size(); if (stacksToClear == QTextDocument::UndoStack && undoCommandsAvailable) { for (int i = 0; i < undoState; ++i) { - QTextUndoCommand c = undoStack[undoState]; + QTextUndoCommand c = undoStack.at(undoState); if (c.command & QTextUndoCommand::Custom) delete c.custom; } @@ -1114,7 +1115,7 @@ void QTextDocumentPrivate::clearUndoRedoStacks(QTextDocument::Stacks stacksToCle } else if (stacksToClear == QTextDocument::RedoStack && redoCommandsAvailable) { for (int i = undoState; i < undoStack.size(); ++i) { - QTextUndoCommand c = undoStack[i]; + QTextUndoCommand c = undoStack.at(i); if (c.command & QTextUndoCommand::Custom) delete c.custom; } @@ -1124,7 +1125,7 @@ void QTextDocumentPrivate::clearUndoRedoStacks(QTextDocument::Stacks stacksToCle } else if (stacksToClear == QTextDocument::UndoAndRedoStacks && !undoStack.isEmpty()) { for (int i = 0; i < undoStack.size(); ++i) { - QTextUndoCommand c = undoStack[i]; + QTextUndoCommand c = undoStack.at(i); if (c.command & QTextUndoCommand::Custom) delete c.custom; } @@ -1187,8 +1188,8 @@ void QTextDocumentPrivate::endEditBlock() return; if (undoEnabled && undoState > 0) { - const bool wasBlocking = !undoStack[undoState - 1].block_end; - if (undoStack[undoState - 1].block_part) { + const bool wasBlocking = !undoStack.at(undoState - 1).block_end; + if (undoStack.at(undoState - 1).block_part) { undoStack[undoState - 1].block_end = true; if (wasBlocking) emit document()->undoCommandAdded(); diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp index f8f4e454e0..a1a562c839 100644 --- a/src/gui/text/qtextdocumentfragment.cpp +++ b/src/gui/text/qtextdocumentfragment.cpp @@ -882,7 +882,7 @@ QTextHtmlImporter::Table QTextHtmlImporter::scanTable(int tableNodeIdx) if (at(cell).isTableCell()) { // skip all columns with spans from previous rows while (colsInRow < rowColSpanForColumn.size()) { - const RowColSpanInfo &spanInfo = rowColSpanForColumn[colsInRow]; + const RowColSpanInfo &spanInfo = rowColSpanForColumn.at(colsInRow); if (spanInfo.row + spanInfo.rowSpan > effectiveRow) { Q_ASSERT(spanInfo.col == colsInRow); @@ -1081,8 +1081,8 @@ QTextHtmlImporter::ProcessNodeResult QTextHtmlImporter::processBlockNode() && indent != 0 && (lists.isEmpty() || !hasBlock - || !lists.last().list - || lists.last().list->itemNumber(cursor.block()) == -1 + || !lists.constLast().list + || lists.constLast().list->itemNumber(cursor.block()) == -1 ) ) { block.setIndent(indent); diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index 1b2113d281..0c8904b4c5 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -265,7 +265,7 @@ void QTextTableData::updateTableSize() const QFixed effectiveLeftMargin = this->leftMargin + border + padding; const QFixed effectiveRightMargin = this->rightMargin + border + padding; size.height = contentsHeight == -1 - ? rowPositions.last() + heights.last() + padding + border + cellSpacing + effectiveBottomMargin + ? rowPositions.constLast() + heights.constLast() + padding + border + cellSpacing + effectiveBottomMargin : effectiveTopMargin + contentsHeight + effectiveBottomMargin; size.width = effectiveLeftMargin + contentsWidth + effectiveRightMargin; } @@ -1238,7 +1238,7 @@ void QTextDocumentLayoutPrivate::drawFlow(const QPointF &offset, QPainter *paint // if we're past what is already laid out then we're better off // not trying to draw things that may not be positioned correctly yet - if (currentPosInDoc >= checkPoints.last().positionInFrame) + if (currentPosInDoc >= checkPoints.constLast().positionInFrame) break; if (lastVisibleCheckPoint != checkPoints.end() @@ -1798,7 +1798,7 @@ recalc_minmax_widths: td->columnPositions[i] = td->columnPositions.at(i-1) + td->widths.at(i-1) + 2 * td->border + cellSpacing; // - margin to compensate the + margin in columnPositions[0] - const QFixed contentsWidth = td->columnPositions.last() + td->widths.last() + td->padding + td->border + cellSpacing - leftMargin; + const QFixed contentsWidth = td->columnPositions.constLast() + td->widths.constLast() + td->padding + td->border + cellSpacing - leftMargin; // if the table is too big and causes an overflow re-do the layout with WrapAnywhere as wrap // mode @@ -1845,14 +1845,14 @@ recalc_minmax_widths: td->calcRowPosition(r); const int tableStartPage = (absoluteTableY / pageHeight).truncate(); - const int currentPage = ((td->rowPositions[r] + absoluteTableY) / pageHeight).truncate(); + const int currentPage = ((td->rowPositions.at(r) + absoluteTableY) / pageHeight).truncate(); const QFixed pageBottom = (currentPage + 1) * pageHeight - td->effectiveBottomMargin - absoluteTableY - cellSpacing - td->border; const QFixed pageTop = currentPage * pageHeight + td->effectiveTopMargin - absoluteTableY + cellSpacing + td->border; const QFixed nextPageTop = pageTop + pageHeight; - if (td->rowPositions[r] > pageBottom) + if (td->rowPositions.at(r) > pageBottom) td->rowPositions[r] = nextPageTop; - else if (td->rowPositions[r] < pageTop) + else if (td->rowPositions.at(r) < pageTop) td->rowPositions[r] = pageTop; bool dropRowToNextPage = true; @@ -1863,7 +1863,7 @@ recalc_minmax_widths: QFixed dropDistance = 0; relayout: - const int rowStartPage = ((td->rowPositions[r] + absoluteTableY) / pageHeight).truncate(); + const int rowStartPage = ((td->rowPositions.at(r) + absoluteTableY) / pageHeight).truncate(); // if any of the header rows or the first non-header row start on the next page // then the entire header should be dropped if (r <= headerRowCount && rowStartPage > tableStartPage && !hasDroppedTable) { @@ -1927,13 +1927,13 @@ relayout: } if (rowCellCount > 0 && dropRowToNextPage) { - dropDistance = nextPageTop - td->rowPositions[r]; + dropDistance = nextPageTop - td->rowPositions.at(r); td->rowPositions[r] = nextPageTop; td->heights[r] = 0; dropRowToNextPage = false; cellHeights.resize(cellCountBeforeRow); if (r > headerRowCount) - td->heights[r-1] = pageBottom - td->rowPositions[r-1]; + td->heights[r - 1] = pageBottom - td->rowPositions.at(r - 1); goto relayout; } @@ -1944,7 +1944,7 @@ relayout: } if (r == headerRowCount - 1) { - td->headerHeight = td->rowPositions[r] + td->heights[r] - td->rowPositions[0] + td->cellSpacing + 2 * td->border; + td->headerHeight = td->rowPositions.at(r) + td->heights.at(r) - td->rowPositions.at(0) + td->cellSpacing + 2 * td->border; td->headerHeight -= td->headerHeight * (td->headerHeight / pageHeight).truncate(); td->effectiveTopMargin += td->headerHeight; } @@ -2304,7 +2304,7 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout docPos = it.currentBlock().position(); if (inRootFrame) { - if (qAbs(layoutStruct->y - checkPoints.last().y) > 2000) { + if (qAbs(layoutStruct->y - checkPoints.constLast().y) > 2000) { QFixed left, right; floatMargins(layoutStruct->y, layoutStruct, &left, &right); if (left == layoutStruct->x_left && right == layoutStruct->x_right) { @@ -2554,7 +2554,7 @@ void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayout checkPoints.append(cp); checkPoints.reserve(checkPoints.size()); } else { - currentLazyLayoutPosition = checkPoints.last().positionInFrame; + currentLazyLayoutPosition = checkPoints.constLast().positionInFrame; // ####### //checkPoints.last().positionInFrame = q->document()->docHandle()->length(); } diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 6be84c0186..d11f8c34b1 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1643,8 +1643,14 @@ void QTextEngine::itemize() const if (analysis->bidiLevel % 2) --analysis->bidiLevel; analysis->flags = QScriptAnalysis::LineOrParagraphSeparator; - if (option.flags() & QTextOption::ShowLineAndParagraphSeparators) + if (option.flags() & QTextOption::ShowLineAndParagraphSeparators) { + const int offset = uc - string; + layoutData->string.detach(); + string = reinterpret_cast<const ushort *>(layoutData->string.unicode()); + uc = string + offset; + e = uc + length; *const_cast<ushort*>(uc) = 0x21B5; // visual line separator + } break; case QChar::Tabulation: analysis->flags = QScriptAnalysis::Tab; @@ -3272,7 +3278,7 @@ int QTextEngine::endOfLine(int lineNum) insertionPointsForLine(lineNum, insertionPoints); if (insertionPoints.size() > 0) - return insertionPoints.last(); + return insertionPoints.constLast(); return 0; } @@ -3282,7 +3288,7 @@ int QTextEngine::beginningOfLine(int lineNum) insertionPointsForLine(lineNum, insertionPoints); if (insertionPoints.size() > 0) - return insertionPoints.first(); + return insertionPoints.constFirst(); return 0; } diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index 49ec9ca768..2109b15a85 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -364,9 +364,10 @@ void QTextFormatPrivate::recalcFont() const f.setPixelSize(props.at(i).value.toInt()); break; case QTextFormat::FontWeight: { - int weight = props.at(i).value.toInt(); - if (weight == 0) weight = QFont::Normal; - f.setWeight(weight); + const QVariant weightValue = props.at(i).value; + int weight = weightValue.toInt(); + if (weight >= 0 && weightValue.isValid()) + f.setWeight(weight); break; } case QTextFormat::FontItalic: f.setItalic(props.at(i).value.toBool()); @@ -3462,7 +3463,7 @@ void QTextFormatCollection::setDefaultFont(const QFont &f) { defaultFnt = f; for (int i = 0; i < formats.count(); ++i) - if (formats[i].d) + if (formats.at(i).d) formats[i].d->resolveFont(defaultFnt); } diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h index bc627521ff..805affd87c 100644 --- a/src/gui/text/qtextformat.h +++ b/src/gui/text/qtextformat.h @@ -431,9 +431,9 @@ public: { return doubleProperty(FontPointSize); } inline void setFontWeight(int weight) - { if (weight == QFont::Normal) weight = 0; setProperty(FontWeight, weight); } + { setProperty(FontWeight, weight); } inline int fontWeight() const - { int weight = intProperty(FontWeight); if (weight == 0) weight = QFont::Normal; return weight; } + { return hasProperty(FontWeight) ? intProperty(FontWeight) : QFont::Normal; } inline void setFontItalic(bool italic) { setProperty(FontItalic, italic); } inline bool fontItalic() const diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index 576ff7d935..103a208c26 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -665,7 +665,7 @@ void QTextHtmlParser::parseTag() if (hasPrefix(QLatin1Char('/'))) { if (nodes.last().id == Html_style) { #ifndef QT_NO_CSSPARSER - QCss::Parser parser(nodes.last().text); + QCss::Parser parser(nodes.constLast().text); QCss::StyleSheet sheet; sheet.origin = QCss::StyleSheetOrigin_Author; parser.parse(&sheet, Qt::CaseInsensitive); diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index f7741bad2c..73d2e545ba 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -812,10 +812,10 @@ bool QTextOdfWriter::writeAll() } // add objects for lists, frames and tables - QVector<QTextFormat> allFormats = m_document->allFormats(); - QList<int> copy = formats.toList(); - for (QList<int>::Iterator iter = copy.begin(); iter != copy.end(); ++iter) { - QTextObject *object = m_document->objectForFormat(allFormats[*iter]); + const QVector<QTextFormat> allFormats = m_document->allFormats(); + const QList<int> copy = formats.toList(); + for (auto index : copy) { + QTextObject *object = m_document->objectForFormat(allFormats[index]); if (object) formats << object->formatIndex(); } diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index 2d5636e1d9..e4a3c2b915 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -824,7 +824,7 @@ void QTextTable::insertColumns(int pos, int num) QVector<QTextLength> columnWidths = tfmt.columnWidthConstraints(); if (! columnWidths.isEmpty()) { for (int i = num; i > 0; --i) - columnWidths.insert(pos, columnWidths[qMax(0, pos-1)]); + columnWidths.insert(pos, columnWidths.at(qMax(0, pos - 1))); } tfmt.setColumnWidthConstraints (columnWidths); QTextObject::setFormat(tfmt); @@ -1046,11 +1046,12 @@ void QTextTable::mergeCells(int row, int column, int numRows, int numCols) // find the position at which to insert the contents of the merged cells QFragmentFindHelper helper(origCellPosition, p->fragmentMap()); - const auto it = std::lower_bound(d->cells.begin(), d->cells.end(), helper); + const auto begin = d->cells.cbegin(); + const auto it = std::lower_bound(begin, d->cells.cend(), helper); Q_ASSERT(it != d->cells.end()); Q_ASSERT(!(helper < *it)); Q_ASSERT(*it == cellFragment); - const int insertCellIndex = it - d->cells.begin(); + const int insertCellIndex = it - begin; int insertFragment = d->cells.value(insertCellIndex + 1, d->fragment_end); uint insertPos = p->fragmentMap().position(insertFragment); @@ -1079,11 +1080,12 @@ void QTextTable::mergeCells(int row, int column, int numRows, int numCols) if (firstCellIndex == -1) { QFragmentFindHelper helper(pos, p->fragmentMap()); - const auto it = std::lower_bound(d->cells.begin(), d->cells.end(), helper); + const auto begin = d->cells.cbegin(); + const auto it = std::lower_bound(begin, d->cells.cend(), helper); Q_ASSERT(it != d->cells.end()); Q_ASSERT(!(helper < *it)); Q_ASSERT(*it == fragment); - firstCellIndex = cellIndex = it - d->cells.begin(); + firstCellIndex = cellIndex = it - begin; } ++cellIndex; @@ -1136,7 +1138,7 @@ void QTextTable::mergeCells(int row, int column, int numRows, int numCols) } } - d->fragment_start = d->cells.first(); + d->fragment_start = d->cells.constFirst(); fmt.setTableCellRowSpan(numRows); fmt.setTableCellColumnSpan(numCols); @@ -1212,9 +1214,9 @@ void QTextTable::splitCell(int row, int column, int numRows, int numCols) for (int r = row + 1; r < row + rowSpan; ++r) { // find the cell before which to insert the new cell markers int gridIndex = r * d->nCols + column; - QVector<int>::iterator it = std::upper_bound(d->cellIndices.begin(), d->cellIndices.end(), gridIndex); - int cellIndex = it - d->cellIndices.begin(); - int fragment = d->cells.value(cellIndex, d->fragment_end); + const auto begin = d->cellIndices.cbegin(); + const auto it = std::upper_bound(begin, d->cellIndices.cend(), gridIndex); + int fragment = d->cells.value(it - begin, d->fragment_end); rowPositions[r - row] = p->fragmentMap().position(fragment); } |