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(QObject *parent = 0);
22 int rowCount(const QModelIndex & parent = QModelIndex()) const;
23 void setBookmarkModeActive(bool mode);
25 QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
26 bool setData(const QModelIndex &index, const QVariant &value, int role);
28 Qt::ItemFlags flags(const QModelIndex &index) const;
30 //! Replace model data and refresh ui.
32 \param dictionaries hash set (dictionary, is active) with dictionaries
34 void setTranslations(QHash<QString, QList<Translation*> > translations, QHash<QString, bool> wordsInBookmarks);
35 //! Clear model data and refresh UI
38 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
42 void addToBookmarks(QString word);
44 void removeFromBookmarks(QString word);
48 //! Set value at role in index row of data.
50 \param index word position in data list
51 \param value new value for role
54 void setModelProperty(int index, const QVariant value, QString role);
57 int setDataPriv(int index, const QVariant &value, int role);
58 void addWord(QString word, QList<Translation*> translations, bool isBookmarked);
60 QHash<QString, QList<Translation*> > _translations;
61 QHash<QString, bool > _wordInBookmarks;
62 QList<QString> _wordList;
64 bool isBookmarkModeActive;
68 #endif // WORDLISTMODEL_H