From e74b58742049c078e82654f7806394cf1e6bdf4c Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 2 Jan 2024 16:58:12 +0800 Subject: [PATCH] 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. --- src/base/CMakeLists.txt | 9 +++++++-- src/base/utils/compare.h | 9 ++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index 36825a283..5c7b10c44 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -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 ) diff --git a/src/base/utils/compare.h b/src/base/utils/compare.h index 53de6b73a..d424b974c 100644 --- a/src/base/utils/compare.h +++ b/src/base/utils/compare.h @@ -31,7 +31,14 @@ #include #include -#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 + +// 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 #endif