diff options
Diffstat (limited to 'desktop-widgets/tab-widgets/maintab.cpp')
-rw-r--r-- | desktop-widgets/tab-widgets/maintab.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index 19fa56332..eff22192b 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -375,6 +375,9 @@ void MainTab::divesEdited(const QVector<dive *> &, DiveField field) case DiveField::TAGS: ui.tagWidget->setText(get_taglist_string(current_dive->tag_list)); break; + case DiveField::BUDDY: + ui.buddy->setText(current_dive->buddy); + break; default: break; } @@ -979,21 +982,20 @@ void MainTab::markChangedWidget(QWidget *w) modified = true; } -void MainTab::on_buddy_textChanged() +static QStringList stringToList(const QString &s) { - if (editMode == IGNORE || acceptingEdit == true) - return; + QStringList res = s.split(",", QString::SkipEmptyParts); + for (QString &str: res) + str = str.trimmed(); + return res; +} - if (same_string(displayed_dive.buddy, qPrintable(ui.buddy->toPlainText()))) +void MainTab::on_buddy_editingFinished() +{ + if (editMode == IGNORE || acceptingEdit == true || !current_dive) return; - QStringList text_list = ui.buddy->toPlainText().split(",", QString::SkipEmptyParts); - for (int i = 0; i < text_list.size(); i++) - text_list[i] = text_list[i].trimmed(); - QString text = text_list.join(", "); - free(displayed_dive.buddy); - displayed_dive.buddy = copy_qstring(text); - markChangedWidget(ui.buddy); + Command::editBuddies(getSelectedDivesCurrentLast(), stringToList(ui.buddy->toPlainText()), current_dive); } void MainTab::on_divemaster_textChanged() |