src/hbwidgets/editors/hbabstractedit.cpp
changeset 5 627c4a0fd0e7
parent 3 11d3954df52a
child 6 c3690ec91ef8
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
   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()
   174 */
   181 */
   175 HbAbstractEdit::~HbAbstractEdit()
   182 HbAbstractEdit::~HbAbstractEdit()
   176 {
   183 {
   177     Q_D(HbAbstractEdit);
   184     Q_D(HbAbstractEdit);
   178     if (d->selectionControl) {
   185     if (d->selectionControl) {
   179         d->selectionControl->detachEditor();
   186         d->selectionControl->detachEditorFromDestructor();
   180     }
   187     }
   181 }
   188 }
   182 
   189 
   183 /*!
   190 /*!
   184     \reimp
   191     \reimp
   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) {
   827         d->cursor = cursor;
   832         d->cursor = cursor;
   828 
   833 
   829         d->updateCurrentCharFormat();
   834         d->updateCurrentCharFormat();
   830 
   835 
   831         d->ensureCursorVisible();
   836         d->ensureCursorVisible();
   832         d->repaintOldAndNewSelection(oldCursor);
       
   833         d->cursorChanged(HbValidator::CursorChangeFromContentSet);
   837         d->cursorChanged(HbValidator::CursorChangeFromContentSet);
   834     }
   838     }
   835 }
   839 }
   836 
   840 
   837 /*!
   841 /*!
   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.