From d5bf0358cbafee6a285ab42091d028c5416e346f 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 4f25f86aa..47f5a4d03 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -199,11 +199,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 aa63d102b..f0428a5f7 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