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
86
87
88
89
90
91
92
93
94
95
96
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
145
146
147
148
149
150
151
152
153
154
155QCollator::QCollator()
161
162
163
164
165QCollator::QCollator(
const QLocale &locale)
166 : d(
new QCollatorPrivate(locale))
171
172
173QCollator::QCollator(
const QCollator &other)
178 d->ensureInitialized();
184
185
186QCollator::~QCollator()
188 if (d && !d->ref.deref())
193
194
195QCollator &QCollator::operator=(
const QCollator &other)
197 if (
this != &other) {
198 if (d && !d->ref.deref())
203 d->ensureInitialized();
211
212
213
214
215
216
217
218
219
220
223
224
225
226
227
228
231
232
233
236
237
238
239
240
241
242
244bool comparesEqual(
const QCollator &lhs,
const QCollator &rhs)
noexcept
248 if (!lhs.d || !rhs.d)
251 return lhs.d->options == rhs.d->options
252 && lhs.d->locale == rhs.d->locale;
256
257
258void QCollator::detach()
261 d =
new QCollatorPrivate(QLocale().collation());
263 }
else if (d->ref.loadRelaxed() != 1) {
264 QCollatorPrivate *x =
new QCollatorPrivate(d->locale);
274
275
276
277
278void QCollator::setLocale(
const QLocale &locale)
280 if (locale ==
this->locale())
288
289
290
291
292
293
294
295QLocale QCollator::locale()
const
297 return d ? d->locale : QLocale().collation();
301
302
303
304
305void QCollator::setCaseSensitivity(Qt::CaseSensitivity cs)
307 if (cs == caseSensitivity())
311 d->options.setFlag(CollationOption::CaseInsensitive, cs == Qt::CaseInsensitive);
315
316
317
318
319
320
321
322
323
324
325
326Qt::CaseSensitivity QCollator::caseSensitivity()
const
328 return d && d->options.testFlag(CollationOption::CaseInsensitive) ? Qt::CaseInsensitive
333
334
335
336
337void QCollator::setNumericMode(
bool on)
339 if (on == numericMode())
343 d->options.setFlag(CollationOption::NumericSort, on);
347
348
349
350
351
352
353
354
355
356bool QCollator::numericMode()
const
358 return d && d->options.testFlag(CollationOption::NumericSort);
362
363
364
365
366void QCollator::setIgnorePunctuation(
bool on)
368 if (on == ignorePunctuation())
372 d->options.setFlag(CollationOption::IgnorePunctuation, on);
376
377
378
379
380
381
382
383bool QCollator::ignorePunctuation()
const
385 return d && d->options.testFlag(CollationOption::IgnorePunctuation);
389
390
391
392
393
394
395
396
397
398void QCollator::setOptions(CollationOptions options)
400 if (d && d->options == options)
403 d->options = options;
407
408
409
410
411
412QCollator::CollationOptions QCollator::options()
const
414 return d ? d->options : CollationOptions{};
418
419
420
421
422
423
424
425
428
429
430
431
432
433
434
435
438
439
440
441
444
445
446
447
450
451
452
453
454
455
456
457
458
459
460
461
462
463
466
467
468
469
470
471
472
473
474int QCollator::defaultCompare(QStringView s1, QStringView s2)
476 return defaultCollator->localData().collator().compare(s1, s2);
480
481
482
483
484
485
486
487QCollatorSortKey QCollator::defaultSortKey(QStringView key)
489 return defaultCollator->localData().collator().sortKey(key.toString());
493
494
495
496
497
498
499
500
501
502
503
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
525
526
527QCollatorSortKey::QCollatorSortKey(QCollatorSortKeyPrivate *d)
533
534
535QCollatorSortKey::QCollatorSortKey(
const QCollatorSortKey &other)
541
542
543
544
545
546
549
550
551QCollatorSortKey::~QCollatorSortKey()
556
557
558QCollatorSortKey& QCollatorSortKey::operator=(
const QCollatorSortKey &other)
560 if (
this != &other) {
567
568
569
570
571
572
575
576
577
578
579
580
581
582
583
584
585
586
587
590
591
592
595
596
597
598
599
600
601
602
603
604
605
606
Combined button and popup list for selecting options.
GenerationalCollator(const QCollator ©)
GenerationalCollator()=default