Changeset 846 for trunk/src/gui/text/qtextcursor.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/text/qtextcursor.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 65 65 QTextCursorPrivate::QTextCursorPrivate(QTextDocumentPrivate *p) 66 66 : priv(p), x(0), position(0), anchor(0), adjusted_anchor(0), 67 currentCharFormat(-1), visualNavigation(false) 67 currentCharFormat(-1), visualNavigation(false), keepPositionOnInsert(false), 68 changed(false) 68 69 { 69 70 priv->addCursor(this); … … 80 81 currentCharFormat = rhs.currentCharFormat; 81 82 visualNavigation = rhs.visualNavigation; 83 keepPositionOnInsert = rhs.keepPositionOnInsert; 84 changed = rhs.changed; 82 85 priv->addCursor(this); 83 86 } … … 96 99 || (position == positionOfChange 97 100 && (op == QTextUndoCommand::KeepCursor 98 || anchor < position)101 || keepPositionOnInsert) 99 102 ) 100 103 ) { … … 361 364 QTextBlock blockIt = block(); 362 365 366 if (!blockIt.isValid()) 367 return false; 368 363 369 if (op >= QTextCursor::Left && op <= QTextCursor::WordRight 364 && blockIt. blockFormat().layoutDirection() == Qt::RightToLeft) {370 && blockIt.textDirection() == Qt::RightToLeft) { 365 371 if (op == QTextCursor::Left) 366 372 op = QTextCursor::NextCharacter; … … 1146 1152 The cursor is positioned between characters. 1147 1153 1148 \sa setPosition() movePosition() anchor() 1154 \sa setPosition() movePosition() anchor() positionInBlock() 1149 1155 */ 1150 1156 int QTextCursor::position() const … … 1153 1159 return -1; 1154 1160 return d->position; 1161 } 1162 1163 /*! 1164 \since 4.7 1165 Returns the relative position of the cursor within the block. 1166 The cursor is positioned between characters. 1167 1168 This is equivalent to \c{ position() - block().position()}. 1169 1170 \sa position() 1171 */ 1172 int QTextCursor::positionInBlock() const 1173 { 1174 if (!d || !d->priv) 1175 return 0; 1176 return d->position - d->block().position(); 1155 1177 } 1156 1178 … … 1261 1283 } 1262 1284 1285 1286 /*! 1287 \since 4.7 1288 1289 Sets the visual x position for vertical cursor movements to \a x. 1290 1291 The vertical movement x position is cleared automatically when the cursor moves horizontally, and kept 1292 unchanged when the cursor moves vertically. The mechanism allows the cursor to move up and down on a 1293 visually straight line with proportional fonts, and to gently "jump" over short lines. 1294 1295 A value of -1 indicates no predefined x position. It will then be set automatically the next time the 1296 cursor moves up or down. 1297 1298 \sa verticalMovementX() 1299 */ 1300 void QTextCursor::setVerticalMovementX(int x) 1301 { 1302 if (d) 1303 d->x = x; 1304 } 1305 1306 /*! \since 4.7 1307 1308 Returns the visual x position for vertical cursor movements. 1309 1310 A value of -1 indicates no predefined x position. It will then be set automatically the next time the 1311 cursor moves up or down. 1312 1313 \sa setVerticalMovementX() 1314 */ 1315 int QTextCursor::verticalMovementX() const 1316 { 1317 return d ? d->x : -1; 1318 } 1319 1320 /*! 1321 \since 4.7 1322 1323 Returns whether the cursor should keep its current position when text gets inserted at the position of the 1324 cursor. 1325 1326 The default is false; 1327 1328 \sa setKeepPositionOnInsert() 1329 */ 1330 bool QTextCursor::keepPositionOnInsert() const 1331 { 1332 return d ? d->keepPositionOnInsert : false; 1333 } 1334 1335 /*! 1336 \since 4.7 1337 1338 Defines whether the cursor should keep its current position when text gets inserted at the current position of the 1339 cursor. 1340 1341 If \a b is true, the cursor keeps its current position when text gets inserted at the positing of the cursor. 1342 If \a b is false, the cursor moves along with the inserted text. 1343 1344 The default is false. 1345 1346 Note that a cursor always moves when text is inserted before the current position of the cursor, and it 1347 always keeps its position when text is inserted after the current position of the cursor. 1348 1349 \sa keepPositionOnInsert() 1350 */ 1351 void QTextCursor::setKeepPositionOnInsert(bool b) 1352 { 1353 if (d) 1354 d->keepPositionOnInsert = b; 1355 } 1356 1357 1358 1263 1359 /*! 1264 1360 Inserts \a text at the current position, using the current … … 1393 1489 if (!d || !d->priv) 1394 1490 return; 1395 1491 1396 1492 if (d->position != d->anchor) { 1397 1493 removeSelectedText(); 1398 1494 return; 1399 1495 } 1400 1496 1401 1497 if (d->anchor < 1 || !d->canDelete(d->anchor-1)) 1402 1498 return; 1403 1499 d->anchor--; 1404 1500 1405 1501 QTextDocumentPrivate::FragmentIterator fragIt = d->priv->find(d->anchor); 1406 1502 const QTextFragmentData * const frag = fragIt.value(); … … 1414 1510 --d->anchor; 1415 1511 } 1416 1512 1417 1513 d->adjusted_anchor = d->anchor; 1418 1514 d->remove(); … … 2347 2443 return; 2348 2444 2445 if (d->priv->editBlock == 0) // we are the initial edit block, store current cursor position for undo 2446 d->priv->editBlockCursorPosition = d->position; 2447 2349 2448 d->priv->beginEditBlock(); 2350 2449 } … … 2415 2514 } 2416 2515 2516 2417 2517 /*! 2418 2518 \since 4.2 2419 2519 Returns the position of the cursor within its containing line. 2520 2521 Note that this is the column number relative to a wrapped line, 2522 not relative to the block (i.e. the paragraph). 2523 2524 You probably want to call positionInBlock() instead. 2525 2526 \sa positionInBlock() 2420 2527 */ 2421 2528 int QTextCursor::columnNumber() const
Note:
See TracChangeset
for help on using the changeset viewer.