Revise conditional for when to use QCollator

According to https://doc.qt.io/qt-6/qcollator.html#posix-fallback-implementation
The 'POSIX fallback implementation' is only used when ICU is not available. So the correct way is to detect ICU directly and not depend on the OS. The exceptions are macOS and Windows since they support the required functionalities natively.
Closes #20205.
PR #20207.
This commit is contained in:
Chocobo1 2024-01-02 16:58:12 +08:00 committed by Vladimir Golovnev (Glassez)
parent 2589363622
commit e74b587420
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7
2 changed files with 15 additions and 3 deletions

View file

@ -194,11 +194,16 @@ add_library(qbt_base STATIC
target_link_libraries(qbt_base
PRIVATE
OpenSSL::Crypto OpenSSL::SSL
OpenSSL::Crypto
OpenSSL::SSL
ZLIB::ZLIB
PUBLIC
LibtorrentRasterbar::torrent-rasterbar
Qt::Core Qt::Network Qt::Sql Qt::Xml
Qt::Core
Qt::CorePrivate
Qt::Network
Qt::Sql
Qt::Xml
qbt_common_cfg
)

View file

@ -31,7 +31,14 @@
#include <Qt>
#include <QtGlobal>
#if !defined(Q_OS_WIN) && (!defined(Q_OS_UNIX) || defined(Q_OS_MACOS) || defined(QT_FEATURE_icu))
// for QT_FEATURE_xxx, see: https://wiki.qt.io/Qt5_Build_System#How_to
#include <QtCore/private/qtcore-config_p.h>
// macOS and Windows support 'case sensitivity' and 'numeric mode' natively
// https://github.com/qt/qtbase/blob/6.0/src/corelib/CMakeLists.txt#L777-L793
// https://github.com/qt/qtbase/blob/6.0/src/corelib/text/qcollator_macx.cpp#L74-L77
// https://github.com/qt/qtbase/blob/6.0/src/corelib/text/qcollator_win.cpp#L72-L78
#if ((QT_FEATURE_icu == 1) || defined(Q_OS_MACOS) || defined(Q_OS_WIN))
#define QBT_USE_QCOLLATOR
#include <QCollator>
#endif