14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "cntmycardview.h" |
18 #include "cntmycardview.h" |
19 #include "cntfetchcontactsview.h" |
19 #include "cntfetchcontactpopup.h" |
20 #include "cntglobal.h" |
20 #include "cntglobal.h" |
21 #include <qtcontacts.h> |
21 #include <qtcontacts.h> |
22 #include <hbpushbutton.h> |
22 #include <hbpushbutton.h> |
23 #include <hbaction.h> |
23 #include <hbaction.h> |
24 #include <hbview.h> |
24 #include <hbview.h> |
96 |
92 |
97 if (mViewManager->contactManager( SYMBIAN_BACKEND )->contactIds(filter).isEmpty()) |
93 if (mViewManager->contactManager( SYMBIAN_BACKEND )->contactIds(filter).isEmpty()) |
98 { |
94 { |
99 chooseButton->setEnabled(false); |
95 chooseButton->setEnabled(false); |
100 } |
96 } |
101 |
|
102 if (!mFetchView) { |
|
103 mFetchView = new CntFetchContacts(*mViewManager->contactManager( SYMBIAN_BACKEND )); |
|
104 connect(mFetchView, SIGNAL(clicked()), this, SLOT(handleMultiCardSelection())); |
|
105 } |
|
106 } |
97 } |
107 |
98 |
108 void CntMyCardView::deactivate() |
99 void CntMyCardView::deactivate() |
109 { |
100 { |
110 } |
101 } |
133 viewParameters.insert(EMyCard, "myCard" ); |
124 viewParameters.insert(EMyCard, "myCard" ); |
134 |
125 |
135 QVariant var; |
126 QVariant var; |
136 var.setValue(*mContact); |
127 var.setValue(*mContact); |
137 viewParameters.insert(ESelectedContact, var); |
128 viewParameters.insert(ESelectedContact, var); |
|
129 viewParameters.insert(EExtraAction, CNT_ROOT_ACTION); |
138 mViewManager->changeView(viewParameters); |
130 mViewManager->changeView(viewParameters); |
139 } |
131 } |
140 |
132 |
141 /*! |
133 /*! |
142 Opens the my card selection view |
134 Opens the my card selection view |
143 */ |
135 */ |
144 void CntMyCardView::openMyCardSelectionView() |
136 void CntMyCardView::openMyCardSelectionView() |
145 { |
137 { |
146 // Display a list of contacts to choose a mycard from. |
138 CntFetchContactPopup* popup = CntFetchContactPopup::createSingleSelectionPopup( |
147 mFetchView->setDetails(hbTrId("txt_phob_title_select_contact"), ""); |
139 hbTrId("txt_phob_title_select_contact"), |
148 QSet<QContactLocalId> emptyContactsSet; |
140 *mViewManager->contactManager(SYMBIAN_BACKEND)); |
149 mFetchView->displayContacts(HbAbstractItemView::SingleSelection, emptyContactsSet); |
141 connect( popup, SIGNAL(fetchReady(QSet<QContactLocalId>)), this, SLOT(handleMultiCardSelection(QSet<QContactLocalId>))); |
|
142 popup->showPopup(); |
150 } |
143 } |
151 |
144 |
152 void CntMyCardView::handleMultiCardSelection() |
145 void CntMyCardView::handleMultiCardSelection( QSet<QContactLocalId> aIds ) |
153 { |
146 { |
154 QContactManager* manager = mViewManager->contactManager( SYMBIAN_BACKEND ); |
147 QContactManager* manager = mViewManager->contactManager( SYMBIAN_BACKEND ); |
155 |
148 |
156 QSet<QContactLocalId> selectedContacts = mFetchView->getSelectedContacts(); |
149 if ( !aIds.isEmpty() ) { |
157 |
150 QList<QContactLocalId> selectedContactsList = aIds.values(); |
158 if ( !mFetchView->wasCanceled() && !selectedContacts.isEmpty() ) { |
|
159 QList<QContactLocalId> selectedContactsList = selectedContacts.values(); |
|
160 QContact contact = manager->contact(selectedContactsList.front()); |
151 QContact contact = manager->contact(selectedContactsList.front()); |
161 removeFromGroup(&contact); |
152 removeFromGroup(&contact); |
162 |
153 |
163 manager->setSelfContactId( contact.localId() ); |
154 manager->setSelfContactId( contact.localId() ); |
164 showPreviousView(); |
155 showPreviousView(); |