blob: f040aa42953d14256b364c82316debdc9c2dcb5c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#ifndef NAVITRECENTSMODEL_H
#define NAVITRECENTSMODEL_H
#include <QAbstractItemModel>
#include <QDebug>
#include "navitinstance.h"
#include "navithelper.h"
#include <glib.h>
extern "C" {
#include "config.h"
#include "item.h" /* needs to be first, as attr.h depends on it */
#include "navit.h"
#include "coord.h"
#include "attr.h"
#include "xmlconfig.h" // for NAVIT_OBJECT
#include "layout.h"
#include "map.h"
#include "transform.h"
#include "mapset.h"
#include "search.h"
#include "proxy.h"
}
class NavitRecentsModel : public QAbstractItemModel
{
Q_OBJECT
Q_PROPERTY(NavitInstance * navit MEMBER m_navitInstance WRITE setNavit)
public:
enum RecentsModelRoles {
LabelRole = Qt::UserRole + 1
};
explicit NavitRecentsModel(QObject *parent = 0);
int rowCount(const QModelIndex & parent = QModelIndex()) const override;
QHash<int, QByteArray> roleNames() const override;
QVariant data(const QModelIndex & index, int role) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &child) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
void setNavit(NavitInstance * navit);
Q_INVOKABLE void setAsDestination(int index);
Q_INVOKABLE void setAsPosition(int index);
Q_INVOKABLE void addAsBookmark(int index);
Q_INVOKABLE void addStop(int index, int position);
Q_INVOKABLE void remove(int index);
private:
QList<QVariantMap> m_recents;
NavitInstance *m_navitInstance = nullptr;
void update();
};
#endif // NAVITRECENTSMODEL_H
|