author | zecke <zecke> | 2002-04-15 20:53:57 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-04-15 20:53:57 (UTC) |
commit | e010d922ac415558e5efd35e69e39e45908b5501 (patch) (unidiff) | |
tree | 7b6dac3a82613fdefb15c818541891f577ecf48d /libopie/tododb.cpp | |
parent | 15244683bb97d303d0d3b6104b46a9b429aaed85 (diff) | |
download | opie-e010d922ac415558e5efd35e69e39e45908b5501.zip opie-e010d922ac415558e5efd35e69e39e45908b5501.tar.gz opie-e010d922ac415558e5efd35e69e39e45908b5501.tar.bz2 |
updates?
too much to remember
-rw-r--r-- | libopie/tododb.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp index 3f6dc30..4d6711d 100644 --- a/libopie/tododb.cpp +++ b/libopie/tododb.cpp | |||
@@ -176,52 +176,72 @@ QValueList<ToDoEvent> ToDoDB::overDue() | |||
176 | QValueList<ToDoEvent> events; | 176 | QValueList<ToDoEvent> events; |
177 | for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ | 177 | for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ |
178 | if( (*it).isOverdue() ) | 178 | if( (*it).isOverdue() ) |
179 | events.append((*it) ); | 179 | events.append((*it) ); |
180 | } | 180 | } |
181 | return events; | 181 | return events; |
182 | } | 182 | } |
183 | QValueList<ToDoEvent> ToDoDB::rawToDos() | 183 | QValueList<ToDoEvent> ToDoDB::rawToDos() |
184 | { | 184 | { |
185 | return m_todos; | 185 | return m_todos; |
186 | } | 186 | } |
187 | void ToDoDB::addEvent( const ToDoEvent &event ) | 187 | void ToDoDB::addEvent( const ToDoEvent &event ) |
188 | { | 188 | { |
189 | m_todos.append( event ); | 189 | m_todos.append( event ); |
190 | } | 190 | } |
191 | void ToDoDB::editEvent( const ToDoEvent &event ) | 191 | void ToDoDB::editEvent( const ToDoEvent &event ) |
192 | { | 192 | { |
193 | m_todos.remove( event ); | 193 | m_todos.remove( event ); |
194 | m_todos.append( event ); | 194 | m_todos.append( event ); |
195 | } | 195 | } |
196 | void ToDoDB::removeEvent( const ToDoEvent &event ) | 196 | void ToDoDB::removeEvent( const ToDoEvent &event ) |
197 | { | 197 | { |
198 | m_todos.remove( event ); | 198 | m_todos.remove( event ); |
199 | } | 199 | } |
200 | void ToDoDB::replaceEvent(const ToDoEvent &event ) | ||
201 | { | ||
202 | QValueList<ToDoEvent>::Iterator it; | ||
203 | int uid = event.uid(); | ||
204 | // == is not overloaded as we would like :( so let's search for the uid | ||
205 | for(it = m_todos.begin(); it != m_todos.end(); ++it ){ | ||
206 | if( (*it).uid() == uid ){ | ||
207 | m_todos.remove( (*it) ); | ||
208 | break; // should save us the iterate is now borked | ||
209 | } | ||
210 | } | ||
211 | m_todos.append(event); | ||
212 | } | ||
200 | void ToDoDB::reload() | 213 | void ToDoDB::reload() |
201 | { | 214 | { |
202 | load(); | 215 | load(); |
203 | } | 216 | } |
217 | void ToDoDB::mergeWith(const QValueList<ToDoEvent>& events ) | ||
218 | { | ||
219 | QValueList<ToDoEvent>::ConstIterator it; | ||
220 | for( it = events.begin(); it != events.end(); ++it ){ | ||
221 | replaceEvent( (*it) ); | ||
222 | } | ||
223 | } | ||
204 | void ToDoDB::setFileName(const QString &file ) | 224 | void ToDoDB::setFileName(const QString &file ) |
205 | { | 225 | { |
206 | m_fileName =file; | 226 | m_fileName =file; |
207 | } | 227 | } |
208 | QString ToDoDB::fileName()const | 228 | QString ToDoDB::fileName()const |
209 | { | 229 | { |
210 | return m_fileName; | 230 | return m_fileName; |
211 | } | 231 | } |
212 | void ToDoDB::load() | 232 | void ToDoDB::load() |
213 | { | 233 | { |
214 | m_todos = m_res->load( m_fileName ); | 234 | m_todos = m_res->load( m_fileName ); |
215 | } | 235 | } |
216 | bool ToDoDB::save() | 236 | bool ToDoDB::save() |
217 | { | 237 | { |
218 | return m_res->save( m_fileName, m_todos ); | 238 | return m_res->save( m_fileName, m_todos ); |
219 | } | 239 | } |
220 | 240 | ||
221 | 241 | ||
222 | 242 | ||
223 | 243 | ||
224 | 244 | ||
225 | 245 | ||
226 | 246 | ||
227 | 247 | ||