| 1 | #ifndef RECENTLOCATIONSMODEL_HXX |
| 2 | #define RECENTLOCATIONSMODEL_HXX |
| 3 | |
| 4 | #include <QAbstractListModel> |
| 5 | #include <QVariantList> |
| 6 | |
| 7 | |
| 8 | class RecentLocationsModel : public QAbstractListModel |
| 9 | { |
| 10 | Q_OBJECT |
| 11 | |
| 12 | Q_PROPERTY(bool isEmpty READ isEmpty NOTIFY isEmptyChanged) |
| 13 | |
| 14 | public: |
| 15 | RecentLocationsModel(QObject* pr = nullptr); |
| 16 | |
| 17 | QVariant data(const QModelIndex &index, int role) const override; |
| 18 | |
| 19 | int rowCount(const QModelIndex &parent) const override; |
| 20 | |
| 21 | QHash<int, QByteArray> roleNames() const override; |
| 22 | |
| 23 | QVariantMap mostRecent() const; |
| 24 | |
| 25 | void insert(QVariant location); |
| 26 | |
| 27 | void saveToSettings(); |
| 28 | |
| 29 | Q_INVOKABLE QVariantMap locationAt(int index) const; |
| 30 | |
| 31 | bool isEmpty() const; |
| 32 | |
| 33 | signals: |
| 34 | void isEmptyChanged(); |
| 35 | |
| 36 | private: |
| 37 | QVariantList m_data; |
| 38 | }; |
| 39 | |
| 40 | #endif // RECENTLOCATIONSMODEL_HXX |