diff --git a/btreeidx.cc b/btreeidx.cc index d0f12257..2ba6f4ea 100644 --- a/btreeidx.cc +++ b/btreeidx.cc @@ -209,12 +209,15 @@ void BtreeWordSearchRequest::run() QRegExp regexp; bool useWildcards = allowMiddleMatches && ( str.find( '*' ) != wstring::npos || - str.find( '?' ) != wstring::npos ); + str.find( '?' ) != wstring::npos || + str.find( '[' ) != wstring::npos || + str.find( ']' ) != wstring::npos); wstring folded = Folding::apply( str ); + if( useWildcards ) { - regexp.setPattern( gd::toQString( Folding::applyDiacriticsOnly( str ) ) ); + regexp.setPattern( gd::toQString( Folding::applyDiacriticsOnly( Folding::applySimpleCaseOnly( str ) ) ) ); regexp.setPatternSyntax( QRegExp::WildcardUnix ); regexp.setCaseSensitivity( Qt::CaseInsensitive ); @@ -234,7 +237,7 @@ void BtreeWordSearchRequest::run() if( bNoLetters ) { - if( ch == '*' || ch == '?' ) + if( ch == '*' || ch == '?' || ch == '[' || ch == ']' ) { // Store escaped symbols wstring::size_type n = folded.size(); @@ -249,7 +252,7 @@ void BtreeWordSearchRequest::run() } else { - if( ch == '\\' || ch == '*' || ch == '?' ) + if( ch == '\\' || ch == '*' || ch == '?' || ch == '[' || ch == ']' ) break; } diff --git a/folding.cc b/folding.cc index ff35b596..10220f2d 100644 --- a/folding.cc +++ b/folding.cc @@ -43,7 +43,8 @@ wstring apply( wstring const & in, bool preserveWildcards ) if ( !isCombiningMark( ch ) && !isWhitespace( ch ) && ( !isPunct( ch ) - || ( preserveWildcards && ( ch == '\\' || ch == '?' || ch == '*' ) ) + || ( preserveWildcards && + ( ch == '\\' || ch == '?' || ch == '*' || ch == '[' || ch == ']' ) ) ) ) withoutDiacritics.push_back( ch ); diff --git a/mainwindow.cc b/mainwindow.cc index b3284db1..1dbf0202 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -854,7 +854,7 @@ void MainWindow::updateSearchPaneAndBar( bool searchInDock ) translateBoxToolBarAction->setVisible( true ); } - translateLine->setToolTip( tr( "String to search in dictionaries, the wildcards '*' and '?' are allowed.\nTo find '*' and '?' symbols use '\\*' and '\\?' respectively" ) ); + translateLine->setToolTip( tr( "String to search in dictionaries. The wildcards '*', '?' and sets of symbols '[...]' are allowed.\nTo find '*', '?', '[', ']' symbols use '\\*', '\\?', '\\[', '\\]' respectively" ) ); // reset the flag when switching UI modes wordListSelChanged = false;