summaryrefslogtreecommitdiff
authortille <tille>2003-05-08 13:55:09 (UTC)
committer tille <tille>2003-05-08 13:55:09 (UTC)
commit0cb4111d34d9fe96731f48983e1ff2e67262db02 (patch) (unidiff)
treece6ec869ae7753ab0261e7ad075a10ad8b0a404b
parent78c60031b506b85dc20bd555d83486aeb831bf38 (diff)
downloadopie-0cb4111d34d9fe96731f48983e1ff2e67262db02.zip
opie-0cb4111d34d9fe96731f48983e1ff2e67262db02.tar.gz
opie-0cb4111d34d9fe96731f48983e1ff2e67262db02.tar.bz2
search stuff
and match, toRichText & toShortText in oevent
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
@@ -938,33 +938,24 @@ void OContact::setEmails( const QString &str )
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;
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
@@ -102,26 +102,25 @@ public:
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 ); }
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
@@ -12,24 +12,28 @@
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 *
@@ -64,35 +68,35 @@
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
@@ -117,29 +121,24 @@ bool OContactAccess::save ()
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 );
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
@@ -8,24 +8,28 @@
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 *
@@ -101,26 +105,24 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
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 */
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
@@ -577,12 +577,30 @@ void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& val
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
@@ -13,24 +13,25 @@
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();
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,16 +1,17 @@
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 );
@@ -201,34 +202,64 @@ void 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;
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
@@ -104,25 +104,25 @@ public:
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
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
@@ -37,24 +37,30 @@ public:
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
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
@@ -60,24 +60,30 @@ public:
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
@@ -172,24 +178,30 @@ bool OPimAccessTemplate<T>::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>
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
@@ -64,24 +64,30 @@ public:
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 */
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
@@ -249,25 +249,25 @@ public:
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:
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
@@ -176,24 +176,28 @@ QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) {
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);
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
@@ -4,24 +4,25 @@
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& );
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
@@ -765,12 +765,28 @@ QBitArray OTodoAccessXML::supports()const {
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
@@ -15,24 +15,25 @@ public:
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 );
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
@@ -577,12 +577,30 @@ void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& val
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
@@ -13,24 +13,25 @@
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();
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
@@ -37,24 +37,30 @@ public:
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
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
@@ -176,24 +176,28 @@ QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) {
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);
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
@@ -4,24 +4,25 @@
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& );
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
@@ -765,12 +765,28 @@ QBitArray OTodoAccessXML::supports()const {
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
@@ -15,24 +15,25 @@ public:
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 );
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
@@ -12,24 +12,28 @@
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 *
@@ -64,35 +68,35 @@
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
@@ -117,29 +121,24 @@ bool OContactAccess::save ()
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 );
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
@@ -8,24 +8,28 @@
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 *
@@ -101,26 +105,24 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
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 */
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
@@ -60,24 +60,30 @@ public:
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
@@ -172,24 +178,30 @@ bool OPimAccessTemplate<T>::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>
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
@@ -64,24 +64,30 @@ public:
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 */
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
@@ -938,33 +938,24 @@ void OContact::setEmails( const QString &str )
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;
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
@@ -102,26 +102,25 @@ public:
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 ); }
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,16 +1,17 @@
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 );
@@ -201,34 +202,64 @@ void 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;
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
@@ -104,25 +104,25 @@ public:
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
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
@@ -249,25 +249,25 @@ public:
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: