15QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QCollatorSortKeyPrivate)
16Q_LOGGING_CATEGORY(lcQCollator,
"qt.core.qcollator")
28 int currentGeneration = QLocalePrivate::s_generation.loadRelaxed();
29 if (Q_UNLIKELY(
generation != currentGeneration)) {
32 theCollator = QCollator();
52Q_GLOBAL_STATIC(GenerationalCollatorHolder, defaultCollator)
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
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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
222
223
224
225
226
227
228
229
230
231
232QCollator::QCollator()
238
239
240
241
242QCollator::QCollator(
const QLocale &locale)
243 : d(
new QCollatorPrivate(locale))
248
249
250QCollator::QCollator(
const QCollator &other)
255 d->ensureInitialized();
261
262
263QCollator::~QCollator()
265 if (d && !d->ref.deref())
270
271
272QCollator &QCollator::operator=(
const QCollator &other)
274 if (
this != &other) {
275 if (d && !d->ref.deref())
280 d->ensureInitialized();
288
289
290
291
292
293
294
295
296
297
300
301
302
303
304
305
308
309
310
313
314
315
316
317
318
319
321bool comparesEqual(
const QCollator &lhs,
const QCollator &rhs)
noexcept
325 if (!lhs.d || !rhs.d)
328 return lhs.d->options == rhs.d->options
329 && lhs.d->locale == rhs.d->locale;
333
334
335void QCollator::detach()
338 d =
new QCollatorPrivate(QLocale().collation());
340 }
else if (d->ref.loadRelaxed() != 1) {
341 QCollatorPrivate *x =
new QCollatorPrivate(d->locale);
342 x->options = d->options;
352
353
354
355
356void QCollator::setLocale(
const QLocale &locale)
358 if (locale ==
this->locale())
366
367
368
369
370
371
372
373QLocale QCollator::locale()
const
375 return d ? d->locale : QLocale().collation();
379
380
381
382
383void QCollator::setCaseSensitivity(Qt::CaseSensitivity cs)
385 if (cs == caseSensitivity())
389 d->options.setFlag(CollationOption::CaseInsensitive, cs == Qt::CaseInsensitive);
393
394
395
396
397
398
399
400
401
402
403
404Qt::CaseSensitivity QCollator::caseSensitivity()
const
406 return d && d->options.testFlag(CollationOption::CaseInsensitive) ? Qt::CaseInsensitive
411
412
413
414
415void QCollator::setNumericMode(
bool on)
417 if (on == numericMode())
421 d->options.setFlag(CollationOption::NumericSort, on);
425
426
427
428
429
430
431
432
433
434bool QCollator::numericMode()
const
436 return d && d->options.testFlag(CollationOption::NumericSort);
440
441
442
443
444void QCollator::setIgnorePunctuation(
bool on)
446 if (on == ignorePunctuation())
450 d->options.setFlag(CollationOption::IgnorePunctuation, on);
454
455
456
457
458
459
460
461bool QCollator::ignorePunctuation()
const
463 return d && d->options.testFlag(CollationOption::IgnorePunctuation);
467
468
469
470
471
472
473
474
475
476void QCollator::setOptions(CollationOptions options)
478 if (d && d->options == options)
481 d->options = options;
485
486
487
488
489
490QCollator::CollationOptions QCollator::options()
const
492 return d ? d->options : CollationOptions{};
496
497
498
499
500
501
502
503
506
507
508
509
510
511
512
513
516
517
518
519
522
523
524
525
528
529
530
531
532
533
534
535
536
537
538
539
540
541
544
545
546
547
548
549
550
551
552int QCollator::defaultCompare(QStringView s1, QStringView s2)
554 return defaultCollator->localData().collator().compare(s1, s2);
558
559
560
561
562
563
564
565QCollatorSortKey QCollator::defaultSortKey(QStringView key)
567 return defaultCollator->localData().collator().sortKey(key.toString());
571
572
573
574
575
576
577
578
579
580
581
582
583
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
605
606
607QCollatorSortKey::QCollatorSortKey(QCollatorSortKeyPrivate *d)
613
614
615QCollatorSortKey::QCollatorSortKey(
const QCollatorSortKey &other)
621
622
623
624
625
626
629
630
631QCollatorSortKey::~QCollatorSortKey()
636
637
638QCollatorSortKey& QCollatorSortKey::operator=(
const QCollatorSortKey &other)
640 if (
this != &other) {
647
648
649
650
651
652
655
656
657
658
659
660
661
662
663
664
665
666
667
670
671
672
675
676
677
678
679
680
681
682
683
684
685
686
~GenerationalCollatorHolder()
Combined button and popup list for selecting options.
GenerationalCollator(const QCollator ©)
GenerationalCollator()=default