Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qcollator.h
Go to the documentation of this file.
1// Copyright (C) 2020 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
5#ifndef QCOLLATOR_H
6#define QCOLLATOR_H
7
8#include <QtCore/qstring.h>
9#include <QtCore/qstringlist.h>
10#include <QtCore/qlocale.h>
11
13
17
18class Q_CORE_EXPORT QCollatorSortKey
19{
20 friend class QCollator;
21public:
26 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QCollatorSortKey)
28 { d.swap(other.d); }
29
30 int compare(const QCollatorSortKey &key) const;
31 friend bool operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
32 { return lhs.compare(rhs) < 0; }
33
34protected:
36
37 QExplicitlySharedDataPointer<QCollatorSortKeyPrivate> d;
38
39private:
41};
42
43class Q_CORE_EXPORT QCollator
44{
45public:
46 QCollator();
47 explicit QCollator(const QLocale &locale);
48 QCollator(const QCollator &);
49 ~QCollator();
50 QCollator &operator=(const QCollator &);
52 : d(other.d) { other.d = nullptr; }
53 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QCollator)
54
56 { qt_ptr_swap(d, other.d); }
57
58 void setLocale(const QLocale &locale);
59 QLocale locale() const;
60
61 Qt::CaseSensitivity caseSensitivity() const;
63
64 void setNumericMode(bool on);
65 bool numericMode() const;
66
67 void setIgnorePunctuation(bool on);
68 bool ignorePunctuation() const;
69
70 int compare(const QString &s1, const QString &s2) const
71 { return compare(QStringView(s1), QStringView(s2)); }
72#if QT_CORE_REMOVED_SINCE(6, 4) && QT_POINTER_SIZE != 4
73 int compare(const QChar *s1, int len1, const QChar *s2, int len2) const
74 { return compare(QStringView(s1, len1), QStringView(s2, len2)); }
75#endif
76 int compare(const QChar *s1, qsizetype len1, const QChar *s2, qsizetype len2) const
77 { return compare(QStringView(s1, len1), QStringView(s2, len2)); }
78
79 bool operator()(const QString &s1, const QString &s2) const
80 { return compare(s1, s2) < 0; }
82
84 { return compare(s1, s2) < 0; }
85
86 QCollatorSortKey sortKey(const QString &string) const;
87
88 static int defaultCompare(QStringView s1, QStringView s2);
89 static QCollatorSortKey defaultSortKey(QStringView key);
90
91private:
93
94 void detach();
95};
96
97Q_DECLARE_SHARED(QCollatorSortKey)
98Q_DECLARE_SHARED(QCollator)
99
101
102#endif // QCOLLATOR_P_H
\inmodule QtCore
\inmodule QtCore
Definition qcollator.h:19
QExplicitlySharedDataPointer< QCollatorSortKeyPrivate > d
Definition qcollator.h:37
friend bool operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
Both keys must have been created by the same QCollator's sortKey().
Definition qcollator.h:31
int compare(const QCollatorSortKey &key) const
Compares this key to otherKey, which must have been created by the same QCollator's sortKey() as this...
QCollatorSortKey(QCollatorSortKey &&other) noexcept=default
\inmodule QtCore
Definition qcollator.h:44
int compare(const QChar *s1, qsizetype len1, const QChar *s2, qsizetype len2) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcollator.h:76
bool operator()(const QString &s1, const QString &s2) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcollator.h:79
QCollator(QCollator &&other) noexcept
Definition qcollator.h:51
QCollator & operator=(const QCollator &)
Assigns other to this collator.
bool operator()(QStringView s1, QStringView s2) const
Definition qcollator.h:83
int compare(const QString &s1, const QString &s2) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcollator.h:70
\inmodule QtCore
Definition qstringview.h:78
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
CaseSensitivity
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
GLuint64 key
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
#define QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(Class, ExportMacro)
constexpr void qt_ptr_swap(T *&lhs, T *&rhs) noexcept
Definition qswap.h:29
#define s2
static int compare(quint64 a, quint64 b)
ptrdiff_t qsizetype
Definition qtypes.h:165
QSharedPointer< T > other(t)
[5]
this swap(other)
wordList<< "alpha"<< "omega"<< "omicron"<< "zeta";QLineEdit *lineEdit=new QLineEdit(this);QCompleter *completer=new QCompleter(wordList, this);completer-> setCaseSensitivity(Qt::CaseInsensitive)