FlightGear next
QmlStringListModel.cxx
Go to the documentation of this file.
2
3#include <algorithm>
4
5
6QmlStringListModel::QmlStringListModel(QObject* parent) : QAbstractListModel(parent)
7{
8}
9
11
13{
14 beginResetModel();
15 m_values = v;
16 endResetModel();
17}
18
19QStringList QmlStringListModel::values() const
20{
21 return m_values;
22}
23
24int QmlStringListModel::rowCount(const QModelIndex& parent) const
25{
26 Q_UNUSED(parent)
27 return m_values.size();
28}
29
30QHash<int, QByteArray> QmlStringListModel::roleNames() const
31{
32 auto roles = QAbstractListModel::roleNames();
33 return roles;
34}
35
36QVariant QmlStringListModel::data(const QModelIndex& m, int role) const
37{
38 auto s = m_values.at(m.row());
39 if (role == Qt::DisplayRole) {
40 return s;
41 }
42
43 return {};
44}
void setValues(QStringList v)
QmlStringListModel(QObject *parent=nullptr)
QHash< int, QByteArray > roleNames() const override
~QmlStringListModel() override
QVariant data(const QModelIndex &m, int role) const override
int rowCount(const QModelIndex &parent) const override