data/ContactPeopleModels.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QList> | ||
| 4 | #include <QString> | ||
| 5 | #include <QStringList> | ||
| 6 | |||
| 7 | // Sprint 103 people value types (SPRINT-103.md D-3…D-15): positions, | ||
| 8 | // meeting dates, relationships, introducers, social profiles, labelled | ||
| 9 | // dates and mail links. Members of ContactCard (ContactModels.h); read and | ||
| 10 | // written by VCardPeople.cpp / VCardPeoplePatch.cpp. | ||
| 11 | |||
| 12 | // Sprint 103 (D-10): a WGS 84 position — card GEO, the GEO parameter of | ||
| 13 | // ADR and of X-MAILJD-MET-PLACE. Reads "geo:52.5,13.4" (vCard 4.0, RFC 5870) | ||
| 14 | // and "52.5;13.4" (vCard 3.0); out-of-range values are invalid. | ||
| 15 | struct GeoPoint { | ||
| 16 | 56525 | double latitude = 0; | |
| 17 | 56517 | double longitude = 0; | |
| 18 | 56517 | bool valid = false; | |
| 19 | QString toUri() const; // "geo:52.52,13.405" ("" when invalid) | ||
| 20 | static GeoPoint fromText(const QString &text); | ||
| 21 | static GeoPoint at(double latitude, double longitude); | ||
| 22 |
4/6✓ Branch 2 → 3 taken 8 times.
✓ Branch 2 → 4 taken 56517 times.
✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 56517 times.
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 56517 times.
|
56525 | bool operator==(const GeoPoint &) const = default; |
| 23 | }; | ||
| 24 | |||
| 25 | // Sprint 103 (D-7): the date of a meeting — a year ("2019"), a month | ||
| 26 | // ("2019-06"), a full date or a day without year ("--06-14"). | ||
| 27 | struct LooseDate { | ||
| 28 | 27671 | int year = 0; | |
| 29 | 27389 | int month = 0; | |
| 30 | 27383 | int day = 0; | |
| 31 | bool isValid() const; | ||
| 32 |
3/4✓ Branch 2 → 3 taken 79 times.
✓ Branch 2 → 5 taken 211 times.
✓ Branch 3 → 4 taken 79 times.
✗ Branch 3 → 5 not taken.
|
290 | bool hasDay() const { return day > 0 && month > 0; } |
| 33 | QString toIso() const; | ||
| 34 | static LooseDate fromIso(const QString &text); | ||
| 35 |
6/6✓ Branch 2 → 3 taken 282 times.
✓ Branch 2 → 4 taken 27389 times.
✓ Branch 4 → 5 taken 6 times.
✓ Branch 4 → 6 taken 27383 times.
✓ Branch 6 → 7 taken 2 times.
✓ Branch 6 → 8 taken 27381 times.
|
27671 | bool operator==(const LooseDate &) const = default; |
| 36 | }; | ||
| 37 | |||
| 38 | // Sprint 103 (D-3, D-4, S103.1.1): one relationship stored on this card. | ||
| 39 | // `type` names what the target is to the card holder (RFC 6350 §6.6.6): | ||
| 40 | // RELATED;TYPE=parent on Ben's card says "the target is Ben's parent". | ||
| 41 | // Types are lower case: the RFC values, x-manager/x-report, the kin | ||
| 42 | // subtypes of D-4 (grandparent, cousin, …) and "custom" with `label`. | ||
| 43 | struct ContactRelation { | ||
| 44 | 10613 | QString type; | |
| 45 | 10610 | QString label; // custom label ("Godchild"); empty otherwise | |
| 46 | 10610 | QString targetUri; // uri value as stored ("urn:uuid:…", "mailto:…", "http…") | |
| 47 | 10606 | QString targetUid; // UID of the related card when known (urn:uuid or X-MAILJD-UID) | |
| 48 | 10606 | QString targetName; // text value ("Mia Weber"), Apple and legacy names | |
| 49 | 10606 | QString model; // "related", "apple" (X-ABRELATEDNAMES) or "legacy" (read-only) | |
| 50 | 10605 | int sourceIndex = -1; | |
| 51 | 1357 | bool readOnly() const { return model == QLatin1String("legacy"); } | |
| 52 |
10/14✓ Branch 3 → 4 taken 3 times.
✓ Branch 3 → 5 taken 10610 times.
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 10610 times.
✓ Branch 9 → 10 taken 4 times.
✓ Branch 9 → 11 taken 10606 times.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 10606 times.
✗ Branch 15 → 16 not taken.
✓ Branch 15 → 17 taken 10606 times.
✓ Branch 18 → 19 taken 1 time.
✓ Branch 18 → 20 taken 10605 times.
✗ Branch 20 → 21 not taken.
✓ Branch 20 → 22 taken 10605 times.
|
10613 | bool operator==(const ContactRelation &) const = default; |
| 53 | }; | ||
| 54 | |||
| 55 | // A person named by reference: an introducer (D-7), a person in an event. | ||
| 56 | struct ContactPersonRef { | ||
| 57 | 484 | QString uri; // "urn:uuid:…" or another URI | |
| 58 | 484 | QString uid; | |
| 59 | 484 | QString name; // text form or display name | |
| 60 | 484 | int sourceIndex = -1; | |
| 61 |
4/8✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 484 times.
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 484 times.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 484 times.
✗ Branch 11 → 12 not taken.
✓ Branch 11 → 13 taken 484 times.
|
484 | bool operator==(const ContactPersonRef &) const = default; |
| 62 | }; | ||
| 63 | |||
| 64 | // Sprint 103 (D-7, S103.1.3): how we met — one meeting per card. | ||
| 65 | struct ContactMet { | ||
| 66 | 27104 | LooseDate date; | |
| 67 | 26959 | QString place; | |
| 68 | 26955 | GeoPoint placeGeo; | |
| 69 | 26955 | QList<ContactPersonRef> via; // introducers ("Met through") | |
| 70 | 26539 | QString eventUid; // the occasion (calendar event UID) | |
| 71 | 26539 | QString note; | |
| 72 | 26537 | QString channel; // "mail" when introduced by mail (I-5) | |
| 73 | 1752 | bool isEmpty() const { | |
| 74 |
8/10✓ Branch 3 → 4 taken 1562 times.
✓ Branch 3 → 13 taken 190 times.
✓ Branch 5 → 6 taken 1561 times.
✓ Branch 5 → 13 taken 1 time.
✓ Branch 7 → 8 taken 1559 times.
✓ Branch 7 → 13 taken 2 times.
✓ Branch 9 → 10 taken 1559 times.
✗ Branch 9 → 13 not taken.
✓ Branch 11 → 12 taken 1559 times.
✗ Branch 11 → 13 not taken.
|
1752 | return !date.isValid() && place.isEmpty() && via.isEmpty() && eventUid.isEmpty() && note.isEmpty(); |
| 75 | } | ||
| 76 |
11/14✓ Branch 3 → 4 taken 145 times.
✓ Branch 3 → 5 taken 26959 times.
✓ Branch 6 → 7 taken 4 times.
✓ Branch 6 → 8 taken 26955 times.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 26955 times.
✓ Branch 12 → 13 taken 416 times.
✓ Branch 12 → 14 taken 26539 times.
✗ Branch 15 → 16 not taken.
✓ Branch 15 → 17 taken 26539 times.
✓ Branch 18 → 19 taken 2 times.
✓ Branch 18 → 20 taken 26537 times.
✗ Branch 21 → 22 not taken.
✓ Branch 21 → 23 taken 26537 times.
|
27104 | bool operator==(const ContactMet &) const = default; |
| 77 | }; | ||
| 78 | |||
| 79 | // Sprint 103 (D-8, S103.1.2): a social profile (X-SOCIALPROFILE / | ||
| 80 | // SOCIALPROFILE) or a chat address (IMPP). `service` is the lower-case | ||
| 81 | // service type as stored or recognised ("mastodon", "matrix"); `value` the | ||
| 82 | // URL or URI; `user` the handle parameter (X-USER / USERNAME). | ||
| 83 | struct ContactSocial { | ||
| 84 | 969 | QString kind = QStringLiteral("profile"); // "profile" or "chat" | |
| 85 | 969 | QString service; | |
| 86 | 969 | QString value; | |
| 87 | 969 | QString user; | |
| 88 | 969 | QString property; // property it was read from; "" = choose by version | |
| 89 | 968 | int sourceIndex = -1; | |
| 90 |
7/12✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 969 times.
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 969 times.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 969 times.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 969 times.
✓ Branch 15 → 16 taken 1 time.
✓ Branch 15 → 17 taken 968 times.
✗ Branch 17 → 18 not taken.
✓ Branch 17 → 19 taken 968 times.
|
969 | bool operator==(const ContactSocial &) const = default; |
| 91 | }; | ||
| 92 | |||
| 93 | // Sprint 103 (D-15): "this mail is about the person" (X-MAILJD-MAIL). | ||
| 94 | struct ContactMailLink { | ||
| 95 | 1771 | QString messageId; // without angle brackets | |
| 96 | 1770 | QString subject; | |
| 97 | 1770 | QString date; // "YYYY-MM-DD" | |
| 98 | 1770 | int sourceIndex = -1; | |
| 99 |
5/8✓ Branch 3 → 4 taken 1 time.
✓ Branch 3 → 5 taken 1770 times.
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 1770 times.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 1770 times.
✗ Branch 11 → 12 not taken.
✓ Branch 11 → 13 taken 1770 times.
|
1771 | bool operator==(const ContactMailLink &) const = default; |
| 100 | }; | ||
| 101 | |||
| 102 |