From 3b2a02dffaeaa788e08c7ba07af14df7ef055489 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 8 Jul 2015 14:27:17 -0300 Subject: Get the selected dive site from the list Hooked up an eventFilter on the QListView that displays our dive sites so it would filter the keys enter and space, storing the current dive_site uuid when that happens. Also it stores the uuid on clicks. Now we need to get that information when processing acceptedChanges() and check if the uuid stored there == displayed_dive_site.uuid and also if text != displayed_dive_site.name, because if the user didn't click on anything but only wrote stuff on the LineEdit no dive site would be selected and so uuid == displayed_dive_site.uuid (wich would mean 'no changes') Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'qt-ui/maintab.cpp') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 043fe0a6a..88b607d1b 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -67,6 +67,11 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), completer->setCaseSensitivity(Qt::CaseInsensitive); completerListview->setItemDelegate(new LocationFilterDelegate()); + locationManagementEditHelper = new LocationManagementEditHelper(); + completerListview->installEventFilter(locationManagementEditHelper); + connect(completerListview, &QAbstractItemView::activated, + locationManagementEditHelper, &LocationManagementEditHelper::handleActivation); + ui.location->setCompleter(completer); connect(ui.addDiveSite, SIGNAL(clicked()), this, SLOT(showDiveSiteSimpleEdit())); connect(ui.geocodeButton, SIGNAL(clicked()), this, SLOT(reverseGeocode())); @@ -386,6 +391,7 @@ void MainTab::enableEdition(EditMode newEditMode) displayMessage(tr("Multiple dives are being edited.")); } else { displayMessage(tr("This dive is being edited.")); + locationManagementEditHelper->resetDiveSiteUuid(); } editMode = newEditMode != NONE ? newEditMode : DIVE; } -- cgit v1.2.3-70-g09d2