KCoreAddons

kcompositejob.h
1 /*
2  This file is part of the KDE project
3 
4  SPDX-FileCopyrightText: 2006 Kevin Ottens <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-only
7 */
8 
9 #ifndef KCOMPOSITEJOB_H
10 #define KCOMPOSITEJOB_H
11 
12 #include <kcoreaddons_export.h>
13 #include <kjob.h>
14 
15 #include <QList>
16 
17 class KCompositeJobPrivate;
18 /**
19  * @class KCompositeJob kcompositejob.h KCompositeJob
20  *
21  * The base class for all jobs able to be composed of one
22  * or more subjobs.
23  */
24 class KCOREADDONS_EXPORT KCompositeJob : public KJob
25 {
26  Q_OBJECT
27 
28 public:
29  /**
30  * Creates a new KCompositeJob object.
31  *
32  * @param parent the parent QObject
33  */
34  explicit KCompositeJob(QObject *parent = nullptr);
35 
36  /**
37  * Destroys a KCompositeJob object.
38  */
39  ~KCompositeJob() override;
40 
41 protected:
42  /**
43  * Add a job that has to be finished before a result
44  * is emitted. This has obviously to be called before
45  * the result has been emitted by the job.
46  *
47  * Note that the composite job takes ownership of @p job
48  *
49  * @param job the subjob to add
50  * @return true if the job has been added correctly, false otherwise
51  */
52  virtual bool addSubjob(KJob *job);
53 
54  /**
55  * Mark a sub job as being done.
56  *
57  * The ownership of @p job is passed on to the caller.
58  *
59  * @param job the subjob to remove
60  * @return true if the job has been removed correctly, false otherwise
61  */
62  virtual bool removeSubjob(KJob *job);
63 
64  /**
65  * Checks if this job has subjobs running.
66  *
67  * @return true if we still have subjobs running, false otherwise
68  */
69  bool hasSubjobs() const;
70 
71  /**
72  * Retrieves the list of the subjobs.
73  *
74  * @return the full list of sub jobs
75  */
76  const QList<KJob *> &subjobs() const;
77 
78  /**
79  * Clears the list of subjobs.
80  *
81  * Note that this will *not* delete the subjobs.
82  * Ownership of the subjobs is passed on to the caller.
83  */
84  void clearSubjobs();
85 
86 protected Q_SLOTS:
87  /**
88  * Called whenever a subjob finishes.
89  * Default implementation checks for errors and propagates
90  * to parent job, and in all cases it calls removeSubjob.
91  *
92  * @param job the subjob
93  */
94  virtual void slotResult(KJob *job);
95 
96  /**
97  * Forward signal from subjob.
98  *
99  * @param job the subjob
100  * @param plain the info message in plain text version
101  * @param rich the info message in rich text version
102  * @see infoMessage()
103  */
104  virtual void slotInfoMessage(KJob *job, const QString &plain, const QString &rich);
105 
106 protected:
107  KCompositeJob(KCompositeJobPrivate &dd, QObject *parent);
108 
109 private:
110  Q_DECLARE_PRIVATE(KCompositeJob)
111 };
112 
113 #endif
The base class for all jobs able to be composed of one or more subjobs.
Definition: kcompositejob.h:24
The base class for all jobs.
Definition: kjob.h:76
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Apr 11 2021 23:01:47 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.