From kde-commits Sun Nov 30 23:46:59 2014 From: Johannes Zarl Date: Sun, 30 Nov 2014 23:46:59 +0000 To: kde-commits Subject: [kphotoalbum/annotation_map_2] Map: Fix incorrect usage of QVariant. Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=141739123013263 Git commit d618697432957ed44e5757c889bca117404f60b5 by Johannes Zarl. Committed on 30/11/2014 at 23:46. Pushed by johanneszarl into branch 'annotation_map_2'. Fix incorrect usage of QVariant. M +6 -8 Map/MapMarkerModelHelper.cpp http://commits.kde.org/kphotoalbum/d618697432957ed44e5757c889bca117404f60b5 diff --git a/Map/MapMarkerModelHelper.cpp b/Map/MapMarkerModelHelper.cpp index 757b62a..e406d9a 100644 --- a/Map/MapMarkerModelHelper.cpp +++ b/Map/MapMarkerModelHelper.cpp @@ -32,7 +32,6 @@ # define Debug if (false) qDebug #endif = -const int CoordinatesRole =3D Qt::UserRole + 0; const int FileNameRole =3D Qt::UserRole + 1; = Map::MapMarkerModelHelper::MapMarkerModelHelper() : m_itemModel(0), m_item= SelectionModel(0) @@ -60,7 +59,6 @@ void Map::MapMarkerModelHelper::addImage(const DB::ImageI= nfo& image) QStandardItem* const newItem =3D new QStandardItem(image.label()); = newItem->setToolTip(image.label()); - newItem->setData(QVariant::fromValue(image.coordinates()), Coordinates= Role); newItem->setData(QVariant::fromValue(image.fileName()), FileNameRole); m_itemModel->appendRow(newItem); } @@ -78,12 +76,13 @@ void Map::MapMarkerModelHelper::slotDataChanged(const Q= ModelIndex&, const QModel bool Map::MapMarkerModelHelper::itemCoordinates(const QModelIndex& index, KGeoMap::GeoCoordinates* c= onst coordinates) const { - if (! index.data(CoordinatesRole).canConvert(= )) { + if (! index.data(FileNameRole).canConvert()) { return false; } = if (coordinates) { - *coordinates =3D index.data(CoordinatesRole).value(); + const DB::FileName filename =3D index.data(FileNameRole).value(); + *coordinates =3D filename.info()->coordinates(); } = return true; @@ -106,7 +105,7 @@ KGeoMap::ModelHelper::Flags Map::MapMarkerModelHelper::= modelFlags() const = KGeoMap::ModelHelper::Flags Map::MapMarkerModelHelper::itemFlags(const QMo= delIndex &index) const { - if (! index.data(CoordinatesRole).canConvert(= )) { + if (! index.data(FileNameRole).canConvert()) { return FlagNull; } = @@ -120,14 +119,13 @@ bool Map::MapMarkerModelHelper::itemIcon(const QModel= Index& index, QPixmap* const pixmap, KUrl* const) const { - DB::FileName filename =3D index.data(FileNameRole).value= (); if (! index.data(FileNameRole).canConvert()) { - Debug() << "Cannot convert icon for " << filename.relative(); return false; } = + const DB::FileName filename =3D index.data(FileNameRole).value(); *pixmap =3D ImageManager::ThumbnailCache::instance()->lookup( filename= ); - *offset =3D QPoint(pixmap->width()/2, pixmap->height()-1); + *offset =3D QPoint(pixmap->width()/2, pixmap->height()/2); Debug() << "Map icon for " << filename.relative() << (pixmap->isNull()= ? " missing." : " found."); return !pixmap->isNull(); }