KCoreAddons

kcompositejob.h
1/*
2 This file is part of the KDE project
3
4 SPDX-FileCopyrightText: 2006 Kevin Ottens <ervin@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
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
17class 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 */
24class KCOREADDONS_EXPORT KCompositeJob : public KJob
25{
26 Q_OBJECT
27
28public:
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
41protected:
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
86protected 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 message the info message
101 * @see infoMessage()
102 */
103 virtual void slotInfoMessage(KJob *job, const QString &message);
104
105protected:
106 KCOREADDONS_NO_EXPORT KCompositeJob(KCompositeJobPrivate &dd, QObject *parent);
107
108private:
109 Q_DECLARE_PRIVATE(KCompositeJob)
110};
111
112#endif
The base class for all jobs able to be composed of one or more subjobs.
The base class for all jobs.
Definition kjob.h:74
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:31 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.