Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Itinerary
Commits
e74371e7
Commit
e74371e7
authored
Jul 21, 2022
by
Volker Krause
Browse files
Add support for boat/ferry trips to the statistics model
parent
c2561401
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/app/StatisticsPage.qml
View file @
e74371e7
...
...
@@ -105,6 +105,14 @@ Kirigami.ScrollablePage {
StatisticsDelegate
{
statItem
:
model
.
busDistance
}
StatisticsDelegate
{
statItem
:
model
.
busCO2
}
Kirigami.Separator
{
Kirigami.FormData.isSection
:
true
Kirigami.FormData.label
:
i18n
(
"
Boat
"
)
}
StatisticsDelegate
{
statItem
:
model
.
boatCount
}
StatisticsDelegate
{
statItem
:
model
.
boatDistance
}
StatisticsDelegate
{
statItem
:
model
.
boatCO2
}
Kirigami.Separator
{
Kirigami.FormData.isSection
:
true
Kirigami.FormData.label
:
i18n
(
"
Car
"
)
...
...
src/app/statisticsmodel.cpp
View file @
e74371e7
...
...
@@ -181,6 +181,21 @@ StatisticsItem StatisticsModel::carCO2() const
return
StatisticsItem
(
i18n
(
"CO₂"
),
formatCo2
(
m_statData
[
Car
][
CO2
]),
trend
(
Car
,
CO2
));
}
StatisticsItem
StatisticsModel
::
boatCount
()
const
{
return
StatisticsItem
(
i18n
(
"Boat trips"
),
QLocale
().
toString
(
m_statData
[
Boat
][
TripCount
]),
trend
(
Boat
,
TripCount
));
}
StatisticsItem
StatisticsModel
::
boatDistance
()
const
{
return
StatisticsItem
(
i18n
(
"Distance"
),
i18n
(
"%1 km"
,
m_statData
[
Boat
][
Distance
]
/
1000
),
trend
(
Boat
,
Distance
));
}
StatisticsItem
StatisticsModel
::
boatCO2
()
const
{
return
StatisticsItem
(
i18n
(
"CO₂"
),
formatCo2
(
m_statData
[
Boat
][
CO2
]),
trend
(
Boat
,
CO2
));
}
StatisticsModel
::
AggregateType
StatisticsModel
::
typeForReservation
(
const
QVariant
&
res
)
const
{
if
(
JsonLd
::
isA
<
FlightReservation
>
(
res
))
{
...
...
@@ -189,6 +204,8 @@ StatisticsModel::AggregateType StatisticsModel::typeForReservation(const QVarian
return
Train
;
}
else
if
(
JsonLd
::
isA
<
BusReservation
>
(
res
))
{
return
Bus
;
}
else
if
(
JsonLd
::
isA
<
BoatReservation
>
(
res
))
{
return
Boat
;
}
return
Car
;
}
...
...
@@ -215,6 +232,7 @@ static const int emissionPerKm[] = {
14
,
// train
68
,
// bus
158
,
// car
113
,
// ferry
};
int
StatisticsModel
::
co2emission
(
StatisticsModel
::
AggregateType
type
,
int
distance
)
const
...
...
src/app/statisticsmodel.h
View file @
e74371e7
...
...
@@ -69,6 +69,10 @@ class StatisticsModel : public QObject
Q_PROPERTY
(
StatisticsItem
carDistance
READ
carDistance
NOTIFY
changed
)
Q_PROPERTY
(
StatisticsItem
carCO2
READ
carCO2
NOTIFY
changed
)
Q_PROPERTY
(
StatisticsItem
boatCount
READ
boatCount
NOTIFY
changed
)
Q_PROPERTY
(
StatisticsItem
boatDistance
READ
boatDistance
NOTIFY
changed
)
Q_PROPERTY
(
StatisticsItem
boatCO2
READ
boatCO2
NOTIFY
changed
)
Q_PROPERTY
(
ReservationManager
*
reservationManager
READ
reservationManager
WRITE
setReservationManager
NOTIFY
setupChanged
)
Q_PROPERTY
(
TripGroupManager
*
tripGroupManager
READ
tripGroupManager
WRITE
setTripGroupManager
NOTIFY
setupChanged
)
...
...
@@ -105,6 +109,10 @@ public:
StatisticsItem
carDistance
()
const
;
StatisticsItem
carCO2
()
const
;
StatisticsItem
boatCount
()
const
;
StatisticsItem
boatDistance
()
const
;
StatisticsItem
boatCO2
()
const
;
Q_SIGNALS:
void
setupChanged
();
void
changed
();
...
...
@@ -117,7 +125,7 @@ private:
QDate
m_begin
;
QDate
m_end
;
enum
AggregateType
{
Total
,
Flight
,
Train
,
Bus
,
Car
,
AGGREGATE_TYPE_COUNT
};
enum
AggregateType
{
Total
,
Flight
,
Train
,
Bus
,
Car
,
Boat
,
AGGREGATE_TYPE_COUNT
};
enum
StatType
{
TripCount
,
Distance
,
CO2
,
STAT_TYPE_COUNT
};
AggregateType
typeForReservation
(
const
QVariant
&
res
)
const
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment