272 |
268 |
273 QList<QContactSortOrder> groupsOrder; |
269 QList<QContactSortOrder> groupsOrder; |
274 groupsOrder.append(sortOrderGroupName); |
270 groupsOrder.append(sortOrderGroupName); |
275 |
271 |
276 QList<QContactLocalId> groupContactIds = mContactManager->contactIds(groupFilter, groupsOrder); |
272 QList<QContactLocalId> groupContactIds = mContactManager->contactIds(groupFilter, groupsOrder); |
277 if (!groupContactIds.isEmpty()) |
273 |
278 { |
274 for(int i = 0;i < groupContactIds.count();i++) |
279 for(int i = 0;i < groupContactIds.count();i++) |
275 { |
280 { |
276 QVariantList dataList; |
281 QVariantList dataList; |
277 |
282 |
278 // group name |
283 // group name |
279 QStringList displayList; |
284 QStringList displayList; |
280 |
285 |
281 QContact contact = mContactManager->contact(groupContactIds.at(i)); |
286 QContact contact = mContactManager->contact(groupContactIds.at(i)); |
282 QContactName contactName = contact.detail<QContactName>(); |
287 QContactName contactName = contact.detail<QContactName>(); |
283 QString groupName = contactName.customLabel(); |
288 QString groupName = contactName.customLabel(); |
284 if(groupContactIds.at(i) != mFavoriteGroupId ) |
289 if(groupContactIds.at(i) != mFavoriteGroupId ) |
285 { |
290 { |
286 if (groupName.isNull()) |
291 if (groupName.isNull()) |
287 { |
|
288 QString unnamed(hbTrId("Unnamed")); |
|
289 displayList.append(unnamed); |
|
290 } |
|
291 else |
|
292 { |
|
293 displayList.append(groupName); |
|
294 } |
|
295 |
|
296 QContactRelationshipFilter rFilter; |
|
297 rFilter.setRelationshipType(QContactRelationship::HasMember); |
|
298 rFilter.setRelatedContactRole(QContactRelationship::First); |
|
299 rFilter.setRelatedContactId(contact.id()); |
|
300 |
|
301 QContactSortOrder sortOrderFirstName; |
|
302 sortOrderFirstName.setDetailDefinitionName(QContactName::DefinitionName, |
|
303 QContactName::FieldFirst); |
|
304 sortOrderFirstName.setCaseSensitivity(Qt::CaseInsensitive); |
|
305 |
|
306 QContactSortOrder sortOrderLastName; |
|
307 sortOrderLastName.setDetailDefinitionName(QContactName::DefinitionName, |
|
308 QContactName::FieldLast); |
|
309 sortOrderLastName.setCaseSensitivity(Qt::CaseInsensitive); |
|
310 |
|
311 QList<QContactSortOrder> sortOrders; |
|
312 sortOrders.append(sortOrderFirstName); |
|
313 sortOrders.append(sortOrderLastName); |
|
314 |
|
315 // group members and their count |
|
316 QList<QContactLocalId> groupMemberIds = mContactManager->contactIds(rFilter, sortOrders); |
|
317 |
|
318 if (!groupMemberIds.isEmpty()) |
|
319 { |
|
320 QStringList nameList; |
|
321 for(int i = 0;i < groupMemberIds.count();i++) |
|
322 { |
|
323 QContact contact = mContactManager->contact(groupMemberIds.at(i)); |
|
324 QString memberName = contact.displayLabel(); |
|
325 nameList << memberName; |
|
326 if (nameList.join(", ").length() > 30) |
292 { |
327 { |
293 QString unnamed(hbTrId("Unnamed")); |
|
294 displayList.append(unnamed); |
|
295 } |
|
296 else |
|
297 { |
|
298 displayList.append(groupName); |
|
299 } |
|
300 |
|
301 QContactRelationshipFilter rFilter; |
|
302 rFilter.setRelationshipType(QContactRelationship::HasMember); |
|
303 rFilter.setRelatedContactRole(QContactRelationship::First); |
|
304 rFilter.setRelatedContactId(contact.id()); |
|
305 |
|
306 QContactSortOrder sortOrderFirstName; |
|
307 sortOrderFirstName.setDetailDefinitionName(QContactName::DefinitionName, |
|
308 QContactName::FieldFirst); |
|
309 sortOrderFirstName.setCaseSensitivity(Qt::CaseInsensitive); |
|
310 |
|
311 QContactSortOrder sortOrderLastName; |
|
312 sortOrderLastName.setDetailDefinitionName(QContactName::DefinitionName, |
|
313 QContactName::FieldLast); |
|
314 sortOrderLastName.setCaseSensitivity(Qt::CaseInsensitive); |
|
315 |
|
316 QList<QContactSortOrder> sortOrders; |
|
317 sortOrders.append(sortOrderFirstName); |
|
318 sortOrders.append(sortOrderLastName); |
|
319 |
|
320 // group members and their count |
|
321 QList<QContactLocalId> groupMemberIds = mContactManager->contactIds(rFilter, sortOrders); |
|
322 |
|
323 if (!groupMemberIds.isEmpty()) |
|
324 { |
|
325 QStringList nameList; |
|
326 for(int i = 0;i < groupMemberIds.count();i++) |
|
327 { |
|
328 QContact contact = mContactManager->contact(groupMemberIds.at(i)); |
|
329 QString memberName = contact.displayLabel(); |
|
330 nameList << memberName; |
|
331 if (nameList.join(", ").length() > 30) |
|
332 { |
|
333 break; |
|
334 } |
|
335 } |
|
336 QString names = nameList.join(", "); |
|
337 displayList.append(names); |
|
338 displayList.append(hbTrId("(%1)").arg(groupMemberIds.count())); |
|
339 } |
|
340 else |
|
341 { |
|
342 displayList.append(hbTrId("No members selected")); |
|
343 } |
|
344 dataList.append(displayList); |
|
345 |
|
346 // Default if no image for group |
|
347 bool icon = false; |
|
348 QList<QContactAvatar> details = contact.details<QContactAvatar>(); |
|
349 for (int i = 0;i < details.count();i++) |
|
350 { |
|
351 if (details.at(i).imageUrl().isValid()) |
|
352 { |
|
353 dataList.append(QStringList(details.at(i).imageUrl().toString())); |
|
354 icon = true; |
|
355 break; |
328 break; |
356 } |
329 } |
357 } |
330 } |
358 if(!icon) |
331 QString names = nameList.join(", "); |
|
332 displayList.append(names); |
|
333 displayList.append(hbTrId("(%1)").arg(groupMemberIds.count())); |
|
334 } |
|
335 else |
|
336 { |
|
337 displayList.append(hbTrId("No members selected")); |
|
338 } |
|
339 dataList.append(displayList); |
|
340 |
|
341 // Default if no image for group |
|
342 bool icon = false; |
|
343 QList<QContactAvatar> details = contact.details<QContactAvatar>(); |
|
344 for (int i = 0;i < details.count();i++) |
|
345 { |
|
346 if (details.at(i).imageUrl().isValid()) |
359 { |
347 { |
360 dataList.append(QStringList("qtg_large_custom")); |
348 dataList.append(QStringList(details.at(i).imageUrl().toString())); |
|
349 icon = true; |
|
350 break; |
361 } |
351 } |
362 |
352 } |
363 // contact Id for identification |
353 if(!icon) |
364 dataList.append(groupContactIds.at(i)); |
354 { |
365 |
355 dataList.append(QStringList("qtg_large_custom")); |
366 mDataPointer->mDataList.append(dataList); |
356 } |
367 } |
357 |
368 } |
358 // contact Id for identification |
369 } |
359 dataList.append(groupContactIds.at(i)); |
370 } |
360 |
371 |
361 mDataPointer->mDataList.append(dataList); |
372 |
362 } |
373 bool CntCollectionListModel::isFavoriteGroupCreated() |
363 } |
374 { |
364 } |
375 bool favoriteGroupCreated = false; |
365 |
376 QContactDetailFilter groupFilter; |
|
377 groupFilter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType); |
|
378 groupFilter.setValue(QString(QLatin1String(QContactType::TypeGroup))); |
|
379 |
|
380 QList<QContactLocalId> groupContactIds = mContactManager->contactIds(groupFilter); |
|
381 |
|
382 if (!groupContactIds.isEmpty()) |
|
383 { |
|
384 for(int i = 0;i < groupContactIds.count();i++) |
|
385 { |
|
386 QContact contact = mContactManager->contact(groupContactIds.at(i)); |
|
387 QContactName contactName = contact.detail<QContactName>(); |
|
388 QString groupName = contactName.customLabel(); |
|
389 if(groupName.compare("Favorites") == 0) |
|
390 { |
|
391 favoriteGroupCreated = true; |
|
392 mFavoriteGroupId = groupContactIds.at(i); |
|
393 break; |
|
394 } |
|
395 } |
|
396 } |
|
397 return favoriteGroupCreated; |
|
398 } |
|
399 |
|
400 int CntCollectionListModel::favoriteGroupId() |
|
401 { |
|
402 return mFavoriteGroupId; |
|
403 } |
|
404 |
366 |
405 bool CntCollectionListModel::isExtensionGroup(const QModelIndex &index) |
367 bool CntCollectionListModel::isExtensionGroup(const QModelIndex &index) |
406 { |
368 { |
407 int row = index.row(); |
369 int row = index.row(); |
408 if (row < 0) |
370 if (row < 0) |
423 CntViewParameters CntCollectionListModel::extensionGroupActivated(int row) |
385 CntViewParameters CntCollectionListModel::extensionGroupActivated(int row) |
424 { |
386 { |
425 CntViewParameters params; |
387 CntViewParameters params; |
426 for(int i = 0;i < mDataPointer->mExtensions.value(row)->groupCount();i++) |
388 for(int i = 0;i < mDataPointer->mExtensions.value(row)->groupCount();i++) |
427 { |
389 { |
428 const CntUiExtensionGroup& group = mDataPointer->mExtensions.value(row)->groupAt(i); |
390 CntUiExtensionGroup& group = mDataPointer->mExtensions.value(row)->groupAt(i); |
429 if (group.serviceId() == mDataPointer->mDataList.at(row)[2].toInt()) |
391 if (group.serviceId() == mDataPointer->mDataList.at(row)[2].toInt()) |
430 { |
392 { |
431 group.activated(params); |
393 group.activated(params); |
432 break; |
394 break; |
433 } |
395 } |
434 } |
396 } |
435 return params; |
397 return params; |
436 } |
398 } |
437 |
399 |
438 CntViewParameters CntCollectionListModel::extensionGroupLongPressed(int row, const QPointF& coords) |
400 void CntCollectionListModel::extensionGroupLongPressed(int row, const QPointF& coords, CntExtensionGroupCallback* interface) |
439 { |
401 { |
440 CntViewParameters params; |
|
441 for(int i = 0;i < mDataPointer->mExtensions.value(row)->groupCount();i++) |
402 for(int i = 0;i < mDataPointer->mExtensions.value(row)->groupCount();i++) |
442 { |
403 { |
443 const CntUiExtensionGroup& group = mDataPointer->mExtensions.value(row)->groupAt(i); |
404 CntUiExtensionGroup& group = mDataPointer->mExtensions.value(row)->groupAt(i); |
444 if (group.serviceId() == mDataPointer->mDataList.at(row)[2].toInt()) |
405 if (group.serviceId() == mDataPointer->mDataList.at(row)[2].toInt()) |
445 { |
406 { |
446 group.longPressed(coords, params); |
407 group.longPressed(coords, interface); |
447 break; |
408 break; |
448 } |
409 } |
449 } |
410 } |
450 return params; |
411 } |
451 } |
412 |
452 |
|