Mailcommon

folderjob.h
1 /*
2  *
3  * SPDX-FileCopyrightText: 2003 Zack Rusin <[email protected]>
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>
13 namespace MailCommon
14 {
15 /**
16  * @brief The FolderJob class
17  */
18 class MAILCOMMON_EXPORT FolderJob : public QObject
19 {
20  Q_OBJECT
21 
22 public:
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  Q_REQUIRED_RESULT int error() const;
44 
45  /**
46  * @return true if this job can be canceled, e.g. to exit the application
47  */
48  Q_REQUIRED_RESULT 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 
58 Q_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 
72 protected:
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:18
Q_SCRIPTABLE Q_NOREPLY void start()
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Sep 27 2023 03:59:52 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.