diff options
author | Jan Mulder <jlmulder@xs4all.nl> | 2018-01-28 11:28:01 +0100 |
---|---|---|
committer | Jan Mulder <jlmulder@xs4all.nl> | 2018-01-31 14:48:14 +0100 |
commit | 83259008e763d3cc120c826f58f91a0ff62b6b92 (patch) | |
tree | c78b2d3cd2e390858a38787c97a130d55f5c9458 /mobile-widgets | |
parent | 572fc470718e4a11d5df60b37e7a2a91639285c7 (diff) | |
download | subsurface-83259008e763d3cc120c826f58f91a0ff62b6b92.tar.gz |
mobile cleanup: unduplicate code and do not loop over dives (3)
See e6e1473e6. Exact same commit but here for the
list of divemaster. The careful reader will spot a
small addition to the clearDetailsEdit() QML function.
Two more field are cleared.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Diffstat (limited to 'mobile-widgets')
-rw-r--r-- | mobile-widgets/qml/DiveDetails.qml | 2 | ||||
-rw-r--r-- | mobile-widgets/qml/DiveDetailsEdit.qml | 5 | ||||
-rw-r--r-- | mobile-widgets/qml/main.qml | 2 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 15 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.h | 6 |
5 files changed, 12 insertions, 18 deletions
diff --git a/mobile-widgets/qml/DiveDetails.qml b/mobile-widgets/qml/DiveDetails.qml index 787c826db..2335efb23 100644 --- a/mobile-widgets/qml/DiveDetails.qml +++ b/mobile-widgets/qml/DiveDetails.qml @@ -241,7 +241,7 @@ Kirigami.Page { } else { buddyIndex = manager.buddyList.indexOf(currentItem.modelData.dive.buddy) } - divemasterIndex = currentItem.modelData.dive.divemasterList.indexOf(currentItem.modelData.dive.divemaster) + divemasterIndex = manager.divemasterList.indexOf(currentItem.modelData.dive.divemaster) notes = currentItem.modelData.dive.notes if (currentItem.modelData.dive.singleWeight) { // we have only one weight, go ahead, have fun and edit it diff --git a/mobile-widgets/qml/DiveDetailsEdit.qml b/mobile-widgets/qml/DiveDetailsEdit.qml index 8373ba5b7..c623a856f 100644 --- a/mobile-widgets/qml/DiveDetailsEdit.qml +++ b/mobile-widgets/qml/DiveDetailsEdit.qml @@ -48,6 +48,8 @@ Item { detailsEdit.depthText = "" detailsEdit.airtempText = "" detailsEdit.watertempText = "" + detailsEdit.divemasterText = "" + detailsEdit.buddyText = "" suitBox.currentIndex = -1 buddyBox.currentIndex = -1 divemasterBox.currentIndex = -1 @@ -248,8 +250,7 @@ Item { } HintsTextEdit { id: divemasterBox - model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ? - diveDetailsListView.currentItem.modelData.dive.divemasterList : null + model: manager.divemasterList inputMethodHints: Qt.ImhNoPredictiveText Layout.fillWidth: true } diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml index ad073a08b..08b5f329f 100644 --- a/mobile-widgets/qml/main.qml +++ b/mobile-widgets/qml/main.qml @@ -85,7 +85,7 @@ Kirigami.ApplicationWindow { detailsWindow.buddyIndex = -1 detailsWindow.buddyText = "" detailsWindow.depth = "" - detailsWindow.divemasterModel = manager.divemasterInit + detailsWindow.divemasterModel = manager.divemasterList detailsWindow.divemasterIndex = -1 detailsWindow.divemasterText = "" detailsWindow.notes = "" diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 36f7768e5..57cacba74 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -275,6 +275,7 @@ void QMLManager::openLocalThenRemote(QString url) } buddyModel.updateModel(); emit buddyListChanged(); suitModel.updateModel(); emit suitListChanged(); + divemasterModel.updateModel(); emit divemasterListChanged(); } void QMLManager::mergeLocalRepo() @@ -1561,19 +1562,9 @@ QStringList QMLManager::buddyList() const return buddyModel.stringList(); } -QStringList QMLManager::divemasterInit() const +QStringList QMLManager::divemasterList() 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; + return divemasterModel.stringList(); } QStringList QMLManager::cylinderInit() const diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h index c8c6a9906..4f188ac7d 100644 --- a/mobile-widgets/qmlmanager.h +++ b/mobile-widgets/qmlmanager.h @@ -38,7 +38,7 @@ class QMLManager : public QObject { Q_PROPERTY(int selectedDiveTimestamp MEMBER m_selectedDiveTimestamp WRITE setSelectedDiveTimestamp NOTIFY selectedDiveTimestampChanged) Q_PROPERTY(QStringList suitList READ suitList NOTIFY suitListChanged) Q_PROPERTY(QStringList buddyList READ buddyList NOTIFY buddyListChanged) - Q_PROPERTY(QStringList divemasterInit READ divemasterInit CONSTANT) + Q_PROPERTY(QStringList divemasterList READ divemasterList NOTIFY divemasterListChanged) Q_PROPERTY(QStringList cylinderInit READ cylinderInit CONSTANT) Q_PROPERTY(bool showPin MEMBER m_showPin WRITE setShowPin NOTIFY showPinChanged) Q_PROPERTY(QString progressMessage MEMBER m_progressMessage WRITE setProgressMessage NOTIFY progressMessageChanged) @@ -133,7 +133,7 @@ public: QStringList suitList() const; QStringList buddyList() const; - QStringList divemasterInit() const; + QStringList divemasterList() const; QStringList cylinderInit() const; bool showPin() const; void setShowPin(bool enable); @@ -199,6 +199,7 @@ public slots: private: BuddyCompletionModel buddyModel; SuitCompletionModel suitModel; + DiveMasterCompletionModel divemasterModel; QString m_cloudUserName; QString m_cloudPassword; QString m_cloudPin; @@ -272,6 +273,7 @@ signals: void btEnabledChanged(); void suitListChanged(); void buddyListChanged(); + void divemasterListChanged(); }; #endif |