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,8 +263,13 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override 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() ) {
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); 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: protected:

View file

@ -219,8 +219,12 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override 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() ) {
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); 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: protected:

View file

@ -140,8 +140,12 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override 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() ) {
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); 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; QAtomicInt FTS_index_completed;
bool synonymSearchEnabled; bool synonymSearchEnabled;
string dictionaryName; string dictionaryName;
//default to true; std::optional< bool > metadata_enable_fts = std::nullopt;
bool enable_FTS = true;
// Load user icon if it exist // Load user icon if it exist
// By default set icon to empty // By default set icon to empty
@ -376,7 +375,7 @@ public:
void setFtsEnable( bool _enable_FTS ) 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, /// Returns all the available properties, like the author's name, copyright,

View file

@ -235,9 +235,12 @@ public:
{ {
if ( ensureInitDone().size() ) if ( ensureInitDone().size() )
return; return;
if ( metadata_enable_fts.has_value() ) {
can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "DSL", Qt::CaseInsensitive ) can_FTS = fts.enabled && metadata_enable_fts.value();
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); }
else
can_FTS = fts.enabled && !fts.disabledTypes.contains( "DSL", Qt::CaseInsensitive )
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize );
} }
uint32_t getFtsIndexVersion() override uint32_t getFtsIndexVersion() override

View file

@ -154,9 +154,12 @@ public:
{ {
if ( ensureInitDone().size() ) if ( ensureInitDone().size() )
return; return;
if ( metadata_enable_fts.has_value() ) {
can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "EPWING", Qt::CaseInsensitive ) can_FTS = fts.enabled && metadata_enable_fts.value();
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); }
else
can_FTS = fts.enabled && !fts.disabledTypes.contains( "EPWING", Qt::CaseInsensitive )
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize );
} }
static int japaneseWriting( gd::wchar ch ); static int japaneseWriting( gd::wchar ch );

View file

@ -408,8 +408,12 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override 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() ) {
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); 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: protected:

View file

@ -260,9 +260,12 @@ public:
{ {
if ( !ensureInitDone().empty() ) if ( !ensureInitDone().empty() )
return; return;
if ( metadata_enable_fts.has_value() ) {
can_FTS = enable_FTS && fts.enabled && !fts.disabledTypes.contains( "MDICT", Qt::CaseInsensitive ) can_FTS = fts.enabled && metadata_enable_fts.value();
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); }
else
can_FTS = fts.enabled && !fts.disabledTypes.contains( "MDICT", Qt::CaseInsensitive )
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize );
} }
QString getCachedFileName( QString name ); QString getCachedFileName( QString name );

View file

@ -177,8 +177,12 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override 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() ) {
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); 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: protected:

View file

@ -640,8 +640,12 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override 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() ) {
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); 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 uint32_t getFtsIndexVersion() override

View file

@ -200,8 +200,12 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override 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() ) {
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); 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: protected:

View file

@ -200,8 +200,12 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override 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() ) {
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); 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 uint32_t getFtsIndexVersion() override

View file

@ -221,8 +221,12 @@ public:
void setFTSParameters( Config::FullTextSearch const & fts ) override 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() ) {
&& ( fts.maxDictionarySize == 0 || getArticleCount() <= fts.maxDictionarySize ); 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: protected: