summaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-08-13 08:34:04 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-08-13 08:34:04 -0300
commit3464bcf6ef50a8b38c2fd91416c3d7ce932fdc7a (patch)
tree2544ce4379922985841f0fa9f55bfca16e1200d9 /qt-ui/maintab.cpp
parent16addbf373d138819411540a5be49513d58a4038 (diff)
downloadsubsurface-3464bcf6ef50a8b38c2fd91416c3d7ce932fdc7a.tar.gz
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 <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r--qt-ui/maintab.cpp29
1 files changed, 19 insertions, 10 deletions
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()