emailuis/nmailuiwidgets/src/nmrecipientlineedit.cpp
changeset 76 38bf5461e270
parent 74 6c59112cfd31
equal deleted inserted replaced
74:6c59112cfd31 76:38bf5461e270
   378 {
   378 {
   379     //passing gesture event to base class.
   379     //passing gesture event to base class.
   380     HbLineEdit::gestureEvent(event);
   380     HbLineEdit::gestureEvent(event);
   381 
   381 
   382     if (HbTapGesture *tap = qobject_cast<HbTapGesture*>(event->gesture(Qt::TapGesture))) {
   382     if (HbTapGesture *tap = qobject_cast<HbTapGesture*>(event->gesture(Qt::TapGesture))) {
   383         //capturing gesture position, and map to local co-ordinates.
       
   384         QPointF pos = mapFromScene(tap->scenePosition());
       
   385 
   383 
   386         switch (tap->state()) {
   384         switch (tap->state()) {
   387         case Qt::GestureFinished:
   385         case Qt::GestureFinished:
   388             if (HbTapGesture::Tap == tap->tapStyleHint()) {
   386             if (HbTapGesture::Tap == tap->tapStyleHint()) {
   389                 handleTap();
   387                 handleTap();
   405 void NmRecipientLineEdit::handleTap()
   403 void NmRecipientLineEdit::handleTap()
   406 {
   404 {
   407     int currentPos = cursorPosition();
   405     int currentPos = cursorPosition();
   408     QString txt = text();
   406     QString txt = text();
   409 
   407 
   410     QString leftTxt = txt.left(currentPos+2);
   408     QString leftTxt = txt.left(currentPos+2); //recipient items delimeter takes 2 characters
   411     int previousSemicolonIndex = leftTxt.lastIndexOf(NmRecipientLineEditSemicolon,currentPos);
   409     int previousSemicolonIndex = leftTxt.lastIndexOf(NmRecipientLineEditSemicolon,currentPos);
   412     if ((currentPos>0) &&
   410     if ((currentPos>0) &&
   413        (currentPos==previousSemicolonIndex || currentPos==previousSemicolonIndex+1)) {
   411        (currentPos==previousSemicolonIndex || currentPos==previousSemicolonIndex+1)) {
       
   412         //do we really need this? currentPos==previousSemicolonIndex 
   414         //pressed just on seperator
   413         //pressed just on seperator
   415         setCursorPosition(previousSemicolonIndex+2);
   414         setCursorPosition(previousSemicolonIndex+2);
   416     }
   415     }
   417     else
   416     else {
   418     {
       
   419         // pressed in middle of an address
   417         // pressed in middle of an address
   420         setCursorPosition(currentPos);
       
   421         if (textCursor().charFormat().fontUnderline()) {
   418         if (textCursor().charFormat().fontUnderline()) {
   422             // This entry is a "contact"
   419             // This entry is a "contact"
   423             setHighlight(currentPos);
   420             setHighlight(currentPos); 
   424         }
   421         }
   425     }
   422     }
   426     update();
       
   427 }
   423 }
   428 
   424 
   429 /*!
   425 /*!
   430    Generate a list of all the email addresses from the content of the lineedit.
   426    Generate a list of all the email addresses from the content of the lineedit.
   431 */
   427 */
   506     mNeedToGenerateEmailAddressList = true;
   502     mNeedToGenerateEmailAddressList = true;
   507 
   503 
   508     //if there is no text, hide popup already
   504     //if there is no text, hide popup already
   509     if (document()->isEmpty()) {
   505     if (document()->isEmpty()) {
   510         hideAutofillPopup();
   506         hideAutofillPopup();
   511     }
   507         return; //no need to continue
   512 
   508     }
   513     if (mContactHistoryModel) {
   509 
   514         int startPos(-1), length(-1);
   510     int startPos(-1), length(-1);
   515         currentTextPart(startPos, length);
   511     currentTextPart(startPos, length);
   516         QString t = text.mid(startPos, length);
   512     QString t = text.mid(startPos, length);
   517         if (t.length()) {
   513     if (t.length()) {
   518             mContactHistoryModel->query(t);
   514         mContactHistoryModel->query(t);
   519         }
       
   520     }
   515     }
   521 }
   516 }
   522 
   517 
   523 /*!
   518 /*!
   524     If recipient is added from Contacts by Contacts, we need to add it to the list.
   519     If recipient is added from Contacts by Contacts, we need to add it to the list.
   588     // Get the activated item with given modelIndex
   583     // Get the activated item with given modelIndex
   589     NmContactHistoryModelItem item = mContactHistoryModel->data(modelIndex, Qt::DisplayRole).value<NmContactHistoryModelItem>();
   584     NmContactHistoryModelItem item = mContactHistoryModel->data(modelIndex, Qt::DisplayRole).value<NmContactHistoryModelItem>();
   590     if (item.subItemCount()) {
   585     if (item.subItemCount()) {
   591         QList<NmContactHistoryModelSubItem> itemlist = item.subEntries();
   586         QList<NmContactHistoryModelSubItem> itemlist = item.subEntries();
   592         if (itemlist.count() == 2) {
   587         if (itemlist.count() == 2) {
   593             address.setDisplayName(itemlist[0].mItemText);
   588             address.setDisplayName(itemlist[0].mItemText.trimmed());
   594             address.setAddress(itemlist[1].mItemText);
   589             address.setAddress(itemlist[1].mItemText.trimmed());
   595         } else if (itemlist.count() == 1) {
   590         } else if (itemlist.count() == 1) {
   596             // only emailaddress found (no display name)
   591             // only emailaddress found (no display name)
   597             address.setAddress(itemlist[0].mItemText);
   592             address.setAddress(itemlist[0].mItemText.trimmed());
   598         }
   593         }
   599     }
   594     }
   600 }
   595 }
   601 
   596 
   602 /*!
   597 /*!
   751         setSelection(startPos, endPos - startPos + 2);
   746         setSelection(startPos, endPos - startPos + 2);
   752     }
   747     }
   753     else {
   748     else {
   754         deselect();
   749         deselect();
   755     }
   750     }
   756 
   751     
   757     update();
   752     
   758 }
   753 }
   759 
   754 
   760 /*!
   755 /*!
   761  inserts a new contact text (underlined) + trailing delimiter to current cursor position in editor field
   756  inserts a new contact text (underlined) + trailing delimiter to current cursor position in editor field
   762  */
   757  */