diff --git a/src/dict/aard.cc b/src/dict/aard.cc index e713b86d..421f9595 100644 --- a/src/dict/aard.cc +++ b/src/dict/aard.cc @@ -263,8 +263,13 @@ public: void setFTSParameters( Config::FullTextSearch const & fts ) override { - can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "AARD", Qt::CaseInsensitive ) - && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); + if ( metadata_enable_fts.has_value() ) { + can_FTS = fts.enabled && metadata_enable_fts.value(); + } + else { + can_FTS = fts.enabled && !fts.disabledTypes.contains( "AARD", Qt::CaseInsensitive ) + && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); + } } protected: diff --git a/src/dict/bgl.cc b/src/dict/bgl.cc index f2d7d161..1435d950 100644 --- a/src/dict/bgl.cc +++ b/src/dict/bgl.cc @@ -219,8 +219,12 @@ public: void setFTSParameters( Config::FullTextSearch const & fts ) override { - can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "BGL", Qt::CaseInsensitive ) - && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); + if ( metadata_enable_fts.has_value() ) { + can_FTS = fts.enabled && metadata_enable_fts.value(); + } + else + can_FTS = fts.enabled && !fts.disabledTypes.contains( "BGL", Qt::CaseInsensitive ) + && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); } protected: diff --git a/src/dict/dictdfiles.cc b/src/dict/dictdfiles.cc index 6f71130d..60012101 100644 --- a/src/dict/dictdfiles.cc +++ b/src/dict/dictdfiles.cc @@ -140,8 +140,12 @@ public: void setFTSParameters( Config::FullTextSearch const & fts ) override { - can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "DICTD", Qt::CaseInsensitive ) - && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); + if ( metadata_enable_fts.has_value() ) { + can_FTS = fts.enabled && metadata_enable_fts.value(); + } + else + can_FTS = fts.enabled && !fts.disabledTypes.contains( "DICTD", Qt::CaseInsensitive ) + && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); } }; diff --git a/src/dict/dictionary.hh b/src/dict/dictionary.hh index 2fed491b..ef2ecdcc 100644 --- a/src/dict/dictionary.hh +++ b/src/dict/dictionary.hh @@ -315,8 +315,7 @@ protected: QAtomicInt FTS_index_completed; bool synonymSearchEnabled; string dictionaryName; - //default to true; - bool enable_FTS = true; + std::optional< bool > metadata_enable_fts = std::nullopt; // Load user icon if it exist // By default set icon to empty @@ -376,7 +375,7 @@ public: void setFtsEnable( bool _enable_FTS ) { - enable_FTS = _enable_FTS; + metadata_enable_fts = _enable_FTS; } /// Returns all the available properties, like the author's name, copyright, diff --git a/src/dict/dsl.cc b/src/dict/dsl.cc index 91d81f7a..88ee1d44 100644 --- a/src/dict/dsl.cc +++ b/src/dict/dsl.cc @@ -235,9 +235,12 @@ public: { if ( ensureInitDone().size() ) return; - - can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "DSL", Qt::CaseInsensitive ) - && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); + if ( metadata_enable_fts.has_value() ) { + can_FTS = fts.enabled && metadata_enable_fts.value(); + } + else + can_FTS = fts.enabled && !fts.disabledTypes.contains( "DSL", Qt::CaseInsensitive ) + && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); } uint32_t getFtsIndexVersion() override diff --git a/src/dict/epwing.cc b/src/dict/epwing.cc index 470f4b51..ce3b26c0 100644 --- a/src/dict/epwing.cc +++ b/src/dict/epwing.cc @@ -154,9 +154,12 @@ public: { if ( ensureInitDone().size() ) return; - - can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "EPWING", Qt::CaseInsensitive ) - && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); + if ( metadata_enable_fts.has_value() ) { + can_FTS = fts.enabled && metadata_enable_fts.value(); + } + else + can_FTS = fts.enabled && !fts.disabledTypes.contains( "EPWING", Qt::CaseInsensitive ) + && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); } static int japaneseWriting( gd::wchar ch ); diff --git a/src/dict/gls.cc b/src/dict/gls.cc index 2b96ae50..03256a0f 100644 --- a/src/dict/gls.cc +++ b/src/dict/gls.cc @@ -408,8 +408,12 @@ public: void setFTSParameters( Config::FullTextSearch const & fts ) override { - can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "GLS", Qt::CaseInsensitive ) - && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); + if ( metadata_enable_fts.has_value() ) { + can_FTS = fts.enabled && metadata_enable_fts.value(); + } + else + can_FTS = fts.enabled && !fts.disabledTypes.contains( "GLS", Qt::CaseInsensitive ) + && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); } protected: diff --git a/src/dict/mdx.cc b/src/dict/mdx.cc index 4504a2e3..665f3a72 100644 --- a/src/dict/mdx.cc +++ b/src/dict/mdx.cc @@ -260,9 +260,12 @@ public: { if ( !ensureInitDone().empty() ) return; - - can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "MDICT", Qt::CaseInsensitive ) - && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); + if ( metadata_enable_fts.has_value() ) { + can_FTS = fts.enabled && metadata_enable_fts.value(); + } + else + can_FTS = fts.enabled && !fts.disabledTypes.contains( "MDICT", Qt::CaseInsensitive ) + && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); } QString getCachedFileName( QString name ); diff --git a/src/dict/sdict.cc b/src/dict/sdict.cc index d5cb74f7..207ffe23 100644 --- a/src/dict/sdict.cc +++ b/src/dict/sdict.cc @@ -177,8 +177,12 @@ public: void setFTSParameters( Config::FullTextSearch const & fts ) override { - can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "SDICT", Qt::CaseInsensitive ) - && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); + if ( metadata_enable_fts.has_value() ) { + can_FTS = fts.enabled && metadata_enable_fts.value(); + } + else + can_FTS = fts.enabled && !fts.disabledTypes.contains( "SDICT", Qt::CaseInsensitive ) + && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); } protected: diff --git a/src/dict/slob.cc b/src/dict/slob.cc index b1f5fa33..c8e1b164 100644 --- a/src/dict/slob.cc +++ b/src/dict/slob.cc @@ -640,8 +640,12 @@ public: void setFTSParameters( Config::FullTextSearch const & fts ) override { - can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "SLOB", Qt::CaseInsensitive ) - && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); + if ( metadata_enable_fts.has_value() ) { + can_FTS = fts.enabled && metadata_enable_fts.value(); + } + else + can_FTS = fts.enabled && !fts.disabledTypes.contains( "SLOB", Qt::CaseInsensitive ) + && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); } uint32_t getFtsIndexVersion() override diff --git a/src/dict/stardict.cc b/src/dict/stardict.cc index 6a4b0f3c..c5096aaa 100644 --- a/src/dict/stardict.cc +++ b/src/dict/stardict.cc @@ -200,8 +200,12 @@ public: void setFTSParameters( Config::FullTextSearch const & fts ) override { - can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "STARDICT", Qt::CaseInsensitive ) - && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); + if ( metadata_enable_fts.has_value() ) { + can_FTS = fts.enabled && metadata_enable_fts.value(); + } + else + can_FTS = fts.enabled && !fts.disabledTypes.contains( "STARDICT", Qt::CaseInsensitive ) + && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); } protected: diff --git a/src/dict/xdxf.cc b/src/dict/xdxf.cc index 79e01e21..bda3fd85 100644 --- a/src/dict/xdxf.cc +++ b/src/dict/xdxf.cc @@ -200,8 +200,12 @@ public: void setFTSParameters( Config::FullTextSearch const & fts ) override { - can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "XDXF", Qt::CaseInsensitive ) - && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); + if ( metadata_enable_fts.has_value() ) { + can_FTS = fts.enabled && metadata_enable_fts.value(); + } + else + can_FTS = fts.enabled && !fts.disabledTypes.contains( "XDXF", Qt::CaseInsensitive ) + && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); } uint32_t getFtsIndexVersion() override diff --git a/src/dict/zim.cc b/src/dict/zim.cc index 53e36078..61a13ab4 100644 --- a/src/dict/zim.cc +++ b/src/dict/zim.cc @@ -221,8 +221,12 @@ public: void setFTSParameters( Config::FullTextSearch const & fts ) override { - can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "ZIM", Qt::CaseInsensitive ) - && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); + if ( metadata_enable_fts.has_value() ) { + can_FTS = fts.enabled && metadata_enable_fts.value(); + } + else + can_FTS = fts.enabled && !fts.disabledTypes.contains( "ZIM", Qt::CaseInsensitive ) + && ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); } protected: