1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-12 18:05:10 +02:00

Compare commits

..

27 Commits
9.3 ... 9.4

Author SHA1 Message Date
82d2ac0871 Fixed layout centering 2021-08-08 11:07:53 +02:00
0b3e35db72 Fixed some possible corner case 2021-08-05 00:02:47 +02:00
0c4e5b0017 A more human yaml syntax 2021-08-04 23:51:24 +02:00
933f2c3837 Rotate JPEG thumbnails acording to EXIF data
fixes #385
2021-08-04 08:57:42 +02:00
6e4cc406ab Version++ 2021-07-31 08:25:30 +02:00
21ce65146a Cache homebrew packages between builds 2021-07-30 23:41:50 +02:00
c99adfd6d2 Use the apt addon instead of manual packages install 2021-07-30 08:56:49 +02:00
c537f1ba6c Use travis-ci homebrew addon instead of manual package installation 2021-07-30 08:44:18 +02:00
4e36d8633c Translated using Weblate (Turkish)
Currently translated at 100.0% (406 of 406 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/tr/
2021-07-29 23:00:36 +02:00
8beeeb7526 Merge branch 'origin/master' into Weblate. 2021-07-27 21:54:33 +02:00
69cc6ccb75 Render symbols/labels for not rendered areas 2021-07-27 21:53:24 +02:00
f042f11eed Fixed rule evaluation logic 2021-07-27 21:52:37 +02:00
f72835f05e Translated using Weblate (Finnish)
Currently translated at 99.2% (403 of 406 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/fi/
2021-07-24 20:18:47 +02:00
c8779b4592 Translated using Weblate (Esperanto)
Currently translated at 95.5% (388 of 406 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/eo/
2021-07-24 20:18:47 +02:00
4b30e665cc Translated using Weblate (Russian)
Currently translated at 100.0% (406 of 406 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/ru/
2021-07-24 20:18:47 +02:00
ac45ccaab6 Translated using Weblate (Ukrainian)
Currently translated at 95.3% (387 of 406 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/uk/
2021-07-24 20:18:46 +02:00
6d2182eb46 Translated using Weblate (French)
Currently translated at 100.0% (406 of 406 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/fr/
2021-07-24 07:30:18 +02:00
50aea76bf7 Merge branch 'origin/master' into Weblate. 2021-07-22 00:34:45 +02:00
7676a21fc3 Some more file open logic fix/improvement 2021-07-22 00:32:36 +02:00
dc6a57338e Code cleanup 2021-07-22 00:31:57 +02:00
fa3fac5314 Merge branch 'origin/master' into Weblate. 2021-07-21 02:07:49 +02:00
a53fedf838 Yet another unnecessary file open remove 2021-07-21 02:06:35 +02:00
4d284ad0e5 Merge branch 'origin/master' into Weblate. 2021-07-19 22:52:50 +02:00
3f3ccb6856 Cache the open file descriptors between successive raster loads 2021-07-19 22:51:00 +02:00
2ea16eaaab Do not open/close the data files when not accessing them 2021-07-19 22:47:44 +02:00
effb0bb654 Translated using Weblate (Russian)
Currently translated at 99.5% (404 of 406 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/ru/
2021-07-19 08:46:45 +02:00
8bd08b31a3 Give the flags human readable names 2021-07-18 22:32:49 +02:00
60 changed files with 642 additions and 260 deletions

View File

@ -1,4 +1,4 @@
version: 9.3.{build}
version: 9.4.{build}
configuration:
- Release
@ -30,43 +30,29 @@ environment:
NSISDEF: /DQT6
install:
- cmd: >-
- cmd: |-
set PATH=%QTDIR%\bin;%NSISDIR%;%PATH%
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\"%VCVARS%
build_script:
- cmd: >-
- cmd: |-
lrelease gpxsee.pro
qmake gpxsee.pro
nmake release
md installer
copy release\GPXSee.exe installer
windeployqt --release installer\GPXSee.exe
copy pkg\%NSI% installer
copy pkg\macros.nsh installer
xcopy pkg\csv installer\csv /i
xcopy pkg\maps installer\maps /i
xcopy lang\*.qm installer\translations\ /sy
copy licence.txt installer
copy %OPENSSLDIR%\%LIBCRYPTO% installer
copy %OPENSSLDIR%\%LIBSSL% installer
makensis.exe %NSISDEF% installer\%NSI%
artifacts:
- path: installer\GPXSee-*.exe

View File

@ -7,13 +7,23 @@ os:
dist: focal
osx_image: xcode12
before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get -qq update; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
cache:
directories:
- $HOME/Library/Caches/Homebrew
install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install qt; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install qtbase5-dev qtbase5-private-dev libqt5opengl5-dev qttools5-dev-tools; fi
before_cache:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew cleanup; fi
addons:
homebrew:
packages:
- qt
apt:
packages:
- qtbase5-dev
- qtbase5-private-dev
- libqt5opengl5-dev
- qttools5-dev-tools
script:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then PATH=/usr/local/opt/qt/bin/:${PATH}; fi

View File

@ -3,7 +3,7 @@ unix:!macx {
} else {
TARGET = GPXSee
}
VERSION = 9.3
VERSION = 9.4
QT += core \
gui \
@ -20,6 +20,7 @@ INCLUDEPATH += ./src
HEADERS += src/common/config.h \
src/GUI/axislabelitem.h \
src/GUI/dirselectwidget.h \
src/GUI/flowlayout.h \
src/GUI/graphicsscene.h \
src/GUI/mapaction.h \
src/GUI/mapitem.h \
@ -28,6 +29,7 @@ HEADERS += src/common/config.h \
src/GUI/planeitem.h \
src/GUI/poiaction.h \
src/GUI/popup.h \
src/GUI/thumbnail.h \
src/common/garmin.h \
src/common/coordinates.h \
src/common/range.h \
@ -230,10 +232,12 @@ HEADERS += src/common/config.h \
SOURCES += src/main.cpp \
src/GUI/axislabelitem.cpp \
src/GUI/dirselectwidget.cpp \
src/GUI/flowlayout.cpp \
src/GUI/mapitem.cpp \
src/GUI/marginswidget.cpp \
src/GUI/markerinfoitem.cpp \
src/GUI/popup.cpp \
src/GUI/thumbnail.cpp \
src/common/coordinates.cpp \
src/common/rectc.cpp \
src/common/range.cpp \
@ -261,7 +265,6 @@ SOURCES += src/main.cpp \
src/GUI/fileselectwidget.cpp \
src/GUI/temperaturegraph.cpp \
src/GUI/trackitem.cpp \
src/GUI/tooltip.cpp \
src/GUI/routeitem.cpp \
src/GUI/graphitem.cpp \
src/GUI/pathitem.cpp \

View File

@ -152,7 +152,7 @@
<message>
<location filename="../src/GUI/dirselectwidget.cpp" line="38"/>
<source>Select directory</source>
<translation type="unfinished"></translation>
<translation>Elekti dosierujon</translation>
</message>
</context>
<context>
@ -1619,17 +1619,17 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="702"/>
<source>Data:</source>
<translation type="unfinished"></translation>
<translation>Dateno:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="703"/>
<source>Maps:</source>
<translation type="unfinished"></translation>
<translation>Mapoj:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="704"/>
<source>POI:</source>
<translation type="unfinished"></translation>
<translation>POI:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="715"/>

View File

@ -147,12 +147,12 @@
<message>
<location filename="../src/GUI/dirselectwidget.cpp" line="16"/>
<source>System default</source>
<translation type="unfinished"></translation>
<translation>Järjestelmän oletus</translation>
</message>
<message>
<location filename="../src/GUI/dirselectwidget.cpp" line="38"/>
<source>Select directory</source>
<translation type="unfinished"></translation>
<translation>Valitse hakemisto</translation>
</message>
</context>
<context>
@ -1619,17 +1619,17 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="702"/>
<source>Data:</source>
<translation type="unfinished"></translation>
<translation>Tiedot:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="703"/>
<source>Maps:</source>
<translation type="unfinished"></translation>
<translation>Kartat:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="704"/>
<source>POI:</source>
<translation type="unfinished"></translation>
<translation>POI:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="715"/>

View File

@ -147,12 +147,12 @@
<message>
<location filename="../src/GUI/dirselectwidget.cpp" line="16"/>
<source>System default</source>
<translation type="unfinished"></translation>
<translation>Selon le système</translation>
</message>
<message>
<location filename="../src/GUI/dirselectwidget.cpp" line="38"/>
<source>Select directory</source>
<translation type="unfinished"></translation>
<translation>Sélectionner un dossier</translation>
</message>
</context>
<context>
@ -1086,7 +1086,7 @@
<message>
<location filename="../src/map/maplist.cpp" line="137"/>
<source>World-file georeferenced images</source>
<translation type="unfinished"></translation>
<translation>Images de carte positionnées par world file</translation>
</message>
<message>
<location filename="../src/map/maplist.cpp" line="139"/>
@ -1455,12 +1455,12 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="56"/>
<source>Select the proper projection of maps without a projection definition (JNX, KMZ and world file maps).</source>
<translation type="unfinished"></translation>
<translation>Choisir la projection des cartes sans définition de projection (cartes JNX, KMZ ou world file).</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="58"/>
<source>Select the desired projection of vector maps (IMG and Mapsforge maps). The projection must be valid for the whole map area.</source>
<translation type="unfinished"></translation>
<translation>Choisir la projection des cartes vectorielles (cartes IMG ou Mapsforge). La projection doit être valide sur l&apos;étendue de la carte.</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="174"/>
@ -1614,27 +1614,27 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="694"/>
<source>Select the initial paths of the file open dialogues. Leave the field empty for the system default.</source>
<translation type="unfinished"></translation>
<translation>Personnaliser le dossier initial à l&apos;ouverture de fichier. Laisser vide pour le dossier par défaut du système.</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="702"/>
<source>Data:</source>
<translation type="unfinished"></translation>
<translation>Données :</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="703"/>
<source>Maps:</source>
<translation type="unfinished"></translation>
<translation>Cartes :</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="704"/>
<source>POI:</source>
<translation type="unfinished"></translation>
<translation>POI :</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="715"/>
<source>Initial paths</source>
<translation type="unfinished"></translation>
<translation>Chemins initiaux</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="733"/>

View File

@ -147,12 +147,12 @@
<message>
<location filename="../src/GUI/dirselectwidget.cpp" line="16"/>
<source>System default</source>
<translation type="unfinished"></translation>
<translation>По умолчанию</translation>
</message>
<message>
<location filename="../src/GUI/dirselectwidget.cpp" line="38"/>
<source>Select directory</source>
<translation type="unfinished"></translation>
<translation>Выбрать каталог</translation>
</message>
</context>
<context>
@ -1615,27 +1615,27 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="694"/>
<source>Select the initial paths of the file open dialogues. Leave the field empty for the system default.</source>
<translation type="unfinished"></translation>
<translation>Выберите начальные пути диалогов открытия файлов. Оставьте поле пустым для системного значения по умолчанию.</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="702"/>
<source>Data:</source>
<translation type="unfinished"></translation>
<translation>Данные:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="703"/>
<source>Maps:</source>
<translation type="unfinished"></translation>
<translation>Карты:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="704"/>
<source>POI:</source>
<translation type="unfinished"></translation>
<translation>POI:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="715"/>
<source>Initial paths</source>
<translation type="unfinished"></translation>
<translation>Начальные пути</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="733"/>

View File

@ -147,12 +147,12 @@
<message>
<location filename="../src/GUI/dirselectwidget.cpp" line="16"/>
<source>System default</source>
<translation type="unfinished"></translation>
<translation>Sistem öntanımlı değeri</translation>
</message>
<message>
<location filename="../src/GUI/dirselectwidget.cpp" line="38"/>
<source>Select directory</source>
<translation type="unfinished"></translation>
<translation>Dizin seç</translation>
</message>
</context>
<context>
@ -1085,7 +1085,7 @@
<message>
<location filename="../src/map/maplist.cpp" line="137"/>
<source>World-file georeferenced images</source>
<translation type="unfinished"></translation>
<translation>World-file coğrafi referanslı görüntüler</translation>
</message>
<message>
<location filename="../src/map/maplist.cpp" line="139"/>
@ -1138,12 +1138,12 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="56"/>
<source>Select the proper projection of maps without a projection definition (JNX, KMZ and world file maps).</source>
<translation type="unfinished"></translation>
<translation>İz düşümü tanımı olmayan haritaların uygun iz düşümünü seçin (JNX, KMZ ve world file haritaları).</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="58"/>
<source>Select the desired projection of vector maps (IMG and Mapsforge maps). The projection must be valid for the whole map area.</source>
<translation type="unfinished"></translation>
<translation>Vektör haritalarının (IMG ve Mapsforge haritaları) istenen iz düşümünü seçin. İz düşümü, tüm harita alanı için geçerli olmalıdır.</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="90"/>
@ -1613,27 +1613,27 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="694"/>
<source>Select the initial paths of the file open dialogues. Leave the field empty for the system default.</source>
<translation type="unfinished"></translation>
<translation>Dosya açma iletişim kutularının ilk yollarını seçin. Sistem öntanımlı değeri için alanı boş bırakın.</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="702"/>
<source>Data:</source>
<translation type="unfinished"></translation>
<translation>Veri:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="703"/>
<source>Maps:</source>
<translation type="unfinished"></translation>
<translation>Haritalar:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="704"/>
<source>POI:</source>
<translation type="unfinished"></translation>
<translation>POI:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="715"/>
<source>Initial paths</source>
<translation type="unfinished"></translation>
<translation>İlk yollar</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="733"/>

View File

@ -1620,17 +1620,17 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="702"/>
<source>Data:</source>
<translation type="unfinished"></translation>
<translation>Дані:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="703"/>
<source>Maps:</source>
<translation type="unfinished"></translation>
<translation>Мапи:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="704"/>
<source>POI:</source>
<translation type="unfinished"></translation>
<translation>POI:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="715"/>

View File

@ -9,7 +9,7 @@ Unicode true
; The name of the installer
Name "GPXSee"
; Program version
!define VERSION "9.3"
!define VERSION "9.4"
; The file to write
OutFile "GPXSee-${VERSION}.exe"

View File

@ -9,7 +9,7 @@ Unicode true
; The name of the installer
Name "GPXSee"
; Program version
!define VERSION "9.3"
!define VERSION "9.4"
; The file to write
OutFile "GPXSee-${VERSION}_x64.exe"

View File

@ -9,7 +9,7 @@
#include "areaitem.h"
QString AreaItem::info() const
ToolTip AreaItem::info() const
{
ToolTip tt;
@ -19,7 +19,7 @@ QString AreaItem::info() const
tt.insert(qApp->translate("PolygonItem", "Description"),
_area.description());
return tt.toString();
return tt;
}
AreaItem::AreaItem(const Area &area, Map *map, GraphicsItem *parent)

View File

@ -25,7 +25,7 @@ public:
void setStyle(Qt::PenStyle style);
void setDigitalZoom(int zoom);
QString info() const;
ToolTip info() const;
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);

View File

@ -9,7 +9,7 @@ CadenceGraphItem::CadenceGraphItem(const Graph &graph, GraphType type,
{
}
QString CadenceGraphItem::info() const
ToolTip CadenceGraphItem::info() const
{
ToolTip tt;
QLocale l(QLocale::system());
@ -19,5 +19,5 @@ QString CadenceGraphItem::info() const
tt.insert(tr("Average"), l.toString(avg(), 'f', 1)
+ UNIT_SPACE + tr("rpm"));
return tt.toString();
return tt;
}

View File

@ -11,7 +11,7 @@ public:
CadenceGraphItem(const Graph &graph, GraphType type, int width,
const QColor &color, QGraphicsItem *parent = 0);
QString info() const;
ToolTip info() const;
};
#endif // CADENCEGRAPHITEM_H

View File

@ -26,7 +26,7 @@ ElevationGraphItem::ElevationGraphItem(const Graph &graph, GraphType type,
}
}
QString ElevationGraphItem::info() const
ToolTip ElevationGraphItem::info() const
{
ToolTip tt;
qreal scale = (_units == Metric) ? 1.0 : M2FT;
@ -42,6 +42,5 @@ QString ElevationGraphItem::info() const
tt.insert(tr("Minimum"), l.toString(min() * scale, 'f', 0)
+ UNIT_SPACE + su);
return tt.toString();
return tt;
}

View File

@ -18,7 +18,7 @@ public:
qreal max() const {return _max;}
qreal min() const {return _min;}
QString info() const;
ToolTip info() const;
private:
qreal _ascent, _descent, _min, _max;

181
src/GUI/flowlayout.cpp Normal file
View File

@ -0,0 +1,181 @@
#include <QtWidgets>
#include "flowlayout.h"
struct FlowLayoutItem
{
FlowLayoutItem() : item(0) {}
FlowLayoutItem(QLayoutItem *item, int x, int y) : item(item), pos(x, y) {}
QLayoutItem *item;
QPoint pos;
};
FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing)
: QLayout(parent), _hSpace(hSpacing), _vSpace(vSpacing)
{
setContentsMargins(margin, margin, margin, margin);
}
FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing)
: _hSpace(hSpacing), _vSpace(vSpacing)
{
setContentsMargins(margin, margin, margin, margin);
}
FlowLayout::~FlowLayout()
{
qDeleteAll(_items);
}
void FlowLayout::addItem(QLayoutItem *item)
{
_items.append(item);
}
int FlowLayout::horizontalSpacing() const
{
return (_hSpace >= 0)
? _hSpace
: smartSpacing(QStyle::PM_LayoutHorizontalSpacing);
}
int FlowLayout::verticalSpacing() const
{
return (_vSpace >= 0)
? _vSpace
: smartSpacing(QStyle::PM_LayoutVerticalSpacing);
}
int FlowLayout::count() const
{
return _items.size();
}
QLayoutItem *FlowLayout::itemAt(int index) const
{
return _items.value(index);
}
QLayoutItem *FlowLayout::takeAt(int index)
{
if (index >= 0 && index < _items.size())
return _items.takeAt(index);
return 0;
}
Qt::Orientations FlowLayout::expandingDirections() const
{
return {};
}
bool FlowLayout::hasHeightForWidth() const
{
return true;
}
int FlowLayout::heightForWidth(int width) const
{
int height = doLayout(QRect(0, 0, width, 0), true);
return height;
}
void FlowLayout::setGeometry(const QRect &rect)
{
QLayout::setGeometry(rect);
doLayout(rect, false);
}
QSize FlowLayout::sizeHint() const
{
return minimumSize();
}
QSize FlowLayout::minimumSize() const
{
QSize size;
for (int i = 0; i < _items.size(); i++)
size = size.expandedTo(_items.at(i)->minimumSize());
const QMargins margins = contentsMargins();
size += QSize(margins.left() + margins.right(), margins.top()
+ margins.bottom());
return size;
}
int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
{
int left, top, right, bottom;
getContentsMargins(&left, &top, &right, &bottom);
QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom);
int x = effectiveRect.x();
int y = effectiveRect.y();
int lineHeight = 0;
QVector<QVector<FlowLayoutItem>> rows;
for (int i = 0; i < _items.size(); i++) {
QLayoutItem *item = _items.at(i);
const QWidget *wid = item->widget();
int spaceX = horizontalSpacing();
if (spaceX == -1)
spaceX = wid->style()->layoutSpacing(QSizePolicy::PushButton,
QSizePolicy::PushButton, Qt::Horizontal);
int spaceY = verticalSpacing();
if (spaceY == -1)
spaceY = wid->style()->layoutSpacing(QSizePolicy::PushButton,
QSizePolicy::PushButton, Qt::Vertical);
int nextX = x + item->sizeHint().width() + spaceX;
if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) {
x = effectiveRect.x();
y = y + lineHeight + spaceY;
nextX = x + item->sizeHint().width() + spaceX;
lineHeight = 0;
rows.append(QVector<FlowLayoutItem>());
}
if (rows.isEmpty())
rows.append(QVector<FlowLayoutItem>());
rows.last().append(FlowLayoutItem(item, x, y));
x = nextX;
lineHeight = qMax(lineHeight, item->sizeHint().height());
}
if (!testOnly) {
for (int i = 0; i < rows.size(); i++) {
const FlowLayoutItem &li = rows.at(i).last();
int width = li.item->sizeHint().width() + li.pos.x()
- effectiveRect.x();
int offset = (effectiveRect.width() - width) / 2;
int height = 0;
for (int j = 0; j < rows.at(i).size(); j++)
height = qMax(rows.at(i).at(j).item->sizeHint().height(), height);
for (int j = 0; j < rows.at(i).size(); j++) {
QLayoutItem *item = rows.at(i).at(j).item;
const QPoint &p = rows.at(i).at(j).pos;
QSize sh(item->sizeHint());
item->setGeometry(QRect(QPoint(p.x() + offset, p.y() + height
- sh.height()), sh));
}
}
}
return y + lineHeight - rect.y() + bottom;
}
int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
{
QObject *parent = this->parent();
if (!parent)
return -1;
else if (parent->isWidgetType()) {
QWidget *pw = static_cast<QWidget *>(parent);
return pw->style()->pixelMetric(pm, 0, pw);
} else
return static_cast<QLayout *>(parent)->spacing();
}

38
src/GUI/flowlayout.h Normal file
View File

@ -0,0 +1,38 @@
#ifndef FLOWLAYOUT_H
#define FLOWLAYOUT_H
#include <QLayout>
#include <QRect>
#include <QStyle>
class FlowLayout : public QLayout
{
public:
FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1,
int vSpacing = -1);
FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1);
~FlowLayout();
void addItem(QLayoutItem *item);
int horizontalSpacing() const;
int verticalSpacing() const;
Qt::Orientations expandingDirections() const;
bool hasHeightForWidth() const;
int heightForWidth(int) const;
int count() const;
QLayoutItem *itemAt(int index) const;
QSize minimumSize() const;
void setGeometry(const QRect &rect);
QSize sizeHint() const;
QLayoutItem *takeAt(int index);
private:
int doLayout(const QRect &rect, bool testOnly) const;
int smartSpacing(QStyle::PixelMetric pm) const;
QList<QLayoutItem *> _items;
int _hSpace;
int _vSpace;
};
#endif // FLOWLAYOUT_H

