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
9dfd0963
Commit
9dfd0963
authored
Jun 01, 2021
by
Volker Krause
Browse files
Implement deleting entire trip groups
Fixes
#29
.
parent
d2eaee48
Changes
5
Hide whitespace changes
Inline
Side-by-side
autotests/tripgrouptest.cpp
View file @
9dfd0963
...
...
@@ -203,6 +203,23 @@ private Q_SLOTS:
QCOMPARE
(
g
.
elements
().
size
(),
resMgr
.
batches
().
size
()
-
1
);
QCOMPARE
(
g
.
name
(),
QStringLiteral
(
"Oslo Airport (June 2000)"
));
}
void
testDeletion
()
{
ReservationManager
resMgr
;
clearReservations
(
&
resMgr
);
resMgr
.
importReservation
(
readFile
(
QStringLiteral
(
SOURCE_DIR
"/../tests/randa2017.json"
)));
TripGroupManager
mgr
;
QSignalSpy
addSpy
(
&
mgr
,
&
TripGroupManager
::
tripGroupAdded
);
mgr
.
setReservationManager
(
&
resMgr
);
QCOMPARE
(
addSpy
.
size
(),
1
);
QVERIFY
(
resMgr
.
batches
().
size
()
>
8
);
const
auto
groupId
=
addSpy
.
at
(
0
).
at
(
0
).
toString
();
const
auto
g
=
mgr
.
tripGroup
(
groupId
);
mgr
.
removeReservationsInGroup
(
groupId
);
QCOMPARE
(
resMgr
.
batches
().
size
(),
0
);
QCOMPARE
(
mgr
.
tripGroups
().
size
(),
0
);
}
};
QTEST_GUILESS_MAIN
(
TripGroupTest
)
...
...
src/app/TimelinePage.qml
View file @
9dfd0963
...
...
@@ -124,6 +124,28 @@ Kirigami.ScrollablePage {
}
}
Kirigami.OverlaySheet
{
id
:
deleteTripGroupWarningSheet
property
string
tripGroupId
QQC2.Label
{
text
:
i18n
(
"
Do you really want to delete this trip?
"
)
wrapMode
:
Text
.
WordWrap
}
footer
:
RowLayout
{
QQC2.Button
{
Layout.alignment
:
Qt
.
AlignHCenter
text
:
i18n
(
"
Delete
"
)
icon.name
:
"
edit-delete
"
onClicked
:
{
deleteTripGroupWarningSheet
.
sheetOpen
=
false
;
TripGroupManager
.
removeReservationsInGroup
(
deleteTripGroupWarningSheet
.
tripGroupId
);
}
}
}
}
Kirigami.CardsListView
{
id
:
listView
model
:
TripGroupProxyModel
...
...
src/app/TripGroupDelegate.qml
View file @
9dfd0963
...
...
@@ -69,7 +69,7 @@ Kirigami.AbstractCard {
Localizer
.
formatDateTime
(
root
.
tripGroup
,
"
beginDateTime
"
))
}
Row
Layout
{
Row
{
visible
:
weatherForecast
.
valid
Kirigami.Icon
{
...
...
@@ -103,6 +103,22 @@ Kirigami.AbstractCard {
}
}
Kirigami.Separator
{
visible
:
root
.
rangeType
==
TimelineElement
.
RangeBegin
}
Row
{
visible
:
root
.
rangeType
==
TimelineElement
.
RangeBegin
anchors.right
:
parent
.
right
QQC2.ToolButton
{
icon.name
:
"
edit-delete
"
onClicked
:
{
deleteTripGroupWarningSheet
.
tripGroupId
=
root
.
tripGroupId
deleteTripGroupWarningSheet
.
sheetOpen
=
true
}
}
}
Component.onCompleted
:
{
// hide content entirely in the header-only end elements
parent
.
visible
=
contentLayout
.
visible
...
...
src/app/tripgroupmanager.cpp
View file @
9dfd0963
...
...
@@ -143,6 +143,19 @@ void TripGroupManager::clear()
d
.
removeRecursively
();
}
void
TripGroupManager
::
removeReservationsInGroup
(
const
QString
&
groupId
)
{
const
auto
groupIt
=
m_tripGroups
.
constFind
(
groupId
);
if
(
groupIt
==
m_tripGroups
.
constEnd
())
{
return
;
}
const
auto
elements
=
groupIt
.
value
().
elements
();
for
(
const
auto
&
element
:
elements
)
{
m_resMgr
->
removeBatch
(
element
);
}
}
void
TripGroupManager
::
batchAdded
(
const
QString
&
resId
)
{
auto
it
=
std
::
lower_bound
(
m_reservations
.
begin
(),
m_reservations
.
end
(),
resId
,
[
this
](
const
auto
&
lhs
,
const
auto
&
rhs
)
{
...
...
src/app/tripgroupmanager.h
View file @
9dfd0963
...
...
@@ -33,6 +33,9 @@ public:
static
void
clear
();
// for testing only!
/** Deletes all elements in the trip group with Identifier @p id. */
Q_INVOKABLE
void
removeReservationsInGroup
(
const
QString
&
groupId
);
Q_SIGNALS:
void
tripGroupAdded
(
const
QString
&
id
);
void
tripGroupChanged
(
const
QString
&
id
);
...
...
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