Diffstat (limited to 'libopie2/opiepim/core/opimaccesstemplate.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimaccesstemplate.h | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h index 2deb92a..073d5f9 100644 --- a/libopie2/opiepim/core/opimaccesstemplate.h +++ b/libopie2/opiepim/core/opimaccesstemplate.h | |||
@@ -81,33 +81,70 @@ public: | |||
81 | //@} | 81 | //@} |
82 | 82 | ||
83 | 83 | ||
84 | bool wasChangedExternally()const; | 84 | bool wasChangedExternally()const; |
85 | 85 | ||
86 | //@{ | 86 | //@{ |
87 | virtual List allRecords()const; | 87 | virtual List allRecords()const; |
88 | virtual List matchRegexp( const QRegExp &r ) const; | 88 | virtual List matchRegexp( const QRegExp &r ) const; |
89 | virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); | 89 | virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); |
90 | virtual T find( UID uid )const; | 90 | virtual T find( UID uid )const; |
91 | virtual T find( UID uid, const QArray<int>&, | 91 | virtual T find( UID uid, const QArray<int>&, |
92 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; | 92 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; |
93 | virtual List sorted( const List&, bool ascending, int sortOrder, | 93 | //@} |
94 | |||
95 | /** | ||
96 | * Get sorted lists.. | ||
97 | * @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params: | ||
98 | * @param list of UID's received by allRecords() or others... | ||
99 | * @param sortOrder Setting the sort order defined by enum SortOrder | ||
100 | * @param ascending Sort in ascending order if true, otherwise descending | ||
101 | * @param sortFilter Setting the sort filter defined by enum SortFilter | ||
102 | * @param cat number of category. | ||
103 | */ | ||
104 | virtual List sorted( const List& list, bool ascending, int sortOrder, | ||
94 | int sortFilter, int cat )const; | 105 | int sortFilter, int cat )const; |
95 | virtual List sorted( const List&, bool ascending, int sortOrder, | 106 | |
107 | /** | ||
108 | * Get sorted lists.. | ||
109 | * @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params: | ||
110 | * @param list of UID's received by allRecords() or others... | ||
111 | * @param sortOrder Setting the sort order defined by enum SortOrder | ||
112 | * @param ascending Sort in ascending order if true, otherwise descending | ||
113 | * @param sortFilter Setting the sort filter defined by enum SortFilter | ||
114 | * @param cats List of categories. | ||
115 | */ | ||
116 | virtual List sorted( const List& list, bool ascending, int sortOrder, | ||
96 | int sortFilter, const QArray<UID>& cats )const; | 117 | int sortFilter, const QArray<UID>& cats )const; |
118 | |||
119 | /** | ||
120 | * Get sorted lists.. | ||
121 | * @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params: | ||
122 | * @param ascending Sort in ascending order if true, otherwise descending | ||
123 | * @param sortOrder Setting the sort order defined by enum SortOrder | ||
124 | * @param sortFilter Setting the sort filter defined by enum SortFilter | ||
125 | * @param cat number of category. | ||
126 | */ | ||
97 | virtual List sorted( bool ascending, int sortOrder, int sortFilter, int cat )const; | 127 | virtual List sorted( bool ascending, int sortOrder, int sortFilter, int cat )const; |
98 | virtual List sorted( bool ascending, int sortOrder, int sortOrder, | ||
99 | const QArray<UID>& cats )const; | ||
100 | //@} | ||
101 | 128 | ||
129 | /** | ||
130 | * Get sorted lists.. | ||
131 | * @see OPimContactAccess, OPimTodoAccess and ODateBookAccess regarding more info for the following params: | ||
132 | * @param ascending Sort in ascending order if true, otherwise descending | ||
133 | * @param sortOrder Setting the sort order defined by enum SortOrder | ||
134 | * @param sortFilter Setting the sort filter defined by enum SortFilter | ||
135 | * @param cats List of categories. | ||
136 | */ | ||
137 | virtual List sorted( bool ascending, int sortOrder, int sortFilter, | ||
138 | const QArray<UID>& cats )const; | ||
102 | /** | 139 | /** |
103 | * (Re)Implementation | 140 | * (Re)Implementation |
104 | */ | 141 | */ |
105 | //@{ | 142 | //@{ |
106 | UIDArray matchRegexpSimple( const QRegExp& r )const; | 143 | UIDArray matchRegexpSimple( const QRegExp& r )const; |
107 | UIDArray queryByExampleSimple( const OPimRecord*, int, const QDateTime& )const; | 144 | UIDArray queryByExampleSimple( const OPimRecord*, int, const QDateTime& )const; |
108 | UIDArray sortedSimple( const UIDArray&, bool asc, int sortOrder, | 145 | UIDArray sortedSimple( const UIDArray&, bool asc, int sortOrder, |
109 | int sortFilter, int cat )const; | 146 | int sortFilter, int cat )const; |
110 | UIDArray sortedSimple( const UIDArray&, bool asc, int sortOrder, | 147 | UIDArray sortedSimple( const UIDArray&, bool asc, int sortOrder, |
111 | int sortFilter, const QArray<int>& )const; | 148 | int sortFilter, const QArray<int>& )const; |
112 | UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter, | 149 | UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter, |
113 | int cat )const; | 150 | int cat )const; |
@@ -120,25 +157,24 @@ public: | |||
120 | //@{ | 157 | //@{ |
121 | virtual bool add( const T& t ) ; | 158 | virtual bool add( const T& t ) ; |
122 | bool add( const OPimRecord& ); | 159 | bool add( const OPimRecord& ); |
123 | bool add( const OPimRecord* ); | 160 | bool add( const OPimRecord* ); |
124 | virtual bool remove( const T& t ); | 161 | virtual bool remove( const T& t ); |
125 | bool remove( UID uid ); | 162 | bool remove( UID uid ); |
126 | bool remove( const OPimRecord& ); | 163 | bool remove( const OPimRecord& ); |
127 | virtual bool replace( const T& t) ; | 164 | virtual bool replace( const T& t) ; |
128 | 165 | ||
129 | //@} | 166 | //@} |
130 | 167 | ||
131 | void setReadAhead( uint count ); | 168 | void setReadAhead( uint count ); |
132 | virtual T cacheFind( int uid )const; | ||
133 | void cache( const T& )const; | 169 | void cache( const T& )const; |
134 | void setSaneCacheSize( int ); | 170 | void setSaneCacheSize( int ); |
135 | 171 | ||
136 | QArray<UID> records()const; | 172 | QArray<UID> records()const; |
137 | protected: | 173 | protected: |
138 | /** | 174 | /** |
139 | * invalidate the cache | 175 | * invalidate the cache |
140 | */ | 176 | */ |
141 | void invalidateCache(); | 177 | void invalidateCache(); |
142 | 178 | ||
143 | void setBackEnd( BackEnd* end ); | 179 | void setBackEnd( BackEnd* end ); |
144 | /** | 180 | /** |
@@ -249,29 +285,24 @@ OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime | |||
249 | template <class T> | 285 | template <class T> |
250 | T OPimAccessTemplate<T>::find( UID uid ) const{ | 286 | T OPimAccessTemplate<T>::find( UID uid ) const{ |
251 | // First search in cache.. | 287 | // First search in cache.. |
252 | if ( m_cache.contains( uid ) ) | 288 | if ( m_cache.contains( uid ) ) |
253 | return m_cache.find( uid ); | 289 | return m_cache.find( uid ); |
254 | 290 | ||
255 | T t = m_backEnd->find( uid ); | 291 | T t = m_backEnd->find( uid ); |
256 | cache( t ); | 292 | cache( t ); |
257 | 293 | ||
258 | return t; | 294 | return t; |
259 | } | 295 | } |
260 | 296 | ||
261 | template <class T> | ||
262 | T OPimAccessTemplate<T>::cacheFind( int uid ) const | ||
263 | { | ||
264 | return m_cache.find( uid ); | ||
265 | } | ||
266 | 297 | ||
267 | /** | 298 | /** |
268 | * read ahead cache find method ;) | 299 | * read ahead cache find method ;) |
269 | */ | 300 | */ |
270 | template <class T> | 301 | template <class T> |
271 | T OPimAccessTemplate<T>::find( UID uid, const QArray<int>& ar, | 302 | T OPimAccessTemplate<T>::find( UID uid, const QArray<int>& ar, |
272 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { | 303 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { |
273 | /* | 304 | /* |
274 | * better do T.isEmpty() | 305 | * better do T.isEmpty() |
275 | * after a find this way we would | 306 | * after a find this way we would |
276 | * avoid two finds in QCache... | 307 | * avoid two finds in QCache... |
277 | */ | 308 | */ |