more detailed completed status for KMCommands

svn path=/trunk/kdepim/; revision=316069
wilder-work
Ingo Klcker 22 years ago
parent a085342123
commit a17a4d395e
  1. 10
      actionscheduler.cpp
  2. 7
      actionscheduler.h
  3. 21
      kmcommands.cpp
  4. 6
      kmcommands.h
  5. 21
      kmheaders.cpp
  6. 5
      kmheaders.h

@ -1,5 +1,5 @@
/* Action Scheduler
This file is part of KMail, the KDE mail client.
Copyright (c) Don Sanders <sanders@kde.org>
@ -566,14 +566,14 @@ void ActionScheduler::moveMessage()
KMFilterAction::sendMDN( msg, KMime::MDN::Deleted );
KMCommand *cmd = new KMMoveCommand( folder, msg );
connect ( cmd, SIGNAL( completed(bool) ),
this, SLOT( moveMessageFinished(bool) ) );
connect( cmd, SIGNAL( completed( KMCommand::Result ) ),
this, SLOT( moveMessageFinished( KMCommand::Result ) ) );
cmd->start();
}
void ActionScheduler::moveMessageFinished(bool success)
void ActionScheduler::moveMessageFinished( KMCommand::Result result )
{
if ( !success )
if ( result != KMCommand::OK )
mResult = ResultError;
if (!mSrcFolder->count())

@ -1,4 +1,5 @@
/* Action Scheduler
/* -*- mode: C++ -*-
Action Scheduler
This file is part of KMail, the KDE mail client.
Copyright (c) Don Sanders <sanders@kde.org>
@ -37,6 +38,8 @@
#include "kmfilteraction.h" // for KMFilterAction::ReturnCode
#include "kmfilter.h"
#include "kmfiltermgr.h" // KMFilterMgr::FilterSet
#include "kmcommands.h"
class KMHeaders;
/* A class for asynchronous filtering of messages */
@ -107,7 +110,7 @@ private slots:
void messageRetrieved(KMMessage*);
void filterMessage();
void moveMessage();
void moveMessageFinished(bool);
void moveMessageFinished( KMCommand::Result result );
private:
static KMFolderMgr *tempFolderMgr;

@ -1589,8 +1589,10 @@ void KMMoveCommand::execute()
typedef QMap< KMFolder*, QPtrList<KMMessage>* > FolderToMessageListMap;
FolderToMessageListMap folderDeleteList;
if (mDestFolder && mDestFolder->open() != 0)
if (mDestFolder && mDestFolder->open() != 0) {
completeMove( Failed );
return;
}
KCursorSaver busy(KBusyPtr::busy());
// TODO set SSL state according to source and destfolder connection?
@ -1665,7 +1667,7 @@ void KMMoveCommand::execute()
} else if (rc != 0) {
// Something went wrong. Stop processing here, it is likely that the
// other moves would fail as well.
completeMove( false);
completeMove( Failed );
return;
}
}
@ -1697,11 +1699,11 @@ void KMMoveCommand::execute()
if ( mMsgList.first() ) {
srcFolder = mMsgList.first()->parent();
if ( mDestFolder && mDestFolder == srcFolder ) {
completeMove( true );
completeMove( OK );
}
}
if ( !mDestFolder ) {
emit completeMove( true );
completeMove( OK );
}
}
}
@ -1719,10 +1721,11 @@ void KMMoveCommand::slotImapFolderCompleted(KMFolderImap *, bool success)
kdDebug(5006) << "### Not all moved messages reported back that they were " << endl
<< "### added to the target folder. Did uidValidity change? " << endl;
}
completeMove( OK );
} else {
// Should we inform the user here or leave that to the caller?
completeMove( Failed );
}
completeMove( success );
}
void KMMoveCommand::slotMsgAddedToDestFolder(KMFolder *folder, Q_UINT32 serNum)
@ -1738,24 +1741,24 @@ void KMMoveCommand::slotMsgAddedToDestFolder(KMFolder *folder, Q_UINT32 serNum)
if (mDestFolder && mDestFolder->folderType() != KMFolderTypeImap) {
mDestFolder->sync();
}
completeMove( true );
completeMove( OK );
} else {
mProgressItem->incCompletedItems();
mProgressItem->updateProgress();
}
}
void KMMoveCommand::completeMove( bool success )
void KMMoveCommand::completeMove( Result result )
{
if ( mProgressItem )
mProgressItem->setComplete();
emit completed( success );
emit completed( result );
deleteLater();
}
void KMMoveCommand::slotMoveCanceled()
{
completeMove( false );
completeMove( Canceled );
}
// srcFolder doesn't make much sense for searchFolders

