15QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QCollatorSortKeyPrivate)
27 int currentGeneration = QLocalePrivate::s_generation.loadRelaxed();
28 if (Q_UNLIKELY(
generation != currentGeneration)) {
31 theCollator = QCollator();
37Q_GLOBAL_STATIC(QThreadStorage<GenerationalCollator>, defaultCollator)
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
156
157
158
159
160
161
162
163
164
165
166QCollator::QCollator()
172
173
174
175
176QCollator::QCollator(
const QLocale &locale)
177 : d(
new QCollatorPrivate(locale))
182
183
184QCollator::QCollator(
const QCollator &other)
189 d->ensureInitialized();
195
196
197QCollator::~QCollator()
199 if (d && !d->ref.deref())
204
205
206QCollator &QCollator::operator=(
const QCollator &other)
208 if (
this != &other) {
209 if (d && !d->ref.deref())
214 d->ensureInitialized();
222
223
224
225
226
227
228
229
230
231
234
235
236
237
238
239
242
243
244
247
248
249
250
251
252
253
255bool comparesEqual(
const QCollator &lhs,
const QCollator &rhs)
noexcept
259 if (!lhs.d || !rhs.d)
262 return lhs.d->options == rhs.d->options
263 && lhs.d->locale == rhs.d->locale;
267
268
269void QCollator::detach()
272 d =
new QCollatorPrivate(QLocale().collation());
274 }
else if (d->ref.loadRelaxed() != 1) {
275 QCollatorPrivate *x =
new QCollatorPrivate(d->locale);
276 x->options = d->options;
286
287
288
289
290void QCollator::setLocale(
const QLocale &locale)
292 if (locale ==
this->locale())
300
301
302
303
304
305
306
307QLocale QCollator::locale()
const
309 return d ? d->locale : QLocale().collation();
313
314
315
316
317void QCollator::setCaseSensitivity(Qt::CaseSensitivity cs)
319 if (cs == caseSensitivity())
323 d->options.setFlag(CollationOption::CaseInsensitive, cs == Qt::CaseInsensitive);
327
328
329
330
331
332
333
334
335
336
337
338Qt::CaseSensitivity QCollator::caseSensitivity()
const
340 return d && d->options.testFlag(CollationOption::CaseInsensitive) ? Qt::CaseInsensitive
345
346
347
348
349void QCollator::setNumericMode(
bool on)
351 if (on == numericMode())
355 d->options.setFlag(CollationOption::NumericSort, on);
359
360
361
362
363
364
365
366
367
368bool QCollator::numericMode()
const
370 return d && d->options.testFlag(CollationOption::NumericSort);
374
375
376
377
378void QCollator::setIgnorePunctuation(
bool on)
380 if (on == ignorePunctuation())
384 d->options.setFlag(CollationOption::IgnorePunctuation, on);
388
389
390
391
392
393
394
395bool QCollator::ignorePunctuation()
const
397 return d && d->options.testFlag(CollationOption::IgnorePunctuation);
401
402
403
404
405
406
407
408
409
410void QCollator::setOptions(CollationOptions options)
412 if (d && d->options == options)
415 d->options = options;
419
420
421
422
423
424QCollator::CollationOptions QCollator::options()
const
426 return d ? d->options : CollationOptions{};
430
431
432
433
434
435
436
437
440
441
442
443
444
445
446
447
450
451
452
453
456
457
458
459
462
463
464
465
466
467
468
469
470
471
472
473
474
475
478
479
480
481
482
483
484
485
486int QCollator::defaultCompare(QStringView s1, QStringView s2)
488 return defaultCollator->localData().collator().compare(s1, s2);
492
493
494
495
496
497
498
499QCollatorSortKey QCollator::defaultSortKey(QStringView key)
501 return defaultCollator->localData().collator().sortKey(key.toString());
505
506
507
508
509
510
511
512
513
514
515
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
537
538
539QCollatorSortKey::QCollatorSortKey(QCollatorSortKeyPrivate *d)
545
546
547QCollatorSortKey::QCollatorSortKey(
const QCollatorSortKey &other)
553
554
555
556
557
558
561
562
563QCollatorSortKey::~QCollatorSortKey()
568
569
570QCollatorSortKey& QCollatorSortKey::operator=(
const QCollatorSortKey &other)
572 if (
this != &other) {
579
580
581
582
583
584
587
588
589
590
591
592
593
594
595
596
597
598
599
602
603
604
607
608
609
610
611
612
613
614
615
616
617
618
Combined button and popup list for selecting options.
GenerationalCollator(const QCollator ©)
GenerationalCollator()=default