mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
When starting the planner, copy cylinders from currently selected dive.
This way, the user can save dives containing sets of "standard cylinders". Selecting one of those prepopulates the gas list for the planner. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
90638180d2
commit
9a4f8b50bd
5 changed files with 33 additions and 0 deletions
|
@ -436,6 +436,11 @@ void DivePlannerPointsModel::copyCylinders(dive *d)
|
||||||
copy_cylinders(stagingDive, d);
|
copy_cylinders(stagingDive, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivePlannerPointsModel::copyCylindersFrom(dive *d)
|
||||||
|
{
|
||||||
|
copy_cylinders(d, stagingDive);
|
||||||
|
}
|
||||||
|
|
||||||
QStringList &DivePlannerPointsModel::getGasList()
|
QStringList &DivePlannerPointsModel::getGasList()
|
||||||
{
|
{
|
||||||
struct dive *activeDive = isPlanner() ? stagingDive : current_dive;
|
struct dive *activeDive = isPlanner() ? stagingDive : current_dive;
|
||||||
|
|
|
@ -48,6 +48,7 @@ public:
|
||||||
void rememberTanks();
|
void rememberTanks();
|
||||||
bool tankInUse(int o2, int he);
|
bool tankInUse(int o2, int he);
|
||||||
void copyCylinders(struct dive *d);
|
void copyCylinders(struct dive *d);
|
||||||
|
void copyCylindersFrom(struct dive *d);
|
||||||
/**
|
/**
|
||||||
* @return the row number.
|
* @return the row number.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -325,6 +325,8 @@ void MainWindow::enableDcShortcuts()
|
||||||
|
|
||||||
void MainWindow::on_actionDivePlanner_triggered()
|
void MainWindow::on_actionDivePlanner_triggered()
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
struct dive *dive;
|
||||||
if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
|
if (DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING ||
|
||||||
ui.InfoWidget->isEditing()) {
|
ui.InfoWidget->isEditing()) {
|
||||||
QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before trying to plan a dive."));
|
QMessageBox::warning(this, tr("Warning"), tr("Please save or cancel the current dive edit before trying to plan a dive."));
|
||||||
|
@ -334,6 +336,13 @@ void MainWindow::on_actionDivePlanner_triggered()
|
||||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
|
||||||
DivePlannerPointsModel::instance()->clear();
|
DivePlannerPointsModel::instance()->clear();
|
||||||
CylindersModel::instance()->clear();
|
CylindersModel::instance()->clear();
|
||||||
|
for_each_dive(i,dive) {
|
||||||
|
if(dive->selected){
|
||||||
|
DivePlannerPointsModel::instance()->copyCylindersFrom(dive);
|
||||||
|
CylindersModel::instance()->copyFromDive(dive);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
ui.stackedWidget->setCurrentIndex(PLANNERPROFILE);
|
ui.stackedWidget->setCurrentIndex(PLANNERPROFILE);
|
||||||
ui.infoPane->setCurrentIndex(PLANNERWIDGET);
|
ui.infoPane->setCurrentIndex(PLANNERWIDGET);
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,6 +332,23 @@ void CylindersModel::setDive(dive *d)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CylindersModel::copyFromDive(dive *d)
|
||||||
|
{
|
||||||
|
if (!d)
|
||||||
|
return;
|
||||||
|
rows = 0;
|
||||||
|
for (int i = 0; i < MAX_CYLINDERS; i++) {
|
||||||
|
if (!cylinder_none(&d->cylinder[i]) &&
|
||||||
|
(prefs.display_unused_tanks || d->cylinder[i].used)) {
|
||||||
|
rows = i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rows > 0) {
|
||||||
|
beginInsertRows(QModelIndex(), 0, rows - 1);
|
||||||
|
endInsertRows();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Qt::ItemFlags CylindersModel::flags(const QModelIndex &index) const
|
Qt::ItemFlags CylindersModel::flags(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (index.column() == REMOVE)
|
if (index.column() == REMOVE)
|
||||||
|
|
|
@ -120,6 +120,7 @@ public:
|
||||||
void clear();
|
void clear();
|
||||||
void update();
|
void update();
|
||||||
void setDive(struct dive *d);
|
void setDive(struct dive *d);
|
||||||
|
void copyFromDive(struct dive *d);
|
||||||
cylinder_t *cylinderAt(const QModelIndex &index);
|
cylinder_t *cylinderAt(const QModelIndex &index);
|
||||||
bool changed;
|
bool changed;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue