Fix a bug for app match;

This commit is contained in:
rookie-J 2021-06-28 19:38:27 +08:00
parent bbf27b9d5f
commit 4b02fdbb34
2 changed files with 38 additions and 4 deletions

View File

@ -228,10 +228,11 @@ void AppMatch::getDesktopFilePath() {
}
void AppMatch::getAppName(QMap<NameString, QStringList> &installed) {
QMap<NameString, QStringList>::const_iterator i;
for(i = m_installAppMap.constBegin(); i != m_installAppMap.constEnd(); ++i) {
appNameMatch(i.key().app_name, installed);
}
// QMap<NameString, QStringList>::const_iterator i;
// for(i = m_installAppMap.constBegin(); i != m_installAppMap.constEnd(); ++i) {
// appNameMatch(i.key().app_name, installed);
// }
appNameMatch(installed);
qDebug() << "installed app match is successful!";
}
@ -276,6 +277,38 @@ void AppMatch::appNameMatch(QString appname, QMap<NameString, QStringList> &inst
}
}
}
void AppMatch::appNameMatch(QMap<NameString, QStringList> &installed) {
QStringList list;
NameString name;
QMapIterator<NameString, QStringList> iter(m_installAppMap);
while(iter.hasNext()) {
iter.next();
list = iter.value();
name.app_name = iter.key().app_name;
if(iter.key().app_name.contains(m_sourceText, Qt::CaseInsensitive)) {
installed.insert(name, list);
continue;
}
QStringList pinyinlist;
pinyinlist = FileUtils::findMultiToneWords(iter.key().app_name);
for(int i = 0; i < pinyinlist.size() / 2; i++) {
QString shouzimu = pinyinlist.at(2 * i + 1); // 中文转首字母
if(shouzimu.contains(m_sourceText, Qt::CaseInsensitive)) {
installed.insert(name, list);
continue;
}
if(m_sourceText.size() < 2)
continue;
QString pinyin = pinyinlist.at(2 * i); // 中文转拼音
if(pinyin.contains(m_sourceText, Qt::CaseInsensitive)) {
installed.insert(name, list);
continue;
}
}
}
}
void AppMatch::softWareCenterSearch(QMap<NameString, QStringList> &softwarereturn) {
// if(m_interFace->timeout() != -1) {

View File

@ -65,6 +65,7 @@ private:
void getAppName(QMap<NameString, QStringList> &installed);
// void appNameMatch(QString appname,QString desktoppath,QString appicon);
void appNameMatch(QString appname, QMap<NameString, QStringList> &installed);
void appNameMatch(QMap<NameString, QStringList> &installed);
void softWareCenterSearch(QMap<NameString, QStringList> &softwarereturn);