19 #include "cntfetchcontactpopup.h" |
19 #include "cntfetchcontactpopup.h" |
20 #include "cntcontactcardheadingitem.h" |
20 #include "cntcontactcardheadingitem.h" |
21 #include "cntglobal.h" |
21 #include "cntglobal.h" |
22 #include "cntimagelabel.h" |
22 #include "cntimagelabel.h" |
23 #include "cntimageutility.h" |
23 #include "cntimageutility.h" |
|
24 #include "cntthumbnailmanager.h" |
24 #include <hbnotificationdialog.h> |
25 #include <hbnotificationdialog.h> |
25 #include <hbmessagebox.h> |
26 #include <hbmessagebox.h> |
26 #include <hbmenu.h> |
27 #include <hbmenu.h> |
27 #include <hblistview.h> |
28 #include <hblistview.h> |
28 #include <hblistviewitem.h> |
29 #include <hblistviewitem.h> |
31 #include <hbscrollbar.h> |
32 #include <hbscrollbar.h> |
32 #include <hbview.h> |
33 #include <hbview.h> |
33 #include <hbaction.h> |
34 #include <hbaction.h> |
34 #include <hblabel.h> |
35 #include <hblabel.h> |
35 #include <hbparameterlengthlimiter.h> |
36 #include <hbparameterlengthlimiter.h> |
36 #include <thumbnailmanager_qt.h> |
|
37 #include <cntlistmodel.h> |
37 #include <cntlistmodel.h> |
38 #include <hbmainwindow.h> |
38 #include <hbmainwindow.h> |
39 #include <xqservicerequest.h> |
39 #include <xqservicerequest.h> |
40 |
40 |
41 #include "cntdocumentloader.h" |
41 #include "cntdocumentloader.h" |
103 connect(mManageAction, SIGNAL(triggered()), this, SLOT(manageMembers())); |
103 connect(mManageAction, SIGNAL(triggered()), this, SLOT(manageMembers())); |
104 mDeleteAction = static_cast<HbAction*>( mDocument->findObject("cnt:deletegroup")); |
104 mDeleteAction = static_cast<HbAction*>( mDocument->findObject("cnt:deletegroup")); |
105 connect(mDeleteAction, SIGNAL(triggered()), this, SLOT(deleteGroup())); |
105 connect(mDeleteAction, SIGNAL(triggered()), this, SLOT(deleteGroup())); |
106 mShowActionsAction = static_cast<HbAction*>( mDocument->findObject("cnt:groupactions")); |
106 mShowActionsAction = static_cast<HbAction*>( mDocument->findObject("cnt:groupactions")); |
107 connect(mShowActionsAction, SIGNAL(triggered()), this, SLOT(openGroupActions())); |
107 connect(mShowActionsAction, SIGNAL(triggered()), this, SLOT(openGroupActions())); |
108 |
|
109 // thumbnail manager |
|
110 mThumbnailManager = new ThumbnailManager(this); |
|
111 mThumbnailManager->setMode(ThumbnailManager::Default); |
|
112 mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForQuality); |
|
113 mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge); |
|
114 |
|
115 connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void*, int, int)), |
|
116 this, SLOT(thumbnailReady(QPixmap, void*, int, int))); |
|
117 } |
108 } |
118 |
109 |
119 /*! |
110 /*! |
120 Destructor |
111 Destructor |
121 */ |
112 */ |
145 // reading "landscape" section |
136 // reading "landscape" section |
146 mDocument->load( CNT_GROUPMEMBERVIEW_XML, "landscape" ); |
137 mDocument->load( CNT_GROUPMEMBERVIEW_XML, "landscape" ); |
147 } |
138 } |
148 } |
139 } |
149 |
140 |
150 void CntGroupMemberViewPrivate::activate( CntAbstractViewManager* aMgr, const CntViewParameters aArgs ) |
141 void CntGroupMemberViewPrivate::activate( const CntViewParameters aArgs ) |
151 { |
142 { |
152 mViewManager = aMgr; |
|
153 mArgs = aArgs; |
143 mArgs = aArgs; |
154 |
144 mViewManager = &mEngine->viewManager(); |
|
145 mThumbnailManager = &mEngine->thumbnailManager(); |
|
146 |
|
147 connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void*, int, int)), |
|
148 this, SLOT(thumbnailReady(QPixmap, void*, int, int))); |
|
149 |
155 if (mView->navigationAction() != mSoftkey) |
150 if (mView->navigationAction() != mSoftkey) |
156 { |
151 { |
157 mView->setNavigationAction(mSoftkey); |
152 mView->setNavigationAction(mSoftkey); |
158 } |
153 } |
159 |
154 |
174 for (int i = 0;i < details.count();i++) |
169 for (int i = 0;i < details.count();i++) |
175 { |
170 { |
176 if (details.at(i).imageUrl().isValid()) |
171 if (details.at(i).imageUrl().isValid()) |
177 { |
172 { |
178 mAvatar = new QContactAvatar(details.at(i)); |
173 mAvatar = new QContactAvatar(details.at(i)); |
179 mThumbnailManager->getThumbnail(mAvatar->imageUrl().toString()); |
174 mThumbnailManager->getThumbnail(ThumbnailManager::ThumbnailLarge, mAvatar->imageUrl().toString()); |
180 break; |
175 break; |
181 } |
176 } |
182 } |
177 } |
183 |
178 |
184 // create list & model |
179 // create list & model |
185 mListView->setFrictionEnabled(true); |
180 mListView->setFrictionEnabled(true); |
186 mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); |
181 mListView->setScrollingStyle(HbScrollArea::PanWithFollowOn); |
187 mListView->verticalScrollBar()->setInteractive(true); |
182 mListView->verticalScrollBar()->setInteractive(true); |
188 mListView->setUniformItemSizes(true); |
183 mListView->setUniformItemSizes(true); |
189 mListView->listItemPrototype()->setGraphicsSize(HbListViewItem::Thumbnail); |
184 |
|
185 HbFrameBackground frame; |
|
186 frame.setFrameGraphicsName("qtg_fr_list_normal"); |
|
187 frame.setFrameType(HbFrameDrawer::NinePieces); |
|
188 |
|
189 HbListViewItem* prototype = mListView->listItemPrototype(); |
|
190 prototype->setGraphicsSize(HbListViewItem::Thumbnail); |
|
191 prototype->setDefaultFrame(frame); |
|
192 |
190 HbIndexFeedback *indexFeedback = new HbIndexFeedback(mView); |
193 HbIndexFeedback *indexFeedback = new HbIndexFeedback(mView); |
191 indexFeedback->setIndexFeedbackPolicy(HbIndexFeedback::IndexFeedbackSingleCharacter); |
194 indexFeedback->setIndexFeedbackPolicy(HbIndexFeedback::IndexFeedbackSingleCharacter); |
192 indexFeedback->setItemView(mListView); |
195 indexFeedback->setItemView(mListView); |
193 |
196 |
194 HbFrameBackground frame; |
197 // if no contacts are present, then disable the Manage Members toolbar |
195 frame.setFrameGraphicsName("qtg_fr_list_normal"); |
198 QContactDetailFilter filter; |
196 frame.setFrameType(HbFrameDrawer::NinePieces); |
199 filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); |
197 mListView->itemPrototypes().first()->setDefaultFrame(frame); |
200 filter.setValue(QLatin1String(QContactType::TypeContact)); |
|
201 |
|
202 QList<QContactLocalId> contactIds = getContactManager()->contactIds(filter); |
|
203 if (contactIds.isEmpty()) |
|
204 { |
|
205 mManageAction->setEnabled(false); |
|
206 } |
198 |
207 |
199 createModel(); |
208 createModel(); |
200 |
209 |
201 if (mArgs.value(ESelectedAction).toString() == CNT_SAVE_ACTION) |
210 if (mArgs.value(ESelectedAction).toString() == CNT_SAVE_ACTION) |
202 { |
211 { |
214 Q_Q(CntGroupMemberView); |
223 Q_Q(CntGroupMemberView); |
215 |
224 |
216 emit q->backPressed(); |
225 emit q->backPressed(); |
217 |
226 |
218 //save the contact if avatar has been changed. |
227 //save the contact if avatar has been changed. |
219 QContact contact = mViewManager->contactManager( SYMBIAN_BACKEND )->contact(mGroupContact->localId()); |
228 QContact contact = getContactManager()->contact(mGroupContact->localId()); |
220 if ( contact != *mGroupContact ) |
229 if ( contact != *mGroupContact ) |
221 { |
230 { |
222 getContactManager()->saveContact(mGroupContact); |
231 getContactManager()->saveContact(mGroupContact); |
223 } |
232 } |
224 mViewManager->back(mArgs); |
233 mViewManager->back(mArgs); |
251 } |
260 } |
252 |
261 |
253 CntFetchContactPopup* popup = CntFetchContactPopup::createMultiSelectionPopup( |
262 CntFetchContactPopup* popup = CntFetchContactPopup::createMultiSelectionPopup( |
254 HbParameterLengthLimiter(hbTrId("txt_phob_title_members_of_1_group")).arg(groupName), |
263 HbParameterLengthLimiter(hbTrId("txt_phob_title_members_of_1_group")).arg(groupName), |
255 hbTrId("txt_common_button_save"), |
264 hbTrId("txt_common_button_save"), |
256 *mViewManager->contactManager(SYMBIAN_BACKEND)); |
265 mEngine->contactManager(SYMBIAN_BACKEND)); |
257 connect( popup, SIGNAL(fetchReady(QSet<QContactLocalId>)),this, SLOT(handleManageMembers(QSet<QContactLocalId>)) ); |
266 connect( popup, SIGNAL(fetchReady(QSet<QContactLocalId>)),this, SLOT(handleManageMembers(QSet<QContactLocalId>)) ); |
258 popup->setSelectedContacts( mOriginalGroupMembers.toSet() ); |
267 popup->setSelectedContacts( mOriginalGroupMembers.toSet() ); |
259 popup->showPopup(); |
268 popup->showPopup(); |
260 } |
269 } |
261 |
270 |
268 setRelationship(removedMembers, removedMemberships); |
277 setRelationship(removedMembers, removedMemberships); |
269 |
278 |
270 QSet<QContactLocalId> addedMembers = aIds - mOriginalGroupMembers.toSet(); |
279 QSet<QContactLocalId> addedMembers = aIds - mOriginalGroupMembers.toSet(); |
271 setRelationship(addedMembers, addedMemberships); |
280 setRelationship(addedMembers, addedMemberships); |
272 |
281 |
273 QMap<int, QContactManager::Error> errors; |
|
274 if (!addedMemberships.isEmpty()) |
282 if (!addedMemberships.isEmpty()) |
275 { |
283 { |
276 getContactManager()->saveRelationships(&addedMemberships, &errors); |
284 getContactManager()->saveRelationships(&addedMemberships, NULL); |
277 } |
285 } |
278 |
286 |
279 if (!removedMemberships.isEmpty()) |
287 if (!removedMemberships.isEmpty()) |
280 { |
288 { |
281 getContactManager()->removeRelationships(removedMemberships, &errors); |
289 getContactManager()->removeRelationships(removedMemberships, NULL); |
282 } |
290 } |
283 } |
291 } |
284 |
292 |
285 void CntGroupMemberViewPrivate::createModel() |
293 void CntGroupMemberViewPrivate::createModel() |
286 { |
294 { |
287 QContactRelationshipFilter rFilter; |
295 QContactRelationshipFilter rFilter; |
288 rFilter.setRelationshipType(QContactRelationship::HasMember); |
296 rFilter.setRelationshipType(QContactRelationship::HasMember); |
289 rFilter.setRelatedContactRole(QContactRelationship::First); |
297 rFilter.setRelatedContactRole(QContactRelationship::First); |
290 rFilter.setRelatedContactId(mGroupContact->id()); |
298 rFilter.setRelatedContactId(mGroupContact->id()); |
291 |
299 |
292 mModel = new CntListModel(getContactManager(), rFilter, false); |
300 mModel = new CntListModel(getContactManager(), rFilter, false); |
293 mListView->setModel(mModel); |
301 mListView->setModel(mModel); |
294 } |
302 } |
295 |
303 |
296 void CntGroupMemberViewPrivate::editGroup() |
304 void CntGroupMemberViewPrivate::editGroup() |
464 mViewManager->changeView( mArgs ); |
472 mViewManager->changeView( mArgs ); |
465 } |
473 } |
466 |
474 |
467 QContactManager* CntGroupMemberViewPrivate::getContactManager() |
475 QContactManager* CntGroupMemberViewPrivate::getContactManager() |
468 { |
476 { |
469 return mViewManager->contactManager(SYMBIAN_BACKEND); |
477 return &mEngine->contactManager(SYMBIAN_BACKEND); |
470 } |
478 } |
471 |
479 |
472 void CntGroupMemberViewPrivate::setRelationship(QSet<QContactLocalId> &aLocalId, |
480 void CntGroupMemberViewPrivate::setRelationship(QSet<QContactLocalId> &aLocalIds, |
473 QList<QContactRelationship> &aRelationshipList) |
481 QList<QContactRelationship> &aRelationshipList) |
474 { |
482 { |
475 foreach (QContactLocalId id, aLocalId) { |
483 foreach (QContactLocalId localId, aLocalIds) { |
476 QContact contact = getContactManager()->contact(id); |
484 QContactId id; |
477 |
485 id.setLocalId(localId); |
478 QContactRelationship membership; |
486 QContactRelationship membership; |
479 membership.setRelationshipType(QContactRelationship::HasMember); |
487 membership.setRelationshipType(QContactRelationship::HasMember); |
480 membership.setFirst(mGroupContact->id()); |
488 membership.setFirst(mGroupContact->id()); |
481 membership.setSecond(contact.id()); |
489 membership.setSecond(id); |
482 aRelationshipList.append(membership); |
490 aRelationshipList.append(membership); |
483 } |
491 } |
484 } |
492 } |
485 |
493 |
486 /*! |
494 /*! |
490 { |
498 { |
491 HbMenu *menu = new HbMenu(); |
499 HbMenu *menu = new HbMenu(); |
492 HbAction *changeImageAction = menu->addAction(hbTrId("txt_phob_menu_change_picture"), this, SLOT(openImageEditor())); |
500 HbAction *changeImageAction = menu->addAction(hbTrId("txt_phob_menu_change_picture"), this, SLOT(openImageEditor())); |
493 if (mAvatar && !mAvatar->imageUrl().isEmpty()) |
501 if (mAvatar && !mAvatar->imageUrl().isEmpty()) |
494 { |
502 { |
495 HbAction *removeAction = menu->addAction(hbTrId("txt_phob_menu_remove_image"), this, SLOT(removeImage())); |
503 menu->addAction(hbTrId("txt_phob_menu_remove_image"), this, SLOT(removeImage())); |
496 } |
504 } |
497 menu->setPreferredPos(aCoords); |
505 menu->setPreferredPos(aCoords); |
498 menu->open(); |
506 menu->open(); |
499 } |
507 } |
500 |
508 |