View File

@ -27,7 +27,7 @@ GearRatioGraphItem::GearRatioGraphItem(const Graph &graph, GraphType type,
_top = key;
}
QString GearRatioGraphItem::info() const
ToolTip GearRatioGraphItem::info() const
{
ToolTip tt;
QLocale l(QLocale::system());
@ -36,5 +36,5 @@ QString GearRatioGraphItem::info() const
tt.insert(tr("Maximum"), l.toString(max(), 'f', 2));
tt.insert(tr("Most used"), l.toString(top(), 'f', 2));
return tt.toString();
return tt;
}

View File

@ -15,7 +15,7 @@ public:
qreal top() const {return _top;}
const QMap<qreal, qreal> &map() const {return _map;}
QString info() const;
ToolTip info() const;
private:
QMap<qreal, qreal> _map;

View File

@ -3,13 +3,14 @@
#include <QGraphicsScene>
#include <QGraphicsItem>
#include "tooltip.h"
class GraphicsItem : public QGraphicsItem
{
public:
GraphicsItem(QGraphicsItem *parent = 0) : QGraphicsItem(parent) {}
virtual QString info() const = 0;
virtual ToolTip info() const = 0;
int type() const {return QGraphicsItem::UserType + 1;}
};

View File

@ -16,7 +16,7 @@ public:
const QColor &color, Qt::PenStyle style, QGraphicsItem *parent = 0);
virtual ~GraphItem() {}
virtual QString info() const = 0;
virtual ToolTip info() const = 0;
QPainterPath shape() const {return _shape;}
QRectF boundingRect() const {return _shape.boundingRect();}

