Change color / mark widget as changed correctly on LocationEdit

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2015-03-09 15:51:32 -03:00 committed by Dirk Hohndel
parent 30c5a027ca
commit 986b6c509a
2 changed files with 39 additions and 5 deletions

View file

@ -696,10 +696,14 @@ void LocationInformationWidget::setLocationId(uint32_t uuid)
ui.diveSiteCoordinates->clear();
}
displayed_dive_site = *currentDs;
ui.diveSiteName->setText(displayed_dive_site.name);
ui.diveSiteDescription->setText(displayed_dive_site.description);
ui.diveSiteNotes->setPlainText(displayed_dive_site.notes);
ui.diveSiteCoordinates->setText(printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg));
if (displayed_dive_site.name)
ui.diveSiteName->setText(displayed_dive_site.name);
if (displayed_dive_site.description)
ui.diveSiteDescription->setText(displayed_dive_site.description);
if (displayed_dive_site.notes)
ui.diveSiteNotes->setPlainText(displayed_dive_site.notes);
if (displayed_dive_site.latitude.udeg || displayed_dive_site.longitude.udeg)
ui.diveSiteCoordinates->setText(printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg));
}
void LocationInformationWidget::updateGpsCoordinates()
@ -769,5 +773,30 @@ void LocationInformationWidget::markChangedWidget(QWidget *w)
void LocationInformationWidget::enableEdition()
{
MainWindow::instance()->dive_list()->setEnabled(false);
MainWindow::instance()->setEnabledToolbar(false);
ui.diveSiteMessage->show();
}
void LocationInformationWidget::on_diveSiteCoordinates_textChanged(const QString& text)
{
markChangedWidget(ui.diveSiteCoordinates);
}
void LocationInformationWidget::on_diveSiteDescription_textChanged(const QString& text)
{
if (!same_string(qPrintable(text), currentDs->description))
markChangedWidget(ui.diveSiteDescription);
}
void LocationInformationWidget::on_diveSiteName_textChanged(const QString& text)
{
if (!same_string(qPrintable(text), currentDs->name))
markChangedWidget(ui.diveSiteName);
}
void LocationInformationWidget::on_diveSiteNotes_textChanged()
{
if (!same_string(qPrintable(ui.diveSiteNotes->toPlainText()), currentDs->notes))
markChangedWidget(ui.diveSiteNotes);
}

View file

@ -232,6 +232,11 @@ public slots:
void updateGpsCoordinates(void);
void markChangedWidget(QWidget *w);
void enableEdition();
void on_diveSiteCoordinates_textChanged(const QString& text);
void on_diveSiteDescription_textChanged(const QString& text);
void on_diveSiteName_textChanged(const QString& text);
void on_diveSiteNotes_textChanged();
signals:
void informationManagementEnded();