[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdepim/korganizer/views/todoview
From:       Sergio Luis Martins <iamsergio () gmail ! com>
Date:       2010-02-03 3:32:08
Message-ID: 1265167928.713049.7363.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1084417 by smartins:

regression--

Adding sub-todos is now possible without crashing.

Added the old uid hash back because hierarchies are at a kcal level, akonadi has now \
knowledge of to-do hierarchies.

Once akonadi supports incidence relations we can kill a bunch of code in todoview \
just by feeding it the calendarmodel.

Do not backport.


 M  +10 -1     kotodomodel.cpp  
 M  +10 -0     kotodomodel.h  


--- trunk/KDE/kdepim/korganizer/views/todoview/kotodomodel.cpp #1084416:1084417
@@ -65,6 +65,7 @@
     if ( Akonadi::hasTodo( mTodo ) ) {
       mItemId = mTodo.id();
       mModel->mTodoHash.insert( mTodo.id(), this );
+      mModel->mTodoUidHash.insert( Akonadi::todo( mTodo )->uid(), this );
     }
   }
 
@@ -73,9 +74,11 @@
   {
     if ( Akonadi::hasTodo( mTodo ) ) {
       mModel->mTodoHash.remove( mItemId );
+      mModel->mTodoUidHash.remove( Akonadi::todo( mTodo )->uid() );
     } else {
       // root node gets deleted, clear the whole hash
       mModel->mTodoHash.clear();
+      mModel->mTodoUidHash.clear();
     }
     qDeleteAll( mChildren );
   }
@@ -405,6 +408,11 @@
   return mTodoHash.value( todo.id() );
 }
 
+KOTodoModel::TodoTreeNode *KOTodoModel::findTodo( const QString &uid ) const
+{
+  return mTodoUidHash.value( uid );
+}
+
 void KOTodoModel::expandTodoIfNeeded( const Item &todoItem )
 {
   Todo::Ptr todo = Akonadi::todo( todoItem );
@@ -472,7 +480,8 @@
 
     // if the parent is not already in the tree, we have to insert it first.
     // necessary because we can't rely on todos coming in a defined order.
-    TodoTreeNode *parent = findTodo( relatedTodoItem );
+    TodoTreeNode *parent = findTodo( relatedTodo->uid() );
+
     if ( !parent ) {
       parent = insertTodo( relatedTodoItem, checkRelated );
     }
--- trunk/KDE/kdepim/korganizer/views/todoview/kotodomodel.h #1084416:1084417
@@ -158,6 +158,14 @@
     */
     TodoTreeNode *findTodo( const Akonadi::Item &todo ) const;
 
+    /** Recursively find a todo.
+     *
+     * @param uid uid to the todo to find.
+     * @return Pointer to the TodoTreeNode node which represents the todo
+     *         searched for or 0 if not found.
+     */
+     TodoTreeNode *findTodo( const QString &uid ) const;
+
     /**
      * If the todo is overdue or due today, the expandIndex signal
      * is emitted so that the view can expand the parents of this
@@ -195,6 +203,8 @@
     /** Hash to speed up searching todo by their uid */
     QHash<Akonadi::Item::Id, TodoTreeNode*> mTodoHash;
 
+    QHash<QString, TodoTreeNode*> mTodoUidHash;
+
     /** This IncidenceChanger is used to change todos */
     IncidenceChangerBase *mChanger;
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic