File indexing completed on 2024-04-14 04:51:56

0001 /**************************************************************************
0002  *   Copyright (C) 2011 Matthias Fuchs <mat69@gmx.net>                     *
0003  *                                                                         *
0004  *   This program is free software; you can redistribute it and/or modify  *
0005  *   it under the terms of the GNU General Public License as published by  *
0006  *   the Free Software Foundation; either version 2 of the License, or     *
0007  *   (at your option) any later version.                                   *
0008  *                                                                         *
0009  *   This program is distributed in the hope that it will be useful,       *
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0012  *   GNU General Public License for more details.                          *
0013  *                                                                         *
0014  *   You should have received a copy of the GNU General Public License     *
0015  *   along with this program; if not, write to the                         *
0016  *   Free Software Foundation, Inc.,                                       *
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
0018  ***************************************************************************/
0019 
0020 #ifndef KGET_FILE_DELETER_H
0021 #define KGET_FILE_DELETER_H
0022 
0023 #include "kget_export.h"
0024 
0025 class KJob;
0026 class QUrl;
0027 class QObject;
0028 
0029 /**
0030  * The FileDeleter is a wrapper around KIO ensuring that always
0031  * just one job is started for deleting a file.
0032  * Thus deleteFile can be called multiple times safely and all callees
0033  * are informed once the file is actually deleted.
0034  */
0035 class KGET_EXPORT FileDeleter
0036 {
0037 public:
0038     FileDeleter();
0039     ~FileDeleter();
0040 
0041     /**
0042      * Starts the deletion of dest and emits KJob::finished once done.
0043      * You can safely call this method multiple times for the same destination.
0044      * @param dest destination to delete
0045      * @param receiver receiver of the finished signal
0046      * @param method method the finished signal should be connected to, thus
0047      *        informing you of the result
0048      * @return the KJob that has been created
0049      * @note only use the returned job to create connections yourself, not to modify it!
0050      */
0051     static KJob *deleteFile(const QUrl &dest, QObject *receiver = nullptr, const char *method = nullptr);
0052 
0053     /**
0054      * @return true if dest is being deleted
0055      */
0056     static bool isFileBeingDeleted(const QUrl &dest);
0057 
0058 private:
0059     class Private;
0060     Private *d;
0061 };
0062 
0063 #endif