performance/PeopleShowcaseEvents.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Sprint 103 S103.0.8: calendar events of the people showcase. A separate | ||
| 2 | // object file: only binaries that link CalendarStore (and call seedEvents) | ||
| 3 | // pull it in. | ||
| 4 | #include "PeopleShowcase.h" | ||
| 5 | |||
| 6 | #include "ContactShowcase.h" | ||
| 7 | #include "data/CalendarStore.h" | ||
| 8 | #include "data/ICalEventCodec.h" | ||
| 9 | #include "ui/ThemeManager.h" | ||
| 10 | |||
| 11 | #include <QTimeZone> | ||
| 12 | |||
| 13 | namespace PeopleShowcase { | ||
| 14 | |||
| 15 | namespace { | ||
| 16 |
1/1✓ Branch 3 → 4 taken 30 times.
|
30 | QString text(const char *value) { return QString::fromUtf8(value); } |
| 17 | } // namespace | ||
| 18 | |||
| 19 | 1 | bool seedEvents(CalendarStore &calendar, QString *error) { | |
| 20 | 1 | CalendarInfo info; | |
| 21 | 1 | info.path = QStringLiteral("/remote.php/dav/calendars/jens/personal/"); | |
| 22 | 1 | info.accountId = ContactShowcase::AccountCloud; | |
| 23 | 1 | info.displayName = QStringLiteral("Persönlich"); | |
| 24 |
2/2✓ Branch 15 → 16 taken 1 time.
✓ Branch 16 → 17 taken 1 time.
|
1 | info.color = ThemeManager::calendarPalette().value(0); |
| 25 |
1/1✓ Branch 20 → 21 taken 1 time.
|
1 | calendar.upsertCalendar(info, info.accountId); |
| 26 | struct Event { | ||
| 27 | const char *uid; | ||
| 28 | const char *summary; | ||
| 29 | const char *location; | ||
| 30 | QDateTime start; | ||
| 31 | int hours; | ||
| 32 | bool allDay; | ||
| 33 | const char *people; // keys | ||
| 34 | const char *attendees; // "mailto,CN;…" | ||
| 35 | }; | ||
| 36 |
2/2✓ Branch 21 → 22 taken 1 time.
✓ Branch 22 → 23 taken 1 time.
|
1 | const QTimeZone lisbon("Europe/Lisbon"); |
| 37 |
2/2✓ Branch 24 → 25 taken 1 time.
✓ Branch 25 → 26 taken 1 time.
|
1 | const QTimeZone berlin("Europe/Berlin"); |
| 38 | const Event events[] = { | ||
| 39 |
1/1✓ Branch 28 → 29 taken 1 time.
|
1 | {"dinner-taberna@example.org", "Dinner at Taberna", "Taberna da Rua, Lisboa", QDateTime(QDate(2026, 9, 28), QTime(19, 30), lisbon), 3, false, "ana,rui", ""}, |
| 40 |
1/1✓ Branch 31 → 32 taken 1 time.
|
1 | {"cccamp-2019@example.org", "Chaos Communication Camp 2019", "Ziegeleipark Mildenberg, Zehdenick", QDateTime(QDate(2019, 8, 21), QTime(0, 0), berlin), 120, true, "ben", ""}, |
| 41 |
1/1✓ Branch 34 → 35 taken 1 time.
|
1 | {"board-games@example.org", "Board games", "Kastanienallee 7, Berlin", QDateTime(QDate(2026, 10, 10), QTime(18, 0), berlin), 4, false, "ben,clara,nina", ""}, |
| 42 |
1/1✓ Branch 37 → 38 taken 1 time.
|
1 | {"climbing@example.org", "Climbing", "Berta Block, Berlin", QDateTime(QDate(2026, 10, 3), QTime(17, 0), berlin), 2, false, "nina,akira", ""}, |
| 43 |
1/1✓ Branch 40 → 41 taken 1 time.
|
1 | {"kickoff@example.org", "Project kickoff", "Example GmbH, Berlin", QDateTime(QDate(2026, 10, 15), QTime(10, 0), berlin), 1, false, "", "tom.becker@example.com,Tom Becker,ORGANIZER;ana@example.org,Ana Silva;sam@example.social,Sam Rivera"}, |
| 44 |
1/1✓ Branch 43 → 44 taken 1 time.
|
1 | {"lisbon-trip@example.org", "Trip to Lisbon", "Lisboa", QDateTime(QDate(2026, 11, 20), QTime(0, 0), lisbon), 72, true, "", ""}, |
| 45 |
12/26✓ Branch 27 → 28 taken 1 time.
✓ Branch 29 → 30 taken 1 time.
✓ Branch 30 → 31 taken 1 time.
✓ Branch 32 → 33 taken 1 time.
✓ Branch 33 → 34 taken 1 time.
✓ Branch 35 → 36 taken 1 time.
✓ Branch 36 → 37 taken 1 time.
✓ Branch 38 → 39 taken 1 time.
✓ Branch 39 → 40 taken 1 time.
✓ Branch 41 → 42 taken 1 time.
✓ Branch 42 → 43 taken 1 time.
✓ Branch 44 → 45 taken 1 time.
✗ Branch 250 → 251 not taken.
✗ Branch 250 → 252 not taken.
✗ Branch 255 → 256 not taken.
✗ Branch 255 → 257 not taken.
✗ Branch 260 → 261 not taken.
✗ Branch 260 → 262 not taken.
✗ Branch 265 → 266 not taken.
✗ Branch 265 → 267 not taken.
✗ Branch 270 → 271 not taken.
✗ Branch 270 → 272 not taken.
✗ Branch 275 → 276 not taken.
✗ Branch 275 → 279 not taken.
✗ Branch 277 → 278 not taken.
✗ Branch 277 → 279 not taken.
|
14 | }; |
| 46 |
2/2✓ Branch 225 → 46 taken 6 times.
✓ Branch 225 → 226 taken 1 time.
|
7 | for (const Event &e : events) { |
| 47 | 6 | CalendarEvent event; | |
| 48 |
1/1✓ Branch 47 → 48 taken 6 times.
|
6 | event.uid = text(e.uid); |
| 49 | 6 | event.accountId = info.accountId; | |
| 50 | 6 | event.calendarPath = info.path; | |
| 51 |
2/2✓ Branch 55 → 56 taken 6 times.
✓ Branch 56 → 57 taken 6 times.
|
6 | event.resourceHref = info.path + event.uid + QStringLiteral(".ics"); |
| 52 |
1/1✓ Branch 62 → 63 taken 6 times.
|
6 | event.summary = text(e.summary); |
| 53 |
1/1✓ Branch 65 → 66 taken 6 times.
|
6 | event.location = text(e.location); |
| 54 | 6 | event.allDay = e.allDay; | |
| 55 |
5/5✓ Branch 68 → 69 taken 2 times.
✓ Branch 68 → 72 taken 4 times.
✓ Branch 69 → 70 taken 2 times.
✓ Branch 70 → 71 taken 2 times.
✓ Branch 71 → 73 taken 2 times.
|
6 | event.dtStart = e.allDay ? QDateTime(e.start.date(), QTime(0, 0)) : e.start; |
| 56 |
4/4✓ Branch 75 → 76 taken 2 times.
✓ Branch 75 → 77 taken 4 times.
✓ Branch 76 → 78 taken 2 times.
✓ Branch 77 → 78 taken 4 times.
|
6 | event.dtEnd = e.allDay ? event.dtStart.addDays(e.hours / 24) : e.start.addSecs(e.hours * 3600); |
| 57 | 6 | event.peopleSet = true; | |
| 58 |
6/6✓ Branch 80 → 81 taken 6 times.
✓ Branch 84 → 85 taken 6 times.
✓ Branch 86 → 87 taken 6 times.
✓ Branch 87 → 88 taken 6 times.
✓ Branch 104 → 89 taken 8 times.
✓ Branch 104 → 105 taken 6 times.
|
14 | for (const QString &key : text(e.people).split(QLatin1Char(','), Qt::SkipEmptyParts)) { |
| 59 |
5/9✓ Branch 90 → 91 taken 8 times.
✓ Branch 94 → 95 taken 8 times.
✓ Branch 95 → 96 taken 8 times.
✓ Branch 96 → 97 taken 8 times.
✓ Branch 97 → 98 taken 8 times.
✗ Branch 304 → 305 not taken.
✗ Branch 304 → 306 not taken.
✗ Branch 307 → 308 not taken.
✗ Branch 307 → 309 not taken.
|
16 | event.people << EventPerson{QStringLiteral("urn:uuid:") + uidOf(key), uidOf(key), nameOf(key)}; |
| 60 | 6 | } | |
| 61 |
6/6✓ Branch 106 → 107 taken 6 times.
✓ Branch 110 → 111 taken 6 times.
✓ Branch 112 → 113 taken 6 times.
✓ Branch 113 → 114 taken 6 times.
✓ Branch 141 → 115 taken 3 times.
✓ Branch 141 → 142 taken 6 times.
|
9 | for (const QString &entry : text(e.attendees).split(QLatin1Char(';'), Qt::SkipEmptyParts)) { |
| 62 |
1/1✓ Branch 119 → 120 taken 3 times.
|
3 | const QStringList parts = entry.split(QLatin1Char(',')); |
| 63 | 3 | EventAttendee attendee; | |
| 64 |
1/1✓ Branch 120 → 121 taken 3 times.
|
3 | attendee.address = parts.value(0); |
| 65 |
1/1✓ Branch 123 → 124 taken 3 times.
|
3 | attendee.name = parts.value(1); |
| 66 |
1/1✓ Branch 127 → 128 taken 3 times.
|
3 | attendee.organizer = parts.value(2) == QLatin1String("ORGANIZER"); |
| 67 | 3 | attendee.partstat = QStringLiteral("ACCEPTED"); | |
| 68 |
1/1✓ Branch 136 → 137 taken 3 times.
|
3 | event.attendees << attendee; |
| 69 | 9 | } | |
| 70 |
2/2✓ Branch 143 → 144 taken 6 times.
✓ Branch 144 → 145 taken 6 times.
|
6 | const ICal::Component component = ICalEventCodec::eventComponent(event, ICalTime::ZoneResolver(ICal::Component{})); |
| 71 | 6 | ICal::Component withAttendees = component; | |
| 72 |
4/4✓ Branch 148 → 149 taken 6 times.
✓ Branch 149 → 150 taken 6 times.
✓ Branch 193 → 151 taken 3 times.
✓ Branch 193 → 194 taken 6 times.
|
9 | for (const EventAttendee &attendee : event.attendees) { |
| 73 | 3 | ICal::Property property; | |
| 74 |
6/6✓ Branch 152 → 153 taken 1 time.
✓ Branch 152 → 156 taken 2 times.
✓ Branch 161 → 162 taken 2 times.
✓ Branch 161 → 163 taken 1 time.
✓ Branch 163 → 164 taken 1 time.
✓ Branch 163 → 165 taken 2 times.
|
6 | property.name = attendee.organizer ? QStringLiteral("ORGANIZER") : QStringLiteral("ATTENDEE"); |
| 75 |
1/1✓ Branch 168 → 169 taken 3 times.
|
6 | property.value = QStringLiteral("mailto:") + attendee.address; |
| 76 |
1/3✓ Branch 177 → 178 taken 3 times.
✗ Branch 359 → 360 not taken.
✗ Branch 359 → 361 not taken.
|
3 | property.parameters << ICal::Parameter{QStringLiteral("CN"), attendee.name}; |
| 77 |
2/2✓ Branch 180 → 181 taken 2 times.
✓ Branch 180 → 189 taken 1 time.
|
3 | if (!attendee.organizer) |
| 78 |
1/3✓ Branch 185 → 186 taken 2 times.
✗ Branch 368 → 369 not taken.
✗ Branch 368 → 370 not taken.
|
2 | property.parameters << ICal::Parameter{QStringLiteral("PARTSTAT"), attendee.partstat}; |
| 79 |
1/1✓ Branch 189 → 190 taken 3 times.
|
3 | withAttendees.appendProperty(property); |
| 80 | 3 | } | |
| 81 |
1/1✓ Branch 194 → 195 taken 6 times.
|
6 | event.icalRaw = ICalEventCodec::componentText(withAttendees); |
| 82 |
2/3✓ Branch 197 → 198 taken 6 times.
✗ Branch 198 → 199 not taken.
✓ Branch 198 → 211 taken 6 times.
|
6 | if (!calendar.upsertEvent(event)) { |
| 83 | ✗ | if (error) | |
| 84 | ✗ | *error = QStringLiteral("Cannot store showcase event %1").arg(event.uid); | |
| 85 | ✗ | return false; | |
| 86 | } | ||
| 87 | 6 | } | |
| 88 | 1 | return true; | |
| 89 | 8 | } | |
| 90 | |||
| 91 | } // namespace PeopleShowcase | ||
| 92 |