1 | /** =========================================================== |
2 | * @file |
3 | * |
4 | * This file is a part of digiKam project |
5 | * <a href="http://www.digikam.org">http://www.digikam.org</a> |
6 | * |
7 | * @date 2009-12-01 |
8 | * @brief world map widget library |
9 | * |
10 | * @author Copyright (C) 2009-2011, 2014 by Michael G. Hansen |
11 | * <a href="mailto:mike at mghansen dot de">mike at mghansen dot de</a> |
12 | * @author Copyright (C) 2010-2013 by Gilles Caulier |
13 | * <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a> |
14 | * @author Copyright (C) 2014 by Justus Schwartz |
15 | * <a href="mailto:justus at gmx dot li">justus at gmx dot li</a> |
16 | * |
17 | * This program is free software; you can redistribute it |
18 | * and/or modify it under the terms of the GNU General |
19 | * Public License as published by the Free Software Foundation; |
20 | * either version 2, or (at your option) any later version. |
21 | * |
22 | * This program is distributed in the hope that it will be useful, |
23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * GNU General Public License for more details. |
26 | * |
27 | * ============================================================ */ |
28 | |
29 | #ifndef KGEOMAP_WIDGET_H |
30 | #define KGEOMAP_WIDGET_H |
31 | |
32 | // Qt includes |
33 | |
34 | #include <QtGui/QWidget> |
35 | #include <QtCore/QStringList> |
36 | |
37 | // local includes |
38 | |
39 | #include "kgeomap_primitives.h" |
40 | #include "libkgeomap_export.h" |
41 | |
42 | class KAction; |
43 | class KConfigGroup; |
44 | class QDragEnterEvent; |
45 | class QDropEvent; |
46 | class ; |
47 | |
48 | namespace KGeoMap |
49 | { |
50 | |
51 | class AbstractMarkerTiler; |
52 | class DragDropHandler; |
53 | class KGeoMapSharedData; |
54 | class ModelHelper; |
55 | class TrackManager; |
56 | |
57 | class KGEOMAP_EXPORT KGeoMapWidget : public QWidget |
58 | { |
59 | Q_OBJECT |
60 | |
61 | public: |
62 | |
63 | explicit KGeoMapWidget(QWidget* const parent = 0); |
64 | ~KGeoMapWidget(); |
65 | |
66 | void saveSettingsToGroup(KConfigGroup* const group); |
67 | void readSettingsFromGroup(const KConfigGroup* const group); |
68 | |
69 | /// @name Data |
70 | //@{ |
71 | void addUngroupedModel(ModelHelper* const modelHelper); |
72 | void removeUngroupedModel(ModelHelper* const modelHelper); |
73 | void setGroupedModel(AbstractMarkerTiler* const markerModel); |
74 | void setDragDropHandler(DragDropHandler* const dragDropHandler); |
75 | void setTrackManager(TrackManager* const trackManager); |
76 | //@} |
77 | |
78 | /// @name UI setup |
79 | //@{ |
80 | KAction* getControlAction(const QString& actionName); |
81 | QWidget* getControlWidget(); |
82 | void addWidgetToControlWidget(QWidget* const newWidget); |
83 | void (QMenu* const ); |
84 | void setMouseMode(const MouseModes mouseMode); |
85 | void setAvailableMouseModes(const MouseModes mouseModes); |
86 | void setVisibleMouseModes(const MouseModes mouseModes); |
87 | void setAllowModifications(const bool state); |
88 | void setActive(const bool state); |
89 | bool getActiveState(); |
90 | bool getStickyModeState() const; |
91 | void setStickyModeState(const bool state); |
92 | void (const ExtraActions actions); |
93 | void (const ExtraActions actions); |
94 | //@} |
95 | |
96 | /// @name Map related functions |
97 | //@{ |
98 | QStringList availableBackends() const; |
99 | bool setBackend(const QString& backendName); |
100 | |
101 | GeoCoordinates getCenter() const; |
102 | void setCenter(const GeoCoordinates& coordinate); |
103 | |
104 | void setZoom(const QString& newZoom); |
105 | QString getZoom(); |
106 | |
107 | void adjustBoundariesToGroupedMarkers(const bool useSaneZoomLevel = true); |
108 | void refreshMap(); |
109 | //@} |
110 | |
111 | /// @name Appearance |
112 | //@{ |
113 | void setSortKey(const int sortKey); |
114 | void setThumnailSize(const int newThumbnailSize); |
115 | void setThumbnailGroupingRadius(const int newGroupingRadius); |
116 | void setMarkerGroupingRadius(const int newGroupingRadius); |
117 | int getThumbnailSize() const; |
118 | int getUndecoratedThumbnailSize() const; |
119 | void setShowThumbnails(const bool state); |
120 | //@} |
121 | |
122 | /// @name Region selection |
123 | //@{ |
124 | void setRegionSelection(const GeoCoordinates::Pair& region); |
125 | GeoCoordinates::Pair getRegionSelection(); |
126 | void clearRegionSelection(); |
127 | //@} |
128 | |
129 | /** |
130 | * @name Internal |
131 | * Functions that are only used internally and should be hidden from the public interface |
132 | */ |
133 | //@{ |
134 | void updateMarkers(); |
135 | void updateClusters(); |
136 | void markClustersAsDirty(); |
137 | |
138 | void getColorInfos(const int clusterIndex, QColor* fillColor, QColor* strokeColor, |
139 | Qt::PenStyle* strokeStyle, QString* labelText, QColor* labelColor, |
140 | const KGeoMapGroupState* const overrideSelection = 0, |
141 | const int* const overrideCount = 0) const; |
142 | |
143 | void getColorInfos(const KGeoMapGroupState groupState, |
144 | const int nMarkers, |
145 | QColor* fillColor, QColor* strokeColor, |
146 | Qt::PenStyle* strokeStyle, QString* labelText, QColor* labelColor) const; |
147 | |
148 | QString convertZoomToBackendZoom(const QString& someZoom, const QString& targetBackend) const; |
149 | QPixmap getDecoratedPixmapForCluster(const int clusterId, const KGeoMapGroupState* const selectedStateOverride, const int* const countOverride, QPoint* const centerPoint); |
150 | QVariant getClusterRepresentativeMarker(const int clusterIndex, const int sortKey); |
151 | //@} |
152 | |
153 | public Q_SLOTS: |
154 | |
155 | /// @name Appearance |
156 | //@{ |
157 | void slotZoomIn(); |
158 | void slotZoomOut(); |
159 | void slotDecreaseThumbnailSize(); |
160 | void slotIncreaseThumbnailSize(); |
161 | //@} |
162 | |
163 | /// @name Internal? |
164 | //@{ |
165 | void slotUpdateActionsEnabled(); |
166 | void slotClustersNeedUpdating(); |
167 | void stopThumbnailTimer(); |
168 | void slotStickyModeChanged(); |
169 | //@} |
170 | |
171 | Q_SIGNALS: |
172 | |
173 | void signalUngroupedModelChanged(const int index); |
174 | void signalRegionSelectionChanged(); |
175 | void signalRemoveCurrentFilter(); |
176 | void signalStickyModeChanged(); |
177 | void signalMouseModeChanged(const KGeoMap::MouseModes& currentMouseMode); |
178 | |
179 | public: |
180 | |
181 | /** Return a string version of LibMarbleWidget release in format "major.minor.patch" |
182 | */ |
183 | static QString MarbleWidgetVersion(); |
184 | |
185 | /** Return a string version of libkgeomap release |
186 | */ |
187 | static QString version(); |
188 | |
189 | protected: |
190 | |
191 | bool currentBackendReady() const; |
192 | void applyCacheToBackend(); |
193 | void saveBackendToCache(); |
194 | void (); |
195 | void dropEvent(QDropEvent* event); |
196 | void dragMoveEvent(QDragMoveEvent* event); |
197 | void dragEnterEvent(QDragEnterEvent* event); |
198 | void dragLeaveEvent(QDragLeaveEvent* event); |
199 | void createActions(); |
200 | void createActionsForBackendSelection(); |
201 | void setShowPlaceholderWidget(const bool state); |
202 | void setMapWidgetInFrame(QWidget* const widgetForFrame); |
203 | void removeMapWidgetFromFrame(); |
204 | |
205 | protected Q_SLOTS: |
206 | |
207 | void slotBackendReadyChanged(const QString& backendName); |
208 | void slotChangeBackend(QAction* action); |
209 | void slotBackendZoomChanged(const QString& newZoom); |
210 | void slotClustersMoved(const QIntList& clusterIndices, const QPair<int, QModelIndex>& snapTarget); |
211 | void slotClustersClicked(const QIntList& clusterIndices); |
212 | void slotShowThumbnailsChanged(); |
213 | void slotRequestLazyReclustering(); |
214 | void slotLazyReclusteringRequestCallBack(); |
215 | void slotItemDisplaySettingsChanged(); |
216 | void slotUngroupedModelChanged(); |
217 | void slotNewSelectionFromMap(const KGeoMap::GeoCoordinates::Pair& sel); |
218 | |
219 | /// @name Mouse modes |
220 | //@{ |
221 | void slotMouseModeChanged(QAction* triggeredAction); |
222 | void slotRemoveCurrentRegionSelection(); |
223 | //@} |
224 | |
225 | private: |
226 | |
227 | const QExplicitlySharedDataPointer<KGeoMapSharedData> s; |
228 | |
229 | class Private; |
230 | Private* const d; |
231 | |
232 | Q_DISABLE_COPY(KGeoMapWidget) |
233 | }; |
234 | |
235 | } /* namespace KGeoMap */ |
236 | |
237 | #endif /* KGEOMAP_WIDGET_H */ |
238 | |