[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-16 12:30:10
Message-ID: 20100916123010.3CEB3AC871 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1176019 by amantia:
Support multiple collections when moving to trash, marking as something.
M +18 -6 markascommand.cpp
M +3 -2 markascommand_p.h
M +2 -0 movecommand.cpp
M +31 -9 movetotrashcommand.cpp
M +4 -2 movetotrashcommand_p.h
M +26 -10 standardmailactionmanager.cpp
--- trunk/KDE/kdepimlibs/akonadi/kmime/markascommand.cpp #1176018:1176019
@@ -28,16 +28,20 @@
{
mMessages = msgList;
mTargetStatus = targetStatus;
+ mFolderListJobCount = 0;
}
-MarkAsCommand::MarkAsCommand(const Akonadi::MessageStatus &targetStatus, const \
Akonadi::Collection& sourceFolder, QObject* parent): CommandBase( parent ) \
+MarkAsCommand::MarkAsCommand(const Akonadi::MessageStatus &targetStatus, const \
Akonadi::Collection::List& folders, QObject* parent): CommandBase( parent ) {
- mSourceFolder = sourceFolder;
+ mFolders = folders;
mTargetStatus = targetStatus;
+ mFolderListJobCount = mFolders.size();
}
void MarkAsCommand::slotFetchDone(KJob* job)
{
+ mFolderListJobCount--;
+
if ( job->error() ) {
// handle errors
Util::showJobError(job);
@@ -62,17 +66,24 @@
}
markMessages();
+
+ if ( mFolderListJobCount > 0 ) {
+ Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( \
mFolders[mFolderListJobCount - 1], parent() ); + \
job->fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent ); + \
connect( job, SIGNAL( result( KJob* ) ), this, SLOT( slotFetchDone( KJob* ) ) ); }
+}
void MarkAsCommand::execute()
{
- if ( mSourceFolder.isValid() ) {
- Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( mSourceFolder, parent() \
); + if ( !mFolders.isEmpty() ) {
+ //yes, we go backwards, shouldn't matter
+ Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( \
mFolders[mFolderListJobCount - 1], parent() );
job->fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
connect( job, SIGNAL( result( KJob* ) ), this, SLOT( slotFetchDone( KJob* ) ) );
} else if ( !mMessages.isEmpty() ) {
- mSourceFolder = mMessages.first().parentCollection();
+ mFolders << mMessages.first().parentCollection();
markMessages();
} else {
emitResult( OK );
@@ -114,7 +125,8 @@
kDebug()<<" Error trying to set item status:" << job->errorText();
emitResult( Failed );
}
- if ( mMarkJobCount == 0 ) {
+ if ( mMarkJobCount == 0 && mFolderListJobCount == 0 ) {
+ qDebug() << "MARK ALL AS DONE";
emitResult( OK );
}
}
--- trunk/KDE/kdepimlibs/akonadi/kmime/markascommand_p.h #1176018:1176019
@@ -34,7 +34,7 @@
Q_OBJECT
public:
MarkAsCommand( const Akonadi::MessageStatus& targetStatus, const \
Akonadi::Item::List & msgList, QObject* parent = 0 );
- MarkAsCommand( const Akonadi::MessageStatus& targetStatus, const \
Akonadi::Collection& sourceFolder, QObject* parent = 0 ); + MarkAsCommand( const \
Akonadi::MessageStatus& targetStatus, const Akonadi::Collection::List& folders, \
QObject* parent = 0 ); void execute();
private Q_SLOTS:
@@ -44,10 +44,11 @@
private:
void markMessages();
- Akonadi::Collection mSourceFolder;
+ Akonadi::Collection::List mFolders;
QList<Akonadi::Item> mMessages;
Akonadi::MessageStatus mTargetStatus;
int mMarkJobCount;
+ int mFolderListJobCount;
};
#endif // MARKASCOMMAND_H
--- trunk/KDE/kdepimlibs/akonadi/kmime/movecommand.cpp #1176018:1176019
@@ -35,6 +35,8 @@
void MoveCommand::execute()
{
+ if ( mMessages.isEmpty() )
+ emitResult( OK );
if ( mDestFolder.isValid() ) {
Akonadi::ItemMoveJob *job = new Akonadi::ItemMoveJob( mMessages, mDestFolder, \
this );
connect( job, SIGNAL(result(KJob*)), this, SLOT(slotMoveResult(KJob*)) );
--- trunk/KDE/kdepimlibs/akonadi/kmime/movetotrashcommand.cpp #1176018:1176019
@@ -28,11 +28,12 @@
#include <akonadi/kmime/specialmailcollections.h>
#include <akonadi/entitytreemodel.h>
-MoveToTrashCommand::MoveToTrashCommand(QAbstractItemModel* model, const \
Akonadi::Collection& sourceFolder, QObject* parent): CommandBase( parent ) \
+MoveToTrashCommand::MoveToTrashCommand(QAbstractItemModel* model, const \
Akonadi::Collection::List& folders, QObject* parent): CommandBase( parent ) {
the_trashCollectionFolder = -1;
- mSourceFolder = sourceFolder;
+ mFolders = folders;
mModel = model;
+ mFolderListJobCount = mFolders.size();
}
MoveToTrashCommand::MoveToTrashCommand(QAbstractItemModel* model, const QList< \
Akonadi::Item >& msgList, QObject* parent): CommandBase( parent ) @@ -40,11 +41,14 @@
the_trashCollectionFolder = -1;
mMessages = msgList;
mModel = model;
+ mFolderListJobCount = 0;
}
void MoveToTrashCommand::slotFetchDone(KJob* job)
{
+ mFolderListJobCount--;
+
if ( job->error() ) {
// handle errors
Util::showJobError(job);
@@ -57,17 +61,23 @@
mMessages = fjob->items();
moveMessages();
+
+ if ( mFolderListJobCount > 0 ) {
+ Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( \
mFolders[mFolderListJobCount - 1], parent() ); + \
job->fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent ); + \
connect( job, SIGNAL( result( KJob* ) ), this, SLOT( slotFetchDone( KJob* ) ) ); }
+}
void MoveToTrashCommand::execute()
{
- if ( mSourceFolder.isValid() ) {
- Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( mSourceFolder, parent() \
); + if ( !mFolders.isEmpty() ) {
+ Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( \
mFolders[mFolderListJobCount - 1], parent() );
job->fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
connect( job, SIGNAL( result( KJob* ) ), this, SLOT( slotFetchDone( KJob* ) ) );
} else if ( !mMessages.isEmpty() ) {
- mSourceFolder = mMessages.first().parentCollection();
+ mFolders << mMessages.first().parentCollection();
moveMessages();
} else {
emitResult( OK );
@@ -76,14 +86,26 @@
void MoveToTrashCommand::moveMessages()
{
- if ( mSourceFolder.isValid() ) {
- MoveCommand *moveCommand = new MoveCommand( findTrashFolder( mSourceFolder ), \
mMessages, this );
- connect( moveCommand, SIGNAL( result( Result ) ), this, SLOT( emitResult( Result \
) ) ); + Akonadi::Collection folder = mFolders[mFolderListJobCount];
+ if ( folder.isValid() ) {
+ MoveCommand *moveCommand = new MoveCommand( findTrashFolder( folder ), \
mMessages, this ); + connect( moveCommand, SIGNAL( result( Result ) ), this, SLOT( \
slotMoveDone( Result ) ) ); moveCommand->execute();
- } else
+ } else {
emitResult( Failed );
}
+}
+void MoveToTrashCommand::slotMoveDone( const Result& result )
+{
+ if (result == Failed )
+ emitResult( Failed );
+ if ( mFolderListJobCount == 0 && result == OK) {
+ qDebug() << "MOVETOTRASH ALL AS DONE";
+ emitResult( OK );
+ }
+}
+
Akonadi::Collection MoveToTrashCommand::collectionFromId(const \
Akonadi::Collection::Id& id) const {
const QModelIndex idx = Akonadi::EntityTreeModel::modelIndexForCollection(
--- trunk/KDE/kdepimlibs/akonadi/kmime/movetotrashcommand_p.h #1176018:1176019
@@ -35,12 +35,13 @@
Q_OBJECT
public:
MoveToTrashCommand( QAbstractItemModel* model, const QList< Akonadi::Item >& \
msgList, QObject* parent = 0 );
- MoveToTrashCommand( QAbstractItemModel* model, const Akonadi::Collection& \
sourceFolder, QObject* parent = 0 ); + MoveToTrashCommand( QAbstractItemModel* \
model, const Akonadi::Collection::List& folders, QObject* parent = 0 );
/*reimp*/ void execute();
private Q_SLOTS:
void slotFetchDone( KJob* job );
+ void slotMoveDone( const Result &result);
private:
void moveMessages();
@@ -49,10 +50,11 @@
Akonadi::Collection findTrashFolder( const Akonadi::Collection& folder );
Akonadi::Collection collectionFromId(const Akonadi::Collection::Id& id) const;
- Akonadi::Collection mSourceFolder;
+ Akonadi::Collection::List mFolders;
QList<Akonadi::Item> mMessages;
Akonadi::Collection::Id the_trashCollectionFolder;
QAbstractItemModel* mModel;
+ int mFolderListJobCount;
};
#endif // MOVETOTRASHCOMMAND_H
\ No newline at end of file
--- trunk/KDE/kdepimlibs/akonadi/kmime/standardmailactionmanager.cpp #1176018:1176019
@@ -199,6 +199,23 @@
return index.data( EntityTreeModel::CollectionRole).value<Collection>();
}
+ Collection::List selectedCollections() const
+ {
+ Collection::List collections;
+
+ if ( !mCollectionSelectionModel )
+ return collections;
+
+ foreach ( const QModelIndex &index, mCollectionSelectionModel->selectedRows() \
) { + const Collection collection = index.data( \
EntityTreeModel::CollectionRole ).value<Collection>(); + if ( \
collection.isValid() ) + collections << collection;
+ }
+
+ return collections;
+ }
+
+
AgentInstance selectedAgentInstance() const
{
const Collection collection = selectedCollection();
@@ -270,15 +287,14 @@
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();
+ if ( collections.isEmpty() )
+ return;
Akonadi::MessageStatus targetStatus;
targetStatus.setStatusFromStr( QLatin1String( typeStr ) );
- MarkAsCommand *command = new MarkAsCommand( targetStatus, collection, mParent \
); + MarkAsCommand *command = new MarkAsCommand( targetStatus, collections, \
mParent ); command->execute();
}
@@ -296,12 +312,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();
- MoveToTrashCommand *command = new MoveToTrashCommand( \
const_cast<QAbstractItemModel*>( mCollectionSelectionModel->model() ), collection, \
mParent ); + if ( collections.isEmpty() )
+ return;
+
+ MoveToTrashCommand *command = new MoveToTrashCommand( \
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