aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mobile/commandmodel.cpp
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2016-09-25 04:19:05 +0200
committerRenaud G <renaud@rolisteam.org>2016-09-25 04:19:05 +0200
commit664ac48622701dedaa816f5c27fff5f99389690e (patch)
tree9112c9051e3904a892207b73f2e64eda9b5306b5 /mobile/commandmodel.cpp
parente103f23c9d2e9096bde3b0d9fa798eed5dc8b64a (diff)
downloadOneRoll-664ac48622701dedaa816f5c27fff5f99389690e.tar.gz
OneRoll-664ac48622701dedaa816f5c27fff5f99389690e.zip
-first draft of mobile application.
Diffstat (limited to 'mobile/commandmodel.cpp')
-rw-r--r--mobile/commandmodel.cpp32
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();
+}