mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
c2f7702805
commit
dee59e5334
3 changed files with 23 additions and 5 deletions
|
@ -232,6 +232,8 @@ SimpleDiveSiteEditDialog::SimpleDiveSiteEditDialog(QWidget *parent) :
|
||||||
ui(new Ui::SimpleDiveSiteEditDialog()), changed_dive_site(false)
|
ui(new Ui::SimpleDiveSiteEditDialog()), changed_dive_site(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
ui->diveSiteDescription->installEventFilter(this);
|
||||||
|
ui->diveSiteNotes->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleDiveSiteEditDialog::~SimpleDiveSiteEditDialog()
|
SimpleDiveSiteEditDialog::~SimpleDiveSiteEditDialog()
|
||||||
|
@ -239,6 +241,18 @@ SimpleDiveSiteEditDialog::~SimpleDiveSiteEditDialog()
|
||||||
delete ui;
|
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)
|
void SimpleDiveSiteEditDialog::showEvent(QShowEvent *ev)
|
||||||
{
|
{
|
||||||
const int heigth = 275;
|
const int heigth = 275;
|
||||||
|
@ -292,7 +306,7 @@ void SimpleDiveSiteEditDialog::on_diveSiteCoordinates_editingFinished()
|
||||||
changed_dive_site = true;
|
changed_dive_site = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleDiveSiteEditDialog::on_diveSiteDescription_editingFinished()
|
void SimpleDiveSiteEditDialog::diveSiteDescription_editingFinished()
|
||||||
{
|
{
|
||||||
if (ui->diveSiteDescription->toPlainText() == displayed_dive_site.description)
|
if (ui->diveSiteDescription->toPlainText() == displayed_dive_site.description)
|
||||||
return;
|
return;
|
||||||
|
@ -301,7 +315,7 @@ void SimpleDiveSiteEditDialog::on_diveSiteDescription_editingFinished()
|
||||||
changed_dive_site = true;
|
changed_dive_site = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleDiveSiteEditDialog::on_diveSiteNotes_editingFinished()
|
void SimpleDiveSiteEditDialog::diveSiteNotes_editingFinished()
|
||||||
{
|
{
|
||||||
if (ui->diveSiteNotes->toPlainText() == displayed_dive_site.notes)
|
if (ui->diveSiteNotes->toPlainText() == displayed_dive_site.notes)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -52,11 +52,12 @@ public:
|
||||||
SimpleDiveSiteEditDialog(QWidget *parent);
|
SimpleDiveSiteEditDialog(QWidget *parent);
|
||||||
virtual ~SimpleDiveSiteEditDialog();
|
virtual ~SimpleDiveSiteEditDialog();
|
||||||
bool changed_dive_site;
|
bool changed_dive_site;
|
||||||
|
bool eventFilter(QObject *obj, QEvent *ev);
|
||||||
public slots:
|
public slots:
|
||||||
void on_diveSiteName_editingFinished();
|
void on_diveSiteName_editingFinished();
|
||||||
void on_diveSiteCoordinates_editingFinished();
|
void on_diveSiteCoordinates_editingFinished();
|
||||||
void on_diveSiteDescription_editingFinished();
|
void diveSiteDescription_editingFinished();
|
||||||
void on_diveSiteNotes_editingFinished();
|
void diveSiteNotes_editingFinished();
|
||||||
protected:
|
protected:
|
||||||
void showEvent(QShowEvent *ev);
|
void showEvent(QShowEvent *ev);
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -805,7 +805,10 @@ void MainTab::acceptChanges()
|
||||||
addedId = added_dive->id;
|
addedId = added_dive->id;
|
||||||
if (displayed_dive_site.uuid)
|
if (displayed_dive_site.uuid)
|
||||||
copy_dive_site(&displayed_dive_site, get_dive_site_by_uuid(displayed_dive_site.uuid));
|
copy_dive_site(&displayed_dive_site, get_dive_site_by_uuid(displayed_dive_site.uuid));
|
||||||
|
else if (ui.location->text().count()) {
|
||||||
|
uint32_t uuid = create_dive_site(qPrintable(ui.location->text()));
|
||||||
|
added_dive->dive_site_uuid = uuid;
|
||||||
|
}
|
||||||
// unselect everything as far as the UI is concerned and select the new
|
// unselect everything as far as the UI is concerned and select the new
|
||||||
// dive - we'll have to undo/redo this later after we resort the dive_table
|
// dive - we'll have to undo/redo this later after we resort the dive_table
|
||||||
// but we need the dive selected for the middle part of this function - this
|
// but we need the dive selected for the middle part of this function - this
|
||||||
|
|
Loading…
Add table
Reference in a new issue