64 //back button |
70 //back button |
65 mSoftkey = new HbAction(Hb::BackNaviAction, mView); |
71 mSoftkey = new HbAction(Hb::BackNaviAction, mView); |
66 connect(mSoftkey, SIGNAL(triggered()), this, SLOT(showPreviousView())); |
72 connect(mSoftkey, SIGNAL(triggered()), this, SLOT(showPreviousView())); |
67 |
73 |
68 // menu actions |
74 // menu actions |
|
75 mNewGroupAction = static_cast<HbAction*>(mDocumentLoader.findObject("cnt:newgroup")); |
|
76 connect(mNewGroupAction, SIGNAL(triggered()), this, SLOT(newGroup())); |
69 mDeleteGroupsAction = static_cast<HbAction*>(mDocumentLoader.findObject("cnt:deletegroups")); |
77 mDeleteGroupsAction = static_cast<HbAction*>(mDocumentLoader.findObject("cnt:deletegroups")); |
70 mDeleteGroupsAction->setParent(mView); |
|
71 connect(mDeleteGroupsAction, SIGNAL(triggered()), this, SLOT(deleteGroups())); |
78 connect(mDeleteGroupsAction, SIGNAL(triggered()), this, SLOT(deleteGroups())); |
72 |
79 |
73 // toolbar actions |
80 // toolbar actions |
|
81 |
74 mNamesAction = static_cast<HbAction*>(mDocumentLoader.findObject("cnt:names")); |
82 mNamesAction = static_cast<HbAction*>(mDocumentLoader.findObject("cnt:names")); |
75 mNamesAction->setParent(mView); |
|
76 connect(mNamesAction, SIGNAL(triggered()), this, SLOT(showPreviousView())); |
83 connect(mNamesAction, SIGNAL(triggered()), this, SLOT(showPreviousView())); |
77 mRefreshAction = static_cast<HbAction*>(mDocumentLoader.findObject("cnt:refresh")); |
84 mFindAction = static_cast<HbAction*>(mDocumentLoader.findObject("cnt:find")); |
78 mRefreshAction->setParent(mView); |
85 mExtensionAction = static_cast<HbAction*> (mDocumentLoader.findObject("cnt:activity")); |
79 connect(mRefreshAction, SIGNAL(triggered()), this, SLOT(refreshDataModel())); |
|
80 mNewGroupAction = static_cast<HbAction*>(mDocumentLoader.findObject("cnt:newgroup")); |
|
81 mNewGroupAction->setParent(mView); |
|
82 connect(mNewGroupAction, SIGNAL(triggered()), this, SLOT(newGroup())); |
|
83 } |
86 } |
84 |
87 |
85 /*! |
88 /*! |
86 |
89 |
87 */ |
90 */ |
112 mDeleteGroupsAction->setEnabled(false); |
115 mDeleteGroupsAction->setEnabled(false); |
113 } |
116 } |
114 |
117 |
115 // set up the list |
118 // set up the list |
116 mListView = static_cast<HbListView*>(mDocumentLoader.findWidget(QString("listView"))); |
119 mListView = static_cast<HbListView*>(mDocumentLoader.findWidget(QString("listView"))); |
|
120 mListView->setUniformItemSizes(true); |
117 |
121 |
118 connect(mListView, SIGNAL(activated(const QModelIndex&)), this, |
122 connect(mListView, SIGNAL(activated(const QModelIndex&)), this, |
119 SLOT(openGroup(const QModelIndex&))); |
123 SLOT(openGroup(const QModelIndex&))); |
120 connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), this, |
124 connect(mListView, SIGNAL(longPressed(HbAbstractViewItem*,QPointF)), this, |
121 SLOT(showContextMenu(HbAbstractViewItem*,QPointF))); |
125 SLOT(showContextMenu(HbAbstractViewItem*,QPointF))); |
148 /*! |
152 /*! |
149 Called after user clicked on the listview. |
153 Called after user clicked on the listview. |
150 */ |
154 */ |
151 void CntCollectionView::openGroup(const QModelIndex &index) |
155 void CntCollectionView::openGroup(const QModelIndex &index) |
152 { |
156 { |
153 int id = index.data(Qt::UserRole).toInt(); |
157 if (mModel->isExtensionGroup(index)) |
154 int favoriteGrpId = mModel->favoriteGroupId(); |
158 { |
155 |
159 CntViewParameters params = mModel->extensionGroupActivated(index.row()); |
156 if (id == favoriteGrpId ) |
160 if (params.count()) |
157 { |
161 { |
158 QContact favoriteGroup = mViewManager->contactManager(SYMBIAN_BACKEND)->contact(favoriteGrpId); |
162 mViewManager->changeView(params); |
159 QContactRelationshipFilter rFilter; |
163 } |
160 rFilter.setRelationshipType(QContactRelationship::HasMember); |
164 } |
161 rFilter.setRelatedContactRole(QContactRelationshipFilter::First); |
165 else |
162 rFilter.setRelatedContactId(favoriteGroup.id()); |
166 { |
163 // group members and their count |
167 int id = index.data(Qt::UserRole).toInt(); |
164 QList<QContactLocalId> groupMemberIds = mViewManager->contactManager(SYMBIAN_BACKEND)->contactIds(rFilter); |
168 int favoriteGrpId = mModel->favoriteGroupId(); |
165 |
169 |
166 if (groupMemberIds.isEmpty()) |
170 if (id == favoriteGrpId ) |
167 { |
171 { |
168 CntViewParameters viewParameters(CntViewParameters::collectionFavoritesView); |
172 QContact favoriteGroup = mViewManager->contactManager(SYMBIAN_BACKEND)->contact(favoriteGrpId); |
169 viewParameters.setSelectedContact(favoriteGroup); |
173 QContactRelationshipFilter rFilter; |
|
174 rFilter.setRelationshipType(QContactRelationship::HasMember); |
|
175 rFilter.setRelatedContactRole(QContactRelationship::First); |
|
176 rFilter.setRelatedContactId(favoriteGroup.id()); |
|
177 // group members and their count |
|
178 QList<QContactLocalId> groupMemberIds = mViewManager->contactManager(SYMBIAN_BACKEND)->contactIds(rFilter); |
|
179 |
|
180 if (groupMemberIds.isEmpty()) |
|
181 { |
|
182 CntViewParameters viewParameters; |
|
183 viewParameters.insert(EViewId, collectionFavoritesView); |
|
184 QVariant var; |
|
185 var.setValue(favoriteGroup); |
|
186 viewParameters.insert(ESelectedContact, var); |
|
187 mViewManager->changeView(viewParameters); |
|
188 } |
|
189 else |
|
190 { |
|
191 CntViewParameters viewParameters; |
|
192 viewParameters.insert(EViewId, FavoritesMemberView); |
|
193 QVariant var; |
|
194 var.setValue(favoriteGroup); |
|
195 viewParameters.insert(ESelectedContact, var); |
|
196 mViewManager->changeView(viewParameters); |
|
197 } |
|
198 } |
|
199 else |
|
200 { |
|
201 QContact groupContact = mViewManager->contactManager(SYMBIAN_BACKEND)->contact(id); |
|
202 |
|
203 CntViewParameters viewParameters; |
|
204 viewParameters.insert(EViewId, groupMemberView); |
|
205 QVariant var; |
|
206 var.setValue(groupContact); |
|
207 viewParameters.insert(ESelectedContact, var); |
170 mViewManager->changeView(viewParameters); |
208 mViewManager->changeView(viewParameters); |
171 } |
209 } |
172 else |
210 } |
173 { |
211 } |
174 CntViewParameters viewParameters(CntViewParameters::FavoritesMemberView); |
212 |
175 viewParameters.setSelectedContact(favoriteGroup); |
213 void CntCollectionView::showContextMenu(HbAbstractViewItem *item, const QPointF &coords) |
176 mViewManager->changeView(viewParameters); |
214 { |
|
215 if (mModel->isExtensionGroup(item->modelIndex())) |
|
216 { |
|
217 CntViewParameters params = mModel->extensionGroupLongPressed(item->modelIndex().row(), coords); |
|
218 if (params.count()) |
|
219 { |
|
220 mViewManager->changeView(params); |
177 } |
221 } |
178 } |
222 } |
179 else |
223 else |
180 { |
224 { |
181 QContact groupContact = mViewManager->contactManager(SYMBIAN_BACKEND)->contact(id); |
225 int id = item->modelIndex().data(Qt::UserRole).toInt(); |
182 CntViewParameters viewParameters(CntViewParameters::groupMemberView); |
226 int favoriteGrpId = mModel->favoriteGroupId(); |
183 viewParameters.setSelectedContact(groupContact); |
227 |
184 mViewManager->changeView(viewParameters); |
228 HbMenu *menu = new HbMenu(); |
185 } |
229 HbAction *openAction = 0; |
186 } |
230 HbAction *deleteAction = 0; |
187 |
231 |
188 void CntCollectionView::showContextMenu(HbAbstractViewItem *item, const QPointF &coords) |
232 openAction = menu->addAction(hbTrId("txt_common_menu_open")); |
189 { |
233 |
190 int id = item->modelIndex().data(Qt::UserRole).toInt(); |
234 if (id != favoriteGrpId) |
191 int favoriteGrpId = mModel->favoriteGroupId(); |
235 { |
192 |
236 deleteAction = menu->addAction(hbTrId("txt_phob_menu_delete_group")); |
193 HbMenu *menu = new HbMenu(); |
237 } |
194 HbAction *openAction = 0; |
238 |
195 HbAction *deleteAction = 0; |
239 HbAction *selectedAction = menu->exec(coords); |
196 |
240 |
197 openAction = menu->addAction(hbTrId("txt_common_menu_open")); |
241 if (selectedAction) |
198 |
242 { |
199 if (id != favoriteGrpId) |
243 if (selectedAction == openAction) |
200 { |
244 { |
201 deleteAction = menu->addAction(hbTrId("txt_phob_menu_delete_group")); |
245 openGroup(item->modelIndex()); |
202 } |
246 } |
203 |
247 else if (selectedAction == deleteAction) |
204 HbAction *selectedAction = menu->exec(coords); |
248 { |
205 |
249 QContact groupContact = mViewManager->contactManager(SYMBIAN_BACKEND)->contact(id); |
206 if (selectedAction) |
250 deleteGroup(groupContact); |
207 { |
251 } |
208 if (selectedAction == openAction) |
252 } |
209 { |
253 menu->deleteLater(); |
210 openGroup(item->modelIndex()); |
254 } |
211 } |
|
212 else if (selectedAction == deleteAction) |
|
213 { |
|
214 QContact groupContact = mViewManager->contactManager(SYMBIAN_BACKEND)->contact(id); |
|
215 deleteGroup(groupContact); |
|
216 } |
|
217 } |
|
218 menu->deleteLater(); |
|
219 } |
255 } |
220 |
256 |
221 void CntCollectionView::newGroup() |
257 void CntCollectionView::newGroup() |
222 { |
258 { |
223 QString mTextOfNewItem(""); |
259 QString mTextOfNewItem(""); |
255 groupSelectionPopup->populateListOfContact(); |
291 groupSelectionPopup->populateListOfContact(); |
256 HbAction* action = groupSelectionPopup->exec(); |
292 HbAction* action = groupSelectionPopup->exec(); |
257 if (action == groupSelectionPopup->primaryAction()) |
293 if (action == groupSelectionPopup->primaryAction()) |
258 { |
294 { |
259 groupSelectionPopup->saveNewGroup(); |
295 groupSelectionPopup->saveNewGroup(); |
260 CntViewParameters viewParameters(CntViewParameters::groupMemberView); |
296 |
261 viewParameters.setSelectedContact(groupContact); |
297 CntViewParameters viewParameters; |
|
298 viewParameters.insert(EViewId, groupMemberView); |
|
299 QVariant var; |
|
300 var.setValue(groupContact); |
|
301 viewParameters.insert(ESelectedContact, var); |
262 mViewManager->changeView(viewParameters); |
302 mViewManager->changeView(viewParameters); |
|
303 |
263 delete groupSelectionPopup; |
304 delete groupSelectionPopup; |
264 } |
305 } |
265 else if (action == groupSelectionPopup->secondaryAction()) |
306 else if (action == groupSelectionPopup->secondaryAction()) |
266 { |
307 { |
267 delete groupSelectionPopup; |
308 delete groupSelectionPopup; |