summaryrefslogtreecommitdiffstats
path: root/mobile-widgets
diff options
context:
space:
mode:
authorGravatar Joakim Bygdell <j.bygdell@gmail.com>2016-05-20 18:48:35 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-05-21 06:59:38 -0700
commit80274b09689dff727ffe60f9b31faab4622dbc0b (patch)
treef4e6af789b506f93fb047f9d8c8276de4592b2c1 /mobile-widgets
parent6be5aba7990ec53b104ddbd57256c2eedf91f8c4 (diff)
downloadsubsurface-80274b09689dff727ffe60f9b31faab4622dbc0b.tar.gz
Add init function to qmlmanager
In order to get autocomplete to work on manual dive add we apparently need a separate init function. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets')
-rw-r--r--mobile-widgets/qmlmanager.cpp51
-rw-r--r--mobile-widgets/qmlmanager.h7
2 files changed, 58 insertions, 0 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 82ea319bb..1c3e1210e 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -1337,3 +1337,54 @@ void QMLManager::quit()
saveChangesCloud(false);
QApplication::quit();
}
+
+QStringList QMLManager::suitInit() const
+{
+ QStringList suits;
+ struct dive *d;
+ int i = 0;
+ for_each_dive (i, d) {
+ QString temp = d->suit;
+ if (!temp.isEmpty())
+ suits << d->suit;
+ }
+ suits.removeDuplicates();
+ suits.sort();
+ return suits;
+}
+
+QStringList QMLManager::buddyInit() 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;
+}
+
+QStringList QMLManager::divemasterInit() const
+{
+ QStringList divemasters;
+ struct dive *d;
+ int i = 0;
+ for_each_dive (i, d) {
+ QString temp = d->divemaster;
+ if (!temp.isEmpty())
+ divemasters << d->divemaster;
+ }
+ divemasters.removeDuplicates();
+ divemasters.sort();
+ return divemasters;
+}
diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h
index 906e7b0b2..10ff0ba51 100644
--- a/mobile-widgets/qmlmanager.h
+++ b/mobile-widgets/qmlmanager.h
@@ -29,6 +29,9 @@ class QMLManager : public QObject {
Q_PROPERTY(bool syncToCloud READ syncToCloud WRITE setSyncToCloud NOTIFY syncToCloudChanged)
Q_PROPERTY(int updateSelectedDive READ updateSelectedDive WRITE setUpdateSelectedDive NOTIFY updateSelectedDiveChanged)
Q_PROPERTY(int selectedDiveTimestamp READ selectedDiveTimestamp WRITE setSelectedDiveTimestamp NOTIFY selectedDiveTimestampChanged)
+ Q_PROPERTY(QStringList suitInit READ suitInit CONSTANT)
+ Q_PROPERTY(QStringList buddyInit READ buddyInit CONSTANT)
+ Q_PROPERTY(QStringList divemasterInit READ divemasterInit CONSTANT)
public:
QMLManager();
@@ -97,6 +100,10 @@ public:
typedef void (QMLManager::*execute_function_type)();
DiveListSortModel *dlSortModel;
+ QStringList suitInit() const;
+ QStringList buddyInit() const;
+ QStringList divemasterInit() const;
+
public slots:
void applicationStateChanged(Qt::ApplicationState state);
void savePreferences();