Akonadi

collectiondeletejob.cpp
1/*
2 SPDX-FileCopyrightText: 2006 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "collectiondeletejob.h"
8#include "collection.h"
9#include "job_p.h"
10#include "private/protocol_p.h"
11#include "protocolhelper_p.h"
12
13#include <KLocalizedString>
14
15using namespace Akonadi;
16
17class Akonadi::CollectionDeleteJobPrivate : public JobPrivate
18{
19public:
20 explicit CollectionDeleteJobPrivate(CollectionDeleteJob *parent)
21 : JobPrivate(parent)
22 {
23 }
24 QString jobDebuggingString() const override;
25
26 Collection mCollection;
27};
28
29QString Akonadi::CollectionDeleteJobPrivate::jobDebuggingString() const
30{
31 return QStringLiteral("Delete Collection id: %1").arg(mCollection.id());
32}
33
35 : Job(new CollectionDeleteJobPrivate(this), parent)
36{
38
39 d->mCollection = collection;
40}
41
45
47{
49
50 if (!d->mCollection.isValid() && d->mCollection.remoteId().isEmpty()) {
52 setErrorText(i18n("Invalid collection"));
53 emitResult();
54 return;
55 }
56
57 d->sendCommand(Protocol::DeleteCollectionCommandPtr::create(ProtocolHelper::entityToScope(d->mCollection)));
58}
59
61{
62 if (!response->isResponse() || response->type() != Protocol::Command::DeleteCollection) {
63 return Job::doHandleResponse(tag, response);
64 }
65
66 return true;
67}
68
69#include "moc_collectiondeletejob.cpp"
Job that deletes a collection in the Akonadi storage.
~CollectionDeleteJob() override
Destroys the collection delete job.
bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override
This method should be reimplemented in the concrete jobs in case you want to handle incoming data.
void doStart() override
This method must be reimplemented in the concrete jobs.
CollectionDeleteJob(const Collection &collection, QObject *parent=nullptr)
Creates a new collection delete job.
Represents a collection of PIM items.
Definition collection.h:62
Base class for all actions in the Akonadi storage.
Definition job.h:81
virtual bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response)
This method should be reimplemented in the concrete jobs in case you want to handle incoming data.
Definition job.cpp:381
@ Unknown
Unknown error.
Definition job.h:102
void setErrorText(const QString &errorText)
void emitResult()
void setError(int errorCode)
QString i18n(const char *text, const TYPE &arg...)
Helper integration between Akonadi and Qt.
QString arg(Args &&... args) const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.