Diffstat (limited to 'libopie/pim/otodoaccesssql.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/pim/otodoaccesssql.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libopie/pim/otodoaccesssql.cpp b/libopie/pim/otodoaccesssql.cpp index 3913661..75a0860 100644 --- a/libopie/pim/otodoaccesssql.cpp +++ b/libopie/pim/otodoaccesssql.cpp | |||
@@ -278,61 +278,64 @@ namespace { | |||
278 | EffQuery::EffQuery( const QDate& start, const QDate& end, bool inc ) | 278 | EffQuery::EffQuery( const QDate& start, const QDate& end, bool inc ) |
279 | : OSQLQuery(), m_start( start ), m_end( end ),m_inc(inc) {} | 279 | : OSQLQuery(), m_start( start ), m_end( end ),m_inc(inc) {} |
280 | EffQuery::~EffQuery() {} | 280 | EffQuery::~EffQuery() {} |
281 | QString EffQuery::query()const { | 281 | QString EffQuery::query()const { |
282 | return m_inc ? with() : out(); | 282 | return m_inc ? with() : out(); |
283 | } | 283 | } |
284 | QString EffQuery::with()const { | 284 | QString EffQuery::with()const { |
285 | QString str; | 285 | QString str; |
286 | str = QString("select uid from todolist where ( DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6' ) OR DueDate = '0-0-0' ") | 286 | str = QString("select uid from todolist where ( DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6' ) OR DueDate = '0-0-0' ") |
287 | .arg( m_start.year() ).arg( m_start.month() ).arg( m_start.day() ) | 287 | .arg( m_start.year() ).arg( m_start.month() ).arg( m_start.day() ) |
288 | .arg( m_end .year() ).arg( m_end .month() ).arg( m_end .day() ); | 288 | .arg( m_end .year() ).arg( m_end .month() ).arg( m_end .day() ); |
289 | return str; | 289 | return str; |
290 | } | 290 | } |
291 | QString EffQuery::out()const { | 291 | QString EffQuery::out()const { |
292 | QString str; | 292 | QString str; |
293 | str = QString("select uid from todolist where DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6'") | 293 | str = QString("select uid from todolist where DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6'") |
294 | .arg(m_start.year() ).arg(m_start.month() ).arg( m_start.day() ) | 294 | .arg(m_start.year() ).arg(m_start.month() ).arg( m_start.day() ) |
295 | .arg(m_end. year() ).arg(m_end. month() ).arg(m_end.day() ); | 295 | .arg(m_end. year() ).arg(m_end. month() ).arg(m_end.day() ); |
296 | 296 | ||
297 | return str; | 297 | return str; |
298 | } | 298 | } |
299 | }; | 299 | }; |
300 | 300 | ||
301 | OTodoAccessBackendSQL::OTodoAccessBackendSQL( const QString& file ) | 301 | OTodoAccessBackendSQL::OTodoAccessBackendSQL( const QString& file ) |
302 | : OTodoAccessBackend(), m_dict(15), m_dirty(true) | 302 | : OTodoAccessBackend(), m_dict(15), m_driver(NULL), m_dirty(true) |
303 | { | 303 | { |
304 | QString fi = file; | 304 | QString fi = file; |
305 | if ( fi.isEmpty() ) | 305 | if ( fi.isEmpty() ) |
306 | fi = Global::applicationFileName( "todolist", "todolist.db" ); | 306 | fi = Global::applicationFileName( "todolist", "todolist.db" ); |
307 | OSQLManager man; | 307 | OSQLManager man; |
308 | m_driver = man.standard(); | 308 | m_driver = man.standard(); |
309 | m_driver->setUrl(fi); | 309 | m_driver->setUrl(fi); |
310 | // fillDict(); | 310 | // fillDict(); |
311 | } | 311 | } |
312 | 312 | ||
313 | OTodoAccessBackendSQL::~OTodoAccessBackendSQL(){ | 313 | OTodoAccessBackendSQL::~OTodoAccessBackendSQL(){ |
314 | if( m_driver ) | ||
315 | delete m_driver; | ||
314 | } | 316 | } |
317 | |||
315 | bool OTodoAccessBackendSQL::load(){ | 318 | bool OTodoAccessBackendSQL::load(){ |
316 | if (!m_driver->open() ) | 319 | if (!m_driver->open() ) |
317 | return false; | 320 | return false; |
318 | 321 | ||
319 | CreateQuery creat; | 322 | CreateQuery creat; |
320 | OSQLResult res = m_driver->query(&creat ); | 323 | OSQLResult res = m_driver->query(&creat ); |
321 | 324 | ||
322 | m_dirty = true; | 325 | m_dirty = true; |
323 | return true; | 326 | return true; |
324 | } | 327 | } |
325 | bool OTodoAccessBackendSQL::reload(){ | 328 | bool OTodoAccessBackendSQL::reload(){ |
326 | return load(); | 329 | return load(); |
327 | } | 330 | } |
328 | 331 | ||
329 | bool OTodoAccessBackendSQL::save(){ | 332 | bool OTodoAccessBackendSQL::save(){ |
330 | return m_driver->close(); | 333 | return m_driver->close(); |
331 | } | 334 | } |
332 | QArray<int> OTodoAccessBackendSQL::allRecords()const { | 335 | QArray<int> OTodoAccessBackendSQL::allRecords()const { |
333 | if (m_dirty ) | 336 | if (m_dirty ) |
334 | update(); | 337 | update(); |
335 | 338 | ||
336 | return m_uids; | 339 | return m_uids; |
337 | } | 340 | } |
338 | QArray<int> OTodoAccessBackendSQL::queryByExample( const OTodo& , int, const QDateTime& ){ | 341 | QArray<int> OTodoAccessBackendSQL::queryByExample( const OTodo& , int, const QDateTime& ){ |