made progressbar layout 2 rows, max 6 bars total
[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 #include <QHBoxLayout>
23
24 #include "progressbar.h"
25 #include "operationthread.h"
26
27
28 typedef QList<QPair<OperationThread*, ProgressBar*> > OperationList;
29
30 class FileOperator : public QWidget {
31     Q_OBJECT
32
33 public:
34     FileOperator(QWidget *parent = 0);
35
36     void deleteFiles(const QFileInfoList &files);
37     void copyFiles(const QFileInfoList &files, QDir &destination);
38     void moveFiles(const QFileInfoList &files, QDir &destination);
39
40 public slots:
41     void showErrorPrompt(OperationThread* op,
42         const QString &message,
43         const QString &fileName,
44         const int err);
45     void showOverwritePrompt(OperationThread* op,
46         const QString &fileName,
47         const bool dirOverDir);
48     void showInputFilenamePrompt(OperationThread* op,
49         const QFileInfo &fileName,
50         const bool dirOverDir);
51
52     void remove(OperationThread* op);
53
54     void togglePauseOperation(ProgressBar* bar);
55     void abortOperation(ProgressBar* bar);
56
57 protected:
58     void initOperation(OperationThread *thread, ProgressBar *bar);
59     ProgressBar *get(OperationThread *op) const;
60     OperationThread *get(ProgressBar *bar) const;
61     void addBarToLayout(ProgressBar *bar);
62     void removeBarFromLayout(ProgressBar *bar);
63
64     bool checkMaxOpsNumber();
65
66     OperationList opList;
67     QPixmap deleteIcon, inverseDeleteIcon, copyIcon, inverseCopyIcon, moveIcon, inverseMoveIcon;
68     QHBoxLayout *topRow, *bottomRow;
69 };
70
71 #endif // FILEOPERATOR_H