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();
38Q_GLOBAL_STATIC(QThreadStorage<GenerationalCollator>, defaultCollator)
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
95
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
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
198
199
200
201
202
203
204
205
206
207
208QCollator::QCollator()
214
215
216
217
218QCollator::QCollator(
const QLocale &locale)
219 : d(
new QCollatorPrivate(locale))
224
225
226QCollator::QCollator(
const QCollator &other)
231 d->ensureInitialized();
237
238
239QCollator::~QCollator()
241 if (d && !d->ref.deref())
246
247
248QCollator &QCollator::operator=(
const QCollator &other)
250 if (
this != &other) {
251 if (d && !d->ref.deref())
256 d->ensureInitialized();
264
265
266
267
268
269
270
271
272
273
276
277
278
279
280
281
284
285
286
289
290
291
292
293
294
295
297bool comparesEqual(
const QCollator &lhs,
const QCollator &rhs)
noexcept
301 if (!lhs.d || !rhs.d)
304 return lhs.d->options == rhs.d->options
305 && lhs.d->locale == rhs.d->locale;
309
310
311void QCollator::detach()
314 d =
new QCollatorPrivate(QLocale().collation());
316 }
else if (d->ref.loadRelaxed() != 1) {
317 QCollatorPrivate *x =
new QCollatorPrivate(d->locale);
318 x->options = d->options;
328
329
330
331
332void QCollator::setLocale(
const QLocale &locale)
334 if (locale ==
this->locale())
342
343
344
345
346
347
348
349QLocale QCollator::locale()
const
351 return d ? d->locale : QLocale().collation();
355
356
357
358
359void QCollator::setCaseSensitivity(Qt::CaseSensitivity cs)
361 if (cs == caseSensitivity())
365 d->options.setFlag(CollationOption::CaseInsensitive, cs == Qt::CaseInsensitive);
369
370
371
372
373
374
375
376
377
378
379
380Qt::CaseSensitivity QCollator::caseSensitivity()
const
382 return d && d->options.testFlag(CollationOption::CaseInsensitive) ? Qt::CaseInsensitive
387
388
389
390
391void QCollator::setNumericMode(
bool on)
393 if (on == numericMode())
397 d->options.setFlag(CollationOption::NumericSort, on);
401
402
403
404
405
406
407
408
409
410bool QCollator::numericMode()
const
412 return d && d->options.testFlag(CollationOption::NumericSort);
416
417
418
419
420void QCollator::setIgnorePunctuation(
bool on)
422 if (on == ignorePunctuation())
426 d->options.setFlag(CollationOption::IgnorePunctuation, on);
430
431
432
433
434
435
436
437bool QCollator::ignorePunctuation()
const
439 return d && d->options.testFlag(CollationOption::IgnorePunctuation);
443
444
445
446
447
448
449
450
451
452void QCollator::setOptions(CollationOptions options)
454 if (d && d->options == options)
457 d->options = options;
461
462
463
464
465
466QCollator::CollationOptions QCollator::options()
const
468 return d ? d->options : CollationOptions{};
472
473
474
475
476
477
478
479
482
483
484
485
486
487
488
489
492
493
494
495
498
499
500
501
504
505
506
507
508
509
510
511
512
513
514
515
516
517
520
521
522
523
524
525
526
527
528int QCollator::defaultCompare(QStringView s1, QStringView s2)
530 return defaultCollator->localData().collator().compare(s1, s2);
534
535
536
537
538
539
540
541QCollatorSortKey QCollator::defaultSortKey(QStringView key)
543 return defaultCollator->localData().collator().sortKey(key.toString());
547
548
549
550
551
552
553
554
555
556
557
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
579
580
581QCollatorSortKey::QCollatorSortKey(QCollatorSortKeyPrivate *d)
587
588
589QCollatorSortKey::QCollatorSortKey(
const QCollatorSortKey &other)
595
596
597
598
599
600
603
604
605QCollatorSortKey::~QCollatorSortKey()
610
611
612QCollatorSortKey& QCollatorSortKey::operator=(
const QCollatorSortKey &other)
614 if (
this != &other) {
621
622
623
624
625
626
629
630
631
632
633
634
635
636
637
638
639
640
641
644
645
646
649
650
651
652
653
654
655
656
657
658
659
660
Combined button and popup list for selecting options.
GenerationalCollator(const QCollator ©)
GenerationalCollator()=default