| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquicktextnodeengine_p.h |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | - | |||||||
| 5 | - | |||||||
| 6 | - | |||||||
| 7 | class QQuickTextNodeEngine { | - | ||||||
| 8 | public: | - | ||||||
| 9 | enum Decoration { | - | ||||||
| 10 | NoDecoration = 0x0, | - | ||||||
| 11 | Underline = 0x1, | - | ||||||
| 12 | Overline = 0x2, | - | ||||||
| 13 | StrikeOut = 0x4, | - | ||||||
| 14 | Background = 0x8 | - | ||||||
| 15 | }; | - | ||||||
| 16 | typedef QFlags<Decoration> Decorations; | - | ||||||
| 17 | - | |||||||
| 18 | enum SelectionState { | - | ||||||
| 19 | Unselected, | - | ||||||
| 20 | Selected | - | ||||||
| 21 | }; | - | ||||||
| 22 | - | |||||||
| 23 | struct BinaryTreeNode { | - | ||||||
| 24 | - | |||||||
| 25 | BinaryTreeNode() | - | ||||||
| 26 | : selectionState(Unselected), clipNode(0), decorations(Decoration::NoDecoration) | - | ||||||
| 27 | , ascent(0.0), leftChildIndex(-1), rightChildIndex(-1) | - | ||||||
| 28 | { | - | ||||||
| 29 | } never executed: end of block | 0 | ||||||
| 30 | - | |||||||
| 31 | BinaryTreeNode(const QRectF &brect, const QImage &i, SelectionState selState, qreal a) | - | ||||||
| 32 | : boundingRect(brect), selectionState(selState), clipNode(0), decorations(Decoration::NoDecoration) | - | ||||||
| 33 | , image(i), ascent(a), leftChildIndex(-1), rightChildIndex(-1) | - | ||||||
| 34 | { | - | ||||||
| 35 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||
| 36 | - | |||||||
| 37 | BinaryTreeNode(const QGlyphRun &g, SelectionState selState, const QRectF &brect, | - | ||||||
| 38 | const Decorations &decs, const QColor &c, const QColor &bc, | - | ||||||
| 39 | const QPointF &pos, qreal a); | - | ||||||
| 40 | - | |||||||
| 41 | QGlyphRun glyphRun; | - | ||||||
| 42 | QRectF boundingRect; | - | ||||||
| 43 | SelectionState selectionState; | - | ||||||
| 44 | QQuickDefaultClipNode *clipNode; | - | ||||||
| 45 | Decorations decorations; | - | ||||||
| 46 | QColor color; | - | ||||||
| 47 | QColor backgroundColor; | - | ||||||
| 48 | QPointF position; | - | ||||||
| 49 | QImage image; | - | ||||||
| 50 | qreal ascent; | - | ||||||
| 51 | - | |||||||
| 52 | int leftChildIndex; | - | ||||||
| 53 | int rightChildIndex; | - | ||||||
| 54 | - | |||||||
| 55 | QList<QPair<int, int> > ranges; | - | ||||||
| 56 | - | |||||||
| 57 | static void insert(QVarLengthArray<BinaryTreeNode, 16> *binaryTree, const QRectF &rect, const QImage &image, qreal ascent, SelectionState selectionState) | - | ||||||
| 58 | { insert(binaryTree, BinaryTreeNode(rect, image, selectionState, ascent)); } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||
| 59 | - | |||||||
| 60 | static void insert(QVarLengthArray<BinaryTreeNode, 16> *binaryTree, const QGlyphRun &glyphRun, SelectionState selectionState, | - | ||||||
| 61 | Decorations decorations, const QColor &textColor, const QColor &backgroundColor, const QPointF &position); | - | ||||||
| 62 | static void insert(QVarLengthArray<BinaryTreeNode, 16> *binaryTree, const BinaryTreeNode &binaryTreeNode); | - | ||||||
| 63 | static void inOrder(const QVarLengthArray<BinaryTreeNode, 16> &binaryTree, QVarLengthArray<int> *sortedIndexes, int currentIndex = 0); | - | ||||||
| 64 | }; | - | ||||||
| 65 | - | |||||||
| 66 | struct BinaryTreeNodeKey | - | ||||||
| 67 | { | - | ||||||
| 68 | BinaryTreeNodeKey(BinaryTreeNode *node); | - | ||||||
| 69 | - | |||||||
| 70 | bool operator==(const BinaryTreeNodeKey &otherKey) const | - | ||||||
| 71 | { | - | ||||||
| 72 | return executed 250924 times by 24 tests: fontEngine == otherKey.fontEnginereturn fontEngine == otherKey.fontEngine && clipNode == otherKey.clipNode && color == otherKey.color && selectionState == otherKey.selectionState;Executed by:
executed 250924 times by 24 tests: return fontEngine == otherKey.fontEngine && clipNode == otherKey.clipNode && color == otherKey.color && selectionState == otherKey.selectionState;Executed by:
| 250924 | ||||||
| 73 | && clipNode == otherKey.clipNode executed 250924 times by 24 tests: return fontEngine == otherKey.fontEngine && clipNode == otherKey.clipNode && color == otherKey.color && selectionState == otherKey.selectionState;Executed by:
| 250924 | ||||||
| 74 | && color == otherKey.color executed 250924 times by 24 tests: return fontEngine == otherKey.fontEngine && clipNode == otherKey.clipNode && color == otherKey.color && selectionState == otherKey.selectionState;Executed by:
| 250924 | ||||||
| 75 | && selectionState == otherKey.selectionState; executed 250924 times by 24 tests: return fontEngine == otherKey.fontEngine && clipNode == otherKey.clipNode && color == otherKey.color && selectionState == otherKey.selectionState;Executed by:
| 250924 | ||||||
| 76 | } | - | ||||||
| 77 | - | |||||||
| 78 | QFontEngine *fontEngine; | - | ||||||
| 79 | QQuickDefaultClipNode *clipNode; | - | ||||||
| 80 | QRgb color; | - | ||||||
| 81 | int selectionState; | - | ||||||
| 82 | }; | - | ||||||
| 83 | - | |||||||
| 84 | QQuickTextNodeEngine() | - | ||||||
| 85 | : m_currentTextDirection(Qt::LeftToRight) | - | ||||||
| 86 | , m_hasSelection(false) | - | ||||||
| 87 | , m_hasContents(false) | - | ||||||
| 88 | {} executed 250225 times by 24 tests: end of blockExecuted by:
| 250225 | ||||||
| 89 | - | |||||||
| 90 | bool hasContents() const { return executed 562 times by 4 tests: m_hasContents;return m_hasContents;Executed by:
executed 562 times by 4 tests: }return m_hasContents;Executed by:
| 562 | ||||||
| 91 | void addTextBlock(QTextDocument *, const QTextBlock &, const QPointF &position, const QColor &textColor, const QColor& anchorColor, int selectionStart, int selectionEnd); | - | ||||||
| 92 | QTextLine currentLine() const { return executed 954 times by 5 tests: m_currentLine;return m_currentLine;Executed by:
executed 954 times by 5 tests: }return m_currentLine;Executed by:
| 954 | ||||||
| 93 | - | |||||||
| 94 | void setCurrentLine(const QTextLine ¤tLine) | - | ||||||
| 95 | { | - | ||||||
| 96 | if (m_currentLine.isValid()
| 2213-249113 | ||||||
| 97 | processCurrentLine(); executed 2213 times by 7 tests: processCurrentLine();Executed by:
| 2213 | ||||||
| 98 | - | |||||||
| 99 | m_currentLine = currentLine; | - | ||||||
| 100 | } executed 251326 times by 24 tests: end of blockExecuted by:
| 251326 | ||||||
| 101 | - | |||||||
| 102 | void setCurrentTextDirection(Qt::LayoutDirection textDirection) | - | ||||||
| 103 | { | - | ||||||
| 104 | m_currentTextDirection = textDirection; | - | ||||||
| 105 | } executed 670 times by 5 tests: end of blockExecuted by:
| 670 | ||||||
| 106 | - | |||||||
| 107 | void addBorder(const QRectF &rect, qreal border, QTextFrameFormat::BorderStyle borderStyle, | - | ||||||
| 108 | const QBrush &borderBrush); | - | ||||||
| 109 | void addFrameDecorations(QTextDocument *document, QTextFrame *frame); | - | ||||||
| 110 | void addImage(const QRectF &rect, const QImage &image, qreal ascent, | - | ||||||
| 111 | SelectionState selectionState, | - | ||||||
| 112 | QTextFrameFormat::Position layoutPosition); | - | ||||||
| 113 | int addText(const QTextBlock &block, | - | ||||||
| 114 | const QTextCharFormat &charFormat, | - | ||||||
| 115 | const QColor &textColor, | - | ||||||
| 116 | const QVarLengthArray<QTextLayout::FormatRange> &colorChanges, | - | ||||||
| 117 | int textPos, int fragmentEnd, | - | ||||||
| 118 | int selectionStart, int selectionEnd); | - | ||||||
| 119 | void addTextObject(const QPointF &position, const QTextCharFormat &format, | - | ||||||
| 120 | SelectionState selectionState, | - | ||||||
| 121 | QTextDocument *textDocument, int pos, | - | ||||||
| 122 | QTextFrameFormat::Position layoutPosition = QTextFrameFormat::InFlow); | - | ||||||
| 123 | void addSelectedGlyphs(const QGlyphRun &glyphRun); | - | ||||||
| 124 | void addUnselectedGlyphs(const QGlyphRun &glyphRun); | - | ||||||
| 125 | void addGlyphsInRange(int rangeStart, int rangeEnd, | - | ||||||
| 126 | const QColor &color, const QColor &backgroundColor, | - | ||||||
| 127 | int selectionStart, int selectionEnd); | - | ||||||
| 128 | void addGlyphsForRanges(const QVarLengthArray<QTextLayout::FormatRange> &ranges, | - | ||||||
| 129 | int start, int end, | - | ||||||
| 130 | int selectionStart, int selectionEnd); | - | ||||||
| 131 | - | |||||||
| 132 | void mergeProcessedNodes(QList<BinaryTreeNode *> *regularNodes, | - | ||||||
| 133 | QList<BinaryTreeNode *> *imageNodes); | - | ||||||
| 134 | void addToSceneGraph(QQuickTextNode *parent, | - | ||||||
| 135 | QQuickText::TextStyle style = QQuickText::Normal, | - | ||||||
| 136 | const QColor &styleColor = QColor()); | - | ||||||
| 137 | - | |||||||
| 138 | void setSelectionColor(const QColor &selectionColor) | - | ||||||
| 139 | { | - | ||||||
| 140 | m_selectionColor = selectionColor; | - | ||||||
| 141 | } executed 249381 times by 24 tests: end of blockExecuted by:
| 249381 | ||||||
| 142 | - | |||||||
| 143 | void setSelectedTextColor(const QColor &selectedTextColor) | - | ||||||
| 144 | { | - | ||||||
| 145 | m_selectedTextColor = selectedTextColor; | - | ||||||
| 146 | } executed 249381 times by 24 tests: end of blockExecuted by:
| 249381 | ||||||
| 147 | - | |||||||
| 148 | void setTextColor(const QColor &textColor) | - | ||||||
| 149 | { | - | ||||||
| 150 | m_textColor = textColor; | - | ||||||
| 151 | } executed 250521 times by 24 tests: end of blockExecuted by:
| 250521 | ||||||
| 152 | - | |||||||
| 153 | void setAnchorColor(const QColor &anchorColor) | - | ||||||
| 154 | { | - | ||||||
| 155 | m_anchorColor = anchorColor; | - | ||||||
| 156 | } executed 248527 times by 24 tests: end of blockExecuted by:
| 248527 | ||||||
| 157 | - | |||||||
| 158 | void setPosition(const QPointF &position) | - | ||||||
| 159 | { | - | ||||||
| 160 | m_position = position; | - | ||||||
| 161 | } executed 249151 times by 24 tests: end of blockExecuted by:
| 249151 | ||||||
| 162 | - | |||||||
| 163 | - | |||||||
| 164 | - | |||||||
| 165 | - | |||||||
| 166 | private: | - | ||||||
| 167 | struct TextDecoration | - | ||||||
| 168 | { | - | ||||||
| 169 | TextDecoration() : selectionState(Unselected) {} never executed: end of block | 0 | ||||||
| 170 | TextDecoration(const SelectionState &s, | - | ||||||
| 171 | const QRectF &r, | - | ||||||
| 172 | const QColor &c) | - | ||||||
| 173 | : selectionState(s) | - | ||||||
| 174 | , rect(r) | - | ||||||
| 175 | , color(c) | - | ||||||
| 176 | { | - | ||||||
| 177 | } executed 40 times by 3 tests: end of blockExecuted by:
| 40 | ||||||
| 178 | - | |||||||
| 179 | SelectionState selectionState; | - | ||||||
| 180 | QRectF rect; | - | ||||||
| 181 | QColor color; | - | ||||||
| 182 | }; | - | ||||||
| 183 | - | |||||||
| 184 | void processCurrentLine(); | - | ||||||
| 185 | void addTextDecorations(const QVarLengthArray<TextDecoration> &textDecorations, qreal offset, qreal thickness); | - | ||||||
| 186 | void mergeFormats(QTextLayout *textLayout, QVarLengthArray<QTextLayout::FormatRange> *mergedFormats); | - | ||||||
| 187 | - | |||||||
| 188 | QColor m_selectionColor; | - | ||||||
| 189 | QColor m_textColor; | - | ||||||
| 190 | QColor m_backgroundColor; | - | ||||||
| 191 | QColor m_selectedTextColor; | - | ||||||
| 192 | QColor m_anchorColor; | - | ||||||
| 193 | QPointF m_position; | - | ||||||
| 194 | - | |||||||
| 195 | QTextLine m_currentLine; | - | ||||||
| 196 | Qt::LayoutDirection m_currentTextDirection; | - | ||||||
| 197 | - | |||||||
| 198 | QList<QPair<QRectF, QColor> > m_backgrounds; | - | ||||||
| 199 | QList<QRectF> m_selectionRects; | - | ||||||
| 200 | QVarLengthArray<BinaryTreeNode, 16> m_currentLineTree; | - | ||||||
| 201 | - | |||||||
| 202 | QList<TextDecoration> m_lines; | - | ||||||
| 203 | QVector<BinaryTreeNode> m_processedNodes; | - | ||||||
| 204 | - | |||||||
| 205 | bool m_hasSelection : 1; | - | ||||||
| 206 | bool m_hasContents : 1; | - | ||||||
| 207 | friend class QQuickTextNode; | - | ||||||
| 208 | - | |||||||
| 209 | }; | - | ||||||
| 210 | - | |||||||
| 211 | - | |||||||
| Switch to Source code | Preprocessed file |