opt: fulltext next navigation optimization (#1718)

* opt: fulltext dialog navigation optimization.

The fulltext dialog navigation (next,previous) use webview's findText,try to find the longest word for navigation
This commit is contained in:
xiaoyifang 2024-08-09 11:47:46 +08:00 committed by GitHub
parent b0bea92106
commit 3279fe8b07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2111,10 +2111,18 @@ void ArticleView::highlightFTSResults()
webview->page()->runJavaScript( script ); webview->page()->runJavaScript( script );
auto parts = regString.split( " ", Qt::SkipEmptyParts ); auto parts = regString.split( " ", Qt::SkipEmptyParts );
if ( !parts.isEmpty() ) { if ( parts.isEmpty() ) {
firstAvailableText = parts[ 0 ]; return;
ftsSearchPanel->show();
} }
//hold the longest word
for ( auto & p : parts ) {
if ( p.size() > firstAvailableText.size() ) {
firstAvailableText = p;
}
}
ftsSearchPanel->show();
} }
void ArticleView::setActiveDictIds( const ActiveDictIds & ad ) void ArticleView::setActiveDictIds( const ActiveDictIds & ad )