Populate buddy completion model using CSV

While preparing to extend tags model to 'Buddy' field we populate
completion list by splittng those fields by comma.

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Sergey Starosek 2014-01-15 22:35:13 +02:00 committed by Dirk Hohndel
parent 630eece8b2
commit d2c95ddf75

View file

@ -32,7 +32,20 @@ void Class::updateModel() \
setStringList(list); \
}
CREATE_UPDATE_METHOD(BuddyCompletionModel, buddy);
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());
}
CREATE_UPDATE_METHOD(DiveMasterCompletionModel, divemaster);
CREATE_UPDATE_METHOD(LocationCompletionModel, location);
CREATE_UPDATE_METHOD(SuitCompletionModel, suit);