From bd5b36cac79637b849b4bc665a54e99b9b0706a2 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Sun, 22 May 2022 22:12:30 +0300 Subject: [PATCH] Extract ArticleView::highlightAllFtsOccurences() Extracting this function allows to simplify the code and facilitates optimizing it in the next commit. Remove `#if QT_VERSION >= 0x040600` along the way as GoldenDict does not support Qt versions older than 4.6 for several years now. --- articleview.cc | 17 ++++++++--------- articleview.hh | 1 + 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/articleview.cc b/articleview.cc index ac2bdf6e..2e01b7f0 100644 --- a/articleview.cc +++ b/articleview.cc @@ -2643,17 +2643,9 @@ void ArticleView::highlightFTSResults() if( ftsSearchMatchCase ) flags |= QWebPage::FindCaseSensitively; -#if QT_VERSION >= 0x040600 - flags |= QWebPage::HighlightAllOccurrences; - - for( int x = 0; x < allMatches.size(); x++ ) - ui.definition->findText( allMatches.at( x ), flags ); - - flags &= ~QWebPage::HighlightAllOccurrences; -#endif - if( !allMatches.isEmpty() ) { + highlightAllFtsOccurences( flags ); if( ui.definition->findText( allMatches.at( 0 ), flags ) ) { ui.definition->page()->currentFrame()-> @@ -2669,6 +2661,13 @@ void ArticleView::highlightFTSResults() ftsSearchIsOpened = true; } +void ArticleView::highlightAllFtsOccurences( QWebPage::FindFlags flags ) +{ + flags |= QWebPage::HighlightAllOccurrences; + for( int x = 0; x < allMatches.size(); x++ ) + ui.definition->findText( allMatches.at( x ), flags ); +} + void ArticleView::performFtsFindOperation( bool backwards ) { if( !ftsSearchIsOpened ) diff --git a/articleview.hh b/articleview.hh index 8a38d00d..ebc9dbaf 100644 --- a/articleview.hh +++ b/articleview.hh @@ -61,6 +61,7 @@ class ArticleView: public QFrame int ftsPosition; void highlightFTSResults(); + void highlightAllFtsOccurences( QWebPage::FindFlags flags ); void performFtsFindOperation( bool backwards ); public: