libosmscout 1.1.1
Loading...
Searching...
No Matches
MapObjectInfoModel.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_CLIENT_QT_MAPOBJECTINFOMODEL_H
2#define OSMSCOUT_CLIENT_QT_MAPOBJECTINFOMODEL_H
3
4/*
5 OSMScout - a Qt backend for libosmscout and libosmscout-map
6 Copyright (C) 2016 Lukas Karas
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
24
25#include <osmscout/GeoCoord.h>
27
28#include <osmscoutclient/DBThread.h>
29
33
34#include <QObject>
35#include <QAbstractListModel>
36#include <iostream>
37
38namespace osmscout {
39
43class OSMSCOUT_CLIENT_QT_API MapObjectInfoModel: public QAbstractListModel
44{
45 Q_OBJECT
46 Q_PROPERTY(bool ready READ isReady NOTIFY readyChange)
47
48
49public:
50 enum Roles {
51 LabelRole = Qt::UserRole,
52 TypeRole = Qt::UserRole+1,
53 IdRole = Qt::UserRole+2,
54 NameRole = Qt::UserRole+3,
55 ObjectRole = Qt::UserRole+4,
56 PhoneRole = Qt::UserRole+5,
57 WebsiteRole = Qt::UserRole+6,
58 AddressLocationRole = Qt::UserRole+7,
59 AddressNumberRole = Qt::UserRole+8,
60 PostalCodeRole = Qt::UserRole+9,
61 RegionRole = Qt::UserRole+10,
62 LatRole = Qt::UserRole+11,
63 LonRole = Qt::UserRole+12,
64 AltLangName = Qt::UserRole+13,
65 OpeningHours = Qt::UserRole+14
66 };
67 Q_ENUM(Roles)
68
69signals:
70 void readyChange(bool ready);
71 void objectsOnViewRequested(const MapViewStruct &view, const QRectF &filterRectangle);
72 void objectsRequested(const LocationEntry &entry, bool reverseLookupAddresses);
73
74public slots:
75 void dbInitialized(const osmscout::GeoBox&);
76 void setPosition(QObject *mapView,
77 const int width, const int height,
78 const int screenX, const int screenY);
79
80 void onViewObjectsLoaded(const MapViewStruct&,
81 const QList<LookupModule::ObjectInfo> &objects);
82
83 void setLocationEntry(QObject *o);
84
85 void onObjectsLoaded(const LocationEntry &entry,
86 const QList<LookupModule::ObjectInfo> &objects);
87
88private:
89 void addToModel(const QList<LookupModule::ObjectInfo> &objects);
90
91public:
94
95 Q_INVOKABLE int inline rowCount(const QModelIndex &parent = QModelIndex()) const override
96 {
97 Q_UNUSED(parent);
98 return model.size();
99 };
100
101 bool inline isReady() const
102 {
103 return ready;
104 };
105
106 Q_INVOKABLE QObject* createOverlayObject(int row) const;
107
108 Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const override;
109 QHash<int, QByteArray> roleNames() const override;
110 Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const override;
111
112private:
113 bool ready;
114 bool setup;
115 QList<ObjectKey> objectSet; // set of objects already inserted to model
116 QList<LookupModule::ObjectInfo> model;
117 MapViewStruct view;
118 QRectF filterRectangle;
119 LocationEntry locationEntry;
120
121 QList<osmscout::MapData> mapData;
122 double mapDpi;
123 LookupModule* lookupModule;
124 SettingsRef settings;
125};
126
127}
128
129#endif /* OSMSCOUT_CLIENT_QT_MAPOBJECTINFOMODEL_H */
#define OSMSCOUT_CLIENT_QT_API
Definition ClientQtImportExport.h:45
Definition LocationEntry.h:47
Definition LookupModule.h:47
Q_INVOKABLE int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition MapObjectInfoModel.h:95
bool ready
Definition MapObjectInfoModel.h:46
void setPosition(QObject *mapView, const int width, const int height, const int screenX, const int screenY)
void setLocationEntry(QObject *o)
Q_INVOKABLE QObject * createOverlayObject(int row) const
void onObjectsLoaded(const LocationEntry &entry, const QList< LookupModule::ObjectInfo > &objects)
void readyChange(bool ready)
Q_INVOKABLE Qt::ItemFlags flags(const QModelIndex &index) const override
void onViewObjectsLoaded(const MapViewStruct &, const QList< LookupModule::ObjectInfo > &objects)
void dbInitialized(const osmscout::GeoBox &)
void objectsRequested(const LocationEntry &entry, bool reverseLookupAddresses)
bool isReady() const
Definition MapObjectInfoModel.h:101
void objectsOnViewRequested(const MapViewStruct &view, const QRectF &filterRectangle)
Q_INVOKABLE QVariant data(const QModelIndex &index, int role) const override
Roles
Definition MapObjectInfoModel.h:50
@ WebsiteRole
Definition MapObjectInfoModel.h:57
@ PostalCodeRole
Definition MapObjectInfoModel.h:60
@ NameRole
Definition MapObjectInfoModel.h:54
@ LatRole
Definition MapObjectInfoModel.h:62
@ TypeRole
Definition MapObjectInfoModel.h:52
@ AddressNumberRole
Definition MapObjectInfoModel.h:59
@ RegionRole
Definition MapObjectInfoModel.h:61
@ AddressLocationRole
Definition MapObjectInfoModel.h:58
@ LonRole
Definition MapObjectInfoModel.h:63
@ LabelRole
Definition MapObjectInfoModel.h:51
@ OpeningHours
Definition MapObjectInfoModel.h:65
@ IdRole
Definition MapObjectInfoModel.h:53
@ PhoneRole
Definition MapObjectInfoModel.h:56
@ AltLangName
Definition MapObjectInfoModel.h:64
@ ObjectRole
Definition MapObjectInfoModel.h:55
QHash< int, QByteArray > roleNames() const override
Definition Area.h:39