batchextract.h 2.75 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * ark -- archiver for the KDE project
 *
 * Copyright (C) 2008 Harald Hvaal <haraldhv (at@at) stud.ntnu.no>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */

#ifndef BATCHEXTRACT_H
#define BATCHEXTRACT_H

25
#include "kerfuffle_export.h"
26

27
28
29
#include <QtCore/QMap>
#include <QtCore/QPair>
#include <QtCore/QString>
30
#include <QtCore/QStringList>
31
32

#include <kcompositejob.h>
33

34
class Interface;
35
class KJobTrackerInterface;
36
class KUrl;
37

38
namespace Kerfuffle
39
{
40
41
class Archive;
class Query;
42

43
44
45
class KERFUFFLE_EXPORT BatchExtract : public KCompositeJob
{
    Q_OBJECT
46

47
public:
48
49
50
    /**
     * Creates a new BatchExtract object.
     */
51
    BatchExtract();
52
53
54
55

    /**
     * Destroys a BatchExtract object.
     */
56
    virtual ~BatchExtract();
57

58
    void addExtraction(Archive* archive, bool preservePaths = true, QString destinationFolder = QString());
59
60
61
62
63
64
65

    /**
     * Starts the extraction of all files.
     *
     * Each extraction job is started after the last one finishes.
     * The jobs are executed in the order they were added via addInput.
     */
66
    void start();
67

68
    void setAutoSubfolder(bool value);
69
70
71
72
73
74
75
76
77
78
79

    /**
     * Adds a file to the list of files that will be extracted.
     *
     * @param url The file that will be added to the list.
     *
     * @return @c true  The file exists and a suitable plugin
     *                  could be found for it.
     * @return @c false The file does not exist or a suitable
     *                  plugin could not be found.
     */
80
81
82
83
84
    bool addInput(const KUrl& url);
    bool showExtractDialog();
    void setDestinationFolder(QString folder);
    void setSubfolder(QString subfolder);
    void setPreservePaths(bool value);
85

86
87
private slots:
    void forwardProgress(KJob *job, unsigned long percent);
88
    void showFailedFiles();
89
90
    void slotResult(KJob *job);
    void slotUserQuery(Query *query);
91

92
private:
93
94
95
    int m_initialJobCount;
    QMap<KJob*, QPair<QString, QString> > m_fileNames;
    bool m_autoSubfolders;
96

97
98
    QList<Archive*> m_inputs;
    QString m_destinationFolder;
99
    QStringList m_failedFiles;
100
    QString m_subfolder;
101
102
    bool m_preservePaths;
};
103
}
104
105

#endif // BATCHEXTRACT_H