From 53b4d84a6ebebc4792f3b03cb926a454075fda34 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Wed, 20 Feb 2019 20:13:03 +0100 Subject: [PATCH] Undo: remove MainTab::*TaggedStrings() functions Moving the tagged-string edit functions into the undo-system made the MainTab::saveTaggedStrings() and MainTab::diffTaggedStrings() functions unnecessary. Remove them. Signed-off-by: Berthold Stoeger --- desktop-widgets/tab-widgets/maintab.cpp | 71 ------------------------- desktop-widgets/tab-widgets/maintab.h | 2 - 2 files changed, 73 deletions(-) diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp index 19b096f0f..84f64e0d0 100644 --- a/desktop-widgets/tab-widgets/maintab.cpp +++ b/desktop-widgets/tab-widgets/maintab.cpp @@ -807,10 +807,6 @@ void MainTab::acceptChanges() // were identical with the master dive shown (and mark the divelist as changed) struct dive *cd = current_dive; - // three text fields are somewhat special and are represented as tags - // in the UI - they need somewhat smarter handling - saveTaggedStrings(selectedDives); - if (cylindersModel->changed) { mark_divelist_changed(true); MODIFY_DIVES(selectedDives, @@ -1099,73 +1095,6 @@ void MainTab::copyTagsToDisplayedDive() taglist_cleanup(&displayed_dive.tag_list); } -// buddy and divemaster are represented in the UI just like the tags, but the internal -// representation is just a string (with commas as delimiters). So we need to do the same -// thing we did for tags, just differently -void MainTab::saveTaggedStrings(const QVector &selectedDives) -{ - QStringList addedList, removedList; - struct dive *cd = current_dive; - - if (diffTaggedStrings(cd->buddy, displayed_dive.buddy, addedList, removedList)) - MODIFY_DIVES(selectedDives, - QStringList oldList = QString(mydive->buddy).split(QRegExp("\\s*,\\s*"), QString::SkipEmptyParts); - QString newString; - QString comma; - Q_FOREACH (const QString tag, oldList) { - if (!removedList.contains(tag, Qt::CaseInsensitive)) { - newString += comma + tag; - comma = ", "; - } - } - Q_FOREACH (const QString tag, addedList) { - if (!oldList.contains(tag, Qt::CaseInsensitive)) { - newString += comma + tag; - comma = ", "; - } - } - free(mydive->buddy); - mydive->buddy = copy_qstring(newString); - ); - addedList.clear(); - removedList.clear(); - if (diffTaggedStrings(cd->divemaster, displayed_dive.divemaster, addedList, removedList)) - MODIFY_DIVES(selectedDives, - QStringList oldList = QString(mydive->divemaster).split(QRegExp("\\s*,\\s*"), QString::SkipEmptyParts); - QString newString; - QString comma; - Q_FOREACH (const QString tag, oldList) { - if (!removedList.contains(tag, Qt::CaseInsensitive)) { - newString += comma + tag; - comma = ", "; - } - } - Q_FOREACH (const QString tag, addedList) { - if (!oldList.contains(tag, Qt::CaseInsensitive)) { - newString += comma + tag; - comma = ", "; - } - } - free(mydive->divemaster); - mydive->divemaster = copy_qstring(newString); - ); -} - -int MainTab::diffTaggedStrings(QString currentString, QString displayedString, QStringList &addedList, QStringList &removedList) -{ - const QStringList currentList = currentString.split(',', QString::SkipEmptyParts); - const QStringList displayedList = displayedString.split(',', QString::SkipEmptyParts); - for (const QString &tag: currentList) { - if (!displayedList.contains(tag, Qt::CaseInsensitive)) - removedList << tag.trimmed(); - } - for (const QString &tag: displayedList) { - if (!currentList.contains(tag, Qt::CaseInsensitive)) - addedList << tag.trimmed(); - } - return removedList.length() + addedList.length(); -} - void MainTab::on_tagWidget_editingFinished() { if (editMode == IGNORE || !current_dive) diff --git a/desktop-widgets/tab-widgets/maintab.h b/desktop-widgets/tab-widgets/maintab.h index dacc10955..5d341d287 100644 --- a/desktop-widgets/tab-widgets/maintab.h +++ b/desktop-widgets/tab-widgets/maintab.h @@ -119,8 +119,6 @@ private: int lastTabSelectedDiveTrip; void resetPallete(); void copyTagsToDisplayedDive(); - void saveTaggedStrings(const QVector &selectedDives); - int diffTaggedStrings(QString currentString, QString displayedString, QStringList &addedList, QStringList &removedList); void markChangedWidget(QWidget *w); dive_trip_t *currentTrip; dive_trip_t displayedTrip;