1 //=========================================== 2 // Lumina-DE source code 3 // Copyright (c) 2014, Ken Moore 4 // Available under the 3-clause BSD license 5 // See the LICENSE file for full details 6 //=========================================== 7 // This is the dialog for showing currently running file operations 8 //=========================================== 9 #ifndef _LUMINA_FILE_MANAGER_FILE_OP_DIALOG_H 10 #define _LUMINA_FILE_MANAGER_FILE_OP_DIALOG_H 11 12 // Qt includes 13 #include <QDialog> 14 #include <QMessageBox> 15 #include <QStringList> 16 #include <QTimer> 17 #include <QFileInfo> 18 #include <QDir> 19 #include <QFile> 20 #include <QThread> 21 22 // libLumina includes 23 #include <LuminaXDG.h> 24 #include <LUtils.h> 25 26 class FOWorker : public QObject{ 27 Q_OBJECT 28 public: 29 //variables that need to be set before starting the operations 30 QStringList ofiles, nfiles; //original/new files 31 bool isRM, isCP, isRESTORE, isMV; 32 bool stopped; 33 int overwrite; // [-1= auto, 0= no overwrite, 1= overwrite] 34 35 FOWorker()36 FOWorker() : QObject(){ 37 isRM = isCP = isRESTORE = isMV = stopped = false; 38 overwrite = -1; //auto 39 } ~FOWorker()40 ~FOWorker(){} 41 42 public slots: 43 void slotStartOperations(); 44 45 private: 46 QStringList subfiles(QString dirpath, bool dirsfirst = false); //recursive function for fetching all "child" files/dirs (dirs last by default) 47 QString newFileName(QString path); 48 QStringList removeItem(QString path, bool recursive = false); 49 QStringList copyItem(QString oldpath, QString newpath); 50 51 signals: 52 void startingItem(int, int, QString, QString); //current number, total number, Old File, New File (if appropriate) 53 void finished(QStringList); //errors returned 54 }; 55 56 namespace Ui{ 57 class FODialog; 58 }; 59 60 class FODialog : public QDialog{ 61 Q_OBJECT 62 public: 63 FODialog(QWidget *parent = 0); 64 ~FODialog(); 65 66 bool noerrors; 67 68 void setOverwrite(bool); 69 bool RemoveFiles(QStringList paths); 70 bool CopyFiles(QStringList oldPaths, QStringList newPaths); //same permissions as old files 71 bool RestoreFiles(QStringList oldPaths, QStringList newPaths); //user/group rw permissions 72 bool MoveFiles(QStringList oldPaths, QStringList newPaths); //no change in permissions 73 74 private: 75 Ui::FODialog *ui; 76 QThread *WorkThread; 77 FOWorker *Worker; 78 79 bool CheckOverwrite(); //Returns "true" if it is ok to start the procedure 80 81 private slots: 82 void on_push_stop_clicked(); 83 void UpdateItem(int, int, QString, QString); 84 void WorkDone(QStringList); 85 }; 86 87 #endif 88