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
KItinerary
Commits
660bd99e
Commit
660bd99e
authored
Jul 19, 2022
by
Volker Krause
Browse files
Also generate iCal events for boat/ferry trip reservations
parent
38bb5647
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/calendarhandler.cpp
View file @
660bd99e
...
...
@@ -12,6 +12,7 @@
#include
"mergeutil.h"
#include
"sortutil.h"
#include
<KItinerary/BoatTrip>
#include
<KItinerary/BusTrip>
#include
<KItinerary/Event>
#include
<KItinerary/Flight>
...
...
@@ -52,6 +53,7 @@ using namespace KCalendarCore;
static
void
fillFlightReservation
(
const
QVector
<
QVariant
>
&
reservations
,
const
KCalendarCore
::
Event
::
Ptr
&
event
);
static
void
fillTrainReservation
(
const
TrainReservation
&
reservation
,
const
KCalendarCore
::
Event
::
Ptr
&
event
);
static
void
fillBusReservation
(
const
BusReservation
&
reservation
,
const
KCalendarCore
::
Event
::
Ptr
&
event
);
static
void
fillBoatReservation
(
const
BoatReservation
&
reservation
,
const
KCalendarCore
::
Event
::
Ptr
&
event
);
static
void
fillLodgingReservation
(
const
QVector
<
QVariant
>
&
reservations
,
const
KCalendarCore
::
Event
::
Ptr
&
event
);
static
void
fillEvent
(
const
KItinerary
::
Event
&
ev
,
const
KCalendarCore
::
Event
::
Ptr
&
event
);
static
void
fillEventReservation
(
const
QVector
<
QVariant
>
&
reservations
,
const
KCalendarCore
::
Event
::
Ptr
&
event
);
...
...
@@ -137,6 +139,8 @@ void CalendarHandler::fillEvent(const QVector<QVariant> &reservations, const QSh
fillTrainReservation
(
reservation
.
value
<
TrainReservation
>
(),
event
);
}
else
if
(
typeId
==
qMetaTypeId
<
BusReservation
>
())
{
fillBusReservation
(
reservation
.
value
<
BusReservation
>
(),
event
);
}
else
if
(
typeId
==
qMetaTypeId
<
BoatReservation
>
())
{
fillBoatReservation
(
reservation
.
value
<
BoatReservation
>
(),
event
);
}
else
if
(
JsonLd
::
isA
<
EventReservation
>
(
reservation
))
{
fillEventReservation
(
reservations
,
event
);
}
else
if
(
JsonLd
::
isA
<
Event
>
(
reservation
))
{
...
...
@@ -293,6 +297,30 @@ static void fillBusReservation(const BusReservation &reservation, const KCalenda
event
->
setDescription
(
desc
.
join
(
QLatin1Char
(
'\n'
)));
}
static
void
fillBoatReservation
(
const
KItinerary
::
BoatReservation
&
reservation
,
const
KCalendarCore
::
Event
::
Ptr
&
event
)
{
const
auto
trip
=
reservation
.
reservationFor
().
value
<
BoatTrip
>
();
const
auto
depTerminal
=
trip
.
departureBoatTerminal
();
const
auto
arrTerminal
=
trip
.
arrivalBoatTerminal
();
event
->
setSummary
(
i18n
(
"Ferry from %1 to %2"
,
depTerminal
.
name
(),
arrTerminal
.
name
()));
event
->
setLocation
(
depTerminal
.
name
());
fillGeoPosition
(
depTerminal
,
event
);
event
->
setDtStart
(
trip
.
departureTime
());
event
->
setDtEnd
(
trip
.
arrivalTime
());
event
->
setAllDay
(
false
);
QStringList
desc
;
const
auto
ticket
=
reservation
.
reservedTicket
().
value
<
Ticket
>
();
if
(
!
reservation
.
reservationNumber
().
isEmpty
())
{
desc
.
push_back
(
i18n
(
"Booking reference: %1"
,
reservation
.
reservationNumber
()));
}
if
(
!
ticket
.
ticketNumber
().
isEmpty
()
&&
ticket
.
ticketNumber
()
!=
reservation
.
reservationNumber
())
{
desc
.
push_back
(
i18n
(
"Ticket number: %1"
,
ticket
.
ticketNumber
()));
}
event
->
setDescription
(
desc
.
join
(
QLatin1Char
(
'\n'
)));
}
static
void
fillLodgingReservation
(
const
QVector
<
QVariant
>
&
reservations
,
const
KCalendarCore
::
Event
::
Ptr
&
event
)
{
const
auto
reservation
=
reservations
.
at
(
0
).
value
<
LodgingReservation
>
();
...
...
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