Debian Codegraph @

src/GUI/QmlStringListModel.cxx

raw symbols SCIP
1 #include "QmlStringListModel.hxx"
2
3 #include <algorithm>
4
5
6 QmlStringListModel::QmlStringListModel(QObject* parent) : QAbstractListModel(parent)
7 {
8 }
9
10 QmlStringListModel::~QmlStringListModel() = default;
11
12 void QmlStringListModel::setValues(QStringList v)
13 {
14 beginResetModel();
15 m_values = v;
16 endResetModel();
17 }
18
19 QStringList QmlStringListModel::values() const
20 {
21 return m_values;
22 }
23
24 int QmlStringListModel::rowCount(const QModelIndex& parent) const
25 {
26 Q_UNUSED(parent)
27 return m_values.size();
28 }
29
30 QHash<int, QByteArray> QmlStringListModel::roleNames() const
31 {
32 auto roles = QAbstractListModel::roleNames();
33 return roles;
34 }
35
36 QVariant 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 }