summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets/maintab.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-02-20 20:13:03 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commit53b4d84a6ebebc4792f3b03cb926a454075fda34 (patch)
tree0c426c0ebd5ef2c007750873f76862514c0b76c0 /desktop-widgets/tab-widgets/maintab.cpp
parent464721b2ecf27e4ecd7e3a29b78e626838ef82b8 (diff)
downloadsubsurface-53b4d84a6ebebc4792f3b03cb926a454075fda34.tar.gz
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 <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/tab-widgets/maintab.cpp')
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp71
1 files changed, 0 insertions, 71 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<dive *> &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)