mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
0ae7c820f2
commit
25b0a846af
6 changed files with 96 additions and 49 deletions
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue