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;
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
37 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
41 void addToBookmarks(QString word);
43 void removeFromBookmarks(QString word);
47 //! Set value at role in index row of data.
49 \param index word position in data list
50 \param value new value for role
53 void setModelProperty(int index, const QVariant value, QString role);
56 int setDataPriv(int index, const QVariant &value, int role);
57 void addWord(QString word, QList<Translation*> translations, bool isBookmarked);
59 QHash<QString, QList<Translation*> > _translations;
60 QHash<QString, bool > _wordInBookmarks;
61 QList<QString> _wordList;
63 void ascendingQuickSort(int left, int right);
64 void descendingQuickSort(int left, int right);
68 #endif // WORDLISTMODEL_H