#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(key, value)); } QString ToolTip::toString() const { QString html; 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 += QString("" "") .arg(img.path(), QString::number(size.width()), QString::number(size.height())); } html += "
"; } if (!_list.isEmpty()) { html += ""; for (int i = 0; i < _list.count(); i++) html += ""; html += "
" + _list.at(i).key() + ": " + _list.at(i).value() + "
"; } return html; }