Fix set of symbols [...] handling in the input line

This commit is contained in:
Abs62 2014-03-14 16:39:54 +04:00
parent 2f82ea7e55
commit b20f4d016b
3 changed files with 10 additions and 6 deletions

View file

@ -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;
}

View file

@ -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 );

View file

@ -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;