From e5dc44b4a799c5c22a5972ae78fa78e19a2b3396 Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Wed, 22 Jun 2011 20:40:39 +0200 Subject: [PATCH] Fix undo move mail. And add dialog when there is a error (cherry picked from commit 71adab0d59a22b7e122a18bedf7b358f2207c7ad) --- undostack.cpp | 12 +++++++++--- undostack.h | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/undostack.cpp b/undostack.cpp index 755179e3b..f86d06a52 100644 --- a/undostack.cpp +++ b/undostack.cpp @@ -23,7 +23,7 @@ #include "kmmainwin.h" #include "kmkernel.h" - +#include #include #include @@ -90,8 +90,8 @@ void UndoStack::undo() { UndoInfo *info = mStack.takeFirst(); emit undoStackChanged(); - Akonadi::ItemMoveJob( info->items, info->srcFolder, this ); - // TODO: handle job error? + Akonadi::ItemMoveJob * job = new Akonadi::ItemMoveJob( info->items, info->srcFolder, this ); + connect( job, SIGNAL(result(KJob*)), this, SLOT(slotMoveResult(KJob*)) ); delete info; } else @@ -101,6 +101,12 @@ void UndoStack::undo() } } +void UndoStack::slotMoveResult( KJob *job ) +{ + if ( job->error() ) + KMessageBox::sorry( kmkernel->mainWin(), i18n("Can not move message. %1").arg( job->errorString() ) ); +} + void UndoStack::pushSingleAction(const Akonadi::Item &item, const Akonadi::Collection &folder, const Akonadi::Collection &destFolder) { diff --git a/undostack.h b/undostack.h index 6ac8c995e..b321ae69e 100644 --- a/undostack.h +++ b/undostack.h @@ -26,6 +26,8 @@ #include #include #include +class KJob; + namespace KMail { /** A class for storing Undo information. */ @@ -58,6 +60,9 @@ public: public slots: void msgDestroyed( const Akonadi::Item &msg); +protected slots: + void slotMoveResult(KJob*); + protected: QList mStack; int mSize;