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

List:       kde-commits
Subject:    KDE/kdepim/kalarm
From:       David Jarvie <djarvie () kde ! org>
Date:       2010-11-08 18:56:17
Message-ID: 20101108185617.5FD61AC89B () svn ! kde ! org
[Download RAW message or body]

SVN commit 1194334 by djarvie:

Prevent spurious errors being displayed when deleting a collection


 M  +14 -0     akonadimodel.cpp  
 M  +3 -0      akonadimodel.h  
 M  +1 -0      collectionmodel.cpp  


--- trunk/KDE/kdepim/kalarm/akonadimodel.cpp #1194333:1194334
@@ -1092,7 +1092,9 @@
 {
     if (!collection.isValid())
         return false;
+    kDebug() << collection.id();
     Collection col = collection;
+    mCollectionsDeleting << collection.id();
     CollectionDeleteJob* job = new CollectionDeleteJob(col);
     connect(job, SIGNAL(result(KJob*)), SLOT(deleteCollectionJobDone(KJob*)));
     mPendingCollectionJobs[job] = CollJobData(col.id(), displayName(col));
@@ -1101,6 +1103,14 @@
 }
 
 /******************************************************************************
+* Return whether a collection is currently being deleted.
+*/
+bool AkonadiModel::isCollectionBeingDeleted(Collection::Id id) const
+{
+    return mCollectionsDeleting.contains(id);
+}
+
+/******************************************************************************
 * Called when a collection deletion job has completed.
 * Checks for any error.
 */
@@ -1366,9 +1376,12 @@
 }
 bool AkonadiModel::deleteEvent(Akonadi::Entity::Id itemId)
 {
+    kDebug() << itemId;
     QModelIndex ix = itemIndex(itemId);
     if (!ix.isValid())
         return false;
+    if (mCollectionsDeleting.contains(ix.data(ParentCollectionRole).value<Collection>().id()))
 +        return true;    // the event's collection is being deleted
     Item item = ix.data(ItemRole).value<Item>();
     ItemDeleteJob* job = new ItemDeleteJob(item);
     connect(job, SIGNAL(result(KJob*)), SLOT(itemJobDone(KJob*)));
@@ -1602,6 +1615,7 @@
 {
     kDebug() << collection.id();
     mCollectionRights.remove(collection.id());
+    mCollectionsDeleting.removeAll(collection.id());
 }
 
 /******************************************************************************
--- trunk/KDE/kdepim/kalarm/akonadimodel.h #1194333:1194334
@@ -118,6 +118,8 @@
          */
         bool removeCollection(const Akonadi::Collection&);
 
+        bool isCollectionBeingDeleted(Akonadi::Collection::Id) const;
+
         QModelIndex         itemIndex(Akonadi::Item::Id id) const
                                         { return itemIndex(Akonadi::Item(id)); }
         QModelIndex         itemIndex(const Akonadi::Item&) const;
@@ -261,6 +263,7 @@
         QMap<KJob*, Akonadi::Item::Id> mPendingItemJobs;  // pending item \
                creation/deletion jobs, with event ID
         QMap<Akonadi::Item::Id, Akonadi::Item> mItemModifyJobQueue;  // pending item \
                modification jobs, invalid item = queue empty but job active
         QList<Akonadi::Item::Id> mItemsBeingCreated;  // new items not fully \
initialised yet +        QList<Akonadi::Collection::Id> mCollectionsDeleting;  // \
                collections currently being removed
         QQueue<Event>   mPendingEventChanges;   // changed events with \
changedEvent() signal pending  QFont           mFont;
 };
--- trunk/KDE/kdepim/kalarm/collectionmodel.cpp #1194333:1194334
@@ -552,6 +552,7 @@
             else
                 removeCollection(collection);
             AkonadiModel* model = static_cast<AkonadiModel*>(sourceModel());
+            if (!model->isCollectionBeingDeleted(collection.id()))
             model->setData(model->collectionIndex(collection), value, \
AkonadiModel::EnabledRole);  }
     }


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

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