update dict
[QFreeRecite.git] / src / gui / ListModel.cpp
blobdc398da9f7835c442cc28ac9bdd0c1d1f5be056c
1 #include <QtGui>
2 #include <QMessageBox>
3 #include <set>
4 #include <fstream>
5 #include <iostream>
6 #include <Manager.h>
7 #include <Dict.h>
8 #include <ConfigHolder.h>
9 #include <Exporter.h>
10 #include <ctime>
11 #include "ListModel.h"
13 using namespace freeRecite;
15 ListModel::ListModel(QObject *parent)
16 : QAbstractListModel(parent)
18 //Do Nothing Here!
21 ListModel::~ListModel() {
22 #ifdef DEBUG
23 qDebug("~ListModel()");
24 #endif //DEBUG
27 void ListModel::addToList(const QString &word) {
28 if(!words.contains(word)){
29 words.append(word);
30 emit layoutChanged();
34 int ListModel::rowCount(const QModelIndex& parent) const
36 return static_cast<int>(words.size());
39 QVariant ListModel::data(const QModelIndex &index, int role) const {
40 if(!index.isValid() || role != Qt::DisplayRole)
41 return QVariant();
42 else
43 return QVariant(words[index.row()]);