summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2019-10-20 07:37:51 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-10-20 16:08:55 -0400
commit158a2ec1591598973dbde0cedd80a4494f34045a (patch)
tree80a3a2cc527dff4d3323d6fe58eae2638fc1118c
parent32ae3810ce3844bd517002477e41afb78e493f2f (diff)
downloadsubsurface-158a2ec1591598973dbde0cedd80a4494f34045a.tar.gz
Mobile: remove remaining accesses to DiveObjectHelper from QML
Add a couple more roles and remove the dive role that allows accesss to the DiveObjectHelper in the first place. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--mobile-widgets/qml/DiveDetails.qml20
-rw-r--r--mobile-widgets/qml/DiveDetailsEdit.qml10
-rw-r--r--qt-models/divelistmodel.cpp6
-rw-r--r--qt-models/divelistmodel.h7
4 files changed, 23 insertions, 20 deletions
diff --git a/mobile-widgets/qml/DiveDetails.qml b/mobile-widgets/qml/DiveDetails.qml
index 4d9f7fc63..e84cf843e 100644
--- a/mobile-widgets/qml/DiveDetails.qml
+++ b/mobile-widgets/qml/DiveDetails.qml
@@ -216,7 +216,7 @@ Kirigami.Page {
onCurrentItemChanged: {
// why do we do this? What consumes this?
- manager.selectedDiveTimestamp = currentItem.modelData.dive.timestamp
+ manager.selectedDiveTimestamp = currentItem.modelData.date
// make sure the core data structures reflect that this dive is selected
manager.selectDive(currentItem.modelData.id)
// update the map to show the highlighted flag and center on it
@@ -284,15 +284,15 @@ Kirigami.Page {
// careful when translating, this text is "magic" in DiveDetailsEdit.qml
weight = "cannot edit multiple weight systems"
}
- startpressure = dive.startPressure
- endpressure = dive.endPressure
- usedGas = dive.firstGas
- usedCyl = dive.getCylinder
- cylinderIndex0 = dive.cylinderList.indexOf(usedCyl[0])
- cylinderIndex1 = dive.cylinderList.indexOf(usedCyl[1])
- cylinderIndex2 = dive.cylinderList.indexOf(usedCyl[2])
- cylinderIndex3 = dive.cylinderList.indexOf(usedCyl[3])
- cylinderIndex4 = dive.cylinderList.indexOf(usedCyl[4])
+ startpressure = modelData.startPressure
+ endpressure = modelData.endPressure
+ usedGas = modelData.firstGas
+ usedCyl = modelData.getCylinder
+ cylinderIndex0 = modelData.cylinderList.indexOf(usedCyl[0])
+ cylinderIndex1 = modelData.cylinderList.indexOf(usedCyl[1])
+ cylinderIndex2 = modelData.cylinderList.indexOf(usedCyl[2])
+ cylinderIndex3 = modelData.cylinderList.indexOf(usedCyl[3])
+ cylinderIndex4 = modelData.cylinderList.indexOf(usedCyl[4])
rating = modelData.rating
visibility = modelData.viz
diff --git a/mobile-widgets/qml/DiveDetailsEdit.qml b/mobile-widgets/qml/DiveDetailsEdit.qml
index 266f275a4..7e0e7f766 100644
--- a/mobile-widgets/qml/DiveDetailsEdit.qml
+++ b/mobile-widgets/qml/DiveDetailsEdit.qml
@@ -363,7 +363,7 @@ Item {
id: cylinderBox0
flat: true
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
- diveDetailsListView.currentItem.modelData.dive.cylinderList : null
+ diveDetailsListView.currentItem.modelData.cylinderList : null
inputMethodHints: Qt.ImhNoPredictiveText
Layout.fillWidth: true
}
@@ -420,7 +420,7 @@ Item {
id: cylinderBox1
flat: true
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
- diveDetailsListView.currentItem.modelData.dive.cylinderList : null
+ diveDetailsListView.currentItem.modelData.cylinderList : null
inputMethodHints: Qt.ImhNoPredictiveText
Layout.fillWidth: true
}
@@ -484,7 +484,7 @@ Item {
currentIndex: find(usedCyl[2])
flat: true
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
- diveDetailsListView.currentItem.modelData.dive.cylinderList : null
+ diveDetailsListView.currentItem.modelData.cylinderList : null
inputMethodHints: Qt.ImhNoPredictiveText
Layout.fillWidth: true
}
@@ -547,7 +547,7 @@ Item {
currentIndex: find(usedCyl[3])
flat: true
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
- diveDetailsListView.currentItem.modelData.dive.cylinderList : null
+ diveDetailsListView.currentItem.modelData.cylinderList : null
inputMethodHints: Qt.ImhNoPredictiveText
Layout.fillWidth: true
}
@@ -611,7 +611,7 @@ Item {
currentIndex: find(usedCyl[4])
flat: true
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
- diveDetailsListView.currentItem.modelData.dive.cylinderList : null
+ diveDetailsListView.currentItem.modelData.cylinderList : null
inputMethodHints: Qt.ImhNoPredictiveText
Layout.fillWidth: true
}
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp
index d0a309330..99d8bc588 100644
--- a/qt-models/divelistmodel.cpp
+++ b/qt-models/divelistmodel.cpp
@@ -241,7 +241,6 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const
if (!d)
return QVariant();
switch(role) {
- case DiveRole: return QVariant::fromValue(DiveObjectHelper(d));
case DiveDateRole: return (qlonglong)d->when;
// We have to return a QString as trip-id, because that will be used as section
// variable in the QtQuick list view. That has to be a string because it will try
@@ -276,6 +275,8 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const
case NoDiveRole: return d->duration.seconds == 0 && d->dc.duration.seconds == 0;
case DiveSiteRole: return QVariant::fromValue(d->dive_site);
case CylinderRole: return formatGetCylinder(d).join(", ");
+ case GetCylinderRole: return formatGetCylinder(d);
+ case CylinderListRole: return getFullCylinderList();
case SingleWeightRole: return d->weightsystems.nr <= 1;
case StartPressureRole: return getStartPressure(d);
case EndPressureRole: return getEndPressure(d);
@@ -287,7 +288,6 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const
QHash<int, QByteArray> DiveListModel::roleNames() const
{
QHash<int, QByteArray> roles;
- roles[DiveRole] = "dive";
roles[DiveDateRole] = "date";
roles[TripIdRole] = "tripId";
roles[TripNrDivesRole] = "tripNrDives";
@@ -313,6 +313,8 @@ QHash<int, QByteArray> DiveListModel::roleNames() const
roles[NoDiveRole] = "noDive";
roles[DiveSiteRole] = "diveSite";
roles[CylinderRole] = "cylinder";
+ roles[GetCylinderRole] = "getCylinder";
+ roles[CylinderListRole] = "cylinderList";
roles[SingleWeightRole] = "singleWeight";
roles[StartPressureRole] = "startPressure";
roles[EndPressureRole] = "endPressure";
diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h
index 2f8985235..d9e0928dc 100644
--- a/qt-models/divelistmodel.h
+++ b/qt-models/divelistmodel.h
@@ -36,15 +36,14 @@ QStringList formatGetCylinder(const dive *d);
QStringList getStartPressure(const dive *d);
QStringList getEndPressure(const dive *d);
QStringList getFirstGas(const dive *d);
-
+QStringList getFullCylinderList();
class DiveListModel : public QAbstractListModel
{
Q_OBJECT
public:
enum DiveListRoles {
- DiveRole = Qt::UserRole + 1,
- DiveDateRole,
+ DiveDateRole = Qt::UserRole + 1,
TripIdRole,
TripNrDivesRole,
DateTimeRole,
@@ -69,6 +68,8 @@ public:
NoDiveRole,
DiveSiteRole,
CylinderRole,
+ GetCylinderRole,
+ CylinderListRole,
SingleWeightRole,
StartPressureRole,
EndPressureRole,