From 25b0a846af1d4661d16c3de9784879ad44476d08 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 4 Feb 2014 17:34:16 -0200 Subject: Created a method to check if calculations should take place. Created a method to check if calculations should take place taking into consideration what changed on the model. if the model changes *everything*, them, all calculations should be done, but if just some of the columns of the model are changed, only those columns should trigger an visual update on the items. In theory this patch looks right, but something is wrong ( calculations are not being made. ), so I'll commit this any how, and fix on the next commit. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/profile/diveplotdatamodel.cpp | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'qt-ui/profile/diveplotdatamodel.cpp') 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 -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)); +} -- cgit v1.2.3-70-g09d2