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