summaryrefslogtreecommitdiff
path: root/libopie2/opiepim
authoreilers <eilers>2004-04-02 12:21:19 (UTC)
committer eilers <eilers>2004-04-02 12:21:19 (UTC)
commitbf7ec4adff3226b085421e0ea0b0699b748d3328 (patch) (unidiff)
tree4db1eefa301438b43c20140a6625d5b04c5916de /libopie2/opiepim
parent7b3b820494376699ec431deea3ecd41309037997 (diff)
downloadopie-bf7ec4adff3226b085421e0ea0b0699b748d3328.zip
opie-bf7ec4adff3226b085421e0ea0b0699b748d3328.tar.gz
opie-bf7ec4adff3226b085421e0ea0b0699b748d3328.tar.bz2
Removed the avaluation code. Horizontal layout won the competition, therfore the rest is removed..
Diffstat (limited to 'libopie2/opiepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp177
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
@@ -2,3 +2,3 @@
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>
@@ -51,15 +51,2 @@ using namespace Opie::DB;
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/*
@@ -174,3 +161,2 @@ namespace Opie {
174 QString qu; 161 QString qu;
175#ifdef __STORE_HORIZONTAL_
176 162
@@ -186,9 +172,2 @@ namespace Opie {
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;
@@ -211,11 +190,3 @@ namespace Opie {
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
@@ -237,3 +208,2 @@ namespace Opie {
237 208
238#ifdef __STORE_HORIZONTAL_
239 QString qu; 209 QString qu;
@@ -289,71 +259,4 @@ namespace Opie {
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;
@@ -419,3 +322,2 @@ namespace Opie {
419 */ 322 */
420#ifdef __STORE_HORIZONTAL_
421 QString FindQuery::single()const{ 323 QString FindQuery::single()const{
@@ -427,9 +329,2 @@ namespace Opie {
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
@@ -710,9 +605,4 @@ QArray<int> OPimContactAccessBackend_SQL::sorted( bool asc, int , int , int )
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
@@ -779,3 +669,2 @@ QArray<int> OPimContactAccessBackend_SQL::extractUids( OSQLResult& res ) const
779 669
780#ifdef __STORE_HORIZONTAL_
781QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) const 670QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) const
@@ -843,66 +732,2 @@ QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) co
843} 732}
844#else
845
846QMap<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