mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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 <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
3595ad0294
commit
dbdff1c0af
3 changed files with 17 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "divepicturewidget.h"
|
||||
#include <dive.h>
|
||||
#include <qtconcurrentmap.h>
|
||||
#include <qdir.h>
|
||||
|
||||
void DivePictureDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
|
@ -11,11 +12,11 @@ DivePictureModel::DivePictureModel(QObject *parent): QAbstractTableModel(parent)
|
|||
{
|
||||
}
|
||||
|
||||
typedef QPair<QString, QPixmap> SPixmap;
|
||||
typedef QPair<QString, QImage> SPixmap;
|
||||
typedef QList<SPixmap> 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;
|
||||
}
|
||||
|
|
|
@ -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<QString, QPixmap> stringPixmapCache;
|
||||
QHash<QString, QImage> stringPixmapCache;
|
||||
};
|
||||
|
||||
class DivePictureDelegate : QStyledItemDelegate {
|
||||
|
|
|
@ -289,8 +289,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<height>30</height>
|
||||
<width>662</width>
|
||||
<height>649</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
|
@ -369,8 +369,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>399</width>
|
||||
<height>325</height>
|
||||
<width>662</width>
|
||||
<height>649</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
|
@ -679,8 +679,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>267</width>
|
||||
<height>115</height>
|
||||
<width>662</width>
|
||||
<height>649</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
|
@ -819,7 +819,11 @@
|
|||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="DivePictureWidget" name="photosView"/>
|
||||
<widget class="DivePictureWidget" name="photosView">
|
||||
<property name="viewMode">
|
||||
<enum>QListView::IconMode</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
Loading…
Reference in a new issue