fix: fulltext search,found dictionaries update

This commit is contained in:
YiFang Xiao 2023-05-14 13:49:20 +08:00 committed by xiaoyifang
parent e3e0c33614
commit 126e76ee62
4 changed files with 15 additions and 10 deletions

View file

@ -271,7 +271,7 @@ sptr< Dictionary::DataRequest > ArticleMaker::makeDefinitionFor(
string header = makeHtmlHeader( phrase.phrase, QString(), true ); string header = makeHtmlHeader( phrase.phrase, QString(), true );
return std::make_shared<ArticleRequest>( phrase, Instances::Group{}, return std::make_shared<ArticleRequest>( phrase, Instances::Group{groupId,""},
contexts, ftsDicts, header, contexts, ftsDicts, header,
-1, true ); -1, true );
} }
@ -731,6 +731,7 @@ void ArticleRequest::bodyFinished()
} }
} }
ActiveDictIds hittedWord{ group.id, word, dictIds };
if ( bodyRequests.empty() ) if ( bodyRequests.empty() )
{ {
@ -775,23 +776,24 @@ void ArticleRequest::bodyFinished()
appendDataSlice( footer.data(), footer.size() ); appendDataSlice( footer.data(), footer.size() );
} }
if ( stemmedWordFinder.get() ) { if ( stemmedWordFinder.get() ) {
update(); update();
qDebug() << "send dicts(stemmed):" << word << ":" << dictIds; qDebug() << "send dicts(stemmed):" << hittedWord;
emit GlobalBroadcaster::instance()->dictionaryChanges( ActiveDictIds{ group.id, word, dictIds } ); emit GlobalBroadcaster::instance()->dictionaryChanges( hittedWord );
dictIds.clear(); dictIds.clear();
} }
else { else {
finish(); finish();
qDebug() << "send dicts(finished):" << word << ":" << dictIds; qDebug() << "send dicts(finished):" << hittedWord;
emit GlobalBroadcaster::instance()->dictionaryChanges( ActiveDictIds{ group.id, word, dictIds } ); emit GlobalBroadcaster::instance()->dictionaryChanges( hittedWord );
dictIds.clear(); dictIds.clear();
} }
} }
else if ( wasUpdated ) { else if ( wasUpdated ) {
update(); update();
qDebug() << "send dicts(updated):" << word << ":" << dictIds; qDebug() << "send dicts(updated):" << hittedWord;
emit GlobalBroadcaster::instance()->dictionaryChanges( ActiveDictIds{ group.id, word, dictIds } ); emit GlobalBroadcaster::instance()->dictionaryChanges( hittedWord );
dictIds.clear(); dictIds.clear();
} }
} }

View file

@ -287,7 +287,7 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource(
{ {
// Individual dictionaries set from full-text search // Individual dictionaries set from full-text search
QStringList dictIDList = dictIDs.split( "," ); QStringList dictIDList = dictIDs.split( "," );
return articleMaker.makeDefinitionFor( phrase, 0, QMap< QString, QString >(), QSet< QString >(), dictIDList ); return articleMaker.makeDefinitionFor( phrase, group, QMap< QString, QString >(), QSet< QString >(), dictIDList );
} }
// See if we have some dictionaries muted // See if we have some dictionaries muted

View file

@ -11,6 +11,11 @@ struct ActiveDictIds
unsigned groupId; unsigned groupId;
QString word; QString word;
QStringList dictIds; QStringList dictIds;
operator QString() const
{
return QString( "groupId:%1,word:%2,dictId:%3" ).arg( QString::number( groupId ), word, dictIds.join( "," ) );
}
}; };
class GlobalBroadcaster : public QObject class GlobalBroadcaster : public QObject

View file

@ -37,8 +37,6 @@ struct Group
Group(unsigned id, QString const & name_); Group(unsigned id, QString const & name_);
Group() = default;
/// Makes the configuration group from the current contents. /// Makes the configuration group from the current contents.
Config::Group makeConfigGroup(); Config::Group makeConfigGroup();