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#include <QtCore/qloggingcategory.h>
25#if QT_CONFIG(icu) || defined(Q_OS_ANDROID)
26#include <unicode/ucol.h>
27#elif defined(Q_OS_MACOS)
28#include <CoreServices/CoreServices.h>
29#elif defined(Q_OS_WIN)
30#include <qt_windows.h>
31#endif
32#ifdef Q_OS_ANDROID
33#include "qjniobject.h"
34#include "qjnitypes.h"
35#endif
36
37QT_BEGIN_NAMESPACE
38
39Q_DECLARE_LOGGING_CATEGORY(lcQCollator)
40
41#if QT_CONFIG(icu) || defined(Q_OS_ANDROID)
42typedef UCollator *CollatorType;
43typedef QByteArray CollatorKeyType;
44const CollatorType NoCollator = nullptr;
45
46#elif defined(Q_OS_MACOS)
47typedef CollatorRef CollatorType;
48typedef QList<UCCollationValue> CollatorKeyType;
49const CollatorType NoCollator = 0;
50
51#elif defined(Q_OS_WIN)
52typedef QByteArray CollatorKeyType;
53typedef int CollatorType;
54const CollatorType NoCollator = 0;
55
56#else // posix - ignores CollatorType collator, only handles system locale
57typedef QList<wchar_t> CollatorKeyType;
58typedef bool CollatorType;
60#endif
61
62#ifdef Q_OS_ANDROID
63Q_DECLARE_JNI_CLASS(QtCollator, "org/qtproject/qt/android/QtCollator")
64Q_DECLARE_JNI_CLASS(Collator, "android/icu/text/Collator")
65#endif
66
67
69{
70public:
71 using Opt = QCollator::CollationOption;
72
74 QLocale locale;
76 bool dirty = true;
77
79#ifdef Q_OS_ANDROID
80 QtJniTypes::Collator fallbackCollator = QJniObject(); // needs to be null rather than default-constructed
81#endif
82
83 QCollatorPrivate(const QLocale &locale) : locale(locale) {}
85 bool isC() const { return locale.language() == QLocale::C; }
86
87 void clear() {
90 }
91
93 {
94 if (dirty)
95 init();
96 }
97
98 // Implemented by each back-end, in its own way:
99 void init();
100 void cleanup();
101
102 static QCollatorSortKey sortKeyFromData(CollatorKeyType &&data);
103
104private:
106};
107
109{
110public:
111 explicit QCollatorSortKeyPrivate(CollatorKeyType &&list)
113 {
114 }
115
117
118private:
120};
121
122inline QCollatorSortKey QCollatorPrivate::sortKeyFromData(CollatorKeyType &&data)
123{
124 return QCollatorSortKey(new QCollatorSortKeyPrivate(std::move(data)));
125}
126
127QT_END_NAMESPACE
128
129#endif // QCOLLATOR_P_H
QAtomicInt ref
Definition qcollator_p.h:73
bool isC() const
Definition qcollator_p.h:85
void ensureInitialized()
Definition qcollator_p.h:92
QCollatorPrivate(const QLocale &locale)
Definition qcollator_p.h:83
CollatorType collator
Definition qcollator_p.h:78
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:59
bool CollatorType
Definition qcollator_p.h:58
GenerationalCollator(const QCollator &copy)
Definition qcollator.cpp:25