c0a47ee82ae22a3d68015ad8ab5106d8a8239eec
[case] / src / fileoperator.h
1 // case - file manager for N900
2 // Copyright (C) 2010 Lukas Hrazky <lukkash@email.cz>
3 // 
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 // 
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 // 
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
18 #ifndef FILEOPERATOR_H
19 #define FILEOPERATOR_H
20
21 #include <QWidget>
22
23 #include "progressbar.h"
24 #include "operationthread.h"
25
26
27 typedef QList<QPair<OperationThread*, ProgressBar*> > OperationList;
28
29 class FileOperator : public QWidget {
30     Q_OBJECT
31
32 public:
33     FileOperator(QWidget *parent = 0);
34
35     void deleteFiles(const QFileInfoList &files);
36     void copyFiles(const QFileInfoList &files, QDir &destination);
37     void moveFiles(const QFileInfoList &files, QDir &destination);
38
39 public slots:
40     void showErrorPrompt(OperationThread* op,
41         const QString &message,
42         const QString &fileName,
43         const int err);
44     void showOverwritePrompt(OperationThread* op,
45         const QString &fileName,
46         const bool dirOverDir);
47     void showInputFilenamePrompt(OperationThread* op,
48         const QFileInfo &fileName,
49         const bool dirOverDir);
50
51     void remove(OperationThread* op);
52
53     void togglePauseOperation(ProgressBar* bar);
54     void abortOperation(ProgressBar* bar);
55
56 protected:
57     void initOperation(OperationThread *thread, ProgressBar *bar);
58     ProgressBar *get(OperationThread *op) const;
59     OperationThread *get(ProgressBar *bar) const;
60
61     OperationList opList;
62     QPixmap deleteIcon, inverseDeleteIcon, copyIcon, inverseCopyIcon, moveIcon, inverseMoveIcon;
63 };
64
65 #endif // FILEOPERATOR_H