-rw-r--r-- | libopie/tododb.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp index 91331d0..e440dfc 100644 --- a/libopie/tododb.cpp +++ b/libopie/tododb.cpp | |||
@@ -93,123 +93,123 @@ public: | |||
93 | event.setDate( date); | 93 | event.setDate( date); |
94 | } | 94 | } |
95 | dummy = element->attribute("Priority" ); | 95 | dummy = element->attribute("Priority" ); |
96 | dumInt = dummy.toInt(&ok ); | 96 | dumInt = dummy.toInt(&ok ); |
97 | if(!ok ) dumInt = ToDoEvent::NORMAL; | 97 | if(!ok ) dumInt = ToDoEvent::NORMAL; |
98 | event.setPriority( dumInt ); | 98 | event.setPriority( dumInt ); |
99 | //description | 99 | //description |
100 | dummy = element->attribute("Description" ); | 100 | dummy = element->attribute("Description" ); |
101 | event.setDescription( dummy ); | 101 | event.setDescription( dummy ); |
102 | // category | 102 | // category |
103 | dummy = element->attribute("Categories" ); | 103 | dummy = element->attribute("Categories" ); |
104 | dumInt = dummy.toInt(&ok ); | 104 | dumInt = dummy.toInt(&ok ); |
105 | if(ok ) { | 105 | if(ok ) { |
106 | QArray<int> arrat(1); | 106 | QArray<int> arrat(1); |
107 | arrat[0] = dumInt; | 107 | arrat[0] = dumInt; |
108 | event.setCategory( Qtopia::Record::idsToString( arrat ) ); | 108 | event.setCategory( Qtopia::Record::idsToString( arrat ) ); |
109 | } | 109 | } |
110 | //uid | 110 | //uid |
111 | dummy = element->attribute("Uid" ); | 111 | dummy = element->attribute("Uid" ); |
112 | dumInt = dummy.toInt(&ok ); | 112 | dumInt = dummy.toInt(&ok ); |
113 | if(ok ) event.setUid( dumInt ); | 113 | if(ok ) event.setUid( dumInt ); |
114 | m_todos.append( event ); | 114 | m_todos.append( event ); |
115 | element = element->nextChild(); // next element | 115 | element = element->nextChild(); // next element |
116 | } | 116 | } |
117 | //} | 117 | //} |
118 | }else { | 118 | }else { |
119 | qWarning("could not load" ); | 119 | qWarning("could not load" ); |
120 | } | 120 | } |
121 | delete root; | 121 | delete root; |
122 | return m_todos; | 122 | return m_todos; |
123 | } | 123 | } |
124 | }; | 124 | }; |
125 | 125 | ||
126 | } | 126 | } |
127 | 127 | ||
128 | ToDoDB::ToDoDB(const QString &fileName = QString::null, ToDoResource *res ){ | 128 | ToDoDB::ToDoDB(const QString &fileName = QString::null, ToDoResource *res ){ |
129 | m_fileName = fileName; | 129 | m_fileName = fileName; |
130 | if( fileName.isEmpty() && res == 0 ){ | 130 | if( fileName.isEmpty() && res == 0 ){ |
131 | m_fileName = Global::applicationFileName("todolist","todolist.xml");; | 131 | m_fileName = Global::applicationFileName("todolist","todolist.xml");; |
132 | //qWarning("%s", m_fileName.latin1() ); | 132 | //qWarning("%s", m_fileName.latin1() ); |
133 | }else if(res == 0 ){ // let's create a ToDoResource for xml | 133 | }else if(res == 0 ){ // let's create a ToDoResource for xml |
134 | res = new FileToDoResource(); | 134 | res = new FileToDoResource(); |
135 | } | 135 | } |
136 | m_res = res; | 136 | m_res = res; |
137 | load(); | 137 | load(); |
138 | } | 138 | } |
139 | ToDoDB::~ToDoDB() | 139 | ToDoDB::~ToDoDB() |
140 | { | 140 | { |
141 | 141 | delete m_res; | |
142 | } | 142 | } |
143 | QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, const QDate &to, | 143 | QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, const QDate &to, |
144 | bool all ) | 144 | bool all ) |
145 | { | 145 | { |
146 | QValueList<ToDoEvent> events; | 146 | QValueList<ToDoEvent> events; |
147 | for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ | 147 | for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ |
148 | if( (*it).hasDate() ){ | 148 | if( (*it).hasDate() ){ |
149 | if( (*it).date() >= from && (*it).date() <= to ) | 149 | if( (*it).date() >= from && (*it).date() <= to ) |
150 | events.append( (*it) ); | 150 | events.append( (*it) ); |
151 | }else if( all ){ | 151 | }else if( all ){ |
152 | events.append( (*it) ); | 152 | events.append( (*it) ); |
153 | } | 153 | } |
154 | } | 154 | } |
155 | return events; | 155 | return events; |
156 | } | 156 | } |
157 | QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, | 157 | QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, |
158 | bool all) | 158 | bool all) |
159 | { | 159 | { |
160 | return effectiveToDos( from, QDate::currentDate(), all ); | 160 | return effectiveToDos( from, QDate::currentDate(), all ); |
161 | } | 161 | } |
162 | QValueList<ToDoEvent> ToDoDB::overDue() | 162 | QValueList<ToDoEvent> ToDoDB::overDue() |
163 | { | 163 | { |
164 | QValueList<ToDoEvent> events; | 164 | QValueList<ToDoEvent> events; |
165 | for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ | 165 | for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ |
166 | if( (*it).isOverdue() ) | 166 | if( (*it).isOverdue() ) |
167 | events.append((*it) ); | 167 | events.append((*it) ); |
168 | } | 168 | } |
169 | return events; | 169 | return events; |
170 | } | 170 | } |
171 | QValueList<ToDoEvent> ToDoDB::rawToDos() | 171 | QValueList<ToDoEvent> ToDoDB::rawToDos() |
172 | { | 172 | { |
173 | return m_todos; | 173 | return m_todos; |
174 | } | 174 | } |
175 | void ToDoDB::addEvent( const ToDoEvent &event ) | 175 | void ToDoDB::addEvent( const ToDoEvent &event ) |
176 | { | 176 | { |
177 | m_todos.append( event ); | 177 | m_todos.append( event ); |
178 | } | 178 | } |
179 | void ToDoDB::editEvent( const ToDoEvent &event ) | 179 | void ToDoDB::editEvent( const ToDoEvent &event ) |
180 | { | 180 | { |
181 | m_todos.remove( event ); | 181 | m_todos.remove( event ); |
182 | m_todos.append( event ); | 182 | m_todos.append( event ); |
183 | } | 183 | } |
184 | void ToDoDB::removeEvent( const ToDoEvent &event ) | 184 | void ToDoDB::removeEvent( const ToDoEvent &event ) |
185 | { | 185 | { |
186 | m_todos.remove( event ); | 186 | m_todos.remove( event ); |
187 | } | 187 | } |
188 | void ToDoDB::reload() | 188 | void ToDoDB::reload() |
189 | { | 189 | { |
190 | load(); | 190 | load(); |
191 | } | 191 | } |
192 | void ToDoDB::setFileName(const QString &file ) | 192 | void ToDoDB::setFileName(const QString &file ) |
193 | { | 193 | { |
194 | m_fileName =file; | 194 | m_fileName =file; |
195 | } | 195 | } |
196 | QString ToDoDB::fileName()const | 196 | QString ToDoDB::fileName()const |
197 | { | 197 | { |
198 | return m_fileName; | 198 | return m_fileName; |
199 | } | 199 | } |
200 | void ToDoDB::load() | 200 | void ToDoDB::load() |
201 | { | 201 | { |
202 | 202 | m_todos = m_res->load( m_fileName ); | |
203 | } | 203 | } |
204 | bool ToDoDB::save() | 204 | bool ToDoDB::save() |
205 | { | 205 | { |
206 | return m_res->save( m_fileName, m_todos ); | 206 | return m_res->save( m_fileName, m_todos ); |
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | ||
210 | 210 | ||
211 | 211 | ||
212 | 212 | ||
213 | 213 | ||
214 | 214 | ||
215 | 215 | ||