summaryrefslogtreecommitdiff
path: root/libopie2/opiepim
Unidiff
Diffstat (limited to 'libopie2/opiepim') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/backend/obackendfactory.h12
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend.h12
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp22
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp3
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.h4
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp6
-rw-r--r--libopie2/opiepim/backend/opimaccessbackend.h4
-rw-r--r--libopie2/opiepim/backend/otodoaccessbackend.h4
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.cpp26
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp6
-rw-r--r--libopie2/opiepim/core/ocontactaccess.h11
-rw-r--r--libopie2/opiepim/core/oconversion.h5
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h4
-rw-r--r--libopie2/opiepim/core/opimcache.h6
-rw-r--r--libopie2/opiepim/core/opimxrefmanager.h2
-rw-r--r--libopie2/opiepim/core/otemplatebase.h7
-rw-r--r--libopie2/opiepim/ocontact.cpp219
-rw-r--r--libopie2/opiepim/ocontact.h9
-rw-r--r--libopie2/opiepim/orecordlist.h10
-rw-r--r--libopie2/opiepim/otodo.cpp12
-rw-r--r--libopie2/opiepim/otodo.h9
-rw-r--r--libopie2/opiepim/ui/opimmainwindow.cpp14
22 files changed, 306 insertions, 101 deletions
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h
index ad6cf5a..f3c339d 100644
--- a/libopie2/opiepim/backend/obackendfactory.h
+++ b/libopie2/opiepim/backend/obackendfactory.h
@@ -1,42 +1,50 @@
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
@@ -47,48 +55,50 @@
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,
@@ -127,28 +137,30 @@ class OBackendFactory
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/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h
index ebeb42d..280e05c 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend.h
@@ -1,45 +1,53 @@
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
@@ -82,26 +90,30 @@ class OContactAccessBackend: public OPimAccessBackend<OContact> {
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/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index 270bef3..b60c5be 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -1,43 +1,58 @@
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
@@ -130,48 +145,49 @@ bool OContactAccessBackend_VCard::load ()
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;
@@ -425,49 +441,51 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
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() ) );
@@ -513,49 +531,49 @@ VObject* OContactAccessBackend_VCard::createVObject( const OContact &c )
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() );
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
index 097142b..1c21619 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
@@ -1,43 +1,46 @@
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
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.h b/libopie2/opiepim/backend/odatebookaccessbackend.h
index 86ff298..3c02c42 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend.h
@@ -47,27 +47,31 @@ public:
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/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
index ab2eea4..5ea945c 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
@@ -409,72 +409,72 @@ bool ODateBookAccessBackend_XML::loadFile() {
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");
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h
index f4bbe35..c3d91f7 100644
--- a/libopie2/opiepim/backend/opimaccessbackend.h
+++ b/libopie2/opiepim/backend/opimaccessbackend.h
@@ -1,33 +1,34 @@
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
@@ -86,50 +87,49 @@ public:
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 );
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.h b/libopie2/opiepim/backend/otodoaccessbackend.h
index 05e8ca9..6be95bc 100644
--- a/libopie2/opiepim/backend/otodoaccessbackend.h
+++ b/libopie2/opiepim/backend/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 21
22private:
23 class Private;
24 Private *d;
25
22}; 26};
23 27
24#endif 28#endif
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp
index 3577e14..6415952 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.cpp
+++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp
@@ -1,47 +1,55 @@
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
@@ -53,53 +61,69 @@ namespace {
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);
@@ -164,49 +188,49 @@ void OTodoAccessVCal::removeAllCompleted() {
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 );
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index 3d15354..f688735 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -66,49 +66,49 @@ char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
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) );
@@ -815,52 +815,54 @@ QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder,
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 ) )
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h
index e90db32..9b0a719 100644
--- a/libopie2/opiepim/core/ocontactaccess.h
+++ b/libopie2/opiepim/core/ocontactaccess.h
@@ -1,43 +1,51 @@
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
@@ -144,27 +152,30 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
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/libopie2/opiepim/core/oconversion.h b/libopie2/opiepim/core/oconversion.h
index 13367e1..4c0a497 100644
--- a/libopie2/opiepim/core/oconversion.h
+++ b/libopie2/opiepim/core/oconversion.h
@@ -16,28 +16,33 @@
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/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index 8ff205c..ecbeb68 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -1,36 +1,37 @@
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 */
@@ -131,48 +132,51 @@ public:
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}
diff --git a/libopie2/opiepim/core/opimcache.h b/libopie2/opiepim/core/opimcache.h
index 73414e5..7f7cff5 100644
--- a/libopie2/opiepim/core/opimcache.h
+++ b/libopie2/opiepim/core/opimcache.h
@@ -1,72 +1,78 @@
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{
diff --git a/libopie2/opiepim/core/opimxrefmanager.h b/libopie2/opiepim/core/opimxrefmanager.h
index 39e5eef..c485e98 100644
--- a/libopie2/opiepim/core/opimxrefmanager.h
+++ b/libopie2/opiepim/core/opimxrefmanager.h
@@ -15,27 +15,29 @@ class 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/libopie2/opiepim/core/otemplatebase.h b/libopie2/opiepim/core/otemplatebase.h
index 29fb6ec..cadac74 100644
--- a/libopie2/opiepim/core/otemplatebase.h
+++ b/libopie2/opiepim/core/otemplatebase.h
@@ -1,87 +1,94 @@
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() {
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index be4ce0a..3473baa 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -1,51 +1,52 @@
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*/
@@ -417,244 +418,316 @@ OContact::~OContact()
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);
483 marker = true;
484 }
485
486 switch( addressformat ){
487 case Zip_City_State:{ // Zip_Code City, State
479 state = businessState(); 488 state = businessState();
480 if ( !(value = businessZip()).isEmpty() ) 489 if ( !(value = businessZip()).isEmpty() ){
481 text += Qtopia::escapeString(value) + " "; 490 text += "<br>" + Qtopia::escapeString(value) + " ";
491 marker = true;
492
493 } else
494 text += "<br>";
495
482 if ( !(value = businessCity()).isEmpty() ) { 496 if ( !(value = businessCity()).isEmpty() ) {
497 marker = true;
483 text += Qtopia::escapeString(value); 498 text += Qtopia::escapeString(value);
484 if ( state ) 499 if ( state )
485 text += ", " + Qtopia::escapeString(state); 500 text += ", " + Qtopia::escapeString(state);
486 text += "<br>"; 501 } else if ( !state.isEmpty() ){
487 } else if ( !state.isEmpty() ) 502 text += "<br>" + Qtopia::escapeString(state);
488 text += Qtopia::escapeString(state) + "<br>"; 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);
580 marker = true;
581 }
582
583 switch( addressformat ){
584 case Zip_City_State:{ // Zip_Code City, State
542 state = homeState(); 585 state = homeState();
543 if ( !(value = homeZip()).isEmpty() ) 586 if ( !(value = homeZip()).isEmpty() ){
544 text += Qtopia::escapeString(value) + " "; 587 text += "<br>" + Qtopia::escapeString(value) + " ";
588 marker = true;
589 } else
590 text += "<br>";
591
545 if ( !(value = homeCity()).isEmpty() ) { 592 if ( !(value = homeCity()).isEmpty() ) {
593 marker = true;
546 text += Qtopia::escapeString(value); 594 text += Qtopia::escapeString(value);
547 if ( !state.isEmpty() ) 595 if ( !state.isEmpty() )
548 text += ", " + Qtopia::escapeString(state); 596 text += ", " + Qtopia::escapeString(state);
549 text += "<br>"; 597 } else if (!state.isEmpty()) {
550 } else if (!state.isEmpty()) 598 text += "<br>" + Qtopia::escapeString(state);
551 text += Qtopia::escapeString(state) + "<br>"; 599 marker = true;
552 if ( !(value = homeCountry()).isEmpty() ) 600 }
553 text += Qtopia::escapeString(value) + "<br>"; 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 ) {
675 text += "<br>";
602 if ( str.toInt() == 1 ) 676 if ( str.toInt() == 1 )
603 str = QObject::tr( "Male" ); 677 str = QObject::tr( "Male" );
604 else if ( str.toInt() == 2 ) 678 else if ( str.toInt() == 2 )
605 str = QObject::tr( "Female" ); 679 str = QObject::tr( "Female" );
606 text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; 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
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h
index dd2de17..9a1a8dc 100644
--- a/libopie2/opiepim/ocontact.h
+++ b/libopie2/opiepim/ocontact.h
@@ -11,65 +11,70 @@
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 ); }
@@ -212,29 +217,29 @@ public:
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/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h
index edcd729..5211f57 100644
--- a/libopie2/opiepim/orecordlist.h
+++ b/libopie2/opiepim/orecordlist.h
@@ -1,33 +1,34 @@
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();
@@ -50,51 +51,52 @@ public:
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
@@ -102,48 +104,49 @@ ORecordList( const QArray<int>& ids,
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;
@@ -199,48 +202,51 @@ ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
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() {
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp
index 38b93f7..5a18c37 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/otodo.cpp
@@ -7,48 +7,53 @@
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() {
@@ -261,58 +266,57 @@ void 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
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h
index f9a345a..6df98b9 100644
--- a/libopie2/opiepim/otodo.h
+++ b/libopie2/opiepim/otodo.h
@@ -77,53 +77,48 @@ public:
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
@@ -220,52 +215,48 @@ public:
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;
diff --git a/libopie2/opiepim/ui/opimmainwindow.cpp b/libopie2/opiepim/ui/opimmainwindow.cpp
index 4044bc1..2739e26 100644
--- a/libopie2/opiepim/ui/opimmainwindow.cpp
+++ b/libopie2/opiepim/ui/opimmainwindow.cpp
@@ -1,111 +1,123 @@
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