mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Undo: implement undo of buddy editing
This was mostly trivial by reusing the code for tag-editing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
8c89f6fe15
commit
a9bd0690fe
6 changed files with 63 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue