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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
#ifndef NAVITPOIMODEL_H
#define NAVITPOIMODEL_H
#include <QAbstractItemModel>
#include <QDebug>
#include <QThread>
#include <QThreadPool>
#include <QRunnable>
#include <QMutex>
#include <QMap>
#include <QVariant>
#include <QJsonDocument>
#include <QJsonObject>
#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"
#include "callback.h"
#include "event.h"
}
class POISearchWorker : public QObject
{
Q_OBJECT
public:
POISearchWorker (NavitInstance * navit, QString filter, int screenX, int screenY, int distance);
~POISearchWorker ();
void start();
void proccess();
void proccessMapset();
void proccessMapsetItem();
void finish();
static void callbackHandler(POISearchWorker this_);
signals:
void gotSearchResult(QVariantMap poi);
private:
NavitInstance * m_navitInstance;
QString m_filter;
int m_screenX;
int m_screenY;
int m_distance;
enum projection m_pro;
struct mapset_handle * m_h = nullptr;
struct map_selection * m_sel = nullptr;
struct coord m_center;
struct map *m_m = nullptr;
<<<<<<< HEAD
struct callback * m_idleCallback = nullptr;
struct event_idle * m_idle = nullptr;
=======
struct item * m_item = nullptr;
struct map_rect *m_mr = nullptr;
struct callback * m_idleCallback = nullptr;
struct event_idle * m_idle = nullptr;
struct map_selection *m_selm = nullptr;
>>>>>>> 3e7fdbf86... add:gt5_gui Run POI search on idle
};
class NavitPOIModel : public QAbstractItemModel
{
Q_OBJECT
Q_PROPERTY(NavitInstance * navit MEMBER m_navitInstance WRITE setNavit)
public:
enum POIModelRoles {
NameRole = Qt::UserRole + 1,
TypeRole,
DistanceRole,
IconRole,
CoordinatesRole,
AddressRole,
LabelRole
};
NavitPOIModel(QObject *parent = 0);
~NavitPOIModel() override;
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;
public slots:
void search(QString filter, int screenX = -1, int screenY = -1, int distance = 15000);
void setAsDestination(int index);
void setAsPosition(int index);
void addAsBookmark(int index);
void addStop(int index, int position);
void setNavit(NavitInstance * navit);
void reset();
private slots:
void receiveSearchResult(QVariantMap poi);
private:
QList<QVariantMap> m_pois;
NavitInstance *m_navitInstance = nullptr;
QStringList m_poiTypes;
QString getAddressString(struct item *item, int prependPostal);
void stopWorker(bool clearModel = false);
POISearchWorker *m_poiWorker = nullptr;
QMutex modelMutex;
};
#endif // NAVITPOIMODEL_H
|