Merge pull request #189 from sunfengsheng/main

fix:解决多音字问题
This commit is contained in:
iaom 2021-03-22 14:32:51 +08:00 committed by GitHub
commit 4ca0bc1ff3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 12 deletions

View File

@ -256,6 +256,8 @@ void AppMatch::getAppName(QMap<NameString,QStringList> &installed)
void AppMatch::appNameMatch(QString appname,QMap<NameString,QStringList> &installed){
NameString name{appname};
QStringList list;
QStringList pinyinlist;
pinyinlist=FileUtils::findMultiToneWords(appname);
QMapIterator<NameString,QStringList> iter(m_installAppMap);
while(iter.hasNext())
{
@ -270,18 +272,21 @@ void AppMatch::appNameMatch(QString appname,QMap<NameString,QStringList> &instal
installed.insert(name,list);
return;
}
QString shouzimu=FileUtils::findMultiToneWords(appname).at(1);// 中文转首字母
if(shouzimu.contains(m_sourceText,Qt::CaseInsensitive)){
// installed.insert(name,m_installAppMap.value(name));
installed.insert(name,list);
return;
}
if(m_sourceText.size()<2)
return;
QString pinyin=FileUtils::findMultiToneWords(appname).at(0);// 中文转拼音
if(pinyin.contains(m_sourceText,Qt::CaseInsensitive)){
// installed.insert(name,m_installAppMap.value(name));
installed.insert(name,list);
for(int i;i<pinyinlist.size()/2;i++){
QString shouzimu=pinyinlist.at(2*i+1);// 中文转首字母
if(shouzimu.contains(m_sourceText,Qt::CaseInsensitive)){
// installed.insert(name,m_installAppMap.value(name));
installed.insert(name,list);
return;
}
if(m_sourceText.size()<2)
return;
QString pinyin=pinyinlist.at(2*i);// 中文转拼音
if(pinyin.contains(m_sourceText,Qt::CaseInsensitive)){
// installed.insert(name,m_installAppMap.value(name));
installed.insert(name,list);
return;
}
}
}