Fixes showing the Empty Profile when Add / Plan dive is cancelled.

for some reason the next selected dive is NULL after cancelling the
plan. I'm investigating.

This patch fixes the show of the empty profile and it also untangles
some parts of the code, keeping the mainwindow where it should belong
: the mainwindow.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-05-28 15:43:32 -03:00 committed by Dirk Hohndel
parent 2f8f632cf6
commit 1e4f744165
4 changed files with 25 additions and 19 deletions

View file

@ -256,7 +256,7 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg
connect(ui.buttonBox, SIGNAL(rejected()), plannerModel, SLOT(cancelPlan()));
connect(plannerModel, SIGNAL(planCreated()), MainWindow::instance(), SLOT(removeFakeDiveForAddAndPlan()));
connect(plannerModel, SIGNAL(planCreated()), MainWindow::instance(), SLOT(showProfile()));
connect(plannerModel, SIGNAL(planCanceled()), MainWindow::instance(), SLOT(showProfile()));
connect(plannerModel, SIGNAL(planCanceled()), MainWindow::instance(), SLOT(planCanceled()));
/* set defaults. */
ui.startTime->setTime(QTime(1, 0));
@ -653,18 +653,14 @@ void DivePlannerPointsModel::cancelPlan()
return;
}
}
// we unselected all dives earlier, so restore that first and then recreate the dive list
MainWindow::instance()->removeFakeDiveForAddAndPlan();
MainWindow::instance()->dive_list()->restoreSelection();
MainWindow::instance()->dive_list()->reload(DiveTripModel::CURRENT);
MainWindow::instance()->refreshDisplay();
emit planCanceled();
if (mode != ADD) {
free(stagingDive);
stagingDive = NULL;
}
setPlanMode(NOTHING);
diveplan.dp = NULL;
emit planCanceled();
}
DivePlannerPointsModel::Mode DivePlannerPointsModel::currentMode() const