Another futile attempt to keep whitespace consistent

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-06-03 16:48:59 -07:00
parent 3e46b4862a
commit 1fec6453a2
2 changed files with 28 additions and 22 deletions

View file

@ -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)
{
}

View file

@ -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