From b1847f9ebb45fcdeb4488f8acd7df2b9ee75906a Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 3 Jun 2014 19:34:36 -0300 Subject: Also hold a pointer to the struct picture on the model. Changes to hold a pointer to the struct picture on the model, so we can use it to determine the correct positioning of the image on the profile. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/divepicturewidget.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'qt-ui/divepicturewidget.cpp') diff --git a/qt-ui/divepicturewidget.cpp b/qt-ui/divepicturewidget.cpp index 5da7c73a4..97b7bd25e 100644 --- a/qt-ui/divepicturewidget.cpp +++ b/qt-ui/divepicturewidget.cpp @@ -43,15 +43,17 @@ void DivePictureModel::updateDivePictures(int divenr) return; } + stringPixmapCache.clear(); QStringList pictures; FOR_EACH_PICTURE( d ) { + stringPixmapCache[QString(picture->filename)].picture = picture; pictures.push_back(QString(picture->filename)); } - stringPixmapCache.clear(); + SPixmapList retList = QtConcurrent::blockingMapped( pictures, scaleImages); Q_FOREACH(const SPixmap & pixmap, retList) - stringPixmapCache[pixmap.first] = pixmap.second; + stringPixmapCache[pixmap.first].image = pixmap.second; beginInsertRows(QModelIndex(), 0, numberOfPictures-1); endInsertRows(); @@ -59,7 +61,7 @@ void DivePictureModel::updateDivePictures(int divenr) int DivePictureModel::columnCount(const QModelIndex &parent) const { - return 1; + return 2; } QVariant DivePictureModel::data(const QModelIndex &index, int role) const @@ -69,10 +71,17 @@ QVariant DivePictureModel::data(const QModelIndex &index, int role) const return ret; QString key = stringPixmapCache.keys().at(index.row()); - switch(role){ - case Qt::ToolTipRole : ret = key; break; - case Qt::DecorationRole : ret = stringPixmapCache[key]; break; - case Qt::DisplayRole : ret = QFileInfo(key).fileName(); + if(index.column() == 0){ + switch(role){ + case Qt::ToolTipRole : ret = key; break; + case Qt::DecorationRole : ret = stringPixmapCache[key].image; break; + case Qt::DisplayRole : ret = QFileInfo(key).fileName(); + } + } + else if (index.column() == 1){ + switch(role){ + case Qt::UserRole : ret = QVariant::fromValue( (void*) stringPixmapCache[key].picture); + } } return ret; } -- cgit v1.2.3-70-g09d2