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)
|
|
|
|
{
|
|
|
|
PropertyMap map;
|
|
|
|
AppInfoTable::self()->query(map, desktopFile, Properties{property});
|
2023-03-14 14:01:28 +08:00
|
|
|
return map.value(property);
|
2023-03-07 17:33:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
PropertyMap ApplicationInfo::getInfo(const QString &desktopFile, Properties properties)
|
|
|
|
{
|
|
|
|
PropertyMap propertyMap;
|
|
|
|
AppInfoTable::self()->query(propertyMap, desktopFile, properties);
|
|
|
|
return propertyMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
ApplicationInfoMap ApplicationInfo::getInfo(Properties properties)
|
|
|
|
{
|
|
|
|
ApplicationInfoMap infoMap;
|
|
|
|
AppInfoTable::self()->query(infoMap, properties);
|
|
|
|
return infoMap;
|
|
|
|
}
|
2023-03-14 14:01:28 +08:00
|
|
|
|
|
|
|
ApplicationInfoMap ApplicationInfo::getInfo(Properties properties, PropertyMap restrictions)
|
|
|
|
{
|
|
|
|
ApplicationInfoMap infoMap;
|
|
|
|
AppInfoTable::self()->query(infoMap, properties, restrictions);
|
|
|
|
return infoMap;
|
|
|
|
}
|
|
|
|
|
2023-03-14 16:06:37 +08:00
|
|
|
ApplicationInfoMap ApplicationInfo::searchApp(Properties properties, const QString &keyword, PropertyMap restrictions)
|
2023-03-14 14:01:28 +08:00
|
|
|
{
|
|
|
|
ApplicationInfoMap infoMap;
|
2023-03-14 16:06:37 +08:00
|
|
|
AppInfoTable::self()->query(infoMap, properties, keyword, restrictions);
|
2023-03-14 14:01:28 +08:00
|
|
|
return infoMap;
|
|
|
|
}
|
|
|
|
|
2023-03-14 16:06:37 +08:00
|
|
|
ApplicationInfoMap ApplicationInfo::searchApp(Properties properties, const QStringList &keywords, PropertyMap restrictions)
|
|
|
|
{
|
|
|
|
ApplicationInfoMap infoMap;
|
|
|
|
AppInfoTable::self()->query(infoMap, properties, keywords, restrictions);
|
|
|
|
return infoMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ApplicationInfo::setAppFavoritesState(const QString &desktopFilePath, size_t num)
|
2023-03-14 14:01:28 +08:00
|
|
|
{
|
|
|
|
AppInfoTable::self()->setAppFavoritesState(desktopFilePath, num);
|
|
|
|
}
|
|
|
|
|
2023-03-14 16:06:37 +08:00
|
|
|
void ApplicationInfo::setAppTopState(const QString &desktopFilePath, size_t num)
|
2023-03-14 14:01:28 +08:00
|
|
|
{
|
|
|
|
AppInfoTable::self()->setAppTopState(desktopFilePath, num);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ApplicationInfo::changeFavoriteAppPos(const QString &desktopFilePath, size_t pos)
|
|
|
|
{
|
|
|
|
return AppInfoTable::self()->changeFavoriteAppPos(desktopFilePath, pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ApplicationInfo::changeTopAppPos(const QString &desktopFilePath, size_t pos)
|
|
|
|
{
|
|
|
|
return AppInfoTable::self()->changeTopAppPos(desktopFilePath, pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ApplicationInfo::tranPidToDesktopFp(int pid, QString &desktopFilePath)
|
|
|
|
{
|
|
|
|
return AppInfoTable::self()->tranPidToDesktopFp(pid, desktopFilePath);
|
|
|
|
}
|