summaryrefslogtreecommitdiff
path: root/libopie/tododb.cpp
Side-by-side diff
Diffstat (limited to 'libopie/tododb.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/tododb.cpp20
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
@@ -188,28 +188,48 @@ void ToDoDB::addEvent( const ToDoEvent &event )
{
m_todos.append( event );
}
void ToDoDB::editEvent( const ToDoEvent &event )
{
m_todos.remove( event );
m_todos.append( event );
}
void ToDoDB::removeEvent( const ToDoEvent &event )
{
m_todos.remove( event );
}
+void ToDoDB::replaceEvent(const ToDoEvent &event )
+{
+ QValueList<ToDoEvent>::Iterator it;
+ int uid = event.uid();
+ // == is not overloaded as we would like :( so let's search for the uid
+ for(it = m_todos.begin(); it != m_todos.end(); ++it ){
+ if( (*it).uid() == uid ){
+ m_todos.remove( (*it) );
+ break; // should save us the iterate is now borked
+ }
+ }
+ m_todos.append(event);
+}
void ToDoDB::reload()
{
load();
}
+void ToDoDB::mergeWith(const QValueList<ToDoEvent>& events )
+{
+ QValueList<ToDoEvent>::ConstIterator it;
+ for( it = events.begin(); it != events.end(); ++it ){
+ replaceEvent( (*it) );
+ }
+}
void ToDoDB::setFileName(const QString &file )
{
m_fileName =file;
}
QString ToDoDB::fileName()const
{
return m_fileName;
}
void ToDoDB::load()
{
m_todos = m_res->load( m_fileName );
}