/usr/include/libfm-qt/fileoperation.h is in libfm-qt-dev 0.12.0-14build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | /*
* Copyright (C) 2012 - 2015 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef FM_FILEOPERATION_H
#define FM_FILEOPERATION_H
#include "libfmqtglobals.h"
#include <QObject>
#include <QElapsedTimer>
#include <libfm/fm.h>
#include "core/filepath.h"
class QTimer;
namespace Fm {
class FileOperationDialog;
class LIBFM_QT_API FileOperation : public QObject {
Q_OBJECT
public:
enum Type {
Copy = FM_FILE_OP_COPY,
Move = FM_FILE_OP_MOVE,
Link = FM_FILE_OP_LINK,
Delete = FM_FILE_OP_DELETE,
Trash = FM_FILE_OP_TRASH,
UnTrash = FM_FILE_OP_UNTRASH,
ChangeAttr = FM_FILE_OP_CHANGE_ATTR
};
public:
explicit FileOperation(Type type, Fm::FilePathList srcFiles, QObject* parent = 0);
virtual ~FileOperation();
void setDestination(Fm::FilePath dest);
void setChmod(mode_t newMode, mode_t newModeMask) {
fm_file_ops_job_set_chmod(job_, newMode, newModeMask);
}
void setChown(gint uid, gint gid) {
fm_file_ops_job_set_chown(job_, uid, gid);
}
// This only work for change attr jobs.
void setRecursiveChattr(bool recursive) {
fm_file_ops_job_set_recursive(job_, (gboolean)recursive);
}
bool run();
void cancel() {
if(job_) {
fm_job_cancel(FM_JOB(job_));
}
}
bool isRunning() const {
return job_ ? fm_job_is_running(FM_JOB(job_)) : false;
}
bool isCancelled() const {
return job_ ? fm_job_is_cancelled(FM_JOB(job_)) : false;
}
FmFileOpsJob* job() {
return job_;
}
bool autoDestroy() {
return autoDestroy_;
}
void setAutoDestroy(bool destroy = true) {
autoDestroy_ = destroy;
}
Type type() {
return (Type)job_->type;
}
// convinient static functions
static FileOperation* copyFiles(Fm::FilePathList srcFiles, Fm::FilePath dest, QWidget* parent = 0);
static FileOperation* moveFiles(Fm::FilePathList srcFiles, Fm::FilePath dest, QWidget* parent = 0);
static FileOperation* symlinkFiles(Fm::FilePathList srcFiles, Fm::FilePath dest, QWidget* parent = 0);
static FileOperation* deleteFiles(Fm::FilePathList srcFiles, bool promp = true, QWidget* parent = 0);
static FileOperation* trashFiles(Fm::FilePathList srcFiles, bool promp = true, QWidget* parent = 0);
static FileOperation* unTrashFiles(Fm::FilePathList srcFiles, QWidget* parent = 0);
static FileOperation* changeAttrFiles(Fm::FilePathList srcFiles, QWidget* parent = 0);
Q_SIGNALS:
void finished();
private:
static gint onFileOpsJobAsk(FmFileOpsJob* job, const char* question, char* const* options, FileOperation* pThis);
static gint onFileOpsJobAskRename(FmFileOpsJob* job, FmFileInfo* src, FmFileInfo* dest, char** new_name, FileOperation* pThis);
static FmJobErrorAction onFileOpsJobError(FmFileOpsJob* job, GError* err, FmJobErrorSeverity severity, FileOperation* pThis);
static void onFileOpsJobPrepared(FmFileOpsJob* job, FileOperation* pThis);
static void onFileOpsJobCurFile(FmFileOpsJob* job, const char* cur_file, FileOperation* pThis);
static void onFileOpsJobPercent(FmFileOpsJob* job, guint percent, FileOperation* pThis);
static void onFileOpsJobFinished(FmFileOpsJob* job, FileOperation* pThis);
static void onFileOpsJobCancelled(FmFileOpsJob* job, FileOperation* pThis);
void handleFinish();
void disconnectJob();
void showDialog();
void pauseElapsedTimer() {
if(Q_LIKELY(elapsedTimer_ != nullptr)) {
lastElapsed_ += elapsedTimer_->elapsed();
elapsedTimer_->invalidate();
}
}
void resumeElapsedTimer() {
if(Q_LIKELY(elapsedTimer_ != nullptr)) {
elapsedTimer_->start();
}
}
qint64 elapsedTime() {
if(Q_LIKELY(elapsedTimer_ != nullptr)) {
return lastElapsed_ + elapsedTimer_->elapsed();
}
return 0;
}
private Q_SLOTS:
void onUiTimeout();
private:
FmFileOpsJob* job_;
FileOperationDialog* dlg;
Fm::FilePath destPath;
Fm::FilePathList srcPaths;
QTimer* uiTimer;
QElapsedTimer* elapsedTimer_;
qint64 lastElapsed_;
bool updateRemainingTime_;
QString curFile;
bool autoDestroy_;
};
}
#endif // FM_FILEOPERATION_H
|