summaryrefslogtreecommitdiffstats
path: root/qt-ui/completionmodels.cpp
diff options
context:
space:
mode:
authorGravatar Sergey Starosek <sergey.starosek@gmail.com>2014-01-15 22:35:13 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-16 09:12:55 +0700
commitd2c95ddf7522e9e453fa4ed0726fbb4223137aec (patch)
tree605c472174e34eed664eae77d2fa3634e9139d94 /qt-ui/completionmodels.cpp
parent630eece8b23daa0668c649efadf45b420c948e70 (diff)
downloadsubsurface-d2c95ddf7522e9e453fa4ed0726fbb4223137aec.tar.gz
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>
Diffstat (limited to 'qt-ui/completionmodels.cpp')
-rw-r--r--qt-ui/completionmodels.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/qt-ui/completionmodels.cpp b/qt-ui/completionmodels.cpp
index ed1699a92..c4a4eeb8d 100644
--- a/qt-ui/completionmodels.cpp
+++ b/qt-ui/completionmodels.cpp
@@ -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);