Skip to content
GitLab
Menu
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
a7143d27
Commit
a7143d27
authored
Oct 01, 2021
by
Volker Krause
Browse files
Allow to add transfers to event reservations as well
parent
e2f79df3
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/app/transfermanager.cpp
View file @
a7143d27
...
...
@@ -147,7 +147,8 @@ bool TransferManager::canAddTransfer(const QString& resId, Transfer::Alignment a
t
.
setReservationId
(
resId
);
t
.
setAlignment
(
alignment
);
return
(
alignment
==
Transfer
::
Before
?
checkTransferBefore
(
resId
,
res
,
t
)
:
checkTransferAfter
(
resId
,
res
,
t
))
!=
ShouldRemove
;
const
bool
canAdd
=
(
alignment
==
Transfer
::
Before
?
checkTransferBefore
(
resId
,
res
,
t
)
:
checkTransferAfter
(
resId
,
res
,
t
))
!=
ShouldRemove
;
return
canAdd
&&
t
.
hasLocations
()
&&
t
.
anchorTime
().
isValid
();
}
Transfer
TransferManager
::
addTransfer
(
const
QString
&
resId
,
Transfer
::
Alignment
alignment
)
...
...
@@ -263,29 +264,25 @@ TransferManager::CheckTransferResult TransferManager::checkTransferBefore(const
return
notInGroup
?
CanAddManually
:
ShouldAutoAdd
;
}
if
(
isLocationChange
)
{
const
auto
prevResId
=
m_resMgr
->
previousBatch
(
resId
);
// TODO this fails for multiple nested range elements!
if
(
prevResId
.
isEmpty
())
{
return
ShouldRemove
;
}
const
auto
prevRes
=
m_resMgr
->
reservation
(
prevResId
);
// TODO this needs to consider transfers before nextResId
QVariant
prevLoc
;
if
(
LocationUtil
::
isLocationChange
(
prevRes
))
{
prevLoc
=
LocationUtil
::
arrivalLocation
(
prevRes
);
}
else
{
prevLoc
=
LocationUtil
::
location
(
prevRes
);
}
if
(
!
toLoc
.
isNull
()
&&
!
prevLoc
.
isNull
()
&&
!
LocationUtil
::
isSameLocation
(
toLoc
,
prevLoc
,
LocationUtil
::
WalkingDistance
))
{
qDebug
()
<<
res
<<
prevRes
<<
LocationUtil
::
name
(
toLoc
)
<<
LocationUtil
::
name
(
prevLoc
);
transfer
.
setFrom
(
PublicTransport
::
locationFromPlace
(
prevLoc
,
prevRes
));
transfer
.
setFromName
(
LocationUtil
::
name
(
prevLoc
));
return
ShouldAutoAdd
;
}
const
auto
prevResId
=
m_resMgr
->
previousBatch
(
resId
);
// TODO this fails for multiple nested range elements!
if
(
prevResId
.
isEmpty
())
{
return
ShouldRemove
;
}
const
auto
prevRes
=
m_resMgr
->
reservation
(
prevResId
);
// TODO this needs to consider transfers before nextResId
QVariant
prevLoc
;
if
(
LocationUtil
::
isLocationChange
(
prevRes
))
{
prevLoc
=
LocationUtil
::
arrivalLocation
(
prevRes
);
}
else
{
prevLoc
=
LocationUtil
::
location
(
prevRes
);
}
if
(
!
toLoc
.
isNull
()
&&
!
prevLoc
.
isNull
()
&&
!
LocationUtil
::
isSameLocation
(
toLoc
,
prevLoc
,
LocationUtil
::
WalkingDistance
))
{
qDebug
()
<<
res
<<
prevRes
<<
LocationUtil
::
name
(
toLoc
)
<<
LocationUtil
::
name
(
prevLoc
)
<<
transfer
.
anchorTime
();
transfer
.
setFrom
(
PublicTransport
::
locationFromPlace
(
prevLoc
,
prevRes
));
transfer
.
setFromName
(
LocationUtil
::
name
(
prevLoc
));
return
isLocationChange
?
ShouldAutoAdd
:
CanAddManually
;
// TODO
}
return
ShouldRemove
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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