1 #include "HistoryListModel.h"
3 HistoryListModel::HistoryListModel(QStringList words, QObject *parent) :
4 QAbstractListModel(parent) {
6 QHash<int, QByteArray> roles;
7 roles[WordRole] = "word";
8 roles[NumberRole] = "number";
10 setHistoryTypes(words);
13 int HistoryListModel::rowCount(const QModelIndex &parent) const {
14 return _words.count();
17 void HistoryListModel::setHistoryTypes(QStringList words) {
18 for(int i = 0; i < words.count(); i++) {
23 QVariant HistoryListModel::data(const QModelIndex & index, int role) const
25 if (index.row() < 0 || index.row() > _words.count())
28 const QString word = _words[index.row()];
31 if (role == NumberRole)
36 void HistoryListModel::addType(QString word) {
37 beginInsertRows(QModelIndex(), rowCount(), rowCount());