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>
This commit is contained in:
Berthold Stoeger 2019-02-20 20:13:03 +01:00 committed by Dirk Hohndel
parent 464721b2ec
commit 53b4d84a6e
2 changed files with 0 additions and 73 deletions

View file

@ -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)

View file

@ -119,8 +119,6 @@ private:
int lastTabSelectedDiveTrip;
void resetPallete();
void copyTagsToDisplayedDive();
void saveTaggedStrings(const QVector<dive *> &selectedDives);
int diffTaggedStrings(QString currentString, QString displayedString, QStringList &addedList, QStringList &removedList);
void markChangedWidget(QWidget *w);
dive_trip_t *currentTrip;
dive_trip_t displayedTrip;