mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Merge branch 'latest'
This commit is contained in:
commit
738c472daf
4 changed files with 28 additions and 6 deletions
1
dive.h
1
dive.h
|
@ -640,7 +640,6 @@ struct divedatapoint {
|
||||||
|
|
||||||
struct diveplan {
|
struct diveplan {
|
||||||
timestamp_t when;
|
timestamp_t when;
|
||||||
int lastdive_nr;
|
|
||||||
int surface_pressure; /* mbar */
|
int surface_pressure; /* mbar */
|
||||||
int bottomsac; /* ml/min */
|
int bottomsac; /* ml/min */
|
||||||
int decosac; /* ml/min */
|
int decosac; /* ml/min */
|
||||||
|
|
14
planner.c
14
planner.c
|
@ -49,6 +49,20 @@ void dump_plan(struct diveplan *diveplan)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool diveplan_empty(struct diveplan *diveplan)
|
||||||
|
{
|
||||||
|
struct divedatapoint *dp;
|
||||||
|
if (!diveplan || !diveplan->dp)
|
||||||
|
return true;
|
||||||
|
dp = diveplan->dp;
|
||||||
|
while(dp) {
|
||||||
|
if (dp->time)
|
||||||
|
return false;
|
||||||
|
dp = dp->next;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void set_last_stop(bool last_stop_6m)
|
void set_last_stop(bool last_stop_6m)
|
||||||
{
|
{
|
||||||
if (last_stop_6m == true)
|
if (last_stop_6m == true)
|
||||||
|
|
|
@ -13,6 +13,7 @@ extern void show_planned_dive(char **error_string_p);
|
||||||
extern void set_last_stop(bool last_stop_6m);
|
extern void set_last_stop(bool last_stop_6m);
|
||||||
extern void get_gas_from_events(struct divecomputer *dc, int time, int *o2, int *he);
|
extern void get_gas_from_events(struct divecomputer *dc, int time, int *o2, int *he);
|
||||||
extern int get_gasidx(struct dive *dive, int o2, int he);
|
extern int get_gasidx(struct dive *dive, int o2, int he);
|
||||||
|
extern bool diveplan_empty(struct diveplan *diveplan);
|
||||||
|
|
||||||
extern struct dive *planned_dive;
|
extern struct dive *planned_dive;
|
||||||
extern char *cache_data;
|
extern char *cache_data;
|
||||||
|
|
|
@ -388,6 +388,7 @@ bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &v
|
||||||
{
|
{
|
||||||
int o2 = 0;
|
int o2 = 0;
|
||||||
int he = 0;
|
int he = 0;
|
||||||
|
int i, shift;
|
||||||
if (role == Qt::EditRole) {
|
if (role == Qt::EditRole) {
|
||||||
divedatapoint &p = divepoints[index.row()];
|
divedatapoint &p = divepoints[index.row()];
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
|
@ -398,10 +399,13 @@ bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &v
|
||||||
p.time = value.toInt() * 60;
|
p.time = value.toInt() * 60;
|
||||||
break;
|
break;
|
||||||
case DURATION:
|
case DURATION:
|
||||||
if (index.row())
|
i = index.row();
|
||||||
p.time = value.toInt() * 60 + divepoints[index.row() - 1].time;
|
if (i)
|
||||||
|
shift = divepoints[i].time - divepoints[i - 1].time - value.toInt() * 60;
|
||||||
else
|
else
|
||||||
p.time = value.toInt() * 60;
|
shift = divepoints[i].time - value.toInt() * 60;
|
||||||
|
while (i < divepoints.size())
|
||||||
|
divepoints[i++].time -= shift;
|
||||||
break;
|
break;
|
||||||
case CCSETPOINT: {
|
case CCSETPOINT: {
|
||||||
int po2 = 0;
|
int po2 = 0;
|
||||||
|
@ -445,7 +449,7 @@ QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orienta
|
||||||
|
|
||||||
Qt::ItemFlags DivePlannerPointsModel::flags(const QModelIndex &index) const
|
Qt::ItemFlags DivePlannerPointsModel::flags(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (index.column() != DURATION && index.column() != REMOVE)
|
if (index.column() != REMOVE)
|
||||||
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
|
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
|
||||||
else
|
else
|
||||||
return QAbstractItemModel::flags(index);
|
return QAbstractItemModel::flags(index);
|
||||||
|
@ -764,6 +768,7 @@ void DivePlannerPointsModel::clear()
|
||||||
} else {
|
} else {
|
||||||
stagingDive = alloc_dive();
|
stagingDive = alloc_dive();
|
||||||
}
|
}
|
||||||
|
bool oldRecalc = setRecalc(false);
|
||||||
CylindersModel::instance()->setDive(stagingDive);
|
CylindersModel::instance()->setDive(stagingDive);
|
||||||
if (rowCount() > 0) {
|
if (rowCount() > 0) {
|
||||||
beginRemoveRows(QModelIndex(), 0, rowCount() - 1);
|
beginRemoveRows(QModelIndex(), 0, rowCount() - 1);
|
||||||
|
@ -771,12 +776,15 @@ void DivePlannerPointsModel::clear()
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
CylindersModel::instance()->clear();
|
CylindersModel::instance()->clear();
|
||||||
|
setRecalc(oldRecalc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePlannerPointsModel::addDecoToModel()
|
void DivePlannerPointsModel::addDecoToModel()
|
||||||
{
|
{
|
||||||
struct divedatapoint *dp;
|
struct divedatapoint *dp;
|
||||||
|
|
||||||
|
if (diveplan_empty(&diveplan))
|
||||||
|
return;
|
||||||
bool oldRecalc = plannerModel->setRecalc(false);
|
bool oldRecalc = plannerModel->setRecalc(false);
|
||||||
plannerModel->removeDeco();
|
plannerModel->removeDeco();
|
||||||
|
|
||||||
|
@ -832,7 +840,7 @@ void DivePlannerPointsModel::createTemporaryPlan()
|
||||||
#if DEBUG_PLAN
|
#if DEBUG_PLAN
|
||||||
dump_plan(&diveplan);
|
dump_plan(&diveplan);
|
||||||
#endif
|
#endif
|
||||||
if (plannerModel->recalcQ()) {
|
if (plannerModel->recalcQ() && !diveplan_empty(&diveplan)) {
|
||||||
plan(&diveplan, &cache, &tempDive, stagingDive, isPlanner());
|
plan(&diveplan, &cache, &tempDive, stagingDive, isPlanner());
|
||||||
addDecoToModel();
|
addDecoToModel();
|
||||||
if (mode == ADD || mode == PLAN) {
|
if (mode == ADD || mode == PLAN) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue