mobile cleanup: unduplicate code and do not loop over dives (2)

See e6e1473e6. Exact same commit but here for the
list of buddies.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This commit is contained in:
Jan Mulder 2018-01-28 10:26:45 +01:00
parent fed2c5b6a1
commit 572fc47071
7 changed files with 9 additions and 50 deletions

View file

@ -273,7 +273,7 @@ void QMLManager::openLocalThenRemote(QString url)
appendTextToLog(QStringLiteral("have cloud credentials, trying to connect"));
tryRetrieveDataFromBackend();
}
buddyModel.updateModel();
buddyModel.updateModel(); emit buddyListChanged();
suitModel.updateModel(); emit suitListChanged();
}
@ -1556,25 +1556,9 @@ QStringList QMLManager::suitList() const
return suitModel.stringList();
}
QStringList QMLManager::buddyInit() const
QStringList QMLManager::buddyList() const
{
QStringList buddies;
struct dive *d;
int i = 0;
for_each_dive (i, d) {
QString temp = d->buddy;
if (!temp.isEmpty() && !temp.contains(",")){
buddies << d->buddy;
}
else if (!temp.isEmpty()){
QRegExp sep("(,\\s)");
QStringList tempList = temp.split(sep);
buddies << tempList;
}
}
buddies.removeDuplicates();
buddies.sort();
return buddies;
return buddyModel.stringList();
}
QStringList QMLManager::divemasterInit() const