11#include <qt_windows.h>
17#ifndef SORT_DIGITSASNUMBERS
18#define SORT_DIGITSASNUMBERS 8
30 localeID = qt_inIsoNametoLCID(QLocalePrivate::get(locale)->bcp47Name().constData());
32 if (caseSensitivity == Qt::CaseInsensitive)
33 collator |= NORM_IGNORECASE;
40 if (ignorePunctuation)
41 collator |= NORM_IGNORESYMBOLS;
50int QCollator::compare(QStringView s1, QStringView s2)
const
53 return s2.size() ? -1 : 0;
58 return s1.compare(s2, d->caseSensitivity);
60 d->ensureInitialized();
70 const int ret = CompareString(d->localeID, d->collator,
71 reinterpret_cast<
const wchar_t *>(s1.data()), s1.size(),
72 reinterpret_cast<
const wchar_t *>(s2.data()), s2.size());
76 switch (DWORD error = GetLastError()) {
77 case ERROR_INVALID_FLAGS:
78 qWarning(
"Unsupported flags (%d) used in QCollator",
int(d->collator));
80 case ERROR_INVALID_PARAMETER:
81 qWarning(
"Invalid parameter for QCollator::compare()");
84 qWarning(
"Failed (%ld) comparison in QCollator::compare()",
long(error));
92QCollatorSortKey QCollator::sortKey(
const QString &string)
const
94 d->ensureInitialized();
97 return QCollatorSortKey(
new QCollatorSortKeyPrivate(string));
100 int size = LCMapStringW(d->localeID, LCMAP_SORTKEY | d->collator,
101 reinterpret_cast<
const wchar_t*>(string.constData()), string.size(),
104 QString ret(size, Qt::Uninitialized);
105 int finalSize = LCMapStringW(d->localeID, LCMAP_SORTKEY | d->collator,
106 reinterpret_cast<
const wchar_t*>(string.constData()), string.size(),
107 reinterpret_cast<
wchar_t*>(ret.data()), ret.size());
108 if (finalSize == 0) {
110 <<
"there were problems when generating the ::sortKey by LCMapStringW with error:"
113 return QCollatorSortKey(
new QCollatorSortKeyPrivate(std::move(ret)));
116int QCollatorSortKey::compare(
const QCollatorSortKey &otherKey)
const
118 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)