libosmscout  1.1.1
MapOverlay.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_CLIENT_QT_MAPOVERLAY_H
2 #define OSMSCOUT_CLIENT_QT_MAPOVERLAY_H
3 
4 /*
5  OSMScout - a Qt backend for libosmscout and libosmscout-map
6  Copyright (C) 2017 Lukáš 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 
23 #include <osmscout/InputHandler.h>
24 
26 
27 #include <QQuickPaintedItem>
28 
29 namespace osmscout {
30 
34 class OSMSCOUT_CLIENT_QT_API MapOverlay : public QQuickPaintedItem
35 {
36  Q_OBJECT
37  Q_PROPERTY(QObject *view READ GetView WRITE SetMapView)
38 
39 protected:
41 
42 public slots:
43  void changeView(const MapView &view);
44  void redraw();
45 
46 public:
47  MapOverlay(QQuickItem* parent = 0);
48  virtual ~MapOverlay();
49 
50  inline void SetMapView(QObject *o)
51  {
52  MapView *updated = dynamic_cast<MapView*>(o);
53  if (updated == nullptr){
54  qWarning() << "Failed to cast " << o << " to MapView*.";
55  return;
56  }
57 
58  bool changed = *view != *updated;
59  if (changed){
60  changeView(*updated);
61  }
62  }
63 
64  inline MapView* GetView() const
65  {
66  return view; // We should be owner, parent is set http://doc.qt.io/qt-5/qqmlengine.html#objectOwnership
67  }
68 };
69 
70 }
71 
72 #endif // OSMSCOUT_CLIENT_QT_MAPOVERLAY_H
MapView * GetView() const
Definition: MapOverlay.h:64
#define OSMSCOUT_CLIENT_QT_API
Definition: ClientQtImportExport.h:45
MapView * view
Definition: MapOverlay.h:40
Definition: Area.h:38
Definition: MapOverlay.h:34
void SetMapView(QObject *o)
Definition: MapOverlay.h:50
Definition: InputHandler.h:160