Mailcommon

folderjob.h
1/*
2 *
3 * SPDX-FileCopyrightText: 2003 Zack Rusin <zack@kde.org>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8#pragma once
9
10#include "mailcommon_export.h"
11#include <Akonadi/Collection>
12#include <QObject>
13namespace MailCommon
14{
15/**
16 * @brief The FolderJob class
17 */
18class MAILCOMMON_EXPORT FolderJob : public QObject
19{
20 Q_OBJECT
21
22public:
23 explicit FolderJob(QObject *parent = nullptr);
24
25 ~FolderJob() override;
26
27 /**
28 * Start the job
29 */
30 void start();
31
32 /**
33 * Interrupt the job. Note that the finished() and result() signal
34 * will be emitted, unless you called setPassiveDestructor(true) before.
35 * This kills the job, don't use it afterwards.
36 */
37 virtual void kill();
38
39 /**
40 * @return the error code of the job. This must only be called from
41 * the slot connected to the finished() signal.
42 */
43 [[nodiscard]] int error() const;
44
45 /**
46 * @return true if this job can be canceled, e.g. to exit the application
47 */
48 [[nodiscard]] bool isCancellable() const;
49
50 /**
51 * Call this to change the "cancellable" property of this job.
52 * By default, tListMessages, tGetMessage, tGetFolder and tCheckUidValidity
53 * are cancellable, the others are not. But when copying, a non-cancellable
54 * tGetMessage is needed.
55 */
56 void setCancellable(bool b);
57
58Q_SIGNALS:
59 /**
60 * Emitted when the job finishes all processing.
61 */
62 void finished();
63
64 /**
65 * Emitted when the job finishes all processing.
66 * More convenient signal than finished(), since it provides a pointer to the job.
67 * This signal is emitted by the FolderJob destructor => do NOT downcast
68 * the job to a subclass!
69 */
70 void result(FolderJob *job);
71
72protected:
73 /**
74 * Has to be reimplemented. It's called by the start() method. Should
75 * start the processing of the specified job function.
76 */
77 virtual void execute() = 0;
78
79 Akonadi::Collection mSrcFolder;
80 int mErrorCode = 0;
81
82 bool mStarted = false;
83 bool mCancellable = false;
84};
85}
The FolderJob class.
Definition folderjob.h:19
virtual void execute()=0
Has to be reimplemented.
void result(FolderJob *job)
Emitted when the job finishes all processing.
void finished()
Emitted when the job finishes all processing.
Q_SCRIPTABLE Q_NOREPLY void start()
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:01 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.