2023-03-07 17:33:08 +08:00
|
|
|
#include "application-info.h"
|
|
|
|
#include "app-info-table.h"
|
2024-01-04 17:16:45 +08:00
|
|
|
|
2023-03-07 17:33:08 +08:00
|
|
|
using namespace UkuiSearch;
|
|
|
|
namespace UkuiSearch {
|
2024-01-04 17:16:45 +08:00
|
|
|
class ApplicationInfoPrivate : public QObject
|
2023-03-07 17:33:08 +08:00
|
|
|
{
|
2024-01-04 17:16:45 +08:00
|
|
|
public:
|
|
|
|
explicit ApplicationInfoPrivate(ApplicationInfo *parent = nullptr) : QObject(parent), m_infoTable(new AppInfoTable(this)) {}
|
|
|
|
AppInfoTable *m_infoTable = nullptr;
|
2023-03-07 17:33:08 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-01-04 17:16:45 +08:00
|
|
|
ApplicationInfo::ApplicationInfo(QObject *parent) : QObject(parent), d(new ApplicationInfoPrivate(this)) {
|
|
|
|
connect(d->m_infoTable, &AppInfoTable::appDBItems2BUpdate, this, &ApplicationInfo::appDBItems2BUpdate);
|
|
|
|
connect(d->m_infoTable, &AppInfoTable::appDBItems2BUpdateAll, this, &ApplicationInfo::appDBItems2BUpdateAll);
|
|
|
|
connect(d->m_infoTable, &AppInfoTable::appDBItems2BAdd, this, &ApplicationInfo::appDBItems2BAdd);
|
|
|
|
connect(d->m_infoTable, &AppInfoTable::appDBItems2BDelete, this, &ApplicationInfo::appDBItems2BDelete);
|
2023-03-07 17:33:08 +08:00
|
|
|
}
|
|
|
|
|
2024-01-04 17:16:45 +08:00
|
|
|
QVariant ApplicationInfo::getInfo(const QString &desktopFile, ApplicationProperty::Property property) {
|
2023-03-15 16:39:38 +08:00
|
|
|
ApplicationPropertyMap map;
|
2024-01-04 17:16:45 +08:00
|
|
|
d->m_infoTable->query(map, desktopFile, ApplicationProperties{property});
|
2023-03-14 14:01:28 +08:00
|
|
|
return map.value(property);
|
2023-03-07 17:33:08 +08:00
|
|
|
}
|
|
|
|
|
2024-01-04 17:16:45 +08:00
|
|
|
ApplicationPropertyMap ApplicationInfo::getInfo(const QString& desktopFile, ApplicationProperties properties) {
|
2023-03-15 16:39:38 +08:00
|
|
|
ApplicationPropertyMap propertyMap;
|
2024-01-04 17:16:45 +08:00
|
|
|
d->m_infoTable->query(propertyMap, desktopFile, properties);
|
2023-03-07 17:33:08 +08:00
|
|
|
return propertyMap;
|
|
|
|
}
|
|
|
|
|
2024-01-04 17:16:45 +08:00
|
|
|
ApplicationInfoMap ApplicationInfo::getInfo(ApplicationProperties properties) {
|
2023-03-07 17:33:08 +08:00
|
|
|
ApplicationInfoMap infoMap;
|
2024-01-04 17:16:45 +08:00
|
|
|
d->m_infoTable->query(infoMap, properties);
|
2023-03-07 17:33:08 +08:00
|
|
|
return infoMap;
|
|
|
|
}
|
2023-03-14 14:01:28 +08:00
|
|
|
|
2024-01-04 17:16:45 +08:00
|
|
|
ApplicationInfoMap ApplicationInfo::getInfo(ApplicationProperties properties, ApplicationPropertyMap restrictions) {
|
2023-03-14 14:01:28 +08:00
|
|
|
ApplicationInfoMap infoMap;
|
2024-01-04 17:16:45 +08:00
|
|
|
d->m_infoTable->query(infoMap, properties, restrictions);
|
2023-03-14 14:01:28 +08:00
|
|
|
return infoMap;
|
|
|
|
}
|
|
|
|
|
2024-01-04 17:16:45 +08:00
|
|
|
ApplicationInfoMap ApplicationInfo::searchApp(ApplicationProperties properties, const QString &keyword, ApplicationPropertyMap restrictions) {
|
2023-03-14 14:01:28 +08:00
|
|
|
ApplicationInfoMap infoMap;
|
2024-01-04 17:16:45 +08:00
|
|
|
d->m_infoTable->query(infoMap, properties, QStringList{keyword}, restrictions);
|
2023-03-14 14:01:28 +08:00
|
|
|
return infoMap;
|
|
|
|
}
|
|
|
|
|
2024-01-04 17:16:45 +08:00
|
|
|
ApplicationInfoMap ApplicationInfo::searchApp(ApplicationProperties properties, const QStringList &keywords, ApplicationPropertyMap restrictions) {
|
2023-03-14 16:06:37 +08:00
|
|
|
ApplicationInfoMap infoMap;
|
2024-01-04 17:16:45 +08:00
|
|
|
d->m_infoTable->query(infoMap, properties, keywords, restrictions);
|
2023-03-14 16:06:37 +08:00
|
|
|
return infoMap;
|
|
|
|
}
|
|
|
|
|
2024-01-04 17:16:45 +08:00
|
|
|
void ApplicationInfo::setAppToFavorites(const QString &desktopFilePath) {
|
|
|
|
return d->m_infoTable->setAppFavoritesState(desktopFilePath);
|
2023-03-14 14:01:28 +08:00
|
|
|
}
|
|
|
|
|
2024-01-04 17:16:45 +08:00
|
|
|
void ApplicationInfo::setFavoritesOfApp(const QString &desktopFilePath, size_t num) {
|
|
|
|
return d->m_infoTable->setAppFavoritesState(desktopFilePath, num);
|
2023-03-14 14:01:28 +08:00
|
|
|
}
|
|
|
|
|
2024-01-04 17:16:45 +08:00
|
|
|
void ApplicationInfo::setAppToTop(const QString &desktopFilePath) {
|
|
|
|
return d->m_infoTable->setAppTopState(desktopFilePath);
|
2023-03-14 14:01:28 +08:00
|
|
|
}
|
|
|
|
|
2024-01-04 17:16:45 +08:00
|
|
|
void ApplicationInfo::setTopOfApp(const QString &desktopFilePath, size_t num) {
|
|
|
|
return d->m_infoTable->setAppTopState(desktopFilePath, num);
|
2023-03-14 14:01:28 +08:00
|
|
|
}
|
|
|
|
|
2024-01-04 17:16:45 +08:00
|
|
|
void ApplicationInfo::setAppLaunchedState(const QString &desktopFilePath, bool launched) {
|
|
|
|
return d->m_infoTable->setAppLaunchedState(desktopFilePath, launched);
|
2023-04-14 13:45:05 +08:00
|
|
|
}
|
|
|
|
|
2024-01-04 17:16:45 +08:00
|
|
|
bool ApplicationInfo::tranPidToDesktopFp(int pid, QString &desktopFilePath) {
|
|
|
|
return d->m_infoTable->tranPidToDesktopFp(pid, desktopFilePath);
|
2023-03-14 14:01:28 +08:00
|
|
|
}
|
2023-04-17 16:14:44 +08:00
|
|
|
|
2024-01-04 17:16:45 +08:00
|
|
|
bool ApplicationInfo::tranPidToDesktopFp(uint pid, QString &desktopFilePath) {
|
|
|
|
return d->m_infoTable->tranPidToDesktopFp(pid, desktopFilePath);
|
2023-04-17 16:14:44 +08:00
|
|
|
}
|
|
|
|
|
2024-01-04 17:16:45 +08:00
|
|
|
bool ApplicationInfo::desktopFilePathFromName(const QString &desktopFileName, QString &desktopFilePath) {
|
|
|
|
return d->m_infoTable->desktopFilePathFromName(desktopFileName, desktopFilePath);
|
2023-04-17 16:14:44 +08:00
|
|
|
}
|
2023-08-08 17:00:31 +08:00
|
|
|
|
2024-01-04 17:16:45 +08:00
|
|
|
bool ApplicationInfo::tranWinIdToDesktopFilePath(const QVariant &winId, QString &desktopFilePath) {
|
|
|
|
return d->m_infoTable->tranWinIdToDesktopFilePath(winId, desktopFilePath);
|
2024-01-26 09:54:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ApplicationInfo::~ApplicationInfo() = default;
|