12#include <qt_windows.h>
18#ifndef SORT_DIGITSASNUMBERS
19#define SORT_DIGITSASNUMBERS 8
31 localeID = qt_inIsoNametoLCID(QLocalePrivate::get(locale)->bcp47Name().constData());
33 if (caseSensitivity == Qt::CaseInsensitive)
34 collator |= NORM_IGNORECASE;
41 if (ignorePunctuation)
42 collator |= NORM_IGNORESYMBOLS;
51int QCollator::compare(QStringView s1, QStringView s2)
const
54 return s2.size() ? -1 : 0;
59 return s1.compare(s2, d->caseSensitivity);
61 d->ensureInitialized();
71 const int ret = CompareString(d->localeID, d->collator,
72 reinterpret_cast<
const wchar_t *>(s1.data()), s1.size(),
73 reinterpret_cast<
const wchar_t *>(s2.data()), s2.size());
77 switch (DWORD error = GetLastError()) {
78 case ERROR_INVALID_FLAGS:
79 qWarning(
"Unsupported flags (%d) used in QCollator",
int(d->collator));
81 case ERROR_INVALID_PARAMETER:
82 qWarning(
"Invalid parameter for QCollator::compare()");
85 qWarning(
"Failed (%ld) comparison in QCollator::compare()",
long(error));
93QCollatorSortKey QCollator::sortKey(
const QString &string)
const
95 d->ensureInitialized();
98 return QCollatorSortKey(
new QCollatorSortKeyPrivate(string));
101 int size = LCMapStringW(d->localeID, LCMAP_SORTKEY | d->collator,
102 reinterpret_cast<
const wchar_t*>(string.constData()), string.size(),
105 QString ret(size, Qt::Uninitialized);
106 int finalSize = LCMapStringW(d->localeID, LCMAP_SORTKEY | d->collator,
107 reinterpret_cast<
const wchar_t*>(string.constData()), string.size(),
108 reinterpret_cast<
wchar_t*>(ret.data()), ret.size());
109 if (finalSize == 0) {
111 <<
"there were problems when generating the ::sortKey by LCMapStringW with error:"
114 return QCollatorSortKey(
new QCollatorSortKeyPrivate(std::move(ret)));
117int QCollatorSortKey::compare(
const QCollatorSortKey &otherKey)
const
119 return d->m_key.compare(otherKey.d->m_key);
Combined button and popup list for selecting options.
#define SORT_DIGITSASNUMBERS
LCID qt_inIsoNametoLCID(const char *name)