diff options
author | Sergey Starosek <sergey.starosek@gmail.com> | 2014-01-19 19:27:49 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-19 13:57:40 -0800 |
commit | 9faf52dd437765bdab177d6b9d207a6784d41882 (patch) | |
tree | be3dc9d5a3f680e44ab3bf374d46f7c8f1134a14 /qt-ui | |
parent | c8807c2ad20e0bfdc28818327bb2f876b0d69292 (diff) | |
download | subsurface-9faf52dd437765bdab177d6b9d207a6784d41882.tar.gz |
Populate divemaster completion model using CSV
Split divemaster field value using comma and populate completion list.
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/completionmodels.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
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<QString> 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<QString> 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); |