3131
3232#endif
3333
34- #define GET_IN_RANGE (v, minv, maxv ) (std::min(std::max((v), (minv)), (maxv)))
35-
3634SimpleMapView::SimpleMapView (SimpleMapViewBase* parent)
3735 : SimpleMapViewBase(parent),
3836 m_zoomLevel(17 ),
@@ -104,7 +102,7 @@ int SimpleMapView::minZoomLevel() const
104102
105103void SimpleMapView::setMinZoomLevel (int minZoomLevel)
106104{
107- m_minZoomLevel = GET_IN_RANGE (minZoomLevel, 0 , m_maxZoomLevel);
105+ m_minZoomLevel = std::clamp (minZoomLevel, 0 , m_maxZoomLevel);
108106 this ->setZoomLevel (m_zoomLevel);
109107}
110108
@@ -115,7 +113,7 @@ int SimpleMapView::maxZoomLevel() const
115113
116114void SimpleMapView::setMaxZoomLevel (int maxZoomLevel)
117115{
118- m_maxZoomLevel = GET_IN_RANGE (maxZoomLevel, m_minZoomLevel, INT_MAX);
116+ m_maxZoomLevel = std::clamp (maxZoomLevel, m_minZoomLevel, INT_MAX);
119117 this ->setZoomLevel (m_zoomLevel);
120118}
121119
@@ -129,7 +127,7 @@ void SimpleMapView::setZoomLevel(int zoomLevel)
129127 if (!this ->isEnabled () || m_lockZoom) return ;
130128
131129 const int oldZoomLevel = m_zoomLevel;
132- m_zoomLevel = GET_IN_RANGE (zoomLevel, m_minZoomLevel, m_maxZoomLevel);
130+ m_zoomLevel = std::clamp (zoomLevel, m_minZoomLevel, m_maxZoomLevel);
133131
134132 if (oldZoomLevel != m_zoomLevel)
135133 {
@@ -180,8 +178,8 @@ void SimpleMapView::setCenter(qreal latitude, qreal longitude)
180178
181179 bool isChanged = false ;
182180
183- latitude = GET_IN_RANGE (latitude, -90.0 , 90.0 );
184- longitude = GET_IN_RANGE (longitude, -180.0 , 180.0 );
181+ latitude = std::clamp (latitude, -90.0 , 90.0 );
182+ longitude = std::clamp (longitude, -180.0 , 180.0 );
185183
186184 if (latitude != this ->latitude ())
187185 {
@@ -262,13 +260,13 @@ void SimpleMapView::setTileServer(const QString& tileServer, bool wait)
262260 if (wait)
263261 {
264262 QEventLoop eventLoop;
265- (void )this ->connect (reply, &QNetworkReply::finished, &eventLoop, &QEventLoop::quit);
263+ (void )reply ->connect (reply, &QNetworkReply::finished, &eventLoop, &QEventLoop::quit);
266264 (void )eventLoop.exec ();
267265 handleResponse ();
268266 }
269267 else
270268 {
271- (void )this ->connect (reply, &QNetworkReply::finished, this , handleResponse);
269+ (void )reply ->connect (reply, &QNetworkReply::finished, this , handleResponse);
272270 }
273271 }
274272 else
@@ -610,7 +608,7 @@ void SimpleMapView::downloadTiles(const QString& path, const QGeoCoordinate& p1,
610608
611609 QNetworkReply* reply = m_networkManager.get (request);
612610
613- (void )this ->connect (reply, &QNetworkReply::finished, this ,
611+ (void )reply ->connect (reply, &QNetworkReply::finished, this ,
614612 [this , downloadNextTile, increaseTilePosition, qrcFile, qrcTextStream, x_next, y_next, z_next, p1, p2, x_start, y_start, x_end, y_end, z_end, currentRequestCount, originalZ, dir, progressBar, downloadedTileCount, reply, x, y, z, tilePath]()
615613 {
616614 if (reply->error () == QNetworkReply::NoError)
@@ -878,7 +876,7 @@ void SimpleMapView::fetchTileFromRemote(const QPoint& tilePosition)
878876 QNetworkReply* reply = m_networkManager.get (request);
879877 m_replyMap[tileKey] = reply;
880878
881- (void )this ->connect (reply, &QNetworkReply::finished, this ,
879+ (void )reply ->connect (reply, &QNetworkReply::finished, this ,
882880 [this , reply, tileKey]()
883881 {
884882 if (reply->error () == QNetworkReply::NoError)
@@ -891,7 +889,6 @@ void SimpleMapView::fetchTileFromRemote(const QPoint& tilePosition)
891889 }
892890 else
893891 {
894- qDebug () << " [SimpleMapView]" << reply->errorString ();
895892 if (!m_abortingReplies)
896893 {
897894 m_backupTileServerIndex = 0 ;
0 commit comments