author | eilers <eilers> | 2004-04-02 12:21:19 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-04-02 12:21:19 (UTC) |
commit | bf7ec4adff3226b085421e0ea0b0699b748d3328 (patch) (unidiff) | |
tree | 4db1eefa301438b43c20140a6625d5b04c5916de | |
parent | 7b3b820494376699ec431deea3ecd41309037997 (diff) | |
download | opie-bf7ec4adff3226b085421e0ea0b0699b748d3328.zip opie-bf7ec4adff3226b085421e0ea0b0699b748d3328.tar.gz opie-bf7ec4adff3226b085421e0ea0b0699b748d3328.tar.bz2 |
Removed the avaluation code. Horizontal layout won the competition, therfore the rest is removed..
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp | 177 |
1 files changed, 1 insertions, 176 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp index d16d692..1ea35a8 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp | |||
@@ -1,15 +1,15 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
@@ -40,37 +40,24 @@ | |||
40 | #include <qpe/recordfields.h> | 40 | #include <qpe/recordfields.h> |
41 | 41 | ||
42 | #include <opie2/opimcontactfields.h> | 42 | #include <opie2/opimcontactfields.h> |
43 | #include <opie2/opimdateconversion.h> | 43 | #include <opie2/opimdateconversion.h> |
44 | #include <opie2/osqldriver.h> | 44 | #include <opie2/osqldriver.h> |
45 | #include <opie2/osqlresult.h> | 45 | #include <opie2/osqlresult.h> |
46 | #include <opie2/osqlmanager.h> | 46 | #include <opie2/osqlmanager.h> |
47 | #include <opie2/osqlquery.h> | 47 | #include <opie2/osqlquery.h> |
48 | 48 | ||
49 | using namespace Opie::DB; | 49 | using namespace Opie::DB; |
50 | 50 | ||
51 | 51 | ||
52 | // If defined, we use a horizontal table ( uid, attr1, attr2, attr3, ..., attrn ) instead | ||
53 | // vertical like "uid, type, value". | ||
54 | // DON'T DEACTIVATE THIS DEFINE IN PRODUCTIVE ENVIRONMENTS !! | ||
55 | #define __STORE_HORIZONTAL_ | ||
56 | |||
57 | // Distinct loading is not very fast. If I expect that every person has just | ||
58 | // one (and always one) 'Last Name', I can request all uid's for existing lastnames, | ||
59 | // which is faster.. | ||
60 | // But this may not be true for all entries, like company contacts.. | ||
61 | // The current AddressBook application handles this problem, but other may not.. (eilers) | ||
62 | #define __USE_SUPERFAST_LOADQUERY | ||
63 | |||
64 | |||
65 | /* | 52 | /* |
66 | * Implementation of used query types | 53 | * Implementation of used query types |
67 | * CREATE query | 54 | * CREATE query |
68 | * LOAD query | 55 | * LOAD query |
69 | * INSERT | 56 | * INSERT |
70 | * REMOVE | 57 | * REMOVE |
71 | * CLEAR | 58 | * CLEAR |
72 | */ | 59 | */ |
73 | namespace Opie { | 60 | namespace Opie { |
74 | /** | 61 | /** |
75 | * CreateQuery for the Todolist Table | 62 | * CreateQuery for the Todolist Table |
76 | */ | 63 | */ |
@@ -163,88 +150,71 @@ namespace Opie { | |||
163 | 150 | ||
164 | 151 | ||
165 | 152 | ||
166 | // We using three tables to store the information: | 153 | // We using three tables to store the information: |
167 | // 1. addressbook : It contains General information about the contact (non custom) | 154 | // 1. addressbook : It contains General information about the contact (non custom) |
168 | // 2. custom_data : Not official supported entries | 155 | // 2. custom_data : Not official supported entries |
169 | // All tables are connected by the uid of the contact. | 156 | // All tables are connected by the uid of the contact. |
170 | // Maybe I should add a table for meta-information ? | 157 | // Maybe I should add a table for meta-information ? |
171 | CreateQuery::CreateQuery() : OSQLQuery() {} | 158 | CreateQuery::CreateQuery() : OSQLQuery() {} |
172 | CreateQuery::~CreateQuery() {} | 159 | CreateQuery::~CreateQuery() {} |
173 | QString CreateQuery::query()const { | 160 | QString CreateQuery::query()const { |
174 | QString qu; | 161 | QString qu; |
175 | #ifdef __STORE_HORIZONTAL_ | ||
176 | 162 | ||
177 | qu += "create table addressbook( uid PRIMARY KEY "; | 163 | qu += "create table addressbook( uid PRIMARY KEY "; |
178 | 164 | ||
179 | QStringList fieldList = OPimContactFields::untrfields( false ); | 165 | QStringList fieldList = OPimContactFields::untrfields( false ); |
180 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ | 166 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ |
181 | qu += QString( ",\"%1\" VARCHAR(10)" ).arg( *it ); | 167 | qu += QString( ",\"%1\" VARCHAR(10)" ).arg( *it ); |
182 | } | 168 | } |
183 | qu += " );"; | 169 | qu += " );"; |
184 | 170 | ||
185 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );"; | 171 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );"; |
186 | 172 | ||
187 | #else | ||
188 | |||
189 | qu += "create table addressbook( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id));"; | ||
190 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );"; | ||
191 | // qu += "create table dates( uid PRIMARY KEY, type, day, month, year, hour, minute, second );"; | ||
192 | |||
193 | #endif // __STORE_HORIZONTAL_ | ||
194 | return qu; | 173 | return qu; |
195 | } | 174 | } |
196 | 175 | ||
197 | ClearQuery::ClearQuery() | 176 | ClearQuery::ClearQuery() |
198 | : OSQLQuery() {} | 177 | : OSQLQuery() {} |
199 | ClearQuery::~ClearQuery() {} | 178 | ClearQuery::~ClearQuery() {} |
200 | QString ClearQuery::query()const { | 179 | QString ClearQuery::query()const { |
201 | QString qu = "drop table addressbook;"; | 180 | QString qu = "drop table addressbook;"; |
202 | qu += "drop table custom_data;"; | 181 | qu += "drop table custom_data;"; |
203 | // qu += "drop table dates;"; | 182 | // qu += "drop table dates;"; |
204 | return qu; | 183 | return qu; |
205 | } | 184 | } |
206 | 185 | ||
207 | 186 | ||
208 | LoadQuery::LoadQuery() : OSQLQuery() {} | 187 | LoadQuery::LoadQuery() : OSQLQuery() {} |
209 | LoadQuery::~LoadQuery() {} | 188 | LoadQuery::~LoadQuery() {} |
210 | QString LoadQuery::query()const { | 189 | QString LoadQuery::query()const { |
211 | QString qu; | 190 | QString qu; |
212 | #ifdef __STORE_HORIZONTAL_ | ||
213 | qu += "select uid from addressbook"; | 191 | qu += "select uid from addressbook"; |
214 | #else | ||
215 | # ifndef __USE_SUPERFAST_LOADQUERY | ||
216 | qu += "select distinct uid from addressbook"; | ||
217 | # else | ||
218 | qu += "select uid from addressbook where type = 'Last Name'"; | ||
219 | # endif // __USE_SUPERFAST_LOADQUERY | ||
220 | #endif // __STORE_HORIZONTAL_ | ||
221 | 192 | ||
222 | return qu; | 193 | return qu; |
223 | } | 194 | } |
224 | 195 | ||
225 | 196 | ||
226 | InsertQuery::InsertQuery( const OPimContact& contact ) | 197 | InsertQuery::InsertQuery( const OPimContact& contact ) |
227 | : OSQLQuery(), m_contact( contact ) { | 198 | : OSQLQuery(), m_contact( contact ) { |
228 | } | 199 | } |
229 | 200 | ||
230 | InsertQuery::~InsertQuery() { | 201 | InsertQuery::~InsertQuery() { |
231 | } | 202 | } |
232 | 203 | ||
233 | /* | 204 | /* |
234 | * converts from a OPimContact to a query | 205 | * converts from a OPimContact to a query |
235 | */ | 206 | */ |
236 | QString InsertQuery::query()const{ | 207 | QString InsertQuery::query()const{ |
237 | 208 | ||
238 | #ifdef __STORE_HORIZONTAL_ | ||
239 | QString qu; | 209 | QString qu; |
240 | qu += "insert into addressbook VALUES( " + | 210 | qu += "insert into addressbook VALUES( " + |
241 | QString::number( m_contact.uid() ); | 211 | QString::number( m_contact.uid() ); |
242 | 212 | ||
243 | // Get all information out of the contact-class | 213 | // Get all information out of the contact-class |
244 | // Remember: The category is stored in contactMap, too ! | 214 | // Remember: The category is stored in contactMap, too ! |
245 | QMap<int, QString> contactMap = m_contact.toMap(); | 215 | QMap<int, QString> contactMap = m_contact.toMap(); |
246 | 216 | ||
247 | QStringList fieldList = OPimContactFields::untrfields( false ); | 217 | QStringList fieldList = OPimContactFields::untrfields( false ); |
248 | QMap<QString, int> translate = OPimContactFields::untrFieldsToId(); | 218 | QMap<QString, int> translate = OPimContactFields::untrFieldsToId(); |
249 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ | 219 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ |
250 | // Convert Column-String to Id and get value for this id.. | 220 | // Convert Column-String to Id and get value for this id.. |
@@ -278,93 +248,26 @@ namespace Opie { | |||
278 | qu += ",\"\""; | 248 | qu += ",\"\""; |
279 | } | 249 | } |
280 | } | 250 | } |
281 | break; | 251 | break; |
282 | 252 | ||
283 | default: | 253 | default: |
284 | qu += QString( ",\"%1\"" ).arg( contactMap[id] ); | 254 | qu += QString( ",\"%1\"" ).arg( contactMap[id] ); |
285 | } | 255 | } |
286 | } | 256 | } |
287 | qu += " );"; | 257 | qu += " );"; |
288 | 258 | ||
289 | 259 | ||
290 | #else | ||
291 | // Get all information out of the contact-class | ||
292 | // Remember: The category is stored in contactMap, too ! | ||
293 | QMap<int, QString> contactMap = m_contact.toMap(); | ||
294 | |||
295 | QMap<QString, QString> addressbook_db; | ||
296 | |||
297 | // Get the translation from the ID to the String | ||
298 | QMap<int, QString> transMap = OPimContactFields::idToUntrFields(); | ||
299 | |||
300 | for( QMap<int, QString>::Iterator it = contactMap.begin(); | ||
301 | it != contactMap.end(); ++it ){ | ||
302 | switch ( it.key() ){ | ||
303 | case Qtopia::Birthday:{ | ||
304 | // These entries should stored in a special format | ||
305 | // year-month-day | ||
306 | QDate day = m_contact.birthday(); | ||
307 | addressbook_db.insert( transMap[it.key()], | ||
308 | QString("%1-%2-%3") | ||
309 | .arg( day.year() ) | ||
310 | .arg( day.month() ) | ||
311 | .arg( day.day() ) ); | ||
312 | } | ||
313 | break; | ||
314 | case Qtopia::Anniversary:{ | ||
315 | // These entries should stored in a special format | ||
316 | // year-month-day | ||
317 | QDate day = m_contact.anniversary(); | ||
318 | addressbook_db.insert( transMap[it.key()], | ||
319 | QString("%1-%2-%3") | ||
320 | .arg( day.year() ) | ||
321 | .arg( day.month() ) | ||
322 | .arg( day.day() ) ); | ||
323 | } | ||
324 | break; | ||
325 | case Qtopia::AddressUid: // Ignore UID | ||
326 | break; | ||
327 | default: // Translate id to String | ||
328 | addressbook_db.insert( transMap[it.key()], it.data() ); | ||
329 | break; | ||
330 | } | ||
331 | |||
332 | } | ||
333 | |||
334 | // Now convert this whole stuff into a SQL String, beginning with | ||
335 | // the addressbook table.. | ||
336 | QString qu; | ||
337 | // qu += "begin transaction;"; | ||
338 | int id = 0; | ||
339 | for( QMap<QString, QString>::Iterator it = addressbook_db.begin(); | ||
340 | it != addressbook_db.end(); ++it ){ | ||
341 | qu += "insert into addressbook VALUES(" | ||
342 | + QString::number( m_contact.uid() ) | ||
343 | + "," | ||
344 | + QString::number( id++ ) | ||
345 | + ",'" | ||
346 | + it.key() //.latin1() | ||
347 | + "'," | ||
348 | + "0" // Priority for future enhancements | ||
349 | + ",'" | ||
350 | + it.data() //.latin1() | ||
351 | + "');"; | ||
352 | } | ||
353 | |||
354 | #endif //__STORE_HORIZONTAL_ | ||
355 | // Now add custom data.. | 260 | // Now add custom data.. |
356 | #ifdef __STORE_HORIZONTAL_ | ||
357 | int id = 0; | 261 | int id = 0; |
358 | #endif | ||
359 | id = 0; | 262 | id = 0; |
360 | QMap<QString, QString> customMap = m_contact.toExtraMap(); | 263 | QMap<QString, QString> customMap = m_contact.toExtraMap(); |
361 | for( QMap<QString, QString>::Iterator it = customMap.begin(); | 264 | for( QMap<QString, QString>::Iterator it = customMap.begin(); |
362 | it != customMap.end(); ++it ){ | 265 | it != customMap.end(); ++it ){ |
363 | qu += "insert into custom_data VALUES(" | 266 | qu += "insert into custom_data VALUES(" |
364 | + QString::number( m_contact.uid() ) | 267 | + QString::number( m_contact.uid() ) |
365 | + "," | 268 | + "," |
366 | + QString::number( id++ ) | 269 | + QString::number( id++ ) |
367 | + ",'" | 270 | + ",'" |
368 | + it.key() //.latin1() | 271 | + it.key() //.latin1() |
369 | + "'," | 272 | + "'," |
370 | + "0" // Priority for future enhancements | 273 | + "0" // Priority for future enhancements |
@@ -408,39 +311,31 @@ namespace Opie { | |||
408 | else | 311 | else |
409 | return multi(); | 312 | return multi(); |
410 | } | 313 | } |
411 | QString FindQuery::multi()const { | 314 | QString FindQuery::multi()const { |
412 | QString qu = "select uid, type, value from addressbook where"; | 315 | QString qu = "select uid, type, value from addressbook where"; |
413 | for (uint i = 0; i < m_uids.count(); i++ ) { | 316 | for (uint i = 0; i < m_uids.count(); i++ ) { |
414 | qu += " UID = " + QString::number( m_uids[i] ) + " OR"; | 317 | qu += " UID = " + QString::number( m_uids[i] ) + " OR"; |
415 | } | 318 | } |
416 | qu.remove( qu.length()-2, 2 ); // Hmmmm.. | 319 | qu.remove( qu.length()-2, 2 ); // Hmmmm.. |
417 | return qu; | 320 | return qu; |
418 | } | 321 | } |
419 | */ | 322 | */ |
420 | #ifdef __STORE_HORIZONTAL_ | ||
421 | QString FindQuery::single()const{ | 323 | QString FindQuery::single()const{ |
422 | QString qu = "select *"; | 324 | QString qu = "select *"; |
423 | qu += " from addressbook where uid = " + QString::number(m_uid); | 325 | qu += " from addressbook where uid = " + QString::number(m_uid); |
424 | 326 | ||
425 | // qWarning("find query: %s", qu.latin1() ); | 327 | // qWarning("find query: %s", qu.latin1() ); |
426 | return qu; | 328 | return qu; |
427 | } | 329 | } |
428 | #else | ||
429 | QString FindQuery::single()const{ | ||
430 | QString qu = "select uid, type, value from addressbook where uid = "; | ||
431 | qu += QString::number(m_uid); | ||
432 | return qu; | ||
433 | } | ||
434 | #endif | ||
435 | 330 | ||
436 | 331 | ||
437 | FindCustomQuery::FindCustomQuery(int uid) | 332 | FindCustomQuery::FindCustomQuery(int uid) |
438 | : OSQLQuery(), m_uid( uid ) { | 333 | : OSQLQuery(), m_uid( uid ) { |
439 | } | 334 | } |
440 | FindCustomQuery::FindCustomQuery(const QArray<int>& ints) | 335 | FindCustomQuery::FindCustomQuery(const QArray<int>& ints) |
441 | : OSQLQuery(), m_uids( ints ){ | 336 | : OSQLQuery(), m_uids( ints ){ |
442 | } | 337 | } |
443 | FindCustomQuery::~FindCustomQuery() { | 338 | FindCustomQuery::~FindCustomQuery() { |
444 | } | 339 | } |
445 | QString FindCustomQuery::query()const{ | 340 | QString FindCustomQuery::query()const{ |
446 | // if ( m_uids.count() == 0 ) | 341 | // if ( m_uids.count() == 0 ) |
@@ -699,31 +594,26 @@ bool OPimContactAccessBackend_SQL::hasQuerySettings (uint querySettings) const | |||
699 | return ( true ); | 594 | return ( true ); |
700 | default: | 595 | default: |
701 | return ( false ); | 596 | return ( false ); |
702 | } | 597 | } |
703 | 598 | ||
704 | } | 599 | } |
705 | 600 | ||
706 | QArray<int> OPimContactAccessBackend_SQL::sorted( bool asc, int , int , int ) | 601 | QArray<int> OPimContactAccessBackend_SQL::sorted( bool asc, int , int , int ) |
707 | { | 602 | { |
708 | QTime t; | 603 | QTime t; |
709 | t.start(); | 604 | t.start(); |
710 | 605 | ||
711 | #ifdef __STORE_HORIZONTAL_ | ||
712 | QString query = "SELECT uid FROM addressbook "; | 606 | QString query = "SELECT uid FROM addressbook "; |
713 | query += "ORDER BY \"Last Name\" "; | 607 | query += "ORDER BY \"Last Name\" "; |
714 | #else | ||
715 | QString query = "SELECT uid FROM addressbook WHERE type = 'Last Name' "; | ||
716 | query += "ORDER BY upper( value )"; | ||
717 | #endif | ||
718 | 608 | ||
719 | if ( !asc ) | 609 | if ( !asc ) |
720 | query += "DESC"; | 610 | query += "DESC"; |
721 | 611 | ||
722 | // qWarning("sorted query is: %s", query.latin1() ); | 612 | // qWarning("sorted query is: %s", query.latin1() ); |
723 | 613 | ||
724 | OSQLRawQuery raw( query ); | 614 | OSQLRawQuery raw( query ); |
725 | OSQLResult res = m_driver->query( &raw ); | 615 | OSQLResult res = m_driver->query( &raw ); |
726 | if ( res.state() != OSQLResult::Success ){ | 616 | if ( res.state() != OSQLResult::Success ){ |
727 | QArray<int> empty; | 617 | QArray<int> empty; |
728 | return empty; | 618 | return empty; |
729 | } | 619 | } |
@@ -768,25 +658,24 @@ QArray<int> OPimContactAccessBackend_SQL::extractUids( OSQLResult& res ) const | |||
768 | 658 | ||
769 | int i = 0; | 659 | int i = 0; |
770 | for (it = list.begin(); it != list.end(); ++it ) { | 660 | for (it = list.begin(); it != list.end(); ++it ) { |
771 | ints[i] = (*it).data("uid").toInt(); | 661 | ints[i] = (*it).data("uid").toInt(); |
772 | i++; | 662 | i++; |
773 | } | 663 | } |
774 | qWarning("extractUids ready: count2 = %d needs %d ms", i, t.elapsed() ); | 664 | qWarning("extractUids ready: count2 = %d needs %d ms", i, t.elapsed() ); |
775 | 665 | ||
776 | return ints; | 666 | return ints; |
777 | 667 | ||
778 | } | 668 | } |
779 | 669 | ||
780 | #ifdef __STORE_HORIZONTAL_ | ||
781 | QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) const | 670 | QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) const |
782 | { | 671 | { |
783 | QTime t; | 672 | QTime t; |
784 | t.start(); | 673 | t.start(); |
785 | 674 | ||
786 | QMap<int, QString> nonCustomMap; | 675 | QMap<int, QString> nonCustomMap; |
787 | 676 | ||
788 | int t2needed = 0; | 677 | int t2needed = 0; |
789 | int t3needed = 0; | 678 | int t3needed = 0; |
790 | QTime t2; | 679 | QTime t2; |
791 | t2.start(); | 680 | t2.start(); |
792 | FindQuery query( uid ); | 681 | FindQuery query( uid ); |
@@ -832,88 +721,24 @@ QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) co | |||
832 | } | 721 | } |
833 | 722 | ||
834 | // First insert uid | 723 | // First insert uid |
835 | nonCustomMap.insert( Qtopia::AddressUid, resItem.data( "uid" ) ); | 724 | nonCustomMap.insert( Qtopia::AddressUid, resItem.data( "uid" ) ); |
836 | t3needed = t3.elapsed(); | 725 | t3needed = t3.elapsed(); |
837 | 726 | ||
838 | // qWarning("Adding UID: %s", resItem.data( "uid" ).latin1() ); | 727 | // qWarning("Adding UID: %s", resItem.data( "uid" ).latin1() ); |
839 | qWarning("RequestNonCustom needed: insg.:%d ms, query: %d ms, mapping: %d ms", | 728 | qWarning("RequestNonCustom needed: insg.:%d ms, query: %d ms, mapping: %d ms", |
840 | t.elapsed(), t2needed, t3needed ); | 729 | t.elapsed(), t2needed, t3needed ); |
841 | 730 | ||
842 | return nonCustomMap; | 731 | return nonCustomMap; |
843 | } | 732 | } |
844 | #else | ||
845 | |||
846 | QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) const | ||
847 | { | ||
848 | QTime t; | ||
849 | t.start(); | ||
850 | |||
851 | QMap<int, QString> nonCustomMap; | ||
852 | |||
853 | int t2needed = 0; | ||
854 | QTime t2; | ||
855 | t2.start(); | ||
856 | FindQuery query( uid ); | ||
857 | OSQLResult res_noncustom = m_driver->query( &query ); | ||
858 | t2needed = t2.elapsed(); | ||
859 | |||
860 | if ( res_noncustom.state() == OSQLResult::Failure ) { | ||
861 | qWarning("OSQLResult::Failure in find query !!"); | ||
862 | QMap<int, QString> empty; | ||
863 | return empty; | ||
864 | } | ||
865 | |||
866 | int t3needed = 0; | ||
867 | QTime t3; | ||
868 | t3.start(); | ||
869 | QMap<QString, int> translateMap = OPimContactFields::untrFieldsToId(); | ||
870 | |||
871 | OSQLResultItem::ValueList list = res_noncustom.results(); | ||
872 | OSQLResultItem::ValueList::Iterator it = list.begin(); | ||
873 | for ( ; it != list.end(); ++it ) { | ||
874 | if ( (*it).data("type") != "" ){ | ||
875 | int typeId = translateMap[(*it).data( "type" )]; | ||
876 | switch( typeId ){ | ||
877 | case Qtopia::Birthday: | ||
878 | case Qtopia::Anniversary:{ | ||
879 | // Birthday and Anniversary are encoded special ( yyyy-mm-dd ) | ||
880 | QStringList list = QStringList::split( '-', (*it).data( "value" ) ); | ||
881 | QStringList::Iterator lit = list.begin(); | ||
882 | int year = (*lit).toInt(); | ||
883 | qWarning("1. %s", (*lit).latin1()); | ||
884 | int month = (*(++lit)).toInt(); | ||
885 | qWarning("2. %s", (*lit).latin1()); | ||
886 | int day = (*(++lit)).toInt(); | ||
887 | qWarning("3. %s", (*lit).latin1()); | ||
888 | qWarning( "RequestNonCustom->Converting:%s to Year: %d, Month: %d, Day: %d ", (*it).data( "value" ).latin1(), year, month, day ); | ||
889 | QDate date( year, month, day ); | ||
890 | nonCustomMap.insert( typeId, OPimDateConversion::dateToString( date ) ); | ||
891 | } | ||
892 | break; | ||
893 | default: | ||
894 | nonCustomMap.insert( typeId, | ||
895 | (*it).data( "value" ) ); | ||
896 | } | ||
897 | } | ||
898 | } | ||
899 | // Add UID to Map.. | ||
900 | nonCustomMap.insert( Qtopia::AddressUid, QString::number( uid ) ); | ||
901 | t3needed = t3.elapsed(); | ||
902 | |||
903 | qWarning("RequestNonCustom needed: insg.:%d ms, query: %d ms, mapping: %d ms", t.elapsed(), t2needed, t3needed ); | ||
904 | return nonCustomMap; | ||
905 | } | ||
906 | |||
907 | #endif // __STORE_HORIZONTAL_ | ||
908 | 733 | ||
909 | QMap<QString, QString> OPimContactAccessBackend_SQL::requestCustom( int uid ) const | 734 | QMap<QString, QString> OPimContactAccessBackend_SQL::requestCustom( int uid ) const |
910 | { | 735 | { |
911 | QTime t; | 736 | QTime t; |
912 | t.start(); | 737 | t.start(); |
913 | 738 | ||
914 | QMap<QString, QString> customMap; | 739 | QMap<QString, QString> customMap; |
915 | 740 | ||
916 | FindCustomQuery query( uid ); | 741 | FindCustomQuery query( uid ); |
917 | OSQLResult res_custom = m_driver->query( &query ); | 742 | OSQLResult res_custom = m_driver->query( &query ); |
918 | 743 | ||
919 | if ( res_custom.state() == OSQLResult::Failure ) { | 744 | if ( res_custom.state() == OSQLResult::Failure ) { |