mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 22:35:27 +00:00
QML UI: don't combine multiple trips to the same location into one
The way sectioning of the dive list works is by watching for different strings in the section.property. In order to be able to tell different trips apart we combine the address of the dive trip variable with the location (which will create a new section for a new trip, even if the location text is the same) and then strip that information out before showing the trip header. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
6a8768ee26
commit
35e60a7355
3 changed files with 26 additions and 2 deletions
|
@ -106,7 +106,19 @@ MobileComponents.Page {
|
|||
|
||||
MobileComponents.Heading {
|
||||
id: sectionText
|
||||
text: {section == "--" ? "" : section }
|
||||
text: {
|
||||
// if the tripMeta (which we get as "section") ends in ::-- we know
|
||||
// that there's no trip -- otherwise strip the meta information before
|
||||
// the :: and show the trip location
|
||||
var shownText
|
||||
var endsWithDoubleDash = /::--$/;
|
||||
if (endsWithDoubleDash.test(section)) {
|
||||
shownText = ""
|
||||
} else {
|
||||
shownText = section.replace(/.*::/, "")
|
||||
}
|
||||
shownText
|
||||
}
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
|
@ -150,7 +162,7 @@ MobileComponents.Page {
|
|||
boundsBehavior: Flickable.StopAtBounds
|
||||
maximumFlickVelocity: parent.height * 5
|
||||
cacheBuffer: 0 // seems to avoid empty rendered profiles
|
||||
section.property: "dive.trip"
|
||||
section.property: "dive.tripMeta"
|
||||
section.criteria: ViewSection.FullString
|
||||
section.delegate: tripHeading
|
||||
header: MobileComponents.Heading {
|
||||
|
|
|
@ -219,6 +219,16 @@ QString DiveObjectHelper::trip() const
|
|||
return m_dive->divetrip ? m_dive->divetrip->location : EMPTY_DIVE_STRING;
|
||||
}
|
||||
|
||||
// combine the pointer address with the trip location so that
|
||||
// we detect multiple, destinct trips to the same location
|
||||
QString DiveObjectHelper::tripMeta() const
|
||||
{
|
||||
QString ret = EMPTY_DIVE_STRING;
|
||||
if (m_dive->divetrip)
|
||||
ret = QString::number((quint64)m_dive->divetrip, 16) + QLatin1Literal("::") + m_dive->divetrip->location;
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString DiveObjectHelper::maxcns() const
|
||||
{
|
||||
return QString(m_dive->maxcns);
|
||||
|
|
|
@ -29,6 +29,7 @@ class DiveObjectHelper : public QObject {
|
|||
Q_PROPERTY(QString suit READ suit CONSTANT)
|
||||
Q_PROPERTY(QStringList cylinders READ cylinders CONSTANT)
|
||||
Q_PROPERTY(QString trip READ trip CONSTANT)
|
||||
Q_PROPERTY(QString tripMeta READ tripMeta CONSTANT)
|
||||
Q_PROPERTY(QString maxcns READ maxcns CONSTANT)
|
||||
Q_PROPERTY(QString otu READ otu CONSTANT)
|
||||
public:
|
||||
|
@ -58,6 +59,7 @@ public:
|
|||
QStringList cylinders() const;
|
||||
QString cylinder(int idx) const;
|
||||
QString trip() const;
|
||||
QString tripMeta() const;
|
||||
QString maxcns() const;
|
||||
QString otu() const;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue