From dbdff1c0afe958c00cae9344ba50fe31e43b243d Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 2 Jun 2014 22:09:21 -0300 Subject: Change from QPixmap to QImage due to thread issues. QPixmap cannot be accessed from outside the Main thread, but QImage can. so change that. Also, make the Photo widget display in Icon mode. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/divepicturewidget.cpp | 8 +++++--- qt-ui/divepicturewidget.h | 2 +- qt-ui/maintab.ui | 18 +++++++++++------- 3 files changed, 17 insertions(+), 11 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/divepicturewidget.cpp b/qt-ui/divepicturewidget.cpp index 916345346..e5824e608 100644 --- a/qt-ui/divepicturewidget.cpp +++ b/qt-ui/divepicturewidget.cpp @@ -1,6 +1,7 @@ #include "divepicturewidget.h" #include #include +#include void DivePictureDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { @@ -11,11 +12,11 @@ DivePictureModel::DivePictureModel(QObject *parent): QAbstractTableModel(parent) { } -typedef QPair SPixmap; +typedef QPair SPixmap; typedef QList SPixmapList; SPixmap scaleImages(const QString& s) { - QPixmap p = QPixmap(s).scaled(128,128, Qt::KeepAspectRatio); + QImage p = QImage(s).scaled(128,128, Qt::KeepAspectRatio); SPixmap ret; ret.first = s; ret.second = p; @@ -63,8 +64,9 @@ QVariant DivePictureModel::data(const QModelIndex &index, int role) const QString key = stringPixmapCache.keys().at(index.row()); switch(role){ - case Qt::DisplayRole : ret = key; break; + case Qt::ToolTipRole : ret = key; break; case Qt::DecorationRole : ret = stringPixmapCache[key]; break; + case Qt::DisplayRole : ret = QFileInfo(key).fileName(); } return ret; } diff --git a/qt-ui/divepicturewidget.h b/qt-ui/divepicturewidget.h index 9fb5465df..4660bd070 100644 --- a/qt-ui/divepicturewidget.h +++ b/qt-ui/divepicturewidget.h @@ -19,7 +19,7 @@ private: // Currently, load the images on the fly // Later, use a thread to load the images // Later, save the thumbnails so we don't need to reopen every time. - QHash stringPixmapCache; + QHash stringPixmapCache; }; class DivePictureDelegate : QStyledItemDelegate { diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index 0998db22f..904a49304 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -289,8 +289,8 @@ 0 0 - 100 - 30 + 662 + 649 @@ -369,8 +369,8 @@ 0 0 - 399 - 325 + 662 + 649 @@ -679,8 +679,8 @@ 0 0 - 267 - 115 + 662 + 649 @@ -819,7 +819,11 @@ - + + + QListView::IconMode + + -- cgit v1.2.3-70-g09d2