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>
This commit is contained in:
Jan Mulder 2018-10-10 14:07:47 +02:00 committed by bstoeger
parent 6137e0bc60
commit a47df05ce5
2 changed files with 5 additions and 4 deletions

View file

@ -1279,7 +1279,7 @@ void MainTab::saveTaggedStrings(const QVector<dive *> &selectedDives)
QStringList addedList, removedList; QStringList addedList, removedList;
struct dive *cd = current_dive; 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, MODIFY_DIVES(selectedDives,
QStringList oldList = QString(mydive->buddy).split(QRegExp("\\s*,\\s*"), QString::SkipEmptyParts); QStringList oldList = QString(mydive->buddy).split(QRegExp("\\s*,\\s*"), QString::SkipEmptyParts);
QString newString; QString newString;
@ -1301,7 +1301,7 @@ void MainTab::saveTaggedStrings(const QVector<dive *> &selectedDives)
); );
addedList.clear(); addedList.clear();
removedList.clear(); removedList.clear();
diffTaggedStrings(cd->divemaster, displayed_dive.divemaster, addedList, removedList); if (diffTaggedStrings(cd->divemaster, displayed_dive.divemaster, addedList, removedList))
MODIFY_DIVES(selectedDives, MODIFY_DIVES(selectedDives,
QStringList oldList = QString(mydive->divemaster).split(QRegExp("\\s*,\\s*"), QString::SkipEmptyParts); QStringList oldList = QString(mydive->divemaster).split(QRegExp("\\s*,\\s*"), QString::SkipEmptyParts);
QString newString; 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; QStringList displayedList, currentList;
currentList = currentString.split(',', QString::SkipEmptyParts); currentList = currentString.split(',', QString::SkipEmptyParts);
@ -1336,6 +1336,7 @@ void MainTab::diffTaggedStrings(QString currentString, QString displayedString,
if (!currentList.contains(tag, Qt::CaseInsensitive)) if (!currentList.contains(tag, Qt::CaseInsensitive))
addedList << tag.trimmed(); addedList << tag.trimmed();
} }
return removedList.length() + addedList.length();
} }
void MainTab::on_tagWidget_textChanged() void MainTab::on_tagWidget_textChanged()

View file

@ -119,7 +119,7 @@ private:
void copyTagsToDisplayedDive(); void copyTagsToDisplayedDive();
void saveTags(const QVector<dive *> &selectedDives); void saveTags(const QVector<dive *> &selectedDives);
void saveTaggedStrings(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); void markChangedWidget(QWidget *w);
dive_trip_t *currentTrip; dive_trip_t *currentTrip;
dive_trip_t displayedTrip; dive_trip_t displayedTrip;