-rw-r--r-- | libopie/pim/opimaccessbackend.h | 53 | ||||
-rw-r--r-- | libopie/pim/opimaccesstemplate.h | 81 | ||||
-rw-r--r-- | libopie/pim/opimrecord.h | 19 | ||||
-rw-r--r-- | libopie/pim/orecordlist.h | 40 | ||||
-rw-r--r-- | libopie/pim/otemplatebase.h | 3 | ||||
-rw-r--r-- | libopie2/opiepim/backend/opimaccessbackend.h | 53 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimaccesstemplate.h | 81 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.h | 19 | ||||
-rw-r--r-- | libopie2/opiepim/core/otemplatebase.h | 3 | ||||
-rw-r--r-- | libopie2/opiepim/orecordlist.h | 40 |
10 files changed, 374 insertions, 18 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 | |||
@@ -4,22 +4,75 @@ | |||
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 | */ | ||
8 | template <class T = OPimRecord> | 17 | template <class T = OPimRecord> |
9 | class OPimAccessBackend { | 18 | class OPimAccessBackend { |
10 | public: | 19 | public: |
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 | }; |
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 | |||
@@ -8,37 +8,107 @@ | |||
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 | |||
12 | template <class T = OPimRecord > | 21 | template <class T = OPimRecord > |
13 | class OPimAccessTemplate : public OTemplateBase<T> { | 22 | class OPimAccessTemplate : public OTemplateBase<T> { |
14 | public: | 23 | public: |
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) ; |
39 | protected: | 102 | protected: |
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 | }; |
@@ -113,6 +183,9 @@ void OPimAccessTemplate<T>::invalidateCache() { | |||
113 | template <class T> | 183 | template <class T> |
114 | OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { | 184 | OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { |
115 | return m_backEnd; | 185 | return m_backEnd; |
116 | } | 186 | } |
117 | 187 | template <class T> | |
188 | bool 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 | |||
@@ -6,11 +6,18 @@ | |||
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 | */ | ||
10 | class OPimRecord : public Qtopia::Record { | 16 | class OPimRecord : public Qtopia::Record { |
11 | public: | 17 | public: |
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); |
@@ -43,8 +50,9 @@ public: | |||
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 | /** |
@@ -87,21 +95,26 @@ public: | |||
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 | ||
106 | protected: | 119 | protected: |
107 | Qtopia::UidGen &uidGen(); | 120 | Qtopia::UidGen &uidGen(); |
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 | |||
@@ -6,18 +6,39 @@ | |||
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 | */ | ||
11 | template <class T = OPimRecord> | 17 | template <class T = OPimRecord> |
12 | class ORecordListIterator { | 18 | class ORecordListIterator { |
13 | public: | 19 | public: |
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 | ||
@@ -34,18 +55,33 @@ private: | |||
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 | */ | ||
39 | template <class T = OPimRecord > | 63 | template <class T = OPimRecord > |
40 | class ORecordList { | 64 | class ORecordList { |
41 | public: | 65 | public: |
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; |
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 | |||
@@ -2,8 +2,11 @@ | |||
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 | */ | ||
6 | template <class T = OPimRecord> | 9 | template <class T = OPimRecord> |
7 | class OTemplateBase { | 10 | class OTemplateBase { |
8 | public: | 11 | public: |
9 | OTemplateBase() { | 12 | OTemplateBase() { |
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h index 8e744e7..5707b58 100644 --- a/libopie2/opiepim/backend/opimaccessbackend.h +++ b/libopie2/opiepim/backend/opimaccessbackend.h | |||
@@ -4,22 +4,75 @@ | |||
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 | */ | ||
8 | template <class T = OPimRecord> | 17 | template <class T = OPimRecord> |
9 | class OPimAccessBackend { | 18 | class OPimAccessBackend { |
10 | public: | 19 | public: |
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 | }; |
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h index e0708e1..36f5a99 100644 --- a/libopie2/opiepim/core/opimaccesstemplate.h +++ b/libopie2/opiepim/core/opimaccesstemplate.h | |||
@@ -8,37 +8,107 @@ | |||
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 | |||
12 | template <class T = OPimRecord > | 21 | template <class T = OPimRecord > |
13 | class OPimAccessTemplate : public OTemplateBase<T> { | 22 | class OPimAccessTemplate : public OTemplateBase<T> { |
14 | public: | 23 | public: |
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) ; |
39 | protected: | 102 | protected: |
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 | }; |
@@ -113,6 +183,9 @@ void OPimAccessTemplate<T>::invalidateCache() { | |||
113 | template <class T> | 183 | template <class T> |
114 | OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { | 184 | OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { |
115 | return m_backEnd; | 185 | return m_backEnd; |
116 | } | 186 | } |
117 | 187 | template <class T> | |
188 | bool OPimAccessTemplate<T>::wasChangedExternally()const { | ||
189 | return false; | ||
190 | } | ||
118 | #endif | 191 | #endif |
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h index e4d33d6..dbb94ed 100644 --- a/libopie2/opiepim/core/opimrecord.h +++ b/libopie2/opiepim/core/opimrecord.h | |||
@@ -6,11 +6,18 @@ | |||
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 | */ | ||
10 | class OPimRecord : public Qtopia::Record { | 16 | class OPimRecord : public Qtopia::Record { |
11 | public: | 17 | public: |
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); |
@@ -43,8 +50,9 @@ public: | |||
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 | /** |
@@ -87,21 +95,26 @@ public: | |||
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 | ||
106 | protected: | 119 | protected: |
107 | Qtopia::UidGen &uidGen(); | 120 | Qtopia::UidGen &uidGen(); |
diff --git a/libopie2/opiepim/core/otemplatebase.h b/libopie2/opiepim/core/otemplatebase.h index 41cc934..add1de4 100644 --- a/libopie2/opiepim/core/otemplatebase.h +++ b/libopie2/opiepim/core/otemplatebase.h | |||
@@ -2,8 +2,11 @@ | |||
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 | */ | ||
6 | template <class T = OPimRecord> | 9 | template <class T = OPimRecord> |
7 | class OTemplateBase { | 10 | class OTemplateBase { |
8 | public: | 11 | public: |
9 | OTemplateBase() { | 12 | OTemplateBase() { |
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h index a3955b0..3b30a73 100644 --- a/libopie2/opiepim/orecordlist.h +++ b/libopie2/opiepim/orecordlist.h | |||
@@ -6,18 +6,39 @@ | |||
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 | */ | ||
11 | template <class T = OPimRecord> | 17 | template <class T = OPimRecord> |
12 | class ORecordListIterator { | 18 | class ORecordListIterator { |
13 | public: | 19 | public: |
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 | ||
@@ -34,18 +55,33 @@ private: | |||
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 | */ | ||
39 | template <class T = OPimRecord > | 63 | template <class T = OPimRecord > |
40 | class ORecordList { | 64 | class ORecordList { |
41 | public: | 65 | public: |
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; |