| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/text/qtextcursor.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | enum { | - | ||||||||||||||||||||||||
| 6 | AdjustPrev = 0x1, | - | ||||||||||||||||||||||||
| 7 | AdjustUp = 0x3, | - | ||||||||||||||||||||||||
| 8 | AdjustNext = 0x4, | - | ||||||||||||||||||||||||
| 9 | AdjustDown = 0x12 | - | ||||||||||||||||||||||||
| 10 | }; | - | ||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | QTextCursorPrivate::QTextCursorPrivate(QTextDocumentPrivate *p) | - | ||||||||||||||||||||||||
| 13 | : priv(p), x(0), position(0), anchor(0), adjusted_anchor(0), | - | ||||||||||||||||||||||||
| 14 | currentCharFormat(-1), visualNavigation(false), keepPositionOnInsert(false), | - | ||||||||||||||||||||||||
| 15 | changed(false) | - | ||||||||||||||||||||||||
| 16 | { | - | ||||||||||||||||||||||||
| 17 | priv->addCursor(this); | - | ||||||||||||||||||||||||
| 18 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 19 | - | |||||||||||||||||||||||||
| 20 | QTextCursorPrivate::QTextCursorPrivate(const QTextCursorPrivate &rhs) | - | ||||||||||||||||||||||||
| 21 | : QSharedData(rhs) | - | ||||||||||||||||||||||||
| 22 | { | - | ||||||||||||||||||||||||
| 23 | position = rhs.position; | - | ||||||||||||||||||||||||
| 24 | anchor = rhs.anchor; | - | ||||||||||||||||||||||||
| 25 | adjusted_anchor = rhs.adjusted_anchor; | - | ||||||||||||||||||||||||
| 26 | priv = rhs.priv; | - | ||||||||||||||||||||||||
| 27 | x = rhs.x; | - | ||||||||||||||||||||||||
| 28 | currentCharFormat = rhs.currentCharFormat; | - | ||||||||||||||||||||||||
| 29 | visualNavigation = rhs.visualNavigation; | - | ||||||||||||||||||||||||
| 30 | keepPositionOnInsert = rhs.keepPositionOnInsert; | - | ||||||||||||||||||||||||
| 31 | changed = rhs.changed; | - | ||||||||||||||||||||||||
| 32 | priv->addCursor(this); | - | ||||||||||||||||||||||||
| 33 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 34 | - | |||||||||||||||||||||||||
| 35 | QTextCursorPrivate::~QTextCursorPrivate() | - | ||||||||||||||||||||||||
| 36 | { | - | ||||||||||||||||||||||||
| 37 | if (priv
| 0 | ||||||||||||||||||||||||
| 38 | priv->removeCursor(this); never executed: priv->removeCursor(this); | 0 | ||||||||||||||||||||||||
| 39 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 40 | - | |||||||||||||||||||||||||
| 41 | QTextCursorPrivate::AdjustResult QTextCursorPrivate::adjustPosition(int positionOfChange, int charsAddedOrRemoved, QTextUndoCommand::Operation op) | - | ||||||||||||||||||||||||
| 42 | { | - | ||||||||||||||||||||||||
| 43 | QTextCursorPrivate::AdjustResult result = QTextCursorPrivate::CursorMoved; | - | ||||||||||||||||||||||||
| 44 | - | |||||||||||||||||||||||||
| 45 | if (position < positionOfChange
| 0 | ||||||||||||||||||||||||
| 46 | || (position == positionOfChange
| 0 | ||||||||||||||||||||||||
| 47 | && (op == QTextUndoCommand::KeepCursor
| 0 | ||||||||||||||||||||||||
| 48 | || keepPositionOnInsert
| 0 | ||||||||||||||||||||||||
| 49 | ) | - | ||||||||||||||||||||||||
| 50 | ) { | - | ||||||||||||||||||||||||
| 51 | result = CursorUnchanged; | - | ||||||||||||||||||||||||
| 52 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 53 | if (charsAddedOrRemoved < 0
| 0 | ||||||||||||||||||||||||
| 54 | position = positionOfChange; never executed: position = positionOfChange; | 0 | ||||||||||||||||||||||||
| 55 | else | - | ||||||||||||||||||||||||
| 56 | position += charsAddedOrRemoved; never executed: position += charsAddedOrRemoved; | 0 | ||||||||||||||||||||||||
| 57 | - | |||||||||||||||||||||||||
| 58 | currentCharFormat = -1; | - | ||||||||||||||||||||||||
| 59 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||
| 61 | if (anchor >= positionOfChange
| 0 | ||||||||||||||||||||||||
| 62 | && (anchor != positionOfChange
| 0 | ||||||||||||||||||||||||
| 63 | if (charsAddedOrRemoved < 0
| 0 | ||||||||||||||||||||||||
| 64 | anchor = positionOfChange; never executed: anchor = positionOfChange; | 0 | ||||||||||||||||||||||||
| 65 | else | - | ||||||||||||||||||||||||
| 66 | anchor += charsAddedOrRemoved; never executed: anchor += charsAddedOrRemoved; | 0 | ||||||||||||||||||||||||
| 67 | } | - | ||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||
| 69 | if (adjusted_anchor >= positionOfChange
| 0 | ||||||||||||||||||||||||
| 70 | && (adjusted_anchor != positionOfChange
| 0 | ||||||||||||||||||||||||
| 71 | if (charsAddedOrRemoved < 0
| 0 | ||||||||||||||||||||||||
| 72 | adjusted_anchor = positionOfChange; never executed: adjusted_anchor = positionOfChange; | 0 | ||||||||||||||||||||||||
| 73 | else | - | ||||||||||||||||||||||||
| 74 | adjusted_anchor += charsAddedOrRemoved; never executed: adjusted_anchor += charsAddedOrRemoved; | 0 | ||||||||||||||||||||||||
| 75 | } | - | ||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||
| 77 | return never executed: result;return result;never executed: return result; | 0 | ||||||||||||||||||||||||
| 78 | } | - | ||||||||||||||||||||||||
| 79 | - | |||||||||||||||||||||||||
| 80 | void QTextCursorPrivate::setX() | - | ||||||||||||||||||||||||
| 81 | { | - | ||||||||||||||||||||||||
| 82 | if (priv->isInEditBlock()
| 0 | ||||||||||||||||||||||||
| 83 | x = -1; | - | ||||||||||||||||||||||||
| 84 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 85 | } | - | ||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||
| 87 | QTextBlock block = this->block(); | - | ||||||||||||||||||||||||
| 88 | const QTextLayout *layout = blockLayout(block); | - | ||||||||||||||||||||||||
| 89 | int pos = position - block.position(); | - | ||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||
| 91 | QTextLine line = layout->lineForTextPosition(pos); | - | ||||||||||||||||||||||||
| 92 | if (line.isValid()
| 0 | ||||||||||||||||||||||||
| 93 | x = line.cursorToX(pos); never executed: x = line.cursorToX(pos); | 0 | ||||||||||||||||||||||||
| 94 | else | - | ||||||||||||||||||||||||
| 95 | x = -1; never executed: x = -1; | 0 | ||||||||||||||||||||||||
| 96 | } | - | ||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | void QTextCursorPrivate::remove() | - | ||||||||||||||||||||||||
| 99 | { | - | ||||||||||||||||||||||||
| 100 | if (anchor == position
| 0 | ||||||||||||||||||||||||
| 101 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 102 | currentCharFormat = -1; | - | ||||||||||||||||||||||||
| 103 | int pos1 = position; | - | ||||||||||||||||||||||||
| 104 | int pos2 = adjusted_anchor; | - | ||||||||||||||||||||||||
| 105 | QTextUndoCommand::Operation op = QTextUndoCommand::KeepCursor; | - | ||||||||||||||||||||||||
| 106 | if (pos1 > pos2
| 0 | ||||||||||||||||||||||||
| 107 | pos1 = adjusted_anchor; | - | ||||||||||||||||||||||||
| 108 | pos2 = position; | - | ||||||||||||||||||||||||
| 109 | op = QTextUndoCommand::MoveCursor; | - | ||||||||||||||||||||||||
| 110 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||
| 112 | - | |||||||||||||||||||||||||
| 113 | QTextTable *table = complexSelectionTable(); | - | ||||||||||||||||||||||||
| 114 | if (table
| 0 | ||||||||||||||||||||||||
| 115 | priv->beginEditBlock(); | - | ||||||||||||||||||||||||
| 116 | int startRow, startCol, numRows, numCols; | - | ||||||||||||||||||||||||
| 117 | selectedTableCells(&startRow, &numRows, &startCol, &numCols); | - | ||||||||||||||||||||||||
| 118 | clearCells(table, startRow, startCol, numRows, numCols, op); | - | ||||||||||||||||||||||||
| 119 | adjusted_anchor = anchor = position; | - | ||||||||||||||||||||||||
| 120 | priv->endEditBlock(); | - | ||||||||||||||||||||||||
| 121 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 122 | priv->remove(pos1, pos2-pos1, op); | - | ||||||||||||||||||||||||
| 123 | adjusted_anchor = anchor = position; | - | ||||||||||||||||||||||||
| 124 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 125 | - | |||||||||||||||||||||||||
| 126 | } | - | ||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||
| 128 | void QTextCursorPrivate::clearCells(QTextTable *table, int startRow, int startCol, int numRows, int numCols, QTextUndoCommand::Operation op) | - | ||||||||||||||||||||||||
| 129 | { | - | ||||||||||||||||||||||||
| 130 | priv->beginEditBlock(); | - | ||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||
| 132 | for (int row = startRow; row < startRow + numRows
| 0 | ||||||||||||||||||||||||
| 133 | for (int col = startCol; col < startCol + numCols
| 0 | ||||||||||||||||||||||||
| 134 | QTextTableCell cell = table->cellAt(row, col); | - | ||||||||||||||||||||||||
| 135 | const int startPos = cell.firstPosition(); | - | ||||||||||||||||||||||||
| 136 | const int endPos = cell.lastPosition(); | - | ||||||||||||||||||||||||
| 137 | ((!(startPos <= endPos)) ? qt_assert("startPos <= endPos",__FILE__,188) : qt_noop()); | - | ||||||||||||||||||||||||
| 138 | priv->remove(startPos, endPos - startPos, op); | - | ||||||||||||||||||||||||
| 139 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 140 | - | |||||||||||||||||||||||||
| 141 | priv->endEditBlock(); | - | ||||||||||||||||||||||||
| 142 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 143 | - | |||||||||||||||||||||||||
| 144 | bool QTextCursorPrivate::canDelete(int pos) const | - | ||||||||||||||||||||||||
| 145 | { | - | ||||||||||||||||||||||||
| 146 | QTextDocumentPrivate::FragmentIterator fit = priv->find(pos); | - | ||||||||||||||||||||||||
| 147 | QTextCharFormat fmt = priv->formatCollection()->charFormat((*fit)->format); | - | ||||||||||||||||||||||||
| 148 | return never executed: (fmt.objectIndex() == -1 || fmt.objectType() == QTextFormat::ImageObject);return (fmt.objectIndex() == -1 || fmt.objectType() == QTextFormat::ImageObject);never executed: return (fmt.objectIndex() == -1 || fmt.objectType() == QTextFormat::ImageObject); | 0 | ||||||||||||||||||||||||
| 149 | } | - | ||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||
| 151 | void QTextCursorPrivate::insertBlock(const QTextBlockFormat &format, const QTextCharFormat &charFormat) | - | ||||||||||||||||||||||||
| 152 | { | - | ||||||||||||||||||||||||
| 153 | QTextFormatCollection *formats = priv->formatCollection(); | - | ||||||||||||||||||||||||
| 154 | int idx = formats->indexForFormat(format); | - | ||||||||||||||||||||||||
| 155 | ((!(formats->format(idx).isBlockFormat())) ? qt_assert("formats->format(idx).isBlockFormat()",__FILE__,206) : qt_noop()); | - | ||||||||||||||||||||||||
| 156 | - | |||||||||||||||||||||||||
| 157 | priv->insertBlock(position, idx, formats->indexForFormat(charFormat)); | - | ||||||||||||||||||||||||
| 158 | currentCharFormat = -1; | - | ||||||||||||||||||||||||
| 159 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||
| 161 | void QTextCursorPrivate::adjustCursor(QTextCursor::MoveOperation m) | - | ||||||||||||||||||||||||
| 162 | { | - | ||||||||||||||||||||||||
| 163 | adjusted_anchor = anchor; | - | ||||||||||||||||||||||||
| 164 | if (position == anchor
| 0 | ||||||||||||||||||||||||
| 165 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 166 | - | |||||||||||||||||||||||||
| 167 | QTextFrame *f_position = priv->frameAt(position); | - | ||||||||||||||||||||||||
| 168 | QTextFrame *f_anchor = priv->frameAt(adjusted_anchor); | - | ||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||
| 170 | if (f_position != f_anchor
| 0 | ||||||||||||||||||||||||
| 171 | - | |||||||||||||||||||||||||
| 172 | QList<QTextFrame *> positionChain; | - | ||||||||||||||||||||||||
| 173 | QList<QTextFrame *> anchorChain; | - | ||||||||||||||||||||||||
| 174 | QTextFrame *f = f_position; | - | ||||||||||||||||||||||||
| 175 | while (f
| 0 | ||||||||||||||||||||||||
| 176 | positionChain.prepend(f); | - | ||||||||||||||||||||||||
| 177 | f = f->parentFrame(); | - | ||||||||||||||||||||||||
| 178 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 179 | f = f_anchor; | - | ||||||||||||||||||||||||
| 180 | while (f
| 0 | ||||||||||||||||||||||||
| 181 | anchorChain.prepend(f); | - | ||||||||||||||||||||||||
| 182 | f = f->parentFrame(); | - | ||||||||||||||||||||||||
| 183 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 184 | ((!(positionChain.at(0) == anchorChain.at(0))) ? qt_assert("positionChain.at(0) == anchorChain.at(0)",__FILE__,235) : qt_noop()); | - | ||||||||||||||||||||||||
| 185 | int i = 1; | - | ||||||||||||||||||||||||
| 186 | int l = qMin(positionChain.size(), anchorChain.size()); | - | ||||||||||||||||||||||||
| 187 | for (; i < l
| 0 | ||||||||||||||||||||||||
| 188 | if (positionChain.at(i) != anchorChain.at(i)
| 0 | ||||||||||||||||||||||||
| 189 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 190 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 191 | - | |||||||||||||||||||||||||
| 192 | if (m <= QTextCursor::WordLeft
| 0 | ||||||||||||||||||||||||
| 193 | if (i < positionChain.size()
| 0 | ||||||||||||||||||||||||
| 194 | position = positionChain.at(i)->firstPosition() - 1; never executed: position = positionChain.at(i)->firstPosition() - 1; | 0 | ||||||||||||||||||||||||
| 195 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 196 | if (i < positionChain.size()
| 0 | ||||||||||||||||||||||||
| 197 | position = positionChain.at(i)->lastPosition() + 1; never executed: position = positionChain.at(i)->lastPosition() + 1; | 0 | ||||||||||||||||||||||||
| 198 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 199 | if (position < adjusted_anchor
| 0 | ||||||||||||||||||||||||
| 200 | if (i < anchorChain.size()
| 0 | ||||||||||||||||||||||||
| 201 | adjusted_anchor = anchorChain.at(i)->lastPosition() + 1; never executed: adjusted_anchor = anchorChain.at(i)->lastPosition() + 1; | 0 | ||||||||||||||||||||||||
| 202 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 203 | if (i < anchorChain.size()
| 0 | ||||||||||||||||||||||||
| 204 | adjusted_anchor = anchorChain.at(i)->firstPosition() - 1; never executed: adjusted_anchor = anchorChain.at(i)->firstPosition() - 1; | 0 | ||||||||||||||||||||||||
| 205 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||
| 207 | f_position = positionChain.at(i-1); | - | ||||||||||||||||||||||||
| 208 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 209 | - | |||||||||||||||||||||||||
| 210 | - | |||||||||||||||||||||||||
| 211 | QTextTable *table = qobject_cast<QTextTable *>(f_position); | - | ||||||||||||||||||||||||
| 212 | if (!table
| 0 | ||||||||||||||||||||||||
| 213 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 214 | - | |||||||||||||||||||||||||
| 215 | QTextTableCell c_position = table->cellAt(position); | - | ||||||||||||||||||||||||
| 216 | QTextTableCell c_anchor = table->cellAt(adjusted_anchor); | - | ||||||||||||||||||||||||
| 217 | if (c_position != c_anchor
| 0 | ||||||||||||||||||||||||
| 218 | position = c_position.firstPosition(); | - | ||||||||||||||||||||||||
| 219 | if (position < adjusted_anchor
| 0 | ||||||||||||||||||||||||
| 220 | adjusted_anchor = c_anchor.lastPosition(); never executed: adjusted_anchor = c_anchor.lastPosition(); | 0 | ||||||||||||||||||||||||
| 221 | else | - | ||||||||||||||||||||||||
| 222 | adjusted_anchor = c_anchor.firstPosition(); never executed: adjusted_anchor = c_anchor.firstPosition(); | 0 | ||||||||||||||||||||||||
| 223 | } | - | ||||||||||||||||||||||||
| 224 | currentCharFormat = -1; | - | ||||||||||||||||||||||||
| 225 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 226 | - | |||||||||||||||||||||||||
| 227 | void QTextCursorPrivate::aboutToRemoveCell(int from, int to) | - | ||||||||||||||||||||||||
| 228 | { | - | ||||||||||||||||||||||||
| 229 | ((!(from <= to)) ? qt_assert("from <= to",__FILE__,280) : qt_noop()); | - | ||||||||||||||||||||||||
| 230 | if (position == anchor
| 0 | ||||||||||||||||||||||||
| 231 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 232 | - | |||||||||||||||||||||||||
| 233 | QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position)); | - | ||||||||||||||||||||||||
| 234 | if (!t
| 0 | ||||||||||||||||||||||||
| 235 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 236 | QTextTableCell removedCellFrom = t->cellAt(from); | - | ||||||||||||||||||||||||
| 237 | QTextTableCell removedCellEnd = t->cellAt(to); | - | ||||||||||||||||||||||||
| 238 | if (! removedCellFrom.isValid()
| 0 | ||||||||||||||||||||||||
| 239 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 240 | - | |||||||||||||||||||||||||
| 241 | int curFrom = position; | - | ||||||||||||||||||||||||
| 242 | int curTo = adjusted_anchor; | - | ||||||||||||||||||||||||
| 243 | if (curTo < curFrom
| 0 | ||||||||||||||||||||||||
| 244 | qSwap(curFrom, curTo); never executed: qSwap(curFrom, curTo); | 0 | ||||||||||||||||||||||||
| 245 | - | |||||||||||||||||||||||||
| 246 | QTextTableCell cellStart = t->cellAt(curFrom); | - | ||||||||||||||||||||||||
| 247 | QTextTableCell cellEnd = t->cellAt(curTo); | - | ||||||||||||||||||||||||
| 248 | - | |||||||||||||||||||||||||
| 249 | if (cellStart.row() >= removedCellFrom.row()
| 0 | ||||||||||||||||||||||||
| 250 | && cellStart.column() >= removedCellFrom.column()
| 0 | ||||||||||||||||||||||||
| 251 | && cellEnd.column() <= removedCellEnd.column()
| 0 | ||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||
| 253 | QTextTableCell cell; | - | ||||||||||||||||||||||||
| 254 | if (removedCellFrom.row() == 0
| 0 | ||||||||||||||||||||||||
| 255 | cell = t->cellAt(cellStart.row(), removedCellEnd.column()+1); never executed: cell = t->cellAt(cellStart.row(), removedCellEnd.column()+1); | 0 | ||||||||||||||||||||||||
| 256 | else if (removedCellFrom.column() == 0
| 0 | ||||||||||||||||||||||||
| 257 | cell = t->cellAt(removedCellEnd.row() + 1, cellStart.column()); never executed: cell = t->cellAt(removedCellEnd.row() + 1, cellStart.column()); | 0 | ||||||||||||||||||||||||
| 258 | - | |||||||||||||||||||||||||
| 259 | int newPosition; | - | ||||||||||||||||||||||||
| 260 | if (cell.isValid()
| 0 | ||||||||||||||||||||||||
| 261 | newPosition = cell.firstPosition(); never executed: newPosition = cell.firstPosition(); | 0 | ||||||||||||||||||||||||
| 262 | else | - | ||||||||||||||||||||||||
| 263 | newPosition = t->lastPosition()+1; never executed: newPosition = t->lastPosition()+1; | 0 | ||||||||||||||||||||||||
| 264 | - | |||||||||||||||||||||||||
| 265 | setPosition(newPosition); | - | ||||||||||||||||||||||||
| 266 | anchor = newPosition; | - | ||||||||||||||||||||||||
| 267 | adjusted_anchor = newPosition; | - | ||||||||||||||||||||||||
| 268 | x = 0; | - | ||||||||||||||||||||||||
| 269 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 270 | else if (cellStart.row() >= removedCellFrom.row()
| 0 | ||||||||||||||||||||||||
| 271 | && cellEnd.row() > removedCellEnd.row()
| 0 | ||||||||||||||||||||||||
| 272 | int newPosition = t->cellAt(removedCellEnd.row() + 1, cellStart.column()).firstPosition(); | - | ||||||||||||||||||||||||
| 273 | if (position < anchor
| 0 | ||||||||||||||||||||||||
| 274 | position = newPosition; never executed: position = newPosition; | 0 | ||||||||||||||||||||||||
| 275 | else | - | ||||||||||||||||||||||||
| 276 | anchor = adjusted_anchor = newPosition; never executed: anchor = adjusted_anchor = newPosition; | 0 | ||||||||||||||||||||||||
| 277 | } | - | ||||||||||||||||||||||||
| 278 | else if (cellStart.column() >= removedCellFrom.column()
| 0 | ||||||||||||||||||||||||
| 279 | && cellEnd.column() > removedCellEnd.column()
| 0 | ||||||||||||||||||||||||
| 280 | int newPosition = t->cellAt(cellStart.row(), removedCellEnd.column()+1).firstPosition(); | - | ||||||||||||||||||||||||
| 281 | if (position < anchor
| 0 | ||||||||||||||||||||||||
| 282 | position = newPosition; never executed: position = newPosition; | 0 | ||||||||||||||||||||||||
| 283 | else | - | ||||||||||||||||||||||||
| 284 | anchor = adjusted_anchor = newPosition; never executed: anchor = adjusted_anchor = newPosition; | 0 | ||||||||||||||||||||||||
| 285 | } | - | ||||||||||||||||||||||||
| 286 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 287 | - | |||||||||||||||||||||||||
| 288 | bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode) | - | ||||||||||||||||||||||||
| 289 | { | - | ||||||||||||||||||||||||
| 290 | currentCharFormat = -1; | - | ||||||||||||||||||||||||
| 291 | bool adjustX = true; | - | ||||||||||||||||||||||||
| 292 | QTextBlock blockIt = block(); | - | ||||||||||||||||||||||||
| 293 | bool visualMovement = priv->defaultCursorMoveStyle == Qt::VisualMoveStyle; | - | ||||||||||||||||||||||||
| 294 | - | |||||||||||||||||||||||||
| 295 | if (!blockIt.isValid()
| 0 | ||||||||||||||||||||||||
| 296 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 297 | - | |||||||||||||||||||||||||
| 298 | if (blockIt.textDirection() == Qt::RightToLeft
| 0 | ||||||||||||||||||||||||
| 299 | if (op == QTextCursor::WordLeft
| 0 | ||||||||||||||||||||||||
| 300 | op = QTextCursor::NextWord; never executed: op = QTextCursor::NextWord; | 0 | ||||||||||||||||||||||||
| 301 | else if (op == QTextCursor::WordRight
| 0 | ||||||||||||||||||||||||
| 302 | op = QTextCursor::PreviousWord; never executed: op = QTextCursor::PreviousWord; | 0 | ||||||||||||||||||||||||
| 303 | - | |||||||||||||||||||||||||
| 304 | if (!visualMovement
| 0 | ||||||||||||||||||||||||
| 305 | if (op == QTextCursor::Left
| 0 | ||||||||||||||||||||||||
| 306 | op = QTextCursor::NextCharacter; never executed: op = QTextCursor::NextCharacter; | 0 | ||||||||||||||||||||||||
| 307 | else if (op == QTextCursor::Right
| 0 | ||||||||||||||||||||||||
| 308 | op = QTextCursor::PreviousCharacter; never executed: op = QTextCursor::PreviousCharacter; | 0 | ||||||||||||||||||||||||
| 309 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 310 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 311 | - | |||||||||||||||||||||||||
| 312 | const QTextLayout *layout = blockLayout(blockIt); | - | ||||||||||||||||||||||||
| 313 | int relativePos = position - blockIt.position(); | - | ||||||||||||||||||||||||
| 314 | QTextLine line; | - | ||||||||||||||||||||||||
| 315 | if (!priv->isInEditBlock()
| 0 | ||||||||||||||||||||||||
| 316 | line = layout->lineForTextPosition(relativePos); never executed: line = layout->lineForTextPosition(relativePos); | 0 | ||||||||||||||||||||||||
| 317 | - | |||||||||||||||||||||||||
| 318 | ((!(priv->frameAt(position) == priv->frameAt(adjusted_anchor))) ? qt_assert("priv->frameAt(position) == priv->frameAt(adjusted_anchor)",__FILE__,369) : qt_noop()); | - | ||||||||||||||||||||||||
| 319 | - | |||||||||||||||||||||||||
| 320 | int newPosition = position; | - | ||||||||||||||||||||||||
| 321 | - | |||||||||||||||||||||||||
| 322 | if (mode == QTextCursor::KeepAnchor
| 0 | ||||||||||||||||||||||||
| 323 | if ((op >= QTextCursor::EndOfLine
| 0 | ||||||||||||||||||||||||
| 324 | || (op >= QTextCursor::Right
| 0 | ||||||||||||||||||||||||
| 325 | QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position)); | - | ||||||||||||||||||||||||
| 326 | ((!(t)) ? qt_assert("t",__FILE__,377) : qt_noop()); | - | ||||||||||||||||||||||||
| 327 | QTextTableCell cell_pos = t->cellAt(position); | - | ||||||||||||||||||||||||
| 328 | if (cell_pos.column() + cell_pos.columnSpan() != t->columns()
| 0 | ||||||||||||||||||||||||
| 329 | op = QTextCursor::NextCell; never executed: op = QTextCursor::NextCell; | 0 | ||||||||||||||||||||||||
| 330 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 331 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 332 | - | |||||||||||||||||||||||||
| 333 | if (x == -1
| 0 | ||||||||||||||||||||||||
| 334 | setX(); never executed: setX(); | 0 | ||||||||||||||||||||||||
| 335 | - | |||||||||||||||||||||||||
| 336 | switch(op) { | - | ||||||||||||||||||||||||
| 337 | case never executed: QTextCursor::NoMove:case QTextCursor::NoMove:never executed: case QTextCursor::NoMove: | 0 | ||||||||||||||||||||||||
| 338 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 339 | - | |||||||||||||||||||||||||
| 340 | case never executed: QTextCursor::Start:case QTextCursor::Start:never executed: case QTextCursor::Start: | 0 | ||||||||||||||||||||||||
| 341 | newPosition = 0; | - | ||||||||||||||||||||||||
| 342 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 343 | case never executed: QTextCursor::StartOfLine:case QTextCursor::StartOfLine:never executed: {case QTextCursor::StartOfLine: | 0 | ||||||||||||||||||||||||
| 344 | newPosition = blockIt.position(); | - | ||||||||||||||||||||||||
| 345 | if (line.isValid()
| 0 | ||||||||||||||||||||||||
| 346 | newPosition += line.textStart(); never executed: newPosition += line.textStart(); | 0 | ||||||||||||||||||||||||
| 347 | - | |||||||||||||||||||||||||
| 348 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 349 | } | - | ||||||||||||||||||||||||
| 350 | case never executed: QTextCursor::StartOfBlock:case QTextCursor::StartOfBlock:never executed: {case QTextCursor::StartOfBlock: | 0 | ||||||||||||||||||||||||
| 351 | newPosition = blockIt.position(); | - | ||||||||||||||||||||||||
| 352 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 353 | } | - | ||||||||||||||||||||||||
| 354 | case never executed: QTextCursor::PreviousBlock:case QTextCursor::PreviousBlock:never executed: {case QTextCursor::PreviousBlock: | 0 | ||||||||||||||||||||||||
| 355 | if (blockIt == priv->blocksBegin()
| 0 | ||||||||||||||||||||||||
| 356 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 357 | blockIt = blockIt.previous(); | - | ||||||||||||||||||||||||
| 358 | - | |||||||||||||||||||||||||
| 359 | newPosition = blockIt.position(); | - | ||||||||||||||||||||||||
| 360 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 361 | } | - | ||||||||||||||||||||||||
| 362 | case never executed: QTextCursor::PreviousCharacter:case QTextCursor::PreviousCharacter:never executed: case QTextCursor::PreviousCharacter: | 0 | ||||||||||||||||||||||||
| 363 | if (mode == QTextCursor::MoveAnchor
| 0 | ||||||||||||||||||||||||
| 364 | newPosition = qMin(position, adjusted_anchor); never executed: newPosition = qMin(position, adjusted_anchor); | 0 | ||||||||||||||||||||||||
| 365 | else | - | ||||||||||||||||||||||||
| 366 | newPosition = priv->previousCursorPosition(position, QTextLayout::SkipCharacters); never executed: newPosition = priv->previousCursorPosition(position, QTextLayout::SkipCharacters); | 0 | ||||||||||||||||||||||||
| 367 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 368 | case never executed: QTextCursor::Left:case QTextCursor::Left:never executed: case QTextCursor::Left: | 0 | ||||||||||||||||||||||||
| 369 | if (mode == QTextCursor::MoveAnchor
| 0 | ||||||||||||||||||||||||
| 370 | newPosition = visualMovement
never executed: newPosition = visualMovement ? qMax(position, adjusted_anchor) : qMin(position, adjusted_anchor); | 0 | ||||||||||||||||||||||||
| 371 | : qMin(position, adjusted_anchor); never executed: newPosition = visualMovement ? qMax(position, adjusted_anchor) : qMin(position, adjusted_anchor); | 0 | ||||||||||||||||||||||||
| 372 | else | - | ||||||||||||||||||||||||
| 373 | newPosition = visualMovement
never executed: newPosition = visualMovement ? priv->leftCursorPosition(position) : priv->previousCursorPosition(position, QTextLayout::SkipCharacters); | 0 | ||||||||||||||||||||||||
| 374 | : priv->previousCursorPosition(position, QTextLayout::SkipCharacters); never executed: newPosition = visualMovement ? priv->leftCursorPosition(position) : priv->previousCursorPosition(position, QTextLayout::SkipCharacters); | 0 | ||||||||||||||||||||||||
| 375 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 376 | case never executed: QTextCursor::StartOfWord:case QTextCursor::StartOfWord:never executed: {case QTextCursor::StartOfWord: | 0 | ||||||||||||||||||||||||
| 377 | if (relativePos == 0
| 0 | ||||||||||||||||||||||||
| 378 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 379 | - | |||||||||||||||||||||||||
| 380 | - | |||||||||||||||||||||||||
| 381 | QTextEngine *engine = layout->engine(); | - | ||||||||||||||||||||||||
| 382 | const QCharAttributes *attributes = engine->attributes(); | - | ||||||||||||||||||||||||
| 383 | if ((
| 0 | ||||||||||||||||||||||||
| 384 | && (attributes[relativePos - 1].whiteSpace
| 0 | ||||||||||||||||||||||||
| 385 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 386 | - | |||||||||||||||||||||||||
| 387 | if (relativePos < blockIt.length()-1
| 0 | ||||||||||||||||||||||||
| 388 | ++ never executed: position;++position;never executed: ++position; | 0 | ||||||||||||||||||||||||
| 389 | - | |||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||
| 391 | } | - | ||||||||||||||||||||||||
| 392 | case never executed: QTextCursor::PreviousWord:case QTextCursor::PreviousWord:never executed: case QTextCursor::PreviousWord:code before this statement never executed: case QTextCursor::PreviousWord: | 0 | ||||||||||||||||||||||||
| 393 | case never executed: QTextCursor::WordLeft:case QTextCursor::WordLeft:never executed: case QTextCursor::WordLeft: | 0 | ||||||||||||||||||||||||
| 394 | newPosition = priv->previousCursorPosition(position, QTextLayout::SkipWords); | - | ||||||||||||||||||||||||
| 395 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 396 | case never executed: QTextCursor::Up:case QTextCursor::Up:never executed: {case QTextCursor::Up: | 0 | ||||||||||||||||||||||||
| 397 | int i = line.lineNumber() - 1; | - | ||||||||||||||||||||||||
| 398 | if (i == -1
| 0 | ||||||||||||||||||||||||
| 399 | if (blockIt == priv->blocksBegin()
| 0 | ||||||||||||||||||||||||
| 400 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 401 | int blockPosition = blockIt.position(); | - | ||||||||||||||||||||||||
| 402 | QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(blockPosition)); | - | ||||||||||||||||||||||||
| 403 | if (table
| 0 | ||||||||||||||||||||||||
| 404 | QTextTableCell cell = table->cellAt(blockPosition); | - | ||||||||||||||||||||||||
| 405 | if (cell.firstPosition() == blockPosition
| 0 | ||||||||||||||||||||||||
| 406 | int row = cell.row() - 1; | - | ||||||||||||||||||||||||
| 407 | if (row >= 0
| 0 | ||||||||||||||||||||||||
| 408 | blockPosition = table->cellAt(row, cell.column()).lastPosition(); | - | ||||||||||||||||||||||||
| 409 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 410 | - | |||||||||||||||||||||||||
| 411 | blockPosition = table->firstPosition() - 1; | - | ||||||||||||||||||||||||
| 412 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 413 | blockIt = priv->blocksFind(blockPosition); | - | ||||||||||||||||||||||||
| 414 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 415 | blockIt = blockIt.previous(); | - | ||||||||||||||||||||||||
| 416 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 417 | } else { | - | ||||||||||||||||||||||||
| 418 | blockIt = blockIt.previous(); | - | ||||||||||||||||||||||||
| 419 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 420 | layout = blockLayout(blockIt); | - | ||||||||||||||||||||||||
| 421 | i = layout->lineCount()-1; | - | ||||||||||||||||||||||||
| 422 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 423 | if (layout->lineCount()
| 0 | ||||||||||||||||||||||||
| 424 | QTextLine line = layout->lineAt(i); | - | ||||||||||||||||||||||||
| 425 | newPosition = line.xToCursor(x) + blockIt.position(); | - | ||||||||||||||||||||||||
| 426 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 427 | newPosition = blockIt.position(); | - | ||||||||||||||||||||||||
| 428 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 429 | adjustX = false; | - | ||||||||||||||||||||||||
| 430 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 431 | } | - | ||||||||||||||||||||||||
| 432 | - | |||||||||||||||||||||||||
| 433 | case never executed: QTextCursor::End:case QTextCursor::End:never executed: case QTextCursor::End: | 0 | ||||||||||||||||||||||||
| 434 | newPosition = priv->length() - 1; | - | ||||||||||||||||||||||||
| 435 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 436 | case never executed: QTextCursor::EndOfLine:case QTextCursor::EndOfLine:never executed: {case QTextCursor::EndOfLine: | 0 | ||||||||||||||||||||||||
| 437 | if (!line.isValid()
| 0 | ||||||||||||||||||||||||
| 438 | if (blockIt.length() >= 1
| 0 | ||||||||||||||||||||||||
| 439 | - | |||||||||||||||||||||||||
| 440 | newPosition = blockIt.position() + blockIt.length() - 1; never executed: newPosition = blockIt.position() + blockIt.length() - 1; | 0 | ||||||||||||||||||||||||
| 441 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 442 | } | - | ||||||||||||||||||||||||
| 443 | newPosition = blockIt.position() + line.textStart() + line.textLength(); | - | ||||||||||||||||||||||||
| 444 | if (newPosition >= priv->length()
| 0 | ||||||||||||||||||||||||
| 445 | newPosition = priv->length() - 1; never executed: newPosition = priv->length() - 1; | 0 | ||||||||||||||||||||||||
| 446 | if (line.lineNumber() < layout->lineCount() - 1
| 0 | ||||||||||||||||||||||||
| 447 | const QString text = blockIt.text(); | - | ||||||||||||||||||||||||
| 448 | - | |||||||||||||||||||||||||
| 449 | - | |||||||||||||||||||||||||
| 450 | if (text.at(line.textStart() + line.textLength() - 1).isSpace()
| 0 | ||||||||||||||||||||||||
| 451 | -- never executed: newPosition;--newPosition;never executed: --newPosition; | 0 | ||||||||||||||||||||||||
| 452 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 453 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 454 | } | - | ||||||||||||||||||||||||
| 455 | case never executed: QTextCursor::EndOfWord:case QTextCursor::EndOfWord:never executed: {case QTextCursor::EndOfWord: | 0 | ||||||||||||||||||||||||
| 456 | QTextEngine *engine = layout->engine(); | - | ||||||||||||||||||||||||
| 457 | const QCharAttributes *attributes = engine->attributes(); | - | ||||||||||||||||||||||||
| 458 | const int len = blockIt.length() - 1; | - | ||||||||||||||||||||||||
| 459 | if (relativePos >= len
| 0 | ||||||||||||||||||||||||
| 460 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 461 | if (engine->atWordSeparator(relativePos)
| 0 | ||||||||||||||||||||||||
| 462 | ++relativePos; | - | ||||||||||||||||||||||||
| 463 | while (relativePos < len
| 0 | ||||||||||||||||||||||||
| 464 | ++ never executed: relativePos;++relativePos;never executed: ++relativePos; | 0 | ||||||||||||||||||||||||
| 465 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 466 | while (relativePos < len
| 0 | ||||||||||||||||||||||||
| 467 | ++ never executed: relativePos;++relativePos;never executed: ++relativePos; | 0 | ||||||||||||||||||||||||
| 468 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 469 | newPosition = blockIt.position() + relativePos; | - | ||||||||||||||||||||||||
| 470 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 471 | } | - | ||||||||||||||||||||||||
| 472 | case never executed: QTextCursor::EndOfBlock:case QTextCursor::EndOfBlock:never executed: case QTextCursor::EndOfBlock: | 0 | ||||||||||||||||||||||||
| 473 | if (blockIt.length() >= 1
| 0 | ||||||||||||||||||||||||
| 474 | - | |||||||||||||||||||||||||
| 475 | newPosition = blockIt.position() + blockIt.length() - 1; never executed: newPosition = blockIt.position() + blockIt.length() - 1; | 0 | ||||||||||||||||||||||||
| 476 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 477 | case never executed: QTextCursor::NextBlock:case QTextCursor::NextBlock:never executed: {case QTextCursor::NextBlock: | 0 | ||||||||||||||||||||||||
| 478 | blockIt = blockIt.next(); | - | ||||||||||||||||||||||||
| 479 | if (!blockIt.isValid()
| 0 | ||||||||||||||||||||||||
| 480 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 481 | - | |||||||||||||||||||||||||
| 482 | newPosition = blockIt.position(); | - | ||||||||||||||||||||||||
| 483 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 484 | } | - | ||||||||||||||||||||||||
| 485 | case never executed: QTextCursor::NextCharacter:case QTextCursor::NextCharacter:never executed: case QTextCursor::NextCharacter: | 0 | ||||||||||||||||||||||||
| 486 | if (mode == QTextCursor::MoveAnchor
| 0 | ||||||||||||||||||||||||
| 487 | newPosition = qMax(position, adjusted_anchor); never executed: newPosition = qMax(position, adjusted_anchor); | 0 | ||||||||||||||||||||||||
| 488 | else | - | ||||||||||||||||||||||||
| 489 | newPosition = priv->nextCursorPosition(position, QTextLayout::SkipCharacters); never executed: newPosition = priv->nextCursorPosition(position, QTextLayout::SkipCharacters); | 0 | ||||||||||||||||||||||||
| 490 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 491 | case never executed: QTextCursor::Right:case QTextCursor::Right:never executed: case QTextCursor::Right: | 0 | ||||||||||||||||||||||||
| 492 | if (mode == QTextCursor::MoveAnchor
| 0 | ||||||||||||||||||||||||
| 493 | newPosition = visualMovement
never executed: newPosition = visualMovement ? qMin(position, adjusted_anchor) : qMax(position, adjusted_anchor); | 0 | ||||||||||||||||||||||||
| 494 | : qMax(position, adjusted_anchor); never executed: newPosition = visualMovement ? qMin(position, adjusted_anchor) : qMax(position, adjusted_anchor); | 0 | ||||||||||||||||||||||||
| 495 | else | - | ||||||||||||||||||||||||
| 496 | newPosition = visualMovement
never executed: newPosition = visualMovement ? priv->rightCursorPosition(position) : priv->nextCursorPosition(position, QTextLayout::SkipCharacters); | 0 | ||||||||||||||||||||||||
| 497 | : priv->nextCursorPosition(position, QTextLayout::SkipCharacters); never executed: newPosition = visualMovement ? priv->rightCursorPosition(position) : priv->nextCursorPosition(position, QTextLayout::SkipCharacters); | 0 | ||||||||||||||||||||||||
| 498 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 499 | case never executed: QTextCursor::NextWord:case QTextCursor::NextWord:never executed: case QTextCursor::NextWord: | 0 | ||||||||||||||||||||||||
| 500 | case never executed: QTextCursor::WordRight:case QTextCursor::WordRight:never executed: case QTextCursor::WordRight: | 0 | ||||||||||||||||||||||||
| 501 | newPosition = priv->nextCursorPosition(position, QTextLayout::SkipWords); | - | ||||||||||||||||||||||||
| 502 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 503 | - | |||||||||||||||||||||||||
| 504 | case never executed: QTextCursor::Down:case QTextCursor::Down:never executed: {case QTextCursor::Down: | 0 | ||||||||||||||||||||||||
| 505 | int i = line.lineNumber() + 1; | - | ||||||||||||||||||||||||
| 506 | - | |||||||||||||||||||||||||
| 507 | if (i >= layout->lineCount()
| 0 | ||||||||||||||||||||||||
| 508 | int blockPosition = blockIt.position() + blockIt.length() - 1; | - | ||||||||||||||||||||||||
| 509 | QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(blockPosition)); | - | ||||||||||||||||||||||||
| 510 | if (table
| 0 | ||||||||||||||||||||||||
| 511 | QTextTableCell cell = table->cellAt(blockPosition); | - | ||||||||||||||||||||||||
| 512 | if (cell.lastPosition() == blockPosition
| 0 | ||||||||||||||||||||||||
| 513 | int row = cell.row() + cell.rowSpan(); | - | ||||||||||||||||||||||||
| 514 | if (row < table->rows()
| 0 | ||||||||||||||||||||||||
| 515 | blockPosition = table->cellAt(row, cell.column()).firstPosition(); | - | ||||||||||||||||||||||||
| 516 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 517 | - | |||||||||||||||||||||||||
| 518 | blockPosition = table->lastPosition() + 1; | - | ||||||||||||||||||||||||
| 519 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 520 | blockIt = priv->blocksFind(blockPosition); | - | ||||||||||||||||||||||||
| 521 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 522 | blockIt = blockIt.next(); | - | ||||||||||||||||||||||||
| 523 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 524 | } else { | - | ||||||||||||||||||||||||
| 525 | blockIt = blockIt.next(); | - | ||||||||||||||||||||||||
| 526 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 527 | - | |||||||||||||||||||||||||
| 528 | if (blockIt == priv->blocksEnd()
| 0 | ||||||||||||||||||||||||
| 529 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 530 | layout = blockLayout(blockIt); | - | ||||||||||||||||||||||||
| 531 | i = 0; | - | ||||||||||||||||||||||||
| 532 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 533 | if (layout->lineCount()
| 0 | ||||||||||||||||||||||||
| 534 | QTextLine line = layout->lineAt(i); | - | ||||||||||||||||||||||||
| 535 | newPosition = line.xToCursor(x) + blockIt.position(); | - | ||||||||||||||||||||||||
| 536 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 537 | newPosition = blockIt.position(); | - | ||||||||||||||||||||||||
| 538 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 539 | adjustX = false; | - | ||||||||||||||||||||||||
| 540 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 541 | } | - | ||||||||||||||||||||||||
| 542 | case never executed: QTextCursor::NextCell:case QTextCursor::NextCell:never executed: case QTextCursor::NextCell: | 0 | ||||||||||||||||||||||||
| 543 | case never executed: QTextCursor::PreviousCell:case QTextCursor::PreviousCell:never executed: case QTextCursor::PreviousCell: | 0 | ||||||||||||||||||||||||
| 544 | case never executed: QTextCursor::NextRow:case QTextCursor::NextRow:never executed: case QTextCursor::NextRow: | 0 | ||||||||||||||||||||||||
| 545 | case never executed: QTextCursor::PreviousRow:case QTextCursor::PreviousRow:never executed: {case QTextCursor::PreviousRow: | 0 | ||||||||||||||||||||||||
| 546 | QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(position)); | - | ||||||||||||||||||||||||
| 547 | if (!table
| 0 | ||||||||||||||||||||||||
| 548 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 549 | - | |||||||||||||||||||||||||
| 550 | QTextTableCell cell = table->cellAt(position); | - | ||||||||||||||||||||||||
| 551 | ((!(cell.isValid())) ? qt_assert("cell.isValid()",__FILE__,602) : qt_noop()); | - | ||||||||||||||||||||||||
| 552 | int column = cell.column(); | - | ||||||||||||||||||||||||
| 553 | int row = cell.row(); | - | ||||||||||||||||||||||||
| 554 | const int currentRow = row; | - | ||||||||||||||||||||||||
| 555 | if (op == QTextCursor::NextCell
| 0 | ||||||||||||||||||||||||
| 556 | do { | - | ||||||||||||||||||||||||
| 557 | column += cell.columnSpan(); | - | ||||||||||||||||||||||||
| 558 | if (column >= table->columns()
| 0 | ||||||||||||||||||||||||
| 559 | column = 0; | - | ||||||||||||||||||||||||
| 560 | ++row; | - | ||||||||||||||||||||||||
| 561 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 562 | cell = table->cellAt(row, column); | - | ||||||||||||||||||||||||
| 563 | - | |||||||||||||||||||||||||
| 564 | } never executed: while (cell.isValid()end of block
| 0 | ||||||||||||||||||||||||
| 565 | && ((op == QTextCursor::NextRow
| 0 | ||||||||||||||||||||||||
| 566 | || cell.row() < row
| 0 | ||||||||||||||||||||||||
| 567 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 568 | else if (op == QTextCursor::PreviousCell
| 0 | ||||||||||||||||||||||||
| 569 | do { | - | ||||||||||||||||||||||||
| 570 | --column; | - | ||||||||||||||||||||||||
| 571 | if (column < 0
| 0 | ||||||||||||||||||||||||
| 572 | column = table->columns()-1; | - | ||||||||||||||||||||||||
| 573 | --row; | - | ||||||||||||||||||||||||
| 574 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 575 | cell = table->cellAt(row, column); | - | ||||||||||||||||||||||||
| 576 | - | |||||||||||||||||||||||||
| 577 | } never executed: while (cell.isValid()end of block
| 0 | ||||||||||||||||||||||||
| 578 | && ((op == QTextCursor::PreviousRow
| 0 | ||||||||||||||||||||||||
| 579 | || cell.row() < row
| 0 | ||||||||||||||||||||||||
| 580 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 581 | if (cell.isValid()
| 0 | ||||||||||||||||||||||||
| 582 | newPosition = cell.firstPosition(); never executed: newPosition = cell.firstPosition(); | 0 | ||||||||||||||||||||||||
| 583 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 584 | } | - | ||||||||||||||||||||||||
| 585 | } | - | ||||||||||||||||||||||||
| 586 | - | |||||||||||||||||||||||||
| 587 | if (mode == QTextCursor::KeepAnchor
| 0 | ||||||||||||||||||||||||
| 588 | QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(position)); | - | ||||||||||||||||||||||||
| 589 | if (table
| 0 | ||||||||||||||||||||||||
| 590 | || (op >= QTextCursor::NextBlock
| 0 | ||||||||||||||||||||||||
| 591 | int oldColumn = table->cellAt(position).column(); | - | ||||||||||||||||||||||||
| 592 | - | |||||||||||||||||||||||||
| 593 | const QTextTableCell otherCell = table->cellAt(newPosition); | - | ||||||||||||||||||||||||
| 594 | if (!otherCell.isValid()
| 0 | ||||||||||||||||||||||||
| 595 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 596 | - | |||||||||||||||||||||||||
| 597 | int newColumn = otherCell.column(); | - | ||||||||||||||||||||||||
| 598 | if ((oldColumn > newColumn
| 0 | ||||||||||||||||||||||||
| 599 | || (oldColumn < newColumn
| 0 | ||||||||||||||||||||||||
| 600 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 601 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 602 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 603 | - | |||||||||||||||||||||||||
| 604 | const bool moved = setPosition(newPosition); | - | ||||||||||||||||||||||||
| 605 | - | |||||||||||||||||||||||||
| 606 | if (mode == QTextCursor::MoveAnchor
| 0 | ||||||||||||||||||||||||
| 607 | anchor = position; | - | ||||||||||||||||||||||||
| 608 | adjusted_anchor = position; | - | ||||||||||||||||||||||||
| 609 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 610 | adjustCursor(op); | - | ||||||||||||||||||||||||
| 611 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 612 | - | |||||||||||||||||||||||||
| 613 | if (adjustX
| 0 | ||||||||||||||||||||||||
| 614 | setX(); never executed: setX(); | 0 | ||||||||||||||||||||||||
| 615 | - | |||||||||||||||||||||||||
| 616 | return never executed: moved;return moved;never executed: return moved; | 0 | ||||||||||||||||||||||||
| 617 | } | - | ||||||||||||||||||||||||
| 618 | - | |||||||||||||||||||||||||
| 619 | QTextTable *QTextCursorPrivate::complexSelectionTable() const | - | ||||||||||||||||||||||||
| 620 | { | - | ||||||||||||||||||||||||
| 621 | if (position == anchor
| 0 | ||||||||||||||||||||||||
| 622 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 623 | - | |||||||||||||||||||||||||
| 624 | QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position)); | - | ||||||||||||||||||||||||
| 625 | if (t
| 0 | ||||||||||||||||||||||||
| 626 | QTextTableCell cell_pos = t->cellAt(position); | - | ||||||||||||||||||||||||
| 627 | QTextTableCell cell_anchor = t->cellAt(adjusted_anchor); | - | ||||||||||||||||||||||||
| 628 | - | |||||||||||||||||||||||||
| 629 | ((!(cell_anchor.isValid())) ? qt_assert("cell_anchor.isValid()",__FILE__,680) : qt_noop()); | - | ||||||||||||||||||||||||
| 630 | - | |||||||||||||||||||||||||
| 631 | if (cell_pos == cell_anchor
| 0 | ||||||||||||||||||||||||
| 632 | t = 0; never executed: t = 0; | 0 | ||||||||||||||||||||||||
| 633 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 634 | return never executed: t;return t;never executed: return t; | 0 | ||||||||||||||||||||||||
| 635 | } | - | ||||||||||||||||||||||||
| 636 | - | |||||||||||||||||||||||||
| 637 | void QTextCursorPrivate::selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const | - | ||||||||||||||||||||||||
| 638 | { | - | ||||||||||||||||||||||||
| 639 | *firstRow = -1; | - | ||||||||||||||||||||||||
| 640 | *firstColumn = -1; | - | ||||||||||||||||||||||||
| 641 | *numRows = -1; | - | ||||||||||||||||||||||||
| 642 | *numColumns = -1; | - | ||||||||||||||||||||||||
| 643 | - | |||||||||||||||||||||||||
| 644 | if (position == anchor
| 0 | ||||||||||||||||||||||||
| 645 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 646 | - | |||||||||||||||||||||||||
| 647 | QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position)); | - | ||||||||||||||||||||||||
| 648 | if (!t
| 0 | ||||||||||||||||||||||||
| 649 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 650 | - | |||||||||||||||||||||||||
| 651 | QTextTableCell cell_pos = t->cellAt(position); | - | ||||||||||||||||||||||||
| 652 | QTextTableCell cell_anchor = t->cellAt(adjusted_anchor); | - | ||||||||||||||||||||||||
| 653 | - | |||||||||||||||||||||||||
| 654 | ((!(cell_anchor.isValid())) ? qt_assert("cell_anchor.isValid()",__FILE__,705) : qt_noop()); | - | ||||||||||||||||||||||||
| 655 | - | |||||||||||||||||||||||||
| 656 | if (cell_pos == cell_anchor
| 0 | ||||||||||||||||||||||||
| 657 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 658 | - | |||||||||||||||||||||||||
| 659 | *firstRow = qMin(cell_pos.row(), cell_anchor.row()); | - | ||||||||||||||||||||||||
| 660 | *firstColumn = qMin(cell_pos.column(), cell_anchor.column()); | - | ||||||||||||||||||||||||
| 661 | *numRows = qMax(cell_pos.row() + cell_pos.rowSpan(), cell_anchor.row() + cell_anchor.rowSpan()) - *firstRow; | - | ||||||||||||||||||||||||
| 662 | *numColumns = qMax(cell_pos.column() + cell_pos.columnSpan(), cell_anchor.column() + cell_anchor.columnSpan()) - *firstColumn; | - | ||||||||||||||||||||||||
| 663 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 664 | - | |||||||||||||||||||||||||
| 665 | static void setBlockCharFormatHelper(QTextDocumentPrivate *priv, int pos1, int pos2, | - | ||||||||||||||||||||||||
| 666 | const QTextCharFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode) | - | ||||||||||||||||||||||||
| 667 | { | - | ||||||||||||||||||||||||
| 668 | QTextBlock it = priv->blocksFind(pos1); | - | ||||||||||||||||||||||||
| 669 | QTextBlock end = priv->blocksFind(pos2); | - | ||||||||||||||||||||||||
| 670 | if (end.isValid()
| 0 | ||||||||||||||||||||||||
| 671 | end = end.next(); never executed: end = end.next(); | 0 | ||||||||||||||||||||||||
| 672 | - | |||||||||||||||||||||||||
| 673 | for (; it != end
| 0 | ||||||||||||||||||||||||
| 674 | priv->setCharFormat(it.position() - 1, 1, format, changeMode); | - | ||||||||||||||||||||||||
| 675 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 676 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 677 | - | |||||||||||||||||||||||||
| 678 | void QTextCursorPrivate::setBlockCharFormat(const QTextCharFormat &_format, | - | ||||||||||||||||||||||||
| 679 | QTextDocumentPrivate::FormatChangeMode changeMode) | - | ||||||||||||||||||||||||
| 680 | { | - | ||||||||||||||||||||||||
| 681 | priv->beginEditBlock(); | - | ||||||||||||||||||||||||
| 682 | - | |||||||||||||||||||||||||
| 683 | QTextCharFormat format = _format; | - | ||||||||||||||||||||||||
| 684 | format.clearProperty(QTextFormat::ObjectIndex); | - | ||||||||||||||||||||||||
| 685 | - | |||||||||||||||||||||||||
| 686 | QTextTable *table = complexSelectionTable(); | - | ||||||||||||||||||||||||
| 687 | if (table
| 0 | ||||||||||||||||||||||||
| 688 | int row_start, col_start, num_rows, num_cols; | - | ||||||||||||||||||||||||
| 689 | selectedTableCells(&row_start, &num_rows, &col_start, &num_cols); | - | ||||||||||||||||||||||||
| 690 | - | |||||||||||||||||||||||||
| 691 | ((!(row_start != -1)) ? qt_assert("row_start != -1",__FILE__,742) : qt_noop()); | - | ||||||||||||||||||||||||
| 692 | for (int r = row_start; r < row_start + num_rows
| 0 | ||||||||||||||||||||||||
| 693 | for (int c = col_start; c < col_start + num_cols
| 0 | ||||||||||||||||||||||||
| 694 | QTextTableCell cell = table->cellAt(r, c); | - | ||||||||||||||||||||||||
| 695 | int rspan = cell.rowSpan(); | - | ||||||||||||||||||||||||
| 696 | int cspan = cell.columnSpan(); | - | ||||||||||||||||||||||||
| 697 | if (rspan != 1
| 0 | ||||||||||||||||||||||||
| 698 | int cr = cell.row(); | - | ||||||||||||||||||||||||
| 699 | if (cr != r
| 0 | ||||||||||||||||||||||||
| 700 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 701 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 702 | if (cspan != 1
| 0 | ||||||||||||||||||||||||
| 703 | int cc = cell.column(); | - | ||||||||||||||||||||||||
| 704 | if (cc != c
| 0 | ||||||||||||||||||||||||
| 705 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 706 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 707 | - | |||||||||||||||||||||||||
| 708 | int pos1 = cell.firstPosition(); | - | ||||||||||||||||||||||||
| 709 | int pos2 = cell.lastPosition(); | - | ||||||||||||||||||||||||
| 710 | setBlockCharFormatHelper(priv, pos1, pos2, format, changeMode); | - | ||||||||||||||||||||||||
| 711 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 712 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 713 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 714 | int pos1 = position; | - | ||||||||||||||||||||||||
| 715 | int pos2 = adjusted_anchor; | - | ||||||||||||||||||||||||
| 716 | if (pos1 > pos2
| 0 | ||||||||||||||||||||||||
| 717 | pos1 = adjusted_anchor; | - | ||||||||||||||||||||||||
| 718 | pos2 = position; | - | ||||||||||||||||||||||||
| 719 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 720 | - | |||||||||||||||||||||||||
| 721 | setBlockCharFormatHelper(priv, pos1, pos2, format, changeMode); | - | ||||||||||||||||||||||||
| 722 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 723 | priv->endEditBlock(); | - | ||||||||||||||||||||||||
| 724 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 725 | - | |||||||||||||||||||||||||
| 726 | - | |||||||||||||||||||||||||
| 727 | void QTextCursorPrivate::setBlockFormat(const QTextBlockFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode) | - | ||||||||||||||||||||||||
| 728 | { | - | ||||||||||||||||||||||||
| 729 | QTextTable *table = complexSelectionTable(); | - | ||||||||||||||||||||||||
| 730 | if (table
| 0 | ||||||||||||||||||||||||
| 731 | priv->beginEditBlock(); | - | ||||||||||||||||||||||||
| 732 | int row_start, col_start, num_rows, num_cols; | - | ||||||||||||||||||||||||
| 733 | selectedTableCells(&row_start, &num_rows, &col_start, &num_cols); | - | ||||||||||||||||||||||||
| 734 | - | |||||||||||||||||||||||||
| 735 | ((!(row_start != -1)) ? qt_assert("row_start != -1",__FILE__,786) : qt_noop()); | - | ||||||||||||||||||||||||
| 736 | for (int r = row_start; r < row_start + num_rows
| 0 | ||||||||||||||||||||||||
| 737 | for (int c = col_start; c < col_start + num_cols
| 0 | ||||||||||||||||||||||||
| 738 | QTextTableCell cell = table->cellAt(r, c); | - | ||||||||||||||||||||||||
| 739 | int rspan = cell.rowSpan(); | - | ||||||||||||||||||||||||
| 740 | int cspan = cell.columnSpan(); | - | ||||||||||||||||||||||||
| 741 | if (rspan != 1
| 0 | ||||||||||||||||||||||||
| 742 | int cr = cell.row(); | - | ||||||||||||||||||||||||
| 743 | if (cr != r
| 0 | ||||||||||||||||||||||||
| 744 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 745 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 746 | if (cspan != 1
| 0 | ||||||||||||||||||||||||
| 747 | int cc = cell.column(); | - | ||||||||||||||||||||||||
| 748 | if (cc != c
| 0 | ||||||||||||||||||||||||
| 749 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 750 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 751 | - | |||||||||||||||||||||||||
| 752 | int pos1 = cell.firstPosition(); | - | ||||||||||||||||||||||||
| 753 | int pos2 = cell.lastPosition(); | - | ||||||||||||||||||||||||
| 754 | priv->setBlockFormat(priv->blocksFind(pos1), priv->blocksFind(pos2), format, changeMode); | - | ||||||||||||||||||||||||
| 755 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 756 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 757 | priv->endEditBlock(); | - | ||||||||||||||||||||||||
| 758 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 759 | int pos1 = position; | - | ||||||||||||||||||||||||
| 760 | int pos2 = adjusted_anchor; | - | ||||||||||||||||||||||||
| 761 | if (pos1 > pos2
| 0 | ||||||||||||||||||||||||
| 762 | pos1 = adjusted_anchor; | - | ||||||||||||||||||||||||
| 763 | pos2 = position; | - | ||||||||||||||||||||||||
| 764 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 765 | - | |||||||||||||||||||||||||
| 766 | priv->setBlockFormat(priv->blocksFind(pos1), priv->blocksFind(pos2), format, changeMode); | - | ||||||||||||||||||||||||
| 767 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 768 | } | - | ||||||||||||||||||||||||
| 769 | - | |||||||||||||||||||||||||
| 770 | void QTextCursorPrivate::setCharFormat(const QTextCharFormat &_format, QTextDocumentPrivate::FormatChangeMode changeMode) | - | ||||||||||||||||||||||||
| 771 | { | - | ||||||||||||||||||||||||
| 772 | ((!(position != anchor)) ? qt_assert("position != anchor",__FILE__,823) : qt_noop()); | - | ||||||||||||||||||||||||
| 773 | - | |||||||||||||||||||||||||
| 774 | QTextCharFormat format = _format; | - | ||||||||||||||||||||||||
| 775 | format.clearProperty(QTextFormat::ObjectIndex); | - | ||||||||||||||||||||||||
| 776 | - | |||||||||||||||||||||||||
| 777 | QTextTable *table = complexSelectionTable(); | - | ||||||||||||||||||||||||
| 778 | if (table
| 0 | ||||||||||||||||||||||||
| 779 | priv->beginEditBlock(); | - | ||||||||||||||||||||||||
| 780 | int row_start, col_start, num_rows, num_cols; | - | ||||||||||||||||||||||||
| 781 | selectedTableCells(&row_start, &num_rows, &col_start, &num_cols); | - | ||||||||||||||||||||||||
| 782 | - | |||||||||||||||||||||||||
| 783 | ((!(row_start != -1)) ? qt_assert("row_start != -1",__FILE__,834) : qt_noop()); | - | ||||||||||||||||||||||||
| 784 | for (int r = row_start; r < row_start + num_rows
| 0 | ||||||||||||||||||||||||
| 785 | for (int c = col_start; c < col_start + num_cols
| 0 | ||||||||||||||||||||||||
| 786 | QTextTableCell cell = table->cellAt(r, c); | - | ||||||||||||||||||||||||
| 787 | int rspan = cell.rowSpan(); | - | ||||||||||||||||||||||||
| 788 | int cspan = cell.columnSpan(); | - | ||||||||||||||||||||||||
| 789 | if (rspan != 1
| 0 | ||||||||||||||||||||||||
| 790 | int cr = cell.row(); | - | ||||||||||||||||||||||||
| 791 | if (cr != r
| 0 | ||||||||||||||||||||||||
| 792 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 793 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 794 | if (cspan != 1
| 0 | ||||||||||||||||||||||||
| 795 | int cc = cell.column(); | - | ||||||||||||||||||||||||
| 796 | if (cc != c
| 0 | ||||||||||||||||||||||||
| 797 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 798 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 799 | - | |||||||||||||||||||||||||
| 800 | int pos1 = cell.firstPosition(); | - | ||||||||||||||||||||||||
| 801 | int pos2 = cell.lastPosition(); | - | ||||||||||||||||||||||||
| 802 | priv->setCharFormat(pos1, pos2-pos1, format, changeMode); | - | ||||||||||||||||||||||||
| 803 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 804 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 805 | priv->endEditBlock(); | - | ||||||||||||||||||||||||
| 806 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 807 | int pos1 = position; | - | ||||||||||||||||||||||||
| 808 | int pos2 = adjusted_anchor; | - | ||||||||||||||||||||||||
| 809 | if (pos1 > pos2
| 0 | ||||||||||||||||||||||||
| 810 | pos1 = adjusted_anchor; | - | ||||||||||||||||||||||||
| 811 | pos2 = position; | - | ||||||||||||||||||||||||
| 812 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 813 | - | |||||||||||||||||||||||||
| 814 | priv->setCharFormat(pos1, pos2-pos1, format, changeMode); | - | ||||||||||||||||||||||||
| 815 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 816 | } | - | ||||||||||||||||||||||||
| 817 | - | |||||||||||||||||||||||||
| 818 | - | |||||||||||||||||||||||||
| 819 | QTextLayout *QTextCursorPrivate::blockLayout(QTextBlock &block) const{ | - | ||||||||||||||||||||||||
| 820 | QTextLayout *tl = block.layout(); | - | ||||||||||||||||||||||||
| 821 | if (!tl->lineCount()
| 0 | ||||||||||||||||||||||||
| 822 | priv->layout()->blockBoundingRect(block); never executed: priv->layout()->blockBoundingRect(block); | 0 | ||||||||||||||||||||||||
| 823 | return never executed: tl;return tl;never executed: return tl; | 0 | ||||||||||||||||||||||||
| 824 | } | - | ||||||||||||||||||||||||
| 825 | QTextCursor::QTextCursor() | - | ||||||||||||||||||||||||
| 826 | : d(0) | - | ||||||||||||||||||||||||
| 827 | { | - | ||||||||||||||||||||||||
| 828 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 829 | - | |||||||||||||||||||||||||
| 830 | - | |||||||||||||||||||||||||
| 831 | - | |||||||||||||||||||||||||
| 832 | - | |||||||||||||||||||||||||
| 833 | QTextCursor::QTextCursor(QTextDocument *document) | - | ||||||||||||||||||||||||
| 834 | : d(new QTextCursorPrivate(document->docHandle())) | - | ||||||||||||||||||||||||
| 835 | { | - | ||||||||||||||||||||||||
| 836 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 837 | - | |||||||||||||||||||||||||
| 838 | - | |||||||||||||||||||||||||
| 839 | - | |||||||||||||||||||||||||
| 840 | - | |||||||||||||||||||||||||
| 841 | QTextCursor::QTextCursor(QTextFrame *frame) | - | ||||||||||||||||||||||||
| 842 | : d(new QTextCursorPrivate(frame->document()->docHandle())) | - | ||||||||||||||||||||||||
| 843 | { | - | ||||||||||||||||||||||||
| 844 | d->adjusted_anchor = d->anchor = d->position = frame->firstPosition(); | - | ||||||||||||||||||||||||
| 845 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 846 | - | |||||||||||||||||||||||||
| 847 | - | |||||||||||||||||||||||||
| 848 | - | |||||||||||||||||||||||||
| 849 | - | |||||||||||||||||||||||||
| 850 | - | |||||||||||||||||||||||||
| 851 | QTextCursor::QTextCursor(const QTextBlock &block) | - | ||||||||||||||||||||||||
| 852 | : d(new QTextCursorPrivate(block.docHandle())) | - | ||||||||||||||||||||||||
| 853 | { | - | ||||||||||||||||||||||||
| 854 | d->adjusted_anchor = d->anchor = d->position = block.position(); | - | ||||||||||||||||||||||||
| 855 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 856 | - | |||||||||||||||||||||||||
| 857 | - | |||||||||||||||||||||||||
| 858 | - | |||||||||||||||||||||||||
| 859 | - | |||||||||||||||||||||||||
| 860 | - | |||||||||||||||||||||||||
| 861 | QTextCursor::QTextCursor(QTextDocumentPrivate *p, int pos) | - | ||||||||||||||||||||||||
| 862 | : d(new QTextCursorPrivate(p)) | - | ||||||||||||||||||||||||
| 863 | { | - | ||||||||||||||||||||||||
| 864 | d->adjusted_anchor = d->anchor = d->position = pos; | - | ||||||||||||||||||||||||
| 865 | - | |||||||||||||||||||||||||
| 866 | d->setX(); | - | ||||||||||||||||||||||||
| 867 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 868 | - | |||||||||||||||||||||||||
| 869 | - | |||||||||||||||||||||||||
| 870 | - | |||||||||||||||||||||||||
| 871 | - | |||||||||||||||||||||||||
| 872 | QTextCursor::QTextCursor(QTextCursorPrivate *d) | - | ||||||||||||||||||||||||
| 873 | { | - | ||||||||||||||||||||||||
| 874 | ((!(d)) ? qt_assert("d",__FILE__,1094) : qt_noop()); | - | ||||||||||||||||||||||||
| 875 | this->d = d; | - | ||||||||||||||||||||||||
| 876 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 877 | - | |||||||||||||||||||||||||
| 878 | - | |||||||||||||||||||||||||
| 879 | - | |||||||||||||||||||||||||
| 880 | - | |||||||||||||||||||||||||
| 881 | QTextCursor::QTextCursor(const QTextCursor &cursor) | - | ||||||||||||||||||||||||
| 882 | { | - | ||||||||||||||||||||||||
| 883 | d = cursor.d; | - | ||||||||||||||||||||||||
| 884 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 885 | - | |||||||||||||||||||||||||
| 886 | - | |||||||||||||||||||||||||
| 887 | - | |||||||||||||||||||||||||
| 888 | - | |||||||||||||||||||||||||
| 889 | - | |||||||||||||||||||||||||
| 890 | - | |||||||||||||||||||||||||
| 891 | - | |||||||||||||||||||||||||
| 892 | QTextCursor &QTextCursor::operator=(const QTextCursor &cursor) | - | ||||||||||||||||||||||||
| 893 | { | - | ||||||||||||||||||||||||
| 894 | d = cursor.d; | - | ||||||||||||||||||||||||
| 895 | return never executed: *this;return *this;never executed: return *this; | 0 | ||||||||||||||||||||||||
| 896 | } | - | ||||||||||||||||||||||||
| 897 | QTextCursor::~QTextCursor() | - | ||||||||||||||||||||||||
| 898 | { | - | ||||||||||||||||||||||||
| 899 | } | - | ||||||||||||||||||||||||
| 900 | - | |||||||||||||||||||||||||
| 901 | - | |||||||||||||||||||||||||
| 902 | - | |||||||||||||||||||||||||
| 903 | - | |||||||||||||||||||||||||
| 904 | - | |||||||||||||||||||||||||
| 905 | bool QTextCursor::isNull() const | - | ||||||||||||||||||||||||
| 906 | { | - | ||||||||||||||||||||||||
| 907 | return never executed: !d || !d->priv;return !d || !d->priv;never executed: return !d || !d->priv; | 0 | ||||||||||||||||||||||||
| 908 | } | - | ||||||||||||||||||||||||
| 909 | void QTextCursor::setPosition(int pos, MoveMode m) | - | ||||||||||||||||||||||||
| 910 | { | - | ||||||||||||||||||||||||
| 911 | if (!d
| 0 | ||||||||||||||||||||||||
| 912 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 913 | - | |||||||||||||||||||||||||
| 914 | if (pos < 0
| 0 | ||||||||||||||||||||||||
| 915 | QMessageLogger(__FILE__, 1155, __PRETTY_FUNCTION__).warning("QTextCursor::setPosition: Position '%d' out of range", pos); | - | ||||||||||||||||||||||||
| 916 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 917 | } | - | ||||||||||||||||||||||||
| 918 | - | |||||||||||||||||||||||||
| 919 | d->setPosition(pos); | - | ||||||||||||||||||||||||
| 920 | if (m == MoveAnchor
| 0 | ||||||||||||||||||||||||
| 921 | d->anchor = pos; | - | ||||||||||||||||||||||||
| 922 | d->adjusted_anchor = pos; | - | ||||||||||||||||||||||||
| 923 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 924 | QTextCursor::MoveOperation op; | - | ||||||||||||||||||||||||
| 925 | if (pos < d->anchor
| 0 | ||||||||||||||||||||||||
| 926 | op = QTextCursor::Left; never executed: op = QTextCursor::Left; | 0 | ||||||||||||||||||||||||
| 927 | else | - | ||||||||||||||||||||||||
| 928 | op = QTextCursor::Right; never executed: op = QTextCursor::Right; | 0 | ||||||||||||||||||||||||
| 929 | d->adjustCursor(op); | - | ||||||||||||||||||||||||
| 930 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 931 | d->setX(); | - | ||||||||||||||||||||||||
| 932 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 933 | - | |||||||||||||||||||||||||
| 934 | - | |||||||||||||||||||||||||
| 935 | - | |||||||||||||||||||||||||
| 936 | - | |||||||||||||||||||||||||
| 937 | - | |||||||||||||||||||||||||
| 938 | - | |||||||||||||||||||||||||
| 939 | - | |||||||||||||||||||||||||
| 940 | int QTextCursor::position() const | - | ||||||||||||||||||||||||
| 941 | { | - | ||||||||||||||||||||||||
| 942 | if (!d
| 0 | ||||||||||||||||||||||||
| 943 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 944 | return never executed: d->position;return d->position;never executed: return d->position; | 0 | ||||||||||||||||||||||||
| 945 | } | - | ||||||||||||||||||||||||
| 946 | int QTextCursor::positionInBlock() const | - | ||||||||||||||||||||||||
| 947 | { | - | ||||||||||||||||||||||||
| 948 | if (!d
| 0 | ||||||||||||||||||||||||
| 949 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 950 | return never executed: d->position - d->block().position();return d->position - d->block().position();never executed: return d->position - d->block().position(); | 0 | ||||||||||||||||||||||||
| 951 | } | - | ||||||||||||||||||||||||
| 952 | int QTextCursor::anchor() const | - | ||||||||||||||||||||||||
| 953 | { | - | ||||||||||||||||||||||||
| 954 | if (!d
| 0 | ||||||||||||||||||||||||
| 955 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 956 | return never executed: d->anchor;return d->anchor;never executed: return d->anchor; | 0 | ||||||||||||||||||||||||
| 957 | } | - | ||||||||||||||||||||||||
| 958 | bool QTextCursor::movePosition(MoveOperation op, MoveMode mode, int n) | - | ||||||||||||||||||||||||
| 959 | { | - | ||||||||||||||||||||||||
| 960 | if (!d
| 0 | ||||||||||||||||||||||||
| 961 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 962 | switch (op) { | - | ||||||||||||||||||||||||
| 963 | case never executed: Start:case Start:never executed: case Start: | 0 | ||||||||||||||||||||||||
| 964 | case never executed: StartOfLine:case StartOfLine:never executed: case StartOfLine: | 0 | ||||||||||||||||||||||||
| 965 | case never executed: End:case End:never executed: case End: | 0 | ||||||||||||||||||||||||
| 966 | case never executed: EndOfLine:case EndOfLine:never executed: case EndOfLine: | 0 | ||||||||||||||||||||||||
| 967 | n = 1; | - | ||||||||||||||||||||||||
| 968 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 969 | default never executed: :default:never executed: break;default:never executed: break; | 0 | ||||||||||||||||||||||||
| 970 | } | - | ||||||||||||||||||||||||
| 971 | - | |||||||||||||||||||||||||
| 972 | int previousPosition = d->position; | - | ||||||||||||||||||||||||
| 973 | for (; n > 0
| 0 | ||||||||||||||||||||||||
| 974 | if (!d->movePosition(op, mode)
| 0 | ||||||||||||||||||||||||
| 975 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 976 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 977 | - | |||||||||||||||||||||||||
| 978 | if (d->visualNavigation
| 0 | ||||||||||||||||||||||||
| 979 | QTextBlock b = d->block(); | - | ||||||||||||||||||||||||
| 980 | if (previousPosition < d->position
| 0 | ||||||||||||||||||||||||
| 981 | while (!b.next().isVisible()
| 0 | ||||||||||||||||||||||||
| 982 | b = b.next(); never executed: b = b.next(); | 0 | ||||||||||||||||||||||||
| 983 | d->setPosition(b.position() + b.length() - 1); | - | ||||||||||||||||||||||||
| 984 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 985 | while (!b.previous().isVisible()
| 0 | ||||||||||||||||||||||||
| 986 | b = b.previous(); never executed: b = b.previous(); | 0 | ||||||||||||||||||||||||
| 987 | d->setPosition(b.position()); | - | ||||||||||||||||||||||||
| 988 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 989 | if (mode == QTextCursor::MoveAnchor
| 0 | ||||||||||||||||||||||||
| 990 | d->anchor = d->position; never executed: d->anchor = d->position; | 0 | ||||||||||||||||||||||||
| 991 | while (d->movePosition(op, mode)
| 0 | ||||||||||||||||||||||||
| 992 | && !d->block().isVisible()
| 0 | ||||||||||||||||||||||||
| 993 | ; never executed: ; | 0 | ||||||||||||||||||||||||
| 994 | - | |||||||||||||||||||||||||
| 995 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 996 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 997 | } | - | ||||||||||||||||||||||||
| 998 | bool QTextCursor::visualNavigation() const | - | ||||||||||||||||||||||||
| 999 | { | - | ||||||||||||||||||||||||
| 1000 | return never executed: d ? d->visualNavigation : false;return d ? d->visualNavigation : false;never executed: return d ? d->visualNavigation : false; | 0 | ||||||||||||||||||||||||
| 1001 | } | - | ||||||||||||||||||||||||
| 1002 | void QTextCursor::setVisualNavigation(bool b) | - | ||||||||||||||||||||||||
| 1003 | { | - | ||||||||||||||||||||||||
| 1004 | if (d
| 0 | ||||||||||||||||||||||||
| 1005 | d->visualNavigation = b; never executed: d->visualNavigation = b; | 0 | ||||||||||||||||||||||||
| 1006 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1007 | void QTextCursor::setVerticalMovementX(int x) | - | ||||||||||||||||||||||||
| 1008 | { | - | ||||||||||||||||||||||||
| 1009 | if (d
| 0 | ||||||||||||||||||||||||
| 1010 | d->x = x; never executed: d->x = x; | 0 | ||||||||||||||||||||||||
| 1011 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1012 | int QTextCursor::verticalMovementX() const | - | ||||||||||||||||||||||||
| 1013 | { | - | ||||||||||||||||||||||||
| 1014 | return never executed: d ? d->x : -1;return d ? d->x : -1;never executed: return d ? d->x : -1; | 0 | ||||||||||||||||||||||||
| 1015 | } | - | ||||||||||||||||||||||||
| 1016 | bool QTextCursor::keepPositionOnInsert() const | - | ||||||||||||||||||||||||
| 1017 | { | - | ||||||||||||||||||||||||
| 1018 | return never executed: d ? d->keepPositionOnInsert : false;return d ? d->keepPositionOnInsert : false;never executed: return d ? d->keepPositionOnInsert : false; | 0 | ||||||||||||||||||||||||
| 1019 | } | - | ||||||||||||||||||||||||
| 1020 | void QTextCursor::setKeepPositionOnInsert(bool b) | - | ||||||||||||||||||||||||
| 1021 | { | - | ||||||||||||||||||||||||
| 1022 | if (d
| 0 | ||||||||||||||||||||||||
| 1023 | d->keepPositionOnInsert = b; never executed: d->keepPositionOnInsert = b; | 0 | ||||||||||||||||||||||||
| 1024 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1025 | void QTextCursor::insertText(const QString &text) | - | ||||||||||||||||||||||||
| 1026 | { | - | ||||||||||||||||||||||||
| 1027 | QTextCharFormat fmt = charFormat(); | - | ||||||||||||||||||||||||
| 1028 | fmt.clearProperty(QTextFormat::ObjectType); | - | ||||||||||||||||||||||||
| 1029 | insertText(text, fmt); | - | ||||||||||||||||||||||||
| 1030 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1031 | - | |||||||||||||||||||||||||
| 1032 | - | |||||||||||||||||||||||||
| 1033 | - | |||||||||||||||||||||||||
| 1034 | - | |||||||||||||||||||||||||
| 1035 | - | |||||||||||||||||||||||||
| 1036 | - | |||||||||||||||||||||||||
| 1037 | - | |||||||||||||||||||||||||
| 1038 | void QTextCursor::insertText(const QString &text, const QTextCharFormat &_format) | - | ||||||||||||||||||||||||
| 1039 | { | - | ||||||||||||||||||||||||
| 1040 | if (!d
| 0 | ||||||||||||||||||||||||
| 1041 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1042 | - | |||||||||||||||||||||||||
| 1043 | ((!(_format.isValid())) ? qt_assert("_format.isValid()",__FILE__,1417) : qt_noop()); | - | ||||||||||||||||||||||||
| 1044 | - | |||||||||||||||||||||||||
| 1045 | QTextCharFormat format = _format; | - | ||||||||||||||||||||||||
| 1046 | format.clearProperty(QTextFormat::ObjectIndex); | - | ||||||||||||||||||||||||
| 1047 | - | |||||||||||||||||||||||||
| 1048 | bool hasEditBlock = false; | - | ||||||||||||||||||||||||
| 1049 | - | |||||||||||||||||||||||||
| 1050 | if (d->anchor != d->position
| 0 | ||||||||||||||||||||||||
| 1051 | hasEditBlock = true; | - | ||||||||||||||||||||||||
| 1052 | d->priv->beginEditBlock(); | - | ||||||||||||||||||||||||
| 1053 | d->remove(); | - | ||||||||||||||||||||||||
| 1054 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1055 | - | |||||||||||||||||||||||||
| 1056 | if (!text.isEmpty()
| 0 | ||||||||||||||||||||||||
| 1057 | QTextFormatCollection *formats = d->priv->formatCollection(); | - | ||||||||||||||||||||||||
| 1058 | int formatIdx = formats->indexForFormat(format); | - | ||||||||||||||||||||||||
| 1059 | ((!(formats->format(formatIdx).isCharFormat())) ? qt_assert("formats->format(formatIdx).isCharFormat()",__FILE__,1433) : qt_noop()); | - | ||||||||||||||||||||||||
| 1060 | - | |||||||||||||||||||||||||
| 1061 | QTextBlockFormat blockFmt = blockFormat(); | - | ||||||||||||||||||||||||
| 1062 | - | |||||||||||||||||||||||||
| 1063 | - | |||||||||||||||||||||||||
| 1064 | int textStart = d->priv->text.length(); | - | ||||||||||||||||||||||||
| 1065 | int blockStart = 0; | - | ||||||||||||||||||||||||
| 1066 | d->priv->text += text; | - | ||||||||||||||||||||||||
| 1067 | int textEnd = d->priv->text.length(); | - | ||||||||||||||||||||||||
| 1068 | - | |||||||||||||||||||||||||
| 1069 | for (int i = 0; i < text.length()
| 0 | ||||||||||||||||||||||||
| 1070 | QChar ch = text.at(i); | - | ||||||||||||||||||||||||
| 1071 | - | |||||||||||||||||||||||||
| 1072 | const int blockEnd = i; | - | ||||||||||||||||||||||||
| 1073 | - | |||||||||||||||||||||||||
| 1074 | if (ch == QLatin1Char('\r')
| 0 | ||||||||||||||||||||||||
| 1075 | && (
| 0 | ||||||||||||||||||||||||
| 1076 | && text.at(i + 1) == QLatin1Char('\n')
| 0 | ||||||||||||||||||||||||
| 1077 | ++i; | - | ||||||||||||||||||||||||
| 1078 | ch = text.at(i); | - | ||||||||||||||||||||||||
| 1079 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1080 | - | |||||||||||||||||||||||||
| 1081 | if (ch == QLatin1Char('\n')
| 0 | ||||||||||||||||||||||||
| 1082 | || ch == QChar::ParagraphSeparator
| 0 | ||||||||||||||||||||||||
| 1083 | || ch == QChar(0xfdd0)
| 0 | ||||||||||||||||||||||||
| 1084 | || ch == QChar(0xfdd1)
| 0 | ||||||||||||||||||||||||
| 1085 | || ch == QLatin1Char('\r')
| 0 | ||||||||||||||||||||||||
| 1086 | - | |||||||||||||||||||||||||
| 1087 | if (!hasEditBlock
| 0 | ||||||||||||||||||||||||
| 1088 | hasEditBlock = true; | - | ||||||||||||||||||||||||
| 1089 | d->priv->beginEditBlock(); | - | ||||||||||||||||||||||||
| 1090 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1091 | - | |||||||||||||||||||||||||
| 1092 | if (blockEnd > blockStart
| 0 | ||||||||||||||||||||||||
| 1093 | d->priv->insert(d->position, textStart + blockStart, blockEnd - blockStart, formatIdx); never executed: d->priv->insert(d->position, textStart + blockStart, blockEnd - blockStart, formatIdx); | 0 | ||||||||||||||||||||||||
| 1094 | - | |||||||||||||||||||||||||
| 1095 | d->insertBlock(blockFmt, format); | - | ||||||||||||||||||||||||
| 1096 | blockStart = i + 1; | - | ||||||||||||||||||||||||
| 1097 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1098 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1099 | if (textStart + blockStart < textEnd
| 0 | ||||||||||||||||||||||||
| 1100 | d->priv->insert(d->position, textStart + blockStart, textEnd - textStart - blockStart, formatIdx); never executed: d->priv->insert(d->position, textStart + blockStart, textEnd - textStart - blockStart, formatIdx); | 0 | ||||||||||||||||||||||||
| 1101 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1102 | if (hasEditBlock
| 0 | ||||||||||||||||||||||||
| 1103 | d->priv->endEditBlock(); never executed: d->priv->endEditBlock(); | 0 | ||||||||||||||||||||||||
| 1104 | d->setX(); | - | ||||||||||||||||||||||||
| 1105 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1106 | - | |||||||||||||||||||||||||
| 1107 | - | |||||||||||||||||||||||||
| 1108 | - | |||||||||||||||||||||||||
| 1109 | - | |||||||||||||||||||||||||
| 1110 | - | |||||||||||||||||||||||||
| 1111 | - | |||||||||||||||||||||||||
| 1112 | - | |||||||||||||||||||||||||
| 1113 | void QTextCursor::deleteChar() | - | ||||||||||||||||||||||||
| 1114 | { | - | ||||||||||||||||||||||||
| 1115 | if (!d
| 0 | ||||||||||||||||||||||||
| 1116 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1117 | - | |||||||||||||||||||||||||
| 1118 | if (d->position != d->anchor
| 0 | ||||||||||||||||||||||||
| 1119 | removeSelectedText(); | - | ||||||||||||||||||||||||
| 1120 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1121 | } | - | ||||||||||||||||||||||||
| 1122 | - | |||||||||||||||||||||||||
| 1123 | if (!d->canDelete(d->position)
| 0 | ||||||||||||||||||||||||
| 1124 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1125 | d->adjusted_anchor = d->anchor = | - | ||||||||||||||||||||||||
| 1126 | d->priv->nextCursorPosition(d->anchor, QTextLayout::SkipCharacters); | - | ||||||||||||||||||||||||
| 1127 | d->remove(); | - | ||||||||||||||||||||||||
| 1128 | d->setX(); | - | ||||||||||||||||||||||||
| 1129 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1130 | - | |||||||||||||||||||||||||
| 1131 | - | |||||||||||||||||||||||||
| 1132 | - | |||||||||||||||||||||||||
| 1133 | - | |||||||||||||||||||||||||
| 1134 | - | |||||||||||||||||||||||||
| 1135 | - | |||||||||||||||||||||||||
| 1136 | - | |||||||||||||||||||||||||
| 1137 | void QTextCursor::deletePreviousChar() | - | ||||||||||||||||||||||||
| 1138 | { | - | ||||||||||||||||||||||||
| 1139 | if (!d
| 0 | ||||||||||||||||||||||||
| 1140 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1141 | - | |||||||||||||||||||||||||
| 1142 | if (d->position != d->anchor
| 0 | ||||||||||||||||||||||||
| 1143 | removeSelectedText(); | - | ||||||||||||||||||||||||
| 1144 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1145 | } | - | ||||||||||||||||||||||||
| 1146 | - | |||||||||||||||||||||||||
| 1147 | if (d->anchor < 1
| 0 | ||||||||||||||||||||||||
| 1148 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1149 | d->anchor--; | - | ||||||||||||||||||||||||
| 1150 | - | |||||||||||||||||||||||||
| 1151 | QTextDocumentPrivate::FragmentIterator fragIt = d->priv->find(d->anchor); | - | ||||||||||||||||||||||||
| 1152 | const QTextFragmentData * const frag = fragIt.value(); | - | ||||||||||||||||||||||||
| 1153 | int fpos = fragIt.position(); | - | ||||||||||||||||||||||||
| 1154 | QChar uc = d->priv->buffer().at(d->anchor - fpos + frag->stringPosition); | - | ||||||||||||||||||||||||
| 1155 | if (d->anchor > fpos
| 0 | ||||||||||||||||||||||||
| 1156 | - | |||||||||||||||||||||||||
| 1157 | - | |||||||||||||||||||||||||
| 1158 | uc = d->priv->buffer().at(d->anchor - 1 - fpos + frag->stringPosition); | - | ||||||||||||||||||||||||
| 1159 | if (uc.isHighSurrogate()
| 0 | ||||||||||||||||||||||||
| 1160 | -- never executed: d->anchor;--d->anchor;never executed: --d->anchor; | 0 | ||||||||||||||||||||||||
| 1161 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1162 | - | |||||||||||||||||||||||||
| 1163 | d->adjusted_anchor = d->anchor; | - | ||||||||||||||||||||||||
| 1164 | d->remove(); | - | ||||||||||||||||||||||||
| 1165 | d->setX(); | - | ||||||||||||||||||||||||
| 1166 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1167 | - | |||||||||||||||||||||||||
| 1168 | - | |||||||||||||||||||||||||
| 1169 | - | |||||||||||||||||||||||||
| 1170 | - | |||||||||||||||||||||||||
| 1171 | void QTextCursor::select(SelectionType selection) | - | ||||||||||||||||||||||||
| 1172 | { | - | ||||||||||||||||||||||||
| 1173 | if (!d
| 0 | ||||||||||||||||||||||||
| 1174 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1175 | - | |||||||||||||||||||||||||
| 1176 | clearSelection(); | - | ||||||||||||||||||||||||
| 1177 | - | |||||||||||||||||||||||||
| 1178 | const QTextBlock block = d->block(); | - | ||||||||||||||||||||||||
| 1179 | - | |||||||||||||||||||||||||
| 1180 | switch (selection) { | - | ||||||||||||||||||||||||
| 1181 | case never executed: LineUnderCursor:case LineUnderCursor:never executed: case LineUnderCursor: | 0 | ||||||||||||||||||||||||
| 1182 | movePosition(StartOfLine); | - | ||||||||||||||||||||||||
| 1183 | movePosition(EndOfLine, KeepAnchor); | - | ||||||||||||||||||||||||
| 1184 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1185 | case never executed: WordUnderCursor:case WordUnderCursor:never executed: case WordUnderCursor: | 0 | ||||||||||||||||||||||||
| 1186 | movePosition(StartOfWord); | - | ||||||||||||||||||||||||
| 1187 | movePosition(EndOfWord, KeepAnchor); | - | ||||||||||||||||||||||||
| 1188 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1189 | case never executed: BlockUnderCursor:case BlockUnderCursor:never executed: case BlockUnderCursor: | 0 | ||||||||||||||||||||||||
| 1190 | if (block.length() == 1
| 0 | ||||||||||||||||||||||||
| 1191 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1192 | movePosition(StartOfBlock); | - | ||||||||||||||||||||||||
| 1193 | - | |||||||||||||||||||||||||
| 1194 | if (movePosition(PreviousBlock)
| 0 | ||||||||||||||||||||||||
| 1195 | movePosition(EndOfBlock); | - | ||||||||||||||||||||||||
| 1196 | movePosition(NextBlock, KeepAnchor); | - | ||||||||||||||||||||||||
| 1197 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1198 | movePosition(EndOfBlock, KeepAnchor); | - | ||||||||||||||||||||||||
| 1199 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1200 | case never executed: Document:case Document:never executed: case Document: | 0 | ||||||||||||||||||||||||
| 1201 | movePosition(Start); | - | ||||||||||||||||||||||||
| 1202 | movePosition(End, KeepAnchor); | - | ||||||||||||||||||||||||
| 1203 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 1204 | } | - | ||||||||||||||||||||||||
| 1205 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1206 | - | |||||||||||||||||||||||||
| 1207 | - | |||||||||||||||||||||||||
| 1208 | - | |||||||||||||||||||||||||
| 1209 | - | |||||||||||||||||||||||||
| 1210 | bool QTextCursor::hasSelection() const | - | ||||||||||||||||||||||||
| 1211 | { | - | ||||||||||||||||||||||||
| 1212 | return never executed: !!d && d->position != d->anchor;return !!d && d->position != d->anchor;never executed: return !!d && d->position != d->anchor; | 0 | ||||||||||||||||||||||||
| 1213 | } | - | ||||||||||||||||||||||||
| 1214 | bool QTextCursor::hasComplexSelection() const | - | ||||||||||||||||||||||||
| 1215 | { | - | ||||||||||||||||||||||||
| 1216 | if (!d
| 0 | ||||||||||||||||||||||||
| 1217 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1218 | - | |||||||||||||||||||||||||
| 1219 | return never executed: d->complexSelectionTable() != 0;return d->complexSelectionTable() != 0;never executed: return d->complexSelectionTable() != 0; | 0 | ||||||||||||||||||||||||
| 1220 | } | - | ||||||||||||||||||||||||
| 1221 | void QTextCursor::selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const | - | ||||||||||||||||||||||||
| 1222 | { | - | ||||||||||||||||||||||||
| 1223 | *firstRow = -1; | - | ||||||||||||||||||||||||
| 1224 | *firstColumn = -1; | - | ||||||||||||||||||||||||
| 1225 | *numRows = -1; | - | ||||||||||||||||||||||||
| 1226 | *numColumns = -1; | - | ||||||||||||||||||||||||
| 1227 | - | |||||||||||||||||||||||||
| 1228 | if (!d
| 0 | ||||||||||||||||||||||||
| 1229 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1230 | - | |||||||||||||||||||||||||
| 1231 | d->selectedTableCells(firstRow, numRows, firstColumn, numColumns); | - | ||||||||||||||||||||||||
| 1232 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1233 | void QTextCursor::clearSelection() | - | ||||||||||||||||||||||||
| 1234 | { | - | ||||||||||||||||||||||||
| 1235 | if (!d
| 0 | ||||||||||||||||||||||||
| 1236 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1237 | d->adjusted_anchor = d->anchor = d->position; | - | ||||||||||||||||||||||||
| 1238 | d->currentCharFormat = -1; | - | ||||||||||||||||||||||||
| 1239 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1240 | - | |||||||||||||||||||||||||
| 1241 | - | |||||||||||||||||||||||||
| 1242 | - | |||||||||||||||||||||||||
| 1243 | - | |||||||||||||||||||||||||
| 1244 | - | |||||||||||||||||||||||||
| 1245 | - | |||||||||||||||||||||||||
| 1246 | - | |||||||||||||||||||||||||
| 1247 | void QTextCursor::removeSelectedText() | - | ||||||||||||||||||||||||
| 1248 | { | - | ||||||||||||||||||||||||
| 1249 | if (!d
| 0 | ||||||||||||||||||||||||
| 1250 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1251 | - | |||||||||||||||||||||||||
| 1252 | d->priv->beginEditBlock(); | - | ||||||||||||||||||||||||
| 1253 | d->remove(); | - | ||||||||||||||||||||||||
| 1254 | d->priv->endEditBlock(); | - | ||||||||||||||||||||||||
| 1255 | d->setX(); | - | ||||||||||||||||||||||||
| 1256 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1257 | - | |||||||||||||||||||||||||
| 1258 | - | |||||||||||||||||||||||||
| 1259 | - | |||||||||||||||||||||||||
| 1260 | - | |||||||||||||||||||||||||
| 1261 | - | |||||||||||||||||||||||||
| 1262 | - | |||||||||||||||||||||||||
| 1263 | - | |||||||||||||||||||||||||
| 1264 | int QTextCursor::selectionStart() const | - | ||||||||||||||||||||||||
| 1265 | { | - | ||||||||||||||||||||||||
| 1266 | if (!d
| 0 | ||||||||||||||||||||||||
| 1267 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 1268 | return never executed: qMin(d->position, d->adjusted_anchor);return qMin(d->position, d->adjusted_anchor);never executed: return qMin(d->position, d->adjusted_anchor); | 0 | ||||||||||||||||||||||||
| 1269 | } | - | ||||||||||||||||||||||||
| 1270 | - | |||||||||||||||||||||||||
| 1271 | - | |||||||||||||||||||||||||
| 1272 | - | |||||||||||||||||||||||||
| 1273 | - | |||||||||||||||||||||||||
| 1274 | - | |||||||||||||||||||||||||
| 1275 | - | |||||||||||||||||||||||||
| 1276 | - | |||||||||||||||||||||||||
| 1277 | int QTextCursor::selectionEnd() const | - | ||||||||||||||||||||||||
| 1278 | { | - | ||||||||||||||||||||||||
| 1279 | if (!d
| 0 | ||||||||||||||||||||||||
| 1280 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 1281 | return never executed: qMax(d->position, d->adjusted_anchor);return qMax(d->position, d->adjusted_anchor);never executed: return qMax(d->position, d->adjusted_anchor); | 0 | ||||||||||||||||||||||||
| 1282 | } | - | ||||||||||||||||||||||||
| 1283 | - | |||||||||||||||||||||||||
| 1284 | static void getText(QString &text, QTextDocumentPrivate *priv, const QString &docText, int pos, int end) | - | ||||||||||||||||||||||||
| 1285 | { | - | ||||||||||||||||||||||||
| 1286 | while (pos < end
| 0 | ||||||||||||||||||||||||
| 1287 | QTextDocumentPrivate::FragmentIterator fragIt = priv->find(pos); | - | ||||||||||||||||||||||||
| 1288 | const QTextFragmentData * const frag = fragIt.value(); | - | ||||||||||||||||||||||||
| 1289 | - | |||||||||||||||||||||||||
| 1290 | const int offsetInFragment = qMax(0, pos - fragIt.position()); | - | ||||||||||||||||||||||||
| 1291 | const int len = qMin(int(frag->size_array[0] - offsetInFragment), end - pos); | - | ||||||||||||||||||||||||
| 1292 | - | |||||||||||||||||||||||||
| 1293 | text += QString(docText.constData() + frag->stringPosition + offsetInFragment, len); | - | ||||||||||||||||||||||||
| 1294 | pos += len; | - | ||||||||||||||||||||||||
| 1295 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1296 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1297 | QString QTextCursor::selectedText() const | - | ||||||||||||||||||||||||
| 1298 | { | - | ||||||||||||||||||||||||
| 1299 | if (!d
| 0 | ||||||||||||||||||||||||
| 1300 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||||||||
| 1301 | - | |||||||||||||||||||||||||
| 1302 | const QString docText = d->priv->buffer(); | - | ||||||||||||||||||||||||
| 1303 | QString text; | - | ||||||||||||||||||||||||
| 1304 | - | |||||||||||||||||||||||||
| 1305 | QTextTable *table = d->complexSelectionTable(); | - | ||||||||||||||||||||||||
| 1306 | if (table
| 0 | ||||||||||||||||||||||||
| 1307 | int row_start, col_start, num_rows, num_cols; | - | ||||||||||||||||||||||||
| 1308 | selectedTableCells(&row_start, &num_rows, &col_start, &num_cols); | - | ||||||||||||||||||||||||
| 1309 | - | |||||||||||||||||||||||||
| 1310 | ((!(row_start != -1)) ? qt_assert("row_start != -1",__FILE__,1723) : qt_noop()); | - | ||||||||||||||||||||||||
| 1311 | for (int r = row_start; r < row_start + num_rows
| 0 | ||||||||||||||||||||||||
| 1312 | for (int c = col_start; c < col_start + num_cols
| 0 | ||||||||||||||||||||||||
| 1313 | QTextTableCell cell = table->cellAt(r, c); | - | ||||||||||||||||||||||||
| 1314 | int rspan = cell.rowSpan(); | - | ||||||||||||||||||||||||
| 1315 | int cspan = cell.columnSpan(); | - | ||||||||||||||||||||||||
| 1316 | if (rspan != 1
| 0 | ||||||||||||||||||||||||
| 1317 | int cr = cell.row(); | - | ||||||||||||||||||||||||
| 1318 | if (cr != r
| 0 | ||||||||||||||||||||||||
| 1319 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1320 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1321 | if (cspan != 1
| 0 | ||||||||||||||||||||||||
| 1322 | int cc = cell.column(); | - | ||||||||||||||||||||||||
| 1323 | if (cc != c
| 0 | ||||||||||||||||||||||||
| 1324 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1325 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1326 | - | |||||||||||||||||||||||||
| 1327 | getText(text, d->priv, docText, cell.firstPosition(), cell.lastPosition()); | - | ||||||||||||||||||||||||
| 1328 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1329 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1330 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1331 | getText(text, d->priv, docText, selectionStart(), selectionEnd()); | - | ||||||||||||||||||||||||
| 1332 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1333 | - | |||||||||||||||||||||||||
| 1334 | return never executed: text;return text;never executed: return text; | 0 | ||||||||||||||||||||||||
| 1335 | } | - | ||||||||||||||||||||||||
| 1336 | QTextDocumentFragment QTextCursor::selection() const | - | ||||||||||||||||||||||||
| 1337 | { | - | ||||||||||||||||||||||||
| 1338 | return never executed: QTextDocumentFragment(*this);return QTextDocumentFragment(*this);never executed: return QTextDocumentFragment(*this); | 0 | ||||||||||||||||||||||||
| 1339 | } | - | ||||||||||||||||||||||||
| 1340 | - | |||||||||||||||||||||||||
| 1341 | - | |||||||||||||||||||||||||
| 1342 | - | |||||||||||||||||||||||||
| 1343 | - | |||||||||||||||||||||||||
| 1344 | QTextBlock QTextCursor::block() const | - | ||||||||||||||||||||||||
| 1345 | { | - | ||||||||||||||||||||||||
| 1346 | if (!d
| 0 | ||||||||||||||||||||||||
| 1347 | return never executed: QTextBlock();return QTextBlock();never executed: return QTextBlock(); | 0 | ||||||||||||||||||||||||
| 1348 | return never executed: d->block();return d->block();never executed: return d->block(); | 0 | ||||||||||||||||||||||||
| 1349 | } | - | ||||||||||||||||||||||||
| 1350 | - | |||||||||||||||||||||||||
| 1351 | - | |||||||||||||||||||||||||
| 1352 | - | |||||||||||||||||||||||||
| 1353 | - | |||||||||||||||||||||||||
| 1354 | - | |||||||||||||||||||||||||
| 1355 | - | |||||||||||||||||||||||||
| 1356 | QTextBlockFormat QTextCursor::blockFormat() const | - | ||||||||||||||||||||||||
| 1357 | { | - | ||||||||||||||||||||||||
| 1358 | if (!d
| 0 | ||||||||||||||||||||||||
| 1359 | return never executed: QTextBlockFormat();return QTextBlockFormat();never executed: return QTextBlockFormat(); | 0 | ||||||||||||||||||||||||
| 1360 | - | |||||||||||||||||||||||||
| 1361 | return never executed: d->block().blockFormat();return d->block().blockFormat();never executed: return d->block().blockFormat(); | 0 | ||||||||||||||||||||||||
| 1362 | } | - | ||||||||||||||||||||||||
| 1363 | - | |||||||||||||||||||||||||
| 1364 | - | |||||||||||||||||||||||||
| 1365 | - | |||||||||||||||||||||||||
| 1366 | - | |||||||||||||||||||||||||
| 1367 | - | |||||||||||||||||||||||||
| 1368 | - | |||||||||||||||||||||||||
| 1369 | - | |||||||||||||||||||||||||
| 1370 | void QTextCursor::setBlockFormat(const QTextBlockFormat &format) | - | ||||||||||||||||||||||||
| 1371 | { | - | ||||||||||||||||||||||||
| 1372 | if (!d
| 0 | ||||||||||||||||||||||||
| 1373 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1374 | - | |||||||||||||||||||||||||
| 1375 | d->setBlockFormat(format, QTextDocumentPrivate::SetFormat); | - | ||||||||||||||||||||||||
| 1376 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1377 | void QTextCursor::mergeBlockFormat(const QTextBlockFormat &modifier) | - | ||||||||||||||||||||||||
| 1378 | { | - | ||||||||||||||||||||||||
| 1379 | if (!d
| 0 | ||||||||||||||||||||||||
| 1380 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1381 | - | |||||||||||||||||||||||||
| 1382 | d->setBlockFormat(modifier, QTextDocumentPrivate::MergeFormat); | - | ||||||||||||||||||||||||
| 1383 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1384 | QTextCharFormat QTextCursor::blockCharFormat() const | - | ||||||||||||||||||||||||
| 1385 | { | - | ||||||||||||||||||||||||
| 1386 | if (!d
| 0 | ||||||||||||||||||||||||
| 1387 | return never executed: QTextCharFormat();return QTextCharFormat();never executed: return QTextCharFormat(); | 0 | ||||||||||||||||||||||||
| 1388 | - | |||||||||||||||||||||||||
| 1389 | return never executed: d->block().charFormat();return d->block().charFormat();never executed: return d->block().charFormat(); | 0 | ||||||||||||||||||||||||
| 1390 | } | - | ||||||||||||||||||||||||
| 1391 | - | |||||||||||||||||||||||||
| 1392 | - | |||||||||||||||||||||||||
| 1393 | - | |||||||||||||||||||||||||
| 1394 | - | |||||||||||||||||||||||||
| 1395 | - | |||||||||||||||||||||||||
| 1396 | - | |||||||||||||||||||||||||
| 1397 | - | |||||||||||||||||||||||||
| 1398 | void QTextCursor::setBlockCharFormat(const QTextCharFormat &format) | - | ||||||||||||||||||||||||
| 1399 | { | - | ||||||||||||||||||||||||
| 1400 | if (!d
| 0 | ||||||||||||||||||||||||
| 1401 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1402 | - | |||||||||||||||||||||||||
| 1403 | d->setBlockCharFormat(format, QTextDocumentPrivate::SetFormatAndPreserveObjectIndices); | - | ||||||||||||||||||||||||
| 1404 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1405 | void QTextCursor::mergeBlockCharFormat(const QTextCharFormat &modifier) | - | ||||||||||||||||||||||||
| 1406 | { | - | ||||||||||||||||||||||||
| 1407 | if (!d
| 0 | ||||||||||||||||||||||||
| 1408 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1409 | - | |||||||||||||||||||||||||
| 1410 | d->setBlockCharFormat(modifier, QTextDocumentPrivate::MergeFormat); | - | ||||||||||||||||||||||||
| 1411 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1412 | QTextCharFormat QTextCursor::charFormat() const | - | ||||||||||||||||||||||||
| 1413 | { | - | ||||||||||||||||||||||||
| 1414 | if (!d
| 0 | ||||||||||||||||||||||||
| 1415 | return never executed: QTextCharFormat();return QTextCharFormat();never executed: return QTextCharFormat(); | 0 | ||||||||||||||||||||||||
| 1416 | - | |||||||||||||||||||||||||
| 1417 | int idx = d->currentCharFormat; | - | ||||||||||||||||||||||||
| 1418 | if (idx == -1
| 0 | ||||||||||||||||||||||||
| 1419 | QTextBlock block = d->block(); | - | ||||||||||||||||||||||||
| 1420 | - | |||||||||||||||||||||||||
| 1421 | int pos; | - | ||||||||||||||||||||||||
| 1422 | if (d->position == block.position()
| 0 | ||||||||||||||||||||||||
| 1423 | && block.length() > 1
| 0 | ||||||||||||||||||||||||
| 1424 | pos = d->position; never executed: pos = d->position; | 0 | ||||||||||||||||||||||||
| 1425 | else | - | ||||||||||||||||||||||||
| 1426 | pos = d->position - 1; never executed: pos = d->position - 1; | 0 | ||||||||||||||||||||||||
| 1427 | - | |||||||||||||||||||||||||
| 1428 | if (pos == -1
| 0 | ||||||||||||||||||||||||
| 1429 | idx = d->priv->blockCharFormatIndex(d->priv->blockMap().firstNode()); | - | ||||||||||||||||||||||||
| 1430 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 1431 | ((!(pos >= 0 && pos < d->priv->length())) ? qt_assert("pos >= 0 && pos < d->priv->length()",__FILE__,1890) : qt_noop()); | - | ||||||||||||||||||||||||
| 1432 | - | |||||||||||||||||||||||||
| 1433 | QTextDocumentPrivate::FragmentIterator it = d->priv->find(pos); | - | ||||||||||||||||||||||||
| 1434 | ((!(!it.atEnd())) ? qt_assert("!it.atEnd()",__FILE__,1893) : qt_noop()); | - | ||||||||||||||||||||||||
| 1435 | idx = it.value()->format; | - | ||||||||||||||||||||||||
| 1436 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1437 | } | - | ||||||||||||||||||||||||
| 1438 | - | |||||||||||||||||||||||||
| 1439 | QTextCharFormat cfmt = d->priv->formatCollection()->charFormat(idx); | - | ||||||||||||||||||||||||
| 1440 | cfmt.clearProperty(QTextFormat::ObjectIndex); | - | ||||||||||||||||||||||||
| 1441 | - | |||||||||||||||||||||||||
| 1442 | ((!(cfmt.isValid())) ? qt_assert("cfmt.isValid()",__FILE__,1901) : qt_noop()); | - | ||||||||||||||||||||||||
| 1443 | return never executed: cfmt;return cfmt;never executed: return cfmt; | 0 | ||||||||||||||||||||||||
| 1444 | } | - | ||||||||||||||||||||||||
| 1445 | void QTextCursor::setCharFormat(const QTextCharFormat &format) | - | ||||||||||||||||||||||||
| 1446 | { | - | ||||||||||||||||||||||||
| 1447 | if (!d
| 0 | ||||||||||||||||||||||||
| 1448 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1449 | if (d->position == d->anchor
| 0 | ||||||||||||||||||||||||
| 1450 | d->currentCharFormat = d->priv->formatCollection()->indexForFormat(format); | - | ||||||||||||||||||||||||
| 1451 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1452 | } | - | ||||||||||||||||||||||||
| 1453 | d->setCharFormat(format, QTextDocumentPrivate::SetFormatAndPreserveObjectIndices); | - | ||||||||||||||||||||||||
| 1454 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1455 | void QTextCursor::mergeCharFormat(const QTextCharFormat &modifier) | - | ||||||||||||||||||||||||
| 1456 | { | - | ||||||||||||||||||||||||
| 1457 | if (!d
| 0 | ||||||||||||||||||||||||
| 1458 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1459 | if (d->position == d->anchor
| 0 | ||||||||||||||||||||||||
| 1460 | QTextCharFormat format = charFormat(); | - | ||||||||||||||||||||||||
| 1461 | format.merge(modifier); | - | ||||||||||||||||||||||||
| 1462 | d->currentCharFormat = d->priv->formatCollection()->indexForFormat(format); | - | ||||||||||||||||||||||||
| 1463 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1464 | } | - | ||||||||||||||||||||||||
| 1465 | - | |||||||||||||||||||||||||
| 1466 | d->setCharFormat(modifier, QTextDocumentPrivate::MergeFormat); | - | ||||||||||||||||||||||||
| 1467 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1468 | - | |||||||||||||||||||||||||
| 1469 | - | |||||||||||||||||||||||||
| 1470 | - | |||||||||||||||||||||||||
| 1471 | - | |||||||||||||||||||||||||
| 1472 | - | |||||||||||||||||||||||||
| 1473 | - | |||||||||||||||||||||||||
| 1474 | - | |||||||||||||||||||||||||
| 1475 | bool QTextCursor::atBlockStart() const | - | ||||||||||||||||||||||||
| 1476 | { | - | ||||||||||||||||||||||||
| 1477 | if (!d
| 0 | ||||||||||||||||||||||||
| 1478 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1479 | - | |||||||||||||||||||||||||
| 1480 | return never executed: d->position == d->block().position();return d->position == d->block().position();never executed: return d->position == d->block().position(); | 0 | ||||||||||||||||||||||||
| 1481 | } | - | ||||||||||||||||||||||||
| 1482 | - | |||||||||||||||||||||||||
| 1483 | - | |||||||||||||||||||||||||
| 1484 | - | |||||||||||||||||||||||||
| 1485 | - | |||||||||||||||||||||||||
| 1486 | - | |||||||||||||||||||||||||
| 1487 | - | |||||||||||||||||||||||||
| 1488 | - | |||||||||||||||||||||||||
| 1489 | bool QTextCursor::atBlockEnd() const | - | ||||||||||||||||||||||||
| 1490 | { | - | ||||||||||||||||||||||||
| 1491 | if (!d
| 0 | ||||||||||||||||||||||||
| 1492 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1493 | - | |||||||||||||||||||||||||
| 1494 | return never executed: d->position == d->block().position() + d->block().length() - 1;return d->position == d->block().position() + d->block().length() - 1;never executed: return d->position == d->block().position() + d->block().length() - 1; | 0 | ||||||||||||||||||||||||
| 1495 | } | - | ||||||||||||||||||||||||
| 1496 | - | |||||||||||||||||||||||||
| 1497 | - | |||||||||||||||||||||||||
| 1498 | - | |||||||||||||||||||||||||
| 1499 | - | |||||||||||||||||||||||||
| 1500 | - | |||||||||||||||||||||||||
| 1501 | - | |||||||||||||||||||||||||
| 1502 | - | |||||||||||||||||||||||||
| 1503 | bool QTextCursor::atStart() const | - | ||||||||||||||||||||||||
| 1504 | { | - | ||||||||||||||||||||||||
| 1505 | if (!d
| 0 | ||||||||||||||||||||||||
| 1506 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1507 | - | |||||||||||||||||||||||||
| 1508 | return never executed: d->position == 0;return d->position == 0;never executed: return d->position == 0; | 0 | ||||||||||||||||||||||||
| 1509 | } | - | ||||||||||||||||||||||||
| 1510 | bool QTextCursor::atEnd() const | - | ||||||||||||||||||||||||
| 1511 | { | - | ||||||||||||||||||||||||
| 1512 | if (!d
| 0 | ||||||||||||||||||||||||
| 1513 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1514 | - | |||||||||||||||||||||||||
| 1515 | return never executed: d->position == d->priv->length() - 1;return d->position == d->priv->length() - 1;never executed: return d->position == d->priv->length() - 1; | 0 | ||||||||||||||||||||||||
| 1516 | } | - | ||||||||||||||||||||||||
| 1517 | - | |||||||||||||||||||||||||
| 1518 | - | |||||||||||||||||||||||||
| 1519 | - | |||||||||||||||||||||||||
| 1520 | - | |||||||||||||||||||||||||
| 1521 | - | |||||||||||||||||||||||||
| 1522 | - | |||||||||||||||||||||||||
| 1523 | - | |||||||||||||||||||||||||
| 1524 | void QTextCursor::insertBlock() | - | ||||||||||||||||||||||||
| 1525 | { | - | ||||||||||||||||||||||||
| 1526 | insertBlock(blockFormat()); | - | ||||||||||||||||||||||||
| 1527 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1528 | void QTextCursor::insertBlock(const QTextBlockFormat &format) | - | ||||||||||||||||||||||||
| 1529 | { | - | ||||||||||||||||||||||||
| 1530 | QTextCharFormat charFmt = charFormat(); | - | ||||||||||||||||||||||||
| 1531 | charFmt.clearProperty(QTextFormat::ObjectType); | - | ||||||||||||||||||||||||
| 1532 | insertBlock(format, charFmt); | - | ||||||||||||||||||||||||
| 1533 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1534 | void QTextCursor::insertBlock(const QTextBlockFormat &format, const QTextCharFormat &_charFormat) | - | ||||||||||||||||||||||||
| 1535 | { | - | ||||||||||||||||||||||||
| 1536 | if (!d
| 0 | ||||||||||||||||||||||||
| 1537 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1538 | - | |||||||||||||||||||||||||
| 1539 | QTextCharFormat charFormat = _charFormat; | - | ||||||||||||||||||||||||
| 1540 | charFormat.clearProperty(QTextFormat::ObjectIndex); | - | ||||||||||||||||||||||||
| 1541 | - | |||||||||||||||||||||||||
| 1542 | d->priv->beginEditBlock(); | - | ||||||||||||||||||||||||
| 1543 | d->remove(); | - | ||||||||||||||||||||||||
| 1544 | d->insertBlock(format, charFormat); | - | ||||||||||||||||||||||||
| 1545 | d->priv->endEditBlock(); | - | ||||||||||||||||||||||||
| 1546 | d->setX(); | - | ||||||||||||||||||||||||
| 1547 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1548 | QTextList *QTextCursor::insertList(const QTextListFormat &format) | - | ||||||||||||||||||||||||
| 1549 | { | - | ||||||||||||||||||||||||
| 1550 | insertBlock(); | - | ||||||||||||||||||||||||
| 1551 | return never executed: createList(format);return createList(format);never executed: return createList(format); | 0 | ||||||||||||||||||||||||
| 1552 | } | - | ||||||||||||||||||||||||
| 1553 | QTextList *QTextCursor::insertList(QTextListFormat::Style style) | - | ||||||||||||||||||||||||
| 1554 | { | - | ||||||||||||||||||||||||
| 1555 | insertBlock(); | - | ||||||||||||||||||||||||
| 1556 | return never executed: createList(style);return createList(style);never executed: return createList(style); | 0 | ||||||||||||||||||||||||
| 1557 | } | - | ||||||||||||||||||||||||
| 1558 | - | |||||||||||||||||||||||||
| 1559 | - | |||||||||||||||||||||||||
| 1560 | - | |||||||||||||||||||||||||
| 1561 | - | |||||||||||||||||||||||||
| 1562 | - | |||||||||||||||||||||||||
| 1563 | - | |||||||||||||||||||||||||
| 1564 | - | |||||||||||||||||||||||||
| 1565 | QTextList *QTextCursor::createList(const QTextListFormat &format) | - | ||||||||||||||||||||||||
| 1566 | { | - | ||||||||||||||||||||||||
| 1567 | if (!d
| 0 | ||||||||||||||||||||||||
| 1568 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1569 | - | |||||||||||||||||||||||||
| 1570 | QTextList *list = static_cast<QTextList *>(d->priv->createObject(format)); | - | ||||||||||||||||||||||||
| 1571 | QTextBlockFormat modifier; | - | ||||||||||||||||||||||||
| 1572 | modifier.setObjectIndex(list->objectIndex()); | - | ||||||||||||||||||||||||
| 1573 | mergeBlockFormat(modifier); | - | ||||||||||||||||||||||||
| 1574 | return never executed: list;return list;never executed: return list; | 0 | ||||||||||||||||||||||||
| 1575 | } | - | ||||||||||||||||||||||||
| 1576 | QTextList *QTextCursor::createList(QTextListFormat::Style style) | - | ||||||||||||||||||||||||
| 1577 | { | - | ||||||||||||||||||||||||
| 1578 | QTextListFormat fmt; | - | ||||||||||||||||||||||||
| 1579 | fmt.setStyle(style); | - | ||||||||||||||||||||||||
| 1580 | return never executed: createList(fmt);return createList(fmt);never executed: return createList(fmt); | 0 | ||||||||||||||||||||||||
| 1581 | } | - | ||||||||||||||||||||||||
| 1582 | - | |||||||||||||||||||||||||
| 1583 | - | |||||||||||||||||||||||||
| 1584 | - | |||||||||||||||||||||||||
| 1585 | - | |||||||||||||||||||||||||
| 1586 | - | |||||||||||||||||||||||||
| 1587 | - | |||||||||||||||||||||||||
| 1588 | - | |||||||||||||||||||||||||
| 1589 | QTextList *QTextCursor::currentList() const | - | ||||||||||||||||||||||||
| 1590 | { | - | ||||||||||||||||||||||||
| 1591 | if (!d
| 0 | ||||||||||||||||||||||||
| 1592 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1593 | - | |||||||||||||||||||||||||
| 1594 | QTextBlockFormat b = blockFormat(); | - | ||||||||||||||||||||||||
| 1595 | QTextObject *o = d->priv->objectForFormat(b); | - | ||||||||||||||||||||||||
| 1596 | return never executed: qobject_cast<QTextList *>(o);return qobject_cast<QTextList *>(o);never executed: return qobject_cast<QTextList *>(o); | 0 | ||||||||||||||||||||||||
| 1597 | } | - | ||||||||||||||||||||||||
| 1598 | QTextTable *QTextCursor::insertTable(int rows, int cols) | - | ||||||||||||||||||||||||
| 1599 | { | - | ||||||||||||||||||||||||
| 1600 | return never executed: insertTable(rows, cols, QTextTableFormat());return insertTable(rows, cols, QTextTableFormat());never executed: return insertTable(rows, cols, QTextTableFormat()); | 0 | ||||||||||||||||||||||||
| 1601 | } | - | ||||||||||||||||||||||||
| 1602 | QTextTable *QTextCursor::insertTable(int rows, int cols, const QTextTableFormat &format) | - | ||||||||||||||||||||||||
| 1603 | { | - | ||||||||||||||||||||||||
| 1604 | if(!d
| 0 | ||||||||||||||||||||||||
| 1605 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1606 | - | |||||||||||||||||||||||||
| 1607 | int pos = d->position; | - | ||||||||||||||||||||||||
| 1608 | QTextTable *t = QTextTablePrivate::createTable(d->priv, d->position, rows, cols, format); | - | ||||||||||||||||||||||||
| 1609 | d->setPosition(pos+1); | - | ||||||||||||||||||||||||
| 1610 | - | |||||||||||||||||||||||||
| 1611 | d->anchor = d->position; | - | ||||||||||||||||||||||||
| 1612 | d->adjusted_anchor = d->anchor; | - | ||||||||||||||||||||||||
| 1613 | return never executed: t;return t;never executed: return t; | 0 | ||||||||||||||||||||||||
| 1614 | } | - | ||||||||||||||||||||||||
| 1615 | - | |||||||||||||||||||||||||
| 1616 | - | |||||||||||||||||||||||||
| 1617 | - | |||||||||||||||||||||||||
| 1618 | - | |||||||||||||||||||||||||
| 1619 | - | |||||||||||||||||||||||||
| 1620 | - | |||||||||||||||||||||||||
| 1621 | - | |||||||||||||||||||||||||
| 1622 | QTextTable *QTextCursor::currentTable() const | - | ||||||||||||||||||||||||
| 1623 | { | - | ||||||||||||||||||||||||
| 1624 | if(!d
| 0 | ||||||||||||||||||||||||
| 1625 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1626 | - | |||||||||||||||||||||||||
| 1627 | QTextFrame *frame = d->priv->frameAt(d->position); | - | ||||||||||||||||||||||||
| 1628 | while (frame
| 0 | ||||||||||||||||||||||||
| 1629 | QTextTable *table = qobject_cast<QTextTable *>(frame); | - | ||||||||||||||||||||||||
| 1630 | if (table
| 0 | ||||||||||||||||||||||||
| 1631 | return never executed: table;return table;never executed: return table; | 0 | ||||||||||||||||||||||||
| 1632 | frame = frame->parentFrame(); | - | ||||||||||||||||||||||||
| 1633 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1634 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1635 | } | - | ||||||||||||||||||||||||
| 1636 | QTextFrame *QTextCursor::insertFrame(const QTextFrameFormat &format) | - | ||||||||||||||||||||||||
| 1637 | { | - | ||||||||||||||||||||||||
| 1638 | if (!d
| 0 | ||||||||||||||||||||||||
| 1639 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1640 | - | |||||||||||||||||||||||||
| 1641 | return never executed: d->priv->insertFrame(selectionStart(), selectionEnd(), format);return d->priv->insertFrame(selectionStart(), selectionEnd(), format);never executed: return d->priv->insertFrame(selectionStart(), selectionEnd(), format); | 0 | ||||||||||||||||||||||||
| 1642 | } | - | ||||||||||||||||||||||||
| 1643 | - | |||||||||||||||||||||||||
| 1644 | - | |||||||||||||||||||||||||
| 1645 | - | |||||||||||||||||||||||||
| 1646 | - | |||||||||||||||||||||||||
| 1647 | - | |||||||||||||||||||||||||
| 1648 | - | |||||||||||||||||||||||||
| 1649 | QTextFrame *QTextCursor::currentFrame() const | - | ||||||||||||||||||||||||
| 1650 | { | - | ||||||||||||||||||||||||
| 1651 | if(!d
| 0 | ||||||||||||||||||||||||
| 1652 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1653 | - | |||||||||||||||||||||||||
| 1654 | return never executed: d->priv->frameAt(d->position);return d->priv->frameAt(d->position);never executed: return d->priv->frameAt(d->position); | 0 | ||||||||||||||||||||||||
| 1655 | } | - | ||||||||||||||||||||||||
| 1656 | - | |||||||||||||||||||||||||
| 1657 | - | |||||||||||||||||||||||||
| 1658 | - | |||||||||||||||||||||||||
| 1659 | - | |||||||||||||||||||||||||
| 1660 | - | |||||||||||||||||||||||||
| 1661 | void QTextCursor::insertFragment(const QTextDocumentFragment &fragment) | - | ||||||||||||||||||||||||
| 1662 | { | - | ||||||||||||||||||||||||
| 1663 | if (!d
| 0 | ||||||||||||||||||||||||
| 1664 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1665 | - | |||||||||||||||||||||||||
| 1666 | d->priv->beginEditBlock(); | - | ||||||||||||||||||||||||
| 1667 | d->remove(); | - | ||||||||||||||||||||||||
| 1668 | fragment.d->insert(*this); | - | ||||||||||||||||||||||||
| 1669 | d->priv->endEditBlock(); | - | ||||||||||||||||||||||||
| 1670 | - | |||||||||||||||||||||||||
| 1671 | if (fragment.d
| 0 | ||||||||||||||||||||||||
| 1672 | d->priv->mergeCachedResources(fragment.d->doc->docHandle()); never executed: d->priv->mergeCachedResources(fragment.d->doc->docHandle()); | 0 | ||||||||||||||||||||||||
| 1673 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1674 | void QTextCursor::insertHtml(const QString &html) | - | ||||||||||||||||||||||||
| 1675 | { | - | ||||||||||||||||||||||||
| 1676 | if (!d
| 0 | ||||||||||||||||||||||||
| 1677 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1678 | QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(html, d->priv->document()); | - | ||||||||||||||||||||||||
| 1679 | insertFragment(fragment); | - | ||||||||||||||||||||||||
| 1680 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1681 | void QTextCursor::insertImage(const QTextImageFormat &format, QTextFrameFormat::Position alignment) | - | ||||||||||||||||||||||||
| 1682 | { | - | ||||||||||||||||||||||||
| 1683 | if (!d
| 0 | ||||||||||||||||||||||||
| 1684 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1685 | - | |||||||||||||||||||||||||
| 1686 | QTextFrameFormat ffmt; | - | ||||||||||||||||||||||||
| 1687 | ffmt.setPosition(alignment); | - | ||||||||||||||||||||||||
| 1688 | QTextObject *obj = d->priv->createObject(ffmt); | - | ||||||||||||||||||||||||
| 1689 | - | |||||||||||||||||||||||||
| 1690 | QTextImageFormat fmt = format; | - | ||||||||||||||||||||||||
| 1691 | fmt.setObjectIndex(obj->objectIndex()); | - | ||||||||||||||||||||||||
| 1692 | - | |||||||||||||||||||||||||
| 1693 | d->priv->beginEditBlock(); | - | ||||||||||||||||||||||||
| 1694 | d->remove(); | - | ||||||||||||||||||||||||
| 1695 | const int idx = d->priv->formatCollection()->indexForFormat(fmt); | - | ||||||||||||||||||||||||
| 1696 | d->priv->insert(d->position, QString(QChar(QChar::ObjectReplacementCharacter)), idx); | - | ||||||||||||||||||||||||
| 1697 | d->priv->endEditBlock(); | - | ||||||||||||||||||||||||
| 1698 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1699 | - | |||||||||||||||||||||||||
| 1700 | - | |||||||||||||||||||||||||
| 1701 | - | |||||||||||||||||||||||||
| 1702 | - | |||||||||||||||||||||||||
| 1703 | void QTextCursor::insertImage(const QTextImageFormat &format) | - | ||||||||||||||||||||||||
| 1704 | { | - | ||||||||||||||||||||||||
| 1705 | insertText(QString(QChar::ObjectReplacementCharacter), format); | - | ||||||||||||||||||||||||
| 1706 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1707 | void QTextCursor::insertImage(const QString &name) | - | ||||||||||||||||||||||||
| 1708 | { | - | ||||||||||||||||||||||||
| 1709 | QTextImageFormat format; | - | ||||||||||||||||||||||||
| 1710 | format.setName(name); | - | ||||||||||||||||||||||||
| 1711 | insertImage(format); | - | ||||||||||||||||||||||||
| 1712 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1713 | void QTextCursor::insertImage(const QImage &image, const QString &name) | - | ||||||||||||||||||||||||
| 1714 | { | - | ||||||||||||||||||||||||
| 1715 | if (image.isNull()
| 0 | ||||||||||||||||||||||||
| 1716 | QMessageLogger(__FILE__, 2329, __PRETTY_FUNCTION__).warning("QTextCursor::insertImage: attempt to add an invalid image"); | - | ||||||||||||||||||||||||
| 1717 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1718 | } | - | ||||||||||||||||||||||||
| 1719 | QString imageName = name; | - | ||||||||||||||||||||||||
| 1720 | if (name.isEmpty()
| 0 | ||||||||||||||||||||||||
| 1721 | imageName = QString::number(image.cacheKey()); never executed: imageName = QString::number(image.cacheKey()); | 0 | ||||||||||||||||||||||||
| 1722 | d->priv->document()->addResource(QTextDocument::ImageResource, QUrl(imageName), image); | - | ||||||||||||||||||||||||
| 1723 | QTextImageFormat format; | - | ||||||||||||||||||||||||
| 1724 | format.setName(imageName); | - | ||||||||||||||||||||||||
| 1725 | insertImage(format); | - | ||||||||||||||||||||||||
| 1726 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1727 | - | |||||||||||||||||||||||||
| 1728 | - | |||||||||||||||||||||||||
| 1729 | - | |||||||||||||||||||||||||
| 1730 | - | |||||||||||||||||||||||||
| 1731 | - | |||||||||||||||||||||||||
| 1732 | - | |||||||||||||||||||||||||
| 1733 | - | |||||||||||||||||||||||||
| 1734 | bool QTextCursor::operator!=(const QTextCursor &rhs) const | - | ||||||||||||||||||||||||
| 1735 | { | - | ||||||||||||||||||||||||
| 1736 | return never executed: !operator==(rhs);return !operator==(rhs);never executed: return !operator==(rhs); | 0 | ||||||||||||||||||||||||
| 1737 | } | - | ||||||||||||||||||||||||
| 1738 | - | |||||||||||||||||||||||||
| 1739 | - | |||||||||||||||||||||||||
| 1740 | - | |||||||||||||||||||||||||
| 1741 | - | |||||||||||||||||||||||||
| 1742 | - | |||||||||||||||||||||||||
| 1743 | - | |||||||||||||||||||||||||
| 1744 | - | |||||||||||||||||||||||||
| 1745 | bool QTextCursor::operator<(const QTextCursor &rhs) const | - | ||||||||||||||||||||||||
| 1746 | { | - | ||||||||||||||||||||||||
| 1747 | if (!d
| 0 | ||||||||||||||||||||||||
| 1748 | return never executed: !!rhs.d;return !!rhs.d;never executed: return !!rhs.d; | 0 | ||||||||||||||||||||||||
| 1749 | - | |||||||||||||||||||||||||
| 1750 | if (!rhs.d
| 0 | ||||||||||||||||||||||||
| 1751 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1752 | - | |||||||||||||||||||||||||
| 1753 | ((!(d->priv == rhs.d->priv)) ? qt_assert_x("QTextCursor::operator<", "cannot compare cursors attached to different documents",__FILE__,2366) : qt_noop()); | - | ||||||||||||||||||||||||
| 1754 | - | |||||||||||||||||||||||||
| 1755 | return never executed: d->position < rhs.d->position;return d->position < rhs.d->position;never executed: return d->position < rhs.d->position; | 0 | ||||||||||||||||||||||||
| 1756 | } | - | ||||||||||||||||||||||||
| 1757 | bool QTextCursor::operator<=(const QTextCursor &rhs) const | - | ||||||||||||||||||||||||
| 1758 | { | - | ||||||||||||||||||||||||
| 1759 | if (!d
| 0 | ||||||||||||||||||||||||
| 1760 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 1761 | - | |||||||||||||||||||||||||
| 1762 | if (!rhs.d
| 0 | ||||||||||||||||||||||||
| 1763 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1764 | - | |||||||||||||||||||||||||
| 1765 | ((!(d->priv == rhs.d->priv)) ? qt_assert_x("QTextCursor::operator<=", "cannot compare cursors attached to different documents",__FILE__,2386) : qt_noop()); | - | ||||||||||||||||||||||||
| 1766 | - | |||||||||||||||||||||||||
| 1767 | return never executed: d->position <= rhs.d->position;return d->position <= rhs.d->position;never executed: return d->position <= rhs.d->position; | 0 | ||||||||||||||||||||||||
| 1768 | } | - | ||||||||||||||||||||||||
| 1769 | - | |||||||||||||||||||||||||
| 1770 | - | |||||||||||||||||||||||||
| 1771 | - | |||||||||||||||||||||||||
| 1772 | - | |||||||||||||||||||||||||
| 1773 | - | |||||||||||||||||||||||||
| 1774 | - | |||||||||||||||||||||||||
| 1775 | - | |||||||||||||||||||||||||
| 1776 | bool QTextCursor::operator==(const QTextCursor &rhs) const | - | ||||||||||||||||||||||||
| 1777 | { | - | ||||||||||||||||||||||||
| 1778 | if (!d
| 0 | ||||||||||||||||||||||||
| 1779 | return never executed: !rhs.d;return !rhs.d;never executed: return !rhs.d; | 0 | ||||||||||||||||||||||||
| 1780 | - | |||||||||||||||||||||||||
| 1781 | if (!rhs.d
| 0 | ||||||||||||||||||||||||
| 1782 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1783 | - | |||||||||||||||||||||||||
| 1784 | return never executed: d->position == rhs.d->position && d->priv == rhs.d->priv;return d->position == rhs.d->position && d->priv == rhs.d->priv;never executed: return d->position == rhs.d->position && d->priv == rhs.d->priv; | 0 | ||||||||||||||||||||||||
| 1785 | } | - | ||||||||||||||||||||||||
| 1786 | bool QTextCursor::operator>=(const QTextCursor &rhs) const | - | ||||||||||||||||||||||||
| 1787 | { | - | ||||||||||||||||||||||||
| 1788 | if (!d
| 0 | ||||||||||||||||||||||||
| 1789 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1790 | - | |||||||||||||||||||||||||
| 1791 | if (!rhs.d
| 0 | ||||||||||||||||||||||||
| 1792 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 1793 | - | |||||||||||||||||||||||||
| 1794 | ((!(d->priv == rhs.d->priv)) ? qt_assert_x("QTextCursor::operator>=", "cannot compare cursors attached to different documents",__FILE__,2423) : qt_noop()); | - | ||||||||||||||||||||||||
| 1795 | - | |||||||||||||||||||||||||
| 1796 | return never executed: d->position >= rhs.d->position;return d->position >= rhs.d->position;never executed: return d->position >= rhs.d->position; | 0 | ||||||||||||||||||||||||
| 1797 | } | - | ||||||||||||||||||||||||
| 1798 | - | |||||||||||||||||||||||||
| 1799 | - | |||||||||||||||||||||||||
| 1800 | - | |||||||||||||||||||||||||
| 1801 | - | |||||||||||||||||||||||||
| 1802 | - | |||||||||||||||||||||||||
| 1803 | - | |||||||||||||||||||||||||
| 1804 | - | |||||||||||||||||||||||||
| 1805 | bool QTextCursor::operator>(const QTextCursor &rhs) const | - | ||||||||||||||||||||||||
| 1806 | { | - | ||||||||||||||||||||||||
| 1807 | if (!d
| 0 | ||||||||||||||||||||||||
| 1808 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 1809 | - | |||||||||||||||||||||||||
| 1810 | if (!rhs.d
| 0 | ||||||||||||||||||||||||
| 1811 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 1812 | - | |||||||||||||||||||||||||
| 1813 | ((!(d->priv == rhs.d->priv)) ? qt_assert_x("QTextCursor::operator>", "cannot compare cursors attached to different documents",__FILE__,2442) : qt_noop()); | - | ||||||||||||||||||||||||
| 1814 | - | |||||||||||||||||||||||||
| 1815 | return never executed: d->position > rhs.d->position;return d->position > rhs.d->position;never executed: return d->position > rhs.d->position; | 0 | ||||||||||||||||||||||||
| 1816 | } | - | ||||||||||||||||||||||||
| 1817 | void QTextCursor::beginEditBlock() | - | ||||||||||||||||||||||||
| 1818 | { | - | ||||||||||||||||||||||||
| 1819 | if (!d
| 0 | ||||||||||||||||||||||||
| 1820 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1821 | - | |||||||||||||||||||||||||
| 1822 | if (d->priv->editBlock == 0
| 0 | ||||||||||||||||||||||||
| 1823 | d->priv->editBlockCursorPosition = d->position; never executed: d->priv->editBlockCursorPosition = d->position; | 0 | ||||||||||||||||||||||||
| 1824 | - | |||||||||||||||||||||||||
| 1825 | d->priv->beginEditBlock(); | - | ||||||||||||||||||||||||
| 1826 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1827 | void QTextCursor::joinPreviousEditBlock() | - | ||||||||||||||||||||||||
| 1828 | { | - | ||||||||||||||||||||||||
| 1829 | if (!d
| 0 | ||||||||||||||||||||||||
| 1830 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1831 | - | |||||||||||||||||||||||||
| 1832 | d->priv->joinPreviousEditBlock(); | - | ||||||||||||||||||||||||
| 1833 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1834 | void QTextCursor::endEditBlock() | - | ||||||||||||||||||||||||
| 1835 | { | - | ||||||||||||||||||||||||
| 1836 | if (!d
| 0 | ||||||||||||||||||||||||
| 1837 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1838 | - | |||||||||||||||||||||||||
| 1839 | d->priv->endEditBlock(); | - | ||||||||||||||||||||||||
| 1840 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1841 | bool QTextCursor::isCopyOf(const QTextCursor &other) const | - | ||||||||||||||||||||||||
| 1842 | { | - | ||||||||||||||||||||||||
| 1843 | return never executed: d == other.d;return d == other.d;never executed: return d == other.d; | 0 | ||||||||||||||||||||||||
| 1844 | } | - | ||||||||||||||||||||||||
| 1845 | int QTextCursor::blockNumber() const | - | ||||||||||||||||||||||||
| 1846 | { | - | ||||||||||||||||||||||||
| 1847 | if (!d
| 0 | ||||||||||||||||||||||||
| 1848 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1849 | - | |||||||||||||||||||||||||
| 1850 | return never executed: d->block().blockNumber();return d->block().blockNumber();never executed: return d->block().blockNumber(); | 0 | ||||||||||||||||||||||||
| 1851 | } | - | ||||||||||||||||||||||||
| 1852 | int QTextCursor::columnNumber() const | - | ||||||||||||||||||||||||
| 1853 | { | - | ||||||||||||||||||||||||
| 1854 | if (!d
| 0 | ||||||||||||||||||||||||
| 1855 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1856 | - | |||||||||||||||||||||||||
| 1857 | QTextBlock block = d->block(); | - | ||||||||||||||||||||||||
| 1858 | if (!block.isValid()
| 0 | ||||||||||||||||||||||||
| 1859 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1860 | - | |||||||||||||||||||||||||
| 1861 | const QTextLayout *layout = d->blockLayout(block); | - | ||||||||||||||||||||||||
| 1862 | - | |||||||||||||||||||||||||
| 1863 | const int relativePos = d->position - block.position(); | - | ||||||||||||||||||||||||
| 1864 | - | |||||||||||||||||||||||||
| 1865 | if (layout->lineCount() == 0
| 0 | ||||||||||||||||||||||||
| 1866 | return never executed: relativePos;return relativePos;never executed: return relativePos; | 0 | ||||||||||||||||||||||||
| 1867 | - | |||||||||||||||||||||||||
| 1868 | QTextLine line = layout->lineForTextPosition(relativePos); | - | ||||||||||||||||||||||||
| 1869 | if (!line.isValid()
| 0 | ||||||||||||||||||||||||
| 1870 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1871 | return never executed: relativePos - line.textStart();return relativePos - line.textStart();never executed: return relativePos - line.textStart(); | 0 | ||||||||||||||||||||||||
| 1872 | } | - | ||||||||||||||||||||||||
| 1873 | - | |||||||||||||||||||||||||
| 1874 | - | |||||||||||||||||||||||||
| 1875 | - | |||||||||||||||||||||||||
| 1876 | - | |||||||||||||||||||||||||
| 1877 | - | |||||||||||||||||||||||||
| 1878 | QTextDocument *QTextCursor::document() const | - | ||||||||||||||||||||||||
| 1879 | { | - | ||||||||||||||||||||||||
| 1880 | if (d->priv
| 0 | ||||||||||||||||||||||||
| 1881 | return never executed: d->priv->document();return d->priv->document();never executed: return d->priv->document(); | 0 | ||||||||||||||||||||||||
| 1882 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 1883 | } | - | ||||||||||||||||||||||||
| 1884 | - | |||||||||||||||||||||||||
| 1885 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |