Fix duplicate code

wilder-work
Montel Laurent 11 years ago
parent 48637df408
commit 7622cfed1f
  1. 30
      kmreadermainwin.cpp
  2. 1
      kmreadermainwin.h

@ -405,17 +405,26 @@ void KMReaderMainWin::slotMoveItem(QAction *action)
{
const QModelIndex index = action->data().value<QModelIndex>();
const Akonadi::Collection collection = index.data( Akonadi::EntityTreeModel::CollectionRole ).value<Akonadi::Collection>();
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<QModelIndex>();
const Akonadi::Collection collection = index.data( Akonadi::EntityTreeModel::CollectionRole ).value<Akonadi::Collection>();
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);
}
}

@ -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();

Loading…
Cancel
Save