View File

@ -9,7 +9,7 @@ HeartRateGraphItem::HeartRateGraphItem(const Graph &graph, GraphType type,
{
}
QString HeartRateGraphItem::info() const
ToolTip HeartRateGraphItem::info() const
{
ToolTip tt;
QLocale l(QLocale::system());
@ -19,5 +19,5 @@ QString HeartRateGraphItem::info() const
tt.insert(tr("Average"), l.toString(avg(), 'f', 0)
+ UNIT_SPACE + tr("bpm"));
return tt.toString();
return tt;
}

View File

@ -11,7 +11,7 @@ public:
HeartRateGraphItem(const Graph &graph, GraphType type, int width,
const QColor &color, QGraphicsItem *parent = 0);
QString info() const;
ToolTip info() const;
};
#endif // HEARTRATEGRAPHITEM_H

View File

@ -56,17 +56,25 @@ void InfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
//painter->drawRect(boundingRect());
}
int InfoItem::indexOf(const QString &key) const
{
for (int i = 0; i < _list.size(); i++)
if (_list.at(i).key() == key)
return i;
return -1;
}
void InfoItem::insert(const QString &key, const QString &value)
{
KV<QString, QString> kv(key, value);
int i;
prepareGeometryChange();
if ((i = _list.indexOf(kv)) < 0)
_list.append(kv);
if ((i = indexOf(key)) < 0)
_list.append(KV<QString, QString>(key, value));
else
_list[i] = kv;
_list[i] = KV<QString, QString>(key, value);
updateBoundingRect();
update();

View File

@ -22,6 +22,7 @@ public:
private:
void updateBoundingRect();
int indexOf(const QString &key) const;
QList<KV<QString, QString> > _list;
QRectF _boundingRect;

View File

@ -69,7 +69,7 @@ static QRectF bbox(const RectC &rect, Map *map, int samples = 100)
return prect;
}
QString MapItem::info() const
ToolTip MapItem::info() const
{
ToolTip tt;
@ -78,7 +78,7 @@ QString MapItem::info() const
if (!_fileName.isEmpty())
tt.insert(tr("File"), _fileName);
return tt.toString();
return tt;
}
MapItem::MapItem(MapAction *action, Map *map, GraphicsItem *parent)

