2014-05-30 14:38:27 -03:00
|
|
|
#include "divepicturewidget.h"
|
2014-05-30 15:16:00 -03:00
|
|
|
#include <dive.h>
|
2014-05-30 14:38:27 -03:00
|
|
|
|
|
|
|
void DivePictureDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
|
|
{
|
|
|
|
QStyledItemDelegate::paint(painter, option, index);
|
|
|
|
}
|
|
|
|
|
2014-05-30 15:16:00 -03:00
|
|
|
DivePictureModel::DivePictureModel(QObject *parent): QAbstractTableModel(parent)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void DivePictureModel::updateDivePictures(int divenr)
|
|
|
|
{
|
|
|
|
beginRemoveRows(QModelIndex(), 0, numberOfPictures-1);
|
|
|
|
numberOfPictures = 0;
|
|
|
|
endRemoveRows();
|
|
|
|
|
|
|
|
struct dive *d = get_dive(divenr);
|
|
|
|
if (!d)
|
|
|
|
return;
|
|
|
|
// All pictures are set in *all* divecomputers. ( waste of memory if > 100 pictures? )
|
|
|
|
// so just get from the first one.
|
|
|
|
struct event *ev = d->dc.events;
|
|
|
|
while(ev){
|
|
|
|
if(ev->type == 123){ // 123 means PICTURE.
|
|
|
|
numberOfPictures++;
|
|
|
|
}
|
|
|
|
ev = ev->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numberOfPictures == 0)
|
|
|
|
return;
|
|
|
|
beginInsertRows(QModelIndex(), 0, numberOfPictures-1);
|
|
|
|
endInsertRows();
|
|
|
|
}
|
|
|
|
|
2014-05-30 14:38:27 -03:00
|
|
|
int DivePictureModel::columnCount(const QModelIndex &parent) const
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariant DivePictureModel::data(const QModelIndex &index, int role) const
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int DivePictureModel::rowCount(const QModelIndex &parent) const
|
|
|
|
{
|
2014-05-30 15:16:00 -03:00
|
|
|
return numberOfPictures;
|
2014-05-30 14:38:27 -03:00
|
|
|
}
|
|
|
|
|
2014-05-30 14:50:49 -03:00
|
|
|
DivePictureWidget::DivePictureWidget(QWidget *parent): QListView(parent)
|
2014-05-30 14:38:27 -03:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|