aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/divepicturewidget.cpp42
-rw-r--r--qt-ui/divepicturewidget.h8
2 files changed, 28 insertions, 22 deletions
diff --git a/qt-ui/divepicturewidget.cpp b/qt-ui/divepicturewidget.cpp
index 97b7bd25e..a5ca95c0f 100644
--- a/qt-ui/divepicturewidget.cpp
+++ b/qt-ui/divepicturewidget.cpp
@@ -10,7 +10,7 @@ void DivePictureDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
DivePictureModel *DivePictureModel::instance()
{
- static DivePictureModel* self = new DivePictureModel();
+ static DivePictureModel *self = new DivePictureModel();
return self;
}
@@ -21,8 +21,9 @@ DivePictureModel::DivePictureModel()
typedef QPair<QString, QImage> SPixmap;
typedef QList<SPixmap> SPixmapList;
-SPixmap scaleImages(const QString& s) {
- QImage p = QImage(s).scaled(128,128, Qt::KeepAspectRatio);
+SPixmap scaleImages(const QString &s)
+{
+ QImage p = QImage(s).scaled(128, 128, Qt::KeepAspectRatio);
SPixmap ret;
ret.first = s;
ret.second = p;
@@ -32,7 +33,7 @@ SPixmap scaleImages(const QString& s) {
void DivePictureModel::updateDivePictures(int divenr)
{
if (numberOfPictures != 0) {
- beginRemoveRows(QModelIndex(), 0, numberOfPictures-1);
+ beginRemoveRows(QModelIndex(), 0, numberOfPictures - 1);
numberOfPictures = 0;
endRemoveRows();
}
@@ -45,17 +46,17 @@ void DivePictureModel::updateDivePictures(int divenr)
stringPixmapCache.clear();
QStringList pictures;
- FOR_EACH_PICTURE( d ) {
+ FOR_EACH_PICTURE (d) {
stringPixmapCache[QString(picture->filename)].picture = picture;
pictures.push_back(QString(picture->filename));
}
- SPixmapList retList = QtConcurrent::blockingMapped<SPixmapList>( pictures, scaleImages);
- Q_FOREACH(const SPixmap & pixmap, retList)
+ SPixmapList retList = QtConcurrent::blockingMapped<SPixmapList>(pictures, scaleImages);
+ Q_FOREACH (const SPixmap &pixmap, retList)
stringPixmapCache[pixmap.first].image = pixmap.second;
- beginInsertRows(QModelIndex(), 0, numberOfPictures-1);
+ beginInsertRows(QModelIndex(), 0, numberOfPictures - 1);
endInsertRows();
}
@@ -71,16 +72,21 @@ QVariant DivePictureModel::data(const QModelIndex &index, int role) const
return ret;
QString key = stringPixmapCache.keys().at(index.row());
- 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();
+ 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);
+ } else if (index.column() == 1) {
+ switch (role) {
+ case Qt::UserRole:
+ ret = QVariant::fromValue((void *)stringPixmapCache[key].picture);
}
}
return ret;
@@ -91,6 +97,6 @@ int DivePictureModel::rowCount(const QModelIndex &parent) const
return numberOfPictures;
}
-DivePictureWidget::DivePictureWidget(QWidget *parent): QListView(parent)
+DivePictureWidget::DivePictureWidget(QWidget *parent) : QListView(parent)
{
}
diff --git a/qt-ui/divepicturewidget.h b/qt-ui/divepicturewidget.h
index d66b3053f..92df82c5f 100644
--- a/qt-ui/divepicturewidget.h
+++ b/qt-ui/divepicturewidget.h
@@ -7,19 +7,20 @@
#include <QThread>
struct picture;
-struct PhotoHelper{
+struct PhotoHelper {
QImage image;
struct picture *picture;
};
class DivePictureModel : public QAbstractTableModel {
-Q_OBJECT
+ Q_OBJECT
public:
static DivePictureModel *instance();
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
void updateDivePictures(int divenr);
+
private:
DivePictureModel();
int numberOfPictures;
@@ -33,14 +34,13 @@ class DivePictureDelegate : QStyledItemDelegate {
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
};
-class DivePictureWidget : public QListView{
+class DivePictureWidget : public QListView {
Q_OBJECT
public:
DivePictureWidget(QWidget *parent);
};
class DivePictureThumbnailThread : public QThread {
-
};
#endif \ No newline at end of file