-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModel.h
More file actions
46 lines (37 loc) · 1.14 KB
/
Model.h
File metadata and controls
46 lines (37 loc) · 1.14 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
#pragma once
#include <QtWidgets>
#include <QAbstractListModel>
struct FileData
{
QString header;
QPixmap preview;
QString filePath;
QDate creationDate;
bool isPlayable;
};
enum FileDataRoles
{
HeaderRole = Qt::DisplayRole,
PreviewRole = Qt::UserRole + 1,
FilePathRole = Qt::UserRole + 2,
CreationDateRole = Qt::UserRole + 3,
IsPlayableRole = Qt::UserRole + 4,
IsSelectedRole = Qt::UserRole + 5
};
class MyListModel: public QAbstractListModel
{
Q_OBJECT
public:
explicit MyListModel(QObject *parent = nullptr): QAbstractListModel(parent)
{}
void Load(const QList<FileData>& files);
void ObtainFiles(QList<FileData>& files) const;
virtual QVariant data(const QModelIndex &index, int role) const override;
virtual bool setData(const QModelIndex& index, const QVariant& value, int role) override;
virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
virtual int rowCount(const QModelIndex& /*parent*/) const override;
void AddFile(const QFileInfo& fileInf, const QString& haeder = "");
void DelFile(QModelIndex& index);
private:
QList<FileData> m_files;
};