src/hbwidgets/editors/hbselectioncontrol_p.cpp
changeset 21 4633027730f5
parent 7 923ff622b8b9
equal deleted inserted replaced
7:923ff622b8b9 21:4633027730f5
    72 class HbSelectionControlPrivate :public HbDialogPrivate
    72 class HbSelectionControlPrivate :public HbDialogPrivate
    73 {
    73 {
    74     Q_DECLARE_PUBLIC(HbSelectionControl)
    74     Q_DECLARE_PUBLIC(HbSelectionControl)
    75 
    75 
    76 public:
    76 public:
       
    77     enum HandleType {
       
    78         DummyHandle,
       
    79         SelectionStartHandle,
       
    80         SelectionEndHandle
       
    81     };
    77     HbSelectionControlPrivate();
    82     HbSelectionControlPrivate();
    78     void init();
    83     void init();
    79     void createPrimitives();
    84     void createPrimitives();
    80     void updateHandle(int newHandlePos,
    85     void updateHandle(int newHandlePos,
    81                       Qt::AlignmentFlag handleAlignment,
    86                       Qt::AlignmentFlag handleAlignment,
    82                       QGraphicsItem *handle,
    87                       QGraphicsItem *handle,
    83                       QGraphicsItem *handleTouchArea,
    88                       QGraphicsItem *handleTouchArea,
    84                       HbStyle::Primitive handlePrimitive);
    89                       HbStylePrivate::Primitive handlePrimitive);
    85     QGraphicsItem * reparent(QGraphicsItem *item);
    90     QGraphicsItem * reparent(QGraphicsItem *item);
    86     void reparent(QGraphicsItem *item, QGraphicsItem *newParent);
    91     void reparent(QGraphicsItem *item, QGraphicsItem *newParent);
    87     void reparentHandles(QGraphicsItem *newParent);
    92     void reparentHandles(QGraphicsItem *newParent);
    88     void tapGestureFinished (const QPointF& point);
       
    89     void panGestureStarted (HbPanGesture *gesture);
    93     void panGestureStarted (HbPanGesture *gesture);
    90     void panGestureUpdated (HbPanGesture *gesture);
    94     void panGestureUpdated (HbPanGesture *gesture);
    91     void panGestureFinished (HbPanGesture *gesture);
    95     void panGestureFinished (HbPanGesture *gesture);
    92     void show();
    96     void show();
    93     void _q_aboutToChangeView();
    97     void _q_aboutToChangeView();
    95 
    99 
    96 public:
   100 public:
    97 
   101 
    98     HbAbstractEdit *mEdit;
   102     HbAbstractEdit *mEdit;
    99     QGraphicsItem *mTopLevelAncestor;
   103     QGraphicsItem *mTopLevelAncestor;
       
   104     QPointF mTouchOffset;
   100 
   105 
   101     QGraphicsItem *mSelectionStartHandle;
   106     QGraphicsItem *mSelectionStartHandle;
   102     QGraphicsItem *mSelectionEndHandle;
   107     QGraphicsItem *mSelectionEndHandle;
   103     HbTouchArea* mSelectionStartTouchArea;
   108     HbTouchArea* mSelectionStartTouchArea;
   104     HbTouchArea* mSelectionEndTouchArea;
   109     HbTouchArea* mSelectionEndTouchArea;
   105 
   110 
   106     HbSelectionControl::HandleType mPressed;
   111     HandleType mPressed;
   107     bool mPanInProgress;
   112     bool mPanInProgress;
   108     QBasicTimer mWordSnapTimer;
   113     QBasicTimer mWordSnapTimer;
       
   114     qreal mLastCursorHeight;
   109 };
   115 };
   110 
   116 
   111 
   117 
   112 HbSelectionControlPrivate::HbSelectionControlPrivate():
   118 HbSelectionControlPrivate::HbSelectionControlPrivate():
   113     mEdit(0),
   119     mEdit(0),
   114     mTopLevelAncestor(0),
   120     mTopLevelAncestor(0),
   115     mSelectionStartHandle(0),
   121     mSelectionStartHandle(0),
   116     mSelectionEndHandle(0),
   122     mSelectionEndHandle(0),
   117     mSelectionStartTouchArea(0),
   123     mSelectionStartTouchArea(0),
   118     mSelectionEndTouchArea(0),
   124     mSelectionEndTouchArea(0),
   119     mPressed(HbSelectionControl::HandleType(0)),
   125     mPressed(HandleType(0)),
   120     mPanInProgress(false)
   126     mPanInProgress(false),
       
   127     mLastCursorHeight(0.0)
   121 {    
   128 {    
   122 }
   129 }
   123 
   130 
   124 void HbSelectionControlPrivate::init()
   131 void HbSelectionControlPrivate::init()
   125 {
   132 {
   130     QGraphicsItem::GraphicsItemFlags itemFlags = q->flags();
   137     QGraphicsItem::GraphicsItemFlags itemFlags = q->flags();
   131 #if QT_VERSION >= 0x040600
   138 #if QT_VERSION >= 0x040600
   132     itemFlags |=  QGraphicsItem::ItemSendsGeometryChanges;
   139     itemFlags |=  QGraphicsItem::ItemSendsGeometryChanges;
   133 #endif
   140 #endif
   134     itemFlags &= ~QGraphicsItem::ItemIsFocusable;
   141     itemFlags &= ~QGraphicsItem::ItemIsFocusable;
   135     itemFlags |=  QGraphicsItem::ItemIsPanel;
       
   136     q->setFlags(itemFlags);
   142     q->setFlags(itemFlags);
   137     q->setFocusPolicy(Qt::NoFocus);
   143     q->setFocusPolicy(Qt::NoFocus);
   138     q->setActive(false);
       
   139 
   144 
   140     // Control will handle all events going to different handlers.
   145     // Control will handle all events going to different handlers.
   141     q->setHandlesChildEvents(true);
   146     q->setHandlesChildEvents(true);
   142 }
   147 }
   143 
   148 
   144 void HbSelectionControlPrivate::createPrimitives()
   149 void HbSelectionControlPrivate::createPrimitives()
   145 {
   150 {
   146     Q_Q(HbSelectionControl);
   151     Q_Q(HbSelectionControl);
   147     if (!mSelectionStartHandle) {
   152     if (!mSelectionStartHandle) {
   148         mSelectionStartHandle = q->style()->createPrimitive(HbStyle::P_SelectionControl_selectionstart, q);
   153         mSelectionStartHandle = HbStylePrivate::createPrimitive(HbStylePrivate::P_SelectionControl_selectionstart, q);
   149         mSelectionStartHandle->setFlag(QGraphicsItem::ItemIsPanel);
       
   150         mSelectionStartHandle->setFlag(QGraphicsItem::ItemIsFocusable,false);
   154         mSelectionStartHandle->setFlag(QGraphicsItem::ItemIsFocusable,false);
   151         mSelectionStartHandle->setActive(false);
       
   152     }
   155     }
   153 
   156 
   154     if (!mSelectionEndHandle) {
   157     if (!mSelectionEndHandle) {
   155         mSelectionEndHandle = q->style()->createPrimitive(HbStyle::P_SelectionControl_selectionend, q);
   158         mSelectionEndHandle = HbStylePrivate::createPrimitive(HbStylePrivate::P_SelectionControl_selectionend, q);
   156         mSelectionEndHandle->setFlag(QGraphicsItem::ItemIsPanel);
       
   157         mSelectionEndHandle->setFlag(QGraphicsItem::ItemIsFocusable,false);
   159         mSelectionEndHandle->setFlag(QGraphicsItem::ItemIsFocusable,false);
   158         mSelectionEndHandle->setActive(false);
       
   159     }
   160     }
   160 
   161 
   161     if (!mSelectionStartTouchArea) {
   162     if (!mSelectionStartTouchArea) {
   162         mSelectionStartTouchArea = new HbTouchArea(q);
   163         mSelectionStartTouchArea = new HbTouchArea(q);
   163         mSelectionStartTouchArea->setFlag(QGraphicsItem::ItemIsPanel);
       
   164         mSelectionStartTouchArea->setFlag(QGraphicsItem::ItemIsFocusable,false);
   164         mSelectionStartTouchArea->setFlag(QGraphicsItem::ItemIsFocusable,false);
   165         mSelectionStartTouchArea->setActive(false);
       
   166         HbStyle::setItemName(mSelectionStartTouchArea, "handle-toucharea");
   165         HbStyle::setItemName(mSelectionStartTouchArea, "handle-toucharea");
   167         mSelectionStartTouchArea->grabGesture(Qt::TapGesture);
   166         mSelectionStartTouchArea->grabGesture(Qt::TapGesture);
   168         mSelectionStartTouchArea->grabGesture(Qt::PanGesture);
   167         mSelectionStartTouchArea->grabGesture(Qt::PanGesture);
   169     }
   168     }
   170 
   169 
   171     if (!mSelectionEndTouchArea) {
   170     if (!mSelectionEndTouchArea) {
   172         mSelectionEndTouchArea = new HbTouchArea(q);
   171         mSelectionEndTouchArea = new HbTouchArea(q);
   173         mSelectionEndTouchArea->setFlag(QGraphicsItem::ItemIsPanel);
       
   174         mSelectionEndTouchArea->setFlag(QGraphicsItem::ItemIsFocusable,false);
   172         mSelectionEndTouchArea->setFlag(QGraphicsItem::ItemIsFocusable,false);
   175         mSelectionEndTouchArea->setActive(false);
       
   176         HbStyle::setItemName(mSelectionEndTouchArea, "handle-toucharea");
   173         HbStyle::setItemName(mSelectionEndTouchArea, "handle-toucharea");
   177         mSelectionEndTouchArea->grabGesture(Qt::TapGesture);
   174         mSelectionEndTouchArea->grabGesture(Qt::TapGesture);
   178         mSelectionEndTouchArea->grabGesture(Qt::PanGesture);
   175         mSelectionEndTouchArea->grabGesture(Qt::PanGesture);
   179     }
   176     }
   180 }
   177 }
   186 */
   183 */
   187 void HbSelectionControlPrivate::updateHandle(int newHandlePos,
   184 void HbSelectionControlPrivate::updateHandle(int newHandlePos,
   188                   Qt::AlignmentFlag handleAlignment,
   185                   Qt::AlignmentFlag handleAlignment,
   189                   QGraphicsItem *handle,
   186                   QGraphicsItem *handle,
   190                   QGraphicsItem *handleTouchArea,
   187                   QGraphicsItem *handleTouchArea,
   191                   HbStyle::Primitive handlePrimitive)
   188                   HbStylePrivate::Primitive handlePrimitive)
   192 {    
   189 {    
   193     Q_Q(HbSelectionControl);
   190     Q_Q(HbSelectionControl);
   194 
   191 
   195     HbStyleOption option;
   192     HbStyleOption option;
   196 
   193 
   197     q->initStyleOption(&option);
   194     q->initStyleOption(&option);
   198     mEdit->style()->updatePrimitive(handle, handlePrimitive, &option);
   195     HbStylePrivate::updatePrimitive(handle, handlePrimitive, &option);
   199 
   196 
   200     QRectF rect = mEdit->rectForPosition(newHandlePos,Qt::AlignTop?QTextLine::Leading:QTextLine::Trailing);
   197     QRectF rect = mEdit->rectForPosition(newHandlePos,Qt::AlignTop?QTextLine::Leading:QTextLine::Trailing);
       
   198     mLastCursorHeight = rect.height();
   201 
   199 
   202     // Convert rect to handle's parent coordinate system
   200     // Convert rect to handle's parent coordinate system
   203     rect = handle->parentItem()->mapRectFromItem(mEdit,rect);
   201     rect = handle->parentItem()->mapRectFromItem(mEdit,rect);
   204 
   202 
   205     // Center handle around center point of rect
   203     // Center handle around center point of rect
   213        boundingRect.moveTop(rect.bottom());
   211        boundingRect.moveTop(rect.bottom());
   214     }
   212     }
   215 
   213 
   216     handle->setPos(boundingRect.topLeft());
   214     handle->setPos(boundingRect.topLeft());
   217 
   215 
   218     // Center handle touch area around center pos of handle
   216     // Position handle touch area around center-top of handle
   219     QPointF centerPos = boundingRect.center();
   217     QPointF centerPos = boundingRect.center();
       
   218     rect = boundingRect;
   220     boundingRect = handleTouchArea->boundingRect();
   219     boundingRect = handleTouchArea->boundingRect();
   221     boundingRect.moveCenter(centerPos);
   220     boundingRect.moveCenter(centerPos);
       
   221     boundingRect.moveTop(rect.top());
       
   222 
   222     handleTouchArea->setPos(boundingRect.topLeft());
   223     handleTouchArea->setPos(boundingRect.topLeft());
   223 
   224 
   224     if (!mPanInProgress) {
   225     if (!mPanInProgress) {
   225         QGraphicsItem * newParent = reparent(handle);
   226         QGraphicsItem * newParent = reparent(handle);
   226         reparent(handleTouchArea, newParent);
   227         reparent(handleTouchArea, newParent);
   254     return newParent;
   255     return newParent;
   255 }
   256 }
   256 
   257 
   257 void HbSelectionControlPrivate::reparent(QGraphicsItem *item, QGraphicsItem *newParent)
   258 void HbSelectionControlPrivate::reparent(QGraphicsItem *item, QGraphicsItem *newParent)
   258 {
   259 {
   259     Q_Q(HbSelectionControl);
       
   260 
       
   261     if (item && newParent && newParent != item->parentItem()) {
   260     if (item && newParent && newParent != item->parentItem()) {
   262 
   261 
   263         // Reparent handle items to newParent
   262         // Reparent handle items to newParent
   264         QPointF pos = newParent->mapFromItem(item->parentItem(),item->pos());
   263         QPointF pos = newParent->mapFromItem(item->parentItem(),item->pos());
   265 
       
   266         // If the item is parented to other then q we have to
       
   267         // turn off the QGraphicsItem::ItemIsPanel flag because
       
   268         // otherwise the new parent loses its activeness.
       
   269         bool enablePanel = (newParent == q);
       
   270 
       
   271         item->setFlag(QGraphicsItem::ItemIsPanel,enablePanel);
       
   272 
   264 
   273         // TODO: This is a workaround for a Qt bug when reparenting from a clipping parent to a
   265         // TODO: This is a workaround for a Qt bug when reparenting from a clipping parent to a
   274         //       non-clipping parent
   266         //       non-clipping parent
   275         item->setParentItem(0);
   267         item->setParentItem(0);
   276         item->setParentItem(newParent);
   268         item->setParentItem(newParent);
   285     reparent(mSelectionStartTouchArea, newParent);
   277     reparent(mSelectionStartTouchArea, newParent);
   286     reparent(mSelectionEndHandle, newParent);
   278     reparent(mSelectionEndHandle, newParent);
   287     reparent(mSelectionEndTouchArea, newParent);
   279     reparent(mSelectionEndTouchArea, newParent);
   288 }
   280 }
   289 
   281 
   290 
       
   291 void HbSelectionControlPrivate::tapGestureFinished(const QPointF &pos)
       
   292 {
       
   293     if (mEdit->contextMenuFlags().testFlag(Hb::ShowTextContextMenuOnSelectionClicked)) {
       
   294         mEdit->showContextMenu(pos);
       
   295     }
       
   296 }
       
   297 
       
   298 void HbSelectionControlPrivate::panGestureStarted(HbPanGesture *gesture)
   282 void HbSelectionControlPrivate::panGestureStarted(HbPanGesture *gesture)
   299 {
   283 {
   300     Q_Q(HbSelectionControl);
   284     Q_Q(HbSelectionControl);
   301 
   285 
   302     QPointF point = q->mapFromScene(gesture->sceneStartPos());
   286     QPointF point = q->mapFromScene(gesture->sceneStartPos());
   303     mPressed = HbSelectionControl::DummyHandle;
   287     mPressed = DummyHandle;
   304 
   288 
   305     // Find out which handle is being moved
   289     // Find out which handle is being moved
   306     if (mSelectionStartTouchArea->contains(q->mapToItem(mSelectionStartTouchArea, point))) {
   290     if (mSelectionStartTouchArea->contains(q->mapToItem(mSelectionStartTouchArea, point))) {
   307         mPressed = HbSelectionControl::SelectionStartHandle;
   291         mPressed = SelectionStartHandle;
       
   292         mTouchOffset = mSelectionStartHandle->pos() - point;
   308     }
   293     }
   309     if (mSelectionEndTouchArea->contains(q->mapToItem(mSelectionEndTouchArea, point))) {
   294     if (mSelectionEndTouchArea->contains(q->mapToItem(mSelectionEndTouchArea, point))) {
   310         bool useArea = true;
   295         bool useArea = true;
   311         if(mPressed != HbSelectionControl::DummyHandle) {
   296         if(mPressed != DummyHandle) {
   312 
   297 
   313             // The press point was inside in both of the touch areas
   298             // The press point was inside in both of the touch areas
   314             // choose the touch area whose center is closer to the press point
   299             // choose the touch area whose center is closer to the press point
   315             QRectF rect = mSelectionStartTouchArea->boundingRect();
   300             QRectF rect = mSelectionStartHandle->boundingRect();
   316             rect.moveTopLeft(mSelectionStartTouchArea->pos());
   301             rect.moveTopLeft(mSelectionStartHandle->pos());
   317             QLineF  lineEventPosSelStartCenter(point,rect.center());
   302             QLineF  lineEventPosSelStartCenter(point,rect.center());
   318 
   303 
   319             rect = mSelectionEndTouchArea->boundingRect();
   304             rect = mSelectionEndHandle->boundingRect();
   320             rect.moveTopLeft(mSelectionEndTouchArea->pos());
   305             rect.moveTopLeft(mSelectionEndHandle->pos());
   321             QLineF  lineEventPosSelEndCenter(point,rect.center());
   306             QLineF  lineEventPosSelEndCenter(point,rect.center());
   322 
   307 
   323             if (lineEventPosSelStartCenter.length() < lineEventPosSelEndCenter.length()) {
   308             if (lineEventPosSelStartCenter.length() < lineEventPosSelEndCenter.length()) {
   324                 useArea = false;
   309                 useArea = false;
   325             }
   310             }
   326         }
   311         }
   327         if (useArea) {
   312         if (useArea) {
   328             mPressed = HbSelectionControl::SelectionEndHandle;
   313             mPressed = SelectionEndHandle;
   329         }
   314             mTouchOffset = mSelectionEndHandle->pos() - point;
   330     }
   315         }
   331 
   316     }
   332     if (mPressed == HbSelectionControl::DummyHandle) {
   317 
       
   318     if (mPressed == DummyHandle) {
   333         // Hit is outside touch areas, ignore
   319         // Hit is outside touch areas, ignore
   334         return;
   320         return;
   335     }
   321     }
   336 
   322 
   337     // Position cursor at the pressed selection handle
   323     // Position cursor at the pressed selection handle
   338 
   324 
   339     QTextCursor cursor = mEdit->textCursor();
   325     QTextCursor cursor = mEdit->textCursor();
   340     int selStartPos = qMin(mEdit->textCursor().anchor(),mEdit->textCursor().position());
   326     int selStartPos = qMin(mEdit->textCursor().anchor(),mEdit->textCursor().position());
   341     int selEndPos = qMax(mEdit->textCursor().anchor(),mEdit->textCursor().position());
   327     int selEndPos = qMax(mEdit->textCursor().anchor(),mEdit->textCursor().position());
   342 
   328 
   343     if (mPressed == HbSelectionControl::SelectionStartHandle) {
   329     if (mPressed == SelectionStartHandle) {
   344         cursor.setPosition(selEndPos);
   330         cursor.setPosition(selEndPos);
   345         cursor.setPosition(selStartPos, QTextCursor::KeepAnchor);
   331         cursor.setPosition(selStartPos, QTextCursor::KeepAnchor);
   346     } else {
   332     } else {
   347         cursor.setPosition(selStartPos);
   333         cursor.setPosition(selStartPos);
   348         cursor.setPosition(selEndPos, QTextCursor::KeepAnchor);
   334         cursor.setPosition(selEndPos, QTextCursor::KeepAnchor);
   371         cursor.setPosition(anchPos);
   357         cursor.setPosition(anchPos);
   372         cursor.setPosition(curPos, QTextCursor::KeepAnchor);
   358         cursor.setPosition(curPos, QTextCursor::KeepAnchor);
   373         mEdit->setTextCursor(cursor);
   359         mEdit->setTextCursor(cursor);
   374     }
   360     }
   375 
   361 
   376     mPressed = HbSelectionControl::DummyHandle;
   362     mPressed = DummyHandle;
   377     q->updatePrimitives();
   363     q->updatePrimitives();
   378 }
   364 }
   379 
   365 
   380 
   366 
   381 void HbSelectionControlPrivate::panGestureUpdated(HbPanGesture *gesture)
   367 void HbSelectionControlPrivate::panGestureUpdated(HbPanGesture *gesture)
   394     editPos = QPointF(qMin(qMax(editPos.x(),docRect.left()),docRect.right()),
   380     editPos = QPointF(qMin(qMax(editPos.x(),docRect.left()),docRect.right()),
   395                       qMin(qMax(editPos.y(),docRect.top()),docRect.bottom()));
   381                       qMin(qMax(editPos.y(),docRect.top()),docRect.bottom()));
   396 
   382 
   397     QRectF handleRect = mSelectionStartHandle->boundingRect();
   383     QRectF handleRect = mSelectionStartHandle->boundingRect();
   398 
   384 
   399     handleRect.moveCenter(editPos);
   385     handleRect.moveTopLeft(editPos + mTouchOffset);
   400 
   386 
   401     // Set hitTestPos based on which handle was grabbed
   387     // Set hitTestPos based on which handle was grabbed
   402     QPointF hitTestPos = handleRect.center();
   388     QPointF hitTestPos = handleRect.center();
   403 
   389 
   404     if (mPressed == HbSelectionControl::SelectionStartHandle) {
   390     if (mPressed == SelectionStartHandle) {
   405         hitTestPos.setY(handleRect.bottom()+1);
   391         hitTestPos.setY(handleRect.bottom()+mLastCursorHeight/2);
   406     } else {
   392     } else {
   407         hitTestPos.setY(handleRect.top()-1);
   393         hitTestPos.setY(handleRect.top()-mLastCursorHeight/2);
   408     }
   394     }
   409 
   395 
   410     // Override hitTestPos if origEditPos was outside the canvas
   396     // Override hitTestPos if origEditPos was outside the canvas
   411     if (outsideCanvas) {
   397     if (outsideCanvas) {
   412         if (origEditPos.y() < docRect.top()) {
   398         if (origEditPos.y() < docRect.top()) {
   608     return HbWidget::itemChange(change, value);
   594     return HbWidget::itemChange(change, value);
   609 }
   595 }
   610 
   596 
   611 void HbSelectionControl::gestureEvent(QGestureEvent* event) {
   597 void HbSelectionControl::gestureEvent(QGestureEvent* event) {
   612     Q_D(HbSelectionControl);
   598     Q_D(HbSelectionControl);
       
   599 
   613     if(HbTapGesture *tap = qobject_cast<HbTapGesture*>(event->gesture(Qt::TapGesture))) {
   600     if(HbTapGesture *tap = qobject_cast<HbTapGesture*>(event->gesture(Qt::TapGesture))) {
   614         QPointF pos = event->mapToGraphicsScene(tap->position());
   601         if (d->mEdit && tap->tapStyleHint() != HbTapGesture::TapAndHold) {
   615         switch(tap->state()) {
   602             d->mEdit->gestureEvent(event);
   616         case Qt::GestureStarted:
   603             // Cancel HbAbstractEdit gesture overriding settings
   617             if (d->mEdit) {
   604             tap->setProperty(HbPrivate::ThresholdRect.latin1(), QVariant());
   618                 HbWidgetFeedback::triggered(this, Hb::InstantPressed);
   605             scene()->setProperty(HbPrivate::OverridingGesture.latin1(),QVariant());
   619             }
   606             HbWidgetFeedback::triggered(this, Hb::InstantPressed);
   620             break;
       
   621         case Qt::GestureUpdated:
       
   622             break;
       
   623       case Qt::GestureFinished:
       
   624             if (d->mEdit) {
       
   625                 d->tapGestureFinished(pos);
       
   626                 HbWidgetFeedback::triggered(this, Hb::InstantReleased);
       
   627             }
       
   628             break;
       
   629       case Qt::GestureCanceled:
       
   630             break;
       
   631       default:
       
   632             break;
       
   633         }
   607         }
   634     }
   608     }
   635 
   609 
   636     if(HbPanGesture *pan = qobject_cast<HbPanGesture*>(event->gesture(Qt::PanGesture))) {
   610     if(HbPanGesture *pan = qobject_cast<HbPanGesture*>(event->gesture(Qt::PanGesture))) {
   637         switch(pan->state()) {
   611         switch(pan->state()) {
   680         if (d->mEdit->textCursor().hasSelection() ) {
   654         if (d->mEdit->textCursor().hasSelection() ) {
   681            
   655            
   682             int selStartPos = qMin(d->mEdit->textCursor().anchor(),d->mEdit->textCursor().position());
   656             int selStartPos = qMin(d->mEdit->textCursor().anchor(),d->mEdit->textCursor().position());
   683             int selEndPos = qMax(d->mEdit->textCursor().anchor(),d->mEdit->textCursor().position());
   657             int selEndPos = qMax(d->mEdit->textCursor().anchor(),d->mEdit->textCursor().position());
   684 
   658 
   685             d->updateHandle(selStartPos,Qt::AlignTop,d->mSelectionStartHandle,d->mSelectionStartTouchArea,HbStyle::P_SelectionControl_selectionstart);
   659             d->updateHandle(selStartPos,Qt::AlignTop,d->mSelectionStartHandle,d->mSelectionStartTouchArea,HbStylePrivate::P_SelectionControl_selectionstart);
   686             d->updateHandle(selEndPos,Qt::AlignBottom,d->mSelectionEndHandle,d->mSelectionEndTouchArea,HbStyle::P_SelectionControl_selectionend);
   660             d->updateHandle(selEndPos,Qt::AlignBottom,d->mSelectionEndHandle,d->mSelectionEndTouchArea,HbStylePrivate::P_SelectionControl_selectionend);
   687         }
   661         }
   688         else {
   662         else {
   689             hide();
   663             hide();
   690         }
   664         }
   691     }
   665     }