From 664ac48622701dedaa816f5c27fff5f99389690e Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sun, 25 Sep 2016 04:19:05 +0200 Subject: -first draft of mobile application. --- mobile/commandmodel.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'mobile/commandmodel.cpp') 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 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 CommandModel::roleNames() const +{ + QHash 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(name,cmd)); + endInsertRows(); +} -- cgit v1.2.3-70-g09d2