From 2cded299ace9dd5d312956dd3c65509971ded9b6 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 2 Jun 2014 19:18:07 -0300 Subject: Add the data() method of the Picture Model. This method should give the correct data to all views that the model is connected to. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/divepicturewidget.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/qt-ui/divepicturewidget.cpp b/qt-ui/divepicturewidget.cpp index d0155bd0f..01e52d6e8 100644 --- a/qt-ui/divepicturewidget.cpp +++ b/qt-ui/divepicturewidget.cpp @@ -32,7 +32,7 @@ void DivePictureModel::updateDivePictures(int divenr) } struct dive *d = get_dive(divenr); - int numberOfPictures = dive_get_picture_count(d); + numberOfPictures = dive_get_picture_count(d); if (!d || numberOfPictures == 0) { return; } @@ -58,7 +58,15 @@ int DivePictureModel::columnCount(const QModelIndex &parent) const QVariant DivePictureModel::data(const QModelIndex &index, int role) const { - + QVariant ret; + if (!index.isValid()) + return ret; + + QString key = stringPixmapCache.keys().at(index.row()); + switch(role){ + case Qt::DisplayRole : return key; + case Qt::DecorationRole : return stringPixmapCache[key]; + } } int DivePictureModel::rowCount(const QModelIndex &parent) const -- cgit v1.2.3-70-g09d2