View File

@ -26,7 +26,7 @@ public:
void setStyle(Qt::PenStyle style);
void setDigitalZoom(int zoom);
QString info() const;
ToolTip info() const;
signals:
void triggered();

View File

@ -19,7 +19,10 @@ public:
void setDigitalZoom(int zoom) {setScale(pow(2, -zoom));}
int type() const {return parentItem()->type();}
QString info() const {return static_cast<GraphicsItem*>(parentItem())->info();}
ToolTip info() const
{
return static_cast<GraphicsItem*>(parentItem())->info();
}
static QRect tickRect(int value);

View File

@ -6,25 +6,31 @@
#include <QMouseEvent>
#include <QBasicTimer>
#include <QScreen>
#include <QVBoxLayout>
#include <QApplication>
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
#include <QDesktopWidget>
#endif // QT 5.15
#include "tooltip.h"
#include "thumbnail.h"
#include "flowlayout.h"
#include "popup.h"
class PopupLabel : public QLabel
class PopupFrame : public QFrame
{
public:
PopupLabel(const QString &text, QWidget *parent = 0);
~PopupLabel();
PopupFrame(const ToolTip &toolTip, QWidget *parent = 0);
~PopupFrame();
const ToolTip &toolTip() const {return _toolTip;}
bool eventFilter(QObject *o, QEvent *ev);
void place(const QPoint &pos, QWidget *w);
void deleteAfterTimer();
void stopTimer() {_timer.stop();}
static PopupLabel *_instance;
static PopupFrame *_instance;
protected:
void paintEvent(QPaintEvent *event);
@ -32,14 +38,17 @@ protected:
void contextMenuEvent(QContextMenuEvent *) {}
private:
void createLayout(const ToolTip &content);
QBasicTimer _timer;
ToolTip _toolTip;
};
PopupLabel *PopupLabel::_instance = 0;
PopupFrame *PopupFrame::_instance = 0;
PopupLabel::PopupLabel(const QString &text, QWidget *parent)
: QLabel(text, parent, Qt::ToolTip | Qt::BypassGraphicsProxyWidget
| Qt::WindowDoesNotAcceptFocus)
PopupFrame::PopupFrame(const ToolTip &toolTip, QWidget *parent)
: QFrame(parent, Qt::ToolTip | Qt::BypassGraphicsProxyWidget
| Qt::WindowDoesNotAcceptFocus), _toolTip(toolTip)
{
delete _instance;
_instance = this;
@ -48,39 +57,73 @@ PopupLabel::PopupLabel(const QString &text, QWidget *parent)
setBackgroundRole(QPalette::ToolTipBase);
setPalette(QToolTip::palette());
ensurePolished();
setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0,
this));
setFrameStyle(QFrame::NoFrame);
setAlignment(Qt::AlignLeft);
setIndent(1);
setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0,
this) / 255.0);
setTextInteractionFlags(Qt::TextBrowserInteraction);
setOpenExternalLinks(true);
setWordWrap(true);
createLayout(toolTip);
setMouseTracking(true);
qApp->installEventFilter(this);
}
PopupLabel::~PopupLabel()
PopupFrame::~PopupFrame()
{
_instance = 0;
}
void PopupLabel::paintEvent(QPaintEvent *event)
void PopupFrame::createLayout(const ToolTip &content)
{
QVBoxLayout *layout = new QVBoxLayout();
int margin = 1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0,
this);
layout->setContentsMargins(margin, margin, margin, margin);
layout->setSpacing(0);
if (!content.images().isEmpty()) {
FlowLayout *imagesLayout = new FlowLayout(0, 2, 2);
int size = qMin(960/content.images().size(), 240);
for (int i = 0; i < content.images().size(); i++)
imagesLayout->addWidget(new Thumbnail(content.images().at(i), size));
layout->addLayout(imagesLayout);
}
if (!content.list().isEmpty()) {
QString html = "<table>";
for (int i = 0; i < content.list().count(); i++)
html += "<tr><td align=\"right\"><b>" + content.list().at(i).key()
+ ":&nbsp;</b></td><td>" + content.list().at(i).value()
+ "</td></tr>";
html += "</table>";
QLabel *label = new QLabel(html);
label->setAlignment(Qt::AlignLeft);
label->setIndent(1);
label->setTextInteractionFlags(Qt::TextBrowserInteraction);
label->setOpenExternalLinks(true);
label->setWordWrap(true);
layout->addWidget(label);
}
setLayout(layout);
}
void PopupFrame::paintEvent(QPaintEvent *event)
{
QStylePainter p(this);
QStyleOptionFrame opt;
opt.initFrom(this);
p.drawPrimitive(QStyle::PE_PanelTipLabel, opt);
p.end();
QLabel::paintEvent(event);
QFrame::paintEvent(event);
}
void PopupLabel::timerEvent(QTimerEvent *event)
void PopupFrame::timerEvent(QTimerEvent *event)
{
if (event->timerId() == _timer.timerId()) {
_timer.stop();
@ -88,7 +131,7 @@ void PopupLabel::timerEvent(QTimerEvent *event)
}
}
bool PopupLabel::eventFilter(QObject *o, QEvent *ev)
bool PopupFrame::eventFilter(QObject *o, QEvent *ev)
{
Q_UNUSED(o);
@ -123,7 +166,7 @@ bool PopupLabel::eventFilter(QObject *o, QEvent *ev)
return false;
}
void PopupLabel::place(const QPoint &pos, QWidget *w)
void PopupFrame::place(const QPoint &pos, QWidget *w)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QRect screen = QApplication::desktop()->screenGeometry(w);
@ -148,31 +191,34 @@ void PopupLabel::place(const QPoint &pos, QWidget *w)
this->move(p);
}
void PopupLabel::deleteAfterTimer()
void PopupFrame::deleteAfterTimer()
{
if (!_timer.isActive())
_timer.start(300, this);
}
void Popup::show(const QPoint &pos, const QString &text, QWidget *w)
void Popup::show(const QPoint &pos, const ToolTip &toolTip, QWidget *w)
{
if (text.isEmpty())
if (toolTip.isEmpty())
return;
if (PopupLabel::_instance) {
PopupLabel::_instance->stopTimer();
PopupLabel::_instance->setText(text);
if (PopupFrame::_instance) {
if (toolTip == PopupFrame::_instance->toolTip())
PopupFrame::_instance->stopTimer();
else {
delete PopupFrame::_instance;
PopupFrame::_instance = new PopupFrame(toolTip);
}
} else
PopupLabel::_instance = new PopupLabel(text);
PopupFrame::_instance = new PopupFrame(toolTip);
PopupLabel::_instance->resize(PopupLabel::_instance->sizeHint());
PopupLabel::_instance->place(pos, w);
PopupLabel::_instance->showNormal();
PopupFrame::_instance->resize(PopupFrame::_instance->sizeHint());
PopupFrame::_instance->place(pos, w);
PopupFrame::_instance->showNormal();
}
void Popup::clear()
{
if (PopupLabel::_instance)
delete PopupLabel::_instance;
if (PopupFrame::_instance)
delete PopupFrame::_instance;
}

View File

@ -2,13 +2,13 @@
#define POPUP_H
class QPoint;
class QString;
class QWidget;
class ToolTip;
class Popup
{
public:
static void show(const QPoint &pos, const QString &text, QWidget *w);
static void show(const QPoint &pos, const ToolTip &toolTip, QWidget *w);
static void clear();
};

View File

@ -9,7 +9,7 @@ PowerGraphItem::PowerGraphItem(const Graph &graph, GraphType type, int width,
{
}
QString PowerGraphItem::info() const
ToolTip PowerGraphItem::info() const
{
ToolTip tt;
QLocale l(QLocale::system());
@ -19,5 +19,5 @@ QString PowerGraphItem::info() const
tt.insert(tr("Average"), l.toString(avg(), 'f', 1)
+ UNIT_SPACE + tr("W"));
return tt.toString();
return tt;
}

View File

@ -11,7 +11,7 @@ public:
PowerGraphItem(const Graph &graph, GraphType type, int width,
const QColor &color, QGraphicsItem *parent = 0);
QString info() const;
ToolTip info() const;
};
#endif // POWERGRAPHITEM_H

View File

@ -8,7 +8,7 @@
#include "routeitem.h"
QString RouteItem::info() const
ToolTip RouteItem::info() const
{
ToolTip tt;
@ -32,7 +32,7 @@ QString RouteItem::info() const
tt.insert(tr("Links"), links);
}
return tt.toString();
return tt;
}
RouteItem::RouteItem(const Route &route, Map *map, QGraphicsItem *parent)

