[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kphotoalbum/annotation_map_2] Map: Fix incorrect usage of QVariant.
From:       Johannes Zarl <johannes () zarl ! at>
Date:       2014-11-30 23:46:59
Message-ID: E1XvECh-0006Md-Vl () scm ! kde ! org
[Download RAW message or body]

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 = Qt::UserRole + 0;
 const int FileNameRole = Qt::UserRole + 1;
 
 Map::MapMarkerModelHelper::MapMarkerModelHelper() : m_itemModel(0), \
m_itemSelectionModel(0) @@ -60,7 +59,6 @@ void \
Map::MapMarkerModelHelper::addImage(const DB::ImageInfo& image)  \
QStandardItem* const newItem = new QStandardItem(image.label());  
     newItem->setToolTip(image.label());
-    newItem->setData(QVariant::fromValue(image.coordinates()), \
                CoordinatesRole);
     newItem->setData(QVariant::fromValue(image.fileName()), FileNameRole);
     m_itemModel->appendRow(newItem);
 }
@@ -78,12 +76,13 @@ void Map::MapMarkerModelHelper::slotDataChanged(const \
QModelIndex&, const QModel  bool \
                Map::MapMarkerModelHelper::itemCoordinates(const \
                QModelIndex& index,
                                                 KGeoMap::GeoCoordinates* \
const coordinates) const  {
-    if (! index.data(CoordinatesRole).canConvert<KGeoMap::GeoCoordinates>()) \
{ +    if (! index.data(FileNameRole).canConvert<DB::FileName>()) {
         return false;
     }
 
     if (coordinates) {
-        *coordinates = \
index.data(CoordinatesRole).value<KGeoMap::GeoCoordinates>(); +        \
const DB::FileName filename = \
index.data(FileNameRole).value<DB::FileName>(); +        *coordinates = \
filename.info()->coordinates();  }
 
     return true;
@@ -106,7 +105,7 @@ KGeoMap::ModelHelper::Flags \
Map::MapMarkerModelHelper::modelFlags() const  
 KGeoMap::ModelHelper::Flags Map::MapMarkerModelHelper::itemFlags(const \
QModelIndex &index) const  {
-    if (! index.data(CoordinatesRole).canConvert<KGeoMap::GeoCoordinates>()) \
{ +    if (! index.data(FileNameRole).canConvert<DB::FileName>()) {
         return FlagNull;
     }
 
@@ -120,14 +119,13 @@ bool Map::MapMarkerModelHelper::itemIcon(const \
QModelIndex& index,  QPixmap* const pixmap,
                                          KUrl* const) const
 {
-    DB::FileName filename = \
index.data(FileNameRole).value<DB::FileName>();  if (! \
                index.data(FileNameRole).canConvert<DB::FileName>()) {
-        Debug() << "Cannot convert icon for " << filename.relative();
         return false;
     }
 
+    const DB::FileName filename = \
                index.data(FileNameRole).value<DB::FileName>();
     *pixmap = ImageManager::ThumbnailCache::instance()->lookup( filename \
                );
-    *offset = QPoint(pixmap->width()/2, pixmap->height()-1);
+    *offset = QPoint(pixmap->width()/2, pixmap->height()/2);
     Debug() << "Map icon for " << filename.relative() << (pixmap->isNull() \
? " missing." : " found.");  return !pixmap->isNull();
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic