-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathStreamListModel.h
66 lines (53 loc) · 1.63 KB
/
StreamListModel.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
64
65
66
#ifndef STREAMLISTMODEL_H
#define STREAMLISTMODEL_H
#include <QAbstractListModel>
class StreamListModel : public QAbstractListModel
{
Q_OBJECT
public:
StreamListModel(QObject* parent = nullptr);
QVariant data(const QModelIndex& index, int role) const override;
QHash<int, QByteArray> roleNames() const override;
Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const override {
Q_UNUSED(parent)
return _size;
}
enum Roles {
Visibility,
ID,
Size,
DoneSize,
Time,
RecordState,
UploadingState,
};
void clear() {
beginResetModel();
_vectors.clear();
_size = 0;
endResetModel();
}
int size() {
return _size;
}
signals:
void appendEvent(int id, uint32_t size, uint32_t doneSize, const QString& time, int recordState, int uploadState);
private:
Q_DISABLE_COPY(StreamListModel)
int _size = 0;
int _categories = 0;
QVector<int> _roles;
QHash<int, QByteArray> _roleNames {
{{StreamListModel::Visibility}, {"visibity"}},
{{StreamListModel::ID}, {"id"}},
{{StreamListModel::Size}, {"size"}},
{{StreamListModel::DoneSize}, {"doneSize"}},
{{StreamListModel::Time}, {"time"}},
{{StreamListModel::RecordState}, {"recordState"}},
{{StreamListModel::UploadingState}, {"uploadState"}},
};
QHash<int, QVector<QVariant>> _vectors;
QHash<int, int> _index;
void doAppend(int id, uint32_t size, uint32_t doneSize, const QString& time, int recordState, int uploadState);
};
#endif // STREAMLISTMODEL_H