aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/command_edit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'desktop-widgets/command_edit.cpp')
-rw-r--r--desktop-widgets/command_edit.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/desktop-widgets/command_edit.cpp b/desktop-widgets/command_edit.cpp
index c3a47016e..165bbbe90 100644
--- a/desktop-widgets/command_edit.cpp
+++ b/desktop-widgets/command_edit.cpp
@@ -3,6 +3,7 @@
#include "command_edit.h"
#include "core/divelist.h"
#include "core/qthelper.h" // for copy_qstring
+#include "desktop-widgets/mapwidget.h" // TODO: Replace desktop-dependency by signal
namespace Command {
@@ -450,4 +451,36 @@ DiveField EditTags::fieldId() const
return DiveField::TAGS;
}
+// String list helper
+static QStringList stringToList(const QString &s)
+{
+ QStringList res = s.split(",", QString::SkipEmptyParts);
+ for (QString &str: res)
+ str = str.trimmed();
+ return res;
+}
+
+// ***** Buddies *****
+QStringList EditBuddies::data(struct dive *d) const
+{
+ return stringToList(d->buddy);
+}
+
+void EditBuddies::set(struct dive *d, const QStringList &v) const
+{
+ QString text = v.join(", ");
+ free(d->buddy);
+ d->buddy = copy_qstring(text);
+}
+
+QString EditBuddies::fieldName() const
+{
+ return tr("buddies");
+}
+
+DiveField EditBuddies::fieldId() const
+{
+ return DiveField::BUDDY;
+}
+
} // namespace Command