diff --git a/src/GUI/tooltip.cpp b/src/GUI/tooltip.cpp index 42e640f1..a8464a6a 100644 --- a/src/GUI/tooltip.cpp +++ b/src/GUI/tooltip.cpp @@ -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 = "
"; + for (int i = 0; i < _images.size(); i++) { + const ImageInfo &img = _images.at(i); + QSize size(thumbnailSize(img, qMin(960/_images.size(), 240))); - html += "
"; - html += QString("" - "") - .arg(_img.path(), QString::number(width), QString::number(height)); + html += QString("" + "") + .arg(img.path(), QString::number(size.width()), + QString::number(size.height())); + } html += "
"; } diff --git a/src/GUI/tooltip.h b/src/GUI/tooltip.h index 1d61f9a6..ee4a6180 100644 --- a/src/GUI/tooltip.h +++ b/src/GUI/tooltip.h @@ -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 &images) {_images = images;} QString toString() const; private: QList > _list; - ImageInfo _img; + QVector _images; }; #endif // TOOLTIP_H diff --git a/src/GUI/waypointitem.cpp b/src/GUI/waypointitem.cpp index d4be0399..f32c6366 100644 --- a/src/GUI/waypointitem.cpp +++ b/src/GUI/waypointitem.cpp @@ -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(); } diff --git a/src/data/exifparser.cpp b/src/data/exifparser.cpp index 80200efc..5bb85eb6 100644 --- a/src/data/exifparser.cpp +++ b/src/data/exifparser.cpp @@ -209,7 +209,7 @@ bool EXIFParser::parseTIFF(QFile *file, QVector &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, diff --git a/src/data/gpiparser.cpp b/src/data/gpiparser.cpp index c1a51164..cd529a07 100644 --- a/src/data/gpiparser.cpp +++ b/src/data/gpiparser.cpp @@ -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); diff --git a/src/data/waypoint.h b/src/data/waypoint.h index df25fdf1..c70a4e52 100644 --- a/src/data/waypoint.h +++ b/src/data/waypoint.h @@ -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 &images() const {return _images;} const QVector &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 _images; QVector _links; QDateTime _timestamp; qreal _elevation;