author | mickeyl <mickeyl> | 2004-02-24 12:46:23 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-24 12:46:23 (UTC) |
commit | 911473db35a9fce5f3589f03c27210456faaba86 (patch) (unidiff) | |
tree | 7d55b6117b24de6ab18747b00a4641d38001c0ed /libopie2/opiepim/backend | |
parent | a2ead23c3614fe581261455cb4c3f31cee2098f3 (diff) | |
download | opie-911473db35a9fce5f3589f03c27210456faaba86.zip opie-911473db35a9fce5f3589f03c27210456faaba86.tar.gz opie-911473db35a9fce5f3589f03c27210456faaba86.tar.bz2 |
*phew* here is the class and file rename patch. not converted yet: backend,
but that will be not visible to application classes so we can change it later.
23 files changed, 593 insertions, 593 deletions
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h index 346e2f5..06421d1 100644 --- a/libopie2/opiepim/backend/obackendfactory.h +++ b/libopie2/opiepim/backend/obackendfactory.h | |||
@@ -57,13 +57,13 @@ class OBackendPrivate; | |||
57 | * of at least Todolist, Contacts and Datebook. In the future this class will | 57 | * of at least Todolist, Contacts and Datebook. In the future this class will |
58 | * allow users to switch the backend with ( XML->SQLite ) without the need | 58 | * allow users to switch the backend with ( XML->SQLite ) without the need |
59 | * to recompile.# | 59 | * to recompile.# |
60 | * This class as the whole PIM Api is making use of templates | 60 | * This class as the whole PIM Api is making use of templates |
61 | * | 61 | * |
62 | * <pre> | 62 | * <pre> |
63 | * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null ); | 63 | * OPimTodoAccessBackend* backend = OBackEndFactory<OPimTodoAccessBackend>::Default("todo", QString::null ); |
64 | * backend->load(); | 64 | * backend->load(); |
65 | * </pre> | 65 | * </pre> |
66 | * | 66 | * |
67 | * @author Stefan Eilers | 67 | * @author Stefan Eilers |
68 | * @version 0.1 | 68 | * @version 0.1 |
69 | */ | 69 | */ |
@@ -105,29 +105,29 @@ class OBackendFactory | |||
105 | if (!find ) return 0; | 105 | if (!find ) return 0; |
106 | 106 | ||
107 | switch ( *find ){ | 107 | switch ( *find ){ |
108 | case TODO: | 108 | case TODO: |
109 | #ifdef __USE_SQL | 109 | #ifdef __USE_SQL |
110 | if ( backend == "sql" ) | 110 | if ( backend == "sql" ) |
111 | return (T*) new OTodoAccessBackendSQL(""); | 111 | return (T*) new OPimTodoAccessBackendSQL(""); |
112 | #else | 112 | #else |
113 | if ( backend == "sql" ) | 113 | if ( backend == "sql" ) |
114 | qWarning ("OBackendFactory:: sql Backend for TODO not implemented! Using XML instead!"); | 114 | qWarning ("OBackendFactory:: sql Backend for TODO not implemented! Using XML instead!"); |
115 | #endif | 115 | #endif |
116 | 116 | ||
117 | return (T*) new OTodoAccessXML( appName ); | 117 | return (T*) new OPimTodoAccessXML( appName ); |
118 | case CONTACT: | 118 | case CONTACT: |
119 | #ifdef __USE_SQL | 119 | #ifdef __USE_SQL |
120 | if ( backend == "sql" ) | 120 | if ( backend == "sql" ) |
121 | return (T*) new OContactAccessBackend_SQL(""); | 121 | return (T*) new OPimContactAccessBackend_SQL(""); |
122 | #else | 122 | #else |
123 | if ( backend == "sql" ) | 123 | if ( backend == "sql" ) |
124 | qWarning ("OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!"); | 124 | qWarning ("OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!"); |
125 | #endif | 125 | #endif |
126 | 126 | ||
127 | return (T*) new OContactAccessBackend_XML( appName ); | 127 | return (T*) new OPimContactAccessBackend_XML( appName ); |
128 | case DATE: | 128 | case DATE: |
129 | #ifdef __USE_SQL | 129 | #ifdef __USE_SQL |
130 | if ( backend == "sql" ) | 130 | if ( backend == "sql" ) |
131 | return (T*) new ODateBookAccessBackend_SQL(""); | 131 | return (T*) new ODateBookAccessBackend_SQL(""); |
132 | #else | 132 | #else |
133 | if ( backend == "sql" ) | 133 | if ( backend == "sql" ) |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h index 6113cea..8436adc 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend.h | |||
@@ -36,38 +36,38 @@ | |||
36 | * | 36 | * |
37 | */ | 37 | */ |
38 | 38 | ||
39 | #ifndef _OCONTACTACCESSBACKEND_H_ | 39 | #ifndef _OCONTACTACCESSBACKEND_H_ |
40 | #define _OCONTACTACCESSBACKEND_H_ | 40 | #define _OCONTACTACCESSBACKEND_H_ |
41 | 41 | ||
42 | #include <opie2/ocontact.h> | 42 | #include <opie2/opimcontact.h> |
43 | #include <opie2/opimaccessbackend.h> | 43 | #include <opie2/opimaccessbackend.h> |
44 | 44 | ||
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | 46 | ||
47 | namespace Opie { | 47 | namespace Opie { |
48 | /** | 48 | /** |
49 | * This class represents the interface of all Contact Backends. | 49 | * This class represents the interface of all Contact Backends. |
50 | * Derivates of this class will be used to access the contacts. | 50 | * Derivates of this class will be used to access the contacts. |
51 | * As implementation currently XML and vCard exist. This class needs to be implemented | 51 | * As implementation currently XML and vCard exist. This class needs to be implemented |
52 | * if you want to provide your own storage. | 52 | * if you want to provide your own storage. |
53 | * In all queries a list of uids is passed on instead of loading the actual record! | 53 | * In all queries a list of uids is passed on instead of loading the actual record! |
54 | * | 54 | * |
55 | * @see OContactAccessBackend_VCard | 55 | * @see OPimContactAccessBackend_VCard |
56 | * @see OContactAccessBackend_XML | 56 | * @see OPimContactAccessBackend_XML |
57 | */ | 57 | */ |
58 | class OContactAccessBackend: public OPimAccessBackend<OContact> { | 58 | class OPimContactAccessBackend: public OPimAccessBackend<OPimContact> { |
59 | public: | 59 | public: |
60 | /** | 60 | /** |
61 | * @todo make non line in regard to BC guide of KDE | 61 | * @todo make non line in regard to BC guide of KDE |
62 | */ | 62 | */ |
63 | OContactAccessBackend() {} | 63 | OPimContactAccessBackend() {} |
64 | /** | 64 | /** |
65 | * @todo make non inline in regard to the BC guide of KDE | 65 | * @todo make non inline in regard to the BC guide of KDE |
66 | */ | 66 | */ |
67 | virtual ~OContactAccessBackend() {} | 67 | virtual ~OPimContactAccessBackend() {} |
68 | 68 | ||
69 | 69 | ||
70 | /** | 70 | /** |
71 | * Return if database was changed externally. | 71 | * Return if database was changed externally. |
72 | * This may just make sense on file based databases like a XML-File. | 72 | * This may just make sense on file based databases like a XML-File. |
73 | * It is used to prevent to overwrite the current database content | 73 | * It is used to prevent to overwrite the current database content |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp index d0c8052..f121cc2 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp | |||
@@ -36,14 +36,14 @@ | |||
36 | #include <qdatetime.h> | 36 | #include <qdatetime.h> |
37 | #include <qstringlist.h> | 37 | #include <qstringlist.h> |
38 | 38 | ||
39 | #include <qpe/global.h> | 39 | #include <qpe/global.h> |
40 | #include <qpe/recordfields.h> | 40 | #include <qpe/recordfields.h> |
41 | 41 | ||
42 | #include <opie2/ocontactfields.h> | 42 | #include <opie2/opimcontactfields.h> |
43 | #include <opie2/oconversion.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 | 49 | ||
@@ -102,21 +102,21 @@ namespace Opie { | |||
102 | LoadQuery(); | 102 | LoadQuery(); |
103 | ~LoadQuery(); | 103 | ~LoadQuery(); |
104 | QString query()const; | 104 | QString query()const; |
105 | }; | 105 | }; |
106 | 106 | ||
107 | /** | 107 | /** |
108 | * inserts/adds a OContact to the table | 108 | * inserts/adds a OPimContact to the table |
109 | */ | 109 | */ |
110 | class InsertQuery : public OSQLQuery { | 110 | class InsertQuery : public OSQLQuery { |
111 | public: | 111 | public: |
112 | InsertQuery(const OContact& ); | 112 | InsertQuery(const OPimContact& ); |
113 | ~InsertQuery(); | 113 | ~InsertQuery(); |
114 | QString query()const; | 114 | QString query()const; |
115 | private: | 115 | private: |
116 | OContact m_contact; | 116 | OPimContact m_contact; |
117 | }; | 117 | }; |
118 | 118 | ||
119 | 119 | ||
120 | /** | 120 | /** |
121 | * removes one from the table | 121 | * removes one from the table |
122 | */ | 122 | */ |
@@ -173,13 +173,13 @@ namespace Opie { | |||
173 | QString CreateQuery::query()const { | 173 | QString CreateQuery::query()const { |
174 | QString qu; | 174 | QString qu; |
175 | #ifdef __STORE_HORIZONTAL_ | 175 | #ifdef __STORE_HORIZONTAL_ |
176 | 176 | ||
177 | qu += "create table addressbook( uid PRIMARY KEY "; | 177 | qu += "create table addressbook( uid PRIMARY KEY "; |
178 | 178 | ||
179 | QStringList fieldList = OContactFields::untrfields( false ); | 179 | QStringList fieldList = OPimContactFields::untrfields( false ); |
180 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ | 180 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ |
181 | qu += QString( ",\"%1\" VARCHAR(10)" ).arg( *it ); | 181 | qu += QString( ",\"%1\" VARCHAR(10)" ).arg( *it ); |
182 | } | 182 | } |
183 | qu += " );"; | 183 | qu += " );"; |
184 | 184 | ||
185 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );"; | 185 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );"; |
@@ -220,35 +220,35 @@ namespace Opie { | |||
220 | #endif // __STORE_HORIZONTAL_ | 220 | #endif // __STORE_HORIZONTAL_ |
221 | 221 | ||
222 | return qu; | 222 | return qu; |
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | InsertQuery::InsertQuery( const OContact& contact ) | 226 | InsertQuery::InsertQuery( const OPimContact& contact ) |
227 | : OSQLQuery(), m_contact( contact ) { | 227 | : OSQLQuery(), m_contact( contact ) { |
228 | } | 228 | } |
229 | 229 | ||
230 | InsertQuery::~InsertQuery() { | 230 | InsertQuery::~InsertQuery() { |
231 | } | 231 | } |
232 | 232 | ||
233 | /* | 233 | /* |
234 | * converts from a OContact to a query | 234 | * converts from a OPimContact to a query |
235 | */ | 235 | */ |
236 | QString InsertQuery::query()const{ | 236 | QString InsertQuery::query()const{ |
237 | 237 | ||
238 | #ifdef __STORE_HORIZONTAL_ | 238 | #ifdef __STORE_HORIZONTAL_ |
239 | QString qu; | 239 | QString qu; |
240 | qu += "insert into addressbook VALUES( " + | 240 | qu += "insert into addressbook VALUES( " + |
241 | QString::number( m_contact.uid() ); | 241 | QString::number( m_contact.uid() ); |
242 | 242 | ||
243 | // Get all information out of the contact-class | 243 | // Get all information out of the contact-class |
244 | // Remember: The category is stored in contactMap, too ! | 244 | // Remember: The category is stored in contactMap, too ! |
245 | QMap<int, QString> contactMap = m_contact.toMap(); | 245 | QMap<int, QString> contactMap = m_contact.toMap(); |
246 | 246 | ||
247 | QStringList fieldList = OContactFields::untrfields( false ); | 247 | QStringList fieldList = OPimContactFields::untrfields( false ); |
248 | QMap<QString, int> translate = OContactFields::untrFieldsToId(); | 248 | QMap<QString, int> translate = OPimContactFields::untrFieldsToId(); |
249 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ | 249 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ |
250 | // Convert Column-String to Id and get value for this id.. | 250 | // Convert Column-String to Id and get value for this id.. |
251 | // Hmmm.. Maybe not very cute solution.. | 251 | // Hmmm.. Maybe not very cute solution.. |
252 | int id = translate[*it]; | 252 | int id = translate[*it]; |
253 | switch ( id ){ | 253 | switch ( id ){ |
254 | case Qtopia::Birthday:{ | 254 | case Qtopia::Birthday:{ |
@@ -292,13 +292,13 @@ namespace Opie { | |||
292 | // Remember: The category is stored in contactMap, too ! | 292 | // Remember: The category is stored in contactMap, too ! |
293 | QMap<int, QString> contactMap = m_contact.toMap(); | 293 | QMap<int, QString> contactMap = m_contact.toMap(); |
294 | 294 | ||
295 | QMap<QString, QString> addressbook_db; | 295 | QMap<QString, QString> addressbook_db; |
296 | 296 | ||
297 | // Get the translation from the ID to the String | 297 | // Get the translation from the ID to the String |
298 | QMap<int, QString> transMap = OContactFields::idToUntrFields(); | 298 | QMap<int, QString> transMap = OPimContactFields::idToUntrFields(); |
299 | 299 | ||
300 | for( QMap<int, QString>::Iterator it = contactMap.begin(); | 300 | for( QMap<int, QString>::Iterator it = contactMap.begin(); |
301 | it != contactMap.end(); ++it ){ | 301 | it != contactMap.end(); ++it ){ |
302 | switch ( it.key() ){ | 302 | switch ( it.key() ){ |
303 | case Qtopia::Birthday:{ | 303 | case Qtopia::Birthday:{ |
304 | // These entries should stored in a special format | 304 | // These entries should stored in a special format |
@@ -456,17 +456,17 @@ namespace Opie { | |||
456 | 456 | ||
457 | 457 | ||
458 | /* --------------------------------------------------------------------------- */ | 458 | /* --------------------------------------------------------------------------- */ |
459 | 459 | ||
460 | namespace Opie { | 460 | namespace Opie { |
461 | 461 | ||
462 | OContactAccessBackend_SQL::OContactAccessBackend_SQL ( const QString& /* appname */, | 462 | OPimContactAccessBackend_SQL::OPimContactAccessBackend_SQL ( const QString& /* appname */, |
463 | const QString& filename ): | 463 | const QString& filename ): |
464 | OContactAccessBackend(), m_changed(false), m_driver( NULL ) | 464 | OPimContactAccessBackend(), m_changed(false), m_driver( NULL ) |
465 | { | 465 | { |
466 | qWarning("C'tor OContactAccessBackend_SQL starts"); | 466 | qWarning("C'tor OPimContactAccessBackend_SQL starts"); |
467 | QTime t; | 467 | QTime t; |
468 | t.start(); | 468 | t.start(); |
469 | 469 | ||
470 | /* Expecting to access the default filename if nothing else is set */ | 470 | /* Expecting to access the default filename if nothing else is set */ |
471 | if ( filename.isEmpty() ){ | 471 | if ( filename.isEmpty() ){ |
472 | m_fileName = Global::applicationFileName( "addressbook","addressbook.db" ); | 472 | m_fileName = Global::applicationFileName( "addressbook","addressbook.db" ); |
@@ -477,22 +477,22 @@ OContactAccessBackend_SQL::OContactAccessBackend_SQL ( const QString& /* appname | |||
477 | OSQLManager man; | 477 | OSQLManager man; |
478 | m_driver = man.standard(); | 478 | m_driver = man.standard(); |
479 | m_driver->setUrl( m_fileName ); | 479 | m_driver->setUrl( m_fileName ); |
480 | 480 | ||
481 | load(); | 481 | load(); |
482 | 482 | ||
483 | qWarning("C'tor OContactAccessBackend_SQL ends: %d ms", t.elapsed() ); | 483 | qWarning("C'tor OPimContactAccessBackend_SQL ends: %d ms", t.elapsed() ); |
484 | } | 484 | } |
485 | 485 | ||
486 | OContactAccessBackend_SQL::~OContactAccessBackend_SQL () | 486 | OPimContactAccessBackend_SQL::~OPimContactAccessBackend_SQL () |
487 | { | 487 | { |
488 | if( m_driver ) | 488 | if( m_driver ) |
489 | delete m_driver; | 489 | delete m_driver; |
490 | } | 490 | } |
491 | 491 | ||
492 | bool OContactAccessBackend_SQL::load () | 492 | bool OPimContactAccessBackend_SQL::load () |
493 | { | 493 | { |
494 | if (!m_driver->open() ) | 494 | if (!m_driver->open() ) |
495 | return false; | 495 | return false; |
496 | 496 | ||
497 | // Don't expect that the database exists. | 497 | // Don't expect that the database exists. |
498 | // It is save here to create the table, even if it | 498 | // It is save here to create the table, even if it |
@@ -503,48 +503,48 @@ bool OContactAccessBackend_SQL::load () | |||
503 | update(); | 503 | update(); |
504 | 504 | ||
505 | return true; | 505 | return true; |
506 | 506 | ||
507 | } | 507 | } |
508 | 508 | ||
509 | bool OContactAccessBackend_SQL::reload() | 509 | bool OPimContactAccessBackend_SQL::reload() |
510 | { | 510 | { |
511 | return load(); | 511 | return load(); |
512 | } | 512 | } |
513 | 513 | ||
514 | bool OContactAccessBackend_SQL::save() | 514 | bool OPimContactAccessBackend_SQL::save() |
515 | { | 515 | { |
516 | return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) | 516 | return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) |
517 | } | 517 | } |
518 | 518 | ||
519 | 519 | ||
520 | void OContactAccessBackend_SQL::clear () | 520 | void OPimContactAccessBackend_SQL::clear () |
521 | { | 521 | { |
522 | ClearQuery cle; | 522 | ClearQuery cle; |
523 | OSQLResult res = m_driver->query( &cle ); | 523 | OSQLResult res = m_driver->query( &cle ); |
524 | 524 | ||
525 | reload(); | 525 | reload(); |
526 | } | 526 | } |
527 | 527 | ||
528 | bool OContactAccessBackend_SQL::wasChangedExternally() | 528 | bool OPimContactAccessBackend_SQL::wasChangedExternally() |
529 | { | 529 | { |
530 | return false; | 530 | return false; |
531 | } | 531 | } |
532 | 532 | ||
533 | QArray<int> OContactAccessBackend_SQL::allRecords() const | 533 | QArray<int> OPimContactAccessBackend_SQL::allRecords() const |
534 | { | 534 | { |
535 | 535 | ||
536 | // FIXME: Think about cute handling of changed tables.. | 536 | // FIXME: Think about cute handling of changed tables.. |
537 | // Thus, we don't have to call update here... | 537 | // Thus, we don't have to call update here... |
538 | if ( m_changed ) | 538 | if ( m_changed ) |
539 | ((OContactAccessBackend_SQL*)this)->update(); | 539 | ((OPimContactAccessBackend_SQL*)this)->update(); |
540 | 540 | ||
541 | return m_uids; | 541 | return m_uids; |
542 | } | 542 | } |
543 | 543 | ||
544 | bool OContactAccessBackend_SQL::add ( const OContact &newcontact ) | 544 | bool OPimContactAccessBackend_SQL::add ( const OPimContact &newcontact ) |
545 | { | 545 | { |
546 | InsertQuery ins( newcontact ); | 546 | InsertQuery ins( newcontact ); |
547 | OSQLResult res = m_driver->query( &ins ); | 547 | OSQLResult res = m_driver->query( &ins ); |
548 | 548 | ||
549 | if ( res.state() == OSQLResult::Failure ) | 549 | if ( res.state() == OSQLResult::Failure ) |
550 | return false; | 550 | return false; |
@@ -554,56 +554,56 @@ bool OContactAccessBackend_SQL::add ( const OContact &newcontact ) | |||
554 | m_uids[c] = newcontact.uid(); | 554 | m_uids[c] = newcontact.uid(); |
555 | 555 | ||
556 | return true; | 556 | return true; |
557 | } | 557 | } |
558 | 558 | ||
559 | 559 | ||
560 | bool OContactAccessBackend_SQL::remove ( int uid ) | 560 | bool OPimContactAccessBackend_SQL::remove ( int uid ) |
561 | { | 561 | { |
562 | RemoveQuery rem( uid ); | 562 | RemoveQuery rem( uid ); |
563 | OSQLResult res = m_driver->query(&rem ); | 563 | OSQLResult res = m_driver->query(&rem ); |
564 | 564 | ||
565 | if ( res.state() == OSQLResult::Failure ) | 565 | if ( res.state() == OSQLResult::Failure ) |
566 | return false; | 566 | return false; |
567 | 567 | ||
568 | m_changed = true; | 568 | m_changed = true; |
569 | 569 | ||
570 | return true; | 570 | return true; |
571 | } | 571 | } |
572 | 572 | ||
573 | bool OContactAccessBackend_SQL::replace ( const OContact &contact ) | 573 | bool OPimContactAccessBackend_SQL::replace ( const OPimContact &contact ) |
574 | { | 574 | { |
575 | if ( !remove( contact.uid() ) ) | 575 | if ( !remove( contact.uid() ) ) |
576 | return false; | 576 | return false; |
577 | 577 | ||
578 | return add( contact ); | 578 | return add( contact ); |
579 | } | 579 | } |
580 | 580 | ||
581 | 581 | ||
582 | OContact OContactAccessBackend_SQL::find ( int uid ) const | 582 | OPimContact OPimContactAccessBackend_SQL::find ( int uid ) const |
583 | { | 583 | { |
584 | qWarning("OContactAccessBackend_SQL::find()"); | 584 | qWarning("OPimContactAccessBackend_SQL::find()"); |
585 | QTime t; | 585 | QTime t; |
586 | t.start(); | 586 | t.start(); |
587 | 587 | ||
588 | OContact retContact( requestNonCustom( uid ) ); | 588 | OPimContact retContact( requestNonCustom( uid ) ); |
589 | retContact.setExtraMap( requestCustom( uid ) ); | 589 | retContact.setExtraMap( requestCustom( uid ) ); |
590 | 590 | ||
591 | qWarning("OContactAccessBackend_SQL::find() needed: %d ms", t.elapsed() ); | 591 | qWarning("OPimContactAccessBackend_SQL::find() needed: %d ms", t.elapsed() ); |
592 | return retContact; | 592 | return retContact; |
593 | } | 593 | } |
594 | 594 | ||
595 | 595 | ||
596 | 596 | ||
597 | QArray<int> OContactAccessBackend_SQL::queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() ) | 597 | QArray<int> OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &query, int settings, const QDateTime& d = QDateTime() ) |
598 | { | 598 | { |
599 | QString qu = "SELECT uid FROM addressbook WHERE"; | 599 | QString qu = "SELECT uid FROM addressbook WHERE"; |
600 | 600 | ||
601 | QMap<int, QString> queryFields = query.toMap(); | 601 | QMap<int, QString> queryFields = query.toMap(); |
602 | QStringList fieldList = OContactFields::untrfields( false ); | 602 | QStringList fieldList = OPimContactFields::untrfields( false ); |
603 | QMap<QString, int> translate = OContactFields::untrFieldsToId(); | 603 | QMap<QString, int> translate = OPimContactFields::untrFieldsToId(); |
604 | 604 | ||
605 | // Convert every filled field to a SQL-Query | 605 | // Convert every filled field to a SQL-Query |
606 | bool isAnyFieldSelected = false; | 606 | bool isAnyFieldSelected = false; |
607 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ | 607 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ |
608 | int id = translate[*it]; | 608 | int id = translate[*it]; |
609 | QString queryStr = queryFields[id]; | 609 | QString queryStr = queryFields[id]; |
@@ -611,13 +611,13 @@ QArray<int> OContactAccessBackend_SQL::queryByExample ( const OContact &query, i | |||
611 | isAnyFieldSelected = true; | 611 | isAnyFieldSelected = true; |
612 | switch( id ){ | 612 | switch( id ){ |
613 | default: | 613 | default: |
614 | // Switching between case sensitive and insensitive... | 614 | // Switching between case sensitive and insensitive... |
615 | // LIKE is not case sensitive, GLOB is case sensitive | 615 | // LIKE is not case sensitive, GLOB is case sensitive |
616 | // Do exist a better solution to switch this ? | 616 | // Do exist a better solution to switch this ? |
617 | if ( settings & OContactAccess::IgnoreCase ) | 617 | if ( settings & OPimContactAccess::IgnoreCase ) |
618 | qu += "(\"" + *it + "\"" + " LIKE " + "'" | 618 | qu += "(\"" + *it + "\"" + " LIKE " + "'" |
619 | + queryStr.replace(QRegExp("\\*"),"%") + "'" + ") AND "; | 619 | + queryStr.replace(QRegExp("\\*"),"%") + "'" + ") AND "; |
620 | else | 620 | else |
621 | qu += "(\"" + *it + "\"" + " GLOB " + "'" | 621 | qu += "(\"" + *it + "\"" + " GLOB " + "'" |
622 | + queryStr + "'" + ") AND "; | 622 | + queryStr + "'" + ") AND "; |
623 | 623 | ||
@@ -640,73 +640,73 @@ QArray<int> OContactAccessBackend_SQL::queryByExample ( const OContact &query, i | |||
640 | 640 | ||
641 | QArray<int> list = extractUids( res ); | 641 | QArray<int> list = extractUids( res ); |
642 | 642 | ||
643 | return list; | 643 | return list; |
644 | } | 644 | } |
645 | 645 | ||
646 | QArray<int> OContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const | 646 | QArray<int> OPimContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const |
647 | { | 647 | { |
648 | QArray<int> nix(0); | 648 | QArray<int> nix(0); |
649 | return nix; | 649 | return nix; |
650 | } | 650 | } |
651 | 651 | ||
652 | const uint OContactAccessBackend_SQL::querySettings() | 652 | const uint OPimContactAccessBackend_SQL::querySettings() |
653 | { | 653 | { |
654 | return OContactAccess::IgnoreCase | 654 | return OPimContactAccess::IgnoreCase |
655 | || OContactAccess::WildCards; | 655 | || OPimContactAccess::WildCards; |
656 | } | 656 | } |
657 | 657 | ||
658 | bool OContactAccessBackend_SQL::hasQuerySettings (uint querySettings) const | 658 | bool OPimContactAccessBackend_SQL::hasQuerySettings (uint querySettings) const |
659 | { | 659 | { |
660 | /* OContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay | 660 | /* OPimContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay |
661 | * may be added with any of the other settings. IgnoreCase should never used alone. | 661 | * may be added with any of the other settings. IgnoreCase should never used alone. |
662 | * Wildcards, RegExp, ExactMatch should never used at the same time... | 662 | * Wildcards, RegExp, ExactMatch should never used at the same time... |
663 | */ | 663 | */ |
664 | 664 | ||
665 | // Step 1: Check whether the given settings are supported by this backend | 665 | // Step 1: Check whether the given settings are supported by this backend |
666 | if ( ( querySettings & ( | 666 | if ( ( querySettings & ( |
667 | OContactAccess::IgnoreCase | 667 | OPimContactAccess::IgnoreCase |
668 | | OContactAccess::WildCards | 668 | | OPimContactAccess::WildCards |
669 | // | OContactAccess::DateDiff | 669 | // | OPimContactAccess::DateDiff |
670 | // | OContactAccess::DateYear | 670 | // | OPimContactAccess::DateYear |
671 | // | OContactAccess::DateMonth | 671 | // | OPimContactAccess::DateMonth |
672 | // | OContactAccess::DateDay | 672 | // | OPimContactAccess::DateDay |
673 | // | OContactAccess::RegExp | 673 | // | OPimContactAccess::RegExp |
674 | // | OContactAccess::ExactMatch | 674 | // | OPimContactAccess::ExactMatch |
675 | ) ) != querySettings ) | 675 | ) ) != querySettings ) |
676 | return false; | 676 | return false; |
677 | 677 | ||
678 | // Step 2: Check whether the given combinations are ok.. | 678 | // Step 2: Check whether the given combinations are ok.. |
679 | 679 | ||
680 | // IngoreCase alone is invalid | 680 | // IngoreCase alone is invalid |
681 | if ( querySettings == OContactAccess::IgnoreCase ) | 681 | if ( querySettings == OPimContactAccess::IgnoreCase ) |
682 | return false; | 682 | return false; |
683 | 683 | ||
684 | // WildCards, RegExp and ExactMatch should never used at the same time | 684 | // WildCards, RegExp and ExactMatch should never used at the same time |
685 | switch ( querySettings & ~( OContactAccess::IgnoreCase | 685 | switch ( querySettings & ~( OPimContactAccess::IgnoreCase |
686 | | OContactAccess::DateDiff | 686 | | OPimContactAccess::DateDiff |
687 | | OContactAccess::DateYear | 687 | | OPimContactAccess::DateYear |
688 | | OContactAccess::DateMonth | 688 | | OPimContactAccess::DateMonth |
689 | | OContactAccess::DateDay | 689 | | OPimContactAccess::DateDay |
690 | ) | 690 | ) |
691 | ){ | 691 | ){ |
692 | case OContactAccess::RegExp: | 692 | case OPimContactAccess::RegExp: |
693 | return ( true ); | 693 | return ( true ); |
694 | case OContactAccess::WildCards: | 694 | case OPimContactAccess::WildCards: |
695 | return ( true ); | 695 | return ( true ); |
696 | case OContactAccess::ExactMatch: | 696 | case OPimContactAccess::ExactMatch: |
697 | return ( true ); | 697 | return ( true ); |
698 | case 0: // one of the upper removed bits were set.. | 698 | case 0: // one of the upper removed bits were set.. |
699 | return ( true ); | 699 | return ( true ); |
700 | default: | 700 | default: |
701 | return ( false ); | 701 | return ( false ); |
702 | } | 702 | } |
703 | 703 | ||
704 | } | 704 | } |
705 | 705 | ||
706 | QArray<int> OContactAccessBackend_SQL::sorted( bool asc, int , int , int ) | 706 | QArray<int> OPimContactAccessBackend_SQL::sorted( bool asc, int , int , int ) |
707 | { | 707 | { |
708 | QTime t; | 708 | QTime t; |
709 | t.start(); | 709 | t.start(); |
710 | 710 | ||
711 | #ifdef __STORE_HORIZONTAL_ | 711 | #ifdef __STORE_HORIZONTAL_ |
712 | QString query = "SELECT uid FROM addressbook "; | 712 | QString query = "SELECT uid FROM addressbook "; |
@@ -732,13 +732,13 @@ QArray<int> OContactAccessBackend_SQL::sorted( bool asc, int , int , int ) | |||
732 | 732 | ||
733 | qWarning("sorted needed %d ms!", t.elapsed() ); | 733 | qWarning("sorted needed %d ms!", t.elapsed() ); |
734 | return list; | 734 | return list; |
735 | } | 735 | } |
736 | 736 | ||
737 | 737 | ||
738 | void OContactAccessBackend_SQL::update() | 738 | void OPimContactAccessBackend_SQL::update() |
739 | { | 739 | { |
740 | qWarning("Update starts"); | 740 | qWarning("Update starts"); |
741 | QTime t; | 741 | QTime t; |
742 | t.start(); | 742 | t.start(); |
743 | 743 | ||
744 | // Now load the database set and extract the uid's | 744 | // Now load the database set and extract the uid's |
@@ -753,13 +753,13 @@ void OContactAccessBackend_SQL::update() | |||
753 | 753 | ||
754 | m_changed = false; | 754 | m_changed = false; |
755 | 755 | ||
756 | qWarning("Update ends %d ms", t.elapsed() ); | 756 | qWarning("Update ends %d ms", t.elapsed() ); |
757 | } | 757 | } |
758 | 758 | ||
759 | QArray<int> OContactAccessBackend_SQL::extractUids( OSQLResult& res ) const | 759 | QArray<int> OPimContactAccessBackend_SQL::extractUids( OSQLResult& res ) const |
760 | { | 760 | { |
761 | qWarning("extractUids"); | 761 | qWarning("extractUids"); |
762 | QTime t; | 762 | QTime t; |
763 | t.start(); | 763 | t.start(); |
764 | OSQLResultItem::ValueList list = res.results(); | 764 | OSQLResultItem::ValueList list = res.results(); |
765 | OSQLResultItem::ValueList::Iterator it; | 765 | OSQLResultItem::ValueList::Iterator it; |
@@ -775,13 +775,13 @@ QArray<int> OContactAccessBackend_SQL::extractUids( OSQLResult& res ) const | |||
775 | 775 | ||
776 | return ints; | 776 | return ints; |
777 | 777 | ||
778 | } | 778 | } |
779 | 779 | ||
780 | #ifdef __STORE_HORIZONTAL_ | 780 | #ifdef __STORE_HORIZONTAL_ |
781 | QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const | 781 | QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) const |
782 | { | 782 | { |
783 | QTime t; | 783 | QTime t; |
784 | t.start(); | 784 | t.start(); |
785 | 785 | ||
786 | QMap<int, QString> nonCustomMap; | 786 | QMap<int, QString> nonCustomMap; |
787 | 787 | ||
@@ -795,14 +795,14 @@ QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const | |||
795 | 795 | ||
796 | OSQLResultItem resItem = res_noncustom.first(); | 796 | OSQLResultItem resItem = res_noncustom.first(); |
797 | 797 | ||
798 | QTime t3; | 798 | QTime t3; |
799 | t3.start(); | 799 | t3.start(); |
800 | // Now loop through all columns | 800 | // Now loop through all columns |
801 | QStringList fieldList = OContactFields::untrfields( false ); | 801 | QStringList fieldList = OPimContactFields::untrfields( false ); |
802 | QMap<QString, int> translate = OContactFields::untrFieldsToId(); | 802 | QMap<QString, int> translate = OPimContactFields::untrFieldsToId(); |
803 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ | 803 | for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ |
804 | // Get data for the selected column and store it with the | 804 | // Get data for the selected column and store it with the |
805 | // corresponding id into the map.. | 805 | // corresponding id into the map.. |
806 | 806 | ||
807 | int id = translate[*it]; | 807 | int id = translate[*it]; |
808 | QString value = resItem.data( (*it) ); | 808 | QString value = resItem.data( (*it) ); |
@@ -817,13 +817,13 @@ QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const | |||
817 | QStringList::Iterator lit = list.begin(); | 817 | QStringList::Iterator lit = list.begin(); |
818 | int year = (*lit).toInt(); | 818 | int year = (*lit).toInt(); |
819 | int month = (*(++lit)).toInt(); | 819 | int month = (*(++lit)).toInt(); |
820 | int day = (*(++lit)).toInt(); | 820 | int day = (*(++lit)).toInt(); |
821 | if ( ( day != 0 ) && ( month != 0 ) && ( year != 0 ) ){ | 821 | if ( ( day != 0 ) && ( month != 0 ) && ( year != 0 ) ){ |
822 | QDate date( year, month, day ); | 822 | QDate date( year, month, day ); |
823 | nonCustomMap.insert( id, OConversion::dateToString( date ) ); | 823 | nonCustomMap.insert( id, OPimDateConversion::dateToString( date ) ); |
824 | } | 824 | } |
825 | } | 825 | } |
826 | break; | 826 | break; |
827 | case Qtopia::AddressCategory: | 827 | case Qtopia::AddressCategory: |
828 | qWarning("Category is: %s", value.latin1() ); | 828 | qWarning("Category is: %s", value.latin1() ); |
829 | default: | 829 | default: |
@@ -840,13 +840,13 @@ QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const | |||
840 | t.elapsed(), t2needed, t3needed ); | 840 | t.elapsed(), t2needed, t3needed ); |
841 | 841 | ||
842 | return nonCustomMap; | 842 | return nonCustomMap; |
843 | } | 843 | } |
844 | #else | 844 | #else |
845 | 845 | ||
846 | QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const | 846 | QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) const |
847 | { | 847 | { |
848 | QTime t; | 848 | QTime t; |
849 | t.start(); | 849 | t.start(); |
850 | 850 | ||
851 | QMap<int, QString> nonCustomMap; | 851 | QMap<int, QString> nonCustomMap; |
852 | 852 | ||
@@ -863,13 +863,13 @@ QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const | |||
863 | return empty; | 863 | return empty; |
864 | } | 864 | } |
865 | 865 | ||
866 | int t3needed = 0; | 866 | int t3needed = 0; |
867 | QTime t3; | 867 | QTime t3; |
868 | t3.start(); | 868 | t3.start(); |
869 | QMap<QString, int> translateMap = OContactFields::untrFieldsToId(); | 869 | QMap<QString, int> translateMap = OPimContactFields::untrFieldsToId(); |
870 | 870 | ||
871 | OSQLResultItem::ValueList list = res_noncustom.results(); | 871 | OSQLResultItem::ValueList list = res_noncustom.results(); |
872 | OSQLResultItem::ValueList::Iterator it = list.begin(); | 872 | OSQLResultItem::ValueList::Iterator it = list.begin(); |
873 | for ( ; it != list.end(); ++it ) { | 873 | for ( ; it != list.end(); ++it ) { |
874 | if ( (*it).data("type") != "" ){ | 874 | if ( (*it).data("type") != "" ){ |
875 | int typeId = translateMap[(*it).data( "type" )]; | 875 | int typeId = translateMap[(*it).data( "type" )]; |
@@ -884,13 +884,13 @@ QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const | |||
884 | int month = (*(++lit)).toInt(); | 884 | int month = (*(++lit)).toInt(); |
885 | qWarning("2. %s", (*lit).latin1()); | 885 | qWarning("2. %s", (*lit).latin1()); |
886 | int day = (*(++lit)).toInt(); | 886 | int day = (*(++lit)).toInt(); |
887 | qWarning("3. %s", (*lit).latin1()); | 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 ); | 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 ); | 889 | QDate date( year, month, day ); |
890 | nonCustomMap.insert( typeId, OConversion::dateToString( date ) ); | 890 | nonCustomMap.insert( typeId, OPimDateConversion::dateToString( date ) ); |
891 | } | 891 | } |
892 | break; | 892 | break; |
893 | default: | 893 | default: |
894 | nonCustomMap.insert( typeId, | 894 | nonCustomMap.insert( typeId, |
895 | (*it).data( "value" ) ); | 895 | (*it).data( "value" ) ); |
896 | } | 896 | } |
@@ -903,13 +903,13 @@ QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const | |||
903 | qWarning("RequestNonCustom needed: insg.:%d ms, query: %d ms, mapping: %d ms", t.elapsed(), t2needed, t3needed ); | 903 | qWarning("RequestNonCustom needed: insg.:%d ms, query: %d ms, mapping: %d ms", t.elapsed(), t2needed, t3needed ); |
904 | return nonCustomMap; | 904 | return nonCustomMap; |
905 | } | 905 | } |
906 | 906 | ||
907 | #endif // __STORE_HORIZONTAL_ | 907 | #endif // __STORE_HORIZONTAL_ |
908 | 908 | ||
909 | QMap<QString, QString> OContactAccessBackend_SQL::requestCustom( int uid ) const | 909 | QMap<QString, QString> OPimContactAccessBackend_SQL::requestCustom( int uid ) const |
910 | { | 910 | { |
911 | QTime t; | 911 | QTime t; |
912 | t.start(); | 912 | t.start(); |
913 | 913 | ||
914 | QMap<QString, QString> customMap; | 914 | QMap<QString, QString> customMap; |
915 | 915 | ||
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h index 55b95fd..58ae2ae 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h | |||
@@ -27,14 +27,14 @@ | |||
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | /* | 29 | /* |
30 | * SQL Backend for the OPIE-Contact Database. | 30 | * SQL Backend for the OPIE-Contact Database. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | #ifndef _OContactAccessBackend_SQL_ | 33 | #ifndef _OPimContactAccessBackend_SQL_ |
34 | #define _OContactAccessBackend_SQL_ | 34 | #define _OPimContactAccessBackend_SQL_ |
35 | 35 | ||
36 | #include <opie2/ocontactaccessbackend.h> | 36 | #include <opie2/ocontactaccessbackend.h> |
37 | #include <opie2/ocontactaccess.h> | 37 | #include <opie2/ocontactaccess.h> |
38 | 38 | ||
39 | #include <qlist.h> | 39 | #include <qlist.h> |
40 | #include <qdict.h> | 40 | #include <qdict.h> |
@@ -46,49 +46,49 @@ class OSQLResultItem; | |||
46 | 46 | ||
47 | namespace Opie { | 47 | namespace Opie { |
48 | 48 | ||
49 | /* the default xml implementation */ | 49 | /* the default xml implementation */ |
50 | /** | 50 | /** |
51 | * This class is the SQL implementation of a Contact backend | 51 | * This class is the SQL implementation of a Contact backend |
52 | * it does implement everything available for OContact. | 52 | * it does implement everything available for OPimContact. |
53 | * @see OPimAccessBackend for more information of available methods | 53 | * @see OPimAccessBackend for more information of available methods |
54 | */ | 54 | */ |
55 | class OContactAccessBackend_SQL : public OContactAccessBackend { | 55 | class OPimContactAccessBackend_SQL : public OPimContactAccessBackend { |
56 | public: | 56 | public: |
57 | OContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null ); | 57 | OPimContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null ); |
58 | 58 | ||
59 | ~OContactAccessBackend_SQL (); | 59 | ~OPimContactAccessBackend_SQL (); |
60 | 60 | ||
61 | bool save(); | 61 | bool save(); |
62 | 62 | ||
63 | bool load (); | 63 | bool load (); |
64 | 64 | ||
65 | void clear (); | 65 | void clear (); |
66 | 66 | ||
67 | bool wasChangedExternally(); | 67 | bool wasChangedExternally(); |
68 | 68 | ||
69 | QArray<int> allRecords() const; | 69 | QArray<int> allRecords() const; |
70 | 70 | ||
71 | OContact find ( int uid ) const; | 71 | OPimContact find ( int uid ) const; |
72 | // FIXME: Add lookahead-cache support ! | 72 | // FIXME: Add lookahead-cache support ! |
73 | //OContact find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; | 73 | //OPimContact find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; |
74 | 74 | ||
75 | QArray<int> queryByExample ( const OContact &query, int settings, | 75 | QArray<int> queryByExample ( const OPimContact &query, int settings, |
76 | const QDateTime& d ); | 76 | const QDateTime& d ); |
77 | 77 | ||
78 | QArray<int> matchRegexp( const QRegExp &r ) const; | 78 | QArray<int> matchRegexp( const QRegExp &r ) const; |
79 | 79 | ||
80 | const uint querySettings(); | 80 | const uint querySettings(); |
81 | 81 | ||
82 | bool hasQuerySettings (uint querySettings) const; | 82 | bool hasQuerySettings (uint querySettings) const; |
83 | 83 | ||
84 | // Currently only asc implemented.. | 84 | // Currently only asc implemented.. |
85 | QArray<int> sorted( bool asc, int , int , int ); | 85 | QArray<int> sorted( bool asc, int , int , int ); |
86 | bool add ( const OContact &newcontact ); | 86 | bool add ( const OPimContact &newcontact ); |
87 | 87 | ||
88 | bool replace ( const OContact &contact ); | 88 | bool replace ( const OPimContact &contact ); |
89 | 89 | ||
90 | bool remove ( int uid ); | 90 | bool remove ( int uid ); |
91 | bool reload(); | 91 | bool reload(); |
92 | 92 | ||
93 | private: | 93 | private: |
94 | QArray<int> extractUids( OSQLResult& res ) const; | 94 | QArray<int> extractUids( OSQLResult& res ) const; |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp index f85cf38..b569f8b 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp | |||
@@ -36,21 +36,21 @@ | |||
36 | #include <qpe/timeconversion.h> | 36 | #include <qpe/timeconversion.h> |
37 | 37 | ||
38 | #include <qfile.h> | 38 | #include <qfile.h> |
39 | 39 | ||
40 | namespace Opie { | 40 | namespace Opie { |
41 | 41 | ||
42 | OContactAccessBackend_VCard::OContactAccessBackend_VCard ( const QString& , const QString& filename ): | 42 | OPimContactAccessBackend_VCard::OPimContactAccessBackend_VCard ( const QString& , const QString& filename ): |
43 | m_dirty( false ), | 43 | m_dirty( false ), |
44 | m_file( filename ) | 44 | m_file( filename ) |
45 | { | 45 | { |
46 | load(); | 46 | load(); |
47 | } | 47 | } |
48 | 48 | ||
49 | 49 | ||
50 | bool OContactAccessBackend_VCard::load () | 50 | bool OPimContactAccessBackend_VCard::load () |
51 | { | 51 | { |
52 | m_map.clear(); | 52 | m_map.clear(); |
53 | m_dirty = false; | 53 | m_dirty = false; |
54 | 54 | ||
55 | VObject* obj = 0l; | 55 | VObject* obj = 0l; |
56 | 56 | ||
@@ -61,13 +61,13 @@ bool OContactAccessBackend_VCard::load () | |||
61 | }else{ | 61 | }else{ |
62 | qWarning("File \"%s\" not found !", m_file.latin1() ); | 62 | qWarning("File \"%s\" not found !", m_file.latin1() ); |
63 | return false; | 63 | return false; |
64 | } | 64 | } |
65 | 65 | ||
66 | while ( obj ) { | 66 | while ( obj ) { |
67 | OContact con = parseVObject( obj ); | 67 | OPimContact con = parseVObject( obj ); |
68 | /* | 68 | /* |
69 | * if uid is 0 assign a new one | 69 | * if uid is 0 assign a new one |
70 | * this at least happens on | 70 | * this at least happens on |
71 | * Nokia6210 | 71 | * Nokia6210 |
72 | */ | 72 | */ |
73 | if ( con.uid() == 0 ){ | 73 | if ( con.uid() == 0 ){ |
@@ -82,17 +82,17 @@ bool OContactAccessBackend_VCard::load () | |||
82 | cleanVObject( t ); | 82 | cleanVObject( t ); |
83 | } | 83 | } |
84 | 84 | ||
85 | return true; | 85 | return true; |
86 | 86 | ||
87 | } | 87 | } |
88 | bool OContactAccessBackend_VCard::reload() | 88 | bool OPimContactAccessBackend_VCard::reload() |
89 | { | 89 | { |
90 | return load(); | 90 | return load(); |
91 | } | 91 | } |
92 | bool OContactAccessBackend_VCard::save() | 92 | bool OPimContactAccessBackend_VCard::save() |
93 | { | 93 | { |
94 | if (!m_dirty ) | 94 | if (!m_dirty ) |
95 | return true; | 95 | return true; |
96 | 96 | ||
97 | QFileDirect file( m_file ); | 97 | QFileDirect file( m_file ); |
98 | if (!file.open(IO_WriteOnly ) ) | 98 | if (!file.open(IO_WriteOnly ) ) |
@@ -100,111 +100,111 @@ bool OContactAccessBackend_VCard::save() | |||
100 | 100 | ||
101 | VObject *obj; | 101 | VObject *obj; |
102 | obj = newVObject( VCCalProp ); | 102 | obj = newVObject( VCCalProp ); |
103 | addPropValue( obj, VCVersionProp, "1.0" ); | 103 | addPropValue( obj, VCVersionProp, "1.0" ); |
104 | 104 | ||
105 | VObject *vo; | 105 | VObject *vo; |
106 | for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ | 106 | for(QMap<int, OPimContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ |
107 | vo = createVObject( *it ); | 107 | vo = createVObject( *it ); |
108 | writeVObject( file.directHandle() , vo ); | 108 | writeVObject( file.directHandle() , vo ); |
109 | cleanVObject( vo ); | 109 | cleanVObject( vo ); |
110 | } | 110 | } |
111 | cleanStrTbl(); | 111 | cleanStrTbl(); |
112 | deleteVObject( obj ); | 112 | deleteVObject( obj ); |
113 | 113 | ||
114 | m_dirty = false; | 114 | m_dirty = false; |
115 | return true; | 115 | return true; |
116 | 116 | ||
117 | 117 | ||
118 | } | 118 | } |
119 | void OContactAccessBackend_VCard::clear () | 119 | void OPimContactAccessBackend_VCard::clear () |
120 | { | 120 | { |
121 | m_map.clear(); | 121 | m_map.clear(); |
122 | m_dirty = true; // ??? sure ? (se) | 122 | m_dirty = true; // ??? sure ? (se) |
123 | } | 123 | } |
124 | 124 | ||
125 | bool OContactAccessBackend_VCard::add ( const OContact& newcontact ) | 125 | bool OPimContactAccessBackend_VCard::add ( const OPimContact& newcontact ) |
126 | { | 126 | { |
127 | m_map.insert( newcontact.uid(), newcontact ); | 127 | m_map.insert( newcontact.uid(), newcontact ); |
128 | m_dirty = true; | 128 | m_dirty = true; |
129 | return true; | 129 | return true; |
130 | } | 130 | } |
131 | 131 | ||
132 | bool OContactAccessBackend_VCard::remove ( int uid ) | 132 | bool OPimContactAccessBackend_VCard::remove ( int uid ) |
133 | { | 133 | { |
134 | m_map.remove( uid ); | 134 | m_map.remove( uid ); |
135 | m_dirty = true; | 135 | m_dirty = true; |
136 | return true; | 136 | return true; |
137 | } | 137 | } |
138 | 138 | ||
139 | bool OContactAccessBackend_VCard::replace ( const OContact &contact ) | 139 | bool OPimContactAccessBackend_VCard::replace ( const OPimContact &contact ) |
140 | { | 140 | { |
141 | m_map.replace( contact.uid(), contact ); | 141 | m_map.replace( contact.uid(), contact ); |
142 | m_dirty = true; | 142 | m_dirty = true; |
143 | return true; | 143 | return true; |
144 | } | 144 | } |
145 | 145 | ||
146 | OContact OContactAccessBackend_VCard::find ( int uid ) const | 146 | OPimContact OPimContactAccessBackend_VCard::find ( int uid ) const |
147 | { | 147 | { |
148 | return m_map[uid]; | 148 | return m_map[uid]; |
149 | } | 149 | } |
150 | 150 | ||
151 | QArray<int> OContactAccessBackend_VCard::allRecords() const | 151 | QArray<int> OPimContactAccessBackend_VCard::allRecords() const |
152 | { | 152 | { |
153 | QArray<int> ar( m_map.count() ); | 153 | QArray<int> ar( m_map.count() ); |
154 | QMap<int, OContact>::ConstIterator it; | 154 | QMap<int, OPimContact>::ConstIterator it; |
155 | int i = 0; | 155 | int i = 0; |
156 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { | 156 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { |
157 | ar[i] = it.key(); | 157 | ar[i] = it.key(); |
158 | i++; | 158 | i++; |
159 | } | 159 | } |
160 | return ar; | 160 | return ar; |
161 | } | 161 | } |
162 | 162 | ||
163 | // Not implemented | 163 | // Not implemented |
164 | QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int, const QDateTime& ) | 164 | QArray<int> OPimContactAccessBackend_VCard::queryByExample ( const OPimContact&, int, const QDateTime& ) |
165 | { | 165 | { |
166 | QArray<int> ar(0); | 166 | QArray<int> ar(0); |
167 | return ar; | 167 | return ar; |
168 | } | 168 | } |
169 | 169 | ||
170 | // Not implemented | 170 | // Not implemented |
171 | QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const | 171 | QArray<int> OPimContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const |
172 | { | 172 | { |
173 | QArray<int> ar(0); | 173 | QArray<int> ar(0); |
174 | return ar; | 174 | return ar; |
175 | } | 175 | } |
176 | 176 | ||
177 | const uint OContactAccessBackend_VCard::querySettings() | 177 | const uint OPimContactAccessBackend_VCard::querySettings() |
178 | { | 178 | { |
179 | return 0; // No search possible | 179 | return 0; // No search possible |
180 | } | 180 | } |
181 | 181 | ||
182 | bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const | 182 | bool OPimContactAccessBackend_VCard::hasQuerySettings (uint ) const |
183 | { | 183 | { |
184 | return false; // No search possible, therefore all settings invalid ;) | 184 | return false; // No search possible, therefore all settings invalid ;) |
185 | } | 185 | } |
186 | 186 | ||
187 | bool OContactAccessBackend_VCard::wasChangedExternally() | 187 | bool OPimContactAccessBackend_VCard::wasChangedExternally() |
188 | { | 188 | { |
189 | return false; // Don't expect concurrent access | 189 | return false; // Don't expect concurrent access |
190 | } | 190 | } |
191 | 191 | ||
192 | // Not implemented | 192 | // Not implemented |
193 | QArray<int> OContactAccessBackend_VCard::sorted( bool , int, int, int ) | 193 | QArray<int> OPimContactAccessBackend_VCard::sorted( bool , int, int, int ) |
194 | { | 194 | { |
195 | QArray<int> ar(0); | 195 | QArray<int> ar(0); |
196 | return ar; | 196 | return ar; |
197 | } | 197 | } |
198 | 198 | ||
199 | // *** Private stuff *** | 199 | // *** Private stuff *** |
200 | 200 | ||
201 | 201 | ||
202 | OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) | 202 | OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj ) |
203 | { | 203 | { |
204 | OContact c; | 204 | OPimContact c; |
205 | 205 | ||
206 | VObjectIterator it; | 206 | VObjectIterator it; |
207 | initPropIterator( &it, obj ); | 207 | initPropIterator( &it, obj ); |
208 | while( moreIteration( &it ) ) { | 208 | while( moreIteration( &it ) ) { |
209 | VObject *o = nextVObject( &it ); | 209 | VObject *o = nextVObject( &it ); |
210 | QCString name = vObjectName( o ); | 210 | QCString name = vObjectName( o ); |
@@ -424,13 +424,13 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) | |||
424 | } | 424 | } |
425 | c.setFileAs(); | 425 | c.setFileAs(); |
426 | return c; | 426 | return c; |
427 | } | 427 | } |
428 | 428 | ||
429 | 429 | ||
430 | VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) | 430 | VObject* OPimContactAccessBackend_VCard::createVObject( const OPimContact &c ) |
431 | { | 431 | { |
432 | VObject *vcard = newVObject( VCCardProp ); | 432 | VObject *vcard = newVObject( VCCardProp ); |
433 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); | 433 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); |
434 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); | 434 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); |
435 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); | 435 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); |
436 | 436 | ||
@@ -530,13 +530,13 @@ VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) | |||
530 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); | 530 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); |
531 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); | 531 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); |
532 | 532 | ||
533 | return vcard; | 533 | return vcard; |
534 | } | 534 | } |
535 | 535 | ||
536 | QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const | 536 | QString OPimContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const |
537 | { | 537 | { |
538 | QString str_rfc2425 = QString("%1-%2-%3") | 538 | QString str_rfc2425 = QString("%1-%2-%3") |
539 | .arg( d.year() ) | 539 | .arg( d.year() ) |
540 | .arg( d.month(), 2 ) | 540 | .arg( d.month(), 2 ) |
541 | .arg( d.day(), 2 ); | 541 | .arg( d.day(), 2 ); |
542 | // Now replace spaces with "0"... | 542 | // Now replace spaces with "0"... |
@@ -544,13 +544,13 @@ QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const | |||
544 | while ( ( pos = str_rfc2425.find (' ') ) > 0 ) | 544 | while ( ( pos = str_rfc2425.find (' ') ) > 0 ) |
545 | str_rfc2425.replace( pos, 1, "0" ); | 545 | str_rfc2425.replace( pos, 1, "0" ); |
546 | 546 | ||
547 | return str_rfc2425; | 547 | return str_rfc2425; |
548 | } | 548 | } |
549 | 549 | ||
550 | QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) | 550 | QDate OPimContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) |
551 | { | 551 | { |
552 | int monthPos = datestr.find('-'); | 552 | int monthPos = datestr.find('-'); |
553 | int dayPos = datestr.find('-', monthPos+1 ); | 553 | int dayPos = datestr.find('-', monthPos+1 ); |
554 | int sep_ignore = 1; | 554 | int sep_ignore = 1; |
555 | if ( monthPos == -1 || dayPos == -1 ) { | 555 | if ( monthPos == -1 || dayPos == -1 ) { |
556 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); | 556 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); |
@@ -569,21 +569,21 @@ QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) | |||
569 | int d = datestr.mid( dayPos + sep_ignore ).toInt(); | 569 | int d = datestr.mid( dayPos + sep_ignore ).toInt(); |
570 | qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); | 570 | qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); |
571 | QDate date ( y,m,d ); | 571 | QDate date ( y,m,d ); |
572 | return date; | 572 | return date; |
573 | } | 573 | } |
574 | 574 | ||
575 | VObject* OContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value ) | 575 | VObject* OPimContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value ) |
576 | { | 576 | { |
577 | VObject *ret = 0; | 577 | VObject *ret = 0; |
578 | if ( o && !value.isEmpty() ) | 578 | if ( o && !value.isEmpty() ) |
579 | ret = addPropValue( o, prop, value.latin1() ); | 579 | ret = addPropValue( o, prop, value.latin1() ); |
580 | return ret; | 580 | return ret; |
581 | } | 581 | } |
582 | 582 | ||
583 | VObject* OContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop) | 583 | VObject* OPimContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop) |
584 | { | 584 | { |
585 | VObject *ret = 0; | 585 | VObject *ret = 0; |
586 | if ( o ) | 586 | if ( o ) |
587 | ret = addProp( o, prop ); | 587 | ret = addProp( o, prop ); |
588 | return ret; | 588 | return ret; |
589 | } | 589 | } |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h index 11be027..2a786af 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h | |||
@@ -29,57 +29,57 @@ | |||
29 | /* | 29 | /* |
30 | * VCard Backend for the OPIE-Contact Database. | 30 | * VCard Backend for the OPIE-Contact Database. |
31 | */ | 31 | */ |
32 | #ifndef __OCONTACTACCESSBACKEND_VCARD_H_ | 32 | #ifndef __OCONTACTACCESSBACKEND_VCARD_H_ |
33 | #define __OCONTACTACCESSBACKEND_VCARD_H_ | 33 | #define __OCONTACTACCESSBACKEND_VCARD_H_ |
34 | 34 | ||
35 | #include <opie2/ocontact.h> | 35 | #include <opie2/opimcontact.h> |
36 | 36 | ||
37 | #include <opie2/ocontactaccessbackend.h> | 37 | #include <opie2/ocontactaccessbackend.h> |
38 | 38 | ||
39 | class VObject; | 39 | class VObject; |
40 | 40 | ||
41 | namespace Opie { | 41 | namespace Opie { |
42 | /** | 42 | /** |
43 | * This is the vCard 2.1 implementation of the Contact Storage | 43 | * This is the vCard 2.1 implementation of the Contact Storage |
44 | * @see OContactAccessBackend_XML | 44 | * @see OPimContactAccessBackend_XML |
45 | * @see OPimAccessBackend | 45 | * @see OPimAccessBackend |
46 | */ | 46 | */ |
47 | class OContactAccessBackend_VCard : public OContactAccessBackend { | 47 | class OPimContactAccessBackend_VCard : public OPimContactAccessBackend { |
48 | public: | 48 | public: |
49 | OContactAccessBackend_VCard ( const QString& appname, const QString& filename = QString::null ); | 49 | OPimContactAccessBackend_VCard ( const QString& appname, const QString& filename = QString::null ); |
50 | 50 | ||
51 | bool load (); | 51 | bool load (); |
52 | bool reload(); | 52 | bool reload(); |
53 | bool save(); | 53 | bool save(); |
54 | void clear (); | 54 | void clear (); |
55 | 55 | ||
56 | bool add ( const OContact& newcontact ); | 56 | bool add ( const OPimContact& newcontact ); |
57 | bool remove ( int uid ); | 57 | bool remove ( int uid ); |
58 | bool replace ( const OContact& contact ); | 58 | bool replace ( const OPimContact& contact ); |
59 | 59 | ||
60 | OContact find ( int uid ) const; | 60 | OPimContact find ( int uid ) const; |
61 | QArray<int> allRecords() const; | 61 | QArray<int> allRecords() const; |
62 | QArray<int> queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() ); | 62 | QArray<int> queryByExample ( const OPimContact &query, int settings, const QDateTime& d = QDateTime() ); |
63 | QArray<int> matchRegexp( const QRegExp &r ) const; | 63 | QArray<int> matchRegexp( const QRegExp &r ) const; |
64 | 64 | ||
65 | const uint querySettings(); | 65 | const uint querySettings(); |
66 | bool hasQuerySettings (uint querySettings) const; | 66 | bool hasQuerySettings (uint querySettings) const; |
67 | QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ); | 67 | QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ); |
68 | bool wasChangedExternally(); | 68 | bool wasChangedExternally(); |
69 | 69 | ||
70 | private: | 70 | private: |
71 | OContact parseVObject( VObject* obj ); | 71 | OPimContact parseVObject( VObject* obj ); |
72 | VObject* createVObject( const OContact& c ); | 72 | VObject* createVObject( const OPimContact& c ); |
73 | QString convDateToVCardDate( const QDate& c ) const; | 73 | QString convDateToVCardDate( const QDate& c ) const; |
74 | QDate convVCardDateToDate( const QString& datestr ); | 74 | QDate convVCardDateToDate( const QString& datestr ); |
75 | VObject *safeAddPropValue( VObject *o, const char* prop, const QString& value ); | 75 | VObject *safeAddPropValue( VObject *o, const char* prop, const QString& value ); |
76 | VObject *safeAddProp( VObject* o, const char* prop); | 76 | VObject *safeAddProp( VObject* o, const char* prop); |
77 | 77 | ||
78 | bool m_dirty : 1; | 78 | bool m_dirty : 1; |
79 | QString m_file; | 79 | QString m_file; |
80 | QMap<int, OContact> m_map; | 80 | QMap<int, OPimContact> m_map; |
81 | }; | 81 | }; |
82 | 82 | ||
83 | } | 83 | } |
84 | 84 | ||
85 | #endif | 85 | #endif |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp index 07ad29a..0adba68 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp | |||
@@ -51,13 +51,13 @@ | |||
51 | #include <errno.h> | 51 | #include <errno.h> |
52 | 52 | ||
53 | using namespace Opie; | 53 | using namespace Opie; |
54 | 54 | ||
55 | 55 | ||
56 | namespace Opie { | 56 | namespace Opie { |
57 | OContactAccessBackend_XML::OContactAccessBackend_XML ( const QString& appname, const QString& filename ): | 57 | OPimContactAccessBackend_XML::OPimContactAccessBackend_XML ( const QString& appname, const QString& filename ): |
58 | m_changed( false ) | 58 | m_changed( false ) |
59 | { | 59 | { |
60 | // Just m_contactlist should call delete if an entry | 60 | // Just m_contactlist should call delete if an entry |
61 | // is removed. | 61 | // is removed. |
62 | m_contactList.setAutoDelete( true ); | 62 | m_contactList.setAutoDelete( true ); |
63 | m_uidToContact.setAutoDelete( false ); | 63 | m_uidToContact.setAutoDelete( false ); |
@@ -75,13 +75,13 @@ OContactAccessBackend_XML::OContactAccessBackend_XML ( const QString& appname, c | |||
75 | m_fileName = filename; | 75 | m_fileName = filename; |
76 | 76 | ||
77 | /* Load Database now */ | 77 | /* Load Database now */ |
78 | load (); | 78 | load (); |
79 | } | 79 | } |
80 | 80 | ||
81 | bool OContactAccessBackend_XML::save() | 81 | bool OPimContactAccessBackend_XML::save() |
82 | { | 82 | { |
83 | 83 | ||
84 | if ( !m_changed ) | 84 | if ( !m_changed ) |
85 | return true; | 85 | return true; |
86 | 86 | ||
87 | QString strNewFile = m_fileName + ".new"; | 87 | QString strNewFile = m_fileName + ".new"; |
@@ -101,13 +101,13 @@ bool OContactAccessBackend_XML::save() | |||
101 | QCString cstr = out.utf8(); | 101 | QCString cstr = out.utf8(); |
102 | f.writeBlock( cstr.data(), cstr.length() ); | 102 | f.writeBlock( cstr.data(), cstr.length() ); |
103 | idx_offset += cstr.length(); | 103 | idx_offset += cstr.length(); |
104 | out = ""; | 104 | out = ""; |
105 | 105 | ||
106 | // Write all contacts | 106 | // Write all contacts |
107 | QListIterator<OContact> it( m_contactList ); | 107 | QListIterator<OPimContact> it( m_contactList ); |
108 | for ( ; it.current(); ++it ) { | 108 | for ( ; it.current(); ++it ) { |
109 | // qWarning(" Uid %d at Offset: %x", (*it)->uid(), idx_offset ); | 109 | // qWarning(" Uid %d at Offset: %x", (*it)->uid(), idx_offset ); |
110 | out += "<Contact "; | 110 | out += "<Contact "; |
111 | (*it)->save( out ); | 111 | (*it)->save( out ); |
112 | out += "/>\n"; | 112 | out += "/>\n"; |
113 | cstr = out.utf8(); | 113 | cstr = out.utf8(); |
@@ -145,13 +145,13 @@ bool OContactAccessBackend_XML::save() | |||
145 | removeJournal(); | 145 | removeJournal(); |
146 | 146 | ||
147 | m_changed = false; | 147 | m_changed = false; |
148 | return true; | 148 | return true; |
149 | } | 149 | } |
150 | 150 | ||
151 | bool OContactAccessBackend_XML::load () | 151 | bool OPimContactAccessBackend_XML::load () |
152 | { | 152 | { |
153 | m_contactList.clear(); | 153 | m_contactList.clear(); |
154 | m_uidToContact.clear(); | 154 | m_uidToContact.clear(); |
155 | 155 | ||
156 | /* Load XML-File and journal if it exists */ | 156 | /* Load XML-File and journal if it exists */ |
157 | if ( !load ( m_fileName, false ) ) | 157 | if ( !load ( m_fileName, false ) ) |
@@ -164,61 +164,61 @@ bool OContactAccessBackend_XML::load () | |||
164 | */ | 164 | */ |
165 | load (m_journalName, true); | 165 | load (m_journalName, true); |
166 | 166 | ||
167 | return true; | 167 | return true; |
168 | } | 168 | } |
169 | 169 | ||
170 | void OContactAccessBackend_XML::clear () | 170 | void OPimContactAccessBackend_XML::clear () |
171 | { | 171 | { |
172 | m_contactList.clear(); | 172 | m_contactList.clear(); |
173 | m_uidToContact.clear(); | 173 | m_uidToContact.clear(); |
174 | 174 | ||
175 | m_changed = false; | 175 | m_changed = false; |
176 | } | 176 | } |
177 | 177 | ||
178 | bool OContactAccessBackend_XML::wasChangedExternally() | 178 | bool OPimContactAccessBackend_XML::wasChangedExternally() |
179 | { | 179 | { |
180 | QFileInfo fi( m_fileName ); | 180 | QFileInfo fi( m_fileName ); |
181 | 181 | ||
182 | QDateTime lastmod = fi.lastModified (); | 182 | QDateTime lastmod = fi.lastModified (); |
183 | 183 | ||
184 | return (lastmod != m_readtime); | 184 | return (lastmod != m_readtime); |
185 | } | 185 | } |
186 | 186 | ||
187 | QArray<int> OContactAccessBackend_XML::allRecords() const | 187 | QArray<int> OPimContactAccessBackend_XML::allRecords() const |
188 | { | 188 | { |
189 | QArray<int> uid_list( m_contactList.count() ); | 189 | QArray<int> uid_list( m_contactList.count() ); |
190 | 190 | ||
191 | uint counter = 0; | 191 | uint counter = 0; |
192 | QListIterator<OContact> it( m_contactList ); | 192 | QListIterator<OPimContact> it( m_contactList ); |
193 | for( ; it.current(); ++it ){ | 193 | for( ; it.current(); ++it ){ |
194 | uid_list[counter++] = (*it)->uid(); | 194 | uid_list[counter++] = (*it)->uid(); |
195 | } | 195 | } |
196 | 196 | ||
197 | return ( uid_list ); | 197 | return ( uid_list ); |
198 | } | 198 | } |
199 | 199 | ||
200 | OContact OContactAccessBackend_XML::find ( int uid ) const | 200 | OPimContact OPimContactAccessBackend_XML::find ( int uid ) const |
201 | { | 201 | { |
202 | OContact foundContact; //Create empty contact | 202 | OPimContact foundContact; //Create empty contact |
203 | 203 | ||
204 | OContact* found = m_uidToContact.find( QString().setNum( uid ) ); | 204 | OPimContact* found = m_uidToContact.find( QString().setNum( uid ) ); |
205 | 205 | ||
206 | if ( found ){ | 206 | if ( found ){ |
207 | foundContact = *found; | 207 | foundContact = *found; |
208 | } | 208 | } |
209 | 209 | ||
210 | return ( foundContact ); | 210 | return ( foundContact ); |
211 | } | 211 | } |
212 | 212 | ||
213 | QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, int settings, | 213 | QArray<int> OPimContactAccessBackend_XML::queryByExample ( const OPimContact &query, int settings, |
214 | const QDateTime& d ) | 214 | const QDateTime& d ) |
215 | { | 215 | { |
216 | 216 | ||
217 | QArray<int> m_currentQuery( m_contactList.count() ); | 217 | QArray<int> m_currentQuery( m_contactList.count() ); |
218 | QListIterator<OContact> it( m_contactList ); | 218 | QListIterator<OPimContact> it( m_contactList ); |
219 | uint arraycounter = 0; | 219 | uint arraycounter = 0; |
220 | 220 | ||
221 | for( ; it.current(); ++it ){ | 221 | for( ; it.current(); ++it ){ |
222 | /* Search all fields and compare them with query object. Store them into list | 222 | /* Search all fields and compare them with query object. Store them into list |
223 | * if all fields matches. | 223 | * if all fields matches. |
224 | */ | 224 | */ |
@@ -237,25 +237,25 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i | |||
237 | queryDate = new QDate( query.anniversary() ); | 237 | queryDate = new QDate( query.anniversary() ); |
238 | checkDate = new QDate( (*it)->anniversary() ); | 238 | checkDate = new QDate( (*it)->anniversary() ); |
239 | } | 239 | } |
240 | 240 | ||
241 | if ( queryDate->isValid() ){ | 241 | if ( queryDate->isValid() ){ |
242 | if( checkDate->isValid() ){ | 242 | if( checkDate->isValid() ){ |
243 | if ( settings & OContactAccess::DateYear ){ | 243 | if ( settings & OPimContactAccess::DateYear ){ |
244 | if ( queryDate->year() != checkDate->year() ) | 244 | if ( queryDate->year() != checkDate->year() ) |
245 | allcorrect = false; | 245 | allcorrect = false; |
246 | } | 246 | } |
247 | if ( settings & OContactAccess::DateMonth ){ | 247 | if ( settings & OPimContactAccess::DateMonth ){ |
248 | if ( queryDate->month() != checkDate->month() ) | 248 | if ( queryDate->month() != checkDate->month() ) |
249 | allcorrect = false; | 249 | allcorrect = false; |
250 | } | 250 | } |
251 | if ( settings & OContactAccess::DateDay ){ | 251 | if ( settings & OPimContactAccess::DateDay ){ |
252 | if ( queryDate->day() != checkDate->day() ) | 252 | if ( queryDate->day() != checkDate->day() ) |
253 | allcorrect = false; | 253 | allcorrect = false; |
254 | } | 254 | } |
255 | if ( settings & OContactAccess::DateDiff ) { | 255 | if ( settings & OPimContactAccess::DateDiff ) { |
256 | QDate current; | 256 | QDate current; |
257 | // If we get an additional date, we | 257 | // If we get an additional date, we |
258 | // will take this date instead of | 258 | // will take this date instead of |
259 | // the current one.. | 259 | // the current one.. |
260 | if ( !d.date().isValid() ) | 260 | if ( !d.date().isValid() ) |
261 | current = QDate::currentDate(); | 261 | current = QDate::currentDate(); |
@@ -298,38 +298,38 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i | |||
298 | delete checkDate; | 298 | delete checkDate; |
299 | checkDate = 0l; | 299 | checkDate = 0l; |
300 | break; | 300 | break; |
301 | default: | 301 | default: |
302 | /* Just compare fields which are not empty in the query object */ | 302 | /* Just compare fields which are not empty in the query object */ |
303 | if ( !query.field(i).isEmpty() ){ | 303 | if ( !query.field(i).isEmpty() ){ |
304 | switch ( settings & ~( OContactAccess::IgnoreCase | 304 | switch ( settings & ~( OPimContactAccess::IgnoreCase |
305 | | OContactAccess::DateDiff | 305 | | OPimContactAccess::DateDiff |
306 | | OContactAccess::DateYear | 306 | | OPimContactAccess::DateYear |
307 | | OContactAccess::DateMonth | 307 | | OPimContactAccess::DateMonth |
308 | | OContactAccess::DateDay | 308 | | OPimContactAccess::DateDay |
309 | | OContactAccess::MatchOne | 309 | | OPimContactAccess::MatchOne |
310 | ) ){ | 310 | ) ){ |
311 | 311 | ||
312 | case OContactAccess::RegExp:{ | 312 | case OPimContactAccess::RegExp:{ |
313 | QRegExp expr ( query.field(i), | 313 | QRegExp expr ( query.field(i), |
314 | !(settings & OContactAccess::IgnoreCase), | 314 | !(settings & OPimContactAccess::IgnoreCase), |
315 | false ); | 315 | false ); |
316 | if ( expr.find ( (*it)->field(i), 0 ) == -1 ) | 316 | if ( expr.find ( (*it)->field(i), 0 ) == -1 ) |
317 | allcorrect = false; | 317 | allcorrect = false; |
318 | } | 318 | } |
319 | break; | 319 | break; |
320 | case OContactAccess::WildCards:{ | 320 | case OPimContactAccess::WildCards:{ |
321 | QRegExp expr ( query.field(i), | 321 | QRegExp expr ( query.field(i), |
322 | !(settings & OContactAccess::IgnoreCase), | 322 | !(settings & OPimContactAccess::IgnoreCase), |
323 | true ); | 323 | true ); |
324 | if ( expr.find ( (*it)->field(i), 0 ) == -1 ) | 324 | if ( expr.find ( (*it)->field(i), 0 ) == -1 ) |
325 | allcorrect = false; | 325 | allcorrect = false; |
326 | } | 326 | } |
327 | break; | 327 | break; |
328 | case OContactAccess::ExactMatch:{ | 328 | case OPimContactAccess::ExactMatch:{ |
329 | if (settings & OContactAccess::IgnoreCase){ | 329 | if (settings & OPimContactAccess::IgnoreCase){ |
330 | if ( query.field(i).upper() != | 330 | if ( query.field(i).upper() != |
331 | (*it)->field(i).upper() ) | 331 | (*it)->field(i).upper() ) |
332 | allcorrect = false; | 332 | allcorrect = false; |
333 | }else{ | 333 | }else{ |
334 | if ( query.field(i) != (*it)->field(i) ) | 334 | if ( query.field(i) != (*it)->field(i) ) |
335 | allcorrect = false; | 335 | allcorrect = false; |
@@ -348,16 +348,16 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i | |||
348 | // Shrink to fit.. | 348 | // Shrink to fit.. |
349 | m_currentQuery.resize(arraycounter); | 349 | m_currentQuery.resize(arraycounter); |
350 | 350 | ||
351 | return m_currentQuery; | 351 | return m_currentQuery; |
352 | } | 352 | } |
353 | 353 | ||
354 | QArray<int> OContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const | 354 | QArray<int> OPimContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const |
355 | { | 355 | { |
356 | QArray<int> m_currentQuery( m_contactList.count() ); | 356 | QArray<int> m_currentQuery( m_contactList.count() ); |
357 | QListIterator<OContact> it( m_contactList ); | 357 | QListIterator<OPimContact> it( m_contactList ); |
358 | uint arraycounter = 0; | 358 | uint arraycounter = 0; |
359 | 359 | ||
360 | for( ; it.current(); ++it ){ | 360 | for( ; it.current(); ++it ){ |
361 | if ( (*it)->match( r ) ){ | 361 | if ( (*it)->match( r ) ){ |
362 | m_currentQuery[arraycounter++] = (*it)->uid(); | 362 | m_currentQuery[arraycounter++] = (*it)->uid(); |
363 | } | 363 | } |
@@ -366,82 +366,82 @@ QArray<int> OContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const | |||
366 | // Shrink to fit.. | 366 | // Shrink to fit.. |
367 | m_currentQuery.resize(arraycounter); | 367 | m_currentQuery.resize(arraycounter); |
368 | 368 | ||
369 | return m_currentQuery; | 369 | return m_currentQuery; |
370 | } | 370 | } |
371 | 371 | ||
372 | const uint OContactAccessBackend_XML::querySettings() | 372 | const uint OPimContactAccessBackend_XML::querySettings() |
373 | { | 373 | { |
374 | return ( OContactAccess::WildCards | 374 | return ( OPimContactAccess::WildCards |
375 | | OContactAccess::IgnoreCase | 375 | | OPimContactAccess::IgnoreCase |
376 | | OContactAccess::RegExp | 376 | | OPimContactAccess::RegExp |
377 | | OContactAccess::ExactMatch | 377 | | OPimContactAccess::ExactMatch |
378 | | OContactAccess::DateDiff | 378 | | OPimContactAccess::DateDiff |
379 | | OContactAccess::DateYear | 379 | | OPimContactAccess::DateYear |
380 | | OContactAccess::DateMonth | 380 | | OPimContactAccess::DateMonth |
381 | | OContactAccess::DateDay | 381 | | OPimContactAccess::DateDay |
382 | ); | 382 | ); |
383 | } | 383 | } |
384 | 384 | ||
385 | bool OContactAccessBackend_XML::hasQuerySettings (uint querySettings) const | 385 | bool OPimContactAccessBackend_XML::hasQuerySettings (uint querySettings) const |
386 | { | 386 | { |
387 | /* OContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay | 387 | /* OPimContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay |
388 | * may be added with any of the other settings. IgnoreCase should never used alone. | 388 | * may be added with any of the other settings. IgnoreCase should never used alone. |
389 | * Wildcards, RegExp, ExactMatch should never used at the same time... | 389 | * Wildcards, RegExp, ExactMatch should never used at the same time... |
390 | */ | 390 | */ |
391 | 391 | ||
392 | // Step 1: Check whether the given settings are supported by this backend | 392 | // Step 1: Check whether the given settings are supported by this backend |
393 | if ( ( querySettings & ( | 393 | if ( ( querySettings & ( |
394 | OContactAccess::IgnoreCase | 394 | OPimContactAccess::IgnoreCase |
395 | | OContactAccess::WildCards | 395 | | OPimContactAccess::WildCards |
396 | | OContactAccess::DateDiff | 396 | | OPimContactAccess::DateDiff |
397 | | OContactAccess::DateYear | 397 | | OPimContactAccess::DateYear |
398 | | OContactAccess::DateMonth | 398 | | OPimContactAccess::DateMonth |
399 | | OContactAccess::DateDay | 399 | | OPimContactAccess::DateDay |
400 | | OContactAccess::RegExp | 400 | | OPimContactAccess::RegExp |
401 | | OContactAccess::ExactMatch | 401 | | OPimContactAccess::ExactMatch |
402 | ) ) != querySettings ) | 402 | ) ) != querySettings ) |
403 | return false; | 403 | return false; |
404 | 404 | ||
405 | // Step 2: Check whether the given combinations are ok.. | 405 | // Step 2: Check whether the given combinations are ok.. |
406 | 406 | ||
407 | // IngoreCase alone is invalid | 407 | // IngoreCase alone is invalid |
408 | if ( querySettings == OContactAccess::IgnoreCase ) | 408 | if ( querySettings == OPimContactAccess::IgnoreCase ) |
409 | return false; | 409 | return false; |
410 | 410 | ||
411 | // WildCards, RegExp and ExactMatch should never used at the same time | 411 | // WildCards, RegExp and ExactMatch should never used at the same time |
412 | switch ( querySettings & ~( OContactAccess::IgnoreCase | 412 | switch ( querySettings & ~( OPimContactAccess::IgnoreCase |
413 | | OContactAccess::DateDiff | 413 | | OPimContactAccess::DateDiff |
414 | | OContactAccess::DateYear | 414 | | OPimContactAccess::DateYear |
415 | | OContactAccess::DateMonth | 415 | | OPimContactAccess::DateMonth |
416 | | OContactAccess::DateDay | 416 | | OPimContactAccess::DateDay |
417 | ) | 417 | ) |
418 | ){ | 418 | ){ |
419 | case OContactAccess::RegExp: | 419 | case OPimContactAccess::RegExp: |
420 | return ( true ); | 420 | return ( true ); |
421 | case OContactAccess::WildCards: | 421 | case OPimContactAccess::WildCards: |
422 | return ( true ); | 422 | return ( true ); |
423 | case OContactAccess::ExactMatch: | 423 | case OPimContactAccess::ExactMatch: |
424 | return ( true ); | 424 | return ( true ); |
425 | case 0: // one of the upper removed bits were set.. | 425 | case 0: // one of the upper removed bits were set.. |
426 | return ( true ); | 426 | return ( true ); |
427 | default: | 427 | default: |
428 | return ( false ); | 428 | return ( false ); |
429 | } | 429 | } |
430 | } | 430 | } |
431 | 431 | ||
432 | // Currently only asc implemented.. | 432 | // Currently only asc implemented.. |
433 | QArray<int> OContactAccessBackend_XML::sorted( bool asc, int , int , int ) | 433 | QArray<int> OPimContactAccessBackend_XML::sorted( bool asc, int , int , int ) |
434 | { | 434 | { |
435 | QMap<QString, int> nameToUid; | 435 | QMap<QString, int> nameToUid; |
436 | QStringList names; | 436 | QStringList names; |
437 | QArray<int> m_currentQuery( m_contactList.count() ); | 437 | QArray<int> m_currentQuery( m_contactList.count() ); |
438 | 438 | ||
439 | // First fill map and StringList with all Names | 439 | // First fill map and StringList with all Names |
440 | // Afterwards sort namelist and use map to fill array to return.. | 440 | // Afterwards sort namelist and use map to fill array to return.. |
441 | QListIterator<OContact> it( m_contactList ); | 441 | QListIterator<OPimContact> it( m_contactList ); |
442 | for( ; it.current(); ++it ){ | 442 | for( ; it.current(); ++it ){ |
443 | names.append( (*it)->fileAs() + QString::number( (*it)->uid() ) ); | 443 | names.append( (*it)->fileAs() + QString::number( (*it)->uid() ) ); |
444 | nameToUid.insert( (*it)->fileAs() + QString::number( (*it)->uid() ), (*it)->uid() ); | 444 | nameToUid.insert( (*it)->fileAs() + QString::number( (*it)->uid() ), (*it)->uid() ); |
445 | } | 445 | } |
446 | names.sort(); | 446 | names.sort(); |
447 | 447 | ||
@@ -455,31 +455,31 @@ QArray<int> OContactAccessBackend_XML::sorted( bool asc, int , int , int ) | |||
455 | } | 455 | } |
456 | 456 | ||
457 | return m_currentQuery; | 457 | return m_currentQuery; |
458 | 458 | ||
459 | } | 459 | } |
460 | 460 | ||
461 | bool OContactAccessBackend_XML::add ( const OContact &newcontact ) | 461 | bool OPimContactAccessBackend_XML::add ( const OPimContact &newcontact ) |
462 | { | 462 | { |
463 | //qWarning("odefaultbackend: ACTION::ADD"); | 463 | //qWarning("odefaultbackend: ACTION::ADD"); |
464 | updateJournal (newcontact, ACTION_ADD); | 464 | updateJournal (newcontact, ACTION_ADD); |
465 | addContact_p( newcontact ); | 465 | addContact_p( newcontact ); |
466 | 466 | ||
467 | m_changed = true; | 467 | m_changed = true; |
468 | 468 | ||
469 | return true; | 469 | return true; |
470 | } | 470 | } |
471 | 471 | ||
472 | bool OContactAccessBackend_XML::replace ( const OContact &contact ) | 472 | bool OPimContactAccessBackend_XML::replace ( const OPimContact &contact ) |
473 | { | 473 | { |
474 | m_changed = true; | 474 | m_changed = true; |
475 | 475 | ||
476 | OContact* found = m_uidToContact.find ( QString().setNum( contact.uid() ) ); | 476 | OPimContact* found = m_uidToContact.find ( QString().setNum( contact.uid() ) ); |
477 | 477 | ||
478 | if ( found ) { | 478 | if ( found ) { |
479 | OContact* newCont = new OContact( contact ); | 479 | OPimContact* newCont = new OPimContact( contact ); |
480 | 480 | ||
481 | updateJournal ( *newCont, ACTION_REPLACE); | 481 | updateJournal ( *newCont, ACTION_REPLACE); |
482 | m_contactList.removeRef ( found ); | 482 | m_contactList.removeRef ( found ); |
483 | m_contactList.append ( newCont ); | 483 | m_contactList.append ( newCont ); |
484 | m_uidToContact.remove( QString().setNum( contact.uid() ) ); | 484 | m_uidToContact.remove( QString().setNum( contact.uid() ) ); |
485 | m_uidToContact.insert( QString().setNum( newCont->uid() ), newCont ); | 485 | m_uidToContact.insert( QString().setNum( newCont->uid() ), newCont ); |
@@ -488,43 +488,43 @@ bool OContactAccessBackend_XML::replace ( const OContact &contact ) | |||
488 | 488 | ||
489 | return true; | 489 | return true; |
490 | } else | 490 | } else |
491 | return false; | 491 | return false; |
492 | } | 492 | } |
493 | 493 | ||
494 | bool OContactAccessBackend_XML::remove ( int uid ) | 494 | bool OPimContactAccessBackend_XML::remove ( int uid ) |
495 | { | 495 | { |
496 | m_changed = true; | 496 | m_changed = true; |
497 | 497 | ||
498 | OContact* found = m_uidToContact.find ( QString().setNum( uid ) ); | 498 | OPimContact* found = m_uidToContact.find ( QString().setNum( uid ) ); |
499 | 499 | ||
500 | if ( found ) { | 500 | if ( found ) { |
501 | updateJournal ( *found, ACTION_REMOVE); | 501 | updateJournal ( *found, ACTION_REMOVE); |
502 | m_contactList.removeRef ( found ); | 502 | m_contactList.removeRef ( found ); |
503 | m_uidToContact.remove( QString().setNum( uid ) ); | 503 | m_uidToContact.remove( QString().setNum( uid ) ); |
504 | 504 | ||
505 | return true; | 505 | return true; |
506 | } else | 506 | } else |
507 | return false; | 507 | return false; |
508 | } | 508 | } |
509 | 509 | ||
510 | bool OContactAccessBackend_XML::reload(){ | 510 | bool OPimContactAccessBackend_XML::reload(){ |
511 | /* Reload is the same as load in this implementation */ | 511 | /* Reload is the same as load in this implementation */ |
512 | return ( load() ); | 512 | return ( load() ); |
513 | } | 513 | } |
514 | 514 | ||
515 | void OContactAccessBackend_XML::addContact_p( const OContact &newcontact ) | 515 | void OPimContactAccessBackend_XML::addContact_p( const OPimContact &newcontact ) |
516 | { | 516 | { |
517 | OContact* contRef = new OContact( newcontact ); | 517 | OPimContact* contRef = new OPimContact( newcontact ); |
518 | 518 | ||
519 | m_contactList.append ( contRef ); | 519 | m_contactList.append ( contRef ); |
520 | m_uidToContact.insert( QString().setNum( newcontact.uid() ), contRef ); | 520 | m_uidToContact.insert( QString().setNum( newcontact.uid() ), contRef ); |
521 | } | 521 | } |
522 | 522 | ||
523 | /* This function loads the xml-database and the journalfile */ | 523 | /* This function loads the xml-database and the journalfile */ |
524 | bool OContactAccessBackend_XML::load( const QString filename, bool isJournal ) | 524 | bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal ) |
525 | { | 525 | { |
526 | 526 | ||
527 | /* We use the time of the last read to check if the file was | 527 | /* We use the time of the last read to check if the file was |
528 | * changed externally. | 528 | * changed externally. |
529 | */ | 529 | */ |
530 | if ( !isJournal ){ | 530 | if ( !isJournal ){ |
@@ -587,46 +587,46 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal ) | |||
587 | dict.insert( "Anniversary", new int(Qtopia::Anniversary) ); | 587 | dict.insert( "Anniversary", new int(Qtopia::Anniversary) ); |
588 | dict.insert( "Nickname", new int(Qtopia::Nickname) ); | 588 | dict.insert( "Nickname", new int(Qtopia::Nickname) ); |
589 | dict.insert( "Notes", new int(Qtopia::Notes) ); | 589 | dict.insert( "Notes", new int(Qtopia::Notes) ); |
590 | dict.insert( "action", new int(JOURNALACTION) ); | 590 | dict.insert( "action", new int(JOURNALACTION) ); |
591 | dict.insert( "actionrow", new int(JOURNALROW) ); | 591 | dict.insert( "actionrow", new int(JOURNALROW) ); |
592 | 592 | ||
593 | //qWarning( "OContactDefaultBackEnd::loading %s", filename.latin1() ); | 593 | //qWarning( "OPimContactDefaultBackEnd::loading %s", filename.latin1() ); |
594 | 594 | ||
595 | XMLElement *root = XMLElement::load( filename ); | 595 | XMLElement *root = XMLElement::load( filename ); |
596 | if(root != 0l ){ // start parsing | 596 | if(root != 0l ){ // start parsing |
597 | /* Parse all XML-Elements and put the data into the | 597 | /* Parse all XML-Elements and put the data into the |
598 | * Contact-Class | 598 | * Contact-Class |
599 | */ | 599 | */ |
600 | XMLElement *element = root->firstChild(); | 600 | XMLElement *element = root->firstChild(); |
601 | //qWarning("OContactAccess::load tagName(): %s", root->tagName().latin1() ); | 601 | //qWarning("OPimContactAccess::load tagName(): %s", root->tagName().latin1() ); |
602 | element = element->firstChild(); | 602 | element = element->firstChild(); |
603 | 603 | ||
604 | /* Search Tag "Contacts" which is the parent of all Contacts */ | 604 | /* Search Tag "Contacts" which is the parent of all Contacts */ |
605 | while( element && !isJournal ){ | 605 | while( element && !isJournal ){ |
606 | if( element->tagName() != QString::fromLatin1("Contacts") ){ | 606 | if( element->tagName() != QString::fromLatin1("Contacts") ){ |
607 | //qWarning ("OContactDefBack::Searching for Tag \"Contacts\"! Found: %s", | 607 | //qWarning ("OPimContactDefBack::Searching for Tag \"Contacts\"! Found: %s", |
608 | // element->tagName().latin1()); | 608 | // element->tagName().latin1()); |
609 | element = element->nextChild(); | 609 | element = element->nextChild(); |
610 | } else { | 610 | } else { |
611 | element = element->firstChild(); | 611 | element = element->firstChild(); |
612 | break; | 612 | break; |
613 | } | 613 | } |
614 | } | 614 | } |
615 | /* Parse all Contacts and ignore unknown tags */ | 615 | /* Parse all Contacts and ignore unknown tags */ |
616 | while( element ){ | 616 | while( element ){ |
617 | if( element->tagName() != QString::fromLatin1("Contact") ){ | 617 | if( element->tagName() != QString::fromLatin1("Contact") ){ |
618 | //qWarning ("OContactDefBack::Searching for Tag \"Contact\"! Found: %s", | 618 | //qWarning ("OPimContactDefBack::Searching for Tag \"Contact\"! Found: %s", |
619 | // element->tagName().latin1()); | 619 | // element->tagName().latin1()); |
620 | element = element->nextChild(); | 620 | element = element->nextChild(); |
621 | continue; | 621 | continue; |
622 | } | 622 | } |
623 | /* Found alement with tagname "contact", now parse and store all | 623 | /* Found alement with tagname "contact", now parse and store all |
624 | * attributes contained | 624 | * attributes contained |
625 | */ | 625 | */ |
626 | //qWarning("OContactDefBack::load element tagName() : %s", | 626 | //qWarning("OPimContactDefBack::load element tagName() : %s", |
627 | // element->tagName().latin1() ); | 627 | // element->tagName().latin1() ); |
628 | QString dummy; | 628 | QString dummy; |
629 | foundAction = false; | 629 | foundAction = false; |
630 | 630 | ||
631 | XMLElement::AttributeMap aMap = element->attributes(); | 631 | XMLElement::AttributeMap aMap = element->attributes(); |
632 | XMLElement::AttributeMap::Iterator it; | 632 | XMLElement::AttributeMap::Iterator it; |
@@ -667,13 +667,13 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal ) | |||
667 | default: // no conversion needed add them to the map | 667 | default: // no conversion needed add them to the map |
668 | contactMap.insert( *find, it.data() ); | 668 | contactMap.insert( *find, it.data() ); |
669 | break; | 669 | break; |
670 | } | 670 | } |
671 | } | 671 | } |
672 | /* now generate the Contact contact */ | 672 | /* now generate the Contact contact */ |
673 | OContact contact( contactMap ); | 673 | OPimContact contact( contactMap ); |
674 | 674 | ||
675 | for (customIt = customMap.begin(); customIt != customMap.end(); ++customIt ) { | 675 | for (customIt = customMap.begin(); customIt != customMap.end(); ++customIt ) { |
676 | contact.setCustomField( customIt.key(), customIt.data() ); | 676 | contact.setCustomField( customIt.key(), customIt.data() ); |
677 | } | 677 | } |
678 | 678 | ||
679 | if (foundAction){ | 679 | if (foundAction){ |
@@ -710,13 +710,13 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal ) | |||
710 | delete root; | 710 | delete root; |
711 | qWarning("returning from loading" ); | 711 | qWarning("returning from loading" ); |
712 | return true; | 712 | return true; |
713 | } | 713 | } |
714 | 714 | ||
715 | 715 | ||
716 | void OContactAccessBackend_XML::updateJournal( const OContact& cnt, | 716 | void OPimContactAccessBackend_XML::updateJournal( const OPimContact& cnt, |
717 | journal_action action ) | 717 | journal_action action ) |
718 | { | 718 | { |
719 | QFile f( m_journalName ); | 719 | QFile f( m_journalName ); |
720 | bool created = !f.exists(); | 720 | bool created = !f.exists(); |
721 | if ( !f.open(IO_WriteOnly|IO_Append) ) | 721 | if ( !f.open(IO_WriteOnly|IO_Append) ) |
722 | return; | 722 | return; |
@@ -738,13 +738,13 @@ void OContactAccessBackend_XML::updateJournal( const OContact& cnt, | |||
738 | buf += " action=\"" + QString::number( (int)action ) + "\" "; | 738 | buf += " action=\"" + QString::number( (int)action ) + "\" "; |
739 | buf += "/>\n"; | 739 | buf += "/>\n"; |
740 | QCString cstr = buf.utf8(); | 740 | QCString cstr = buf.utf8(); |
741 | f.writeBlock( cstr.data(), cstr.length() ); | 741 | f.writeBlock( cstr.data(), cstr.length() ); |
742 | } | 742 | } |
743 | 743 | ||
744 | void OContactAccessBackend_XML::removeJournal() | 744 | void OPimContactAccessBackend_XML::removeJournal() |
745 | { | 745 | { |
746 | QFile f ( m_journalName ); | 746 | QFile f ( m_journalName ); |
747 | if ( f.exists() ) | 747 | if ( f.exists() ) |
748 | f.remove(); | 748 | f.remove(); |
749 | } | 749 | } |
750 | 750 | ||
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h index f439c4c..eaea352 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h | |||
@@ -27,82 +27,82 @@ | |||
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | /* | 29 | /* |
30 | * XML Backend for the OPIE-Contact Database. | 30 | * XML Backend for the OPIE-Contact Database. |
31 | */ | 31 | */ |
32 | 32 | ||
33 | #ifndef _OContactAccessBackend_XML_ | 33 | #ifndef _OPimContactAccessBackend_XML_ |
34 | #define _OContactAccessBackend_XML_ | 34 | #define _OPimContactAccessBackend_XML_ |
35 | 35 | ||
36 | #include <opie2/ocontactaccessbackend.h> | 36 | #include <opie2/ocontactaccessbackend.h> |
37 | #include <opie2/ocontactaccess.h> | 37 | #include <opie2/ocontactaccess.h> |
38 | 38 | ||
39 | #include <qlist.h> | 39 | #include <qlist.h> |
40 | #include <qdict.h> | 40 | #include <qdict.h> |
41 | 41 | ||
42 | namespace Opie { | 42 | namespace Opie { |
43 | /* the default xml implementation */ | 43 | /* the default xml implementation */ |
44 | /** | 44 | /** |
45 | * This class is the XML implementation of a Contact backend | 45 | * This class is the XML implementation of a Contact backend |
46 | * it does implement everything available for OContact. | 46 | * it does implement everything available for OPimContact. |
47 | * @see OPimAccessBackend for more information of available methods | 47 | * @see OPimAccessBackend for more information of available methods |
48 | */ | 48 | */ |
49 | class OContactAccessBackend_XML : public OContactAccessBackend { | 49 | class OPimContactAccessBackend_XML : public OPimContactAccessBackend { |
50 | public: | 50 | public: |
51 | OContactAccessBackend_XML ( const QString& appname, const QString& filename = QString::null ); | 51 | OPimContactAccessBackend_XML ( const QString& appname, const QString& filename = QString::null ); |
52 | 52 | ||
53 | bool save(); | 53 | bool save(); |
54 | 54 | ||
55 | bool load (); | 55 | bool load (); |
56 | 56 | ||
57 | void clear (); | 57 | void clear (); |
58 | 58 | ||
59 | bool wasChangedExternally(); | 59 | bool wasChangedExternally(); |
60 | 60 | ||
61 | QArray<int> allRecords() const; | 61 | QArray<int> allRecords() const; |
62 | 62 | ||
63 | OContact find ( int uid ) const; | 63 | OPimContact find ( int uid ) const; |
64 | 64 | ||
65 | QArray<int> queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() ); | 65 | QArray<int> queryByExample ( const OPimContact &query, int settings, const QDateTime& d = QDateTime() ); |
66 | 66 | ||
67 | QArray<int> matchRegexp( const QRegExp &r ) const; | 67 | QArray<int> matchRegexp( const QRegExp &r ) const; |
68 | 68 | ||
69 | const uint querySettings(); | 69 | const uint querySettings(); |
70 | 70 | ||
71 | bool hasQuerySettings (uint querySettings) const; | 71 | bool hasQuerySettings (uint querySettings) const; |
72 | 72 | ||
73 | // Currently only asc implemented.. | 73 | // Currently only asc implemented.. |
74 | QArray<int> sorted( bool asc, int , int , int ); | 74 | QArray<int> sorted( bool asc, int , int , int ); |
75 | bool add ( const OContact &newcontact ); | 75 | bool add ( const OPimContact &newcontact ); |
76 | 76 | ||
77 | bool replace ( const OContact &contact ); | 77 | bool replace ( const OPimContact &contact ); |
78 | 78 | ||
79 | bool remove ( int uid ); | 79 | bool remove ( int uid ); |
80 | bool reload(); | 80 | bool reload(); |
81 | 81 | ||
82 | private: | 82 | private: |
83 | 83 | ||
84 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; | 84 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; |
85 | 85 | ||
86 | void addContact_p( const OContact &newcontact ); | 86 | void addContact_p( const OPimContact &newcontact ); |
87 | 87 | ||
88 | /* This function loads the xml-database and the journalfile */ | 88 | /* This function loads the xml-database and the journalfile */ |
89 | bool load( const QString filename, bool isJournal ); | 89 | bool load( const QString filename, bool isJournal ); |
90 | 90 | ||
91 | 91 | ||
92 | void updateJournal( const OContact& cnt, journal_action action ); | 92 | void updateJournal( const OPimContact& cnt, journal_action action ); |
93 | void removeJournal(); | 93 | void removeJournal(); |
94 | 94 | ||
95 | protected: | 95 | protected: |
96 | bool m_changed; | 96 | bool m_changed; |
97 | QString m_journalName; | 97 | QString m_journalName; |
98 | QString m_fileName; | 98 | QString m_fileName; |
99 | QString m_appName; | 99 | QString m_appName; |
100 | QList<OContact> m_contactList; | 100 | QList<OPimContact> m_contactList; |
101 | QDateTime m_readtime; | 101 | QDateTime m_readtime; |
102 | 102 | ||
103 | QDict<OContact> m_uidToContact; | 103 | QDict<OPimContact> m_uidToContact; |
104 | }; | 104 | }; |
105 | 105 | ||
106 | } | 106 | } |
107 | 107 | ||
108 | #endif | 108 | #endif |
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.cpp b/libopie2/opiepim/backend/odatebookaccessbackend.cpp index 9bf4bf0..f3b7b5f 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend.cpp | |||
@@ -25,25 +25,25 @@ | |||
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <qtl.h> | 29 | #include <qtl.h> |
30 | 30 | ||
31 | #include <opie2/orecur.h> | 31 | #include <opie2/opimrecurrence.h> |
32 | 32 | ||
33 | #include <opie2/odatebookaccessbackend.h> | 33 | #include <opie2/odatebookaccessbackend.h> |
34 | 34 | ||
35 | using namespace Opie; | 35 | using namespace Opie; |
36 | 36 | ||
37 | namespace { | 37 | namespace { |
38 | /* a small helper to get all NonRepeating events for a range of time */ | 38 | /* a small helper to get all NonRepeating events for a range of time */ |
39 | void events( OEffectiveEvent::ValueList& tmpList, const OEvent::ValueList& events, | 39 | void events( OEffectiveEvent::ValueList& tmpList, const OPimEvent::ValueList& events, |
40 | const QDate& from, const QDate& to ) { | 40 | const QDate& from, const QDate& to ) { |
41 | QDateTime dtStart, dtEnd; | 41 | QDateTime dtStart, dtEnd; |
42 | 42 | ||
43 | for ( OEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) { | 43 | for ( OPimEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) { |
44 | dtStart = (*it).startDateTime(); | 44 | dtStart = (*it).startDateTime(); |
45 | dtEnd = (*it).endDateTime(); | 45 | dtEnd = (*it).endDateTime(); |
46 | 46 | ||
47 | /* | 47 | /* |
48 | * If in range | 48 | * If in range |
49 | */ | 49 | */ |
@@ -88,19 +88,19 @@ namespace { | |||
88 | dt = dt.addDays( 1 ); | 88 | dt = dt.addDays( 1 ); |
89 | } | 89 | } |
90 | } | 90 | } |
91 | } | 91 | } |
92 | } | 92 | } |
93 | 93 | ||
94 | void repeat( OEffectiveEvent::ValueList& tmpList, const OEvent::ValueList& list, | 94 | void repeat( OEffectiveEvent::ValueList& tmpList, const OPimEvent::ValueList& list, |
95 | const QDate& from, const QDate& to ) { | 95 | const QDate& from, const QDate& to ) { |
96 | QDate repeat; | 96 | QDate repeat; |
97 | for ( OEvent::ValueList::ConstIterator it = list.begin(); it != list.end(); ++it ) { | 97 | for ( OPimEvent::ValueList::ConstIterator it = list.begin(); it != list.end(); ++it ) { |
98 | int dur = (*it).startDateTime().date().daysTo( (*it).endDateTime().date() ); | 98 | int dur = (*it).startDateTime().date().daysTo( (*it).endDateTime().date() ); |
99 | QDate itDate = from.addDays(-dur ); | 99 | QDate itDate = from.addDays(-dur ); |
100 | ORecur rec = (*it).recurrence(); | 100 | OPimRecurrence rec = (*it).recurrence(); |
101 | if ( !rec.hasEndDate() || rec.endDate() > to ) { | 101 | if ( !rec.hasEndDate() || rec.endDate() > to ) { |
102 | rec.setEndDate( to ); | 102 | rec.setEndDate( to ); |
103 | rec.setHasEndDate( true ); | 103 | rec.setHasEndDate( true ); |
104 | } | 104 | } |
105 | while (rec.nextOcurrence(itDate, repeat ) ) { | 105 | while (rec.nextOcurrence(itDate, repeat ) ) { |
106 | if (repeat > to ) break; | 106 | if (repeat > to ) break; |
@@ -149,23 +149,23 @@ namespace { | |||
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||
152 | namespace Opie { | 152 | namespace Opie { |
153 | 153 | ||
154 | ODateBookAccessBackend::ODateBookAccessBackend() | 154 | ODateBookAccessBackend::ODateBookAccessBackend() |
155 | : OPimAccessBackend<OEvent>() | 155 | : OPimAccessBackend<OPimEvent>() |
156 | { | 156 | { |
157 | 157 | ||
158 | } | 158 | } |
159 | ODateBookAccessBackend::~ODateBookAccessBackend() { | 159 | ODateBookAccessBackend::~ODateBookAccessBackend() { |
160 | 160 | ||
161 | } | 161 | } |
162 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDate& from, | 162 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDate& from, |
163 | const QDate& to ) { | 163 | const QDate& to ) { |
164 | OEffectiveEvent::ValueList tmpList; | 164 | OEffectiveEvent::ValueList tmpList; |
165 | OEvent::ValueList list = directNonRepeats(); | 165 | OPimEvent::ValueList list = directNonRepeats(); |
166 | 166 | ||
167 | events( tmpList, list, from, to ); | 167 | events( tmpList, list, from, to ); |
168 | repeat( tmpList, directRawRepeats(),from,to ); | 168 | repeat( tmpList, directRawRepeats(),from,to ); |
169 | 169 | ||
170 | list = directRawRepeats(); // Useless, isn't it ? (eilers) | 170 | list = directRawRepeats(); // Useless, isn't it ? (eilers) |
171 | 171 | ||
@@ -187,13 +187,13 @@ OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDateT | |||
187 | return tmpList; | 187 | return tmpList; |
188 | } | 188 | } |
189 | 189 | ||
190 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDate& from, | 190 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDate& from, |
191 | const QDate& to ) { | 191 | const QDate& to ) { |
192 | OEffectiveEvent::ValueList tmpList; | 192 | OEffectiveEvent::ValueList tmpList; |
193 | OEvent::ValueList list = directNonRepeats(); | 193 | OPimEvent::ValueList list = directNonRepeats(); |
194 | 194 | ||
195 | events( tmpList, list, from, to ); | 195 | events( tmpList, list, from, to ); |
196 | 196 | ||
197 | qHeapSort( tmpList ); | 197 | qHeapSort( tmpList ); |
198 | return tmpList; | 198 | return tmpList; |
199 | } | 199 | } |
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.h b/libopie2/opiepim/backend/odatebookaccessbackend.h index 6853670..a9cce6a 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend.h +++ b/libopie2/opiepim/backend/odatebookaccessbackend.h | |||
@@ -29,21 +29,21 @@ | |||
29 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_H | 29 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_H |
30 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_H | 30 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_H |
31 | 31 | ||
32 | #include <qarray.h> | 32 | #include <qarray.h> |
33 | 33 | ||
34 | #include <opie2/opimaccessbackend.h> | 34 | #include <opie2/opimaccessbackend.h> |
35 | #include <opie2/oevent.h> | 35 | #include <opie2/opimevent.h> |
36 | 36 | ||
37 | namespace Opie { | 37 | namespace Opie { |
38 | /** | 38 | /** |
39 | * This class is the interface to the storage of Events. | 39 | * This class is the interface to the storage of Events. |
40 | * @see OPimAccessBackend | 40 | * @see OPimAccessBackend |
41 | * | 41 | * |
42 | */ | 42 | */ |
43 | class ODateBookAccessBackend : public OPimAccessBackend<OEvent> { | 43 | class ODateBookAccessBackend : public OPimAccessBackend<OPimEvent> { |
44 | public: | 44 | public: |
45 | typedef int UID; | 45 | typedef int UID; |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * c'tor without parameter | 48 | * c'tor without parameter |
49 | */ | 49 | */ |
@@ -73,18 +73,18 @@ public: | |||
73 | 73 | ||
74 | /** | 74 | /** |
75 | * If you do not want to implement the effectiveEvents methods below | 75 | * If you do not want to implement the effectiveEvents methods below |
76 | * you need to supply it with directNonRepeats. | 76 | * you need to supply it with directNonRepeats. |
77 | * This method can return empty lists if effectiveEvents is implememted | 77 | * This method can return empty lists if effectiveEvents is implememted |
78 | */ | 78 | */ |
79 | virtual OEvent::ValueList directNonRepeats() = 0; | 79 | virtual OPimEvent::ValueList directNonRepeats() = 0; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * Same as above but return raw repeats! | 82 | * Same as above but return raw repeats! |
83 | */ | 83 | */ |
84 | virtual OEvent::ValueList directRawRepeats() = 0; | 84 | virtual OPimEvent::ValueList directRawRepeats() = 0; |
85 | 85 | ||
86 | /* is implemented by default but you can reimplement it*/ | 86 | /* is implemented by default but you can reimplement it*/ |
87 | /** | 87 | /** |
88 | * Effective Events are special event occuring during a time frame. This method does calcualte | 88 | * Effective Events are special event occuring during a time frame. This method does calcualte |
89 | * EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method | 89 | * EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method |
90 | * yourself | 90 | * yourself |
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp index e79696c..2ee76cc 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp | |||
@@ -40,13 +40,13 @@ | |||
40 | #include <qpe/global.h> | 40 | #include <qpe/global.h> |
41 | 41 | ||
42 | #include <opie2/osqldriver.h> | 42 | #include <opie2/osqldriver.h> |
43 | #include <opie2/osqlmanager.h> | 43 | #include <opie2/osqlmanager.h> |
44 | #include <opie2/osqlquery.h> | 44 | #include <opie2/osqlquery.h> |
45 | 45 | ||
46 | #include <opie2/orecur.h> | 46 | #include <opie2/opimrecurrence.h> |
47 | #include <opie2/odatebookaccessbackend_sql.h> | 47 | #include <opie2/odatebookaccessbackend_sql.h> |
48 | 48 | ||
49 | namespace Opie { | 49 | namespace Opie { |
50 | 50 | ||
51 | 51 | ||
52 | ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& , | 52 | ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& , |
@@ -72,33 +72,33 @@ ODateBookAccessBackend_SQL::~ODateBookAccessBackend_SQL() { | |||
72 | 72 | ||
73 | void ODateBookAccessBackend_SQL::initFields() | 73 | void ODateBookAccessBackend_SQL::initFields() |
74 | { | 74 | { |
75 | 75 | ||
76 | // This map contains the translation of the fieldtype id's to | 76 | // This map contains the translation of the fieldtype id's to |
77 | // the names of the table columns | 77 | // the names of the table columns |
78 | m_fieldMap.insert( OEvent::FUid, "uid" ); | 78 | m_fieldMap.insert( OPimEvent::FUid, "uid" ); |
79 | m_fieldMap.insert( OEvent::FCategories, "Categories" ); | 79 | m_fieldMap.insert( OPimEvent::FCategories, "Categories" ); |
80 | m_fieldMap.insert( OEvent::FDescription, "Description" ); | 80 | m_fieldMap.insert( OPimEvent::FDescription, "Description" ); |
81 | m_fieldMap.insert( OEvent::FLocation, "Location" ); | 81 | m_fieldMap.insert( OPimEvent::FLocation, "Location" ); |
82 | m_fieldMap.insert( OEvent::FType, "Type" ); | 82 | m_fieldMap.insert( OPimEvent::FType, "Type" ); |
83 | m_fieldMap.insert( OEvent::FAlarm, "Alarm" ); | 83 | m_fieldMap.insert( OPimEvent::FAlarm, "Alarm" ); |
84 | m_fieldMap.insert( OEvent::FSound, "Sound" ); | 84 | m_fieldMap.insert( OPimEvent::FSound, "Sound" ); |
85 | m_fieldMap.insert( OEvent::FRType, "RType" ); | 85 | m_fieldMap.insert( OPimEvent::FRType, "RType" ); |
86 | m_fieldMap.insert( OEvent::FRWeekdays, "RWeekdays" ); | 86 | m_fieldMap.insert( OPimEvent::FRWeekdays, "RWeekdays" ); |
87 | m_fieldMap.insert( OEvent::FRPosition, "RPosition" ); | 87 | m_fieldMap.insert( OPimEvent::FRPosition, "RPosition" ); |
88 | m_fieldMap.insert( OEvent::FRFreq, "RFreq" ); | 88 | m_fieldMap.insert( OPimEvent::FRFreq, "RFreq" ); |
89 | m_fieldMap.insert( OEvent::FRHasEndDate, "RHasEndDate" ); | 89 | m_fieldMap.insert( OPimEvent::FRHasEndDate, "RHasEndDate" ); |
90 | m_fieldMap.insert( OEvent::FREndDate, "REndDate" ); | 90 | m_fieldMap.insert( OPimEvent::FREndDate, "REndDate" ); |
91 | m_fieldMap.insert( OEvent::FRCreated, "RCreated" ); | 91 | m_fieldMap.insert( OPimEvent::FRCreated, "RCreated" ); |
92 | m_fieldMap.insert( OEvent::FRExceptions, "RExceptions" ); | 92 | m_fieldMap.insert( OPimEvent::FRExceptions, "RExceptions" ); |
93 | m_fieldMap.insert( OEvent::FStart, "Start" ); | 93 | m_fieldMap.insert( OPimEvent::FStart, "Start" ); |
94 | m_fieldMap.insert( OEvent::FEnd, "End" ); | 94 | m_fieldMap.insert( OPimEvent::FEnd, "End" ); |
95 | m_fieldMap.insert( OEvent::FNote, "Note" ); | 95 | m_fieldMap.insert( OPimEvent::FNote, "Note" ); |
96 | m_fieldMap.insert( OEvent::FTimeZone, "TimeZone" ); | 96 | m_fieldMap.insert( OPimEvent::FTimeZone, "TimeZone" ); |
97 | m_fieldMap.insert( OEvent::FRecParent, "RecParent" ); | 97 | m_fieldMap.insert( OPimEvent::FRecParent, "RecParent" ); |
98 | m_fieldMap.insert( OEvent::FRecChildren, "Recchildren" ); | 98 | m_fieldMap.insert( OPimEvent::FRecChildren, "Recchildren" ); |
99 | 99 | ||
100 | // Create a map that maps the column name to the id | 100 | // Create a map that maps the column name to the id |
101 | QMapConstIterator<int, QString> it; | 101 | QMapConstIterator<int, QString> it; |
102 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ | 102 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ |
103 | m_reverseFieldMap.insert( it.data(), it.key() ); | 103 | m_reverseFieldMap.insert( it.data(), it.key() ); |
104 | } | 104 | } |
@@ -162,13 +162,13 @@ bool ODateBookAccessBackend_SQL::save() | |||
162 | 162 | ||
163 | QArray<int> ODateBookAccessBackend_SQL::allRecords()const | 163 | QArray<int> ODateBookAccessBackend_SQL::allRecords()const |
164 | { | 164 | { |
165 | return m_uids; | 165 | return m_uids; |
166 | } | 166 | } |
167 | 167 | ||
168 | QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OEvent&, int, const QDateTime& ) { | 168 | QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OPimEvent&, int, const QDateTime& ) { |
169 | return QArray<int>(); | 169 | return QArray<int>(); |
170 | } | 170 | } |
171 | 171 | ||
172 | void ODateBookAccessBackend_SQL::clear() | 172 | void ODateBookAccessBackend_SQL::clear() |
173 | { | 173 | { |
174 | QString qu = "drop table datebook;"; | 174 | QString qu = "drop table datebook;"; |
@@ -178,39 +178,39 @@ void ODateBookAccessBackend_SQL::clear() | |||
178 | OSQLResult res = m_driver->query( &raw ); | 178 | OSQLResult res = m_driver->query( &raw ); |
179 | 179 | ||
180 | reload(); | 180 | reload(); |
181 | } | 181 | } |
182 | 182 | ||
183 | 183 | ||
184 | OEvent ODateBookAccessBackend_SQL::find( int uid ) const{ | 184 | OPimEvent ODateBookAccessBackend_SQL::find( int uid ) const{ |
185 | QString qu = "select *"; | 185 | QString qu = "select *"; |
186 | qu += "from datebook where uid = " + QString::number(uid); | 186 | qu += "from datebook where uid = " + QString::number(uid); |
187 | 187 | ||
188 | OSQLRawQuery raw( qu ); | 188 | OSQLRawQuery raw( qu ); |
189 | OSQLResult res = m_driver->query( &raw ); | 189 | OSQLResult res = m_driver->query( &raw ); |
190 | 190 | ||
191 | OSQLResultItem resItem = res.first(); | 191 | OSQLResultItem resItem = res.first(); |
192 | 192 | ||
193 | // Create Map for date event and insert UID | 193 | // Create Map for date event and insert UID |
194 | QMap<int,QString> dateEventMap; | 194 | QMap<int,QString> dateEventMap; |
195 | dateEventMap.insert( OEvent::FUid, QString::number( uid ) ); | 195 | dateEventMap.insert( OPimEvent::FUid, QString::number( uid ) ); |
196 | 196 | ||
197 | // Now insert the data out of the columns into the map. | 197 | // Now insert the data out of the columns into the map. |
198 | QMapConstIterator<int, QString> it; | 198 | QMapConstIterator<int, QString> it; |
199 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ | 199 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ |
200 | dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) ); | 200 | dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) ); |
201 | } | 201 | } |
202 | 202 | ||
203 | // Last step: Put map into date event and return it | 203 | // Last step: Put map into date event and return it |
204 | OEvent retDate( dateEventMap ); | 204 | OPimEvent retDate( dateEventMap ); |
205 | 205 | ||
206 | return retDate; | 206 | return retDate; |
207 | } | 207 | } |
208 | 208 | ||
209 | // FIXME: Speed up update of uid's.. | 209 | // FIXME: Speed up update of uid's.. |
210 | bool ODateBookAccessBackend_SQL::add( const OEvent& ev ) | 210 | bool ODateBookAccessBackend_SQL::add( const OPimEvent& ev ) |
211 | { | 211 | { |
212 | QMap<int,QString> eventMap = ev.toMap(); | 212 | QMap<int,QString> eventMap = ev.toMap(); |
213 | 213 | ||
214 | QString qu = "insert into datebook VALUES( " + QString::number( ev.uid() ); | 214 | QString qu = "insert into datebook VALUES( " + QString::number( ev.uid() ); |
215 | QMap<int, QString>::Iterator it; | 215 | QMap<int, QString>::Iterator it; |
216 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ | 216 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ |
@@ -269,13 +269,13 @@ bool ODateBookAccessBackend_SQL::remove( int uid ) | |||
269 | // Update list of uid's | 269 | // Update list of uid's |
270 | update(); | 270 | update(); |
271 | 271 | ||
272 | return true; | 272 | return true; |
273 | } | 273 | } |
274 | 274 | ||
275 | bool ODateBookAccessBackend_SQL::replace( const OEvent& ev ) | 275 | bool ODateBookAccessBackend_SQL::replace( const OPimEvent& ev ) |
276 | { | 276 | { |
277 | remove( ev.uid() ); | 277 | remove( ev.uid() ); |
278 | return add( ev ); | 278 | return add( ev ); |
279 | } | 279 | } |
280 | 280 | ||
281 | QArray<int> ODateBookAccessBackend_SQL::rawEvents()const | 281 | QArray<int> ODateBookAccessBackend_SQL::rawEvents()const |
@@ -306,28 +306,28 @@ QArray<int> ODateBookAccessBackend_SQL::nonRepeats()const | |||
306 | return nix; | 306 | return nix; |
307 | } | 307 | } |
308 | 308 | ||
309 | return extractUids( res ); | 309 | return extractUids( res ); |
310 | } | 310 | } |
311 | 311 | ||
312 | OEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats() | 312 | OPimEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats() |
313 | { | 313 | { |
314 | QArray<int> nonRepUids = nonRepeats(); | 314 | QArray<int> nonRepUids = nonRepeats(); |
315 | OEvent::ValueList list; | 315 | OPimEvent::ValueList list; |
316 | 316 | ||
317 | for (uint i = 0; i < nonRepUids.count(); ++i ){ | 317 | for (uint i = 0; i < nonRepUids.count(); ++i ){ |
318 | list.append( find( nonRepUids[i] ) ); | 318 | list.append( find( nonRepUids[i] ) ); |
319 | } | 319 | } |
320 | 320 | ||
321 | return list; | 321 | return list; |
322 | 322 | ||
323 | } | 323 | } |
324 | OEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats() | 324 | OPimEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats() |
325 | { | 325 | { |
326 | QArray<int> rawRepUids = rawRepeats(); | 326 | QArray<int> rawRepUids = rawRepeats(); |
327 | OEvent::ValueList list; | 327 | OPimEvent::ValueList list; |
328 | 328 | ||
329 | for (uint i = 0; i < rawRepUids.count(); ++i ){ | 329 | for (uint i = 0; i < rawRepUids.count(); ++i ){ |
330 | list.append( find( rawRepUids[i] ) ); | 330 | list.append( find( rawRepUids[i] ) ); |
331 | } | 331 | } |
332 | 332 | ||
333 | return list; | 333 | return list; |
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.h b/libopie2/opiepim/backend/odatebookaccessbackend_sql.h index 89939ef..cbfeb97 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.h +++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.h | |||
@@ -52,25 +52,25 @@ public: | |||
52 | bool load(); | 52 | bool load(); |
53 | bool reload(); | 53 | bool reload(); |
54 | bool save(); | 54 | bool save(); |
55 | 55 | ||
56 | QArray<int> allRecords()const; | 56 | QArray<int> allRecords()const; |
57 | QArray<int> matchRegexp(const QRegExp &r) const; | 57 | QArray<int> matchRegexp(const QRegExp &r) const; |
58 | QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); | 58 | QArray<int> queryByExample( const OPimEvent&, int, const QDateTime& d = QDateTime() ); |
59 | OEvent find( int uid )const; | 59 | OPimEvent find( int uid )const; |
60 | void clear(); | 60 | void clear(); |
61 | bool add( const OEvent& ev ); | 61 | bool add( const OPimEvent& ev ); |
62 | bool remove( int uid ); | 62 | bool remove( int uid ); |
63 | bool replace( const OEvent& ev ); | 63 | bool replace( const OPimEvent& ev ); |
64 | 64 | ||
65 | QArray<UID> rawEvents()const; | 65 | QArray<UID> rawEvents()const; |
66 | QArray<UID> rawRepeats()const; | 66 | QArray<UID> rawRepeats()const; |
67 | QArray<UID> nonRepeats()const; | 67 | QArray<UID> nonRepeats()const; |
68 | 68 | ||
69 | OEvent::ValueList directNonRepeats(); | 69 | OPimEvent::ValueList directNonRepeats(); |
70 | OEvent::ValueList directRawRepeats(); | 70 | OPimEvent::ValueList directRawRepeats(); |
71 | 71 | ||
72 | private: | 72 | private: |
73 | bool loadFile(); | 73 | bool loadFile(); |
74 | QString m_fileName; | 74 | QString m_fileName; |
75 | QArray<int> m_uids; | 75 | QArray<int> m_uids; |
76 | 76 | ||
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp index 0ebda98..77c0253 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp | |||
@@ -43,14 +43,14 @@ | |||
43 | 43 | ||
44 | #include <qtopia/global.h> | 44 | #include <qtopia/global.h> |
45 | #include <qtopia/stringutil.h> | 45 | #include <qtopia/stringutil.h> |
46 | #include <qtopia/timeconversion.h> | 46 | #include <qtopia/timeconversion.h> |
47 | 47 | ||
48 | #include <opie2/opimnotifymanager.h> | 48 | #include <opie2/opimnotifymanager.h> |
49 | #include <opie2/orecur.h> | 49 | #include <opie2/opimrecurrence.h> |
50 | #include <opie2/otimezone.h> | 50 | #include <opie2/opimtimezone.h> |
51 | #include <opie2/odatebookaccessbackend_xml.h> | 51 | #include <opie2/odatebookaccessbackend_xml.h> |
52 | 52 | ||
53 | using namespace Opie; | 53 | using namespace Opie; |
54 | 54 | ||
55 | namespace { | 55 | namespace { |
56 | // FROM TT again | 56 | // FROM TT again |
@@ -78,16 +78,16 @@ char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) | |||
78 | return ((char *)hsearch); | 78 | return ((char *)hsearch); |
79 | } | 79 | } |
80 | } | 80 | } |
81 | 81 | ||
82 | namespace { | 82 | namespace { |
83 | time_t start, end, created, rp_end; | 83 | time_t start, end, created, rp_end; |
84 | ORecur* rec; | 84 | OPimRecurrence* rec; |
85 | ORecur* recur() { | 85 | OPimRecurrence* recur() { |
86 | if (!rec) | 86 | if (!rec) |
87 | rec = new ORecur; | 87 | rec = new OPimRecurrence; |
88 | 88 | ||
89 | return rec; | 89 | return rec; |
90 | } | 90 | } |
91 | int alarmTime; | 91 | int alarmTime; |
92 | int snd; | 92 | int snd; |
93 | enum Attribute{ | 93 | enum Attribute{ |
@@ -111,14 +111,14 @@ namespace { | |||
111 | FTimeZone, | 111 | FTimeZone, |
112 | FRecParent, | 112 | FRecParent, |
113 | FRecChildren, | 113 | FRecChildren, |
114 | FExceptions | 114 | FExceptions |
115 | }; | 115 | }; |
116 | 116 | ||
117 | // FIXME: Use OEvent::toMap() here !! (eilers) | 117 | // FIXME: Use OPimEvent::toMap() here !! (eilers) |
118 | inline void save( const OEvent& ev, QString& buf ) { | 118 | inline void save( const OPimEvent& ev, QString& buf ) { |
119 | qWarning("Saving %d %s", ev.uid(), ev.description().latin1() ); | 119 | qWarning("Saving %d %s", ev.uid(), ev.description().latin1() ); |
120 | buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\""; | 120 | buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\""; |
121 | if (!ev.location().isEmpty() ) | 121 | if (!ev.location().isEmpty() ) |
122 | buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\""; | 122 | buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\""; |
123 | 123 | ||
124 | buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\""; | 124 | buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\""; |
@@ -143,15 +143,15 @@ namespace { | |||
143 | 143 | ||
144 | /* | 144 | /* |
145 | * fscking timezones :) well, we'll first convert | 145 | * fscking timezones :) well, we'll first convert |
146 | * the QDateTime to a QDateTime in UTC time | 146 | * the QDateTime to a QDateTime in UTC time |
147 | * and then we'll create a nice time_t | 147 | * and then we'll create a nice time_t |
148 | */ | 148 | */ |
149 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); | 149 | OPimTimeZone zone( ev.timeZone().isEmpty() ? OPimTimeZone::current() : ev.timeZone() ); |
150 | buf += " start=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.startDateTime(), OTimeZone::utc() ) ) ) + "\""; | 150 | buf += " start=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.startDateTime(), OPimTimeZone::utc() ) ) ) + "\""; |
151 | buf += " end=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.endDateTime() , OTimeZone::utc() ) ) ) + "\""; | 151 | buf += " end=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.endDateTime() , OPimTimeZone::utc() ) ) ) + "\""; |
152 | if (!ev.note().isEmpty() ) { | 152 | if (!ev.note().isEmpty() ) { |
153 | buf += " note=\"" + Qtopia::escapeString( ev.note() ) + "\""; | 153 | buf += " note=\"" + Qtopia::escapeString( ev.note() ) + "\""; |
154 | } | 154 | } |
155 | 155 | ||
156 | buf += " timezone=\""; | 156 | buf += " timezone=\""; |
157 | if ( ev.timeZone().isEmpty() ) | 157 | if ( ev.timeZone().isEmpty() ) |
@@ -174,14 +174,14 @@ namespace { | |||
174 | buf+= "\""; | 174 | buf+= "\""; |
175 | } | 175 | } |
176 | 176 | ||
177 | // skip custom writing | 177 | // skip custom writing |
178 | } | 178 | } |
179 | 179 | ||
180 | inline bool forAll( const QMap<int, OEvent>& list, QFile& file ) { | 180 | inline bool forAll( const QMap<int, OPimEvent>& list, QFile& file ) { |
181 | QMap<int, OEvent>::ConstIterator it; | 181 | QMap<int, OPimEvent>::ConstIterator it; |
182 | QString buf; | 182 | QString buf; |
183 | QCString str; | 183 | QCString str; |
184 | int total_written; | 184 | int total_written; |
185 | for ( it = list.begin(); it != list.end(); ++it ) { | 185 | for ( it = list.begin(); it != list.end(); ++it ) { |
186 | buf = "<event"; | 186 | buf = "<event"; |
187 | save( it.data(), buf ); | 187 | save( it.data(), buf ); |
@@ -261,40 +261,40 @@ bool ODateBookAccessBackend_XML::save() { | |||
261 | m_changed = false; | 261 | m_changed = false; |
262 | return true; | 262 | return true; |
263 | } | 263 | } |
264 | QArray<int> ODateBookAccessBackend_XML::allRecords()const { | 264 | QArray<int> ODateBookAccessBackend_XML::allRecords()const { |
265 | QArray<int> ints( m_raw.count()+ m_rep.count() ); | 265 | QArray<int> ints( m_raw.count()+ m_rep.count() ); |
266 | uint i = 0; | 266 | uint i = 0; |
267 | QMap<int, OEvent>::ConstIterator it; | 267 | QMap<int, OPimEvent>::ConstIterator it; |
268 | 268 | ||
269 | for ( it = m_raw.begin(); it != m_raw.end(); ++it ) { | 269 | for ( it = m_raw.begin(); it != m_raw.end(); ++it ) { |
270 | ints[i] = it.key(); | 270 | ints[i] = it.key(); |
271 | i++; | 271 | i++; |
272 | } | 272 | } |
273 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) { | 273 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) { |
274 | ints[i] = it.key(); | 274 | ints[i] = it.key(); |
275 | i++; | 275 | i++; |
276 | } | 276 | } |
277 | 277 | ||
278 | return ints; | 278 | return ints; |
279 | } | 279 | } |
280 | QArray<int> ODateBookAccessBackend_XML::queryByExample(const OEvent&, int, const QDateTime& ) { | 280 | QArray<int> ODateBookAccessBackend_XML::queryByExample(const OPimEvent&, int, const QDateTime& ) { |
281 | return QArray<int>(); | 281 | return QArray<int>(); |
282 | } | 282 | } |
283 | void ODateBookAccessBackend_XML::clear() { | 283 | void ODateBookAccessBackend_XML::clear() { |
284 | m_changed = true; | 284 | m_changed = true; |
285 | m_raw.clear(); | 285 | m_raw.clear(); |
286 | m_rep.clear(); | 286 | m_rep.clear(); |
287 | } | 287 | } |
288 | OEvent ODateBookAccessBackend_XML::find( int uid ) const{ | 288 | OPimEvent ODateBookAccessBackend_XML::find( int uid ) const{ |
289 | if ( m_raw.contains( uid ) ) | 289 | if ( m_raw.contains( uid ) ) |
290 | return m_raw[uid]; | 290 | return m_raw[uid]; |
291 | else | 291 | else |
292 | return m_rep[uid]; | 292 | return m_rep[uid]; |
293 | } | 293 | } |
294 | bool ODateBookAccessBackend_XML::add( const OEvent& ev ) { | 294 | bool ODateBookAccessBackend_XML::add( const OPimEvent& ev ) { |
295 | m_changed = true; | 295 | m_changed = true; |
296 | if (ev.hasRecurrence() ) | 296 | if (ev.hasRecurrence() ) |
297 | m_rep.insert( ev.uid(), ev ); | 297 | m_rep.insert( ev.uid(), ev ); |
298 | else | 298 | else |
299 | m_raw.insert( ev.uid(), ev ); | 299 | m_raw.insert( ev.uid(), ev ); |
300 | 300 | ||
@@ -304,61 +304,61 @@ bool ODateBookAccessBackend_XML::remove( int uid ) { | |||
304 | m_changed = true; | 304 | m_changed = true; |
305 | m_rep.remove( uid ); | 305 | m_rep.remove( uid ); |
306 | m_rep.remove( uid ); | 306 | m_rep.remove( uid ); |
307 | 307 | ||
308 | return true; | 308 | return true; |
309 | } | 309 | } |
310 | bool ODateBookAccessBackend_XML::replace( const OEvent& ev ) { | 310 | bool ODateBookAccessBackend_XML::replace( const OPimEvent& ev ) { |
311 | replace( ev.uid() ); // ??? Shouldn't this be "remove( ev.uid() ) ??? (eilers) | 311 | replace( ev.uid() ); // ??? Shouldn't this be "remove( ev.uid() ) ??? (eilers) |
312 | return add( ev ); | 312 | return add( ev ); |
313 | } | 313 | } |
314 | QArray<int> ODateBookAccessBackend_XML::rawEvents()const { | 314 | QArray<int> ODateBookAccessBackend_XML::rawEvents()const { |
315 | return allRecords(); | 315 | return allRecords(); |
316 | } | 316 | } |
317 | QArray<int> ODateBookAccessBackend_XML::rawRepeats()const { | 317 | QArray<int> ODateBookAccessBackend_XML::rawRepeats()const { |
318 | QArray<int> ints( m_rep.count() ); | 318 | QArray<int> ints( m_rep.count() ); |
319 | uint i = 0; | 319 | uint i = 0; |
320 | QMap<int, OEvent>::ConstIterator it; | 320 | QMap<int, OPimEvent>::ConstIterator it; |
321 | 321 | ||
322 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) { | 322 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) { |
323 | ints[i] = it.key(); | 323 | ints[i] = it.key(); |
324 | i++; | 324 | i++; |
325 | } | 325 | } |
326 | 326 | ||
327 | return ints; | 327 | return ints; |
328 | } | 328 | } |
329 | QArray<int> ODateBookAccessBackend_XML::nonRepeats()const { | 329 | QArray<int> ODateBookAccessBackend_XML::nonRepeats()const { |
330 | QArray<int> ints( m_raw.count() ); | 330 | QArray<int> ints( m_raw.count() ); |
331 | uint i = 0; | 331 | uint i = 0; |
332 | QMap<int, OEvent>::ConstIterator it; | 332 | QMap<int, OPimEvent>::ConstIterator it; |
333 | 333 | ||
334 | for ( it = m_raw.begin(); it != m_raw.end(); ++it ) { | 334 | for ( it = m_raw.begin(); it != m_raw.end(); ++it ) { |
335 | ints[i] = it.key(); | 335 | ints[i] = it.key(); |
336 | i++; | 336 | i++; |
337 | } | 337 | } |
338 | 338 | ||
339 | return ints; | 339 | return ints; |
340 | } | 340 | } |
341 | OEvent::ValueList ODateBookAccessBackend_XML::directNonRepeats() { | 341 | OPimEvent::ValueList ODateBookAccessBackend_XML::directNonRepeats() { |
342 | OEvent::ValueList list; | 342 | OPimEvent::ValueList list; |
343 | QMap<int, OEvent>::ConstIterator it; | 343 | QMap<int, OPimEvent>::ConstIterator it; |
344 | for (it = m_raw.begin(); it != m_raw.end(); ++it ) | 344 | for (it = m_raw.begin(); it != m_raw.end(); ++it ) |
345 | list.append( it.data() ); | 345 | list.append( it.data() ); |
346 | 346 | ||
347 | return list; | 347 | return list; |
348 | } | 348 | } |
349 | OEvent::ValueList ODateBookAccessBackend_XML::directRawRepeats() { | 349 | OPimEvent::ValueList ODateBookAccessBackend_XML::directRawRepeats() { |
350 | OEvent::ValueList list; | 350 | OPimEvent::ValueList list; |
351 | QMap<int, OEvent>::ConstIterator it; | 351 | QMap<int, OPimEvent>::ConstIterator it; |
352 | for (it = m_rep.begin(); it != m_rep.end(); ++it ) | 352 | for (it = m_rep.begin(); it != m_rep.end(); ++it ) |
353 | list.append( it.data() ); | 353 | list.append( it.data() ); |
354 | 354 | ||
355 | return list; | 355 | return list; |
356 | } | 356 | } |
357 | 357 | ||
358 | // FIXME: Use OEvent::fromMap() (eilers) | 358 | // FIXME: Use OPimEvent::fromMap() (eilers) |
359 | bool ODateBookAccessBackend_XML::loadFile() { | 359 | bool ODateBookAccessBackend_XML::loadFile() { |
360 | m_changed = false; | 360 | m_changed = false; |
361 | 361 | ||
362 | int fd = ::open( QFile::encodeName(m_name).data(), O_RDONLY ); | 362 | int fd = ::open( QFile::encodeName(m_name).data(), O_RDONLY ); |
363 | if ( fd < 0 ) return false; | 363 | if ( fd < 0 ) return false; |
364 | 364 | ||
@@ -411,13 +411,13 @@ bool ODateBookAccessBackend_XML::loadFile() { | |||
411 | i = point -dt; | 411 | i = point -dt; |
412 | i+= strLen; | 412 | i+= strLen; |
413 | 413 | ||
414 | alarmTime = -1; | 414 | alarmTime = -1; |
415 | snd = 0; // silent | 415 | snd = 0; // silent |
416 | 416 | ||
417 | OEvent ev; | 417 | OPimEvent ev; |
418 | rec = 0; | 418 | rec = 0; |
419 | 419 | ||
420 | while ( TRUE ) { | 420 | while ( TRUE ) { |
421 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) | 421 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) |
422 | ++i; | 422 | ++i; |
423 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) | 423 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) |
@@ -477,34 +477,34 @@ bool ODateBookAccessBackend_XML::loadFile() { | |||
477 | ::munmap(map_addr, attribute.st_size ); | 477 | ::munmap(map_addr, attribute.st_size ); |
478 | m_changed = false; // changed during add | 478 | m_changed = false; // changed during add |
479 | 479 | ||
480 | return true; | 480 | return true; |
481 | } | 481 | } |
482 | 482 | ||
483 | // FIXME: Use OEvent::fromMap() which makes this obsolete.. (eilers) | 483 | // FIXME: Use OPimEvent::fromMap() which makes this obsolete.. (eilers) |
484 | void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { | 484 | void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) { |
485 | /* AllDay is alway in UTC */ | 485 | /* AllDay is alway in UTC */ |
486 | if ( ev.isAllDay() ) { | 486 | if ( ev.isAllDay() ) { |
487 | OTimeZone utc = OTimeZone::utc(); | 487 | OPimTimeZone utc = OPimTimeZone::utc(); |
488 | ev.setStartDateTime( utc.fromUTCDateTime( start ) ); | 488 | ev.setStartDateTime( utc.fromUTCDateTime( start ) ); |
489 | ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); | 489 | ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); |
490 | ev.setTimeZone( "UTC"); // make sure it is really utc | 490 | ev.setTimeZone( "UTC"); // make sure it is really utc |
491 | }else { | 491 | }else { |
492 | /* to current date time */ | 492 | /* to current date time */ |
493 | // qWarning(" Start is %d", start ); | 493 | // qWarning(" Start is %d", start ); |
494 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); | 494 | OPimTimeZone zone( ev.timeZone().isEmpty() ? OPimTimeZone::current() : ev.timeZone() ); |
495 | QDateTime date = zone.toDateTime( start ); | 495 | QDateTime date = zone.toDateTime( start ); |
496 | qWarning(" Start is %s", date.toString().latin1() ); | 496 | qWarning(" Start is %s", date.toString().latin1() ); |
497 | ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); | 497 | ev.setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) ); |
498 | 498 | ||
499 | date = zone.toDateTime( end ); | 499 | date = zone.toDateTime( end ); |
500 | ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); | 500 | ev.setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) ); |
501 | } | 501 | } |
502 | if ( rec && rec->doesRecur() ) { | 502 | if ( rec && rec->doesRecur() ) { |
503 | OTimeZone utc = OTimeZone::utc(); | 503 | OPimTimeZone utc = OPimTimeZone::utc(); |
504 | ORecur recu( *rec ); // call copy c'tor; | 504 | OPimRecurrence recu( *rec ); // call copy c'tor; |
505 | recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); | 505 | recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); |
506 | recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); | 506 | recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); |
507 | recu.setStart( ev.startDateTime().date() ); | 507 | recu.setStart( ev.startDateTime().date() ); |
508 | ev.setRecurrence( recu ); | 508 | ev.setRecurrence( recu ); |
509 | } | 509 | } |
510 | 510 | ||
@@ -521,13 +521,13 @@ void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { | |||
521 | if ( ev.hasRecurrence() ) | 521 | if ( ev.hasRecurrence() ) |
522 | m_rep.insert( ev.uid(), ev ); | 522 | m_rep.insert( ev.uid(), ev ); |
523 | else | 523 | else |
524 | m_raw.insert( ev.uid(), ev ); | 524 | m_raw.insert( ev.uid(), ev ); |
525 | 525 | ||
526 | } | 526 | } |
527 | void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) { | 527 | void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString& value) { |
528 | // qWarning(" setting %s", value.latin1() ); | 528 | // qWarning(" setting %s", value.latin1() ); |
529 | switch( id ) { | 529 | switch( id ) { |
530 | case FDescription: | 530 | case FDescription: |
531 | e.setDescription( value ); | 531 | e.setDescription( value ); |
532 | break; | 532 | break; |
533 | case FLocation: | 533 | case FLocation: |
@@ -551,23 +551,23 @@ void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& val | |||
551 | case FSound: | 551 | case FSound: |
552 | snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; | 552 | snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; |
553 | break; | 553 | break; |
554 | // recurrence stuff | 554 | // recurrence stuff |
555 | case FRType: | 555 | case FRType: |
556 | if ( value == "Daily" ) | 556 | if ( value == "Daily" ) |
557 | recur()->setType( ORecur::Daily ); | 557 | recur()->setType( OPimRecurrence::Daily ); |
558 | else if ( value == "Weekly" ) | 558 | else if ( value == "Weekly" ) |
559 | recur()->setType( ORecur::Weekly); | 559 | recur()->setType( OPimRecurrence::Weekly); |
560 | else if ( value == "MonthlyDay" ) | 560 | else if ( value == "MonthlyDay" ) |
561 | recur()->setType( ORecur::MonthlyDay ); | 561 | recur()->setType( OPimRecurrence::MonthlyDay ); |
562 | else if ( value == "MonthlyDate" ) | 562 | else if ( value == "MonthlyDate" ) |
563 | recur()->setType( ORecur::MonthlyDate ); | 563 | recur()->setType( OPimRecurrence::MonthlyDate ); |
564 | else if ( value == "Yearly" ) | 564 | else if ( value == "Yearly" ) |
565 | recur()->setType( ORecur::Yearly ); | 565 | recur()->setType( OPimRecurrence::Yearly ); |
566 | else | 566 | else |
567 | recur()->setType( ORecur::NoRepeat ); | 567 | recur()->setType( OPimRecurrence::NoRepeat ); |
568 | break; | 568 | break; |
569 | case FRWeekdays: | 569 | case FRWeekdays: |
570 | recur()->setDays( value.toInt() ); | 570 | recur()->setDays( value.toInt() ); |
571 | break; | 571 | break; |
572 | case FRPosition: | 572 | case FRPosition: |
573 | recur()->setPosition( value.toInt() ); | 573 | recur()->setPosition( value.toInt() ); |
@@ -624,13 +624,13 @@ void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& val | |||
624 | } | 624 | } |
625 | } | 625 | } |
626 | QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const | 626 | QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const |
627 | { | 627 | { |
628 | QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() ); | 628 | QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() ); |
629 | uint arraycounter = 0; | 629 | uint arraycounter = 0; |
630 | QMap<int, OEvent>::ConstIterator it; | 630 | QMap<int, OPimEvent>::ConstIterator it; |
631 | 631 | ||
632 | for ( it = m_raw.begin(); it != m_raw.end(); ++it ) | 632 | for ( it = m_raw.begin(); it != m_raw.end(); ++it ) |
633 | if ( it.data().match( r ) ) | 633 | if ( it.data().match( r ) ) |
634 | m_currentQuery[arraycounter++] = it.data().uid(); | 634 | m_currentQuery[arraycounter++] = it.data().uid(); |
635 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) | 635 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) |
636 | if ( it.data().match( r ) ) | 636 | if ( it.data().match( r ) ) |
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h index 29f5f4f..6823ce6 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h +++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h | |||
@@ -49,34 +49,34 @@ public: | |||
49 | bool load(); | 49 | bool load(); |
50 | bool reload(); | 50 | bool reload(); |
51 | bool save(); | 51 | bool save(); |
52 | 52 | ||
53 | QArray<int> allRecords()const; | 53 | QArray<int> allRecords()const; |
54 | QArray<int> matchRegexp(const QRegExp &r) const; | 54 | QArray<int> matchRegexp(const QRegExp &r) const; |
55 | QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); | 55 | QArray<int> queryByExample( const OPimEvent&, int, const QDateTime& d = QDateTime() ); |
56 | OEvent find( int uid )const; | 56 | OPimEvent find( int uid )const; |
57 | void clear(); | 57 | void clear(); |
58 | bool add( const OEvent& ev ); | 58 | bool add( const OPimEvent& ev ); |
59 | bool remove( int uid ); | 59 | bool remove( int uid ); |
60 | bool replace( const OEvent& ev ); | 60 | bool replace( const OPimEvent& ev ); |
61 | 61 | ||
62 | QArray<UID> rawEvents()const; | 62 | QArray<UID> rawEvents()const; |
63 | QArray<UID> rawRepeats()const; | 63 | QArray<UID> rawRepeats()const; |
64 | QArray<UID> nonRepeats()const; | 64 | QArray<UID> nonRepeats()const; |
65 | 65 | ||
66 | OEvent::ValueList directNonRepeats(); | 66 | OPimEvent::ValueList directNonRepeats(); |
67 | OEvent::ValueList directRawRepeats(); | 67 | OPimEvent::ValueList directRawRepeats(); |
68 | 68 | ||
69 | private: | 69 | private: |
70 | bool m_changed :1 ; | 70 | bool m_changed :1 ; |
71 | bool loadFile(); | 71 | bool loadFile(); |
72 | inline void finalizeRecord( OEvent& ev ); | 72 | inline void finalizeRecord( OPimEvent& ev ); |
73 | inline void setField( OEvent&, int field, const QString& val ); | 73 | inline void setField( OPimEvent&, int field, const QString& val ); |
74 | QString m_name; | 74 | QString m_name; |
75 | QMap<int, OEvent> m_raw; | 75 | QMap<int, OPimEvent> m_raw; |
76 | QMap<int, OEvent> m_rep; | 76 | QMap<int, OPimEvent> m_rep; |
77 | 77 | ||
78 | struct Data; | 78 | struct Data; |
79 | Data* data; | 79 | Data* data; |
80 | class Private; | 80 | class Private; |
81 | Private *d; | 81 | Private *d; |
82 | }; | 82 | }; |
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h index 505358e..0682063 100644 --- a/libopie2/opiepim/backend/opimaccessbackend.h +++ b/libopie2/opiepim/backend/opimaccessbackend.h | |||
@@ -29,13 +29,13 @@ | |||
29 | #ifndef OPIE_PIM_ACCESS_BACKEND | 29 | #ifndef OPIE_PIM_ACCESS_BACKEND |
30 | #define OPIE_PIM_ACCESS_BACKEND | 30 | #define OPIE_PIM_ACCESS_BACKEND |
31 | 31 | ||
32 | #include <qarray.h> | 32 | #include <qarray.h> |
33 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
34 | 34 | ||
35 | #include <opie2/otemplatebase.h> | 35 | #include <opie2/opimtemplatebase.h> |
36 | #include <opie2/opimrecord.h> | 36 | #include <opie2/opimrecord.h> |
37 | 37 | ||
38 | 38 | ||
39 | namespace Opie { | 39 | namespace Opie { |
40 | class OPimAccessBackendPrivate; | 40 | class OPimAccessBackendPrivate; |
41 | /** | 41 | /** |
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.cpp b/libopie2/opiepim/backend/otodoaccessbackend.cpp index d27f5ef..790a764 100644 --- a/libopie2/opiepim/backend/otodoaccessbackend.cpp +++ b/libopie2/opiepim/backend/otodoaccessbackend.cpp | |||
@@ -27,15 +27,15 @@ | |||
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <opie2/otodoaccessbackend.h> | 30 | #include <opie2/otodoaccessbackend.h> |
31 | 31 | ||
32 | namespace Opie { | 32 | namespace Opie { |
33 | OTodoAccessBackend::OTodoAccessBackend() | 33 | OPimTodoAccessBackend::OPimTodoAccessBackend() |
34 | : OPimAccessBackend<OTodo>() | 34 | : OPimAccessBackend<OPimTodo>() |
35 | { | 35 | { |
36 | } | 36 | } |
37 | OTodoAccessBackend::~OTodoAccessBackend() { | 37 | OPimTodoAccessBackend::~OPimTodoAccessBackend() { |
38 | 38 | ||
39 | } | 39 | } |
40 | 40 | ||
41 | } | 41 | } |
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.h b/libopie2/opiepim/backend/otodoaccessbackend.h index 54b52cc..9dfda45 100644 --- a/libopie2/opiepim/backend/otodoaccessbackend.h +++ b/libopie2/opiepim/backend/otodoaccessbackend.h | |||
@@ -28,20 +28,20 @@ | |||
28 | */ | 28 | */ |
29 | #ifndef OPIE_TODO_ACCESS_BACKEND_H | 29 | #ifndef OPIE_TODO_ACCESS_BACKEND_H |
30 | #define OPIE_TODO_ACCESS_BACKEND_H | 30 | #define OPIE_TODO_ACCESS_BACKEND_H |
31 | 31 | ||
32 | #include <qbitarray.h> | 32 | #include <qbitarray.h> |
33 | 33 | ||
34 | #include <opie2/otodo.h> | 34 | #include <opie2/opimtodo.h> |
35 | #include <opie2/opimaccessbackend.h> | 35 | #include <opie2/opimaccessbackend.h> |
36 | 36 | ||
37 | namespace Opie { | 37 | namespace Opie { |
38 | class OTodoAccessBackend : public OPimAccessBackend<OTodo> { | 38 | class OPimTodoAccessBackend : public OPimAccessBackend<OPimTodo> { |
39 | public: | 39 | public: |
40 | OTodoAccessBackend(); | 40 | OPimTodoAccessBackend(); |
41 | ~OTodoAccessBackend(); | 41 | ~OPimTodoAccessBackend(); |
42 | virtual QArray<int> effectiveToDos( const QDate& start, | 42 | virtual QArray<int> effectiveToDos( const QDate& start, |
43 | const QDate& end, | 43 | const QDate& end, |
44 | bool includeNoDates ) = 0; | 44 | bool includeNoDates ) = 0; |
45 | virtual QArray<int> overDue() = 0; | 45 | virtual QArray<int> overDue() = 0; |
46 | virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter, | 46 | virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter, |
47 | int cat ) = 0; | 47 | int cat ) = 0; |
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp index 944f82a..72232e5 100644 --- a/libopie2/opiepim/backend/otodoaccesssql.cpp +++ b/libopie2/opiepim/backend/otodoaccesssql.cpp | |||
@@ -36,13 +36,13 @@ | |||
36 | #include <opie2/osqlmanager.h> | 36 | #include <opie2/osqlmanager.h> |
37 | #include <opie2/osqlquery.h> | 37 | #include <opie2/osqlquery.h> |
38 | 38 | ||
39 | #include <opie2/otodoaccesssql.h> | 39 | #include <opie2/otodoaccesssql.h> |
40 | #include <opie2/opimstate.h> | 40 | #include <opie2/opimstate.h> |
41 | #include <opie2/opimnotifymanager.h> | 41 | #include <opie2/opimnotifymanager.h> |
42 | #include <opie2/orecur.h> | 42 | #include <opie2/opimrecurrence.h> |
43 | 43 | ||
44 | using namespace Opie; | 44 | using namespace Opie; |
45 | /* | 45 | /* |
46 | * first some query | 46 | * first some query |
47 | * CREATE query | 47 | * CREATE query |
48 | * LOAD query | 48 | * LOAD query |
@@ -70,21 +70,21 @@ namespace { | |||
70 | LoadQuery(); | 70 | LoadQuery(); |
71 | ~LoadQuery(); | 71 | ~LoadQuery(); |
72 | QString query()const; | 72 | QString query()const; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * inserts/adds a OTodo to the table | 76 | * inserts/adds a OPimTodo to the table |
77 | */ | 77 | */ |
78 | class InsertQuery : public OSQLQuery { | 78 | class InsertQuery : public OSQLQuery { |
79 | public: | 79 | public: |
80 | InsertQuery(const OTodo& ); | 80 | InsertQuery(const OPimTodo& ); |
81 | ~InsertQuery(); | 81 | ~InsertQuery(); |
82 | QString query()const; | 82 | QString query()const; |
83 | private: | 83 | private: |
84 | OTodo m_todo; | 84 | OPimTodo m_todo; |
85 | }; | 85 | }; |
86 | 86 | ||
87 | /** | 87 | /** |
88 | * removes one from the table | 88 | * removes one from the table |
89 | */ | 89 | */ |
90 | class RemoveQuery : public OSQLQuery { | 90 | class RemoveQuery : public OSQLQuery { |
@@ -149,13 +149,13 @@ namespace { | |||
149 | CreateQuery::CreateQuery() : OSQLQuery() {} | 149 | CreateQuery::CreateQuery() : OSQLQuery() {} |
150 | CreateQuery::~CreateQuery() {} | 150 | CreateQuery::~CreateQuery() {} |
151 | QString CreateQuery::query()const { | 151 | QString CreateQuery::query()const { |
152 | QString qu; | 152 | QString qu; |
153 | qu += "create table todolist( uid PRIMARY KEY, categories, completed, "; | 153 | qu += "create table todolist( uid PRIMARY KEY, categories, completed, "; |
154 | qu += "description, summary, priority, DueDate, progress , state, "; | 154 | qu += "description, summary, priority, DueDate, progress , state, "; |
155 | // This is the recurrance-stuff .. Exceptions are currently not supported (see ORecur.cpp) ! (eilers) | 155 | // This is the recurrance-stuff .. Exceptions are currently not supported (see OPimRecurrence.cpp) ! (eilers) |
156 | qu += "RType, RWeekdays, RPosition, RFreq, RHasEndDate, EndDate, Created, Exceptions, "; | 156 | qu += "RType, RWeekdays, RPosition, RFreq, RHasEndDate, EndDate, Created, Exceptions, "; |
157 | qu += "reminders, alarms, maintainer, startdate, completeddate);"; | 157 | qu += "reminders, alarms, maintainer, startdate, completeddate);"; |
158 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; | 158 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; |
159 | return qu; | 159 | return qu; |
160 | } | 160 | } |
161 | 161 | ||
@@ -167,19 +167,19 @@ namespace { | |||
167 | //qu += "select distinct uid from todolist"; | 167 | //qu += "select distinct uid from todolist"; |
168 | qu += "select uid from todolist"; | 168 | qu += "select uid from todolist"; |
169 | 169 | ||
170 | return qu; | 170 | return qu; |
171 | } | 171 | } |
172 | 172 | ||
173 | InsertQuery::InsertQuery( const OTodo& todo ) | 173 | InsertQuery::InsertQuery( const OPimTodo& todo ) |
174 | : OSQLQuery(), m_todo( todo ) { | 174 | : OSQLQuery(), m_todo( todo ) { |
175 | } | 175 | } |
176 | InsertQuery::~InsertQuery() { | 176 | InsertQuery::~InsertQuery() { |
177 | } | 177 | } |
178 | /* | 178 | /* |
179 | * converts from a OTodo to a query | 179 | * converts from a OPimTodo to a query |
180 | * we leave out X-Ref + Alarms | 180 | * we leave out X-Ref + Alarms |
181 | */ | 181 | */ |
182 | QString InsertQuery::query()const{ | 182 | QString InsertQuery::query()const{ |
183 | 183 | ||
184 | int year, month, day; | 184 | int year, month, day; |
185 | year = month = day = 0; | 185 | year = month = day = 0; |
@@ -215,20 +215,20 @@ namespace { | |||
215 | + QString::number(m_todo.priority() ) + "," | 215 | + QString::number(m_todo.priority() ) + "," |
216 | + "'" + QString::number(year) + "-" | 216 | + "'" + QString::number(year) + "-" |
217 | + QString::number(month) | 217 | + QString::number(month) |
218 | + "-" + QString::number( day ) + "'" + "," | 218 | + "-" + QString::number( day ) + "'" + "," |
219 | + QString::number( m_todo.progress() ) + "," | 219 | + QString::number( m_todo.progress() ) + "," |
220 | + QString::number( m_todo.state().state() ) + "," | 220 | + QString::number( m_todo.state().state() ) + "," |
221 | + "'" + recMap[ ORecur::RType ] + "'" + "," | 221 | + "'" + recMap[ OPimRecurrence::RType ] + "'" + "," |
222 | + "'" + recMap[ ORecur::RWeekdays ] + "'" + "," | 222 | + "'" + recMap[ OPimRecurrence::RWeekdays ] + "'" + "," |
223 | + "'" + recMap[ ORecur::RPosition ] + "'" + "," | 223 | + "'" + recMap[ OPimRecurrence::RPosition ] + "'" + "," |
224 | + "'" + recMap[ ORecur::RFreq ] + "'" + "," | 224 | + "'" + recMap[ OPimRecurrence::RFreq ] + "'" + "," |
225 | + "'" + recMap[ ORecur::RHasEndDate ] + "'" + "," | 225 | + "'" + recMap[ OPimRecurrence::RHasEndDate ] + "'" + "," |
226 | + "'" + recMap[ ORecur::EndDate ] + "'" + "," | 226 | + "'" + recMap[ OPimRecurrence::EndDate ] + "'" + "," |
227 | + "'" + recMap[ ORecur::Created ] + "'" + "," | 227 | + "'" + recMap[ OPimRecurrence::Created ] + "'" + "," |
228 | + "'" + recMap[ ORecur::Exceptions ] + "'" + ","; | 228 | + "'" + recMap[ OPimRecurrence::Exceptions ] + "'" + ","; |
229 | 229 | ||
230 | if ( m_todo.hasNotifiers() ) { | 230 | if ( m_todo.hasNotifiers() ) { |
231 | OPimNotifyManager manager = m_todo.notifiers(); | 231 | OPimNotifyManager manager = m_todo.notifiers(); |
232 | qu += "'" + manager.remindersToString() + "'" + "," | 232 | qu += "'" + manager.remindersToString() + "'" + "," |
233 | + "'" + manager.alarmsToString() + "'" + ","; | 233 | + "'" + manager.alarmsToString() + "'" + ","; |
234 | } | 234 | } |
@@ -326,68 +326,68 @@ namespace { | |||
326 | return str; | 326 | return str; |
327 | } | 327 | } |
328 | }; | 328 | }; |
329 | 329 | ||
330 | 330 | ||
331 | namespace Opie { | 331 | namespace Opie { |
332 | OTodoAccessBackendSQL::OTodoAccessBackendSQL( const QString& file ) | 332 | OPimTodoAccessBackendSQL::OPimTodoAccessBackendSQL( const QString& file ) |
333 | : OTodoAccessBackend(), m_dict(15), m_driver(NULL), m_dirty(true) | 333 | : OPimTodoAccessBackend(), m_dict(15), m_driver(NULL), m_dirty(true) |
334 | { | 334 | { |
335 | QString fi = file; | 335 | QString fi = file; |
336 | if ( fi.isEmpty() ) | 336 | if ( fi.isEmpty() ) |
337 | fi = Global::applicationFileName( "todolist", "todolist.db" ); | 337 | fi = Global::applicationFileName( "todolist", "todolist.db" ); |
338 | OSQLManager man; | 338 | OSQLManager man; |
339 | m_driver = man.standard(); | 339 | m_driver = man.standard(); |
340 | m_driver->setUrl(fi); | 340 | m_driver->setUrl(fi); |
341 | // fillDict(); | 341 | // fillDict(); |
342 | } | 342 | } |
343 | 343 | ||
344 | OTodoAccessBackendSQL::~OTodoAccessBackendSQL(){ | 344 | OPimTodoAccessBackendSQL::~OPimTodoAccessBackendSQL(){ |
345 | if( m_driver ) | 345 | if( m_driver ) |
346 | delete m_driver; | 346 | delete m_driver; |
347 | } | 347 | } |
348 | 348 | ||
349 | bool OTodoAccessBackendSQL::load(){ | 349 | bool OPimTodoAccessBackendSQL::load(){ |
350 | if (!m_driver->open() ) | 350 | if (!m_driver->open() ) |
351 | return false; | 351 | return false; |
352 | 352 | ||
353 | CreateQuery creat; | 353 | CreateQuery creat; |
354 | OSQLResult res = m_driver->query(&creat ); | 354 | OSQLResult res = m_driver->query(&creat ); |
355 | 355 | ||
356 | m_dirty = true; | 356 | m_dirty = true; |
357 | return true; | 357 | return true; |
358 | } | 358 | } |
359 | bool OTodoAccessBackendSQL::reload(){ | 359 | bool OPimTodoAccessBackendSQL::reload(){ |
360 | return load(); | 360 | return load(); |
361 | } | 361 | } |
362 | 362 | ||
363 | bool OTodoAccessBackendSQL::save(){ | 363 | bool OPimTodoAccessBackendSQL::save(){ |
364 | return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) | 364 | return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) |
365 | } | 365 | } |
366 | QArray<int> OTodoAccessBackendSQL::allRecords()const { | 366 | QArray<int> OPimTodoAccessBackendSQL::allRecords()const { |
367 | if (m_dirty ) | 367 | if (m_dirty ) |
368 | update(); | 368 | update(); |
369 | 369 | ||
370 | return m_uids; | 370 | return m_uids; |
371 | } | 371 | } |
372 | QArray<int> OTodoAccessBackendSQL::queryByExample( const OTodo& , int, const QDateTime& ){ | 372 | QArray<int> OPimTodoAccessBackendSQL::queryByExample( const OPimTodo& , int, const QDateTime& ){ |
373 | QArray<int> ints(0); | 373 | QArray<int> ints(0); |
374 | return ints; | 374 | return ints; |
375 | } | 375 | } |
376 | OTodo OTodoAccessBackendSQL::find(int uid ) const{ | 376 | OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{ |
377 | FindQuery query( uid ); | 377 | FindQuery query( uid ); |
378 | return todo( m_driver->query(&query) ); | 378 | return todo( m_driver->query(&query) ); |
379 | 379 | ||
380 | } | 380 | } |
381 | OTodo OTodoAccessBackendSQL::find( int uid, const QArray<int>& ints, | 381 | OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints, |
382 | uint cur, Frontend::CacheDirection dir ) const{ | 382 | uint cur, Frontend::CacheDirection dir ) const{ |
383 | uint CACHE = readAhead(); | 383 | uint CACHE = readAhead(); |
384 | qWarning("searching for %d", uid ); | 384 | qWarning("searching for %d", uid ); |
385 | QArray<int> search( CACHE ); | 385 | QArray<int> search( CACHE ); |
386 | uint size =0; | 386 | uint size =0; |
387 | OTodo to; | 387 | OPimTodo to; |
388 | 388 | ||
389 | // we try to cache CACHE items | 389 | // we try to cache CACHE items |
390 | switch( dir ) { | 390 | switch( dir ) { |
391 | /* forward */ | 391 | /* forward */ |
392 | case 0: // FIXME: Not a good style to use magic numbers here (eilers) | 392 | case 0: // FIXME: Not a good style to use magic numbers here (eilers) |
393 | for (uint i = cur; i < ints.count() && size < CACHE; i++ ) { | 393 | for (uint i = cur; i < ints.count() && size < CACHE; i++ ) { |
@@ -409,31 +409,31 @@ OTodo OTodoAccessBackendSQL::find( int uid, const QArray<int>& ints, | |||
409 | OSQLResult res = m_driver->query( &query ); | 409 | OSQLResult res = m_driver->query( &query ); |
410 | if ( res.state() != OSQLResult::Success ) | 410 | if ( res.state() != OSQLResult::Success ) |
411 | return to; | 411 | return to; |
412 | 412 | ||
413 | return todo( res ); | 413 | return todo( res ); |
414 | } | 414 | } |
415 | void OTodoAccessBackendSQL::clear() { | 415 | void OPimTodoAccessBackendSQL::clear() { |
416 | ClearQuery cle; | 416 | ClearQuery cle; |
417 | OSQLResult res = m_driver->query( &cle ); | 417 | OSQLResult res = m_driver->query( &cle ); |
418 | CreateQuery qu; | 418 | CreateQuery qu; |
419 | res = m_driver->query(&qu); | 419 | res = m_driver->query(&qu); |
420 | } | 420 | } |
421 | bool OTodoAccessBackendSQL::add( const OTodo& t) { | 421 | bool OPimTodoAccessBackendSQL::add( const OPimTodo& t) { |
422 | InsertQuery ins( t ); | 422 | InsertQuery ins( t ); |
423 | OSQLResult res = m_driver->query( &ins ); | 423 | OSQLResult res = m_driver->query( &ins ); |
424 | 424 | ||
425 | if ( res.state() == OSQLResult::Failure ) | 425 | if ( res.state() == OSQLResult::Failure ) |
426 | return false; | 426 | return false; |
427 | int c = m_uids.count(); | 427 | int c = m_uids.count(); |
428 | m_uids.resize( c+1 ); | 428 | m_uids.resize( c+1 ); |
429 | m_uids[c] = t.uid(); | 429 | m_uids[c] = t.uid(); |
430 | 430 | ||
431 | return true; | 431 | return true; |
432 | } | 432 | } |
433 | bool OTodoAccessBackendSQL::remove( int uid ) { | 433 | bool OPimTodoAccessBackendSQL::remove( int uid ) { |
434 | RemoveQuery rem( uid ); | 434 | RemoveQuery rem( uid ); |
435 | OSQLResult res = m_driver->query(&rem ); | 435 | OSQLResult res = m_driver->query(&rem ); |
436 | 436 | ||
437 | if ( res.state() == OSQLResult::Failure ) | 437 | if ( res.state() == OSQLResult::Failure ) |
438 | return false; | 438 | return false; |
439 | 439 | ||
@@ -442,32 +442,32 @@ bool OTodoAccessBackendSQL::remove( int uid ) { | |||
442 | } | 442 | } |
443 | /* | 443 | /* |
444 | * FIXME better set query | 444 | * FIXME better set query |
445 | * but we need the cache for that | 445 | * but we need the cache for that |
446 | * now we remove | 446 | * now we remove |
447 | */ | 447 | */ |
448 | bool OTodoAccessBackendSQL::replace( const OTodo& t) { | 448 | bool OPimTodoAccessBackendSQL::replace( const OPimTodo& t) { |
449 | remove( t.uid() ); | 449 | remove( t.uid() ); |
450 | bool b= add(t); | 450 | bool b= add(t); |
451 | m_dirty = false; // we changed some stuff but the UID stayed the same | 451 | m_dirty = false; // we changed some stuff but the UID stayed the same |
452 | return b; | 452 | return b; |
453 | } | 453 | } |
454 | QArray<int> OTodoAccessBackendSQL::overDue() { | 454 | QArray<int> OPimTodoAccessBackendSQL::overDue() { |
455 | OverDueQuery qu; | 455 | OverDueQuery qu; |
456 | return uids( m_driver->query(&qu ) ); | 456 | return uids( m_driver->query(&qu ) ); |
457 | } | 457 | } |
458 | QArray<int> OTodoAccessBackendSQL::effectiveToDos( const QDate& s, | 458 | QArray<int> OPimTodoAccessBackendSQL::effectiveToDos( const QDate& s, |
459 | const QDate& t, | 459 | const QDate& t, |
460 | bool u) { | 460 | bool u) { |
461 | EffQuery ef(s, t, u ); | 461 | EffQuery ef(s, t, u ); |
462 | return uids (m_driver->query(&ef) ); | 462 | return uids (m_driver->query(&ef) ); |
463 | } | 463 | } |
464 | /* | 464 | /* |
465 | * | 465 | * |
466 | */ | 466 | */ |
467 | QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder, | 467 | QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder, |
468 | int sortFilter, int cat ) { | 468 | int sortFilter, int cat ) { |
469 | qWarning("sorted %d, %d", asc, sortOrder ); | 469 | qWarning("sorted %d, %d", asc, sortOrder ); |
470 | QString query; | 470 | QString query; |
471 | query = "select uid from todolist WHERE "; | 471 | query = "select uid from todolist WHERE "; |
472 | 472 | ||
473 | /* | 473 | /* |
@@ -527,53 +527,53 @@ QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder, | |||
527 | } | 527 | } |
528 | 528 | ||
529 | qWarning( query ); | 529 | qWarning( query ); |
530 | OSQLRawQuery raw(query ); | 530 | OSQLRawQuery raw(query ); |
531 | return uids( m_driver->query(&raw) ); | 531 | return uids( m_driver->query(&raw) ); |
532 | } | 532 | } |
533 | bool OTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{ | 533 | bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{ |
534 | if ( str == "0-0-0" ) | 534 | if ( str == "0-0-0" ) |
535 | return false; | 535 | return false; |
536 | else{ | 536 | else{ |
537 | int day, year, month; | 537 | int day, year, month; |
538 | QStringList list = QStringList::split("-", str ); | 538 | QStringList list = QStringList::split("-", str ); |
539 | year = list[0].toInt(); | 539 | year = list[0].toInt(); |
540 | month = list[1].toInt(); | 540 | month = list[1].toInt(); |
541 | day = list[2].toInt(); | 541 | day = list[2].toInt(); |
542 | da.setYMD( year, month, day ); | 542 | da.setYMD( year, month, day ); |
543 | return true; | 543 | return true; |
544 | } | 544 | } |
545 | } | 545 | } |
546 | OTodo OTodoAccessBackendSQL::todo( const OSQLResult& res) const{ | 546 | OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res) const{ |
547 | if ( res.state() == OSQLResult::Failure ) { | 547 | if ( res.state() == OSQLResult::Failure ) { |
548 | OTodo to; | 548 | OPimTodo to; |
549 | return to; | 549 | return to; |
550 | } | 550 | } |
551 | 551 | ||
552 | OSQLResultItem::ValueList list = res.results(); | 552 | OSQLResultItem::ValueList list = res.results(); |
553 | OSQLResultItem::ValueList::Iterator it = list.begin(); | 553 | OSQLResultItem::ValueList::Iterator it = list.begin(); |
554 | qWarning("todo1"); | 554 | qWarning("todo1"); |
555 | OTodo to = todo( (*it) ); | 555 | OPimTodo to = todo( (*it) ); |
556 | cache( to ); | 556 | cache( to ); |
557 | ++it; | 557 | ++it; |
558 | 558 | ||
559 | for ( ; it != list.end(); ++it ) { | 559 | for ( ; it != list.end(); ++it ) { |
560 | qWarning("caching"); | 560 | qWarning("caching"); |
561 | cache( todo( (*it) ) ); | 561 | cache( todo( (*it) ) ); |
562 | } | 562 | } |
563 | return to; | 563 | return to; |
564 | } | 564 | } |
565 | OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const { | 565 | OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { |
566 | qWarning("todo"); | 566 | qWarning("todo"); |
567 | bool hasDueDate = false; QDate dueDate = QDate::currentDate(); | 567 | bool hasDueDate = false; QDate dueDate = QDate::currentDate(); |
568 | hasDueDate = date( dueDate, item.data("DueDate") ); | 568 | hasDueDate = date( dueDate, item.data("DueDate") ); |
569 | QStringList cats = QStringList::split(";", item.data("categories") ); | 569 | QStringList cats = QStringList::split(";", item.data("categories") ); |
570 | 570 | ||
571 | qWarning("Item is completed: %d", item.data("completed").toInt() ); | 571 | qWarning("Item is completed: %d", item.data("completed").toInt() ); |
572 | 572 | ||
573 | OTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(), | 573 | OPimTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(), |
574 | cats, item.data("summary"), item.data("description"), | 574 | cats, item.data("summary"), item.data("description"), |
575 | item.data("progress").toUShort(), hasDueDate, dueDate, | 575 | item.data("progress").toUShort(), hasDueDate, dueDate, |
576 | item.data("uid").toInt() ); | 576 | item.data("uid").toInt() ); |
577 | 577 | ||
578 | bool isOk; | 578 | bool isOk; |
579 | int prioInt = QString( item.data("priority") ).toInt( &isOk ); | 579 | int prioInt = QString( item.data("priority") ).toInt( &isOk ); |
@@ -596,71 +596,71 @@ OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const { | |||
596 | 596 | ||
597 | OPimState pimState; | 597 | OPimState pimState; |
598 | pimState.setState( QString( item.data("state") ).toInt() ); | 598 | pimState.setState( QString( item.data("state") ).toInt() ); |
599 | to.setState( pimState ); | 599 | to.setState( pimState ); |
600 | 600 | ||
601 | QMap<int, QString> recMap; | 601 | QMap<int, QString> recMap; |
602 | recMap.insert( ORecur::RType , item.data("RType") ); | 602 | recMap.insert( OPimRecurrence::RType , item.data("RType") ); |
603 | recMap.insert( ORecur::RWeekdays , item.data("RWeekdays") ); | 603 | recMap.insert( OPimRecurrence::RWeekdays , item.data("RWeekdays") ); |
604 | recMap.insert( ORecur::RPosition , item.data("RPosition") ); | 604 | recMap.insert( OPimRecurrence::RPosition , item.data("RPosition") ); |
605 | recMap.insert( ORecur::RFreq , item.data("RFreq") ); | 605 | recMap.insert( OPimRecurrence::RFreq , item.data("RFreq") ); |
606 | recMap.insert( ORecur::RHasEndDate, item.data("RHasEndDate") ); | 606 | recMap.insert( OPimRecurrence::RHasEndDate, item.data("RHasEndDate") ); |
607 | recMap.insert( ORecur::EndDate , item.data("EndDate") ); | 607 | recMap.insert( OPimRecurrence::EndDate , item.data("EndDate") ); |
608 | recMap.insert( ORecur::Created , item.data("Created") ); | 608 | recMap.insert( OPimRecurrence::Created , item.data("Created") ); |
609 | recMap.insert( ORecur::Exceptions , item.data("Exceptions") ); | 609 | recMap.insert( OPimRecurrence::Exceptions , item.data("Exceptions") ); |
610 | 610 | ||
611 | ORecur recur; | 611 | OPimRecurrence recur; |
612 | recur.fromMap( recMap ); | 612 | recur.fromMap( recMap ); |
613 | to.setRecurrence( recur ); | 613 | to.setRecurrence( recur ); |
614 | 614 | ||
615 | return to; | 615 | return to; |
616 | } | 616 | } |
617 | OTodo OTodoAccessBackendSQL::todo( int uid )const { | 617 | OPimTodo OPimTodoAccessBackendSQL::todo( int uid )const { |
618 | FindQuery find( uid ); | 618 | FindQuery find( uid ); |
619 | return todo( m_driver->query(&find) ); | 619 | return todo( m_driver->query(&find) ); |
620 | } | 620 | } |
621 | /* | 621 | /* |
622 | * update the dict | 622 | * update the dict |
623 | */ | 623 | */ |
624 | void OTodoAccessBackendSQL::fillDict() { | 624 | void OPimTodoAccessBackendSQL::fillDict() { |
625 | /* initialize dict */ | 625 | /* initialize dict */ |
626 | /* | 626 | /* |
627 | * UPDATE dict if you change anything!!! | 627 | * UPDATE dict if you change anything!!! |
628 | * FIXME: Isn't this dict obsolete ? (eilers) | 628 | * FIXME: Isn't this dict obsolete ? (eilers) |
629 | */ | 629 | */ |
630 | m_dict.setAutoDelete( TRUE ); | 630 | m_dict.setAutoDelete( TRUE ); |
631 | m_dict.insert("Categories" , new int(OTodo::Category) ); | 631 | m_dict.insert("Categories" , new int(OPimTodo::Category) ); |
632 | m_dict.insert("Uid" , new int(OTodo::Uid) ); | 632 | m_dict.insert("Uid" , new int(OPimTodo::Uid) ); |
633 | m_dict.insert("HasDate" , new int(OTodo::HasDate) ); | 633 | m_dict.insert("HasDate" , new int(OPimTodo::HasDate) ); |
634 | m_dict.insert("Completed" , new int(OTodo::Completed) ); | 634 | m_dict.insert("Completed" , new int(OPimTodo::Completed) ); |
635 | m_dict.insert("Description" , new int(OTodo::Description) ); | 635 | m_dict.insert("Description" , new int(OPimTodo::Description) ); |
636 | m_dict.insert("Summary" , new int(OTodo::Summary) ); | 636 | m_dict.insert("Summary" , new int(OPimTodo::Summary) ); |
637 | m_dict.insert("Priority" , new int(OTodo::Priority) ); | 637 | m_dict.insert("Priority" , new int(OPimTodo::Priority) ); |
638 | m_dict.insert("DateDay" , new int(OTodo::DateDay) ); | 638 | m_dict.insert("DateDay" , new int(OPimTodo::DateDay) ); |
639 | m_dict.insert("DateMonth" , new int(OTodo::DateMonth) ); | 639 | m_dict.insert("DateMonth" , new int(OPimTodo::DateMonth) ); |
640 | m_dict.insert("DateYear" , new int(OTodo::DateYear) ); | 640 | m_dict.insert("DateYear" , new int(OPimTodo::DateYear) ); |
641 | m_dict.insert("Progress" , new int(OTodo::Progress) ); | 641 | m_dict.insert("Progress" , new int(OPimTodo::Progress) ); |
642 | m_dict.insert("Completed", new int(OTodo::Completed) ); // Why twice ? (eilers) | 642 | m_dict.insert("Completed", new int(OPimTodo::Completed) ); // Why twice ? (eilers) |
643 | m_dict.insert("CrossReference", new int(OTodo::CrossReference) ); | 643 | m_dict.insert("CrossReference", new int(OPimTodo::CrossReference) ); |
644 | // m_dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) ); // old stuff (eilers) | 644 | // m_dict.insert("HasAlarmDateTime",new int(OPimTodo::HasAlarmDateTime) ); // old stuff (eilers) |
645 | // m_dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) ); // old stuff (eilers) | 645 | // m_dict.insert("AlarmDateTime", new int(OPimTodo::AlarmDateTime) ); // old stuff (eilers) |
646 | } | 646 | } |
647 | /* | 647 | /* |
648 | * need to be const so let's fool the | 648 | * need to be const so let's fool the |
649 | * compiler :( | 649 | * compiler :( |
650 | */ | 650 | */ |
651 | void OTodoAccessBackendSQL::update()const { | 651 | void OPimTodoAccessBackendSQL::update()const { |
652 | ((OTodoAccessBackendSQL*)this)->m_dirty = false; | 652 | ((OPimTodoAccessBackendSQL*)this)->m_dirty = false; |
653 | LoadQuery lo; | 653 | LoadQuery lo; |
654 | OSQLResult res = m_driver->query(&lo); | 654 | OSQLResult res = m_driver->query(&lo); |
655 | if ( res.state() != OSQLResult::Success ) | 655 | if ( res.state() != OSQLResult::Success ) |
656 | return; | 656 | return; |
657 | 657 | ||
658 | ((OTodoAccessBackendSQL*)this)->m_uids = uids( res ); | 658 | ((OPimTodoAccessBackendSQL*)this)->m_uids = uids( res ); |
659 | } | 659 | } |
660 | QArray<int> OTodoAccessBackendSQL::uids( const OSQLResult& res) const{ | 660 | QArray<int> OPimTodoAccessBackendSQL::uids( const OSQLResult& res) const{ |
661 | 661 | ||
662 | OSQLResultItem::ValueList list = res.results(); | 662 | OSQLResultItem::ValueList list = res.results(); |
663 | OSQLResultItem::ValueList::Iterator it; | 663 | OSQLResultItem::ValueList::Iterator it; |
664 | QArray<int> ints(list.count() ); | 664 | QArray<int> ints(list.count() ); |
665 | qWarning(" count = %d", list.count() ); | 665 | qWarning(" count = %d", list.count() ); |
666 | 666 | ||
@@ -669,27 +669,27 @@ QArray<int> OTodoAccessBackendSQL::uids( const OSQLResult& res) const{ | |||
669 | ints[i] = (*it).data("uid").toInt(); | 669 | ints[i] = (*it).data("uid").toInt(); |
670 | i++; | 670 | i++; |
671 | } | 671 | } |
672 | return ints; | 672 | return ints; |
673 | } | 673 | } |
674 | 674 | ||
675 | QArray<int> OTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const | 675 | QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const |
676 | { | 676 | { |
677 | 677 | ||
678 | #warning OTodoAccessBackendSQL::matchRegexp() not implemented !! | 678 | #warning OPimTodoAccessBackendSQL::matchRegexp() not implemented !! |
679 | 679 | ||
680 | #if 0 | 680 | #if 0 |
681 | 681 | ||
682 | Copied from xml-backend by not adapted to sql (eilers) | 682 | Copied from xml-backend by not adapted to sql (eilers) |
683 | 683 | ||
684 | QArray<int> m_currentQuery( m_events.count() ); | 684 | QArray<int> m_currentQuery( m_events.count() ); |
685 | uint arraycounter = 0; | 685 | uint arraycounter = 0; |
686 | 686 | ||
687 | 687 | ||
688 | 688 | ||
689 | QMap<int, OTodo>::ConstIterator it; | 689 | QMap<int, OPimTodo>::ConstIterator it; |
690 | for (it = m_events.begin(); it != m_events.end(); ++it ) { | 690 | for (it = m_events.begin(); it != m_events.end(); ++it ) { |
691 | if ( it.data().match( r ) ) | 691 | if ( it.data().match( r ) ) |
692 | m_currentQuery[arraycounter++] = it.data().uid(); | 692 | m_currentQuery[arraycounter++] = it.data().uid(); |
693 | 693 | ||
694 | } | 694 | } |
695 | // Shrink to fit.. | 695 | // Shrink to fit.. |
@@ -697,30 +697,30 @@ QArray<int> OTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const | |||
697 | 697 | ||
698 | return m_currentQuery; | 698 | return m_currentQuery; |
699 | #endif | 699 | #endif |
700 | QArray<int> empty; | 700 | QArray<int> empty; |
701 | return empty; | 701 | return empty; |
702 | } | 702 | } |
703 | QBitArray OTodoAccessBackendSQL::supports()const { | 703 | QBitArray OPimTodoAccessBackendSQL::supports()const { |
704 | 704 | ||
705 | return sup(); | 705 | return sup(); |
706 | } | 706 | } |
707 | 707 | ||
708 | QBitArray OTodoAccessBackendSQL::sup() const{ | 708 | QBitArray OPimTodoAccessBackendSQL::sup() const{ |
709 | 709 | ||
710 | QBitArray ar( OTodo::CompletedDate + 1 ); | 710 | QBitArray ar( OPimTodo::CompletedDate + 1 ); |
711 | ar.fill( true ); | 711 | ar.fill( true ); |
712 | ar[OTodo::CrossReference] = false; | 712 | ar[OPimTodo::CrossReference] = false; |
713 | ar[OTodo::State ] = false; | 713 | ar[OPimTodo::State ] = false; |
714 | ar[OTodo::Reminders] = false; | 714 | ar[OPimTodo::Reminders] = false; |
715 | ar[OTodo::Notifiers] = false; | 715 | ar[OPimTodo::Notifiers] = false; |
716 | ar[OTodo::Maintainer] = false; | 716 | ar[OPimTodo::Maintainer] = false; |
717 | 717 | ||
718 | return ar; | 718 | return ar; |
719 | } | 719 | } |
720 | 720 | ||
721 | void OTodoAccessBackendSQL::removeAllCompleted(){ | 721 | void OPimTodoAccessBackendSQL::removeAllCompleted(){ |
722 | #warning OTodoAccessBackendSQL::removeAllCompleted() not implemented !! | 722 | #warning OPimTodoAccessBackendSQL::removeAllCompleted() not implemented !! |
723 | 723 | ||
724 | } | 724 | } |
725 | 725 | ||
726 | } | 726 | } |
diff --git a/libopie2/opiepim/backend/otodoaccesssql.h b/libopie2/opiepim/backend/otodoaccesssql.h index 1a6f614..e945863 100644 --- a/libopie2/opiepim/backend/otodoaccesssql.h +++ b/libopie2/opiepim/backend/otodoaccesssql.h | |||
@@ -36,29 +36,29 @@ | |||
36 | class OSQLDriver; | 36 | class OSQLDriver; |
37 | class OSQLResult; | 37 | class OSQLResult; |
38 | class OSQLResultItem; | 38 | class OSQLResultItem; |
39 | 39 | ||
40 | namespace Opie { | 40 | namespace Opie { |
41 | 41 | ||
42 | class OTodoAccessBackendSQL : public OTodoAccessBackend { | 42 | class OPimTodoAccessBackendSQL : public OPimTodoAccessBackend { |
43 | public: | 43 | public: |
44 | OTodoAccessBackendSQL( const QString& file ); | 44 | OPimTodoAccessBackendSQL( const QString& file ); |
45 | ~OTodoAccessBackendSQL(); | 45 | ~OPimTodoAccessBackendSQL(); |
46 | 46 | ||
47 | bool load(); | 47 | bool load(); |
48 | bool reload(); | 48 | bool reload(); |
49 | bool save(); | 49 | bool save(); |
50 | QArray<int> allRecords()const; | 50 | QArray<int> allRecords()const; |
51 | 51 | ||
52 | QArray<int> queryByExample( const OTodo& t, int settings, const QDateTime& d = QDateTime() ); | 52 | QArray<int> queryByExample( const OPimTodo& t, int settings, const QDateTime& d = QDateTime() ); |
53 | OTodo find(int uid)const; | 53 | OPimTodo find(int uid)const; |
54 | OTodo find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; | 54 | OPimTodo find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; |
55 | void clear(); | 55 | void clear(); |
56 | bool add( const OTodo& t ); | 56 | bool add( const OPimTodo& t ); |
57 | bool remove( int uid ); | 57 | bool remove( int uid ); |
58 | bool replace( const OTodo& t ); | 58 | bool replace( const OPimTodo& t ); |
59 | 59 | ||
60 | QArray<int> overDue(); | 60 | QArray<int> overDue(); |
61 | QArray<int> effectiveToDos( const QDate& start, | 61 | QArray<int> effectiveToDos( const QDate& start, |
62 | const QDate& end, bool includeNoDates ); | 62 | const QDate& end, bool includeNoDates ); |
63 | QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat ); | 63 | QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat ); |
64 | 64 | ||
@@ -68,16 +68,16 @@ public: | |||
68 | 68 | ||
69 | 69 | ||
70 | private: | 70 | private: |
71 | void update()const; | 71 | void update()const; |
72 | void fillDict(); | 72 | void fillDict(); |
73 | inline bool date( QDate& date, const QString& )const; | 73 | inline bool date( QDate& date, const QString& )const; |
74 | inline OTodo todo( const OSQLResult& )const; | 74 | inline OPimTodo todo( const OSQLResult& )const; |
75 | inline OTodo todo( OSQLResultItem& )const; | 75 | inline OPimTodo todo( OSQLResultItem& )const; |
76 | inline QArray<int> uids( const OSQLResult& )const; | 76 | inline QArray<int> uids( const OSQLResult& )const; |
77 | OTodo todo( int uid )const; | 77 | OPimTodo todo( int uid )const; |
78 | QBitArray sup() const; | 78 | QBitArray sup() const; |
79 | 79 | ||
80 | QAsciiDict<int> m_dict; | 80 | QAsciiDict<int> m_dict; |
81 | OSQLDriver* m_driver; | 81 | OSQLDriver* m_driver; |
82 | QArray<int> m_uids; | 82 | QArray<int> m_uids; |
83 | bool m_dirty : 1; | 83 | bool m_dirty : 1; |
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp index e364ee2..0a1baf9 100644 --- a/libopie2/opiepim/backend/otodoaccessvcal.cpp +++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp | |||
@@ -34,14 +34,14 @@ | |||
34 | 34 | ||
35 | #include <opie2/otodoaccessvcal.h> | 35 | #include <opie2/otodoaccessvcal.h> |
36 | 36 | ||
37 | using namespace Opie; | 37 | using namespace Opie; |
38 | 38 | ||
39 | namespace { | 39 | namespace { |
40 | static OTodo eventByVObj( VObject *obj ){ | 40 | static OPimTodo eventByVObj( VObject *obj ){ |
41 | OTodo event; | 41 | OPimTodo event; |
42 | VObject *ob; | 42 | VObject *ob; |
43 | QCString name; | 43 | QCString name; |
44 | // no uid, attendees, ... and no fun | 44 | // no uid, attendees, ... and no fun |
45 | // description | 45 | // description |
46 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ | 46 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ |
47 | name = vObjectStringZValue( ob ); | 47 | name = vObjectStringZValue( ob ); |
@@ -88,13 +88,13 @@ namespace { | |||
88 | qWarning("Categories:%s", name.data() ); | 88 | qWarning("Categories:%s", name.data() ); |
89 | } | 89 | } |
90 | 90 | ||
91 | event.setUid( 1 ); | 91 | event.setUid( 1 ); |
92 | return event; | 92 | return event; |
93 | }; | 93 | }; |
94 | static VObject *vobjByEvent( const OTodo &event ) { | 94 | static VObject *vobjByEvent( const OPimTodo &event ) { |
95 | VObject *task = newVObject( VCTodoProp ); | 95 | VObject *task = newVObject( VCTodoProp ); |
96 | if( task == 0 ) | 96 | if( task == 0 ) |
97 | return 0l; | 97 | return 0l; |
98 | 98 | ||
99 | if( event.hasDueDate() ) { | 99 | if( event.hasDueDate() ) { |
100 | QTime time(0, 0, 0); | 100 | QTime time(0, 0, 0); |
@@ -135,19 +135,19 @@ namespace { | |||
135 | #endif | 135 | #endif |
136 | return task; | 136 | return task; |
137 | }; | 137 | }; |
138 | } | 138 | } |
139 | 139 | ||
140 | namespace Opie { | 140 | namespace Opie { |
141 | OTodoAccessVCal::OTodoAccessVCal( const QString& path ) | 141 | OPimTodoAccessVCal::OPimTodoAccessVCal( const QString& path ) |
142 | : m_dirty(false), m_file( path ) | 142 | : m_dirty(false), m_file( path ) |
143 | { | 143 | { |
144 | } | 144 | } |
145 | OTodoAccessVCal::~OTodoAccessVCal() { | 145 | OPimTodoAccessVCal::~OPimTodoAccessVCal() { |
146 | } | 146 | } |
147 | bool OTodoAccessVCal::load() { | 147 | bool OPimTodoAccessVCal::load() { |
148 | m_map.clear(); | 148 | m_map.clear(); |
149 | m_dirty = false; | 149 | m_dirty = false; |
150 | 150 | ||
151 | VObject* vcal = 0l; | 151 | VObject* vcal = 0l; |
152 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); | 152 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); |
153 | if (!vcal ) | 153 | if (!vcal ) |
@@ -160,123 +160,123 @@ bool OTodoAccessVCal::load() { | |||
160 | initPropIterator(&it, vcal); | 160 | initPropIterator(&it, vcal); |
161 | 161 | ||
162 | while( moreIteration( &it ) ) { | 162 | while( moreIteration( &it ) ) { |
163 | vobj = ::nextVObject( &it ); | 163 | vobj = ::nextVObject( &it ); |
164 | QCString name = ::vObjectName( vobj ); | 164 | QCString name = ::vObjectName( vobj ); |
165 | if( name == VCTodoProp ){ | 165 | if( name == VCTodoProp ){ |
166 | OTodo to = eventByVObj( vobj ); | 166 | OPimTodo to = eventByVObj( vobj ); |
167 | m_map.insert( to.uid(), to ); | 167 | m_map.insert( to.uid(), to ); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
171 | // Should I do a delete vcal? | 171 | // Should I do a delete vcal? |
172 | 172 | ||
173 | return true; | 173 | return true; |
174 | } | 174 | } |
175 | bool OTodoAccessVCal::reload() { | 175 | bool OPimTodoAccessVCal::reload() { |
176 | return load(); | 176 | return load(); |
177 | } | 177 | } |
178 | bool OTodoAccessVCal::save() { | 178 | bool OPimTodoAccessVCal::save() { |
179 | if (!m_dirty ) | 179 | if (!m_dirty ) |
180 | return true; | 180 | return true; |
181 | 181 | ||
182 | QFileDirect file( m_file ); | 182 | QFileDirect file( m_file ); |
183 | if (!file.open(IO_WriteOnly ) ) | 183 | if (!file.open(IO_WriteOnly ) ) |
184 | return false; | 184 | return false; |
185 | 185 | ||
186 | VObject *obj; | 186 | VObject *obj; |
187 | obj = newVObject( VCCalProp ); | 187 | obj = newVObject( VCCalProp ); |
188 | addPropValue( obj, VCVersionProp, "1.0" ); | 188 | addPropValue( obj, VCVersionProp, "1.0" ); |
189 | VObject *vo; | 189 | VObject *vo; |
190 | for(QMap<int, OTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ | 190 | for(QMap<int, OPimTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ |
191 | vo = vobjByEvent( it.data() ); | 191 | vo = vobjByEvent( it.data() ); |
192 | addVObjectProp(obj, vo ); | 192 | addVObjectProp(obj, vo ); |
193 | } | 193 | } |
194 | writeVObject( file.directHandle(), obj ); | 194 | writeVObject( file.directHandle(), obj ); |
195 | cleanVObject( obj ); | 195 | cleanVObject( obj ); |
196 | cleanStrTbl(); | 196 | cleanStrTbl(); |
197 | 197 | ||
198 | m_dirty = false; | 198 | m_dirty = false; |
199 | return true; | 199 | return true; |
200 | } | 200 | } |
201 | void OTodoAccessVCal::clear() { | 201 | void OPimTodoAccessVCal::clear() { |
202 | m_map.clear(); | 202 | m_map.clear(); |
203 | m_dirty = true; | 203 | m_dirty = true; |
204 | } | 204 | } |
205 | bool OTodoAccessVCal::add( const OTodo& to ) { | 205 | bool OPimTodoAccessVCal::add( const OPimTodo& to ) { |
206 | m_map.insert( to.uid(), to ); | 206 | m_map.insert( to.uid(), to ); |
207 | m_dirty = true; | 207 | m_dirty = true; |
208 | return true; | 208 | return true; |
209 | } | 209 | } |
210 | bool OTodoAccessVCal::remove( int uid ) { | 210 | bool OPimTodoAccessVCal::remove( int uid ) { |
211 | m_map.remove( uid ); | 211 | m_map.remove( uid ); |
212 | m_dirty = true; | 212 | m_dirty = true; |
213 | return true; | 213 | return true; |
214 | } | 214 | } |
215 | void OTodoAccessVCal::removeAllCompleted() { | 215 | void OPimTodoAccessVCal::removeAllCompleted() { |
216 | for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { | 216 | for ( QMap<int, OPimTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { |
217 | if ( (*it).isCompleted() ) | 217 | if ( (*it).isCompleted() ) |
218 | m_map.remove( it ); | 218 | m_map.remove( it ); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | bool OTodoAccessVCal::replace( const OTodo& to ) { | 221 | bool OPimTodoAccessVCal::replace( const OPimTodo& to ) { |
222 | m_map.replace( to.uid(), to ); | 222 | m_map.replace( to.uid(), to ); |
223 | m_dirty = true; | 223 | m_dirty = true; |
224 | return true; | 224 | return true; |
225 | } | 225 | } |
226 | OTodo OTodoAccessVCal::find(int uid )const { | 226 | OPimTodo OPimTodoAccessVCal::find(int uid )const { |
227 | return m_map[uid]; | 227 | return m_map[uid]; |
228 | } | 228 | } |
229 | QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { | 229 | QArray<int> OPimTodoAccessVCal::sorted( bool, int, int, int ) { |
230 | QArray<int> ar(0); | 230 | QArray<int> ar(0); |
231 | return ar; | 231 | return ar; |
232 | } | 232 | } |
233 | QArray<int> OTodoAccessVCal::allRecords()const { | 233 | QArray<int> OPimTodoAccessVCal::allRecords()const { |
234 | QArray<int> ar( m_map.count() ); | 234 | QArray<int> ar( m_map.count() ); |
235 | QMap<int, OTodo>::ConstIterator it; | 235 | QMap<int, OPimTodo>::ConstIterator it; |
236 | int i = 0; | 236 | int i = 0; |
237 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { | 237 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { |
238 | ar[i] = it.key(); | 238 | ar[i] = it.key(); |
239 | i++; | 239 | i++; |
240 | } | 240 | } |
241 | return ar; | 241 | return ar; |
242 | } | 242 | } |
243 | QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp& /* r */)const { | 243 | QArray<int> OPimTodoAccessVCal::matchRegexp(const QRegExp& /* r */)const { |
244 | QArray<int> ar(0); | 244 | QArray<int> ar(0); |
245 | return ar; | 245 | return ar; |
246 | } | 246 | } |
247 | QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { | 247 | QArray<int> OPimTodoAccessVCal::queryByExample( const OPimTodo&, int, const QDateTime& ) { |
248 | QArray<int> ar(0); | 248 | QArray<int> ar(0); |
249 | return ar; | 249 | return ar; |
250 | } | 250 | } |
251 | QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , | 251 | QArray<int> OPimTodoAccessVCal::effectiveToDos( const QDate& , |
252 | const QDate& , | 252 | const QDate& , |
253 | bool ) { | 253 | bool ) { |
254 | QArray<int> ar(0); | 254 | QArray<int> ar(0); |
255 | return ar; | 255 | return ar; |
256 | } | 256 | } |
257 | QArray<int> OTodoAccessVCal::overDue() { | 257 | QArray<int> OPimTodoAccessVCal::overDue() { |
258 | QArray<int> ar(0); | 258 | QArray<int> ar(0); |
259 | return ar; | 259 | return ar; |
260 | } | 260 | } |
261 | QBitArray OTodoAccessVCal::supports()const { | 261 | QBitArray OPimTodoAccessVCal::supports()const { |
262 | static QBitArray ar = sup(); | 262 | static QBitArray ar = sup(); |
263 | 263 | ||
264 | return ar; | 264 | return ar; |
265 | } | 265 | } |
266 | QBitArray OTodoAccessVCal::sup() { | 266 | QBitArray OPimTodoAccessVCal::sup() { |
267 | QBitArray ar ( OTodo::CompletedDate +1 ); | 267 | QBitArray ar ( OPimTodo::CompletedDate +1 ); |
268 | ar.fill( true ); | 268 | ar.fill( true ); |
269 | 269 | ||
270 | ar[OTodo::CrossReference] = false; | 270 | ar[OPimTodo::CrossReference] = false; |
271 | ar[OTodo::State ] = false; | 271 | ar[OPimTodo::State ] = false; |
272 | ar[OTodo::Reminders] = false; | 272 | ar[OPimTodo::Reminders] = false; |
273 | ar[OTodo::Notifiers] = false; | 273 | ar[OPimTodo::Notifiers] = false; |
274 | ar[OTodo::Maintainer] = false; | 274 | ar[OPimTodo::Maintainer] = false; |
275 | ar[OTodo::Progress] = false; | 275 | ar[OPimTodo::Progress] = false; |
276 | ar[OTodo::Alarms ] = false; | 276 | ar[OPimTodo::Alarms ] = false; |
277 | ar[OTodo::Recurrence] = false; | 277 | ar[OPimTodo::Recurrence] = false; |
278 | 278 | ||
279 | return ar; | 279 | return ar; |
280 | } | 280 | } |
281 | 281 | ||
282 | } | 282 | } |
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.h b/libopie2/opiepim/backend/otodoaccessvcal.h index f9323fb..1e106d3 100644 --- a/libopie2/opiepim/backend/otodoaccessvcal.h +++ b/libopie2/opiepim/backend/otodoaccessvcal.h | |||
@@ -30,43 +30,43 @@ | |||
30 | #define OPIE_OTODO_ACCESS_VCAL_H | 30 | #define OPIE_OTODO_ACCESS_VCAL_H |
31 | 31 | ||
32 | #include <opie2/otodoaccessbackend.h> | 32 | #include <opie2/otodoaccessbackend.h> |
33 | 33 | ||
34 | namespace Opie { | 34 | namespace Opie { |
35 | 35 | ||
36 | class OTodoAccessVCal : public OTodoAccessBackend { | 36 | class OPimTodoAccessVCal : public OPimTodoAccessBackend { |
37 | public: | 37 | public: |
38 | OTodoAccessVCal(const QString& ); | 38 | OPimTodoAccessVCal(const QString& ); |
39 | ~OTodoAccessVCal(); | 39 | ~OPimTodoAccessVCal(); |
40 | 40 | ||
41 | bool load(); | 41 | bool load(); |
42 | bool reload(); | 42 | bool reload(); |
43 | bool save(); | 43 | bool save(); |
44 | 44 | ||
45 | QArray<int> allRecords()const; | 45 | QArray<int> allRecords()const; |
46 | QArray<int> matchRegexp(const QRegExp &r) const; | 46 | QArray<int> matchRegexp(const QRegExp &r) const; |
47 | QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() ); | 47 | QArray<int> queryByExample( const OPimTodo& t, int sort, const QDateTime& d = QDateTime() ); |
48 | QArray<int> effectiveToDos( const QDate& start, | 48 | QArray<int> effectiveToDos( const QDate& start, |
49 | const QDate& end, | 49 | const QDate& end, |
50 | bool includeNoDates ); | 50 | bool includeNoDates ); |
51 | QArray<int> overDue(); | 51 | QArray<int> overDue(); |
52 | QArray<int> sorted( bool asc, int sortOrder, int sortFilter, | 52 | QArray<int> sorted( bool asc, int sortOrder, int sortFilter, |
53 | int cat ); | 53 | int cat ); |
54 | OTodo find(int uid)const; | 54 | OPimTodo find(int uid)const; |
55 | void clear(); | 55 | void clear(); |
56 | bool add( const OTodo& ); | 56 | bool add( const OPimTodo& ); |
57 | bool remove( int uid ); | 57 | bool remove( int uid ); |
58 | bool replace( const OTodo& ); | 58 | bool replace( const OPimTodo& ); |
59 | 59 | ||
60 | void removeAllCompleted(); | 60 | void removeAllCompleted(); |
61 | virtual QBitArray supports()const; | 61 | virtual QBitArray supports()const; |
62 | 62 | ||
63 | private: | 63 | private: |
64 | static QBitArray sup(); | 64 | static QBitArray sup(); |
65 | bool m_dirty : 1; | 65 | bool m_dirty : 1; |
66 | QString m_file; | 66 | QString m_file; |
67 | QMap<int, OTodo> m_map; | 67 | QMap<int, OPimTodo> m_map; |
68 | }; | 68 | }; |
69 | 69 | ||
70 | } | 70 | } |
71 | 71 | ||
72 | #endif | 72 | #endif |
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index 2d50ecd..cce6111 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp | |||
@@ -40,31 +40,31 @@ | |||
40 | #include <qvector.h> | 40 | #include <qvector.h> |
41 | 41 | ||
42 | #include <qpe/global.h> | 42 | #include <qpe/global.h> |
43 | #include <qpe/stringutil.h> | 43 | #include <qpe/stringutil.h> |
44 | #include <qpe/timeconversion.h> | 44 | #include <qpe/timeconversion.h> |
45 | 45 | ||
46 | #include <opie2/oconversion.h> | 46 | #include <opie2/opimdateconversion.h> |
47 | #include <opie2/opimstate.h> | 47 | #include <opie2/opimstate.h> |
48 | #include <opie2/otimezone.h> | 48 | #include <opie2/opimtimezone.h> |
49 | #include <opie2/opimnotifymanager.h> | 49 | #include <opie2/opimnotifymanager.h> |
50 | #include <opie2/orecur.h> | 50 | #include <opie2/opimrecurrence.h> |
51 | #include <opie2/otodoaccessxml.h> | 51 | #include <opie2/otodoaccessxml.h> |
52 | 52 | ||
53 | using namespace Opie; | 53 | using namespace Opie; |
54 | 54 | ||
55 | namespace { | 55 | namespace { |
56 | time_t rp_end; | 56 | time_t rp_end; |
57 | ORecur* rec; | 57 | OPimRecurrence* rec; |
58 | ORecur *recur() { | 58 | OPimRecurrence *recur() { |
59 | if (!rec ) rec = new ORecur; | 59 | if (!rec ) rec = new OPimRecurrence; |
60 | return rec; | 60 | return rec; |
61 | } | 61 | } |
62 | int snd; | 62 | int snd; |
63 | enum MoreAttributes { | 63 | enum MoreAttributes { |
64 | FRType = OTodo::CompletedDate + 2, | 64 | FRType = OPimTodo::CompletedDate + 2, |
65 | FRWeekdays, | 65 | FRWeekdays, |
66 | FRPosition, | 66 | FRPosition, |
67 | FRFreq, | 67 | FRFreq, |
68 | FRHasEndDate, | 68 | FRHasEndDate, |
69 | FREndDate, | 69 | FREndDate, |
70 | FRStart, | 70 | FRStart, |
@@ -95,53 +95,53 @@ char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) | |||
95 | return ((char *)hsearch); | 95 | return ((char *)hsearch); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | namespace Opie { | 99 | namespace Opie { |
100 | 100 | ||
101 | OTodoAccessXML::OTodoAccessXML( const QString& appName, | 101 | OPimTodoAccessXML::OPimTodoAccessXML( const QString& appName, |
102 | const QString& fileName ) | 102 | const QString& fileName ) |
103 | : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) | 103 | : OPimTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) |
104 | { | 104 | { |
105 | if (!fileName.isEmpty() ) | 105 | if (!fileName.isEmpty() ) |
106 | m_file = fileName; | 106 | m_file = fileName; |
107 | else | 107 | else |
108 | m_file = Global::applicationFileName( "todolist", "todolist.xml" ); | 108 | m_file = Global::applicationFileName( "todolist", "todolist.xml" ); |
109 | } | 109 | } |
110 | OTodoAccessXML::~OTodoAccessXML() { | 110 | OPimTodoAccessXML::~OPimTodoAccessXML() { |
111 | 111 | ||
112 | } | 112 | } |
113 | bool OTodoAccessXML::load() { | 113 | bool OPimTodoAccessXML::load() { |
114 | rec = 0; | 114 | rec = 0; |
115 | m_opened = true; | 115 | m_opened = true; |
116 | m_changed = false; | 116 | m_changed = false; |
117 | /* initialize dict */ | 117 | /* initialize dict */ |
118 | /* | 118 | /* |
119 | * UPDATE dict if you change anything!!! | 119 | * UPDATE dict if you change anything!!! |
120 | */ | 120 | */ |
121 | QAsciiDict<int> dict(26); | 121 | QAsciiDict<int> dict(26); |
122 | dict.setAutoDelete( TRUE ); | 122 | dict.setAutoDelete( TRUE ); |
123 | dict.insert("Categories" , new int(OTodo::Category) ); | 123 | dict.insert("Categories" , new int(OPimTodo::Category) ); |
124 | dict.insert("Uid" , new int(OTodo::Uid) ); | 124 | dict.insert("Uid" , new int(OPimTodo::Uid) ); |
125 | dict.insert("HasDate" , new int(OTodo::HasDate) ); | 125 | dict.insert("HasDate" , new int(OPimTodo::HasDate) ); |
126 | dict.insert("Completed" , new int(OTodo::Completed) ); | 126 | dict.insert("Completed" , new int(OPimTodo::Completed) ); |
127 | dict.insert("Description" , new int(OTodo::Description) ); | 127 | dict.insert("Description" , new int(OPimTodo::Description) ); |
128 | dict.insert("Summary" , new int(OTodo::Summary) ); | 128 | dict.insert("Summary" , new int(OPimTodo::Summary) ); |
129 | dict.insert("Priority" , new int(OTodo::Priority) ); | 129 | dict.insert("Priority" , new int(OPimTodo::Priority) ); |
130 | dict.insert("DateDay" , new int(OTodo::DateDay) ); | 130 | dict.insert("DateDay" , new int(OPimTodo::DateDay) ); |
131 | dict.insert("DateMonth" , new int(OTodo::DateMonth) ); | 131 | dict.insert("DateMonth" , new int(OPimTodo::DateMonth) ); |
132 | dict.insert("DateYear" , new int(OTodo::DateYear) ); | 132 | dict.insert("DateYear" , new int(OPimTodo::DateYear) ); |
133 | dict.insert("Progress" , new int(OTodo::Progress) ); | 133 | dict.insert("Progress" , new int(OPimTodo::Progress) ); |
134 | dict.insert("CompletedDate", new int(OTodo::CompletedDate) ); | 134 | dict.insert("CompletedDate", new int(OPimTodo::CompletedDate) ); |
135 | dict.insert("StartDate", new int(OTodo::StartDate) ); | 135 | dict.insert("StartDate", new int(OPimTodo::StartDate) ); |
136 | dict.insert("CrossReference", new int(OTodo::CrossReference) ); | 136 | dict.insert("CrossReference", new int(OPimTodo::CrossReference) ); |
137 | dict.insert("State", new int(OTodo::State) ); | 137 | dict.insert("State", new int(OPimTodo::State) ); |
138 | dict.insert("Alarms", new int(OTodo::Alarms) ); | 138 | dict.insert("Alarms", new int(OPimTodo::Alarms) ); |
139 | dict.insert("Reminders", new int(OTodo::Reminders) ); | 139 | dict.insert("Reminders", new int(OPimTodo::Reminders) ); |
140 | dict.insert("Notifiers", new int(OTodo::Notifiers) ); | 140 | dict.insert("Notifiers", new int(OPimTodo::Notifiers) ); |
141 | dict.insert("Maintainer", new int(OTodo::Maintainer) ); | 141 | dict.insert("Maintainer", new int(OPimTodo::Maintainer) ); |
142 | dict.insert("rtype", new int(FRType) ); | 142 | dict.insert("rtype", new int(FRType) ); |
143 | dict.insert("rweekdays", new int(FRWeekdays) ); | 143 | dict.insert("rweekdays", new int(FRWeekdays) ); |
144 | dict.insert("rposition", new int(FRPosition) ); | 144 | dict.insert("rposition", new int(FRPosition) ); |
145 | dict.insert("rfreq", new int(FRFreq) ); | 145 | dict.insert("rfreq", new int(FRFreq) ); |
146 | dict.insert("start", new int(FRStart) ); | 146 | dict.insert("start", new int(FRStart) ); |
147 | dict.insert("rhasenddate", new int(FRHasEndDate) ); | 147 | dict.insert("rhasenddate", new int(FRHasEndDate) ); |
@@ -176,13 +176,13 @@ bool OTodoAccessXML::load() { | |||
176 | int strLen = strlen(collectionString); | 176 | int strLen = strlen(collectionString); |
177 | while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { | 177 | while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { |
178 | i = point -dt; | 178 | i = point -dt; |
179 | i+= strLen; | 179 | i+= strLen; |
180 | qWarning("Found a start at %d %d", i, (point-dt) ); | 180 | qWarning("Found a start at %d %d", i, (point-dt) ); |
181 | 181 | ||
182 | OTodo ev; | 182 | OPimTodo ev; |
183 | m_year = m_month = m_day = 0; | 183 | m_year = m_month = m_day = 0; |
184 | 184 | ||
185 | while ( TRUE ) { | 185 | while ( TRUE ) { |
186 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) | 186 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) |
187 | ++i; | 187 | ++i; |
188 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) | 188 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) |
@@ -239,14 +239,14 @@ bool OTodoAccessXML::load() { | |||
239 | m_changed = true; | 239 | m_changed = true; |
240 | } | 240 | } |
241 | if ( ev.hasDueDate() ) { | 241 | if ( ev.hasDueDate() ) { |
242 | ev.setDueDate( QDate(m_year, m_month, m_day) ); | 242 | ev.setDueDate( QDate(m_year, m_month, m_day) ); |
243 | } | 243 | } |
244 | if ( rec && rec->doesRecur() ) { | 244 | if ( rec && rec->doesRecur() ) { |
245 | OTimeZone utc = OTimeZone::utc(); | 245 | OPimTimeZone utc = OPimTimeZone::utc(); |
246 | ORecur recu( *rec ); // call copy c'tor | 246 | OPimRecurrence recu( *rec ); // call copy c'tor |
247 | recu.setEndDate( utc.fromUTCDateTime( rp_end ).date() ); | 247 | recu.setEndDate( utc.fromUTCDateTime( rp_end ).date() ); |
248 | recu.setStart( ev.dueDate() ); | 248 | recu.setStart( ev.dueDate() ); |
249 | ev.setRecurrence( recu ); | 249 | ev.setRecurrence( recu ); |
250 | } | 250 | } |
251 | m_events.insert(ev.uid(), ev ); | 251 | m_events.insert(ev.uid(), ev ); |
252 | m_year = m_month = m_day = -1; | 252 | m_year = m_month = m_day = -1; |
@@ -256,17 +256,17 @@ bool OTodoAccessXML::load() { | |||
256 | 256 | ||
257 | munmap(map_addr, attribut.st_size ); | 257 | munmap(map_addr, attribut.st_size ); |
258 | 258 | ||
259 | qWarning("counts %d records loaded!", m_events.count() ); | 259 | qWarning("counts %d records loaded!", m_events.count() ); |
260 | return true; | 260 | return true; |
261 | } | 261 | } |
262 | bool OTodoAccessXML::reload() { | 262 | bool OPimTodoAccessXML::reload() { |
263 | m_events.clear(); | 263 | m_events.clear(); |
264 | return load(); | 264 | return load(); |
265 | } | 265 | } |
266 | bool OTodoAccessXML::save() { | 266 | bool OPimTodoAccessXML::save() { |
267 | // qWarning("saving"); | 267 | // qWarning("saving"); |
268 | if (!m_opened || !m_changed ) { | 268 | if (!m_opened || !m_changed ) { |
269 | // qWarning("not saving"); | 269 | // qWarning("not saving"); |
270 | return true; | 270 | return true; |
271 | } | 271 | } |
272 | QString strNewFile = m_file + ".new"; | 272 | QString strNewFile = m_file + ".new"; |
@@ -276,13 +276,13 @@ bool OTodoAccessXML::save() { | |||
276 | 276 | ||
277 | int written; | 277 | int written; |
278 | QString out; | 278 | QString out; |
279 | out = "<!DOCTYPE Tasks>\n<Tasks>\n"; | 279 | out = "<!DOCTYPE Tasks>\n<Tasks>\n"; |
280 | 280 | ||
281 | // for all todos | 281 | // for all todos |
282 | QMap<int, OTodo>::Iterator it; | 282 | QMap<int, OPimTodo>::Iterator it; |
283 | for (it = m_events.begin(); it != m_events.end(); ++it ) { | 283 | for (it = m_events.begin(); it != m_events.end(); ++it ) { |
284 | out+= "<Task " + toString( (*it) ) + " />\n"; | 284 | out+= "<Task " + toString( (*it) ) + " />\n"; |
285 | QCString cstr = out.utf8(); | 285 | QCString cstr = out.utf8(); |
286 | written = f.writeBlock( cstr.data(), cstr.length() ); | 286 | written = f.writeBlock( cstr.data(), cstr.length() ); |
287 | 287 | ||
288 | /* less written then we wanted */ | 288 | /* less written then we wanted */ |
@@ -311,66 +311,66 @@ bool OTodoAccessXML::save() { | |||
311 | QFile::remove( strNewFile ); | 311 | QFile::remove( strNewFile ); |
312 | } | 312 | } |
313 | 313 | ||
314 | m_changed = false; | 314 | m_changed = false; |
315 | return true; | 315 | return true; |
316 | } | 316 | } |
317 | QArray<int> OTodoAccessXML::allRecords()const { | 317 | QArray<int> OPimTodoAccessXML::allRecords()const { |
318 | QArray<int> ids( m_events.count() ); | 318 | QArray<int> ids( m_events.count() ); |
319 | QMap<int, OTodo>::ConstIterator it; | 319 | QMap<int, OPimTodo>::ConstIterator it; |
320 | int i = 0; | 320 | int i = 0; |
321 | 321 | ||
322 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 322 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
323 | ids[i] = it.key(); | 323 | ids[i] = it.key(); |
324 | i++; | 324 | i++; |
325 | } | 325 | } |
326 | return ids; | 326 | return ids; |
327 | } | 327 | } |
328 | QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int, const QDateTime& ) { | 328 | QArray<int> OPimTodoAccessXML::queryByExample( const OPimTodo&, int, const QDateTime& ) { |
329 | QArray<int> ids(0); | 329 | QArray<int> ids(0); |
330 | return ids; | 330 | return ids; |
331 | } | 331 | } |
332 | OTodo OTodoAccessXML::find( int uid )const { | 332 | OPimTodo OPimTodoAccessXML::find( int uid )const { |
333 | OTodo todo; | 333 | OPimTodo todo; |
334 | todo.setUid( 0 ); // isEmpty() | 334 | todo.setUid( 0 ); // isEmpty() |
335 | QMap<int, OTodo>::ConstIterator it = m_events.find( uid ); | 335 | QMap<int, OPimTodo>::ConstIterator it = m_events.find( uid ); |
336 | if ( it != m_events.end() ) | 336 | if ( it != m_events.end() ) |
337 | todo = it.data(); | 337 | todo = it.data(); |
338 | 338 | ||
339 | return todo; | 339 | return todo; |
340 | } | 340 | } |
341 | void OTodoAccessXML::clear() { | 341 | void OPimTodoAccessXML::clear() { |
342 | if (m_opened ) | 342 | if (m_opened ) |
343 | m_changed = true; | 343 | m_changed = true; |
344 | 344 | ||
345 | m_events.clear(); | 345 | m_events.clear(); |
346 | } | 346 | } |
347 | bool OTodoAccessXML::add( const OTodo& todo ) { | 347 | bool OPimTodoAccessXML::add( const OPimTodo& todo ) { |
348 | // qWarning("add"); | 348 | // qWarning("add"); |
349 | m_changed = true; | 349 | m_changed = true; |
350 | m_events.insert( todo.uid(), todo ); | 350 | m_events.insert( todo.uid(), todo ); |
351 | 351 | ||
352 | return true; | 352 | return true; |
353 | } | 353 | } |
354 | bool OTodoAccessXML::remove( int uid ) { | 354 | bool OPimTodoAccessXML::remove( int uid ) { |
355 | m_changed = true; | 355 | m_changed = true; |
356 | m_events.remove( uid ); | 356 | m_events.remove( uid ); |
357 | 357 | ||
358 | return true; | 358 | return true; |
359 | } | 359 | } |
360 | bool OTodoAccessXML::replace( const OTodo& todo) { | 360 | bool OPimTodoAccessXML::replace( const OPimTodo& todo) { |
361 | m_changed = true; | 361 | m_changed = true; |
362 | m_events.replace( todo.uid(), todo ); | 362 | m_events.replace( todo.uid(), todo ); |
363 | 363 | ||
364 | return true; | 364 | return true; |
365 | } | 365 | } |
366 | QArray<int> OTodoAccessXML::effectiveToDos( const QDate& start, | 366 | QArray<int> OPimTodoAccessXML::effectiveToDos( const QDate& start, |
367 | const QDate& end, | 367 | const QDate& end, |
368 | bool includeNoDates ) { | 368 | bool includeNoDates ) { |
369 | QArray<int> ids( m_events.count() ); | 369 | QArray<int> ids( m_events.count() ); |
370 | QMap<int, OTodo>::Iterator it; | 370 | QMap<int, OPimTodo>::Iterator it; |
371 | 371 | ||
372 | int i = 0; | 372 | int i = 0; |
373 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 373 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
374 | if ( !it.data().hasDueDate() ) { | 374 | if ( !it.data().hasDueDate() ) { |
375 | if ( includeNoDates ) { | 375 | if ( includeNoDates ) { |
376 | ids[i] = it.key(); | 376 | ids[i] = it.key(); |
@@ -382,30 +382,30 @@ QArray<int> OTodoAccessXML::effectiveToDos( const QDate& start, | |||
382 | i++; | 382 | i++; |
383 | } | 383 | } |
384 | } | 384 | } |
385 | ids.resize( i ); | 385 | ids.resize( i ); |
386 | return ids; | 386 | return ids; |
387 | } | 387 | } |
388 | QArray<int> OTodoAccessXML::overDue() { | 388 | QArray<int> OPimTodoAccessXML::overDue() { |
389 | QArray<int> ids( m_events.count() ); | 389 | QArray<int> ids( m_events.count() ); |
390 | int i = 0; | 390 | int i = 0; |
391 | 391 | ||
392 | QMap<int, OTodo>::Iterator it; | 392 | QMap<int, OPimTodo>::Iterator it; |
393 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 393 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
394 | if ( it.data().isOverdue() ) { | 394 | if ( it.data().isOverdue() ) { |
395 | ids[i] = it.key(); | 395 | ids[i] = it.key(); |
396 | i++; | 396 | i++; |
397 | } | 397 | } |
398 | } | 398 | } |
399 | ids.resize( i ); | 399 | ids.resize( i ); |
400 | return ids; | 400 | return ids; |
401 | } | 401 | } |
402 | 402 | ||
403 | 403 | ||
404 | /* private */ | 404 | /* private */ |
405 | void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev, | 405 | void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev, |
406 | const QCString& attr, const QString& val) { | 406 | const QCString& attr, const QString& val) { |
407 | // qWarning("parse to do from XMLElement" ); | 407 | // qWarning("parse to do from XMLElement" ); |
408 | 408 | ||
409 | int *find=0; | 409 | int *find=0; |
410 | 410 | ||
411 | find = (*dict)[ attr.data() ]; | 411 | find = (*dict)[ attr.data() ]; |
@@ -413,76 +413,76 @@ void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev, | |||
413 | // qWarning("Unknown option" + it.key() ); | 413 | // qWarning("Unknown option" + it.key() ); |
414 | ev.setCustomField( attr, val ); | 414 | ev.setCustomField( attr, val ); |
415 | return; | 415 | return; |
416 | } | 416 | } |
417 | 417 | ||
418 | switch( *find ) { | 418 | switch( *find ) { |
419 | case OTodo::Uid: | 419 | case OPimTodo::Uid: |
420 | ev.setUid( val.toInt() ); | 420 | ev.setUid( val.toInt() ); |
421 | break; | 421 | break; |
422 | case OTodo::Category: | 422 | case OPimTodo::Category: |
423 | ev.setCategories( ev.idsFromString( val ) ); | 423 | ev.setCategories( ev.idsFromString( val ) ); |
424 | break; | 424 | break; |
425 | case OTodo::HasDate: | 425 | case OPimTodo::HasDate: |
426 | ev.setHasDueDate( val.toInt() ); | 426 | ev.setHasDueDate( val.toInt() ); |
427 | break; | 427 | break; |
428 | case OTodo::Completed: | 428 | case OPimTodo::Completed: |
429 | ev.setCompleted( val.toInt() ); | 429 | ev.setCompleted( val.toInt() ); |
430 | break; | 430 | break; |
431 | case OTodo::Description: | 431 | case OPimTodo::Description: |
432 | ev.setDescription( val ); | 432 | ev.setDescription( val ); |
433 | break; | 433 | break; |
434 | case OTodo::Summary: | 434 | case OPimTodo::Summary: |
435 | ev.setSummary( val ); | 435 | ev.setSummary( val ); |
436 | break; | 436 | break; |
437 | case OTodo::Priority: | 437 | case OPimTodo::Priority: |
438 | ev.setPriority( val.toInt() ); | 438 | ev.setPriority( val.toInt() ); |
439 | break; | 439 | break; |
440 | case OTodo::DateDay: | 440 | case OPimTodo::DateDay: |
441 | m_day = val.toInt(); | 441 | m_day = val.toInt(); |
442 | break; | 442 | break; |
443 | case OTodo::DateMonth: | 443 | case OPimTodo::DateMonth: |
444 | m_month = val.toInt(); | 444 | m_month = val.toInt(); |
445 | break; | 445 | break; |
446 | case OTodo::DateYear: | 446 | case OPimTodo::DateYear: |
447 | m_year = val.toInt(); | 447 | m_year = val.toInt(); |
448 | break; | 448 | break; |
449 | case OTodo::Progress: | 449 | case OPimTodo::Progress: |
450 | ev.setProgress( val.toInt() ); | 450 | ev.setProgress( val.toInt() ); |
451 | break; | 451 | break; |
452 | case OTodo::CompletedDate: | 452 | case OPimTodo::CompletedDate: |
453 | ev.setCompletedDate( OConversion::dateFromString( val ) ); | 453 | ev.setCompletedDate( OPimDateConversion::dateFromString( val ) ); |
454 | break; | 454 | break; |
455 | case OTodo::StartDate: | 455 | case OPimTodo::StartDate: |
456 | ev.setStartDate( OConversion::dateFromString( val ) ); | 456 | ev.setStartDate( OPimDateConversion::dateFromString( val ) ); |
457 | break; | 457 | break; |
458 | case OTodo::State: | 458 | case OPimTodo::State: |
459 | ev.setState( val.toInt() ); | 459 | ev.setState( val.toInt() ); |
460 | break; | 460 | break; |
461 | case OTodo::Alarms:{ | 461 | case OPimTodo::Alarms:{ |
462 | OPimNotifyManager &manager = ev.notifiers(); | 462 | OPimNotifyManager &manager = ev.notifiers(); |
463 | QStringList als = QStringList::split(";", val ); | 463 | QStringList als = QStringList::split(";", val ); |
464 | for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { | 464 | for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { |
465 | QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty | 465 | QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty |
466 | qWarning("alarm: %s", alarm.join("___").latin1() ); | 466 | qWarning("alarm: %s", alarm.join("___").latin1() ); |
467 | qWarning("alarm[0]: %s %s", alarm[0].latin1(), OConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); | 467 | qWarning("alarm[0]: %s %s", alarm[0].latin1(), OPimDateConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); |
468 | OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() ); | 468 | OPimAlarm al( alarm[2].toInt(), OPimDateConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() ); |
469 | manager.add( al ); | 469 | manager.add( al ); |
470 | } | 470 | } |
471 | } | 471 | } |
472 | break; | 472 | break; |
473 | case OTodo::Reminders:{ | 473 | case OPimTodo::Reminders:{ |
474 | OPimNotifyManager &manager = ev.notifiers(); | 474 | OPimNotifyManager &manager = ev.notifiers(); |
475 | QStringList rems = QStringList::split(";", val ); | 475 | QStringList rems = QStringList::split(";", val ); |
476 | for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { | 476 | for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { |
477 | OPimReminder rem( (*it).toInt() ); | 477 | OPimReminder rem( (*it).toInt() ); |
478 | manager.add( rem ); | 478 | manager.add( rem ); |
479 | } | 479 | } |
480 | } | 480 | } |
481 | break; | 481 | break; |
482 | case OTodo::CrossReference: | 482 | case OPimTodo::CrossReference: |
483 | { | 483 | { |
484 | /* | 484 | /* |
485 | * A cross refernce looks like | 485 | * A cross refernce looks like |
486 | * appname,id;appname,id | 486 | * appname,id;appname,id |
487 | * we need to split it up | 487 | * we need to split it up |
488 | */ | 488 | */ |
@@ -496,23 +496,23 @@ void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev, | |||
496 | } | 496 | } |
497 | break; | 497 | break; |
498 | } | 498 | } |
499 | /* Recurrence stuff below + post processing later */ | 499 | /* Recurrence stuff below + post processing later */ |
500 | case FRType: | 500 | case FRType: |
501 | if ( val == "Daily" ) | 501 | if ( val == "Daily" ) |
502 | recur()->setType( ORecur::Daily ); | 502 | recur()->setType( OPimRecurrence::Daily ); |
503 | else if ( val == "Weekly" ) | 503 | else if ( val == "Weekly" ) |
504 | recur()->setType( ORecur::Weekly); | 504 | recur()->setType( OPimRecurrence::Weekly); |
505 | else if ( val == "MonthlyDay" ) | 505 | else if ( val == "MonthlyDay" ) |
506 | recur()->setType( ORecur::MonthlyDay ); | 506 | recur()->setType( OPimRecurrence::MonthlyDay ); |
507 | else if ( val == "MonthlyDate" ) | 507 | else if ( val == "MonthlyDate" ) |
508 | recur()->setType( ORecur::MonthlyDate ); | 508 | recur()->setType( OPimRecurrence::MonthlyDate ); |
509 | else if ( val == "Yearly" ) | 509 | else if ( val == "Yearly" ) |
510 | recur()->setType( ORecur::Yearly ); | 510 | recur()->setType( OPimRecurrence::Yearly ); |
511 | else | 511 | else |
512 | recur()->setType( ORecur::NoRepeat ); | 512 | recur()->setType( OPimRecurrence::NoRepeat ); |
513 | break; | 513 | break; |
514 | case FRWeekdays: | 514 | case FRWeekdays: |
515 | recur()->setDays( val.toInt() ); | 515 | recur()->setDays( val.toInt() ); |
516 | break; | 516 | break; |
517 | case FRPosition: | 517 | case FRPosition: |
518 | recur()->setPosition( val.toInt() ); | 518 | recur()->setPosition( val.toInt() ); |
@@ -550,13 +550,13 @@ QString customToXml(const QMap<QString, QString>& customMap ) | |||
550 | return buf; | 550 | return buf; |
551 | } | 551 | } |
552 | 552 | ||
553 | 553 | ||
554 | } | 554 | } |
555 | 555 | ||
556 | QString OTodoAccessXML::toString( const OTodo& ev )const { | 556 | QString OPimTodoAccessXML::toString( const OPimTodo& ev )const { |
557 | QString str; | 557 | QString str; |
558 | 558 | ||
559 | str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; | 559 | str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; |
560 | str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; | 560 | str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; |
561 | str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; | 561 | str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; |
562 | str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; | 562 | str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; |
@@ -588,15 +588,15 @@ QString OTodoAccessXML::toString( const OTodo& ev )const { | |||
588 | */ | 588 | */ |
589 | // cross refernce | 589 | // cross refernce |
590 | if ( ev.hasRecurrence() ) { | 590 | if ( ev.hasRecurrence() ) { |
591 | str += ev.recurrence().toString(); | 591 | str += ev.recurrence().toString(); |
592 | } | 592 | } |
593 | if ( ev.hasStartDate() ) | 593 | if ( ev.hasStartDate() ) |
594 | str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" "; | 594 | str += "StartDate=\""+ OPimDateConversion::dateToString( ev.startDate() ) +"\" "; |
595 | if ( ev.hasCompletedDate() ) | 595 | if ( ev.hasCompletedDate() ) |
596 | str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" "; | 596 | str += "CompletedDate=\""+ OPimDateConversion::dateToString( ev.completedDate() ) +"\" "; |
597 | if ( ev.hasState() ) | 597 | if ( ev.hasState() ) |
598 | str += "State=\""+QString::number( ev.state().state() )+"\" "; | 598 | str += "State=\""+QString::number( ev.state().state() )+"\" "; |
599 | 599 | ||
600 | /* | 600 | /* |
601 | * save reminders and notifiers! | 601 | * save reminders and notifiers! |
602 | * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER_DURATION:SOUND:.... | 602 | * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER_DURATION:SOUND:.... |
@@ -607,25 +607,25 @@ QString OTodoAccessXML::toString( const OTodo& ev )const { | |||
607 | if (!alarms.isEmpty() ) { | 607 | if (!alarms.isEmpty() ) { |
608 | QStringList als; | 608 | QStringList als; |
609 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); | 609 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); |
610 | for ( ; it != alarms.end(); ++it ) { | 610 | for ( ; it != alarms.end(); ++it ) { |
611 | /* only if time is valid */ | 611 | /* only if time is valid */ |
612 | if ( (*it).dateTime().isValid() ) { | 612 | if ( (*it).dateTime().isValid() ) { |
613 | als << OConversion::dateTimeToString( (*it).dateTime() ) | 613 | als << OPimDateConversion::dateTimeToString( (*it).dateTime() ) |
614 | + ":" + QString::number( (*it).duration() ) | 614 | + ":" + QString::number( (*it).duration() ) |
615 | + ":" + QString::number( (*it).sound() ) | 615 | + ":" + QString::number( (*it).sound() ) |
616 | + ":"; | 616 | + ":"; |
617 | } | 617 | } |
618 | } | 618 | } |
619 | // now write the list | 619 | // now write the list |
620 | qWarning("als: %s", als.join("____________").latin1() ); | 620 | qWarning("als: %s", als.join("____________").latin1() ); |
621 | str += "Alarms=\""+als.join(";") +"\" "; | 621 | str += "Alarms=\""+als.join(";") +"\" "; |
622 | } | 622 | } |
623 | 623 | ||
624 | /* | 624 | /* |
625 | * now the same for reminders but more easy. We just save the uid of the OEvent. | 625 | * now the same for reminders but more easy. We just save the uid of the OPimEvent. |
626 | */ | 626 | */ |
627 | OPimNotifyManager::Reminders reminders = manager.reminders(); | 627 | OPimNotifyManager::Reminders reminders = manager.reminders(); |
628 | if (!reminders.isEmpty() ) { | 628 | if (!reminders.isEmpty() ) { |
629 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); | 629 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); |
630 | QStringList records; | 630 | QStringList records; |
631 | for ( ; it != reminders.end(); ++it ) { | 631 | for ( ; it != reminders.end(); ++it ) { |
@@ -636,44 +636,44 @@ QString OTodoAccessXML::toString( const OTodo& ev )const { | |||
636 | } | 636 | } |
637 | str += customToXml( ev.toExtraMap() ); | 637 | str += customToXml( ev.toExtraMap() ); |
638 | 638 | ||
639 | 639 | ||
640 | return str; | 640 | return str; |
641 | } | 641 | } |
642 | QString OTodoAccessXML::toString( const QArray<int>& ints ) const { | 642 | QString OPimTodoAccessXML::toString( const QArray<int>& ints ) const { |
643 | return Qtopia::Record::idsToString( ints ); | 643 | return Qtopia::Record::idsToString( ints ); |
644 | } | 644 | } |
645 | 645 | ||
646 | /* internal class for sorting | 646 | /* internal class for sorting |
647 | * | 647 | * |
648 | * Inspired by todoxmlio.cpp from TT | 648 | * Inspired by todoxmlio.cpp from TT |
649 | */ | 649 | */ |
650 | 650 | ||
651 | struct OTodoXMLContainer { | 651 | struct OPimTodoXMLContainer { |
652 | OTodo todo; | 652 | OPimTodo todo; |
653 | }; | 653 | }; |
654 | 654 | ||
655 | namespace { | 655 | namespace { |
656 | inline QString string( const OTodo& todo) { | 656 | inline QString string( const OPimTodo& todo) { |
657 | return todo.summary().isEmpty() ? | 657 | return todo.summary().isEmpty() ? |
658 | todo.description().left(20 ) : | 658 | todo.description().left(20 ) : |
659 | todo.summary(); | 659 | todo.summary(); |
660 | } | 660 | } |
661 | inline int completed( const OTodo& todo1, const OTodo& todo2) { | 661 | inline int completed( const OPimTodo& todo1, const OPimTodo& todo2) { |
662 | int ret = 0; | 662 | int ret = 0; |
663 | if ( todo1.isCompleted() ) ret++; | 663 | if ( todo1.isCompleted() ) ret++; |
664 | if ( todo2.isCompleted() ) ret--; | 664 | if ( todo2.isCompleted() ) ret--; |
665 | return ret; | 665 | return ret; |
666 | } | 666 | } |
667 | inline int priority( const OTodo& t1, const OTodo& t2) { | 667 | inline int priority( const OPimTodo& t1, const OPimTodo& t2) { |
668 | return ( t1.priority() - t2.priority() ); | 668 | return ( t1.priority() - t2.priority() ); |
669 | } | 669 | } |
670 | inline int description( const OTodo& t1, const OTodo& t2) { | 670 | inline int description( const OPimTodo& t1, const OPimTodo& t2) { |
671 | return QString::compare( string(t1), string(t2) ); | 671 | return QString::compare( string(t1), string(t2) ); |
672 | } | 672 | } |
673 | inline int deadline( const OTodo& t1, const OTodo& t2) { | 673 | inline int deadline( const OPimTodo& t1, const OPimTodo& t2) { |
674 | int ret = 0; | 674 | int ret = 0; |
675 | if ( t1.hasDueDate() && | 675 | if ( t1.hasDueDate() && |
676 | t2.hasDueDate() ) | 676 | t2.hasDueDate() ) |
677 | ret = t2.dueDate().daysTo( t1.dueDate() ); | 677 | ret = t2.dueDate().daysTo( t1.dueDate() ); |
678 | else if ( t1.hasDueDate() ) | 678 | else if ( t1.hasDueDate() ) |
679 | ret = -1; | 679 | ret = -1; |
@@ -700,37 +700,37 @@ namespace { | |||
700 | * | 700 | * |
701 | * > 0 (positive integer) if item1 > item2 | 701 | * > 0 (positive integer) if item1 > item2 |
702 | * | 702 | * |
703 | * < 0 (negative integer) if item1 < item2 | 703 | * < 0 (negative integer) if item1 < item2 |
704 | * | 704 | * |
705 | */ | 705 | */ |
706 | class OTodoXMLVector : public QVector<OTodoXMLContainer> { | 706 | class OPimTodoXMLVector : public QVector<OPimTodoXMLContainer> { |
707 | public: | 707 | public: |
708 | OTodoXMLVector(int size, bool asc, int sort) | 708 | OPimTodoXMLVector(int size, bool asc, int sort) |
709 | : QVector<OTodoXMLContainer>( size ) | 709 | : QVector<OPimTodoXMLContainer>( size ) |
710 | { | 710 | { |
711 | setAutoDelete( true ); | 711 | setAutoDelete( true ); |
712 | m_asc = asc; | 712 | m_asc = asc; |
713 | m_sort = sort; | 713 | m_sort = sort; |
714 | } | 714 | } |
715 | /* return the summary/description */ | 715 | /* return the summary/description */ |
716 | QString string( const OTodo& todo) { | 716 | QString string( const OPimTodo& todo) { |
717 | return todo.summary().isEmpty() ? | 717 | return todo.summary().isEmpty() ? |
718 | todo.description().left(20 ) : | 718 | todo.description().left(20 ) : |
719 | todo.summary(); | 719 | todo.summary(); |
720 | } | 720 | } |
721 | /** | 721 | /** |
722 | * we take the sortorder( switch on it ) | 722 | * we take the sortorder( switch on it ) |
723 | * | 723 | * |
724 | */ | 724 | */ |
725 | int compareItems( Item d1, Item d2 ) { | 725 | int compareItems( Item d1, Item d2 ) { |
726 | bool seComp, sePrio, seDesc, seDeadline; | 726 | bool seComp, sePrio, seDesc, seDeadline; |
727 | seComp = sePrio = seDeadline = seDesc = false; | 727 | seComp = sePrio = seDeadline = seDesc = false; |
728 | int ret =0; | 728 | int ret =0; |
729 | OTodoXMLContainer* con1 = (OTodoXMLContainer*)d1; | 729 | OPimTodoXMLContainer* con1 = (OPimTodoXMLContainer*)d1; |
730 | OTodoXMLContainer* con2 = (OTodoXMLContainer*)d2; | 730 | OPimTodoXMLContainer* con2 = (OPimTodoXMLContainer*)d2; |
731 | 731 | ||
732 | /* same item */ | 732 | /* same item */ |
733 | if ( con1->todo.uid() == con2->todo.uid() ) | 733 | if ( con1->todo.uid() == con2->todo.uid() ) |
734 | return 0; | 734 | return 0; |
735 | 735 | ||
736 | switch ( m_sort ) { | 736 | switch ( m_sort ) { |
@@ -813,16 +813,16 @@ public: | |||
813 | private: | 813 | private: |
814 | bool m_asc; | 814 | bool m_asc; |
815 | int m_sort; | 815 | int m_sort; |
816 | 816 | ||
817 | }; | 817 | }; |
818 | 818 | ||
819 | QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, | 819 | QArray<int> OPimTodoAccessXML::sorted( bool asc, int sortOrder, |
820 | int sortFilter, int cat ) { | 820 | int sortFilter, int cat ) { |
821 | OTodoXMLVector vector(m_events.count(), asc,sortOrder ); | 821 | OPimTodoXMLVector vector(m_events.count(), asc,sortOrder ); |
822 | QMap<int, OTodo>::Iterator it; | 822 | QMap<int, OPimTodo>::Iterator it; |
823 | int item = 0; | 823 | int item = 0; |
824 | 824 | ||
825 | bool bCat = sortFilter & 1 ? true : false; | 825 | bool bCat = sortFilter & 1 ? true : false; |
826 | bool bOnly = sortFilter & 2 ? true : false; | 826 | bool bOnly = sortFilter & 2 ? true : false; |
827 | bool comp = sortFilter & 4 ? true : false; | 827 | bool comp = sortFilter & 4 ? true : false; |
828 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 828 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
@@ -848,13 +848,13 @@ QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, | |||
848 | 848 | ||
849 | if ((*it).isCompleted() && comp ) { | 849 | if ((*it).isCompleted() && comp ) { |
850 | continue; | 850 | continue; |
851 | } | 851 | } |
852 | 852 | ||
853 | 853 | ||
854 | OTodoXMLContainer* con = new OTodoXMLContainer(); | 854 | OPimTodoXMLContainer* con = new OPimTodoXMLContainer(); |
855 | con->todo = (*it); | 855 | con->todo = (*it); |
856 | vector.insert(item, con ); | 856 | vector.insert(item, con ); |
857 | item++; | 857 | item++; |
858 | } | 858 | } |
859 | vector.resize( item ); | 859 | vector.resize( item ); |
860 | /* sort it now */ | 860 | /* sort it now */ |
@@ -863,41 +863,41 @@ QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, | |||
863 | QArray<int> array( vector.count() ); | 863 | QArray<int> array( vector.count() ); |
864 | for (uint i= 0; i < vector.count(); i++ ) { | 864 | for (uint i= 0; i < vector.count(); i++ ) { |
865 | array[i] = ( vector.at(i) )->todo.uid(); | 865 | array[i] = ( vector.at(i) )->todo.uid(); |
866 | } | 866 | } |
867 | return array; | 867 | return array; |
868 | }; | 868 | }; |
869 | void OTodoAccessXML::removeAllCompleted() { | 869 | void OPimTodoAccessXML::removeAllCompleted() { |
870 | QMap<int, OTodo> events = m_events; | 870 | QMap<int, OPimTodo> events = m_events; |
871 | for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { | 871 | for ( QMap<int, OPimTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { |
872 | if ( (*it).isCompleted() ) | 872 | if ( (*it).isCompleted() ) |
873 | events.remove( it.key() ); | 873 | events.remove( it.key() ); |
874 | } | 874 | } |
875 | m_events = events; | 875 | m_events = events; |
876 | } | 876 | } |
877 | QBitArray OTodoAccessXML::supports()const { | 877 | QBitArray OPimTodoAccessXML::supports()const { |
878 | static QBitArray ar = sup(); | 878 | static QBitArray ar = sup(); |
879 | return ar; | 879 | return ar; |
880 | } | 880 | } |
881 | QBitArray OTodoAccessXML::sup() { | 881 | QBitArray OPimTodoAccessXML::sup() { |
882 | QBitArray ar( OTodo::CompletedDate +1 ); | 882 | QBitArray ar( OPimTodo::CompletedDate +1 ); |
883 | ar.fill( true ); | 883 | ar.fill( true ); |
884 | ar[OTodo::CrossReference] = false; | 884 | ar[OPimTodo::CrossReference] = false; |
885 | ar[OTodo::State ] = false; | 885 | ar[OPimTodo::State ] = false; |
886 | ar[OTodo::Reminders] = false; | 886 | ar[OPimTodo::Reminders] = false; |
887 | ar[OTodo::Notifiers] = false; | 887 | ar[OPimTodo::Notifiers] = false; |
888 | ar[OTodo::Maintainer] = false; | 888 | ar[OPimTodo::Maintainer] = false; |
889 | 889 | ||
890 | return ar; | 890 | return ar; |
891 | } | 891 | } |
892 | QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const | 892 | QArray<int> OPimTodoAccessXML::matchRegexp( const QRegExp &r ) const |
893 | { | 893 | { |
894 | QArray<int> m_currentQuery( m_events.count() ); | 894 | QArray<int> m_currentQuery( m_events.count() ); |
895 | uint arraycounter = 0; | 895 | uint arraycounter = 0; |
896 | 896 | ||
897 | QMap<int, OTodo>::ConstIterator it; | 897 | QMap<int, OPimTodo>::ConstIterator it; |
898 | for (it = m_events.begin(); it != m_events.end(); ++it ) { | 898 | for (it = m_events.begin(); it != m_events.end(); ++it ) { |
899 | if ( it.data().match( r ) ) | 899 | if ( it.data().match( r ) ) |
900 | m_currentQuery[arraycounter++] = it.data().uid(); | 900 | m_currentQuery[arraycounter++] = it.data().uid(); |
901 | 901 | ||
902 | } | 902 | } |
903 | // Shrink to fit.. | 903 | // Shrink to fit.. |
diff --git a/libopie2/opiepim/backend/otodoaccessxml.h b/libopie2/opiepim/backend/otodoaccessxml.h index d634398..3a51543 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.h +++ b/libopie2/opiepim/backend/otodoaccessxml.h | |||
@@ -34,55 +34,55 @@ | |||
34 | 34 | ||
35 | #include <opie2/otodoaccessbackend.h> | 35 | #include <opie2/otodoaccessbackend.h> |
36 | 36 | ||
37 | namespace Opie { | 37 | namespace Opie { |
38 | class XMLElement; | 38 | class XMLElement; |
39 | 39 | ||
40 | class OTodoAccessXML : public OTodoAccessBackend { | 40 | class OPimTodoAccessXML : public OPimTodoAccessBackend { |
41 | public: | 41 | public: |
42 | /** | 42 | /** |
43 | * fileName if Empty we will use the default path | 43 | * fileName if Empty we will use the default path |
44 | */ | 44 | */ |
45 | OTodoAccessXML( const QString& appName, | 45 | OPimTodoAccessXML( const QString& appName, |
46 | const QString& fileName = QString::null ); | 46 | const QString& fileName = QString::null ); |
47 | ~OTodoAccessXML(); | 47 | ~OPimTodoAccessXML(); |
48 | 48 | ||
49 | bool load(); | 49 | bool load(); |
50 | bool reload(); | 50 | bool reload(); |
51 | bool save(); | 51 | bool save(); |
52 | 52 | ||
53 | QArray<int> allRecords()const; | 53 | QArray<int> allRecords()const; |
54 | QArray<int> matchRegexp(const QRegExp &r) const; | 54 | QArray<int> matchRegexp(const QRegExp &r) const; |
55 | QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() ); | 55 | QArray<int> queryByExample( const OPimTodo&, int querysettings, const QDateTime& d = QDateTime() ); |
56 | OTodo find( int uid )const; | 56 | OPimTodo find( int uid )const; |
57 | void clear(); | 57 | void clear(); |
58 | bool add( const OTodo& ); | 58 | bool add( const OPimTodo& ); |
59 | bool remove( int uid ); | 59 | bool remove( int uid ); |
60 | void removeAllCompleted(); | 60 | void removeAllCompleted(); |
61 | bool replace( const OTodo& ); | 61 | bool replace( const OPimTodo& ); |
62 | 62 | ||
63 | /* our functions */ | 63 | /* our functions */ |
64 | QArray<int> effectiveToDos( const QDate& start, | 64 | QArray<int> effectiveToDos( const QDate& start, |
65 | const QDate& end, | 65 | const QDate& end, |
66 | bool includeNoDates ); | 66 | bool includeNoDates ); |
67 | QArray<int> overDue(); | 67 | QArray<int> overDue(); |
68 | QArray<int> sorted( bool asc, int sortOrder, | 68 | QArray<int> sorted( bool asc, int sortOrder, |
69 | int sortFilter, int cat ); | 69 | int sortFilter, int cat ); |
70 | QBitArray supports()const; | 70 | QBitArray supports()const; |
71 | private: | 71 | private: |
72 | static QBitArray sup(); | 72 | static QBitArray sup(); |
73 | void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& ); | 73 | void todo( QAsciiDict<int>*, OPimTodo&,const QCString&,const QString& ); |
74 | QString toString( const OTodo& )const; | 74 | QString toString( const OPimTodo& )const; |
75 | QString toString( const QArray<int>& ints ) const; | 75 | QString toString( const QArray<int>& ints ) const; |
76 | QMap<int, OTodo> m_events; | 76 | QMap<int, OPimTodo> m_events; |
77 | QString m_file; | 77 | QString m_file; |
78 | QString m_app; | 78 | QString m_app; |
79 | bool m_opened : 1; | 79 | bool m_opened : 1; |
80 | bool m_changed : 1; | 80 | bool m_changed : 1; |
81 | class OTodoAccessXMLPrivate; | 81 | class OPimTodoAccessXMLPrivate; |
82 | OTodoAccessXMLPrivate* d; | 82 | OPimTodoAccessXMLPrivate* d; |
83 | int m_year, m_month, m_day; | 83 | int m_year, m_month, m_day; |
84 | 84 | ||
85 | }; | 85 | }; |
86 | 86 | ||
87 | }; | 87 | }; |
88 | 88 | ||