summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp9
-rw-r--r--libopie/pim/ocontact.h3
-rw-r--r--libopie/pim/ocontactaccess.cpp13
-rw-r--r--libopie/pim/ocontactaccess.h6
-rw-r--r--libopie/pim/odatebookaccessbackend_xml.cpp18
-rw-r--r--libopie/pim/odatebookaccessbackend_xml.h1
-rw-r--r--libopie/pim/oevent.cpp41
-rw-r--r--libopie/pim/oevent.h2
-rw-r--r--libopie/pim/opimaccessbackend.h6
-rw-r--r--libopie/pim/opimaccesstemplate.h12
-rw-r--r--libopie/pim/opimrecord.h6
-rw-r--r--libopie/pim/otodo.h2
-rw-r--r--libopie/pim/otodoaccessvcal.cpp4
-rw-r--r--libopie/pim/otodoaccessvcal.h1
-rw-r--r--libopie/pim/otodoaccessxml.cpp16
-rw-r--r--libopie/pim/otodoaccessxml.h1
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp18
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.h1
-rw-r--r--libopie2/opiepim/backend/opimaccessbackend.h6
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.cpp4
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.h1
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp16
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.h1
-rw-r--r--libopie2/opiepim/core/ocontactaccess.cpp13
-rw-r--r--libopie2/opiepim/core/ocontactaccess.h6
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h12
-rw-r--r--libopie2/opiepim/core/opimrecord.h6
-rw-r--r--libopie2/opiepim/ocontact.cpp9
-rw-r--r--libopie2/opiepim/ocontact.h3
-rw-r--r--libopie2/opiepim/oevent.cpp41
-rw-r--r--libopie2/opiepim/oevent.h2
-rw-r--r--libopie2/opiepim/otodo.h2
32 files changed, 228 insertions, 54 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index 96a5f65..a38b62b 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -902,105 +902,96 @@ QStringList OContact::fields()
902 list.append( "BusinessWebPage" ); 902 list.append( "BusinessWebPage" );
903 903
904 list.append( "Office" ); 904 list.append( "Office" );
905 list.append( "Profession" ); 905 list.append( "Profession" );
906 list.append( "Assistant" ); 906 list.append( "Assistant" );
907 list.append( "Manager" ); 907 list.append( "Manager" );
908 908
909 list.append( "HomeStreet" ); 909 list.append( "HomeStreet" );
910 list.append( "HomeCity" ); 910 list.append( "HomeCity" );
911 list.append( "HomeState" ); 911 list.append( "HomeState" );
912 list.append( "HomeZip" ); 912 list.append( "HomeZip" );
913 list.append( "HomeCountry" ); 913 list.append( "HomeCountry" );
914 list.append( "HomeWebPage" ); 914 list.append( "HomeWebPage" );
915 915
916 list.append( "Spouse" ); 916 list.append( "Spouse" );
917 list.append( "Gender" ); 917 list.append( "Gender" );
918 list.append( "Birthday" ); 918 list.append( "Birthday" );
919 list.append( "Anniversary" ); 919 list.append( "Anniversary" );
920 list.append( "Nickname" ); 920 list.append( "Nickname" );
921 list.append( "Children" ); 921 list.append( "Children" );
922 922
923 list.append( "Notes" ); 923 list.append( "Notes" );
924 list.append( "Groups" ); 924 list.append( "Groups" );
925 925
926 return list; 926 return list;
927} 927}
928 928
929 929
930/*! 930/*!
931 Sets the list of email address for contact to those contained in \a str. 931 Sets the list of email address for contact to those contained in \a str.
932 Email address should be separated by ';'s. 932 Email address should be separated by ';'s.
933*/ 933*/
934void OContact::setEmails( const QString &str ) 934void OContact::setEmails( const QString &str )
935{ 935{
936 replace( Qtopia::Emails, str ); 936 replace( Qtopia::Emails, str );
937 if ( str.isEmpty() ) 937 if ( str.isEmpty() )
938 setDefaultEmail( QString::null ); 938 setDefaultEmail( QString::null );
939} 939}
940 940
941/*! 941/*!
942 Sets the list of children for the contact to those contained in \a str. 942 Sets the list of children for the contact to those contained in \a str.
943*/ 943*/
944void OContact::setChildren( const QString &str ) 944void OContact::setChildren( const QString &str )
945{ 945{
946 replace( Qtopia::Children, str ); 946 replace( Qtopia::Children, str );
947} 947}
948 948
949/*! 949/*!
950 Returns TRUE if the contact matches the regular expression \a regexp.
951 Otherwise returns FALSE.
952*/
953bool OContact::match( const QString &regexp ) const
954{
955 return match(QRegExp(regexp));
956}
957
958/*!
959 \overload 950 \overload
960 Returns TRUE if the contact matches the regular expression \a regexp. 951 Returns TRUE if the contact matches the regular expression \a regexp.
961 Otherwise returns FALSE. 952 Otherwise returns FALSE.
962*/ 953*/
963bool OContact::match( const QRegExp &r ) const 954bool OContact::match( const QRegExp &r ) const
964{ 955{
965 bool match; 956 bool match;
966 match = false; 957 match = false;
967 QMap<int, QString>::ConstIterator it; 958 QMap<int, QString>::ConstIterator it;
968 for ( it = mMap.begin(); it != mMap.end(); ++it ) { 959 for ( it = mMap.begin(); it != mMap.end(); ++it ) {
969 if ( (*it).find( r ) > -1 ) { 960 if ( (*it).find( r ) > -1 ) {
970 match = true; 961 match = true;
971 break; 962 break;
972 } 963 }
973 } 964 }
974 return match; 965 return match;
975} 966}
976 967
977 968
978QString OContact::toShortText() const 969QString OContact::toShortText() const
979{ 970{
980 return ( fullName() ); 971 return ( fullName() );
981} 972}
982QString OContact::type() const 973QString OContact::type() const
983{ 974{
984 return QString::fromLatin1( "OContact" ); 975 return QString::fromLatin1( "OContact" );
985} 976}
986 977
987// Definition is missing ! (se) 978// Definition is missing ! (se)
988QMap<QString,QString> OContact::toExtraMap() const 979QMap<QString,QString> OContact::toExtraMap() const
989{ 980{
990 qWarning ("Function not implemented: OContact::toExtraMap()"); 981 qWarning ("Function not implemented: OContact::toExtraMap()");
991 QMap <QString,QString> useless; 982 QMap <QString,QString> useless;
992 return useless; 983 return useless;
993} 984}
994 985
995class QString OContact::recordField( int pos ) const 986class QString OContact::recordField( int pos ) const
996{ 987{
997 QStringList SLFIELDS = fields(); // ?? why this ? (se) 988 QStringList SLFIELDS = fields(); // ?? why this ? (se)
998 return SLFIELDS[pos]; 989 return SLFIELDS[pos];
999} 990}
1000 991
1001// In future releases, we should store birthday and anniversary 992// In future releases, we should store birthday and anniversary
1002// internally as QDate instead of QString ! 993// internally as QDate instead of QString !
1003// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) 994// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
1004 995
1005/*! \fn void OContact::setBirthday( const QDate& date ) 996/*! \fn void OContact::setBirthday( const QDate& date )
1006 Sets the birthday for the contact to \a date. If date is null 997 Sets the birthday for the contact to \a date. If date is null
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h
index 50f6176..0e6cbd2 100644
--- a/libopie/pim/ocontact.h
+++ b/libopie/pim/ocontact.h
@@ -66,98 +66,97 @@ public:
66 void setDefaultEmail( const QString &v ); 66 void setDefaultEmail( const QString &v );
67 // inserts email to list and ensure's doesn't already exist 67 // inserts email to list and ensure's doesn't already exist
68 void insertEmail( const QString &v ); 68 void insertEmail( const QString &v );
69 void removeEmail( const QString &v ); 69 void removeEmail( const QString &v );
70 void clearEmails(); 70 void clearEmails();
71 void insertEmails( const QStringList &v ); 71 void insertEmails( const QStringList &v );
72 72
73 // home 73 // home
74 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } 74 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); }
75 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } 75 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); }
76 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } 76 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); }
77 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } 77 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); }
78 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } 78 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); }
79 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } 79 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); }
80 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } 80 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); }
81 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } 81 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); }
82 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } 82 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); }
83 83
84 // business 84 // business
85 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } 85 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); }
86 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } 86 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); }
87 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } 87 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); }
88 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } 88 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); }
89 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } 89 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); }
90 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } 90 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); }
91 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } 91 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); }
92 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } 92 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); }
93 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } 93 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); }
94 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } 94 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); }
95 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } 95 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); }
96 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } 96 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); }
97 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } 97 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); }
98 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } 98 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); }
99 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } 99 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); }
100 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } 100 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); }
101 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } 101 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); }
102 102
103 // personal 103 // personal
104 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } 104 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); }
105 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } 105 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); }
106 void setBirthday( const QDate &v ); 106 void setBirthday( const QDate &v );
107 void setAnniversary( const QDate &v ); 107 void setAnniversary( const QDate &v );
108 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } 108 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); }
109 void setChildren( const QString &v ); 109 void setChildren( const QString &v );
110 110
111 // other 111 // other
112 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } 112 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); }
113 113
114 bool match( const QString &regexp ) const; 114 virtual bool match( const QRegExp &regexp ) const;
115 bool match( const QRegExp &regexp ) const;
116 115
117// // custom 116// // custom
118// void setCustomField( const QString &key, const QString &v ) 117// void setCustomField( const QString &key, const QString &v )
119// { replace(Custom- + key, v ); } 118// { replace(Custom- + key, v ); }
120 119
121 // name 120 // name
122 QString fullName() const; 121 QString fullName() const;
123 QString title() const { return find( Qtopia::Title ); } 122 QString title() const { return find( Qtopia::Title ); }
124 QString firstName() const { return find( Qtopia::FirstName ); } 123 QString firstName() const { return find( Qtopia::FirstName ); }
125 QString middleName() const { return find( Qtopia::MiddleName ); } 124 QString middleName() const { return find( Qtopia::MiddleName ); }
126 QString lastName() const { return find( Qtopia::LastName ); } 125 QString lastName() const { return find( Qtopia::LastName ); }
127 QString suffix() const { return find( Qtopia::Suffix ); } 126 QString suffix() const { return find( Qtopia::Suffix ); }
128 QString fileAs() const { return find( Qtopia::FileAs ); } 127 QString fileAs() const { return find( Qtopia::FileAs ); }
129 128
130 // email 129 // email
131 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } 130 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); }
132 QStringList emailList() const; 131 QStringList emailList() const;
133 132
134 // home 133 // home
135 /* 134 /*
136 * OPimAddress address(enum Location)const; 135 * OPimAddress address(enum Location)const;
137 * would be some how nicer... 136 * would be some how nicer...
138 * -zecke 137 * -zecke
139 */ 138 */
140 QString homeStreet() const { return find( Qtopia::HomeStreet ); } 139 QString homeStreet() const { return find( Qtopia::HomeStreet ); }
141 QString homeCity() const { return find( Qtopia::HomeCity ); } 140 QString homeCity() const { return find( Qtopia::HomeCity ); }
142 QString homeState() const { return find( Qtopia::HomeState ); } 141 QString homeState() const { return find( Qtopia::HomeState ); }
143 QString homeZip() const { return find( Qtopia::HomeZip ); } 142 QString homeZip() const { return find( Qtopia::HomeZip ); }
144 QString homeCountry() const { return find( Qtopia::HomeCountry ); } 143 QString homeCountry() const { return find( Qtopia::HomeCountry ); }
145 QString homePhone() const { return find( Qtopia::HomePhone ); } 144 QString homePhone() const { return find( Qtopia::HomePhone ); }
146 QString homeFax() const { return find( Qtopia::HomeFax ); } 145 QString homeFax() const { return find( Qtopia::HomeFax ); }
147 QString homeMobile() const { return find( Qtopia::HomeMobile ); } 146 QString homeMobile() const { return find( Qtopia::HomeMobile ); }
148 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } 147 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); }
149 /** Multi line string containing all non-empty address info in the form 148 /** Multi line string containing all non-empty address info in the form
150 * Street 149 * Street
151 * City, State Zip 150 * City, State Zip
152 * Country 151 * Country
153 */ 152 */
154 QString displayHomeAddress() const; 153 QString displayHomeAddress() const;
155 154
156 // business 155 // business
157 QString company() const { return find( Qtopia::Company ); } 156 QString company() const { return find( Qtopia::Company ); }
158 QString businessStreet() const { return find( Qtopia::BusinessStreet ); } 157 QString businessStreet() const { return find( Qtopia::BusinessStreet ); }
159 QString businessCity() const { return find( Qtopia::BusinessCity ); } 158 QString businessCity() const { return find( Qtopia::BusinessCity ); }
160 QString businessState() const { return find( Qtopia::BusinessState ); } 159 QString businessState() const { return find( Qtopia::BusinessState ); }
161 QString businessZip() const { return find( Qtopia::BusinessZip ); } 160 QString businessZip() const { return find( Qtopia::BusinessZip ); }
162 QString businessCountry() const { return find( Qtopia::BusinessCountry ); } 161 QString businessCountry() const { return find( Qtopia::BusinessCountry ); }
163 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } 162 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); }
diff --git a/libopie/pim/ocontactaccess.cpp b/libopie/pim/ocontactaccess.cpp
index 9c9338e..2e3ec1f 100644
--- a/libopie/pim/ocontactaccess.cpp
+++ b/libopie/pim/ocontactaccess.cpp
@@ -1,169 +1,168 @@
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 * 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 * Info: This class could just work with a change in the header-file 12 * Info: This class could just work with a change in the header-file
13 * of the Contact class ! Therefore our libopie only compiles 13 * of the Contact class ! Therefore our libopie only compiles
14 * with our version of libqpe 14 * with our version of libqpe
15 * ===================================================================== 15 * =====================================================================
16 * ToDo: XML-Backend: Automatic reload if something was changed... 16 * ToDo: XML-Backend: Automatic reload if something was changed...
17 * 17 *
18 * 18 *
19 * ===================================================================== 19 * =====================================================================
20 * Version: $Id$ 20 * Version: $Id$
21 * ===================================================================== 21 * =====================================================================
22 * History: 22 * History:
23 * $Log$ 23 * $Log$
24 * Revision 1.8 2003/05/08 13:55:09 tille
25 * search stuff
26 * and match, toRichText & toShortText in oevent
27 *
24 * Revision 1.7 2002/11/13 14:14:51 eilers 28 * Revision 1.7 2002/11/13 14:14:51 eilers
25 * Added sorted for Contacts.. 29 * Added sorted for Contacts..
26 * 30 *
27 * Revision 1.6 2002/11/01 15:10:42 eilers 31 * Revision 1.6 2002/11/01 15:10:42 eilers
28 * Added regExp-search in database for all fields in a contact. 32 * Added regExp-search in database for all fields in a contact.
29 * 33 *
30 * Revision 1.5 2002/10/16 10:52:40 eilers 34 * Revision 1.5 2002/10/16 10:52:40 eilers
31 * Added some docu to the interface and now using the cache infrastucture by zecke.. :) 35 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
32 * 36 *
33 * Revision 1.4 2002/10/14 16:21:54 eilers 37 * Revision 1.4 2002/10/14 16:21:54 eilers
34 * Some minor interface updates 38 * Some minor interface updates
35 * 39 *
36 * Revision 1.3 2002/10/07 17:34:24 eilers 40 * Revision 1.3 2002/10/07 17:34:24 eilers
37 * added OBackendFactory for advanced backend access 41 * added OBackendFactory for advanced backend access
38 * 42 *
39 * Revision 1.2 2002/10/02 16:18:11 eilers 43 * Revision 1.2 2002/10/02 16:18:11 eilers
40 * debugged and seems to work almost perfectly .. 44 * debugged and seems to work almost perfectly ..
41 * 45 *
42 * Revision 1.1 2002/09/27 17:11:44 eilers 46 * Revision 1.1 2002/09/27 17:11:44 eilers
43 * Added API for accessing the Contact-Database ! It is compiling, but 47 * Added API for accessing the Contact-Database ! It is compiling, but
44 * please do not expect that anything is working ! 48 * please do not expect that anything is working !
45 * I will debug that stuff in the next time .. 49 * I will debug that stuff in the next time ..
46 * Please read README_COMPILE for compiling ! 50 * Please read README_COMPILE for compiling !
47 * 51 *
48 * 52 *
49 */ 53 */
50 54
51#include "ocontactaccess.h" 55#include "ocontactaccess.h"
52#include "obackendfactory.h" 56#include "obackendfactory.h"
53 57
54#include <qasciidict.h> 58#include <qasciidict.h>
55#include <qdatetime.h> 59#include <qdatetime.h>
56#include <qfile.h> 60#include <qfile.h>
57#include <qregexp.h> 61#include <qregexp.h>
58#include <qlist.h> 62#include <qlist.h>
59#include <qcopchannel_qws.h> 63#include <qcopchannel_qws.h>
60 64
61//#include <qpe/qcopenvelope_qws.h> 65//#include <qpe/qcopenvelope_qws.h>
62#include <qpe/global.h> 66#include <qpe/global.h>
63 67
64#include <errno.h> 68#include <errno.h>
65#include <fcntl.h> 69#include <fcntl.h>
66#include <unistd.h> 70#include <unistd.h>
67#include <stdlib.h> 71#include <stdlib.h>
68 72
69#include "ocontactaccessbackend_xml.h" 73#include "ocontactaccessbackend_xml.h"
70 74
71 75
72OContactAccess::OContactAccess ( const QString appname, const QString , 76OContactAccess::OContactAccess ( const QString appname, const QString ,
73 OContactAccessBackend* end, bool autosync ): 77 OContactAccessBackend* end, bool autosync ):
74 OPimAccessTemplate<OContact>( end ) 78 OPimAccessTemplate<OContact>( end )
75{ 79{
76 /* take care of the backend. If there is no one defined, we 80 /* take care of the backend. If there is no one defined, we
77 * will use the XML-Backend as default (until we have a cute SQL-Backend..). 81 * will use the XML-Backend as default (until we have a cute SQL-Backend..).
78 */ 82 */
79 if( end == 0 ) { 83 if( end == 0 ) {
80 qWarning ("Using BackendFactory !"); 84 qWarning ("Using BackendFactory !");
81 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); 85 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname );
82 } 86 }
83 // Set backend locally and in template 87 // Set backend locally and in template
84 m_backEnd = end; 88 m_backEnd = end;
85 OPimAccessTemplate<OContact>::setBackEnd (end); 89 OPimAccessTemplate<OContact>::setBackEnd (end);
86 90
87 91
88 /* Connect signal of external db change to function */ 92 /* Connect signal of external db change to function */
89 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); 93 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
90 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), 94 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)),
91 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 95 this, SLOT(copMessage( const QCString &, const QByteArray &)) );
92 if ( autosync ){ 96 if ( autosync ){
93 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); 97 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this );
94 connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), 98 connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)),
95 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 99 this, SLOT(copMessage( const QCString &, const QByteArray &)) );
96 } 100 }
97 101
98 102
99} 103}
100OContactAccess::~OContactAccess () 104OContactAccess::~OContactAccess ()
101{ 105{
102 /* The user may forget to save the changed database, therefore try to 106 /* The user may forget to save the changed database, therefore try to
103 * do it for him.. 107 * do it for him..
104 */ 108 */
105 save(); 109 save();
106 // delete m_backEnd; is done by template.. 110 // delete m_backEnd; is done by template..
107} 111}
108 112
109 113
110bool OContactAccess::save () 114bool OContactAccess::save ()
111{ 115{
112 /* If the database was changed externally, we could not save the 116 /* If the database was changed externally, we could not save the
113 * Data. This will remove added items which is unacceptable ! 117 * Data. This will remove added items which is unacceptable !
114 * Therefore: Reload database and merge the data... 118 * Therefore: Reload database and merge the data...
115 */ 119 */
116 if ( OPimAccessTemplate<OContact>::wasChangedExternally() ) 120 if ( OPimAccessTemplate<OContact>::wasChangedExternally() )
117 reload(); 121 reload();
118 122
119 bool status = OPimAccessTemplate<OContact>::save(); 123 bool status = OPimAccessTemplate<OContact>::save();
120 if ( !status ) return false; 124 if ( !status ) return false;
121 125
122 /* Now tell everyone that new data is available. 126 /* Now tell everyone that new data is available.
123 */ 127 */
124 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); 128 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" );
125 129
126 return true; 130 return true;
127} 131}
128 132
129ORecordList<OContact> OContactAccess::matchRegexp( const QRegExp &r ) const{
130 QArray<int> matchingContacts = m_backEnd -> matchRegexp( r );
131 return ( ORecordList<OContact>(matchingContacts, this) );
132}
133
134const uint OContactAccess::querySettings() 133const uint OContactAccess::querySettings()
135{ 134{
136 return ( m_backEnd->querySettings() ); 135 return ( m_backEnd->querySettings() );
137} 136}
138 137
139bool OContactAccess::hasQuerySettings ( int querySettings ) const 138bool OContactAccess::hasQuerySettings ( int querySettings ) const
140{ 139{
141 return ( m_backEnd->hasQuerySettings ( querySettings ) ); 140 return ( m_backEnd->hasQuerySettings ( querySettings ) );
142} 141}
143ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const 142ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const
144{ 143{
145 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); 144 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat );
146 return ( ORecordList<OContact>(matchingContacts, this) ); 145 return ( ORecordList<OContact>(matchingContacts, this) );
147} 146}
148 147
149 148
150bool OContactAccess::wasChangedExternally()const 149bool OContactAccess::wasChangedExternally()const
151{ 150{
152 return ( m_backEnd->wasChangedExternally() ); 151 return ( m_backEnd->wasChangedExternally() );
153} 152}
154 153
155 154
156void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) 155void OContactAccess::copMessage( const QCString &msg, const QByteArray & )
157{ 156{
158 if ( msg == "addressbookUpdated()" ){ 157 if ( msg == "addressbookUpdated()" ){
159 qWarning ("OContactAccess: Received addressbokUpdated()"); 158 qWarning ("OContactAccess: Received addressbokUpdated()");
160 emit signalChanged ( this ); 159 emit signalChanged ( this );
161 } else if ( msg == "flush()" ) { 160 } else if ( msg == "flush()" ) {
162 qWarning ("OContactAccess: Received flush()"); 161 qWarning ("OContactAccess: Received flush()");
163 save (); 162 save ();
164 } else if ( msg == "reload()" ) { 163 } else if ( msg == "reload()" ) {
165 qWarning ("OContactAccess: Received reload()"); 164 qWarning ("OContactAccess: Received reload()");
166 reload (); 165 reload ();
167 emit signalChanged ( this ); 166 emit signalChanged ( this );
168 } 167 }
169} 168}
diff --git a/libopie/pim/ocontactaccess.h b/libopie/pim/ocontactaccess.h
index d7ceaf2..e90db32 100644
--- a/libopie/pim/ocontactaccess.h
+++ b/libopie/pim/ocontactaccess.h
@@ -1,162 +1,164 @@
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.8 2003/05/08 13:55:09 tille
21 * search stuff
22 * and match, toRichText & toShortText in oevent
23 *
20 * Revision 1.7 2003/04/13 18:07:10 zecke 24 * Revision 1.7 2003/04/13 18:07:10 zecke
21 * More API doc 25 * More API doc
22 * QString -> const QString& 26 * QString -> const QString&
23 * QString = 0l -> QString::null 27 * QString = 0l -> QString::null
24 * 28 *
25 * Revision 1.6 2003/01/02 14:27:12 eilers 29 * Revision 1.6 2003/01/02 14:27:12 eilers
26 * Improved query by example: Search by date is possible.. First step 30 * Improved query by example: Search by date is possible.. First step
27 * for a today plugin for birthdays.. 31 * for a today plugin for birthdays..
28 * 32 *
29 * Revision 1.5 2002/11/13 14:14:51 eilers 33 * Revision 1.5 2002/11/13 14:14:51 eilers
30 * Added sorted for Contacts.. 34 * Added sorted for Contacts..
31 * 35 *
32 * Revision 1.4 2002/11/01 15:10:42 eilers 36 * Revision 1.4 2002/11/01 15:10:42 eilers
33 * Added regExp-search in database for all fields in a contact. 37 * Added regExp-search in database for all fields in a contact.
34 * 38 *
35 * Revision 1.3 2002/10/16 10:52:40 eilers 39 * Revision 1.3 2002/10/16 10:52:40 eilers
36 * Added some docu to the interface and now using the cache infrastucture by zecke.. :) 40 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
37 * 41 *
38 * Revision 1.2 2002/10/14 16:21:54 eilers 42 * Revision 1.2 2002/10/14 16:21:54 eilers
39 * Some minor interface updates 43 * Some minor interface updates
40 * 44 *
41 * Revision 1.1 2002/09/27 17:11:44 eilers 45 * Revision 1.1 2002/09/27 17:11:44 eilers
42 * Added API for accessing the Contact-Database ! It is compiling, but 46 * Added API for accessing the Contact-Database ! It is compiling, but
43 * please do not expect that anything is working ! 47 * please do not expect that anything is working !
44 * I will debug that stuff in the next time .. 48 * I will debug that stuff in the next time ..
45 * Please read README_COMPILE for compiling ! 49 * Please read README_COMPILE for compiling !
46 * 50 *
47 * ===================================================================== 51 * =====================================================================
48 */ 52 */
49#ifndef _OCONTACTACCESS_H 53#ifndef _OCONTACTACCESS_H
50#define _OCONTACTACCESS_H 54#define _OCONTACTACCESS_H
51 55
52#include <qobject.h> 56#include <qobject.h>
53 57
54#include <qpe/qcopenvelope_qws.h> 58#include <qpe/qcopenvelope_qws.h>
55 59
56#include <qvaluelist.h> 60#include <qvaluelist.h>
57#include <qfileinfo.h> 61#include <qfileinfo.h>
58 62
59#include "ocontact.h" 63#include "ocontact.h"
60#include "ocontactaccessbackend.h" 64#include "ocontactaccessbackend.h"
61#include "opimaccesstemplate.h" 65#include "opimaccesstemplate.h"
62 66
63/** 67/**
64 * Class to access the contacts database. 68 * Class to access the contacts database.
65 * This is just a frontend for the real database handling which is 69 * This is just a frontend for the real database handling which is
66 * done by the backend. 70 * done by the backend.
67 * This class is used to access the Contacts on a system. This class as any OPIE PIM 71 * This class is used to access the Contacts on a system. This class as any OPIE PIM
68 * class is backend independent. 72 * class is backend independent.
69 73
70 * @see OPimAccessTemplate 74 * @see OPimAccessTemplate
71 */ 75 */
72class OContactAccess: public QObject, public OPimAccessTemplate<OContact> 76class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
73{ 77{
74 Q_OBJECT 78 Q_OBJECT
75 79
76 public: 80 public:
77 /** 81 /**
78 * Create Database with contacts (addressbook). 82 * Create Database with contacts (addressbook).
79 * @param appname Name of application which wants access to the database 83 * @param appname Name of application which wants access to the database
80 * (i.e. "todolist") 84 * (i.e. "todolist")
81 * @param filename The name of the database file. If not set, the default one 85 * @param filename The name of the database file. If not set, the default one
82 * is used. 86 * is used.
83 * @param backend Pointer to an alternative Backend. If not set, we will use 87 * @param backend Pointer to an alternative Backend. If not set, we will use
84 * the default backend. 88 * the default backend.
85 * @param handlesync If <b>true</b> the database stores the current state 89 * @param handlesync If <b>true</b> the database stores the current state
86 * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> 90 * automatically if it receives the signals <i>flush()</i> and <i>reload()</i>
87 * which are used before and after synchronisation. If the application wants 91 * which are used before and after synchronisation. If the application wants
88 * to react itself, it should be disabled by setting it to <b>false</b> 92 * to react itself, it should be disabled by setting it to <b>false</b>
89 * @see OContactAccessBackend 93 * @see OContactAccessBackend
90 */ 94 */
91 OContactAccess (const QString appname, const QString filename = 0l, 95 OContactAccess (const QString appname, const QString filename = 0l,
92 OContactAccessBackend* backend = 0l, bool handlesync = true); 96 OContactAccessBackend* backend = 0l, bool handlesync = true);
93 ~OContactAccess (); 97 ~OContactAccess ();
94 98
95 /** Constants for query. 99 /** Constants for query.
96 * Use this constants to set the query parameters. 100 * Use this constants to set the query parameters.
97 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! 101 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes !
98 * @see queryByExample() 102 * @see queryByExample()
99 */ 103 */
100 enum QuerySettings { 104 enum QuerySettings {
101 WildCards = 0x0001, 105 WildCards = 0x0001,
102 IgnoreCase = 0x0002, 106 IgnoreCase = 0x0002,
103 RegExp = 0x0004, 107 RegExp = 0x0004,
104 ExactMatch = 0x0008, 108 ExactMatch = 0x0008,
105 MatchOne = 0x0010, // Only one Entry must match 109 MatchOne = 0x0010, // Only one Entry must match
106 DateDiff = 0x0020, // Find all entries from today until given date 110 DateDiff = 0x0020, // Find all entries from today until given date
107 DateYear = 0x0040, // The year matches 111 DateYear = 0x0040, // The year matches
108 DateMonth = 0x0080, // The month matches 112 DateMonth = 0x0080, // The month matches
109 DateDay = 0x0100, // The day matches 113 DateDay = 0x0100, // The day matches
110 }; 114 };
111 115
112 116
113 ORecordList<OContact> matchRegexp( const QRegExp &r )const;
114
115 /** Return all Contacts in a sorted manner. 117 /** Return all Contacts in a sorted manner.
116 * @param ascending true: Sorted in acending order. 118 * @param ascending true: Sorted in acending order.
117 * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess 119 * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess
118 * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess 120 * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess
119 * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess 121 * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess
120 */ 122 */
121 List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const; 123 List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const;
122 124
123 /** Return all possible settings. 125 /** Return all possible settings.
124 * @return All settings provided by the current backend 126 * @return All settings provided by the current backend
125 * (i.e.: query_WildCards & query_IgnoreCase) 127 * (i.e.: query_WildCards & query_IgnoreCase)
126 */ 128 */
127 const uint querySettings(); 129 const uint querySettings();
128 130
129 /** Check whether settings are correct. 131 /** Check whether settings are correct.
130 * @return <i>true</i> if the given settings are correct and possible. 132 * @return <i>true</i> if the given settings are correct and possible.
131 */ 133 */
132 bool hasQuerySettings ( int querySettings ) const; 134 bool hasQuerySettings ( int querySettings ) const;
133 135
134 /** 136 /**
135 * if the resource was changed externally. 137 * if the resource was changed externally.
136 * You should use the signal instead of polling possible changes ! 138 * You should use the signal instead of polling possible changes !
137 */ 139 */
138 bool wasChangedExternally()const; 140 bool wasChangedExternally()const;
139 141
140 142
141 /** Save contacts database. 143 /** Save contacts database.
142 * Save is more a "commit". After calling this function, all changes are public available. 144 * Save is more a "commit". After calling this function, all changes are public available.
143 * @return true if successful 145 * @return true if successful
144 */ 146 */
145 bool save(); 147 bool save();
146 148
147 signals: 149 signals:
148 /* Signal is emitted if the database was changed. Therefore 150 /* Signal is emitted if the database was changed. Therefore
149 * we may need to reload to stay consistent. 151 * we may need to reload to stay consistent.
150 * @param which Pointer to the database who created this event. This pointer 152 * @param which Pointer to the database who created this event. This pointer
151 * is useful if an application has to handle multiple databases at the same time. 153 * is useful if an application has to handle multiple databases at the same time.
152 * @see reload() 154 * @see reload()
153 */ 155 */
154 void signalChanged ( const OContactAccess *which ); 156 void signalChanged ( const OContactAccess *which );
155 157
156 158
157 private: 159 private:
158 // class OContactAccessPrivate; 160 // class OContactAccessPrivate;
159 // OContactAccessPrivate* d; 161 // OContactAccessPrivate* d;
160 OContactAccessBackend *m_backEnd; 162 OContactAccessBackend *m_backEnd;
161 bool m_loading:1; 163 bool m_loading:1;
162 164
diff --git a/libopie/pim/odatebookaccessbackend_xml.cpp b/libopie/pim/odatebookaccessbackend_xml.cpp
index a0ae7b7..ab2eea4 100644
--- a/libopie/pim/odatebookaccessbackend_xml.cpp
+++ b/libopie/pim/odatebookaccessbackend_xml.cpp
@@ -541,48 +541,66 @@ void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& val
541 case FRHasEndDate: 541 case FRHasEndDate:
542 recur()->setHasEndDate( value.toInt() ); 542 recur()->setHasEndDate( value.toInt() );
543 break; 543 break;
544 case FREndDate: { 544 case FREndDate: {
545 rp_end = (time_t) value.toLong(); 545 rp_end = (time_t) value.toLong();
546 break; 546 break;
547 } 547 }
548 case FRStart: { 548 case FRStart: {
549 start = (time_t) value.toLong(); 549 start = (time_t) value.toLong();
550 break; 550 break;
551 } 551 }
552 case FREnd: { 552 case FREnd: {
553 end = ( (time_t) value.toLong() ); 553 end = ( (time_t) value.toLong() );
554 break; 554 break;
555 } 555 }
556 case FNote: 556 case FNote:
557 e.setNote( value ); 557 e.setNote( value );
558 break; 558 break;
559 case FCreated: 559 case FCreated:
560 created = value.toInt(); 560 created = value.toInt();
561 break; 561 break;
562 case FRecParent: 562 case FRecParent:
563 e.setParent( value.toInt() ); 563 e.setParent( value.toInt() );
564 break; 564 break;
565 case FRecChildren:{ 565 case FRecChildren:{
566 QStringList list = QStringList::split(' ', value ); 566 QStringList list = QStringList::split(' ', value );
567 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 567 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
568 e.addChild( (*it).toInt() ); 568 e.addChild( (*it).toInt() );
569 } 569 }
570 } 570 }
571 break; 571 break;
572 case FExceptions:{ 572 case FExceptions:{
573 QStringList list = QStringList::split(' ', value ); 573 QStringList list = QStringList::split(' ', value );
574 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 574 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
575 QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() ); 575 QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() );
576 qWarning("adding exception %s", date.toString().latin1() ); 576 qWarning("adding exception %s", date.toString().latin1() );
577 recur()->exceptions().append( date ); 577 recur()->exceptions().append( date );
578 } 578 }
579 } 579 }
580 break; 580 break;
581 case FTimeZone: 581 case FTimeZone:
582 if ( value != "None" ) 582 if ( value != "None" )
583 e.setTimeZone( value ); 583 e.setTimeZone( value );
584 break; 584 break;
585 default: 585 default:
586 break; 586 break;
587 } 587 }
588} 588}
589QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const
590{
591 QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() );
592 uint arraycounter = 0;
593 QMap<int, OEvent>::ConstIterator it;
594
595 for ( it = m_raw.begin(); it != m_raw.end(); ++it )
596 if ( it.data().match( r ) )
597 m_currentQuery[arraycounter++] = it.data().uid();
598 for ( it = m_rep.begin(); it != m_rep.end(); ++it )
599 if ( it.data().match( r ) )
600 m_currentQuery[arraycounter++] = it.data().uid();
601
602 // Shrink to fit..
603 m_currentQuery.resize(arraycounter);
604
605 return m_currentQuery;
606}
diff --git a/libopie/pim/odatebookaccessbackend_xml.h b/libopie/pim/odatebookaccessbackend_xml.h
index 7848f7c..a5cc0fc 100644
--- a/libopie/pim/odatebookaccessbackend_xml.h
+++ b/libopie/pim/odatebookaccessbackend_xml.h
@@ -1,54 +1,55 @@
1#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H 1#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H
2#define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H 2#define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H
3 3
4#include <qmap.h> 4#include <qmap.h>
5 5
6#include "odatebookaccessbackend.h" 6#include "odatebookaccessbackend.h"
7 7
8/** 8/**
9 * This is the default XML implementation for DateBoook XML storage 9 * This is the default XML implementation for DateBoook XML storage
10 * It fully implements the interface 10 * It fully implements the interface
11 * @see ODateBookAccessBackend 11 * @see ODateBookAccessBackend
12 * @see OPimAccessBackend 12 * @see OPimAccessBackend
13 */ 13 */
14class ODateBookAccessBackend_XML : public ODateBookAccessBackend { 14class ODateBookAccessBackend_XML : public ODateBookAccessBackend {
15public: 15public:
16 ODateBookAccessBackend_XML( const QString& appName, 16 ODateBookAccessBackend_XML( const QString& appName,
17 const QString& fileName = QString::null); 17 const QString& fileName = QString::null);
18 ~ODateBookAccessBackend_XML(); 18 ~ODateBookAccessBackend_XML();
19 19
20 bool load(); 20 bool load();
21 bool reload(); 21 bool reload();
22 bool save(); 22 bool save();
23 23
24 QArray<int> allRecords()const; 24 QArray<int> allRecords()const;
25 QArray<int> matchRegexp(const QRegExp &r) const;
25 QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); 26 QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() );
26 OEvent find( int uid )const; 27 OEvent find( int uid )const;
27 void clear(); 28 void clear();
28 bool add( const OEvent& ev ); 29 bool add( const OEvent& ev );
29 bool remove( int uid ); 30 bool remove( int uid );
30 bool replace( const OEvent& ev ); 31 bool replace( const OEvent& ev );
31 32
32 QArray<UID> rawEvents()const; 33 QArray<UID> rawEvents()const;
33 QArray<UID> rawRepeats()const; 34 QArray<UID> rawRepeats()const;
34 QArray<UID> nonRepeats()const; 35 QArray<UID> nonRepeats()const;
35 36
36 OEvent::ValueList directNonRepeats(); 37 OEvent::ValueList directNonRepeats();
37 OEvent::ValueList directRawRepeats(); 38 OEvent::ValueList directRawRepeats();
38 39
39private: 40private:
40 bool m_changed :1 ; 41 bool m_changed :1 ;
41 bool loadFile(); 42 bool loadFile();
42 inline void finalizeRecord( OEvent& ev ); 43 inline void finalizeRecord( OEvent& ev );
43 inline void setField( OEvent&, int field, const QString& val ); 44 inline void setField( OEvent&, int field, const QString& val );
44 QString m_name; 45 QString m_name;
45 QMap<int, OEvent> m_raw; 46 QMap<int, OEvent> m_raw;
46 QMap<int, OEvent> m_rep; 47 QMap<int, OEvent> m_rep;
47 48
48 struct Data; 49 struct Data;
49 Data* data; 50 Data* data;
50 class Private; 51 class Private;
51 Private *d; 52 Private *d;
52}; 53};
53 54
54#endif 55#endif
diff --git a/libopie/pim/oevent.cpp b/libopie/pim/oevent.cpp
index 3ba8a52..28cf873 100644
--- a/libopie/pim/oevent.cpp
+++ b/libopie/pim/oevent.cpp
@@ -1,52 +1,53 @@
1#include <qshared.h> 1#include <qshared.h>
2 2
3#include <qpe/palmtopuidgen.h> 3#include <qpe/palmtopuidgen.h>
4#include <qpe/categories.h> 4#include <qpe/categories.h>
5#include <qpe/stringutil.h>
5 6
6#include "orecur.h" 7#include "orecur.h"
7#include "opimresolver.h" 8#include "opimresolver.h"
8#include "opimnotifymanager.h" 9#include "opimnotifymanager.h"
9 10
10#include "oevent.h" 11#include "oevent.h"
11 12
12int OCalendarHelper::week( const QDate& date) { 13int OCalendarHelper::week( const QDate& date) {
13 // Calculates the week this date is in within that 14 // Calculates the week this date is in within that
14 // month. Equals the "row" is is in in the month view 15 // month. Equals the "row" is is in in the month view
15 int week = 1; 16 int week = 1;
16 QDate tmp( date.year(), date.month(), 1 ); 17 QDate tmp( date.year(), date.month(), 1 );
17 if ( date.dayOfWeek() < tmp.dayOfWeek() ) 18 if ( date.dayOfWeek() < tmp.dayOfWeek() )
18 ++week; 19 ++week;
19 20
20 week += ( date.day() - 1 ) / 7; 21 week += ( date.day() - 1 ) / 7;
21 22
22 return week; 23 return week;
23} 24}
24int OCalendarHelper::ocurrence( const QDate& date) { 25int OCalendarHelper::ocurrence( const QDate& date) {
25 // calculates the number of occurrances of this day of the 26 // calculates the number of occurrances of this day of the
26 // week till the given date (e.g 3rd Wednesday of the month) 27 // week till the given date (e.g 3rd Wednesday of the month)
27 return ( date.day() - 1 ) / 7 + 1; 28 return ( date.day() - 1 ) / 7 + 1;
28} 29}
29int OCalendarHelper::dayOfWeek( char day ) { 30int OCalendarHelper::dayOfWeek( char day ) {
30 int dayOfWeek = 1; 31 int dayOfWeek = 1;
31 char i = ORecur::MON; 32 char i = ORecur::MON;
32 while ( !( i & day ) && i <= ORecur::SUN ) { 33 while ( !( i & day ) && i <= ORecur::SUN ) {
33 i <<= 1; 34 i <<= 1;
34 ++dayOfWeek; 35 ++dayOfWeek;
35 } 36 }
36 return dayOfWeek; 37 return dayOfWeek;
37} 38}
38int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) { 39int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) {
39 return ( second.year() - first.year() ) * 12 + 40 return ( second.year() - first.year() ) * 12 +
40 second.month() - first.month(); 41 second.month() - first.month();
41} 42}
42 43
43struct OEvent::Data : public QShared { 44struct OEvent::Data : public QShared {
44 Data() : QShared() { 45 Data() : QShared() {
45 child = 0; 46 child = 0;
46 recur = 0; 47 recur = 0;
47 manager = 0; 48 manager = 0;
48 isAllDay = false; 49 isAllDay = false;
49 parent = 0; 50 parent = 0;
50 } 51 }
51 ~Data() { 52 ~Data() {
52 delete manager; 53 delete manager;
@@ -165,106 +166,136 @@ QDateTime OEvent::startDateTimeInZone()const {
165 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); 166 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime();
166 167
167 OTimeZone zone(data->timezone ); 168 OTimeZone zone(data->timezone );
168 return zone.toDateTime( data->start, OTimeZone::current() ); 169 return zone.toDateTime( data->start, OTimeZone::current() );
169} 170}
170void OEvent::setStartDateTime( const QDateTime& dt ) { 171void OEvent::setStartDateTime( const QDateTime& dt ) {
171 changeOrModify(); 172 changeOrModify();
172 data->start = dt; 173 data->start = dt;
173} 174}
174QDateTime OEvent::endDateTime()const { 175QDateTime OEvent::endDateTime()const {
175 /* 176 /*
176 * if all Day event the end time needs 177 * if all Day event the end time needs
177 * to be on the same day as the start 178 * to be on the same day as the start
178 */ 179 */
179 if ( data->isAllDay ) 180 if ( data->isAllDay )
180 return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); 181 return QDateTime( data->start.date(), QTime(23, 59, 59 ) );
181 return data->end; 182 return data->end;
182} 183}
183QDateTime OEvent::endDateTimeInZone()const { 184QDateTime OEvent::endDateTimeInZone()const {
184 /* if no timezone, or all day event or if the current and this timeZone match... */ 185 /* if no timezone, or all day event or if the current and this timeZone match... */
185 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); 186 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime();
186 187
187 OTimeZone zone(data->timezone ); 188 OTimeZone zone(data->timezone );
188 return zone.toDateTime( data->end, OTimeZone::current() ); 189 return zone.toDateTime( data->end, OTimeZone::current() );
189} 190}
190void OEvent::setEndDateTime( const QDateTime& dt ) { 191void OEvent::setEndDateTime( const QDateTime& dt ) {
191 changeOrModify(); 192 changeOrModify();
192 data->end = dt; 193 data->end = dt;
193} 194}
194bool OEvent::isMultipleDay()const { 195bool OEvent::isMultipleDay()const {
195 return data->end.date().day() - data->start.date().day(); 196 return data->end.date().day() - data->start.date().day();
196} 197}
197bool OEvent::isAllDay()const { 198bool OEvent::isAllDay()const {
198 return data->isAllDay; 199 return data->isAllDay;
199} 200}
200void OEvent::setAllDay( bool allDay ) { 201void OEvent::setAllDay( bool allDay ) {
201 changeOrModify(); 202 changeOrModify();
202 data->isAllDay = allDay; 203 data->isAllDay = allDay;
203 if (allDay ) data->timezone = "UTC"; 204 if (allDay ) data->timezone = "UTC";
204} 205}
205void OEvent::setTimeZone( const QString& tz ) { 206void OEvent::setTimeZone( const QString& tz ) {
206 changeOrModify(); 207 changeOrModify();
207 data->timezone = tz; 208 data->timezone = tz;
208} 209}
209QString OEvent::timeZone()const { 210QString OEvent::timeZone()const {
210 if (data->isAllDay ) return QString::fromLatin1("UTC"); 211 if (data->isAllDay ) return QString::fromLatin1("UTC");
211 return data->timezone; 212 return data->timezone;
212} 213}
213bool OEvent::match( const QRegExp& )const { 214bool OEvent::match( const QRegExp& re )const {
214 // FIXME 215 if (data->description.contains( re ) )
216 return true;
217 if ( data->note.contains( re ) )
218 return true;
219 if ( data->location.contains( re ) )
220 return true;
221 if ( data->start.toString().contains( re ) )
222 return true;
223 if ( data->end.toString().contains( re ) )
224 return true;
215 return false; 225 return false;
216} 226}
217QString OEvent::toRichText()const { 227QString OEvent::toRichText()const {
218 // FIXME 228 QString text;
219 return "OEvent test"; 229 if ( !description().isEmpty() ) {
230 text += "<b>" + QObject::tr( "Description:") + "</b><br>";
231 text += Qtopia::escapeString(description() ).
232 replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
233 }
234 if ( startDateTime().isValid() ) {
235 text += "<b>" + QObject::tr( "Start:") + "</b> ";
236 text += Qtopia::escapeString(startDateTime().toString() ).
237 replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
238 }
239 if ( endDateTime().isValid() ) {
240 text += "<b>" + QObject::tr( "End:") + "</b> ";
241 text += Qtopia::escapeString(endDateTime().toString() ).
242 replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
243 }
244 if ( !note().isEmpty() ) {
245 text += "<b>" + QObject::tr( "Note:") + "</b><br>";
246 text += note();
247// text += Qtopia::escapeString(note() ).
248// replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
249 }
250 return text;
220} 251}
221QString OEvent::toShortText()const { 252QString OEvent::toShortText()const {
222 return "OEvent shotText"; 253 return description();
223} 254}
224QString OEvent::type()const { 255QString OEvent::type()const {
225 return QString::fromLatin1("OEvent"); 256 return QString::fromLatin1("OEvent");
226} 257}
227QString OEvent::recordField( int /*id */ )const { 258QString OEvent::recordField( int /*id */ )const {
228 return QString::null; 259 return QString::null;
229} 260}
230int OEvent::rtti() { 261int OEvent::rtti() {
231 return OPimResolver::DateBook; 262 return OPimResolver::DateBook;
232} 263}
233bool OEvent::loadFromStream( QDataStream& ) { 264bool OEvent::loadFromStream( QDataStream& ) {
234 return true; 265 return true;
235} 266}
236bool OEvent::saveToStream( QDataStream& )const { 267bool OEvent::saveToStream( QDataStream& )const {
237 return true; 268 return true;
238} 269}
239void OEvent::changeOrModify() { 270void OEvent::changeOrModify() {
240 if ( data->count != 1 ) { 271 if ( data->count != 1 ) {
241 data->deref(); 272 data->deref();
242 Data* d2 = new Data; 273 Data* d2 = new Data;
243 d2->description = data->description; 274 d2->description = data->description;
244 d2->location = data->location; 275 d2->location = data->location;
245 276
246 if (data->manager ) 277 if (data->manager )
247 d2->manager = new OPimNotifyManager( *data->manager ); 278 d2->manager = new OPimNotifyManager( *data->manager );
248 279
249 if ( data->recur ) 280 if ( data->recur )
250 d2->recur = new ORecur( *data->recur ); 281 d2->recur = new ORecur( *data->recur );
251 282
252 d2->note = data->note; 283 d2->note = data->note;
253 d2->created = data->created; 284 d2->created = data->created;
254 d2->start = data->start; 285 d2->start = data->start;
255 d2->end = data->end; 286 d2->end = data->end;
256 d2->isAllDay = data->isAllDay; 287 d2->isAllDay = data->isAllDay;
257 d2->timezone = data->timezone; 288 d2->timezone = data->timezone;
258 d2->parent = data->parent; 289 d2->parent = data->parent;
259 290
260 if ( data->child ) { 291 if ( data->child ) {
261 d2->child = new QArray<int>( *data->child ); 292 d2->child = new QArray<int>( *data->child );
262 d2->child->detach(); 293 d2->child->detach();
263 } 294 }
264 295
265 data = d2; 296 data = d2;
266 } 297 }
267} 298}
268void OEvent::deref() { 299void OEvent::deref() {
269 if ( data->deref() ) { 300 if ( data->deref() ) {
270 delete data; 301 delete data;
diff --git a/libopie/pim/oevent.h b/libopie/pim/oevent.h
index 57d32d0..b696d81 100644
--- a/libopie/pim/oevent.h
+++ b/libopie/pim/oevent.h
@@ -68,97 +68,97 @@ public:
68 */ 68 */
69 OEvent( const OEvent& ); 69 OEvent( const OEvent& );
70 ~OEvent(); 70 ~OEvent();
71 OEvent &operator=( const OEvent& ); 71 OEvent &operator=( const OEvent& );
72 72
73 QString description()const; 73 QString description()const;
74 void setDescription( const QString& description ); 74 void setDescription( const QString& description );
75 75
76 QString location()const; 76 QString location()const;
77 void setLocation( const QString& loc ); 77 void setLocation( const QString& loc );
78 78
79 bool hasNotifiers()const; 79 bool hasNotifiers()const;
80 OPimNotifyManager &notifiers()const; 80 OPimNotifyManager &notifiers()const;
81 81
82 ORecur recurrence()const; 82 ORecur recurrence()const;
83 void setRecurrence( const ORecur& ); 83 void setRecurrence( const ORecur& );
84 bool hasRecurrence()const; 84 bool hasRecurrence()const;
85 85
86 QString note()const; 86 QString note()const;
87 void setNote( const QString& note ); 87 void setNote( const QString& note );
88 88
89 89
90 QDateTime createdDateTime()const; 90 QDateTime createdDateTime()const;
91 void setCreatedDateTime( const QDateTime& dt); 91 void setCreatedDateTime( const QDateTime& dt);
92 92
93 /** set the date to dt. dt is the QDateTime in localtime */ 93 /** set the date to dt. dt is the QDateTime in localtime */
94 void setStartDateTime( const QDateTime& ); 94 void setStartDateTime( const QDateTime& );
95 /** returns the datetime in the local timeZone */ 95 /** returns the datetime in the local timeZone */
96 QDateTime startDateTime()const; 96 QDateTime startDateTime()const;
97 97
98 /** returns the start datetime in the current zone */ 98 /** returns the start datetime in the current zone */
99 QDateTime startDateTimeInZone()const; 99 QDateTime startDateTimeInZone()const;
100 100
101 /** in current timezone */ 101 /** in current timezone */
102 void setEndDateTime( const QDateTime& ); 102 void setEndDateTime( const QDateTime& );
103 /** in current timezone */ 103 /** in current timezone */
104 QDateTime endDateTime()const; 104 QDateTime endDateTime()const;
105 QDateTime endDateTimeInZone()const; 105 QDateTime endDateTimeInZone()const;
106 106
107 bool isMultipleDay()const; 107 bool isMultipleDay()const;
108 bool isAllDay()const; 108 bool isAllDay()const;
109 void setAllDay( bool isAllDay ); 109 void setAllDay( bool isAllDay );
110 110
111 /* pin this event to a timezone! FIXME */ 111 /* pin this event to a timezone! FIXME */
112 void setTimeZone( const QString& timeZone ); 112 void setTimeZone( const QString& timeZone );
113 QString timeZone()const; 113 QString timeZone()const;
114 114
115 115
116 bool match( const QRegExp& )const; 116 virtual bool match( const QRegExp& )const;
117 117
118 /** For exception to recurrence here is a list of children... */ 118 /** For exception to recurrence here is a list of children... */
119 QArray<int> children()const; 119 QArray<int> children()const;
120 void setChildren( const QArray<int>& ); 120 void setChildren( const QArray<int>& );
121 void addChild( int uid ); 121 void addChild( int uid );
122 void removeChild( int uid ); 122 void removeChild( int uid );
123 123
124 /** return the parent OEvent */ 124 /** return the parent OEvent */
125 int parent()const; 125 int parent()const;
126 void setParent( int uid ); 126 void setParent( int uid );
127 127
128 128
129 /* needed reimp */ 129 /* needed reimp */
130 QString toRichText()const; 130 QString toRichText()const;
131 QString toShortText()const; 131 QString toShortText()const;
132 QString type()const; 132 QString type()const;
133 133
134 QMap<int, QString> toMap()const; 134 QMap<int, QString> toMap()const;
135 QMap<QString, QString> toExtraMap()const; 135 QMap<QString, QString> toExtraMap()const;
136 QString recordField(int )const; 136 QString recordField(int )const;
137 137
138 static int rtti(); 138 static int rtti();
139 139
140 bool loadFromStream( QDataStream& ); 140 bool loadFromStream( QDataStream& );
141 bool saveToStream( QDataStream& )const; 141 bool saveToStream( QDataStream& )const;
142 142
143/* bool operator==( const OEvent& ); 143/* bool operator==( const OEvent& );
144 bool operator!=( const OEvent& ); 144 bool operator!=( const OEvent& );
145 bool operator<( const OEvent& ); 145 bool operator<( const OEvent& );
146 bool operator<=( const OEvent& ); 146 bool operator<=( const OEvent& );
147 bool operator>( const OEvent& ); 147 bool operator>( const OEvent& );
148 bool operator>=(const OEvent& ); 148 bool operator>=(const OEvent& );
149*/ 149*/
150private: 150private:
151 inline void changeOrModify(); 151 inline void changeOrModify();
152 void deref(); 152 void deref();
153 struct Data; 153 struct Data;
154 Data* data; 154 Data* data;
155 class Private; 155 class Private;
156 Private* priv; 156 Private* priv;
157 157
158}; 158};
159 159
160/** 160/**
161 * AN Event can span through multiple days. We split up a multiday eve 161 * AN Event can span through multiple days. We split up a multiday eve
162 */ 162 */
163class OEffectiveEvent { 163class OEffectiveEvent {
164public: 164public:
diff --git a/libopie/pim/opimaccessbackend.h b/libopie/pim/opimaccessbackend.h
index 01a0c86..f4bbe35 100644
--- a/libopie/pim/opimaccessbackend.h
+++ b/libopie/pim/opimaccessbackend.h
@@ -1,96 +1,102 @@
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
10/** 10/**
11 * OPimAccessBackend is the base class 11 * OPimAccessBackend is the base class
12 * for all private backends 12 * for all private backends
13 * it operates on OPimRecord as the base class 13 * it operates on OPimRecord as the base class
14 * and it's responsible for fast manipulating 14 * and it's responsible for fast manipulating
15 * the resource the implementation takes care 15 * the resource the implementation takes care
16 * of 16 * of
17 */ 17 */
18template <class T = OPimRecord> 18template <class T = OPimRecord>
19class OPimAccessBackend { 19class OPimAccessBackend {
20public: 20public:
21 typedef OTemplateBase<T> Frontend; 21 typedef OTemplateBase<T> Frontend;
22 22
23 /** The access hint from the frontend */ 23 /** The access hint from the frontend */
24 OPimAccessBackend(int access = 0); 24 OPimAccessBackend(int access = 0);
25 virtual ~OPimAccessBackend(); 25 virtual ~OPimAccessBackend();
26 26
27 /** 27 /**
28 * load the resource 28 * load the resource
29 */ 29 */
30 virtual bool load() = 0; 30 virtual bool load() = 0;
31 31
32 /** 32 /**
33 * reload the resource 33 * reload the resource
34 */ 34 */
35 virtual bool reload() = 0; 35 virtual bool reload() = 0;
36 36
37 /** 37 /**
38 * save the resource and 38 * save the resource and
39 * all it's changes 39 * all it's changes
40 */ 40 */
41 virtual bool save() = 0; 41 virtual bool save() = 0;
42 42
43 /** 43 /**
44 * return an array of 44 * return an array of
45 * all available uids 45 * all available uids
46 */ 46 */
47 virtual QArray<int> allRecords()const = 0; 47 virtual QArray<int> allRecords()const = 0;
48 48
49 /**
50 * return a List of records
51 * that match the regex
52 */
53 virtual QArray<int> matchRegexp(const QRegExp &r) const = 0;
54
49 /** 55 /**
50 * queryByExample for T with the given Settings 56 * queryByExample for T with the given Settings
51 * 57 *
52 */ 58 */
53 virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; 59 virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0;
54 60
55 /** 61 /**
56 * find the OPimRecord with uid @param uid 62 * find the OPimRecord with uid @param uid
57 * returns T and T.isEmpty() if nothing was found 63 * returns T and T.isEmpty() if nothing was found
58 */ 64 */
59 virtual T find(int uid )const = 0; 65 virtual T find(int uid )const = 0;
60 66
61 virtual T find(int uid, const QArray<int>& items, 67 virtual T find(int uid, const QArray<int>& items,
62 uint current, typename Frontend::CacheDirection )const ; 68 uint current, typename Frontend::CacheDirection )const ;
63 /** 69 /**
64 * clear the back end 70 * clear the back end
65 */ 71 */
66 virtual void clear() = 0; 72 virtual void clear() = 0;
67 73
68 /** 74 /**
69 * add T 75 * add T
70 */ 76 */
71 virtual bool add( const T& t ) = 0; 77 virtual bool add( const T& t ) = 0;
72 78
73 /** 79 /**
74 * remove 80 * remove
75 */ 81 */
76 virtual bool remove( int uid ) = 0; 82 virtual bool remove( int uid ) = 0;
77 83
78 /** 84 /**
79 * replace a record with T.uid() 85 * replace a record with T.uid()
80 */ 86 */
81 virtual bool replace( const T& t ) = 0; 87 virtual bool replace( const T& t ) = 0;
82 88
83 /* 89 /*
84 * setTheFrontEnd!!! 90 * setTheFrontEnd!!!
85 */ 91 */
86 void setFrontend( Frontend* front ); 92 void setFrontend( Frontend* front );
87 93
88 /** 94 /**
89 * set the read ahead count 95 * set the read ahead count
90 */ 96 */
91 void setReadAhead( uint count ); 97 void setReadAhead( uint count );
92protected: 98protected:
93 int access()const; 99 int access()const;
94 void cache( const T& t )const; 100 void cache( const T& t )const;
95 101
96 /** 102 /**
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h
index 6a3a0db..8ff205c 100644
--- a/libopie/pim/opimaccesstemplate.h
+++ b/libopie/pim/opimaccesstemplate.h
@@ -24,96 +24,102 @@ class OPimAccessTemplate : public OTemplateBase<T> {
24public: 24public:
25 enum Access { 25 enum Access {
26 Random = 0, 26 Random = 0,
27 SortedAccess 27 SortedAccess
28 }; 28 };
29 typedef ORecordList<T> List; 29 typedef ORecordList<T> List;
30 typedef OPimAccessBackend<T> BackEnd; 30 typedef OPimAccessBackend<T> BackEnd;
31 typedef OPimCache<T> Cache; 31 typedef OPimCache<T> Cache;
32 32
33 /** 33 /**
34 * c'tor BackEnd 34 * c'tor BackEnd
35 * enum Access a small hint on how to handle the backend 35 * enum Access a small hint on how to handle the backend
36 */ 36 */
37 OPimAccessTemplate( BackEnd* end); 37 OPimAccessTemplate( BackEnd* end);
38 38
39 virtual ~OPimAccessTemplate(); 39 virtual ~OPimAccessTemplate();
40 40
41 /** 41 /**
42 * load from the backend 42 * load from the backend
43 */ 43 */
44 bool load(); 44 bool load();
45 45
46 /** Reload database. 46 /** Reload database.
47 * You should execute this function if the external database 47 * You should execute this function if the external database
48 * was changed. 48 * was changed.
49 * This function will load the external database and afterwards 49 * This function will load the external database and afterwards
50 * rejoin the local changes. Therefore the local database will be set consistent. 50 * rejoin the local changes. Therefore the local database will be set consistent.
51 */ 51 */
52 virtual bool reload(); 52 virtual bool reload();
53 53
54 /** Save contacts database. 54 /** Save contacts database.
55 * Save is more a "commit". After calling this function, all changes are public available. 55 * Save is more a "commit". After calling this function, all changes are public available.
56 * @return true if successful 56 * @return true if successful
57 */ 57 */
58 bool save(); 58 bool save();
59 59
60 /** 60 /**
61 * if the resource was changed externally 61 * if the resource was changed externally
62 * You should use the signal handling instead of polling possible changes ! 62 * You should use the signal handling instead of polling possible changes !
63 * zecke: Do you implement a signal for otodoaccess ? 63 * zecke: Do you implement a signal for otodoaccess ?
64 */ 64 */
65 bool wasChangedExternally()const; 65 bool wasChangedExternally()const;
66 66
67 /** 67 /**
68 * return a List of records 68 * return a List of records
69 * you can iterate over them 69 * you can iterate over them
70 */ 70 */
71 virtual List allRecords()const; 71 virtual List allRecords()const;
72
73 /**
74 * return a List of records
75 * that match the regex
76 */
77 virtual List matchRegexp( const QRegExp &r ) const;
72 78
73 /** 79 /**
74 * queryByExample. 80 * queryByExample.
75 * @see otodoaccess, ocontactaccess 81 * @see otodoaccess, ocontactaccess
76 */ 82 */
77 virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); 83 virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() );
78 84
79 /** 85 /**
80 * find the OPimRecord uid 86 * find the OPimRecord uid
81 */ 87 */
82 virtual T find( int uid )const; 88 virtual T find( int uid )const;
83 89
84 /** 90 /**
85 * read ahead cache find method ;) 91 * read ahead cache find method ;)
86 */ 92 */
87 virtual T find( int uid, const QArray<int>&, 93 virtual T find( int uid, const QArray<int>&,
88 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; 94 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const;
89 95
90 /* invalidate cache here */ 96 /* invalidate cache here */
91 /** 97 /**
92 * clears the backend and invalidates the backend 98 * clears the backend and invalidates the backend
93 */ 99 */
94 void clear() ; 100 void clear() ;
95 101
96 /** 102 /**
97 * add T to the backend 103 * add T to the backend
98 * @param t The item to add. 104 * @param t The item to add.
99 * @return <i>true</i> if added successfully. 105 * @return <i>true</i> if added successfully.
100 */ 106 */
101 virtual bool add( const T& t ) ; 107 virtual bool add( const T& t ) ;
102 bool add( const OPimRecord& ); 108 bool add( const OPimRecord& );
103 109
104 /* only the uid matters */ 110 /* only the uid matters */
105 /** 111 /**
106 * remove T from the backend 112 * remove T from the backend
107 * @param t The item to remove 113 * @param t The item to remove
108 * @return <i>true</i> if successful. 114 * @return <i>true</i> if successful.
109 */ 115 */
110 virtual bool remove( const T& t ); 116 virtual bool remove( const T& t );
111 117
112 /** 118 /**
113 * remove the OPimRecord with uid 119 * remove the OPimRecord with uid
114 * @param uid The ID of the item to remove 120 * @param uid The ID of the item to remove
115 * @return <i>true</i> if successful. 121 * @return <i>true</i> if successful.
116 */ 122 */
117 bool remove( int uid ); 123 bool remove( int uid );
118 bool remove( const OPimRecord& ); 124 bool remove( const OPimRecord& );
119 125
@@ -136,96 +142,102 @@ protected:
136 /** 142 /**
137 * invalidate the cache 143 * invalidate the cache
138 */ 144 */
139 void invalidateCache(); 145 void invalidateCache();
140 146
141 void setBackEnd( BackEnd* end ); 147 void setBackEnd( BackEnd* end );
142 /** 148 /**
143 * returns the backend 149 * returns the backend
144 */ 150 */
145 BackEnd* backEnd(); 151 BackEnd* backEnd();
146 BackEnd* m_backEnd; 152 BackEnd* m_backEnd;
147 Cache m_cache; 153 Cache m_cache;
148 154
149}; 155};
150 156
151template <class T> 157template <class T>
152OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) 158OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end )
153 : OTemplateBase<T>(), m_backEnd( end ) 159 : OTemplateBase<T>(), m_backEnd( end )
154{ 160{
155 if (end ) 161 if (end )
156 end->setFrontend( this ); 162 end->setFrontend( this );
157} 163}
158template <class T> 164template <class T>
159OPimAccessTemplate<T>::~OPimAccessTemplate() { 165OPimAccessTemplate<T>::~OPimAccessTemplate() {
160 qWarning("~OPimAccessTemplate<T>"); 166 qWarning("~OPimAccessTemplate<T>");
161 delete m_backEnd; 167 delete m_backEnd;
162} 168}
163template <class T> 169template <class T>
164bool OPimAccessTemplate<T>::load() { 170bool OPimAccessTemplate<T>::load() {
165 invalidateCache(); 171 invalidateCache();
166 return m_backEnd->load(); 172 return m_backEnd->load();
167} 173}
168template <class T> 174template <class T>
169bool OPimAccessTemplate<T>::reload() { 175bool OPimAccessTemplate<T>::reload() {
170 invalidateCache(); // zecke: I think this should be added (se) 176 invalidateCache(); // zecke: I think this should be added (se)
171 return m_backEnd->reload(); 177 return m_backEnd->reload();
172} 178}
173template <class T> 179template <class T>
174bool OPimAccessTemplate<T>::save() { 180bool OPimAccessTemplate<T>::save() {
175 return m_backEnd->save(); 181 return m_backEnd->save();
176} 182}
177template <class T> 183template <class T>
178typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { 184typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const {
179 QArray<int> ints = m_backEnd->allRecords(); 185 QArray<int> ints = m_backEnd->allRecords();
180 List lis(ints, this ); 186 List lis(ints, this );
181 return lis; 187 return lis;
182} 188}
183template <class T> 189template <class T>
190typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const {
191 QArray<int> ints = m_backEnd->matchRegexp( r );
192 List lis(ints, this );
193 return lis;
194}
195template <class T>
184QArray<int> OPimAccessTemplate<T>::records()const { 196QArray<int> OPimAccessTemplate<T>::records()const {
185 return m_backEnd->allRecords(); 197 return m_backEnd->allRecords();
186} 198}
187template <class T> 199template <class T>
188typename OPimAccessTemplate<T>::List 200typename OPimAccessTemplate<T>::List
189OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { 201OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) {
190 QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); 202 QArray<int> ints = m_backEnd->queryByExample( t, settings, d );
191 203
192 List lis(ints, this ); 204 List lis(ints, this );
193 return lis; 205 return lis;
194} 206}
195template <class T> 207template <class T>
196T OPimAccessTemplate<T>::find( int uid ) const{ 208T OPimAccessTemplate<T>::find( int uid ) const{
197 T t = m_backEnd->find( uid ); 209 T t = m_backEnd->find( uid );
198 cache( t ); 210 cache( t );
199 return t; 211 return t;
200} 212}
201template <class T> 213template <class T>
202T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, 214T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
203 uint current, typename OTemplateBase<T>::CacheDirection dir )const { 215 uint current, typename OTemplateBase<T>::CacheDirection dir )const {
204 /* 216 /*
205 * better do T.isEmpty() 217 * better do T.isEmpty()
206 * after a find this way we would 218 * after a find this way we would
207 * avoid two finds in QCache... 219 * avoid two finds in QCache...
208 */ 220 */
209 // qWarning("find it now %d", uid ); 221 // qWarning("find it now %d", uid );
210 if (m_cache.contains( uid ) ) { 222 if (m_cache.contains( uid ) ) {
211 return m_cache.find( uid ); 223 return m_cache.find( uid );
212 } 224 }
213 225
214 T t = m_backEnd->find( uid, ar, current, dir ); 226 T t = m_backEnd->find( uid, ar, current, dir );
215 cache( t ); 227 cache( t );
216 return t; 228 return t;
217} 229}
218template <class T> 230template <class T>
219void OPimAccessTemplate<T>::clear() { 231void OPimAccessTemplate<T>::clear() {
220 invalidateCache(); 232 invalidateCache();
221 m_backEnd->clear(); 233 m_backEnd->clear();
222} 234}
223template <class T> 235template <class T>
224bool OPimAccessTemplate<T>::add( const T& t ) { 236bool OPimAccessTemplate<T>::add( const T& t ) {
225 cache( t ); 237 cache( t );
226 return m_backEnd->add( t ); 238 return m_backEnd->add( t );
227} 239}
228template <class T> 240template <class T>
229bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { 241bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
230 /* same type */ 242 /* same type */
231 if ( rec.rtti() == T::rtti() ) { 243 if ( rec.rtti() == T::rtti() ) {
diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h
index c7f9460..de2d9f4 100644
--- a/libopie/pim/opimrecord.h
+++ b/libopie/pim/opimrecord.h
@@ -28,96 +28,102 @@ public:
28 /** 28 /**
29 * copy c'tor 29 * copy c'tor
30 */ 30 */
31 OPimRecord( const OPimRecord& rec ); 31 OPimRecord( const OPimRecord& rec );
32 32
33 /** 33 /**
34 * copy operator 34 * copy operator
35 */ 35 */
36 OPimRecord &operator=( const OPimRecord& ); 36 OPimRecord &operator=( const OPimRecord& );
37 37
38 /** 38 /**
39 * category names resolved 39 * category names resolved
40 */ 40 */
41 QStringList categoryNames( const QString& appname )const; 41 QStringList categoryNames( const QString& appname )const;
42 42
43 /** 43 /**
44 * set category names they will be resolved 44 * set category names they will be resolved
45 */ 45 */
46 void setCategoryNames( const QStringList& ); 46 void setCategoryNames( const QStringList& );
47 47
48 /** 48 /**
49 * addCategoryName adds a name 49 * addCategoryName adds a name
50 * to the internal category list 50 * to the internal category list
51 */ 51 */
52 void addCategoryName( const QString& ); 52 void addCategoryName( const QString& );
53 53
54 /** 54 /**
55 * if a Record isEmpty 55 * if a Record isEmpty
56 * it's empty if it's 0 56 * it's empty if it's 0
57 */ 57 */
58 virtual bool isEmpty()const; 58 virtual bool isEmpty()const;
59 59
60 /** 60 /**
61 * toRichText summary 61 * toRichText summary
62 */ 62 */
63 virtual QString toRichText()const = 0; 63 virtual QString toRichText()const = 0;
64 64
65 /** 65 /**
66 * a small one line summary 66 * a small one line summary
67 */ 67 */
68 virtual QString toShortText()const = 0; 68 virtual QString toShortText()const = 0;
69 69
70 /** 70 /**
71 * the name of the Record 71 * the name of the Record
72 */ 72 */
73 virtual QString type()const = 0; 73 virtual QString type()const = 0;
74 74
75 /** 75 /**
76 * matches the Records the regular expression?
77 */
78 virtual bool match( const QString &regexp ) const {return match(QRegExp(regexp));};
79 virtual bool match( const QRegExp &regexp ) const = 0;
80
81 /**
76 * converts the internal structure to a map 82 * converts the internal structure to a map
77 */ 83 */
78 virtual QMap<int, QString> toMap()const = 0; 84 virtual QMap<int, QString> toMap()const = 0;
79 85
80 /** 86 /**
81 * key value representation of extra items 87 * key value representation of extra items
82 */ 88 */
83 virtual QMap<QString, QString> toExtraMap()const = 0; 89 virtual QMap<QString, QString> toExtraMap()const = 0;
84 90
85 /** 91 /**
86 * the name for a recordField 92 * the name for a recordField
87 */ 93 */
88 virtual QString recordField(int)const = 0; 94 virtual QString recordField(int)const = 0;
89 95
90 /** 96 /**
91 * returns a reference of the 97 * returns a reference of the
92 * Cross Reference Manager 98 * Cross Reference Manager
93 * Partner 'One' is THIS PIM RECORD! 99 * Partner 'One' is THIS PIM RECORD!
94 * 'Two' is the Partner where we link to 100 * 'Two' is the Partner where we link to
95 */ 101 */
96 OPimXRefManager& xrefmanager(); 102 OPimXRefManager& xrefmanager();
97 103
98 /** 104 /**
99 * set the uid 105 * set the uid
100 */ 106 */
101 virtual void setUid( int uid ); 107 virtual void setUid( int uid );
102 108
103 /* 109 /*
104 * used inside the Templates for casting 110 * used inside the Templates for casting
105 * REIMPLEMENT in your .... 111 * REIMPLEMENT in your ....
106 */ 112 */
107 static int rtti(); 113 static int rtti();
108 114
109 /** 115 /**
110 * some marshalling and de marshalling code 116 * some marshalling and de marshalling code
111 * saves the OPimRecord 117 * saves the OPimRecord
112 * to and from a DataStream 118 * to and from a DataStream
113 */ 119 */
114 virtual bool loadFromStream(QDataStream& ); 120 virtual bool loadFromStream(QDataStream& );
115 virtual bool saveToStream( QDataStream& stream )const; 121 virtual bool saveToStream( QDataStream& stream )const;
116 122
117protected: 123protected:
118 Qtopia::UidGen &uidGen(); 124 Qtopia::UidGen &uidGen();
119// QString crossToString()const; 125// QString crossToString()const;
120 126
121private: 127private:
122 class OPimRecordPrivate; 128 class OPimRecordPrivate;
123 OPimRecordPrivate *d; 129 OPimRecordPrivate *d;
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h
index a58d9aa..0e7c73f 100644
--- a/libopie/pim/otodo.h
+++ b/libopie/pim/otodo.h
@@ -213,77 +213,77 @@ public:
213 /** 213 /**
214 * Set the priority of the Todo 214 * Set the priority of the Todo
215 */ 215 */
216 void setPriority(int priority ); 216 void setPriority(int priority );
217 217
218 /** 218 /**
219 * Set the progress. 219 * Set the progress.
220 */ 220 */
221 void setProgress( ushort progress ); 221 void setProgress( ushort progress );
222 222
223 /** 223 /**
224 * set the end date 224 * set the end date
225 */ 225 */
226 void setDueDate( const QDate& date ); 226 void setDueDate( const QDate& date );
227 227
228 /** 228 /**
229 * set the start date 229 * set the start date
230 */ 230 */
231 void setStartDate( const QDate& date ); 231 void setStartDate( const QDate& date );
232 232
233 /** 233 /**
234 * set the completed date 234 * set the completed date
235 */ 235 */
236 void setCompletedDate( const QDate& date ); 236 void setCompletedDate( const QDate& date );
237 237
238 void setRecurrence( const ORecur& ); 238 void setRecurrence( const ORecur& );
239 /** 239 /**
240 * set the alarm time 240 * set the alarm time
241 */ 241 */
242 void setAlarmDateTime ( const QDateTime& alarm ); 242 void setAlarmDateTime ( const QDateTime& alarm );
243 243
244 void setDescription(const QString& ); 244 void setDescription(const QString& );
245 void setSummary(const QString& ); 245 void setSummary(const QString& );
246 246
247 /** 247 /**
248 * set the state of a Todo 248 * set the state of a Todo
249 * @param state State what the todo should take 249 * @param state State what the todo should take
250 */ 250 */
251 void setState( const OPimState& state); 251 void setState( const OPimState& state);
252 252
253 /** 253 /**
254 * set the Maintainer Mode 254 * set the Maintainer Mode
255 */ 255 */
256 void setMaintainer( const OPimMaintainer& ); 256 void setMaintainer( const OPimMaintainer& );
257 257
258 bool isOverdue(); 258 bool isOverdue();
259 259
260 260
261 bool match( const QRegExp &r )const; 261 virtual bool match( const QRegExp &r )const;
262 262
263 bool operator<(const OTodo &toDoEvent )const; 263 bool operator<(const OTodo &toDoEvent )const;
264 bool operator<=(const OTodo &toDoEvent )const; 264 bool operator<=(const OTodo &toDoEvent )const;
265 bool operator!=(const OTodo &toDoEvent )const; 265 bool operator!=(const OTodo &toDoEvent )const;
266 bool operator>(const OTodo &toDoEvent )const; 266 bool operator>(const OTodo &toDoEvent )const;
267 bool operator>=(const OTodo &toDoEvent)const; 267 bool operator>=(const OTodo &toDoEvent)const;
268 bool operator==(const OTodo &toDoEvent )const; 268 bool operator==(const OTodo &toDoEvent )const;
269 OTodo &operator=(const OTodo &toDoEvent ); 269 OTodo &operator=(const OTodo &toDoEvent );
270 270
271 static int rtti(); 271 static int rtti();
272 272
273 private: 273 private:
274 class OTodoPrivate; 274 class OTodoPrivate;
275 struct OTodoData; 275 struct OTodoData;
276 276
277 void deref(); 277 void deref();
278 inline void changeOrModify(); 278 inline void changeOrModify();
279 void copy( OTodoData* src, OTodoData* dest ); 279 void copy( OTodoData* src, OTodoData* dest );
280 OTodoPrivate *d; 280 OTodoPrivate *d;
281 OTodoData *data; 281 OTodoData *data;
282 282
283}; 283};
284inline bool OTodo::operator!=(const OTodo &toDoEvent )const { 284inline bool OTodo::operator!=(const OTodo &toDoEvent )const {
285 return !(*this == toDoEvent); 285 return !(*this == toDoEvent);
286} 286}
287 287
288 288
289#endif 289#endif
diff --git a/libopie/pim/otodoaccessvcal.cpp b/libopie/pim/otodoaccessvcal.cpp
index 9bc16c6..3577e14 100644
--- a/libopie/pim/otodoaccessvcal.cpp
+++ b/libopie/pim/otodoaccessvcal.cpp
@@ -140,82 +140,86 @@ bool OTodoAccessVCal::save() {
140 cleanVObject( obj ); 140 cleanVObject( obj );
141 cleanStrTbl(); 141 cleanStrTbl();
142 142
143 m_dirty = false; 143 m_dirty = false;
144 return true; 144 return true;
145} 145}
146void OTodoAccessVCal::clear() { 146void OTodoAccessVCal::clear() {
147 m_map.clear(); 147 m_map.clear();
148 m_dirty = true; 148 m_dirty = true;
149} 149}
150bool OTodoAccessVCal::add( const OTodo& to ) { 150bool OTodoAccessVCal::add( const OTodo& to ) {
151 m_map.insert( to.uid(), to ); 151 m_map.insert( to.uid(), to );
152 m_dirty = true; 152 m_dirty = true;
153 return true; 153 return true;
154} 154}
155bool OTodoAccessVCal::remove( int uid ) { 155bool OTodoAccessVCal::remove( int uid ) {
156 m_map.remove( uid ); 156 m_map.remove( uid );
157 m_dirty = true; 157 m_dirty = true;
158 return true; 158 return true;
159} 159}
160void OTodoAccessVCal::removeAllCompleted() { 160void OTodoAccessVCal::removeAllCompleted() {
161 for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { 161 for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) {
162 if ( (*it).isCompleted() ) 162 if ( (*it).isCompleted() )
163 m_map.remove( it ); 163 m_map.remove( it );
164 } 164 }
165} 165}
166bool OTodoAccessVCal::replace( const OTodo& to ) { 166bool OTodoAccessVCal::replace( const OTodo& to ) {
167 m_map.replace( to.uid(), to ); 167 m_map.replace( to.uid(), to );
168 m_dirty = true; 168 m_dirty = true;
169 return true; 169 return true;
170} 170}
171OTodo OTodoAccessVCal::find(int uid )const { 171OTodo OTodoAccessVCal::find(int uid )const {
172 return m_map[uid]; 172 return m_map[uid];
173} 173}
174QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { 174QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) {
175 QArray<int> ar(0); 175 QArray<int> ar(0);
176 return ar; 176 return ar;
177} 177}
178QArray<int> OTodoAccessVCal::allRecords()const { 178QArray<int> OTodoAccessVCal::allRecords()const {
179 QArray<int> ar( m_map.count() ); 179 QArray<int> ar( m_map.count() );
180 QMap<int, OTodo>::ConstIterator it; 180 QMap<int, OTodo>::ConstIterator it;
181 int i = 0; 181 int i = 0;
182 for ( it = m_map.begin(); it != m_map.end(); ++it ) { 182 for ( it = m_map.begin(); it != m_map.end(); ++it ) {
183 ar[i] = it.key(); 183 ar[i] = it.key();
184 i++; 184 i++;
185 } 185 }
186 return ar; 186 return ar;
187} 187}
188QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp &r)const {
189 QArray<int> ar(0);
190 return ar;
191}
188QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { 192QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) {
189 QArray<int> ar(0); 193 QArray<int> ar(0);
190 return ar; 194 return ar;
191} 195}
192QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , 196QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& ,
193 const QDate& , 197 const QDate& ,
194 bool ) { 198 bool ) {
195 QArray<int> ar(0); 199 QArray<int> ar(0);
196 return ar; 200 return ar;
197} 201}
198QArray<int> OTodoAccessVCal::overDue() { 202QArray<int> OTodoAccessVCal::overDue() {
199 QArray<int> ar(0); 203 QArray<int> ar(0);
200 return ar; 204 return ar;
201} 205}
202QBitArray OTodoAccessVCal::supports()const { 206QBitArray OTodoAccessVCal::supports()const {
203 static QBitArray ar = sup(); 207 static QBitArray ar = sup();
204 208
205 return ar; 209 return ar;
206} 210}
207QBitArray OTodoAccessVCal::sup() { 211QBitArray OTodoAccessVCal::sup() {
208 QBitArray ar ( OTodo::CompletedDate +1 ); 212 QBitArray ar ( OTodo::CompletedDate +1 );
209 ar.fill( true ); 213 ar.fill( true );
210 214
211 ar[OTodo::CrossReference] = false; 215 ar[OTodo::CrossReference] = false;
212 ar[OTodo::State ] = false; 216 ar[OTodo::State ] = false;
213 ar[OTodo::Reminders] = false; 217 ar[OTodo::Reminders] = false;
214 ar[OTodo::Notifiers] = false; 218 ar[OTodo::Notifiers] = false;
215 ar[OTodo::Maintainer] = false; 219 ar[OTodo::Maintainer] = false;
216 ar[OTodo::Progress] = false; 220 ar[OTodo::Progress] = false;
217 ar[OTodo::Alarms ] = false; 221 ar[OTodo::Alarms ] = false;
218 ar[OTodo::Recurrence] = false; 222 ar[OTodo::Recurrence] = false;
219 223
220 return ar; 224 return ar;
221} 225}
diff --git a/libopie/pim/otodoaccessvcal.h b/libopie/pim/otodoaccessvcal.h
index 489416b..2b17147 100644
--- a/libopie/pim/otodoaccessvcal.h
+++ b/libopie/pim/otodoaccessvcal.h
@@ -1,39 +1,40 @@
1#ifndef OPIE_OTODO_ACCESS_VCAL_H 1#ifndef OPIE_OTODO_ACCESS_VCAL_H
2#define OPIE_OTODO_ACCESS_VCAL_H 2#define OPIE_OTODO_ACCESS_VCAL_H
3 3
4#include "otodoaccessbackend.h" 4#include "otodoaccessbackend.h"
5 5
6class OTodoAccessVCal : public OTodoAccessBackend { 6class OTodoAccessVCal : public OTodoAccessBackend {
7public: 7public:
8 OTodoAccessVCal(const QString& ); 8 OTodoAccessVCal(const QString& );
9 ~OTodoAccessVCal(); 9 ~OTodoAccessVCal();
10 10
11 bool load(); 11 bool load();
12 bool reload(); 12 bool reload();
13 bool save(); 13 bool save();
14 14
15 QArray<int> allRecords()const; 15 QArray<int> allRecords()const;
16 QArray<int> matchRegexp(const QRegExp &r) const;
16 QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() ); 17 QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() );
17 QArray<int> effectiveToDos( const QDate& start, 18 QArray<int> effectiveToDos( const QDate& start,
18 const QDate& end, 19 const QDate& end,
19 bool includeNoDates ); 20 bool includeNoDates );
20 QArray<int> overDue(); 21 QArray<int> overDue();
21 QArray<int> sorted( bool asc, int sortOrder, int sortFilter, 22 QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
22 int cat ); 23 int cat );
23 OTodo find(int uid)const; 24 OTodo find(int uid)const;
24 void clear(); 25 void clear();
25 bool add( const OTodo& ); 26 bool add( const OTodo& );
26 bool remove( int uid ); 27 bool remove( int uid );
27 bool replace( const OTodo& ); 28 bool replace( const OTodo& );
28 29
29 void removeAllCompleted(); 30 void removeAllCompleted();
30 virtual QBitArray supports()const; 31 virtual QBitArray supports()const;
31 32
32private: 33private:
33 static QBitArray sup(); 34 static QBitArray sup();
34 bool m_dirty : 1; 35 bool m_dirty : 1;
35 QString m_file; 36 QString m_file;
36 QMap<int, OTodo> m_map; 37 QMap<int, OTodo> m_map;
37}; 38};
38 39
39#endif 40#endif
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp
index 285d2b8..69b7ab4 100644
--- a/libopie/pim/otodoaccessxml.cpp
+++ b/libopie/pim/otodoaccessxml.cpp
@@ -729,48 +729,64 @@ QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder,
729 if ( !(*it).isOverdue() && bOnly ) { 729 if ( !(*it).isOverdue() && bOnly ) {
730 qWarning("item is not overdue but bOnly checked"); 730 qWarning("item is not overdue but bOnly checked");
731 continue; 731 continue;
732 } 732 }
733 733
734 if ((*it).isCompleted() && comp ) { 734 if ((*it).isCompleted() && comp ) {
735 qWarning("completed continue!"); 735 qWarning("completed continue!");
736 continue; 736 continue;
737 } 737 }
738 738
739 739
740 OTodoXMLContainer* con = new OTodoXMLContainer(); 740 OTodoXMLContainer* con = new OTodoXMLContainer();
741 con->todo = (*it); 741 con->todo = (*it);
742 vector.insert(item, con ); 742 vector.insert(item, con );
743 item++; 743 item++;
744 } 744 }
745 qWarning("XXX %d Items added", item); 745 qWarning("XXX %d Items added", item);
746 vector.resize( item ); 746 vector.resize( item );
747 /* sort it now */ 747 /* sort it now */
748 vector.sort(); 748 vector.sort();
749 /* now get the uids */ 749 /* now get the uids */
750 QArray<int> array( vector.count() ); 750 QArray<int> array( vector.count() );
751 for (uint i= 0; i < vector.count(); i++ ) { 751 for (uint i= 0; i < vector.count(); i++ ) {
752 array[i] = ( vector.at(i) )->todo.uid(); 752 array[i] = ( vector.at(i) )->todo.uid();
753 } 753 }
754 return array; 754 return array;
755}; 755};
756void OTodoAccessXML::removeAllCompleted() { 756void OTodoAccessXML::removeAllCompleted() {
757 for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { 757 for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) {
758 if ( (*it).isCompleted() ) 758 if ( (*it).isCompleted() )
759 m_events.remove( it ); 759 m_events.remove( it );
760 } 760 }
761} 761}
762QBitArray OTodoAccessXML::supports()const { 762QBitArray OTodoAccessXML::supports()const {
763 static QBitArray ar = sup(); 763 static QBitArray ar = sup();
764 return ar; 764 return ar;
765} 765}
766QBitArray OTodoAccessXML::sup() { 766QBitArray OTodoAccessXML::sup() {
767 QBitArray ar( OTodo::CompletedDate +1 ); 767 QBitArray ar( OTodo::CompletedDate +1 );
768 ar.fill( true ); 768 ar.fill( true );
769 ar[OTodo::CrossReference] = false; 769 ar[OTodo::CrossReference] = false;
770 ar[OTodo::State ] = false; 770 ar[OTodo::State ] = false;
771 ar[OTodo::Reminders] = false; 771 ar[OTodo::Reminders] = false;
772 ar[OTodo::Notifiers] = false; 772 ar[OTodo::Notifiers] = false;
773 ar[OTodo::Maintainer] = false; 773 ar[OTodo::Maintainer] = false;
774 774
775 return ar; 775 return ar;
776} 776}
777QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const
778{
779 QArray<int> m_currentQuery( m_events.count() );
780 uint arraycounter = 0;
781
782 QMap<int, OTodo>::ConstIterator it;
783 for (it = m_events.begin(); it != m_events.end(); ++it ) {
784 if ( it.data().match( r ) )
785 m_currentQuery[arraycounter++] = it.data().uid();
786
787 }
788 // Shrink to fit..
789 m_currentQuery.resize(arraycounter);
790
791 return m_currentQuery;
792}
diff --git a/libopie/pim/otodoaccessxml.h b/libopie/pim/otodoaccessxml.h
index cc4a16f..e4850a1 100644
--- a/libopie/pim/otodoaccessxml.h
+++ b/libopie/pim/otodoaccessxml.h
@@ -1,59 +1,60 @@
1#ifndef OPIE_TODO_ACCESS_XML_H 1#ifndef OPIE_TODO_ACCESS_XML_H
2#define OPIE_TODO_ACCESS_XML_H 2#define OPIE_TODO_ACCESS_XML_H
3 3
4#include <qasciidict.h> 4#include <qasciidict.h>
5#include <qmap.h> 5#include <qmap.h>
6 6
7#include "otodoaccessbackend.h" 7#include "otodoaccessbackend.h"
8 8
9namespace Opie { 9namespace Opie {
10 class XMLElement; 10 class XMLElement;
11}; 11};
12 12
13class OTodoAccessXML : public OTodoAccessBackend { 13class OTodoAccessXML : public OTodoAccessBackend {
14public: 14public:
15 /** 15 /**
16 * fileName if Empty we will use the default path 16 * fileName if Empty we will use the default path
17 */ 17 */
18 OTodoAccessXML( const QString& appName, 18 OTodoAccessXML( const QString& appName,
19 const QString& fileName = QString::null ); 19 const QString& fileName = QString::null );
20 ~OTodoAccessXML(); 20 ~OTodoAccessXML();
21 21
22 bool load(); 22 bool load();
23 bool reload(); 23 bool reload();
24 bool save(); 24 bool save();
25 25
26 QArray<int> allRecords()const; 26 QArray<int> allRecords()const;
27 QArray<int> matchRegexp(const QRegExp &r) const;
27 QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() ); 28 QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() );
28 OTodo find( int uid )const; 29 OTodo find( int uid )const;
29 void clear(); 30 void clear();
30 bool add( const OTodo& ); 31 bool add( const OTodo& );
31 bool remove( int uid ); 32 bool remove( int uid );
32 void removeAllCompleted(); 33 void removeAllCompleted();
33 bool replace( const OTodo& ); 34 bool replace( const OTodo& );
34 35
35 /* our functions */ 36 /* our functions */
36 QArray<int> effectiveToDos( const QDate& start, 37 QArray<int> effectiveToDos( const QDate& start,
37 const QDate& end, 38 const QDate& end,
38 bool includeNoDates ); 39 bool includeNoDates );
39 QArray<int> overDue(); 40 QArray<int> overDue();
40 QArray<int> sorted( bool asc, int sortOrder, 41 QArray<int> sorted( bool asc, int sortOrder,
41 int sortFilter, int cat ); 42 int sortFilter, int cat );
42 QBitArray supports()const; 43 QBitArray supports()const;
43private: 44private:
44 static QBitArray sup(); 45 static QBitArray sup();
45 void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& ); 46 void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& );
46 QString toString( const OTodo& )const; 47 QString toString( const OTodo& )const;
47 QString toString( const QArray<int>& ints ) const; 48 QString toString( const QArray<int>& ints ) const;
48 QMap<int, OTodo> m_events; 49 QMap<int, OTodo> m_events;
49 QString m_file; 50 QString m_file;
50 QString m_app; 51 QString m_app;
51 bool m_opened : 1; 52 bool m_opened : 1;
52 bool m_changed : 1; 53 bool m_changed : 1;
53 class OTodoAccessXMLPrivate; 54 class OTodoAccessXMLPrivate;
54 OTodoAccessXMLPrivate* d; 55 OTodoAccessXMLPrivate* d;
55 int m_year, m_month, m_day; 56 int m_year, m_month, m_day;
56 57
57}; 58};
58 59
59#endif 60#endif
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
index a0ae7b7..ab2eea4 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
@@ -541,48 +541,66 @@ void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& val
541 case FRHasEndDate: 541 case FRHasEndDate:
542 recur()->setHasEndDate( value.toInt() ); 542 recur()->setHasEndDate( value.toInt() );
543 break; 543 break;
544 case FREndDate: { 544 case FREndDate: {
545 rp_end = (time_t) value.toLong(); 545 rp_end = (time_t) value.toLong();
546 break; 546 break;
547 } 547 }
548 case FRStart: { 548 case FRStart: {
549 start = (time_t) value.toLong(); 549 start = (time_t) value.toLong();
550 break; 550 break;
551 } 551 }
552 case FREnd: { 552 case FREnd: {
553 end = ( (time_t) value.toLong() ); 553 end = ( (time_t) value.toLong() );
554 break; 554 break;
555 } 555 }
556 case FNote: 556 case FNote:
557 e.setNote( value ); 557 e.setNote( value );
558 break; 558 break;
559 case FCreated: 559 case FCreated:
560 created = value.toInt(); 560 created = value.toInt();
561 break; 561 break;
562 case FRecParent: 562 case FRecParent:
563 e.setParent( value.toInt() ); 563 e.setParent( value.toInt() );
564 break; 564 break;
565 case FRecChildren:{ 565 case FRecChildren:{
566 QStringList list = QStringList::split(' ', value ); 566 QStringList list = QStringList::split(' ', value );
567 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 567 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
568 e.addChild( (*it).toInt() ); 568 e.addChild( (*it).toInt() );
569 } 569 }
570 } 570 }
571 break; 571 break;
572 case FExceptions:{ 572 case FExceptions:{
573 QStringList list = QStringList::split(' ', value ); 573 QStringList list = QStringList::split(' ', value );
574 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 574 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
575 QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() ); 575 QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() );
576 qWarning("adding exception %s", date.toString().latin1() ); 576 qWarning("adding exception %s", date.toString().latin1() );
577 recur()->exceptions().append( date ); 577 recur()->exceptions().append( date );
578 } 578 }
579 } 579 }
580 break; 580 break;
581 case FTimeZone: 581 case FTimeZone:
582 if ( value != "None" ) 582 if ( value != "None" )
583 e.setTimeZone( value ); 583 e.setTimeZone( value );
584 break; 584 break;
585 default: 585 default:
586 break; 586 break;
587 } 587 }
588} 588}
589QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const
590{
591 QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() );
592 uint arraycounter = 0;
593 QMap<int, OEvent>::ConstIterator it;
594
595 for ( it = m_raw.begin(); it != m_raw.end(); ++it )
596 if ( it.data().match( r ) )
597 m_currentQuery[arraycounter++] = it.data().uid();
598 for ( it = m_rep.begin(); it != m_rep.end(); ++it )
599 if ( it.data().match( r ) )
600 m_currentQuery[arraycounter++] = it.data().uid();
601
602 // Shrink to fit..
603 m_currentQuery.resize(arraycounter);
604
605 return m_currentQuery;
606}
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
index 7848f7c..a5cc0fc 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
@@ -1,54 +1,55 @@
1#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H 1#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H
2#define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H 2#define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H
3 3
4#include <qmap.h> 4#include <qmap.h>
5 5
6#include "odatebookaccessbackend.h" 6#include "odatebookaccessbackend.h"
7 7
8/** 8/**
9 * This is the default XML implementation for DateBoook XML storage 9 * This is the default XML implementation for DateBoook XML storage
10 * It fully implements the interface 10 * It fully implements the interface
11 * @see ODateBookAccessBackend 11 * @see ODateBookAccessBackend
12 * @see OPimAccessBackend 12 * @see OPimAccessBackend
13 */ 13 */
14class ODateBookAccessBackend_XML : public ODateBookAccessBackend { 14class ODateBookAccessBackend_XML : public ODateBookAccessBackend {
15public: 15public:
16 ODateBookAccessBackend_XML( const QString& appName, 16 ODateBookAccessBackend_XML( const QString& appName,
17 const QString& fileName = QString::null); 17 const QString& fileName = QString::null);
18 ~ODateBookAccessBackend_XML(); 18 ~ODateBookAccessBackend_XML();
19 19
20 bool load(); 20 bool load();
21 bool reload(); 21 bool reload();
22 bool save(); 22 bool save();
23 23
24 QArray<int> allRecords()const; 24 QArray<int> allRecords()const;
25 QArray<int> matchRegexp(const QRegExp &r) const;
25 QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); 26 QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() );
26 OEvent find( int uid )const; 27 OEvent find( int uid )const;
27 void clear(); 28 void clear();
28 bool add( const OEvent& ev ); 29 bool add( const OEvent& ev );
29 bool remove( int uid ); 30 bool remove( int uid );
30 bool replace( const OEvent& ev ); 31 bool replace( const OEvent& ev );
31 32
32 QArray<UID> rawEvents()const; 33 QArray<UID> rawEvents()const;
33 QArray<UID> rawRepeats()const; 34 QArray<UID> rawRepeats()const;
34 QArray<UID> nonRepeats()const; 35 QArray<UID> nonRepeats()const;
35 36
36 OEvent::ValueList directNonRepeats(); 37 OEvent::ValueList directNonRepeats();
37 OEvent::ValueList directRawRepeats(); 38 OEvent::ValueList directRawRepeats();
38 39
39private: 40private:
40 bool m_changed :1 ; 41 bool m_changed :1 ;
41 bool loadFile(); 42 bool loadFile();
42 inline void finalizeRecord( OEvent& ev ); 43 inline void finalizeRecord( OEvent& ev );
43 inline void setField( OEvent&, int field, const QString& val ); 44 inline void setField( OEvent&, int field, const QString& val );
44 QString m_name; 45 QString m_name;
45 QMap<int, OEvent> m_raw; 46 QMap<int, OEvent> m_raw;
46 QMap<int, OEvent> m_rep; 47 QMap<int, OEvent> m_rep;
47 48
48 struct Data; 49 struct Data;
49 Data* data; 50 Data* data;
50 class Private; 51 class Private;
51 Private *d; 52 Private *d;
52}; 53};
53 54
54#endif 55#endif
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h
index 01a0c86..f4bbe35 100644
--- a/libopie2/opiepim/backend/opimaccessbackend.h
+++ b/libopie2/opiepim/backend/opimaccessbackend.h
@@ -1,96 +1,102 @@
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
10/** 10/**
11 * OPimAccessBackend is the base class 11 * OPimAccessBackend is the base class
12 * for all private backends 12 * for all private backends
13 * it operates on OPimRecord as the base class 13 * it operates on OPimRecord as the base class
14 * and it's responsible for fast manipulating 14 * and it's responsible for fast manipulating
15 * the resource the implementation takes care 15 * the resource the implementation takes care
16 * of 16 * of
17 */ 17 */
18template <class T = OPimRecord> 18template <class T = OPimRecord>
19class OPimAccessBackend { 19class OPimAccessBackend {
20public: 20public:
21 typedef OTemplateBase<T> Frontend; 21 typedef OTemplateBase<T> Frontend;
22 22
23 /** The access hint from the frontend */ 23 /** The access hint from the frontend */
24 OPimAccessBackend(int access = 0); 24 OPimAccessBackend(int access = 0);
25 virtual ~OPimAccessBackend(); 25 virtual ~OPimAccessBackend();
26 26
27 /** 27 /**
28 * load the resource 28 * load the resource
29 */ 29 */
30 virtual bool load() = 0; 30 virtual bool load() = 0;
31 31
32 /** 32 /**
33 * reload the resource 33 * reload the resource
34 */ 34 */
35 virtual bool reload() = 0; 35 virtual bool reload() = 0;
36 36
37 /** 37 /**
38 * save the resource and 38 * save the resource and
39 * all it's changes 39 * all it's changes
40 */ 40 */
41 virtual bool save() = 0; 41 virtual bool save() = 0;
42 42
43 /** 43 /**
44 * return an array of 44 * return an array of
45 * all available uids 45 * all available uids
46 */ 46 */
47 virtual QArray<int> allRecords()const = 0; 47 virtual QArray<int> allRecords()const = 0;
48 48
49 /**
50 * return a List of records
51 * that match the regex
52 */
53 virtual QArray<int> matchRegexp(const QRegExp &r) const = 0;
54
49 /** 55 /**
50 * queryByExample for T with the given Settings 56 * queryByExample for T with the given Settings
51 * 57 *
52 */ 58 */
53 virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; 59 virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0;
54 60
55 /** 61 /**
56 * find the OPimRecord with uid @param uid 62 * find the OPimRecord with uid @param uid
57 * returns T and T.isEmpty() if nothing was found 63 * returns T and T.isEmpty() if nothing was found
58 */ 64 */
59 virtual T find(int uid )const = 0; 65 virtual T find(int uid )const = 0;
60 66
61 virtual T find(int uid, const QArray<int>& items, 67 virtual T find(int uid, const QArray<int>& items,
62 uint current, typename Frontend::CacheDirection )const ; 68 uint current, typename Frontend::CacheDirection )const ;
63 /** 69 /**
64 * clear the back end 70 * clear the back end
65 */ 71 */
66 virtual void clear() = 0; 72 virtual void clear() = 0;
67 73
68 /** 74 /**
69 * add T 75 * add T
70 */ 76 */
71 virtual bool add( const T& t ) = 0; 77 virtual bool add( const T& t ) = 0;
72 78
73 /** 79 /**
74 * remove 80 * remove
75 */ 81 */
76 virtual bool remove( int uid ) = 0; 82 virtual bool remove( int uid ) = 0;
77 83
78 /** 84 /**
79 * replace a record with T.uid() 85 * replace a record with T.uid()
80 */ 86 */
81 virtual bool replace( const T& t ) = 0; 87 virtual bool replace( const T& t ) = 0;
82 88
83 /* 89 /*
84 * setTheFrontEnd!!! 90 * setTheFrontEnd!!!
85 */ 91 */
86 void setFrontend( Frontend* front ); 92 void setFrontend( Frontend* front );
87 93
88 /** 94 /**
89 * set the read ahead count 95 * set the read ahead count
90 */ 96 */
91 void setReadAhead( uint count ); 97 void setReadAhead( uint count );
92protected: 98protected:
93 int access()const; 99 int access()const;
94 void cache( const T& t )const; 100 void cache( const T& t )const;
95 101
96 /** 102 /**
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp
index 9bc16c6..3577e14 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.cpp
+++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp
@@ -140,82 +140,86 @@ bool OTodoAccessVCal::save() {
140 cleanVObject( obj ); 140 cleanVObject( obj );
141 cleanStrTbl(); 141 cleanStrTbl();
142 142
143 m_dirty = false; 143 m_dirty = false;
144 return true; 144 return true;
145} 145}
146void OTodoAccessVCal::clear() { 146void OTodoAccessVCal::clear() {
147 m_map.clear(); 147 m_map.clear();
148 m_dirty = true; 148 m_dirty = true;
149} 149}
150bool OTodoAccessVCal::add( const OTodo& to ) { 150bool OTodoAccessVCal::add( const OTodo& to ) {
151 m_map.insert( to.uid(), to ); 151 m_map.insert( to.uid(), to );
152 m_dirty = true; 152 m_dirty = true;
153 return true; 153 return true;
154} 154}
155bool OTodoAccessVCal::remove( int uid ) { 155bool OTodoAccessVCal::remove( int uid ) {
156 m_map.remove( uid ); 156 m_map.remove( uid );
157 m_dirty = true; 157 m_dirty = true;
158 return true; 158 return true;
159} 159}
160void OTodoAccessVCal::removeAllCompleted() { 160void OTodoAccessVCal::removeAllCompleted() {
161 for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { 161 for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) {
162 if ( (*it).isCompleted() ) 162 if ( (*it).isCompleted() )
163 m_map.remove( it ); 163 m_map.remove( it );
164 } 164 }
165} 165}
166bool OTodoAccessVCal::replace( const OTodo& to ) { 166bool OTodoAccessVCal::replace( const OTodo& to ) {
167 m_map.replace( to.uid(), to ); 167 m_map.replace( to.uid(), to );
168 m_dirty = true; 168 m_dirty = true;
169 return true; 169 return true;
170} 170}
171OTodo OTodoAccessVCal::find(int uid )const { 171OTodo OTodoAccessVCal::find(int uid )const {
172 return m_map[uid]; 172 return m_map[uid];
173} 173}
174QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { 174QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) {
175 QArray<int> ar(0); 175 QArray<int> ar(0);
176 return ar; 176 return ar;
177} 177}
178QArray<int> OTodoAccessVCal::allRecords()const { 178QArray<int> OTodoAccessVCal::allRecords()const {
179 QArray<int> ar( m_map.count() ); 179 QArray<int> ar( m_map.count() );
180 QMap<int, OTodo>::ConstIterator it; 180 QMap<int, OTodo>::ConstIterator it;
181 int i = 0; 181 int i = 0;
182 for ( it = m_map.begin(); it != m_map.end(); ++it ) { 182 for ( it = m_map.begin(); it != m_map.end(); ++it ) {
183 ar[i] = it.key(); 183 ar[i] = it.key();
184 i++; 184 i++;
185 } 185 }
186 return ar; 186 return ar;
187} 187}
188QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp &r)const {
189 QArray<int> ar(0);
190 return ar;
191}
188QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { 192QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) {
189 QArray<int> ar(0); 193 QArray<int> ar(0);
190 return ar; 194 return ar;
191} 195}
192QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , 196QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& ,
193 const QDate& , 197 const QDate& ,
194 bool ) { 198 bool ) {
195 QArray<int> ar(0); 199 QArray<int> ar(0);
196 return ar; 200 return ar;
197} 201}
198QArray<int> OTodoAccessVCal::overDue() { 202QArray<int> OTodoAccessVCal::overDue() {
199 QArray<int> ar(0); 203 QArray<int> ar(0);
200 return ar; 204 return ar;
201} 205}
202QBitArray OTodoAccessVCal::supports()const { 206QBitArray OTodoAccessVCal::supports()const {
203 static QBitArray ar = sup(); 207 static QBitArray ar = sup();
204 208
205 return ar; 209 return ar;
206} 210}
207QBitArray OTodoAccessVCal::sup() { 211QBitArray OTodoAccessVCal::sup() {
208 QBitArray ar ( OTodo::CompletedDate +1 ); 212 QBitArray ar ( OTodo::CompletedDate +1 );
209 ar.fill( true ); 213 ar.fill( true );
210 214
211 ar[OTodo::CrossReference] = false; 215 ar[OTodo::CrossReference] = false;
212 ar[OTodo::State ] = false; 216 ar[OTodo::State ] = false;
213 ar[OTodo::Reminders] = false; 217 ar[OTodo::Reminders] = false;
214 ar[OTodo::Notifiers] = false; 218 ar[OTodo::Notifiers] = false;
215 ar[OTodo::Maintainer] = false; 219 ar[OTodo::Maintainer] = false;
216 ar[OTodo::Progress] = false; 220 ar[OTodo::Progress] = false;
217 ar[OTodo::Alarms ] = false; 221 ar[OTodo::Alarms ] = false;
218 ar[OTodo::Recurrence] = false; 222 ar[OTodo::Recurrence] = false;
219 223
220 return ar; 224 return ar;
221} 225}
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.h b/libopie2/opiepim/backend/otodoaccessvcal.h
index 489416b..2b17147 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.h
+++ b/libopie2/opiepim/backend/otodoaccessvcal.h
@@ -1,39 +1,40 @@
1#ifndef OPIE_OTODO_ACCESS_VCAL_H 1#ifndef OPIE_OTODO_ACCESS_VCAL_H
2#define OPIE_OTODO_ACCESS_VCAL_H 2#define OPIE_OTODO_ACCESS_VCAL_H
3 3
4#include "otodoaccessbackend.h" 4#include "otodoaccessbackend.h"
5 5
6class OTodoAccessVCal : public OTodoAccessBackend { 6class OTodoAccessVCal : public OTodoAccessBackend {
7public: 7public:
8 OTodoAccessVCal(const QString& ); 8 OTodoAccessVCal(const QString& );
9 ~OTodoAccessVCal(); 9 ~OTodoAccessVCal();
10 10
11 bool load(); 11 bool load();
12 bool reload(); 12 bool reload();
13 bool save(); 13 bool save();
14 14
15 QArray<int> allRecords()const; 15 QArray<int> allRecords()const;
16 QArray<int> matchRegexp(const QRegExp &r) const;
16 QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() ); 17 QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() );
17 QArray<int> effectiveToDos( const QDate& start, 18 QArray<int> effectiveToDos( const QDate& start,
18 const QDate& end, 19 const QDate& end,
19 bool includeNoDates ); 20 bool includeNoDates );
20 QArray<int> overDue(); 21 QArray<int> overDue();
21 QArray<int> sorted( bool asc, int sortOrder, int sortFilter, 22 QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
22 int cat ); 23 int cat );
23 OTodo find(int uid)const; 24 OTodo find(int uid)const;
24 void clear(); 25 void clear();
25 bool add( const OTodo& ); 26 bool add( const OTodo& );
26 bool remove( int uid ); 27 bool remove( int uid );
27 bool replace( const OTodo& ); 28 bool replace( const OTodo& );
28 29
29 void removeAllCompleted(); 30 void removeAllCompleted();
30 virtual QBitArray supports()const; 31 virtual QBitArray supports()const;
31 32
32private: 33private:
33 static QBitArray sup(); 34 static QBitArray sup();
34 bool m_dirty : 1; 35 bool m_dirty : 1;
35 QString m_file; 36 QString m_file;
36 QMap<int, OTodo> m_map; 37 QMap<int, OTodo> m_map;
37}; 38};
38 39
39#endif 40#endif
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index 285d2b8..69b7ab4 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -729,48 +729,64 @@ QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder,
729 if ( !(*it).isOverdue() && bOnly ) { 729 if ( !(*it).isOverdue() && bOnly ) {
730 qWarning("item is not overdue but bOnly checked"); 730 qWarning("item is not overdue but bOnly checked");
731 continue; 731 continue;
732 } 732 }
733 733
734 if ((*it).isCompleted() && comp ) { 734 if ((*it).isCompleted() && comp ) {
735 qWarning("completed continue!"); 735 qWarning("completed continue!");
736 continue; 736 continue;
737 } 737 }
738 738
739 739
740 OTodoXMLContainer* con = new OTodoXMLContainer(); 740 OTodoXMLContainer* con = new OTodoXMLContainer();
741 con->todo = (*it); 741 con->todo = (*it);
742 vector.insert(item, con ); 742 vector.insert(item, con );
743 item++; 743 item++;
744 } 744 }
745 qWarning("XXX %d Items added", item); 745 qWarning("XXX %d Items added", item);
746 vector.resize( item ); 746 vector.resize( item );
747 /* sort it now */ 747 /* sort it now */
748 vector.sort(); 748 vector.sort();
749 /* now get the uids */ 749 /* now get the uids */
750 QArray<int> array( vector.count() ); 750 QArray<int> array( vector.count() );
751 for (uint i= 0; i < vector.count(); i++ ) { 751 for (uint i= 0; i < vector.count(); i++ ) {
752 array[i] = ( vector.at(i) )->todo.uid(); 752 array[i] = ( vector.at(i) )->todo.uid();
753 } 753 }
754 return array; 754 return array;
755}; 755};
756void OTodoAccessXML::removeAllCompleted() { 756void OTodoAccessXML::removeAllCompleted() {
757 for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { 757 for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) {
758 if ( (*it).isCompleted() ) 758 if ( (*it).isCompleted() )
759 m_events.remove( it ); 759 m_events.remove( it );
760 } 760 }
761} 761}
762QBitArray OTodoAccessXML::supports()const { 762QBitArray OTodoAccessXML::supports()const {
763 static QBitArray ar = sup(); 763 static QBitArray ar = sup();
764 return ar; 764 return ar;
765} 765}
766QBitArray OTodoAccessXML::sup() { 766QBitArray OTodoAccessXML::sup() {
767 QBitArray ar( OTodo::CompletedDate +1 ); 767 QBitArray ar( OTodo::CompletedDate +1 );
768 ar.fill( true ); 768 ar.fill( true );
769 ar[OTodo::CrossReference] = false; 769 ar[OTodo::CrossReference] = false;
770 ar[OTodo::State ] = false; 770 ar[OTodo::State ] = false;
771 ar[OTodo::Reminders] = false; 771 ar[OTodo::Reminders] = false;
772 ar[OTodo::Notifiers] = false; 772 ar[OTodo::Notifiers] = false;
773 ar[OTodo::Maintainer] = false; 773 ar[OTodo::Maintainer] = false;
774 774
775 return ar; 775 return ar;
776} 776}
777QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const
778{
779 QArray<int> m_currentQuery( m_events.count() );
780 uint arraycounter = 0;
781
782 QMap<int, OTodo>::ConstIterator it;
783 for (it = m_events.begin(); it != m_events.end(); ++it ) {
784 if ( it.data().match( r ) )
785 m_currentQuery[arraycounter++] = it.data().uid();
786
787 }
788 // Shrink to fit..
789 m_currentQuery.resize(arraycounter);
790
791 return m_currentQuery;
792}
diff --git a/libopie2/opiepim/backend/otodoaccessxml.h b/libopie2/opiepim/backend/otodoaccessxml.h
index cc4a16f..e4850a1 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.h
+++ b/libopie2/opiepim/backend/otodoaccessxml.h
@@ -1,59 +1,60 @@
1#ifndef OPIE_TODO_ACCESS_XML_H 1#ifndef OPIE_TODO_ACCESS_XML_H
2#define OPIE_TODO_ACCESS_XML_H 2#define OPIE_TODO_ACCESS_XML_H
3 3
4#include <qasciidict.h> 4#include <qasciidict.h>
5#include <qmap.h> 5#include <qmap.h>
6 6
7#include "otodoaccessbackend.h" 7#include "otodoaccessbackend.h"
8 8
9namespace Opie { 9namespace Opie {
10 class XMLElement; 10 class XMLElement;
11}; 11};
12 12
13class OTodoAccessXML : public OTodoAccessBackend { 13class OTodoAccessXML : public OTodoAccessBackend {
14public: 14public:
15 /** 15 /**
16 * fileName if Empty we will use the default path 16 * fileName if Empty we will use the default path
17 */ 17 */
18 OTodoAccessXML( const QString& appName, 18 OTodoAccessXML( const QString& appName,
19 const QString& fileName = QString::null ); 19 const QString& fileName = QString::null );
20 ~OTodoAccessXML(); 20 ~OTodoAccessXML();
21 21
22 bool load(); 22 bool load();
23 bool reload(); 23 bool reload();
24 bool save(); 24 bool save();
25 25
26 QArray<int> allRecords()const; 26 QArray<int> allRecords()const;
27 QArray<int> matchRegexp(const QRegExp &r) const;
27 QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() ); 28 QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() );
28 OTodo find( int uid )const; 29 OTodo find( int uid )const;
29 void clear(); 30 void clear();
30 bool add( const OTodo& ); 31 bool add( const OTodo& );
31 bool remove( int uid ); 32 bool remove( int uid );
32 void removeAllCompleted(); 33 void removeAllCompleted();
33 bool replace( const OTodo& ); 34 bool replace( const OTodo& );
34 35
35 /* our functions */ 36 /* our functions */
36 QArray<int> effectiveToDos( const QDate& start, 37 QArray<int> effectiveToDos( const QDate& start,
37 const QDate& end, 38 const QDate& end,
38 bool includeNoDates ); 39 bool includeNoDates );
39 QArray<int> overDue(); 40 QArray<int> overDue();
40 QArray<int> sorted( bool asc, int sortOrder, 41 QArray<int> sorted( bool asc, int sortOrder,
41 int sortFilter, int cat ); 42 int sortFilter, int cat );
42 QBitArray supports()const; 43 QBitArray supports()const;
43private: 44private:
44 static QBitArray sup(); 45 static QBitArray sup();
45 void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& ); 46 void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& );
46 QString toString( const OTodo& )const; 47 QString toString( const OTodo& )const;
47 QString toString( const QArray<int>& ints ) const; 48 QString toString( const QArray<int>& ints ) const;
48 QMap<int, OTodo> m_events; 49 QMap<int, OTodo> m_events;
49 QString m_file; 50 QString m_file;
50 QString m_app; 51 QString m_app;
51 bool m_opened : 1; 52 bool m_opened : 1;
52 bool m_changed : 1; 53 bool m_changed : 1;
53 class OTodoAccessXMLPrivate; 54 class OTodoAccessXMLPrivate;
54 OTodoAccessXMLPrivate* d; 55 OTodoAccessXMLPrivate* d;
55 int m_year, m_month, m_day; 56 int m_year, m_month, m_day;
56 57
57}; 58};
58 59
59#endif 60#endif
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp
index 9c9338e..2e3ec1f 100644
--- a/libopie2/opiepim/core/ocontactaccess.cpp
+++ b/libopie2/opiepim/core/ocontactaccess.cpp
@@ -1,169 +1,168 @@
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 * 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 * Info: This class could just work with a change in the header-file 12 * Info: This class could just work with a change in the header-file
13 * of the Contact class ! Therefore our libopie only compiles 13 * of the Contact class ! Therefore our libopie only compiles
14 * with our version of libqpe 14 * with our version of libqpe
15 * ===================================================================== 15 * =====================================================================
16 * ToDo: XML-Backend: Automatic reload if something was changed... 16 * ToDo: XML-Backend: Automatic reload if something was changed...
17 * 17 *
18 * 18 *
19 * ===================================================================== 19 * =====================================================================
20 * Version: $Id$ 20 * Version: $Id$
21 * ===================================================================== 21 * =====================================================================
22 * History: 22 * History:
23 * $Log$ 23 * $Log$
24 * Revision 1.8 2003/05/08 13:55:09 tille
25 * search stuff
26 * and match, toRichText & toShortText in oevent
27 *
24 * Revision 1.7 2002/11/13 14:14:51 eilers 28 * Revision 1.7 2002/11/13 14:14:51 eilers
25 * Added sorted for Contacts.. 29 * Added sorted for Contacts..
26 * 30 *
27 * Revision 1.6 2002/11/01 15:10:42 eilers 31 * Revision 1.6 2002/11/01 15:10:42 eilers
28 * Added regExp-search in database for all fields in a contact. 32 * Added regExp-search in database for all fields in a contact.
29 * 33 *
30 * Revision 1.5 2002/10/16 10:52:40 eilers 34 * Revision 1.5 2002/10/16 10:52:40 eilers
31 * Added some docu to the interface and now using the cache infrastucture by zecke.. :) 35 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
32 * 36 *
33 * Revision 1.4 2002/10/14 16:21:54 eilers 37 * Revision 1.4 2002/10/14 16:21:54 eilers
34 * Some minor interface updates 38 * Some minor interface updates
35 * 39 *
36 * Revision 1.3 2002/10/07 17:34:24 eilers 40 * Revision 1.3 2002/10/07 17:34:24 eilers
37 * added OBackendFactory for advanced backend access 41 * added OBackendFactory for advanced backend access
38 * 42 *
39 * Revision 1.2 2002/10/02 16:18:11 eilers 43 * Revision 1.2 2002/10/02 16:18:11 eilers
40 * debugged and seems to work almost perfectly .. 44 * debugged and seems to work almost perfectly ..
41 * 45 *
42 * Revision 1.1 2002/09/27 17:11:44 eilers 46 * Revision 1.1 2002/09/27 17:11:44 eilers
43 * Added API for accessing the Contact-Database ! It is compiling, but 47 * Added API for accessing the Contact-Database ! It is compiling, but
44 * please do not expect that anything is working ! 48 * please do not expect that anything is working !
45 * I will debug that stuff in the next time .. 49 * I will debug that stuff in the next time ..
46 * Please read README_COMPILE for compiling ! 50 * Please read README_COMPILE for compiling !
47 * 51 *
48 * 52 *
49 */ 53 */
50 54
51#include "ocontactaccess.h" 55#include "ocontactaccess.h"
52#include "obackendfactory.h" 56#include "obackendfactory.h"
53 57
54#include <qasciidict.h> 58#include <qasciidict.h>
55#include <qdatetime.h> 59#include <qdatetime.h>
56#include <qfile.h> 60#include <qfile.h>
57#include <qregexp.h> 61#include <qregexp.h>
58#include <qlist.h> 62#include <qlist.h>
59#include <qcopchannel_qws.h> 63#include <qcopchannel_qws.h>
60 64
61//#include <qpe/qcopenvelope_qws.h> 65//#include <qpe/qcopenvelope_qws.h>
62#include <qpe/global.h> 66#include <qpe/global.h>
63 67
64#include <errno.h> 68#include <errno.h>
65#include <fcntl.h> 69#include <fcntl.h>
66#include <unistd.h> 70#include <unistd.h>
67#include <stdlib.h> 71#include <stdlib.h>
68 72
69#include "ocontactaccessbackend_xml.h" 73#include "ocontactaccessbackend_xml.h"
70 74
71 75
72OContactAccess::OContactAccess ( const QString appname, const QString , 76OContactAccess::OContactAccess ( const QString appname, const QString ,
73 OContactAccessBackend* end, bool autosync ): 77 OContactAccessBackend* end, bool autosync ):
74 OPimAccessTemplate<OContact>( end ) 78 OPimAccessTemplate<OContact>( end )
75{ 79{
76 /* take care of the backend. If there is no one defined, we 80 /* take care of the backend. If there is no one defined, we
77 * will use the XML-Backend as default (until we have a cute SQL-Backend..). 81 * will use the XML-Backend as default (until we have a cute SQL-Backend..).
78 */ 82 */
79 if( end == 0 ) { 83 if( end == 0 ) {
80 qWarning ("Using BackendFactory !"); 84 qWarning ("Using BackendFactory !");
81 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); 85 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname );
82 } 86 }
83 // Set backend locally and in template 87 // Set backend locally and in template
84 m_backEnd = end; 88 m_backEnd = end;
85 OPimAccessTemplate<OContact>::setBackEnd (end); 89 OPimAccessTemplate<OContact>::setBackEnd (end);
86 90
87 91
88 /* Connect signal of external db change to function */ 92 /* Connect signal of external db change to function */
89 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); 93 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
90 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), 94 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)),
91 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 95 this, SLOT(copMessage( const QCString &, const QByteArray &)) );
92 if ( autosync ){ 96 if ( autosync ){
93 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); 97 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this );
94 connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), 98 connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)),
95 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 99 this, SLOT(copMessage( const QCString &, const QByteArray &)) );
96 } 100 }
97 101
98 102
99} 103}
100OContactAccess::~OContactAccess () 104OContactAccess::~OContactAccess ()
101{ 105{
102 /* The user may forget to save the changed database, therefore try to 106 /* The user may forget to save the changed database, therefore try to
103 * do it for him.. 107 * do it for him..
104 */ 108 */
105 save(); 109 save();
106 // delete m_backEnd; is done by template.. 110 // delete m_backEnd; is done by template..
107} 111}
108 112
109 113
110bool OContactAccess::save () 114bool OContactAccess::save ()
111{ 115{
112 /* If the database was changed externally, we could not save the 116 /* If the database was changed externally, we could not save the
113 * Data. This will remove added items which is unacceptable ! 117 * Data. This will remove added items which is unacceptable !
114 * Therefore: Reload database and merge the data... 118 * Therefore: Reload database and merge the data...
115 */ 119 */
116 if ( OPimAccessTemplate<OContact>::wasChangedExternally() ) 120 if ( OPimAccessTemplate<OContact>::wasChangedExternally() )
117 reload(); 121 reload();
118 122
119 bool status = OPimAccessTemplate<OContact>::save(); 123 bool status = OPimAccessTemplate<OContact>::save();
120 if ( !status ) return false; 124 if ( !status ) return false;
121 125
122 /* Now tell everyone that new data is available. 126 /* Now tell everyone that new data is available.
123 */ 127 */
124 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); 128 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" );
125 129
126 return true; 130 return true;
127} 131}
128 132
129ORecordList<OContact> OContactAccess::matchRegexp( const QRegExp &r ) const{
130 QArray<int> matchingContacts = m_backEnd -> matchRegexp( r );
131 return ( ORecordList<OContact>(matchingContacts, this) );
132}
133
134const uint OContactAccess::querySettings() 133const uint OContactAccess::querySettings()
135{ 134{
136 return ( m_backEnd->querySettings() ); 135 return ( m_backEnd->querySettings() );
137} 136}
138 137
139bool OContactAccess::hasQuerySettings ( int querySettings ) const 138bool OContactAccess::hasQuerySettings ( int querySettings ) const
140{ 139{
141 return ( m_backEnd->hasQuerySettings ( querySettings ) ); 140 return ( m_backEnd->hasQuerySettings ( querySettings ) );
142} 141}
143ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const 142ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const
144{ 143{
145 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); 144 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat );
146 return ( ORecordList<OContact>(matchingContacts, this) ); 145 return ( ORecordList<OContact>(matchingContacts, this) );
147} 146}
148 147
149 148
150bool OContactAccess::wasChangedExternally()const 149bool OContactAccess::wasChangedExternally()const
151{ 150{
152 return ( m_backEnd->wasChangedExternally() ); 151 return ( m_backEnd->wasChangedExternally() );
153} 152}
154 153
155 154
156void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) 155void OContactAccess::copMessage( const QCString &msg, const QByteArray & )
157{ 156{
158 if ( msg == "addressbookUpdated()" ){ 157 if ( msg == "addressbookUpdated()" ){
159 qWarning ("OContactAccess: Received addressbokUpdated()"); 158 qWarning ("OContactAccess: Received addressbokUpdated()");
160 emit signalChanged ( this ); 159 emit signalChanged ( this );
161 } else if ( msg == "flush()" ) { 160 } else if ( msg == "flush()" ) {
162 qWarning ("OContactAccess: Received flush()"); 161 qWarning ("OContactAccess: Received flush()");
163 save (); 162 save ();
164 } else if ( msg == "reload()" ) { 163 } else if ( msg == "reload()" ) {
165 qWarning ("OContactAccess: Received reload()"); 164 qWarning ("OContactAccess: Received reload()");
166 reload (); 165 reload ();
167 emit signalChanged ( this ); 166 emit signalChanged ( this );
168 } 167 }
169} 168}
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h
index d7ceaf2..e90db32 100644
--- a/libopie2/opiepim/core/ocontactaccess.h
+++ b/libopie2/opiepim/core/ocontactaccess.h
@@ -1,162 +1,164 @@
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.8 2003/05/08 13:55:09 tille
21 * search stuff
22 * and match, toRichText & toShortText in oevent
23 *
20 * Revision 1.7 2003/04/13 18:07:10 zecke 24 * Revision 1.7 2003/04/13 18:07:10 zecke
21 * More API doc 25 * More API doc
22 * QString -> const QString& 26 * QString -> const QString&
23 * QString = 0l -> QString::null 27 * QString = 0l -> QString::null
24 * 28 *
25 * Revision 1.6 2003/01/02 14:27:12 eilers 29 * Revision 1.6 2003/01/02 14:27:12 eilers
26 * Improved query by example: Search by date is possible.. First step 30 * Improved query by example: Search by date is possible.. First step
27 * for a today plugin for birthdays.. 31 * for a today plugin for birthdays..
28 * 32 *
29 * Revision 1.5 2002/11/13 14:14:51 eilers 33 * Revision 1.5 2002/11/13 14:14:51 eilers
30 * Added sorted for Contacts.. 34 * Added sorted for Contacts..
31 * 35 *
32 * Revision 1.4 2002/11/01 15:10:42 eilers 36 * Revision 1.4 2002/11/01 15:10:42 eilers
33 * Added regExp-search in database for all fields in a contact. 37 * Added regExp-search in database for all fields in a contact.
34 * 38 *
35 * Revision 1.3 2002/10/16 10:52:40 eilers 39 * Revision 1.3 2002/10/16 10:52:40 eilers
36 * Added some docu to the interface and now using the cache infrastucture by zecke.. :) 40 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
37 * 41 *
38 * Revision 1.2 2002/10/14 16:21:54 eilers 42 * Revision 1.2 2002/10/14 16:21:54 eilers
39 * Some minor interface updates 43 * Some minor interface updates
40 * 44 *
41 * Revision 1.1 2002/09/27 17:11:44 eilers 45 * Revision 1.1 2002/09/27 17:11:44 eilers
42 * Added API for accessing the Contact-Database ! It is compiling, but 46 * Added API for accessing the Contact-Database ! It is compiling, but
43 * please do not expect that anything is working ! 47 * please do not expect that anything is working !
44 * I will debug that stuff in the next time .. 48 * I will debug that stuff in the next time ..
45 * Please read README_COMPILE for compiling ! 49 * Please read README_COMPILE for compiling !
46 * 50 *
47 * ===================================================================== 51 * =====================================================================
48 */ 52 */
49#ifndef _OCONTACTACCESS_H 53#ifndef _OCONTACTACCESS_H
50#define _OCONTACTACCESS_H 54#define _OCONTACTACCESS_H
51 55
52#include <qobject.h> 56#include <qobject.h>
53 57
54#include <qpe/qcopenvelope_qws.h> 58#include <qpe/qcopenvelope_qws.h>
55 59
56#include <qvaluelist.h> 60#include <qvaluelist.h>
57#include <qfileinfo.h> 61#include <qfileinfo.h>
58 62
59#include "ocontact.h" 63#include "ocontact.h"
60#include "ocontactaccessbackend.h" 64#include "ocontactaccessbackend.h"
61#include "opimaccesstemplate.h" 65#include "opimaccesstemplate.h"
62 66
63/** 67/**
64 * Class to access the contacts database. 68 * Class to access the contacts database.
65 * This is just a frontend for the real database handling which is 69 * This is just a frontend for the real database handling which is
66 * done by the backend. 70 * done by the backend.
67 * This class is used to access the Contacts on a system. This class as any OPIE PIM 71 * This class is used to access the Contacts on a system. This class as any OPIE PIM
68 * class is backend independent. 72 * class is backend independent.
69 73
70 * @see OPimAccessTemplate 74 * @see OPimAccessTemplate
71 */ 75 */
72class OContactAccess: public QObject, public OPimAccessTemplate<OContact> 76class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
73{ 77{
74 Q_OBJECT 78 Q_OBJECT
75 79
76 public: 80 public:
77 /** 81 /**
78 * Create Database with contacts (addressbook). 82 * Create Database with contacts (addressbook).
79 * @param appname Name of application which wants access to the database 83 * @param appname Name of application which wants access to the database
80 * (i.e. "todolist") 84 * (i.e. "todolist")
81 * @param filename The name of the database file. If not set, the default one 85 * @param filename The name of the database file. If not set, the default one
82 * is used. 86 * is used.
83 * @param backend Pointer to an alternative Backend. If not set, we will use 87 * @param backend Pointer to an alternative Backend. If not set, we will use
84 * the default backend. 88 * the default backend.
85 * @param handlesync If <b>true</b> the database stores the current state 89 * @param handlesync If <b>true</b> the database stores the current state
86 * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> 90 * automatically if it receives the signals <i>flush()</i> and <i>reload()</i>
87 * which are used before and after synchronisation. If the application wants 91 * which are used before and after synchronisation. If the application wants
88 * to react itself, it should be disabled by setting it to <b>false</b> 92 * to react itself, it should be disabled by setting it to <b>false</b>
89 * @see OContactAccessBackend 93 * @see OContactAccessBackend
90 */ 94 */
91 OContactAccess (const QString appname, const QString filename = 0l, 95 OContactAccess (const QString appname, const QString filename = 0l,
92 OContactAccessBackend* backend = 0l, bool handlesync = true); 96 OContactAccessBackend* backend = 0l, bool handlesync = true);
93 ~OContactAccess (); 97 ~OContactAccess ();
94 98
95 /** Constants for query. 99 /** Constants for query.
96 * Use this constants to set the query parameters. 100 * Use this constants to set the query parameters.
97 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! 101 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes !
98 * @see queryByExample() 102 * @see queryByExample()
99 */ 103 */
100 enum QuerySettings { 104 enum QuerySettings {
101 WildCards = 0x0001, 105 WildCards = 0x0001,
102 IgnoreCase = 0x0002, 106 IgnoreCase = 0x0002,
103 RegExp = 0x0004, 107 RegExp = 0x0004,
104 ExactMatch = 0x0008, 108 ExactMatch = 0x0008,
105 MatchOne = 0x0010, // Only one Entry must match 109 MatchOne = 0x0010, // Only one Entry must match
106 DateDiff = 0x0020, // Find all entries from today until given date 110 DateDiff = 0x0020, // Find all entries from today until given date
107 DateYear = 0x0040, // The year matches 111 DateYear = 0x0040, // The year matches
108 DateMonth = 0x0080, // The month matches 112 DateMonth = 0x0080, // The month matches
109 DateDay = 0x0100, // The day matches 113 DateDay = 0x0100, // The day matches
110 }; 114 };
111 115
112 116
113 ORecordList<OContact> matchRegexp( const QRegExp &r )const;
114
115 /** Return all Contacts in a sorted manner. 117 /** Return all Contacts in a sorted manner.
116 * @param ascending true: Sorted in acending order. 118 * @param ascending true: Sorted in acending order.
117 * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess 119 * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess
118 * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess 120 * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess
119 * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess 121 * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess
120 */ 122 */
121 List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const; 123 List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const;
122 124
123 /** Return all possible settings. 125 /** Return all possible settings.
124 * @return All settings provided by the current backend 126 * @return All settings provided by the current backend
125 * (i.e.: query_WildCards & query_IgnoreCase) 127 * (i.e.: query_WildCards & query_IgnoreCase)
126 */ 128 */
127 const uint querySettings(); 129 const uint querySettings();
128 130
129 /** Check whether settings are correct. 131 /** Check whether settings are correct.
130 * @return <i>true</i> if the given settings are correct and possible. 132 * @return <i>true</i> if the given settings are correct and possible.
131 */ 133 */
132 bool hasQuerySettings ( int querySettings ) const; 134 bool hasQuerySettings ( int querySettings ) const;
133 135
134 /** 136 /**
135 * if the resource was changed externally. 137 * if the resource was changed externally.
136 * You should use the signal instead of polling possible changes ! 138 * You should use the signal instead of polling possible changes !
137 */ 139 */
138 bool wasChangedExternally()const; 140 bool wasChangedExternally()const;
139 141
140 142
141 /** Save contacts database. 143 /** Save contacts database.
142 * Save is more a "commit". After calling this function, all changes are public available. 144 * Save is more a "commit". After calling this function, all changes are public available.
143 * @return true if successful 145 * @return true if successful
144 */ 146 */
145 bool save(); 147 bool save();
146 148
147 signals: 149 signals:
148 /* Signal is emitted if the database was changed. Therefore 150 /* Signal is emitted if the database was changed. Therefore
149 * we may need to reload to stay consistent. 151 * we may need to reload to stay consistent.
150 * @param which Pointer to the database who created this event. This pointer 152 * @param which Pointer to the database who created this event. This pointer
151 * is useful if an application has to handle multiple databases at the same time. 153 * is useful if an application has to handle multiple databases at the same time.
152 * @see reload() 154 * @see reload()
153 */ 155 */
154 void signalChanged ( const OContactAccess *which ); 156 void signalChanged ( const OContactAccess *which );
155 157
156 158
157 private: 159 private:
158 // class OContactAccessPrivate; 160 // class OContactAccessPrivate;
159 // OContactAccessPrivate* d; 161 // OContactAccessPrivate* d;
160 OContactAccessBackend *m_backEnd; 162 OContactAccessBackend *m_backEnd;
161 bool m_loading:1; 163 bool m_loading:1;
162 164
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index 6a3a0db..8ff205c 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -24,96 +24,102 @@ class OPimAccessTemplate : public OTemplateBase<T> {
24public: 24public:
25 enum Access { 25 enum Access {
26 Random = 0, 26 Random = 0,
27 SortedAccess 27 SortedAccess
28 }; 28 };
29 typedef ORecordList<T> List; 29 typedef ORecordList<T> List;
30 typedef OPimAccessBackend<T> BackEnd; 30 typedef OPimAccessBackend<T> BackEnd;
31 typedef OPimCache<T> Cache; 31 typedef OPimCache<T> Cache;
32 32
33 /** 33 /**
34 * c'tor BackEnd 34 * c'tor BackEnd
35 * enum Access a small hint on how to handle the backend 35 * enum Access a small hint on how to handle the backend
36 */ 36 */
37 OPimAccessTemplate( BackEnd* end); 37 OPimAccessTemplate( BackEnd* end);
38 38
39 virtual ~OPimAccessTemplate(); 39 virtual ~OPimAccessTemplate();
40 40
41 /** 41 /**
42 * load from the backend 42 * load from the backend
43 */ 43 */
44 bool load(); 44 bool load();
45 45
46 /** Reload database. 46 /** Reload database.
47 * You should execute this function if the external database 47 * You should execute this function if the external database
48 * was changed. 48 * was changed.
49 * This function will load the external database and afterwards 49 * This function will load the external database and afterwards
50 * rejoin the local changes. Therefore the local database will be set consistent. 50 * rejoin the local changes. Therefore the local database will be set consistent.
51 */ 51 */
52 virtual bool reload(); 52 virtual bool reload();
53 53
54 /** Save contacts database. 54 /** Save contacts database.
55 * Save is more a "commit". After calling this function, all changes are public available. 55 * Save is more a "commit". After calling this function, all changes are public available.
56 * @return true if successful 56 * @return true if successful
57 */ 57 */
58 bool save(); 58 bool save();
59 59
60 /** 60 /**
61 * if the resource was changed externally 61 * if the resource was changed externally
62 * You should use the signal handling instead of polling possible changes ! 62 * You should use the signal handling instead of polling possible changes !
63 * zecke: Do you implement a signal for otodoaccess ? 63 * zecke: Do you implement a signal for otodoaccess ?
64 */ 64 */
65 bool wasChangedExternally()const; 65 bool wasChangedExternally()const;
66 66
67 /** 67 /**
68 * return a List of records 68 * return a List of records
69 * you can iterate over them 69 * you can iterate over them
70 */ 70 */
71 virtual List allRecords()const; 71 virtual List allRecords()const;
72
73 /**
74 * return a List of records
75 * that match the regex
76 */
77 virtual List matchRegexp( const QRegExp &r ) const;
72 78
73 /** 79 /**
74 * queryByExample. 80 * queryByExample.
75 * @see otodoaccess, ocontactaccess 81 * @see otodoaccess, ocontactaccess
76 */ 82 */
77 virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); 83 virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() );
78 84
79 /** 85 /**
80 * find the OPimRecord uid 86 * find the OPimRecord uid
81 */ 87 */
82 virtual T find( int uid )const; 88 virtual T find( int uid )const;
83 89
84 /** 90 /**
85 * read ahead cache find method ;) 91 * read ahead cache find method ;)
86 */ 92 */
87 virtual T find( int uid, const QArray<int>&, 93 virtual T find( int uid, const QArray<int>&,
88 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; 94 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const;
89 95
90 /* invalidate cache here */ 96 /* invalidate cache here */
91 /** 97 /**
92 * clears the backend and invalidates the backend 98 * clears the backend and invalidates the backend
93 */ 99 */
94 void clear() ; 100 void clear() ;
95 101
96 /** 102 /**
97 * add T to the backend 103 * add T to the backend
98 * @param t The item to add. 104 * @param t The item to add.
99 * @return <i>true</i> if added successfully. 105 * @return <i>true</i> if added successfully.
100 */ 106 */
101 virtual bool add( const T& t ) ; 107 virtual bool add( const T& t ) ;
102 bool add( const OPimRecord& ); 108 bool add( const OPimRecord& );
103 109
104 /* only the uid matters */ 110 /* only the uid matters */
105 /** 111 /**
106 * remove T from the backend 112 * remove T from the backend
107 * @param t The item to remove 113 * @param t The item to remove
108 * @return <i>true</i> if successful. 114 * @return <i>true</i> if successful.
109 */ 115 */
110 virtual bool remove( const T& t ); 116 virtual bool remove( const T& t );
111 117
112 /** 118 /**
113 * remove the OPimRecord with uid 119 * remove the OPimRecord with uid
114 * @param uid The ID of the item to remove 120 * @param uid The ID of the item to remove
115 * @return <i>true</i> if successful. 121 * @return <i>true</i> if successful.
116 */ 122 */
117 bool remove( int uid ); 123 bool remove( int uid );
118 bool remove( const OPimRecord& ); 124 bool remove( const OPimRecord& );
119 125
@@ -136,96 +142,102 @@ protected:
136 /** 142 /**
137 * invalidate the cache 143 * invalidate the cache
138 */ 144 */
139 void invalidateCache(); 145 void invalidateCache();
140 146
141 void setBackEnd( BackEnd* end ); 147 void setBackEnd( BackEnd* end );
142 /** 148 /**
143 * returns the backend 149 * returns the backend
144 */ 150 */
145 BackEnd* backEnd(); 151 BackEnd* backEnd();
146 BackEnd* m_backEnd; 152 BackEnd* m_backEnd;
147 Cache m_cache; 153 Cache m_cache;
148 154
149}; 155};
150 156
151template <class T> 157template <class T>
152OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) 158OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end )
153 : OTemplateBase<T>(), m_backEnd( end ) 159 : OTemplateBase<T>(), m_backEnd( end )
154{ 160{
155 if (end ) 161 if (end )
156 end->setFrontend( this ); 162 end->setFrontend( this );
157} 163}
158template <class T> 164template <class T>
159OPimAccessTemplate<T>::~OPimAccessTemplate() { 165OPimAccessTemplate<T>::~OPimAccessTemplate() {
160 qWarning("~OPimAccessTemplate<T>"); 166 qWarning("~OPimAccessTemplate<T>");
161 delete m_backEnd; 167 delete m_backEnd;
162} 168}
163template <class T> 169template <class T>
164bool OPimAccessTemplate<T>::load() { 170bool OPimAccessTemplate<T>::load() {
165 invalidateCache(); 171 invalidateCache();
166 return m_backEnd->load(); 172 return m_backEnd->load();
167} 173}
168template <class T> 174template <class T>
169bool OPimAccessTemplate<T>::reload() { 175bool OPimAccessTemplate<T>::reload() {
170 invalidateCache(); // zecke: I think this should be added (se) 176 invalidateCache(); // zecke: I think this should be added (se)
171 return m_backEnd->reload(); 177 return m_backEnd->reload();
172} 178}
173template <class T> 179template <class T>
174bool OPimAccessTemplate<T>::save() { 180bool OPimAccessTemplate<T>::save() {
175 return m_backEnd->save(); 181 return m_backEnd->save();
176} 182}
177template <class T> 183template <class T>
178typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { 184typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const {
179 QArray<int> ints = m_backEnd->allRecords(); 185 QArray<int> ints = m_backEnd->allRecords();
180 List lis(ints, this ); 186 List lis(ints, this );
181 return lis; 187 return lis;
182} 188}
183template <class T> 189template <class T>
190typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const {
191 QArray<int> ints = m_backEnd->matchRegexp( r );
192 List lis(ints, this );
193 return lis;
194}
195template <class T>
184QArray<int> OPimAccessTemplate<T>::records()const { 196QArray<int> OPimAccessTemplate<T>::records()const {
185 return m_backEnd->allRecords(); 197 return m_backEnd->allRecords();
186} 198}
187template <class T> 199template <class T>
188typename OPimAccessTemplate<T>::List 200typename OPimAccessTemplate<T>::List
189OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { 201OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) {
190 QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); 202 QArray<int> ints = m_backEnd->queryByExample( t, settings, d );
191 203
192 List lis(ints, this ); 204 List lis(ints, this );
193 return lis; 205 return lis;
194} 206}
195template <class T> 207template <class T>
196T OPimAccessTemplate<T>::find( int uid ) const{ 208T OPimAccessTemplate<T>::find( int uid ) const{
197 T t = m_backEnd->find( uid ); 209 T t = m_backEnd->find( uid );
198 cache( t ); 210 cache( t );
199 return t; 211 return t;
200} 212}
201template <class T> 213template <class T>
202T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, 214T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
203 uint current, typename OTemplateBase<T>::CacheDirection dir )const { 215 uint current, typename OTemplateBase<T>::CacheDirection dir )const {
204 /* 216 /*
205 * better do T.isEmpty() 217 * better do T.isEmpty()
206 * after a find this way we would 218 * after a find this way we would
207 * avoid two finds in QCache... 219 * avoid two finds in QCache...
208 */ 220 */
209 // qWarning("find it now %d", uid ); 221 // qWarning("find it now %d", uid );
210 if (m_cache.contains( uid ) ) { 222 if (m_cache.contains( uid ) ) {
211 return m_cache.find( uid ); 223 return m_cache.find( uid );
212 } 224 }
213 225
214 T t = m_backEnd->find( uid, ar, current, dir ); 226 T t = m_backEnd->find( uid, ar, current, dir );
215 cache( t ); 227 cache( t );
216 return t; 228 return t;
217} 229}
218template <class T> 230template <class T>
219void OPimAccessTemplate<T>::clear() { 231void OPimAccessTemplate<T>::clear() {
220 invalidateCache(); 232 invalidateCache();
221 m_backEnd->clear(); 233 m_backEnd->clear();
222} 234}
223template <class T> 235template <class T>
224bool OPimAccessTemplate<T>::add( const T& t ) { 236bool OPimAccessTemplate<T>::add( const T& t ) {
225 cache( t ); 237 cache( t );
226 return m_backEnd->add( t ); 238 return m_backEnd->add( t );
227} 239}
228template <class T> 240template <class T>
229bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { 241bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
230 /* same type */ 242 /* same type */
231 if ( rec.rtti() == T::rtti() ) { 243 if ( rec.rtti() == T::rtti() ) {
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h
index c7f9460..de2d9f4 100644
--- a/libopie2/opiepim/core/opimrecord.h
+++ b/libopie2/opiepim/core/opimrecord.h
@@ -28,96 +28,102 @@ public:
28 /** 28 /**
29 * copy c'tor 29 * copy c'tor
30 */ 30 */
31 OPimRecord( const OPimRecord& rec ); 31 OPimRecord( const OPimRecord& rec );
32 32
33 /** 33 /**
34 * copy operator 34 * copy operator
35 */ 35 */
36 OPimRecord &operator=( const OPimRecord& ); 36 OPimRecord &operator=( const OPimRecord& );
37 37
38 /** 38 /**
39 * category names resolved 39 * category names resolved
40 */ 40 */
41 QStringList categoryNames( const QString& appname )const; 41 QStringList categoryNames( const QString& appname )const;
42 42
43 /** 43 /**
44 * set category names they will be resolved 44 * set category names they will be resolved
45 */ 45 */
46 void setCategoryNames( const QStringList& ); 46 void setCategoryNames( const QStringList& );
47 47
48 /** 48 /**
49 * addCategoryName adds a name 49 * addCategoryName adds a name
50 * to the internal category list 50 * to the internal category list
51 */ 51 */
52 void addCategoryName( const QString& ); 52 void addCategoryName( const QString& );
53 53
54 /** 54 /**
55 * if a Record isEmpty 55 * if a Record isEmpty
56 * it's empty if it's 0 56 * it's empty if it's 0
57 */ 57 */
58 virtual bool isEmpty()const; 58 virtual bool isEmpty()const;
59 59
60 /** 60 /**
61 * toRichText summary 61 * toRichText summary
62 */ 62 */
63 virtual QString toRichText()const = 0; 63 virtual QString toRichText()const = 0;
64 64
65 /** 65 /**
66 * a small one line summary 66 * a small one line summary
67 */ 67 */
68 virtual QString toShortText()const = 0; 68 virtual QString toShortText()const = 0;
69 69
70 /** 70 /**
71 * the name of the Record 71 * the name of the Record
72 */ 72 */
73 virtual QString type()const = 0; 73 virtual QString type()const = 0;
74 74
75 /** 75 /**
76 * matches the Records the regular expression?
77 */
78 virtual bool match( const QString &regexp ) const {return match(QRegExp(regexp));};
79 virtual bool match( const QRegExp &regexp ) const = 0;
80
81 /**
76 * converts the internal structure to a map 82 * converts the internal structure to a map
77 */ 83 */
78 virtual QMap<int, QString> toMap()const = 0; 84 virtual QMap<int, QString> toMap()const = 0;
79 85
80 /** 86 /**
81 * key value representation of extra items 87 * key value representation of extra items
82 */ 88 */
83 virtual QMap<QString, QString> toExtraMap()const = 0; 89 virtual QMap<QString, QString> toExtraMap()const = 0;
84 90
85 /** 91 /**
86 * the name for a recordField 92 * the name for a recordField
87 */ 93 */
88 virtual QString recordField(int)const = 0; 94 virtual QString recordField(int)const = 0;
89 95
90 /** 96 /**
91 * returns a reference of the 97 * returns a reference of the
92 * Cross Reference Manager 98 * Cross Reference Manager
93 * Partner 'One' is THIS PIM RECORD! 99 * Partner 'One' is THIS PIM RECORD!
94 * 'Two' is the Partner where we link to 100 * 'Two' is the Partner where we link to
95 */ 101 */
96 OPimXRefManager& xrefmanager(); 102 OPimXRefManager& xrefmanager();
97 103
98 /** 104 /**
99 * set the uid 105 * set the uid
100 */ 106 */
101 virtual void setUid( int uid ); 107 virtual void setUid( int uid );
102 108
103 /* 109 /*
104 * used inside the Templates for casting 110 * used inside the Templates for casting
105 * REIMPLEMENT in your .... 111 * REIMPLEMENT in your ....
106 */ 112 */
107 static int rtti(); 113 static int rtti();
108 114
109 /** 115 /**
110 * some marshalling and de marshalling code 116 * some marshalling and de marshalling code
111 * saves the OPimRecord 117 * saves the OPimRecord
112 * to and from a DataStream 118 * to and from a DataStream
113 */ 119 */
114 virtual bool loadFromStream(QDataStream& ); 120 virtual bool loadFromStream(QDataStream& );
115 virtual bool saveToStream( QDataStream& stream )const; 121 virtual bool saveToStream( QDataStream& stream )const;
116 122
117protected: 123protected:
118 Qtopia::UidGen &uidGen(); 124 Qtopia::UidGen &uidGen();
119// QString crossToString()const; 125// QString crossToString()const;
120 126
121private: 127private:
122 class OPimRecordPrivate; 128 class OPimRecordPrivate;
123 OPimRecordPrivate *d; 129 OPimRecordPrivate *d;
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp
index 96a5f65..a38b62b 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/ocontact.cpp
@@ -902,105 +902,96 @@ QStringList OContact::fields()
902 list.append( "BusinessWebPage" ); 902 list.append( "BusinessWebPage" );
903 903
904 list.append( "Office" ); 904 list.append( "Office" );
905 list.append( "Profession" ); 905 list.append( "Profession" );
906 list.append( "Assistant" ); 906 list.append( "Assistant" );
907 list.append( "Manager" ); 907 list.append( "Manager" );
908 908
909 list.append( "HomeStreet" ); 909 list.append( "HomeStreet" );
910 list.append( "HomeCity" ); 910 list.append( "HomeCity" );
911 list.append( "HomeState" ); 911 list.append( "HomeState" );
912 list.append( "HomeZip" ); 912 list.append( "HomeZip" );
913 list.append( "HomeCountry" ); 913 list.append( "HomeCountry" );
914 list.append( "HomeWebPage" ); 914 list.append( "HomeWebPage" );
915 915
916 list.append( "Spouse" ); 916 list.append( "Spouse" );
917 list.append( "Gender" ); 917 list.append( "Gender" );
918 list.append( "Birthday" ); 918 list.append( "Birthday" );
919 list.append( "Anniversary" ); 919 list.append( "Anniversary" );
920 list.append( "Nickname" ); 920 list.append( "Nickname" );
921 list.append( "Children" ); 921 list.append( "Children" );
922 922
923 list.append( "Notes" ); 923 list.append( "Notes" );
924 list.append( "Groups" ); 924 list.append( "Groups" );
925 925
926 return list; 926 return list;
927} 927}
928 928
929 929
930/*! 930/*!
931 Sets the list of email address for contact to those contained in \a str. 931 Sets the list of email address for contact to those contained in \a str.
932 Email address should be separated by ';'s. 932 Email address should be separated by ';'s.
933*/ 933*/
934void OContact::setEmails( const QString &str ) 934void OContact::setEmails( const QString &str )
935{ 935{
936 replace( Qtopia::Emails, str ); 936 replace( Qtopia::Emails, str );
937 if ( str.isEmpty() ) 937 if ( str.isEmpty() )
938 setDefaultEmail( QString::null ); 938 setDefaultEmail( QString::null );
939} 939}
940 940
941/*! 941/*!
942 Sets the list of children for the contact to those contained in \a str. 942 Sets the list of children for the contact to those contained in \a str.
943*/ 943*/
944void OContact::setChildren( const QString &str ) 944void OContact::setChildren( const QString &str )
945{ 945{
946 replace( Qtopia::Children, str ); 946 replace( Qtopia::Children, str );
947} 947}
948 948
949/*! 949/*!
950 Returns TRUE if the contact matches the regular expression \a regexp.
951 Otherwise returns FALSE.
952*/
953bool OContact::match( const QString &regexp ) const
954{
955 return match(QRegExp(regexp));
956}
957
958/*!
959 \overload 950 \overload
960 Returns TRUE if the contact matches the regular expression \a regexp. 951 Returns TRUE if the contact matches the regular expression \a regexp.
961 Otherwise returns FALSE. 952 Otherwise returns FALSE.
962*/ 953*/
963bool OContact::match( const QRegExp &r ) const 954bool OContact::match( const QRegExp &r ) const
964{ 955{
965 bool match; 956 bool match;
966 match = false; 957 match = false;
967 QMap<int, QString>::ConstIterator it; 958 QMap<int, QString>::ConstIterator it;
968 for ( it = mMap.begin(); it != mMap.end(); ++it ) { 959 for ( it = mMap.begin(); it != mMap.end(); ++it ) {
969 if ( (*it).find( r ) > -1 ) { 960 if ( (*it).find( r ) > -1 ) {
970 match = true; 961 match = true;
971 break; 962 break;
972 } 963 }
973 } 964 }
974 return match; 965 return match;
975} 966}
976 967
977 968
978QString OContact::toShortText() const 969QString OContact::toShortText() const
979{ 970{
980 return ( fullName() ); 971 return ( fullName() );
981} 972}
982QString OContact::type() const 973QString OContact::type() const
983{ 974{
984 return QString::fromLatin1( "OContact" ); 975 return QString::fromLatin1( "OContact" );
985} 976}
986 977
987// Definition is missing ! (se) 978// Definition is missing ! (se)
988QMap<QString,QString> OContact::toExtraMap() const 979QMap<QString,QString> OContact::toExtraMap() const
989{ 980{
990 qWarning ("Function not implemented: OContact::toExtraMap()"); 981 qWarning ("Function not implemented: OContact::toExtraMap()");
991 QMap <QString,QString> useless; 982 QMap <QString,QString> useless;
992 return useless; 983 return useless;
993} 984}
994 985
995class QString OContact::recordField( int pos ) const 986class QString OContact::recordField( int pos ) const
996{ 987{
997 QStringList SLFIELDS = fields(); // ?? why this ? (se) 988 QStringList SLFIELDS = fields(); // ?? why this ? (se)
998 return SLFIELDS[pos]; 989 return SLFIELDS[pos];
999} 990}
1000 991
1001// In future releases, we should store birthday and anniversary 992// In future releases, we should store birthday and anniversary
1002// internally as QDate instead of QString ! 993// internally as QDate instead of QString !
1003// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) 994// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
1004 995
1005/*! \fn void OContact::setBirthday( const QDate& date ) 996/*! \fn void OContact::setBirthday( const QDate& date )
1006 Sets the birthday for the contact to \a date. If date is null 997 Sets the birthday for the contact to \a date. If date is null
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h
index 50f6176..0e6cbd2 100644
--- a/libopie2/opiepim/ocontact.h
+++ b/libopie2/opiepim/ocontact.h
@@ -66,98 +66,97 @@ public:
66 void setDefaultEmail( const QString &v ); 66 void setDefaultEmail( const QString &v );
67 // inserts email to list and ensure's doesn't already exist 67 // inserts email to list and ensure's doesn't already exist
68 void insertEmail( const QString &v ); 68 void insertEmail( const QString &v );
69 void removeEmail( const QString &v ); 69 void removeEmail( const QString &v );
70 void clearEmails(); 70 void clearEmails();
71 void insertEmails( const QStringList &v ); 71 void insertEmails( const QStringList &v );
72 72
73 // home 73 // home
74 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } 74 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); }
75 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } 75 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); }
76 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } 76 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); }
77 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } 77 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); }
78 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } 78 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); }
79 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } 79 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); }
80 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } 80 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); }
81 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } 81 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); }
82 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } 82 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); }
83 83
84 // business 84 // business
85 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } 85 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); }
86 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } 86 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); }
87 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } 87 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); }
88 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } 88 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); }
89 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } 89 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); }
90 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } 90 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); }
91 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } 91 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); }
92 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } 92 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); }
93 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } 93 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); }
94 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } 94 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); }
95 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } 95 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); }
96 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } 96 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); }
97 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } 97 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); }
98 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } 98 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); }
99 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } 99 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); }
100 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } 100 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); }
101 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } 101 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); }
102 102
103 // personal 103 // personal
104 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } 104 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); }
105 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } 105 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); }
106 void setBirthday( const QDate &v ); 106 void setBirthday( const QDate &v );
107 void setAnniversary( const QDate &v ); 107 void setAnniversary( const QDate &v );
108 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } 108 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); }
109 void setChildren( const QString &v ); 109 void setChildren( const QString &v );
110 110
111 // other 111 // other
112 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } 112 void setNotes( const QString &v ) { replace( Qtopia::Notes, v); }
113 113
114 bool match( const QString &regexp ) const; 114 virtual bool match( const QRegExp &regexp ) const;
115 bool match( const QRegExp &regexp ) const;
116 115
117// // custom 116// // custom
118// void setCustomField( const QString &key, const QString &v ) 117// void setCustomField( const QString &key, const QString &v )
119// { replace(Custom- + key, v ); } 118// { replace(Custom- + key, v ); }
120 119
121 // name 120 // name
122 QString fullName() const; 121 QString fullName() const;
123 QString title() const { return find( Qtopia::Title ); } 122 QString title() const { return find( Qtopia::Title ); }
124 QString firstName() const { return find( Qtopia::FirstName ); } 123 QString firstName() const { return find( Qtopia::FirstName ); }
125 QString middleName() const { return find( Qtopia::MiddleName ); } 124 QString middleName() const { return find( Qtopia::MiddleName ); }
126 QString lastName() const { return find( Qtopia::LastName ); } 125 QString lastName() const { return find( Qtopia::LastName ); }
127 QString suffix() const { return find( Qtopia::Suffix ); } 126 QString suffix() const { return find( Qtopia::Suffix ); }
128 QString fileAs() const { return find( Qtopia::FileAs ); } 127 QString fileAs() const { return find( Qtopia::FileAs ); }
129 128
130 // email 129 // email
131 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } 130 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); }
132 QStringList emailList() const; 131 QStringList emailList() const;
133 132
134 // home 133 // home
135 /* 134 /*
136 * OPimAddress address(enum Location)const; 135 * OPimAddress address(enum Location)const;
137 * would be some how nicer... 136 * would be some how nicer...
138 * -zecke 137 * -zecke
139 */ 138 */
140 QString homeStreet() const { return find( Qtopia::HomeStreet ); } 139 QString homeStreet() const { return find( Qtopia::HomeStreet ); }
141 QString homeCity() const { return find( Qtopia::HomeCity ); } 140 QString homeCity() const { return find( Qtopia::HomeCity ); }
142 QString homeState() const { return find( Qtopia::HomeState ); } 141 QString homeState() const { return find( Qtopia::HomeState ); }
143 QString homeZip() const { return find( Qtopia::HomeZip ); } 142 QString homeZip() const { return find( Qtopia::HomeZip ); }
144 QString homeCountry() const { return find( Qtopia::HomeCountry ); } 143 QString homeCountry() const { return find( Qtopia::HomeCountry ); }
145 QString homePhone() const { return find( Qtopia::HomePhone ); } 144 QString homePhone() const { return find( Qtopia::HomePhone ); }
146 QString homeFax() const { return find( Qtopia::HomeFax ); } 145 QString homeFax() const { return find( Qtopia::HomeFax ); }
147 QString homeMobile() const { return find( Qtopia::HomeMobile ); } 146 QString homeMobile() const { return find( Qtopia::HomeMobile ); }
148 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } 147 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); }
149 /** Multi line string containing all non-empty address info in the form 148 /** Multi line string containing all non-empty address info in the form
150 * Street 149 * Street
151 * City, State Zip 150 * City, State Zip
152 * Country 151 * Country
153 */ 152 */
154 QString displayHomeAddress() const; 153 QString displayHomeAddress() const;
155 154
156 // business 155 // business
157 QString company() const { return find( Qtopia::Company ); } 156 QString company() const { return find( Qtopia::Company ); }
158 QString businessStreet() const { return find( Qtopia::BusinessStreet ); } 157 QString businessStreet() const { return find( Qtopia::BusinessStreet ); }
159 QString businessCity() const { return find( Qtopia::BusinessCity ); } 158 QString businessCity() const { return find( Qtopia::BusinessCity ); }
160 QString businessState() const { return find( Qtopia::BusinessState ); } 159 QString businessState() const { return find( Qtopia::BusinessState ); }
161 QString businessZip() const { return find( Qtopia::BusinessZip ); } 160 QString businessZip() const { return find( Qtopia::BusinessZip ); }
162 QString businessCountry() const { return find( Qtopia::BusinessCountry ); } 161 QString businessCountry() const { return find( Qtopia::BusinessCountry ); }
163 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } 162 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); }
diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/oevent.cpp
index 3ba8a52..28cf873 100644
--- a/libopie2/opiepim/oevent.cpp
+++ b/libopie2/opiepim/oevent.cpp
@@ -1,52 +1,53 @@
1#include <qshared.h> 1#include <qshared.h>
2 2
3#include <qpe/palmtopuidgen.h> 3#include <qpe/palmtopuidgen.h>
4#include <qpe/categories.h> 4#include <qpe/categories.h>
5#include <qpe/stringutil.h>
5 6
6#include "orecur.h" 7#include "orecur.h"
7#include "opimresolver.h" 8#include "opimresolver.h"
8#include "opimnotifymanager.h" 9#include "opimnotifymanager.h"
9 10
10#include "oevent.h" 11#include "oevent.h"
11 12
12int OCalendarHelper::week( const QDate& date) { 13int OCalendarHelper::week( const QDate& date) {
13 // Calculates the week this date is in within that 14 // Calculates the week this date is in within that
14 // month. Equals the "row" is is in in the month view 15 // month. Equals the "row" is is in in the month view
15 int week = 1; 16 int week = 1;
16 QDate tmp( date.year(), date.month(), 1 ); 17 QDate tmp( date.year(), date.month(), 1 );
17 if ( date.dayOfWeek() < tmp.dayOfWeek() ) 18 if ( date.dayOfWeek() < tmp.dayOfWeek() )
18 ++week; 19 ++week;
19 20
20 week += ( date.day() - 1 ) / 7; 21 week += ( date.day() - 1 ) / 7;
21 22
22 return week; 23 return week;
23} 24}
24int OCalendarHelper::ocurrence( const QDate& date) { 25int OCalendarHelper::ocurrence( const QDate& date) {
25 // calculates the number of occurrances of this day of the 26 // calculates the number of occurrances of this day of the
26 // week till the given date (e.g 3rd Wednesday of the month) 27 // week till the given date (e.g 3rd Wednesday of the month)
27 return ( date.day() - 1 ) / 7 + 1; 28 return ( date.day() - 1 ) / 7 + 1;
28} 29}
29int OCalendarHelper::dayOfWeek( char day ) { 30int OCalendarHelper::dayOfWeek( char day ) {
30 int dayOfWeek = 1; 31 int dayOfWeek = 1;
31 char i = ORecur::MON; 32 char i = ORecur::MON;
32 while ( !( i & day ) && i <= ORecur::SUN ) { 33 while ( !( i & day ) && i <= ORecur::SUN ) {
33 i <<= 1; 34 i <<= 1;
34 ++dayOfWeek; 35 ++dayOfWeek;
35 } 36 }
36 return dayOfWeek; 37 return dayOfWeek;
37} 38}
38int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) { 39int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) {
39 return ( second.year() - first.year() ) * 12 + 40 return ( second.year() - first.year() ) * 12 +
40 second.month() - first.month(); 41 second.month() - first.month();
41} 42}
42 43
43struct OEvent::Data : public QShared { 44struct OEvent::Data : public QShared {
44 Data() : QShared() { 45 Data() : QShared() {
45 child = 0; 46 child = 0;
46 recur = 0; 47 recur = 0;
47 manager = 0; 48 manager = 0;
48 isAllDay = false; 49 isAllDay = false;
49 parent = 0; 50 parent = 0;
50 } 51 }
51 ~Data() { 52 ~Data() {
52 delete manager; 53 delete manager;
@@ -165,106 +166,136 @@ QDateTime OEvent::startDateTimeInZone()const {
165 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); 166 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime();
166 167
167 OTimeZone zone(data->timezone ); 168 OTimeZone zone(data->timezone );
168 return zone.toDateTime( data->start, OTimeZone::current() ); 169 return zone.toDateTime( data->start, OTimeZone::current() );
169} 170}
170void OEvent::setStartDateTime( const QDateTime& dt ) { 171void OEvent::setStartDateTime( const QDateTime& dt ) {
171 changeOrModify(); 172 changeOrModify();
172 data->start = dt; 173 data->start = dt;
173} 174}
174QDateTime OEvent::endDateTime()const { 175QDateTime OEvent::endDateTime()const {
175 /* 176 /*
176 * if all Day event the end time needs 177 * if all Day event the end time needs
177 * to be on the same day as the start 178 * to be on the same day as the start
178 */ 179 */
179 if ( data->isAllDay ) 180 if ( data->isAllDay )
180 return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); 181 return QDateTime( data->start.date(), QTime(23, 59, 59 ) );
181 return data->end; 182 return data->end;
182} 183}
183QDateTime OEvent::endDateTimeInZone()const { 184QDateTime OEvent::endDateTimeInZone()const {
184 /* if no timezone, or all day event or if the current and this timeZone match... */ 185 /* if no timezone, or all day event or if the current and this timeZone match... */
185 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); 186 if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime();
186 187
187 OTimeZone zone(data->timezone ); 188 OTimeZone zone(data->timezone );
188 return zone.toDateTime( data->end, OTimeZone::current() ); 189 return zone.toDateTime( data->end, OTimeZone::current() );
189} 190}
190void OEvent::setEndDateTime( const QDateTime& dt ) { 191void OEvent::setEndDateTime( const QDateTime& dt ) {
191 changeOrModify(); 192 changeOrModify();
192 data->end = dt; 193 data->end = dt;
193} 194}
194bool OEvent::isMultipleDay()const { 195bool OEvent::isMultipleDay()const {
195 return data->end.date().day() - data->start.date().day(); 196 return data->end.date().day() - data->start.date().day();
196} 197}
197bool OEvent::isAllDay()const { 198bool OEvent::isAllDay()const {
198 return data->isAllDay; 199 return data->isAllDay;
199} 200}
200void OEvent::setAllDay( bool allDay ) { 201void OEvent::setAllDay( bool allDay ) {
201 changeOrModify(); 202 changeOrModify();
202 data->isAllDay = allDay; 203 data->isAllDay = allDay;
203 if (allDay ) data->timezone = "UTC"; 204 if (allDay ) data->timezone = "UTC";
204} 205}
205void OEvent::setTimeZone( const QString& tz ) { 206void OEvent::setTimeZone( const QString& tz ) {
206 changeOrModify(); 207 changeOrModify();
207 data->timezone = tz; 208 data->timezone = tz;
208} 209}
209QString OEvent::timeZone()const { 210QString OEvent::timeZone()const {
210 if (data->isAllDay ) return QString::fromLatin1("UTC"); 211 if (data->isAllDay ) return QString::fromLatin1("UTC");
211 return data->timezone; 212 return data->timezone;
212} 213}
213bool OEvent::match( const QRegExp& )const { 214bool OEvent::match( const QRegExp& re )const {
214 // FIXME 215 if (data->description.contains( re ) )
216 return true;
217 if ( data->note.contains( re ) )
218 return true;
219 if ( data->location.contains( re ) )
220 return true;
221 if ( data->start.toString().contains( re ) )
222 return true;
223 if ( data->end.toString().contains( re ) )
224 return true;
215 return false; 225 return false;
216} 226}
217QString OEvent::toRichText()const { 227QString OEvent::toRichText()const {
218 // FIXME 228 QString text;
219 return "OEvent test"; 229 if ( !description().isEmpty() ) {
230 text += "<b>" + QObject::tr( "Description:") + "</b><br>";
231 text += Qtopia::escapeString(description() ).
232 replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
233 }
234 if ( startDateTime().isValid() ) {
235 text += "<b>" + QObject::tr( "Start:") + "</b> ";
236 text += Qtopia::escapeString(startDateTime().toString() ).
237 replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
238 }
239 if ( endDateTime().isValid() ) {
240 text += "<b>" + QObject::tr( "End:") + "</b> ";
241 text += Qtopia::escapeString(endDateTime().toString() ).
242 replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
243 }
244 if ( !note().isEmpty() ) {
245 text += "<b>" + QObject::tr( "Note:") + "</b><br>";
246 text += note();
247// text += Qtopia::escapeString(note() ).
248// replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
249 }
250 return text;
220} 251}
221QString OEvent::toShortText()const { 252QString OEvent::toShortText()const {
222 return "OEvent shotText"; 253 return description();
223} 254}
224QString OEvent::type()const { 255QString OEvent::type()const {
225 return QString::fromLatin1("OEvent"); 256 return QString::fromLatin1("OEvent");
226} 257}
227QString OEvent::recordField( int /*id */ )const { 258QString OEvent::recordField( int /*id */ )const {
228 return QString::null; 259 return QString::null;
229} 260}
230int OEvent::rtti() { 261int OEvent::rtti() {
231 return OPimResolver::DateBook; 262 return OPimResolver::DateBook;
232} 263}
233bool OEvent::loadFromStream( QDataStream& ) { 264bool OEvent::loadFromStream( QDataStream& ) {
234 return true; 265 return true;
235} 266}
236bool OEvent::saveToStream( QDataStream& )const { 267bool OEvent::saveToStream( QDataStream& )const {
237 return true; 268 return true;
238} 269}
239void OEvent::changeOrModify() { 270void OEvent::changeOrModify() {
240 if ( data->count != 1 ) { 271 if ( data->count != 1 ) {
241 data->deref(); 272 data->deref();
242 Data* d2 = new Data; 273 Data* d2 = new Data;
243 d2->description = data->description; 274 d2->description = data->description;
244 d2->location = data->location; 275 d2->location = data->location;
245 276
246 if (data->manager ) 277 if (data->manager )
247 d2->manager = new OPimNotifyManager( *data->manager ); 278 d2->manager = new OPimNotifyManager( *data->manager );
248 279
249 if ( data->recur ) 280 if ( data->recur )
250 d2->recur = new ORecur( *data->recur ); 281 d2->recur = new ORecur( *data->recur );
251 282
252 d2->note = data->note; 283 d2->note = data->note;
253 d2->created = data->created; 284 d2->created = data->created;
254 d2->start = data->start; 285 d2->start = data->start;
255 d2->end = data->end; 286 d2->end = data->end;
256 d2->isAllDay = data->isAllDay; 287 d2->isAllDay = data->isAllDay;
257 d2->timezone = data->timezone; 288 d2->timezone = data->timezone;
258 d2->parent = data->parent; 289 d2->parent = data->parent;
259 290
260 if ( data->child ) { 291 if ( data->child ) {
261 d2->child = new QArray<int>( *data->child ); 292 d2->child = new QArray<int>( *data->child );
262 d2->child->detach(); 293 d2->child->detach();
263 } 294 }
264 295
265 data = d2; 296 data = d2;
266 } 297 }
267} 298}
268void OEvent::deref() { 299void OEvent::deref() {
269 if ( data->deref() ) { 300 if ( data->deref() ) {
270 delete data; 301 delete data;
diff --git a/libopie2/opiepim/oevent.h b/libopie2/opiepim/oevent.h
index 57d32d0..b696d81 100644
--- a/libopie2/opiepim/oevent.h
+++ b/libopie2/opiepim/oevent.h
@@ -68,97 +68,97 @@ public:
68 */ 68 */
69 OEvent( const OEvent& ); 69 OEvent( const OEvent& );
70 ~OEvent(); 70 ~OEvent();
71 OEvent &operator=( const OEvent& ); 71 OEvent &operator=( const OEvent& );
72 72
73 QString description()const; 73 QString description()const;
74 void setDescription( const QString& description ); 74 void setDescription( const QString& description );
75 75
76 QString location()const; 76 QString location()const;
77 void setLocation( const QString& loc ); 77 void setLocation( const QString& loc );
78 78
79 bool hasNotifiers()const; 79 bool hasNotifiers()const;
80 OPimNotifyManager &notifiers()const; 80 OPimNotifyManager &notifiers()const;
81 81
82 ORecur recurrence()const; 82 ORecur recurrence()const;
83 void setRecurrence( const ORecur& ); 83 void setRecurrence( const ORecur& );
84 bool hasRecurrence()const; 84 bool hasRecurrence()const;
85 85
86 QString note()const; 86 QString note()const;
87 void setNote( const QString& note ); 87 void setNote( const QString& note );
88 88
89 89
90 QDateTime createdDateTime()const; 90 QDateTime createdDateTime()const;
91 void setCreatedDateTime( const QDateTime& dt); 91 void setCreatedDateTime( const QDateTime& dt);
92 92
93 /** set the date to dt. dt is the QDateTime in localtime */ 93 /** set the date to dt. dt is the QDateTime in localtime */
94 void setStartDateTime( const QDateTime& ); 94 void setStartDateTime( const QDateTime& );
95 /** returns the datetime in the local timeZone */ 95 /** returns the datetime in the local timeZone */
96 QDateTime startDateTime()const; 96 QDateTime startDateTime()const;
97 97
98 /** returns the start datetime in the current zone */ 98 /** returns the start datetime in the current zone */
99 QDateTime startDateTimeInZone()const; 99 QDateTime startDateTimeInZone()const;
100 100
101 /** in current timezone */ 101 /** in current timezone */
102 void setEndDateTime( const QDateTime& ); 102 void setEndDateTime( const QDateTime& );
103 /** in current timezone */ 103 /** in current timezone */
104 QDateTime endDateTime()const; 104 QDateTime endDateTime()const;
105 QDateTime endDateTimeInZone()const; 105 QDateTime endDateTimeInZone()const;
106 106
107 bool isMultipleDay()const; 107 bool isMultipleDay()const;
108 bool isAllDay()const; 108 bool isAllDay()const;
109 void setAllDay( bool isAllDay ); 109 void setAllDay( bool isAllDay );
110 110
111 /* pin this event to a timezone! FIXME */ 111 /* pin this event to a timezone! FIXME */
112 void setTimeZone( const QString& timeZone ); 112 void setTimeZone( const QString& timeZone );
113 QString timeZone()const; 113 QString timeZone()const;
114 114
115 115
116 bool match( const QRegExp& )const; 116 virtual bool match( const QRegExp& )const;
117 117
118 /** For exception to recurrence here is a list of children... */ 118 /** For exception to recurrence here is a list of children... */
119 QArray<int> children()const; 119 QArray<int> children()const;
120 void setChildren( const QArray<int>& ); 120 void setChildren( const QArray<int>& );
121 void addChild( int uid ); 121 void addChild( int uid );
122 void removeChild( int uid ); 122 void removeChild( int uid );
123 123
124 /** return the parent OEvent */ 124 /** return the parent OEvent */
125 int parent()const; 125 int parent()const;
126 void setParent( int uid ); 126 void setParent( int uid );
127 127
128 128
129 /* needed reimp */ 129 /* needed reimp */
130 QString toRichText()const; 130 QString toRichText()const;
131 QString toShortText()const; 131 QString toShortText()const;
132 QString type()const; 132 QString type()const;
133 133
134 QMap<int, QString> toMap()const; 134 QMap<int, QString> toMap()const;
135 QMap<QString, QString> toExtraMap()const; 135 QMap<QString, QString> toExtraMap()const;
136 QString recordField(int )const; 136 QString recordField(int )const;
137 137
138 static int rtti(); 138 static int rtti();
139 139
140 bool loadFromStream( QDataStream& ); 140 bool loadFromStream( QDataStream& );
141 bool saveToStream( QDataStream& )const; 141 bool saveToStream( QDataStream& )const;
142 142
143/* bool operator==( const OEvent& ); 143/* bool operator==( const OEvent& );
144 bool operator!=( const OEvent& ); 144 bool operator!=( const OEvent& );
145 bool operator<( const OEvent& ); 145 bool operator<( const OEvent& );
146 bool operator<=( const OEvent& ); 146 bool operator<=( const OEvent& );
147 bool operator>( const OEvent& ); 147 bool operator>( const OEvent& );
148 bool operator>=(const OEvent& ); 148 bool operator>=(const OEvent& );
149*/ 149*/
150private: 150private:
151 inline void changeOrModify(); 151 inline void changeOrModify();
152 void deref(); 152 void deref();
153 struct Data; 153 struct Data;
154 Data* data; 154 Data* data;
155 class Private; 155 class Private;
156 Private* priv; 156 Private* priv;
157 157
158}; 158};
159 159
160/** 160/**
161 * AN Event can span through multiple days. We split up a multiday eve 161 * AN Event can span through multiple days. We split up a multiday eve
162 */ 162 */
163class OEffectiveEvent { 163class OEffectiveEvent {
164public: 164public:
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h
index a58d9aa..0e7c73f 100644
--- a/libopie2/opiepim/otodo.h
+++ b/libopie2/opiepim/otodo.h
@@ -213,77 +213,77 @@ public:
213 /** 213 /**
214 * Set the priority of the Todo 214 * Set the priority of the Todo
215 */ 215 */
216 void setPriority(int priority ); 216 void setPriority(int priority );
217 217
218 /** 218 /**
219 * Set the progress. 219 * Set the progress.
220 */ 220 */
221 void setProgress( ushort progress ); 221 void setProgress( ushort progress );
222 222
223 /** 223 /**
224 * set the end date 224 * set the end date
225 */ 225 */
226 void setDueDate( const QDate& date ); 226 void setDueDate( const QDate& date );
227 227
228 /** 228 /**
229 * set the start date 229 * set the start date
230 */ 230 */
231 void setStartDate( const QDate& date ); 231 void setStartDate( const QDate& date );
232 232
233 /** 233 /**
234 * set the completed date 234 * set the completed date
235 */ 235 */
236 void setCompletedDate( const QDate& date ); 236 void setCompletedDate( const QDate& date );
237 237
238 void setRecurrence( const ORecur& ); 238 void setRecurrence( const ORecur& );
239 /** 239 /**
240 * set the alarm time 240 * set the alarm time
241 */ 241 */
242 void setAlarmDateTime ( const QDateTime& alarm ); 242 void setAlarmDateTime ( const QDateTime& alarm );
243 243
244 void setDescription(const QString& ); 244 void setDescription(const QString& );
245 void setSummary(const QString& ); 245 void setSummary(const QString& );
246 246
247 /** 247 /**
248 * set the state of a Todo 248 * set the state of a Todo
249 * @param state State what the todo should take 249 * @param state State what the todo should take
250 */ 250 */
251 void setState( const OPimState& state); 251 void setState( const OPimState& state);
252 252
253 /** 253 /**
254 * set the Maintainer Mode 254 * set the Maintainer Mode
255 */ 255 */
256 void setMaintainer( const OPimMaintainer& ); 256 void setMaintainer( const OPimMaintainer& );
257 257
258 bool isOverdue(); 258 bool isOverdue();
259 259
260 260
261 bool match( const QRegExp &r )const; 261 virtual bool match( const QRegExp &r )const;
262 262
263 bool operator<(const OTodo &toDoEvent )const; 263 bool operator<(const OTodo &toDoEvent )const;
264 bool operator<=(const OTodo &toDoEvent )const; 264 bool operator<=(const OTodo &toDoEvent )const;
265 bool operator!=(const OTodo &toDoEvent )const; 265 bool operator!=(const OTodo &toDoEvent )const;
266 bool operator>(const OTodo &toDoEvent )const; 266 bool operator>(const OTodo &toDoEvent )const;
267 bool operator>=(const OTodo &toDoEvent)const; 267 bool operator>=(const OTodo &toDoEvent)const;
268 bool operator==(const OTodo &toDoEvent )const; 268 bool operator==(const OTodo &toDoEvent )const;
269 OTodo &operator=(const OTodo &toDoEvent ); 269 OTodo &operator=(const OTodo &toDoEvent );
270 270
271 static int rtti(); 271 static int rtti();
272 272
273 private: 273 private:
274 class OTodoPrivate; 274 class OTodoPrivate;
275 struct OTodoData; 275 struct OTodoData;
276 276
277 void deref(); 277 void deref();
278 inline void changeOrModify(); 278 inline void changeOrModify();
279 void copy( OTodoData* src, OTodoData* dest ); 279 void copy( OTodoData* src, OTodoData* dest );
280 OTodoPrivate *d; 280 OTodoPrivate *d;
281 OTodoData *data; 281 OTodoData *data;
282 282
283}; 283};
284inline bool OTodo::operator!=(const OTodo &toDoEvent )const { 284inline bool OTodo::operator!=(const OTodo &toDoEvent )const {
285 return !(*this == toDoEvent); 285 return !(*this == toDoEvent);
286} 286}
287 287
288 288
289#endif 289#endif