|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cntservicecontactselectionview.h" |
|
19 |
|
20 #include <cntservicescontact.h> |
|
21 #include <QCoreApplication> |
|
22 #include <QModelIndex> |
|
23 #include <hblistview.h> |
|
24 #include <cntlistmodel.h> |
|
25 |
|
26 CntServiceContactSelectionView::CntServiceContactSelectionView( CntAbstractServiceProvider& aServiceProvider ): |
|
27 CntBaseSelectionView(), |
|
28 mProvider( aServiceProvider ) |
|
29 { |
|
30 connect(mListView, SIGNAL(activated(const QModelIndex&)), this, SLOT(onListViewActivated(const QModelIndex&))); |
|
31 connect( this, SIGNAL(viewClosed()), this, SLOT(aboutToCloseView()) ); |
|
32 connect( this, SIGNAL(viewOpened(CntAbstractViewManager*, const CntViewParameters)), this, SLOT(aboutToOpenView(CntAbstractViewManager*, const CntViewParameters)) ); |
|
33 } |
|
34 |
|
35 CntServiceContactSelectionView::~CntServiceContactSelectionView() |
|
36 { |
|
37 |
|
38 } |
|
39 |
|
40 // An item in the selection list has been clicked |
|
41 void CntServiceContactSelectionView::onListViewActivated(const QModelIndex &aIndex) |
|
42 { |
|
43 QContact contact = mListModel->contact(aIndex); |
|
44 contact.saveDetail(&mDetail); |
|
45 |
|
46 CntViewParameters params; |
|
47 params.insert(EViewId, serviceEditView); |
|
48 QVariant var; |
|
49 var.setValue(contact); |
|
50 params.insert(ESelectedContact, var); |
|
51 mMgr->changeView(params); |
|
52 } |
|
53 |
|
54 void CntServiceContactSelectionView::aboutToCloseView() |
|
55 { |
|
56 QVariant variant; |
|
57 variant.setValue(KCntServicesReturnValueContactNotModified); |
|
58 mProvider.CompleteServiceAndCloseApp(variant); |
|
59 CntViewParameters args; |
|
60 mMgr->back( args ); |
|
61 } |
|
62 |
|
63 void CntServiceContactSelectionView::aboutToOpenView(CntAbstractViewManager* aMgr, const CntViewParameters viewParameters) |
|
64 { |
|
65 mMgr = aMgr; |
|
66 |
|
67 QContactDetailFilter filter; |
|
68 filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); |
|
69 QString typeContact = QContactType::TypeContact; |
|
70 filter.setValue(typeContact); |
|
71 mListModel->setFilter(filter); |
|
72 // hide my card if it's not set |
|
73 if (mListModel->myCardId() == 0) |
|
74 { |
|
75 mListModel->showMyCard(false); |
|
76 } |
|
77 mDetail = viewParameters.value(ESelectedDetail).value<QContactDetail>(); |
|
78 } |
|
79 |
|
80 // EOF |