-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.cpp | 13 | ||||
-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.h | 6 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimaccesstemplate.h | 12 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.h | 6 |
4 files changed, 28 insertions, 9 deletions
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,47 +1,51 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage the Contacts. | 2 | * Class to manage the Contacts. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * | 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 | * |
@@ -52,106 +56,101 @@ | |||
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 | ||
72 | OContactAccess::OContactAccess ( const QString appname, const QString , | 76 | OContactAccess::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 | } |
100 | OContactAccess::~OContactAccess () | 104 | OContactAccess::~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 | ||
110 | bool OContactAccess::save () | 114 | bool 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 | ||
129 | ORecordList<OContact> OContactAccess::matchRegexp( const QRegExp &r ) const{ | ||
130 | QArray<int> matchingContacts = m_backEnd -> matchRegexp( r ); | ||
131 | return ( ORecordList<OContact>(matchingContacts, this) ); | ||
132 | } | ||
133 | |||
134 | const uint OContactAccess::querySettings() | 133 | const uint OContactAccess::querySettings() |
135 | { | 134 | { |
136 | return ( m_backEnd->querySettings() ); | 135 | return ( m_backEnd->querySettings() ); |
137 | } | 136 | } |
138 | 137 | ||
139 | bool OContactAccess::hasQuerySettings ( int querySettings ) const | 138 | bool OContactAccess::hasQuerySettings ( int querySettings ) const |
140 | { | 139 | { |
141 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); | 140 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); |
142 | } | 141 | } |
143 | ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const | 142 | ORecordList<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 | ||
150 | bool OContactAccess::wasChangedExternally()const | 149 | bool OContactAccess::wasChangedExternally()const |
151 | { | 150 | { |
152 | return ( m_backEnd->wasChangedExternally() ); | 151 | return ( m_backEnd->wasChangedExternally() ); |
153 | } | 152 | } |
154 | 153 | ||
155 | 154 | ||
156 | void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) | 155 | void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) |
157 | { | 156 | { |
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,43 +1,47 @@ | |||
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 ! |
@@ -89,50 +93,48 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact> | |||
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; |
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 | |||
@@ -48,48 +48,54 @@ public: | |||
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 | ||
@@ -160,48 +166,54 @@ OPimAccessTemplate<T>::~OPimAccessTemplate() { | |||
160 | qWarning("~OPimAccessTemplate<T>"); | 166 | qWarning("~OPimAccessTemplate<T>"); |
161 | delete m_backEnd; | 167 | delete m_backEnd; |
162 | } | 168 | } |
163 | template <class T> | 169 | template <class T> |
164 | bool OPimAccessTemplate<T>::load() { | 170 | bool OPimAccessTemplate<T>::load() { |
165 | invalidateCache(); | 171 | invalidateCache(); |
166 | return m_backEnd->load(); | 172 | return m_backEnd->load(); |
167 | } | 173 | } |
168 | template <class T> | 174 | template <class T> |
169 | bool OPimAccessTemplate<T>::reload() { | 175 | bool 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 | } |
173 | template <class T> | 179 | template <class T> |
174 | bool OPimAccessTemplate<T>::save() { | 180 | bool OPimAccessTemplate<T>::save() { |
175 | return m_backEnd->save(); | 181 | return m_backEnd->save(); |
176 | } | 182 | } |
177 | template <class T> | 183 | template <class T> |
178 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { | 184 | typename 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 | } |
183 | template <class T> | 189 | template <class T> |
190 | typename 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 | } | ||
195 | template <class T> | ||
184 | QArray<int> OPimAccessTemplate<T>::records()const { | 196 | QArray<int> OPimAccessTemplate<T>::records()const { |
185 | return m_backEnd->allRecords(); | 197 | return m_backEnd->allRecords(); |
186 | } | 198 | } |
187 | template <class T> | 199 | template <class T> |
188 | typename OPimAccessTemplate<T>::List | 200 | typename OPimAccessTemplate<T>::List |
189 | OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { | 201 | OPimAccessTemplate<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 | } |
195 | template <class T> | 207 | template <class T> |
196 | T OPimAccessTemplate<T>::find( int uid ) const{ | 208 | T 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 | } |
201 | template <class T> | 213 | template <class T> |
202 | T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, | 214 | T 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... |
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 | |||
@@ -52,48 +52,54 @@ public: | |||
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 ®exp ) const {return match(QRegExp(regexp));}; | ||
79 | virtual bool match( const QRegExp ®exp ) 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 |