diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2010-06-01 10:39:18 (GMT) |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2010-06-01 10:39:18 (GMT) |
commit | bbc96efe5f47353d3188728fc9024cfec5553709 (patch) | |
tree | 7ba74d60fbfd519989c3d5532cb3c631137cf025 /src/gui | |
parent | 8d6ac1a041eb26f635914b1c356f47e50cdfdc98 (diff) | |
download | Qt-bbc96efe5f47353d3188728fc9024cfec5553709.zip Qt-bbc96efe5f47353d3188728fc9024cfec5553709.tar.gz Qt-bbc96efe5f47353d3188728fc9024cfec5553709.tar.bz2 |
Introduced getter and setter for the visual X cursor position.
The mechanism allows the cursor to move up and down on a visually
straight line with proportional fonts, and to gently "jump"
over short lines.
Reviewed-by: mae
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/text/qtextcursor.cpp | 35 | ||||
-rw-r--r-- | src/gui/text/qtextcursor.h | 3 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index abc0889..d6ac3aa 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -1277,6 +1277,41 @@ void QTextCursor::setVisualNavigation(bool b) d->visualNavigation = b; } + +/*! + \since 4.7 + + Sets the visual x position for vertical cursor movements. + + The vertical movement x position is cleared automatically when the cursor moves horizontally, and kept + unchanged when the cursor moves vertically. The mechanism allows the cursor to move up and down on a + visually straight line with proportional fonts, and to gently "jump" over short lines. + + A value of -1 indicates no predefined x position. It will then be set automatically the next time the + cursor moves up or down. + + \sa verticalMovementX() + */ +void QTextCursor::setVerticalMovementX(int x) +{ + if (d) + d->x = x; +} + +/*! \since 4.7 + + Returns the visual x position for vertical cursor movements. + + A value of -1 indicates no predefined x position. It will then be set automatically the next time the + cursor moves up or down. + + \sa setVerticalMovementX() + */ +int QTextCursor::verticalMovementX() const +{ + return d ? d->x : -1; +} + /*! \since 4.7 diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h index 6cb776c..251cb33 100644 --- a/src/gui/text/qtextcursor.h +++ b/src/gui/text/qtextcursor.h @@ -132,6 +132,9 @@ public: bool visualNavigation() const; void setVisualNavigation(bool b); + void setVerticalMovementX(int x); + int verticalMovementX() const; + void setKeepPositionOnInsert(bool b); bool keepPositionOnInsert() const; |