13 * |
13 * |
14 * Description: LocationPickerDataManager private implementation |
14 * Description: LocationPickerDataManager private implementation |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <e32base.h> |
|
19 #include <e32std.h> |
|
20 #include <lbsposition.h> |
|
21 #include <EPos_CPosLandmark.h> |
|
22 #include <EPos_CPosLandmarkDatabase.h> |
|
23 #include <EPos_CPosLmCategoryManager.h> |
|
24 #include <EPos_CPosLandmarkCategory.h> |
|
25 #include <EPos_CPosLandmarkSearch.h> |
|
26 #include <EPos_CPosLmCategoryCriteria.h> |
|
27 #include <HbIcon> |
18 #include <HbIcon> |
28 |
19 #include <QPixmap> |
|
20 #include <QPainter> |
|
21 #include <QIcon> |
|
22 #include <locationdatalookupdb.h> |
|
23 #include <QFile> |
29 #include "locationpickerdatamanager_p.h" |
24 #include "locationpickerdatamanager_p.h" |
|
25 |
|
26 //constant value used |
|
27 const int ASPECTRATIOHEIGHT(3); |
|
28 const int ASPECTRATIOWIDTH (4); |
30 |
29 |
31 |
30 |
32 // ---------------------------------------------------------------------------- |
31 // ---------------------------------------------------------------------------- |
33 // LocationPickerDataManagerPrivate::LocationPickerDataManagerPrivate() |
32 // LocationPickerDataManagerPrivate::LocationPickerDataManagerPrivate() |
34 // ---------------------------------------------------------------------------- |
33 // ---------------------------------------------------------------------------- |
35 |
34 |
36 LocationPickerDataManagerPrivate::LocationPickerDataManagerPrivate() : |
35 LocationPickerDataManagerPrivate::LocationPickerDataManagerPrivate() : |
37 mModel( NULL ), |
36 mModel( NULL ), |
38 mViewType( ELocationPickerContent ), |
37 mViewType( ELocationPickerContent ), |
39 mIterator(NULL), |
38 mDb( NULL ) |
40 mLandmarkDb(NULL), |
39 { |
41 mLmCategoryManager(NULL), |
40 mDb = new LocationDataLookupDb(); |
42 mLandmarkSearch(NULL) |
41 mDb->open(); |
43 { |
|
44 } |
|
45 |
|
46 // ---------------------------------------------------------------------------- |
|
47 // LocationPickerDataManagerPrivate::LocationPickerDataManagerPrivate() |
|
48 // ---------------------------------------------------------------------------- |
|
49 |
|
50 LocationPickerDataManagerPrivate::LocationPickerDataManagerPrivate( QStandardItemModel &aModel, TViewType aViewType ) : |
|
51 mModel( &aModel ), |
|
52 mViewType( aViewType ), |
|
53 mIterator(NULL), |
|
54 mLandmarkDb(NULL), |
|
55 mLmCategoryManager(NULL), |
|
56 mLandmarkSearch(NULL) |
|
57 { |
|
58 } |
42 } |
59 |
43 |
60 |
44 |
61 // ---------------------------------------------------------------------------- |
45 // ---------------------------------------------------------------------------- |
62 // LocationPickerDataManagerPrivate::~LocationPickerDataManagerPrivate() |
46 // LocationPickerDataManagerPrivate::~LocationPickerDataManagerPrivate() |
63 // ---------------------------------------------------------------------------- |
47 // ---------------------------------------------------------------------------- |
64 LocationPickerDataManagerPrivate::~LocationPickerDataManagerPrivate() |
48 LocationPickerDataManagerPrivate::~LocationPickerDataManagerPrivate() |
65 { |
49 { |
66 // delete the member variables; |
50 // delete the member variables; |
67 |
51 if( mDb ) |
68 if( mIterator ) |
52 { |
69 delete mIterator; |
53 mDb->close(); |
70 if ( mLandmarkDb ) |
54 delete mDb; |
71 delete mLandmarkDb; |
55 mDb = NULL; |
72 if( mLmCategoryManager ) |
56 } |
73 delete mLmCategoryManager; |
|
74 if( mLandmarkSearch ) |
|
75 delete mLandmarkSearch; |
|
76 } |
57 } |
77 |
58 |
78 // ---------------------------------------------------------------------------- |
59 // ---------------------------------------------------------------------------- |
79 // LocationPickerDataManagerPrivate::populateModel() |
60 // LocationPickerDataManagerPrivate::populateModel() |
80 // ---------------------------------------------------------------------------- |
61 // ---------------------------------------------------------------------------- |
81 bool LocationPickerDataManagerPrivate::populateModel( const Qt::Orientations aOrientation, quint32 aCollectionId ) |
62 bool LocationPickerDataManagerPrivate::populateModel( QStandardItemModel &aModel, |
82 { |
63 TViewType aViewType, const Qt::Orientations aOrientation, quint32 aCollectionId ) |
83 bool retValue = false; |
64 { |
|
65 mModel = &aModel; |
|
66 mViewType = aViewType; |
84 mOrientation = aOrientation; |
67 mOrientation = aOrientation; |
85 TRAP_IGNORE( retValue = populateModelL( aCollectionId ) ); |
68 |
86 return retValue; |
69 if( !mDb ) |
87 } |
70 { |
88 |
71 // no items in the landmark database, so return false. |
89 // ---------------------------------------------------------------------------- |
72 return false; |
90 // LocationPickerDataManagerPrivate::populateModel() |
73 } |
91 // ---------------------------------------------------------------------------- |
|
92 bool LocationPickerDataManagerPrivate::populateModelL( quint32 aCollectionId ) |
|
93 { |
|
94 // Handle to the landmark database |
|
95 mLandmarkDb = NULL; |
|
96 |
|
97 //Open and intialize Landmark DB |
|
98 mLandmarkDb = CPosLandmarkDatabase::OpenL(); |
|
99 ExecuteAndDeleteLD( mLandmarkDb->InitializeL() ); |
|
100 |
74 |
101 switch( mViewType ) |
75 switch( mViewType ) |
102 { |
76 { |
103 case ELocationPickerContent: |
77 case ELocationPickerContent: |
104 case ELocationPickerSearchView: |
78 case ELocationPickerSearchView: |
105 { |
79 { |
106 // Create an iterator for iterating the landmarks in the database |
80 QList<QLookupItem> itemArray; |
107 mIterator = mLandmarkDb->LandmarkIteratorL(); |
81 mDb->getEntries( itemArray ); |
108 |
82 return populateLandmarks( itemArray ); |
109 if( ( !mIterator ) || (mIterator->NumOfItemsL() == 0) ) |
83 } |
110 { |
84 |
111 // no items in the landmark database, so return false. |
85 case ELocationPickerCollectionListContent: |
112 return false; |
86 { |
113 } |
87 populateCollections(); |
114 CleanupStack::PushL(mIterator); |
|
115 populateLandmarksL(); |
|
116 CleanupStack::Pop( mIterator ); |
|
117 } |
88 } |
118 break; |
89 break; |
119 case ELocationPickerCollectionListContent: |
|
120 { |
|
121 |
|
122 // Create category manager for landmarks |
|
123 mLmCategoryManager = CPosLmCategoryManager::NewL( *mLandmarkDb ); |
|
124 |
|
125 if( !mLmCategoryManager ) |
|
126 { |
|
127 return false; |
|
128 } |
|
129 // Create an iterator for iterating the referenced categories in the database |
|
130 mIterator = mLmCategoryManager->ReferencedCategoryIteratorL(); |
|
131 |
|
132 if( ( !mIterator ) || (mIterator->NumOfItemsL() == 0) ) |
|
133 { |
|
134 // no items in the landmark database, so return false. |
|
135 return false; |
|
136 } |
|
137 CleanupStack::PushL(mIterator); |
|
138 populateCollectionsL(); |
|
139 CleanupStack::Pop( mIterator ); |
|
140 |
|
141 } |
|
142 break; |
|
143 |
90 |
144 case ELocationPickerCollectionContent: |
91 case ELocationPickerCollectionContent: |
145 { |
92 { |
146 |
93 QList<QLookupItem> itemArray; |
147 // create a search object. |
94 mDb->getEntries( itemArray, aCollectionId ); |
148 mLandmarkSearch = CPosLandmarkSearch::NewL( *mLandmarkDb ); |
95 if( itemArray.count() == 0 ) |
149 CleanupStack::PushL( mLandmarkSearch ); |
|
150 |
|
151 // Create the search criterion |
|
152 CPosLmCategoryCriteria* criteria = CPosLmCategoryCriteria::NewLC(); |
|
153 criteria->SetCategoryItemId( aCollectionId ); |
|
154 |
|
155 // Start the search and execute it at once. |
|
156 ExecuteAndDeleteLD( mLandmarkSearch->StartLandmarkSearchL( *criteria ) ); |
|
157 CleanupStack::PopAndDestroy( criteria ); |
|
158 |
|
159 // Retrieve an iterator to access the matching landmarks. |
|
160 mIterator = mLandmarkSearch->MatchIteratorL(); |
|
161 if( ( !mIterator ) || (mIterator->NumOfItemsL() == 0) ) |
|
162 { |
|
163 // no landmarks in this collection |
|
164 CleanupStack::Pop(mLandmarkSearch); |
|
165 return false; |
96 return false; |
166 } |
97 |
167 CleanupStack::PushL( mIterator ); |
98 return populateLandmarks( itemArray ); |
168 populateLandmarksL(); |
|
169 CleanupStack::Pop( mIterator ); |
|
170 CleanupStack::Pop(mLandmarkSearch); |
|
171 } |
99 } |
172 break; |
|
173 } |
100 } |
174 return true; |
101 return true; |
175 } |
102 } |
176 |
103 |
177 // ---------------------------------------------------------------------------- |
104 // ---------------------------------------------------------------------------- |
178 // LocationPickerDataManagerPrivate::populateLandmarksL() |
105 // LocationPickerDataManagerPrivate::populateLandmarks() |
179 // ---------------------------------------------------------------------------- |
106 // ---------------------------------------------------------------------------- |
180 |
107 |
181 void LocationPickerDataManagerPrivate::populateLandmarksL() |
108 bool LocationPickerDataManagerPrivate::populateLandmarks( QList<QLookupItem> &aItemArray ) |
182 { |
109 { |
183 // Read each landmark in the database and copy to the model. |
|
184 TPosLmItemId lmId; |
|
185 mModel->clear(); |
110 mModel->clear(); |
186 while ( ( lmId = mIterator->NextL() ) != KPosLmNullItemId ) |
111 |
187 { |
112 if( !aItemArray.count() ) |
188 CPosLandmark* readLandmark = mLandmarkDb->ReadLandmarkLC(lmId ); |
113 { |
189 |
114 return false; |
190 if( readLandmark ) |
115 } |
|
116 QString lmAddressLine1; |
|
117 QString lmAddressLine2; |
|
118 |
|
119 for( int i = 0; i < aItemArray.count(); i++ ) |
|
120 { |
|
121 |
|
122 if( !aItemArray[i].mIsDuplicate ) |
191 { |
123 { |
192 QString lmAddressLine1(" "); |
124 lmAddressLine1 = aItemArray[i].mName; |
193 QString lmAddressLine2(""); |
125 if( lmAddressLine1.isEmpty() ) |
194 |
126 lmAddressLine1 = KSpace; |
195 TPtrC tempStr; |
127 |
196 TInt retStatus; |
|
197 |
|
198 // Copy landmark name in string 1 |
|
199 retStatus = readLandmark->GetLandmarkName( tempStr ); |
|
200 if( retStatus == KErrNone && tempStr.Length() > 0) |
|
201 { |
|
202 lmAddressLine1 = QString( (QChar*)tempStr.Ptr(), tempStr.Length()); |
|
203 } |
|
204 |
|
205 // create address line 2 |
|
206 bool addressEmtpy = true; // used to check if address line 2 is empty |
128 bool addressEmtpy = true; // used to check if address line 2 is empty |
207 |
129 if( !aItemArray[i].mStreet.isEmpty() ) |
208 // get street |
130 { |
209 retStatus = readLandmark->GetPositionField( EPositionFieldStreet, tempStr ); |
131 lmAddressLine2 = aItemArray[i].mStreet; |
210 if( retStatus == KErrNone && tempStr.Length() ) |
|
211 { |
|
212 lmAddressLine2 = QString( (QChar*)tempStr.Ptr(), tempStr.Length()); |
|
213 addressEmtpy = EFalse; |
132 addressEmtpy = EFalse; |
214 } |
133 } |
215 |
134 if( !aItemArray[i].mCity.isEmpty() ) |
216 // Get city |
|
217 retStatus =readLandmark->GetPositionField( EPositionFieldCity, tempStr ); |
|
218 if( retStatus == KErrNone && tempStr.Length() ) |
|
219 { |
135 { |
220 if( !addressEmtpy ) |
136 if( !addressEmtpy ) |
221 { |
137 { |
222 lmAddressLine2 = lmAddressLine2 + KSeparator; |
138 lmAddressLine2 = lmAddressLine2 + KSeparator; |
223 lmAddressLine2 = lmAddressLine2 + KSpace; |
139 lmAddressLine2 = lmAddressLine2 + KSpace; |
224 lmAddressLine2 = lmAddressLine2 + QString( (QChar*)tempStr.Ptr(), tempStr.Length()); |
140 lmAddressLine2 = lmAddressLine2 + aItemArray[i].mCity; |
225 } |
141 } |
226 else |
142 else |
227 { |
143 { |
228 lmAddressLine2 = QString( (QChar*)tempStr.Ptr(), tempStr.Length()); |
144 lmAddressLine2 = aItemArray[i].mCity; |
229 addressEmtpy = EFalse; |
145 addressEmtpy = EFalse; |
230 } |
146 } |
231 } |
147 } |
232 // Get State |
148 if( !aItemArray[i].mState.isEmpty() ) |
233 retStatus =readLandmark->GetPositionField( EPositionFieldState, tempStr ); |
|
234 if( retStatus == KErrNone && tempStr.Length() ) |
|
235 { |
149 { |
236 if( !addressEmtpy ) |
150 if( !addressEmtpy ) |
237 { |
151 { |
238 lmAddressLine2 = lmAddressLine2 + KSeparator; |
152 lmAddressLine2 = lmAddressLine2 + KSeparator; |
239 lmAddressLine2 = lmAddressLine2 + KSpace; |
153 lmAddressLine2 = lmAddressLine2 + KSpace; |
240 lmAddressLine2 = lmAddressLine2 + QString( (QChar*)tempStr.Ptr(), tempStr.Length()); |
154 lmAddressLine2 = lmAddressLine2 + aItemArray[i].mState; |
241 } |
155 } |
242 else |
156 else |
243 { |
157 { |
244 lmAddressLine2 = QString( (QChar*)tempStr.Ptr(), tempStr.Length()); |
158 lmAddressLine2 = aItemArray[i].mState; |
245 addressEmtpy = EFalse; |
159 addressEmtpy = EFalse; |
246 } |
160 } |
247 } |
161 } |
248 |
162 if( !aItemArray[i].mCountry.isEmpty() ) |
249 // get country |
|
250 retStatus =readLandmark->GetPositionField( EPositionFieldCountry, tempStr ); |
|
251 if( retStatus == KErrNone && tempStr.Length() ) |
|
252 { |
163 { |
253 if( !addressEmtpy ) |
164 if( !addressEmtpy ) |
254 { |
165 { |
255 lmAddressLine2 = lmAddressLine2 + KSeparator; |
166 lmAddressLine2 = lmAddressLine2 + KSeparator; |
256 lmAddressLine2 = lmAddressLine2 + KSpace; |
167 lmAddressLine2 = lmAddressLine2 + KSpace; |
257 lmAddressLine2 = lmAddressLine2 + QString( (QChar*)tempStr.Ptr(), tempStr.Length()); |
168 lmAddressLine2 = lmAddressLine2 + aItemArray[i].mCountry; |
258 } |
169 } |
259 else |
170 else |
260 { |
171 { |
261 lmAddressLine2 = QString( (QChar*)tempStr.Ptr(), tempStr.Length()); |
172 lmAddressLine2 = aItemArray[i].mCountry; |
262 addressEmtpy = EFalse; |
173 addressEmtpy = EFalse; |
263 } |
174 } |
264 } |
175 } |
265 |
|
266 // get contact address type |
|
267 QString contactAddressType; |
|
268 retStatus = readLandmark->GetLandmarkDescription( tempStr ); |
|
269 if( retStatus == KErrNone && tempStr.Length() > 0) |
|
270 { |
|
271 contactAddressType = QString( (QChar*)tempStr.Ptr(), tempStr.Length()); |
|
272 } |
|
273 |
|
274 // set icons based on contact address type |
176 // set icons based on contact address type |
275 QVariantList icons; |
177 QVariantList icons; |
276 if( contactAddressType == KContactHome ) |
178 |
277 { |
179 HbIcon adressTypeIcon; |
278 icons << HbIcon(KDummyImage) << HbIcon(KContactHomeIcon); |
180 bool adressIconPresent = false; |
279 } |
181 if( aItemArray[i].mSourceType == ESourceContactsHome ) |
280 else if( contactAddressType == KContactWork ) |
182 { |
281 { |
183 adressTypeIcon = HbIcon(KContactHomeIcon); |
282 icons << HbIcon(KDummyImage) << HbIcon(KContactWorkIcon); |
184 adressIconPresent = true; |
|
185 } |
|
186 else if( aItemArray[i].mSourceType == ESourceContactsWork ) |
|
187 { |
|
188 adressTypeIcon =HbIcon(KContactWorkIcon); |
|
189 adressIconPresent = true; |
|
190 } |
|
191 else if( aItemArray[i].mSourceType == ESourceContactsPref ) |
|
192 { |
|
193 adressTypeIcon =HbIcon(KContactPrefIcon); |
|
194 adressIconPresent = true; |
|
195 } |
|
196 |
|
197 // create a list item and set to model |
|
198 QStringList addressData; |
|
199 //create model for grid view in landscape mode |
|
200 if( mOrientation == Qt::Horizontal && ( mViewType == ELocationPickerCollectionContent || |
|
201 mViewType == ELocationPickerContent ) ) |
|
202 { |
|
203 addressData.clear(); |
|
204 |
|
205 HbIcon landscapeIcon; |
|
206 |
|
207 if( QFile::exists( aItemArray[i].mMapTilePath ) ) |
|
208 { |
|
209 //draw maptile Icon |
|
210 QPainter painter; |
|
211 QPixmap sourcePixmap; |
|
212 sourcePixmap = QPixmap( QString(aItemArray[i].mMapTilePath) ); |
|
213 int mapHeight = (sourcePixmap.height()/ASPECTRATIOHEIGHT)*ASPECTRATIOHEIGHT; |
|
214 int mapWidth = mapHeight*ASPECTRATIOWIDTH/ASPECTRATIOHEIGHT; |
|
215 QPixmap mapPixmap(mapWidth, mapHeight); |
|
216 painter.begin( &mapPixmap ); |
|
217 painter.drawPixmap( 0,0,sourcePixmap,(((sourcePixmap.width()-mapWidth))/2), |
|
218 ((sourcePixmap.height()-mapHeight)/2),mapWidth,mapHeight ); |
|
219 painter.end(); |
|
220 if(adressIconPresent) |
|
221 { |
|
222 //draw the adressType Icon over mapTile Icon |
|
223 QPixmap adressTypePixmap = adressTypeIcon.pixmap(); |
|
224 painter.begin( &mapPixmap ); |
|
225 painter.drawPixmap( (mapPixmap.width()-adressTypePixmap.width()),0,adressTypePixmap ); |
|
226 painter.end(); |
|
227 } |
|
228 QIcon landscape( mapPixmap ); |
|
229 landscapeIcon = HbIcon( landscape ); |
283 } |
230 } |
284 else |
231 else |
285 { |
232 { |
286 icons << HbIcon(KDummyImage) << HbIcon(KContactPrefIcon); |
233 //draw dummy icon |
287 } |
234 landscapeIcon = HbIcon( KDummyImage ); |
288 |
235 } |
289 // create a list item and set to model |
236 |
290 QStringList addressData; |
237 icons<<landscapeIcon; |
291 //create model for grid view in landscape mode |
|
292 if(mOrientation == Qt::Horizontal && ( mViewType == ELocationPickerCollectionContent || mViewType == ELocationPickerContent) ) |
|
293 { |
|
294 addressData.clear(); |
|
295 QStandardItem *modelItem = new QStandardItem(); |
238 QStandardItem *modelItem = new QStandardItem(); |
296 addressData << lmAddressLine1; |
239 addressData << lmAddressLine1; |
297 modelItem->setData(QVariant(addressData), Qt::DisplayRole); |
240 modelItem->setData(QVariant(addressData), Qt::DisplayRole); |
298 modelItem->setData( icons[0], Qt::DecorationRole ); |
241 modelItem->setData( icons[0], Qt::DecorationRole ); |
299 modelItem->setData(QString("contact"),Qt::UserRole); |
242 modelItem->setData( aItemArray[i].mId, Qt::UserRole ); |
300 mModel->appendRow( modelItem ); |
243 mModel->appendRow( modelItem ); |
301 } |
244 } |
302 else |
245 else |
303 { |
246 { |
304 //create model for list view in potrai mode |
247 //create model for list view in potrait mode |
305 addressData.clear(); |
248 addressData.clear(); |
|
249 HbIcon potraitIcon( KDummyImage ); |
|
250 icons<<potraitIcon; |
|
251 if(adressIconPresent) |
|
252 { |
|
253 icons<<adressTypeIcon; |
|
254 } |
306 QStandardItem *modelItem = new QStandardItem(); |
255 QStandardItem *modelItem = new QStandardItem(); |
307 addressData << lmAddressLine1 << lmAddressLine2; |
256 addressData << lmAddressLine1 << lmAddressLine2; |
308 modelItem->setData(QVariant(addressData), Qt::DisplayRole); |
257 modelItem->setData(QVariant(addressData), Qt::DisplayRole); |
309 modelItem->setData( icons, Qt::DecorationRole ); |
258 modelItem->setData( icons, Qt::DecorationRole ); |
|
259 modelItem->setData( aItemArray[i].mId, Qt::UserRole ); |
310 mModel->appendRow( modelItem ); |
260 mModel->appendRow( modelItem ); |
311 } |
261 } |
312 |
|
313 CleanupStack::PopAndDestroy( readLandmark ); |
|
314 } |
262 } |
315 } |
263 } |
316 } |
264 |
317 |
265 return true; |
318 // ---------------------------------------------------------------------------- |
266 } |
319 // LocationPickerDataManagerPrivate::populateCollectionsL() |
267 |
320 // ---------------------------------------------------------------------------- |
268 // ---------------------------------------------------------------------------- |
321 |
269 // LocationPickerDataManagerPrivate::populateCollections() |
322 void LocationPickerDataManagerPrivate::populateCollectionsL() |
270 // ---------------------------------------------------------------------------- |
323 { |
271 |
324 // Read each categpry in the database and copy to the model. |
272 void LocationPickerDataManagerPrivate::populateCollections() |
325 TPosLmItemId lmId; |
273 { |
326 while ((lmId = mIterator->NextL()) != KPosLmNullItemId ) |
274 // add contact collection |
327 { |
275 QStandardItem *modelItemContact = new QStandardItem(); |
328 CPosLandmarkCategory* readCategory = mLmCategoryManager->ReadCategoryLC(lmId ); |
276 QString contactCollectionName( hbTrId("txt_lint_list_contact_addresses") ); |
329 |
277 modelItemContact->setData( QVariant( contactCollectionName ), Qt::DisplayRole ); |
330 if( readCategory ) |
278 modelItemContact->setData( HbIcon ( KCollectionsContacts ), Qt::DecorationRole ); |
331 { |
279 modelItemContact->setData( ESourceLandmarksContactsCat, Qt::UserRole ); |
332 QString categoryName(""); |
280 mModel->appendRow( modelItemContact ); |
333 |
281 |
334 TPtrC tempStr; |
282 QStandardItem *modelItemCalendar = new QStandardItem(); |
335 TInt retStatus; |
283 QString calendarCollectionName( hbTrId("txt_lint_list_calendar_event_locations") ); |
336 |
284 modelItemCalendar->setData( QVariant( calendarCollectionName ), Qt::DisplayRole ); |
337 retStatus = readCategory->GetCategoryName( tempStr ); |
285 modelItemCalendar->setData( HbIcon ( KCollectionsCalendar ), Qt::DecorationRole ); |
338 if( retStatus == KErrNone && tempStr.Length() > 0) |
286 modelItemCalendar->setData( ESourceLandmarksCalendarCat, Qt::UserRole ); |
339 { |
287 mModel->appendRow( modelItemCalendar ); |
340 categoryName = QString( (QChar*)tempStr.Ptr(), tempStr.Length()); |
288 |
341 if(categoryName == KContactsString) |
289 QStandardItem *modelItemPlaces = new QStandardItem(); |
342 { |
290 QString placesCollectionName( hbTrId("txt_lint_list_places") ); |
343 categoryName = hbTrId("txt_lint_list_contact_addresses"); |
291 modelItemPlaces->setData( QVariant( placesCollectionName ), Qt::DisplayRole ); |
344 } |
292 modelItemPlaces->setData( HbIcon (KCollectionsPlaces), Qt::DecorationRole ); |
345 } |
293 modelItemPlaces->setData( ESourceLandmarks, Qt::UserRole ); |
346 |
294 mModel->appendRow( modelItemPlaces ); |
347 // create a list item and copy to model |
295 } |
348 |
296 |
349 QString iconPath; |
|
350 QStandardItem *modelItem = new QStandardItem(); |
|
351 modelItem->setData(QVariant(categoryName), Qt::DisplayRole); |
|
352 modelItem->setData( HbIcon (KCollectionsContacts), Qt::DecorationRole ); |
|
353 mModel->appendRow( modelItem ); |
|
354 |
|
355 CleanupStack::PopAndDestroy( readCategory ); |
|
356 } |
|
357 } |
|
358 } |
|
359 |
|
360 // ---------------------------------------------------------------------------- |
|
361 // LocationPickerDataManagerPrivate::getData() |
|
362 // ---------------------------------------------------------------------------- |
|
363 |
|
364 void LocationPickerDataManagerPrivate::getData( int aIndex, quint32& aValue ) |
|
365 { |
|
366 aValue = 0; |
|
367 RArray<TPosLmItemId> idArray; |
|
368 TRAPD( err, mIterator->GetItemIdsL( idArray, aIndex, 1 ) ); |
|
369 if( err == KErrNone) |
|
370 aValue = (quint32) idArray[0]; |
|
371 } |
|
372 |
297 |
373 // ---------------------------------------------------------------------------- |
298 // ---------------------------------------------------------------------------- |
374 // LocationPickerDataManagerPrivate::getLocationItem() |
299 // LocationPickerDataManagerPrivate::getLocationItem() |
375 // ---------------------------------------------------------------------------- |
300 // ---------------------------------------------------------------------------- |
376 |
301 |
377 void LocationPickerDataManagerPrivate::getLocationItem( quint32 aLmId, QLocationPickerItem& aItem ) |
302 void LocationPickerDataManagerPrivate::getLocationItem( quint32 aId, QLocationPickerItem& aItem ) |
378 { |
303 { |
379 TRAPD( err, getLocationItemL( aLmId, aItem ) ); |
304 QLookupItem item; |
380 if( err != KErrNone ) |
305 item.mId = aId; |
|
306 if( mDb->findEntryById( item ) ) |
|
307 { |
|
308 aItem.mName = item.mName; |
|
309 aItem.mStreet = item.mStreet; |
|
310 aItem.mPostalCode = item.mPostalCode; |
|
311 aItem.mCity = item.mCity; |
|
312 aItem.mState = item.mState; |
|
313 aItem.mCountry = item.mCountry; |
|
314 aItem.mLatitude = item.mLatitude; |
|
315 aItem.mLongitude = item.mLongitude; |
|
316 aItem.mIsValid = true; |
|
317 } |
|
318 else |
|
319 { |
381 aItem.mIsValid = false; |
320 aItem.mIsValid = false; |
382 } |
321 } |
383 |
322 |
384 // ---------------------------------------------------------------------------- |
323 } |
385 // LocationPickerDataManagerPrivate::getLocationItem() |
324 |
386 // ---------------------------------------------------------------------------- |
|
387 |
|
388 void LocationPickerDataManagerPrivate::getLocationItemL( quint32 aLmId, QLocationPickerItem& aItem ) |
|
389 { |
|
390 //Open and intialize Landmark DB |
|
391 CPosLandmarkDatabase* landmarkDb = NULL; |
|
392 landmarkDb = CPosLandmarkDatabase::OpenL(); |
|
393 |
|
394 ExecuteAndDeleteLD( landmarkDb->InitializeL() ); |
|
395 |
|
396 CPosLandmark* readLandmark = landmarkDb->ReadLandmarkLC(aLmId ); |
|
397 |
|
398 if( readLandmark ) |
|
399 { |
|
400 // get position and store |
|
401 TLocality position; |
|
402 readLandmark->GetPosition( position ); |
|
403 aItem.mLatitude = position.Latitude(); |
|
404 aItem.mLongitude = position.Longitude(); |
|
405 |
|
406 // get address fields |
|
407 TPtrC tempStr; |
|
408 TInt retStatus; |
|
409 |
|
410 // Copy landmark name in string 1 |
|
411 retStatus = readLandmark->GetLandmarkName( tempStr ); |
|
412 if( retStatus == KErrNone && tempStr.Length() > 0) |
|
413 { |
|
414 aItem.mName = QString( (QChar*)tempStr.Ptr(), tempStr.Length()); |
|
415 } |
|
416 |
|
417 // get street |
|
418 retStatus = readLandmark->GetPositionField( EPositionFieldStreet, tempStr ); |
|
419 if( retStatus == KErrNone && tempStr.Length() ) |
|
420 { |
|
421 aItem.mStreet = QString( (QChar*)tempStr.Ptr(), tempStr.Length()); |
|
422 } |
|
423 |
|
424 // Get city |
|
425 retStatus =readLandmark->GetPositionField( EPositionFieldCity, tempStr ); |
|
426 if( retStatus == KErrNone && tempStr.Length() ) |
|
427 { |
|
428 aItem.mCity = QString( (QChar*)tempStr.Ptr(), tempStr.Length()); |
|
429 } |
|
430 // Get State |
|
431 retStatus =readLandmark->GetPositionField( EPositionFieldState, tempStr ); |
|
432 if( retStatus == KErrNone && tempStr.Length() ) |
|
433 { |
|
434 aItem.mState = QString( (QChar*)tempStr.Ptr(), tempStr.Length()); |
|
435 } |
|
436 |
|
437 // get country |
|
438 retStatus =readLandmark->GetPositionField( EPositionFieldCountry, tempStr ); |
|
439 if( retStatus == KErrNone && tempStr.Length() ) |
|
440 { |
|
441 aItem.mCountry = QString( (QChar*)tempStr.Ptr(), tempStr.Length()); |
|
442 } |
|
443 } |
|
444 aItem.mIsValid = true; |
|
445 CleanupStack::PopAndDestroy(readLandmark); |
|
446 delete landmarkDb; |
|
447 } |
|