View File

@ -21,7 +21,7 @@ public:
void showWaypoints(bool show);
void showWaypointLabels(bool show);
QString info() const;
ToolTip info() const;
QDateTime date() const {return QDateTime();}
private:

View File

@ -15,7 +15,7 @@ SpeedGraphItem::SpeedGraphItem(const Graph &graph, GraphType type, int width,
_mavg = graph.last().last().s() / movingTime;
}
QString SpeedGraphItem::info() const
ToolTip SpeedGraphItem::info() const
{
ToolTip tt;
qreal scale = (_units == Imperial) ? MS2MIH : (_units == Nautical)
@ -34,7 +34,7 @@ QString SpeedGraphItem::info() const
? avg() * scale : mavg() * scale, 'f', 1) + UNIT_SPACE + su);
tt.insert(tr("Pace"), pace + UNIT_SPACE + pu);
return tt.toString();
return tt;
}
void SpeedGraphItem::setTimeType(TimeType type)

View File

@ -17,7 +17,7 @@ public:
qreal mavg() const {return _mavg;}
qreal max() const {return _max;}
QString info() const;
ToolTip info() const;
void setTimeType(TimeType type);

View File

@ -12,7 +12,7 @@ TemperatureGraphItem::TemperatureGraphItem(const Graph &graph, GraphType type,
_avg = GraphItem::avg();
}
QString TemperatureGraphItem::info() const
ToolTip TemperatureGraphItem::info() const
{
ToolTip tt;
qreal scale = (_units == Metric) ? 1.0 : C2FS;
@ -28,5 +28,5 @@ QString TemperatureGraphItem::info() const
tt.insert(tr("Minimum"), l.toString(min() * scale + offset, 'f', 1)
+ UNIT_SPACE + su);
return tt.toString();
return tt;
}

View File

@ -15,7 +15,7 @@ public:
qreal min() const {return _min;}
qreal avg() const {return _avg;}
QString info() const;
ToolTip info() const;
private:
qreal _min, _max, _avg;

43
src/GUI/thumbnail.cpp Normal file
View File

