summaryrefslogtreecommitdiff
path: root/libopie
Unidiff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/obackendfactory.h12
-rw-r--r--libopie/pim/ocontact.cpp253
-rw-r--r--libopie/pim/ocontact.h9
-rw-r--r--libopie/pim/ocontactaccess.h11
-rw-r--r--libopie/pim/ocontactaccessbackend.h14
-rw-r--r--libopie/pim/ocontactaccessbackend_vcard.cpp22
-rw-r--r--libopie/pim/ocontactaccessbackend_xml.cpp3
-rw-r--r--libopie/pim/oconversion.h5
-rw-r--r--libopie/pim/odatebookaccessbackend.h4
-rw-r--r--libopie/pim/odatebookaccessbackend_xml.cpp6
-rw-r--r--libopie/pim/opimaccessbackend.h4
-rw-r--r--libopie/pim/opimaccesstemplate.h4
-rw-r--r--libopie/pim/opimcache.h6
-rw-r--r--libopie/pim/opimmainwindow.cpp14
-rw-r--r--libopie/pim/opimxrefmanager.h2
-rw-r--r--libopie/pim/orecordlist.h12
-rw-r--r--libopie/pim/otemplatebase.h7
-rw-r--r--libopie/pim/otodo.cpp16
-rw-r--r--libopie/pim/otodo.h9
-rw-r--r--libopie/pim/otodoaccessbackend.h4
-rw-r--r--libopie/pim/otodoaccessvcal.cpp26
-rw-r--r--libopie/pim/otodoaccessxml.cpp6
22 files changed, 327 insertions, 122 deletions
diff --git a/libopie/pim/obackendfactory.h b/libopie/pim/obackendfactory.h
index ad6cf5a..f3c339d 100644
--- a/libopie/pim/obackendfactory.h
+++ b/libopie/pim/obackendfactory.h
@@ -1,154 +1,166 @@
1/* 1/*
2 * Class to manage Backends. 2 * Class to manage Backends.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * 5 *
6 * ===================================================================== 6 * =====================================================================
7 *This program is free software; you can redistribute it and/or 7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; 9 * License as published by the Free Software Foundation;
10 * either version 2 of the License, or (at your option) any later 10 * either version 2 of the License, or (at your option) any later
11 * version. 11 * version.
12 * ===================================================================== 12 * =====================================================================
13 * ToDo: Use plugins 13 * ToDo: Use plugins
14 * ===================================================================== 14 * =====================================================================
15 * Version: $Id$ 15 * Version: $Id$
16 * ===================================================================== 16 * =====================================================================
17 * History: 17 * History:
18 * $Log$ 18 * $Log$
19 * Revision 1.7 2003/08/01 12:30:16 eilers
20 * Merging changes from BRANCH_1_0 to HEAD
21 *
22 * Revision 1.6.4.1 2003/06/30 14:34:19 eilers
23 * Patches from Zecke:
24 * Fixing and cleaning up extraMap handling
25 * Adding d_ptr for binary compatibility in the future
26 *
19 * Revision 1.6 2003/04/13 18:07:10 zecke 27 * Revision 1.6 2003/04/13 18:07:10 zecke
20 * More API doc 28 * More API doc
21 * QString -> const QString& 29 * QString -> const QString&
22 * QString = 0l -> QString::null 30 * QString = 0l -> QString::null
23 * 31 *
24 * Revision 1.5 2003/02/21 23:31:52 zecke 32 * Revision 1.5 2003/02/21 23:31:52 zecke
25 * Add XML datebookresource 33 * Add XML datebookresource
26 * -clean up todoaccessxml header 34 * -clean up todoaccessxml header
27 * -implement some more stuff in the oeven tester 35 * -implement some more stuff in the oeven tester
28 * -extend DefaultFactory to not crash and to use datebook 36 * -extend DefaultFactory to not crash and to use datebook
29 * 37 *
30 * -reading of OEvents is working nicely.. saving will be added 38 * -reading of OEvents is working nicely.. saving will be added
31 * tomorrow 39 * tomorrow
32 * -fix spelling in ODateBookAcces 40 * -fix spelling in ODateBookAcces
33 * 41 *
34 * Revision 1.4 2002/10/14 15:55:18 eilers 42 * Revision 1.4 2002/10/14 15:55:18 eilers
35 * Redeactivate SQL.. ;) 43 * Redeactivate SQL.. ;)
36 * 44 *
37 * Revision 1.3 2002/10/10 17:08:58 zecke 45 * Revision 1.3 2002/10/10 17:08:58 zecke
38 * The Cache is finally in place 46 * The Cache is finally in place
39 * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;) 47 * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;)
40 * The read ahead functionality does not make sense for XMLs backends because most of the stuff is already in memory. While using readahead on SQL makes things a lot faster.... 48 * The read ahead functionality does not make sense for XMLs backends because most of the stuff is already in memory. While using readahead on SQL makes things a lot faster....
41 * I still have to fully implement read ahead 49 * I still have to fully implement read ahead
42 * This change is bic but sc 50 * This change is bic but sc
43 * 51 *
44 * Revision 1.2 2002/10/08 09:27:36 eilers 52 * Revision 1.2 2002/10/08 09:27:36 eilers
45 * Fixed libopie.pro to include the new pim-API. 53 * Fixed libopie.pro to include the new pim-API.
46 * The SQL-Stuff is currently deactivated. Otherwise everyone who wants to 54 * The SQL-Stuff is currently deactivated. Otherwise everyone who wants to
47 * compile itself would need to install libsqlite, libopiesql... 55 * compile itself would need to install libsqlite, libopiesql...
48 * Therefore, the backend currently uses XML only.. 56 * Therefore, the backend currently uses XML only..
49 * 57 *
50 * Revision 1.1 2002/10/07 17:35:01 eilers 58 * Revision 1.1 2002/10/07 17:35:01 eilers
51 * added OBackendFactory for advanced backend access 59 * added OBackendFactory for advanced backend access
52 * 60 *
53 * 61 *
54 * ===================================================================== 62 * =====================================================================
55 */ 63 */
56#ifndef OPIE_BACKENDFACTORY_H_ 64#ifndef OPIE_BACKENDFACTORY_H_
57#define OPIE_BACKENDFACTORY_H_ 65#define OPIE_BACKENDFACTORY_H_
58 66
59#include <qstring.h> 67#include <qstring.h>
60#include <qasciidict.h> 68#include <qasciidict.h>
61#include <qpe/config.h> 69#include <qpe/config.h>
62 70
63#include "otodoaccessxml.h" 71#include "otodoaccessxml.h"
64#include "ocontactaccessbackend_xml.h" 72#include "ocontactaccessbackend_xml.h"
65#include "odatebookaccessbackend_xml.h" 73#include "odatebookaccessbackend_xml.h"
66 74
67#ifdef __USE_SQL 75#ifdef __USE_SQL
68#include "otodoaccesssql.h" 76#include "otodoaccesssql.h"
69#endif 77#endif
70 78
79class OBackendPrivate;
80
71/** 81/**
72 * This class is our factory. It will give us the default implementations 82 * This class is our factory. It will give us the default implementations
73 * of at least Todolist, Contacts and Datebook. In the future this class will 83 * of at least Todolist, Contacts and Datebook. In the future this class will
74 * allow users to switch the backend with ( XML->SQLite ) without the need 84 * allow users to switch the backend with ( XML->SQLite ) without the need
75 * to recompile.# 85 * to recompile.#
76 * This class as the whole PIM Api is making use of templates 86 * This class as the whole PIM Api is making use of templates
77 * 87 *
78 * <pre> 88 * <pre>
79 * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null ); 89 * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null );
80 * backend->load(); 90 * backend->load();
81 * </pre> 91 * </pre>
82 * 92 *
83 * @author Stefan Eilers 93 * @author Stefan Eilers
84 * @version 0.1 94 * @version 0.1
85 */ 95 */
86template<class T> 96template<class T>
87class OBackendFactory 97class OBackendFactory
88{ 98{
89 public: 99 public:
90 OBackendFactory() {}; 100 OBackendFactory() {};
91 101
92 enum BACKENDS { 102 enum BACKENDS {
93 TODO, 103 TODO,
94 CONTACT, 104 CONTACT,
95 DATE 105 DATE
96 }; 106 };
97 107
98 /** 108 /**
99 * Returns a backend implementation for backendName 109 * Returns a backend implementation for backendName
100 * @param backendName the type of the backend 110 * @param backendName the type of the backend
101 * @param appName will be passed on to the backend 111 * @param appName will be passed on to the backend
102 */ 112 */
103 static T* Default( const QString backendName, const QString& appName ){ 113 static T* Default( const QString backendName, const QString& appName ){
104 114
105 // __asm__("int3"); 115 // __asm__("int3");
106 116
107 Config config( "pimaccess" ); 117 Config config( "pimaccess" );
108 config.setGroup ( backendName ); 118 config.setGroup ( backendName );
109 QString backend = config.readEntry( "usebackend" ); 119 QString backend = config.readEntry( "usebackend" );
110 120
111 QAsciiDict<int> dict ( 3 ); 121 QAsciiDict<int> dict ( 3 );
112 dict.setAutoDelete ( TRUE ); 122 dict.setAutoDelete ( TRUE );
113 123
114 dict.insert( "todo", new int (TODO) ); 124 dict.insert( "todo", new int (TODO) );
115 dict.insert( "contact", new int (CONTACT) ); 125 dict.insert( "contact", new int (CONTACT) );
116 dict.insert( "datebook", new int(DATE) ); 126 dict.insert( "datebook", new int(DATE) );
117 127
118 qWarning ("TODO is: %d", TODO); 128 qWarning ("TODO is: %d", TODO);
119 qWarning ("CONTACT is: %d", CONTACT); 129 qWarning ("CONTACT is: %d", CONTACT);
120 130
121 int *find = dict[ backendName ]; 131 int *find = dict[ backendName ];
122 if (!find ) return 0; 132 if (!find ) return 0;
123 133
124 switch ( *find ){ 134 switch ( *find ){
125 case TODO: 135 case TODO:
126#ifdef __USE_SQL 136#ifdef __USE_SQL
127 if ( backend == "sql" ) 137 if ( backend == "sql" )
128 return (T*) new OTodoAccessBackendSQL(""); 138 return (T*) new OTodoAccessBackendSQL("");
129#else 139#else
130 if ( backend == "sql" ) 140 if ( backend == "sql" )
131 qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); 141 qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!");
132#endif 142#endif
133 143
134 return (T*) new OTodoAccessXML( appName ); 144 return (T*) new OTodoAccessXML( appName );
135 case CONTACT: 145 case CONTACT:
136 if ( backend == "sql" ) 146 if ( backend == "sql" )
137 qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); 147 qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!");
138 148
139 return (T*) new OContactAccessBackend_XML( appName ); 149 return (T*) new OContactAccessBackend_XML( appName );
140 case DATE: 150 case DATE:
141 if ( backend == "sql" ) 151 if ( backend == "sql" )
142 qWarning("OBackendFactory:: sql Backend not implemented! Using XML instead!"); 152 qWarning("OBackendFactory:: sql Backend not implemented! Using XML instead!");
143 153
144 return (T*) new ODateBookAccessBackend_XML( appName ); 154 return (T*) new ODateBookAccessBackend_XML( appName );
145 default: 155 default:
146 return NULL; 156 return NULL;
147 } 157 }
148 158
149 159
150 } 160 }
161 private:
162 OBackendPrivate* d;
151}; 163};
152 164
153 165
154#endif 166#endif
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index be4ce0a..3473baa 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -1,75 +1,76 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) 3** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de)
4** 4**
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13** See http://www.trolltech.com/gpl/ for GPL licensing information. 13** See http://www.trolltech.com/gpl/ for GPL licensing information.
14** 14**
15** Contact info@trolltech.com if any conditions of this licensing are 15** Contact info@trolltech.com if any conditions of this licensing are
16** not clear to you. 16** not clear to you.
17** 17**
18**********************************************************************/ 18**********************************************************************/
19 19
20#define QTOPIA_INTERNAL_CONTACT_MRE 20#define QTOPIA_INTERNAL_CONTACT_MRE
21 21
22#include "ocontact.h" 22#include "ocontact.h"
23#include "opimresolver.h" 23#include "opimresolver.h"
24#include "oconversion.h"
24 25
25#include <qpe/stringutil.h> 26#include <qpe/stringutil.h>
26#include "oconversion.h"
27#include <qpe/timestring.h> 27#include <qpe/timestring.h>
28#include <qpe/config.h>
28 29
29#include <qobject.h> 30#include <qobject.h>
30#include <qregexp.h> 31#include <qregexp.h>
31#include <qstylesheet.h> 32#include <qstylesheet.h>
32#include <qfileinfo.h> 33#include <qfileinfo.h>
33#include <qmap.h> 34#include <qmap.h>
34 35
35#include <stdio.h> 36#include <stdio.h>
36 37
37/*! 38/*!
38 \class Contact contact.h 39 \class Contact contact.h
39 \brief The Contact class holds the data of an address book entry. 40 \brief The Contact class holds the data of an address book entry.
40 41
41 This data includes information the name of the person, contact 42 This data includes information the name of the person, contact
42 information, and business information such as deparment and job title. 43 information, and business information such as deparment and job title.
43 44
44 \ingroup qtopiaemb 45 \ingroup qtopiaemb
45 \ingroup qtopiadesktop 46 \ingroup qtopiadesktop
46*/ 47*/
47 48
48 49
49/*! 50/*!
50 Creates a new, empty contact. 51 Creates a new, empty contact.
51*/ 52*/
52OContact::OContact() 53OContact::OContact()
53 : OPimRecord(), mMap(), d( 0 ) 54 : OPimRecord(), mMap(), d( 0 )
54{ 55{
55} 56}
56 57
57/*! 58/*!
58 \internal 59 \internal
59 Creates a new contact. The properties of the contact are 60 Creates a new contact. The properties of the contact are
60 set from \a fromMap. 61 set from \a fromMap.
61*/ 62*/
62OContact::OContact( const QMap<int, QString> &fromMap ) : 63OContact::OContact( const QMap<int, QString> &fromMap ) :
63 OPimRecord(), mMap( fromMap ), d( 0 ) 64 OPimRecord(), mMap( fromMap ), d( 0 )
64{ 65{
65 QString cats = mMap[ Qtopia::AddressCategory ]; 66 QString cats = mMap[ Qtopia::AddressCategory ];
66 if ( !cats.isEmpty() ) 67 if ( !cats.isEmpty() )
67 setCategories( idsFromString( cats ) ); 68 setCategories( idsFromString( cats ) );
68 69
69 QString uidStr = find( Qtopia::AddressUid ); 70 QString uidStr = find( Qtopia::AddressUid );
70 71
71 if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ 72 if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){
72 qWarning( "Invalid UID found. Generate new one.." ); 73 qWarning( "Invalid UID found. Generate new one.." );
73 setUid( uidGen().generate() ); 74 setUid( uidGen().generate() );
74 }else 75 }else
75 setUid( uidStr.toInt() ); 76 setUid( uidStr.toInt() );
@@ -393,292 +394,364 @@ OContact::~OContact()
393/*! \fn QString OContact::groups() const 394/*! \fn QString OContact::groups() const
394 \internal 395 \internal
395 Returns the groups for the contact. 396 Returns the groups for the contact.
396*/ 397*/
397 398
398/*! \fn QStringList OContact::groupList() const 399/*! \fn QStringList OContact::groupList() const
399 \internal 400 \internal
400*/ 401*/
401 402
402/*! \fn QString OContact::field(int) const 403/*! \fn QString OContact::field(int) const
403 \internal 404 \internal
404*/ 405*/
405 406
406/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) 407/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null )
407 \internal 408 \internal
408*/ 409*/
409 410
410/*! \fn void OContact::setUid( int id ) 411/*! \fn void OContact::setUid( int id )
411 \internal 412 \internal
412 Sets the uid for this record to \a id. 413 Sets the uid for this record to \a id.
413*/ 414*/
414 415
415/*! \enum OContact::journal_action 416/*! \enum OContact::journal_action
416 \internal 417 \internal
417*/ 418*/
418 419
419/*! 420/*!
420 \internal 421 \internal
421*/ 422*/
422QMap<int, QString> OContact::toMap() const 423QMap<int, QString> OContact::toMap() const
423{ 424{
424 QMap<int, QString> map = mMap; 425 QMap<int, QString> map = mMap;
425 QString cats = idsToString( categories() ); 426 QString cats = idsToString( categories() );
426 if ( !cats.isEmpty() ) 427 if ( !cats.isEmpty() )
427 map.insert( Qtopia::AddressCategory, cats ); 428 map.insert( Qtopia::AddressCategory, cats );
428 return map; 429 return map;
429} 430}
430 431
431/*! 432/*!
432 Returns a rich text formatted QString representing the contents the contact. 433 Returns a rich text formatted QString representing the contents the contact.
433*/ 434*/
434QString OContact::toRichText() const 435QString OContact::toRichText() const
435{ 436{
436 QString text; 437 QString text;
437 QString value, comp, state; 438 QString value, comp, state;
438 QString str; 439 QString str;
439 bool marker = false; 440 bool marker = false;
440 441
442 Config cfg("qpe");
443 cfg.setGroup("Appearance");
444 int addressformat = cfg.readNumEntry( "AddressFormat", Zip_City_State );
445
441 // name, jobtitle and company 446 // name, jobtitle and company
442 if ( !(value = fullName()).isEmpty() ) 447 if ( !(value = fullName()).isEmpty() )
443 text += "<b><h3><img src=\"addressbook/AddressBook\">" + Qtopia::escapeString(value) + "</h3></b>"; 448 text += "<b><h3><img src=\"addressbook/AddressBook\"> " + Qtopia::escapeString(value) + "</h3></b>";
444 449
445 if ( !(value = jobTitle()).isEmpty() ) 450 if ( !(value = jobTitle()).isEmpty() )
446 text += Qtopia::escapeString(value) + "<br>"; 451 text += Qtopia::escapeString(value);
447 452
448 comp = company(); 453 comp = company();
449 if ( !(value = department()).isEmpty() ) { 454 if ( !(value = department()).isEmpty() ) {
450 text += Qtopia::escapeString(value); 455 text += Qtopia::escapeString(value);
451 if ( comp ) 456 if ( comp )
452 text += ", "; 457 text += ", ";
453 else 458 else
454 text += "<br>"; 459 text += "<br>";
455 } 460 }
456 if ( !comp.isEmpty() ) 461 if ( !comp.isEmpty() )
457 text += Qtopia::escapeString(comp) + "<br>"; 462 text += Qtopia::escapeString(comp);
458 463
459 text += "<hr><br>"; 464 text += "<br><hr>";
460 465
461 // defailt email 466 // defailt email
462 QString defEmail = defaultEmail(); 467 QString defEmail = defaultEmail();
463 if ( !defEmail.isEmpty() ) 468 if ( !defEmail.isEmpty() ){
464 text += "<b><img src=\"addressbook/email\">" + QObject::tr("Default Email: ") + "</b>" 469 text += "<b><img src=\"addressbook/email\"> " + QObject::tr("Default Email: ") + "</b>"
465 + Qtopia::escapeString(defEmail) + "<br>"; 470 + Qtopia::escapeString(defEmail);
466 471 marker = true;
467 text += "<br>"; 472 }
468 473
469 // business address 474 // business address
470 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || 475 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
471 !businessZip().isEmpty() || !businessCountry().isEmpty() ) { 476 !businessZip().isEmpty() || !businessCountry().isEmpty() ) {
472 text += QObject::tr( "<b>Work Address:</b>" ); 477 text += QObject::tr( "<br><br><b>Work Address:</b>" );
473 text += "<br>";
474 marker = true; 478 marker = true;
475 } 479 }
476 480
477 if ( !(value = businessStreet()).isEmpty() ) 481 if ( !(value = businessStreet()).isEmpty() ){
478 text += Qtopia::escapeString(value) + "<br>"; 482 text += "<br>" + Qtopia::escapeString(value);
479 state = businessState(); 483 marker = true;
480 if ( !(value = businessZip()).isEmpty() ) 484 }
481 text += Qtopia::escapeString(value) + " "; 485
482 if ( !(value = businessCity()).isEmpty() ) { 486 switch( addressformat ){
483 text += Qtopia::escapeString(value); 487 case Zip_City_State:{ // Zip_Code City, State
484 if ( state ) 488 state = businessState();
485 text += ", " + Qtopia::escapeString(state); 489 if ( !(value = businessZip()).isEmpty() ){
486 text += "<br>"; 490 text += "<br>" + Qtopia::escapeString(value) + " ";
487 } else if ( !state.isEmpty() ) 491 marker = true;
488 text += Qtopia::escapeString(state) + "<br>"; 492
493 } else
494 text += "<br>";
495
496 if ( !(value = businessCity()).isEmpty() ) {
497 marker = true;
498 text += Qtopia::escapeString(value);
499 if ( state )
500 text += ", " + Qtopia::escapeString(state);
501 } else if ( !state.isEmpty() ){
502 text += "<br>" + Qtopia::escapeString(state);
503 marker = true;
504 }
505 break;
506 }
507 case City_State_Zip:{ // City, State Zip_Code
508 state = businessState();
509 if ( !(value = businessCity()).isEmpty() ) {
510 marker = true;
511 text += "<br>" + Qtopia::escapeString(value);
512 if ( state )
513 text += ", " + Qtopia::escapeString(state);
514 } else if ( !state.isEmpty() ){
515 text += "<br>" + Qtopia::escapeString(state);
516 marker = true;
517 }
518 if ( !(value = businessZip()).isEmpty() ){
519 text += " " + Qtopia::escapeString(value);
520 marker = true;
521 }
522 break;
523 }
524 }
489 525
490 if ( !(value = businessCountry()).isEmpty() ) 526 if ( !(value = businessCountry()).isEmpty() ){
491 text += Qtopia::escapeString(value) + "<br>"; 527 text += "<br>" + Qtopia::escapeString(value);
528 marker = true;
529 }
492 530
493 // rest of Business data 531 // rest of Business data
494 str = office(); 532 str = office();
495 if ( !str.isEmpty() ){ 533 if ( !str.isEmpty() ){
496 text += "<b>" + QObject::tr("Office: ") + "</b>" 534 text += "<br><b>" + QObject::tr("Office: ") + "</b>"
497 + Qtopia::escapeString(str) + "<br>"; 535 + Qtopia::escapeString(str);
498 marker = true; 536 marker = true;
499 } 537 }
500 str = businessWebpage(); 538 str = businessWebpage();
501 if ( !str.isEmpty() ){ 539 if ( !str.isEmpty() ){
502 text += "<b><img src=\"addressbook/webpagework\">" + QObject::tr("Business Web Page: ") + "</b>" 540 text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr("Business Web Page: ") + "</b>"
503 + Qtopia::escapeString(str) + "<br>"; 541 + Qtopia::escapeString(str);
504 marker = true; 542 marker = true;
505 } 543 }
506 str = businessPhone(); 544 str = businessPhone();
507 if ( !str.isEmpty() ){ 545 if ( !str.isEmpty() ){
508 text += "<b><img src=\"addressbook/phonework\">" + QObject::tr("Business Phone: ") + "</b>" 546 text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr("Business Phone: ") + "</b>"
509 + Qtopia::escapeString(str) + "<br>"; 547 + Qtopia::escapeString(str);
510 marker = true; 548 marker = true;
511 } 549 }
512 str = businessFax(); 550 str = businessFax();
513 if ( !str.isEmpty() ){ 551 if ( !str.isEmpty() ){
514 text += "<b><img src=\"addressbook/faxwork\">" + QObject::tr("Business Fax: ") + "</b>" 552 text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr("Business Fax: ") + "</b>"
515 + Qtopia::escapeString(str) + "<br>"; 553 + Qtopia::escapeString(str);
516 marker = true; 554 marker = true;
517 } 555 }
518 str = businessMobile(); 556 str = businessMobile();
519 if ( !str.isEmpty() ){ 557 if ( !str.isEmpty() ){
520 text += "<b><img src=\"addressbook/mobilework\">" + QObject::tr("Business Mobile: ") + "</b>" 558 text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr("Business Mobile: ") + "</b>"
521 + Qtopia::escapeString(str) + "<br>"; 559 + Qtopia::escapeString(str);
522 marker = true; 560 marker = true;
523 } 561 }
524 str = businessPager(); 562 str = businessPager();
525 if ( !str.isEmpty() ){ 563 if ( !str.isEmpty() ){
526 text += "<b>" + QObject::tr("Business Pager: ") + "</b>" 564 text += "<br><b>" + QObject::tr("Business Pager: ") + "</b>"
527 + Qtopia::escapeString(str) + "<br>"; 565 + Qtopia::escapeString(str);
528 marker = true; 566 marker = true;
529 } 567 }
530 568
531 text += "<br>"; 569 text += "<br>";
532 570
533 // home address 571 // home address
534 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || 572 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
535 !homeZip().isEmpty() || !homeCountry().isEmpty() ) { 573 !homeZip().isEmpty() || !homeCountry().isEmpty() ) {
536 text += QObject::tr( "<b>Home Address:</b>" ); 574 text += QObject::tr( "<br><br><b>Home Address:</b>" );
537 text += "<br>"; 575 marker = true;
538 } 576 }
539 577
540 if ( !(value = homeStreet()).isEmpty() ) 578 if ( !(value = homeStreet()).isEmpty() ){
541 text += Qtopia::escapeString(value) + "<br>"; 579 text += "<br>" + Qtopia::escapeString(value);
542 state = homeState(); 580 marker = true;
543 if ( !(value = homeZip()).isEmpty() ) 581 }
544 text += Qtopia::escapeString(value) + " "; 582
545 if ( !(value = homeCity()).isEmpty() ) { 583 switch( addressformat ){
546 text += Qtopia::escapeString(value); 584 case Zip_City_State:{ // Zip_Code City, State
547 if ( !state.isEmpty() ) 585 state = homeState();
548 text += ", " + Qtopia::escapeString(state); 586 if ( !(value = homeZip()).isEmpty() ){
549 text += "<br>"; 587 text += "<br>" + Qtopia::escapeString(value) + " ";
550 } else if (!state.isEmpty()) 588 marker = true;
551 text += Qtopia::escapeString(state) + "<br>"; 589 } else
552 if ( !(value = homeCountry()).isEmpty() ) 590 text += "<br>";
553 text += Qtopia::escapeString(value) + "<br>"; 591
592 if ( !(value = homeCity()).isEmpty() ) {
593 marker = true;
594 text += Qtopia::escapeString(value);
595 if ( !state.isEmpty() )
596 text += ", " + Qtopia::escapeString(state);
597 } else if (!state.isEmpty()) {
598 text += "<br>" + Qtopia::escapeString(state);
599 marker = true;
600 }
601 break;
602 }
603 case City_State_Zip:{ // City, State Zip_Code
604 state = homeState();
605 if ( !(value = homeCity()).isEmpty() ) {
606 marker = true;
607 text += "<br>" + Qtopia::escapeString(value);
608 if ( state )
609 text += ", " + Qtopia::escapeString(state);
610 } else if ( !state.isEmpty() ){
611 text += "<br>" + Qtopia::escapeString(state);
612 marker = true;
613 }
614 if ( !(value = homeZip()).isEmpty() ){
615 text += " " + Qtopia::escapeString(value);
616 marker = true;
617 }
618 break;
619 }
620 }
621
622 if ( !(value = homeCountry()).isEmpty() ){
623 text += "<br>" + Qtopia::escapeString(value);
624 marker = true;
625 }
554 626
555 // rest of Home data 627 // rest of Home data
556 str = homeWebpage(); 628 str = homeWebpage();
557 if ( !str.isEmpty() ){ 629 if ( !str.isEmpty() ){
558 text += "<b><img src=\"addressbook/webpagehome\">" + QObject::tr("Home Web Page: ") + "</b>" 630 text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr("Home Web Page: ") + "</b>"
559 + Qtopia::escapeString(str) + "<br>"; 631 + Qtopia::escapeString(str);
560 marker = true; 632 marker = true;
561 } 633 }
562 str = homePhone(); 634 str = homePhone();
563 if ( !str.isEmpty() ){ 635 if ( !str.isEmpty() ){
564 text += "<b><img src=\"addressbook/phonehome\">" + QObject::tr("Home Phone: ") + "</b>" 636 text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr("Home Phone: ") + "</b>"
565 + Qtopia::escapeString(str) + "<br>"; 637 + Qtopia::escapeString(str);
566 marker = true; 638 marker = true;
567 } 639 }
568 str = homeFax(); 640 str = homeFax();
569 if ( !str.isEmpty() ){ 641 if ( !str.isEmpty() ){
570 text += "<b><img src=\"addressbook/faxhome\">" + QObject::tr("Home Fax: ") + "</b>" 642 text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr("Home Fax: ") + "</b>"
571 + Qtopia::escapeString(str) + "<br>"; 643 + Qtopia::escapeString(str);
572 marker = true; 644 marker = true;
573 } 645 }
574 str = homeMobile(); 646 str = homeMobile();
575 if ( !str.isEmpty() ){ 647 if ( !str.isEmpty() ){
576 text += "<b><img src=\"addressbook/mobilehome\">" + QObject::tr("Home Mobile: ") + "</b>" 648 text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr("Home Mobile: ") + "</b>"
577 + Qtopia::escapeString(str) + "<br>"; 649 + Qtopia::escapeString(str);
578 marker = true; 650 marker = true;
579 } 651 }
580 652
581 if ( marker ) 653 if ( marker )
582 text += "<br><hr><br>"; 654 text += "<br><hr>";
583 // the others... 655
656 // the rest...
584 str = emails(); 657 str = emails();
585 if ( !str.isEmpty() && ( str != defEmail ) ) 658 if ( !str.isEmpty() && ( str != defEmail ) )
586 text += "<b>" + QObject::tr("All Emails: ") + "</b>" 659 text += "<br><b>" + QObject::tr("All Emails: ") + "</b>"
587 + Qtopia::escapeString(str) + "<br>"; 660 + Qtopia::escapeString(str);
588 str = profession(); 661 str = profession();
589 if ( !str.isEmpty() ) 662 if ( !str.isEmpty() )
590 text += "<b>" + QObject::tr("Profession: ") + "</b>" 663 text += "<br><b>" + QObject::tr("Profession: ") + "</b>"
591 + Qtopia::escapeString(str) + "<br>"; 664 + Qtopia::escapeString(str);
592 str = assistant(); 665 str = assistant();
593 if ( !str.isEmpty() ) 666 if ( !str.isEmpty() )
594 text += "<b>" + QObject::tr("Assistant: ") + "</b>" 667 text += "<br><b>" + QObject::tr("Assistant: ") + "</b>"
595 + Qtopia::escapeString(str) + "<br>"; 668 + Qtopia::escapeString(str);
596 str = manager(); 669 str = manager();
597 if ( !str.isEmpty() ) 670 if ( !str.isEmpty() )
598 text += "<b>" + QObject::tr("Manager: ") + "</b>" 671 text += "<br><b>" + QObject::tr("Manager: ") + "</b>"
599 + Qtopia::escapeString(str) + "<br>"; 672 + Qtopia::escapeString(str);
600 str = gender(); 673 str = gender();
601 if ( !str.isEmpty() && str.toInt() != 0 ) { 674 if ( !str.isEmpty() && str.toInt() != 0 ) {
602 if ( str.toInt() == 1 ) 675 text += "<br>";
603 str = QObject::tr( "Male" ); 676 if ( str.toInt() == 1 )
604 else if ( str.toInt() == 2 ) 677 str = QObject::tr( "Male" );
605 str = QObject::tr( "Female" ); 678 else if ( str.toInt() == 2 )
606 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; 679 str = QObject::tr( "Female" );
680 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str;
607 } 681 }
608 str = spouse(); 682 str = spouse();
609 if ( !str.isEmpty() ) 683 if ( !str.isEmpty() )
610 text += "<b>" + QObject::tr("Spouse: ") + "</b>" 684 text += "<br><b>" + QObject::tr("Spouse: ") + "</b>"
611 + Qtopia::escapeString(str) + "<br>"; 685 + Qtopia::escapeString(str);
612 if ( birthday().isValid() ){ 686 if ( birthday().isValid() ){
613 str = TimeString::numberDateString( birthday() ); 687 str = TimeString::numberDateString( birthday() );
614 text += "<b>" + QObject::tr("Birthday: ") + "</b>" 688 text += "<br><b>" + QObject::tr("Birthday: ") + "</b>"
615 + Qtopia::escapeString(str) + "<br>"; 689 + Qtopia::escapeString(str);
616 } 690 }
617 if ( anniversary().isValid() ){ 691 if ( anniversary().isValid() ){
618 str = TimeString::numberDateString( anniversary() ); 692 str = TimeString::numberDateString( anniversary() );
619 text += "<b>" + QObject::tr("Anniversary: ") + "</b>" 693 text += "<br><b>" + QObject::tr("Anniversary: ") + "</b>"
620 + Qtopia::escapeString(str) + "<br>"; 694 + Qtopia::escapeString(str);
621 } 695 }
622 str = children(); 696 str = children();
623 if ( !str.isEmpty() ) 697 if ( !str.isEmpty() )
624 text += "<b>" + QObject::tr("Children: ") + "</b>" 698 text += "<br><b>" + QObject::tr("Children: ") + "</b>"
625 + Qtopia::escapeString(str) + "<br>"; 699 + Qtopia::escapeString(str);
626 700
627 str = nickname(); 701 str = nickname();
628 if ( !str.isEmpty() ) 702 if ( !str.isEmpty() )
629 text += "<b>" + QObject::tr("Nickname: ") + "</b>" 703 text += "<br><b>" + QObject::tr("Nickname: ") + "</b>"
630 + Qtopia::escapeString(str) + "<br>"; 704 + Qtopia::escapeString(str);
631 705
632 // categories 706 // categories
633 if ( categoryNames("Contacts").count() ){ 707 if ( categoryNames("Contacts").count() ){
634 text += "<b>" + QObject::tr( "Category:") + "</b> "; 708 text += "<br><b>" + QObject::tr( "Category:") + "</b> ";
635 text += categoryNames("Contacts").join(", "); 709 text += categoryNames("Contacts").join(", ");
636 text += "<br>";
637 } 710 }
638 711
639 // notes last 712 // notes last
640 if ( !(value = notes()).isEmpty() ) { 713 if ( !(value = notes()).isEmpty() ) {
641 text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; 714 text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> ";
642 QRegExp reg("\n"); 715 QRegExp reg("\n");
643 716
644 //QString tmp = Qtopia::escapeString(value); 717 //QString tmp = Qtopia::escapeString(value);
645 QString tmp = QStyleSheet::convertFromPlainText(value); 718 QString tmp = QStyleSheet::convertFromPlainText(value);
646 //tmp.replace( reg, "<br>" ); 719 //tmp.replace( reg, "<br>" );
647 text += "<br>" + tmp + "<br>"; 720 text += "<br>" + tmp + "<br>";
648 } 721 }
649 return text; 722 return text;
650} 723}
651 724
652/*! 725/*!
653 \internal 726 \internal
654*/ 727*/
655void OContact::insert( int key, const QString &v ) 728void OContact::insert( int key, const QString &v )
656{ 729{
657 QString value = v.stripWhiteSpace(); 730 QString value = v.stripWhiteSpace();
658 if ( value.isEmpty() ) 731 if ( value.isEmpty() )
659 mMap.remove( key ); 732 mMap.remove( key );
660 else 733 else
661 mMap.insert( key, value ); 734 mMap.insert( key, value );
662} 735}
663 736
664/*! 737/*!
665 \internal 738 \internal
666*/ 739*/
667void OContact::replace( int key, const QString & v ) 740void OContact::replace( int key, const QString & v )
668{ 741{
669 QString value = v.stripWhiteSpace(); 742 QString value = v.stripWhiteSpace();
670 if ( value.isEmpty() ) 743 if ( value.isEmpty() )
671 mMap.remove( key ); 744 mMap.remove( key );
672 else 745 else
673 mMap.replace( key, value ); 746 mMap.replace( key, value );
674} 747}
675 748
676/*! 749/*!
677 \internal 750 \internal
678*/ 751*/
679QString OContact::find( int key ) const 752QString OContact::find( int key ) const
680{ 753{
681 return mMap[key]; 754 return mMap[key];
682} 755}
683 756
684/*! 757/*!
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h
index dd2de17..9a1a8dc 100644
--- a/libopie/pim/ocontact.h
+++ b/libopie/pim/ocontact.h
@@ -1,99 +1,104 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) 3** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de)
4** 4**
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13** See http://www.trolltech.com/gpl/ for GPL licensing information. 13** See http://www.trolltech.com/gpl/ for GPL licensing information.
14** 14**
15** Contact info@trolltech.com if any conditions of this licensing are 15** Contact info@trolltech.com if any conditions of this licensing are
16** not clear to you. 16** not clear to you.
17** 17**
18**********************************************************************/ 18**********************************************************************/
19 19
20#ifndef __OCONTACT_H__ 20#ifndef __OCONTACT_H__
21#define __OCONTACT_H__ 21#define __OCONTACT_H__
22 22
23#include <opie/opimrecord.h> 23#include <opie/opimrecord.h>
24#include <qpe/recordfields.h> 24#include <qpe/recordfields.h>
25 25
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28 28
29#if defined(QPC_TEMPLATEDLL) 29#if defined(QPC_TEMPLATEDLL)
30// MOC_SKIP_BEGIN 30// MOC_SKIP_BEGIN
31QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; 31QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
32// MOC_SKIP_END 32// MOC_SKIP_END
33#endif 33#endif
34 34
35class ContactPrivate; 35class OContactPrivate;
36 36
37/** 37/**
38 * OContact class represents a specialised PIM Record for contacts. 38 * OContact class represents a specialised PIM Record for contacts.
39 * It does store all kind of persopn related information. 39 * It does store all kind of persopn related information.
40 * 40 *
41 * @short Contact Container 41 * @short Contact Container
42 * @author TT, Stefan Eiler, Holger Freyther 42 * @author TT, Stefan Eiler, Holger Freyther
43 */ 43 */
44class QPC_EXPORT OContact : public OPimRecord 44class QPC_EXPORT OContact : public OPimRecord
45{ 45{
46 friend class DataSet; 46 friend class DataSet;
47public: 47public:
48 OContact(); 48 OContact();
49 OContact( const QMap<int, QString> &fromMap ); 49 OContact( const QMap<int, QString> &fromMap );
50 virtual ~OContact(); 50 virtual ~OContact();
51 51
52 enum DateFormat{
53 Zip_City_State = 0,
54 City_State_Zip
55 };
56
52 /* 57 /*
53 * do we need to inline them 58 * do we need to inline them
54 * if yes do we need to inline them this way? 59 * if yes do we need to inline them this way?
55 * -zecke 60 * -zecke
56 */ 61 */
57 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } 62 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); }
58 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } 63 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); }
59 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } 64 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); }
60 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } 65 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); }
61 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } 66 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); }
62 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } 67 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); }
63 void setFileAs(); 68 void setFileAs();
64 69
65 // default email address 70 // default email address
66 void setDefaultEmail( const QString &v ); 71 void setDefaultEmail( const QString &v );
67 // inserts email to list and ensure's doesn't already exist 72 // inserts email to list and ensure's doesn't already exist
68 void insertEmail( const QString &v ); 73 void insertEmail( const QString &v );
69 void removeEmail( const QString &v ); 74 void removeEmail( const QString &v );
70 void clearEmails(); 75 void clearEmails();
71 void insertEmails( const QStringList &v ); 76 void insertEmails( const QStringList &v );
72 77
73 // home 78 // home
74 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } 79 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); }
75 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } 80 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); }
76 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } 81 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); }
77 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } 82 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); }
78 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } 83 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); }
79 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } 84 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); }
80 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } 85 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); }
81 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } 86 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); }
82 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } 87 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); }
83 88
84 // business 89 // business
85 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } 90 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); }
86 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } 91 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); }
87 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } 92 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); }
88 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } 93 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); }
89 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } 94 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); }
90 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } 95 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); }
91 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } 96 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); }
92 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } 97 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); }
93 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } 98 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); }
94 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } 99 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); }
95 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } 100 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); }
96 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } 101 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); }
97 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } 102 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); }
98 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } 103 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); }
99 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } 104 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); }
@@ -188,53 +193,53 @@ public:
188 193
189 // other 194 // other
190 QString notes() const { return find( Qtopia::Notes ); } 195 QString notes() const { return find( Qtopia::Notes ); }
191 QString groups() const { return find( Qtopia::Groups ); } 196 QString groups() const { return find( Qtopia::Groups ); }
192 QStringList groupList() const; 197 QStringList groupList() const;
193 198
194// // custom 199// // custom
195// const QString &customField( const QString &key ) 200// const QString &customField( const QString &key )
196// { return find( Custom- + key ); } 201// { return find( Custom- + key ); }
197 202
198 203
199 QString toRichText() const; 204 QString toRichText() const;
200 QMap<int, QString> toMap() const; 205 QMap<int, QString> toMap() const;
201 QString field( int key ) const { return find( key ); } 206 QString field( int key ) const { return find( key ); }
202 207
203 208
204 void setUid( int i ); 209 void setUid( int i );
205 210
206 QString toShortText()const; 211 QString toShortText()const;
207 QString OContact::type()const; 212 QString OContact::type()const;
208 QMap<QString,QString> OContact::toExtraMap() const; 213 QMap<QString,QString> OContact::toExtraMap() const;
209 class QString OContact::recordField(int) const; 214 class QString OContact::recordField(int) const;
210 215
211 // Why private ? (eilers,se) 216 // Why private ? (eilers,se)
212 QString emailSeparator() const { return " "; } 217 QString emailSeparator() const { return " "; }
213 // the emails should be seperated by a comma 218 // the emails should be seperated by a comma
214 void setEmails( const QString &v ); 219 void setEmails( const QString &v );
215 QString emails() const { return find( Qtopia::Emails ); } 220 QString emails() const { return find( Qtopia::Emails ); }
216 static int rtti(); 221 static int rtti();
217 222
218private: 223private:
219 // The XML-Backend needs some access to the private functions 224 // The XML-Backend needs some access to the private functions
220 friend class OContactAccessBackend_XML; 225 friend class OContactAccessBackend_XML;
221 226
222 void insert( int key, const QString &value ); 227 void insert( int key, const QString &value );
223 void replace( int key, const QString &value ); 228 void replace( int key, const QString &value );
224 QString find( int key ) const; 229 QString find( int key ) const;
225 static QStringList fields(); 230 static QStringList fields();
226 231
227 void save( QString &buf ) const; 232 void save( QString &buf ) const;
228 233
229 QString displayAddress( const QString &street, 234 QString displayAddress( const QString &street,
230 const QString &city, 235 const QString &city,
231 const QString &state, 236 const QString &state,
232 const QString &zip, 237 const QString &zip,
233 const QString &country ) const; 238 const QString &country ) const;
234 239
235 QMap<int, QString> mMap; 240 QMap<int, QString> mMap;
236 ContactPrivate *d; 241 OContactPrivate *d;
237}; 242};
238 243
239 244
240#endif 245#endif
diff --git a/libopie/pim/ocontactaccess.h b/libopie/pim/ocontactaccess.h
index e90db32..9b0a719 100644
--- a/libopie/pim/ocontactaccess.h
+++ b/libopie/pim/ocontactaccess.h
@@ -1,67 +1,75 @@
1/* 1/*
2 * Class to manage the Contacts. 2 * Class to manage the Contacts.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) 5 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org)
6 * 6 *
7 * ===================================================================== 7 * =====================================================================
8 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
9 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; 10 * License as published by the Free Software Foundation;
11 * either version 2 of the License, or (at your option) any later 11 * either version 2 of the License, or (at your option) any later
12 * version. 12 * version.
13 * ===================================================================== 13 * =====================================================================
14 * ToDo: Define enum for query settings 14 * ToDo: Define enum for query settings
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.9 2003/08/01 12:30:16 eilers
21 * Merging changes from BRANCH_1_0 to HEAD
22 *
23 * Revision 1.8.2.1 2003/06/30 14:34:19 eilers
24 * Patches from Zecke:
25 * Fixing and cleaning up extraMap handling
26 * Adding d_ptr for binary compatibility in the future
27 *
20 * Revision 1.8 2003/05/08 13:55:09 tille 28 * Revision 1.8 2003/05/08 13:55:09 tille
21 * search stuff 29 * search stuff
22 * and match, toRichText & toShortText in oevent 30 * and match, toRichText & toShortText in oevent
23 * 31 *
24 * Revision 1.7 2003/04/13 18:07:10 zecke 32 * Revision 1.7 2003/04/13 18:07:10 zecke
25 * More API doc 33 * More API doc
26 * QString -> const QString& 34 * QString -> const QString&
27 * QString = 0l -> QString::null 35 * QString = 0l -> QString::null
28 * 36 *
29 * Revision 1.6 2003/01/02 14:27:12 eilers 37 * Revision 1.6 2003/01/02 14:27:12 eilers
30 * Improved query by example: Search by date is possible.. First step 38 * Improved query by example: Search by date is possible.. First step
31 * for a today plugin for birthdays.. 39 * for a today plugin for birthdays..
32 * 40 *
33 * Revision 1.5 2002/11/13 14:14:51 eilers 41 * Revision 1.5 2002/11/13 14:14:51 eilers
34 * Added sorted for Contacts.. 42 * Added sorted for Contacts..
35 * 43 *
36 * Revision 1.4 2002/11/01 15:10:42 eilers 44 * Revision 1.4 2002/11/01 15:10:42 eilers
37 * Added regExp-search in database for all fields in a contact. 45 * Added regExp-search in database for all fields in a contact.
38 * 46 *
39 * Revision 1.3 2002/10/16 10:52:40 eilers 47 * Revision 1.3 2002/10/16 10:52:40 eilers
40 * Added some docu to the interface and now using the cache infrastucture by zecke.. :) 48 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
41 * 49 *
42 * Revision 1.2 2002/10/14 16:21:54 eilers 50 * Revision 1.2 2002/10/14 16:21:54 eilers
43 * Some minor interface updates 51 * Some minor interface updates
44 * 52 *
45 * Revision 1.1 2002/09/27 17:11:44 eilers 53 * Revision 1.1 2002/09/27 17:11:44 eilers
46 * Added API for accessing the Contact-Database ! It is compiling, but 54 * Added API for accessing the Contact-Database ! It is compiling, but
47 * please do not expect that anything is working ! 55 * please do not expect that anything is working !
48 * I will debug that stuff in the next time .. 56 * I will debug that stuff in the next time ..
49 * Please read README_COMPILE for compiling ! 57 * Please read README_COMPILE for compiling !
50 * 58 *
51 * ===================================================================== 59 * =====================================================================
52 */ 60 */
53#ifndef _OCONTACTACCESS_H 61#ifndef _OCONTACTACCESS_H
54#define _OCONTACTACCESS_H 62#define _OCONTACTACCESS_H
55 63
56#include <qobject.h> 64#include <qobject.h>
57 65
58#include <qpe/qcopenvelope_qws.h> 66#include <qpe/qcopenvelope_qws.h>
59 67
60#include <qvaluelist.h> 68#include <qvaluelist.h>
61#include <qfileinfo.h> 69#include <qfileinfo.h>
62 70
63#include "ocontact.h" 71#include "ocontact.h"
64#include "ocontactaccessbackend.h" 72#include "ocontactaccessbackend.h"
65#include "opimaccesstemplate.h" 73#include "opimaccesstemplate.h"
66 74
67/** 75/**
@@ -120,51 +128,54 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
120 * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess 128 * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess
121 * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess 129 * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess
122 */ 130 */
123 List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const; 131 List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const;
124 132
125 /** Return all possible settings. 133 /** Return all possible settings.
126 * @return All settings provided by the current backend 134 * @return All settings provided by the current backend
127 * (i.e.: query_WildCards & query_IgnoreCase) 135 * (i.e.: query_WildCards & query_IgnoreCase)
128 */ 136 */
129 const uint querySettings(); 137 const uint querySettings();
130 138
131 /** Check whether settings are correct. 139 /** Check whether settings are correct.
132 * @return <i>true</i> if the given settings are correct and possible. 140 * @return <i>true</i> if the given settings are correct and possible.
133 */ 141 */
134 bool hasQuerySettings ( int querySettings ) const; 142 bool hasQuerySettings ( int querySettings ) const;
135 143
136 /** 144 /**
137 * if the resource was changed externally. 145 * if the resource was changed externally.
138 * You should use the signal instead of polling possible changes ! 146 * You should use the signal instead of polling possible changes !
139 */ 147 */
140 bool wasChangedExternally()const; 148 bool wasChangedExternally()const;
141 149
142 150
143 /** Save contacts database. 151 /** Save contacts database.
144 * Save is more a "commit". After calling this function, all changes are public available. 152 * Save is more a "commit". After calling this function, all changes are public available.
145 * @return true if successful 153 * @return true if successful
146 */ 154 */
147 bool save(); 155 bool save();
148 156
149 signals: 157 signals:
150 /* Signal is emitted if the database was changed. Therefore 158 /* Signal is emitted if the database was changed. Therefore
151 * we may need to reload to stay consistent. 159 * we may need to reload to stay consistent.
152 * @param which Pointer to the database who created this event. This pointer 160 * @param which Pointer to the database who created this event. This pointer
153 * is useful if an application has to handle multiple databases at the same time. 161 * is useful if an application has to handle multiple databases at the same time.
154 * @see reload() 162 * @see reload()
155 */ 163 */
156 void signalChanged ( const OContactAccess *which ); 164 void signalChanged ( const OContactAccess *which );
157 165
158 166
159 private: 167 private:
160 // class OContactAccessPrivate; 168 // class OContactAccessPrivate;
161 // OContactAccessPrivate* d; 169 // OContactAccessPrivate* d;
162 OContactAccessBackend *m_backEnd; 170 OContactAccessBackend *m_backEnd;
163 bool m_loading:1; 171 bool m_loading:1;
164 172
165 private slots: 173 private slots:
166 void copMessage( const QCString &msg, const QByteArray &data ); 174 void copMessage( const QCString &msg, const QByteArray &data );
167 175
176 private:
177 class Private;
178 Private *d;
168 179
169}; 180};
170#endif 181#endif
diff --git a/libopie/pim/ocontactaccessbackend.h b/libopie/pim/ocontactaccessbackend.h
index ebeb42d..280e05c 100644
--- a/libopie/pim/ocontactaccessbackend.h
+++ b/libopie/pim/ocontactaccessbackend.h
@@ -1,107 +1,119 @@
1/** 1/**
2 * The class responsible for managing a backend. 2 * The class responsible for managing a backend.
3 * The implementation of this abstract class contains 3 * The implementation of this abstract class contains
4 * the complete database handling. 4 * the complete database handling.
5 * 5 *
6 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 6 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
7 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) 7 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org)
8 * 8 *
9 * ===================================================================== 9 * =====================================================================
10 *This program is free software; you can redistribute it and/or 10 *This program is free software; you can redistribute it and/or
11 *modify it under the terms of the GNU Library General Public 11 *modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; 12 * License as published by the Free Software Foundation;
13 * either version 2 of the License, or (at your option) any later 13 * either version 2 of the License, or (at your option) any later
14 * version. 14 * version.
15 * ===================================================================== 15 * =====================================================================
16 * ToDo: Define enum for query settings 16 * ToDo: Define enum for query settings
17 * ===================================================================== 17 * =====================================================================
18 * Version: $Id$ 18 * Version: $Id$
19 * ===================================================================== 19 * =====================================================================
20 * History: 20 * History:
21 * $Log$ 21 * $Log$
22 * Revision 1.6 2003/08/01 12:30:16 eilers
23 * Merging changes from BRANCH_1_0 to HEAD
24 *
25 * Revision 1.5.4.1 2003/06/30 14:34:19 eilers
26 * Patches from Zecke:
27 * Fixing and cleaning up extraMap handling
28 * Adding d_ptr for binary compatibility in the future
29 *
22 * Revision 1.5 2003/04/13 18:07:10 zecke 30 * Revision 1.5 2003/04/13 18:07:10 zecke
23 * More API doc 31 * More API doc
24 * QString -> const QString& 32 * QString -> const QString&
25 * QString = 0l -> QString::null 33 * QString = 0l -> QString::null
26 * 34 *
27 * Revision 1.4 2002/11/13 14:14:51 eilers 35 * Revision 1.4 2002/11/13 14:14:51 eilers
28 * Added sorted for Contacts.. 36 * Added sorted for Contacts..
29 * 37 *
30 * Revision 1.3 2002/11/01 15:10:42 eilers 38 * Revision 1.3 2002/11/01 15:10:42 eilers
31 * Added regExp-search in database for all fields in a contact. 39 * Added regExp-search in database for all fields in a contact.
32 * 40 *
33 * Revision 1.2 2002/10/07 17:34:24 eilers 41 * Revision 1.2 2002/10/07 17:34:24 eilers
34 * added OBackendFactory for advanced backend access 42 * added OBackendFactory for advanced backend access
35 * 43 *
36 * Revision 1.1 2002/09/27 17:11:44 eilers 44 * Revision 1.1 2002/09/27 17:11:44 eilers
37 * Added API for accessing the Contact-Database ! It is compiling, but 45 * Added API for accessing the Contact-Database ! It is compiling, but
38 * please do not expect that anything is working ! 46 * please do not expect that anything is working !
39 * I will debug that stuff in the next time .. 47 * I will debug that stuff in the next time ..
40 * Please read README_COMPILE for compiling ! 48 * Please read README_COMPILE for compiling !
41 * 49 *
42 * ===================================================================== 50 * =====================================================================
43 * 51 *
44 */ 52 */
45 53
46#ifndef _OCONTACTACCESSBACKEND_H_ 54#ifndef _OCONTACTACCESSBACKEND_H_
47#define _OCONTACTACCESSBACKEND_H_ 55#define _OCONTACTACCESSBACKEND_H_
48 56
49#include "ocontact.h" 57#include "ocontact.h"
50#include "opimaccessbackend.h" 58#include "opimaccessbackend.h"
51 59
52#include <qregexp.h> 60#include <qregexp.h>
53 61
54/** 62/**
55 * This class represents the interface of all Contact Backends. 63 * This class represents the interface of all Contact Backends.
56 * Derivates of this class will be used to access the contacts. 64 * Derivates of this class will be used to access the contacts.
57 * As implementation currently XML and vCard exist. This class needs to be implemented 65 * As implementation currently XML and vCard exist. This class needs to be implemented
58 * if you want to provide your own storage. 66 * if you want to provide your own storage.
59 * In all queries a list of uids is passed on instead of loading the actual record! 67 * In all queries a list of uids is passed on instead of loading the actual record!
60 * 68 *
61 * @see OContactAccessBackend_VCard 69 * @see OContactAccessBackend_VCard
62 * @see OContactAccessBackend_XML 70 * @see OContactAccessBackend_XML
63 */ 71 */
64class OContactAccessBackend: public OPimAccessBackend<OContact> { 72class OContactAccessBackend: public OPimAccessBackend<OContact> {
65 public: 73 public:
66 OContactAccessBackend() {} 74 OContactAccessBackend() {}
67 virtual ~OContactAccessBackend() {} 75 virtual ~OContactAccessBackend() {}
68 76
69 77
70 /** 78 /**
71 * Return if database was changed externally. 79 * Return if database was changed externally.
72 * This may just make sense on file based databases like a XML-File. 80 * 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 81 * It is used to prevent to overwrite the current database content
74 * if the file was already changed by something else ! 82 * if the file was already changed by something else !
75 * If this happens, we have to reload before save our data. 83 * If this happens, we have to reload before save our data.
76 * If we use real databases, this should be handled by the database 84 * If we use real databases, this should be handled by the database
77 * management system themselve, therefore this function should always return false in 85 * management system themselve, therefore this function should always return false in
78 * this case. It is not our problem to handle this conflict ... 86 * this case. It is not our problem to handle this conflict ...
79 * @return <i>true</i> if the database was changed and if save without reload will 87 * @return <i>true</i> if the database was changed and if save without reload will
80 * be dangerous. <i>false</i> if the database was not changed or it is save to write 88 * be dangerous. <i>false</i> if the database was not changed or it is save to write
81 * in this situation. 89 * in this situation.
82 */ 90 */
83 virtual bool wasChangedExternally() = 0; 91 virtual bool wasChangedExternally() = 0;
84 92
85 virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0; 93 virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0;
86 94
87 /** 95 /**
88 * Return all possible settings. 96 * Return all possible settings.
89 * @return All settings provided by the current backend 97 * @return All settings provided by the current backend
90 * (i.e.: query_WildCards & query_IgnoreCase) 98 * (i.e.: query_WildCards & query_IgnoreCase)
91 */ 99 */
92 virtual const uint querySettings() = 0; 100 virtual const uint querySettings() = 0;
93 101
94 /** 102 /**
95 * Check whether settings are correct. 103 * Check whether settings are correct.
96 * @return <i>true</i> if the given settings are correct and possible. 104 * @return <i>true</i> if the given settings are correct and possible.
97 */ 105 */
98 virtual bool hasQuerySettings (uint querySettings) const = 0; 106 virtual bool hasQuerySettings (uint querySettings) const = 0;
99 107
100 /** 108 /**
101 * FIXME!!! 109 * FIXME!!!
102 * Returns a sorted list of records either ascendinf or descending for a giving criteria and category 110 * Returns a sorted list of records either ascendinf or descending for a giving criteria and category
103 */ 111 */
104 virtual QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 0; 112 virtual QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 0;
105 113
114
115private:
116 class Private;
117 Private *d;
106}; 118};
107#endif 119#endif
diff --git a/libopie/pim/ocontactaccessbackend_vcard.cpp b/libopie/pim/ocontactaccessbackend_vcard.cpp
index 270bef3..b60c5be 100644
--- a/libopie/pim/ocontactaccessbackend_vcard.cpp
+++ b/libopie/pim/ocontactaccessbackend_vcard.cpp
@@ -1,67 +1,82 @@
1/* 1/*
2 * VCard Backend for the OPIE-Contact Database. 2 * VCard Backend for the OPIE-Contact Database.
3 * 3 *
4 * Copyright (C) 2000 Trolltech AS. All rights reserved. 4 * Copyright (C) 2000 Trolltech AS. All rights reserved.
5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
6 * 6 *
7 * ===================================================================== 7 * =====================================================================
8 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
9 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * ===================================================================== 12 * =====================================================================
13 * ToDo: 13 * ToDo:
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.11 2003/08/01 12:30:16 eilers
21 * Merging changes from BRANCH_1_0 to HEAD
22 *
23 * Revision 1.10.4.3 2003/07/23 08:54:37 eilers
24 * Default email was added to the list of all emails, which already contains
25 * the default email..
26 * This closes bug #1045
27 *
28 * Revision 1.10.4.2 2003/07/23 08:44:45 eilers
29 * Importing of Notes in vcard files wasn't implemented.
30 * Closes bug #1044
31 *
32 * Revision 1.10.4.1 2003/06/02 13:37:49 eilers
33 * Fixing memory leak
34 *
20 * Revision 1.10 2003/04/13 18:07:10 zecke 35 * Revision 1.10 2003/04/13 18:07:10 zecke
21 * More API doc 36 * More API doc
22 * QString -> const QString& 37 * QString -> const QString&
23 * QString = 0l -> QString::null 38 * QString = 0l -> QString::null
24 * 39 *
25 * Revision 1.9 2003/03/21 10:33:09 eilers 40 * Revision 1.9 2003/03/21 10:33:09 eilers
26 * Merged speed optimized xml backend for contacts to main. 41 * Merged speed optimized xml backend for contacts to main.
27 * Added QDateTime to querybyexample. For instance, it is now possible to get 42 * Added QDateTime to querybyexample. For instance, it is now possible to get
28 * all Birthdays/Anniversaries between two dates. This should be used 43 * all Birthdays/Anniversaries between two dates. This should be used
29 * to show all birthdays in the datebook.. 44 * to show all birthdays in the datebook..
30 * This change is sourcecode backward compatible but you have to upgrade 45 * This change is sourcecode backward compatible but you have to upgrade
31 * the binaries for today-addressbook. 46 * the binaries for today-addressbook.
32 * 47 *
33 * Revision 1.8 2003/02/21 16:52:49 zecke 48 * Revision 1.8 2003/02/21 16:52:49 zecke
34 * -Remove old Todo classes they're deprecated and today I already using the 49 * -Remove old Todo classes they're deprecated and today I already using the
35 * new API 50 * new API
36 * -Guard against self assignment in OTodo 51 * -Guard against self assignment in OTodo
37 * -Add test apps for OPIM 52 * -Add test apps for OPIM
38 * -Opiefied Event classes 53 * -Opiefied Event classes
39 * -Added TimeZone handling and pinning of TimeZones to OEvent 54 * -Added TimeZone handling and pinning of TimeZones to OEvent
40 * -Adjust ORecur and the widget to better timezone behaviour 55 * -Adjust ORecur and the widget to better timezone behaviour
41 * 56 *
42 * Revision 1.7 2003/02/16 22:25:46 zecke 57 * Revision 1.7 2003/02/16 22:25:46 zecke
43 * 0000276 Fix for that bug.. or better temp workaround 58 * 0000276 Fix for that bug.. or better temp workaround
44 * A Preferred Number is HOME|VOICE 59 * A Preferred Number is HOME|VOICE
45 * A CellPhone is HOME|VOICE|CELL the type & HOME|VOICE test 60 * A CellPhone is HOME|VOICE|CELL the type & HOME|VOICE test
46 * triggers both 61 * triggers both
47 * and the cell phone number overrides the other entries.. 62 * and the cell phone number overrides the other entries..
48 * 63 *
49 * as a temp I check that it's not equal to HOME|VOICE|CELL before setting the 64 * as a temp I check that it's not equal to HOME|VOICE|CELL before setting the
50 * number 65 * number
51 * 66 *
52 * The right and final fix would be to reorder the if statement to make it 67 * The right and final fix would be to reorder the if statement to make it
53 * if else based and the less common thing put to the bottom 68 * if else based and the less common thing put to the bottom
54 * 69 *
55 * OTodoAccessVcal fix the date for beaming 70 * OTodoAccessVcal fix the date for beaming
56 * 71 *
57 * Revision 1.6 2003/01/13 15:49:31 eilers 72 * Revision 1.6 2003/01/13 15:49:31 eilers
58 * Fixing crash when businesscard.vcf is missing.. 73 * Fixing crash when businesscard.vcf is missing..
59 * 74 *
60 * Revision 1.5 2002/12/07 13:26:22 eilers 75 * Revision 1.5 2002/12/07 13:26:22 eilers
61 * Fixing bug in storing anniversary.. 76 * Fixing bug in storing anniversary..
62 * 77 *
63 * Revision 1.4 2002/11/13 14:14:51 eilers 78 * Revision 1.4 2002/11/13 14:14:51 eilers
64 * Added sorted for Contacts.. 79 * Added sorted for Contacts..
65 * 80 *
66 * Revision 1.3 2002/11/11 16:41:09 kergoth 81 * Revision 1.3 2002/11/11 16:41:09 kergoth
67 * no default arguments in implementation 82 * no default arguments in implementation
@@ -106,96 +121,97 @@ bool OContactAccessBackend_VCard::load ()
106 } 121 }
107 122
108 while ( obj ) { 123 while ( obj ) {
109 OContact con = parseVObject( obj ); 124 OContact con = parseVObject( obj );
110 /* 125 /*
111 * if uid is 0 assign a new one 126 * if uid is 0 assign a new one
112 * this at least happens on 127 * this at least happens on
113 * Nokia6210 128 * Nokia6210
114 */ 129 */
115 if ( con.uid() == 0 ){ 130 if ( con.uid() == 0 ){
116 con.setUid( 1 ); 131 con.setUid( 1 );
117 qWarning("assigned new uid %d",con.uid() ); 132 qWarning("assigned new uid %d",con.uid() );
118 } 133 }
119 134
120 m_map.insert( con.uid(), con ); 135 m_map.insert( con.uid(), con );
121 136
122 VObject *t = obj; 137 VObject *t = obj;
123 obj = nextVObjectInList(obj); 138 obj = nextVObjectInList(obj);
124 cleanVObject( t ); 139 cleanVObject( t );
125 } 140 }
126 141
127 return true; 142 return true;
128 143
129} 144}
130bool OContactAccessBackend_VCard::reload() 145bool OContactAccessBackend_VCard::reload()
131{ 146{
132 return load(); 147 return load();
133} 148}
134bool OContactAccessBackend_VCard::save() 149bool OContactAccessBackend_VCard::save()
135{ 150{
136 if (!m_dirty ) 151 if (!m_dirty )
137 return true; 152 return true;
138 153
139 QFileDirect file( m_file ); 154 QFileDirect file( m_file );
140 if (!file.open(IO_WriteOnly ) ) 155 if (!file.open(IO_WriteOnly ) )
141 return false; 156 return false;
142 157
143 VObject *obj; 158 VObject *obj;
144 obj = newVObject( VCCalProp ); 159 obj = newVObject( VCCalProp );
145 addPropValue( obj, VCVersionProp, "1.0" ); 160 addPropValue( obj, VCVersionProp, "1.0" );
146 161
147 VObject *vo; 162 VObject *vo;
148 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ 163 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
149 vo = createVObject( *it ); 164 vo = createVObject( *it );
150 writeVObject( file.directHandle() , vo ); 165 writeVObject( file.directHandle() , vo );
151 cleanVObject( vo ); 166 cleanVObject( vo );
152 } 167 }
153 cleanStrTbl(); 168 cleanStrTbl();
169 deleteVObject( obj );
154 170
155 m_dirty = false; 171 m_dirty = false;
156 return true; 172 return true;
157 173
158 174
159} 175}
160void OContactAccessBackend_VCard::clear () 176void OContactAccessBackend_VCard::clear ()
161{ 177{
162 m_map.clear(); 178 m_map.clear();
163 m_dirty = true; // ??? sure ? (se) 179 m_dirty = true; // ??? sure ? (se)
164} 180}
165 181
166bool OContactAccessBackend_VCard::add ( const OContact& newcontact ) 182bool OContactAccessBackend_VCard::add ( const OContact& newcontact )
167{ 183{
168 m_map.insert( newcontact.uid(), newcontact ); 184 m_map.insert( newcontact.uid(), newcontact );
169 m_dirty = true; 185 m_dirty = true;
170 return true; 186 return true;
171} 187}
172 188
173bool OContactAccessBackend_VCard::remove ( int uid ) 189bool OContactAccessBackend_VCard::remove ( int uid )
174{ 190{
175 m_map.remove( uid ); 191 m_map.remove( uid );
176 m_dirty = true; 192 m_dirty = true;
177 return true; 193 return true;
178} 194}
179 195
180bool OContactAccessBackend_VCard::replace ( const OContact &contact ) 196bool OContactAccessBackend_VCard::replace ( const OContact &contact )
181{ 197{
182 m_map.replace( contact.uid(), contact ); 198 m_map.replace( contact.uid(), contact );
183 m_dirty = true; 199 m_dirty = true;
184 return true; 200 return true;
185} 201}
186 202
187OContact OContactAccessBackend_VCard::find ( int uid ) const 203OContact OContactAccessBackend_VCard::find ( int uid ) const
188{ 204{
189 return m_map[uid]; 205 return m_map[uid];
190} 206}
191 207
192QArray<int> OContactAccessBackend_VCard::allRecords() const 208QArray<int> OContactAccessBackend_VCard::allRecords() const
193{ 209{
194 QArray<int> ar( m_map.count() ); 210 QArray<int> ar( m_map.count() );
195 QMap<int, OContact>::ConstIterator it; 211 QMap<int, OContact>::ConstIterator it;
196 int i = 0; 212 int i = 0;
197 for ( it = m_map.begin(); it != m_map.end(); ++it ) { 213 for ( it = m_map.begin(); it != m_map.end(); ++it ) {
198 ar[i] = it.key(); 214 ar[i] = it.key();
199 i++; 215 i++;
200 } 216 }
201 return ar; 217 return ar;
@@ -401,185 +417,187 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
401 } 417 }
402 else if ( name == VCOrgProp ) { 418 else if ( name == VCOrgProp ) {
403 VObjectIterator nit; 419 VObjectIterator nit;
404 initPropIterator( &nit, o ); 420 initPropIterator( &nit, o );
405 while( moreIteration( &nit ) ) { 421 while( moreIteration( &nit ) ) {
406 VObject *o = nextVObject( &nit ); 422 VObject *o = nextVObject( &nit );
407 QCString name = vObjectName( o ); 423 QCString name = vObjectName( o );
408 QString value = vObjectStringZValue( o ); 424 QString value = vObjectStringZValue( o );
409 if ( name == VCOrgNameProp ) 425 if ( name == VCOrgNameProp )
410 c.setCompany( value ); 426 c.setCompany( value );
411 else if ( name == VCOrgUnitProp ) 427 else if ( name == VCOrgUnitProp )
412 c.setDepartment( value ); 428 c.setDepartment( value );
413 else if ( name == VCOrgUnit2Prop ) 429 else if ( name == VCOrgUnit2Prop )
414 c.setOffice( value ); 430 c.setOffice( value );
415 } 431 }
416 } 432 }
417 else if ( name == VCTitleProp ) { 433 else if ( name == VCTitleProp ) {
418 c.setJobTitle( value ); 434 c.setJobTitle( value );
419 } 435 }
420 else if ( name == "X-Qtopia-Profession" ) { 436 else if ( name == "X-Qtopia-Profession" ) {
421 c.setProfession( value ); 437 c.setProfession( value );
422 } 438 }
423 else if ( name == "X-Qtopia-Manager" ) { 439 else if ( name == "X-Qtopia-Manager" ) {
424 c.setManager( value ); 440 c.setManager( value );
425 } 441 }
426 else if ( name == "X-Qtopia-Assistant" ) { 442 else if ( name == "X-Qtopia-Assistant" ) {
427 c.setAssistant( value ); 443 c.setAssistant( value );
428 } 444 }
429 else if ( name == "X-Qtopia-Spouse" ) { 445 else if ( name == "X-Qtopia-Spouse" ) {
430 c.setSpouse( value ); 446 c.setSpouse( value );
431 } 447 }
432 else if ( name == "X-Qtopia-Gender" ) { 448 else if ( name == "X-Qtopia-Gender" ) {
433 c.setGender( value ); 449 c.setGender( value );
434 } 450 }
435 else if ( name == "X-Qtopia-Anniversary" ) { 451 else if ( name == "X-Qtopia-Anniversary" ) {
436 c.setAnniversary( convVCardDateToDate( value ) ); 452 c.setAnniversary( convVCardDateToDate( value ) );
437 } 453 }
438 else if ( name == "X-Qtopia-Nickname" ) { 454 else if ( name == "X-Qtopia-Nickname" ) {
439 c.setNickname( value ); 455 c.setNickname( value );
440 } 456 }
441 else if ( name == "X-Qtopia-Children" ) { 457 else if ( name == "X-Qtopia-Children" ) {
442 c.setChildren( value ); 458 c.setChildren( value );
443 } 459 }
444 else if ( name == VCBirthDateProp ) { 460 else if ( name == VCBirthDateProp ) {
445 // Reading Birthdate regarding RFC 2425 (5.8.4) 461 // Reading Birthdate regarding RFC 2425 (5.8.4)
446 c.setBirthday( convVCardDateToDate( value ) ); 462 c.setBirthday( convVCardDateToDate( value ) );
447 463
448 } 464 }
449 465 else if ( name == VCCommentProp ) {
466 c.setNotes( value );
467 }
450#if 0 468#if 0
451 else { 469 else {
452 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 470 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
453 VObjectIterator nit; 471 VObjectIterator nit;
454 initPropIterator( &nit, o ); 472 initPropIterator( &nit, o );
455 while( moreIteration( &nit ) ) { 473 while( moreIteration( &nit ) ) {
456 VObject *o = nextVObject( &nit ); 474 VObject *o = nextVObject( &nit );
457 QCString name = vObjectName( o ); 475 QCString name = vObjectName( o );
458 QString value = vObjectStringZValue( o ); 476 QString value = vObjectStringZValue( o );
459 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 477 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
460 } 478 }
461 } 479 }
462#endif 480#endif
463 } 481 }
464 c.setFileAs(); 482 c.setFileAs();
465 return c; 483 return c;
466} 484}
467 485
468 486
469VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) 487VObject* OContactAccessBackend_VCard::createVObject( const OContact &c )
470{ 488{
471 VObject *vcard = newVObject( VCCardProp ); 489 VObject *vcard = newVObject( VCCardProp );
472 safeAddPropValue( vcard, VCVersionProp, "2.1" ); 490 safeAddPropValue( vcard, VCVersionProp, "2.1" );
473 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); 491 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
474 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); 492 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) );
475 493
476 // full name 494 // full name
477 safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); 495 safeAddPropValue( vcard, VCFullNameProp, c.fullName() );
478 496
479 // name properties 497 // name properties
480 VObject *name = safeAddProp( vcard, VCNameProp ); 498 VObject *name = safeAddProp( vcard, VCNameProp );
481 safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); 499 safeAddPropValue( name, VCFamilyNameProp, c.lastName() );
482 safeAddPropValue( name, VCGivenNameProp, c.firstName() ); 500 safeAddPropValue( name, VCGivenNameProp, c.firstName() );
483 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); 501 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() );
484 safeAddPropValue( name, VCNamePrefixesProp, c.title() ); 502 safeAddPropValue( name, VCNamePrefixesProp, c.title() );
485 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); 503 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() );
486 504
487 // home properties 505 // home properties
488 VObject *home_adr= safeAddProp( vcard, VCAdrProp ); 506 VObject *home_adr= safeAddProp( vcard, VCAdrProp );
489 safeAddProp( home_adr, VCHomeProp ); 507 safeAddProp( home_adr, VCHomeProp );
490 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); 508 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() );
491 safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); 509 safeAddPropValue( home_adr, VCCityProp, c.homeCity() );
492 safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); 510 safeAddPropValue( home_adr, VCRegionProp, c.homeState() );
493 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); 511 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() );
494 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); 512 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() );
495 513
496 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); 514 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() );
497 safeAddProp( home_phone, VCHomeProp ); 515 safeAddProp( home_phone, VCHomeProp );
498 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); 516 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() );
499 safeAddProp( home_phone, VCHomeProp ); 517 safeAddProp( home_phone, VCHomeProp );
500 safeAddProp( home_phone, VCCellularProp ); 518 safeAddProp( home_phone, VCCellularProp );
501 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); 519 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() );
502 safeAddProp( home_phone, VCHomeProp ); 520 safeAddProp( home_phone, VCHomeProp );
503 safeAddProp( home_phone, VCFaxProp ); 521 safeAddProp( home_phone, VCFaxProp );
504 522
505 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); 523 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() );
506 safeAddProp( url, VCHomeProp ); 524 safeAddProp( url, VCHomeProp );
507 525
508 // work properties 526 // work properties
509 VObject *work_adr= safeAddProp( vcard, VCAdrProp ); 527 VObject *work_adr= safeAddProp( vcard, VCAdrProp );
510 safeAddProp( work_adr, VCWorkProp ); 528 safeAddProp( work_adr, VCWorkProp );
511 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); 529 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() );
512 safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); 530 safeAddPropValue( work_adr, VCCityProp, c.businessCity() );
513 safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); 531 safeAddPropValue( work_adr, VCRegionProp, c.businessState() );
514 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); 532 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() );
515 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); 533 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() );
516 534
517 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); 535 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() );
518 safeAddProp( work_phone, VCWorkProp ); 536 safeAddProp( work_phone, VCWorkProp );
519 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); 537 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() );
520 safeAddProp( work_phone, VCWorkProp ); 538 safeAddProp( work_phone, VCWorkProp );
521 safeAddProp( work_phone, VCCellularProp ); 539 safeAddProp( work_phone, VCCellularProp );
522 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); 540 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
523 safeAddProp( work_phone, VCWorkProp ); 541 safeAddProp( work_phone, VCWorkProp );
524 safeAddProp( work_phone, VCFaxProp ); 542 safeAddProp( work_phone, VCFaxProp );
525 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); 543 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
526 safeAddProp( work_phone, VCWorkProp ); 544 safeAddProp( work_phone, VCWorkProp );
527 safeAddProp( work_phone, VCPagerProp ); 545 safeAddProp( work_phone, VCPagerProp );
528 546
529 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); 547 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
530 safeAddProp( url, VCWorkProp ); 548 safeAddProp( url, VCWorkProp );
531 549
532 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); 550 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
533 safeAddProp( title, VCWorkProp ); 551 safeAddProp( title, VCWorkProp );
534 552
535 553
536 QStringList emails = c.emailList(); 554 QStringList emails = c.emailList();
537 emails.prepend( c.defaultEmail() ); 555 // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045
538 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 556 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
539 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 557 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
540 safeAddProp( email, VCInternetProp ); 558 safeAddProp( email, VCInternetProp );
541 } 559 }
542 560
543 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 561 safeAddPropValue( vcard, VCNoteProp, c.notes() );
544 562
545 // Exporting Birthday regarding RFC 2425 (5.8.4) 563 // Exporting Birthday regarding RFC 2425 (5.8.4)
546 if ( c.birthday().isValid() ){ 564 if ( c.birthday().isValid() ){
547 qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() ); 565 qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() );
548 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); 566 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) );
549 } 567 }
550 568
551 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 569 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
552 VObject *org = safeAddProp( vcard, VCOrgProp ); 570 VObject *org = safeAddProp( vcard, VCOrgProp );
553 safeAddPropValue( org, VCOrgNameProp, c.company() ); 571 safeAddPropValue( org, VCOrgNameProp, c.company() );
554 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 572 safeAddPropValue( org, VCOrgUnitProp, c.department() );
555 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 573 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
556 } 574 }
557 575
558 // some values we have to export as custom fields 576 // some values we have to export as custom fields
559 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); 577 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
560 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); 578 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
561 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); 579 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
562 580
563 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); 581 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
564 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 582 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
565 if ( c.anniversary().isValid() ){ 583 if ( c.anniversary().isValid() ){
566 qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() ); 584 qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() );
567 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) ); 585 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) );
568 } 586 }
569 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); 587 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
570 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); 588 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
571 589
572 return vcard; 590 return vcard;
573} 591}
574 592
575QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const 593QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const
576{ 594{
577 QString str_rfc2425 = QString("%1-%2-%3") 595 QString str_rfc2425 = QString("%1-%2-%3")
578 .arg( d.year() ) 596 .arg( d.year() )
579 .arg( d.month(), 2 ) 597 .arg( d.month(), 2 )
580 .arg( d.day(), 2 ); 598 .arg( d.day(), 2 );
581 // Now replace spaces with "0"... 599 // Now replace spaces with "0"...
582 int pos = 0; 600 int pos = 0;
583 while ( ( pos = str_rfc2425.find (' ') ) > 0 ) 601 while ( ( pos = str_rfc2425.find (' ') ) > 0 )
584 str_rfc2425.replace( pos, 1, "0" ); 602 str_rfc2425.replace( pos, 1, "0" );
585 603
diff --git a/libopie/pim/ocontactaccessbackend_xml.cpp b/libopie/pim/ocontactaccessbackend_xml.cpp
index 097142b..1c21619 100644
--- a/libopie/pim/ocontactaccessbackend_xml.cpp
+++ b/libopie/pim/ocontactaccessbackend_xml.cpp
@@ -1,67 +1,70 @@
1/* 1/*
2 * XML Backend for the OPIE-Contact Database. 2 * XML Backend for the OPIE-Contact Database.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * 5 *
6 * ===================================================================== 6 * =====================================================================
7 *This program is free software; you can redistribute it and/or 7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * ToDo: XML-Backend: Automatic reload if something was changed... 12 * ToDo: XML-Backend: Automatic reload if something was changed...
13 * 13 *
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.7 2003/08/01 12:30:16 eilers
21 * Merging changes from BRANCH_1_0 to HEAD
22 *
20 * Revision 1.6 2003/07/07 16:19:47 eilers 23 * Revision 1.6 2003/07/07 16:19:47 eilers
21 * Fixing serious bug in hasQuerySettings() 24 * Fixing serious bug in hasQuerySettings()
22 * 25 *
23 * Revision 1.5 2003/04/13 18:07:10 zecke 26 * Revision 1.5 2003/04/13 18:07:10 zecke
24 * More API doc 27 * More API doc
25 * QString -> const QString& 28 * QString -> const QString&
26 * QString = 0l -> QString::null 29 * QString = 0l -> QString::null
27 * 30 *
28 * Revision 1.4 2003/03/21 14:32:54 mickeyl 31 * Revision 1.4 2003/03/21 14:32:54 mickeyl
29 * g++ compliance fix: default arguments belong into the declaration, but not the definition 32 * g++ compliance fix: default arguments belong into the declaration, but not the definition
30 * 33 *
31 * Revision 1.3 2003/03/21 12:26:28 eilers 34 * Revision 1.3 2003/03/21 12:26:28 eilers
32 * Fixing small bug: If we search a birthday from today to today, it returned 35 * Fixing small bug: If we search a birthday from today to today, it returned
33 * every contact .. 36 * every contact ..
34 * 37 *
35 * Revision 1.2 2003/03/21 10:33:09 eilers 38 * Revision 1.2 2003/03/21 10:33:09 eilers
36 * Merged speed optimized xml backend for contacts to main. 39 * Merged speed optimized xml backend for contacts to main.
37 * Added QDateTime to querybyexample. For instance, it is now possible to get 40 * Added QDateTime to querybyexample. For instance, it is now possible to get
38 * all Birthdays/Anniversaries between two dates. This should be used 41 * all Birthdays/Anniversaries between two dates. This should be used
39 * to show all birthdays in the datebook.. 42 * to show all birthdays in the datebook..
40 * This change is sourcecode backward compatible but you have to upgrade 43 * This change is sourcecode backward compatible but you have to upgrade
41 * the binaries for today-addressbook. 44 * the binaries for today-addressbook.
42 * 45 *
43 * Revision 1.1.2.2 2003/02/11 12:17:28 eilers 46 * Revision 1.1.2.2 2003/02/11 12:17:28 eilers
44 * Speed optimization. Removed the sequential search loops. 47 * Speed optimization. Removed the sequential search loops.
45 * 48 *
46 * Revision 1.1.2.1 2003/02/10 15:31:38 eilers 49 * Revision 1.1.2.1 2003/02/10 15:31:38 eilers
47 * Writing offsets to debug output.. 50 * Writing offsets to debug output..
48 * 51 *
49 * Revision 1.1 2003/02/09 15:05:01 eilers 52 * Revision 1.1 2003/02/09 15:05:01 eilers
50 * Nothing happened.. Just some cleanup before I will start.. 53 * Nothing happened.. Just some cleanup before I will start..
51 * 54 *
52 * Revision 1.12 2003/01/03 16:58:03 eilers 55 * Revision 1.12 2003/01/03 16:58:03 eilers
53 * Reenable debug output 56 * Reenable debug output
54 * 57 *
55 * Revision 1.11 2003/01/03 12:31:28 eilers 58 * Revision 1.11 2003/01/03 12:31:28 eilers
56 * Bugfix for calculating data diffs.. 59 * Bugfix for calculating data diffs..
57 * 60 *
58 * Revision 1.10 2003/01/02 14:27:12 eilers 61 * Revision 1.10 2003/01/02 14:27:12 eilers
59 * Improved query by example: Search by date is possible.. First step 62 * Improved query by example: Search by date is possible.. First step
60 * for a today plugin for birthdays.. 63 * for a today plugin for birthdays..
61 * 64 *
62 * Revision 1.9 2002/12/08 12:48:57 eilers 65 * Revision 1.9 2002/12/08 12:48:57 eilers
63 * Moved journal-enum from ocontact into i the xml-backend.. 66 * Moved journal-enum from ocontact into i the xml-backend..
64 * 67 *
65 * Revision 1.8 2002/11/14 17:04:24 eilers 68 * Revision 1.8 2002/11/14 17:04:24 eilers
66 * Sorting will now work if fullname is identical on some entries 69 * Sorting will now work if fullname is identical on some entries
67 * 70 *
diff --git a/libopie/pim/oconversion.h b/libopie/pim/oconversion.h
index 13367e1..4c0a497 100644
--- a/libopie/pim/oconversion.h
+++ b/libopie/pim/oconversion.h
@@ -1,43 +1,48 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) 3** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de)
4** 4**
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13** See http://www.trolltech.com/gpl/ for GPL licensing information. 13** See http://www.trolltech.com/gpl/ for GPL licensing information.
14** 14**
15** Contact info@trolltech.com if any conditions of this licensing are 15** Contact info@trolltech.com if any conditions of this licensing are
16** not clear to you. 16** not clear to you.
17**********************************************************************/ 17**********************************************************************/
18 18
19#ifndef __oconversion_h__ 19#ifndef __oconversion_h__
20#define __oconversion_h__ 20#define __oconversion_h__
21 21
22/* #include <time.h> */ 22/* #include <time.h> */
23/* #include <sys/types.h> */ 23/* #include <sys/types.h> */
24#include <qdatetime.h> 24#include <qdatetime.h>
25 25
26/* FIXME namespace? -zecke */ 26/* FIXME namespace? -zecke */
27class OConversion 27class OConversion
28{ 28{
29public: 29public:
30 static QString dateToString( const QDate &d ); 30 static QString dateToString( const QDate &d );
31 static QDate dateFromString( const QString &datestr ); 31 static QDate dateFromString( const QString &datestr );
32 32
33 /** 33 /**
34 * simple function to store DateTime as string and read from string 34 * simple function to store DateTime as string and read from string
35 * no timezone changing is done 35 * no timezone changing is done
36 * DDMMYYYYHHMMSS is the simple format 36 * DDMMYYYYHHMMSS is the simple format
37 */ 37 */
38 static QString dateTimeToString( const QDateTime& ); 38 static QString dateTimeToString( const QDateTime& );
39 static QDateTime dateTimeFromString( const QString& ); 39 static QDateTime dateTimeFromString( const QString& );
40
41private:
42 class Private;
43 Private* d;
44
40}; 45};
41 46
42#endif // __oconversion_h__ 47#endif // __oconversion_h__
43 48
diff --git a/libopie/pim/odatebookaccessbackend.h b/libopie/pim/odatebookaccessbackend.h
index 86ff298..3c02c42 100644
--- a/libopie/pim/odatebookaccessbackend.h
+++ b/libopie/pim/odatebookaccessbackend.h
@@ -23,51 +23,55 @@ public:
23 23
24 /** 24 /**
25 * This method should return a list of UIDs containing 25 * This method should return a list of UIDs containing
26 * all events. No filter should be applied 26 * all events. No filter should be applied
27 * @return list of events 27 * @return list of events
28 */ 28 */
29 virtual QArray<UID> rawEvents()const = 0; 29 virtual QArray<UID> rawEvents()const = 0;
30 30
31 /** 31 /**
32 * This method should return a list of UIDs containing 32 * This method should return a list of UIDs containing
33 * all repeating events. No filter should be applied 33 * all repeating events. No filter should be applied
34 * @return list of repeating events 34 * @return list of repeating events
35 */ 35 */
36 virtual QArray<UID> rawRepeats()const = 0; 36 virtual QArray<UID> rawRepeats()const = 0;
37 37
38 /** 38 /**
39 * This mthod should return a list of UIDs containing all non 39 * This mthod should return a list of UIDs containing all non
40 * repeating events. No filter should be applied 40 * repeating events. No filter should be applied
41 * @return list of nonrepeating events 41 * @return list of nonrepeating events
42 */ 42 */
43 virtual QArray<UID> nonRepeats() const = 0; 43 virtual QArray<UID> nonRepeats() const = 0;
44 44
45 /** 45 /**
46 * If you do not want to implement the effectiveEvents methods below 46 * If you do not want to implement the effectiveEvents methods below
47 * you need to supply it with directNonRepeats. 47 * you need to supply it with directNonRepeats.
48 * This method can return empty lists if effectiveEvents is implememted 48 * This method can return empty lists if effectiveEvents is implememted
49 */ 49 */
50 virtual OEvent::ValueList directNonRepeats() = 0; 50 virtual OEvent::ValueList directNonRepeats() = 0;
51 51
52 /** 52 /**
53 * Same as above but return raw repeats! 53 * Same as above but return raw repeats!
54 */ 54 */
55 virtual OEvent::ValueList directRawRepeats() = 0; 55 virtual OEvent::ValueList directRawRepeats() = 0;
56 56
57 /* is implemented by default but you can reimplement it*/ 57 /* is implemented by default but you can reimplement it*/
58 /** 58 /**
59 * Effective Events are special event occuring during a time frame. This method does calcualte 59 * Effective Events are special event occuring during a time frame. This method does calcualte
60 * EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method 60 * EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method
61 * yourself 61 * yourself
62 */ 62 */
63 virtual OEffectiveEvent::ValueList effecticeEvents( const QDate& from, const QDate& to ); 63 virtual OEffectiveEvent::ValueList effecticeEvents( const QDate& from, const QDate& to );
64 64
65 /** 65 /**
66 * this is an overloaded member function 66 * this is an overloaded member function
67 * @see effecticeEvents 67 * @see effecticeEvents
68 */ 68 */
69 virtual OEffectiveEvent::ValueList effecticeEvents( const QDateTime& start ); 69 virtual OEffectiveEvent::ValueList effecticeEvents( const QDateTime& start );
70 70
71private:
72 class Private;
73 Private *d;
74
71}; 75};
72 76
73#endif 77#endif
diff --git a/libopie/pim/odatebookaccessbackend_xml.cpp b/libopie/pim/odatebookaccessbackend_xml.cpp
index ab2eea4..5ea945c 100644
--- a/libopie/pim/odatebookaccessbackend_xml.cpp
+++ b/libopie/pim/odatebookaccessbackend_xml.cpp
@@ -385,120 +385,120 @@ bool ODateBookAccessBackend_XML::loadFile() {
385 while ( TRUE ) { 385 while ( TRUE ) {
386 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) 386 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') )
387 ++i; 387 ++i;
388 if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) 388 if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') )
389 break; 389 break;
390 390
391 391
392 // we have another attribute, read it. 392 // we have another attribute, read it.
393 int j = i; 393 int j = i;
394 while ( j < len && dt[j] != '=' ) 394 while ( j < len && dt[j] != '=' )
395 ++j; 395 ++j;
396 QCString attr( dt+i, j-i+1); 396 QCString attr( dt+i, j-i+1);
397 397
398 i = ++j; // skip = 398 i = ++j; // skip =
399 399
400 // find the start of quotes 400 // find the start of quotes
401 while ( i < len && dt[i] != '"' ) 401 while ( i < len && dt[i] != '"' )
402 ++i; 402 ++i;
403 j = ++i; 403 j = ++i;
404 404
405 bool haveUtf = FALSE; 405 bool haveUtf = FALSE;
406 bool haveEnt = FALSE; 406 bool haveEnt = FALSE;
407 while ( j < len && dt[j] != '"' ) { 407 while ( j < len && dt[j] != '"' ) {
408 if ( ((unsigned char)dt[j]) > 0x7f ) 408 if ( ((unsigned char)dt[j]) > 0x7f )
409 haveUtf = TRUE; 409 haveUtf = TRUE;
410 if ( dt[j] == '&' ) 410 if ( dt[j] == '&' )
411 haveEnt = TRUE; 411 haveEnt = TRUE;
412 ++j; 412 ++j;
413 } 413 }
414 if ( i == j ) { 414 if ( i == j ) {
415 // empty value 415 // empty value
416 i = j + 1; 416 i = j + 1;
417 continue; 417 continue;
418 } 418 }
419 419
420 QCString value( dt+i, j-i+1 ); 420 QCString value( dt+i, j-i+1 );
421 i = j + 1; 421 i = j + 1;
422 422
423 QString str = (haveUtf ? QString::fromUtf8( value ) 423 QString str = (haveUtf ? QString::fromUtf8( value )
424 : QString::fromLatin1( value ) ); 424 : QString::fromLatin1( value ) );
425 if ( haveEnt ) 425 if ( haveEnt )
426 str = Qtopia::plainString( str ); 426 str = Qtopia::plainString( str );
427 427
428 /* 428 /*
429 * add key + value 429 * add key + value
430 */ 430 */
431 find = dict[attr.data()]; 431 find = dict[attr.data()];
432 if (!find) 432 if (!find)
433 ev.setCustomField( attr, value ); 433 ev.setCustomField( attr, str );
434 else { 434 else {
435 setField( ev, *find, value ); 435 setField( ev, *find, str );
436 } 436 }
437 } 437 }
438 /* time to finalize */ 438 /* time to finalize */
439 finalizeRecord( ev ); 439 finalizeRecord( ev );
440 delete rec; 440 delete rec;
441 } 441 }
442 ::munmap(map_addr, attribute.st_size ); 442 ::munmap(map_addr, attribute.st_size );
443 m_changed = false; // changed during add 443 m_changed = false; // changed during add
444 444
445 return true; 445 return true;
446} 446}
447void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { 447void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) {
448 /* AllDay is alway in UTC */ 448 /* AllDay is alway in UTC */
449 if ( ev.isAllDay() ) { 449 if ( ev.isAllDay() ) {
450 OTimeZone utc = OTimeZone::utc(); 450 OTimeZone utc = OTimeZone::utc();
451 ev.setStartDateTime( utc.fromUTCDateTime( start ) ); 451 ev.setStartDateTime( utc.fromUTCDateTime( start ) );
452 ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); 452 ev.setEndDateTime ( utc.fromUTCDateTime( end ) );
453 ev.setTimeZone( "UTC"); // make sure it is really utc 453 ev.setTimeZone( "UTC"); // make sure it is really utc
454 }else { 454 }else {
455 /* to current date time */ 455 /* to current date time */
456 qWarning(" Start is %d", start ); 456 // qWarning(" Start is %d", start );
457 OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); 457 OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() );
458 QDateTime date = zone.toDateTime( start ); 458 QDateTime date = zone.toDateTime( start );
459 qWarning(" Start is %s", date.toString().latin1() ); 459 qWarning(" Start is %s", date.toString().latin1() );
460 ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); 460 ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) );
461 461
462 date = zone.toDateTime( end ); 462 date = zone.toDateTime( end );
463 ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); 463 ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) );
464 } 464 }
465 if ( rec && rec->doesRecur() ) { 465 if ( rec && rec->doesRecur() ) {
466 OTimeZone utc = OTimeZone::utc(); 466 OTimeZone utc = OTimeZone::utc();
467 ORecur recu( *rec ); // call copy c'tor; 467 ORecur recu( *rec ); // call copy c'tor;
468 recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); 468 recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() );
469 recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); 469 recu.setCreatedDateTime( utc.fromUTCDateTime( created ) );
470 recu.setStart( ev.startDateTime().date() ); 470 recu.setStart( ev.startDateTime().date() );
471 ev.setRecurrence( recu ); 471 ev.setRecurrence( recu );
472 } 472 }
473 473
474 if (alarmTime != -1 ) { 474 if (alarmTime != -1 ) {
475 QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); 475 QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 );
476 OPimAlarm al( snd , dt ); 476 OPimAlarm al( snd , dt );
477 ev.notifiers().add( al ); 477 ev.notifiers().add( al );
478 } 478 }
479 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { 479 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) {
480 qWarning("already contains assign uid"); 480 qWarning("already contains assign uid");
481 ev.setUid( 1 ); 481 ev.setUid( 1 );
482 } 482 }
483 qWarning("addind %d %s", ev.uid(), ev.description().latin1() ); 483 qWarning("addind %d %s", ev.uid(), ev.description().latin1() );
484 if ( ev.hasRecurrence() ) 484 if ( ev.hasRecurrence() )
485 m_rep.insert( ev.uid(), ev ); 485 m_rep.insert( ev.uid(), ev );
486 else 486 else
487 m_raw.insert( ev.uid(), ev ); 487 m_raw.insert( ev.uid(), ev );
488 488
489} 489}
490void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) { 490void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) {
491// qWarning(" setting %s", value.latin1() ); 491// qWarning(" setting %s", value.latin1() );
492 switch( id ) { 492 switch( id ) {
493 case FDescription: 493 case FDescription:
494 e.setDescription( value ); 494 e.setDescription( value );
495 break; 495 break;
496 case FLocation: 496 case FLocation:
497 e.setLocation( value ); 497 e.setLocation( value );
498 break; 498 break;
499 case FCategories: 499 case FCategories:
500 e.setCategories( e.idsFromString( value ) ); 500 e.setCategories( e.idsFromString( value ) );
501 break; 501 break;
502 case FUid: 502 case FUid:
503 e.setUid( value.toInt() ); 503 e.setUid( value.toInt() );
504 break; 504 break;
diff --git a/libopie/pim/opimaccessbackend.h b/libopie/pim/opimaccessbackend.h
index f4bbe35..c3d91f7 100644
--- a/libopie/pim/opimaccessbackend.h
+++ b/libopie/pim/opimaccessbackend.h
@@ -1,57 +1,58 @@
1#ifndef OPIE_PIM_ACCESS_BACKEND 1#ifndef OPIE_PIM_ACCESS_BACKEND
2#define OPIE_PIM_ACCESS_BACKEND 2#define OPIE_PIM_ACCESS_BACKEND
3 3
4#include <qarray.h> 4#include <qarray.h>
5 5
6#include <opie/otemplatebase.h> 6#include <opie/otemplatebase.h>
7#include <opie/opimrecord.h> 7#include <opie/opimrecord.h>
8 8
9 9
10class OPimAccessBackendPrivate;
10/** 11/**
11 * OPimAccessBackend is the base class 12 * OPimAccessBackend is the base class
12 * for all private backends 13 * for all private backends
13 * it operates on OPimRecord as the base class 14 * it operates on OPimRecord as the base class
14 * and it's responsible for fast manipulating 15 * and it's responsible for fast manipulating
15 * the resource the implementation takes care 16 * the resource the implementation takes care
16 * of 17 * of
17 */ 18 */
18template <class T = OPimRecord> 19template <class T = OPimRecord>
19class OPimAccessBackend { 20class OPimAccessBackend {
20public: 21public:
21 typedef OTemplateBase<T> Frontend; 22 typedef OTemplateBase<T> Frontend;
22 23
23 /** The access hint from the frontend */ 24 /** The access hint from the frontend */
24 OPimAccessBackend(int access = 0); 25 OPimAccessBackend(int access = 0);
25 virtual ~OPimAccessBackend(); 26 virtual ~OPimAccessBackend();
26 27
27 /** 28 /**
28 * load the resource 29 * load the resource
29 */ 30 */
30 virtual bool load() = 0; 31 virtual bool load() = 0;
31 32
32 /** 33 /**
33 * reload the resource 34 * reload the resource
34 */ 35 */
35 virtual bool reload() = 0; 36 virtual bool reload() = 0;
36 37
37 /** 38 /**
38 * save the resource and 39 * save the resource and
39 * all it's changes 40 * all it's changes
40 */ 41 */
41 virtual bool save() = 0; 42 virtual bool save() = 0;
42 43
43 /** 44 /**
44 * return an array of 45 * return an array of
45 * all available uids 46 * all available uids
46 */ 47 */
47 virtual QArray<int> allRecords()const = 0; 48 virtual QArray<int> allRecords()const = 0;
48 49
49 /** 50 /**
50 * return a List of records 51 * return a List of records
51 * that match the regex 52 * that match the regex
52 */ 53 */
53 virtual QArray<int> matchRegexp(const QRegExp &r) const = 0; 54 virtual QArray<int> matchRegexp(const QRegExp &r) const = 0;
54 55
55 /** 56 /**
56 * queryByExample for T with the given Settings 57 * queryByExample for T with the given Settings
57 * 58 *
@@ -62,98 +63,97 @@ public:
62 * find the OPimRecord with uid @param uid 63 * find the OPimRecord with uid @param uid
63 * returns T and T.isEmpty() if nothing was found 64 * returns T and T.isEmpty() if nothing was found
64 */ 65 */
65 virtual T find(int uid )const = 0; 66 virtual T find(int uid )const = 0;
66 67
67 virtual T find(int uid, const QArray<int>& items, 68 virtual T find(int uid, const QArray<int>& items,
68 uint current, typename Frontend::CacheDirection )const ; 69 uint current, typename Frontend::CacheDirection )const ;
69 /** 70 /**
70 * clear the back end 71 * clear the back end
71 */ 72 */
72 virtual void clear() = 0; 73 virtual void clear() = 0;
73 74
74 /** 75 /**
75 * add T 76 * add T
76 */ 77 */
77 virtual bool add( const T& t ) = 0; 78 virtual bool add( const T& t ) = 0;
78 79
79 /** 80 /**
80 * remove 81 * remove
81 */ 82 */
82 virtual bool remove( int uid ) = 0; 83 virtual bool remove( int uid ) = 0;
83 84
84 /** 85 /**
85 * replace a record with T.uid() 86 * replace a record with T.uid()
86 */ 87 */
87 virtual bool replace( const T& t ) = 0; 88 virtual bool replace( const T& t ) = 0;
88 89
89 /* 90 /*
90 * setTheFrontEnd!!! 91 * setTheFrontEnd!!!
91 */ 92 */
92 void setFrontend( Frontend* front ); 93 void setFrontend( Frontend* front );
93 94
94 /** 95 /**
95 * set the read ahead count 96 * set the read ahead count
96 */ 97 */
97 void setReadAhead( uint count ); 98 void setReadAhead( uint count );
98protected: 99protected:
99 int access()const; 100 int access()const;
100 void cache( const T& t )const; 101 void cache( const T& t )const;
101 102
102 /** 103 /**
103 * use a prime number here! 104 * use a prime number here!
104 */ 105 */
105 void setSaneCacheSize( int ); 106 void setSaneCacheSize( int );
106 107
107 uint readAhead()const; 108 uint readAhead()const;
108 109
109private: 110private:
110 class Private; 111 OPimAccessBackendPrivate *d;
111 Private* d;
112 Frontend* m_front; 112 Frontend* m_front;
113 uint m_read; 113 uint m_read;
114 int m_acc; 114 int m_acc;
115 115
116}; 116};
117 117
118template <class T> 118template <class T>
119OPimAccessBackend<T>::OPimAccessBackend(int acc) 119OPimAccessBackend<T>::OPimAccessBackend(int acc)
120 : m_acc( acc ) 120 : m_acc( acc )
121{ 121{
122 m_front = 0l; 122 m_front = 0l;
123} 123}
124template <class T> 124template <class T>
125OPimAccessBackend<T>::~OPimAccessBackend() { 125OPimAccessBackend<T>::~OPimAccessBackend() {
126 126
127} 127}
128template <class T> 128template <class T>
129void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { 129void OPimAccessBackend<T>::setFrontend( Frontend* fr ) {
130 m_front = fr; 130 m_front = fr;
131} 131}
132template <class T> 132template <class T>
133void OPimAccessBackend<T>::cache( const T& t )const { 133void OPimAccessBackend<T>::cache( const T& t )const {
134 if (m_front ) 134 if (m_front )
135 m_front->cache( t ); 135 m_front->cache( t );
136} 136}
137template <class T> 137template <class T>
138void OPimAccessBackend<T>::setSaneCacheSize( int size) { 138void OPimAccessBackend<T>::setSaneCacheSize( int size) {
139 if (m_front ) 139 if (m_front )
140 m_front->setSaneCacheSize( size ); 140 m_front->setSaneCacheSize( size );
141} 141}
142template <class T> 142template <class T>
143T OPimAccessBackend<T>::find( int uid, const QArray<int>&, 143T OPimAccessBackend<T>::find( int uid, const QArray<int>&,
144 uint, typename Frontend::CacheDirection )const { 144 uint, typename Frontend::CacheDirection )const {
145 return find( uid ); 145 return find( uid );
146} 146}
147template <class T> 147template <class T>
148void OPimAccessBackend<T>::setReadAhead( uint count ) { 148void OPimAccessBackend<T>::setReadAhead( uint count ) {
149 m_read = count; 149 m_read = count;
150} 150}
151template <class T> 151template <class T>
152uint OPimAccessBackend<T>::readAhead()const { 152uint OPimAccessBackend<T>::readAhead()const {
153 return m_read; 153 return m_read;
154} 154}
155template <class T> 155template <class T>
156int OPimAccessBackend<T>::access()const { 156int OPimAccessBackend<T>::access()const {
157 return m_acc; 157 return m_acc;
158} 158}
159#endif 159#endif
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h
index 8ff205c..ecbeb68 100644
--- a/libopie/pim/opimaccesstemplate.h
+++ b/libopie/pim/opimaccesstemplate.h
@@ -1,60 +1,61 @@
1#ifndef OPIE_PIM_ACCESS_TEMPLATE_H 1#ifndef OPIE_PIM_ACCESS_TEMPLATE_H
2#define OPIE_PIM_ACCESS_TEMPLATE_H 2#define OPIE_PIM_ACCESS_TEMPLATE_H
3 3
4#include <qarray.h> 4#include <qarray.h>
5 5
6#include <opie/opimrecord.h> 6#include <opie/opimrecord.h>
7#include <opie/opimaccessbackend.h> 7#include <opie/opimaccessbackend.h>
8#include <opie/orecordlist.h> 8#include <opie/orecordlist.h>
9 9
10#include "opimcache.h" 10#include "opimcache.h"
11#include "otemplatebase.h" 11#include "otemplatebase.h"
12 12
13class OPimAccessTemplatePrivate;
13/** 14/**
14 * Thats the frontend to our OPIE PIM 15 * Thats the frontend to our OPIE PIM
15 * Library. Either you want to use it's 16 * Library. Either you want to use it's
16 * interface or you want to implement 17 * interface or you want to implement
17 * your own Access lib 18 * your own Access lib
18 * Just create a OPimRecord and inherit from 19 * Just create a OPimRecord and inherit from
19 * the plugins 20 * the plugins
20 */ 21 */
21 22
22template <class T = OPimRecord > 23template <class T = OPimRecord >
23class OPimAccessTemplate : public OTemplateBase<T> { 24class OPimAccessTemplate : public OTemplateBase<T> {
24public: 25public:
25 enum Access { 26 enum Access {
26 Random = 0, 27 Random = 0,
27 SortedAccess 28 SortedAccess
28 }; 29 };
29 typedef ORecordList<T> List; 30 typedef ORecordList<T> List;
30 typedef OPimAccessBackend<T> BackEnd; 31 typedef OPimAccessBackend<T> BackEnd;
31 typedef OPimCache<T> Cache; 32 typedef OPimCache<T> Cache;
32 33
33 /** 34 /**
34 * c'tor BackEnd 35 * c'tor BackEnd
35 * enum Access a small hint on how to handle the backend 36 * enum Access a small hint on how to handle the backend
36 */ 37 */
37 OPimAccessTemplate( BackEnd* end); 38 OPimAccessTemplate( BackEnd* end);
38 39
39 virtual ~OPimAccessTemplate(); 40 virtual ~OPimAccessTemplate();
40 41
41 /** 42 /**
42 * load from the backend 43 * load from the backend
43 */ 44 */
44 bool load(); 45 bool load();
45 46
46 /** Reload database. 47 /** Reload database.
47 * You should execute this function if the external database 48 * You should execute this function if the external database
48 * was changed. 49 * was changed.
49 * This function will load the external database and afterwards 50 * This function will load the external database and afterwards
50 * rejoin the local changes. Therefore the local database will be set consistent. 51 * rejoin the local changes. Therefore the local database will be set consistent.
51 */ 52 */
52 virtual bool reload(); 53 virtual bool reload();
53 54
54 /** Save contacts database. 55 /** Save contacts database.
55 * Save is more a "commit". After calling this function, all changes are public available. 56 * Save is more a "commit". After calling this function, all changes are public available.
56 * @return true if successful 57 * @return true if successful
57 */ 58 */
58 bool save(); 59 bool save();
59 60
60 /** 61 /**
@@ -107,96 +108,99 @@ public:
107 virtual bool add( const T& t ) ; 108 virtual bool add( const T& t ) ;
108 bool add( const OPimRecord& ); 109 bool add( const OPimRecord& );
109 110
110 /* only the uid matters */ 111 /* only the uid matters */
111 /** 112 /**
112 * remove T from the backend 113 * remove T from the backend
113 * @param t The item to remove 114 * @param t The item to remove
114 * @return <i>true</i> if successful. 115 * @return <i>true</i> if successful.
115 */ 116 */
116 virtual bool remove( const T& t ); 117 virtual bool remove( const T& t );
117 118
118 /** 119 /**
119 * remove the OPimRecord with uid 120 * remove the OPimRecord with uid
120 * @param uid The ID of the item to remove 121 * @param uid The ID of the item to remove
121 * @return <i>true</i> if successful. 122 * @return <i>true</i> if successful.
122 */ 123 */
123 bool remove( int uid ); 124 bool remove( int uid );
124 bool remove( const OPimRecord& ); 125 bool remove( const OPimRecord& );
125 126
126 /** 127 /**
127 * replace T from backend 128 * replace T from backend
128 * @param t The item to replace 129 * @param t The item to replace
129 * @return <i>true</i> if successful. 130 * @return <i>true</i> if successful.
130 */ 131 */
131 virtual bool replace( const T& t) ; 132 virtual bool replace( const T& t) ;
132 133
133 void setReadAhead( uint count ); 134 void setReadAhead( uint count );
134 /** 135 /**
135 * @internal 136 * @internal
136 */ 137 */
137 void cache( const T& )const; 138 void cache( const T& )const;
138 void setSaneCacheSize( int ); 139 void setSaneCacheSize( int );
139 140
140 QArray<int> records()const; 141 QArray<int> records()const;
141protected: 142protected:
142 /** 143 /**
143 * invalidate the cache 144 * invalidate the cache
144 */ 145 */
145 void invalidateCache(); 146 void invalidateCache();
146 147
147 void setBackEnd( BackEnd* end ); 148 void setBackEnd( BackEnd* end );
148 /** 149 /**
149 * returns the backend 150 * returns the backend
150 */ 151 */
151 BackEnd* backEnd(); 152 BackEnd* backEnd();
152 BackEnd* m_backEnd; 153 BackEnd* m_backEnd;
153 Cache m_cache; 154 Cache m_cache;
154 155
156private:
157 OPimAccessTemplatePrivate *d;
158
155}; 159};
156 160
157template <class T> 161template <class T>
158OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) 162OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end )
159 : OTemplateBase<T>(), m_backEnd( end ) 163 : OTemplateBase<T>(), m_backEnd( end )
160{ 164{
161 if (end ) 165 if (end )
162 end->setFrontend( this ); 166 end->setFrontend( this );
163} 167}
164template <class T> 168template <class T>
165OPimAccessTemplate<T>::~OPimAccessTemplate() { 169OPimAccessTemplate<T>::~OPimAccessTemplate() {
166 qWarning("~OPimAccessTemplate<T>"); 170 qWarning("~OPimAccessTemplate<T>");
167 delete m_backEnd; 171 delete m_backEnd;
168} 172}
169template <class T> 173template <class T>
170bool OPimAccessTemplate<T>::load() { 174bool OPimAccessTemplate<T>::load() {
171 invalidateCache(); 175 invalidateCache();
172 return m_backEnd->load(); 176 return m_backEnd->load();
173} 177}
174template <class T> 178template <class T>
175bool OPimAccessTemplate<T>::reload() { 179bool OPimAccessTemplate<T>::reload() {
176 invalidateCache(); // zecke: I think this should be added (se) 180 invalidateCache(); // zecke: I think this should be added (se)
177 return m_backEnd->reload(); 181 return m_backEnd->reload();
178} 182}
179template <class T> 183template <class T>
180bool OPimAccessTemplate<T>::save() { 184bool OPimAccessTemplate<T>::save() {
181 return m_backEnd->save(); 185 return m_backEnd->save();
182} 186}
183template <class T> 187template <class T>
184typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { 188typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const {
185 QArray<int> ints = m_backEnd->allRecords(); 189 QArray<int> ints = m_backEnd->allRecords();
186 List lis(ints, this ); 190 List lis(ints, this );
187 return lis; 191 return lis;
188} 192}
189template <class T> 193template <class T>
190typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const { 194typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const {
191 QArray<int> ints = m_backEnd->matchRegexp( r ); 195 QArray<int> ints = m_backEnd->matchRegexp( r );
192 List lis(ints, this ); 196 List lis(ints, this );
193 return lis; 197 return lis;
194} 198}
195template <class T> 199template <class T>
196QArray<int> OPimAccessTemplate<T>::records()const { 200QArray<int> OPimAccessTemplate<T>::records()const {
197 return m_backEnd->allRecords(); 201 return m_backEnd->allRecords();
198} 202}
199template <class T> 203template <class T>
200typename OPimAccessTemplate<T>::List 204typename OPimAccessTemplate<T>::List
201OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { 205OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) {
202 QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); 206 QArray<int> ints = m_backEnd->queryByExample( t, settings, d );
diff --git a/libopie/pim/opimcache.h b/libopie/pim/opimcache.h
index 73414e5..7f7cff5 100644
--- a/libopie/pim/opimcache.h
+++ b/libopie/pim/opimcache.h
@@ -1,96 +1,102 @@
1#ifndef OPIE_PIM_CACHE_H 1#ifndef OPIE_PIM_CACHE_H
2#define OPIE_PIM_CACHE_H 2#define OPIE_PIM_CACHE_H
3 3
4#include <qintcache.h> 4#include <qintcache.h>
5 5
6#include "opimrecord.h" 6#include "opimrecord.h"
7 7
8class OPimCacheItemPrivate;
9
8template <class T = OPimRecord> 10template <class T = OPimRecord>
9class OPimCacheItem { 11class OPimCacheItem {
10public: 12public:
11 OPimCacheItem( const T& t = T() ); 13 OPimCacheItem( const T& t = T() );
12 OPimCacheItem( const OPimCacheItem& ); 14 OPimCacheItem( const OPimCacheItem& );
13 ~OPimCacheItem(); 15 ~OPimCacheItem();
14 16
15 OPimCacheItem &operator=( const OPimCacheItem& ); 17 OPimCacheItem &operator=( const OPimCacheItem& );
16 18
17 T record()const; 19 T record()const;
18 void setRecord( const T& ); 20 void setRecord( const T& );
19private: 21private:
20 T m_t; 22 T m_t;
23 OPimCacheItemPrivate *d;
21}; 24};
22 25
26
27class OPimCachePrivate;
23/** 28/**
24 * OPimCache for caching the items 29 * OPimCache for caching the items
25 * We support adding, removing 30 * We support adding, removing
26 * and finding 31 * and finding
27 */ 32 */
28template <class T = OPimRecord> 33template <class T = OPimRecord>
29class OPimCache { 34class OPimCache {
30public: 35public:
31 typedef OPimCacheItem<T> Item; 36 typedef OPimCacheItem<T> Item;
32 OPimCache(); 37 OPimCache();
33 OPimCache( const OPimCache& ); 38 OPimCache( const OPimCache& );
34 ~OPimCache(); 39 ~OPimCache();
35 40
36 OPimCache &operator=( const OPimCache& ); 41 OPimCache &operator=( const OPimCache& );
37 42
38 bool contains(int uid)const; 43 bool contains(int uid)const;
39 void invalidate(); 44 void invalidate();
40 void setSize( int size ); 45 void setSize( int size );
41 46
42 T find(int uid )const; 47 T find(int uid )const;
43 void add( const T& ); 48 void add( const T& );
44 void remove( int uid ); 49 void remove( int uid );
45 void replace( const T& ); 50 void replace( const T& );
46 51
47private: 52private:
48 QIntCache<Item> m_cache; 53 QIntCache<Item> m_cache;
54 OPimCachePrivate* d;
49}; 55};
50 56
51// Implementation 57// Implementation
52template <class T> 58template <class T>
53OPimCacheItem<T>::OPimCacheItem( const T& t ) 59OPimCacheItem<T>::OPimCacheItem( const T& t )
54 : m_t(t) { 60 : m_t(t) {
55} 61}
56template <class T> 62template <class T>
57OPimCacheItem<T>::~OPimCacheItem() { 63OPimCacheItem<T>::~OPimCacheItem() {
58 64
59} 65}
60template <class T> 66template <class T>
61T OPimCacheItem<T>::record()const { 67T OPimCacheItem<T>::record()const {
62 return m_t; 68 return m_t;
63} 69}
64template <class T> 70template <class T>
65void OPimCacheItem<T>::setRecord( const T& t ) { 71void OPimCacheItem<T>::setRecord( const T& t ) {
66 m_t = t; 72 m_t = t;
67} 73}
68// Cache 74// Cache
69template <class T> 75template <class T>
70OPimCache<T>::OPimCache() 76OPimCache<T>::OPimCache()
71 : m_cache(100, 53 ) 77 : m_cache(100, 53 )
72{ 78{
73 m_cache.setAutoDelete( TRUE ); 79 m_cache.setAutoDelete( TRUE );
74} 80}
75template <class T> 81template <class T>
76OPimCache<T>::~OPimCache() { 82OPimCache<T>::~OPimCache() {
77 83
78} 84}
79template <class T> 85template <class T>
80bool OPimCache<T>::contains(int uid )const { 86bool OPimCache<T>::contains(int uid )const {
81 Item* it = m_cache.find( uid, FALSE ); 87 Item* it = m_cache.find( uid, FALSE );
82 if (!it) 88 if (!it)
83 return false; 89 return false;
84 return true; 90 return true;
85} 91}
86template <class T> 92template <class T>
87void OPimCache<T>::invalidate() { 93void OPimCache<T>::invalidate() {
88 m_cache.clear(); 94 m_cache.clear();
89} 95}
90template <class T> 96template <class T>
91void OPimCache<T>::setSize( int size ) { 97void OPimCache<T>::setSize( int size ) {
92 m_cache.setMaxCost( size ); 98 m_cache.setMaxCost( size );
93} 99}
94template <class T> 100template <class T>
95T OPimCache<T>::find(int uid )const { 101T OPimCache<T>::find(int uid )const {
96 Item *it = m_cache.find( uid ); 102 Item *it = m_cache.find( uid );
diff --git a/libopie/pim/opimmainwindow.cpp b/libopie/pim/opimmainwindow.cpp
index 4044bc1..2739e26 100644
--- a/libopie/pim/opimmainwindow.cpp
+++ b/libopie/pim/opimmainwindow.cpp
@@ -1,135 +1,147 @@
1#include <qapplication.h> 1#include <qapplication.h>
2#include <qdatetime.h> 2#include <qdatetime.h>
3#include <qcopchannel_qws.h> 3#include <qcopchannel_qws.h>
4 4
5#include <qpe/sound.h> 5#include <qpe/sound.h>
6#include <qpe/qcopenvelope_qws.h> 6#include <qpe/qcopenvelope_qws.h>
7#include <qpe/qpeapplication.h>
7 8
8#include "opimresolver.h" 9#include "opimresolver.h"
9#include "opimmainwindow.h" 10#include "opimmainwindow.h"
10 11
11OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, 12OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent,
12 const char* name, WFlags flag ) 13 const char* name, WFlags flag )
13 : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { 14 : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) {
14 15
15 /* 16 /*
16 * let's generate our QCopChannel 17 * let's generate our QCopChannel
17 */ 18 */
18 m_str = QString("QPE/"+m_service).local8Bit(); 19 m_str = QString("QPE/"+m_service).local8Bit();
19 m_channel= new QCopChannel(m_str, this ); 20 m_channel= new QCopChannel(m_str, this );
20 connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ), 21 connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ),
21 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); 22 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
22 connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), 23 connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ),
23 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); 24 this, SLOT( appMessage( const QCString&, const QByteArray& ) ) );
24 25
25 /* connect flush and reload */ 26 /* connect flush and reload */
26 connect(qApp, SIGNAL(flush() ), 27 connect(qApp, SIGNAL(flush() ),
27 this, SLOT(flush() ) ); 28 this, SLOT(flush() ) );
28 connect(qApp, SIGNAL(reload() ), 29 connect(qApp, SIGNAL(reload() ),
29 this, SLOT(reload() ) ); 30 this, SLOT(reload() ) );
30} 31}
31OPimMainWindow::~OPimMainWindow() { 32OPimMainWindow::~OPimMainWindow() {
32 delete m_channel; 33 delete m_channel;
33} 34}
34QCopChannel* OPimMainWindow::channel() { 35QCopChannel* OPimMainWindow::channel() {
35 return m_channel; 36 return m_channel;
36} 37}
37void OPimMainWindow::doSetDocument( const QString& ) { 38void OPimMainWindow::doSetDocument( const QString& ) {
38 39
39} 40}
40void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { 41void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) {
42 bool needShow = false;
41 /* 43 /*
42 * create demands to create 44 * create demands to create
43 * a new record... 45 * a new record...
44 */ 46 */
45 QDataStream stream(array, IO_ReadOnly); 47 QDataStream stream(array, IO_ReadOnly);
46 if ( cmd == "create()" ) { 48 if ( cmd == "create()" ) {
49 raise();
47 int uid = create(); 50 int uid = create();
48 QCopEnvelope e(m_str, "created(int)" ); 51 QCopEnvelope e(m_str, "created(int)" );
49 e << uid; 52 e << uid;
53 needShow = true;
50 }else if ( cmd == "remove(int)" ) { 54 }else if ( cmd == "remove(int)" ) {
51 int uid; 55 int uid;
52 stream >> uid; 56 stream >> uid;
53 bool rem = remove( uid ); 57 bool rem = remove( uid );
54 QCopEnvelope e(m_str, "removed(bool)" ); 58 QCopEnvelope e(m_str, "removed(bool)" );
55 e << rem; 59 e << rem;
60 needShow = true;
56 }else if ( cmd == "beam(int)" ) { 61 }else if ( cmd == "beam(int)" ) {
57 int uid; 62 int uid;
58 stream >> uid; 63 stream >> uid;
59 beam( uid); 64 beam( uid);
60 }else if ( cmd == "show(int)" ) { 65 }else if ( cmd == "show(int)" ) {
66 raise();
61 int uid; 67 int uid;
62 stream >> uid; 68 stream >> uid;
63 show( uid ); 69 show( uid );
70 needShow = true;
64 }else if ( cmd == "edit(int)" ) { 71 }else if ( cmd == "edit(int)" ) {
72 raise();
65 int uid; 73 int uid;
66 stream >> uid; 74 stream >> uid;
67 edit( uid ); 75 edit( uid );
68 }else if ( cmd == "add(int,QByteArray)" ) { 76 }else if ( cmd == "add(int,QByteArray)" ) {
69 int rtti; 77 int rtti;
70 QByteArray array; 78 QByteArray array;
71 stream >> rtti; 79 stream >> rtti;
72 stream >> array; 80 stream >> array;
73 m_fallBack = record(rtti, array ); 81 m_fallBack = record(rtti, array );
74 if (!m_fallBack) return; 82 if (!m_fallBack) return;
75 add( *m_fallBack ); 83 add( *m_fallBack );
76 delete m_fallBack; 84 delete m_fallBack;
77 }else if ( cmd == "alarm(QDateTime,int)" ) { 85 }else if ( cmd == "alarm(QDateTime,int)" ) {
86 raise();
78 QDateTime dt; int uid; 87 QDateTime dt; int uid;
79 stream >> dt; 88 stream >> dt;
80 stream >> uid; 89 stream >> uid;
81 qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid ); 90 qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid );
82 QDateTime current = QDateTime::currentDateTime(); 91 QDateTime current = QDateTime::currentDateTime();
83 if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() ) 92 if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() )
84 return; 93 return;
85 doAlarm( dt, uid ); 94 doAlarm( dt, uid );
86 95 needShow = true;
87 } 96 }
97
98 if (needShow )
99 QPEApplication::setKeepRunning();
88} 100}
89/* implement the url scripting here */ 101/* implement the url scripting here */
90void OPimMainWindow::setDocument( const QString& str) { 102void OPimMainWindow::setDocument( const QString& str) {
91 doSetDocument( str ); 103 doSetDocument( str );
92} 104}
93/* 105/*
94 * we now try to get the array demarshalled 106 * we now try to get the array demarshalled
95 * check if the rtti matches this one 107 * check if the rtti matches this one
96 */ 108 */
97OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { 109OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) {
98 if ( service() != rtti ) 110 if ( service() != rtti )
99 return 0l; 111 return 0l;
100 112
101 OPimRecord* record = OPimResolver::self()->record( rtti ); 113 OPimRecord* record = OPimResolver::self()->record( rtti );
102 QDataStream str(array, IO_ReadOnly ); 114 QDataStream str(array, IO_ReadOnly );
103 if ( !record || !record->loadFromStream(str) ) { 115 if ( !record || !record->loadFromStream(str) ) {
104 delete record; 116 delete record;
105 record = 0l; 117 record = 0l;
106 } 118 }
107 119
108 return record; 120 return record;
109} 121}
110/* 122/*
111 * get the rtti for the service 123 * get the rtti for the service
112 */ 124 */
113int OPimMainWindow::service() { 125int OPimMainWindow::service() {
114 if ( m_rtti == -1 ) 126 if ( m_rtti == -1 )
115 m_rtti = OPimResolver::self()->serviceId( m_service ); 127 m_rtti = OPimResolver::self()->serviceId( m_service );
116 128
117 return m_rtti; 129 return m_rtti;
118} 130}
119void OPimMainWindow::doAlarm( const QDateTime&, int ) { 131void OPimMainWindow::doAlarm( const QDateTime&, int ) {
120 132
121} 133}
122void OPimMainWindow::startAlarm(int count ) { 134void OPimMainWindow::startAlarm(int count ) {
123 m_alarmCount = count; 135 m_alarmCount = count;
124 m_playedCount = 0; 136 m_playedCount = 0;
125 Sound::soundAlarm(); 137 Sound::soundAlarm();
126 m_timerId = startTimer( 5000 ); 138 m_timerId = startTimer( 5000 );
127} 139}
128void OPimMainWindow::killAlarm() { 140void OPimMainWindow::killAlarm() {
129 killTimer( m_timerId ); 141 killTimer( m_timerId );
130} 142}
131void OPimMainWindow::timerEvent( QTimerEvent* e) { 143void OPimMainWindow::timerEvent( QTimerEvent* e) {
132 if ( m_playedCount <m_alarmCount ) { 144 if ( m_playedCount <m_alarmCount ) {
133 m_playedCount++; 145 m_playedCount++;
134 Sound::soundAlarm(); 146 Sound::soundAlarm();
135 }else { 147 }else {
diff --git a/libopie/pim/opimxrefmanager.h b/libopie/pim/opimxrefmanager.h
index 39e5eef..c485e98 100644
--- a/libopie/pim/opimxrefmanager.h
+++ b/libopie/pim/opimxrefmanager.h
@@ -1,41 +1,43 @@
1#ifndef OPIM_XREF_MANAGER_H 1#ifndef OPIM_XREF_MANAGER_H
2#define OPIM_XREF_MANAGER_H 2#define OPIM_XREF_MANAGER_H
3 3
4#include <qstringlist.h> 4#include <qstringlist.h>
5 5
6#include <opie/opimxref.h> 6#include <opie/opimxref.h>
7 7
8/** 8/**
9 * This is a simple manager for 9 * This is a simple manager for
10 * OPimXRefs. 10 * OPimXRefs.
11 * It allows addition, removing, replacing 11 * It allows addition, removing, replacing
12 * clearing and 'querying' the XRef... 12 * clearing and 'querying' the XRef...
13 */ 13 */
14class OPimXRefManager { 14class OPimXRefManager {
15public: 15public:
16 OPimXRefManager(); 16 OPimXRefManager();
17 OPimXRefManager( const OPimXRefManager& ); 17 OPimXRefManager( const OPimXRefManager& );
18 ~OPimXRefManager(); 18 ~OPimXRefManager();
19 19
20 OPimXRefManager& operator=( const OPimXRefManager& ); 20 OPimXRefManager& operator=( const OPimXRefManager& );
21 bool operator==( const OPimXRefManager& ); 21 bool operator==( const OPimXRefManager& );
22 22
23 void add( const OPimXRef& ); 23 void add( const OPimXRef& );
24 void remove( const OPimXRef& ); 24 void remove( const OPimXRef& );
25 void replace( const OPimXRef& ); 25 void replace( const OPimXRef& );
26 26
27 void clear(); 27 void clear();
28 28
29 /** 29 /**
30 * apps participating 30 * apps participating
31 */ 31 */
32 QStringList apps()const; 32 QStringList apps()const;
33 OPimXRef::ValueList list()const; 33 OPimXRef::ValueList list()const;
34 OPimXRef::ValueList list( const QString& service )const; 34 OPimXRef::ValueList list( const QString& service )const;
35 OPimXRef::ValueList list( int uid )const; 35 OPimXRef::ValueList list( int uid )const;
36 36
37private: 37private:
38 OPimXRef::ValueList m_list; 38 OPimXRef::ValueList m_list;
39 class Private;
40 Private *d;
39}; 41};
40 42
41#endif 43#endif
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h
index edcd729..5211f57 100644
--- a/libopie/pim/orecordlist.h
+++ b/libopie/pim/orecordlist.h
@@ -1,173 +1,176 @@
1 1
2#ifndef OPIE_RECORD_LIST_H 2#ifndef OPIE_RECORD_LIST_H
3#define OPIE_RECORD_LIST_H 3#define OPIE_RECORD_LIST_H
4 4
5#include <qarray.h> 5#include <qarray.h>
6 6
7#include "otemplatebase.h" 7#include "otemplatebase.h"
8#include "opimrecord.h" 8#include "opimrecord.h"
9 9
10class ORecordListIteratorPrivate;
10/** 11/**
11 * Our List Iterator 12 * Our List Iterator
12 * it behaves like STL or Qt 13 * it behaves like STL or Qt
13 * 14 *
14 * for(it = list.begin(); it != list.end(); ++it ) 15 * for(it = list.begin(); it != list.end(); ++it )
15 * doSomeCoolStuff( (*it) ); 16 * doSomeCoolStuff( (*it) );
16 */ 17 */
17template <class T> class ORecordList; 18template <class T> class ORecordList;
18template <class T = OPimRecord> 19template <class T = OPimRecord>
19class ORecordListIterator { 20class ORecordListIterator {
20 friend class ORecordList<T>; 21 friend class ORecordList<T>;
21public: 22public:
22 typedef OTemplateBase<T> Base; 23 typedef OTemplateBase<T> Base;
23 24
24 /** 25 /**
25 * The c'tor used internally from 26 * The c'tor used internally from
26 * ORecordList 27 * ORecordList
27 */ 28 */
28 ORecordListIterator( const QArray<int>, const Base* ); 29 ORecordListIterator( const QArray<int>, const Base* );
29 30
30 /** 31 /**
31 * The standard c'tor 32 * The standard c'tor
32 */ 33 */
33 ORecordListIterator(); 34 ORecordListIterator();
34 ~ORecordListIterator(); 35 ~ORecordListIterator();
35 36
36 ORecordListIterator( const ORecordListIterator& ); 37 ORecordListIterator( const ORecordListIterator& );
37 ORecordListIterator &operator=(const ORecordListIterator& ); 38 ORecordListIterator &operator=(const ORecordListIterator& );
38 39
39 /** 40 /**
40 * a * operator ;) 41 * a * operator ;)
41 * use it like this T = (*it); 42 * use it like this T = (*it);
42 */ 43 */
43 T operator*(); 44 T operator*();
44 ORecordListIterator &operator++(); 45 ORecordListIterator &operator++();
45 ORecordListIterator &operator--(); 46 ORecordListIterator &operator--();
46 47
47 bool operator==( const ORecordListIterator& it ); 48 bool operator==( const ORecordListIterator& it );
48 bool operator!=( const ORecordListIterator& it ); 49 bool operator!=( const ORecordListIterator& it );
49 50
50 /** 51 /**
51 * the current item 52 * the current item
52 */ 53 */
53 uint current()const; 54 uint current()const;
54 55
55 /** 56 /**
56 * the number of items 57 * the number of items
57 */ 58 */
58 uint count()const; 59 uint count()const;
59 60
60 /** 61 /**
61 * sets the current item 62 * sets the current item
62 */ 63 */
63 void setCurrent( uint cur ); 64 void setCurrent( uint cur );
64 65
65private: 66private:
66 QArray<int> m_uids; 67 QArray<int> m_uids;
67 uint m_current; 68 uint m_current;
68 const Base* m_temp; 69 const Base* m_temp;
69 bool m_end : 1; 70 bool m_end : 1;
70 T m_record; 71 T m_record;
71 bool m_direction :1; 72 bool m_direction :1;
72 73
73 /* d pointer for future versions */ 74 /* d pointer for future versions */
74 class IteratorPrivate; 75 ORecordListIteratorPrivate *d;
75 IteratorPrivate *d;
76}; 76};
77
78class ORecordListPrivate;
77/** 79/**
78 * The recordlist used as a return type 80 * The recordlist used as a return type
79 * from OPimAccessTemplate 81 * from OPimAccessTemplate
80 */ 82 */
81template <class T = OPimRecord > 83template <class T = OPimRecord >
82class ORecordList { 84class ORecordList {
83public: 85public:
84 typedef OTemplateBase<T> Base; 86 typedef OTemplateBase<T> Base;
85 typedef ORecordListIterator<T> Iterator; 87 typedef ORecordListIterator<T> Iterator;
86 88
87 /** 89 /**
88 * c'tor 90 * c'tor
89 */ 91 */
90 ORecordList () { 92 ORecordList () {
91 } 93 }
92ORecordList( const QArray<int>& ids, 94ORecordList( const QArray<int>& ids,
93 const Base* ); 95 const Base* );
94 ~ORecordList(); 96 ~ORecordList();
95 97
96 /** 98 /**
97 * the first iterator 99 * the first iterator
98 */ 100 */
99 Iterator begin(); 101 Iterator begin();
100 102
101 /** 103 /**
102 * the end 104 * the end
103 */ 105 */
104 Iterator end(); 106 Iterator end();
105 107
106 /** 108 /**
107 * the number of items in the list 109 * the number of items in the list
108 */ 110 */
109 uint count()const; 111 uint count()const;
110 112
111 T operator[]( uint i ); 113 T operator[]( uint i );
112 int uidAt(uint i ); 114 int uidAt(uint i );
113 115
114 /** 116 /**
115 * Remove the contact with given uid 117 * Remove the contact with given uid
116 */ 118 */
117 bool remove( int uid ); 119 bool remove( int uid );
118 120
119 /* 121 /*
120 ConstIterator begin()const; 122 ConstIterator begin()const;
121 ConstIterator end()const; 123 ConstIterator end()const;
122 */ 124 */
123private: 125private:
124 QArray<int> m_ids; 126 QArray<int> m_ids;
125 const Base* m_acc; 127 const Base* m_acc;
128 ORecordListPrivate *d;
126}; 129};
127 130
128/* ok now implement it */ 131/* ok now implement it */
129template <class T> 132template <class T>
130ORecordListIterator<T>::ORecordListIterator() { 133ORecordListIterator<T>::ORecordListIterator() {
131 m_current = 0; 134 m_current = 0;
132 m_temp = 0l; 135 m_temp = 0l;
133 m_end = true; 136 m_end = true;
134 m_record = T(); 137 m_record = T();
135 /* forward */ 138 /* forward */
136 m_direction = TRUE; 139 m_direction = TRUE;
137} 140}
138template <class T> 141template <class T>
139ORecordListIterator<T>::~ORecordListIterator() { 142ORecordListIterator<T>::~ORecordListIterator() {
140/* nothing to delete */ 143/* nothing to delete */
141} 144}
142 145
143template <class T> 146template <class T>
144ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { 147ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
145// qWarning("ORecordListIterator copy c'tor"); 148// qWarning("ORecordListIterator copy c'tor");
146 m_uids = it.m_uids; 149 m_uids = it.m_uids;
147 m_current = it.m_current; 150 m_current = it.m_current;
148 m_temp = it.m_temp; 151 m_temp = it.m_temp;
149 m_end = it.m_end; 152 m_end = it.m_end;
150 m_record = it.m_record; 153 m_record = it.m_record;
151 m_direction = it.m_direction; 154 m_direction = it.m_direction;
152} 155}
153 156
154template <class T> 157template <class T>
155ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { 158ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) {
156 m_uids = it.m_uids; 159 m_uids = it.m_uids;
157 m_current = it.m_current; 160 m_current = it.m_current;
158 m_temp = it.m_temp; 161 m_temp = it.m_temp;
159 m_end = it.m_end; 162 m_end = it.m_end;
160 m_record = it.m_record; 163 m_record = it.m_record;
161 164
162 return *this; 165 return *this;
163} 166}
164 167
165template <class T> 168template <class T>
166T ORecordListIterator<T>::operator*() { 169T ORecordListIterator<T>::operator*() {
167 //qWarning("operator* %d %d", m_current, m_uids[m_current] ); 170 //qWarning("operator* %d %d", m_current, m_uids[m_current] );
168 if (!m_end ) 171 if (!m_end )
169 m_record = m_temp->find( m_uids[m_current], m_uids, m_current, 172 m_record = m_temp->find( m_uids[m_current], m_uids, m_current,
170 m_direction ? Base::Forward : 173 m_direction ? Base::Forward :
171 Base::Reverse ); 174 Base::Reverse );
172 else 175 else
173 m_record = T(); 176 m_record = T();
@@ -175,96 +178,99 @@ T ORecordListIterator<T>::operator*() {
175 return m_record; 178 return m_record;
176} 179}
177 180
178template <class T> 181template <class T>
179ORecordListIterator<T> &ORecordListIterator<T>::operator++() { 182ORecordListIterator<T> &ORecordListIterator<T>::operator++() {
180 m_direction = true; 183 m_direction = true;
181 if (m_current < m_uids.count() ) { 184 if (m_current < m_uids.count() ) {
182 m_end = false; 185 m_end = false;
183 ++m_current; 186 ++m_current;
184 }else 187 }else
185 m_end = true; 188 m_end = true;
186 189
187 return *this; 190 return *this;
188} 191}
189template <class T> 192template <class T>
190ORecordListIterator<T> &ORecordListIterator<T>::operator--() { 193ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
191 m_direction = false; 194 m_direction = false;
192 if ( m_current > 0 ) { 195 if ( m_current > 0 ) {
193 --m_current; 196 --m_current;
194 m_end = false; 197 m_end = false;
195 } else 198 } else
196 m_end = true; 199 m_end = true;
197 200
198 return *this; 201 return *this;
199} 202}
200 203
201template <class T> 204template <class T>
202bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { 205bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
203 206
204 /* if both are at we're the same.... */ 207 /* if both are at we're the same.... */
205 if ( m_end == it.m_end ) return true; 208 if ( m_end == it.m_end ) return true;
206 209
207 if ( m_uids != it.m_uids ) return false; 210 if ( m_uids != it.m_uids ) return false;
208 if ( m_current != it.m_current ) return false; 211 if ( m_current != it.m_current ) return false;
209 if ( m_temp != it.m_temp ) return false; 212 if ( m_temp != it.m_temp ) return false;
210 213
211 return true; 214 return true;
212} 215}
213template <class T> 216template <class T>
214bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { 217bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) {
215 return !(*this == it ); 218 return !(*this == it );
216} 219}
217template <class T> 220template <class T>
218ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, 221ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
219 const Base* t ) 222 const Base* t )
220 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), 223 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ),
221 m_direction( false ) 224 m_direction( false )
222{ 225{
226 /* if the list is empty we're already at the end of the list */
227 if (uids.count() == 0 )
228 m_end = true;
223} 229}
224template <class T> 230template <class T>
225uint ORecordListIterator<T>::current()const { 231uint ORecordListIterator<T>::current()const {
226 return m_current; 232 return m_current;
227} 233}
228template <class T> 234template <class T>
229void ORecordListIterator<T>::setCurrent( uint cur ) { 235void ORecordListIterator<T>::setCurrent( uint cur ) {
230 if( cur < m_uids.count() ) { 236 if( cur < m_uids.count() ) {
231 m_end = false; 237 m_end = false;
232 m_current= cur; 238 m_current= cur;
233 } 239 }
234} 240}
235template <class T> 241template <class T>
236uint ORecordListIterator<T>::count()const { 242uint ORecordListIterator<T>::count()const {
237 return m_uids.count(); 243 return m_uids.count();
238} 244}
239template <class T> 245template <class T>
240ORecordList<T>::ORecordList( const QArray<int>& ids, 246ORecordList<T>::ORecordList( const QArray<int>& ids,
241 const Base* acc ) 247 const Base* acc )
242 : m_ids( ids ), m_acc( acc ) 248 : m_ids( ids ), m_acc( acc )
243{ 249{
244} 250}
245template <class T> 251template <class T>
246ORecordList<T>::~ORecordList() { 252ORecordList<T>::~ORecordList() {
247/* nothing to do here */ 253/* nothing to do here */
248} 254}
249template <class T> 255template <class T>
250typename ORecordList<T>::Iterator ORecordList<T>::begin() { 256typename ORecordList<T>::Iterator ORecordList<T>::begin() {
251 Iterator it( m_ids, m_acc ); 257 Iterator it( m_ids, m_acc );
252 return it; 258 return it;
253} 259}
254template <class T> 260template <class T>
255typename ORecordList<T>::Iterator ORecordList<T>::end() { 261typename ORecordList<T>::Iterator ORecordList<T>::end() {
256 Iterator it( m_ids, m_acc ); 262 Iterator it( m_ids, m_acc );
257 it.m_end = true; 263 it.m_end = true;
258 it.m_current = m_ids.count(); 264 it.m_current = m_ids.count();
259 265
260 return it; 266 return it;
261} 267}
262template <class T> 268template <class T>
263uint ORecordList<T>::count()const { 269uint ORecordList<T>::count()const {
264return m_ids.count(); 270return m_ids.count();
265} 271}
266template <class T> 272template <class T>
267T ORecordList<T>::operator[]( uint i ) { 273T ORecordList<T>::operator[]( uint i ) {
268 if ( i >= m_ids.count() ) 274 if ( i >= m_ids.count() )
269 return T(); 275 return T();
270 /* forward */ 276 /* forward */
diff --git a/libopie/pim/otemplatebase.h b/libopie/pim/otemplatebase.h
index 29fb6ec..cadac74 100644
--- a/libopie/pim/otemplatebase.h
+++ b/libopie/pim/otemplatebase.h
@@ -1,91 +1,98 @@
1#ifndef OPIE_TEMPLATE_BASE_H 1#ifndef OPIE_TEMPLATE_BASE_H
2#define OPIE_TEMPLATE_BASE_H 2#define OPIE_TEMPLATE_BASE_H
3 3
4#include <qarray.h> 4#include <qarray.h>
5 5
6#include <opie/opimrecord.h> 6#include <opie/opimrecord.h>
7 7
8 8
9/** 9/**
10 * Templates do not have a base class, This is why 10 * Templates do not have a base class, This is why
11 * we've this class 11 * we've this class
12 * this is here to give us the possibility 12 * this is here to give us the possibility
13 * to have a common base class 13 * to have a common base class
14 * You may not want to use that interface internaly 14 * You may not want to use that interface internaly
15 * POOR mans interface 15 * POOR mans interface
16 */ 16 */
17class OPimBasePrivate;
17struct OPimBase { 18struct OPimBase {
18 /** 19 /**
19 * return the rtti 20 * return the rtti
20 */ 21 */
21 virtual int rtti()= 0; 22 virtual int rtti()= 0;
22 virtual OPimRecord* record()const = 0; 23 virtual OPimRecord* record()const = 0;
23 virtual OPimRecord* record(int uid)const = 0; 24 virtual OPimRecord* record(int uid)const = 0;
24 virtual bool add( const OPimRecord& ) = 0; 25 virtual bool add( const OPimRecord& ) = 0;
25 virtual bool remove( int uid ) = 0; 26 virtual bool remove( int uid ) = 0;
26 virtual bool remove( const OPimRecord& ) = 0; 27 virtual bool remove( const OPimRecord& ) = 0;
27 virtual void clear() = 0; 28 virtual void clear() = 0;
28 virtual bool load() = 0; 29 virtual bool load() = 0;
29 virtual bool save() = 0; 30 virtual bool save() = 0;
30 virtual QArray<int> records()const = 0; 31 virtual QArray<int> records()const = 0;
31 /* 32 /*
32 * ADD editing here? 33 * ADD editing here?
33 * -zecke 34 * -zecke
34 */ 35 */
36private:
37 OPimBasePrivate* d;
35 38
36}; 39};
37/** 40/**
38 * internal template base 41 * internal template base
39 * T needs to implement the copy c'tor!!! 42 * T needs to implement the copy c'tor!!!
40 */ 43 */
44class OTemplateBasePrivate;
41template <class T = OPimRecord> 45template <class T = OPimRecord>
42class OTemplateBase : public OPimBase { 46class OTemplateBase : public OPimBase {
43public: 47public:
44 enum CacheDirection { Forward=0, Reverse }; 48 enum CacheDirection { Forward=0, Reverse };
45 OTemplateBase() { 49 OTemplateBase() {
46 }; 50 };
47 virtual ~OTemplateBase() { 51 virtual ~OTemplateBase() {
48 } 52 }
49 virtual T find( int uid )const = 0; 53 virtual T find( int uid )const = 0;
50 54
51 /** 55 /**
52 * read ahead find 56 * read ahead find
53 */ 57 */
54 virtual T find( int uid, const QArray<int>& items, 58 virtual T find( int uid, const QArray<int>& items,
55 uint current, CacheDirection dir = Forward )const = 0; 59 uint current, CacheDirection dir = Forward )const = 0;
56 virtual void cache( const T& )const = 0; 60 virtual void cache( const T& )const = 0;
57 virtual void setSaneCacheSize( int ) = 0; 61 virtual void setSaneCacheSize( int ) = 0;
58 62
59 /* reimplement of OPimBase */ 63 /* reimplement of OPimBase */
60 int rtti(); 64 int rtti();
61 OPimRecord* record()const; 65 OPimRecord* record()const;
62 OPimRecord* record(int uid )const; 66 OPimRecord* record(int uid )const;
63 static T* rec(); 67 static T* rec();
68
69private:
70 OTemplateBasePrivate *d;
64}; 71};
65 72
66/* 73/*
67 * implementation 74 * implementation
68 */ 75 */
69template <class T> 76template <class T>
70int 77int
71OTemplateBase<T>::rtti() { 78OTemplateBase<T>::rtti() {
72 return T::rtti(); 79 return T::rtti();
73} 80}
74template <class T> 81template <class T>
75OPimRecord* OTemplateBase<T>::record()const { 82OPimRecord* OTemplateBase<T>::record()const {
76 T* t = new T; 83 T* t = new T;
77 return t; 84 return t;
78} 85}
79template <class T> 86template <class T>
80OPimRecord* OTemplateBase<T>::record(int uid )const { 87OPimRecord* OTemplateBase<T>::record(int uid )const {
81 T t2 = find(uid ); 88 T t2 = find(uid );
82 T* t1 = new T(t2); 89 T* t1 = new T(t2);
83 90
84 return t1; 91 return t1;
85}; 92};
86template <class T> 93template <class T>
87T* OTemplateBase<T>::rec() { 94T* OTemplateBase<T>::rec() {
88 return new T; 95 return new T;
89} 96}
90 97
91#endif 98#endif
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp
index 38b93f7..5a18c37 100644
--- a/libopie/pim/otodo.cpp
+++ b/libopie/pim/otodo.cpp
@@ -1,78 +1,83 @@
1 1
2#include <qobject.h> 2#include <qobject.h>
3#include <qshared.h> 3#include <qshared.h>
4 4
5 5
6 6
7#include <qpe/palmtopuidgen.h> 7#include <qpe/palmtopuidgen.h>
8#include <qpe/stringutil.h> 8#include <qpe/stringutil.h>
9#include <qpe/palmtoprecord.h> 9#include <qpe/palmtoprecord.h>
10#include <qpe/stringutil.h> 10#include <qpe/stringutil.h>
11#include <qpe/categories.h> 11#include <qpe/categories.h>
12#include <qpe/categoryselect.h> 12#include <qpe/categoryselect.h>
13 13
14 14
15#include "opimstate.h" 15#include "opimstate.h"
16#include "orecur.h" 16#include "orecur.h"
17#include "opimmaintainer.h" 17#include "opimmaintainer.h"
18#include "opimnotifymanager.h" 18#include "opimnotifymanager.h"
19#include "opimresolver.h" 19#include "opimresolver.h"
20 20
21#include "otodo.h" 21#include "otodo.h"
22 22
23 23
24struct OTodo::OTodoData : public QShared { 24struct OTodo::OTodoData : public QShared {
25 OTodoData() : QShared() { 25 OTodoData() : QShared() {
26 recur = 0; 26 recur = 0;
27 state = 0; 27 state = 0;
28 maintainer = 0; 28 maintainer = 0;
29 notifiers = 0; 29 notifiers = 0;
30 }; 30 };
31 ~OTodoData() {
32 delete recur;
33 delete maintainer;
34 delete notifiers;
35 }
31 36
32 QDate date; 37 QDate date;
33 bool isCompleted:1; 38 bool isCompleted:1;
34 bool hasDate:1; 39 bool hasDate:1;
35 int priority; 40 int priority;
36 QString desc; 41 QString desc;
37 QString sum; 42 QString sum;
38 QMap<QString, QString> extra; 43 QMap<QString, QString> extra;
39 ushort prog; 44 ushort prog;
40 OPimState *state; 45 OPimState *state;
41 ORecur *recur; 46 ORecur *recur;
42 OPimMaintainer *maintainer; 47 OPimMaintainer *maintainer;
43 QDate start; 48 QDate start;
44 QDate completed; 49 QDate completed;
45 OPimNotifyManager *notifiers; 50 OPimNotifyManager *notifiers;
46}; 51};
47 52
48OTodo::OTodo(const OTodo &event ) 53OTodo::OTodo(const OTodo &event )
49 : OPimRecord( event ), data( event.data ) 54 : OPimRecord( event ), data( event.data )
50{ 55{
51 data->ref(); 56 data->ref();
52// qWarning("ref up"); 57// qWarning("ref up");
53} 58}
54OTodo::~OTodo() { 59OTodo::~OTodo() {
55 60
56// qWarning("~OTodo " ); 61// qWarning("~OTodo " );
57 if ( data->deref() ) { 62 if ( data->deref() ) {
58// qWarning("OTodo::dereffing"); 63// qWarning("OTodo::dereffing");
59 delete data; 64 delete data;
60 data = 0l; 65 data = 0l;
61 } 66 }
62} 67}
63OTodo::OTodo(bool completed, int priority, 68OTodo::OTodo(bool completed, int priority,
64 const QArray<int> &category, 69 const QArray<int> &category,
65 const QString& summary, 70 const QString& summary,
66 const QString &description, 71 const QString &description,
67 ushort progress, 72 ushort progress,
68 bool hasDate, QDate date, int uid ) 73 bool hasDate, QDate date, int uid )
69 : OPimRecord( uid ) 74 : OPimRecord( uid )
70{ 75{
71// qWarning("OTodoData " + summary); 76// qWarning("OTodoData " + summary);
72 setCategories( category ); 77 setCategories( category );
73 78
74 data = new OTodoData; 79 data = new OTodoData;
75 80
76 data->date = date; 81 data->date = date;
77 data->isCompleted = completed; 82 data->isCompleted = completed;
78 data->hasDate = hasDate; 83 data->hasDate = hasDate;
@@ -229,114 +234,113 @@ void OTodo::setCompletedDate( const QDate& date ) {
229 changeOrModify(); 234 changeOrModify();
230 data->completed = date; 235 data->completed = date;
231} 236}
232void OTodo::setState( const OPimState& state ) { 237void OTodo::setState( const OPimState& state ) {
233 changeOrModify(); 238 changeOrModify();
234 if (data->state ) 239 if (data->state )
235 (*data->state) = state; 240 (*data->state) = state;
236 else 241 else
237 data->state = new OPimState( state ); 242 data->state = new OPimState( state );
238} 243}
239void OTodo::setRecurrence( const ORecur& rec) { 244void OTodo::setRecurrence( const ORecur& rec) {
240 changeOrModify(); 245 changeOrModify();
241 if (data->recur ) 246 if (data->recur )
242 (*data->recur) = rec; 247 (*data->recur) = rec;
243 else 248 else
244 data->recur = new ORecur( rec ); 249 data->recur = new ORecur( rec );
245} 250}
246void OTodo::setMaintainer( const OPimMaintainer& pim ) { 251void OTodo::setMaintainer( const OPimMaintainer& pim ) {
247 changeOrModify(); 252 changeOrModify();
248 253
249 if (data->maintainer ) 254 if (data->maintainer )
250 (*data->maintainer) = pim; 255 (*data->maintainer) = pim;
251 else 256 else
252 data->maintainer = new OPimMaintainer( pim ); 257 data->maintainer = new OPimMaintainer( pim );
253} 258}
254bool OTodo::isOverdue( ) 259bool OTodo::isOverdue( )
255{ 260{
256 if( data->hasDate && !data->isCompleted) 261 if( data->hasDate && !data->isCompleted)
257 return QDate::currentDate() > data->date; 262 return QDate::currentDate() > data->date;
258 return false; 263 return false;
259} 264}
260void OTodo::setProgress(ushort progress ) 265void OTodo::setProgress(ushort progress )
261{ 266{
262 changeOrModify(); 267 changeOrModify();
263 data->prog = progress; 268 data->prog = progress;
264} 269}
265QString OTodo::toShortText() const { 270QString OTodo::toShortText() const {
266 return summary(); 271 return summary();
267} 272}
268/*! 273/*!
269 Returns a richt text string 274 Returns a richt text string
270*/ 275*/
271QString OTodo::toRichText() const 276QString OTodo::toRichText() const
272{ 277{
273 QString text; 278 QString text;
274 QStringList catlist; 279 QStringList catlist;
275 280
276 // summary 281 // summary
277 text += "<b><h3><img src=\"todo/TodoList\">"; 282 text += "<b><h3><img src=\"todo/TodoList\"> ";
278 if ( !summary().isEmpty() ) { 283 if ( !summary().isEmpty() ) {
279 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" ); 284 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" );
280 } 285 }
281 text += "</h3></b><br><hr><br>"; 286 text += "</h3></b><br><hr><br>";
282 287
283 // description 288 // description
284 if( !description().isEmpty() ){ 289 if( !description().isEmpty() ){
285 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; 290 text += "<b>" + QObject::tr( "Notes:" ) + "</b><br>";
286 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; 291 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
287 } 292 }
288 293
289 // priority 294 // priority
290 int priorityval = priority(); 295 int priorityval = priority();
291 text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" + 296 text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" +
292 QString::number( priorityval ) + "\">"; 297 QString::number( priorityval ) + "\"> ";
293// text += "<b>" + QObject::tr( "Priority:") +"</b><img src=\"todo/priority" + 298
294// QString::number( priority() ) + "\"><br>";
295 switch ( priorityval ) 299 switch ( priorityval )
296 { 300 {
297 case 1 : text += QObject::tr( "Very high" ); 301 case 1 : text += QObject::tr( "Very high" );
298 break; 302 break;
299 case 2 : text += QObject::tr( "High" ); 303 case 2 : text += QObject::tr( "High" );
300 break; 304 break;
301 case 3 : text += QObject::tr( "Normal" ); 305 case 3 : text += QObject::tr( "Normal" );
302 break; 306 break;
303 case 4 : text += QObject::tr( "Low" ); 307 case 4 : text += QObject::tr( "Low" );
304 break; 308 break;
305 case 5 : text += QObject::tr( "Very low" ); 309 case 5 : text += QObject::tr( "Very low" );
306 break; 310 break;
307 }; 311 };
308 text += "<br>"; 312 text += "<br>";
309 313
310 // progress 314 // progress
311 text += "<b>" + QObject::tr( "Progress:") + " </b>" 315 text += "<b>" + QObject::tr( "Progress:") + " </b>"
312 + QString::number( progress() ) + " %<br>"; 316 + QString::number( progress() ) + " %<br>";
313 317
314 // due date 318 // due date
315 if (hasDueDate() ){ 319 if (hasDueDate() ){
316 QDate dd = dueDate(); 320 QDate dd = dueDate();
317 int off = QDate::currentDate().daysTo( dd ); 321 int off = QDate::currentDate().daysTo( dd );
318 322
319 text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; 323 text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\"";
320 if ( off < 0 ) 324 if ( off < 0 )
321 text += "#FF0000"; 325 text += "#FF0000";
322 else if ( off == 0 ) 326 else if ( off == 0 )
323 text += "#FFFF00"; 327 text += "#FFFF00";
324 else if ( off > 0 ) 328 else if ( off > 0 )
325 text += "#00FF00"; 329 text += "#00FF00";
326 330
327 text += "\">" + dd.toString() + "</font><br>"; 331 text += "\">" + dd.toString() + "</font><br>";
328 } 332 }
329 333
330 // categories 334 // categories
331 text += "<b>" + QObject::tr( "Category:") + "</b> "; 335 text += "<b>" + QObject::tr( "Category:") + "</b> ";
332 text += categoryNames( "Todo List" ).join(", "); 336 text += categoryNames( "Todo List" ).join(", ");
333 text += "<br>"; 337 text += "<br>";
334 338
335 return text; 339 return text;
336} 340}
337bool OTodo::hasNotifiers()const { 341bool OTodo::hasNotifiers()const {
338 if (!data->notifiers) return false; 342 if (!data->notifiers) return false;
339 return !data->notifiers->isEmpty(); 343 return !data->notifiers->isEmpty();
340} 344}
341OPimNotifyManager& OTodo::notifiers() { 345OPimNotifyManager& OTodo::notifiers() {
342 if (!data->notifiers ) 346 if (!data->notifiers )
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h
index f9a345a..6df98b9 100644
--- a/libopie/pim/otodo.h
+++ b/libopie/pim/otodo.h
@@ -53,101 +53,96 @@ public:
53 @param completed Is the TodoEvent completed 53 @param completed Is the TodoEvent completed
54 @param priority What is the priority of this ToDoEvent 54 @param priority What is the priority of this ToDoEvent
55 @param category Which category does it belong( uid ) 55 @param category Which category does it belong( uid )
56 @param summary A small summary of the todo 56 @param summary A small summary of the todo
57 @param description What is this ToDoEvent about 57 @param description What is this ToDoEvent about
58 @param hasDate Does this Event got a deadline 58 @param hasDate Does this Event got a deadline
59 @param date what is the deadline? 59 @param date what is the deadline?
60 @param uid what is the UUID of this Event 60 @param uid what is the UUID of this Event
61 **/ 61 **/
62 OTodo( bool completed = false, int priority = Normal, 62 OTodo( bool completed = false, int priority = Normal,
63 const QStringList &category = QStringList(), 63 const QStringList &category = QStringList(),
64 const QString &summary = QString::null , 64 const QString &summary = QString::null ,
65 const QString &description = QString::null, 65 const QString &description = QString::null,
66 ushort progress = 0, 66 ushort progress = 0,
67 bool hasDate = false, QDate date = QDate::currentDate(), 67 bool hasDate = false, QDate date = QDate::currentDate(),
68 int uid = 0 /*empty*/ ); 68 int uid = 0 /*empty*/ );
69 69
70 OTodo( bool completed, int priority, 70 OTodo( bool completed, int priority,
71 const QArray<int>& category, 71 const QArray<int>& category,
72 const QString& summary = QString::null, 72 const QString& summary = QString::null,
73 const QString& description = QString::null, 73 const QString& description = QString::null,
74 ushort progress = 0, 74 ushort progress = 0,
75 bool hasDate = false, QDate date = QDate::currentDate(), 75 bool hasDate = false, QDate date = QDate::currentDate(),
76 int uid = 0 /* empty */ ); 76 int uid = 0 /* empty */ );
77 77
78 /** Copy c'tor 78 /** Copy c'tor
79 * 79 *
80 */ 80 */
81 OTodo(const OTodo & ); 81 OTodo(const OTodo & );
82 82
83 /** 83 /**
84 *destructor 84 *destructor
85 */ 85 */
86 ~OTodo(); 86 ~OTodo();
87 87
88 /** 88 /**
89 * Is this event completed? 89 * Is this event completed?
90 */ 90 */
91 bool isCompleted() const; 91 bool isCompleted() const;
92 92
93 /** 93 /**
94 * Does this Event have a deadline 94 * Does this Event have a deadline
95 */ 95 */
96 bool hasDueDate() const; 96 bool hasDueDate() const;
97 bool hasStartDate()const; 97 bool hasStartDate()const;
98 bool hasCompletedDate()const; 98 bool hasCompletedDate()const;
99 99
100 /** 100 /**
101 * Does this Event has an alarm time ?
102 */
103 bool hasAlarmDateTime() const;
104
105 /**
106 * What is the priority? 101 * What is the priority?
107 */ 102 */
108 int priority()const ; 103 int priority()const ;
109 104
110 /** 105 /**
111 * progress as ushort 0, 20, 40, 60, 80 or 100% 106 * progress as ushort 0, 20, 40, 60, 80 or 100%
112 */ 107 */
113 ushort progress() const; 108 ushort progress() const;
114 109
115 /** 110 /**
116 * The due Date 111 * The due Date
117 */ 112 */
118 QDate dueDate()const; 113 QDate dueDate()const;
119 114
120 /** 115 /**
121 * When did it start? 116 * When did it start?
122 */ 117 */
123 QDate startDate()const; 118 QDate startDate()const;
124 119
125 /** 120 /**
126 * When was it completed? 121 * When was it completed?
127 */ 122 */
128 QDate completedDate()const; 123 QDate completedDate()const;
129 124
130 /** 125 /**
131 * does it have a state? 126 * does it have a state?
132 */ 127 */
133 bool hasState()const; 128 bool hasState()const;
134 129
135 /** 130 /**
136 * What is the state of this OTodo? 131 * What is the state of this OTodo?
137 */ 132 */
138 OPimState state()const; 133 OPimState state()const;
139 134
140 /** 135 /**
141 * has recurrence? 136 * has recurrence?
142 */ 137 */
143 bool hasRecurrence()const; 138 bool hasRecurrence()const;
144 139
145 /** 140 /**
146 * the recurrance of this 141 * the recurrance of this
147 */ 142 */
148 ORecur recurrence()const; 143 ORecur recurrence()const;
149 144
150 /** 145 /**
151 * does this OTodo have a maintainer? 146 * does this OTodo have a maintainer?
152 */ 147 */
153 bool hasMaintainer()const; 148 bool hasMaintainer()const;
@@ -196,99 +191,95 @@ public:
196 QString recordField(int id )const; 191 QString recordField(int id )const;
197 192
198 /** 193 /**
199 * toMap puts all data into the map. int relates 194 * toMap puts all data into the map. int relates
200 * to ToDoEvent RecordFields enum 195 * to ToDoEvent RecordFields enum
201 */ 196 */
202 QMap<int, QString> toMap()const; 197 QMap<int, QString> toMap()const;
203 198
204 /** 199 /**
205 * Set if this Todo is completed 200 * Set if this Todo is completed
206 */ 201 */
207 void setCompleted(bool completed ); 202 void setCompleted(bool completed );
208 203
209 /** 204 /**
210 * set if this todo got an end data 205 * set if this todo got an end data
211 */ 206 */
212 void setHasDueDate( bool hasDate ); 207 void setHasDueDate( bool hasDate );
213 // FIXME we do not have these for start, completed 208 // FIXME we do not have these for start, completed
214 // cause we'll use the isNull() of QDate for figuring 209 // cause we'll use the isNull() of QDate for figuring
215 // out if it's has a date... 210 // out if it's has a date...
216 // decide what to do here? -zecke 211 // decide what to do here? -zecke
217 212
218 /** 213 /**
219 * Set the priority of the Todo 214 * Set the priority of the Todo
220 */ 215 */
221 void setPriority(int priority ); 216 void setPriority(int priority );
222 217
223 /** 218 /**
224 * Set the progress. 219 * Set the progress.
225 */ 220 */
226 void setProgress( ushort progress ); 221 void setProgress( ushort progress );
227 222
228 /** 223 /**
229 * set the end date 224 * set the end date
230 */ 225 */
231 void setDueDate( const QDate& date ); 226 void setDueDate( const QDate& date );
232 227
233 /** 228 /**
234 * set the start date 229 * set the start date
235 */ 230 */
236 void setStartDate( const QDate& date ); 231 void setStartDate( const QDate& date );
237 232
238 /** 233 /**
239 * set the completed date 234 * set the completed date
240 */ 235 */
241 void setCompletedDate( const QDate& date ); 236 void setCompletedDate( const QDate& date );
242 237
243 void setRecurrence( const ORecur& ); 238 void setRecurrence( const ORecur& );
244 /**
245 * set the alarm time
246 */
247 void setAlarmDateTime ( const QDateTime& alarm );
248 239
249 void setDescription(const QString& ); 240 void setDescription(const QString& );
250 void setSummary(const QString& ); 241 void setSummary(const QString& );
251 242
252 /** 243 /**
253 * set the state of a Todo 244 * set the state of a Todo
254 * @param state State what the todo should take 245 * @param state State what the todo should take
255 */ 246 */
256 void setState( const OPimState& state); 247 void setState( const OPimState& state);
257 248
258 /** 249 /**
259 * set the Maintainer Mode 250 * set the Maintainer Mode
260 */ 251 */
261 void setMaintainer( const OPimMaintainer& ); 252 void setMaintainer( const OPimMaintainer& );
262 253
263 bool isOverdue(); 254 bool isOverdue();
264 255
265 256
266 virtual bool match( const QRegExp &r )const; 257 virtual bool match( const QRegExp &r )const;
267 258
268 bool operator<(const OTodo &toDoEvent )const; 259 bool operator<(const OTodo &toDoEvent )const;
269 bool operator<=(const OTodo &toDoEvent )const; 260 bool operator<=(const OTodo &toDoEvent )const;
270 bool operator!=(const OTodo &toDoEvent )const; 261 bool operator!=(const OTodo &toDoEvent )const;
271 bool operator>(const OTodo &toDoEvent )const; 262 bool operator>(const OTodo &toDoEvent )const;
272 bool operator>=(const OTodo &toDoEvent)const; 263 bool operator>=(const OTodo &toDoEvent)const;
273 bool operator==(const OTodo &toDoEvent )const; 264 bool operator==(const OTodo &toDoEvent )const;
274 OTodo &operator=(const OTodo &toDoEvent ); 265 OTodo &operator=(const OTodo &toDoEvent );
275 266
276 static int rtti(); 267 static int rtti();
277 268
278 private: 269 private:
279 class OTodoPrivate; 270 class OTodoPrivate;
280 struct OTodoData; 271 struct OTodoData;
281 272
282 void deref(); 273 void deref();
283 inline void changeOrModify(); 274 inline void changeOrModify();
284 void copy( OTodoData* src, OTodoData* dest ); 275 void copy( OTodoData* src, OTodoData* dest );
285 OTodoPrivate *d; 276 OTodoPrivate *d;
286 OTodoData *data; 277 OTodoData *data;
287 278
288}; 279};
289inline bool OTodo::operator!=(const OTodo &toDoEvent )const { 280inline bool OTodo::operator!=(const OTodo &toDoEvent )const {
290 return !(*this == toDoEvent); 281 return !(*this == toDoEvent);
291} 282}
292 283
293 284
294#endif 285#endif
diff --git a/libopie/pim/otodoaccessbackend.h b/libopie/pim/otodoaccessbackend.h
index 05e8ca9..6be95bc 100644
--- a/libopie/pim/otodoaccessbackend.h
+++ b/libopie/pim/otodoaccessbackend.h
@@ -1,24 +1,28 @@
1#ifndef OPIE_TODO_ACCESS_BACKEND_H 1#ifndef OPIE_TODO_ACCESS_BACKEND_H
2#define OPIE_TODO_ACCESS_BACKEND_H 2#define OPIE_TODO_ACCESS_BACKEND_H
3 3
4#include <qbitarray.h> 4#include <qbitarray.h>
5 5
6#include "otodo.h" 6#include "otodo.h"
7#include "opimaccessbackend.h" 7#include "opimaccessbackend.h"
8 8
9class OTodoAccessBackend : public OPimAccessBackend<OTodo> { 9class OTodoAccessBackend : public OPimAccessBackend<OTodo> {
10public: 10public:
11 OTodoAccessBackend(); 11 OTodoAccessBackend();
12 ~OTodoAccessBackend(); 12 ~OTodoAccessBackend();
13 virtual QArray<int> effectiveToDos( const QDate& start, 13 virtual QArray<int> effectiveToDos( const QDate& start,
14 const QDate& end, 14 const QDate& end,
15 bool includeNoDates ) = 0; 15 bool includeNoDates ) = 0;
16 virtual QArray<int> overDue() = 0; 16 virtual QArray<int> overDue() = 0;
17 virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter, 17 virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
18 int cat ) = 0; 18 int cat ) = 0;
19 virtual void removeAllCompleted() = 0; 19 virtual void removeAllCompleted() = 0;
20 virtual QBitArray supports()const = 0; 20 virtual QBitArray supports()const = 0;
21
22private:
23 class Private;
24 Private *d;
21 25
22}; 26};
23 27
24#endif 28#endif
diff --git a/libopie/pim/otodoaccessvcal.cpp b/libopie/pim/otodoaccessvcal.cpp
index 3577e14..6415952 100644
--- a/libopie/pim/otodoaccessvcal.cpp
+++ b/libopie/pim/otodoaccessvcal.cpp
@@ -1,129 +1,153 @@
1#include <qfile.h> 1#include <qfile.h>
2 2
3#include <qtopia/private/vobject_p.h> 3#include <qtopia/private/vobject_p.h>
4#include <qtopia/timeconversion.h> 4#include <qtopia/timeconversion.h>
5#include <qtopia/private/qfiledirect_p.h> 5#include <qtopia/private/qfiledirect_p.h>
6 6
7#include "otodoaccessvcal.h" 7#include "otodoaccessvcal.h"
8 8
9namespace { 9namespace {
10 static OTodo eventByVObj( VObject *obj ){ 10 static OTodo eventByVObj( VObject *obj ){
11 OTodo event; 11 OTodo event;
12 VObject *ob; 12 VObject *ob;
13 QCString name; 13 QCString name;
14 // no uid, attendees, ... and no fun 14 // no uid, attendees, ... and no fun
15 // description 15 // description
16 if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ 16 if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){
17 name = vObjectStringZValue( ob ); 17 name = vObjectStringZValue( ob );
18#if 0
18 event.setDescription( name ); 19 event.setDescription( name );
20#else
21 event.setSummary( name );
22#endif
19 } 23 }
20 // summary 24 // summary
21 if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { 25 if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) {
22 name = vObjectStringZValue( ob ); 26 name = vObjectStringZValue( ob );
27#if 0
23 event.setSummary( name ); 28 event.setSummary( name );
29#else
30 event.setDescription( name );
31#endif
24 } 32 }
25 // completed 33 // completed
26 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ 34 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){
27 name = vObjectStringZValue( ob ); 35 name = vObjectStringZValue( ob );
28 if( name == "COMPLETED" ){ 36 if( name == "COMPLETED" ){
29 event.setCompleted( true ); 37 event.setCompleted( true );
30 }else{ 38 }else{
31 event.setCompleted( false ); 39 event.setCompleted( false );
32 } 40 }
33 }else 41 }else
34 event.setCompleted( false ); 42 event.setCompleted( false );
35 // priority 43 // priority
36 if ((ob = isAPropertyOf(obj, VCPriorityProp))) { 44 if ((ob = isAPropertyOf(obj, VCPriorityProp))) {
37 name = vObjectStringZValue( ob ); 45 name = vObjectStringZValue( ob );
38 bool ok; 46 bool ok;
39 event.setPriority(name.toInt(&ok) ); 47 event.setPriority(name.toInt(&ok) );
40 } 48 }
41 //due date 49 //due date
42 if((ob = isAPropertyOf(obj, VCDueProp)) ){ 50 if((ob = isAPropertyOf(obj, VCDueProp)) ){
43 event.setHasDueDate( true ); 51 event.setHasDueDate( true );
44 name = vObjectStringZValue( ob ); 52 name = vObjectStringZValue( ob );
45 event.setDueDate( TimeConversion::fromISO8601( name).date() ); 53 event.setDueDate( TimeConversion::fromISO8601( name).date() );
46 } 54 }
47 // categories 55 // categories
48 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ 56 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){
49 name = vObjectStringZValue( ob ); 57 name = vObjectStringZValue( ob );
50 qWarning("Categories:%s", name.data() ); 58 qWarning("Categories:%s", name.data() );
51 } 59 }
52 60
53 event.setUid( 1 ); 61 event.setUid( 1 );
54 return event; 62 return event;
55 }; 63 };
56 static VObject *vobjByEvent( const OTodo &event ) { 64 static VObject *vobjByEvent( const OTodo &event ) {
57 VObject *task = newVObject( VCTodoProp ); 65 VObject *task = newVObject( VCTodoProp );
58 if( task == 0 ) 66 if( task == 0 )
59 return 0l; 67 return 0l;
60 68
61 if( event.hasDueDate() ) { 69 if( event.hasDueDate() ) {
62 QTime time(0, 0, 0); 70 QTime time(0, 0, 0);
63 QDateTime date(event.dueDate(), time ); 71 QDateTime date(event.dueDate(), time );
64 addPropValue( task, VCDueProp, 72 addPropValue( task, VCDueProp,
65 TimeConversion::toISO8601( date ) ); 73 TimeConversion::toISO8601( date ) );
66 } 74 }
67 75
68 if( event.isCompleted() ) 76 if( event.isCompleted() )
69 addPropValue( task, VCStatusProp, "COMPLETED"); 77 addPropValue( task, VCStatusProp, "COMPLETED");
70 78
71 QString string = QString::number(event.priority() ); 79 QString string = QString::number(event.priority() );
72 addPropValue( task, VCPriorityProp, string.local8Bit() ); 80 addPropValue( task, VCPriorityProp, string.local8Bit() );
73 81
74 addPropValue( task, VCCategoriesProp, 82 addPropValue( task, VCCategoriesProp,
75 event.idsToString( event.categories() ).local8Bit() ); 83 event.idsToString( event.categories() ).local8Bit() );
76 84
85#if 0
86
87 // There seems a misrepresentation between summary in otodoevent
88 // and summary in vcard.
89 // The same with description..
90 // Description is summary and vice versa.. Argh.. (eilers)
91
92
77 addPropValue( task, VCDescriptionProp, 93 addPropValue( task, VCDescriptionProp,
78 event.description().local8Bit() ); 94 event.description().local8Bit() );
79 95
80 addPropValue( task, VCSummaryProp, 96 addPropValue( task, VCSummaryProp,
81 event.summary().local8Bit() ); 97 event.summary().local8Bit() );
98
99#else
100 addPropValue( task, VCDescriptionProp,
101 event.summary().local8Bit() );
102
103 addPropValue( task, VCSummaryProp,
104 event.description().local8Bit() );
105#endif
82 return task; 106 return task;
83}; 107};
84} 108}
85 109
86OTodoAccessVCal::OTodoAccessVCal( const QString& path ) 110OTodoAccessVCal::OTodoAccessVCal( const QString& path )
87 : m_dirty(false), m_file( path ) 111 : m_dirty(false), m_file( path )
88{ 112{
89} 113}
90OTodoAccessVCal::~OTodoAccessVCal() { 114OTodoAccessVCal::~OTodoAccessVCal() {
91} 115}
92bool OTodoAccessVCal::load() { 116bool OTodoAccessVCal::load() {
93 m_map.clear(); 117 m_map.clear();
94 m_dirty = false; 118 m_dirty = false;
95 119
96 VObject* vcal = 0l; 120 VObject* vcal = 0l;
97 vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 121 vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
98 if (!vcal ) 122 if (!vcal )
99 return false; 123 return false;
100 124
101 // Iterate over the list 125 // Iterate over the list
102 VObjectIterator it; 126 VObjectIterator it;
103 VObject* vobj; 127 VObject* vobj;
104 128
105 initPropIterator(&it, vcal); 129 initPropIterator(&it, vcal);
106 130
107 while( moreIteration( &it ) ) { 131 while( moreIteration( &it ) ) {
108 vobj = ::nextVObject( &it ); 132 vobj = ::nextVObject( &it );
109 QCString name = ::vObjectName( vobj ); 133 QCString name = ::vObjectName( vobj );
110 if( name == VCTodoProp ){ 134 if( name == VCTodoProp ){
111 OTodo to = eventByVObj( vobj ); 135 OTodo to = eventByVObj( vobj );
112 m_map.insert( to.uid(), to ); 136 m_map.insert( to.uid(), to );
113 } 137 }
114 } 138 }
115 139
116 // Should I do a delete vcal? 140 // Should I do a delete vcal?
117 141
118 return true; 142 return true;
119} 143}
120bool OTodoAccessVCal::reload() { 144bool OTodoAccessVCal::reload() {
121 return load(); 145 return load();
122} 146}
123bool OTodoAccessVCal::save() { 147bool OTodoAccessVCal::save() {
124 if (!m_dirty ) 148 if (!m_dirty )
125 return true; 149 return true;
126 150
127 QFileDirect file( m_file ); 151 QFileDirect file( m_file );
128 if (!file.open(IO_WriteOnly ) ) 152 if (!file.open(IO_WriteOnly ) )
129 return false; 153 return false;
@@ -140,86 +164,86 @@ bool OTodoAccessVCal::save() {
140 cleanVObject( obj ); 164 cleanVObject( obj );
141 cleanStrTbl(); 165 cleanStrTbl();
142 166
143 m_dirty = false; 167 m_dirty = false;
144 return true; 168 return true;
145} 169}
146void OTodoAccessVCal::clear() { 170void OTodoAccessVCal::clear() {
147 m_map.clear(); 171 m_map.clear();
148 m_dirty = true; 172 m_dirty = true;
149} 173}
150bool OTodoAccessVCal::add( const OTodo& to ) { 174bool OTodoAccessVCal::add( const OTodo& to ) {
151 m_map.insert( to.uid(), to ); 175 m_map.insert( to.uid(), to );
152 m_dirty = true; 176 m_dirty = true;
153 return true; 177 return true;
154} 178}
155bool OTodoAccessVCal::remove( int uid ) { 179bool OTodoAccessVCal::remove( int uid ) {
156 m_map.remove( uid ); 180 m_map.remove( uid );
157 m_dirty = true; 181 m_dirty = true;
158 return true; 182 return true;
159} 183}
160void OTodoAccessVCal::removeAllCompleted() { 184void OTodoAccessVCal::removeAllCompleted() {
161 for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { 185 for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) {
162 if ( (*it).isCompleted() ) 186 if ( (*it).isCompleted() )
163 m_map.remove( it ); 187 m_map.remove( it );
164 } 188 }
165} 189}
166bool OTodoAccessVCal::replace( const OTodo& to ) { 190bool OTodoAccessVCal::replace( const OTodo& to ) {
167 m_map.replace( to.uid(), to ); 191 m_map.replace( to.uid(), to );
168 m_dirty = true; 192 m_dirty = true;
169 return true; 193 return true;
170} 194}
171OTodo OTodoAccessVCal::find(int uid )const { 195OTodo OTodoAccessVCal::find(int uid )const {
172 return m_map[uid]; 196 return m_map[uid];
173} 197}
174QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { 198QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) {
175 QArray<int> ar(0); 199 QArray<int> ar(0);
176 return ar; 200 return ar;
177} 201}
178QArray<int> OTodoAccessVCal::allRecords()const { 202QArray<int> OTodoAccessVCal::allRecords()const {
179 QArray<int> ar( m_map.count() ); 203 QArray<int> ar( m_map.count() );
180 QMap<int, OTodo>::ConstIterator it; 204 QMap<int, OTodo>::ConstIterator it;
181 int i = 0; 205 int i = 0;
182 for ( it = m_map.begin(); it != m_map.end(); ++it ) { 206 for ( it = m_map.begin(); it != m_map.end(); ++it ) {
183 ar[i] = it.key(); 207 ar[i] = it.key();
184 i++; 208 i++;
185 } 209 }
186 return ar; 210 return ar;
187} 211}
188QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp &r)const { 212QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp& /* r */)const {
189 QArray<int> ar(0); 213 QArray<int> ar(0);
190 return ar; 214 return ar;
191} 215}
192QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { 216QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) {
193 QArray<int> ar(0); 217 QArray<int> ar(0);
194 return ar; 218 return ar;
195} 219}
196QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , 220QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& ,
197 const QDate& , 221 const QDate& ,
198 bool ) { 222 bool ) {
199 QArray<int> ar(0); 223 QArray<int> ar(0);
200 return ar; 224 return ar;
201} 225}
202QArray<int> OTodoAccessVCal::overDue() { 226QArray<int> OTodoAccessVCal::overDue() {
203 QArray<int> ar(0); 227 QArray<int> ar(0);
204 return ar; 228 return ar;
205} 229}
206QBitArray OTodoAccessVCal::supports()const { 230QBitArray OTodoAccessVCal::supports()const {
207 static QBitArray ar = sup(); 231 static QBitArray ar = sup();
208 232
209 return ar; 233 return ar;
210} 234}
211QBitArray OTodoAccessVCal::sup() { 235QBitArray OTodoAccessVCal::sup() {
212 QBitArray ar ( OTodo::CompletedDate +1 ); 236 QBitArray ar ( OTodo::CompletedDate +1 );
213 ar.fill( true ); 237 ar.fill( true );
214 238
215 ar[OTodo::CrossReference] = false; 239 ar[OTodo::CrossReference] = false;
216 ar[OTodo::State ] = false; 240 ar[OTodo::State ] = false;
217 ar[OTodo::Reminders] = false; 241 ar[OTodo::Reminders] = false;
218 ar[OTodo::Notifiers] = false; 242 ar[OTodo::Notifiers] = false;
219 ar[OTodo::Maintainer] = false; 243 ar[OTodo::Maintainer] = false;
220 ar[OTodo::Progress] = false; 244 ar[OTodo::Progress] = false;
221 ar[OTodo::Alarms ] = false; 245 ar[OTodo::Alarms ] = false;
222 ar[OTodo::Recurrence] = false; 246 ar[OTodo::Recurrence] = false;
223 247
224 return ar; 248 return ar;
225} 249}
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp
index 3d15354..f688735 100644
--- a/libopie/pim/otodoaccessxml.cpp
+++ b/libopie/pim/otodoaccessxml.cpp
@@ -42,97 +42,97 @@ namespace {
42 }; 42 };
43 // FROM TT again 43 // FROM TT again
44char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) 44char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
45{ 45{
46 char needleChar; 46 char needleChar;
47 char haystackChar; 47 char haystackChar;
48 if (!needle || !haystack || !hLen || !nLen) 48 if (!needle || !haystack || !hLen || !nLen)
49 return 0; 49 return 0;
50 50
51 const char* hsearch = haystack; 51 const char* hsearch = haystack;
52 52
53 if ((needleChar = *needle++) != 0) { 53 if ((needleChar = *needle++) != 0) {
54 nLen--; //(to make up for needle++) 54 nLen--; //(to make up for needle++)
55 do { 55 do {
56 do { 56 do {
57 if ((haystackChar = *hsearch++) == 0) 57 if ((haystackChar = *hsearch++) == 0)
58 return (0); 58 return (0);
59 if (hsearch >= haystack + hLen) 59 if (hsearch >= haystack + hLen)
60 return (0); 60 return (0);
61 } while (haystackChar != needleChar); 61 } while (haystackChar != needleChar);
62 } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); 62 } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0);
63 hsearch--; 63 hsearch--;
64 } 64 }
65 return ((char *)hsearch); 65 return ((char *)hsearch);
66} 66}
67} 67}
68 68
69 69
70OTodoAccessXML::OTodoAccessXML( const QString& appName, 70OTodoAccessXML::OTodoAccessXML( const QString& appName,
71 const QString& fileName ) 71 const QString& fileName )
72 : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) 72 : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false )
73{ 73{
74 if (!fileName.isEmpty() ) 74 if (!fileName.isEmpty() )
75 m_file = fileName; 75 m_file = fileName;
76 else 76 else
77 m_file = Global::applicationFileName( "todolist", "todolist.xml" ); 77 m_file = Global::applicationFileName( "todolist", "todolist.xml" );
78} 78}
79OTodoAccessXML::~OTodoAccessXML() { 79OTodoAccessXML::~OTodoAccessXML() {
80 80
81} 81}
82bool OTodoAccessXML::load() { 82bool OTodoAccessXML::load() {
83 rec = 0; 83 rec = 0;
84 m_opened = true; 84 m_opened = true;
85 m_changed = false; 85 m_changed = false;
86 /* initialize dict */ 86 /* initialize dict */
87 /* 87 /*
88 * UPDATE dict if you change anything!!! 88 * UPDATE dict if you change anything!!!
89 */ 89 */
90 QAsciiDict<int> dict(21); 90 QAsciiDict<int> dict(26);
91 dict.setAutoDelete( TRUE ); 91 dict.setAutoDelete( TRUE );
92 dict.insert("Categories" , new int(OTodo::Category) ); 92 dict.insert("Categories" , new int(OTodo::Category) );
93 dict.insert("Uid" , new int(OTodo::Uid) ); 93 dict.insert("Uid" , new int(OTodo::Uid) );
94 dict.insert("HasDate" , new int(OTodo::HasDate) ); 94 dict.insert("HasDate" , new int(OTodo::HasDate) );
95 dict.insert("Completed" , new int(OTodo::Completed) ); 95 dict.insert("Completed" , new int(OTodo::Completed) );
96 dict.insert("Description" , new int(OTodo::Description) ); 96 dict.insert("Description" , new int(OTodo::Description) );
97 dict.insert("Summary" , new int(OTodo::Summary) ); 97 dict.insert("Summary" , new int(OTodo::Summary) );
98 dict.insert("Priority" , new int(OTodo::Priority) ); 98 dict.insert("Priority" , new int(OTodo::Priority) );
99 dict.insert("DateDay" , new int(OTodo::DateDay) ); 99 dict.insert("DateDay" , new int(OTodo::DateDay) );
100 dict.insert("DateMonth" , new int(OTodo::DateMonth) ); 100 dict.insert("DateMonth" , new int(OTodo::DateMonth) );
101 dict.insert("DateYear" , new int(OTodo::DateYear) ); 101 dict.insert("DateYear" , new int(OTodo::DateYear) );
102 dict.insert("Progress" , new int(OTodo::Progress) ); 102 dict.insert("Progress" , new int(OTodo::Progress) );
103 dict.insert("CompletedDate", new int(OTodo::CompletedDate) ); 103 dict.insert("CompletedDate", new int(OTodo::CompletedDate) );
104 dict.insert("StartDate", new int(OTodo::StartDate) ); 104 dict.insert("StartDate", new int(OTodo::StartDate) );
105 dict.insert("CrossReference", new int(OTodo::CrossReference) ); 105 dict.insert("CrossReference", new int(OTodo::CrossReference) );
106 dict.insert("State", new int(OTodo::State) ); 106 dict.insert("State", new int(OTodo::State) );
107 dict.insert("Alarms", new int(OTodo::Alarms) ); 107 dict.insert("Alarms", new int(OTodo::Alarms) );
108 dict.insert("Reminders", new int(OTodo::Reminders) ); 108 dict.insert("Reminders", new int(OTodo::Reminders) );
109 dict.insert("Notifiers", new int(OTodo::Notifiers) ); 109 dict.insert("Notifiers", new int(OTodo::Notifiers) );
110 dict.insert("Maintainer", new int(OTodo::Maintainer) ); 110 dict.insert("Maintainer", new int(OTodo::Maintainer) );
111 dict.insert("rtype", new int(FRType) ); 111 dict.insert("rtype", new int(FRType) );
112 dict.insert("rweekdays", new int(FRWeekdays) ); 112 dict.insert("rweekdays", new int(FRWeekdays) );
113 dict.insert("rposition", new int(FRPosition) ); 113 dict.insert("rposition", new int(FRPosition) );
114 dict.insert("rfreq", new int(FRFreq) ); 114 dict.insert("rfreq", new int(FRFreq) );
115 dict.insert("start", new int(FRStart) ); 115 dict.insert("start", new int(FRStart) );
116 dict.insert("rhasenddate", new int(FRHasEndDate) ); 116 dict.insert("rhasenddate", new int(FRHasEndDate) );
117 dict.insert("enddt", new int(FREndDate) ); 117 dict.insert("enddt", new int(FREndDate) );
118 118
119 // here the custom XML parser from TT it's GPL 119 // here the custom XML parser from TT it's GPL
120 // but we want to push OpiePIM... to TT..... 120 // but we want to push OpiePIM... to TT.....
121 // mmap part from zecke :) 121 // mmap part from zecke :)
122 int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY ); 122 int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY );
123 struct stat attribut; 123 struct stat attribut;
124 if ( fd < 0 ) return false; 124 if ( fd < 0 ) return false;
125 125
126 if ( fstat(fd, &attribut ) == -1 ) { 126 if ( fstat(fd, &attribut ) == -1 ) {
127 ::close( fd ); 127 ::close( fd );
128 return false; 128 return false;
129 } 129 }
130 void* map_addr = ::mmap(NULL, attribut.st_size, PROT_READ, MAP_SHARED, fd, 0 ); 130 void* map_addr = ::mmap(NULL, attribut.st_size, PROT_READ, MAP_SHARED, fd, 0 );
131 if ( map_addr == ( (caddr_t)-1) ) { 131 if ( map_addr == ( (caddr_t)-1) ) {
132 ::close(fd ); 132 ::close(fd );
133 return false; 133 return false;
134 } 134 }
135 /* advise the kernel who we want to read it */ 135 /* advise the kernel who we want to read it */
136 ::madvise( map_addr, attribut.st_size, MADV_SEQUENTIAL ); 136 ::madvise( map_addr, attribut.st_size, MADV_SEQUENTIAL );
137 /* we do not the file any more */ 137 /* we do not the file any more */
138 ::close( fd ); 138 ::close( fd );
@@ -791,84 +791,86 @@ QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder,
791 QMap<int, OTodo>::Iterator it; 791 QMap<int, OTodo>::Iterator it;
792 int item = 0; 792 int item = 0;
793 793
794 bool bCat = sortFilter & 1 ? true : false; 794 bool bCat = sortFilter & 1 ? true : false;
795 bool bOnly = sortFilter & 2 ? true : false; 795 bool bOnly = sortFilter & 2 ? true : false;
796 bool comp = sortFilter & 4 ? true : false; 796 bool comp = sortFilter & 4 ? true : false;
797 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 797 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
798 798
799 /* show category */ 799 /* show category */
800 /* -1 == unfiled */ 800 /* -1 == unfiled */
801 if ( bCat && cat == -1 ) { 801 if ( bCat && cat == -1 ) {
802 if(!(*it).categories().isEmpty() ) 802 if(!(*it).categories().isEmpty() )
803 continue; 803 continue;
804 }else if ( bCat && cat != 0) 804 }else if ( bCat && cat != 0)
805 if (!(*it).categories().contains( cat ) ) { 805 if (!(*it).categories().contains( cat ) ) {
806 continue; 806 continue;
807 } 807 }
808 /* isOverdue but we should not show overdue - why?*/ 808 /* isOverdue but we should not show overdue - why?*/
809/* if ( (*it).isOverdue() && !bOnly ) { 809/* if ( (*it).isOverdue() && !bOnly ) {
810 qWarning("item is overdue but !bOnly"); 810 qWarning("item is overdue but !bOnly");
811 continue; 811 continue;
812 } 812 }
813*/ 813*/
814 if ( !(*it).isOverdue() && bOnly ) { 814 if ( !(*it).isOverdue() && bOnly ) {
815 continue; 815 continue;
816 } 816 }
817 817
818 if ((*it).isCompleted() && comp ) { 818 if ((*it).isCompleted() && comp ) {
819 continue; 819 continue;
820 } 820 }
821 821
822 822
823 OTodoXMLContainer* con = new OTodoXMLContainer(); 823 OTodoXMLContainer* con = new OTodoXMLContainer();
824 con->todo = (*it); 824 con->todo = (*it);
825 vector.insert(item, con ); 825 vector.insert(item, con );
826 item++; 826 item++;
827 } 827 }
828 vector.resize( item ); 828 vector.resize( item );
829 /* sort it now */ 829 /* sort it now */
830 vector.sort(); 830 vector.sort();
831 /* now get the uids */ 831 /* now get the uids */
832 QArray<int> array( vector.count() ); 832 QArray<int> array( vector.count() );
833 for (uint i= 0; i < vector.count(); i++ ) { 833 for (uint i= 0; i < vector.count(); i++ ) {
834 array[i] = ( vector.at(i) )->todo.uid(); 834 array[i] = ( vector.at(i) )->todo.uid();
835 } 835 }
836 return array; 836 return array;
837}; 837};
838void OTodoAccessXML::removeAllCompleted() { 838void OTodoAccessXML::removeAllCompleted() {
839 QMap<int, OTodo> events = m_events;
839 for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { 840 for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) {
840 if ( (*it).isCompleted() ) 841 if ( (*it).isCompleted() )
841 m_events.remove( it ); 842 events.remove( it.key() );
842 } 843 }
844 m_events = events;
843} 845}
844QBitArray OTodoAccessXML::supports()const { 846QBitArray OTodoAccessXML::supports()const {
845 static QBitArray ar = sup(); 847 static QBitArray ar = sup();
846 return ar; 848 return ar;
847} 849}
848QBitArray OTodoAccessXML::sup() { 850QBitArray OTodoAccessXML::sup() {
849 QBitArray ar( OTodo::CompletedDate +1 ); 851 QBitArray ar( OTodo::CompletedDate +1 );
850 ar.fill( true ); 852 ar.fill( true );
851 ar[OTodo::CrossReference] = false; 853 ar[OTodo::CrossReference] = false;
852 ar[OTodo::State ] = false; 854 ar[OTodo::State ] = false;
853 ar[OTodo::Reminders] = false; 855 ar[OTodo::Reminders] = false;
854 ar[OTodo::Notifiers] = false; 856 ar[OTodo::Notifiers] = false;
855 ar[OTodo::Maintainer] = false; 857 ar[OTodo::Maintainer] = false;
856 858
857 return ar; 859 return ar;
858} 860}
859QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const 861QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const
860{ 862{
861 QArray<int> m_currentQuery( m_events.count() ); 863 QArray<int> m_currentQuery( m_events.count() );
862 uint arraycounter = 0; 864 uint arraycounter = 0;
863 865
864 QMap<int, OTodo>::ConstIterator it; 866 QMap<int, OTodo>::ConstIterator it;
865 for (it = m_events.begin(); it != m_events.end(); ++it ) { 867 for (it = m_events.begin(); it != m_events.end(); ++it ) {
866 if ( it.data().match( r ) ) 868 if ( it.data().match( r ) )
867 m_currentQuery[arraycounter++] = it.data().uid(); 869 m_currentQuery[arraycounter++] = it.data().uid();
868 870
869 } 871 }
870 // Shrink to fit.. 872 // Shrink to fit..
871 m_currentQuery.resize(arraycounter); 873 m_currentQuery.resize(arraycounter);
872 874
873 return m_currentQuery; 875 return m_currentQuery;
874} 876}