diff --git a/kmreadermainwin.cpp b/kmreadermainwin.cpp index 44a3f0cf4..c6422ee29 100644 --- a/kmreadermainwin.cpp +++ b/kmreadermainwin.cpp @@ -388,31 +388,35 @@ void KMReaderMainWin::slotMoveItem(QAction *action) { if (action) { const QModelIndex index = action->data().value(); - const Akonadi::Collection collection = index.data(Akonadi::EntityTreeModel::CollectionRole).value(); + const Akonadi::Collection collection = index.data( Akonadi::EntityTreeModel::CollectionRole ).value(); + copyOrMoveItem(collection, true); + } +} - if (mMsg.isValid()) { - Akonadi::ItemMoveJob *job = new Akonadi::ItemMoveJob(mMsg, collection, this); - connect(job, SIGNAL(result(KJob*)), this, SLOT(slotCopyMoveResult(KJob*))); +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); - connect(job, SIGNAL(result(KJob*)), this, SLOT(slotCopyMoveResult(KJob*))); + 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) { if (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, &Akonadi::ItemCopyJob::result, this, &KMReaderMainWin::slotCopyMoveResult); - } else { - Akonadi::ItemCreateJob *job = new Akonadi::ItemCreateJob(mMsg, collection, this); - connect(job, &Akonadi::ItemCopyJob::result, this, &KMReaderMainWin::slotCopyMoveResult); - } + const Akonadi::Collection collection = index.data( Akonadi::EntityTreeModel::CollectionRole ).value(); + copyOrMoveItem(collection, false); } } diff --git a/kmreadermainwin.h b/kmreadermainwin.h index 21b65427b..afcadbcfa 100644 --- a/kmreadermainwin.h +++ b/kmreadermainwin.h @@ -81,6 +81,7 @@ private Q_SLOTS: void slotMoveItem(QAction *action); private: + void copyOrMoveItem(const Akonadi::Collection &collection, bool move); Akonadi::Collection parentCollection() const; void initKMReaderMainWin(); void setupAccel();