Changeset 561 for trunk/src/gui/text/qtextcursor.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/text/qtextcursor.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 93 93 QTextCursorPrivate::AdjustResult result = QTextCursorPrivate::CursorMoved; 94 94 // not(!) <= , so that inserting text adjusts the cursor correctly 95 if (position < positionOfChange || 96 (position == positionOfChange && op == QTextUndoCommand::KeepCursor)) { 95 if (position < positionOfChange 96 || (position == positionOfChange 97 && (op == QTextUndoCommand::KeepCursor 98 || anchor < position) 99 ) 100 ) { 97 101 result = CursorUnchanged; 98 102 } else { … … 126 130 void QTextCursorPrivate::setX() 127 131 { 128 if (priv && priv->isInEditBlock()) {132 if (priv->isInEditBlock()) { 129 133 x = -1; // mark dirty 130 134 return; … … 146 150 if (anchor == position) 147 151 return; 148 priv->beginEditBlock();149 152 currentCharFormat = -1; 150 153 int pos1 = position; … … 160 163 QTextTable *table = complexSelectionTable(); 161 164 if (table) { 165 priv->beginEditBlock(); 162 166 int startRow, startCol, numRows, numCols; 163 167 selectedTableCells(&startRow, &numRows, &startCol, &numCols); 164 168 clearCells(table, startRow, startCol, numRows, numCols, op); 169 adjusted_anchor = anchor = position; 170 priv->endEditBlock(); 165 171 } else { 166 172 priv->remove(pos1, pos2-pos1, op); 167 }168 169 adjusted_anchor = anchor = position;170 priv->endEditBlock(); 173 adjusted_anchor = anchor = position; 174 priv->finishEdit(); 175 } 176 171 177 } 172 178 … … 854 860 \brief The QTextCursor class offers an API to access and modify QTextDocuments. 855 861 856 \ingroup text862 \ingroup richtext-processing 857 863 \ingroup shared 858 \mainclass 864 859 865 860 866 Text cursors are objects that are used to access and modify the contents … … 1075 1081 1076 1082 /*! 1077 Makes a copy of \a cursor and assigns it to this QTextCursor. 1083 Makes a copy of \a cursor and assigns it to this QTextCursor. Note 1084 that QTextCursor is an \l{Implicitly Shared Classes}{implicitly 1085 shared} class. 1086 1078 1087 */ 1079 1088 QTextCursor &QTextCursor::operator=(const QTextCursor &cursor) … … 1289 1298 format.clearProperty(QTextFormat::ObjectIndex); 1290 1299 1291 d->priv->beginEditBlock(); 1292 1293 d->remove(); 1300 bool hasEditBlock = false; 1301 1302 if (d->anchor != d->position) { 1303 hasEditBlock = true; 1304 d->priv->beginEditBlock(); 1305 d->remove(); 1306 } 1307 1294 1308 if (!text.isEmpty()) { 1295 1309 QTextFormatCollection *formats = d->priv->formatCollection(); … … 1319 1333 if (ch == QLatin1Char('\n') 1320 1334 || ch == QChar::ParagraphSeparator 1335 || ch == QTextBeginningOfFrame 1336 || ch == QTextEndOfFrame 1321 1337 || ch == QLatin1Char('\r')) { 1338 1339 if (!hasEditBlock) { 1340 hasEditBlock = true; 1341 d->priv->beginEditBlock(); 1342 } 1322 1343 1323 1344 if (blockEnd > blockStart) … … 1331 1352 d->priv->insert(d->position, textStart + blockStart, textEnd - textStart - blockStart, formatIdx); 1332 1353 } 1333 d->priv->endEditBlock(); 1354 if (hasEditBlock) 1355 d->priv->endEditBlock(); 1334 1356 d->setX(); 1335 1357 } … … 1346 1368 return; 1347 1369 1348 if (d->position == d->anchor) { 1349 if (!d->canDelete(d->position)) 1350 return; 1351 d->adjusted_anchor = d->anchor = 1352 d->priv->nextCursorPosition(d->anchor, QTextLayout::SkipCharacters); 1353 } 1370 if (d->position != d->anchor) { 1371 removeSelectedText(); 1372 return; 1373 } 1374 1375 if (!d->canDelete(d->position)) 1376 return; 1377 d->adjusted_anchor = d->anchor = 1378 d->priv->nextCursorPosition(d->anchor, QTextLayout::SkipCharacters); 1354 1379 d->remove(); 1355 1380 d->setX(); … … 1366 1391 if (!d || !d->priv) 1367 1392 return; 1368 1369 if (d->position == d->anchor) { 1370 if (d->anchor < 1 || !d->canDelete(d->anchor-1)) 1371 return; 1372 d->anchor--; 1373 1374 QTextDocumentPrivate::FragmentIterator fragIt = d->priv->find(d->anchor); 1375 const QTextFragmentData * const frag = fragIt.value(); 1376 int fpos = fragIt.position(); 1377 QChar uc = d->priv->buffer().at(d->anchor - fpos + frag->stringPosition); 1378 if (d->anchor > fpos && uc.unicode() >= 0xdc00 && uc.unicode() < 0xe000) { 1379 // second half of a surrogate, check if we have the first half as well, 1380 // if yes delete both at once 1381 uc = d->priv->buffer().at(d->anchor - 1 - fpos + frag->stringPosition); 1382 if (uc.unicode() >= 0xd800 && uc.unicode() < 0xdc00) 1383 --d->anchor; 1384 } 1385 1386 d->adjusted_anchor = d->anchor; 1387 } 1388 1393 1394 if (d->position != d->anchor) { 1395 removeSelectedText(); 1396 return; 1397 } 1398 1399 if (d->anchor < 1 || !d->canDelete(d->anchor-1)) 1400 return; 1401 d->anchor--; 1402 1403 QTextDocumentPrivate::FragmentIterator fragIt = d->priv->find(d->anchor); 1404 const QTextFragmentData * const frag = fragIt.value(); 1405 int fpos = fragIt.position(); 1406 QChar uc = d->priv->buffer().at(d->anchor - fpos + frag->stringPosition); 1407 if (d->anchor > fpos && uc.unicode() >= 0xdc00 && uc.unicode() < 0xe000) { 1408 // second half of a surrogate, check if we have the first half as well, 1409 // if yes delete both at once 1410 uc = d->priv->buffer().at(d->anchor - 1 - fpos + frag->stringPosition); 1411 if (uc.unicode() >= 0xd800 && uc.unicode() < 0xdc00) 1412 --d->anchor; 1413 } 1414 1415 d->adjusted_anchor = d->anchor; 1389 1416 d->remove(); 1390 1417 d->setX(); … … 1502 1529 return; 1503 1530 1531 d->priv->beginEditBlock(); 1504 1532 d->remove(); 1533 d->priv->endEditBlock(); 1505 1534 d->setX(); 1506 1535 } … … 1834 1863 1835 1864 /*! 1865 \since 4.6 1866 1836 1867 Returns true if the cursor is at the end of the document; 1837 1868 otherwise returns false.
Note:
See TracChangeset
for help on using the changeset viewer.