mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Call that method from the mainWindow when the dive changes. The updateDivePictures walks around the events of the first dc (since all pictures are distributed allong all dive computers) to get the events of type '123' (I wonder if there's not a better way to save pictures on the dive, like an linked list of char* named pictures.) Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
57 lines
1.2 KiB
C++
57 lines
1.2 KiB
C++
#include "divepicturewidget.h"
|
|
#include <dive.h>
|
|
|
|
void DivePictureDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
{
|
|
QStyledItemDelegate::paint(painter, option, index);
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
int DivePictureModel::columnCount(const QModelIndex &parent) const
|
|
{
|
|
|
|
}
|
|
|
|
QVariant DivePictureModel::data(const QModelIndex &index, int role) const
|
|
{
|
|
|
|
}
|
|
|
|
int DivePictureModel::rowCount(const QModelIndex &parent) const
|
|
{
|
|
return numberOfPictures;
|
|
}
|
|
|
|
DivePictureWidget::DivePictureWidget(QWidget *parent): QListView(parent)
|
|
{
|
|
|
|
}
|