-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfilesystemmodel.h
63 lines (51 loc) · 1.24 KB
/
filesystemmodel.h
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
#ifndef FILESYSTEM_H
#define FILESYSTEM_H
#include <QObject>
#include <QAbstractListModel>
#include <QDir>
#include <QFileInfoList>
class FileSystemModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(QString currentPath READ currentPath WRITE setCurrentPath NOTIFY currentPathChanged)
public:
enum Roles
{
NAME,
DIR,
DIR_UP,
DRIVE,
FULL_PATH
};
enum ItemTypes {
File,
Dir,
Back,
Drive,
};
Q_ENUM(Roles)
Q_ENUM(ItemTypes)
struct Item {
QString name;
QString fullPath;
ItemTypes type;
};
FileSystemModel(QObject *parent = nullptr);
void updateDirInfo (void);
void updateDrivesInfo(void);
QString currentPath(void) const;
void setCurrentPath(QString);
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QHash <int, QByteArray> roleNames(void) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
private:
QDir dir;
QList<Item> items;
const QString cdItemName = "up";
signals:
void currentPathChanged(QString);
public slots:
void cdUp(void);
void cd(const QString& path);
};
#endif // FILESYSTEM_H