Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcollator_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2013 Aleix Pol Gonzalez <aleixpol@kde.org>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4// Qt-Security score:significant reason:trivial-impl-only
5
6#ifndef QCOLLATOR_P_H
7#define QCOLLATOR_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtCore/private/qglobal_p.h>
21#include "qcollator.h"
22#include "qlocale_p.h"
23#include <QList>
24#if QT_CONFIG(icu) || defined(Q_OS_ANDROID)
25#include <unicode/ucol.h>
26#elif defined(Q_OS_MACOS)
27#include <CoreServices/CoreServices.h>
28#elif defined(Q_OS_WIN)
29#include <qt_windows.h>
30#endif
31#ifdef Q_OS_ANDROID
32#include "qjniobject.h"
33#include "qjnitypes.h"
34#endif
35
36QT_BEGIN_NAMESPACE
37
38#if QT_CONFIG(icu) || defined(Q_OS_ANDROID)
39typedef UCollator *CollatorType;
40typedef QByteArray CollatorKeyType;
41const CollatorType NoCollator = nullptr;
42
43#elif defined(Q_OS_MACOS)
44typedef CollatorRef CollatorType;
45typedef QList<UCCollationValue> CollatorKeyType;
46const CollatorType NoCollator = 0;
47
48#elif defined(Q_OS_WIN)
49typedef QByteArray CollatorKeyType;
50typedef int CollatorType;
51const CollatorType NoCollator = 0;
52
53#else // posix - ignores CollatorType collator, only handles system locale
54typedef QList<wchar_t> CollatorKeyType;
55typedef bool CollatorType;
57#endif
58
59#ifdef Q_OS_ANDROID
60Q_DECLARE_JNI_CLASS(QtCollator, "org/qtproject/qt/android/QtCollator")
61Q_DECLARE_JNI_CLASS(Collator, "android/icu/text/Collator")
62#endif
63
64
66{
67public:
68 using Opt = QCollator::CollationOption;
69
71 QLocale locale;
73 bool dirty = true;
74
76#ifdef Q_OS_ANDROID
77 QtJniTypes::Collator fallbackCollator = QJniObject(); // needs to be null rather than default-constructed
78#endif
79
80 QCollatorPrivate(const QLocale &locale) : locale(locale) {}
82 bool isC() const { return locale.language() == QLocale::C; }
83
84 void clear() {
87 }
88
90 {
91 if (dirty)
92 init();
93 }
94
95 // Implemented by each back-end, in its own way:
96 void init();
97 void cleanup();
98
99 static QCollatorSortKey sortKeyFromData(CollatorKeyType &&data);
100
101private:
103};
104
106{
107public:
108 explicit QCollatorSortKeyPrivate(CollatorKeyType &&list)
110 {
111 }
112
114
115private:
117};
118
119inline QCollatorSortKey QCollatorPrivate::sortKeyFromData(CollatorKeyType &&data)
120{
121 return QCollatorSortKey(new QCollatorSortKeyPrivate(std::move(data)));
122}
123
124QT_END_NAMESPACE
125
126#endif // QCOLLATOR_P_H
QAtomicInt ref
Definition qcollator_p.h:70
bool isC() const
Definition qcollator_p.h:82
void ensureInitialized()
Definition qcollator_p.h:89
QCollatorPrivate(const QLocale &locale)
Definition qcollator_p.h:80
CollatorType collator
Definition qcollator_p.h:75
static QCollatorSortKey sortKeyFromData(CollatorKeyType &&data)
CollatorKeyType m_key
QCollatorSortKeyPrivate(CollatorKeyType &&list)
Combined button and popup list for selecting options.
const CollatorType NoCollator
Definition qcollator_p.h:56
bool CollatorType
Definition qcollator_p.h:55
GenerationalCollator(const QCollator &copy)
Definition qcollator.cpp:24