mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
parent
0bd724b313
commit
15d9104f2c
|
@ -2482,34 +2482,6 @@ void ArticleView::highlightFTSResults()
|
||||||
{
|
{
|
||||||
closeSearch();
|
closeSearch();
|
||||||
|
|
||||||
const QUrl & url = ui.definition->url();
|
|
||||||
|
|
||||||
bool ignoreDiacritics = Utils::Url::hasQueryItem( url, "ignore_diacritics" );
|
|
||||||
|
|
||||||
QString regString = Utils::Url::queryItemValue( url, "regexp" );
|
|
||||||
if( ignoreDiacritics )
|
|
||||||
regString = gd::toQString( Folding::applyDiacriticsOnly( gd::toWString( regString ) ) );
|
|
||||||
else
|
|
||||||
regString = regString.remove( AccentMarkHandler::accentMark() );
|
|
||||||
|
|
||||||
QRegularExpression regexp;
|
|
||||||
if( Utils::Url::hasQueryItem( url, "wildcards" ) )
|
|
||||||
regexp.setPattern( wildcardsToRegexp( regString ) );
|
|
||||||
else
|
|
||||||
regexp.setPattern( regString );
|
|
||||||
|
|
||||||
QRegularExpression::PatternOptions patternOptions =
|
|
||||||
QRegularExpression::DotMatchesEverythingOption | QRegularExpression::UseUnicodePropertiesOption |
|
|
||||||
QRegularExpression::MultilineOption | QRegularExpression::InvertedGreedinessOption;
|
|
||||||
if( !Utils::Url::hasQueryItem( url, "matchcase" ) )
|
|
||||||
patternOptions |= QRegularExpression::CaseInsensitiveOption;
|
|
||||||
regexp.setPatternOptions( patternOptions );
|
|
||||||
|
|
||||||
if( regexp.pattern().isEmpty() || !regexp.isValid() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
sptr< AccentMarkHandler > marksHandler = ignoreDiacritics ? new DiacriticsHandler : new AccentMarkHandler;
|
|
||||||
|
|
||||||
// Clear any current selection
|
// Clear any current selection
|
||||||
if( ui.definition->selectedText().size() )
|
if( ui.definition->selectedText().size() )
|
||||||
{
|
{
|
||||||
|
@ -2519,6 +2491,33 @@ void ArticleView::highlightFTSResults()
|
||||||
ui.definition->page()->toPlainText(
|
ui.definition->page()->toPlainText(
|
||||||
[ & ]( const QString pageText )
|
[ & ]( const QString pageText )
|
||||||
{
|
{
|
||||||
|
const QUrl & url = ui.definition->url();
|
||||||
|
|
||||||
|
bool ignoreDiacritics = Utils::Url::hasQueryItem( url, "ignore_diacritics" );
|
||||||
|
|
||||||
|
QString regString = Utils::Url::queryItemValue( url, "regexp" );
|
||||||
|
if( ignoreDiacritics )
|
||||||
|
regString = gd::toQString( Folding::applyDiacriticsOnly( gd::toWString( regString ) ) );
|
||||||
|
else
|
||||||
|
regString = regString.remove( AccentMarkHandler::accentMark() );
|
||||||
|
|
||||||
|
QRegularExpression regexp;
|
||||||
|
if( Utils::Url::hasQueryItem( url, "wildcards" ) )
|
||||||
|
regexp.setPattern( wildcardsToRegexp( regString ) );
|
||||||
|
else
|
||||||
|
regexp.setPattern( regString );
|
||||||
|
|
||||||
|
QRegularExpression::PatternOptions patternOptions =
|
||||||
|
QRegularExpression::DotMatchesEverythingOption | QRegularExpression::UseUnicodePropertiesOption |
|
||||||
|
QRegularExpression::MultilineOption | QRegularExpression::InvertedGreedinessOption;
|
||||||
|
if( !Utils::Url::hasQueryItem( url, "matchcase" ) )
|
||||||
|
patternOptions |= QRegularExpression::CaseInsensitiveOption;
|
||||||
|
regexp.setPatternOptions( patternOptions );
|
||||||
|
|
||||||
|
if( regexp.pattern().isEmpty() || !regexp.isValid() )
|
||||||
|
return;
|
||||||
|
sptr< AccentMarkHandler > marksHandler = ignoreDiacritics ? new DiacriticsHandler : new AccentMarkHandler;
|
||||||
|
|
||||||
marksHandler->setText( pageText );
|
marksHandler->setText( pageText );
|
||||||
|
|
||||||
QRegularExpressionMatchIterator it = regexp.globalMatch( marksHandler->normalizedText() );
|
QRegularExpressionMatchIterator it = regexp.globalMatch( marksHandler->normalizedText() );
|
||||||
|
@ -2547,7 +2546,7 @@ void ArticleView::highlightFTSResults()
|
||||||
|
|
||||||
ftsSearchMatchCase = Utils::Url::hasQueryItem( url, "matchcase" );
|
ftsSearchMatchCase = Utils::Url::hasQueryItem( url, "matchcase" );
|
||||||
|
|
||||||
QWebEnginePage::FindFlags flags( 0 );
|
QWebEnginePage::FindFlags flags( QWebEnginePage::FindBackward );
|
||||||
|
|
||||||
if( ftsSearchMatchCase )
|
if( ftsSearchMatchCase )
|
||||||
flags |= QWebEnginePage::FindCaseSensitively;
|
flags |= QWebEnginePage::FindCaseSensitively;
|
||||||
|
|
Loading…
Reference in a new issue