diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2015-06-26 21:20:45 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-06-26 18:50:23 -0700 |
commit | dee59e5334629ff1fb89753f08f512981236a02f (patch) | |
tree | b0884739bd72a0e13d2880842ca76e8a7a9bfbfe /qt-ui/locationinformation.cpp | |
parent | c2f7702805067b121f68dd2fbf5b3ee366f280f0 (diff) | |
download | subsurface-dee59e5334629ff1fb89753f08f512981236a02f.tar.gz |
Dive site rewrite: fix adding a new dive and chaning notes / description
I had to create an event filter to deal with the missing callbacks from
QPlainTextEdit (it doesn't support editingFinished()).
Also we need to manually create a dive site on a newly added dive if the
user entered one.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/locationinformation.cpp')
-rw-r--r-- | qt-ui/locationinformation.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/qt-ui/locationinformation.cpp b/qt-ui/locationinformation.cpp index 50b3ccb1e..a63571a35 100644 --- a/qt-ui/locationinformation.cpp +++ b/qt-ui/locationinformation.cpp @@ -232,6 +232,8 @@ SimpleDiveSiteEditDialog::SimpleDiveSiteEditDialog(QWidget *parent) : ui(new Ui::SimpleDiveSiteEditDialog()), changed_dive_site(false) { ui->setupUi(this); + ui->diveSiteDescription->installEventFilter(this); + ui->diveSiteNotes->installEventFilter(this); } SimpleDiveSiteEditDialog::~SimpleDiveSiteEditDialog() @@ -239,6 +241,18 @@ SimpleDiveSiteEditDialog::~SimpleDiveSiteEditDialog() delete ui; } +bool SimpleDiveSiteEditDialog::eventFilter(QObject *obj, QEvent *ev) +{ + if (ev->type() != QEvent::FocusOut) + return false; + + if (obj == ui->diveSiteDescription) { + diveSiteDescription_editingFinished(); + } else if (obj == ui->diveSiteNotes) { + diveSiteNotes_editingFinished(); + } +} + void SimpleDiveSiteEditDialog::showEvent(QShowEvent *ev) { const int heigth = 275; @@ -292,7 +306,7 @@ void SimpleDiveSiteEditDialog::on_diveSiteCoordinates_editingFinished() changed_dive_site = true; } -void SimpleDiveSiteEditDialog::on_diveSiteDescription_editingFinished() +void SimpleDiveSiteEditDialog::diveSiteDescription_editingFinished() { if (ui->diveSiteDescription->toPlainText() == displayed_dive_site.description) return; @@ -301,7 +315,7 @@ void SimpleDiveSiteEditDialog::on_diveSiteDescription_editingFinished() changed_dive_site = true; } -void SimpleDiveSiteEditDialog::on_diveSiteNotes_editingFinished() +void SimpleDiveSiteEditDialog::diveSiteNotes_editingFinished() { if (ui->diveSiteNotes->toPlainText() == displayed_dive_site.notes) return; |