src/gui/text/qtextcursor.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
child 33 3e2da88830cd
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
  1143 
  1143 
  1144 /*!
  1144 /*!
  1145     Returns the absolute position of the cursor within the document.
  1145     Returns the absolute position of the cursor within the document.
  1146     The cursor is positioned between characters.
  1146     The cursor is positioned between characters.
  1147 
  1147 
  1148     \sa setPosition() movePosition() anchor()
  1148     \sa setPosition() movePosition() anchor() positionInBlock()
  1149 */
  1149 */
  1150 int QTextCursor::position() const
  1150 int QTextCursor::position() const
  1151 {
  1151 {
  1152     if (!d || !d->priv)
  1152     if (!d || !d->priv)
  1153         return -1;
  1153         return -1;
  1154     return d->position;
  1154     return d->position;
       
  1155 }
       
  1156 
       
  1157 /*!
       
  1158     \since 4.7
       
  1159     Returns the relative position of the cursor within the block.
       
  1160     The cursor is positioned between characters.
       
  1161 
       
  1162     This is equivalent to \c{ position() - block().position()}.
       
  1163 
       
  1164     \sa position()
       
  1165 */
       
  1166 int QTextCursor::positionInBlock() const
       
  1167 {
       
  1168     if (!d || !d->priv)
       
  1169         return 0;
       
  1170     return d->position - d->block().position();
  1155 }
  1171 }
  1156 
  1172 
  1157 /*!
  1173 /*!
  1158     Returns the anchor position; this is the same as position() unless
  1174     Returns the anchor position; this is the same as position() unless
  1159     there is a selection in which case position() marks one end of the
  1175     there is a selection in which case position() marks one end of the
  2412         return 0;
  2428         return 0;
  2413 
  2429 
  2414     return d->block().blockNumber();
  2430     return d->block().blockNumber();
  2415 }
  2431 }
  2416 
  2432 
       
  2433 
  2417 /*!
  2434 /*!
  2418     \since 4.2
  2435     \since 4.2
  2419     Returns the position of the cursor within its containing line.
  2436     Returns the position of the cursor within its containing line.
       
  2437 
       
  2438     Note that this is the column number relative to a wrapped line,
       
  2439     not relative to the block (i.e. the paragraph).
       
  2440 
       
  2441     You probably want to call positionInBlock() instead.
       
  2442 
       
  2443     \sa positionInBlock()
  2420 */
  2444 */
  2421 int QTextCursor::columnNumber() const
  2445 int QTextCursor::columnNumber() const
  2422 {
  2446 {
  2423     if (!d || !d->priv)
  2447     if (!d || !d->priv)
  2424         return 0;
  2448         return 0;