fix: prioritize the manual set full text index option per dictionary (#1730)

* fix: prioritize the manual set full text index option per dictionary
This commit is contained in:
xiaoyifang 2024-08-21 13:42:56 +08:00 committed by GitHub
parent 555811e3f3
commit 9332763f67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 75 additions and 30 deletions

View file

@ -263,9 +263,14 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "AARD", Qt::CaseInsensitive )
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:

View file

@ -219,7 +219,11 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "BGL", Qt::CaseInsensitive )
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 );
}

View file

@ -140,7 +140,11 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "DICTD", Qt::CaseInsensitive )
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 );
}
};

View file

@ -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,

View file

@ -235,8 +235,11 @@ public:
{
if ( ensureInitDone().size() )
return;
can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "DSL", Qt::CaseInsensitive )
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 );
}

View file

@ -154,8 +154,11 @@ public:
{
if ( ensureInitDone().size() )
return;
can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "EPWING", Qt::CaseInsensitive )
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 );
}

View file

@ -408,7 +408,11 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "GLS", Qt::CaseInsensitive )
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 );
}

View file

@ -260,8 +260,11 @@ public:
{
if ( !ensureInitDone().empty() )
return;
can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "MDICT", Qt::CaseInsensitive )
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 );
}

View file

@ -177,7 +177,11 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "SDICT", Qt::CaseInsensitive )
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 );
}

View file

@ -640,7 +640,11 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "SLOB", Qt::CaseInsensitive )
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 );
}

View file

@ -200,7 +200,11 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "STARDICT", Qt::CaseInsensitive )
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 );
}

View file

@ -200,7 +200,11 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "XDXF", Qt::CaseInsensitive )
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 );
}

View file

@ -221,7 +221,11 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override
{
can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "ZIM", Qt::CaseInsensitive )
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 );
}