blob: b78aeeec017af5af8c50b1ee472e5923cbd6d9ea (
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
|