mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 23:23:23 +00:00
mobile: add ability to edit tags
We already showed the tags, but we didn't allow the user to edit them. This tries hard not to create inconsistent or illogical tags by trimming white space and being careful with how the tags are added. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
454207cd80
commit
9b669d91e0
5 changed files with 40 additions and 4 deletions
|
@ -1,3 +1,4 @@
|
|||
- mobile: add ability to edit tags
|
||||
- replace dive computer management with a new implementation, this fixes rare cases where
|
||||
Subsurface unnecessarily download already downloaded dives, but also means
|
||||
that some older style dive computer can no longer have nicknames
|
||||
|
|
|
@ -22,6 +22,7 @@ Kirigami.Page {
|
|||
property alias divemasterIndex: detailsEdit.divemasterIndex
|
||||
property alias divemasterText: detailsEdit.divemasterText
|
||||
property alias divemasterModel: detailsEdit.divemasterModel
|
||||
property alias tagText: detailsEdit.tagText
|
||||
property alias depth: detailsEdit.depthText
|
||||
property alias duration: detailsEdit.durationText
|
||||
property alias location: detailsEdit.locationText
|
||||
|
@ -353,6 +354,7 @@ Kirigami.Page {
|
|||
suitIndex = manager.suitList.indexOf(modelData.suit)
|
||||
buddyText = modelData.buddy;
|
||||
divemasterText = modelData.diveMaster
|
||||
tagText = modelData.tags
|
||||
notes = modelData.notes
|
||||
if (modelData.singleWeight) {
|
||||
// we have only one weight, go ahead, have fun and edit it
|
||||
|
|
|
@ -22,6 +22,7 @@ Item {
|
|||
property alias buddyText: buddyBox.editText
|
||||
property alias divemasterIndex: divemasterBox.currentIndex
|
||||
property alias divemasterText: divemasterBox.editText
|
||||
property alias tagText: txtTag.text
|
||||
property alias cylinderIndex0: cylinderBox0.currentIndex
|
||||
property alias cylinderIndex1: cylinderBox1.currentIndex
|
||||
property alias cylinderIndex2: cylinderBox2.currentIndex
|
||||
|
@ -118,7 +119,7 @@ Item {
|
|||
// apply the changes to the dive_table
|
||||
manager.commitChanges(dive_id, detailsEdit.number, detailsEdit.dateText, locationBox.editText, detailsEdit.gpsText, detailsEdit.durationText,
|
||||
detailsEdit.depthText, detailsEdit.airtempText, detailsEdit.watertempText,
|
||||
suitBox.editText, buddyBox.editText, divemasterBox.editText,
|
||||
suitBox.editText, buddyBox.editText, divemasterBox.editText, detailsEdit.tagText,
|
||||
detailsEdit.weightText, detailsEdit.notesText, startpressure,
|
||||
endpressure, usedGas, usedCyl,
|
||||
detailsEdit.rating,
|
||||
|
@ -331,7 +332,19 @@ Item {
|
|||
manager.divemasterList : null
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
width: Kirigami.Units.gridUnit * 20
|
||||
TemplateLabelSmall {
|
||||
Layout.preferredWidth: Kirigami.Units.gridUnit * 4
|
||||
horizontalAlignment: Text.AlignRight
|
||||
text: qsTr("Tags:")
|
||||
}
|
||||
SsrfTextField {
|
||||
Layout.preferredWidth: Kirigami.Units.gridUnit * 16
|
||||
id: txtTag
|
||||
flickable: detailsEditFlickable
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
width: Kirigami.Units.gridUnit * 16
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "core/settings/qPrefPartialPressureGas.h"
|
||||
#include "core/settings/qPrefUnit.h"
|
||||
#include "core/trip.h"
|
||||
#include "core/tag.h"
|
||||
#include "backend-shared/exportfuncs.h"
|
||||
#include "core/worldmap-save.h"
|
||||
#include "core/uploadDiveLogsDE.h"
|
||||
|
@ -1078,7 +1079,7 @@ bool QMLManager::checkDepth(dive *d, QString depth)
|
|||
|
||||
// update the dive and return the notes field, stripped of the HTML junk
|
||||
void QMLManager::commitChanges(QString diveId, QString number, QString date, QString location, QString gps, QString duration, QString depth,
|
||||
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString weight, QString notes,
|
||||
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString tags, QString weight, QString notes,
|
||||
QStringList startpressure, QStringList endpressure, QStringList gasmix, QStringList usedCylinder, int rating, int visibility, QString state)
|
||||
{
|
||||
struct dive *orig = get_dive_by_uniq_id(diveId.toInt());
|
||||
|
@ -1100,6 +1101,7 @@ void QMLManager::commitChanges(QString diveId, QString number, QString date, QSt
|
|||
QStringLiteral("suit :'%1'\n").arg(suit) <<
|
||||
QStringLiteral("buddy :'%1'\n").arg(buddy) <<
|
||||
QStringLiteral("diveMstr:'%1'\n").arg(diveMaster) <<
|
||||
QStringLiteral("tags :'%1'\n").arg(tags) <<
|
||||
QStringLiteral("weight :'%1'\n").arg(weight) <<
|
||||
QStringLiteral("state :'%1'\n").arg(state);
|
||||
}
|
||||
|
@ -1235,6 +1237,24 @@ void QMLManager::commitChanges(QString diveId, QString number, QString date, QSt
|
|||
free(d->divemaster);
|
||||
d->divemaster = copy_qstring(diveMaster);
|
||||
}
|
||||
// normalize the tag list we have and the one we get from the UI
|
||||
// try hard to deal with accidental white space issues
|
||||
QStringList existingTagList = get_taglist_string(d->tag_list).split(",", QString::SkipEmptyParts);
|
||||
QStringList newTagList = tags.split(",", QString::SkipEmptyParts);
|
||||
QStringList newCleanTagList;
|
||||
for (QString s: newTagList) {
|
||||
if (!s.simplified().isEmpty())
|
||||
newCleanTagList << s.simplified();
|
||||
}
|
||||
newCleanTagList.sort();
|
||||
existingTagList.sort();
|
||||
if (newCleanTagList.join(",") != existingTagList.join(",")) {
|
||||
diveChanged = true;
|
||||
taglist_free(d->tag_list);
|
||||
d->tag_list = nullptr;
|
||||
for (QString tag: newCleanTagList)
|
||||
taglist_add_tag(&d->tag_list, qPrintable(tag));
|
||||
}
|
||||
if (d->rating != rating) {
|
||||
diveChanged = true;
|
||||
d->rating = rating;
|
||||
|
|
|
@ -184,7 +184,7 @@ public slots:
|
|||
void commitChanges(QString diveId, QString number, QString date, QString location, QString gps,
|
||||
QString duration, QString depth, QString airtemp,
|
||||
QString watertemp, QString suit, QString buddy,
|
||||
QString diveMaster, QString weight, QString notes, QStringList startpressure,
|
||||
QString diveMaster, QString tags, QString weight, QString notes, QStringList startpressure,
|
||||
QStringList endpressure, QStringList gasmix, QStringList usedCylinder, int rating, int visibility, QString state);
|
||||
void updateTripDetails(QString tripIdString, QString tripLocation, QString tripNotes);
|
||||
void removeDiveFromTrip(int id);
|
||||
|
|
Loading…
Add table
Reference in a new issue