1 | /* |
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 2022 Ahmad Samir <a.samirh78@gmail.com> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
6 | */ |
7 | |
8 | #ifndef DELETEORTRASHJOB_H |
9 | #define DELETEORTRASHJOB_H |
10 | |
11 | #include <KIO/AskUserActionInterface> |
12 | #include <kiowidgets_export.h> |
13 | |
14 | #include <KCompositeJob> |
15 | |
16 | #include <memory> |
17 | |
18 | namespace KIO |
19 | { |
20 | |
21 | class DeleteOrTrashJobPrivate; |
22 | |
23 | /*! |
24 | * \class KIO::DeleteOrTrashJob |
25 | * \inheaderfile KIO/DeleteOrTrashJob |
26 | * \inmodule KIOWidgets |
27 | * |
28 | * \brief This job asks the user for confirmation to delete or move to Trash |
29 | * a list of URLs; or if the job is constructed with |
30 | * AskUserActionInterface::EmptyTrash, to empty the Trash. |
31 | * |
32 | * A KIO::WidgetAskUserActionHandler will be used by default, unless a |
33 | * KJobUiDelegate that implements KIO::AskUserActionInterface is set with |
34 | * setUiDelegate(). |
35 | * |
36 | * In the case of moving items to Trash, this job records the |
37 | * operation using KIO::FileUndoManager. |
38 | * |
39 | * To start the job after constructing it, you must call start(). |
40 | * |
41 | * \since 5.100 |
42 | */ |
43 | class KIOWIDGETS_EXPORT DeleteOrTrashJob : public KCompositeJob |
44 | { |
45 | Q_OBJECT |
46 | public: |
47 | /*! |
48 | * Creates a DeleteOrTrashJob. |
49 | * |
50 | * \a urls the list of urls to delete, move to Trash, or an empty list |
51 | * in the case of AskUserActionInterface::EmptyTrash (in the latter case, |
52 | * the list of urls is ignored) |
53 | * |
54 | * \a deletionType one of AskUserActionInterface::DeletionType |
55 | * |
56 | * \a confirm one of AskUserActionInterface::ConfirmationType |
57 | * |
58 | * \a parent parent object, e.g. a QWidget for widget-based applications |
59 | */ |
60 | explicit DeleteOrTrashJob(const QList<QUrl> &urls, |
61 | AskUserActionInterface::DeletionType deletionType, |
62 | AskUserActionInterface::ConfirmationType confirm, |
63 | QObject *parent); |
64 | |
65 | /*! |
66 | * Destructor |
67 | * |
68 | * Note that jobs auto-delete themselves after emitting result |
69 | */ |
70 | ~DeleteOrTrashJob() override; |
71 | |
72 | /*! |
73 | * You must call this to actually start the job. |
74 | */ |
75 | void start() override; |
76 | |
77 | Q_SIGNALS: |
78 | /** |
79 | * Emitted when the actual delete or trash job has been started. |
80 | * |
81 | * This can be used to display a busy indicator after the user has confirmed |
82 | * this operation. |
83 | * |
84 | * @since 6.15 |
85 | */ |
86 | void started(); |
87 | |
88 | private: |
89 | void slotResult(KJob *job) override; |
90 | |
91 | friend DeleteOrTrashJobPrivate; |
92 | std::unique_ptr<DeleteOrTrashJobPrivate> d; |
93 | }; |
94 | |
95 | } // namespace KIO |
96 | |
97 | #endif // DELETEORTRASHJOB_H |
98 | |