2022-03-05 16:25:49 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include "TabDiveNotes.h"
|
2022-09-17 14:21:17 +00:00
|
|
|
#include "maintab.h"
|
2022-03-05 16:25:49 +00:00
|
|
|
#include "core/divesite.h"
|
|
|
|
#include "core/qthelper.h"
|
|
|
|
#include "core/selection.h"
|
|
|
|
#include "core/subsurface-string.h"
|
2024-03-26 20:06:13 +00:00
|
|
|
#include "core/tag.h"
|
2022-03-05 16:25:49 +00:00
|
|
|
#include "core/trip.h"
|
|
|
|
#include "desktop-widgets/mainwindow.h"
|
|
|
|
#include "desktop-widgets/mapwidget.h"
|
|
|
|
#include "desktop-widgets/simplewidgets.h"
|
|
|
|
#include "qt-models/diveplannermodel.h"
|
|
|
|
#include "commands/command.h"
|
|
|
|
|
|
|
|
#include <QCompleter>
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
|
|
|
struct Completers {
|
|
|
|
QCompleter *diveguide;
|
|
|
|
QCompleter *buddy;
|
|
|
|
QCompleter *tags;
|
|
|
|
};
|
|
|
|
|
2022-09-09 16:12:31 +00:00
|
|
|
TabDiveNotes::TabDiveNotes(MainTab *parent) : TabBase(parent),
|
2022-03-05 16:25:49 +00:00
|
|
|
ignoreInput(false),
|
|
|
|
currentTrip(0)
|
|
|
|
{
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
|
|
|
updateDateTimeFields();
|
|
|
|
|
|
|
|
connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &TabDiveNotes::divesChanged);
|
|
|
|
connect(&diveListNotifier, &DiveListNotifier::tripChanged, this, &TabDiveNotes::tripChanged);
|
|
|
|
connect(&diveListNotifier, &DiveListNotifier::diveSiteChanged, this, &TabDiveNotes::diveSiteEdited);
|
|
|
|
connect(&diveListNotifier, &DiveListNotifier::commandExecuted, this, &TabDiveNotes::closeWarning);
|
|
|
|
|
|
|
|
connect(ui.editDiveSiteButton, &QToolButton::clicked, MainWindow::instance(), &MainWindow::startDiveSiteEdit);
|
2022-04-09 00:24:15 +00:00
|
|
|
#ifdef MAP_SUPPORT
|
2022-03-05 16:25:49 +00:00
|
|
|
connect(ui.location, &DiveLocationLineEdit::entered, MapWidget::instance(), &MapWidget::centerOnIndex);
|
|
|
|
connect(ui.location, &DiveLocationLineEdit::currentChanged, MapWidget::instance(), &MapWidget::centerOnIndex);
|
|
|
|
#endif
|
|
|
|
connect(ui.location, &DiveLocationLineEdit::editingFinished, this, &TabDiveNotes::on_location_diveSiteSelected);
|
|
|
|
|
|
|
|
// One might think that we could listen to the precise property-changed signals of the preferences system.
|
|
|
|
// Alas, this is not the case. When the user switches to system-format, the preferences sends the according
|
|
|
|
// signal. However, the correct date and time format is set by the preferences dialog later. This should be fixed.
|
|
|
|
connect(&diveListNotifier, &DiveListNotifier::settingsChanged, this, &TabDiveNotes::updateDateTimeFields);
|
|
|
|
|
|
|
|
QAction *action = new QAction(tr("OK"), this);
|
|
|
|
connect(action, &QAction::triggered, this, &TabDiveNotes::closeWarning);
|
|
|
|
ui.multiDiveWarningMessage->addAction(action);
|
|
|
|
|
|
|
|
action = new QAction(tr("Undo"), this);
|
|
|
|
connect(action, &QAction::triggered, Command::undoAction(this), &QAction::trigger);
|
|
|
|
connect(action, &QAction::triggered, this, &TabDiveNotes::closeWarning);
|
|
|
|
ui.multiDiveWarningMessage->addAction(action);
|
|
|
|
|
|
|
|
Completers completers;
|
|
|
|
completers.buddy = new QCompleter(&buddyModel, ui.buddy);
|
|
|
|
completers.diveguide = new QCompleter(&diveGuideModel, ui.diveguide);
|
|
|
|
completers.tags = new QCompleter(&tagModel, ui.tagWidget);
|
|
|
|
completers.buddy->setCaseSensitivity(Qt::CaseInsensitive);
|
|
|
|
completers.diveguide->setCaseSensitivity(Qt::CaseInsensitive);
|
|
|
|
completers.tags->setCaseSensitivity(Qt::CaseInsensitive);
|
|
|
|
ui.buddy->setCompleter(completers.buddy);
|
|
|
|
ui.diveguide->setCompleter(completers.diveguide);
|
|
|
|
ui.tagWidget->setCompleter(completers.tags);
|
|
|
|
ui.multiDiveWarningMessage->hide();
|
|
|
|
ui.depth->hide();
|
|
|
|
ui.depthLabel->hide();
|
|
|
|
ui.duration->hide();
|
|
|
|
ui.durationLabel->hide();
|
|
|
|
setMinimumHeight(0);
|
|
|
|
setMinimumWidth(0);
|
|
|
|
|
|
|
|
connect(ui.multiDiveWarningMessage, &KMessageWidget::showAnimationFinished,
|
|
|
|
ui.location, &DiveLocationLineEdit::fixPopupPosition);
|
|
|
|
|
|
|
|
// enable URL clickability in notes:
|
|
|
|
new TextHyperlinkEventFilter(ui.notes); //destroyed when ui.notes is destroyed
|
|
|
|
|
|
|
|
ui.diveTripLocation->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::updateDateTimeFields()
|
|
|
|
{
|
|
|
|
ui.dateEdit->setDisplayFormat(prefs.date_format);
|
|
|
|
ui.timeEdit->setDisplayFormat(prefs.time_format);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::closeWarning()
|
|
|
|
{
|
|
|
|
ui.multiDiveWarningMessage->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
// This function gets called if a field gets updated by an undo command.
|
|
|
|
// Refresh the corresponding UI field.
|
|
|
|
void TabDiveNotes::divesChanged(const QVector<dive *> &dives, DiveField field)
|
|
|
|
{
|
|
|
|
// If the current dive is not in list of changed dives, do nothing
|
2022-09-17 14:21:17 +00:00
|
|
|
if (!parent.includesCurrentDive(dives))
|
2022-03-05 16:25:49 +00:00
|
|
|
return;
|
|
|
|
|
2022-09-17 14:21:17 +00:00
|
|
|
dive *currentDive = parent.currentDive;
|
2022-03-05 16:25:49 +00:00
|
|
|
if (field.duration)
|
2022-09-17 14:21:17 +00:00
|
|
|
ui.duration->setText(render_seconds_to_string(currentDive->duration.seconds));
|
2022-03-05 16:25:49 +00:00
|
|
|
if (field.depth)
|
2022-09-17 14:21:17 +00:00
|
|
|
ui.depth->setText(get_depth_string(currentDive->maxdepth, true));
|
2022-03-05 16:25:49 +00:00
|
|
|
if (field.rating)
|
2022-09-17 14:21:17 +00:00
|
|
|
ui.rating->setCurrentStars(currentDive->rating);
|
2022-03-05 16:25:49 +00:00
|
|
|
if (field.notes)
|
2022-09-17 14:21:17 +00:00
|
|
|
updateNotes(currentDive);
|
2022-03-05 16:25:49 +00:00
|
|
|
if (field.datetime) {
|
2022-09-17 14:21:17 +00:00
|
|
|
updateDateTime(currentDive);
|
|
|
|
DivePlannerPointsModel::instance()->getDiveplan().when = currentDive->when;
|
2022-03-05 16:25:49 +00:00
|
|
|
}
|
|
|
|
if (field.divesite)
|
2022-09-17 14:21:17 +00:00
|
|
|
updateDiveSite(currentDive);
|
2022-03-05 16:25:49 +00:00
|
|
|
if (field.tags)
|
2024-05-29 15:57:48 +00:00
|
|
|
ui.tagWidget->setText(QString::fromStdString(taglist_get_tagstring(currentDive->tags)));
|
2022-03-05 16:25:49 +00:00
|
|
|
if (field.buddy)
|
2024-05-29 18:40:18 +00:00
|
|
|
ui.buddy->setText(QString::fromStdString(currentDive->buddy));
|
2022-03-05 16:25:49 +00:00
|
|
|
if (field.diveguide)
|
2024-05-29 18:40:18 +00:00
|
|
|
ui.diveguide->setText(QString::fromStdString(currentDive->diveguide));
|
2022-03-05 16:25:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::diveSiteEdited(dive_site *ds, int)
|
|
|
|
{
|
2022-09-17 14:21:17 +00:00
|
|
|
if (parent.currentDive && parent.currentDive->dive_site == ds)
|
|
|
|
updateDiveSite(parent.currentDive);
|
2022-03-05 16:25:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This function gets called if a trip-field gets updated by an undo command.
|
|
|
|
// Refresh the corresponding UI field.
|
|
|
|
void TabDiveNotes::tripChanged(dive_trip *trip, TripField field)
|
|
|
|
{
|
|
|
|
// If the current dive is not in list of changed dives, do nothing
|
|
|
|
if (currentTrip != trip)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (field.notes)
|
2024-05-31 15:15:47 +00:00
|
|
|
ui.notes->setText(QString::fromStdString(currentTrip->notes));
|
2022-03-05 16:25:49 +00:00
|
|
|
if (field.location)
|
2024-05-31 15:15:47 +00:00
|
|
|
ui.diveTripLocation->setText(QString::fromStdString(currentTrip->location));
|
2022-03-05 16:25:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool isHtml(const QString &s)
|
|
|
|
{
|
|
|
|
return s.contains("<div", Qt::CaseInsensitive) || s.contains("<table", Qt::CaseInsensitive);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::updateNotes(const struct dive *d)
|
|
|
|
{
|
2024-05-29 18:40:18 +00:00
|
|
|
QString tmp = QString::fromStdString(d->notes);
|
2022-03-05 16:25:49 +00:00
|
|
|
if (isHtml(tmp)) {
|
|
|
|
ui.notes->setHtml(tmp);
|
|
|
|
} else {
|
|
|
|
ui.notes->setPlainText(tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::updateDateTime(const struct dive *d)
|
|
|
|
{
|
|
|
|
QDateTime localTime = timestampToDateTime(d->when);
|
|
|
|
ui.dateEdit->setDate(localTime.date());
|
|
|
|
ui.timeEdit->setTime(localTime.time());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::updateTripDate(const struct dive_trip *t)
|
|
|
|
{
|
|
|
|
QDateTime localTime = timestampToDateTime(trip_date(t));
|
|
|
|
ui.dateEdit->setDate(localTime.date());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::updateDiveSite(struct dive *d)
|
|
|
|
{
|
|
|
|
struct dive_site *ds = d->dive_site;
|
|
|
|
ui.location->setCurrentDiveSite(d);
|
|
|
|
if (ds) {
|
2024-05-11 16:23:40 +00:00
|
|
|
ui.locationTags->setText(QString::fromStdString(taxonomy_get_location_tags(ds->taxonomy, true)));
|
2022-03-05 16:25:49 +00:00
|
|
|
|
|
|
|
if (ui.locationTags->text().isEmpty() && has_location(&ds->location))
|
|
|
|
ui.locationTags->setText(printGPSCoords(&ds->location));
|
|
|
|
ui.editDiveSiteButton->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
ui.locationTags->clear();
|
|
|
|
ui.editDiveSiteButton->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ui.locationTags->text().isEmpty())
|
|
|
|
ui.locationTags->hide();
|
|
|
|
else
|
|
|
|
ui.locationTags->show();
|
|
|
|
}
|
|
|
|
|
2022-09-04 09:04:01 +00:00
|
|
|
void TabDiveNotes::updateData(const std::vector<dive *> &, dive *currentDive, int currentDC)
|
2022-03-05 16:25:49 +00:00
|
|
|
{
|
|
|
|
ui.location->refreshDiveSiteCache();
|
|
|
|
|
|
|
|
ignoreInput = true; // don't trigger on changes to the widgets
|
|
|
|
|
|
|
|
currentTrip = single_selected_trip();
|
|
|
|
if (currentTrip) {
|
|
|
|
// only use trip relevant fields
|
|
|
|
ui.diveguide->setVisible(false);
|
|
|
|
ui.DiveguideLabel->setVisible(false);
|
|
|
|
ui.buddy->setVisible(false);
|
|
|
|
ui.BuddyLabel->setVisible(false);
|
|
|
|
ui.rating->setVisible(false);
|
|
|
|
ui.RatingLabel->setVisible(false);
|
|
|
|
ui.tagWidget->setVisible(false);
|
|
|
|
ui.TagLabel->setVisible(false);
|
|
|
|
ui.dateEdit->setReadOnly(true);
|
|
|
|
ui.timeLabel->setVisible(false);
|
|
|
|
ui.timeEdit->setVisible(false);
|
|
|
|
ui.diveTripLocation->show();
|
|
|
|
ui.location->hide();
|
|
|
|
ui.locationPopupButton->hide();
|
|
|
|
ui.editDiveSiteButton->hide();
|
|
|
|
// rename the remaining fields and fill data from selected trip
|
|
|
|
ui.LocationLabel->setText(tr("Trip location"));
|
2024-05-31 15:15:47 +00:00
|
|
|
ui.diveTripLocation->setText(QString::fromStdString(currentTrip->location));
|
2022-03-05 16:25:49 +00:00
|
|
|
updateTripDate(currentTrip);
|
|
|
|
ui.locationTags->clear();
|
|
|
|
//TODO: Fix this.
|
2024-05-31 15:15:47 +00:00
|
|
|
//ui.location->setText(QString::fromStdSTring(currentTrip->location));
|
2022-03-05 16:25:49 +00:00
|
|
|
ui.NotesLabel->setText(tr("Trip notes"));
|
2024-05-31 15:15:47 +00:00
|
|
|
ui.notes->setText(QString::fromStdString(currentTrip->notes));
|
2022-03-05 16:25:49 +00:00
|
|
|
ui.depth->setVisible(false);
|
|
|
|
ui.depthLabel->setVisible(false);
|
|
|
|
ui.duration->setVisible(false);
|
|
|
|
ui.durationLabel->setVisible(false);
|
|
|
|
} else {
|
|
|
|
// make all the fields visible writeable
|
|
|
|
ui.diveTripLocation->hide();
|
|
|
|
ui.location->show();
|
|
|
|
ui.locationPopupButton->show();
|
|
|
|
ui.editDiveSiteButton->show();
|
|
|
|
ui.diveguide->setVisible(true);
|
|
|
|
ui.buddy->setVisible(true);
|
|
|
|
ui.rating->setVisible(true);
|
|
|
|
ui.RatingLabel->setVisible(true);
|
|
|
|
ui.BuddyLabel->setVisible(true);
|
|
|
|
ui.DiveguideLabel->setVisible(true);
|
|
|
|
ui.TagLabel->setVisible(true);
|
|
|
|
ui.tagWidget->setVisible(true);
|
|
|
|
ui.dateEdit->setReadOnly(false);
|
|
|
|
ui.timeLabel->setVisible(true);
|
|
|
|
ui.timeEdit->setVisible(true);
|
|
|
|
/* and fill them from the dive */
|
2022-09-04 09:04:01 +00:00
|
|
|
ui.rating->setCurrentStars(currentDive->rating);
|
2022-03-05 16:25:49 +00:00
|
|
|
// reset labels in case we last displayed trip notes
|
|
|
|
ui.LocationLabel->setText(tr("Location"));
|
|
|
|
ui.NotesLabel->setText(tr("Notes"));
|
2024-05-29 15:57:48 +00:00
|
|
|
ui.tagWidget->setText(QString::fromStdString(taglist_get_tagstring(currentDive->tags)));
|
2024-05-27 15:09:48 +00:00
|
|
|
bool isManual = is_dc_manually_added_dive(¤tDive->dcs[0]);
|
2022-03-05 16:25:49 +00:00
|
|
|
ui.depth->setVisible(isManual);
|
|
|
|
ui.depthLabel->setVisible(isManual);
|
|
|
|
ui.duration->setVisible(isManual);
|
|
|
|
ui.durationLabel->setVisible(isManual);
|
|
|
|
|
2022-09-04 09:04:01 +00:00
|
|
|
updateNotes(currentDive);
|
|
|
|
updateDiveSite(currentDive);
|
|
|
|
updateDateTime(currentDive);
|
2024-05-29 18:40:18 +00:00
|
|
|
ui.diveguide->setText(QString::fromStdString(currentDive->diveguide));
|
|
|
|
ui.buddy->setText(QString::fromStdString(currentDive->buddy));
|
2022-03-05 16:25:49 +00:00
|
|
|
}
|
2022-09-04 09:04:01 +00:00
|
|
|
ui.duration->setText(render_seconds_to_string(currentDive->duration.seconds));
|
|
|
|
ui.depth->setText(get_depth_string(currentDive->maxdepth, true));
|
2022-03-05 16:25:49 +00:00
|
|
|
|
|
|
|
ui.editDiveSiteButton->setEnabled(!ui.location->text().isEmpty());
|
|
|
|
/* unset the special value text for date and time, just in case someone dove at midnight */
|
|
|
|
ui.dateEdit->setSpecialValueText(QString());
|
|
|
|
ui.timeEdit->setSpecialValueText(QString());
|
|
|
|
|
|
|
|
ignoreInput = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::clear()
|
|
|
|
{
|
|
|
|
ui.rating->setCurrentStars(0);
|
|
|
|
ui.location->clear();
|
|
|
|
ui.diveguide->clear();
|
|
|
|
ui.buddy->clear();
|
|
|
|
ui.notes->clear();
|
|
|
|
/* set date and time to minimums which triggers showing the special value text */
|
|
|
|
ui.dateEdit->setSpecialValueText(QString("-"));
|
|
|
|
ui.dateEdit->setMinimumDate(QDate(1, 1, 1));
|
|
|
|
ui.dateEdit->setDate(QDate(1, 1, 1));
|
|
|
|
ui.timeEdit->setSpecialValueText(QString("-"));
|
|
|
|
ui.timeEdit->setMinimumTime(QTime(0, 0, 0, 0));
|
|
|
|
ui.timeEdit->setTime(QTime(0, 0, 0, 0));
|
|
|
|
ui.tagWidget->clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::divesEdited(int i)
|
|
|
|
{
|
|
|
|
// No warning if only one dive was edited
|
|
|
|
if (i <= 1)
|
|
|
|
return;
|
|
|
|
ui.multiDiveWarningMessage->setCloseButtonVisible(false);
|
|
|
|
ui.multiDiveWarningMessage->setText(tr("Warning: edited %1 dives").arg(i));
|
|
|
|
ui.multiDiveWarningMessage->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::on_buddy_editingFinished()
|
|
|
|
{
|
2022-09-17 14:21:17 +00:00
|
|
|
if (ignoreInput || !parent.currentDive)
|
2022-03-05 16:25:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
divesEdited(Command::editBuddies(stringToList(ui.buddy->toPlainText()), false));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::on_diveguide_editingFinished()
|
|
|
|
{
|
2022-09-17 14:21:17 +00:00
|
|
|
if (ignoreInput || !parent.currentDive)
|
2022-03-05 16:25:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
divesEdited(Command::editDiveGuide(stringToList(ui.diveguide->toPlainText()), false));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::on_duration_editingFinished()
|
|
|
|
{
|
2022-09-17 14:21:17 +00:00
|
|
|
if (ignoreInput || !parent.currentDive)
|
2022-03-05 16:25:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Duration editing is special: we only edit the current dive.
|
|
|
|
divesEdited(Command::editDuration(parseDurationToSeconds(ui.duration->text()), true));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::on_depth_editingFinished()
|
|
|
|
{
|
2022-09-17 14:21:17 +00:00
|
|
|
if (ignoreInput || !parent.currentDive)
|
2022-03-05 16:25:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Depth editing is special: we only edit the current dive.
|
|
|
|
divesEdited(Command::editDepth(parseLengthToMm(ui.depth->text()), true));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Editing of the dive time is different. If multiple dives are edited,
|
|
|
|
// all dives are shifted by an offset.
|
2022-09-17 14:21:17 +00:00
|
|
|
static void shiftTime(QDateTime &dateTime, dive *currentDive)
|
2022-03-05 16:25:49 +00:00
|
|
|
{
|
|
|
|
timestamp_t when = dateTimeToTimestamp(dateTime);
|
2022-09-17 14:21:17 +00:00
|
|
|
if (currentDive->when != when) {
|
|
|
|
timestamp_t offset = when - currentDive->when;
|
2022-03-05 16:25:49 +00:00
|
|
|
Command::shiftTime(getDiveSelection(), (int)offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::on_dateEdit_editingFinished()
|
|
|
|
{
|
2022-09-17 14:21:17 +00:00
|
|
|
if (ignoreInput || !parent.currentDive)
|
2022-03-05 16:25:49 +00:00
|
|
|
return;
|
2022-09-17 14:21:17 +00:00
|
|
|
QDateTime dateTime = timestampToDateTime(parent.currentDive->when);
|
2022-03-05 16:25:49 +00:00
|
|
|
dateTime.setDate(ui.dateEdit->date());
|
2022-09-17 14:21:17 +00:00
|
|
|
shiftTime(dateTime, parent.currentDive);
|
2022-03-05 16:25:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::on_timeEdit_editingFinished()
|
|
|
|
{
|
2022-09-17 14:21:17 +00:00
|
|
|
if (ignoreInput || !parent.currentDive)
|
2022-03-05 16:25:49 +00:00
|
|
|
return;
|
2022-09-17 14:21:17 +00:00
|
|
|
QDateTime dateTime = timestampToDateTime(parent.currentDive->when);
|
2022-03-05 16:25:49 +00:00
|
|
|
dateTime.setTime(ui.timeEdit->time());
|
2022-09-17 14:21:17 +00:00
|
|
|
shiftTime(dateTime, parent.currentDive);
|
2022-03-05 16:25:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::on_tagWidget_editingFinished()
|
|
|
|
{
|
2022-09-17 14:21:17 +00:00
|
|
|
if (ignoreInput || !parent.currentDive)
|
2022-03-05 16:25:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
divesEdited(Command::editTags(ui.tagWidget->getBlockStringList(), false));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::on_location_diveSiteSelected()
|
|
|
|
{
|
2022-09-17 14:21:17 +00:00
|
|
|
if (ignoreInput || !parent.currentDive)
|
2022-03-05 16:25:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
struct dive_site *newDs = ui.location->currDiveSite();
|
|
|
|
if (newDs == RECENTLY_ADDED_DIVESITE)
|
|
|
|
divesEdited(Command::editDiveSiteNew(ui.location->text(), false));
|
|
|
|
else
|
|
|
|
divesEdited(Command::editDiveSite(newDs, false));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::on_locationPopupButton_clicked()
|
|
|
|
{
|
|
|
|
ui.location->showAllSites();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::on_diveTripLocation_editingFinished()
|
|
|
|
{
|
|
|
|
if (!currentTrip)
|
|
|
|
return;
|
|
|
|
Command::editTripLocation(currentTrip, ui.diveTripLocation->text());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::on_notes_editingFinished()
|
|
|
|
{
|
2022-09-17 14:21:17 +00:00
|
|
|
if (!currentTrip && !parent.currentDive)
|
2022-03-05 16:25:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
QString html = ui.notes->toHtml();
|
2024-01-16 16:39:19 +00:00
|
|
|
QString notes = isHtml(html) ? std::move(html) : ui.notes->toPlainText();
|
2022-03-05 16:25:49 +00:00
|
|
|
|
|
|
|
if (currentTrip)
|
|
|
|
Command::editTripNotes(currentTrip, notes);
|
|
|
|
else
|
|
|
|
divesEdited(Command::editNotes(notes, false));
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabDiveNotes::on_rating_valueChanged(int value)
|
|
|
|
{
|
2022-09-17 14:21:17 +00:00
|
|
|
if (ignoreInput || !parent.currentDive)
|
2022-03-05 16:25:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
divesEdited(Command::editRating(value, false));
|
|
|
|
}
|