-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileListModel.hpp
More file actions
43 lines (32 loc) · 903 Bytes
/
FileListModel.hpp
File metadata and controls
43 lines (32 loc) · 903 Bytes
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
#pragma once
#include <QAbstractListModel>
#include <QMap>
#include <functional>
class FileListModel : public QAbstractListModel
{
Q_OBJECT
public:
struct FileItem
{
inline FileItem(const QVariant& state, const QString& path) :
state(state),
path(path)
{
}
QVariant state;
QString path;
};
explicit FileListModel(QObject* parent = nullptr);
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
void clear();
void selectAll();
bool hasSelection() const;
void removeIf(std::function<bool(const FileItem&)>);
public slots:
void addFilePath(const QString& filePath);
private:
QList<FileItem> _files;
};