diff -r ecf6a73a9186 -r 60a8a215b0ec messagingapp/msgui/unifiedviewer/src/univiewertextitem.cpp --- a/messagingapp/msgui/unifiedviewer/src/univiewertextitem.cpp Tue Oct 05 13:58:47 2010 +0530 +++ b/messagingapp/msgui/unifiedviewer/src/univiewertextitem.cpp Tue Oct 19 11:30:16 2010 +0530 @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -54,7 +55,6 @@ #define LOC_CONTACT_INFO hbTrId("txt_messaging_menu_contact_info") #define LOC_CALL hbTrId("txt_common_menu_call_verb") #define LOC_SEND_MESSAGE hbTrId("txt_common_menu_send_message") -#define LOC_SAVE_TO_CONTACTS hbTrId("txt_common_menu_save_to_contacts") #define LOC_COPY hbTrId("txt_common_menu_copy") #define LOC_CREATE_EMAIL hbTrId("txt_messaging_menu_create_mail") #define LOC_OPEN_LINK hbTrId("txt_messaging_menu_open_link") @@ -72,6 +72,7 @@ this->setFlag(QGraphicsItem::ItemIsFocusable,false); this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); this->setBackgroundItem(0); + this->setSmileysEnabled(true); //inserting rules and patterns to map. mRules.insert(NUMBER_RULE,NUMBER_PATTERN); @@ -163,6 +164,7 @@ // Check if there is an anchor at this pos QString anchor = this->anchorAt(pos); + // Secondary Actions if(!anchor.isEmpty() && !this->textCursor().hasSelection()) { //remove default actions. @@ -251,24 +253,9 @@ { HbAction* action = NULL; - QString number = data; - number.remove(NUMBER_RULE); - int contactId = MsgContactHandler::resolveContactDisplayName( - number, - QContactPhoneNumber::DefinitionName, - QContactPhoneNumber::FieldNumber); + action = contextMenu->addAction(LOC_CONTACT_INFO, this, SLOT(openContactInfo())); + action->setData(data); - if(contactId > 0) - { - action = contextMenu->addAction(LOC_CONTACT_INFO, this, SLOT(openContactInfo())); - action->setData(data); - } - else - { - action = contextMenu->addAction(LOC_SAVE_TO_CONTACTS, this, SLOT(saveToContacts())); - action->setData(data); - } - action = contextMenu->addAction(LOC_CALL, this, SLOT(call())); action->setData(data); @@ -289,9 +276,6 @@ action = contextMenu->addAction(LOC_CONTACT_INFO, this, SLOT(openContactInfo())); action->setData(data); - action = contextMenu->addAction(LOC_SAVE_TO_CONTACTS, this, SLOT(saveToContacts())); - action->setData(data); - action = contextMenu->addAction(LOC_COPY, this, SLOT(copyToClipboard())); action->setData(data); } @@ -312,38 +296,16 @@ void UniViewerTextItem::handleShortTap(QString anchor,const QPointF& pos) { + Q_UNUSED(pos) + + // Primary Actions + HbAction action; action.setData(anchor); if(anchor.contains(NUMBER_RULE)) { - QString data = anchor; - data.remove(NUMBER_RULE); - int contactId = MsgContactHandler::resolveContactDisplayName( - data, - QContactPhoneNumber::DefinitionName, - QContactPhoneNumber::FieldNumber); - - if(contactId > 0 ) - { - //if resolved conatct open contact card - connect(&action,SIGNAL(triggered()),this,SLOT(openContactInfo())); - } - else - { - //unresolved contact show popup. - highlightText(true); - - HbMenu* contextMenu = new HbMenu(); - contextMenu->setDismissPolicy(HbPopup::TapAnywhere); - contextMenu->setAttribute(Qt::WA_DeleteOnClose, true); - contextMenu->setPreferredPos(pos); - connect(contextMenu,SIGNAL(aboutToClose()),this,SLOT(menuClosed())); - - addNumberMenu(contextMenu,anchor); - - contextMenu->show(); - } + connect(&action,SIGNAL(triggered()),this,SLOT(openContactInfo())); } else if(anchor.contains(EMAIL_RULE)) { @@ -489,96 +451,63 @@ void UniViewerTextItem::openContactInfo() { - HbAction* action = qobject_cast(sender()); - - if(action) - { - //service stuff. - QString service("phonebookservices"); - QString interface; - QString operation; - QList args; - + HbAction* action = qobject_cast (sender()); + + if (action) { + int contactId = -1; QString data = action->data().toString(); - - if(data.contains(QRegExp("^"+NUMBER_RULE))) - { + QVariant contactType; + + if (data.contains(QRegExp("^" + NUMBER_RULE))) { data.remove(NUMBER_RULE); - - int contactId = MsgContactHandler::resolveContactDisplayName( - data, - QContactPhoneNumber::DefinitionName, - QContactPhoneNumber::FieldNumber); - - if(contactId > 0) - { - //open contact card - interface = QString("com.nokia.symbian.IContactsView"); - operation = QString("openContactCard(int)"); - args << contactId; - } - else - { - //save to contacts with phone number field prefilled. - interface = QString("com.nokia.symbian.IContactsEdit"); - operation = QString("editCreateNew(QString,QString)"); - QString type = QContactPhoneNumber::DefinitionName; - args << type; - args << data; - } + + contactId = MsgContactHandler::resolveContactDisplayName(data, + QContactPhoneNumber::DefinitionName, QContactPhoneNumber::FieldNumber); + + contactType = QContactPhoneNumber::DefinitionName; } - else if(data.contains(QRegExp("^"+EMAIL_RULE))) - { + else if (data.contains(QRegExp("^" + EMAIL_RULE))) { data.remove(EMAIL_RULE); - - int contactId = MsgContactHandler::resolveContactDisplayName( - data, - QContactEmailAddress::DefinitionName, - QContactEmailAddress::FieldEmailAddress); - - if(contactId > 0) - { - //open contact card - interface = QString("com.nokia.symbian.IContactsView"); - operation = QString("openContactCard(int)"); - args << contactId; - } - else - { - //save to contacts with e-mail field prefilled. - interface = QString("com.nokia.symbian.IContactsEdit"); - operation = QString("editCreateNew(QString,QString)"); - QString type = QContactEmailAddress::DefinitionName; - args << type; - args << data; - } - } - XQAiwRequest* request; + + contactId = MsgContactHandler::resolveContactDisplayName(data, + QContactEmailAddress::DefinitionName, QContactEmailAddress::FieldEmailAddress); + + contactType = QContactEmailAddress::DefinitionName; + } + + //service stuff. + QList args; + XQAiwRequest* request = NULL; XQApplicationManager appManager; - request = appManager.create(service, interface, operation, true); // embedded - if ( request == NULL ) - { - return; - } + + if (contactId > 0) { + // open existing contact card + request = appManager.create(XQI_CONTACTS_VIEW, XQOP_CONTACTS_VIEW_CONTACT_CARD, true); // Embedded + args << contactId; + } + else { + // open temp contact card + request = appManager.create(XQI_CONTACTS_VIEW, + XQOP_CONTACTS_VIEW_TEMP_CONTACT_CARD_WITH_DETAIL, true); // Embedded + args << contactType; // Type + args << data; // Actual data + } + + if (request == NULL) { + return; + } // Result handlers - connect (request, SIGNAL(requestOk(const QVariant&)), - this, SLOT(handleOk(const QVariant&))); - connect (request, SIGNAL(requestError(const QVariant&)), - this, SLOT(handleError(const QVariant&))); - + connect(request, SIGNAL(requestOk(const QVariant&)), this, SLOT(handleOk(const QVariant&))); + connect(request, SIGNAL(requestError(const QVariant&)), this, + SLOT(handleError(const QVariant&))); + request->setArguments(args); request->send(); delete request; } } - -void UniViewerTextItem::saveToContacts() -{ - openContactInfo(); -} - void UniViewerTextItem::onServiceRequestCompleted() { //service request is now complete. delete it.