-
Notifications
You must be signed in to change notification settings - Fork 13
/
musicdownloadmodel.h
57 lines (43 loc) · 1.27 KB
/
musicdownloadmodel.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
#ifndef MUSICDOWNLOADMODEL_H
#define MUSICDOWNLOADMODEL_H
#include <QObject>
#include <QAbstractListModel>
class MusicDownloadItem;
class MusicDownloadModel : public QAbstractListModel
{
Q_OBJECT
Q_ENUMS(DataType)
Q_PROPERTY(DataType dataType READ dataType WRITE setDataType NOTIFY dataTypeChanged)
Q_PROPERTY(int count READ count NOTIFY loadFinished)
public:
enum DataRoles {
IdRole = Qt::UserRole + 1,
NameRole,
ArtistRole,
StatusRole,
ProgressRole,
SizeRole,
ErrCodeRole
};
enum DataType {
ProcessingData, CompletedData
};
explicit MusicDownloadModel(QObject *parent = 0);
~MusicDownloadModel();
DataType dataType() const;
void setDataType(const DataType& type);
int count() const;
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
Q_INVOKABLE int getIndexByMusicId(const QString& musicId) const;
QList<MusicDownloadItem*> getDataList() const;
public slots:
void refresh(MusicDownloadItem* item = 0);
signals:
void loadFinished();
void dataTypeChanged();
private:
QList<MusicDownloadItem*> mDataList;
DataType mDataType;
};
#endif // MUSICDOWNLOADMODEL_H