From 3464bcf6ef50a8b38c2fd91416c3d7ce932fdc7a Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 13 Aug 2013 08:34:04 -0300 Subject: Makes the 'auto' edition behave in a better way. This patch makes the auto editon behave in a better way, now you can scroll the notes widget without marking it as editable, and also adds a bit of code cleanup, and a better logic for editing the other widgets. Signed-off-by: Tomaz Canabrava --- qt-ui/maintab.cpp | 29 +++++++++++++++++++---------- qt-ui/maintab.h | 1 + 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index f9d36342f..4057db1cf 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -52,7 +52,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui->divemaster->installEventFilter(this); ui->buddy->installEventFilter(this); ui->suit->installEventFilter(this); - ui->notes->installEventFilter(this); + ui->notes->viewport()->installEventFilter(this); ui->rating->installEventFilter(this); ui->visibility->installEventFilter(this); @@ -126,18 +126,27 @@ void MainTab::equipmentPlusUpdate() addWeight->setGeometry(ui->weightGroup->contentsRect().width() - 30, 2, 24,24); } +void MainTab::enableEdition() +{ + if (ui->editAccept->isVisible() || !currentDive) + return; + + ui->editAccept->setChecked(true); + ui->editAccept->show(); + ui->editReset->show(); + on_editAccept_clicked(true); +} + bool MainTab::eventFilter(QObject* object, QEvent* event) { - if (event->type() == QEvent::FocusIn || event->type() == QEvent::MouseButtonPress) { - if (ui->editAccept->isVisible() || !currentDive) - return false; - - ui->editAccept->setChecked(true); - ui->editAccept->show(); - ui->editReset->show(); - on_editAccept_clicked(true); + if (event->type() == QEvent::FocusIn && (object == ui->rating || object == ui->visibility)){ + enableEdition(); + } + + if (event->type() == QEvent::MouseButtonPress) { + enableEdition(); } - return false; + return false; // don't "eat" the event. } void MainTab::clearEquipment() diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index af76fbb67..745f401a4 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -72,6 +72,7 @@ private: QPushButton *addCylinder; QPushButton *addWeight; enum { NONE, DIVE, TRIP } editMode; + void enableEdition(); }; #endif -- cgit v1.2.3-70-g09d2