MailJDTourDownloadDocsQualityTestsCoverage

Which source lines and branches the tests execute. Lines 91.5 %, branches 75.0 % (minimum 85 % and 72 %). main @ 399ffe3d · 21 October 2026 · pipeline 7238.

GCC Code Coverage Report


Directory: src/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 97.3% 144 / 0 / 148
Functions: 100.0% 24 / 0 / 24
Branches: 87.8% 159 / 0 / 181

data/RelationVocabulary.cpp
Line Branch Exec Source
1 #include "RelationVocabulary.h"
2
3 #include <QCoreApplication>
4 #include <QLocale>
5
6 namespace RelationVocabulary {
7
8 namespace {
9
10 constexpr const char *kContext = "RelationVocabulary";
11
12 // One relationship type. Labels are English source strings; the female and
13 // male forms carry a disambiguation so German gets "Mutter"/"Vater" while
14 // English keeps one word where it has one (D-4).
15 // QT_TRANSLATE_NOOP3 expands to {source, disambiguation}.
16 struct Text {
17 const char *source;
18 const char *disambiguation;
19 };
20
21 struct TypeInfo {
22 const char *id;
23 Category category;
24 const char *inverse; // "" = no known inverse
25 bool editable; // listed in the editor's type menu
26 Text neutral;
27 Text female; // {nullptr, nullptr}: no gendered form
28 Text male;
29 };
30
31 const TypeInfo kTypes[] = {
32 {"spouse", Category::Family, "spouse", true, QT_TRANSLATE_NOOP3("RelationVocabulary", "Partner", "neutral"),
33 QT_TRANSLATE_NOOP3("RelationVocabulary", "Partner", "female"),
34 QT_TRANSLATE_NOOP3("RelationVocabulary", "Partner", "male")},
35 {"ex-partner", Category::Family, "ex-partner", true,
36 QT_TRANSLATE_NOOP3("RelationVocabulary", "Ex-partner", "neutral"),
37 QT_TRANSLATE_NOOP3("RelationVocabulary", "Ex-partner", "female"),
38 QT_TRANSLATE_NOOP3("RelationVocabulary", "Ex-partner", "male")},
39 {"parent", Category::Family, "child", true, QT_TRANSLATE_NOOP3("RelationVocabulary", "Parent", "neutral"),
40 QT_TRANSLATE_NOOP3("RelationVocabulary", "Mother", "female"),
41 QT_TRANSLATE_NOOP3("RelationVocabulary", "Father", "male")},
42 {"child", Category::Family, "parent", true, QT_TRANSLATE_NOOP3("RelationVocabulary", "Child", "neutral"),
43 QT_TRANSLATE_NOOP3("RelationVocabulary", "Daughter", "female"),
44 QT_TRANSLATE_NOOP3("RelationVocabulary", "Son", "male")},
45 {"sibling", Category::Family, "sibling", true, QT_TRANSLATE_NOOP3("RelationVocabulary", "Sibling", "neutral"),
46 QT_TRANSLATE_NOOP3("RelationVocabulary", "Sister", "female"),
47 QT_TRANSLATE_NOOP3("RelationVocabulary", "Brother", "male")},
48 {"grandparent", Category::Family, "grandchild", true,
49 QT_TRANSLATE_NOOP3("RelationVocabulary", "Grandparent", "neutral"),
50 QT_TRANSLATE_NOOP3("RelationVocabulary", "Grandmother", "female"),
51 QT_TRANSLATE_NOOP3("RelationVocabulary", "Grandfather", "male")},
52 {"grandchild", Category::Family, "grandparent", true,
53 QT_TRANSLATE_NOOP3("RelationVocabulary", "Grandchild", "neutral"),
54 QT_TRANSLATE_NOOP3("RelationVocabulary", "Granddaughter", "female"),
55 QT_TRANSLATE_NOOP3("RelationVocabulary", "Grandson", "male")},
56 {"aunt-uncle", Category::Family, "niece-nephew", true,
57 QT_TRANSLATE_NOOP3("RelationVocabulary", "Aunt or uncle", "neutral"),
58 QT_TRANSLATE_NOOP3("RelationVocabulary", "Aunt", "female"),
59 QT_TRANSLATE_NOOP3("RelationVocabulary", "Uncle", "male")},
60 {"niece-nephew", Category::Family, "aunt-uncle", true,
61 QT_TRANSLATE_NOOP3("RelationVocabulary", "Niece or nephew", "neutral"),
62 QT_TRANSLATE_NOOP3("RelationVocabulary", "Niece", "female"),
63 QT_TRANSLATE_NOOP3("RelationVocabulary", "Nephew", "male")},
64 {"cousin", Category::Family, "cousin", true, QT_TRANSLATE_NOOP3("RelationVocabulary", "Cousin", "neutral"),
65 QT_TRANSLATE_NOOP3("RelationVocabulary", "Cousin", "female"),
66 QT_TRANSLATE_NOOP3("RelationVocabulary", "Cousin", "male")},
67 {"parent-in-law", Category::Family, "child-in-law", true,
68 QT_TRANSLATE_NOOP3("RelationVocabulary", "Parent-in-law", "neutral"),
69 QT_TRANSLATE_NOOP3("RelationVocabulary", "Mother-in-law", "female"),
70 QT_TRANSLATE_NOOP3("RelationVocabulary", "Father-in-law", "male")},
71 {"child-in-law", Category::Family, "parent-in-law", true,
72 QT_TRANSLATE_NOOP3("RelationVocabulary", "Child-in-law", "neutral"),
73 QT_TRANSLATE_NOOP3("RelationVocabulary", "Daughter-in-law", "female"),
74 QT_TRANSLATE_NOOP3("RelationVocabulary", "Son-in-law", "male")},
75 // Kinship that follows from others (RelationInference), also editable.
76 {"sibling-in-law", Category::Family, "sibling-in-law", true,
77 QT_TRANSLATE_NOOP3("RelationVocabulary", "Sibling-in-law", "neutral"),
78 QT_TRANSLATE_NOOP3("RelationVocabulary", "Sister-in-law", "female"),
79 QT_TRANSLATE_NOOP3("RelationVocabulary", "Brother-in-law", "male")},
80 {"great-grandparent", Category::Family, "great-grandchild", true,
81 QT_TRANSLATE_NOOP3("RelationVocabulary", "Great-grandparent", "neutral"),
82 QT_TRANSLATE_NOOP3("RelationVocabulary", "Great-grandmother", "female"),
83 QT_TRANSLATE_NOOP3("RelationVocabulary", "Great-grandfather", "male")},
84 {"great-grandchild", Category::Family, "great-grandparent", true,
85 QT_TRANSLATE_NOOP3("RelationVocabulary", "Great-grandchild", "neutral"),
86 QT_TRANSLATE_NOOP3("RelationVocabulary", "Great-granddaughter", "female"),
87 QT_TRANSLATE_NOOP3("RelationVocabulary", "Great-grandson", "male")},
88 {"great-aunt-uncle", Category::Family, "grand-niece-nephew", true,
89 QT_TRANSLATE_NOOP3("RelationVocabulary", "Great-aunt or great-uncle", "neutral"),
90 QT_TRANSLATE_NOOP3("RelationVocabulary", "Great-aunt", "female"),
91 QT_TRANSLATE_NOOP3("RelationVocabulary", "Great-uncle", "male")},
92 {"grand-niece-nephew", Category::Family, "great-aunt-uncle", true,
93 QT_TRANSLATE_NOOP3("RelationVocabulary", "Grandniece or grandnephew", "neutral"),
94 QT_TRANSLATE_NOOP3("RelationVocabulary", "Grandniece", "female"),
95 QT_TRANSLATE_NOOP3("RelationVocabulary", "Grandnephew", "male")},
96 {"kin",Category::Family, "kin", true, QT_TRANSLATE_NOOP3("RelationVocabulary", "Relative", "neutral"),
97 QT_TRANSLATE_NOOP3("RelationVocabulary", "Relative", "female"),
98 QT_TRANSLATE_NOOP3("RelationVocabulary", "Relative", "male")},
99 // F103-10: a family card (a household entry) lists its members; the
100 // member's card shows the family (derived). Stored as kin subtypes.
101 {"member", Category::Family, "member-of", true,
102 QT_TRANSLATE_NOOP3("RelationVocabulary", "Family member", "neutral"), {nullptr, nullptr}, {nullptr, nullptr}},
103 {"member-of", Category::Family, "member", true, QT_TRANSLATE_NOOP3("RelationVocabulary", "Family", "neutral"),
104 {nullptr, nullptr}, {nullptr, nullptr}},
105 {"co-resident", Category::Family, "co-resident", false,
106 QT_TRANSLATE_NOOP3("RelationVocabulary", "Lives with", "neutral"), {nullptr, nullptr}, {nullptr, nullptr}},
107 {"friend", Category::Friends, "friend", true, QT_TRANSLATE_NOOP3("RelationVocabulary", "Friend", "neutral"),
108 QT_TRANSLATE_NOOP3("RelationVocabulary", "Friend", "female"),
109 QT_TRANSLATE_NOOP3("RelationVocabulary", "Friend", "male")},
110 {"acquaintance", Category::Friends, "acquaintance", true,
111 QT_TRANSLATE_NOOP3("RelationVocabulary", "Acquaintance", "neutral"),
112 QT_TRANSLATE_NOOP3("RelationVocabulary", "Acquaintance", "female"),
113 QT_TRANSLATE_NOOP3("RelationVocabulary", "Acquaintance", "male")},
114 {"colleague", Category::Work, "colleague", true, QT_TRANSLATE_NOOP3("RelationVocabulary", "Colleague", "neutral"),
115 QT_TRANSLATE_NOOP3("RelationVocabulary", "Colleague", "female"),
116 QT_TRANSLATE_NOOP3("RelationVocabulary", "Colleague", "male")},
117 {"co-worker", Category::Work, "co-worker", false, QT_TRANSLATE_NOOP3("RelationVocabulary", "Co-worker", "neutral"),
118 {nullptr, nullptr}, {nullptr, nullptr}},
119 {"x-manager", Category::Work, "x-report", true, QT_TRANSLATE_NOOP3("RelationVocabulary", "Manager", "neutral"),
120 QT_TRANSLATE_NOOP3("RelationVocabulary", "Manager", "female"),
121 QT_TRANSLATE_NOOP3("RelationVocabulary", "Manager", "male")},
122 {"x-report", Category::Work, "x-manager", true, QT_TRANSLATE_NOOP3("RelationVocabulary", "Team member", "neutral"),
123 {nullptr, nullptr}, {nullptr, nullptr}},
124 {"agent", Category::Work, "x-assisted", true, QT_TRANSLATE_NOOP3("RelationVocabulary", "Assistant", "neutral"),
125 {nullptr, nullptr}, {nullptr, nullptr}},
126 {"x-assisted", Category::Work, "agent", false,
127 QT_TRANSLATE_NOOP3("RelationVocabulary", "Assisted person", "neutral"), {nullptr, nullptr}, {nullptr, nullptr}},
128 {"neighbor", Category::Other, "neighbor", true, QT_TRANSLATE_NOOP3("RelationVocabulary", "Neighbour", "neutral"),
129 QT_TRANSLATE_NOOP3("RelationVocabulary", "Neighbour", "female"),
130 QT_TRANSLATE_NOOP3("RelationVocabulary", "Neighbour", "male")},
131 {"emergency", Category::Other, "x-emergency-for", true,
132 QT_TRANSLATE_NOOP3("RelationVocabulary", "Emergency contact", "neutral"), {nullptr, nullptr}, {nullptr, nullptr}},
133 {"x-emergency-for", Category::Other, "emergency", false,
134 QT_TRANSLATE_NOOP3("RelationVocabulary", "Emergency contact for", "neutral"), {nullptr, nullptr}, {nullptr, nullptr}},
135 {"contact", Category::Other, "contact", false, QT_TRANSLATE_NOOP3("RelationVocabulary", "Contact", "neutral"),
136 {nullptr, nullptr}, {nullptr, nullptr}},
137 {"met", Category::Other, "met", false, QT_TRANSLATE_NOOP3("RelationVocabulary", "Has met", "neutral"),
138 {nullptr, nullptr}, {nullptr, nullptr}},
139 {"date", Category::Other, "date", false, QT_TRANSLATE_NOOP3("RelationVocabulary", "Date", "neutral"),
140 {nullptr, nullptr}, {nullptr, nullptr}},
141 {"sweetheart", Category::Other, "sweetheart", false,
142 QT_TRANSLATE_NOOP3("RelationVocabulary", "Sweetheart", "neutral"), {nullptr, nullptr}, {nullptr, nullptr}},
143 {"crush", Category::Other, "", false, QT_TRANSLATE_NOOP3("RelationVocabulary", "Crush", "neutral"),
144 {nullptr, nullptr}, {nullptr, nullptr}},
145 {"muse", Category::Other, "", false, QT_TRANSLATE_NOOP3("RelationVocabulary", "Muse", "neutral"),
146 {nullptr, nullptr}, {nullptr, nullptr}},
147 {"me", Category::Other, "me", false, QT_TRANSLATE_NOOP3("RelationVocabulary", "Same person", "neutral"),
148 {nullptr, nullptr}, {nullptr, nullptr}},
149 };
150
151 const char *const kKinSubtypes[] = {"ex-partner", "grandparent", "grandchild", "aunt-uncle",
152 "niece-nephew", "parent-in-law", "child-in-law", "cousin",
153 "member", "member-of", "sibling-in-law", "great-grandparent",
154 "great-grandchild", "great-aunt-uncle", "grand-niece-nephew"};
155
156 const char *const kMxTypes[] = {"x-manager", "x-report", "x-assisted", "x-emergency-for"};
157
158 struct Alias {
159 const char *spelling;
160 const char *id;
161 };
162
163 // Other spellings of a TYPE value (DAVx⁵, Thunderbird, hand-written cards).
164 const Alias kAliases[] = {
165 {"x-assistant", "agent"}, {"assistant", "agent"}, {"manager", "x-manager"},
166 {"x-supervisor", "x-manager"}, {"x-reports", "x-report"}, {"report", "x-report"},
167 {"subordinate", "x-report"}, {"partner", "spouse"}, {"x-partner", "spouse"},
168 {"husband", "spouse"}, {"wife", "spouse"}, {"x-spouse", "spouse"},
169 {"neighbour", "neighbor"}, {"relative", "kin"}, {"x-relative", "kin"},
170 {"brother", "sibling"}, {"sister", "sibling"}, {"mother", "parent"},
171 {"father", "parent"}, {"son", "child"}, {"daughter", "child"},
172 {"x-ex-partner", "ex-partner"}, {"x-cousin", "cousin"}, {"x-grandparent", "grandparent"},
173 {"x-grandchild", "grandchild"},
174 };
175
176 // Label texts other clients and earlier MailJD versions write, matched case
177 // insensitively and independent of the UI language (D-7: recognition never
178 // depends on a marker parameter or the current translation).
179 const Alias kLabels[] = {
180 // Apple/Google names (inside "_$!<…>!$_" or plain) and English labels.
181 {"father", "parent"}, {"mother", "parent"}, {"parent", "parent"}, {"brother", "sibling"},
182 {"sister", "sibling"}, {"sibling", "sibling"}, {"child", "child"}, {"son", "child"},
183 {"daughter", "child"}, {"friend", "friend"}, {"spouse", "spouse"}, {"partner", "spouse"},
184 {"husband", "spouse"}, {"wife", "spouse"}, {"assistant", "agent"}, {"manager", "x-manager"},
185 {"ex-partner", "ex-partner"}, {"grandparent", "grandparent"}, {"grandmother", "grandparent"},
186 {"grandfather", "grandparent"}, {"grandchild", "grandchild"}, {"granddaughter", "grandchild"},
187 {"grandson", "grandchild"}, {"aunt/uncle", "aunt-uncle"}, {"aunt or uncle", "aunt-uncle"},
188 {"aunt", "aunt-uncle"}, {"uncle", "aunt-uncle"}, {"niece/nephew", "niece-nephew"},
189 {"niece or nephew", "niece-nephew"}, {"niece", "niece-nephew"}, {"nephew", "niece-nephew"},
190 {"cousin", "cousin"}, {"parent-in-law", "parent-in-law"}, {"mother-in-law", "parent-in-law"},
191 {"father-in-law", "parent-in-law"}, {"child-in-law", "child-in-law"},
192 {"daughter-in-law", "child-in-law"}, {"son-in-law", "child-in-law"}, {"relative", "kin"},
193 {"neighbour", "neighbor"}, {"neighbor", "neighbor"}, {"colleague", "colleague"},
194 {"acquaintance", "acquaintance"}, {"emergency contact", "emergency"}, {"team member", "x-report"},
195 // German (neutral words of the glossary §6.4 and gendered forms).
196 {"partnerschaft", "spouse"}, {"partnerin", "spouse"}, {"ehemalige partnerschaft", "ex-partner"},
197 {"ex-partnerin", "ex-partner"}, {"elternteil", "parent"}, {"mutter", "parent"}, {"vater", "parent"},
198 {"kind", "child"}, {"tochter", "child"}, {"sohn", "child"}, {"geschwister", "sibling"},
199 {"schwester", "sibling"}, {"bruder", "sibling"}, {"großelternteil", "grandparent"},
200 {"großmutter", "grandparent"}, {"großvater", "grandparent"}, {"enkelkind", "grandchild"},
201 {"enkelin", "grandchild"}, {"enkel", "grandchild"}, {"geschwister der eltern", "aunt-uncle"},
202 {"tante", "aunt-uncle"}, {"onkel", "aunt-uncle"}, {"geschwisterkind", "niece-nephew"},
203 {"tante oder onkel", "aunt-uncle"}, {"nichte oder neffe", "niece-nephew"}, // F103-08
204 {"family member", "member"}, {"familienmitglied", "member"}, {"member of family", "member-of"}, // F103-10
205 {"nichte", "niece-nephew"}, {"neffe", "niece-nephew"}, {"cousine", "cousin"},
206 {"sibling-in-law", "sibling-in-law"}, {"sister-in-law", "sibling-in-law"}, {"brother-in-law", "sibling-in-law"},
207 {"schwägerin", "sibling-in-law"}, {"schwager", "sibling-in-law"}, {"great-grandmother", "great-grandparent"},
208 {"great-grandfather", "great-grandparent"}, {"urgroßmutter", "great-grandparent"},
209 {"urgroßvater", "great-grandparent"}, {"great-granddaughter", "great-grandchild"},
210 {"great-grandson", "great-grandchild"}, {"urenkelin", "great-grandchild"}, {"urenkel", "great-grandchild"},
211 {"great-aunt", "great-aunt-uncle"}, {"great-uncle", "great-aunt-uncle"}, {"großtante", "great-aunt-uncle"},
212 {"großonkel", "great-aunt-uncle"}, {"grandniece", "grand-niece-nephew"}, {"grandnephew", "grand-niece-nephew"},
213 {"großnichte", "grand-niece-nephew"}, {"großneffe", "grand-niece-nephew"},
214 {"kind von onkel oder tante", "cousin"}, {"schwiegerelternteil", "parent-in-law"},
215 {"schwiegermutter", "parent-in-law"}, {"schwiegervater", "parent-in-law"},
216 {"schwiegerkind", "child-in-law"}, {"schwiegertochter", "child-in-law"},
217 {"schwiegersohn", "child-in-law"}, {"verwandtschaft", "kin"}, {"verwandte", "kin"},
218 {"verwandter", "kin"}, {"freundschaft", "friend"}, {"freundin", "friend"}, {"freund", "friend"},
219 {"bekanntschaft", "acquaintance"}, {"bekannte", "acquaintance"}, {"bekannter", "acquaintance"},
220 {"kollegium", "colleague"}, {"kollegin", "colleague"}, {"kollege", "colleague"},
221 {"vorgesetzte person", "x-manager"}, {"vorgesetzte", "x-manager"}, {"vorgesetzter", "x-manager"},
222 {"teammitglied", "x-report"}, {"assistenz", "agent"}, {"nachbarschaft", "neighbor"},
223 {"nachbarin", "neighbor"}, {"nachbar", "neighbor"}, {"notfallkontakt", "emergency"},
224 // S106-156: every neutral label MailJD itself writes (label()), English
225 // and German, so its own write → read round trip keeps the type. The
226 // generic "Family"/"Familie" of member-of is left out on purpose: other
227 // clients use it for any relative.
228 {"cousin oder cousine", "cousin"}, {"schwager oder schwägerin", "sibling-in-law"},
229 {"great-grandparent", "great-grandparent"}, {"urgroßelternteil", "great-grandparent"},
230 {"great-grandchild", "great-grandchild"}, {"urenkelkind", "great-grandchild"},
231 {"great-aunt or great-uncle", "great-aunt-uncle"}, {"großtante oder großonkel", "great-aunt-uncle"},
232 {"grandniece or grandnephew", "grand-niece-nephew"}, {"großnichte oder großneffe", "grand-niece-nephew"},
233 {"lives with", "co-resident"}, {"wohnt zusammen mit", "co-resident"}, {"co-worker", "co-worker"},
234 {"mitarbeit", "co-worker"}, {"assisted person", "x-assisted"}, {"unterstützte person", "x-assisted"},
235 {"emergency contact for", "x-emergency-for"}, {"notfallkontakt für", "x-emergency-for"},
236 {"contact", "contact"}, {"kontakt", "contact"}, {"has met", "met"}, {"getroffen", "met"},
237 {"date", "date"}, {"sweetheart", "sweetheart"}, {"liebling", "sweetheart"}, {"crush", "crush"},
238 {"schwarm", "crush"}, {"muse", "muse"}, {"same person", "me"}, {"dieselbe person", "me"},
239 };
240
241 const char *const kMetDateLabels[] = {"met", "how we met", "first met", "kennengelernt", "kennengelernt am",
242 "erstes treffen"};
243 const char *const kMetViaLabels[] = {"met through", "introduced by", "referred by", "kennengelernt über",
244 "vorgestellt von", "empfohlen von", "kennengelernt durch"};
245
246 35600 QString tr(const char *text, const char *disambiguation = nullptr) {
247 35600 return QCoreApplication::translate(kContext, text, disambiguation);
248 }
249
250 244693 const TypeInfo *find(const QString &type) {
251
1/1
✓ Branch 2 → 3 taken 244693 times.
244693 const QString id = canonical(type);
252
2/2
✓ Branch 9 → 4 taken 4254641 times.
✓ Branch 9 → 10 taken 560 times.
4255201 for (const TypeInfo &info : kTypes)
253
2/2
✓ Branch 6 → 7 taken 244133 times.
✓ Branch 6 → 8 taken 4010508 times.
4254641 if (id == QLatin1String(info.id))
254 244133 return &info;
255 560 return nullptr;
256 244693 }
257
258 33905 QString normalizedLabel(QString label) {
259
1/1
✓ Branch 2 → 3 taken 33905 times.
33905 label = label.trimmed();
260
7/8
✓ Branch 6 → 7 taken 33905 times.
✓ Branch 7 → 8 taken 2 times.
✓ Branch 7 → 12 taken 33903 times.
✓ Branch 9 → 10 taken 2 times.
✓ Branch 10 → 11 taken 2 times.
✗ Branch 10 → 12 not taken.
✓ Branch 13 → 14 taken 2 times.
✓ Branch 13 → 19 taken 33903 times.
33905 if (label.startsWith(QLatin1String("_$!<")) && label.endsWith(QLatin1String(">!$_")))
261
1/1
✓ Branch 15 → 16 taken 2 times.
2 label = label.mid(4, label.size() - 8);
262 33905 return label.toLower();
263 }
264
265 33115 bool inList(const QString &label, const char *const *begin, const char *const *end) {
266
1/1
✓ Branch 3 → 4 taken 33115 times.
33115 const QString key = normalizedLabel(label);
267
2/2
✓ Branch 13 → 6 taken 229604 times.
✓ Branch 13 → 14 taken 32825 times.
262429 for (const char *const *item = begin; item != end; ++item)
268
3/3
✓ Branch 7 → 8 taken 229604 times.
✓ Branch 10 → 11 taken 290 times.
✓ Branch 10 → 12 taken 229314 times.
229604 if (key == QString::fromUtf8(*item))
269 290 return true;
270 32825 return false;
271 33115 }
272
273 // German nouns keep their capital letter inside a sentence; English labels
274 // are lower case there ("Marta Silva is Ana's sibling").
275 5656 QString sentenceWord(const QString &label) {
276
8/12
✓ Branch 2 → 3 taken 5656 times.
✓ Branch 3 → 4 taken 5656 times.
✓ Branch 4 → 5 taken 5655 times.
✓ Branch 4 → 7 taken 1 time.
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 5655 times.
✓ Branch 9 → 10 taken 5656 times.
✗ Branch 9 → 11 not taken.
✓ Branch 11 → 12 taken 1 time.
✓ Branch 11 → 13 taken 5655 times.
✗ Branch 21 → 22 not taken.
✗ Branch 21 → 23 not taken.
5656 if (QLocale().language() == QLocale::German || label.isEmpty())
277 1 return label;
278
2/2
✓ Branch 13 → 14 taken 5655 times.
✓ Branch 16 → 17 taken 5655 times.
5655 return label.at(0).toLower() + label.mid(1);
279 }
280
281 } // namespace
282
283 33 QStringList editableTypes() {
284 33 QStringList types;
285
2/2
✓ Branch 8 → 4 taken 132 times.
✓ Branch 8 → 9 taken 33 times.
165 for (Category category : {Category::Family, Category::Friends, Category::Work, Category::Other})
286
2/2
✓ Branch 4 → 5 taken 132 times.
✓ Branch 5 → 6 taken 132 times.
132 types += typesOf(category);
287 33 return types;
288 ✗ }
289
290 868 QStringList typesOf(Category category) {
291 868 QStringList types;
292
2/2
✓ Branch 11 → 3 taken 33852 times.
✓ Branch 11 → 12 taken 868 times.
34720 for (const TypeInfo &info : kTypes)
293
4/4
✓ Branch 3 → 4 taken 24304 times.
✓ Branch 3 → 10 taken 9548 times.
✓ Branch 4 → 5 taken 6076 times.
✓ Branch 4 → 10 taken 18228 times.
33852 if (info.editable && info.category == category)
294
2/2
✓ Branch 6 → 7 taken 6076 times.
✓ Branch 7 → 8 taken 6076 times.
6076 types.append(QString::fromLatin1(info.id));
295 868 return types;
296 ✗ }
297
298 37413 Category categoryOf(const QString &type) {
299 37413 const TypeInfo *info = find(type);
300
2/2
✓ Branch 3 → 4 taken 37378 times.
✓ Branch 3 → 5 taken 35 times.
37413 return info ? info->category : Category::Other;
301 }
302
303 42258 QString categoryId(Category category) {
304
4/5
✓ Branch 2 → 3 taken 7680 times.
✓ Branch 2 → 8 taken 31773 times.
✓ Branch 2 → 13 taken 1711 times.
✓ Branch 2 → 18 taken 1094 times.
✗ Branch 2 → 19 not taken.
42258 switch (category) {
305 7680 case Category::Family:
306 7680 return QStringLiteral("family");
307 31773 case Category::Friends:
308 31773 return QStringLiteral("friends");
309 1711 case Category::Work:
310 1711 return QStringLiteral("work");
311 1094 case Category::Other:
312 1094 break;
313 }
314 1094 return QStringLiteral("other");
315 }
316
317 5119 QString categoryLabel(Category category) {
318
4/5
✓ Branch 2 → 3 taken 3295 times.
✓ Branch 2 → 4 taken 366 times.
✓ Branch 2 → 5 taken 912 times.
✓ Branch 2 → 6 taken 546 times.
✗ Branch 2 → 7 not taken.
5119 switch (category) {
319 3295 case Category::Family:
320 3295 return tr("Family");
321 366 case Category::Friends:
322 366 return tr("Friends");
323 912 case Category::Work:
324 912 return tr("Work");
325 546 case Category::Other:
326 546 break;
327 }
328 546 return tr("Other");
329 }
330
331 769950 QString canonical(const QString &type) {
332
2/2
✓ Branch 2 → 3 taken 769950 times.
✓ Branch 3 → 4 taken 769950 times.
769950 const QString lower = type.trimmed().toLower();
333
2/2
✓ Branch 13 → 6 taken 19248559 times.
✓ Branch 13 → 14 taken 769938 times.
20018497 for (const Alias &alias : kAliases)
334
2/2
✓ Branch 8 → 9 taken 12 times.
✓ Branch 8 → 12 taken 19248547 times.
19248559 if (lower == QLatin1String(alias.spelling))
335
1/1
✓ Branch 10 → 11 taken 12 times.
12 return QString::fromLatin1(alias.id);
336 769938 return lower;
337 769950 }
338
339 188929 QString inverseOf(const QString &type) {
340 188929 const TypeInfo *info = find(type);
341
3/3
✓ Branch 3 → 4 taken 188406 times.
✓ Branch 3 → 6 taken 523 times.
✓ Branch 5 → 7 taken 188406 times.
188929 return info ? QString::fromLatin1(info->inverse) : QString();
342 }
343
344 1879 bool isKinSubtype(const QString &type) {
345
1/1
✓ Branch 2 → 3 taken 1879 times.
1879 const QString id = canonical(type);
346
2/2
✓ Branch 9 → 4 taken 26264 times.
✓ Branch 9 → 10 taken 1643 times.
27907 for (const char *kin : kKinSubtypes)
347
2/2
✓ Branch 6 → 7 taken 236 times.
✓ Branch 6 → 8 taken 26028 times.
26264 if (id == QLatin1String(kin))
348 236 return true;
349 1643 return false;
350 1879 }
351
352 942 QString wireType(const QString &type) {
353
1/1
✓ Branch 2 → 3 taken 942 times.
942 const QString id = canonical(type);
354
3/3
✓ Branch 3 → 4 taken 942 times.
✓ Branch 4 → 5 taken 119 times.
✓ Branch 4 → 10 taken 823 times.
942 if (isKinSubtype(id))
355 119 return QStringLiteral("kin");
356
6/6
✓ Branch 12 → 13 taken 810 times.
✓ Branch 12 → 15 taken 13 times.
✓ Branch 14 → 15 taken 413 times.
✓ Branch 14 → 16 taken 397 times.
✓ Branch 17 → 18 taken 426 times.
✓ Branch 17 → 23 taken 397 times.
823 if (id == QLatin1String("custom") || id.isEmpty())
357 426 return QStringLiteral("contact");
358 397 return id;
359 942 }
360
361 2 bool isKnown(const QString &type) {
362
1/1
✓ Branch 2 → 3 taken 2 times.
2 const QString id = canonical(type);
363
3/3
✓ Branch 3 → 4 taken 2 times.
✓ Branch 4 → 5 taken 1 time.
✓ Branch 4 → 6 taken 1 time.
2 if (find(id) != nullptr)
364 1 return true;
365
2/2
✓ Branch 12 → 7 taken 4 times.
✓ Branch 12 → 13 taken 1 time.
5 for (const char *x : kMxTypes)
366
1/2
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 4 times.
4 if (id == QLatin1String(x))
367 ✗ return true;
368 1 return false;
369 2 }
370
371 18475 QString label(const QString &type, const QString &gender, const QString &custom) {
372
1/1
✓ Branch 2 → 3 taken 18475 times.
18475 const QString id = canonical(type);
373
5/9
✓ Branch 5 → 6 taken 18349 times.
✓ Branch 5 → 10 taken 126 times.
✗ Branch 7 → 8 not taken.
✓ Branch 7 → 11 taken 18349 times.
✗ Branch 8 → 9 not taken.
✗ Branch 9 → 10 not taken.
✗ Branch 9 → 11 not taken.
✓ Branch 12 → 13 taken 126 times.
✓ Branch 12 → 18 taken 18349 times.
18475 if (id == QLatin1String("custom") || (!custom.isEmpty() && find(id) == nullptr))
374
1/3
✗ Branch 14 → 15 not taken.
✓ Branch 14 → 16 taken 126 times.
✗ Branch 15 → 17 not taken.
126 return custom.isEmpty() ? tr("Other") : custom;
375
1/1
✓ Branch 18 → 19 taken 18349 times.
18349 const TypeInfo *info = find(id);
376
2/2
✓ Branch 19 → 20 taken 1 time.
✓ Branch 19 → 42 taken 18348 times.
18349 if (info == nullptr) {
377 // An RFC or x- type MailJD has no label for: its name, readable.
378
3/4
✓ Branch 21 → 22 taken 1 time.
✓ Branch 22 → 23 taken 1 time.
✗ Branch 22 → 24 not taken.
✓ Branch 23 → 25 taken 1 time.
1 QString name = id.startsWith(QLatin1String("x-")) ? id.mid(2) : id;
379
1/1
✓ Branch 29 → 30 taken 1 time.
1 name.replace(QLatin1Char('-'), QLatin1Char(' '));
380
4/9
✗ Branch 31 → 32 not taken.
✓ Branch 31 → 33 taken 1 time.
✗ Branch 32 → 37 not taken.
✓ Branch 33 → 34 taken 1 time.
✓ Branch 36 → 37 taken 1 time.
✓ Branch 38 → 39 taken 1 time.
✗ Branch 38 → 40 not taken.
✗ Branch 78 → 79 not taken.
✗ Branch 78 → 80 not taken.
1 return name.isEmpty() ? tr("Other") : name.at(0).toUpper() + name.mid(1);
381 1 }
382
3/3
✓ Branch 42 → 43 taken 18348 times.
✓ Branch 43 → 44 taken 18348 times.
✓ Branch 44 → 45 taken 18348 times.
18348 const QString sex = gender.trimmed().left(1).toUpper();
383
6/6
✓ Branch 49 → 50 taken 7844 times.
✓ Branch 49 → 52 taken 10504 times.
✓ Branch 50 → 51 taken 7509 times.
✓ Branch 50 → 52 taken 335 times.
✓ Branch 53 → 54 taken 7509 times.
✓ Branch 53 → 56 taken 10839 times.
18348 if (sex == QLatin1String("F") && info->female.source)
384
1/1
✓ Branch 54 → 55 taken 7509 times.
7509 return tr(info->female.source, info->female.disambiguation);
385
6/6
✓ Branch 58 → 59 taken 3994 times.
✓ Branch 58 → 61 taken 6845 times.
✓ Branch 59 → 60 taken 3780 times.
✓ Branch 59 → 61 taken 214 times.
✓ Branch 62 → 63 taken 3780 times.
✓ Branch 62 → 65 taken 7059 times.
10839 if (sex == QLatin1String("M") && info->male.source)
386
1/1
✓ Branch 63 → 64 taken 3780 times.
3780 return tr(info->male.source, info->male.disambiguation);
387
1/1
✓ Branch 65 → 66 taken 7059 times.
7059 return tr(info->neutral.source, info->neutral.disambiguation);
388 18475 }
389
390 1253 QString inverseLabel(const QString &type, const QString &gender, const QString &custom) {
391
1/1
✓ Branch 2 → 3 taken 1253 times.
1253 const QString inverse = inverseOf(type);
392
2/2
✓ Branch 4 → 5 taken 1232 times.
✓ Branch 4 → 10 taken 21 times.
1253 if (!inverse.isEmpty())
393
1/1
✓ Branch 6 → 7 taken 1232 times.
1232 return label(inverse, gender);
394 //: Label of a relationship seen from the other card when no inverse word exists, e.g. "Godchild of".
395
3/3
✓ Branch 10 → 11 taken 21 times.
✓ Branch 13 → 14 taken 21 times.
✓ Branch 14 → 15 taken 21 times.
42 return tr("%1 of").arg(label(type, {}, custom));
396 1253 }
397
398 6295 QString holderLabel(const QString &type, bool stored, const QString &holderGender) {
399
1/1
✓ Branch 2 → 3 taken 6295 times.
6295 const QString known = canonical(type);
400
8/9
✓ Branch 4 → 5 taken 6295 times.
✗ Branch 4 → 11 not taken.
✓ Branch 7 → 8 taken 6278 times.
✓ Branch 7 → 11 taken 17 times.
✓ Branch 9 → 10 taken 6278 times.
✓ Branch 10 → 11 taken 130 times.
✓ Branch 10 → 12 taken 6148 times.
✓ Branch 13 → 14 taken 147 times.
✓ Branch 13 → 15 taken 6148 times.
6295 if (known.isEmpty() || known == QLatin1String("custom") || known.startsWith(QLatin1String("member")))
401 147 return {};
402
3/3
✓ Branch 15 → 16 taken 5863 times.
✓ Branch 15 → 17 taken 285 times.
✓ Branch 16 → 18 taken 5863 times.
6148 const QString holderType = stored ? inverseOf(known) : known;
403
1/2
✗ Branch 19 → 20 not taken.
✓ Branch 19 → 21 taken 6148 times.
6148 if (holderType.isEmpty())
404 ✗ return {};
405
2/2
✓ Branch 23 → 24 taken 197 times.
✓ Branch 23 → 29 taken 5951 times.
6148 if (holderType == QLatin1String("x-emergency-for")) // already "… for"
406
1/1
✓ Branch 25 → 26 taken 197 times.
197 return label(holderType, holderGender);
407
3/3
✓ Branch 29 → 30 taken 5951 times.
✓ Branch 32 → 33 taken 5951 times.
✓ Branch 33 → 34 taken 5951 times.
11902 return tr("%1 of").arg(label(holderType, holderGender));
408 6295 }
409
410 5656 QString sentence(const QString &targetName, const QString &type, const QString &holderName,
411 const QString &targetGender, const QString &custom) {
412 //: "Marta Silva is Ana Silva's sibling": %1 target, %2 card holder, %3 relation word.
413
4/4
✓ Branch 2 → 3 taken 5656 times.
✓ Branch 3 → 4 taken 5656 times.
✓ Branch 4 → 5 taken 5656 times.
✓ Branch 5 → 6 taken 5656 times.
5656 return tr("%1 is %2's %3").arg(targetName, holderName, sentenceWord(label(type, targetGender, custom)));
414 }
415
416 790 QString typeForLabel(const QString &text) {
417
1/1
✓ Branch 3 → 4 taken 790 times.
790 const QString key = normalizedLabel(text);
418
2/2
✓ Branch 6 → 7 taken 9 times.
✓ Branch 6 → 8 taken 781 times.
790 if (key.isEmpty())
419 9 return {};
420
2/2
✓ Branch 18 → 9 taken 49559 times.
✓ Branch 18 → 19 taken 195 times.
49754 for (const Alias &alias : kLabels)
421
3/3
✓ Branch 10 → 11 taken 49559 times.
✓ Branch 13 → 14 taken 586 times.
✓ Branch 13 → 17 taken 48973 times.
49559 if (key == QString::fromUtf8(alias.spelling))
422
1/1
✓ Branch 15 → 16 taken 586 times.
586 return QString::fromLatin1(alias.id);
423 195 return {};
424 790 }
425
426 950 bool isMetDateLabel(const QString &label) {
427 1900 return inList(label, std::begin(kMetDateLabels), std::end(kMetDateLabels));
428 }
429
430 32165 bool isMetViaLabel(const QString &label) {
431 64330 return inList(label, std::begin(kMetViaLabels), std::end(kMetViaLabels));
432 }
433
434 42 QString metDateLabel() { return tr("Met"); }
435
436 463 QString metViaLabel() { return tr("Met through"); }
437
438 } // namespace RelationVocabulary
439