diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2014-02-04 17:34:16 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-02-05 06:30:33 -0800 |
commit | 25b0a846af1d4661d16c3de9784879ad44476d08 (patch) | |
tree | aaf3618ea0a81da09c26f03c2dc95eea6e24ae21 /qt-ui/profile/diveplotdatamodel.cpp | |
parent | 0ae7c820f24a4f0609fc0f08e425f0a506cf5d92 (diff) | |
download | subsurface-25b0a846af1d4661d16c3de9784879ad44476d08.tar.gz |
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 <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile/diveplotdatamodel.cpp')
-rw-r--r-- | qt-ui/profile/diveplotdatamodel.cpp | 33 |
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)); +} |