Qt 6.x
The Qt SDK
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
16
17class Q_CORE_EXPORT QCollatorSortKey
18{
19 friend class QCollator;
20public:
23 QCollatorSortKey &operator=(const QCollatorSortKey &other);
24 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QCollatorSortKey)
25 void swap(QCollatorSortKey &other) noexcept
26 { d.swap(other.d); }
27
28 int compare(const QCollatorSortKey &key) const;
29 friend bool operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
30 { return lhs.compare(rhs) < 0; }
31
32protected:
34
36
37private:
39};
40
41class Q_CORE_EXPORT QCollator
42{
43public:
44 QCollator();
45 explicit QCollator(const QLocale &locale);
46 QCollator(const QCollator &);
47 ~QCollator();
48 QCollator &operator=(const QCollator &);
50 : d(other.d) { other.d = nullptr; }
51 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QCollator)
52
53 void swap(QCollator &other) noexcept
54 { qt_ptr_swap(d, other.d); }
55
56 void setLocale(const QLocale &locale);
57 QLocale locale() const;
58
59 Qt::CaseSensitivity caseSensitivity() const;
61
62 void setNumericMode(bool on);
63 bool numericMode() const;
64
65 void setIgnorePunctuation(bool on);
66 bool ignorePunctuation() const;
67
68 int compare(const QString &s1, const QString &s2) const
69 { return compare(QStringView(s1), QStringView(s2)); }
70#if QT_CORE_REMOVED_SINCE(6, 4) && QT_POINTER_SIZE != 4
71 int compare(const QChar *s1, int len1, const QChar *s2, int len2) const
72 { return compare(QStringView(s1, len1), QStringView(s2, len2)); }
73#endif
74 int compare(const QChar *s1, qsizetype len1, const QChar *s2, qsizetype len2) const
75 { return compare(QStringView(s1, len1), QStringView(s2, len2)); }
76
77 bool operator()(const QString &s1, const QString &s2) const
78 { return compare(s1, s2) < 0; }
80
82 { return compare(s1, s2) < 0; }
83
84 QCollatorSortKey sortKey(const QString &string) const;
85
86 static int defaultCompare(QStringView s1, QStringView s2);
87 static QCollatorSortKey defaultSortKey(QStringView key);
88
89private:
91
92 void detach();
93};
94
95Q_DECLARE_SHARED(QCollatorSortKey)
96Q_DECLARE_SHARED(QCollator)
97
99
100#endif // QCOLLATOR_P_H
\inmodule QtCore
Definition qchar.h:48
\inmodule QtCore
Definition qcollator.h:18
QExplicitlySharedDataPointer< QCollatorSortKeyPrivate > d
Definition qcollator.h:35
friend bool operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
Both keys must have been created by the same QCollator's sortKey().
Definition qcollator.h:29
int compare(const QCollatorSortKey &key) const
Compares this key to otherKey, which must have been created by the same QCollator's sortKey() as this...
\inmodule QtCore
Definition qcollator.h:42
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:74
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:77
QCollator(QCollator &&other) noexcept
Move constructor.
Definition qcollator.h:49
bool operator()(QStringView s1, QStringView s2) const
Definition qcollator.h:81
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:68
\inmodule QtCore
Definition qstringview.h:76
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
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
constexpr void qt_ptr_swap(T *&lhs, T *&rhs) noexcept
Definition qswap.h:43
#define s2
static int compare(quint64 a, quint64 b)
ptrdiff_t qsizetype
Definition qtypes.h:70
QSharedPointer< T > other(t)
[5]
wordList<< "alpha"<< "omega"<< "omicron"<< "zeta";QLineEdit *lineEdit=new QLineEdit(this);QCompleter *completer=new QCompleter(wordList, this);completer-> setCaseSensitivity(Qt::CaseInsensitive)