-rw-r--r-- | libopie/pim/opimaccessbackend.h | 28 | ||||
-rw-r--r-- | libopie/pim/opimaccesstemplate.h | 53 | ||||
-rw-r--r-- | libopie/pim/orecordlist.h | 29 | ||||
-rw-r--r-- | libopie/pim/otemplatebase.h | 2 | ||||
-rw-r--r-- | libopie/pim/otodo.cpp | 15 | ||||
-rw-r--r-- | libopie/pim/otodo.h | 10 | ||||
-rw-r--r-- | libopie/pim/otodoaccess.cpp | 71 | ||||
-rw-r--r-- | libopie/pim/otodoaccess.h | 79 | ||||
-rw-r--r-- | libopie/pim/otodoaccessbackend.cpp | 10 | ||||
-rw-r--r-- | libopie/pim/otodoaccessbackend.h | 18 | ||||
-rw-r--r-- | libopie/pim/otodoaccessxml.cpp | 362 | ||||
-rw-r--r-- | libopie/pim/otodoaccessxml.h | 53 |
12 files changed, 665 insertions, 65 deletions
diff --git a/libopie/pim/opimaccessbackend.h b/libopie/pim/opimaccessbackend.h index 5707b58..c27acbb 100644 --- a/libopie/pim/opimaccessbackend.h +++ b/libopie/pim/opimaccessbackend.h | |||
@@ -1,89 +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 | 8 | ||
9 | /** | 9 | /** |
10 | * OPimAccessBackend is the base class | 10 | * OPimAccessBackend is the base class |
11 | * for all private backends | 11 | * for all private backends |
12 | * it operates on OPimRecord as the base class | 12 | * it operates on OPimRecord as the base class |
13 | * and it's responsible for fast manipulating | 13 | * and it's responsible for fast manipulating |
14 | * the resource the implementation takes care | 14 | * the resource the implementation takes care |
15 | * of | 15 | * of |
16 | */ | 16 | */ |
17 | template <class T = OPimRecord> | 17 | template <class T = OPimRecord> |
18 | class OPimAccessBackend { | 18 | class OPimAccessBackend { |
19 | public: | 19 | public: |
20 | OPimAccessBackend(); | 20 | OPimAccessBackend(); |
21 | virtual ~OPimAccessBackend(); | 21 | virtual ~OPimAccessBackend(); |
22 | 22 | ||
23 | /** | 23 | /** |
24 | * load the resource | 24 | * load the resource |
25 | */ | 25 | */ |
26 | virtual void load() = 0; | 26 | virtual bool load() = 0; |
27 | 27 | ||
28 | /** | 28 | /** |
29 | * reload the resource | 29 | * reload the resource |
30 | */ | 30 | */ |
31 | virtual void reload() = 0; | 31 | virtual bool reload() = 0; |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * save the resource and | 34 | * save the resource and |
35 | * all it's changes | 35 | * all it's changes |
36 | */ | 36 | */ |
37 | virtual void save() = 0; | 37 | virtual bool save() = 0; |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * return an array of | 40 | * return an array of |
41 | * all available uids | 41 | * all available uids |
42 | */ | 42 | */ |
43 | virtual QArray<int> allRecords()const = 0; | 43 | virtual QArray<int> allRecords()const = 0; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * queryByExample for T with the SortOrder | 46 | * queryByExample for T with the SortOrder |
47 | * sort | 47 | * sort |
48 | */ | 48 | */ |
49 | virtual QArray<int> queryByExample( const T& t, int sort ) = 0; | 49 | virtual QArray<int> queryByExample( const T& t, int sort ) = 0; |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * find the OPimRecord with uid @param uid | 52 | * find the OPimRecord with uid @param uid |
53 | * returns T and T.isEmpty() if nothing was found | 53 | * returns T and T.isEmpty() if nothing was found |
54 | */ | 54 | */ |
55 | virtual T find(int uid ) = 0; | 55 | virtual T find(int uid )const = 0; |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * clear the back end | 58 | * clear the back end |
59 | */ | 59 | */ |
60 | virtual void clear() = 0; | 60 | virtual void clear() = 0; |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * add T | 63 | * add T |
64 | */ | 64 | */ |
65 | virtual bool add( const T& t ) = 0; | 65 | virtual bool add( const T& t ) = 0; |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * remove | 68 | * remove |
69 | */ | 69 | */ |
70 | virtual bool remove( int uid ) = 0; | 70 | virtual bool remove( int uid ) = 0; |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * replace a record with T.uid() | 73 | * replace a record with T.uid() |
74 | */ | 74 | */ |
75 | virtual bool replace( const T& t ) = 0; | 75 | virtual bool replace( const T& t ) = 0; |
76 | 76 | ||
77 | 77 | ||
78 | }; | 78 | }; |
79 | 79 | ||
80 | template <class T> | 80 | template <class T> |
81 | OPimAccessBackend<T>::OPimAccessBackend() { | 81 | OPimAccessBackend<T>::OPimAccessBackend() { |
82 | 82 | ||
83 | } | 83 | } |
84 | template <class T> | 84 | template <class T> |
85 | OPimAccessBackend<T>::~OPimAccessBackend() { | 85 | OPimAccessBackend<T>::~OPimAccessBackend() { |
86 | 86 | ||
87 | } | 87 | } |
88 | 88 | ||
89 | #endif | 89 | #endif |
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h index 36f5a99..31ab516 100644 --- a/libopie/pim/opimaccesstemplate.h +++ b/libopie/pim/opimaccesstemplate.h | |||
@@ -1,191 +1,196 @@ | |||
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 | /** | 12 | /** |
13 | * Thats the frontend to our OPIE PIM | 13 | * Thats the frontend to our OPIE PIM |
14 | * Library. Either you want to use it's | 14 | * Library. Either you want to use it's |
15 | * interface or you want to implement | 15 | * interface or you want to implement |
16 | * your own Access lib | 16 | * your own Access lib |
17 | * Just create a OPimRecord and inherit from | 17 | * Just create a OPimRecord and inherit from |
18 | * the plugins | 18 | * the plugins |
19 | */ | 19 | */ |
20 | 20 | ||
21 | template <class T = OPimRecord > | 21 | template <class T = OPimRecord > |
22 | class OPimAccessTemplate : public OTemplateBase<T> { | 22 | class OPimAccessTemplate : public OTemplateBase<T> { |
23 | public: | 23 | public: |
24 | typedef ORecordList<T> List; | 24 | typedef ORecordList<T> List; |
25 | typedef OPimAccessBackend<T> BackEnd; | 25 | typedef OPimAccessBackend<T> BackEnd; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * our sort order | 28 | * our sort order |
29 | * should be safe explaining | 29 | * should be safe explaining |
30 | */ | 30 | */ |
31 | enum SortOrder { WildCards = 0, IgnoreCase = 1, | 31 | enum SortOrder { WildCards = 0, IgnoreCase = 1, |
32 | RegExp = 2, ExactMatch = 4 }; | 32 | RegExp = 2, ExactMatch = 4 }; |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * c'tor BackEnd | 35 | * c'tor BackEnd |
36 | */ | 36 | */ |
37 | OPimAccessTemplate( BackEnd* end); | 37 | OPimAccessTemplate( BackEnd* end); |
38 | virtual ~OPimAccessTemplate(); | 38 | virtual ~OPimAccessTemplate(); |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * load from the backend | 41 | * load from the backend |
42 | */ | 42 | */ |
43 | virtual void load(); | 43 | virtual bool load(); |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * reload from the backend | 46 | * reload from the backend |
47 | */ | 47 | */ |
48 | virtual void reload(); | 48 | virtual bool reload(); |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * save to the backend | 51 | * save to the backend |
52 | */ | 52 | */ |
53 | virtual void save(); | 53 | virtual bool save(); |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * if the resource was changed externally | 56 | * if the resource was changed externally |
57 | */ | 57 | */ |
58 | bool wasChangedExternally()const; | 58 | bool wasChangedExternally()const; |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * return a List of records | 61 | * return a List of records |
62 | * you can iterate over them | 62 | * you can iterate over them |
63 | */ | 63 | */ |
64 | virtual List allRecords()const; | 64 | virtual List allRecords()const; |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * queryByExample | 67 | * queryByExample |
68 | */ | 68 | */ |
69 | virtual List queryByExample( const T& t, int sortOrder ); | 69 | virtual List queryByExample( const T& t, int sortOrder ); |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * find the OPimRecord uid | 72 | * find the OPimRecord uid |
73 | */ | 73 | */ |
74 | virtual T find( int uid ); | 74 | virtual T find( int uid )const; |
75 | 75 | ||
76 | /* invalidate cache here */ | 76 | /* invalidate cache here */ |
77 | /** | 77 | /** |
78 | * clears the backend and invalidates the backend | 78 | * clears the backend and invalidates the backend |
79 | */ | 79 | */ |
80 | virtual void clear() ; | 80 | virtual void clear() ; |
81 | 81 | ||
82 | /** | 82 | /** |
83 | * add T to the backend | 83 | * add T to the backend |
84 | */ | 84 | */ |
85 | virtual bool add( const T& t ) ; | 85 | virtual bool add( const T& t ) ; |
86 | 86 | ||
87 | /* only the uid matters */ | 87 | /* only the uid matters */ |
88 | /** | 88 | /** |
89 | * remove T from the backend | 89 | * remove T from the backend |
90 | */ | 90 | */ |
91 | virtual bool remove( const T& t ); | 91 | virtual bool remove( const T& t ); |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * remove the OPimRecord with uid | 94 | * remove the OPimRecord with uid |
95 | */ | 95 | */ |
96 | virtual bool remove( int uid ); | 96 | virtual bool remove( int uid ); |
97 | 97 | ||
98 | /** | 98 | /** |
99 | * replace T from backend | 99 | * replace T from backend |
100 | */ | 100 | */ |
101 | virtual bool replace( const T& t) ; | 101 | virtual bool replace( const T& t) ; |
102 | protected: | 102 | protected: |
103 | /** | 103 | /** |
104 | * invalidate the cache | 104 | * invalidate the cache |
105 | */ | 105 | */ |
106 | void invalidateCache(); | 106 | void invalidateCache(); |
107 | 107 | ||
108 | void setBackEnd( BackEnd* end ); | ||
108 | /** | 109 | /** |
109 | * returns the backend | 110 | * returns the backend |
110 | */ | 111 | */ |
111 | BackEnd* backEnd(); | 112 | BackEnd* backEnd(); |
112 | BackEnd* m_backEnd; | 113 | BackEnd* m_backEnd; |
113 | 114 | ||
114 | }; | 115 | }; |
115 | 116 | ||
116 | template <class T> | 117 | template <class T> |
117 | OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) | 118 | OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) |
118 | : OTemplateBase<T>(), m_backEnd( end ) | 119 | : OTemplateBase<T>(), m_backEnd( end ) |
119 | { | 120 | { |
120 | 121 | ||
121 | } | 122 | } |
122 | template <class T> | 123 | template <class T> |
123 | OPimAccessTemplate<T>::~OPimAccessTemplate() { | 124 | OPimAccessTemplate<T>::~OPimAccessTemplate() { |
124 | qWarning("~OPimAccessTemplate<T>"); | 125 | qWarning("~OPimAccessTemplate<T>"); |
125 | delete m_backEnd; | 126 | delete m_backEnd; |
126 | } | 127 | } |
127 | template <class T> | 128 | template <class T> |
128 | void OPimAccessTemplate<T>::load() { | 129 | bool OPimAccessTemplate<T>::load() { |
129 | m_backEnd->load(); | 130 | return m_backEnd->load(); |
130 | } | 131 | } |
131 | template <class T> | 132 | template <class T> |
132 | void OPimAccessTemplate<T>::reload() { | 133 | bool OPimAccessTemplate<T>::reload() { |
133 | m_backEnd->reload(); | 134 | return m_backEnd->reload(); |
134 | } | 135 | } |
135 | template <class T> | 136 | template <class T> |
136 | void OPimAccessTemplate<T>::save() { | 137 | bool OPimAccessTemplate<T>::save() { |
137 | m_backEnd->save(); | 138 | return m_backEnd->save(); |
138 | } | 139 | } |
139 | template <class T> | 140 | template <class T> |
140 | OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { | 141 | OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { |
141 | QArray<int> ints = m_backEnd->allRecords(); | 142 | QArray<int> ints = m_backEnd->allRecords(); |
142 | List lis(ints, this ); | 143 | List lis(ints, this ); |
143 | return lis; | 144 | return lis; |
144 | } | 145 | } |
145 | template <class T> | 146 | template <class T> |
146 | OPimAccessTemplate<T>::List | 147 | OPimAccessTemplate<T>::List |
147 | OPimAccessTemplate<T>::queryByExample( const T& t, int sortOrder ) { | 148 | OPimAccessTemplate<T>::queryByExample( const T& t, int sortOrder ) { |
148 | QArray<int> ints = m_backEnd->queryByExample( t, sortOrder ); | 149 | QArray<int> ints = m_backEnd->queryByExample( t, sortOrder ); |
149 | 150 | ||
150 | List lis(ints, this ); | 151 | List lis(ints, this ); |
151 | return lis; | 152 | return lis; |
152 | } | 153 | } |
153 | template <class T> | 154 | template <class T> |
154 | T OPimAccessTemplate<T>::find( int uid ) { | 155 | T OPimAccessTemplate<T>::find( int uid ) const{ |
155 | T t = m_backEnd->find( uid ); | 156 | T t = m_backEnd->find( uid ); |
156 | return t; | 157 | return t; |
157 | } | 158 | } |
158 | template <class T> | 159 | template <class T> |
159 | void OPimAccessTemplate<T>::clear() { | 160 | void OPimAccessTemplate<T>::clear() { |
160 | invalidateCache(); | 161 | invalidateCache(); |
161 | m_backEnd->clear(); | 162 | m_backEnd->clear(); |
162 | } | 163 | } |
163 | template <class T> | 164 | template <class T> |
164 | bool OPimAccessTemplate<T>::add( const T& t ) { | 165 | bool OPimAccessTemplate<T>::add( const T& t ) { |
165 | return m_backEnd->add( t ); | 166 | return m_backEnd->add( t ); |
166 | } | 167 | } |
167 | template <class T> | 168 | template <class T> |
168 | bool OPimAccessTemplate<T>::remove( const T& t ) { | 169 | bool OPimAccessTemplate<T>::remove( const T& t ) { |
169 | return m_backEnd->remove( t.uid() ); | 170 | return m_backEnd->remove( t.uid() ); |
170 | } | 171 | } |
171 | template <class T> | 172 | template <class T> |
172 | bool OPimAccessTemplate<T>::remove( int uid ) { | 173 | bool OPimAccessTemplate<T>::remove( int uid ) { |
173 | return m_backEnd->remove( uid ); | 174 | return m_backEnd->remove( uid ); |
174 | } | 175 | } |
175 | template <class T> | 176 | template <class T> |
176 | bool OPimAccessTemplate<T>::replace( const T& t ) { | 177 | bool OPimAccessTemplate<T>::replace( const T& t ) { |
177 | return m_backEnd->replace( t ); | 178 | return m_backEnd->replace( t ); |
178 | } | 179 | } |
179 | template <class T> | 180 | template <class T> |
180 | void OPimAccessTemplate<T>::invalidateCache() { | 181 | void OPimAccessTemplate<T>::invalidateCache() { |
181 | 182 | ||
182 | } | 183 | } |
183 | template <class T> | 184 | template <class T> |
184 | OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { | 185 | OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { |
185 | return m_backEnd; | 186 | return m_backEnd; |
186 | } | 187 | } |
187 | template <class T> | 188 | template <class T> |
188 | bool OPimAccessTemplate<T>::wasChangedExternally()const { | 189 | bool OPimAccessTemplate<T>::wasChangedExternally()const { |
189 | return false; | 190 | return false; |
190 | } | 191 | } |
192 | template <class T> | ||
193 | void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) { | ||
194 | m_backEnd = end; | ||
195 | } | ||
191 | #endif | 196 | #endif |
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h index 3b30a73..75bb33c 100644 --- a/libopie/pim/orecordlist.h +++ b/libopie/pim/orecordlist.h | |||
@@ -1,201 +1,208 @@ | |||
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 | 11 | * Our List Iterator |
12 | * it behaves like STL or Qt | 12 | * it behaves like STL or Qt |
13 | * | 13 | * |
14 | * for(it = list.begin(); it != list.end(); ++it ) | 14 | * for(it = list.begin(); it != list.end(); ++it ) |
15 | * doSomeCoolStuff( (*it) ); | 15 | * doSomeCoolStuff( (*it) ); |
16 | */ | 16 | */ |
17 | template <class T> class ORecordList; | ||
17 | template <class T = OPimRecord> | 18 | template <class T = OPimRecord> |
18 | class ORecordListIterator { | 19 | class ORecordListIterator { |
20 | friend class ORecordList<T>; | ||
19 | public: | 21 | public: |
20 | typedef OTemplateBase<T> Base; | 22 | typedef OTemplateBase<T> Base; |
21 | 23 | ||
22 | /** | 24 | /** |
23 | * The c'tor used internally from | 25 | * The c'tor used internally from |
24 | * ORecordList | 26 | * ORecordList |
25 | */ | 27 | */ |
26 | ORecordListIterator( const QArray<int>, const Base* ); | 28 | ORecordListIterator( const QArray<int>, const Base* ); |
27 | 29 | ||
28 | /** | 30 | /** |
29 | * The standard c'tor | 31 | * The standard c'tor |
30 | */ | 32 | */ |
31 | ORecordListIterator(); | 33 | ORecordListIterator(); |
32 | ~ORecordListIterator(); | 34 | ~ORecordListIterator(); |
33 | 35 | ||
34 | ORecordListIterator( const ORecordListIterator& ); | 36 | ORecordListIterator( const ORecordListIterator& ); |
35 | ORecordListIterator &operator=(const ORecordListIterator& ); | 37 | ORecordListIterator &operator=(const ORecordListIterator& ); |
36 | 38 | ||
37 | /** | 39 | /** |
38 | * a * operator ;) | 40 | * a * operator ;) |
39 | * use it like this T = (*it); | 41 | * use it like this T = (*it); |
40 | */ | 42 | */ |
41 | T &operator*(); | 43 | T &operator*(); |
42 | ORecordListIterator &operator++(); | 44 | ORecordListIterator &operator++(); |
43 | ORecordListIterator &operator--(); | 45 | ORecordListIterator &operator--(); |
44 | 46 | ||
45 | bool operator==( const ORecordListIterator& it ); | 47 | bool operator==( const ORecordListIterator& it ); |
46 | bool operator!=( const ORecordListIterator& it ); | 48 | bool operator!=( const ORecordListIterator& it ); |
47 | 49 | ||
48 | private: | 50 | private: |
49 | QArray<int> m_uids; | 51 | QArray<int> m_uids; |
50 | int m_current; | 52 | int m_current; |
51 | const Base* m_temp; | 53 | const Base* m_temp; |
52 | bool m_end : 1; | 54 | bool m_end : 1; |
53 | T m_record; | 55 | T m_record; |
54 | 56 | ||
55 | /* d pointer for future versions */ | 57 | /* d pointer for future versions */ |
56 | class IteratorPrivate; | 58 | class IteratorPrivate; |
57 | IteratorPrivate *d; | 59 | IteratorPrivate *d; |
58 | }; | 60 | }; |
59 | /** | 61 | /** |
60 | * The recordlist used as a return type | 62 | * The recordlist used as a return type |
61 | * from OPimAccessTemplate | 63 | * from OPimAccessTemplate |
62 | */ | 64 | */ |
63 | template <class T = OPimRecord > | 65 | template <class T = OPimRecord > |
64 | class ORecordList { | 66 | class ORecordList { |
65 | public: | 67 | public: |
66 | typedef OTemplateBase<T> Base; | 68 | typedef OTemplateBase<T> Base; |
67 | typedef ORecordListIterator<T> Iterator; | 69 | typedef ORecordListIterator<T> Iterator; |
68 | 70 | ||
69 | /** | 71 | /** |
70 | * c'tor | 72 | * c'tor |
71 | */ | 73 | */ |
72 | ORecordList( const QArray<int>& ids, | 74 | ORecordList( const QArray<int>& ids, |
73 | const Base* ); | 75 | const Base* ); |
74 | ~ORecordList(); | 76 | ~ORecordList(); |
75 | 77 | ||
76 | /** | 78 | /** |
77 | * the first iterator | 79 | * the first iterator |
78 | */ | 80 | */ |
79 | Iterator begin(); | 81 | Iterator begin(); |
80 | 82 | ||
81 | /** | 83 | /** |
82 | * the end | 84 | * the end |
83 | */ | 85 | */ |
84 | Iterator end(); | 86 | Iterator end(); |
85 | /* | 87 | /* |
86 | ConstIterator begin()const; | 88 | ConstIterator begin()const; |
87 | ConstIterator end()const; | 89 | ConstIterator end()const; |
88 | */ | 90 | */ |
89 | private: | 91 | private: |
90 | QArray<int> m_ids; | 92 | QArray<int> m_ids; |
91 | const Base* m_acc; | 93 | const Base* m_acc; |
92 | }; | 94 | }; |
93 | 95 | ||
94 | /* ok now implement it */ | 96 | /* ok now implement it */ |
95 | template <class T> | 97 | template <class T> |
96 | ORecordListIterator<T>::ORecordListIterator() { | 98 | ORecordListIterator<T>::ORecordListIterator() { |
97 | m_current = 0; | 99 | m_current = 0; |
98 | m_temp = 0l; | 100 | m_temp = 0l; |
99 | m_end = true; | 101 | m_end = true; |
100 | } | 102 | } |
101 | template <class T> | 103 | template <class T> |
102 | ORecordListIterator<T>::~ORecordListIterator() { | 104 | ORecordListIterator<T>::~ORecordListIterator() { |
103 | /* nothing to delete */ | 105 | /* nothing to delete */ |
104 | } | 106 | } |
105 | 107 | ||
106 | template <class T> | 108 | template <class T> |
107 | ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { | 109 | ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { |
110 | qWarning("ORecordListIterator"); | ||
108 | m_uids = it.m_uids; | 111 | m_uids = it.m_uids; |
109 | m_current = it.m_current; | 112 | m_current = it.m_current; |
110 | m_temp = it.m_temp; | 113 | m_temp = it.m_temp; |
111 | m_end = it.m_end; | 114 | m_end = it.m_end; |
112 | m_record = it.m_record; | 115 | m_record = it.m_record; |
113 | } | 116 | } |
114 | 117 | ||
115 | template <class T> | 118 | template <class T> |
116 | ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { | 119 | ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { |
117 | m_uids = it.m_uids; | 120 | m_uids = it.m_uids; |
118 | m_current = it.m_current; | 121 | m_current = it.m_current; |
119 | m_temp = it.m_temp; | 122 | m_temp = it.m_temp; |
120 | m_end = it.m_end; | 123 | m_end = it.m_end; |
121 | m_record = it.m_record; | 124 | m_record = it.m_record; |
122 | 125 | ||
123 | return *this; | 126 | return *this; |
124 | } | 127 | } |
125 | 128 | ||
126 | template <class T> | 129 | template <class T> |
127 | T &ORecordListIterator<T>::operator*() { | 130 | T &ORecordListIterator<T>::operator*() { |
131 | qWarning("operator* %d %d", m_current, m_uids[m_current] ); | ||
128 | if (!m_end ) | 132 | if (!m_end ) |
129 | m_record = m_temp->find( m_uids[m_current] ); | 133 | m_record = m_temp->find( m_uids[m_current] ); |
130 | else | 134 | else |
131 | m_record = T(); | 135 | m_record = T(); |
132 | 136 | ||
133 | return m_record; | 137 | return m_record; |
134 | } | 138 | } |
135 | 139 | ||
136 | template <class T> | 140 | template <class T> |
137 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { | 141 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { |
138 | if (m_current < m_uids.count() ) { | 142 | if (m_current < (int)m_uids.count() ) { |
139 | m_end = false; | 143 | m_end = false; |
140 | ++m_current; | 144 | ++m_current; |
141 | }else | 145 | }else |
142 | m_end = true; | 146 | m_end = true; |
143 | 147 | ||
144 | return *this; | 148 | return *this; |
145 | } | 149 | } |
146 | template <class T> | 150 | template <class T> |
147 | ORecordListIterator<T> &ORecordListIterator<T>::operator--() { | 151 | ORecordListIterator<T> &ORecordListIterator<T>::operator--() { |
148 | if ( m_current > 0 ) { | 152 | if ( m_current > 0 ) { |
149 | --m_current; | 153 | --m_current; |
150 | m_end = false; | 154 | m_end = false; |
151 | } else | 155 | } else |
152 | m_end = true; | 156 | m_end = true; |
153 | 157 | ||
154 | return *this; | 158 | return *this; |
155 | } | 159 | } |
156 | 160 | ||
157 | template <class T> | 161 | template <class T> |
158 | bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { | 162 | bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { |
159 | 163 | ||
160 | /* if both are at we're the same.... */ | 164 | /* if both are at we're the same.... */ |
161 | if ( m_end == it.m_end ) return true; | 165 | if ( m_end == it.m_end ) return true; |
162 | 166 | ||
163 | if ( m_uids != it.m_uids ) return false; | 167 | if ( m_uids != it.m_uids ) return false; |
164 | if ( m_current != it.m_current ) return false; | 168 | if ( m_current != it.m_current ) return false; |
165 | if ( m_temp != it.m_temp ) return false; | 169 | if ( m_temp != it.m_temp ) return false; |
166 | 170 | ||
167 | return true; | 171 | return true; |
168 | } | 172 | } |
169 | template <class T> | 173 | template <class T> |
170 | bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { | 174 | bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { |
171 | return !(*this == it ); | 175 | return !(*this == it ); |
172 | } | 176 | } |
173 | template <class T> | 177 | template <class T> |
174 | ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, | 178 | ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, |
175 | const Base* t ) | 179 | const Base* t ) |
176 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) | 180 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) |
177 | { | 181 | { |
178 | } | 182 | } |
179 | 183 | ||
180 | template <class T> | 184 | template <class T> |
181 | ORecordList<T>::ORecordList( const QArray<int>& ids, | 185 | ORecordList<T>::ORecordList( const QArray<int>& ids, |
182 | const Base* acc ) | 186 | const Base* acc ) |
183 | : m_ids( ids ), m_acc( acc ) | 187 | : m_ids( ids ), m_acc( acc ) |
184 | { | 188 | { |
185 | } | 189 | } |
186 | template <class T> | 190 | template <class T> |
187 | ORecordList<T>::~ORecordList() { | 191 | ORecordList<T>::~ORecordList() { |
188 | /* nothing to do here */ | 192 | /* nothing to do here */ |
189 | } | 193 | } |
190 | template <class T> | 194 | template <class T> |
191 | ORecordList<T>::Iterator ORecordList<T>::begin() { | 195 | ORecordList<T>::Iterator ORecordList<T>::begin() { |
196 | qWarning("ORecordList::begin"); | ||
192 | Iterator it( m_ids, m_acc ); | 197 | Iterator it( m_ids, m_acc ); |
193 | return it; | 198 | return it; |
194 | } | 199 | } |
195 | template <class T> | 200 | template <class T> |
196 | ORecordList<T>::Iterator ORecordList<T>::end() { | 201 | ORecordList<T>::Iterator ORecordList<T>::end() { |
197 | Iterator it( m_ids, m_acc ); | 202 | Iterator it( m_ids, m_acc ); |
198 | it.m_end = true; | 203 | it.m_end = true; |
199 | it.m_current = m_ids.count(); | 204 | it.m_current = m_ids.count(); |
205 | |||
206 | return it; | ||
200 | } | 207 | } |
201 | #endif | 208 | #endif |
diff --git a/libopie/pim/otemplatebase.h b/libopie/pim/otemplatebase.h index add1de4..f71417b 100644 --- a/libopie/pim/otemplatebase.h +++ b/libopie/pim/otemplatebase.h | |||
@@ -1,21 +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 | /** | 6 | /** |
7 | * internal template base | 7 | * internal template base |
8 | */ | 8 | */ |
9 | template <class T = OPimRecord> | 9 | template <class T = OPimRecord> |
10 | class OTemplateBase { | 10 | class OTemplateBase { |
11 | public: | 11 | public: |
12 | OTemplateBase() { | 12 | OTemplateBase() { |
13 | }; | 13 | }; |
14 | virtual ~OTemplateBase() { | 14 | virtual ~OTemplateBase() { |
15 | } | 15 | } |
16 | virtual T find( int uid ) = 0; | 16 | virtual T find( int uid )const = 0; |
17 | 17 | ||
18 | }; | 18 | }; |
19 | 19 | ||
20 | 20 | ||
21 | #endif | 21 | #endif |
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp index 8239ba6..b3c14e6 100644 --- a/libopie/pim/otodo.cpp +++ b/libopie/pim/otodo.cpp | |||
@@ -7,106 +7,111 @@ | |||
7 | #include <qpe/palmtopuidgen.h> | 7 | #include <qpe/palmtopuidgen.h> |
8 | #include <qpe/stringutil.h> | 8 | #include <qpe/stringutil.h> |
9 | #include <qpe/palmtoprecord.h> | 9 | #include <qpe/palmtoprecord.h> |
10 | #include <qpe/stringutil.h> | 10 | #include <qpe/stringutil.h> |
11 | #include <qpe/categories.h> | 11 | #include <qpe/categories.h> |
12 | #include <qpe/categoryselect.h> | 12 | #include <qpe/categoryselect.h> |
13 | 13 | ||
14 | 14 | ||
15 | 15 | ||
16 | #include "otodo.h" | 16 | #include "otodo.h" |
17 | 17 | ||
18 | 18 | ||
19 | struct OTodo::OTodoData : public QShared { | 19 | struct OTodo::OTodoData : public QShared { |
20 | OTodoData() : QShared() { | 20 | OTodoData() : QShared() { |
21 | }; | 21 | }; |
22 | 22 | ||
23 | QDate date; | 23 | QDate date; |
24 | bool isCompleted:1; | 24 | bool isCompleted:1; |
25 | bool hasDate:1; | 25 | bool hasDate:1; |
26 | int priority; | 26 | int priority; |
27 | QString desc; | 27 | QString desc; |
28 | QString sum; | 28 | QString sum; |
29 | QMap<QString, QString> extra; | 29 | QMap<QString, QString> extra; |
30 | ushort prog; | 30 | ushort prog; |
31 | bool hasAlarmDateTime :1; | 31 | bool hasAlarmDateTime :1; |
32 | QDateTime alarmDateTime; | 32 | QDateTime alarmDateTime; |
33 | }; | 33 | }; |
34 | 34 | ||
35 | OTodo::OTodo(const OTodo &event ) | 35 | OTodo::OTodo(const OTodo &event ) |
36 | : OPimRecord( event ), data( event.data ) | 36 | : OPimRecord( event ), data( event.data ) |
37 | { | 37 | { |
38 | data->ref(); | 38 | data->ref(); |
39 | //qWarning("ref up"); | 39 | qWarning("ref up"); |
40 | } | 40 | } |
41 | OTodo::~OTodo() { | 41 | OTodo::~OTodo() { |
42 | qWarning("~OTodo " + data->sum ); | ||
42 | if ( data->deref() ) { | 43 | if ( data->deref() ) { |
43 | //qWarning("OTodo::dereffing"); | 44 | qWarning("OTodo::dereffing"); |
44 | delete data; | 45 | delete data; |
45 | data = 0l; | 46 | data = 0l; |
46 | } | 47 | } |
47 | } | 48 | } |
48 | OTodo::OTodo(bool completed, int priority, | 49 | OTodo::OTodo(bool completed, int priority, |
49 | const QArray<int> &category, | 50 | const QArray<int> &category, |
50 | const QString& summary, | 51 | const QString& summary, |
51 | const QString &description, | 52 | const QString &description, |
52 | ushort progress, | 53 | ushort progress, |
53 | bool hasDate, QDate date, int uid ) | 54 | bool hasDate, QDate date, int uid ) |
54 | : OPimRecord( uid ) | 55 | : OPimRecord( uid ) |
55 | { | 56 | { |
56 | //qWarning("OTodoData"); | 57 | qWarning("OTodoData " + summary); |
57 | setCategories( category ); | 58 | setCategories( category ); |
59 | |||
58 | data = new OTodoData; | 60 | data = new OTodoData; |
61 | |||
59 | data->date = date; | 62 | data->date = date; |
60 | data->isCompleted = completed; | 63 | data->isCompleted = completed; |
61 | data->hasDate = hasDate; | 64 | data->hasDate = hasDate; |
62 | data->priority = priority; | 65 | data->priority = priority; |
63 | data->sum = summary; | 66 | data->sum = summary; |
64 | data->prog = progress; | 67 | data->prog = progress; |
65 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 68 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
66 | data->hasAlarmDateTime = false; | 69 | data->hasAlarmDateTime = false; |
67 | 70 | ||
68 | } | 71 | } |
69 | OTodo::OTodo(bool completed, int priority, | 72 | OTodo::OTodo(bool completed, int priority, |
70 | const QStringList &category, | 73 | const QStringList &category, |
71 | const QString& summary, | 74 | const QString& summary, |
72 | const QString &description, | 75 | const QString &description, |
73 | ushort progress, | 76 | ushort progress, |
74 | bool hasDate, QDate date, int uid ) | 77 | bool hasDate, QDate date, int uid ) |
75 | : OPimRecord( uid ) | 78 | : OPimRecord( uid ) |
76 | { | 79 | { |
77 | //qWarning("OTodoData"); | 80 | qWarning("OTodoData" + summary); |
78 | setCategories( idsFromString( category.join(";") ) ); | 81 | setCategories( idsFromString( category.join(";") ) ); |
82 | |||
79 | data = new OTodoData; | 83 | data = new OTodoData; |
80 | data->date = date; | 84 | data->date = date; |
85 | |||
81 | data->isCompleted = completed; | 86 | data->isCompleted = completed; |
82 | data->hasDate = hasDate; | 87 | data->hasDate = hasDate; |
83 | data->priority = priority; | 88 | data->priority = priority; |
84 | data->sum = summary; | 89 | data->sum = summary; |
85 | data->prog = progress; | 90 | data->prog = progress; |
86 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 91 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
87 | data->hasAlarmDateTime = false; | 92 | data->hasAlarmDateTime = false; |
88 | 93 | ||
89 | } | 94 | } |
90 | bool OTodo::match( const QRegExp ®Exp )const | 95 | bool OTodo::match( const QRegExp ®Exp )const |
91 | { | 96 | { |
92 | if( QString::number( data->priority ).find( regExp ) != -1 ){ | 97 | if( QString::number( data->priority ).find( regExp ) != -1 ){ |
93 | return true; | 98 | return true; |
94 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ | 99 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ |
95 | return true; | 100 | return true; |
96 | }else if(data->desc.find( regExp ) != -1 ){ | 101 | }else if(data->desc.find( regExp ) != -1 ){ |
97 | return true; | 102 | return true; |
98 | }else if(data->sum.find( regExp ) != -1 ) { | 103 | }else if(data->sum.find( regExp ) != -1 ) { |
99 | return true; | 104 | return true; |
100 | } | 105 | } |
101 | return false; | 106 | return false; |
102 | } | 107 | } |
103 | bool OTodo::isCompleted() const | 108 | bool OTodo::isCompleted() const |
104 | { | 109 | { |
105 | return data->isCompleted; | 110 | return data->isCompleted; |
106 | } | 111 | } |
107 | bool OTodo::hasDueDate() const | 112 | bool OTodo::hasDueDate() const |
108 | { | 113 | { |
109 | return data->hasDate; | 114 | return data->hasDate; |
110 | } | 115 | } |
111 | bool OTodo::hasAlarmDateTime() const | 116 | bool OTodo::hasAlarmDateTime() const |
112 | { | 117 | { |
@@ -321,58 +326,58 @@ OTodo &OTodo::operator=(const OTodo &item ) | |||
321 | 326 | ||
322 | QMap<int, QString> OTodo::toMap() const { | 327 | QMap<int, QString> OTodo::toMap() const { |
323 | QMap<int, QString> map; | 328 | QMap<int, QString> map; |
324 | 329 | ||
325 | map.insert( Uid, QString::number( uid() ) ); | 330 | map.insert( Uid, QString::number( uid() ) ); |
326 | map.insert( Category, idsToString( categories() ) ); | 331 | map.insert( Category, idsToString( categories() ) ); |
327 | map.insert( HasDate, QString::number( data->hasDate ) ); | 332 | map.insert( HasDate, QString::number( data->hasDate ) ); |
328 | map.insert( Completed, QString::number( data->isCompleted ) ); | 333 | map.insert( Completed, QString::number( data->isCompleted ) ); |
329 | map.insert( Description, data->desc ); | 334 | map.insert( Description, data->desc ); |
330 | map.insert( Summary, data->sum ); | 335 | map.insert( Summary, data->sum ); |
331 | map.insert( Priority, QString::number( data->priority ) ); | 336 | map.insert( Priority, QString::number( data->priority ) ); |
332 | map.insert( DateDay, QString::number( data->date.day() ) ); | 337 | map.insert( DateDay, QString::number( data->date.day() ) ); |
333 | map.insert( DateMonth, QString::number( data->date.month() ) ); | 338 | map.insert( DateMonth, QString::number( data->date.month() ) ); |
334 | map.insert( DateYear, QString::number( data->date.year() ) ); | 339 | map.insert( DateYear, QString::number( data->date.year() ) ); |
335 | map.insert( Progress, QString::number( data->prog ) ); | 340 | map.insert( Progress, QString::number( data->prog ) ); |
336 | map.insert( CrossReference, crossToString() ); | 341 | map.insert( CrossReference, crossToString() ); |
337 | map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); | 342 | map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); |
338 | map.insert( AlarmDateTime, data->alarmDateTime.toString() ); | 343 | map.insert( AlarmDateTime, data->alarmDateTime.toString() ); |
339 | 344 | ||
340 | return map; | 345 | return map; |
341 | } | 346 | } |
342 | 347 | ||
343 | QMap<QString, QString> OTodo::toExtraMap()const { | 348 | QMap<QString, QString> OTodo::toExtraMap()const { |
344 | return data->extra; | 349 | return data->extra; |
345 | } | 350 | } |
346 | /** | 351 | /** |
347 | * change or modify looks at the ref count and either | 352 | * change or modify looks at the ref count and either |
348 | * creates a new QShared Object or it can modify it | 353 | * creates a new QShared Object or it can modify it |
349 | * right in place | 354 | * right in place |
350 | */ | 355 | */ |
351 | void OTodo::changeOrModify() { | 356 | void OTodo::changeOrModify() { |
352 | if ( data->count != 1 ) { | 357 | if ( data->count != 1 ) { |
353 | //qWarning("changeOrModify"); | 358 | qWarning("changeOrModify"); |
354 | data->deref(); | 359 | data->deref(); |
355 | OTodoData* d2 = new OTodoData(); | 360 | OTodoData* d2 = new OTodoData(); |
356 | copy(data, d2 ); | 361 | copy(data, d2 ); |
357 | data = d2; | 362 | data = d2; |
358 | } | 363 | } |
359 | } | 364 | } |
360 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { | 365 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { |
361 | dest->date = src->date; | 366 | dest->date = src->date; |
362 | dest->isCompleted = src->isCompleted; | 367 | dest->isCompleted = src->isCompleted; |
363 | dest->hasDate = src->hasDate; | 368 | dest->hasDate = src->hasDate; |
364 | dest->priority = src->priority; | 369 | dest->priority = src->priority; |
365 | dest->desc = src->desc; | 370 | dest->desc = src->desc; |
366 | dest->sum = src->sum; | 371 | dest->sum = src->sum; |
367 | dest->extra = src->extra; | 372 | dest->extra = src->extra; |
368 | dest->prog = src->prog; | 373 | dest->prog = src->prog; |
369 | dest->hasAlarmDateTime = src->hasAlarmDateTime; | 374 | dest->hasAlarmDateTime = src->hasAlarmDateTime; |
370 | dest->alarmDateTime = src->alarmDateTime; | 375 | dest->alarmDateTime = src->alarmDateTime; |
371 | } | 376 | } |
372 | QString OTodo::type() const { | 377 | QString OTodo::type() const { |
373 | return QString::fromLatin1("OTodo"); | 378 | return QString::fromLatin1("OTodo"); |
374 | } | 379 | } |
375 | QString OTodo::recordField(int id )const { | 380 | QString OTodo::recordField(int id )const { |
376 | return QString::null; | 381 | return QString::null; |
377 | } | 382 | } |
378 | 383 | ||
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h index 75af44c..1443e4f 100644 --- a/libopie/pim/otodo.h +++ b/libopie/pim/otodo.h | |||
@@ -106,74 +106,64 @@ public: | |||
106 | QDate dueDate()const; | 106 | QDate dueDate()const; |
107 | 107 | ||
108 | /** | 108 | /** |
109 | * Alarm Date and Time | 109 | * Alarm Date and Time |
110 | */ | 110 | */ |
111 | QDateTime alarmDateTime()const; | 111 | QDateTime alarmDateTime()const; |
112 | 112 | ||
113 | /** | 113 | /** |
114 | * The description of the todo | 114 | * The description of the todo |
115 | */ | 115 | */ |
116 | QString description()const; | 116 | QString description()const; |
117 | 117 | ||
118 | /** | 118 | /** |
119 | * A small summary of the todo | 119 | * A small summary of the todo |
120 | */ | 120 | */ |
121 | QString summary() const; | 121 | QString summary() const; |
122 | 122 | ||
123 | /** | 123 | /** |
124 | * @reimplemented | 124 | * @reimplemented |
125 | * Return this todoevent in a RichText formatted QString | 125 | * Return this todoevent in a RichText formatted QString |
126 | */ | 126 | */ |
127 | QString toRichText() const; | 127 | QString toRichText() const; |
128 | 128 | ||
129 | /** | 129 | /** |
130 | * reimplementation | 130 | * reimplementation |
131 | */ | 131 | */ |
132 | QString type()const; | 132 | QString type()const; |
133 | QString toShortText()const; | 133 | QString toShortText()const; |
134 | QMap<QString, QString> toExtraMap()const; | 134 | QMap<QString, QString> toExtraMap()const; |
135 | QString recordField(int id )const; | 135 | QString recordField(int id )const; |
136 | 136 | ||
137 | /** | 137 | /** |
138 | * returns a list of apps which have related items | ||
139 | */ | ||
140 | QStringList relatedApps()const; | ||
141 | |||
142 | /** | ||
143 | * returns all relations for one app | ||
144 | */ | ||
145 | QArray<int> relations( const QString& app )const; | ||
146 | |||
147 | /** | ||
148 | * toMap puts all data into the map. int relates | 138 | * toMap puts all data into the map. int relates |
149 | * to ToDoEvent RecordFields enum | 139 | * to ToDoEvent RecordFields enum |
150 | */ | 140 | */ |
151 | QMap<int, QString> toMap()const; | 141 | QMap<int, QString> toMap()const; |
152 | 142 | ||
153 | /** | 143 | /** |
154 | * Set if this Todo is completed | 144 | * Set if this Todo is completed |
155 | */ | 145 | */ |
156 | void setCompleted(bool completed ); | 146 | void setCompleted(bool completed ); |
157 | 147 | ||
158 | /** | 148 | /** |
159 | * set if this todo got an end data | 149 | * set if this todo got an end data |
160 | */ | 150 | */ |
161 | void setHasDueDate( bool hasDate ); | 151 | void setHasDueDate( bool hasDate ); |
162 | 152 | ||
163 | /** | 153 | /** |
164 | * set if this todo has an alarm time and date | 154 | * set if this todo has an alarm time and date |
165 | */ | 155 | */ |
166 | void setHasAlarmDateTime ( bool hasAlarm ); | 156 | void setHasAlarmDateTime ( bool hasAlarm ); |
167 | 157 | ||
168 | /** | 158 | /** |
169 | * Set the priority of the Todo | 159 | * Set the priority of the Todo |
170 | */ | 160 | */ |
171 | void setPriority(int priority ); | 161 | void setPriority(int priority ); |
172 | 162 | ||
173 | /** | 163 | /** |
174 | * Set the progress. | 164 | * Set the progress. |
175 | */ | 165 | */ |
176 | void setProgress( ushort progress ); | 166 | void setProgress( ushort progress ); |
177 | 167 | ||
178 | /** | 168 | /** |
179 | * set the end date | 169 | * set the end date |
diff --git a/libopie/pim/otodoaccess.cpp b/libopie/pim/otodoaccess.cpp new file mode 100644 index 0000000..a65cf5c --- a/dev/null +++ b/libopie/pim/otodoaccess.cpp | |||
@@ -0,0 +1,71 @@ | |||
1 | #include <qdatetime.h> | ||
2 | |||
3 | #include <qpe/alarmserver.h> | ||
4 | |||
5 | #include "otodoaccessxml.h" | ||
6 | #include "otodoaccess.h" | ||
7 | |||
8 | |||
9 | OTodoAccess::OTodoAccess( OTodoAccessBackend* end ) | ||
10 | : QObject(), OPimAccessTemplate<OTodo>( end ), m_todoBackEnd( end ) | ||
11 | { | ||
12 | if (end == 0l ) | ||
13 | m_todoBackEnd = new OTodoAccessXML( "Todolist" ); | ||
14 | |||
15 | setBackEnd( m_todoBackEnd ); | ||
16 | } | ||
17 | OTodoAccess::~OTodoAccess() { | ||
18 | qWarning("~OTodoAccess"); | ||
19 | } | ||
20 | void OTodoAccess::mergeWith( const QValueList<OTodo>& list ) { | ||
21 | QValueList<OTodo>::ConstIterator it; | ||
22 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
23 | replace( (*it) ); | ||
24 | } | ||
25 | } | ||
26 | OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, | ||
27 | const QDate& end, | ||
28 | bool includeNoDates ) { | ||
29 | QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); | ||
30 | |||
31 | List lis( ints, this ); | ||
32 | return lis; | ||
33 | } | ||
34 | OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, | ||
35 | bool includeNoDates ) { | ||
36 | return effectiveToDos( start, QDate::currentDate(), | ||
37 | includeNoDates ); | ||
38 | } | ||
39 | OTodoAccess::List OTodoAccess::overDue() { | ||
40 | List lis( m_todoBackEnd->overDue(), this ); | ||
41 | return lis; | ||
42 | } | ||
43 | void OTodoAccess::addAlarm( const OTodo& event) { | ||
44 | if (!event.hasAlarmDateTime() ) | ||
45 | return; | ||
46 | |||
47 | QDateTime now = QDateTime::currentDateTime(); | ||
48 | QDateTime schedule = event.alarmDateTime(); | ||
49 | |||
50 | if ( schedule > now ){ | ||
51 | AlarmServer::addAlarm( schedule, | ||
52 | "QPE/Application/todolist", | ||
53 | "alarm(QDateTime,int)", event.uid() ); | ||
54 | |||
55 | } | ||
56 | } | ||
57 | void OTodoAccess::delAlarm( int uid) { | ||
58 | |||
59 | QDateTime schedule; // Create null DateTime | ||
60 | |||
61 | // I hope this will remove all scheduled alarms | ||
62 | // with the given uid !? | ||
63 | // If not: I have to rethink how to remove already | ||
64 | // scheduled events... (se) | ||
65 | // it should be fine -zecke | ||
66 | qWarning("Removing alarm for event with uid %d", uid ); | ||
67 | AlarmServer::deleteAlarm( schedule , | ||
68 | "QPE/Application/todolist", | ||
69 | "alarm(QDateTime,int)", uid ); | ||
70 | } | ||
71 | |||
diff --git a/libopie/pim/otodoaccess.h b/libopie/pim/otodoaccess.h new file mode 100644 index 0000000..c43efe9 --- a/dev/null +++ b/libopie/pim/otodoaccess.h | |||
@@ -0,0 +1,79 @@ | |||
1 | #ifndef OPIE_TODO_ACCESS_H | ||
2 | #define OPIE_TODO_ACCESS_H | ||
3 | |||
4 | #include <qobject.h> | ||
5 | #include <qvaluelist.h> | ||
6 | |||
7 | #include "otodo.h" | ||
8 | #include "otodoaccessbackend.h" | ||
9 | #include "opimaccesstemplate.h" | ||
10 | |||
11 | |||
12 | /** | ||
13 | * OTodoAccess | ||
14 | * the class to get access to | ||
15 | * the todolist | ||
16 | */ | ||
17 | class OTodoAccess : public QObject, public OPimAccessTemplate<OTodo> { | ||
18 | Q_OBJECT | ||
19 | public: | ||
20 | /** | ||
21 | * if you use 0l | ||
22 | * the default resource will be | ||
23 | * icked up | ||
24 | */ | ||
25 | OTodoAccess( OTodoAccessBackend* = 0l); | ||
26 | ~OTodoAccess(); | ||
27 | |||
28 | |||
29 | /* our functions here */ | ||
30 | /** | ||
31 | * include todos from start to end | ||
32 | * includeNoDates whether or not to include | ||
33 | * events with no dates | ||
34 | */ | ||
35 | List effectiveToDos( const QDate& start, | ||
36 | const QDate& end, | ||
37 | bool includeNoDates = true ); | ||
38 | |||
39 | /** | ||
40 | * start | ||
41 | * end date taken from the currentDate() | ||
42 | */ | ||
43 | List effectiveToDos( const QDate& start, | ||
44 | bool includeNoDates = true ); | ||
45 | |||
46 | |||
47 | /** | ||
48 | * return overdue OTodos | ||
49 | */ | ||
50 | List overDue(); | ||
51 | /** | ||
52 | * merge a list of OTodos into | ||
53 | * the resource | ||
54 | */ | ||
55 | void mergeWith( const QValueList<OTodo>& ); | ||
56 | |||
57 | /** | ||
58 | * add an Alarm to the AlarmServer | ||
59 | */ | ||
60 | void addAlarm( const OTodo& ); | ||
61 | |||
62 | /** | ||
63 | * delete an alarm with the uid from | ||
64 | * the alarm server | ||
65 | */ | ||
66 | void delAlarm( int uid ); | ||
67 | |||
68 | signals: | ||
69 | /** | ||
70 | * if the OTodoAccess was changed | ||
71 | */ | ||
72 | void signalChanged( const OTodoAccess* ); | ||
73 | private: | ||
74 | OTodoAccessBackend* m_todoBackEnd; | ||
75 | class OTodoAccessPrivate; | ||
76 | OTodoAccessPrivate* d; | ||
77 | }; | ||
78 | |||
79 | #endif | ||
diff --git a/libopie/pim/otodoaccessbackend.cpp b/libopie/pim/otodoaccessbackend.cpp new file mode 100644 index 0000000..baaeecc --- a/dev/null +++ b/libopie/pim/otodoaccessbackend.cpp | |||
@@ -0,0 +1,10 @@ | |||
1 | |||
2 | #include "otodoaccessbackend.h" | ||
3 | |||
4 | OTodoAccessBackend::OTodoAccessBackend() | ||
5 | : OPimAccessBackend<OTodo>() | ||
6 | { | ||
7 | } | ||
8 | OTodoAccessBackend::~OTodoAccessBackend() { | ||
9 | |||
10 | } | ||
diff --git a/libopie/pim/otodoaccessbackend.h b/libopie/pim/otodoaccessbackend.h new file mode 100644 index 0000000..ebe2189 --- a/dev/null +++ b/libopie/pim/otodoaccessbackend.h | |||
@@ -0,0 +1,18 @@ | |||
1 | #ifndef OPIE_TODO_ACCESS_BACKEND_H | ||
2 | #define OPIE_TODO_ACCESS_BACKEND_H | ||
3 | |||
4 | #include "otodo.h" | ||
5 | #include "opimaccessbackend.h" | ||
6 | |||
7 | class OTodoAccessBackend : public OPimAccessBackend<OTodo> { | ||
8 | public: | ||
9 | OTodoAccessBackend(); | ||
10 | ~OTodoAccessBackend(); | ||
11 | virtual QArray<int> effectiveToDos( const QDate& start, | ||
12 | const QDate& end, | ||
13 | bool includeNoDates ) = 0; | ||
14 | virtual QArray<int> overDue() = 0; | ||
15 | |||
16 | }; | ||
17 | |||
18 | #endif | ||
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp new file mode 100644 index 0000000..21756c9 --- a/dev/null +++ b/libopie/pim/otodoaccessxml.cpp | |||
@@ -0,0 +1,362 @@ | |||
1 | #include <qfile.h> | ||
2 | |||
3 | #include <qpe/global.h> | ||
4 | #include <qpe/stringutil.h> | ||
5 | #include <qpe/timeconversion.h> | ||
6 | |||
7 | #include <opie/xmltree.h> | ||
8 | |||
9 | #include "otodoaccessxml.h" | ||
10 | |||
11 | OTodoAccessXML::OTodoAccessXML( const QString& appName, | ||
12 | const QString& fileName ) | ||
13 | : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) | ||
14 | { | ||
15 | if (!fileName.isEmpty() ) | ||
16 | m_file = fileName; | ||
17 | else | ||
18 | m_file = Global::applicationFileName( "todolist", "todolist.xml" ); | ||
19 | } | ||
20 | OTodoAccessXML::~OTodoAccessXML() { | ||
21 | |||
22 | } | ||
23 | bool OTodoAccessXML::load() { | ||
24 | m_opened = false; | ||
25 | m_changed = false; | ||
26 | /* initialize dict */ | ||
27 | /* | ||
28 | * UPDATE dict if you change anything!!! | ||
29 | */ | ||
30 | QAsciiDict<int> dict(15); | ||
31 | dict.setAutoDelete( TRUE ); | ||
32 | dict.insert("Categories" , new int(OTodo::Category) ); | ||
33 | dict.insert("Uid" , new int(OTodo::Uid) ); | ||
34 | dict.insert("HasDate" , new int(OTodo::HasDate) ); | ||
35 | dict.insert("Completed" , new int(OTodo::Completed) ); | ||
36 | dict.insert("Description" , new int(OTodo::Description) ); | ||
37 | dict.insert("Summary" , new int(OTodo::Summary) ); | ||
38 | dict.insert("Priority" , new int(OTodo::Priority) ); | ||
39 | dict.insert("DateDay" , new int(OTodo::DateDay) ); | ||
40 | dict.insert("DateMonth" , new int(OTodo::DateMonth) ); | ||
41 | dict.insert("DateYear" , new int(OTodo::DateYear) ); | ||
42 | dict.insert("Progress" , new int(OTodo::Progress) ); | ||
43 | dict.insert("Completed", new int(OTodo::Completed) ); | ||
44 | dict.insert("CrossReference", new int(OTodo::CrossReference) ); | ||
45 | dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) ); | ||
46 | dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) ); | ||
47 | |||
48 | Opie::XMLElement *root = Opie::XMLElement::load( m_file ); | ||
49 | int day, year, month; | ||
50 | day = year = month = -1; | ||
51 | |||
52 | /* if opened */ | ||
53 | if ( root != 0l ) { | ||
54 | Opie::XMLElement *element = root->firstChild(); | ||
55 | if ( element == 0l ) | ||
56 | return false; | ||
57 | |||
58 | element = element->firstChild(); | ||
59 | |||
60 | while ( element ) { | ||
61 | if ( element->tagName() != QString::fromLatin1("Task") ) { | ||
62 | element = element->nextChild(); | ||
63 | continue; | ||
64 | } | ||
65 | /* here is the right element for a task */ | ||
66 | OTodo ev = todo( &dict, element ); | ||
67 | m_events.insert( ev.uid(), ev ); | ||
68 | |||
69 | element = element->nextChild(); | ||
70 | } | ||
71 | return true; | ||
72 | }else { | ||
73 | qWarning("could not parse"); | ||
74 | return false;; | ||
75 | } | ||
76 | delete root; | ||
77 | |||
78 | m_opened = true; | ||
79 | return true; | ||
80 | } | ||
81 | bool OTodoAccessXML::reload() { | ||
82 | return load(); | ||
83 | } | ||
84 | bool OTodoAccessXML::save() { | ||
85 | if (!m_opened || !m_changed ) | ||
86 | return true; | ||
87 | QString strNewFile = m_file + ".new"; | ||
88 | QFile f( strNewFile ); | ||
89 | if (!f.open( IO_WriteOnly|IO_Raw ) ) | ||
90 | return false; | ||
91 | |||
92 | int written; | ||
93 | QString out; | ||
94 | out = "<!DOCTYPE Tasks>\n<Tasks>\n"; | ||
95 | |||
96 | // for all todos | ||
97 | QMap<int, OTodo>::Iterator it; | ||
98 | for (it = m_events.begin(); it != m_events.end(); ++it ) { | ||
99 | out+= "<Task " + toString( (*it) ) + " />\n"; | ||
100 | QCString cstr = out.utf8(); | ||
101 | written = f.writeBlock( cstr.data(), cstr.length() ); | ||
102 | |||
103 | /* less written then we wanted */ | ||
104 | if ( written != (int)cstr.length() ) { | ||
105 | f.close(); | ||
106 | QFile::remove( strNewFile ); | ||
107 | return false; | ||
108 | } | ||
109 | out = QString::null; | ||
110 | } | ||
111 | |||
112 | out += "</Tasks>"; | ||
113 | QCString cstr = out.utf8(); | ||
114 | written = f.writeBlock( cstr.data(), cstr.length() ); | ||
115 | |||
116 | if ( written != (int)cstr.length() ) { | ||
117 | f.close(); | ||
118 | QFile::remove( strNewFile ); | ||
119 | return false; | ||
120 | } | ||
121 | /* flush before renaming */ | ||
122 | f.close(); | ||
123 | |||
124 | if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) { | ||
125 | qWarning("error renaming"); | ||
126 | QFile::remove( strNewFile ); | ||
127 | } | ||
128 | |||
129 | m_changed = false; | ||
130 | return true; | ||
131 | } | ||
132 | QArray<int> OTodoAccessXML::allRecords()const { | ||
133 | QArray<int> ids( m_events.count() ); | ||
134 | QMap<int, OTodo>::ConstIterator it; | ||
135 | int i = 0; | ||
136 | |||
137 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | ||
138 | ids[i] = it.key(); | ||
139 | i++; | ||
140 | } | ||
141 | return ids; | ||
142 | } | ||
143 | QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int sort ) { | ||
144 | QArray<int> ids(0); | ||
145 | return ids; | ||
146 | } | ||
147 | OTodo OTodoAccessXML::find( int uid )const { | ||
148 | OTodo todo; | ||
149 | todo.setUid( 0 ); // isEmpty() | ||
150 | QMap<int, OTodo>::ConstIterator it = m_events.find( uid ); | ||
151 | if ( it != m_events.end() ) | ||
152 | todo = it.data(); | ||
153 | |||
154 | return todo; | ||
155 | } | ||
156 | void OTodoAccessXML::clear() { | ||
157 | if (m_opened ) | ||
158 | m_changed = true; | ||
159 | |||
160 | m_events.clear(); | ||
161 | } | ||
162 | bool OTodoAccessXML::add( const OTodo& todo ) { | ||
163 | m_changed = true; | ||
164 | m_events.insert( todo.uid(), todo ); | ||
165 | |||
166 | return true; | ||
167 | } | ||
168 | bool OTodoAccessXML::remove( int uid ) { | ||
169 | m_changed = true; | ||
170 | m_events.remove( uid ); | ||
171 | |||
172 | return true; | ||
173 | } | ||
174 | bool OTodoAccessXML::replace( const OTodo& todo) { | ||
175 | m_changed = true; | ||
176 | m_events.replace( todo.uid(), todo ); | ||
177 | |||
178 | return true; | ||
179 | } | ||
180 | QArray<int> OTodoAccessXML::effectiveToDos( const QDate& start, | ||
181 | const QDate& end, | ||
182 | bool includeNoDates ) { | ||
183 | QArray<int> ids( m_events.count() ); | ||
184 | QMap<int, OTodo>::Iterator it; | ||
185 | |||
186 | int i = 0; | ||
187 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | ||
188 | if ( !it.data().hasDueDate() ) { | ||
189 | if ( includeNoDates ) { | ||
190 | ids[i] = it.key(); | ||
191 | i++; | ||
192 | } | ||
193 | }else if ( it.data().dueDate() >= start && | ||
194 | it.data().dueDate() <= end ) { | ||
195 | ids[i] = it.key(); | ||
196 | i++; | ||
197 | } | ||
198 | } | ||
199 | ids.resize( i ); | ||
200 | return ids; | ||
201 | } | ||
202 | QArray<int> OTodoAccessXML::overDue() { | ||
203 | QArray<int> ids( m_events.count() ); | ||
204 | int i = 0; | ||
205 | |||
206 | QMap<int, OTodo>::Iterator it; | ||
207 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | ||
208 | if ( it.data().isOverdue() ) { | ||
209 | ids[i] = it.key(); | ||
210 | i++; | ||
211 | } | ||
212 | } | ||
213 | ids.resize( i ); | ||
214 | return ids; | ||
215 | } | ||
216 | |||
217 | |||
218 | /* private */ | ||
219 | OTodo OTodoAccessXML::todo( QAsciiDict<int>* dict, Opie::XMLElement* element)const { | ||
220 | qWarning("parse to do from XMLElement" ); | ||
221 | OTodo ev; | ||
222 | QMap<QString, QString> attributes = element->attributes(); | ||
223 | QMap<QString, QString>::Iterator it; | ||
224 | |||
225 | int *find=0; | ||
226 | int day, month, year; | ||
227 | day = month = year = -1; | ||
228 | for ( it = attributes.begin(); it != attributes.end(); ++it ) { | ||
229 | find = (*dict)[ it.key() ]; | ||
230 | if (!find ) { | ||
231 | qWarning("Unknown option" + it.key() ); | ||
232 | ev.setCustomField( it.key(), it.data() ); | ||
233 | continue; | ||
234 | } | ||
235 | |||
236 | switch( *find ) { | ||
237 | case OTodo::Uid: | ||
238 | ev.setUid( it.data().toInt() ); | ||
239 | break; | ||
240 | case OTodo::Category: | ||
241 | ev.setCategories( ev.idsFromString( it.data() ) ); | ||
242 | break; | ||
243 | case OTodo::HasDate: | ||
244 | ev.setHasDueDate( it.data().toInt() ); | ||
245 | break; | ||
246 | case OTodo::Completed: | ||
247 | ev.setCompleted( it.data().toInt() ); | ||
248 | break; | ||
249 | case OTodo::Description: | ||
250 | ev.setDescription( it.data() ); | ||
251 | break; | ||
252 | case OTodo::Summary: | ||
253 | ev.setSummary( it.data() ); | ||
254 | break; | ||
255 | case OTodo::Priority: | ||
256 | ev.setPriority( it.data().toInt() ); | ||
257 | break; | ||
258 | case OTodo::DateDay: | ||
259 | day = it.data().toInt(); | ||
260 | break; | ||
261 | case OTodo::DateMonth: | ||
262 | month = it.data().toInt(); | ||
263 | break; | ||
264 | case OTodo::DateYear: | ||
265 | year = it.data().toInt(); | ||
266 | break; | ||
267 | case OTodo::Progress: | ||
268 | ev.setProgress( it.data().toInt() ); | ||
269 | break; | ||
270 | case OTodo::CrossReference: | ||
271 | { | ||
272 | /* | ||
273 | * A cross refernce looks like | ||
274 | * appname,id;appname,id | ||
275 | * we need to split it up | ||
276 | */ | ||
277 | QStringList refs = QStringList::split(';', it.data() ); | ||
278 | QStringList::Iterator strIt; | ||
279 | for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { | ||
280 | int pos = (*strIt).find(','); | ||
281 | if ( pos > -1 ) | ||
282 | ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); | ||
283 | |||
284 | } | ||
285 | break; | ||
286 | } | ||
287 | case OTodo::HasAlarmDateTime: | ||
288 | ev.setHasAlarmDateTime( it.data().toInt() ); | ||
289 | break; | ||
290 | case OTodo::AlarmDateTime: { | ||
291 | /* this sounds better ;) zecke */ | ||
292 | ev.setAlarmDateTime( TimeConversion::fromISO8601( it.data().local8Bit() ) ); | ||
293 | break; | ||
294 | } | ||
295 | default: | ||
296 | break; | ||
297 | } | ||
298 | } | ||
299 | if ( ev.hasDueDate() ) { | ||
300 | QDate date( year, month, day ); | ||
301 | ev.setDueDate( date ); | ||
302 | } | ||
303 | |||
304 | return ev; | ||
305 | } | ||
306 | QString OTodoAccessXML::toString( const OTodo& ev )const { | ||
307 | QString str; | ||
308 | |||
309 | str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; | ||
310 | str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; | ||
311 | str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; | ||
312 | str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; | ||
313 | |||
314 | str += "Categories=\"" + toString( ev.categories() ) + "\" "; | ||
315 | str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" "; | ||
316 | str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" "; | ||
317 | |||
318 | if ( ev.hasDueDate() ) { | ||
319 | str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" "; | ||
320 | str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" "; | ||
321 | str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" "; | ||
322 | } | ||
323 | str += "Uid=\"" + QString::number( ev.uid() ) + "\" "; | ||
324 | |||
325 | // append the extra options | ||
326 | /* FIXME Qtopia::Record this is currently not | ||
327 | * possible you can set custom fields | ||
328 | * but don' iterate over the list | ||
329 | * I may do #define private protected | ||
330 | * for this case - cough --zecke | ||
331 | */ | ||
332 | /* | ||
333 | QMap<QString, QString> extras = ev.extras(); | ||
334 | QMap<QString, QString>::Iterator extIt; | ||
335 | for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) | ||
336 | str += extIt.key() + "=\"" + extIt.data() + "\" "; | ||
337 | */ | ||
338 | // cross refernce | ||
339 | QStringList list = ev.relatedApps(); | ||
340 | QStringList::Iterator listIt; | ||
341 | QString refs; | ||
342 | str += "CrossReference=\""; | ||
343 | bool added = false; | ||
344 | for ( listIt = list.begin(); listIt != list.end(); ++listIt ) { | ||
345 | added = true; | ||
346 | QArray<int> ints = ev.relations( (*listIt) ); | ||
347 | for ( uint i = 0; i< ints.count(); i++ ) { | ||
348 | str += (*listIt) + "," + QString::number( i ) + ";"; | ||
349 | } | ||
350 | } | ||
351 | if ( added ) | ||
352 | str = str.remove( str.length()-1, 1 ); | ||
353 | |||
354 | str += "\" "; | ||
355 | |||
356 | str += "AlarmDateTime=\"" + TimeConversion::toISO8601( ev.alarmDateTime() ) + "\" "; | ||
357 | |||
358 | return str; | ||
359 | } | ||
360 | QString OTodoAccessXML::toString( const QArray<int>& ints ) const { | ||
361 | return Qtopia::Record::idsToString( ints ); | ||
362 | } | ||
diff --git a/libopie/pim/otodoaccessxml.h b/libopie/pim/otodoaccessxml.h new file mode 100644 index 0000000..be9109d --- a/dev/null +++ b/libopie/pim/otodoaccessxml.h | |||
@@ -0,0 +1,53 @@ | |||
1 | #ifndef OPIE_TODO_ACCESS_XML_H | ||
2 | #define OPIE_TODO_ACCESS_XML_H | ||
3 | |||
4 | #include <qasciidict.h> | ||
5 | #include <qmap.h> | ||
6 | |||
7 | #include "otodoaccessbackend.h" | ||
8 | |||
9 | namespace Opie { | ||
10 | class XMLElement; | ||
11 | }; | ||
12 | |||
13 | class OTodoAccessXML : public OTodoAccessBackend { | ||
14 | public: | ||
15 | /** | ||
16 | * fileName if Empty we will use the default path | ||
17 | */ | ||
18 | OTodoAccessXML( const QString& appName, | ||
19 | const QString& fileName = QString::null ); | ||
20 | ~OTodoAccessXML(); | ||
21 | |||
22 | bool load(); | ||
23 | bool reload(); | ||
24 | bool save(); | ||
25 | |||
26 | QArray<int> allRecords()const; | ||
27 | QArray<int> queryByExample( const OTodo&, int sort ); | ||
28 | OTodo find( int uid )const; | ||
29 | void clear(); | ||
30 | bool add( const OTodo& ); | ||
31 | bool remove( int uid ); | ||
32 | bool replace( const OTodo& ); | ||
33 | |||
34 | /* our functions */ | ||
35 | QArray<int> effectiveToDos( const QDate& start, | ||
36 | const QDate& end, | ||
37 | bool includeNoDates ); | ||
38 | QArray<int> overDue(); | ||
39 | private: | ||
40 | OTodo todo( QAsciiDict<int>*, Opie::XMLElement* )const; | ||
41 | QString toString( const OTodo& )const; | ||
42 | QString toString( const QArray<int>& ints ) const; | ||
43 | QMap<int, OTodo> m_events; | ||
44 | QString m_file; | ||
45 | QString m_app; | ||
46 | bool m_opened : 1; | ||
47 | bool m_changed : 1; | ||
48 | class OTodoAccessXMLPrivate; | ||
49 | OTodoAccessXMLPrivate* d; | ||
50 | |||
51 | }; | ||
52 | |||
53 | #endif | ||