mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-31 09:05:14 +01:00
Added support for multiple images
This commit is contained in:
parent
475eb6185a
commit
e4d8ab1feb
@ -1,8 +1,21 @@
|
||||
#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);
|
||||
}
|
||||
|
||||
#define THUMBNAIL_MAX_SIZE 240
|
||||
return QSize(width, height);
|
||||
}
|
||||
|
||||
void ToolTip::insert(const QString &key, const QString &value)
|
||||
{
|
||||
@ -13,22 +26,17 @@ QString ToolTip::toString() const
|
||||
{
|
||||
QString html;
|
||||
|
||||
if (_img.isValid()) {
|
||||
int width, height;
|
||||
if (_img.size().width() > _img.size().height()) {
|
||||
width = qMin(_img.size().width(), THUMBNAIL_MAX_SIZE);
|
||||
qreal ratio = _img.size().width() / (qreal)_img.size().height();
|
||||
height = (int)(width / ratio);
|
||||
} else {
|
||||
height = qMin(_img.size().height(), THUMBNAIL_MAX_SIZE);
|
||||
qreal ratio = _img.size().height() / (qreal)_img.size().width();
|
||||
width = (int)(height / ratio);
|
||||
}
|
||||
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 += "<div align=\"center\">";
|
||||
html += QString("<a href=\"file:%0\">"
|
||||
"<img src=\"%0\" width=\"%1\" height=\"%2\"/></a>")
|
||||
.arg(_img.path(), QString::number(width), QString::number(height));
|
||||
.arg(img.path(), QString::number(size.width()),
|
||||
QString::number(size.height()));
|
||||
}
|
||||
html += "</div>";
|
||||
}
|
||||
|
||||
|
@ -10,12 +10,12 @@ class ToolTip
|
||||
{
|
||||
public:
|
||||
void insert(const QString &key, const QString &value);
|
||||
void setImage(const ImageInfo &image) {_img = image;}
|
||||
void setImages(const QVector<ImageInfo> &images) {_images = images;}
|
||||
QString toString() const;
|
||||
|
||||
private:
|
||||
QList<KV<QString, QString> > _list;
|
||||
ImageInfo _img;
|
||||
QVector<ImageInfo> _images;
|
||||
};
|
||||
|
||||
#endif // TOOLTIP_H
|
||||
|
@ -54,7 +54,7 @@ QString WaypointItem::info() const
|
||||
}
|
||||
tt.insert(qApp->translate("WaypointItem", "Links"), links);
|
||||
}
|
||||
tt.setImage(_waypoint.image());
|
||||
tt.setImages(_waypoint.images());
|
||||
|
||||
return tt.toString();
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ bool EXIFParser::parseTIFF(QFile *file, QVector<Waypoint> &waypoints)
|
||||
|
||||
Waypoint wp(c);
|
||||
wp.setName(QFileInfo(file->fileName()).baseName());
|
||||
wp.setImage(img);
|
||||
wp.addImage(img);
|
||||
wp.setElevation(altitude(tiff, GPSIFD.value(GPSAltitude),
|
||||
GPSIFD.value(GPSAltitudeRef)));
|
||||
wp.setTimestamp(QDateTime(QDate::fromString(text(tiff,
|
||||
|
@ -413,7 +413,7 @@ static quint32 readImageInfo(QDataStream &stream, Waypoint &waypoint,
|
||||
imgFile.write(ba);
|
||||
imgFile.close();
|
||||
|
||||
waypoint.setImage(ImageInfo(imgFile.fileName(), ir.size()));
|
||||
waypoint.addImage(ImageInfo(imgFile.fileName(), ir.size()));
|
||||
|
||||
if (size + 5 != rh.size)
|
||||
stream.setStatus(QDataStream::ReadCorruptData);
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
const QString &name() const {return _name;}
|
||||
const QString &description() const {return _description;}
|
||||
const Address &address() const {return _address;}
|
||||
const ImageInfo &image() const {return _image;}
|
||||
const QVector<ImageInfo> &images() const {return _images;}
|
||||
const QVector<Link> &links() const {return _links;}
|
||||
const QDateTime ×tamp() const {return _timestamp;}
|
||||
qreal elevation() const {return _elevation;}
|
||||
@ -34,7 +34,7 @@ public:
|
||||
void setAddress(const Address &address) {_address = address;}
|
||||
void setTimestamp(const QDateTime ×tamp) {_timestamp = timestamp;}
|
||||
void setElevation(qreal elevation) {_elevation = elevation;}
|
||||
void setImage(const ImageInfo &image) {_image = image;}
|
||||
void addImage(const ImageInfo &image) {_images.append(image);}
|
||||
void addLink(const Link &link) {_links.append(link);}
|
||||
|
||||
bool hasElevation() const {return !std::isnan(_elevation);}
|
||||
@ -48,7 +48,7 @@ private:
|
||||
QString _name;
|
||||
QString _description;
|
||||
Address _address;
|
||||
ImageInfo _image;
|
||||
QVector<ImageInfo> _images;
|
||||
QVector<Link> _links;
|
||||
QDateTime _timestamp;
|
||||
qreal _elevation;
|
||||
|
Loading…
x
Reference in New Issue
Block a user