@ -0,0 +1,43 @@
#include <QImageReader>
#include <QDesktopServices>
#include <QFileInfo>
#include <QMouseEvent>
#include "data/imageinfo.h"
#include "thumbnail.h"
static QSize thumbnailSize(const ImageInfo &img, int limit)
{
int width, height;
if (img.size().width() > img.size().height()) {
width = qMin(img.size().width(), limit);
qreal ratio = img.size().width() / (qreal)img.size().height();
height = (int)(width / ratio);
} else {
height = qMin(img.size().height(), limit);
qreal ratio = img.size().height() / (qreal)img.size().width();
width = (int)(height / ratio);
}
return QSize(width, height);
}
Thumbnail::Thumbnail(const ImageInfo &img, int size, QWidget *parent)
: QLabel(parent)
{
QImageReader reader(img.path());
reader.setAutoTransform(true);
reader.setScaledSize(thumbnailSize(img, size));
setPixmap(QPixmap::fromImage(reader.read()));
setCursor(Qt::PointingHandCursor);
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
_path = QFileInfo(img.path()).absoluteFilePath();
}
void Thumbnail::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
QDesktopServices::openUrl(QUrl::fromLocalFile(_path));
}

20
src/GUI/thumbnail.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef THUMBNAIL_H
#define THUMBNAIL_H
#include <QLabel>
class ImageInfo;
class Thumbnail : public QLabel
{
public:
Thumbnail(const ImageInfo &img, int size, QWidget *parent = 0);
protected:
void mousePressEvent(QMouseEvent *event);
private:
QString _path;
};
#endif // THUMBNAIL_H

View File

@ -1,52 +0,0 @@
#include "popup.h"
#include "tooltip.h"
static QSize thumbnailSize(const ImageInfo &img, int limit)
{
int width, height;
if (img.size().width() > img.size().height()) {
width = qMin(img.size().width(), limit);
qreal ratio = img.size().width() / (qreal)img.size().height();
height = (int)(width / ratio);
} else {
height = qMin(img.size().height(), limit);
qreal ratio = img.size().height() / (qreal)img.size().width();
width = (int)(height / ratio);
}
return QSize(width, height);
}
void ToolTip::insert(const QString &key, const QString &value)
{
_list.append(KV<QString, QString>(key, value));
}
QString ToolTip::toString() const
{
QString html;
if (_images.size()) {
html = "<div align=\"center\">";
for (int i = 0; i < _images.size(); i++) {
const ImageInfo &img = _images.at(i);
QSize size(thumbnailSize(img, qMin(960/_images.size(), 240)));
html += QString("<a href=\"file:%0\">"
"<img src=\"%0\" width=\"%1\" height=\"%2\"/></a>")
.arg(img.path(), QString::number(size.width()),
QString::number(size.height()));
}
html += "</div>";
}
if (!_list.isEmpty()) {
html += "<table>";
for (int i = 0; i < _list.count(); i++)
html += "<tr><td align=\"right\"><b>" + _list.at(i).key()
+ ":&nbsp;</b></td><td>" + _list.at(i).value() + "</td></tr>";
html += "</table>";
}
return html;
}

View File

@ -10,9 +10,31 @@
class ToolTip
{
public:
void insert(const QString &key, const QString &value);
void setImages(const QVector<ImageInfo> &images) {_images = images;}
QString toString() const;
const QList<KV<QString, QString> > &list() const {return _list;}
const QVector<ImageInfo> &images() const {return _images;}
bool isEmpty() const
{
return _list.isEmpty() && _images.isEmpty();
}
bool operator==(const ToolTip &other) const
{
return (_list == other._list && _images == other._images);
}
bool operator!=(const ToolTip &other) const
{
return (_list != other._list || _images != other._images);
}
void insert(const QString &key, const QString &value)
{
_list.append(KV<QString, QString>(key, value));
}
void setImages(const QVector<ImageInfo> &images)
{
_images = images;
}
private:
QList<KV<QString, QString> > _list;

View File

@ -6,7 +6,7 @@
#include "trackitem.h"
QString TrackItem::info() const
ToolTip TrackItem::info() const
{
ToolTip tt;
QLocale l;
@ -37,7 +37,7 @@ QString TrackItem::info() const
tt.insert(tr("Links"), links);
}
return tt.toString();
return tt;
}
TrackItem::TrackItem(const Track &track, Map *map, QGraphicsItem *parent)

View File

@ -15,7 +15,7 @@ class TrackItem : public PathItem
public:
TrackItem(const Track &track, Map *map, QGraphicsItem *parent = 0);
QString info() const;
ToolTip info() const;
QDateTime date() const {return _date;}
private:

View File

