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

List:       kde-commits
Subject:    KDE/kdepimlibs/akonadi/kmime
From:       Andras Mantia <amantia () kde ! org>
Date:       2010-09-17 10:09:53
Message-ID: 20100917100953.178C3AC888 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1176308 by amantia:

Support multiple collections in the duplicate removal actions. It removes the \
duplicates per collection.

 M  +22 -10    removeduplicatescommand.cpp  
 M  +6 -3      removeduplicatescommand_p.h  
 M  +5 -5      standardmailactionmanager.cpp  


--- trunk/KDE/kdepimlibs/akonadi/kmime/removeduplicatescommand.cpp #1176307:1176308
@@ -19,23 +19,28 @@
 
 
 #include "removeduplicatescommand_p.h"
+#include "movetotrashcommand_p.h"
 #include "util_p.h"
 
-#include <akonadi/itemfetchjob.h>
-#include <akonadi/itemfetchscope.h>
-#include <kmime/kmime_message.h>
-#include "movetotrashcommand_p.h"
+#include "akonadi/itemfetchjob.h"
+#include "akonadi/itemfetchscope.h"
+#include "kmime/kmime_message.h"
 
-RemoveDuplicatesCommand::RemoveDuplicatesCommand( QAbstractItemModel* model, const \
Akonadi::Collection& folder, QObject* parent ) : \
+RemoveDuplicatesCommand::RemoveDuplicatesCommand( QAbstractItemModel* model, const \
Akonadi::Collection::List& folders, QObject* parent ) :  CommandBase( parent )
 {
   mModel = model;
-  mFolder = folder;
+  mFolders = folders;
+  mJobCount = mFolders.size();
 }
 
 void RemoveDuplicatesCommand::execute()
 {
-    Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( mFolder, parent() );
+    if ( mJobCount <= 0 ) {
+      emitResult( OK );
+      return;
+    }
+    Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( mFolders[ mJobCount - 1] \
                , parent() );
     job->fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
     job->fetchScope().fetchFullPayload();
     connect( job, SIGNAL( result( KJob* ) ), this, SLOT( slotFetchDone( KJob* ) ) );
@@ -43,6 +48,7 @@
 
 void RemoveDuplicatesCommand::slotFetchDone( KJob* job )
 {
+  mJobCount--;
   if ( job->error() ) {
     // handle errors
     Util::showJobError(job);
@@ -83,15 +89,21 @@
     }
   }
 
-  Akonadi::Item::List duplicateItems;
   for(  QMap<uint, QList<uint> >::iterator it = duplicates.begin(); it != \
                duplicates.end(); ++it ) {    
     for (QList<uint>::iterator dupIt = it.value().begin(); dupIt != \
                it.value().end(); ++dupIt ) {
-      duplicateItems.append( items[*dupIt] );
+      mDuplicateItems.append( items[*dupIt] );
     }
   }
 
-  MoveToTrashCommand *trashCmd = new MoveToTrashCommand( mModel, duplicateItems, \
parent() ); +  if ( mJobCount > 0 ) {
+    Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( mFolders[ mJobCount - 1 \
] , parent() ); +    job->fetchScope().setAncestorRetrieval( \
Akonadi::ItemFetchScope::Parent ); +    job->fetchScope().fetchFullPayload();
+    connect( job, SIGNAL( result( KJob* ) ), this, SLOT( slotFetchDone( KJob* ) ) ); \
 +  } else {
+    MoveToTrashCommand *trashCmd = new MoveToTrashCommand( mModel, mDuplicateItems, \
parent() );  connect( trashCmd, SIGNAL(result(Result)), this, \
SLOT(emitResult(Result)) );  trashCmd->execute();
 }
+}
 
--- trunk/KDE/kdepimlibs/akonadi/kmime/removeduplicatescommand_p.h #1176307:1176308
@@ -23,7 +23,8 @@
 
 #include <commandbase_p.h>
 
-#include <akonadi/collection.h>
+#include "akonadi/collection.h"
+#include "akonadi/item.h"
 
 class QAbstractItemModel;
 class KJob;
@@ -32,13 +33,15 @@
 {
   Q_OBJECT
 public:
-    RemoveDuplicatesCommand( QAbstractItemModel* model, const Akonadi::Collection& \
folder, QObject* parent = 0); +    RemoveDuplicatesCommand( QAbstractItemModel* \
model, const Akonadi::Collection::List& folders, QObject* parent = 0);  virtual void \
execute();  
 private Q_SLOTS:
     void slotFetchDone( KJob* job );
 private:
-    Akonadi::Collection mFolder;
+    Akonadi::Collection::List mFolders;
+    Akonadi::Item::List mDuplicateItems;
+    int mJobCount;
     QAbstractItemModel* mModel; //just pass to the internal trash command
 };
 
--- trunk/KDE/kdepimlibs/akonadi/kmime/standardmailactionmanager.cpp #1176307:1176308
@@ -329,12 +329,12 @@
       if ( mCollectionSelectionModel->selection().indexes().isEmpty() )
         return;
 
-      const QModelIndex index = mCollectionSelectionModel->selection().indexes().at( \
                0 );
-      Q_ASSERT( index.isValid() );
-      const Collection collection = index.data( CollectionModel::CollectionRole \
                ).value<Collection>();
-      Q_ASSERT( collection.isValid() );
+      Collection::List collections = selectedCollections();
 
-      RemoveDuplicatesCommand *command = new RemoveDuplicatesCommand( \
const_cast<QAbstractItemModel*>( mCollectionSelectionModel->model() ), collection, \
mParent ); +      if ( collections.isEmpty() )
+        return;
+
+      RemoveDuplicatesCommand *command = new RemoveDuplicatesCommand( \
const_cast<QAbstractItemModel*>( mCollectionSelectionModel->model() ), collections, \
mParent );  command->execute();
     }
 


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

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