Undo: inform maintab if dive site changed

If a dive site was edited, the location field should be updated.
Do this by hooking into the diveSiteChanged signal of DiveListNotifier.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-03-29 17:48:08 +01:00 committed by Dirk Hohndel
parent 4a3ffeba05
commit bfb6a55707
2 changed files with 8 additions and 0 deletions

View file

@ -82,6 +82,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &MainTab::divesChanged);
connect(&diveListNotifier, &DiveListNotifier::tripChanged, this, &MainTab::tripChanged);
connect(&diveListNotifier, &DiveListNotifier::diveSiteChanged, this, &MainTab::diveSiteEdited);
connect(ui.editDiveSiteButton, &QToolButton::clicked, MainWindow::instance(), &MainWindow::startDiveSiteEdit);
connect(ui.location, &DiveLocationLineEdit::entered, MapWidget::instance(), &MapWidget::centerOnIndex);
@ -381,6 +382,12 @@ void MainTab::divesChanged(dive_trip *trip, const QVector<dive *> &dives, DiveFi
}
}
void MainTab::diveSiteEdited(dive_site *ds, int)
{
if (current_dive && current_dive->dive_site == ds)
updateDiveSite(current_dive);
}
// This function gets called if a trip-field gets updated by an undo command.
// Refresh the corresponding UI field.
void MainTab::tripChanged(dive_trip *trip, TripField field)

View file

@ -59,6 +59,7 @@ signals:
public
slots:
void divesChanged(dive_trip *trip, const QVector<dive *> &dives, DiveField field);
void diveSiteEdited(dive_site *ds, int field);
void tripChanged(dive_trip *trip, TripField field);
void addCylinder_clicked();
void addWeight_clicked();