src/gui/text/qtextcursor.cpp
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
child 33 3e2da88830cd
--- a/src/gui/text/qtextcursor.cpp	Mon Jun 21 22:38:13 2010 +0100
+++ b/src/gui/text/qtextcursor.cpp	Thu Jul 22 16:41:55 2010 +0100
@@ -1145,7 +1145,7 @@
     Returns the absolute position of the cursor within the document.
     The cursor is positioned between characters.
 
-    \sa setPosition() movePosition() anchor()
+    \sa setPosition() movePosition() anchor() positionInBlock()
 */
 int QTextCursor::position() const
 {
@@ -1155,6 +1155,22 @@
 }
 
 /*!
+    \since 4.7
+    Returns the relative position of the cursor within the block.
+    The cursor is positioned between characters.
+
+    This is equivalent to \c{ position() - block().position()}.
+
+    \sa position()
+*/
+int QTextCursor::positionInBlock() const
+{
+    if (!d || !d->priv)
+        return 0;
+    return d->position - d->block().position();
+}
+
+/*!
     Returns the anchor position; this is the same as position() unless
     there is a selection in which case position() marks one end of the
     selection and anchor() marks the other end. Just like the cursor
@@ -2414,9 +2430,17 @@
     return d->block().blockNumber();
 }
 
+
 /*!
     \since 4.2
     Returns the position of the cursor within its containing line.
+
+    Note that this is the column number relative to a wrapped line,
+    not relative to the block (i.e. the paragraph).
+
+    You probably want to call positionInBlock() instead.
+
+    \sa positionInBlock()
 */
 int QTextCursor::columnNumber() const
 {