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

View file

@ -287,7 +287,7 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource(
{
// Individual dictionaries set from full-text search
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

View file

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

View file

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