mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Full-text search: Set group for ArticleView::showDefinition() when view article
This commit is contained in:
parent
c2cdf9b177
commit
503650d617
|
@ -279,7 +279,7 @@ void ArticleView::showDefinition( QString const & word, unsigned group,
|
|||
}
|
||||
|
||||
void ArticleView::showDefinition( QString const & word, QStringList const & dictIDs,
|
||||
QRegExp const & searchRegExp )
|
||||
QRegExp const & searchRegExp, unsigned group )
|
||||
{
|
||||
if( dictIDs.isEmpty() )
|
||||
return;
|
||||
|
@ -301,6 +301,7 @@ void ArticleView::showDefinition( QString const & word, QStringList const & dict
|
|||
req.addQueryItem( "matchcase", "1" );
|
||||
if( searchRegExp.patternSyntax() == QRegExp::WildcardUnix )
|
||||
req.addQueryItem( "wildcards", "1" );
|
||||
req.addQueryItem( "group", QString::number( group ) );
|
||||
|
||||
// Update both histories (pages history and headwords history)
|
||||
saveHistoryUserData();
|
||||
|
@ -925,11 +926,7 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref,
|
|||
QStringList dictsList = ref.queryItemValue( "dictionaries" )
|
||||
.split( ",", QString::SkipEmptyParts );
|
||||
|
||||
QRegExp regexp( ref.queryItemValue( "regexp" ),
|
||||
ref.hasQueryItem( "matchcase" ) ? Qt::CaseSensitive : Qt::CaseInsensitive,
|
||||
ref.hasQueryItem( "wildcards" ) ? QRegExp::WildcardUnix : QRegExp::RegExp2 );
|
||||
|
||||
showDefinition( url.path(), dictsList, regexp );
|
||||
showDefinition( url.path(), dictsList, QRegExp(), getGroup( ref ) );
|
||||
}
|
||||
else
|
||||
showDefinition( url.path(),
|
||||
|
@ -951,11 +948,7 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref,
|
|||
QStringList dictsList = ref.queryItemValue( "dictionaries" )
|
||||
.split( ",", QString::SkipEmptyParts );
|
||||
|
||||
QRegExp regexp( ref.queryItemValue( "regexp" ),
|
||||
ref.hasQueryItem( "matchcase" ) ? Qt::CaseSensitive : Qt::CaseInsensitive,
|
||||
ref.hasQueryItem( "wildcards" ) ? QRegExp::WildcardUnix : QRegExp::RegExp2 );
|
||||
|
||||
showDefinition( url.path().mid( 1 ), dictsList, regexp );
|
||||
showDefinition( url.path().mid( 1 ), dictsList, QRegExp(), getGroup( ref ) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1955,7 +1948,18 @@ void ArticleView::doubleClicked()
|
|||
getCurrentArticle(), Contexts() );
|
||||
}
|
||||
else
|
||||
showDefinition( selectedText, getGroup( ui.definition->url() ), getCurrentArticle() );
|
||||
{
|
||||
QUrl const & ref = ui.definition->url();
|
||||
|
||||
if( ref.hasQueryItem( "dictionaries" ) )
|
||||
{
|
||||
QStringList dictsList = ref.queryItemValue( "dictionaries" )
|
||||
.split( ",", QString::SkipEmptyParts );
|
||||
showDefinition( selectedText, dictsList, QRegExp(), getGroup( ref ) );
|
||||
}
|
||||
else
|
||||
showDefinition( selectedText, getGroup( ref ), getCurrentArticle() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2119,6 +2123,16 @@ void ArticleView::highlightFTSResults()
|
|||
{
|
||||
closeSearch();
|
||||
|
||||
const QUrl & url = ui.definition->url();
|
||||
QRegExp regexp( url.queryItemValue( "regexp" ),
|
||||
url.hasQueryItem( "matchcase" ) ? Qt::CaseSensitive : Qt::CaseInsensitive,
|
||||
url.hasQueryItem( "wildcards" ) ? QRegExp::WildcardUnix : QRegExp::RegExp2 );
|
||||
|
||||
if( regexp.pattern().isEmpty() )
|
||||
return;
|
||||
|
||||
regexp.setMinimal( true );
|
||||
|
||||
// Clear any current selection
|
||||
if ( ui.definition->selectedText().size() )
|
||||
{
|
||||
|
@ -2126,12 +2140,6 @@ void ArticleView::highlightFTSResults()
|
|||
evaluateJavaScript( "window.getSelection().removeAllRanges();_=0;" );
|
||||
}
|
||||
|
||||
const QUrl & url = ui.definition->url();
|
||||
QRegExp regexp( url.queryItemValue( "regexp" ),
|
||||
url.hasQueryItem( "matchcase" ) ? Qt::CaseSensitive : Qt::CaseInsensitive,
|
||||
url.hasQueryItem( "wildcards" ) ? QRegExp::WildcardUnix : QRegExp::RegExp2 );
|
||||
regexp.setMinimal( true );
|
||||
|
||||
QString pageText = ui.definition->page()->currentFrame()->toPlainText();
|
||||
int pos = 0;
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ public:
|
|||
Contexts const & contexts = Contexts() );
|
||||
|
||||
void showDefinition( QString const & word, QStringList const & dictIDs,
|
||||
QRegExp const & searchRegExp );
|
||||
QRegExp const & searchRegExp, unsigned group );
|
||||
|
||||
/// Clears the view and sets the application-global waiting cursor,
|
||||
/// which will be restored when some article loads eventually.
|
||||
|
|
|
@ -2638,7 +2638,8 @@ void MainWindow::showTranslationFor( QString const & inWord,
|
|||
|
||||
navPronounce->setEnabled( false );
|
||||
|
||||
view->showDefinition( inWord, dictIDs, searchRegExp );
|
||||
view->showDefinition( inWord, dictIDs, searchRegExp,
|
||||
groupInstances[ groupList->currentIndex() ].id );
|
||||
|
||||
updatePronounceAvailability();
|
||||
updateFoundInDictsList();
|
||||
|
|
Loading…
Reference in a new issue