diff --git a/qt-ui/completionmodels.cpp b/qt-ui/completionmodels.cpp index a66b8d022..8ccab3f2f 100644 --- a/qt-ui/completionmodels.cpp +++ b/qt-ui/completionmodels.cpp @@ -32,21 +32,23 @@ void Class::updateModel() \ setStringList(list); \ } -void BuddyCompletionModel::updateModel() -{ - QSet set; - struct dive* dive; - int i = 0; - for_each_dive(i, dive) { - QString buddy(dive->buddy); - foreach (const QString &value, buddy.split(",", QString::SkipEmptyParts)) { - set.insert(value.trimmed()); - } - } - setStringList(set.toList()); +#define CREATE_CSV_UPDATE_METHOD(Class, diveStructMember) \ +void Class::updateModel() \ +{ \ + QSet set; \ + struct dive* dive; \ + int i = 0; \ + for_each_dive(i, dive) { \ + QString buddy(dive->diveStructMember); \ + foreach (const QString &value, buddy.split(",", QString::SkipEmptyParts)) { \ + set.insert(value.trimmed()); \ + } \ + } \ + setStringList(set.toList()); \ } -CREATE_UPDATE_METHOD(DiveMasterCompletionModel, divemaster); +CREATE_CSV_UPDATE_METHOD(BuddyCompletionModel, buddy); +CREATE_CSV_UPDATE_METHOD(DiveMasterCompletionModel, divemaster); CREATE_UPDATE_METHOD(LocationCompletionModel, location); CREATE_UPDATE_METHOD(SuitCompletionModel, suit);