File indexing completed on 2024-12-08 06:40:26
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2022 Ahmad Samir <a.samirh78@gmail.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 0008 #ifndef DELETEORTRASHJOB_H 0009 #define DELETEORTRASHJOB_H 0010 0011 #include <KIO/AskUserActionInterface> 0012 #include <kiowidgets_export.h> 0013 0014 #include <KCompositeJob> 0015 0016 #include <memory> 0017 0018 namespace KIO 0019 { 0020 0021 class DeleteOrTrashJobPrivate; 0022 0023 /** 0024 * @class DeleteOrTrashJob deleteortrashjob.h <KIO/DeleteOrTrashJob> 0025 * 0026 * This job asks the user for confirmation to delete or move to Trash 0027 * a list of URLs; or if the job is constructed with 0028 * AskUserActionInterface::EmptyTrash, to empty the Trash. 0029 * 0030 * A KIO::WidgetAskUserActionHandler will be used by default, unless a 0031 * KJobUiDelegate that implements KIO::AskUserActionInterface is set with 0032 * setUiDelegate(). 0033 * 0034 * In the case of moving items to Trash, this job records the 0035 * operation using KIO::FileUndoManager. 0036 * 0037 * To start the job after constructing it, you must call start(). 0038 * 0039 * @since 5.100 0040 */ 0041 class KIOWIDGETS_EXPORT DeleteOrTrashJob : public KCompositeJob 0042 { 0043 Q_OBJECT 0044 public: 0045 /** 0046 * Creates a DeleteOrTrashJob. 0047 * @param urls the list of urls to delete, move to Trash, or an empty list 0048 * in the case of AskUserActionInterface::EmptyTrash (in the latter case, 0049 * the list of urls is ignored) 0050 * @param deletionType one of AskUserActionInterface::DeletionType 0051 * @param confirm one of AskUserActionInterface::ConfirmationType 0052 * @param parent parent object, e.g. a QWidget for widget-based applications 0053 */ 0054 explicit DeleteOrTrashJob(const QList<QUrl> &urls, 0055 AskUserActionInterface::DeletionType deletionType, 0056 AskUserActionInterface::ConfirmationType confirm, 0057 QObject *parent); 0058 0059 /** 0060 * Destructor 0061 * 0062 * Note that jobs auto-delete themselves after emitting result 0063 */ 0064 ~DeleteOrTrashJob() override; 0065 0066 /** 0067 * You must call this to actually start the job. 0068 */ 0069 void start() override; 0070 0071 private: 0072 void slotResult(KJob *job) override; 0073 0074 friend DeleteOrTrashJobPrivate; 0075 std::unique_ptr<DeleteOrTrashJobPrivate> d; 0076 }; 0077 0078 } // namespace KIO 0079 0080 #endif // DELETEORTRASHJOB_H