mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-14 19:04:23 +02:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
9b2ca4ccb7 | |||
2d9677096d | |||
f3eb136187 |
@ -63,7 +63,7 @@ Section "GPXSee (required)" SEC_APP
|
||||
; Write the uninstall keys for Windows
|
||||
WriteRegStr HKCU "${REGENTRY}" "DisplayName" "GPXSee"
|
||||
WriteRegStr HKCU "${REGENTRY}" "Publisher" "Martin Tuma"
|
||||
WriteRegStr HKCU "${REGENTRY}" "DisplayVersion" "2.1"
|
||||
WriteRegStr HKCU "${REGENTRY}" "DisplayVersion" "2.2"
|
||||
WriteRegStr HKCU "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||
WriteRegDWORD HKCU "${REGENTRY}" "NoModify" 1
|
||||
WriteRegDWORD HKCU "${REGENTRY}" "NoRepair" 1
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#define APP_NAME "GPXSee"
|
||||
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
|
||||
#define APP_VERSION "2.1"
|
||||
#define APP_VERSION "2.2"
|
||||
|
||||
#define FONT_FAMILY "Arial"
|
||||
#define FONT_SIZE 12
|
||||
|
@ -18,19 +18,23 @@
|
||||
|
||||
Downloader::Downloader()
|
||||
{
|
||||
connect(&manager, SIGNAL(finished(QNetworkReply*)),
|
||||
connect(&_manager, SIGNAL(finished(QNetworkReply*)),
|
||||
SLOT(downloadFinished(QNetworkReply*)));
|
||||
}
|
||||
|
||||
void Downloader::doDownload(const Download &dl)
|
||||
{
|
||||
QUrl url(dl.url());
|
||||
|
||||
if (_errorDownloads.contains(url))
|
||||
return;
|
||||
|
||||
QNetworkRequest request(url);
|
||||
request.setAttribute(QNetworkRequest::User, QVariant(dl.file()));
|
||||
request.setRawHeader("User-Agent", USER_AGENT);
|
||||
QNetworkReply *reply = manager.get(request);
|
||||
QNetworkReply *reply = _manager.get(request);
|
||||
|
||||
currentDownloads.append(reply);
|
||||
_currentDownloads.append(reply);
|
||||
}
|
||||
|
||||
bool Downloader::saveToDisk(const QString &filename, QIODevice *data)
|
||||
@ -53,6 +57,7 @@ void Downloader::downloadFinished(QNetworkReply *reply)
|
||||
{
|
||||
QUrl url = reply->url();
|
||||
if (reply->error()) {
|
||||
_errorDownloads.insert(url);
|
||||
fprintf(stderr, "Error downloading map tile: %s: %s\n",
|
||||
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
||||
} else {
|
||||
@ -61,10 +66,10 @@ void Downloader::downloadFinished(QNetworkReply *reply)
|
||||
saveToDisk(filename, reply);
|
||||
}
|
||||
|
||||
currentDownloads.removeAll(reply);
|
||||
_currentDownloads.removeAll(reply);
|
||||
reply->deleteLater();
|
||||
|
||||
if (currentDownloads.isEmpty())
|
||||
if (_currentDownloads.isEmpty())
|
||||
emit finished();
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <QNetworkReply>
|
||||
#include <QUrl>
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
|
||||
|
||||
class Download
|
||||
@ -45,8 +46,9 @@ private:
|
||||
void doDownload(const Download &dl);
|
||||
bool saveToDisk(const QString &filename, QIODevice *data);
|
||||
|
||||
QNetworkAccessManager manager;
|
||||
QList<QNetworkReply *> currentDownloads;
|
||||
QNetworkAccessManager _manager;
|
||||
QList<QNetworkReply *> _currentDownloads;
|
||||
QSet<QUrl> _errorDownloads;
|
||||
};
|
||||
|
||||
#endif // DOWNLOADER_H
|
||||
|
@ -74,7 +74,30 @@ void Track::loadGPX(const GPX &gpx)
|
||||
|
||||
if (_trackPaths.size() > 1 && prevScale != _scale)
|
||||
rescale(_scale);
|
||||
_scene->setSceneRect(_scene->itemsBoundingRect());
|
||||
|
||||
QRectF br = trackBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
_scene->setSceneRect(ba);
|
||||
centerOn(ba.center());
|
||||
}
|
||||
|
||||
QRectF Track::trackBoundingRect() const
|
||||
{
|
||||
qreal bottom, top, left, right;
|
||||
|
||||
bottom = _trackPaths.at(0)->sceneBoundingRect().bottom();
|
||||
top = _trackPaths.at(0)->sceneBoundingRect().top();
|
||||
left = _trackPaths.at(0)->sceneBoundingRect().left();
|
||||
right = _trackPaths.at(0)->sceneBoundingRect().right();
|
||||
|
||||
for (int i = 1; i < _trackPaths.size(); i++) {
|
||||
bottom = qMax(bottom, _trackPaths.at(i)->sceneBoundingRect().bottom());
|
||||
top = qMin(top, _trackPaths.at(i)->sceneBoundingRect().top());
|
||||
right = qMax(right, _trackPaths.at(i)->sceneBoundingRect().right());
|
||||
left = qMin(left, _trackPaths.at(i)->sceneBoundingRect().left());
|
||||
}
|
||||
|
||||
return QRectF(QPointF(left, top), QPointF(right, bottom));
|
||||
}
|
||||
|
||||
qreal Track::trackScale() const
|
||||
@ -138,6 +161,9 @@ void Track::loadPOI(const POI &poi)
|
||||
{
|
||||
QHash<Entry, POIItem*>::const_iterator it,jt;
|
||||
|
||||
if (!_tracks.size())
|
||||
return;
|
||||
|
||||
for (int i = 0; i < _tracks.size(); i++) {
|
||||
QVector<Entry> p = poi.points(_tracks.at(i));
|
||||
|
||||
@ -162,8 +188,6 @@ void Track::loadPOI(const POI &poi)
|
||||
jt.value()->hide();
|
||||
}
|
||||
}
|
||||
|
||||
_scene->setSceneRect(_scene->itemsBoundingRect());
|
||||
}
|
||||
|
||||
void Track::setMap(Map *map)
|
||||
@ -188,8 +212,16 @@ void Track::wheelEvent(QWheelEvent *event)
|
||||
qMin(_zoom + 1, ZOOM_MAX) : qMax(_zoom - 1, ZOOM_MIN);
|
||||
|
||||
rescale(mapScale());
|
||||
_scene->setSceneRect(_scene->itemsBoundingRect());
|
||||
centerOn(pos * scale/_scale);
|
||||
QRectF br = trackBoundingRect();
|
||||
QRectF ba = br.adjusted(-TILE_SIZE, -TILE_SIZE, TILE_SIZE, TILE_SIZE);
|
||||
_scene->setSceneRect(ba);
|
||||
|
||||
if (br.width() < viewport()->size().width()
|
||||
&& br.height() < viewport()->size().height())
|
||||
centerOn(br.center());
|
||||
else
|
||||
centerOn(pos * scale/_scale);
|
||||
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
@ -210,7 +242,7 @@ void Track::setTrackLineWidth(qreal width)
|
||||
|
||||
void Track::plot(QPainter *painter, const QRectF &target)
|
||||
{
|
||||
QRectF orig = sceneRect();
|
||||
QRectF orig = _scene->itemsBoundingRect();
|
||||
QRectF adj;
|
||||
qreal ratio, diff;
|
||||
|
||||
|
@ -41,6 +41,7 @@ private slots:
|
||||
void redraw();
|
||||
|
||||
private:
|
||||
QRectF trackBoundingRect() const;
|
||||
qreal trackScale() const;
|
||||
qreal mapScale() const;
|
||||
void rescale(qreal scale);
|
||||
|
Reference in New Issue
Block a user