aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktextnodeengine.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2018-02-21 10:41:54 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2018-02-26 07:13:18 +0000
commit499ec43937e926e4f2fa57a9baa455fcb3862262 (patch)
tree206c90d47387f8322b68f5e3db613189397e1af3 /src/quick/items/qquicktextnodeengine.cpp
parent53d1e9ed21d25e65a2f13606af479838f5f21fe7 (diff)
use nullptr consistently (clang-tidy)
From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/quick/items/qquicktextnodeengine.cpp')
-rw-r--r--src/quick/items/qquicktextnodeengine.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp
index c179ab7163..a53ca2a2a4 100644
--- a/src/quick/items/qquicktextnodeengine.cpp
+++ b/src/quick/items/qquicktextnodeengine.cpp
@@ -75,7 +75,7 @@ QQuickTextNodeEngine::BinaryTreeNode::BinaryTreeNode(const QGlyphRun &g,
: glyphRun(g)
, boundingRect(brect)
, selectionState(selState)
- , clipNode(0)
+ , clipNode(nullptr)
, decorations(decs)
, color(c)
, backgroundColor(bc)
@@ -256,10 +256,10 @@ void QQuickTextNodeEngine::processCurrentLine()
QVarLengthArray<TextDecoration> pendingOverlines;
QVarLengthArray<TextDecoration> pendingStrikeOuts;
if (!sortedIndexes.isEmpty()) {
- QQuickDefaultClipNode *currentClipNode = m_hasSelection ? new QQuickDefaultClipNode(QRectF()) : 0;
+ QQuickDefaultClipNode *currentClipNode = m_hasSelection ? new QQuickDefaultClipNode(QRectF()) : nullptr;
bool currentClipNodeUsed = false;
for (int i=0; i<=sortedIndexes.size(); ++i) {
- BinaryTreeNode *node = 0;
+ BinaryTreeNode *node = nullptr;
if (i < sortedIndexes.size()) {
int sortedIndex = sortedIndexes.at(i);
Q_ASSERT(sortedIndex < m_currentLineTree.size());
@@ -275,7 +275,7 @@ void QQuickTextNodeEngine::processCurrentLine()
decorationRect.setY(m_position.y() + m_currentLine.y());
decorationRect.setHeight(m_currentLine.height());
- if (node != 0)
+ if (node != nullptr)
decorationRect.setRight(node->boundingRect.left());
TextDecoration textDecoration(currentSelectionState, decorationRect, lastColor);
@@ -295,14 +295,14 @@ void QQuickTextNodeEngine::processCurrentLine()
// If we've reached an unselected node from a selected node, we add the
// selection rect to the graph, and we add decoration every time the
// selection state changes, because that means the text color changes
- if (node == 0 || node->selectionState != currentSelectionState) {
+ if (node == nullptr || node->selectionState != currentSelectionState) {
currentRect.setY(m_position.y() + m_currentLine.y());
currentRect.setHeight(m_currentLine.height());
if (currentSelectionState == Selected)
m_selectionRects.append(currentRect);
- if (currentClipNode != 0) {
+ if (currentClipNode != nullptr) {
if (!currentClipNodeUsed) {
delete currentClipNode;
} else {
@@ -312,13 +312,13 @@ void QQuickTextNodeEngine::processCurrentLine()
}
}
- if (node != 0 && m_hasSelection)
+ if (node != nullptr && m_hasSelection)
currentClipNode = new QQuickDefaultClipNode(QRectF());
else
- currentClipNode = 0;
+ currentClipNode = nullptr;
currentClipNodeUsed = false;
- if (node != 0) {
+ if (node != nullptr) {
currentSelectionState = node->selectionState;
currentRect = node->boundingRect;
@@ -333,7 +333,7 @@ void QQuickTextNodeEngine::processCurrentLine()
currentRect = currentRect.united(node->boundingRect);
}
- if (node != 0) {
+ if (node != nullptr) {
if (node->selectionState == Selected) {
node->clipNode = currentClipNode;
currentClipNodeUsed = true;
@@ -449,7 +449,7 @@ void QQuickTextNodeEngine::addTextObject(const QPointF &position, const QTextCha
QTextFrameFormat::Position layoutPosition)
{
QTextObjectInterface *handler = textDocument->documentLayout()->handlerForObject(format.objectType());
- if (handler != 0) {
+ if (handler != nullptr) {
QImage image;
QSizeF size = handler->intrinsicSize(textDocument, pos, format);
@@ -651,7 +651,7 @@ void QQuickTextNodeEngine::addFrameDecorations(QTextDocument *document, QTextFra
QTextFrameFormat frameFormat = frame->format().toFrameFormat();
QTextTable *table = qobject_cast<QTextTable *>(frame);
- QRectF boundingRect = table == 0
+ QRectF boundingRect = table == nullptr
? documentLayout->frameBoundingRect(frame)
: documentLayout->tableBoundingRect(table);
@@ -674,7 +674,7 @@ void QQuickTextNodeEngine::addFrameDecorations(QTextDocument *document, QTextFra
addBorder(boundingRect.adjusted(frameFormat.leftMargin(), frameFormat.topMargin(),
-frameFormat.rightMargin(), -frameFormat.bottomMargin()),
borderWidth, borderStyle, borderBrush);
- if (table != 0) {
+ if (table != nullptr) {
int rows = table->rows();
int columns = table->columns();
@@ -781,7 +781,7 @@ void QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode *parentNode,
// Add all text with unselected color first
for (int i = 0; i < nodes.size(); ++i) {
const BinaryTreeNode *node = nodes.at(i);
- parentNode->addGlyphs(node->position, node->glyphRun, node->color, style, styleColor, 0);
+ parentNode->addGlyphs(node->position, node->glyphRun, node->color, style, styleColor, nullptr);
}
for (int i = 0; i < imageNodes.size(); ++i) {
@@ -812,7 +812,7 @@ void QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode *parentNode,
for (int i = 0; i < nodes.size(); ++i) {
const BinaryTreeNode *node = nodes.at(i);
QQuickDefaultClipNode *clipNode = node->clipNode;
- if (clipNode != 0 && clipNode->parent() == 0)
+ if (clipNode != nullptr && clipNode->parent() == nullptr)
parentNode->appendChildNode(clipNode);
if (node->selectionState == Selected) {
@@ -820,26 +820,26 @@ void QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode *parentNode,
int previousNodeIndex = i - 1;
int nextNodeIndex = i + 1;
const BinaryTreeNode *previousNode = previousNodeIndex < 0 ? 0 : nodes.at(previousNodeIndex);
- while (previousNode != 0 && qFuzzyCompare(previousNode->boundingRect.left(), node->boundingRect.left()))
+ while (previousNode != nullptr && qFuzzyCompare(previousNode->boundingRect.left(), node->boundingRect.left()))
previousNode = --previousNodeIndex < 0 ? 0 : nodes.at(previousNodeIndex);
const BinaryTreeNode *nextNode = nextNodeIndex == nodes.size() ? 0 : nodes.at(nextNodeIndex);
- if (previousNode != 0 && previousNode->selectionState == Unselected)
+ if (previousNode != nullptr && previousNode->selectionState == Unselected)
parentNode->addGlyphs(previousNode->position, previousNode->glyphRun, color, style, styleColor, clipNode);
- if (nextNode != 0 && nextNode->selectionState == Unselected)
+ if (nextNode != nullptr && nextNode->selectionState == Unselected)
parentNode->addGlyphs(nextNode->position, nextNode->glyphRun, color, style, styleColor, clipNode);
// If the previous or next node completely overlaps this one, then we have already drawn the glyphs of
// this node
bool drawCurrent = false;
- if (previousNode != 0 || nextNode != 0) {
+ if (previousNode != nullptr || nextNode != nullptr) {
for (int i = 0; i < node->ranges.size(); ++i) {
const QPair<int, int> &range = node->ranges.at(i);
int rangeLength = range.second - range.first + 1;
- if (previousNode != 0) {
+ if (previousNode != nullptr) {
for (int j = 0; j < previousNode->ranges.size(); ++j) {
const QPair<int, int> &otherRange = previousNode->ranges.at(j);
@@ -853,7 +853,7 @@ void QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode *parentNode,
}
}
- if (nextNode != 0 && rangeLength > 0) {
+ if (nextNode != nullptr && rangeLength > 0) {
for (int j = 0; j < nextNode->ranges.size(); ++j) {
const QPair<int, int> &otherRange = nextNode->ranges.at(j);
@@ -896,8 +896,8 @@ void QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode *parentNode,
void QQuickTextNodeEngine::mergeFormats(QTextLayout *textLayout, QVarLengthArray<QTextLayout::FormatRange> *mergedFormats)
{
- Q_ASSERT(mergedFormats != 0);
- if (textLayout == 0)
+ Q_ASSERT(mergedFormats != nullptr);
+ if (textLayout == nullptr)
return;
QVector<QTextLayout::FormatRange> additionalFormats = textLayout->formats();
@@ -911,7 +911,7 @@ void QQuickTextNodeEngine::mergeFormats(QTextLayout *textLayout, QVarLengthArray
QTextLayout::FormatRange *lastFormat = mergedFormats->data() + mergedFormats->size() - 1;
if (additionalFormat.start < lastFormat->start + lastFormat->length) {
- QTextLayout::FormatRange *mergedRange = 0;
+ QTextLayout::FormatRange *mergedRange = nullptr;
int length = additionalFormat.length;
if (additionalFormat.start > lastFormat->start) {