mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Removed inconsistency when user tried to add dive while planning.
The user could add a dive, and in the middle click on the 'plan' button. Since we didn't cared about that on the widget, a lot of inconsistencies could occour. this fixes that by setting a flag on the Planner, that has now three modes: nothing, plan and add. (maybe in the future an edit mode will be valid too.) If in 'NOTHING' mode, user can enter the addition, edition and planning. If in any other mode, user can't do a thing. The mode gets back to NOTHING when user accepts or cancels a plan / add / edition. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f850a0817c
commit
8a970c64c2
4 changed files with 46 additions and 25 deletions
|
@ -431,13 +431,6 @@ void DivePlannerPointsModel::loadFromDive(dive* d)
|
|||
* as soon as the model is modified, it will
|
||||
* remove all samples from the current dive.
|
||||
* */
|
||||
|
||||
/* On the safe side, clear everything before
|
||||
editing the new dive. */
|
||||
beginRemoveRows(QModelIndex(), 0, rowCount()-1);
|
||||
divepoints.clear();
|
||||
endRemoveRows();
|
||||
|
||||
backupSamples.clear();
|
||||
for(int i = 1; i < d->dc.samples-1; i++){
|
||||
backupSamples.push_back( d->dc.sample[i]);
|
||||
|
@ -940,9 +933,9 @@ void DivePlannerWidget::lastStopChanged(bool checked)
|
|||
plannerModel->setLastStop6m(checked);
|
||||
}
|
||||
|
||||
void DivePlannerPointsModel::setPlanMode(bool isPlan)
|
||||
void DivePlannerPointsModel::setPlanMode(Mode m)
|
||||
{
|
||||
mode = isPlan ? PLAN : ADD;
|
||||
mode = m;
|
||||
}
|
||||
|
||||
bool DivePlannerPointsModel::isPlanner()
|
||||
|
@ -1028,7 +1021,7 @@ int DivePlannerPointsModel::rowCount(const QModelIndex& parent) const
|
|||
return divepoints.count();
|
||||
}
|
||||
|
||||
DivePlannerPointsModel::DivePlannerPointsModel(QObject* parent): QAbstractTableModel(parent)
|
||||
DivePlannerPointsModel::DivePlannerPointsModel(QObject* parent): QAbstractTableModel(parent), mode(NOTHING)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1168,13 +1161,24 @@ void DivePlannerPointsModel::cancelPlan()
|
|||
return;
|
||||
}
|
||||
}
|
||||
clear();
|
||||
emit planCanceled();
|
||||
setPlanMode(NOTHING);
|
||||
}
|
||||
|
||||
DivePlannerPointsModel::Mode DivePlannerPointsModel::currentMode() const
|
||||
{
|
||||
return mode;
|
||||
}
|
||||
|
||||
void DivePlannerPointsModel::clear()
|
||||
{
|
||||
beginRemoveRows(QModelIndex(), 0, rowCount()-1);
|
||||
divepoints.clear();
|
||||
endRemoveRows();
|
||||
emit planCanceled();
|
||||
}
|
||||
|
||||
|
||||
void DivePlannerPointsModel::createTemporaryPlan()
|
||||
{
|
||||
// This needs to be done in the following steps:
|
||||
|
@ -1209,9 +1213,7 @@ void DivePlannerPointsModel::createTemporaryPlan()
|
|||
|
||||
void DivePlannerPointsModel::undoEdition()
|
||||
{
|
||||
beginRemoveRows(QModelIndex(), 0, rowCount()-1);
|
||||
divepoints.clear();
|
||||
endRemoveRows();
|
||||
clear();
|
||||
Q_FOREACH(const sample &s, backupSamples){
|
||||
plannerModel->addStop(s.depth.mm, s.time.seconds, tr("Air"), 0);
|
||||
}
|
||||
|
@ -1249,8 +1251,7 @@ void DivePlannerPointsModel::createPlan()
|
|||
// Remove and clean the diveplan, so we don't delete
|
||||
// the dive by mistake.
|
||||
diveplan.dp = NULL;
|
||||
beginRemoveRows(QModelIndex(), 0, rowCount() -1 );
|
||||
divepoints.clear();
|
||||
endRemoveRows();
|
||||
clear();
|
||||
planCreated();
|
||||
setPlanMode(NOTHING);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue