1 #ifndef WORDLISTMODEL_H
2 #define WORDLISTMODEL_H
4 #include <QAbstractListModel>
5 //#include "../../include/GUIInterface.h"
6 #include "../../include/translation.h"
8 class WordListModel : public QAbstractListModel
15 WordRole = Qt::UserRole + 1,
20 explicit WordListModel(/*QHash<QString, QList<Translation*> > translations, QHash<QString, bool> wordsInBookmarks, */QObject *parent = 0);
22 int rowCount(const QModelIndex & parent = QModelIndex()) const;
24 QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
25 bool setData(const QModelIndex &index, const QVariant &value, int role);
27 Qt::ItemFlags flags(const QModelIndex &index) const;
29 //! Replace model data and refresh ui.
31 \param dictionaries hash set (dictionary, is active) with dictionaries
33 void setTranslations(QHash<QString, QList<Translation*> > translations, QHash<QString, bool> wordsInBookmarks);
34 //! Clear model data and refresh UI
39 // //! Set index of current selected word
41 // \param index word position in data list
43 // void itemSelected(int index);
45 void addToBookmarks(QString word);
47 void removeFromBookmarks(QString word);
51 //! Set value at role in index row of data.
53 \param index word position in data list
54 \param value new value for role
57 void setModelProperty(int index, const QVariant value, QString role);
60 int setDataPriv(int index, const QVariant &value, int role);
61 void addWord(QString word, QList<Translation*> translations, bool isBookmarked);
63 QHash<QString, QList<Translation*> > _translations;
64 QHash<QString, bool > _wordInBookmarks;
65 QList<QString> _wordList;
69 #endif // WORDLISTMODEL_H