Diffstat (limited to 'libopie2/opiepim/backend/otodoaccessvcal.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessvcal.cpp | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp index e364ee2..0a1baf9 100644 --- a/libopie2/opiepim/backend/otodoaccessvcal.cpp +++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp | |||
@@ -28,26 +28,26 @@ | |||
28 | */ | 28 | */ |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | 30 | ||
31 | #include <qtopia/private/vobject_p.h> | 31 | #include <qtopia/private/vobject_p.h> |
32 | #include <qtopia/timeconversion.h> | 32 | #include <qtopia/timeconversion.h> |
33 | #include <qtopia/private/qfiledirect_p.h> | 33 | #include <qtopia/private/qfiledirect_p.h> |
34 | 34 | ||
35 | #include <opie2/otodoaccessvcal.h> | 35 | #include <opie2/otodoaccessvcal.h> |
36 | 36 | ||
37 | using namespace Opie; | 37 | using namespace Opie; |
38 | 38 | ||
39 | namespace { | 39 | namespace { |
40 | static OTodo eventByVObj( VObject *obj ){ | 40 | static OPimTodo eventByVObj( VObject *obj ){ |
41 | OTodo event; | 41 | OPimTodo event; |
42 | VObject *ob; | 42 | VObject *ob; |
43 | QCString name; | 43 | QCString name; |
44 | // no uid, attendees, ... and no fun | 44 | // no uid, attendees, ... and no fun |
45 | // description | 45 | // description |
46 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ | 46 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ |
47 | name = vObjectStringZValue( ob ); | 47 | name = vObjectStringZValue( ob ); |
48 | #if 0 | 48 | #if 0 |
49 | event.setDescription( name ); | 49 | event.setDescription( name ); |
50 | #else | 50 | #else |
51 | event.setSummary( name ); | 51 | event.setSummary( name ); |
52 | #endif | 52 | #endif |
53 | } | 53 | } |
@@ -82,25 +82,25 @@ namespace { | |||
82 | name = vObjectStringZValue( ob ); | 82 | name = vObjectStringZValue( ob ); |
83 | event.setDueDate( TimeConversion::fromISO8601( name).date() ); | 83 | event.setDueDate( TimeConversion::fromISO8601( name).date() ); |
84 | } | 84 | } |
85 | // categories | 85 | // categories |
86 | if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ | 86 | if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ |
87 | name = vObjectStringZValue( ob ); | 87 | name = vObjectStringZValue( ob ); |
88 | qWarning("Categories:%s", name.data() ); | 88 | qWarning("Categories:%s", name.data() ); |
89 | } | 89 | } |
90 | 90 | ||
91 | event.setUid( 1 ); | 91 | event.setUid( 1 ); |
92 | return event; | 92 | return event; |
93 | }; | 93 | }; |
94 | static VObject *vobjByEvent( const OTodo &event ) { | 94 | static VObject *vobjByEvent( const OPimTodo &event ) { |
95 | VObject *task = newVObject( VCTodoProp ); | 95 | VObject *task = newVObject( VCTodoProp ); |
96 | if( task == 0 ) | 96 | if( task == 0 ) |
97 | return 0l; | 97 | return 0l; |
98 | 98 | ||
99 | if( event.hasDueDate() ) { | 99 | if( event.hasDueDate() ) { |
100 | QTime time(0, 0, 0); | 100 | QTime time(0, 0, 0); |
101 | QDateTime date(event.dueDate(), time ); | 101 | QDateTime date(event.dueDate(), time ); |
102 | addPropValue( task, VCDueProp, | 102 | addPropValue( task, VCDueProp, |
103 | TimeConversion::toISO8601( date ) ); | 103 | TimeConversion::toISO8601( date ) ); |
104 | } | 104 | } |
105 | 105 | ||
106 | if( event.isCompleted() ) | 106 | if( event.isCompleted() ) |
@@ -129,154 +129,154 @@ namespace { | |||
129 | #else | 129 | #else |
130 | addPropValue( task, VCDescriptionProp, | 130 | addPropValue( task, VCDescriptionProp, |
131 | event.summary().local8Bit() ); | 131 | event.summary().local8Bit() ); |
132 | 132 | ||
133 | addPropValue( task, VCSummaryProp, | 133 | addPropValue( task, VCSummaryProp, |
134 | event.description().local8Bit() ); | 134 | event.description().local8Bit() ); |
135 | #endif | 135 | #endif |
136 | return task; | 136 | return task; |
137 | }; | 137 | }; |
138 | } | 138 | } |
139 | 139 | ||
140 | namespace Opie { | 140 | namespace Opie { |
141 | OTodoAccessVCal::OTodoAccessVCal( const QString& path ) | 141 | OPimTodoAccessVCal::OPimTodoAccessVCal( const QString& path ) |
142 | : m_dirty(false), m_file( path ) | 142 | : m_dirty(false), m_file( path ) |
143 | { | 143 | { |
144 | } | 144 | } |
145 | OTodoAccessVCal::~OTodoAccessVCal() { | 145 | OPimTodoAccessVCal::~OPimTodoAccessVCal() { |
146 | } | 146 | } |
147 | bool OTodoAccessVCal::load() { | 147 | bool OPimTodoAccessVCal::load() { |
148 | m_map.clear(); | 148 | m_map.clear(); |
149 | m_dirty = false; | 149 | m_dirty = false; |
150 | 150 | ||
151 | VObject* vcal = 0l; | 151 | VObject* vcal = 0l; |
152 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); | 152 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); |
153 | if (!vcal ) | 153 | if (!vcal ) |
154 | return false; | 154 | return false; |
155 | 155 | ||
156 | // Iterate over the list | 156 | // Iterate over the list |
157 | VObjectIterator it; | 157 | VObjectIterator it; |
158 | VObject* vobj; | 158 | VObject* vobj; |
159 | 159 | ||
160 | initPropIterator(&it, vcal); | 160 | initPropIterator(&it, vcal); |
161 | 161 | ||
162 | while( moreIteration( &it ) ) { | 162 | while( moreIteration( &it ) ) { |
163 | vobj = ::nextVObject( &it ); | 163 | vobj = ::nextVObject( &it ); |
164 | QCString name = ::vObjectName( vobj ); | 164 | QCString name = ::vObjectName( vobj ); |
165 | if( name == VCTodoProp ){ | 165 | if( name == VCTodoProp ){ |
166 | OTodo to = eventByVObj( vobj ); | 166 | OPimTodo to = eventByVObj( vobj ); |
167 | m_map.insert( to.uid(), to ); | 167 | m_map.insert( to.uid(), to ); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
171 | // Should I do a delete vcal? | 171 | // Should I do a delete vcal? |
172 | 172 | ||
173 | return true; | 173 | return true; |
174 | } | 174 | } |
175 | bool OTodoAccessVCal::reload() { | 175 | bool OPimTodoAccessVCal::reload() { |
176 | return load(); | 176 | return load(); |
177 | } | 177 | } |
178 | bool OTodoAccessVCal::save() { | 178 | bool OPimTodoAccessVCal::save() { |
179 | if (!m_dirty ) | 179 | if (!m_dirty ) |
180 | return true; | 180 | return true; |
181 | 181 | ||
182 | QFileDirect file( m_file ); | 182 | QFileDirect file( m_file ); |
183 | if (!file.open(IO_WriteOnly ) ) | 183 | if (!file.open(IO_WriteOnly ) ) |
184 | return false; | 184 | return false; |
185 | 185 | ||
186 | VObject *obj; | 186 | VObject *obj; |
187 | obj = newVObject( VCCalProp ); | 187 | obj = newVObject( VCCalProp ); |
188 | addPropValue( obj, VCVersionProp, "1.0" ); | 188 | addPropValue( obj, VCVersionProp, "1.0" ); |
189 | VObject *vo; | 189 | VObject *vo; |
190 | for(QMap<int, OTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ | 190 | for(QMap<int, OPimTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ |
191 | vo = vobjByEvent( it.data() ); | 191 | vo = vobjByEvent( it.data() ); |
192 | addVObjectProp(obj, vo ); | 192 | addVObjectProp(obj, vo ); |
193 | } | 193 | } |
194 | writeVObject( file.directHandle(), obj ); | 194 | writeVObject( file.directHandle(), obj ); |
195 | cleanVObject( obj ); | 195 | cleanVObject( obj ); |
196 | cleanStrTbl(); | 196 | cleanStrTbl(); |
197 | 197 | ||
198 | m_dirty = false; | 198 | m_dirty = false; |
199 | return true; | 199 | return true; |
200 | } | 200 | } |
201 | void OTodoAccessVCal::clear() { | 201 | void OPimTodoAccessVCal::clear() { |
202 | m_map.clear(); | 202 | m_map.clear(); |
203 | m_dirty = true; | 203 | m_dirty = true; |
204 | } | 204 | } |
205 | bool OTodoAccessVCal::add( const OTodo& to ) { | 205 | bool OPimTodoAccessVCal::add( const OPimTodo& to ) { |
206 | m_map.insert( to.uid(), to ); | 206 | m_map.insert( to.uid(), to ); |
207 | m_dirty = true; | 207 | m_dirty = true; |
208 | return true; | 208 | return true; |
209 | } | 209 | } |
210 | bool OTodoAccessVCal::remove( int uid ) { | 210 | bool OPimTodoAccessVCal::remove( int uid ) { |
211 | m_map.remove( uid ); | 211 | m_map.remove( uid ); |
212 | m_dirty = true; | 212 | m_dirty = true; |
213 | return true; | 213 | return true; |
214 | } | 214 | } |
215 | void OTodoAccessVCal::removeAllCompleted() { | 215 | void OPimTodoAccessVCal::removeAllCompleted() { |
216 | for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { | 216 | for ( QMap<int, OPimTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { |
217 | if ( (*it).isCompleted() ) | 217 | if ( (*it).isCompleted() ) |
218 | m_map.remove( it ); | 218 | m_map.remove( it ); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | bool OTodoAccessVCal::replace( const OTodo& to ) { | 221 | bool OPimTodoAccessVCal::replace( const OPimTodo& to ) { |
222 | m_map.replace( to.uid(), to ); | 222 | m_map.replace( to.uid(), to ); |
223 | m_dirty = true; | 223 | m_dirty = true; |
224 | return true; | 224 | return true; |
225 | } | 225 | } |
226 | OTodo OTodoAccessVCal::find(int uid )const { | 226 | OPimTodo OPimTodoAccessVCal::find(int uid )const { |
227 | return m_map[uid]; | 227 | return m_map[uid]; |
228 | } | 228 | } |
229 | QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { | 229 | QArray<int> OPimTodoAccessVCal::sorted( bool, int, int, int ) { |
230 | QArray<int> ar(0); | 230 | QArray<int> ar(0); |
231 | return ar; | 231 | return ar; |
232 | } | 232 | } |
233 | QArray<int> OTodoAccessVCal::allRecords()const { | 233 | QArray<int> OPimTodoAccessVCal::allRecords()const { |
234 | QArray<int> ar( m_map.count() ); | 234 | QArray<int> ar( m_map.count() ); |
235 | QMap<int, OTodo>::ConstIterator it; | 235 | QMap<int, OPimTodo>::ConstIterator it; |
236 | int i = 0; | 236 | int i = 0; |
237 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { | 237 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { |
238 | ar[i] = it.key(); | 238 | ar[i] = it.key(); |
239 | i++; | 239 | i++; |
240 | } | 240 | } |
241 | return ar; | 241 | return ar; |
242 | } | 242 | } |
243 | QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp& /* r */)const { | 243 | QArray<int> OPimTodoAccessVCal::matchRegexp(const QRegExp& /* r */)const { |
244 | QArray<int> ar(0); | 244 | QArray<int> ar(0); |
245 | return ar; | 245 | return ar; |
246 | } | 246 | } |
247 | QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { | 247 | QArray<int> OPimTodoAccessVCal::queryByExample( const OPimTodo&, int, const QDateTime& ) { |
248 | QArray<int> ar(0); | 248 | QArray<int> ar(0); |
249 | return ar; | 249 | return ar; |
250 | } | 250 | } |
251 | QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , | 251 | QArray<int> OPimTodoAccessVCal::effectiveToDos( const QDate& , |
252 | const QDate& , | 252 | const QDate& , |
253 | bool ) { | 253 | bool ) { |
254 | QArray<int> ar(0); | 254 | QArray<int> ar(0); |
255 | return ar; | 255 | return ar; |
256 | } | 256 | } |
257 | QArray<int> OTodoAccessVCal::overDue() { | 257 | QArray<int> OPimTodoAccessVCal::overDue() { |
258 | QArray<int> ar(0); | 258 | QArray<int> ar(0); |
259 | return ar; | 259 | return ar; |
260 | } | 260 | } |
261 | QBitArray OTodoAccessVCal::supports()const { | 261 | QBitArray OPimTodoAccessVCal::supports()const { |
262 | static QBitArray ar = sup(); | 262 | static QBitArray ar = sup(); |
263 | 263 | ||
264 | return ar; | 264 | return ar; |
265 | } | 265 | } |
266 | QBitArray OTodoAccessVCal::sup() { | 266 | QBitArray OPimTodoAccessVCal::sup() { |
267 | QBitArray ar ( OTodo::CompletedDate +1 ); | 267 | QBitArray ar ( OPimTodo::CompletedDate +1 ); |
268 | ar.fill( true ); | 268 | ar.fill( true ); |
269 | 269 | ||
270 | ar[OTodo::CrossReference] = false; | 270 | ar[OPimTodo::CrossReference] = false; |
271 | ar[OTodo::State ] = false; | 271 | ar[OPimTodo::State ] = false; |
272 | ar[OTodo::Reminders] = false; | 272 | ar[OPimTodo::Reminders] = false; |
273 | ar[OTodo::Notifiers] = false; | 273 | ar[OPimTodo::Notifiers] = false; |
274 | ar[OTodo::Maintainer] = false; | 274 | ar[OPimTodo::Maintainer] = false; |
275 | ar[OTodo::Progress] = false; | 275 | ar[OPimTodo::Progress] = false; |
276 | ar[OTodo::Alarms ] = false; | 276 | ar[OPimTodo::Alarms ] = false; |
277 | ar[OTodo::Recurrence] = false; | 277 | ar[OPimTodo::Recurrence] = false; |
278 | 278 | ||
279 | return ar; | 279 | return ar; |
280 | } | 280 | } |
281 | 281 | ||
282 | } | 282 | } |