134 |
134 |
135 This signal is emitted when cursor position has been changed. |
135 This signal is emitted when cursor position has been changed. |
136 */ |
136 */ |
137 |
137 |
138 /*! |
138 /*! |
|
139 \fn void anchorTapped(const QString &anchor) |
|
140 |
|
141 This signal is emitted when a tap gesture happens on a word which has anchor attached. |
|
142 |
|
143 */ |
|
144 |
|
145 /*! |
139 \fn QString HbAbstractEdit::toPlainText() const |
146 \fn QString HbAbstractEdit::toPlainText() const |
140 |
147 |
141 Returns the contents as plain text. |
148 Returns the contents as plain text. |
142 |
149 |
143 \sa QTextDocument::toPlainText() |
150 \sa QTextDocument::toPlainText() |
362 if (d->interactionFlags & Qt::TextSelectableByKeyboard |
369 if (d->interactionFlags & Qt::TextSelectableByKeyboard |
363 && d->cursorMoveKeyEvent(event)) |
370 && d->cursorMoveKeyEvent(event)) |
364 d->acceptKeyPressEvent(event); |
371 d->acceptKeyPressEvent(event); |
365 |
372 |
366 if (!(d->interactionFlags & Qt::TextEditable)) { |
373 if (!(d->interactionFlags & Qt::TextEditable)) { |
367 d->repaintOldAndNewSelection(d->selectionCursor); |
|
368 d->cursorChanged(HbValidator::CursorChangeFromContentUpdate); |
374 d->cursorChanged(HbValidator::CursorChangeFromContentUpdate); |
369 //ensureCursorVisible(); |
|
370 event->ignore(); |
375 event->ignore(); |
371 return; |
376 return; |
372 } |
377 } |
373 |
378 |
374 if (event->key() == Qt::Key_Direction_L || event->key() == Qt::Key_Direction_R) { |
379 if (event->key() == Qt::Key_Direction_L || event->key() == Qt::Key_Direction_R) { |
917 |
921 |
918 if (cursorPos == -1) |
922 if (cursorPos == -1) |
919 return; |
923 return; |
920 |
924 |
921 setCursorPosition(cursorPos); |
925 setCursorPosition(cursorPos); |
922 const QTextCursor oldSelection = d->cursor; |
|
923 d->cursor.select(QTextCursor::WordUnderCursor); |
926 d->cursor.select(QTextCursor::WordUnderCursor); |
924 emit selectionChanged(oldSelection, d->cursor); |
|
925 d->repaintOldAndNewSelection(oldSelection); |
|
926 d->cursorChanged(HbValidator::CursorChangeFromMouse); |
927 d->cursorChanged(HbValidator::CursorChangeFromMouse); |
927 //TODO: focus is in VKB so needs to re-focus to editor |
|
928 // setFocus(); |
|
929 } |
928 } |
930 |
929 |
931 /*! |
930 /*! |
932 Selects all the text in the editor. |
931 Selects all the text in the editor. |
933 \sa selectClickedWord deselect |
932 \sa selectClickedWord deselect |
934 */ |
933 */ |
935 void HbAbstractEdit::selectAll() |
934 void HbAbstractEdit::selectAll() |
936 { |
935 { |
937 Q_D(HbAbstractEdit); |
936 Q_D(HbAbstractEdit); |
938 const QTextCursor oldSelection = d->cursor; |
|
939 d->cursor.select(QTextCursor::Document); |
937 d->cursor.select(QTextCursor::Document); |
940 emit selectionChanged(oldSelection, d->cursor); |
|
941 d->repaintOldAndNewSelection(oldSelection); |
|
942 d->cursorChanged(HbValidator::CursorChangeFromMouse); |
938 d->cursorChanged(HbValidator::CursorChangeFromMouse); |
943 } |
939 } |
944 |
940 |
945 /*! |
941 /*! |
946 Deselects the text in the editor if there is text selected. |
942 Deselects the text in the editor if there is text selected. |
947 \sa selectClickedWord selectAll |
943 \sa selectClickedWord selectAll |
948 */ |
944 */ |
949 void HbAbstractEdit::deselect() |
945 void HbAbstractEdit::deselect() |
950 { |
946 { |
951 Q_D(HbAbstractEdit); |
947 Q_D(HbAbstractEdit); |
952 const QTextCursor oldSelection = d->cursor; |
|
953 d->cursor.clearSelection(); |
948 d->cursor.clearSelection(); |
954 emit selectionChanged(oldSelection, d->cursor); |
949 d->cursorChanged(HbValidator::CursorChangeFromMouse); |
955 } |
950 } |
956 |
951 |
957 /*! |
952 /*! |
958 Launches the format user interface. |
953 Launches the format user interface. |
959 */ |
954 */ |
1131 |
1126 |
1132 d->ensureCursorVisible(); |
1127 d->ensureCursorVisible(); |
1133 QTextCursor previousCursor(d->cursor); |
1128 QTextCursor previousCursor(d->cursor); |
1134 previousCursor.setPosition(d->previousCursorAnchor); |
1129 previousCursor.setPosition(d->previousCursorAnchor); |
1135 previousCursor.setPosition(d->previousCursorPosition, QTextCursor::KeepAnchor); |
1130 previousCursor.setPosition(d->previousCursorPosition, QTextCursor::KeepAnchor); |
1136 d->repaintOldAndNewSelection(previousCursor); |
|
1137 d->cursorChanged(HbValidator::CursorChangeFromOperation); |
1131 d->cursorChanged(HbValidator::CursorChangeFromOperation); |
1138 } |
1132 } |
1139 |
1133 |
1140 /*! |
1134 /*! |
1141 Returns the bounding rect for given text block. |
1135 Returns the bounding rect for given text block. |