mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
fix: merge conflict from upstream
This commit is contained in:
commit
c6811db3a0
|
@ -2570,11 +2570,9 @@ void ArticleView::highlightFTSResults()
|
|||
if( ftsSearchMatchCase )
|
||||
flags |= QWebEnginePage::FindCaseSensitively;
|
||||
|
||||
for( int x = 0; x < allMatches.size(); x++ )
|
||||
ui.definition->findText( allMatches.at( x ), flags );
|
||||
|
||||
if( !allMatches.isEmpty() )
|
||||
{
|
||||
highlightAllFtsOccurences( flags );
|
||||
ui.definition->findText( allMatches.at( 0 ), flags );
|
||||
// if( ui.definition->findText( allMatches.at( 0 ), flags ) )
|
||||
{
|
||||
|
@ -2591,6 +2589,25 @@ void ArticleView::highlightFTSResults()
|
|||
} );
|
||||
}
|
||||
|
||||
void ArticleView::highlightAllFtsOccurences( QWebEnginePage::FindFlags flags )
|
||||
{
|
||||
// Usually allMatches contains mostly duplicates. Thus searching for each element of
|
||||
// allMatches to highlight them takes a long time => collect unique elements into a
|
||||
// set and search for them instead.
|
||||
// Don't use QList::toSet() or QSet's range constructor because they reserve space
|
||||
// for QList::size() elements, whereas the final QSet size is likely 1 or 2.
|
||||
QSet< QString > uniqueMatches;
|
||||
for( int x = 0; x < allMatches.size(); ++x )
|
||||
{
|
||||
QString const & match = allMatches.at( x );
|
||||
// Consider words that differ only in case equal if the search is case-insensitive.
|
||||
uniqueMatches.insert( ftsSearchMatchCase ? match : match.toLower() );
|
||||
}
|
||||
|
||||
for( QSet< QString >::const_iterator it = uniqueMatches.constBegin(); it != uniqueMatches.constEnd(); ++it )
|
||||
ui.definition->findText( *it, flags );
|
||||
}
|
||||
|
||||
void ArticleView::setActiveDictIds(ActiveDictIds ad) {
|
||||
// ignore all other signals.
|
||||
qDebug() << "receive dicts, current word:" << currentWord << ad.word << ":" << ad.dictIds;
|
||||
|
|
|
@ -80,8 +80,8 @@ class ArticleView: public QFrame
|
|||
int ftsPosition;
|
||||
|
||||
void highlightFTSResults();
|
||||
void highlightAllFtsOccurences( QWebEnginePage::FindFlags flags );
|
||||
void performFtsFindOperation( bool backwards );
|
||||
void showFindButtons();
|
||||
|
||||
public:
|
||||
/// The popupView flag influences contents of the context menus to be
|
||||
|
|
|
@ -1128,6 +1128,9 @@ void EpwingBook::getArticle( QString & headword, QString & articleText,
|
|||
headword = QString::fromUtf8( buffer, length );
|
||||
finalizeText( headword );
|
||||
|
||||
if( text_only )
|
||||
fixHeadword( headword );
|
||||
|
||||
articleText = getText( pos.page, pos.offset, text_only );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue