Back to profile or empty state when finishing addition.

This patch adds a signal to MainTab, that should be removed from there
when we finish the rework on the edit part, to go to the edit classes,
but in the meantime, let's keep it there.

The signal is connected to the ProfileWidget in a way that the end of the
edit will also trigger the profile to go back to ProfileState (show the
dive, if there's any) or empty Profile (if there's none).

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-21 20:34:06 -03:00 committed by Dirk Hohndel
parent 3661f291a4
commit fe1df6b1cc
4 changed files with 12 additions and 0 deletions

View file

@ -761,6 +761,7 @@ void MainTab::acceptChanges()
editMode = NONE;
MainWindow::instance()->refreshDisplay();
MainWindow::instance()->graphics()->replot();
emit addDiveFinished();
} else {
editMode = NONE;
MainWindow::instance()->dive_list()->rememberSelection();
@ -861,6 +862,7 @@ void MainTab::rejectChanges()
delete_single_dive(selected_dive);
MainWindow::instance()->dive_list()->reload(DiveTripModel::CURRENT);
MainWindow::instance()->dive_list()->restoreSelection();
emit addDiveFinished();
}
if (selected_dive >= 0) {
multiEditEquipmentPlaceholder = *get_dive(selected_dive);

View file

@ -67,6 +67,9 @@ public:
bool isEditing();
void updateCoordinatesText(qreal lat, qreal lon);
void nextInputField(QKeyEvent *event);
signals:
void addDiveFinished();
public
slots:
void addCylinder_clicked();

View file

@ -75,6 +75,7 @@ MainWindow::MainWindow() : QMainWindow(),
connect(ui.actionRecent2, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool)));
connect(ui.actionRecent3, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool)));
connect(ui.actionRecent4, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool)));
connect(information(), SIGNAL(addDiveFinished()), ui.newProfile, SLOT(setProfileState()));
ui.mainErrorMessage->hide();
initialUiSetup();

View file

@ -606,6 +606,7 @@ void ProfileWidget2::setEmptyState()
if (currentState == EMPTY)
return;
setBackgroundBrush(getColor(::BACKGROUND, isGrayscale));
dataModel->clear();
currentState = EMPTY;
MainWindow::instance()->setToolButtonsEnabled(false);
@ -642,6 +643,11 @@ void ProfileWidget2::setProfileState()
if (currentState == PROFILE)
return;
if (dive_table.nr == 0) { // oops, called to plot something with zero dives. bail out.
setEmptyState();
return;
}
currentState = PROFILE;
MainWindow::instance()->setToolButtonsEnabled(true);
toolTipItem->readPos();