blob: 9b213e666e48486df3fba6fc3f32f6686f0907f2 (
plain)
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
|
#ifndef SDLAPPSLISTMODEL_H
#define SDLAPPSLISTMODEL_H
#include <QAbstractListModel>
#include <QStringList>
class SdlAppsListModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit SdlAppsListModel(QObject *parent = 0);
int rowCount(const QModelIndex &parent) const { return m_data.size(); }
QVariant data(const QModelIndex &index, int role) const {
return m_data.values().at(index.row());
}
virtual QHash<int, QByteArray> roleNames() const {
QHash<int, QByteArray> roles;
roles['t'] = "text";
return roles;
}
void append(int id, QString string) {
beginResetModel();
m_data.clear();
m_data[id] = string;
endResetModel();
}
void clear() {
beginResetModel();
m_data.clear();
endResetModel();
}
signals:
public slots:
private:
QHash<int, QString> m_data;
};
#endif // SDLAPPSLISTMODEL_H
|