diff --git a/kmreadermainwin.cpp b/kmreadermainwin.cpp index 7e994526a..e5ecfd812 100644 --- a/kmreadermainwin.cpp +++ b/kmreadermainwin.cpp @@ -405,17 +405,26 @@ void KMReaderMainWin::slotMoveItem(QAction *action) { const QModelIndex index = action->data().value(); const Akonadi::Collection collection = index.data( Akonadi::EntityTreeModel::CollectionRole ).value(); + copyOrMoveItem(collection, true); + } +} - if ( mMsg.isValid() ) { +void KMReaderMainWin::copyOrMoveItem(const Akonadi::Collection &collection, bool move) +{ + if ( mMsg.isValid() ) { + if (move) { Akonadi::ItemMoveJob *job = new Akonadi::ItemMoveJob( mMsg, collection,this ); connect( job, SIGNAL(result(KJob*)), this, SLOT(slotCopyMoveResult(KJob*)) ); - } - else - { - Akonadi::ItemCreateJob *job = new Akonadi::ItemCreateJob( mMsg, collection, this ); + } else { + Akonadi::ItemCopyJob *job = new Akonadi::ItemCopyJob( mMsg, collection,this ); connect( job, SIGNAL(result(KJob*)), this, SLOT(slotCopyMoveResult(KJob*)) ); } } + else + { + Akonadi::ItemCreateJob *job = new Akonadi::ItemCreateJob( mMsg, collection, this ); + connect( job, SIGNAL(result(KJob*)), this, SLOT(slotCopyMoveResult(KJob*)) ); + } } void KMReaderMainWin::slotCopyItem(QAction*action) @@ -424,16 +433,7 @@ void KMReaderMainWin::slotCopyItem(QAction*action) { const QModelIndex index = action->data().value(); const Akonadi::Collection collection = index.data( Akonadi::EntityTreeModel::CollectionRole ).value(); - - if ( mMsg.isValid() ) { - Akonadi::ItemCopyJob *job = new Akonadi::ItemCopyJob( mMsg, collection,this ); - connect( job, SIGNAL(result(KJob*)), this, SLOT(slotCopyMoveResult(KJob*)) ); - } - else - { - Akonadi::ItemCreateJob *job = new Akonadi::ItemCreateJob( mMsg, collection, this ); - connect( job, SIGNAL(result(KJob*)), this, SLOT(slotCopyMoveResult(KJob*)) ); - } + copyOrMoveItem(collection, false); } } diff --git a/kmreadermainwin.h b/kmreadermainwin.h index eed37698b..0b86e3f81 100644 --- a/kmreadermainwin.h +++ b/kmreadermainwin.h @@ -79,6 +79,7 @@ private slots: void slotMoveItem(QAction *action); private: + void copyOrMoveItem(const Akonadi::Collection &collection, bool move); Akonadi::Collection parentCollection() const; void initKMReaderMainWin(); void setupAccel();