54 |
51 |
55 // ---------------------------------------------------------------------------- |
52 // ---------------------------------------------------------------------------- |
56 // LocationPickerDataManagerPrivate::populateModel() |
53 // LocationPickerDataManagerPrivate::populateModel() |
57 // ---------------------------------------------------------------------------- |
54 // ---------------------------------------------------------------------------- |
58 bool LocationPickerDataManagerPrivate::populateModel( QStandardItemModel &aModel, |
55 bool LocationPickerDataManagerPrivate::populateModel( QStandardItemModel &aModel, |
59 TViewType aViewType, const Qt::Orientations aOrientation, quint32 aCollectionId ) |
56 TViewType aViewType, quint32 aCollectionId ) |
60 { |
57 { |
61 mModel = &aModel; |
58 mModel = &aModel; |
62 mViewType = aViewType; |
59 mViewType = aViewType; |
63 mOrientation = aOrientation; |
|
64 |
60 |
65 if( !mDb ) |
61 if( !mDb ) |
66 { |
62 { |
67 // no items in the landmark database, so return false. |
63 // no items in the landmark database, so return false. |
68 return false; |
64 return false; |
186 else |
189 else |
187 { |
190 { |
188 lmAddressLine2 = aItemArray[i].mCountry; |
191 lmAddressLine2 = aItemArray[i].mCountry; |
189 addressEmtpy = EFalse; |
192 addressEmtpy = EFalse; |
190 } |
193 } |
|
194 contextAddressCountry = aItemArray[i].mCountry; |
191 } |
195 } |
192 // set icons based on contact address type |
196 // set icons based on contact address type |
193 QVariantList icons; |
197 QVariantList icons; |
194 |
198 HbIcon adressTypeIcon; |
195 QString adressType; |
199 QString adressType; |
196 bool adressIconPresent = false; |
200 bool adressIconPresent = false; |
197 if( aItemArray[i].mSourceType == ESourceContactsHome ) |
201 if( aItemArray[i].mSourceType == ESourceContactsHome ) |
198 { |
202 { |
|
203 adressTypeIcon = HbIcon(KContactHomeIcon); |
199 adressType = KContactHomeIcon; |
204 adressType = KContactHomeIcon; |
200 adressIconPresent = true; |
205 adressIconPresent = true; |
201 } |
206 } |
202 else if( aItemArray[i].mSourceType == ESourceContactsWork ) |
207 else if( aItemArray[i].mSourceType == ESourceContactsWork ) |
203 { |
208 { |
|
209 adressTypeIcon = HbIcon(KContactWorkIcon); |
204 adressType = KContactWorkIcon; |
210 adressType = KContactWorkIcon; |
205 adressIconPresent = true; |
|
206 } |
|
207 else if( aItemArray[i].mSourceType == ESourceContactsPref ) |
|
208 { |
|
209 adressType = KContactPrefIcon; |
|
210 adressIconPresent = true; |
211 adressIconPresent = true; |
211 } |
212 } |
212 |
213 |
213 // create a list item and set to model |
214 // create a list item and set to model |
214 QStringList addressData; |
215 QStringList addressData; |
215 //create model for grid view in landscape mode |
216 QString landscapeIconPath; |
216 if( mOrientation == Qt::Horizontal && ( mViewType == ELocationPickerCollectionContent || |
217 |
217 mViewType == ELocationPickerContent ) ) |
218 if( QFile::exists( aItemArray[i].mMapTilePath ) ) |
218 { |
219 { |
219 addressData.clear(); |
220 //draw maptile Icon |
|
221 landscapeIconPath = QString( aItemArray[i].mMapTilePath ); |
|
222 } |
|
223 else |
|
224 { |
|
225 //draw dummy icon |
|
226 landscapeIconPath = QString(""); |
|
227 } |
|
228 addressData.clear(); |
|
229 HbIcon potraitIcon( KDummyImage ); |
|
230 icons<<potraitIcon; |
|
231 if(adressIconPresent) |
|
232 { |
|
233 icons<<adressTypeIcon; |
|
234 } |
|
235 QStringList contextList; |
|
236 contextList<<lmAddressLine1<<contextAddress<<contextAddressCountry; |
|
237 QStandardItem *modelItem = new QStandardItem(); |
|
238 addressData << lmAddressLine1 << lmAddressLine2; |
|
239 modelItem->setData(QVariant(addressData), Qt::DisplayRole); |
|
240 modelItem->setData( icons, Qt::DecorationRole ); |
|
241 modelItem->setData( aItemArray[i].mId, Qt::UserRole ); |
|
242 modelItem->setData(landscapeIconPath,Qt::UserRole+1); |
|
243 modelItem->setData(adressType,Qt::UserRole+2); |
|
244 modelItem->setData(QVariant(contextList), Qt::UserRole+3); |
220 |
245 |
221 QString landscapeIconPath; |
246 mModel->appendRow( modelItem ); |
222 |
|
223 if( QFile::exists( aItemArray[i].mMapTilePath ) ) |
|
224 { |
|
225 //draw maptile Icon |
|
226 |
|
227 landscapeIconPath = QString( QString( aItemArray[i].mMapTilePath ) ); |
|
228 } |
|
229 else |
|
230 { |
|
231 //draw dummy icon |
|
232 landscapeIconPath = QString(""); |
|
233 } |
|
234 |
|
235 icons<<landscapeIconPath; |
|
236 QStandardItem *modelItem = new QStandardItem(); |
|
237 lmAddressLine1 = lmAddressLine1.append(KSeparator); |
|
238 lmAddressLine1 = lmAddressLine1.append(KSpace); |
|
239 QString landMark = lmAddressLine1.append(lmAddressLine2); |
|
240 addressData <<landMark; |
|
241 modelItem->setData(QVariant(addressData), Qt::DisplayRole); |
|
242 modelItem->setData( icons[0], Qt::DecorationRole ); |
|
243 modelItem->setData( aItemArray[i].mId, Qt::UserRole ); |
|
244 modelItem->setData(adressType,Qt::UserRole+1); |
|
245 mModel->appendRow( modelItem ); |
|
246 } |
|
247 else |
|
248 { |
|
249 //create model for list view in potrait mode |
|
250 addressData.clear(); |
|
251 HbIcon potraitIcon( KDummyImage ); |
|
252 icons<<potraitIcon; |
|
253 if(adressIconPresent) |
|
254 { |
|
255 icons<<adressType; |
|
256 } |
|
257 QStandardItem *modelItem = new QStandardItem(); |
|
258 addressData << lmAddressLine1 << lmAddressLine2; |
|
259 modelItem->setData(QVariant(addressData), Qt::DisplayRole); |
|
260 modelItem->setData( icons, Qt::DecorationRole ); |
|
261 modelItem->setData( aItemArray[i].mId, Qt::UserRole ); |
|
262 mModel->appendRow( modelItem ); |
|
263 } |
|
264 } |
247 } |
265 } |
248 } |
266 |
249 |
267 return true; |
250 return true; |
268 } |
251 } |
279 QString contactCollectionNum; |
262 QString contactCollectionNum; |
280 contactCollectionNum.setNum(conNum); |
263 contactCollectionNum.setNum(conNum); |
281 contactCollectionNum.append(" items"); |
264 contactCollectionNum.append(" items"); |
282 QString contactCollectionName( hbTrId("txt_lint_list_contact_addresses") ); |
265 QString contactCollectionName( hbTrId("txt_lint_list_contact_addresses") ); |
283 |
266 |
284 if( mOrientation == Qt::Vertical) |
267 |
285 { |
268 QStringList contact = (QStringList()<<contactCollectionName<<contactCollectionNum); |
286 QStringList contact = (QStringList()<<contactCollectionName<<contactCollectionNum); |
269 modelItemContact->setData( QVariant( contact ), Qt::DisplayRole ); |
287 modelItemContact->setData( QVariant( contact ), Qt::DisplayRole ); |
|
288 } |
|
289 else |
|
290 { |
|
291 QString contact = contactCollectionName.append(contactCollectionNum); |
|
292 modelItemContact->setData( QVariant( contact ), Qt::DisplayRole ); |
|
293 } |
|
294 |
270 |
295 modelItemContact->setData( HbIcon ( KCollectionsContacts ), Qt::DecorationRole ); |
271 modelItemContact->setData( HbIcon ( KCollectionsContacts ), Qt::DecorationRole ); |
296 modelItemContact->setData( ESourceLandmarksContactsCat, Qt::UserRole ); |
272 modelItemContact->setData( ESourceLandmarksContactsCat, Qt::UserRole ); |
297 mModel->appendRow( modelItemContact ); |
273 mModel->appendRow( modelItemContact ); |
298 |
274 |