@ -34,6 +34,8 @@ class KMCommand : public QObject
Q_OBJECT
public:
enum Result { OK, Canceled, Failed };
// Trival constructor, don't retrieve any messages
KMCommand( QWidget *parent = 0 );
// Retrieve all messages in msgList when start is called.
@ -83,7 +85,7 @@ signals:
void messagesTransfered(bool);
/** Emitted when the command has completed.
* @success Success or error. */
void completed( bool success );
void completed( KMCommand::Result result );
private:
// ProgressDialog for transferring messages
@ -596,7 +598,7 @@ public slots:
private:
virtual void execute();
void completeMove( bool success );
void completeMove( Result result );
KMFolder *mDestFolder;
QPtrList<KMMsgBase> mMsgList;

@ -1640,8 +1640,8 @@ void KMHeaders::deleteMsg ()
finalizeMove( nextItem, contentX, contentY );
KMCommand *command = new KMDeleteMsgCommand( mFolder, msgList );
connect (command, SIGNAL(completed( bool)),
this, SLOT(slotMoveCompleted( bool)));
connect( command, SIGNAL( completed( KMCommand::Result ) ),
this, SLOT( slotMoveCompleted( KMCommand::Result ) ) );
command->start();
KMBroadcastStatus::instance()->setStatusMsg("");
@ -1724,19 +1724,19 @@ void KMHeaders::moveMsgToFolder ( KMFolder* destFolder, bool askForConfirmation
finalizeMove( nextItem, contentX, contentY );
KMCommand *command = new KMMoveCommand( destFolder, msgList );
connect (command, SIGNAL(completed( bool)),
this, SLOT(slotMoveCompleted( bool)));
connect( command, SIGNAL( completed( KMCommand::Result ) ),
this, SLOT( slotMoveCompleted( KMCommand::Result ) ) );
command->start();
}
void KMHeaders::slotMoveCompleted( bool success )
void KMHeaders::slotMoveCompleted( KMCommand::Result result )
{
kdDebug(5006) << "KMHeaders::slotMoveCompleted: " << success << endl;
if (success) {
kdDebug(5006) << "KMHeaders::slotMoveCompleted: " << result << endl;
if ( result == KMCommand::OK ) {
KMBroadcastStatus::instance()->setStatusMsg(i18n("Messages moved successfully."));
} else {
/* The move failed or the user canceled it reset the state of all
/* The move failed or the user canceled it; reset the state of all
* messages involved and repaint.
*
* Note: This potentially resets too many items if there is more than one
@ -1755,7 +1755,10 @@ void KMHeaders::slotMoveCompleted( bool success )
}
}
triggerUpdate();
KMBroadcastStatus::instance()->setStatusMsg(i18n("Moving messages failed."));
if ( result == KMCommand::Failed )
KMBroadcastStatus::instance()->setStatusMsg(i18n("Moving messages failed."));
else
KMBroadcastStatus::instance()->setStatusMsg(i18n("Moving messages canceled."));
}
}

@ -1,3 +1,5 @@
// -*- mode: C++ -*-
#ifndef __KMHEADERS
#define __KMHEADERS
@ -12,6 +14,7 @@
#include "kmmessage.h"
#include "kmime_util.h"
#include <kpopupmenu.h>
#include "kmcommands.h"
class KMFolder;
class KMMessage;
@ -291,7 +294,7 @@ protected slots:
void rightButtonPressed( QListViewItem *, const QPoint &, int );
private slots:
void slotMoveCompleted( bool success );
void slotMoveCompleted( KMCommand::Result result );
private:
/** Is equivalent to clearing the list and inserting an item for

Loading…
Cancel
Save