-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileModel.h
More file actions
52 lines (42 loc) · 1.46 KB
/
FileModel.h
File metadata and controls
52 lines (42 loc) · 1.46 KB
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
#ifndef FILEMODEL_H
#define FILEMODEL_H
#include <QAbstractItemModel>
#include <QFileInfo>
#include <QDir>
#include <QFileIconProvider>
#include <QMessageBox>
#include <vector>
#include <QThread>
#include <QFuture>
#include <QtConcurrent>
class FileModel : public QAbstractItemModel
{
Q_OBJECT
public:
FileModel(QObject* parent = nullptr);
~FileModel();
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex& index) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override { return 1; }
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
void setPath(const QString& path);
QString currentPath() const { return currentDir.absolutePath(); };
bool deleteFile(const QModelIndex& index);
bool moveFile(const QModelIndex& index, const QString& newPath);
bool copyFile(const QModelIndex& index, const QString& path);
struct File {
QFileInfo info;
QIcon icon;
};
signals:
void pathChanged(const QString& newPath);
void loading(bool state);
private:
QDir currentDir;
std::vector<File> fileList;
QString sizeToString(qint64 size) const;
bool copyDirectory(QString source, QString destination, bool overwrite = false);
QFileIconProvider iconProvider;
};
#endif // FILEMODEL_H