aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/subsurface-qt/DiveObjectHelper.cpp15
-rw-r--r--core/subsurface-qt/DiveObjectHelper.h2
-rw-r--r--mobile-widgets/qml/DiveDetails.qml3
-rw-r--r--mobile-widgets/qml/DiveDetailsEdit.qml3
-rw-r--r--mobile-widgets/qml/main.qml2
-rw-r--r--mobile-widgets/qmlmanager.cpp17
-rw-r--r--mobile-widgets/qmlmanager.h8
-rw-r--r--qt-models/CMakeLists.txt2
8 files changed, 15 insertions, 37 deletions
diff --git a/core/subsurface-qt/DiveObjectHelper.cpp b/core/subsurface-qt/DiveObjectHelper.cpp
index bc7bd397c..4a7bc70f9 100644
--- a/core/subsurface-qt/DiveObjectHelper.cpp
+++ b/core/subsurface-qt/DiveObjectHelper.cpp
@@ -411,21 +411,6 @@ QString DiveObjectHelper::firstGas() const
return gas;
}
-QStringList DiveObjectHelper::suitList() 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 DiveObjectHelper::locationList() const
{
QStringList locations;
diff --git a/core/subsurface-qt/DiveObjectHelper.h b/core/subsurface-qt/DiveObjectHelper.h
index 49542ca62..a8ecc638c 100644
--- a/core/subsurface-qt/DiveObjectHelper.h
+++ b/core/subsurface-qt/DiveObjectHelper.h
@@ -47,7 +47,6 @@ class DiveObjectHelper : public QObject {
Q_PROPERTY(QString startPressure READ startPressure CONSTANT)
Q_PROPERTY(QString endPressure READ endPressure CONSTANT)
Q_PROPERTY(QString firstGas READ firstGas CONSTANT)
- Q_PROPERTY(QStringList suitList READ suitList CONSTANT)
Q_PROPERTY(QStringList buddyList READ buddyList CONSTANT)
Q_PROPERTY(QStringList divemasterList READ divemasterList CONSTANT)
Q_PROPERTY(QStringList locationList READ locationList CONSTANT)
@@ -93,7 +92,6 @@ public:
QString startPressure() const;
QString endPressure() const;
QString firstGas() const;
- QStringList suitList() const;
QStringList locationList() const;
QStringList buddyList() const;
QStringList divemasterList() const;
diff --git a/mobile-widgets/qml/DiveDetails.qml b/mobile-widgets/qml/DiveDetails.qml
index 1db5efc36..a285e62e4 100644
--- a/mobile-widgets/qml/DiveDetails.qml
+++ b/mobile-widgets/qml/DiveDetails.qml
@@ -30,7 +30,6 @@ Kirigami.Page {
property alias notes: detailsEdit.notesText
property alias suitIndex: detailsEdit.suitIndex
property alias suitText: detailsEdit.suitText
- property alias suitModel: detailsEdit.suitModel
property alias weight: detailsEdit.weightText
property alias startpressure: detailsEdit.startpressureText
property alias endpressure: detailsEdit.endpressureText
@@ -237,7 +236,7 @@ Kirigami.Page {
depth = currentItem.modelData.dive.depth
airtemp = currentItem.modelData.dive.airTemp
watertemp = currentItem.modelData.dive.waterTemp
- suitIndex = currentItem.modelData.dive.suitList.indexOf(currentItem.modelData.dive.suit)
+ suitIndex = manager.suitList.indexOf(currentItem.modelData.dive.suit)
if (currentItem.modelData.dive.buddy.indexOf(",") > 0) {
buddyText = currentItem.modelData.dive.buddy;
} else {
diff --git a/mobile-widgets/qml/DiveDetailsEdit.qml b/mobile-widgets/qml/DiveDetailsEdit.qml
index e680e1734..5808f78a7 100644
--- a/mobile-widgets/qml/DiveDetailsEdit.qml
+++ b/mobile-widgets/qml/DiveDetailsEdit.qml
@@ -224,8 +224,7 @@ Item {
}
HintsTextEdit {
id: suitBox
- model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
- diveDetailsListView.currentItem.modelData.dive.suitList : null
+ model: manager.suitList
inputMethodHints: Qt.ImhNoPredictiveText
Layout.fillWidth: true
}
diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml
index da7089d4f..2df8d9f67 100644
--- a/mobile-widgets/qml/main.qml
+++ b/mobile-widgets/qml/main.qml
@@ -92,7 +92,7 @@ Kirigami.ApplicationWindow {
detailsWindow.location = ""
detailsWindow.gps = ""
detailsWindow.duration = ""
- detailsWindow.suitModel = manager.suitInit
+ detailsWindow.suitModel = manager.suitList
detailsWindow.suitIndex = -1
detailsWindow.suitText = ""
detailsWindow.cylinderModel = manager.cylinderInit
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 18db13621..4846dcdec 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -17,6 +17,7 @@
#include "qt-models/divelistmodel.h"
#include "qt-models/gpslistmodel.h"
+#include "qt-models/completionmodels.h"
#include "core/divelist.h"
#include "core/device.h"
#include "core/pref.h"
@@ -272,6 +273,8 @@ void QMLManager::openLocalThenRemote(QString url)
appendTextToLog(QStringLiteral("have cloud credentials, trying to connect"));
tryRetrieveDataFromBackend();
}
+ buddyModel.updateModel();
+ suitModel.updateModel(); emit suitListChanged();
}
void QMLManager::mergeLocalRepo()
@@ -1548,19 +1551,9 @@ void QMLManager::quit()
QApplication::quit();
}
-QStringList QMLManager::suitInit() const
+QStringList QMLManager::suitList() 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;
+ return suitModel.stringList();
}
QStringList QMLManager::buddyInit() const
diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h
index c171eabaf..d0f1c09a2 100644
--- a/mobile-widgets/qmlmanager.h
+++ b/mobile-widgets/qmlmanager.h
@@ -13,6 +13,7 @@
#include "core/gpslocation.h"
#include "core/downloadfromdcthread.h"
#include "qt-models/divelistmodel.h"
+#include "qt-models/completionmodels.h"
class QMLManager : public QObject {
Q_OBJECT
@@ -35,7 +36,7 @@ class QMLManager : public QObject {
Q_PROPERTY(bool syncToCloud MEMBER m_syncToCloud WRITE setSyncToCloud NOTIFY syncToCloudChanged)
Q_PROPERTY(int updateSelectedDive MEMBER m_updateSelectedDive WRITE setUpdateSelectedDive NOTIFY updateSelectedDiveChanged)
Q_PROPERTY(int selectedDiveTimestamp MEMBER m_selectedDiveTimestamp WRITE setSelectedDiveTimestamp NOTIFY selectedDiveTimestampChanged)
- Q_PROPERTY(QStringList suitInit READ suitInit CONSTANT)
+ Q_PROPERTY(QStringList suitList READ suitList NOTIFY suitListChanged)
Q_PROPERTY(QStringList buddyInit READ buddyInit CONSTANT)
Q_PROPERTY(QStringList divemasterInit READ divemasterInit CONSTANT)
Q_PROPERTY(QStringList cylinderInit READ cylinderInit CONSTANT)
@@ -130,7 +131,7 @@ public:
DiveListSortModel *dlSortModel;
- QStringList suitInit() const;
+ QStringList suitList() const;
QStringList buddyInit() const;
QStringList divemasterInit() const;
QStringList cylinderInit() const;
@@ -196,6 +197,8 @@ public slots:
private:
+ BuddyCompletionModel buddyModel;
+ SuitCompletionModel suitModel;
QString m_cloudUserName;
QString m_cloudPassword;
QString m_cloudPin;
@@ -267,6 +270,7 @@ signals:
void libdcLogChanged();
void developerChanged();
void btEnabledChanged();
+ void suitListChanged();
};
#endif
diff --git a/qt-models/CMakeLists.txt b/qt-models/CMakeLists.txt
index 0f80740c6..f24f6d2a5 100644
--- a/qt-models/CMakeLists.txt
+++ b/qt-models/CMakeLists.txt
@@ -5,6 +5,7 @@
set(SUBSURFACE_GENERIC_MODELS_LIB_SRCS
diveplotdatamodel.cpp
diveimportedmodel.cpp
+ completionmodels.cpp
)
# models exclusively used in desktop builds
@@ -24,7 +25,6 @@ set(SUBSURFACE_DESKTOP_MODELS_LIB_SRCS
divetripmodel.cpp
diveplannermodel.cpp
divecomputerextradatamodel.cpp
- completionmodels.cpp
divelocationmodel.cpp
ssrfsortfilterproxymodel.cpp
)