ukui-search/libsearch/appdata/application-info.cpp

94 lines
3.0 KiB
C++
Raw Normal View History

#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)
{
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);
}
ApplicationInfo::~ApplicationInfo()
{
if(d) {
delete d;
d = nullptr;
}
}
QVariant UkuiSearch::ApplicationInfo::getInfo(const QString &desktopFile, ApplicationProperty::Property property)
{
ApplicationPropertyMap map;
AppInfoTable::self()->query(map, desktopFile, ApplicationProperties{property});
return map.value(property);
}
ApplicationPropertyMap ApplicationInfo::getInfo(const QString &desktopFile, ApplicationProperties properties)
{
ApplicationPropertyMap propertyMap;
AppInfoTable::self()->query(propertyMap, desktopFile, properties);
return propertyMap;
}
ApplicationInfoMap ApplicationInfo::getInfo(ApplicationProperties properties)
{
ApplicationInfoMap infoMap;
AppInfoTable::self()->query(infoMap, properties);
return infoMap;
}
ApplicationInfoMap ApplicationInfo::getInfo(ApplicationProperties properties, ApplicationPropertyMap restrictions)
{
ApplicationInfoMap infoMap;
AppInfoTable::self()->query(infoMap, properties, restrictions);
return infoMap;
}
ApplicationInfoMap ApplicationInfo::searchApp(ApplicationProperties properties, const QString &keyword, ApplicationPropertyMap restrictions)
{
ApplicationInfoMap infoMap;
AppInfoTable::self()->query(infoMap, properties, QStringList{keyword}, restrictions);
return infoMap;
}
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;
}
void ApplicationInfo::setAppToFavorites(const QString &desktopFilePath)
{
AppInfoTable::self()->setAppFavoritesState(desktopFilePath);
}
void ApplicationInfo::setFavoritesOfApp(const QString &desktopFilePath, size_t num)
{
AppInfoTable::self()->setAppFavoritesState(desktopFilePath, num);
}
void ApplicationInfo::setAppToTop(const QString &desktopFilePath)
{
AppInfoTable::self()->setAppTopState(desktopFilePath);
}
void ApplicationInfo::setTopOfApp(const QString &desktopFilePath, size_t num)
{
AppInfoTable::self()->setAppTopState(desktopFilePath, num);
}
bool ApplicationInfo::tranPidToDesktopFp(int pid, QString &desktopFilePath)
{
return AppInfoTable::self()->tranPidToDesktopFp(pid, desktopFilePath);
}