changeset 30 | 96df3ab41000 |
parent 26 | f3533f6eae3f |
child 31 | 8db05346071b |
26:f3533f6eae3f | 30:96df3ab41000 |
---|---|
65 "latitude double," |
65 "latitude double," |
66 "longitude double," |
66 "longitude double," |
67 "icontype int," |
67 "icontype int," |
68 "iconpath varchar(255)," |
68 "iconpath varchar(255)," |
69 "maptile varchar(255))"); |
69 "maptile varchar(255))"); |
70 |
70 |
71 |
|
72 query.exec("create table if not exists lplookupaddress (" |
|
73 "sourceid int," |
|
74 "address varchar(255))"); |
|
71 mDb->close(); |
75 mDb->close(); |
72 } |
76 } |
73 |
77 |
74 // --------------------------------------------------------- |
78 // --------------------------------------------------------- |
75 // LocationDataLookupDb::~LocationDataLookupDb() |
79 // LocationDataLookupDb::~LocationDataLookupDb() |
163 query.exec(); |
167 query.exec(); |
164 |
168 |
165 QVariant var = query.lastInsertId(); |
169 QVariant var = query.lastInsertId(); |
166 aLookupItem.mId = var.toInt(); |
170 aLookupItem.mId = var.toInt(); |
167 |
171 |
172 if(aLookupItem.mSourceType==ESourceCalendar) |
|
173 { |
|
174 query.prepare("INSERT INTO lplookupaddress (" |
|
175 "sourceid ," |
|
176 "address )" |
|
177 "VALUES (" |
|
178 ":sourceid, " |
|
179 ":address) " ); |
|
180 |
|
181 query.bindValue(":sourceid", aLookupItem.mSourceUid); |
|
182 query.bindValue(":address", aLookupItem.mSingleLineAddress); |
|
183 query.exec(); |
|
184 |
|
185 } |
|
186 |
|
168 } |
187 } |
169 } |
188 } |
170 |
189 |
171 // --------------------------------------------------------- |
190 // --------------------------------------------------------- |
172 // LocationDataLookupDb::updateEntryBySourceIdAndType() |
191 // LocationDataLookupDb::updateEntryBySourceIdAndType() |
214 |
233 |
215 query.addBindValue( aLookupItem.mSourceUid ); |
234 query.addBindValue( aLookupItem.mSourceUid ); |
216 query.addBindValue( aLookupItem.mSourceType ); |
235 query.addBindValue( aLookupItem.mSourceType ); |
217 |
236 |
218 query.exec(); |
237 query.exec(); |
219 } |
238 |
239 if(aLookupItem.mSourceType==ESourceCalendar) |
|
240 { |
|
241 query.prepare("UPDATE lplookupaddress SET " |
|
242 "address = ? " |
|
243 "WHERE sourceid = ? "); |
|
244 |
|
245 |
|
246 query.addBindValue( aLookupItem.mSingleLineAddress); |
|
247 query.addBindValue( aLookupItem.mSourceUid); |
|
248 query.exec(); |
|
249 |
|
250 } |
|
251 } |
|
252 |
|
220 } |
253 } |
221 |
254 |
222 // --------------------------------------------------------- |
255 // --------------------------------------------------------- |
223 // LocationDataLookupDb::updateMaptileBySourceIdAndType() |
256 // LocationDataLookupDb::updateMaptileBySourceIdAndType() |
224 // --------------------------------------------------------- |
257 // --------------------------------------------------------- |
285 query.addBindValue( aLookupItem.mMapTilePath ); |
318 query.addBindValue( aLookupItem.mMapTilePath ); |
286 |
319 |
287 query.addBindValue( aLookupItem.mId ); |
320 query.addBindValue( aLookupItem.mId ); |
288 |
321 |
289 query.exec(); |
322 query.exec(); |
323 |
|
324 if(aLookupItem.mSourceType==ESourceCalendar) |
|
325 { |
|
326 query.prepare("UPDATE lplookupaddress SET " |
|
327 "address = ? " |
|
328 "WHERE sourceid = ?"); |
|
329 |
|
330 query.addBindValue( aLookupItem.mSingleLineAddress); |
|
331 query.addBindValue( aLookupItem.mSourceUid ); |
|
332 query.exec(); |
|
333 } |
|
290 } |
334 } |
291 } |
335 } |
292 |
336 |
293 // --------------------------------------------------------- |
337 // --------------------------------------------------------- |
294 // LocationDataLookupDb::deleteEntryBySourceIdAndType() |
338 // LocationDataLookupDb::deleteEntryBySourceIdAndType() |
303 |
347 |
304 query.addBindValue( aLookupItem.mSourceUid ); |
348 query.addBindValue( aLookupItem.mSourceUid ); |
305 query.addBindValue( aLookupItem.mSourceType ); |
349 query.addBindValue( aLookupItem.mSourceType ); |
306 |
350 |
307 query.exec(); |
351 query.exec(); |
352 |
|
353 if(aLookupItem.mSourceType==ESourceCalendar) |
|
354 { |
|
355 query.prepare( "DELETE FROM lplookupaddress " |
|
356 "WHERE sourceid = ? " ); |
|
357 query.addBindValue( aLookupItem.mSourceUid ); |
|
358 query.exec(); |
|
359 } |
|
360 |
|
308 } |
361 } |
309 } |
362 } |
310 |
363 |
311 // --------------------------------------------------------- |
364 // --------------------------------------------------------- |
312 // LocationDataLookupDb::findEntryBySourceIdAndType() |
365 // LocationDataLookupDb::findEntryBySourceIdAndType() |
430 aLookupItemArray.append( lookupItem ); |
483 aLookupItemArray.append( lookupItem ); |
431 } |
484 } |
432 } |
485 } |
433 } |
486 } |
434 |
487 |
488 // --------------------------------------------------------- |
|
489 // LocationDataLookupDb::getEntfillLookupEntryries() |
|
490 // --------------------------------------------------------- |
|
435 void LocationDataLookupDb::fillLookupEntry( QSqlQuery &aQuery, QLookupItem &aLookupItem ) |
491 void LocationDataLookupDb::fillLookupEntry( QSqlQuery &aQuery, QLookupItem &aLookupItem ) |
436 { |
492 { |
437 QSqlRecord rec = aQuery.record(); |
493 QSqlRecord rec = aQuery.record(); |
438 aLookupItem.mId = aQuery.value( rec.indexOf("id") ).toUInt(); |
494 aLookupItem.mId = aQuery.value( rec.indexOf("id") ).toUInt(); |
439 aLookupItem.mIsDuplicate = aQuery.value( rec.indexOf("duplicate") ).toUInt(); |
495 aLookupItem.mIsDuplicate = aQuery.value( rec.indexOf("duplicate") ).toUInt(); |
452 aLookupItem.mIconPath = aQuery.value( rec.indexOf("iconpath") ).toString(); |
508 aLookupItem.mIconPath = aQuery.value( rec.indexOf("iconpath") ).toString(); |
453 aLookupItem.mMapTilePath = aQuery.value( rec.indexOf("maptile") ).toString(); |
509 aLookupItem.mMapTilePath = aQuery.value( rec.indexOf("maptile") ).toString(); |
454 |
510 |
455 } |
511 } |
456 |
512 |
513 // --------------------------------------------------------- |
|
514 // LocationDataLookupDb::getAddressDetails() |
|
515 // --------------------------------------------------------- |
|
516 QString LocationDataLookupDb::getAddressDetails( quint32 mId , quint32 mSourceType ) |
|
517 { |
|
518 QString addressDetails; |
|
519 if (mDbOpen) |
|
520 { |
|
521 QSqlQuery query(*mDb); |
|
522 if (mSourceType == ESourceContactsPref || mSourceType |
|
523 == ESourceContactsWork || mSourceType == ESourceContactsHome) |
|
524 { |
|
525 query.prepare("SELECT * FROM lplookup " |
|
526 "WHERE sourceid = ? AND sourcetype = ?"); |
|
527 query.addBindValue(mId); |
|
528 query.addBindValue(mSourceType); |
|
529 query.exec(); |
|
530 if (query.first()) { |
|
531 QSqlRecord rec = query.record(); |
|
532 QString temp; |
|
533 temp.clear(); |
|
534 temp = query.value(rec.indexOf("street")).toString(); |
|
535 if (!temp.isEmpty()) |
|
536 { |
|
537 addressDetails.append(temp); |
|
538 } |
|
539 temp.clear(); |
|
540 |
|
541 temp = query.value(rec.indexOf("city")).toString(); |
|
542 if (!temp.isEmpty()) { |
|
543 if (!addressDetails.isEmpty()) |
|
544 { |
|
545 addressDetails.append(QChar(',')); |
|
546 addressDetails.append(QChar(' ')); |
|
547 } |
|
548 addressDetails.append(temp); |
|
549 |
|
550 } |
|
551 temp.clear(); |
|
552 temp = query.value(rec.indexOf("state")).toString(); |
|
553 if (!temp.isEmpty()) { |
|
554 if (!addressDetails.isEmpty()) |
|
555 { |
|
556 addressDetails.append(QChar(',')); |
|
557 addressDetails.append(QChar(' ')); |
|
558 } |
|
559 addressDetails.append(temp); |
|
560 |
|
561 } |
|
562 temp.clear(); |
|
563 temp = query.value(rec.indexOf("country")).toString(); |
|
564 if (!temp.isEmpty()) { |
|
565 if (!addressDetails.isEmpty()) |
|
566 { |
|
567 addressDetails.append(QChar(',')); |
|
568 addressDetails.append(QChar(' ')); |
|
569 } |
|
570 addressDetails.append(temp); |
|
571 |
|
572 } |
|
573 |
|
574 } |
|
575 |
|
576 } |
|
577 else if (mSourceType == ESourceCalendar) |
|
578 { |
|
579 query.prepare("SELECT * FROM lplookupaddress " |
|
580 "WHERE sourceid = ? "); |
|
581 query.addBindValue(mId); |
|
582 query.exec(); |
|
583 if ( query.first() ) |
|
584 { |
|
585 QSqlRecord rec = query.record(); |
|
586 addressDetails.append( |
|
587 query.value(rec.indexOf("address")).toString()); |
|
588 } |
|
589 } |
|
590 } |
|
591 return addressDetails; |
|
592 } |
|
593 |
|
594 // --------------------------------------------------------- |
|
595 // LocationDataLookupDb::getCount() |
|
596 // --------------------------------------------------------- |
|
597 void LocationDataLookupDb::getCount( QList<int>& aCount, const quint32 /*aCollectionId*/ ) |
|
598 { |
|
599 if( mDb ) |
|
600 { |
|
601 // ESourceLandmarksContactsCat |
|
602 { |
|
603 QSqlQuery query(*mDb); |
|
604 query.prepare( "SELECT * FROM lplookup " |
|
605 "WHERE sourcetype = ? OR sourcetype = ? OR sourcetype = ?" ); |
|
606 query.addBindValue( ESourceContactsPref ); |
|
607 query.addBindValue( ESourceContactsWork ); |
|
608 query.addBindValue( ESourceContactsHome ); |
|
609 query.exec(); |
|
610 |
|
611 |
|
612 qDebug("size %d",query.size()); |
|
613 int count=0; |
|
614 while( query.next() ) count++; |
|
615 aCount.append(count); |
|
616 } |
|
617 |
|
618 |
|
619 |
|
620 // ESourceLandmarksCalendarCat |
|
621 { |
|
622 QSqlQuery query(*mDb); |
|
623 query.prepare( "SELECT * FROM lplookup " |
|
624 "WHERE sourcetype = ?" ); |
|
625 query.addBindValue( ESourceCalendar ); |
|
626 query.exec(); |
|
627 |
|
628 qDebug("size %d",query.size()); |
|
629 int count=0; |
|
630 while( query.next() ) count++; |
|
631 aCount.append(count); |
|
632 } |
|
633 |
|
634 |
|
635 |
|
636 // ESourceLandmarks |
|
637 { |
|
638 QSqlQuery query(*mDb); |
|
639 query.prepare( "SELECT * FROM lplookup " |
|
640 "WHERE sourcetype = ?" ); |
|
641 query.addBindValue( ESourceLandmarks ); |
|
642 query.exec(); |
|
643 |
|
644 qDebug("size %d",query.size()); |
|
645 int count=0; |
|
646 while( query.next() ) count++; |
|
647 aCount.append(count); |
|
648 } |
|
649 |
|
650 |
|
651 // else // all contents |
|
652 { |
|
653 QSqlQuery query(*mDb); |
|
654 query.prepare( "SELECT * FROM lplookup" ); |
|
655 query.exec(); |
|
656 int count=0; |
|
657 while( query.next() ) count++; |
|
658 aCount.append(count); |
|
659 } |
|
660 |
|
661 |
|
662 } |
|
663 } |
|
664 |
|
457 // End of file |
665 // End of file |