summaryrefslogtreecommitdiffstats
path: root/qt-models/divelistmodel.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-24 11:17:48 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-24 11:17:48 -0700
commit7e7dcb2451e02a3c9dc0c314feeef9a68c625b5a (patch)
tree93f4980c0aa434d3b3d42ff7a99c6ab9cd1be0ad /qt-models/divelistmodel.cpp
parent0029844b1c889a88b4f5785426f4aad4caddc4f9 (diff)
downloadsubsurface-7e7dcb2451e02a3c9dc0c314feeef9a68c625b5a.tar.gz
QML UI: sort by date, not by date string
Just a quick bit of cleanup to separate date (the sortable, numeric value) from the date string that we want to display (but not sort by). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models/divelistmodel.cpp')
-rw-r--r--qt-models/divelistmodel.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp
index 8bb895fc8..4019bee8b 100644
--- a/qt-models/divelistmodel.cpp
+++ b/qt-models/divelistmodel.cpp
@@ -13,8 +13,8 @@ MobileDive::MobileDive(dive *d)
//trip is valid
setTrip(trip->location);
}
-
- setDate(get_dive_date_string(d->when));
+ setDate(d->when);
+ setDateString(get_dive_date_string(d->when));
setDepth(get_depth_string(d->maxdepth));
setDuration(get_dive_duration_string(d->duration.seconds, "h:","min"));
@@ -32,14 +32,24 @@ MobileDive::MobileDive(dive *d)
setDivemaster(d->divemaster);
}
-QString MobileDive::date() const
+QString MobileDive::dateString() const
+{
+ return m_dateString;
+}
+
+void MobileDive::setDateString(const QString &date)
+{
+ m_dateString = date;
+}
+
+timestamp_t MobileDive::date() const
{
return m_date;
}
-void MobileDive::setDate(const QString &date)
+void MobileDive::setDate(timestamp_t when)
{
- m_date = date;
+ m_date = when;
}
QString MobileDive::location() const
@@ -265,7 +275,9 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const
else if (role == DiveTripRole)
return dive.trip();
else if (role == DiveDateRole)
- return dive.date();
+ return (qlonglong)dive.date();
+ else if (role == DiveDateStringRole)
+ return dive.dateString();
else if (role == DiveRatingRole)
return dive.rating();
else if (role == DiveDepthRole)
@@ -306,7 +318,7 @@ QHash<int, QByteArray> DiveListModel::roleNames() const
QHash<int, QByteArray> roles;
roles[DiveNumberRole] = "diveNumber";
roles[DiveTripRole] = "trip";
- roles[DiveDateRole] = "date";
+ roles[DiveDateStringRole] = "date";
roles[DiveRatingRole] = "rating";
roles[DiveDepthRole] = "depth";
roles[DiveDurationRole] = "duration";