72 */ |
72 */ |
73 void CntMyCardView::activate(CntAbstractViewManager* aMgr, const CntViewParameters aArgs) |
73 void CntMyCardView::activate(CntAbstractViewManager* aMgr, const CntViewParameters aArgs) |
74 { |
74 { |
75 mViewManager = aMgr; |
75 mViewManager = aMgr; |
76 |
76 |
77 if (mView->navigationAction() != mSoftkey) |
77 if (mView->navigationAction() != mSoftkey) { |
78 mView->setNavigationAction(mSoftkey); |
78 mView->setNavigationAction(mSoftkey); |
|
79 } |
79 |
80 |
80 HbMainWindow* window = mView->mainWindow(); |
81 HbMainWindow* window = mView->mainWindow(); |
81 connect(window, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(setOrientation(Qt::Orientation))); |
82 connect(window, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(setOrientation(Qt::Orientation))); |
82 setOrientation(window->orientation()); |
83 setOrientation(window->orientation()); |
83 |
84 |
95 if (mViewManager->contactManager( SYMBIAN_BACKEND )->contactIds(filter).isEmpty()) |
96 if (mViewManager->contactManager( SYMBIAN_BACKEND )->contactIds(filter).isEmpty()) |
96 { |
97 { |
97 chooseButton->setEnabled(false); |
98 chooseButton->setEnabled(false); |
98 } |
99 } |
99 |
100 |
100 mFetchView = new CntFetchContacts(mViewManager->contactManager( SYMBIAN_BACKEND )); |
101 if (!mFetchView) { |
101 connect(mFetchView, SIGNAL(clicked()), this, SLOT(handleMultiCardSelection())); |
102 mFetchView = new CntFetchContacts(mViewManager->contactManager( SYMBIAN_BACKEND )); |
|
103 connect(mFetchView, SIGNAL(clicked()), this, SLOT(handleMultiCardSelection())); |
|
104 } |
102 } |
105 } |
103 |
106 |
104 void CntMyCardView::deactivate() |
107 void CntMyCardView::deactivate() |
105 { |
108 { |
106 |
|
107 } |
109 } |
108 |
110 |
109 void CntMyCardView::setOrientation(Qt::Orientation orientation) |
111 void CntMyCardView::setOrientation(Qt::Orientation orientation) |
110 { |
112 { |
111 if (orientation == Qt::Vertical) |
113 if (orientation == Qt::Vertical) |
139 Opens the my card selection view |
141 Opens the my card selection view |
140 */ |
142 */ |
141 void CntMyCardView::openMyCardSelectionView() |
143 void CntMyCardView::openMyCardSelectionView() |
142 { |
144 { |
143 // Display a list of contacts to choose a mycard from. |
145 // Display a list of contacts to choose a mycard from. |
144 mFetchView->setDetails(hbTrId("txt_phob_subtitle_my_card"),hbTrId("Save")); |
146 mFetchView->setDetails(hbTrId("txt_phob_title_select_contact"), ""); |
145 QSet<QContactLocalId> emptyContactsSet; |
147 QSet<QContactLocalId> emptyContactsSet; |
146 mFetchView->displayContacts(CntFetchContacts::popup, |
148 mFetchView->displayContacts(CntFetchContacts::popup, |
147 HbAbstractItemView::SingleSelection, |
149 HbAbstractItemView::SingleSelection, |
148 emptyContactsSet); |
150 emptyContactsSet); |
149 } |
151 } |
155 QSet<QContactLocalId> selectedContacts = mFetchView->getSelectedContacts(); |
157 QSet<QContactLocalId> selectedContacts = mFetchView->getSelectedContacts(); |
156 |
158 |
157 if ( !mFetchView->wasCanceled() && !selectedContacts.isEmpty() ) { |
159 if ( !mFetchView->wasCanceled() && !selectedContacts.isEmpty() ) { |
158 QList<QContactLocalId> selectedContactsList = selectedContacts.values(); |
160 QList<QContactLocalId> selectedContactsList = selectedContacts.values(); |
159 manager->setSelfContactId(selectedContactsList.front()); |
161 manager->setSelfContactId(selectedContactsList.front()); |
|
162 |
|
163 QContact contact = mViewManager->contactManager(SYMBIAN_BACKEND)->contact(selectedContactsList.front()); |
|
164 removeFromGroup(&contact); |
|
165 |
|
166 showPreviousView(); |
160 } |
167 } |
161 |
168 } |
162 CntViewParameters viewParameters; |
169 |
163 viewParameters.insert(EViewId, namesView); |
170 void CntMyCardView::removeFromGroup(const QContact* aContact) |
164 mViewManager->changeView(viewParameters); |
171 { |
|
172 QContactDetailFilter groupFilter; |
|
173 groupFilter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); |
|
174 groupFilter.setValue(QLatin1String(QContactType::TypeGroup)); |
|
175 |
|
176 QContactManager* mgr = mViewManager->contactManager(SYMBIAN_BACKEND); |
|
177 QList<QContactLocalId> groupContactIds = mgr->contactIds(groupFilter); |
|
178 if (!groupContactIds.isEmpty()) { |
|
179 for(int i = 0;i < groupContactIds.count();i++) { |
|
180 QContact groupContact = mgr->contact(groupContactIds.at(i)); |
|
181 QContactRelationship relationship; |
|
182 relationship.setRelationshipType(QContactRelationship::HasMember); |
|
183 relationship.setFirst(groupContact.id()); |
|
184 relationship.setSecond(aContact->id()); |
|
185 mgr->removeRelationship(relationship); |
|
186 } |
|
187 } |
165 } |
188 } |
166 |
189 |
167 // EOF |
190 // EOF |