17 |
17 |
18 #include "cntservicecontactfetchview.h" |
18 #include "cntservicecontactfetchview.h" |
19 |
19 |
20 #include <cntservicescontact.h> |
20 #include <cntservicescontact.h> |
21 #include <cntlistmodel.h> |
21 #include <cntlistmodel.h> |
22 #include "cntservicehandler.h" |
22 #include "cntserviceviewparams.h" |
23 |
23 |
24 #include <hbmenu.h> |
24 #include <hbmenu.h> |
25 #include <hbview.h> |
25 #include <hbview.h> |
26 #include <hblistview.h> |
26 #include <hblistview.h> |
27 #include <hbdocumentloader.h> |
27 #include <hbdocumentloader.h> |
28 #include <hbaction.h> |
28 #include <hbaction.h> |
29 |
29 |
30 #include <QCoreApplication> |
30 #include <QCoreApplication> |
31 |
31 |
32 CntServiceContactFetchView::CntServiceContactFetchView(CntServiceHandler *aServiceHandler): |
32 CntServiceContactFetchView::CntServiceContactFetchView( CntAbstractServiceProvider& aServiceProvider ): |
33 CntBaseSelectionView(), |
33 CntBaseSelectionView(), |
34 mServiceHandler(aServiceHandler) |
34 mProvider( aServiceProvider ) |
35 { |
35 { |
36 HbAction* cancel = static_cast<HbAction*>( mDocument->findObject( "cnt:cancel" ) ); |
36 HbAction* cancel = static_cast<HbAction*>( mDocument->findObject( "cnt:cancel" ) ); |
37 mView->menu()->addAction( cancel ); |
37 mView->menu()->addAction( cancel ); |
38 |
38 |
39 connect(cancel, SIGNAL(triggered()), this, SLOT(cancelFetch()) ); |
39 connect(cancel, SIGNAL(triggered()), this, SLOT(cancelFetch()) ); |
40 connect( this, SIGNAL(viewClosed()), this, SLOT(aboutToCloseView()) ); |
40 connect( this, SIGNAL(viewClosed()), this, SLOT(closeFetchView()) ); |
41 connect( this, SIGNAL(viewOpened(CntAbstractViewManager*, const CntViewParameters)), this, SLOT(aboutToOpenView(CntAbstractViewManager*, const CntViewParameters)) ); |
41 connect( this, SIGNAL(viewOpened(CntAbstractViewManager*, const CntViewParameters)), this, SLOT(aboutToOpenView(CntAbstractViewManager*, const CntViewParameters)) ); |
42 } |
42 } |
43 |
43 |
44 CntServiceContactFetchView::~CntServiceContactFetchView() |
44 CntServiceContactFetchView::~CntServiceContactFetchView() |
45 { |
45 { |
46 } |
46 } |
47 |
47 |
48 |
48 |
49 void CntServiceContactFetchView::cancelFetch() |
49 void CntServiceContactFetchView::cancelFetch() |
50 { |
50 { |
51 connect(mServiceHandler, SIGNAL(returnValueDelivered()), qApp, SLOT(quit())); |
|
52 CntServicesContactList serviceList; |
51 CntServicesContactList serviceList; |
53 mServiceHandler->completeFetch(serviceList); |
52 QVariant variant; |
54 } |
53 variant.setValue(serviceList); |
|
54 mProvider.CompleteServiceAndCloseApp(variant); |
|
55 } |
55 |
56 |
56 void CntServiceContactFetchView::aboutToCloseView() |
57 |
|
58 |
|
59 void CntServiceContactFetchView::closeFetchView() |
57 { |
60 { |
58 CntServicesContactList serviceList; |
61 CntServicesContactList serviceList; |
59 QContactManager* mgr = mMgr->contactManager(SYMBIAN_BACKEND); |
62 QContactManager* mgr = mMgr->contactManager(SYMBIAN_BACKEND); |
60 QModelIndexList temp = mListView->selectionModel()->selection().indexes(); |
63 QModelIndexList temp = mListView->selectionModel()->selection().indexes(); |
61 for(int i = 0; i < temp.count(); i++ ) |
64 for(int i = 0; i < temp.count(); i++ ) |
88 |
91 |
89 //append it to the list |
92 //append it to the list |
90 serviceList.append(servicesContact); |
93 serviceList.append(servicesContact); |
91 } |
94 } |
92 |
95 |
93 connect(mServiceHandler, SIGNAL(returnValueDelivered()), qApp, SLOT(quit())); |
96 QVariant variant; |
94 mServiceHandler->completeFetch(serviceList); |
97 variant.setValue(serviceList); |
|
98 mProvider.CompleteServiceAndCloseApp(variant); |
95 } |
99 } |
96 |
100 |
97 void CntServiceContactFetchView::aboutToOpenView(CntAbstractViewManager* aMgr, const CntViewParameters aArgs) |
101 void CntServiceContactFetchView::aboutToOpenView(CntAbstractViewManager* aMgr, const CntViewParameters aArgs) |
98 { |
102 { |
99 mMgr = aMgr; |
103 mMgr = aMgr; |
100 |
104 |
101 // Set title of the view. |
105 // Set title of the view. |
102 QString title = aArgs.value(CntServiceHandler::ETitle).toString(); |
106 QString title = aArgs.value(KCntServiceViewParamTitle).toString(); |
103 mView->setTitle(title); |
107 mView->setTitle(title); |
104 |
108 |
105 // Set action filter |
109 // Set action filter |
106 QString filter = aArgs.value(CntServiceHandler::EFilter).toString(); |
110 QString action = aArgs.value(ESelectedAction).toString(); |
107 QString action = aArgs.value(CntServiceHandler::EAction).toString(); |
111 // ESelectedAction is defined in cntviewparams.h |
|
112 |
|
113 // Has never been implemented. |
|
114 //QString filterStr = aArgs.value(KCntServiceViewParamFilter).toString(); |
|
115 // KCntServiceViewParamFilter is defined in cntserviceviewparams.h |
|
116 |
108 if (action == KCntActionSms) |
117 if (action == KCntActionSms) |
109 { |
118 { |
110 QContactActionFilter actionFilter; |
119 QContactActionFilter actionFilter; |
111 actionFilter.setActionName("message"); |
120 actionFilter.setActionName("message"); |
112 mListModel->setFilter(actionFilter); |
121 mListModel->setFilter(actionFilter); |