mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-27 11:39:16 +02:00
Added support for thumbnail images in waypoint info
+ fixed and improved exif parser
This commit is contained in:
@ -1,5 +1,9 @@
|
||||
#include <QImageReader>
|
||||
#include "tooltip.h"
|
||||
|
||||
|
||||
#define THUMBNAIL_MAX_SIZE 240
|
||||
|
||||
void ToolTip::insert(const QString &key, const QString &value)
|
||||
{
|
||||
_list.append(KV(key, value));
|
||||
@ -7,16 +11,39 @@ void ToolTip::insert(const QString &key, const QString &value)
|
||||
|
||||
QString ToolTip::toString()
|
||||
{
|
||||
if (_list.isEmpty())
|
||||
return QString();
|
||||
QString html;
|
||||
|
||||
QString ret = "<table>";
|
||||
if (!_img.isNull()) {
|
||||
QImageReader r(_img);
|
||||
QSize size(r.size());
|
||||
|
||||
for (int i = 0; i < _list.count(); i++)
|
||||
ret += "<tr><td align=\"right\"><b>" + _list.at(i).key()
|
||||
+ ": </b></td><td>" + _list.at(i).value() + "</td></tr>";
|
||||
if (size.isValid()) {
|
||||
int width, height;
|
||||
|
||||
ret += "</table>";
|
||||
if (size.width() > size.height()) {
|
||||
width = qMin(size.width(), THUMBNAIL_MAX_SIZE);
|
||||
qreal ratio = (qreal)size.width() / (qreal)size.height();
|
||||
height = (int)(width / ratio);
|
||||
} else {
|
||||
height = qMin(size.height(), THUMBNAIL_MAX_SIZE);
|
||||
qreal ratio = (qreal)size.height() / (qreal)size.width();
|
||||
width = (int)(height / ratio);
|
||||
}
|
||||
|
||||
return ret;
|
||||
html += "<div align=\"center\">";
|
||||
html += QString("<img src=\"file:%0\" width=\"%1\" height=\"%2\"/>")
|
||||
.arg(_img, QString::number(width), QString::number(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()
|
||||
+ ": </b></td><td>" + _list.at(i).value() + "</td></tr>";
|
||||
html += "</table>";
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
@ -9,10 +9,12 @@ class ToolTip
|
||||
{
|
||||
public:
|
||||
void insert(const QString &key, const QString &value);
|
||||
void setImage(const QString &img) {_img = img;}
|
||||
QString toString();
|
||||
|
||||
private:
|
||||
QList<KV> _list;
|
||||
QString _img;
|
||||
};
|
||||
|
||||
#endif // TOOLTIP_H
|
||||
|
@ -27,6 +27,7 @@ QString WaypointItem::toolTip(Units units, CoordinatesFormat format)
|
||||
if (!_waypoint.description().isNull())
|
||||
tt.insert(qApp->translate("WaypointItem", "Description"),
|
||||
_waypoint.description());
|
||||
tt.setImage(_waypoint.image());
|
||||
|
||||
return tt.toString();
|
||||
}
|
||||
|
Reference in New Issue
Block a user