diff options
| author | 2016-09-25 04:19:05 +0200 | |
|---|---|---|
| committer | 2016-09-25 04:19:05 +0200 | |
| commit | 664ac48622701dedaa816f5c27fff5f99389690e (patch) | |
| tree | 9112c9051e3904a892207b73f2e64eda9b5306b5 /mobile/commandmodel.cpp | |
| parent | e103f23c9d2e9096bde3b0d9fa798eed5dc8b64a (diff) | |
| download | OneRoll-664ac48622701dedaa816f5c27fff5f99389690e.tar.gz OneRoll-664ac48622701dedaa816f5c27fff5f99389690e.zip | |
-first draft of mobile application.
Diffstat (limited to 'mobile/commandmodel.cpp')
| -rw-r--r-- | mobile/commandmodel.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/mobile/commandmodel.cpp b/mobile/commandmodel.cpp index 1f6f6e1..6a3ab1d 100644 --- a/mobile/commandmodel.cpp +++ b/mobile/commandmodel.cpp @@ -23,3 +23,35 @@ CommandModel::CommandModel() { } + +QVariant CommandModel::data(const QModelIndex &index, int role) const +{ + QPair<QString,QString> indexP = m_data.at(index.row()); + if(role == NameRole) + { + return indexP.first; + } + else if(role == CmdRole) + { + return indexP.second; + } +} + +int CommandModel::rowCount(const QModelIndex &parent) const +{ + return m_data.count(); +} +QHash<int, QByteArray> CommandModel::roleNames() const +{ + QHash<int, QByteArray> roles; + roles[NameRole] = "name"; + roles[CmdRole] = "cmd"; + return roles; +} +void CommandModel::insertCmd(QString name, QString cmd) +{ + QModelIndex index; + beginInsertRows(index,0,0); + m_data.prepend(QPair<QString,QString>(name,cmd)); + endInsertRows(); +} |