libktorrent  2.1.1
deletedatafilesjob.h
1 /***************************************************************************
2  * Copyright (C) 2008 by Joris Guisson and Ivan Vasic *
3  * joris.guisson@gmail.com *
4  * ivasic@gmail.com *
5  * *
6  * This program is free software; you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License as published by *
8  * the Free Software Foundation; either version 2 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * This program is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with this program; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20  ***************************************************************************/
21 #ifndef BTDELETEDATAFILESJOB_H
22 #define BTDELETEDATAFILESJOB_H
23 
24 #include <util/ptrmap.h>
25 #include <QString>
26 #include <QUrl>
27 #include <torrent/job.h>
28 
29 namespace bt
30 {
31 
36  class DeleteDataFilesJob : public Job
37  {
38  Q_OBJECT
39  public:
43  DeleteDataFilesJob(const QString & base);
44  ~DeleteDataFilesJob() override;
45 
50  void addFile(const QString & file);
51 
57  void addEmptyDirectoryCheck(const QString & fpath);
58 
60  void start() override;
61 
63  void kill(bool quietly) override;
64 
65  private Q_SLOTS:
66  void onDeleteJobDone(KJob* j);
67 
68  private:
69  struct DirTree
70  {
71  QString name;
73 
74  DirTree(const QString & name);
75  ~DirTree();
76 
77  void insert(const QString & fpath);
78  void doDeleteOnEmpty(const QString & base);
79  };
80 
81  private:
82  QList<QUrl> files;
83  QString base;
84  DirTree* directory_tree;
85  KIO::Job* active_job;
86  };
87 
88 }
89 
90 #endif
bt::DeleteDataFilesJob::addFile
void addFile(const QString &file)
bt::PtrMap< QString, DirTree >
bt::DeleteDataFilesJob::addEmptyDirectoryCheck
void addEmptyDirectoryCheck(const QString &fpath)
bt::DeleteDataFilesJob::kill
void kill(bool quietly) override
Kill the job.
bt::DeleteDataFilesJob::start
void start() override
Start the job.
bt::DeleteDataFilesJob::DeleteDataFilesJob
DeleteDataFilesJob(const QString &base)