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>
This commit is contained in:
Tomaz Canabrava 2013-08-13 08:34:04 -03:00
parent 16addbf373
commit 3464bcf6ef
2 changed files with 20 additions and 10 deletions

View file

@ -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();
}
return false;
if (event->type() == QEvent::MouseButtonPress) {
enableEdition();
}
return false; // don't "eat" the event.
}
void MainTab::clearEquipment()

View file

@ -72,6 +72,7 @@ private:
QPushButton *addCylinder;
QPushButton *addWeight;
enum { NONE, DIVE, TRIP } editMode;
void enableEdition();
};
#endif