new style for the progressbars, display more info
[case] / src / fileoperator.h
index 76f5535..076250d 100644 (file)
 #define FILEOPERATOR_H
 
 #include <QWidget>
-#include <QProgressBar>
 #include <QFileInfo>
 #include <QThread>
 #include <QMutex>
 #include <QWaitCondition>
 #include <QDir>
+#include <QFSFileEngine>
 #include <QMap>
 #include <QSet>
 
+#include "progressbar.h"
+
 
 class FileManipulatorThread;
 
@@ -63,11 +65,17 @@ public slots:
     void remove(FileManipulatorThread* manipulator);
     void setBarSize(FileManipulatorThread* manipulator, unsigned int size);
     void updateProgress(FileManipulatorThread* manipulator, int value);
+    void updateMainText(FileManipulatorThread* manipulator, const QString &text);
+    void showPaused(FileManipulatorThread* manipulator);
+
+    void togglePauseOperation(FileManipulatorThread* manipulator);
+    void abortOperation(FileManipulatorThread* manipulator);
 
 protected:
     void caterNewThread(FileManipulatorThread *thread);
 
     QList<FileManipulatorThread*> manipulatorList;
+    QPixmap deleteIcon, inverseDeleteIcon, copyIcon, inverseCopyIcon, moveIcon, inverseMoveIcon;
 };
 
 
@@ -81,13 +89,15 @@ public:
 
     void setText(int value);
 
-    QProgressBar *progressBar;
+    void wake();
+
+    ProgressBar *progressBar;
 
-    time_t startTime;
     QMutex mutex;
-    QWaitCondition waitCond;
     // the new name entered from the overwrite dialog
     QString newNameFromDialog;
+    // flags to abort/pause the operation
+    bool abort, pause;
 
 protected:
     void processFiles(const QFileInfoList &files);
@@ -109,6 +119,12 @@ protected:
     void updateProgress(int value);
     void updateFile(const QString &name);
 
+    void waitOnCond();
+
+    bool checkSequentialFile(const QFSFileEngine &engine);
+
+    QWaitCondition waitCond;
+
     // files to process by the operation
     const QFileInfoList files;
     // destination for files - changes as the operation recurses into directories
@@ -117,8 +133,6 @@ protected:
     // responses from the dialog prompts (error and overwrite)
     FileOperator::Response response;
     FileOperator::Response overwriteAll;
-    // a flag to abort the operation
-    bool abort;
     // an array indicating whether to always ignore the error of index errno
     bool ignoreAll[256];
 
@@ -131,10 +145,11 @@ protected:
     // 1 for a file and file count for dirs (or both for copy&delete)
     QMap<QString, qint64> fileSizeMap;
 
-    // the name of the file thats being processed (for progressBar) and the text of the progressBar (the format)
-    QString fileName, barText;
+    // the text of the progressBar (the format)
+    QString barText;
     // stamp of the last ETA recalculation - done every second
     time_t lastTimeUpdate;
+    time_t startTime, waitTime;
     char timeBuf[10];
     // progress information of the bar and for the current file
     unsigned int barSize, barValue, fileSize, fileValue;
@@ -146,6 +161,8 @@ signals:
     void finished(FileManipulatorThread*);
     void setBarSize(FileManipulatorThread*, unsigned int);
     void updateProgress(FileManipulatorThread*, int);
+    void updateFileName(FileManipulatorThread*, QString);
+    void operationPaused(FileManipulatorThread*);
 };