qthighway/examples/hbserviceclient/src/hbserviceclientview.cpp
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
child 14 6fbed849b4f4
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
    25 #include <hbtoolbar.h>
    25 #include <hbtoolbar.h>
    26 #include <hbaction.h>
    26 #include <hbaction.h>
    27 #include <hblineedit.h>
    27 #include <hblineedit.h>
    28 #include <hblabel.h>
    28 #include <hblabel.h>
    29 //#include <hbcheckbox.h>
    29 //#include <hbcheckbox.h>
       
    30 #include <hbmessagebox.h>
       
    31 #include <cntservicescontact.h>
       
    32 
    30 
    33 
    31 #include <QMessageBox>
    34 #include <QMessageBox>
    32 #include <QVariant>
    35 #include <QVariant>
    33 
    36 
    34 #include "hbserviceclientview.h"
    37 #include "hbserviceclientview.h"
    35 
    38 
    36 #include <xqservicerequest.h>
    39 #include <xqservicerequest.h>
    37 
    40 
    38 #include "../hbserviceprovider/src/hbcontact.h"
    41 #include "../hbserviceprovider/src/hbcontact.h"
       
    42 
    39 
    43 
    40 HbServiceClientView::HbServiceClientView(QGraphicsItem *parent)
    44 HbServiceClientView::HbServiceClientView(QGraphicsItem *parent)
    41     : HbView(parent)
    45     : HbView(parent)
    42 {
    46 {
    43     XQSERVICE_DEBUG_PRINT("HbServiceClientView::HbServiceClientView");
    47     XQSERVICE_DEBUG_PRINT("HbServiceClientView::HbServiceClientView");
    93     connect(callAction, SIGNAL(triggered()), this, SLOT(callContact()));
    97     connect(callAction, SIGNAL(triggered()), this, SLOT(callContact()));
    94 
    98 
    95     HbAction* callEmbeddedAction = new HbAction("Call Embedded"); 
    99     HbAction* callEmbeddedAction = new HbAction("Call Embedded"); 
    96     connect(callEmbeddedAction, SIGNAL(triggered()), this, SLOT(callContactEmbedded()));
   100     connect(callEmbeddedAction, SIGNAL(triggered()), this, SLOT(callContactEmbedded()));
    97 
   101 
    98     HbAction* showAddressesAction = new HbAction("Show Addresses"); 
   102     HbAction* showAddressesAction = new HbAction("Select contacts"); 
    99     connect(showAddressesAction, SIGNAL(triggered()), this, SLOT(showAddresses()));
   103     connect(showAddressesAction, SIGNAL(triggered()), this, SLOT(launchContactSelecting()));
   100     
   104     
   101     toolBar->addAction(callAction);
   105     toolBar->addAction(callAction);
   102     toolBar->addAction(callEmbeddedAction);
   106     toolBar->addAction(callEmbeddedAction);
   103     toolBar->addAction(showAddressesAction);
   107     toolBar->addAction(showAddressesAction);
   104     sndAsync = NULL;
   108     sndAsync = NULL;
   198         msgBox.exec();
   202         msgBox.exec();
   199         //mRetMapValue->setText(QString::number(retValue));
   203         //mRetMapValue->setText(QString::number(retValue));
   200     }
   204     }
   201 }
   205 }
   202 
   206 
       
   207 void HbServiceClientView::launchContactSelecting()
       
   208 {
       
   209     if (sndAsync)
       
   210         delete sndAsync;
       
   211     sndAsync = new XQServiceRequest("com.nokia.services.phonebookservices.Fetch",
       
   212                                     "fetch(QString,QString,QString)", false);
       
   213 
       
   214     connect(sndAsync, SIGNAL(requestCompleted(QVariant)),
       
   215             this, SLOT(addSelectedRecipients(QVariant)));
       
   216     *sndAsync << "Select contact"; 
       
   217     *sndAsync << KCntActionAll;   
       
   218     *sndAsync << KCntFilterDisplayAll;
       
   219 
       
   220     bool result = sndAsync->send();
       
   221     if (!result) {
       
   222     }  
       
   223 
       
   224 }
       
   225 
       
   226 void HbServiceClientView::addSelectedRecipients(const QVariant &value)
       
   227 {
       
   228     CntServicesContactList list;
       
   229     if(value.canConvert<CntServicesContactList>()) {
       
   230         list = qVariantValue<CntServicesContactList>(value);
       
   231     }
       
   232     else {
       
   233         ;
       
   234     }    
       
   235 
       
   236     if (list.count() == 0) {
       
   237         HbMessageBox note;
       
   238         note.setTimeout(10000);
       
   239         // "Nothing returned" will be replaced by a hbTrId when it is ready
       
   240         note.setText(tr("Nothing returned"));
       
   241         note.exec();
       
   242     }
       
   243     else {
       
   244         QString data;
       
   245         foreach (CntServicesContact cnt, list)
       
   246         {
       
   247             QString recipientName = cnt.mDisplayName;
       
   248             data += recipientName + "\n";
       
   249         }
       
   250         HbMessageBox msgBox;
       
   251         msgBox.setWindowTitle("Returned value");
       
   252         msgBox.setText(data);
       
   253         msgBox.exec();
       
   254     }
       
   255 }
       
   256     
   203 Q_IMPLEMENT_USER_METATYPE(HbContact)
   257 Q_IMPLEMENT_USER_METATYPE(HbContact)
   204  
       
   205 Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(HbContactList)
   258 Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(HbContactList)
       
   259 
       
   260 Q_IMPLEMENT_USER_METATYPE(CntServicesContact)
       
   261 Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(CntServicesContactList)