Optimized app search.
This commit is contained in:
parent
c94f70e042
commit
ac8013e047
|
@ -100,7 +100,7 @@ void AppMatch::getAllDesktopFilePath(QString path) {
|
|||
qDebug() << fileInfo.filePath();
|
||||
} else {
|
||||
QString filePathStr = fileInfo.filePath();
|
||||
if(m_filePathList.contains(filePathStr)) {
|
||||
if(m_ExcludedDesktopfiles.contains(filePathStr)) {
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
|
@ -135,80 +135,9 @@ void AppMatch::getAllDesktopFilePath(QString path) {
|
|||
m_installAppMap.insert(appname, appInfolist);
|
||||
++i;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief AppMatch::getDesktopFilePath
|
||||
* 对遍历结果处理
|
||||
*/
|
||||
void AppMatch::getDesktopFilePath() {
|
||||
m_filePathList.clear();
|
||||
m_installAppMap.clear();
|
||||
m_filePathList.append("/usr/share/applications/software-properties-livepatch.desktop");
|
||||
m_filePathList.append("/usr/share/applications/mate-color-select.desktop");
|
||||
m_filePathList.append("/usr/share/applications/blueman-adapters.desktop");
|
||||
m_filePathList.append("/usr/share/applications/blueman-manager.desktop");
|
||||
m_filePathList.append("/usr/share/applications/mate-user-guide.desktop");
|
||||
m_filePathList.append("/usr/share/applications/nm-connection-editor.desktop");
|
||||
m_filePathList.append("/usr/share/applications/debian-uxterm.desktop");
|
||||
m_filePathList.append("/usr/share/applications/debian-xterm.desktop");
|
||||
m_filePathList.append("/usr/share/applications/im-config.desktop");
|
||||
m_filePathList.append("/usr/share/applications/fcitx.desktop");
|
||||
m_filePathList.append("/usr/share/applications/fcitx-configtool.desktop");
|
||||
m_filePathList.append("/usr/share/applications/onboard-settings.desktop");
|
||||
m_filePathList.append("/usr/share/applications/info.desktop");
|
||||
m_filePathList.append("/usr/share/applications/ukui-power-preferences.desktop");
|
||||
m_filePathList.append("/usr/share/applications/ukui-power-statistics.desktop");
|
||||
m_filePathList.append("/usr/share/applications/software-properties-drivers.desktop");
|
||||
m_filePathList.append("/usr/share/applications/software-properties-gtk.desktop");
|
||||
m_filePathList.append("/usr/share/applications/gnome-session-properties.desktop");
|
||||
m_filePathList.append("/usr/share/applications/org.gnome.font-viewer.desktop");
|
||||
m_filePathList.append("/usr/share/applications/xdiagnose.desktop");
|
||||
m_filePathList.append("/usr/share/applications/gnome-language-selector.desktop");
|
||||
m_filePathList.append("/usr/share/applications/mate-notification-properties.desktop");
|
||||
m_filePathList.append("/usr/share/applications/transmission-gtk.desktop");
|
||||
m_filePathList.append("/usr/share/applications/mpv.desktop");
|
||||
m_filePathList.append("/usr/share/applications/system-config-printer.desktop");
|
||||
m_filePathList.append("/usr/share/applications/org.gnome.DejaDup.desktop");
|
||||
m_filePathList.append("/usr/share/applications/yelp.desktop");
|
||||
m_filePathList.append("/usr/share/applications/peony-computer.desktop");
|
||||
m_filePathList.append("/usr/share/applications/peony-home.desktop");
|
||||
m_filePathList.append("/usr/share/applications/peony-trash.desktop");
|
||||
// m_filePathList.append("/usr/share/applications/peony.desktop");
|
||||
|
||||
//v10
|
||||
m_filePathList.append("/usr/share/applications/mate-about.desktop");
|
||||
m_filePathList.append("/usr/share/applications/time.desktop");
|
||||
m_filePathList.append("/usr/share/applications/network.desktop");
|
||||
m_filePathList.append("/usr/share/applications/shares.desktop");
|
||||
m_filePathList.append("/usr/share/applications/mate-power-statistics.desktop");
|
||||
m_filePathList.append("/usr/share/applications/display-im6.desktop");
|
||||
m_filePathList.append("/usr/share/applications/display-im6.q16.desktop");
|
||||
m_filePathList.append("/usr/share/applications/openjdk-8-policytool.desktop");
|
||||
m_filePathList.append("/usr/share/applications/kylin-io-monitor.desktop");
|
||||
m_filePathList.append("/usr/share/applications/wps-office-uninstall.desktop");
|
||||
|
||||
// QString desktop;
|
||||
// QStringList applist;
|
||||
// QMap<QString, QList<QString>>::const_iterator i;
|
||||
// for(i=m_installAppMap.constBegin();i!=m_installAppMap.constEnd();++i){
|
||||
// applist=i.value();
|
||||
// if(m_filePathList.contains(applist.at(0)))
|
||||
// m_filterInstallAppMap.insert(i.key(),applist);
|
||||
// }
|
||||
}
|
||||
|
||||
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);
|
||||
// }
|
||||
// appNameMatch(installed);
|
||||
// qDebug() << "installed app match is successful!";
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief AppMatch::appNameMatch
|
||||
* 进行匹配
|
||||
|
@ -342,26 +271,6 @@ void AppMatch::parseSoftWareCenterReturn(QList<QMap<QString, QString>> list, siz
|
|||
}
|
||||
}
|
||||
|
||||
void AppMatch::getInstalledAppsVersion(QString appname) {
|
||||
// qWarning()<<"apt show "+appname;
|
||||
// m_versionCommand->start("apt show "+appname);
|
||||
// m_versionCommand->startDetached(m_versionCommand->program());
|
||||
// m_versionCommand->waitForFinished();
|
||||
// connect(m_versionCommand,&QProcess::readyReadStandardOutput,this,[=](){
|
||||
// QString result=m_versionCommand->readAllStandardOutput();
|
||||
// if(!result.isEmpty()){
|
||||
// QStringList strlist=result.split("\n");
|
||||
// QString str=strlist.at(1);
|
||||
// if(!str.contains("Version")){
|
||||
// return;
|
||||
// }
|
||||
// qWarning()<<strlist.at(1);
|
||||
// qWarning()<<"-----------------------------------------------";
|
||||
// }
|
||||
// });
|
||||
// m_versionCommand->close();
|
||||
}
|
||||
|
||||
void AppMatch::creatResultInfo(SearchPluginIface::ResultInfo &ri, QMapIterator<NameString, QStringList> &iter, bool isInstalled)
|
||||
{
|
||||
// ri.icon = QIcon::fromTheme(iter.value().at(1), QIcon(":/res/icons/desktop.png"));
|
||||
|
@ -372,16 +281,14 @@ void AppMatch::creatResultInfo(SearchPluginIface::ResultInfo &ri, QMapIterator<N
|
|||
}
|
||||
|
||||
void AppMatch::run() {
|
||||
qDebug() << "AppMatch running..";
|
||||
this->getDesktopFilePath();
|
||||
qDebug() << "App map init..";
|
||||
this->getAllDesktopFilePath("/usr/share/applications/");
|
||||
this->getAllDesktopFilePath(ANDROID_APP_DESKTOP_PATH);
|
||||
connect(m_watchAppDir, &QFileSystemWatcher::directoryChanged, this, [ = ](const QString & path) {
|
||||
if(path == "/usr/share/applications/") {
|
||||
m_installAppMap.clear();
|
||||
this->getAllDesktopFilePath("/usr/share/applications/");
|
||||
} else if(path == ANDROID_APP_DESKTOP_PATH) {
|
||||
this->getAllDesktopFilePath(ANDROID_APP_DESKTOP_PATH);
|
||||
}
|
||||
qDebug() << "App map update " << m_installAppMap.size();
|
||||
});
|
||||
qDebug() << "AppMatch finish..";
|
||||
qDebug() << "App map init finished.." << m_installAppMap.size();
|
||||
}
|
||||
|
|
|
@ -38,6 +38,9 @@ public:
|
|||
bool operator<(const NameString& name) const {
|
||||
return this->app_name.length() <= name.app_name.length();
|
||||
}
|
||||
bool operator==(const NameString& name) const {
|
||||
return this->app_name == name.app_name;
|
||||
}
|
||||
};
|
||||
|
||||
//struct NameString
|
||||
|
@ -64,32 +67,65 @@ private:
|
|||
explicit AppMatch(QObject *parent = nullptr);
|
||||
~AppMatch();
|
||||
void getAllDesktopFilePath(QString path);
|
||||
void getDesktopFilePath();
|
||||
void getAppName(QMap<NameString, QStringList> &installed);
|
||||
// void appNameMatch(QString appname,QString desktoppath,QString appicon);
|
||||
// void appNameMatch(QString keyWord, QString appname, QMap<NameString, QStringList> &installed);
|
||||
void appNameMatch(QString keyWord, size_t uniqueSymbol, DataQueue<SearchPluginIface::ResultInfo> *searchResult);
|
||||
void softWareCenterSearch(QMap<NameString, QStringList> &softwarereturn);
|
||||
void parseSoftWareCenterReturn(QList<QMap<QString, QString>> list, size_t uniqueSymbol, DataQueue<SearchPluginIface::ResultInfo> *searchResult);
|
||||
void getInstalledAppsVersion(QString appname);
|
||||
void creatResultInfo(SearchPluginIface::ResultInfo &ri, QMapIterator<NameString, QStringList> &iter, bool isInstalled = true);
|
||||
|
||||
QString m_sourceText;
|
||||
size_t m_uniqueSymbol;
|
||||
DataQueue<SearchPluginIface::ResultInfo> *m_search_result = nullptr;
|
||||
QStringList m_filePathList;
|
||||
|
||||
QDBusInterface *m_interFace = nullptr;
|
||||
QFileSystemWatcher *m_watchAppDir = nullptr;
|
||||
QMap<NameString, QStringList> m_installAppMap;
|
||||
|
||||
QStringList m_ExcludedDesktopfiles = {
|
||||
"/usr/share/applications/software-properties-livepatch.desktop",
|
||||
"/usr/share/applications/mate-color-select.desktop",
|
||||
"/usr/share/applications/blueman-adapters.desktop",
|
||||
"/usr/share/applications/blueman-manager.desktop",
|
||||
"/usr/share/applications/mate-user-guide.desktop",
|
||||
"/usr/share/applications/nm-connection-editor.desktop",
|
||||
"/usr/share/applications/debian-uxterm.desktop",
|
||||
"/usr/share/applications/debian-xterm.desktop",
|
||||
"/usr/share/applications/im-config.desktop",
|
||||
"/usr/share/applications/fcitx.desktop",
|
||||
"/usr/share/applications/fcitx-configtool.desktop",
|
||||
"/usr/share/applications/onboard-settings.desktop",
|
||||
"/usr/share/applications/info.desktop",
|
||||
"/usr/share/applications/ukui-power-preferences.desktop",
|
||||
"/usr/share/applications/ukui-power-statistics.desktop",
|
||||
"/usr/share/applications/software-properties-drivers.desktop",
|
||||
"/usr/share/applications/software-properties-gtk.desktop",
|
||||
"/usr/share/applications/gnome-session-properties.desktop",
|
||||
"/usr/share/applications/org.gnome.font-viewer.desktop",
|
||||
"/usr/share/applications/xdiagnose.desktop",
|
||||
"/usr/share/applications/gnome-language-selector.desktop",
|
||||
"/usr/share/applications/mate-notification-properties.desktop",
|
||||
"/usr/share/applications/transmission-gtk.desktop",
|
||||
"/usr/share/applications/mpv.desktop",
|
||||
"/usr/share/applications/system-config-printer.desktop",
|
||||
"/usr/share/applications/org.gnome.DejaDup.desktop",
|
||||
"/usr/share/applications/yelp.desktop",
|
||||
"/usr/share/applications/peony-computer.desktop",
|
||||
"/usr/share/applications/peony-home.desktop",
|
||||
"/usr/share/applications/peony-trash.desktop",
|
||||
|
||||
//v10
|
||||
"/usr/share/applications/mate-about.desktop",
|
||||
"/usr/share/applications/time.desktop",
|
||||
"/usr/share/applications/network.desktop",
|
||||
"/usr/share/applications/shares.desktop",
|
||||
"/usr/share/applications/mate-power-statistics.desktop",
|
||||
"/usr/share/applications/display-im6.desktop",
|
||||
"/usr/share/applications/display-im6.q16.desktop",
|
||||
"/usr/share/applications/openjdk-8-policytool.desktop",
|
||||
"/usr/share/applications/kylin-io-monitor.desktop",
|
||||
"/usr/share/applications/wps-office-uninstall.desktop",
|
||||
};
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotDBusCallFinished(QString keyWord, size_t uniqueSymbol, DataQueue<SearchPluginIface::ResultInfo> *searchResult);
|
||||
|
||||
//Q_SIGNALS:
|
||||
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue