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
ba37b5ef
Commit
ba37b5ef
authored
Oct 01, 2021
by
Volker Krause
Browse files
Prevent creation of adjacent transfers
Unless they are to and from a favorite location that is.
parent
48ce78a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/app/transfermanager.cpp
View file @
ba37b5ef
...
...
@@ -269,7 +269,19 @@ TransferManager::CheckTransferResult TransferManager::checkTransferBefore(const
return
ShouldRemove
;
}
const
auto
prevRes
=
m_resMgr
->
reservation
(
prevResId
);
// TODO this needs to consider transfers before nextResId
// check if there is a transfer after prevRes already
const
auto
prevTransfer
=
this
->
transfer
(
prevResId
,
Transfer
::
After
);
if
(
prevTransfer
.
state
()
!=
Transfer
::
UndefinedState
&&
prevTransfer
.
state
()
!=
Transfer
::
Discarded
)
{
if
(
prevTransfer
.
floatingLocationType
()
==
Transfer
::
FavoriteLocation
)
{
transfer
.
setFrom
(
prevTransfer
.
to
());
transfer
.
setFromName
(
prevTransfer
.
toName
());
transfer
.
setFloatingLocationType
(
Transfer
::
FavoriteLocation
);
return
CanAddManually
;
}
return
ShouldRemove
;
}
QVariant
prevLoc
;
if
(
LocationUtil
::
isLocationChange
(
prevRes
))
{
prevLoc
=
LocationUtil
::
arrivalLocation
(
prevRes
);
...
...
@@ -321,8 +333,20 @@ TransferManager::CheckTransferResult TransferManager::checkTransferAfter(const Q
if
(
nextResId
.
isEmpty
())
{
return
ShouldRemove
;
}
// TODO this needs to consider transfers after nextResId
const
auto
nextRes
=
m_resMgr
->
reservation
(
nextResId
);
// check if there is a transfer before nextRes already
const
auto
nextTransfer
=
this
->
transfer
(
nextResId
,
Transfer
::
Before
);
if
(
nextTransfer
.
state
()
!=
Transfer
::
UndefinedState
&&
nextTransfer
.
state
()
!=
Transfer
::
Discarded
)
{
if
(
nextTransfer
.
floatingLocationType
()
==
Transfer
::
FavoriteLocation
)
{
transfer
.
setTo
(
nextTransfer
.
from
());
transfer
.
setToName
(
nextTransfer
.
fromName
());
transfer
.
setFloatingLocationType
(
Transfer
::
FavoriteLocation
);
return
CanAddManually
;
}
return
ShouldRemove
;
}
QVariant
nextLoc
;
if
(
LocationUtil
::
isLocationChange
(
nextRes
))
{
nextLoc
=
LocationUtil
::
departureLocation
(
nextRes
);
...
...
Write
Preview
Supports
Markdown
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