messagingapp/msgui/unifiedviewer/src/univiewertextitem.cpp
changeset 27 e4592d119491
parent 25 84d9eb65b26f
child 47 5b14749788d7
--- a/messagingapp/msgui/unifiedviewer/src/univiewertextitem.cpp	Mon May 03 12:29:07 2010 +0300
+++ b/messagingapp/msgui/unifiedviewer/src/univiewertextitem.cpp	Fri May 14 15:49:35 2010 +0300
@@ -18,6 +18,7 @@
  */
 
 #include "univiewertextitem.h"
+#include "msgcontacthandler.h"
 
 #include <QRegExp>
 #include <QGraphicsSceneMouseEvent>
@@ -27,12 +28,12 @@
 
 #include <HbMenu>
 #include <HbAction>
+#include <HbFrameItem>
 #include <cntservicescontact.h>
-#include <qtcontacts.h>
 #include <XQServiceRequest.h>
 #include <xqaiwrequest.h>
+#include <xqappmgr.h>
 
-QTM_USE_NAMESPACE
 
 //consts
 
@@ -65,7 +66,11 @@
 mCursorPos(-1)
 {
     this->setReadOnly(true);
+    this->setScrollable(false);
     this->setCursorVisibility(Hb::TextCursorHidden);
+    this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+    HbFrameItem *noBackground = new HbFrameItem(this);
+    this->setBackgroundItem(noBackground);
 
     //inserting rules and patterns to map.
     mRules.insert(NUMBER_RULE,NUMBER_PATTERN);
@@ -346,7 +351,8 @@
         QString serviceName("com.nokia.services.commonemail");
         QString interfaceName("imessage.send");
         QString operation("send(QVariant)");
-        XQAiwRequest* request = mAppManager.create(serviceName, interfaceName, 
+        XQApplicationManager appManager;
+        XQAiwRequest* request = appManager.create(serviceName, interfaceName, 
 			operation, true); 
         if ( request == NULL )
             {
@@ -414,9 +420,10 @@
         {
             data.remove(NUMBER_RULE);
     
-            int contactId = resolveContactId(data, 
-                                             QContactPhoneNumber::DefinitionName,
-                                             QContactPhoneNumber::FieldNumber);
+            int contactId = MsgContactHandler::resolveContactDisplayName(
+                                         data, 
+                                         QContactPhoneNumber::DefinitionName,
+                                         QContactPhoneNumber::FieldNumber);
     
             if(contactId > 0)
                 {
@@ -439,9 +446,10 @@
         {
             data.remove(EMAIL_RULE);
     
-            int contactId = resolveContactId(data,
-                                             QContactEmailAddress::DefinitionName,
-                                             QContactEmailAddress::FieldEmailAddress);
+            int contactId = MsgContactHandler::resolveContactDisplayName(
+                    data,
+                    QContactEmailAddress::DefinitionName,
+                    QContactEmailAddress::FieldEmailAddress);
             
             if(contactId > 0)
                 {
@@ -466,7 +474,8 @@
         QString serviceName("com.nokia.services.phonebookservices");
      
         XQAiwRequest* request;
-        request = mAppManager.create(serviceName, "Fetch", operation, true); // embedded
+        XQApplicationManager appManager;
+        request = appManager.create(serviceName, "Fetch", operation, true); // embedded
         if ( request == NULL )
             {
             return;       
@@ -502,33 +511,6 @@
         }
     }
 
-int UniViewerTextItem::resolveContactId(const QString& value,
-                                        const QString& fieldName,
-                                        const QString& fieldType)
-    {
-    int contactId = -1;
-    
-    QContactManager phonebookManager("symbian");
-    
-    QContactDetailFilter phoneFilter;
-    phoneFilter.setDetailDefinitionName(fieldName, fieldType);
-    phoneFilter.setValue(value);
-    phoneFilter.setMatchFlags(QContactFilter::MatchEndsWith);
-
-    QList<QContactSortOrder> sortOrder;
-    QList<QContact> matchingContacts = phonebookManager.contacts(
-            phoneFilter,
-            sortOrder,
-            QStringList());
-
-    if ( matchingContacts.count() > 0 ) 
-        {       
-        contactId = matchingContacts.at(0).localId();;   
-        }
-    
-    return contactId;
-    }
-
 void UniViewerTextItem::menuClosed()
 {
     highlightText(false);
@@ -565,6 +547,7 @@
             }
 
             cursor.clearSelection();
+            break;
         }
     }
 }