summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorC. Boemann <cbo@boemann.dk>2011-12-10 05:15:38 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-09 23:09:40 +0100
commit1222da803ad5d9393956f7fa0e6716bd54da5f36 (patch)
tree785f6f9e957af3ee6924c846aa050cd0f0f06d1d /src
parent1ee9c0925b5aa99113fff9b9483868290cf921ae (diff)
Make sure cursor navigation in qtexttable works like user expects
Before the selection of cells NW of anchor showed some defects where cells would not be selected as the user expects Change-Id: Ia2b63f11b8d534e918ffb97b76339d60f1ca0389 Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qtextcursor.cpp31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp
index 6bbf1be0e3..766d9792cd 100644
--- a/src/gui/text/qtextcursor.cpp
+++ b/src/gui/text/qtextcursor.cpp
@@ -269,25 +269,7 @@ void QTextCursorPrivate::adjustCursor(QTextCursor::MoveOperation m)
QTextTableCell c_position = table->cellAt(position);
QTextTableCell c_anchor = table->cellAt(adjusted_anchor);
if (c_position != c_anchor) {
- bool before;
- int col_position = c_position.column();
- int col_anchor = c_anchor.column();
- if (col_position == col_anchor) {
- before = c_position.row() < c_anchor.row();
- } else {
- before = col_position < col_anchor;
- }
-
- // adjust to cell boundaries
- if (m <= QTextCursor::WordLeft) {
- position = c_position.firstPosition();
- if (!before)
- --position;
- } else {
- position = c_position.lastPosition();
- if (before)
- ++position;
- }
+ position = c_position.firstPosition();
if (position < adjusted_anchor)
adjusted_anchor = c_anchor.lastPosition();
else
@@ -391,6 +373,17 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor
int newPosition = position;
+ if (mode == QTextCursor::KeepAnchor && complexSelectionTable() != 0) {
+ if ((op >= QTextCursor::EndOfLine && op <= QTextCursor::NextWord)
+ || (op >= QTextCursor::Right && op <= QTextCursor::WordRight)) {
+ QTextTable *t = qobject_cast<QTextTable *>(priv->frameAt(position));
+ Q_ASSERT(t); // as we have already made sure we have a complex selection
+ QTextTableCell cell_pos = t->cellAt(position);
+ if (cell_pos.column() + cell_pos.columnSpan() != t->columns())
+ op = QTextCursor::NextCell;
+ }
+ }
+
if (x == -1 && !priv->isInEditBlock() && (op == QTextCursor::Up || op == QTextCursor::Down))
setX();