mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
32ae3810ce
commit
158a2ec159
4 changed files with 23 additions and 20 deletions
|
@ -216,7 +216,7 @@ Kirigami.Page {
|
||||||
|
|
||||||
onCurrentItemChanged: {
|
onCurrentItemChanged: {
|
||||||
// why do we do this? What consumes this?
|
// 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
|
// make sure the core data structures reflect that this dive is selected
|
||||||
manager.selectDive(currentItem.modelData.id)
|
manager.selectDive(currentItem.modelData.id)
|
||||||
// update the map to show the highlighted flag and center on it
|
// 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
|
// careful when translating, this text is "magic" in DiveDetailsEdit.qml
|
||||||
weight = "cannot edit multiple weight systems"
|
weight = "cannot edit multiple weight systems"
|
||||||
}
|
}
|
||||||
startpressure = dive.startPressure
|
startpressure = modelData.startPressure
|
||||||
endpressure = dive.endPressure
|
endpressure = modelData.endPressure
|
||||||
usedGas = dive.firstGas
|
usedGas = modelData.firstGas
|
||||||
usedCyl = dive.getCylinder
|
usedCyl = modelData.getCylinder
|
||||||
cylinderIndex0 = dive.cylinderList.indexOf(usedCyl[0])
|
cylinderIndex0 = modelData.cylinderList.indexOf(usedCyl[0])
|
||||||
cylinderIndex1 = dive.cylinderList.indexOf(usedCyl[1])
|
cylinderIndex1 = modelData.cylinderList.indexOf(usedCyl[1])
|
||||||
cylinderIndex2 = dive.cylinderList.indexOf(usedCyl[2])
|
cylinderIndex2 = modelData.cylinderList.indexOf(usedCyl[2])
|
||||||
cylinderIndex3 = dive.cylinderList.indexOf(usedCyl[3])
|
cylinderIndex3 = modelData.cylinderList.indexOf(usedCyl[3])
|
||||||
cylinderIndex4 = dive.cylinderList.indexOf(usedCyl[4])
|
cylinderIndex4 = modelData.cylinderList.indexOf(usedCyl[4])
|
||||||
rating = modelData.rating
|
rating = modelData.rating
|
||||||
visibility = modelData.viz
|
visibility = modelData.viz
|
||||||
|
|
||||||
|
|
|
@ -363,7 +363,7 @@ Item {
|
||||||
id: cylinderBox0
|
id: cylinderBox0
|
||||||
flat: true
|
flat: true
|
||||||
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
||||||
diveDetailsListView.currentItem.modelData.dive.cylinderList : null
|
diveDetailsListView.currentItem.modelData.cylinderList : null
|
||||||
inputMethodHints: Qt.ImhNoPredictiveText
|
inputMethodHints: Qt.ImhNoPredictiveText
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ Item {
|
||||||
id: cylinderBox1
|
id: cylinderBox1
|
||||||
flat: true
|
flat: true
|
||||||
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
||||||
diveDetailsListView.currentItem.modelData.dive.cylinderList : null
|
diveDetailsListView.currentItem.modelData.cylinderList : null
|
||||||
inputMethodHints: Qt.ImhNoPredictiveText
|
inputMethodHints: Qt.ImhNoPredictiveText
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
@ -484,7 +484,7 @@ Item {
|
||||||
currentIndex: find(usedCyl[2])
|
currentIndex: find(usedCyl[2])
|
||||||
flat: true
|
flat: true
|
||||||
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
||||||
diveDetailsListView.currentItem.modelData.dive.cylinderList : null
|
diveDetailsListView.currentItem.modelData.cylinderList : null
|
||||||
inputMethodHints: Qt.ImhNoPredictiveText
|
inputMethodHints: Qt.ImhNoPredictiveText
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
@ -547,7 +547,7 @@ Item {
|
||||||
currentIndex: find(usedCyl[3])
|
currentIndex: find(usedCyl[3])
|
||||||
flat: true
|
flat: true
|
||||||
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
||||||
diveDetailsListView.currentItem.modelData.dive.cylinderList : null
|
diveDetailsListView.currentItem.modelData.cylinderList : null
|
||||||
inputMethodHints: Qt.ImhNoPredictiveText
|
inputMethodHints: Qt.ImhNoPredictiveText
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
@ -611,7 +611,7 @@ Item {
|
||||||
currentIndex: find(usedCyl[4])
|
currentIndex: find(usedCyl[4])
|
||||||
flat: true
|
flat: true
|
||||||
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
|
||||||
diveDetailsListView.currentItem.modelData.dive.cylinderList : null
|
diveDetailsListView.currentItem.modelData.cylinderList : null
|
||||||
inputMethodHints: Qt.ImhNoPredictiveText
|
inputMethodHints: Qt.ImhNoPredictiveText
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,6 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const
|
||||||
if (!d)
|
if (!d)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
switch(role) {
|
switch(role) {
|
||||||
case DiveRole: return QVariant::fromValue(DiveObjectHelper(d));
|
|
||||||
case DiveDateRole: return (qlonglong)d->when;
|
case DiveDateRole: return (qlonglong)d->when;
|
||||||
// We have to return a QString as trip-id, because that will be used as section
|
// 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
|
// 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 NoDiveRole: return d->duration.seconds == 0 && d->dc.duration.seconds == 0;
|
||||||
case DiveSiteRole: return QVariant::fromValue(d->dive_site);
|
case DiveSiteRole: return QVariant::fromValue(d->dive_site);
|
||||||
case CylinderRole: return formatGetCylinder(d).join(", ");
|
case CylinderRole: return formatGetCylinder(d).join(", ");
|
||||||
|
case GetCylinderRole: return formatGetCylinder(d);
|
||||||
|
case CylinderListRole: return getFullCylinderList();
|
||||||
case SingleWeightRole: return d->weightsystems.nr <= 1;
|
case SingleWeightRole: return d->weightsystems.nr <= 1;
|
||||||
case StartPressureRole: return getStartPressure(d);
|
case StartPressureRole: return getStartPressure(d);
|
||||||
case EndPressureRole: return getEndPressure(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> DiveListModel::roleNames() const
|
||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
roles[DiveRole] = "dive";
|
|
||||||
roles[DiveDateRole] = "date";
|
roles[DiveDateRole] = "date";
|
||||||
roles[TripIdRole] = "tripId";
|
roles[TripIdRole] = "tripId";
|
||||||
roles[TripNrDivesRole] = "tripNrDives";
|
roles[TripNrDivesRole] = "tripNrDives";
|
||||||
|
@ -313,6 +313,8 @@ QHash<int, QByteArray> DiveListModel::roleNames() const
|
||||||
roles[NoDiveRole] = "noDive";
|
roles[NoDiveRole] = "noDive";
|
||||||
roles[DiveSiteRole] = "diveSite";
|
roles[DiveSiteRole] = "diveSite";
|
||||||
roles[CylinderRole] = "cylinder";
|
roles[CylinderRole] = "cylinder";
|
||||||
|
roles[GetCylinderRole] = "getCylinder";
|
||||||
|
roles[CylinderListRole] = "cylinderList";
|
||||||
roles[SingleWeightRole] = "singleWeight";
|
roles[SingleWeightRole] = "singleWeight";
|
||||||
roles[StartPressureRole] = "startPressure";
|
roles[StartPressureRole] = "startPressure";
|
||||||
roles[EndPressureRole] = "endPressure";
|
roles[EndPressureRole] = "endPressure";
|
||||||
|
|
|
@ -36,15 +36,14 @@ QStringList formatGetCylinder(const dive *d);
|
||||||
QStringList getStartPressure(const dive *d);
|
QStringList getStartPressure(const dive *d);
|
||||||
QStringList getEndPressure(const dive *d);
|
QStringList getEndPressure(const dive *d);
|
||||||
QStringList getFirstGas(const dive *d);
|
QStringList getFirstGas(const dive *d);
|
||||||
|
QStringList getFullCylinderList();
|
||||||
|
|
||||||
class DiveListModel : public QAbstractListModel
|
class DiveListModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum DiveListRoles {
|
enum DiveListRoles {
|
||||||
DiveRole = Qt::UserRole + 1,
|
DiveDateRole = Qt::UserRole + 1,
|
||||||
DiveDateRole,
|
|
||||||
TripIdRole,
|
TripIdRole,
|
||||||
TripNrDivesRole,
|
TripNrDivesRole,
|
||||||
DateTimeRole,
|
DateTimeRole,
|
||||||
|
@ -69,6 +68,8 @@ public:
|
||||||
NoDiveRole,
|
NoDiveRole,
|
||||||
DiveSiteRole,
|
DiveSiteRole,
|
||||||
CylinderRole,
|
CylinderRole,
|
||||||
|
GetCylinderRole,
|
||||||
|
CylinderListRole,
|
||||||
SingleWeightRole,
|
SingleWeightRole,
|
||||||
StartPressureRole,
|
StartPressureRole,
|
||||||
EndPressureRole,
|
EndPressureRole,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue