summaryrefslogtreecommitdiffstats
path: root/qt-ui/profile/diveplotdatamodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/profile/diveplotdatamodel.cpp')
-rw-r--r--qt-ui/profile/diveplotdatamodel.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/qt-ui/profile/diveplotdatamodel.cpp b/qt-ui/profile/diveplotdatamodel.cpp
index 362eb018b..31941fef7 100644
--- a/qt-ui/profile/diveplotdatamodel.cpp
+++ b/qt-ui/profile/diveplotdatamodel.cpp
@@ -5,11 +5,12 @@
#include "graphicsview-common.h"
#include "dive.h"
#include "display.h"
+#include "divelist.h"
#include <QDebug>
-DivePlotDataModel::DivePlotDataModel(QObject* parent): QAbstractTableModel(parent), sampleCount(0), plotData(NULL)
+DivePlotDataModel::DivePlotDataModel(QObject* parent): QAbstractTableModel(parent)
{
-
+ pInfo.nr = 0;
}
int DivePlotDataModel::columnCount(const QModelIndex& parent) const
@@ -22,7 +23,7 @@ QVariant DivePlotDataModel::data(const QModelIndex& index, int role) const
if (!index.isValid())
return QVariant();
- plot_data item = plotData[index.row()];
+ plot_data item = pInfo.entry[index.row()];
if (role == Qt::DisplayRole) {
switch (index.column()) {
case DEPTH: return item.depth;
@@ -54,14 +55,14 @@ QVariant DivePlotDataModel::data(const QModelIndex& index, int role) const
return QVariant();
}
-plot_data* DivePlotDataModel::data()
+const plot_info& DivePlotDataModel::data() const
{
- return plotData;
+ return pInfo;
}
int DivePlotDataModel::rowCount(const QModelIndex& parent) const
{
- return sampleCount;
+ return pInfo.nr;
}
QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation, int role) const
@@ -102,7 +103,7 @@ void DivePlotDataModel::clear()
}
}
-void DivePlotDataModel::setDive(dive* d,const plot_info& pInfo)
+void DivePlotDataModel::setDive(dive* d, const plot_info& info)
{
// We need a way to find out if the dive setted is the same old dive, but pointers change,
// and there's no UUID, for now, just repopulate everything.
@@ -112,9 +113,8 @@ void DivePlotDataModel::setDive(dive* d,const plot_info& pInfo)
if (d)
dc = select_dc(&d->dc);
diveId = d->id;
- plotData = pInfo.entry;
- sampleCount = pInfo.nr;
- beginInsertRows(QModelIndex(), 0, sampleCount-1);
+ pInfo = info;
+ beginInsertRows(QModelIndex(), 0, pInfo.nr-1);
endInsertRows();
}
@@ -128,8 +128,8 @@ double DivePlotDataModel::GASFUNC() \
{ \
double ret = -1; \
for(int i = 0, count = rowCount(); i < count; i++){ \
- if (plotData[i].GAS > ret) \
- ret = plotData[i].GAS; \
+ if (pInfo.entry[i].GAS > ret) \
+ ret = pInfo.entry[i].GAS; \
} \
return ret; \
}
@@ -142,3 +142,12 @@ void DivePlotDataModel::emitDataChanged()
{
emit dataChanged(QModelIndex(), QModelIndex());
}
+
+void DivePlotDataModel::calculateDecompression()
+{
+ struct dive *d = getDiveById(id());
+ struct divecomputer *dc = select_dc(&d->dc);
+ init_decompression(d);
+ calculate_deco_information(d, dc, &pInfo, FALSE);
+ dataChanged(index(0, CEILING), index(pInfo.nr-1, TISSUE_16));
+}