summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets
diff options
context:
space:
mode:
authorGravatar Jan Mulder <jlmulder@xs4all.nl>2018-10-10 14:07:47 +0200
committerGravatar bstoeger <32835590+bstoeger@users.noreply.github.com>2018-10-12 13:03:54 +0200
commita47df05ce5a94034fd4b5bdd83c8f425e64a5946 (patch)
treef1c7704c24843b84b506b8240a0654a758d97f4d /desktop-widgets/tab-widgets
parent6137e0bc60691f4b6542cd6bc97fe0106126f728 (diff)
downloadsubsurface-a47df05ce5a94034fd4b5bdd83c8f425e64a5946.tar.gz
Edit: prevent not needed change marking
While trying to understand more of the big change from PR 1528, I found that the divelist was marked changed while it was not changed at all. Reason is simple. The MODIFY_DIVES code assumes its called only for truly changed data. But in case of saving tagged strings, it was not. This fixes this. And I do not believe this has any visual effects. Further, the now broken indentation is fixed seperately. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Diffstat (limited to 'desktop-widgets/tab-widgets')
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp7
-rw-r--r--desktop-widgets/tab-widgets/maintab.h2
2 files changed, 5 insertions, 4 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index 053f4e043..dc794ef4f 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -1279,7 +1279,7 @@ void MainTab::saveTaggedStrings(const QVector<dive *> &selectedDives)
QStringList addedList, removedList;
struct dive *cd = current_dive;
- diffTaggedStrings(cd->buddy, displayed_dive.buddy, addedList, removedList);
+ 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;
@@ -1301,7 +1301,7 @@ void MainTab::saveTaggedStrings(const QVector<dive *> &selectedDives)
);
addedList.clear();
removedList.clear();
- diffTaggedStrings(cd->divemaster, displayed_dive.divemaster, addedList, removedList);
+ 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;
@@ -1323,7 +1323,7 @@ void MainTab::saveTaggedStrings(const QVector<dive *> &selectedDives)
);
}
-void MainTab::diffTaggedStrings(QString currentString, QString displayedString, QStringList &addedList, QStringList &removedList)
+int MainTab::diffTaggedStrings(QString currentString, QString displayedString, QStringList &addedList, QStringList &removedList)
{
QStringList displayedList, currentList;
currentList = currentString.split(',', QString::SkipEmptyParts);
@@ -1336,6 +1336,7 @@ void MainTab::diffTaggedStrings(QString currentString, QString displayedString,
if (!currentList.contains(tag, Qt::CaseInsensitive))
addedList << tag.trimmed();
}
+ return removedList.length() + addedList.length();
}
void MainTab::on_tagWidget_textChanged()
diff --git a/desktop-widgets/tab-widgets/maintab.h b/desktop-widgets/tab-widgets/maintab.h
index c38615c93..d644be4e3 100644
--- a/desktop-widgets/tab-widgets/maintab.h
+++ b/desktop-widgets/tab-widgets/maintab.h
@@ -119,7 +119,7 @@ private:
void copyTagsToDisplayedDive();
void saveTags(const QVector<dive *> &selectedDives);
void saveTaggedStrings(const QVector<dive *> &selectedDives);
- void diffTaggedStrings(QString currentString, QString displayedString, QStringList &addedList, QStringList &removedList);
+ int diffTaggedStrings(QString currentString, QString displayedString, QStringList &addedList, QStringList &removedList);
void markChangedWidget(QWidget *w);
dive_trip_t *currentTrip;
dive_trip_t displayedTrip;