emailuis/nmailuiwidgets/src/nmeditortextedit.cpp
changeset 74 6c59112cfd31
parent 68 83cc6bae1de8
equal deleted inserted replaced
69:4e54af54a4a1 74:6c59112cfd31
   173     
   173     
   174     return ret; 
   174     return ret; 
   175 }
   175 }
   176 
   176 
   177 /*!
   177 /*!
   178  *  Returns the rectangle for the cursor.
   178  *  Returns the rectangle for the cursor including the predictive text area.
       
   179  *  HbAbstractEditPrivate::ensurePositionVisible() uses the same algorithm.
   179  */
   180  */
   180 QRectF NmEditorTextEdit::rectForCursorPosition() const
   181 QRectF NmEditorTextEdit::rectForCursorPosition() const
   181 {
   182 {
   182     NM_FUNCTION;
   183     NM_FUNCTION;
   183     
   184     
   184     return HbTextEdit::rectForPosition(cursorPosition());
   185     int cursorPos = cursorPosition();
   185 }
   186     QRectF rect = rectForPosition(cursorPos);
   186 
   187     QTextDocument *doc = document();
       
   188     if (doc) {
       
   189         rect.adjust(0, -doc->documentMargin(), 0, doc->documentMargin());
       
   190         const QTextBlock block = doc->findBlock(cursorPos);
       
   191         QTextLayout *blockLayout = block.layout();
       
   192         if (block.isValid() && blockLayout) {
       
   193             if (blockLayout->preeditAreaText().length()) {
       
   194                 // Adjust cursor rect so that predictive text will be also visible
       
   195                 rect.adjust(0, 0, boundingRect().width() / 2, 0);
       
   196             }
       
   197         }
       
   198     }
       
   199 
       
   200     return rect;
       
   201 }
       
   202 
       
   203 /*!
       
   204  *  Sets the visible cursor position
       
   205  */
       
   206 
       
   207 void NmEditorTextEdit::moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode)
       
   208 {
       
   209     NM_FUNCTION;
       
   210     HbAbstractEdit::moveCursor(op, mode);
       
   211 }
       
   212