summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index d4c5fbb..e438980 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -3,190 +3,190 @@
3 Copyright (C) Holger Freyther <zecke@handhelds.org> 3 Copyright (C) Holger Freyther <zecke@handhelds.org>
4 Copyright (C) Stefan Eilers <eilers.stefan@epost.de> 4 Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
5 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 5 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
6 .=l. 6 .=l.
7 .>+-= 7 .>+-=
8 _;:, .> :=|. This program is free software; you can 8 _;:, .> :=|. This program is free software; you can
9.> <`_, > . <= redistribute it and/or modify it under 9.> <`_, > . <= redistribute it and/or modify it under
10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
11.="- .-=="i, .._ License as published by the Free Software 11.="- .-=="i, .._ License as published by the Free Software
12 - . .-<_> .<> Foundation; either version 2 of the License, 12 - . .-<_> .<> Foundation; either version 2 of the License,
13 ._= =} : or (at your option) any later version. 13 ._= =} : or (at your option) any later version.
14 .%`+i> _;_. 14 .%`+i> _;_.
15 .i_,=:_. -<s. This program is distributed in the hope that 15 .i_,=:_. -<s. This program is distributed in the hope that
16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
17 : .. .:, . . . without even the implied warranty of 17 : .. .:, . . . without even the implied warranty of
18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.= = ; Library General Public License for more 20..}^=.= = ; Library General Public License for more
21++= -. .` .: details. 21++= -. .` .: details.
22 : = ...= . :.=- 22 : = ...= . :.=-
23 -. .:....=;==+<; You should have received a copy of the GNU 23 -. .:....=;==+<; You should have received a copy of the GNU
24 -_. . . )=. = Library General Public License along with 24 -_. . . )=. = Library General Public License along with
25 -- :-=` this library; see the file COPYING.LIB. 25 -- :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29*/ 29*/
30#ifndef OPIE_PIM_ACCESS_TEMPLATE_H 30#ifndef OPIE_PIM_ACCESS_TEMPLATE_H
31#define OPIE_PIM_ACCESS_TEMPLATE_H 31#define OPIE_PIM_ACCESS_TEMPLATE_H
32 32
33#include <qarray.h> 33#include <qarray.h>
34 34
35#include <opie2/opimrecord.h> 35#include <opie2/opimrecord.h>
36#include <opie2/opimaccessbackend.h> 36#include <opie2/opimaccessbackend.h>
37#include <opie2/opimrecordlist.h> 37#include <opie2/opimrecordlist.h>
38 38
39#include <opie2/opimcache.h> 39#include <opie2/opimcache.h>
40#include <opie2/opimtemplatebase.h> 40#include <opie2/opimtemplatebase.h>
41 41
42namespace Opie { 42namespace Opie {
43 43
44class OPimAccessTemplatePrivate; 44class OPimAccessTemplatePrivate;
45/** 45/**
46 * Thats the frontend to our OPIE PIM 46 * Thats the frontend to our OPIE PIM
47 * Library. Either you want to use it's 47 * Library. Either you want to use it's
48 * interface or you want to implement 48 * interface or you want to implement
49 * your own Access lib 49 * your own Access lib
50 * Just create a OPimRecord and inherit from 50 * Just create a OPimRecord and inherit from
51 * the plugins 51 * the templates
52 */ 52 */
53 53
54template <class T = OPimRecord > 54template <class T = OPimRecord >
55class OPimAccessTemplate : public OTemplateBase<T> { 55class OPimAccessTemplate : public OTemplateBase<T> {
56public: 56public:
57 enum Access { 57 enum Access {
58 Random = 0, 58 Random = 0,
59 SortedAccess 59 SortedAccess
60 }; 60 };
61 typedef OPimRecordList<T> List; 61 typedef OPimRecordList<T> List;
62 typedef OPimAccessBackend<T> BackEnd; 62 typedef OPimAccessBackend<T> BackEnd;
63 typedef OPimCache<T> Cache; 63 typedef OPimCache<T> Cache;
64 64
65 /** 65 /**
66 * c'tor BackEnd 66 * c'tor BackEnd
67 * enum Access a small hint on how to handle the backend 67 * enum Access a small hint on how to handle the backend
68 */ 68 */
69 OPimAccessTemplate( BackEnd* end); 69 OPimAccessTemplate( BackEnd* end);
70 70
71 virtual ~OPimAccessTemplate(); 71 virtual ~OPimAccessTemplate();
72 72
73 /** 73 /**
74 * load from the backend 74 * load from the backend
75 */ 75 */
76 bool load(); 76 bool load();
77 77
78 /** Reload database. 78 /** Reload database.
79 * You should execute this function if the external database 79 * You should execute this function if the external database
80 * was changed. 80 * was changed.
81 * This function will load the external database and afterwards 81 * This function will load the external database and afterwards
82 * rejoin the local changes. Therefore the local database will be set consistent. 82 * rejoin the local changes. Therefore the local database will be set consistent.
83 */ 83 */
84 virtual bool reload(); 84 virtual bool reload();
85 85
86 /** Save contacts database. 86 /** Save contacts database.
87 * Save is more a "commit". After calling this function, all changes are public available. 87 * Save is more a "commit". After calling this function, all changes are public available.
88 * @return true if successful 88 * @return true if successful
89 */ 89 */
90 bool save(); 90 bool save();
91 91
92 /** 92 /**
93 * if the resource was changed externally 93 * if the resource was changed externally
94 * You should use the signal handling instead of polling possible changes ! 94 * You should use the signal handling instead of polling possible changes !
95 * zecke: Do you implement a signal for otodoaccess ? 95 * zecke: Do you implement a signal for otodoaccess ?
96 */ 96 */
97 bool wasChangedExternally()const; 97 bool wasChangedExternally()const;
98 98
99 /** 99 /**
100 * return a List of records 100 * return a List of records
101 * you can iterate over them 101 * you can iterate over them
102 */ 102 */
103 virtual List allRecords()const; 103 virtual List allRecords()const;
104 104
105 /** 105 /**
106 * return a List of records 106 * return a List of records
107 * that match the regex 107 * that match the regex
108 */ 108 */
109 virtual List matchRegexp( const QRegExp &r ) const; 109 virtual List matchRegexp( const QRegExp &r ) const;
110 110
111 /** 111 /**
112 * queryByExample. 112 * queryByExample.
113 * @see otodoaccess, ocontactaccess 113 * @see otodoaccess, ocontactaccess
114 */ 114 */
115 virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); 115 virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() );
116 116
117 /** 117 /**
118 * find the OPimRecord uid 118 * find the OPimRecord uid
119 */ 119 */
120 virtual T find( int uid )const; 120 virtual T find( int uid )const;
121 121
122 /** 122 /**
123 * read ahead cache find method ;) 123 * read ahead cache find method ;)
124 */ 124 */
125 virtual T find( int uid, const QArray<int>&, 125 virtual T find( int uid, const QArray<int>&,
126 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; 126 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const;
127 127
128 /* invalidate cache here */ 128 /* invalidate cache here */
129 /** 129 /**
130 * clears the backend and invalidates the backend 130 * clears the backend and invalidates the backend
131 */ 131 */
132 void clear() ; 132 void clear() ;
133 133
134 /** 134 /**
135 * add T to the backend 135 * add T to the backend
136 * @param t The item to add. 136 * @param t The item to add.
137 * @return <i>true</i> if added successfully. 137 * @return <i>true</i> if added successfully.
138 */ 138 */
139 virtual bool add( const T& t ) ; 139 virtual bool add( const T& t ) ;
140 bool add( const OPimRecord& ); 140 bool add( const OPimRecord& );
141 // Needed for real generic access (eilers) 141 // Needed for real generic access (eilers)
142 // Info: Take this if you are working with OPimRecord, which is a generic base class, and 142 // Info: Take this if you are working with OPimRecord, which is a generic base class, and
143 // you need to add it into any database, you cannot generate a reference to 143 // you need to add it into any database, you cannot generate a reference to
144 // it and casting may be not approriate, too. 144 // it and casting may be not approriate, too.
145 // But take care that the accessing database is compatible to the real type of OPimRecord !! 145 // But take care that the accessing database is compatible to the real type of OPimRecord !!
146 bool add( const OPimRecord* ); 146 bool add( const OPimRecord* );
147 147
148 148
149 /* only the uid matters */ 149 /* only the uid matters */
150 /** 150 /**
151 * remove T from the backend 151 * remove T from the backend
152 * @param t The item to remove 152 * @param t The item to remove
153 * @return <i>true</i> if successful. 153 * @return <i>true</i> if successful.
154 */ 154 */
155 virtual bool remove( const T& t ); 155 virtual bool remove( const T& t );
156 156
157 /** 157 /**
158 * remove the OPimRecord with uid 158 * remove the OPimRecord with uid
159 * @param uid The ID of the item to remove 159 * @param uid The ID of the item to remove
160 * @return <i>true</i> if successful. 160 * @return <i>true</i> if successful.
161 */ 161 */
162 bool remove( int uid ); 162 bool remove( int uid );
163 bool remove( const OPimRecord& ); 163 bool remove( const OPimRecord& );
164 164
165 /** 165 /**
166 * replace T from backend 166 * replace T from backend
167 * @param t The item to replace 167 * @param t The item to replace
168 * @return <i>true</i> if successful. 168 * @return <i>true</i> if successful.
169 */ 169 */
170 virtual bool replace( const T& t) ; 170 virtual bool replace( const T& t) ;
171 171
172 void setReadAhead( uint count ); 172 void setReadAhead( uint count );
173 /** 173 /**
174 * @internal 174 * @internal
175 */ 175 */
176 void cache( const T& )const; 176 void cache( const T& )const;
177 void setSaneCacheSize( int ); 177 void setSaneCacheSize( int );
178 178
179 QArray<int> records()const; 179 QArray<int> records()const;
180protected: 180protected:
181 /** 181 /**
182 * invalidate the cache 182 * invalidate the cache
183 */ 183 */
184 void invalidateCache(); 184 void invalidateCache();
185 185
186 void setBackEnd( BackEnd* end ); 186 void setBackEnd( BackEnd* end );
187 /** 187 /**
188 * returns the backend 188 * returns the backend
189 */ 189 */
190 BackEnd* backEnd(); 190 BackEnd* backEnd();
191 BackEnd* m_backEnd; 191 BackEnd* m_backEnd;
192 Cache m_cache; 192 Cache m_cache;