mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Another futile attempt to keep whitespace consistent
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
3e46b4862a
commit
1fec6453a2
2 changed files with 28 additions and 22 deletions
|
@ -10,7 +10,7 @@ void DivePictureDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
|
||||||
|
|
||||||
DivePictureModel *DivePictureModel::instance()
|
DivePictureModel *DivePictureModel::instance()
|
||||||
{
|
{
|
||||||
static DivePictureModel* self = new DivePictureModel();
|
static DivePictureModel *self = new DivePictureModel();
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,9 @@ DivePictureModel::DivePictureModel()
|
||||||
typedef QPair<QString, QImage> SPixmap;
|
typedef QPair<QString, QImage> SPixmap;
|
||||||
typedef QList<SPixmap> SPixmapList;
|
typedef QList<SPixmap> SPixmapList;
|
||||||
|
|
||||||
SPixmap scaleImages(const QString& s) {
|
SPixmap scaleImages(const QString &s)
|
||||||
QImage p = QImage(s).scaled(128,128, Qt::KeepAspectRatio);
|
{
|
||||||
|
QImage p = QImage(s).scaled(128, 128, Qt::KeepAspectRatio);
|
||||||
SPixmap ret;
|
SPixmap ret;
|
||||||
ret.first = s;
|
ret.first = s;
|
||||||
ret.second = p;
|
ret.second = p;
|
||||||
|
@ -32,7 +33,7 @@ SPixmap scaleImages(const QString& s) {
|
||||||
void DivePictureModel::updateDivePictures(int divenr)
|
void DivePictureModel::updateDivePictures(int divenr)
|
||||||
{
|
{
|
||||||
if (numberOfPictures != 0) {
|
if (numberOfPictures != 0) {
|
||||||
beginRemoveRows(QModelIndex(), 0, numberOfPictures-1);
|
beginRemoveRows(QModelIndex(), 0, numberOfPictures - 1);
|
||||||
numberOfPictures = 0;
|
numberOfPictures = 0;
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
@ -45,17 +46,17 @@ void DivePictureModel::updateDivePictures(int divenr)
|
||||||
|
|
||||||
stringPixmapCache.clear();
|
stringPixmapCache.clear();
|
||||||
QStringList pictures;
|
QStringList pictures;
|
||||||
FOR_EACH_PICTURE( d ) {
|
FOR_EACH_PICTURE (d) {
|
||||||
stringPixmapCache[QString(picture->filename)].picture = picture;
|
stringPixmapCache[QString(picture->filename)].picture = picture;
|
||||||
pictures.push_back(QString(picture->filename));
|
pictures.push_back(QString(picture->filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SPixmapList retList = QtConcurrent::blockingMapped<SPixmapList>( pictures, scaleImages);
|
SPixmapList retList = QtConcurrent::blockingMapped<SPixmapList>(pictures, scaleImages);
|
||||||
Q_FOREACH(const SPixmap & pixmap, retList)
|
Q_FOREACH (const SPixmap &pixmap, retList)
|
||||||
stringPixmapCache[pixmap.first].image = pixmap.second;
|
stringPixmapCache[pixmap.first].image = pixmap.second;
|
||||||
|
|
||||||
beginInsertRows(QModelIndex(), 0, numberOfPictures-1);
|
beginInsertRows(QModelIndex(), 0, numberOfPictures - 1);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,16 +72,21 @@ QVariant DivePictureModel::data(const QModelIndex &index, int role) const
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
QString key = stringPixmapCache.keys().at(index.row());
|
QString key = stringPixmapCache.keys().at(index.row());
|
||||||
if(index.column() == 0){
|
if (index.column() == 0) {
|
||||||
switch(role){
|
switch (role) {
|
||||||
case Qt::ToolTipRole : ret = key; break;
|
case Qt::ToolTipRole:
|
||||||
case Qt::DecorationRole : ret = stringPixmapCache[key].image; break;
|
ret = key;
|
||||||
case Qt::DisplayRole : ret = QFileInfo(key).fileName();
|
break;
|
||||||
|
case Qt::DecorationRole:
|
||||||
|
ret = stringPixmapCache[key].image;
|
||||||
|
break;
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
ret = QFileInfo(key).fileName();
|
||||||
}
|
}
|
||||||
}
|
} else if (index.column() == 1) {
|
||||||
else if (index.column() == 1){
|
switch (role) {
|
||||||
switch(role){
|
case Qt::UserRole:
|
||||||
case Qt::UserRole : ret = QVariant::fromValue( (void*) stringPixmapCache[key].picture);
|
ret = QVariant::fromValue((void *)stringPixmapCache[key].picture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -91,6 +97,6 @@ int DivePictureModel::rowCount(const QModelIndex &parent) const
|
||||||
return numberOfPictures;
|
return numberOfPictures;
|
||||||
}
|
}
|
||||||
|
|
||||||
DivePictureWidget::DivePictureWidget(QWidget *parent): QListView(parent)
|
DivePictureWidget::DivePictureWidget(QWidget *parent) : QListView(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,19 +7,20 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
struct picture;
|
struct picture;
|
||||||
struct PhotoHelper{
|
struct PhotoHelper {
|
||||||
QImage image;
|
QImage image;
|
||||||
struct picture *picture;
|
struct picture *picture;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DivePictureModel : public QAbstractTableModel {
|
class DivePictureModel : public QAbstractTableModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static DivePictureModel *instance();
|
static DivePictureModel *instance();
|
||||||
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
void updateDivePictures(int divenr);
|
void updateDivePictures(int divenr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DivePictureModel();
|
DivePictureModel();
|
||||||
int numberOfPictures;
|
int numberOfPictures;
|
||||||
|
@ -33,14 +34,13 @@ class DivePictureDelegate : QStyledItemDelegate {
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DivePictureWidget : public QListView{
|
class DivePictureWidget : public QListView {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DivePictureWidget(QWidget *parent);
|
DivePictureWidget(QWidget *parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
class DivePictureThumbnailThread : public QThread {
|
class DivePictureThumbnailThread : public QThread {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Add table
Add a link
Reference in a new issue