summaryrefslogtreecommitdiff
path: root/core/pim/todo/todomanager.cpp
authorzecke <zecke>2002-10-07 11:39:30 (UTC)
committer zecke <zecke>2002-10-07 11:39:30 (UTC)
commitf11d4bda64b58abfebf77485d5d77143a10dc8c9 (patch) (unidiff)
treea4e80550c4abe867303553de608316941dd943f1 /core/pim/todo/todomanager.cpp
parentc2cd5470fa3ec69394fa65ad16ab29a6cadab56f (diff)
downloadopie-f11d4bda64b58abfebf77485d5d77143a10dc8c9.zip
opie-f11d4bda64b58abfebf77485d5d77143a10dc8c9.tar.gz
opie-f11d4bda64b58abfebf77485d5d77143a10dc8c9.tar.bz2
Re add files
for todo
Diffstat (limited to 'core/pim/todo/todomanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/todomanager.cpp125
1 files changed, 125 insertions, 0 deletions
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp
new file mode 100644
index 0000000..8e3fa88
--- a/dev/null
+++ b/core/pim/todo/todomanager.cpp
@@ -0,0 +1,125 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <>
4           .>+-=
5 _;:,     .>    :=|. This program is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This program is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28#include <qdatetime.h>
29#include <qpe/categoryselect.h>
30
31#include "todomanager.h"
32
33using namespace Todo;
34
35TodoManager::TodoManager( QObject *obj )
36 : QObject( obj ) {
37 m_db = 0l;
38 QTime time;
39 time.start();
40 int el = time.elapsed();
41 qWarning("QTimer for loading %d", el/1000 );
42}
43TodoManager::~TodoManager() {
44 delete m_db;
45}
46OTodo TodoManager::event(int uid ) {
47 return m_db->find( uid );
48}
49void TodoManager::updateList() {
50 m_list = m_db->allRecords();
51}
52OTodoAccess::List::Iterator TodoManager::begin() {
53 m_it = m_list.begin();
54 return m_it;
55}
56OTodoAccess::List::Iterator TodoManager::end() {
57 return m_list.end();
58}
59OTodoAccess::List::Iterator TodoManager::overDue() {
60 int filter = 2 & 1;
61 m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca );
62 m_it = m_list.begin();
63 return m_it;
64}
65OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start,
66 const QDate& end ) {
67 m_list = m_db->effectiveToDos( start, end );
68 m_it = m_list.begin();
69 return m_it;
70}
71OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) {
72 m_list = m_db->queryByExample( ev, query );
73 m_it = m_list.begin();
74 return m_it;
75}
76OTodoAccess* TodoManager::todoDB() {
77 return m_db;
78}
79void TodoManager::add( const OTodo& ev ) {
80 m_db->add( ev );
81}
82void TodoManager::update( int, const SmallTodo& ) {
83
84}
85void TodoManager::update( int, const OTodo& ev) {
86 m_db->replace( ev );
87}
88void TodoManager::remove( int uid ) {
89 m_db->remove( uid );
90}
91void TodoManager::removeAll() {
92 m_db->clear();
93}
94void TodoManager::save() {
95 m_db->save();
96}
97bool TodoManager::saveAll() {
98 return m_db->save();
99}
100void TodoManager::reload() {
101 m_db->reload();
102}
103QStringList TodoManager::categories() {
104 m_cat.load(categoryFileName() );
105 return m_cat.labels( "Todo List");
106}
107/*
108 * we rely on load beeing called from populateCategories
109 */
110int TodoManager::catId( const QString& cats ) {
111 return m_cat.id( "Todo List", cats );
112}
113void TodoManager::remove( const QArray<int>& ids) {
114 for (uint i=0; i < ids.size(); i++ )
115 remove( ids[i] );
116}
117bool TodoManager::isLoaded()const {
118 return (m_db == 0 );
119}
120void TodoManager::load() {
121 if (!m_db) {
122 m_db = new OTodoAccess();
123 m_db->load();
124 }
125}