Akonadi Mime

movecommand.cpp
1/*
2 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>
3 SPDX-FileCopyrightText: 2010 Andras Mantia <andras@kdab.com>
4
5 SPDX-License-Identifier: LGPL-2.1-or-later
6*/
7
8#include "movecommand.h"
9#include "util_p.h"
10
11#include <Akonadi/ItemDeleteJob>
12#include <Akonadi/ItemMoveJob>
13using namespace Akonadi;
14
15class Akonadi::MoveCommandPrivate
16{
17public:
18 MoveCommandPrivate() = default;
19
20 Akonadi::Collection mDestFolder;
21 Akonadi::Item::List mMessages;
22};
23
24MoveCommand::MoveCommand(const Akonadi::Collection &destFolder, const Akonadi::Item::List &msgList, QObject *parent)
25 : CommandBase(parent)
26 , d(new Akonadi::MoveCommandPrivate())
27{
28 d->mDestFolder = destFolder;
29 d->mMessages = msgList;
30}
31
32MoveCommand::~MoveCommand() = default;
33
34void MoveCommand::execute()
35{
36 if (d->mMessages.isEmpty()) {
37 emitResult(OK);
38 return;
39 }
40 if (d->mDestFolder.isValid()) {
41 auto job = new Akonadi::ItemMoveJob(d->mMessages, d->mDestFolder, this);
42 connect(job, &Akonadi::ItemMoveJob::result, this, &MoveCommand::slotMoveResult);
43 } else {
44 auto job = new Akonadi::ItemDeleteJob(d->mMessages, this);
45 connect(job, &Akonadi::ItemDeleteJob::result, this, &MoveCommand::slotMoveResult);
46 }
47}
48
49void MoveCommand::slotMoveResult(KJob *job)
50{
51 if (job->error()) {
52 // handle errors
53 Util::showJobError(job);
54 emitResult(Failed);
55 } else {
56 emitResult(OK);
57 }
58}
59
60#include "moc_movecommand.cpp"
int error() const
void result(KJob *job)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:32:40 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.