summaryrefslogtreecommitdiff
path: root/libopie
authorzecke <zecke>2002-09-22 19:25:33 (UTC)
committer zecke <zecke>2002-09-22 19:25:33 (UTC)
commit3f194c85b5b9243ff30f1067361ef9fa5bb85a1e (patch) (unidiff)
tree909eae5d629918d579424a8ca644d6795b43faaf /libopie
parent4904161b6b043e1397db4affd7930fd999ff742e (diff)
downloadopie-3f194c85b5b9243ff30f1067361ef9fa5bb85a1e.zip
opie-3f194c85b5b9243ff30f1067361ef9fa5bb85a1e.tar.gz
opie-3f194c85b5b9243ff30f1067361ef9fa5bb85a1e.tar.bz2
Some documentation
and addition to OTodoAccess overDue and effectiveTodos
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/opimaccessbackend.h53
-rw-r--r--libopie/pim/opimaccesstemplate.h81
-rw-r--r--libopie/pim/opimrecord.h19
-rw-r--r--libopie/pim/orecordlist.h40
-rw-r--r--libopie/pim/otemplatebase.h3
5 files changed, 187 insertions, 9 deletions
diff --git a/libopie/pim/opimaccessbackend.h b/libopie/pim/opimaccessbackend.h
index 8e744e7..5707b58 100644
--- a/libopie/pim/opimaccessbackend.h
+++ b/libopie/pim/opimaccessbackend.h
@@ -1,36 +1,89 @@
1#ifndef OPIE_PIM_ACCESS_BACKEND 1#ifndef OPIE_PIM_ACCESS_BACKEND
2#define OPIE_PIM_ACCESS_BACKEND 2#define OPIE_PIM_ACCESS_BACKEND
3 3
4#include <qarray.h> 4#include <qarray.h>
5 5
6#include <opie/opimrecord.h> 6#include <opie/opimrecord.h>
7 7
8
9/**
10 * OPimAccessBackend is the base class
11 * for all private backends
12 * it operates on OPimRecord as the base class
13 * and it's responsible for fast manipulating
14 * the resource the implementation takes care
15 * of
16 */
8template <class T = OPimRecord> 17template <class T = OPimRecord>
9class OPimAccessBackend { 18class OPimAccessBackend {
10public: 19public:
11 OPimAccessBackend(); 20 OPimAccessBackend();
12 virtual ~OPimAccessBackend(); 21 virtual ~OPimAccessBackend();
22
23 /**
24 * load the resource
25 */
13 virtual void load() = 0; 26 virtual void load() = 0;
27
28 /**
29 * reload the resource
30 */
14 virtual void reload() = 0; 31 virtual void reload() = 0;
32
33 /**
34 * save the resource and
35 * all it's changes
36 */
15 virtual void save() = 0; 37 virtual void save() = 0;
38
39 /**
40 * return an array of
41 * all available uids
42 */
16 virtual QArray<int> allRecords()const = 0; 43 virtual QArray<int> allRecords()const = 0;
44
45 /**
46 * queryByExample for T with the SortOrder
47 * sort
48 */
17 virtual QArray<int> queryByExample( const T& t, int sort ) = 0; 49 virtual QArray<int> queryByExample( const T& t, int sort ) = 0;
50
51 /**
52 * find the OPimRecord with uid @param uid
53 * returns T and T.isEmpty() if nothing was found
54 */
18 virtual T find(int uid ) = 0; 55 virtual T find(int uid ) = 0;
56
57 /**
58 * clear the back end
59 */
19 virtual void clear() = 0; 60 virtual void clear() = 0;
61
62 /**
63 * add T
64 */
20 virtual bool add( const T& t ) = 0; 65 virtual bool add( const T& t ) = 0;
66
67 /**
68 * remove
69 */
21 virtual bool remove( int uid ) = 0; 70 virtual bool remove( int uid ) = 0;
71
72 /**
73 * replace a record with T.uid()
74 */
22 virtual bool replace( const T& t ) = 0; 75 virtual bool replace( const T& t ) = 0;
23 76
24 77
25}; 78};
26 79
27template <class T> 80template <class T>
28OPimAccessBackend<T>::OPimAccessBackend() { 81OPimAccessBackend<T>::OPimAccessBackend() {
29 82
30} 83}
31template <class T> 84template <class T>
32OPimAccessBackend<T>::~OPimAccessBackend() { 85OPimAccessBackend<T>::~OPimAccessBackend() {
33 86
34} 87}
35 88
36#endif 89#endif
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h
index e0708e1..36f5a99 100644
--- a/libopie/pim/opimaccesstemplate.h
+++ b/libopie/pim/opimaccesstemplate.h
@@ -1,118 +1,191 @@
1#ifndef OPIE_PIM_ACCESS_TEMPLATE_H 1#ifndef OPIE_PIM_ACCESS_TEMPLATE_H
2#define OPIE_PIM_ACCESS_TEMPLATE_H 2#define OPIE_PIM_ACCESS_TEMPLATE_H
3 3
4#include <qarray.h> 4#include <qarray.h>
5 5
6#include <opie/opimrecord.h> 6#include <opie/opimrecord.h>
7#include <opie/opimaccessbackend.h> 7#include <opie/opimaccessbackend.h>
8#include <opie/orecordlist.h> 8#include <opie/orecordlist.h>
9 9
10#include "otemplatebase.h" 10#include "otemplatebase.h"
11 11
12/**
13 * Thats the frontend to our OPIE PIM
14 * Library. Either you want to use it's
15 * interface or you want to implement
16 * your own Access lib
17 * Just create a OPimRecord and inherit from
18 * the plugins
19 */
20
12template <class T = OPimRecord > 21template <class T = OPimRecord >
13class OPimAccessTemplate : public OTemplateBase<T> { 22class OPimAccessTemplate : public OTemplateBase<T> {
14public: 23public:
15 typedef ORecordList<T> List; 24 typedef ORecordList<T> List;
16 typedef OPimAccessBackend<T> BackEnd; 25 typedef OPimAccessBackend<T> BackEnd;
26
27 /**
28 * our sort order
29 * should be safe explaining
30 */
31 enum SortOrder { WildCards = 0, IgnoreCase = 1,
32 RegExp = 2, ExactMatch = 4 };
33
34 /**
35 * c'tor BackEnd
36 */
17 OPimAccessTemplate( BackEnd* end); 37 OPimAccessTemplate( BackEnd* end);
18 virtual ~OPimAccessTemplate(); 38 virtual ~OPimAccessTemplate();
39
40 /**
41 * load from the backend
42 */
19 virtual void load(); 43 virtual void load();
44
45 /**
46 * reload from the backend
47 */
20 virtual void reload(); 48 virtual void reload();
49
50 /**
51 * save to the backend
52 */
21 virtual void save(); 53 virtual void save();
22 54
23 /* 55 /**
24 *do array to Records conversion 56 * if the resource was changed externally
25 * QArray<int> ids 57 */
58 bool wasChangedExternally()const;
59
60 /**
61 * return a List of records
62 * you can iterate over them
26 */ 63 */
27 virtual List allRecords()const; 64 virtual List allRecords()const;
65
66 /**
67 * queryByExample
68 */
28 virtual List queryByExample( const T& t, int sortOrder ); 69 virtual List queryByExample( const T& t, int sortOrder );
70
71 /**
72 * find the OPimRecord uid
73 */
29 virtual T find( int uid ); 74 virtual T find( int uid );
30 75
31 /* invalidate cache here */ 76 /* invalidate cache here */
77 /**
78 * clears the backend and invalidates the backend
79 */
32 virtual void clear() ; 80 virtual void clear() ;
81
82 /**
83 * add T to the backend
84 */
33 virtual bool add( const T& t ) ; 85 virtual bool add( const T& t ) ;
34 86
35 /* only the uid matters */ 87 /* only the uid matters */
88 /**
89 * remove T from the backend
90 */
36 virtual bool remove( const T& t ); 91 virtual bool remove( const T& t );
92
93 /**
94 * remove the OPimRecord with uid
95 */
37 virtual bool remove( int uid ); 96 virtual bool remove( int uid );
97
98 /**
99 * replace T from backend
100 */
38 virtual bool replace( const T& t) ; 101 virtual bool replace( const T& t) ;
39protected: 102protected:
103 /**
104 * invalidate the cache
105 */
40 void invalidateCache(); 106 void invalidateCache();
107
108 /**
109 * returns the backend
110 */
41 BackEnd* backEnd(); 111 BackEnd* backEnd();
42 BackEnd* m_backEnd; 112 BackEnd* m_backEnd;
43 113
44}; 114};
45 115
46template <class T> 116template <class T>
47OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) 117OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end )
48 : OTemplateBase<T>(), m_backEnd( end ) 118 : OTemplateBase<T>(), m_backEnd( end )
49{ 119{
50 120
51} 121}
52template <class T> 122template <class T>
53OPimAccessTemplate<T>::~OPimAccessTemplate() { 123OPimAccessTemplate<T>::~OPimAccessTemplate() {
54 qWarning("~OPimAccessTemplate<T>"); 124 qWarning("~OPimAccessTemplate<T>");
55 delete m_backEnd; 125 delete m_backEnd;
56} 126}
57template <class T> 127template <class T>
58void OPimAccessTemplate<T>::load() { 128void OPimAccessTemplate<T>::load() {
59 m_backEnd->load(); 129 m_backEnd->load();
60} 130}
61template <class T> 131template <class T>
62void OPimAccessTemplate<T>::reload() { 132void OPimAccessTemplate<T>::reload() {
63 m_backEnd->reload(); 133 m_backEnd->reload();
64} 134}
65template <class T> 135template <class T>
66void OPimAccessTemplate<T>::save() { 136void OPimAccessTemplate<T>::save() {
67 m_backEnd->save(); 137 m_backEnd->save();
68} 138}
69template <class T> 139template <class T>
70OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { 140OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const {
71 QArray<int> ints = m_backEnd->allRecords(); 141 QArray<int> ints = m_backEnd->allRecords();
72 List lis(ints, this ); 142 List lis(ints, this );
73 return lis; 143 return lis;
74} 144}
75template <class T> 145template <class T>
76OPimAccessTemplate<T>::List 146OPimAccessTemplate<T>::List
77OPimAccessTemplate<T>::queryByExample( const T& t, int sortOrder ) { 147OPimAccessTemplate<T>::queryByExample( const T& t, int sortOrder ) {
78 QArray<int> ints = m_backEnd->queryByExample( t, sortOrder ); 148 QArray<int> ints = m_backEnd->queryByExample( t, sortOrder );
79 149
80 List lis(ints, this ); 150 List lis(ints, this );
81 return lis; 151 return lis;
82} 152}
83template <class T> 153template <class T>
84T OPimAccessTemplate<T>::find( int uid ) { 154T OPimAccessTemplate<T>::find( int uid ) {
85 T t = m_backEnd->find( uid ); 155 T t = m_backEnd->find( uid );
86 return t; 156 return t;
87} 157}
88template <class T> 158template <class T>
89void OPimAccessTemplate<T>::clear() { 159void OPimAccessTemplate<T>::clear() {
90 invalidateCache(); 160 invalidateCache();
91 m_backEnd->clear(); 161 m_backEnd->clear();
92} 162}
93template <class T> 163template <class T>
94bool OPimAccessTemplate<T>::add( const T& t ) { 164bool OPimAccessTemplate<T>::add( const T& t ) {
95 return m_backEnd->add( t ); 165 return m_backEnd->add( t );
96} 166}
97template <class T> 167template <class T>
98bool OPimAccessTemplate<T>::remove( const T& t ) { 168bool OPimAccessTemplate<T>::remove( const T& t ) {
99 return m_backEnd->remove( t.uid() ); 169 return m_backEnd->remove( t.uid() );
100} 170}
101template <class T> 171template <class T>
102bool OPimAccessTemplate<T>::remove( int uid ) { 172bool OPimAccessTemplate<T>::remove( int uid ) {
103 return m_backEnd->remove( uid ); 173 return m_backEnd->remove( uid );
104} 174}
105template <class T> 175template <class T>
106bool OPimAccessTemplate<T>::replace( const T& t ) { 176bool OPimAccessTemplate<T>::replace( const T& t ) {
107 return m_backEnd->replace( t ); 177 return m_backEnd->replace( t );
108} 178}
109template <class T> 179template <class T>
110void OPimAccessTemplate<T>::invalidateCache() { 180void OPimAccessTemplate<T>::invalidateCache() {
111 181
112} 182}
113template <class T> 183template <class T>
114OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { 184OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() {
115 return m_backEnd; 185 return m_backEnd;
116} 186}
117 187template <class T>
188bool OPimAccessTemplate<T>::wasChangedExternally()const {
189 return false;
190}
118#endif 191#endif
diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h
index e4d33d6..dbb94ed 100644
--- a/libopie/pim/opimrecord.h
+++ b/libopie/pim/opimrecord.h
@@ -1,120 +1,133 @@
1#ifndef OPIE_PIM_RECORD_H 1#ifndef OPIE_PIM_RECORD_H
2#define OPIE_PIM_RECORD_H 2#define OPIE_PIM_RECORD_H
3 3
4#include <qmap.h> 4#include <qmap.h>
5#include <qstring.h> 5#include <qstring.h>
6#include <qstringlist.h> 6#include <qstringlist.h>
7 7
8#include <qpe/palmtoprecord.h> 8#include <qpe/palmtoprecord.h>
9 9
10
11/**
12 * This is the base class for
13 * all PIM Records
14 *
15 */
10class OPimRecord : public Qtopia::Record { 16class OPimRecord : public Qtopia::Record {
11public: 17public:
12 /** 18 /**
19 * c'tor
13 * uid of 0 isEmpty 20 * uid of 0 isEmpty
14 * uid of 1 will be assigned a new one 21 * uid of 1 will be assigned a new one
15 */ 22 */
16 OPimRecord(int uid = 0); 23 OPimRecord(int uid = 0);
17 ~OPimRecord(); 24 ~OPimRecord();
18 25
19 /** 26 /**
20 * copy c'tor 27 * copy c'tor
21 */ 28 */
22 OPimRecord( const OPimRecord& rec ); 29 OPimRecord( const OPimRecord& rec );
23 30
24 /** 31 /**
25 * copy operator 32 * copy operator
26 */ 33 */
27 OPimRecord &operator=( const OPimRecord& ); 34 OPimRecord &operator=( const OPimRecord& );
28 35
29 /** 36 /**
30 * category names resolved 37 * category names resolved
31 */ 38 */
32 QStringList categoryNames()const; 39 QStringList categoryNames()const;
33 40
34 /** 41 /**
35 * set category names they will be resolved 42 * set category names they will be resolved
36 */ 43 */
37 void setCategoryNames( const QStringList& ); 44 void setCategoryNames( const QStringList& );
38 45
39 /** 46 /**
40 * addCategoryName adds a name 47 * addCategoryName adds a name
41 * to the internal category list 48 * to the internal category list
42 */ 49 */
43 void addCategoryName( const QString& ); 50 void addCategoryName( const QString& );
44 51
45 /** 52 /**
46 * if a Record isEmpty 53 * if a Record isEmpty
54 * it's empty if it's 0
47 */ 55 */
48 virtual bool isEmpty()const; 56 virtual bool isEmpty()const;
49 57
50 /** 58 /**
51 * toRichText summary 59 * toRichText summary
52 */ 60 */
53 virtual QString toRichText()const = 0; 61 virtual QString toRichText()const = 0;
54 62
55 /** 63 /**
56 * a small one line summary 64 * a small one line summary
57 */ 65 */
58 virtual QString toShortText()const = 0; 66 virtual QString toShortText()const = 0;
59 67
60 /** 68 /**
61 * the name of the Record 69 * the name of the Record
62 */ 70 */
63 virtual QString type()const = 0; 71 virtual QString type()const = 0;
64 72
65 /** 73 /**
66 * converts the internal structure to a map 74 * converts the internal structure to a map
67 */ 75 */
68 virtual QMap<int, QString> toMap()const = 0; 76 virtual QMap<int, QString> toMap()const = 0;
69 77
70 /** 78 /**
71 * key value representation of extra items 79 * key value representation of extra items
72 */ 80 */
73 virtual QMap<QString, QString> toExtraMap()const = 0; 81 virtual QMap<QString, QString> toExtraMap()const = 0;
74 82
75 /** 83 /**
76 * the name for a recordField 84 * the name for a recordField
77 */ 85 */
78 virtual QString recordField(int)const = 0; 86 virtual QString recordField(int)const = 0;
79 87
80 /** 88 /**
81 * the related apps names 89 * the related apps names
82 */ 90 */
83 QStringList relatedApps()const; 91 QStringList relatedApps()const;
84 92
85 /** 93 /**
86 * the realtions between an app 94 * the realtions between an app
87 */ 95 */
88 QArray<int> relations( const QString& app )const; 96 QArray<int> relations( const QString& app )const;
89 97
90 /** 98 /**
91 * 99 * clear the relations for all relations
100 * with app
92 */ 101 */
93 void clearRelation( const QString& app ); 102 void clearRelation( const QString& app );
94 103
95 /** 104 /**
96 * 105 * add a relation
97 */ 106 */
98 void addRelation( const QString& app, int id ); 107 void addRelation( const QString& app, int id );
99 108
100 /** 109 /**
101 * 110 * set the relations for an app
102 */ 111 */
103 void setRelations( const QString&, QArray<int> ids ); 112 void setRelations( const QString&, QArray<int> ids );
113
114 /**
115 * set the uid
116 */
104 virtual void setUid( int uid ); 117 virtual void setUid( int uid );
105 118
106protected: 119protected:
107 Qtopia::UidGen &uidGen(); 120 Qtopia::UidGen &uidGen();
108 QString crossToString()const; 121 QString crossToString()const;
109 122
110private: 123private:
111 class OPimRecordPrivate; 124 class OPimRecordPrivate;
112 OPimRecordPrivate *d; 125 OPimRecordPrivate *d;
113 QMap<QString, QArray<int> > m_relations; 126 QMap<QString, QArray<int> > m_relations;
114 static Qtopia::UidGen m_uidGen; 127 static Qtopia::UidGen m_uidGen;
115 128
116}; 129};
117 130
118 131
119 132
120#endif 133#endif
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h
index a3955b0..3b30a73 100644
--- a/libopie/pim/orecordlist.h
+++ b/libopie/pim/orecordlist.h
@@ -1,165 +1,201 @@
1 1
2#ifndef OPIE_RECORD_LIST_H 2#ifndef OPIE_RECORD_LIST_H
3#define OPIE_RECORD_LIST_H 3#define OPIE_RECORD_LIST_H
4 4
5#include <qarray.h> 5#include <qarray.h>
6 6
7#include "otemplatebase.h" 7#include "otemplatebase.h"
8#include "opimrecord.h" 8#include "opimrecord.h"
9 9
10 10/**
11 * Our List Iterator
12 * it behaves like STL or Qt
13 *
14 * for(it = list.begin(); it != list.end(); ++it )
15 * doSomeCoolStuff( (*it) );
16 */
11template <class T = OPimRecord> 17template <class T = OPimRecord>
12class ORecordListIterator { 18class ORecordListIterator {
13public: 19public:
14 typedef OTemplateBase<T> Base; 20 typedef OTemplateBase<T> Base;
21
22 /**
23 * The c'tor used internally from
24 * ORecordList
25 */
15 ORecordListIterator( const QArray<int>, const Base* ); 26 ORecordListIterator( const QArray<int>, const Base* );
27
28 /**
29 * The standard c'tor
30 */
16 ORecordListIterator(); 31 ORecordListIterator();
17 ~ORecordListIterator(); 32 ~ORecordListIterator();
33
18 ORecordListIterator( const ORecordListIterator& ); 34 ORecordListIterator( const ORecordListIterator& );
19 ORecordListIterator &operator=(const ORecordListIterator& ); 35 ORecordListIterator &operator=(const ORecordListIterator& );
36
37 /**
38 * a * operator ;)
39 * use it like this T = (*it);
40 */
20 T &operator*(); 41 T &operator*();
21 ORecordListIterator &operator++(); 42 ORecordListIterator &operator++();
22 ORecordListIterator &operator--(); 43 ORecordListIterator &operator--();
23 44
24 bool operator==( const ORecordListIterator& it ); 45 bool operator==( const ORecordListIterator& it );
25 bool operator!=( const ORecordListIterator& it ); 46 bool operator!=( const ORecordListIterator& it );
26 47
27private: 48private:
28 QArray<int> m_uids; 49 QArray<int> m_uids;
29 int m_current; 50 int m_current;
30 const Base* m_temp; 51 const Base* m_temp;
31 bool m_end : 1; 52 bool m_end : 1;
32 T m_record; 53 T m_record;
33 54
34 /* d pointer for future versions */ 55 /* d pointer for future versions */
35 class IteratorPrivate; 56 class IteratorPrivate;
36 IteratorPrivate *d; 57 IteratorPrivate *d;
37}; 58};
38 59/**
60 * The recordlist used as a return type
61 * from OPimAccessTemplate
62 */
39template <class T = OPimRecord > 63template <class T = OPimRecord >
40class ORecordList { 64class ORecordList {
41public: 65public:
42 typedef OTemplateBase<T> Base; 66 typedef OTemplateBase<T> Base;
43 typedef ORecordListIterator<T> Iterator; 67 typedef ORecordListIterator<T> Iterator;
68
69 /**
70 * c'tor
71 */
44 ORecordList( const QArray<int>& ids, 72 ORecordList( const QArray<int>& ids,
45 const Base* ); 73 const Base* );
46 ~ORecordList(); 74 ~ORecordList();
75
76 /**
77 * the first iterator
78 */
47 Iterator begin(); 79 Iterator begin();
80
81 /**
82 * the end
83 */
48 Iterator end(); 84 Iterator end();
49 /* 85 /*
50 ConstIterator begin()const; 86 ConstIterator begin()const;
51 ConstIterator end()const; 87 ConstIterator end()const;
52 */ 88 */
53private: 89private:
54 QArray<int> m_ids; 90 QArray<int> m_ids;
55 const Base* m_acc; 91 const Base* m_acc;
56}; 92};
57 93
58/* ok now implement it */ 94/* ok now implement it */
59template <class T> 95template <class T>
60ORecordListIterator<T>::ORecordListIterator() { 96ORecordListIterator<T>::ORecordListIterator() {
61 m_current = 0; 97 m_current = 0;
62 m_temp = 0l; 98 m_temp = 0l;
63 m_end = true; 99 m_end = true;
64} 100}
65template <class T> 101template <class T>
66ORecordListIterator<T>::~ORecordListIterator() { 102ORecordListIterator<T>::~ORecordListIterator() {
67/* nothing to delete */ 103/* nothing to delete */
68} 104}
69 105
70template <class T> 106template <class T>
71ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { 107ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
72 m_uids = it.m_uids; 108 m_uids = it.m_uids;
73 m_current = it.m_current; 109 m_current = it.m_current;
74 m_temp = it.m_temp; 110 m_temp = it.m_temp;
75 m_end = it.m_end; 111 m_end = it.m_end;
76 m_record = it.m_record; 112 m_record = it.m_record;
77} 113}
78 114
79template <class T> 115template <class T>
80ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { 116ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) {
81 m_uids = it.m_uids; 117 m_uids = it.m_uids;
82 m_current = it.m_current; 118 m_current = it.m_current;
83 m_temp = it.m_temp; 119 m_temp = it.m_temp;
84 m_end = it.m_end; 120 m_end = it.m_end;
85 m_record = it.m_record; 121 m_record = it.m_record;
86 122
87 return *this; 123 return *this;
88} 124}
89 125
90template <class T> 126template <class T>
91T &ORecordListIterator<T>::operator*() { 127T &ORecordListIterator<T>::operator*() {
92 if (!m_end ) 128 if (!m_end )
93 m_record = m_temp->find( m_uids[m_current] ); 129 m_record = m_temp->find( m_uids[m_current] );
94 else 130 else
95 m_record = T(); 131 m_record = T();
96 132
97 return m_record; 133 return m_record;
98} 134}
99 135
100template <class T> 136template <class T>
101ORecordListIterator<T> &ORecordListIterator<T>::operator++() { 137ORecordListIterator<T> &ORecordListIterator<T>::operator++() {
102 if (m_current < m_uids.count() ) { 138 if (m_current < m_uids.count() ) {
103 m_end = false; 139 m_end = false;
104 ++m_current; 140 ++m_current;
105 }else 141 }else
106 m_end = true; 142 m_end = true;
107 143
108 return *this; 144 return *this;
109} 145}
110template <class T> 146template <class T>
111ORecordListIterator<T> &ORecordListIterator<T>::operator--() { 147ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
112 if ( m_current > 0 ) { 148 if ( m_current > 0 ) {
113 --m_current; 149 --m_current;
114 m_end = false; 150 m_end = false;
115 } else 151 } else
116 m_end = true; 152 m_end = true;
117 153
118 return *this; 154 return *this;
119} 155}
120 156
121template <class T> 157template <class T>
122bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { 158bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
123 159
124 /* if both are at we're the same.... */ 160 /* if both are at we're the same.... */
125 if ( m_end == it.m_end ) return true; 161 if ( m_end == it.m_end ) return true;
126 162
127 if ( m_uids != it.m_uids ) return false; 163 if ( m_uids != it.m_uids ) return false;
128 if ( m_current != it.m_current ) return false; 164 if ( m_current != it.m_current ) return false;
129 if ( m_temp != it.m_temp ) return false; 165 if ( m_temp != it.m_temp ) return false;
130 166
131 return true; 167 return true;
132} 168}
133template <class T> 169template <class T>
134bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { 170bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) {
135 return !(*this == it ); 171 return !(*this == it );
136} 172}
137template <class T> 173template <class T>
138ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, 174ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
139 const Base* t ) 175 const Base* t )
140 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) 176 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false )
141{ 177{
142} 178}
143 179
144template <class T> 180template <class T>
145ORecordList<T>::ORecordList( const QArray<int>& ids, 181ORecordList<T>::ORecordList( const QArray<int>& ids,
146 const Base* acc ) 182 const Base* acc )
147 : m_ids( ids ), m_acc( acc ) 183 : m_ids( ids ), m_acc( acc )
148{ 184{
149} 185}
150template <class T> 186template <class T>
151ORecordList<T>::~ORecordList() { 187ORecordList<T>::~ORecordList() {
152/* nothing to do here */ 188/* nothing to do here */
153} 189}
154template <class T> 190template <class T>
155ORecordList<T>::Iterator ORecordList<T>::begin() { 191ORecordList<T>::Iterator ORecordList<T>::begin() {
156 Iterator it( m_ids, m_acc ); 192 Iterator it( m_ids, m_acc );
157 return it; 193 return it;
158} 194}
159template <class T> 195template <class T>
160ORecordList<T>::Iterator ORecordList<T>::end() { 196ORecordList<T>::Iterator ORecordList<T>::end() {
161 Iterator it( m_ids, m_acc ); 197 Iterator it( m_ids, m_acc );
162 it.m_end = true; 198 it.m_end = true;
163 it.m_current = m_ids.count(); 199 it.m_current = m_ids.count();
164} 200}
165#endif 201#endif
diff --git a/libopie/pim/otemplatebase.h b/libopie/pim/otemplatebase.h
index 41cc934..add1de4 100644
--- a/libopie/pim/otemplatebase.h
+++ b/libopie/pim/otemplatebase.h
@@ -1,18 +1,21 @@
1#ifndef OPIE_TEMPLATE_BASE_H 1#ifndef OPIE_TEMPLATE_BASE_H
2#define OPIE_TEMPLATE_BASE_H 2#define OPIE_TEMPLATE_BASE_H
3 3
4#include "opimrecord.h" 4#include "opimrecord.h"
5 5
6/**
7 * internal template base
8 */
6template <class T = OPimRecord> 9template <class T = OPimRecord>
7class OTemplateBase { 10class OTemplateBase {
8public: 11public:
9 OTemplateBase() { 12 OTemplateBase() {
10 }; 13 };
11 virtual ~OTemplateBase() { 14 virtual ~OTemplateBase() {
12 } 15 }
13 virtual T find( int uid ) = 0; 16 virtual T find( int uid ) = 0;
14 17
15}; 18};
16 19
17 20
18#endif 21#endif