@ -3,7 +3,6 @@
#include <QGraphicsSceneMouseEvent>
#include <QLabel>
#include "font.h"
#include "tooltip.h"
#include "popup.h"
#include "waypointitem.h"
@ -18,7 +17,7 @@ Units WaypointItem::_units = Metric;
CoordinatesFormat WaypointItem::_format = DecimalDegrees;
QTimeZone WaypointItem::_timeZone = QTimeZone::utc();
QString WaypointItem::info() const
ToolTip WaypointItem::info() const
{
ToolTip tt;
QLocale l;
@ -66,7 +65,7 @@ QString WaypointItem::info() const
}
tt.setImages(_waypoint.images());
return tt.toString();
return tt;
}
WaypointItem::WaypointItem(const Waypoint &waypoint, Map *map,

View File

@ -30,7 +30,7 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
QString info() const;
ToolTip info() const;
static void setUnits(Units units) {_units = units;}
static void setCoordinatesFormat(CoordinatesFormat format)

View File

@ -9,8 +9,19 @@ public:
const KEY &key() const {return _key;}
const VALUE &value() const {return _value;}
bool operator==(const KV &other) const {return _key == other._key;}
bool operator<(const KV &other) const {return _key < other._key;}
bool operator==(const KV &other) const
{
return (_key == other._key && _value == other._value);
}
bool operator<(const KV &other) const
{
if (_key < other._key)
return true;
else if (_key > other._key)
return false;
else
return _value < other._value;
}
private:
KEY _key;

View File

@ -16,6 +16,11 @@ public:
bool isValid() const {return _size.isValid() && !_path.isEmpty();}
bool operator==(const ImageInfo &other) const
{
return (_path == other._path);
}
private:
QString _path;
QSize _size;

View File

@ -411,9 +411,9 @@ void NETFile::clear()
}
bool NETFile::link(const SubDiv *subdiv, quint32 shift, Handle &hdl,
const NODFile *nod, Handle &nodHdl, const LBLFile *lbl, Handle &lblHdl,
const NODFile::BlockInfo &blockInfo, quint8 linkId, quint8 lineId,
QList<MapData::Poly> *lines) const
const NODFile *nod, Handle &nodHdl2, Handle &nodHdl, const LBLFile *lbl,
Handle &lblHdl, const NODFile::BlockInfo &blockInfo, quint8 linkId,
quint8 lineId, QList<MapData::Poly> *lines) const
{
MapData::Poly poly;
if (!nod->linkType(nodHdl, blockInfo, linkId, poly.type))
@ -433,24 +433,24 @@ bool NETFile::link(const SubDiv *subdiv, quint32 shift, Handle &hdl,
quint16 mask = 0;
quint32 size;
quint8 s68 = (linkInfo.flags >> 0x12) & 1;
quint8 s69 = (linkInfo.flags >> 0x11) & 1;
quint8 s6a = (linkInfo.flags >> 0x13) & 1;
bool firstIsShape = (linkInfo.flags >> 0x12) & 1;
bool singleTopology = (linkInfo.flags >> 0x11) & 1;
bool hasLevels = (linkInfo.flags >> 0x13) & 1;
if (s69 == 0 || s6a == 1) {
if (!singleTopology || hasLevels) {
if (!bs.readVUInt32(size))
return false;
}
if (s69 == 0) {
if (!singleTopology) {
if (!readAdjCounts(bs, ca, mask))
return false;
}
if (!subdiv->level()) {
NODFile::AdjacencyInfo adj(nod, blockInfo, linkId, linkInfo);
NODFile::AdjacencyInfo adj(nodHdl2, blockInfo, linkId, linkInfo);
if (s69 == 1) {
if (s68 == 1) {
if (singleTopology) {
if (firstIsShape) {
if (!readShape(nod, nodHdl, adj, bs, _tp, subdiv, shift, poly))
return false;
} else {
@ -461,7 +461,7 @@ bool NETFile::link(const SubDiv *subdiv, quint32 shift, Handle &hdl,
quint16 mask2 = mask + 0xffff;
for (int i = 0; i <= ca.size(); i++) {
quint16 step = (i < ca.size()) ? ca.at(i) & mask2 : 0xFFFF;
bool shape = (i > 0) ? ca.at(i-1) & mask : (s68 == 1);
bool shape = (i > 0) ? ca.at(i-1) & mask : firstIsShape;
if (i == lineId) {
if (shape) {
bool check = (i < ca.size()) ? (ca.at(i) & mask) : false;
@ -482,7 +482,9 @@ bool NETFile::link(const SubDiv *subdiv, quint32 shift, Handle &hdl,
}
}
} else {
if (!skipAdjShapes(bs, ca, mask, s68 == 1))
Q_ASSERT(hasLevels);
if (!skipAdjShapes(bs, ca, mask, firstIsShape))
return false;
if (!seekToLevel(bs, subdiv->level()))

View File

@ -30,9 +30,10 @@ public:
bool lblOffset(Handle &hdl, quint32 netOffset, quint32 &lblOffset) const;
bool link(const SubDiv *subdiv, quint32 shift, Handle &hdl,
const NODFile *nod, Handle &nodHdl, const LBLFile *lbl, Handle &lblHdl,
const NODFile::BlockInfo &blockInfo, quint8 linkId, quint8 lineId,
QList<MapData::Poly> *lines) const;
const NODFile *nod, Handle &nodHdl2, Handle &nodHdl, const LBLFile *lbl,
Handle &lblHdl, const NODFile::BlockInfo &blockInfo, quint8 linkId,
quint8 lineId, QList<MapData::Poly> *lines) const;
bool hasLinks() const {return (_linksSize > 0);}
private:
bool linkLabel(Handle &hdl, quint32 offset, quint32 size,

View File

@ -40,13 +40,13 @@ public:
struct AdjacencyInfo
{
AdjacencyInfo(const SubFile *file, const BlockInfo &blockInfo,
quint32 linkId, const LinkInfo &linkInfo) : extHdl(file),
AdjacencyInfo(Handle &hdl, const BlockInfo &blockInfo,
quint32 linkId, const LinkInfo &linkInfo) : extHdl(hdl),
blockInfo(blockInfo), nodeOffset(linkInfo.nodeOffset),
linkOffset(linkInfo.linkOffset), linkId(linkId)
{}
Handle extHdl;
Handle &extHdl;
BlockInfo blockInfo;
NodeInfo nodeInfo;
quint32 nodeOffset;

View File

@ -1,5 +1,6 @@
#include <QFont>
#include <QPainter>
#include <QCache>
#include "map/imgmap.h"
#include "map/textpathitem.h"
#include "map/textpointitem.h"
@ -195,6 +196,8 @@ void RasterTile::ll2xy(QList<MapData::Point> &points)
void RasterTile::drawPolygons(QPainter *painter)
{
QCache<const LBLFile *, SubFile::Handle> hc(16);
for (int n = 0; n < _style->drawOrder().size(); n++) {
for (int i = 0; i < _polygons.size(); i++) {
const MapData::Poly &poly = _polygons.at(i);
@ -207,8 +210,15 @@ void RasterTile::drawPolygons(QPainter *painter)
QPointF br(_map->ll2xy(r.bottomRight()));
QSizeF size(QRectF(tl, br).size());
SubFile::Handle hdl(poly.raster.lbl());
QPixmap pm(poly.raster.lbl()->image(hdl, poly.raster.id()));
bool insert = false;
SubFile::Handle *hdl = hc.object(poly.raster.lbl());
if (!hdl) {
hdl = new SubFile::Handle(poly.raster.lbl());
insert = true;
}
QPixmap pm(poly.raster.lbl()->image(*hdl, poly.raster.id()));
if (insert)
hc.insert(poly.raster.lbl(), hdl);
qreal sx = size.width() / (qreal)pm.width();
qreal sy = size.height() / (qreal)pm.height();

View File

@ -456,7 +456,8 @@ bool RGNFile::extPointObjects(Handle &hdl, const SubDiv *subdiv,
bool RGNFile::links(Handle &hdl, const SubDiv *subdiv, quint32 shift,
const NETFile *net, Handle &netHdl, const NODFile *nod, Handle &nodHdl,
const LBLFile *lbl, Handle &lblHdl, QList<MapData::Poly> *lines) const
Handle &nodHdl2, const LBLFile *lbl, Handle &lblHdl,
QList<MapData::Poly> *lines) const
{
quint32 size, blockIndexId;
quint8 flags;
@ -522,7 +523,7 @@ bool RGNFile::links(Handle &hdl, const SubDiv *subdiv, quint32 shift,
lineId = 0;
}
net->link(subdiv, shift, netHdl, nod, nodHdl, lbl, lblHdl,
net->link(subdiv, shift, netHdl, nod, nodHdl, nodHdl2, lbl, lblHdl,
blockInfo, linkId, lineId, lines);
}

View File

@ -51,7 +51,8 @@ public:
Handle &lblHdl, QList<MapData::Point> *points) const;
bool links(Handle &hdl, const SubDiv *subdiv, quint32 shift,
const NETFile *net, Handle &netHdl, const NODFile *nod, Handle &nodHdl,
const LBLFile *lbl, Handle &lblHdl, QList<MapData::Poly> *lines) const;
Handle &nodHdl2, const LBLFile *lbl, Handle &lblHdl,
QList<MapData::Poly> *lines) const;
bool subdivInit(Handle &hdl, SubDiv *subdiv) const;

View File

@ -24,14 +24,8 @@ public:
if (!subFile)
return;
if (subFile->_path) {
_file.setFileName(*(subFile->_path));
_data.resize(1U<<BLOCK_BITS);
} else {
_file.setFileName(subFile->_img->fileName());
_data.resize(1U<<subFile->_img->blockBits());
}
_data.resize(1U<<subFile->blockBits());
_file.setFileName(subFile->fileName());
_file.open(QIODevice::ReadOnly);
}
@ -149,7 +143,8 @@ public:
bool readVUInt32(Handle &hdl, quint32 bytes, quint32 &val) const;
bool readVBitfield32(Handle &hdl, quint32 &bitfield) const;
QString fileName() const {return _path ? *_path : _img->fileName();}
const QString &fileName() const {return _path ? *_path : _img->fileName();}
unsigned blockBits() const {return _path ? BLOCK_BITS : _img->blockBits();}
protected:
quint32 _gmpOffset;

View File

@ -104,10 +104,22 @@ void VectorTile::polys(const RectC &rect, int bits, bool baseMap,
QList<MapData::Poly> *polygons, QList<MapData::Poly> *lines,
QCache<const SubDiv *, MapData::Polys> *polyCache)
{
SubFile::Handle rgnHdl(_rgn), lblHdl(_lbl), netHdl(_net), nodHdl(_nod);
SubFile::Handle *rgnHdl = 0, *lblHdl = 0, *netHdl = 0, *nodHdl = 0,
*nodHdl2 = 0;
if (_loaded < 0 || (!_loaded && !load(rgnHdl, lblHdl, netHdl, nodHdl)))
if (_loaded < 0)
return;
if (!_loaded) {
rgnHdl = new SubFile::Handle(_rgn);
lblHdl = new SubFile::Handle(_lbl);
netHdl = new SubFile::Handle(_net);
nodHdl = new SubFile::Handle(_nod);
if (!load(*rgnHdl, *lblHdl, *netHdl, *nodHdl)) {
delete rgnHdl; delete lblHdl; delete netHdl; delete nodHdl;
return;
}
}
QList<SubDiv*> subdivs = _tre->subdivs(rect, bits, baseMap);
for (int i = 0; i < subdivs.size(); i++) {
@ -118,19 +130,32 @@ void VectorTile::polys(const RectC &rect, int bits, bool baseMap,
quint32 shift = _tre->shift(subdiv->bits());
QList<MapData::Poly> p, l;
if (!subdiv->initialized() && !_rgn->subdivInit(rgnHdl, subdiv))
if (!rgnHdl) {
rgnHdl = new SubFile::Handle(_rgn);
lblHdl = new SubFile::Handle(_lbl);
netHdl = new SubFile::Handle(_net);
}
if (!subdiv->initialized() && !_rgn->subdivInit(*rgnHdl, subdiv))
continue;
_rgn->polyObjects(rgnHdl, subdiv, RGNFile::Polygon, _lbl, lblHdl,
_net, netHdl, &p);
_rgn->polyObjects(rgnHdl, subdiv, RGNFile::Line, _lbl, lblHdl,
_net, netHdl, &l);
_rgn->extPolyObjects(rgnHdl, subdiv, shift, RGNFile::Polygon, _lbl,
lblHdl, &p);
_rgn->extPolyObjects(rgnHdl, subdiv, shift, RGNFile::Line, _lbl,
lblHdl, &l);
_rgn->links(rgnHdl, subdiv, shift, _net, netHdl, _nod, nodHdl, _lbl,
lblHdl, &l);
_rgn->polyObjects(*rgnHdl, subdiv, RGNFile::Polygon, _lbl, *lblHdl,
_net, *netHdl, &p);
_rgn->polyObjects(*rgnHdl, subdiv, RGNFile::Line, _lbl, *lblHdl,
_net, *netHdl, &l);
_rgn->extPolyObjects(*rgnHdl, subdiv, shift, RGNFile::Polygon, _lbl,
*lblHdl, &p);
_rgn->extPolyObjects(*rgnHdl, subdiv, shift, RGNFile::Line, _lbl,
*lblHdl, &l);
if (_net && _net->hasLinks()) {
if (!nodHdl)
nodHdl = new SubFile::Handle(_nod);
if (!nodHdl2)
nodHdl2 = new SubFile::Handle(_nod);
_rgn->links(*rgnHdl, subdiv, shift, _net, *netHdl, _nod, *nodHdl,
*nodHdl2, _lbl, *lblHdl, &l);
}
copyPolys(rect, &p, polygons);
copyPolys(rect, &l, lines);
@ -140,16 +165,29 @@ void VectorTile::polys(const RectC &rect, int bits, bool baseMap,
copyPolys(rect, &(polys->lines), lines);
}
}
delete rgnHdl; delete lblHdl; delete netHdl; delete nodHdl; delete nodHdl2;
}
void VectorTile::points(const RectC &rect, int bits, bool baseMap,
QList<MapData::Point> *points, QCache<const SubDiv *,
QList<MapData::Point> > *pointCache)
{
SubFile::Handle rgnHdl(_rgn), lblHdl(_lbl), netHdl(_net), nodHdl(_nod);
SubFile::Handle *rgnHdl = 0, *lblHdl = 0;
if (_loaded < 0 || (!_loaded && !load(rgnHdl, lblHdl, netHdl, nodHdl)))
if (_loaded < 0)
return;
if (!_loaded) {
rgnHdl = new SubFile::Handle(_rgn);
lblHdl = new SubFile::Handle(_lbl);
SubFile::Handle nodHdl(_nod);
SubFile::Handle netHdl(_net);
if (!load(*rgnHdl, *lblHdl, netHdl, nodHdl)) {
delete rgnHdl; delete lblHdl;
return;
}
}
QList<SubDiv*> subdivs = _tre->subdivs(rect, bits, baseMap);
for (int i = 0; i < subdivs.size(); i++) {
@ -159,20 +197,27 @@ void VectorTile::points(const RectC &rect, int bits, bool baseMap,
if (!pl) {
QList<MapData::Point> p;
if (!subdiv->initialized() && !_rgn->subdivInit(rgnHdl, subdiv))
if (!rgnHdl) {
rgnHdl = new SubFile::Handle(_rgn);
lblHdl = new SubFile::Handle(_lbl);
}
if (!subdiv->initialized() && !_rgn->subdivInit(*rgnHdl, subdiv))
continue;
_rgn->pointObjects(rgnHdl, subdiv, RGNFile::Point, _lbl, lblHdl,
_rgn->pointObjects(*rgnHdl, subdiv, RGNFile::Point, _lbl, *lblHdl,
&p);
_rgn->pointObjects(rgnHdl, subdiv, RGNFile::IndexedPoint, _lbl,
lblHdl, &p);
_rgn->extPointObjects(rgnHdl, subdiv, _lbl, lblHdl, &p);
_rgn->pointObjects(*rgnHdl, subdiv, RGNFile::IndexedPoint, _lbl,
*lblHdl, &p);
_rgn->extPointObjects(*rgnHdl, subdiv, _lbl, *lblHdl, &p);
copyPoints(rect, &p, points);
pointCache->insert(subdiv, new QList<MapData::Point>(p));
} else
copyPoints(rect, pl, points);
}
delete rgnHdl; delete lblHdl;
}
#ifndef QT_NO_DEBUG

View File

@ -146,7 +146,7 @@ void RasterTile::processAreaLabels(QList<TextItem*> &textItems)
const Style::TextRender *ti = 0;
const Style::Symbol *si = 0;
if (!path.closed || !path.path.elementCount())
if (!path.closed)
continue;
for (int j = 0; j < labels.size(); j++) {
@ -170,6 +170,9 @@ void RasterTile::processAreaLabels(QList<TextItem*> &textItems)
if (!ti && !si)
continue;
if (!path.path.elementCount())
path.path = painterPath(path.poly);
const QImage *img = si ? &si->img() : 0;
const QFont *font = ti ? &ti->font() : 0;
const QColor *color = ti ? &ti->fillColor() : 0;

View File

@ -60,7 +60,7 @@ public:
QList<QByteArray> vc(vals);
if (vc.removeAll("~"))
_neg = true;
_vals = list(vals);
_vals = list(vc);
}
bool match(const QVector<MapData::Tag> &tags) const