2023-04-11 10:19:35 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (C) 2023, KylinSoft Co., Ltd.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Authors: iaom <zhangpengfei@kylinos.cn>
|
|
|
|
*/
|
2023-03-07 17:33:08 +08:00
|
|
|
#ifndef APPLICATIONINFO_H
|
|
|
|
#define APPLICATIONINFO_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
#include "application-property.h"
|
|
|
|
namespace UkuiSearch {
|
|
|
|
class ApplicationInfoPrivate;
|
|
|
|
class ApplicationInfo : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit ApplicationInfo(QObject *parent = nullptr);
|
|
|
|
~ApplicationInfo();
|
|
|
|
/**
|
|
|
|
* @brief getInfo 查询单个应用的单个属性
|
|
|
|
* @param desktopFile
|
|
|
|
* @param property
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
QVariant getInfo(const QString &desktopFile, ApplicationProperty::Property property);
|
|
|
|
/**
|
|
|
|
* @brief getInfo 查询单个应用的多个属性
|
|
|
|
* @param desktopFile
|
|
|
|
* @param properties
|
|
|
|
* @return
|
|
|
|
*/
|
2023-03-15 16:39:38 +08:00
|
|
|
ApplicationPropertyMap getInfo(const QString &desktopFile, ApplicationProperties properties);
|
2023-03-07 17:33:08 +08:00
|
|
|
/**
|
|
|
|
* @brief getInfo 查询所有应用的多个属性
|
|
|
|
* @param property
|
|
|
|
* @return
|
|
|
|
*/
|
2023-03-15 16:39:38 +08:00
|
|
|
ApplicationInfoMap getInfo(ApplicationProperties properties);
|
2023-03-07 17:33:08 +08:00
|
|
|
|
2023-03-14 14:01:28 +08:00
|
|
|
/**
|
|
|
|
* @brief ApplicationInfo::getInfo
|
|
|
|
* get the application info that meets the restrictions
|
|
|
|
* @param restrictions: The restrictions that the search results should meet(e.g. u want get the app infos whose top state is 0)
|
|
|
|
* @param properties: Each application's information should contain these properties
|
|
|
|
* @return ApplicationInfoMap: the search result
|
|
|
|
*/
|
2023-03-15 16:39:38 +08:00
|
|
|
ApplicationInfoMap getInfo(ApplicationProperties properties, ApplicationPropertyMap restrictions);
|
2023-03-14 14:01:28 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ApplicationInfo::searchApp
|
|
|
|
* @param keyWord: the keyword of this search for applications
|
|
|
|
* @param installAppInfoRes: the search results of applications
|
|
|
|
* @return ApplicationInfoMap: the search result
|
|
|
|
*/
|
2023-03-15 16:39:38 +08:00
|
|
|
ApplicationInfoMap searchApp(ApplicationProperties properties, const QString &keyword, ApplicationPropertyMap restrictions);
|
|
|
|
ApplicationInfoMap searchApp(ApplicationProperties properties, const QStringList &keywords, ApplicationPropertyMap restrictions);
|
2023-03-14 14:01:28 +08:00
|
|
|
|
|
|
|
/**
|
2023-03-31 17:24:06 +08:00
|
|
|
* @brief AppInfoTable::setAppToFavorites
|
|
|
|
* set the app to favorites apps(default is at 1)
|
|
|
|
* @param desktopfp: the desktop file path of app
|
2023-03-14 14:01:28 +08:00
|
|
|
*/
|
2023-03-31 17:24:06 +08:00
|
|
|
void setAppToFavorites(const QString &desktopFilePath);
|
2023-03-14 14:01:28 +08:00
|
|
|
|
|
|
|
/**
|
2023-03-31 17:24:06 +08:00
|
|
|
* @brief AppInfoTable::setFavoritesTo
|
|
|
|
* set the favorites state of the app to num, you can also use to change the position of the app which is one of the Favorites Apps
|
|
|
|
* @param desktopfp: the desktop file path of app
|
|
|
|
* @param num: the favorites app's position(from 1). If num is 0, it will remove the app from the favorites apps
|
2023-03-14 14:01:28 +08:00
|
|
|
*/
|
2023-03-31 17:24:06 +08:00
|
|
|
void setFavoritesOfApp(const QString &desktopFilePath, size_t num);
|
2023-03-14 14:01:28 +08:00
|
|
|
|
|
|
|
/**
|
2023-03-31 17:24:06 +08:00
|
|
|
* @brief AppInfoTable::setAppToTop
|
|
|
|
* set the app to top apps(default is at 1)
|
|
|
|
* @param desktopfp: desktop file path of app
|
2023-03-14 14:01:28 +08:00
|
|
|
*/
|
2023-03-31 17:24:06 +08:00
|
|
|
void setAppToTop(const QString &desktopFilePath);
|
2023-03-14 14:01:28 +08:00
|
|
|
|
|
|
|
/**
|
2023-03-31 17:24:06 +08:00
|
|
|
* @brief AppInfoTable::setAppTopTo
|
|
|
|
* set the top state of the app to num, you can also use to change the position of the app which is one of the Top Apps
|
|
|
|
* @param desktopfp: the desktop file path of app
|
|
|
|
* @param num: the top app's position(from 1). If num is 0, it will remove the app from the top apps
|
2023-03-14 14:01:28 +08:00
|
|
|
*/
|
2023-03-31 17:24:06 +08:00
|
|
|
void setTopOfApp(const QString &desktopFilePath, size_t num);
|
2023-03-14 14:01:28 +08:00
|
|
|
|
2023-04-14 13:45:05 +08:00
|
|
|
void setAppLaunchedState(const QString &desktopFilePath, bool launched = true);
|
|
|
|
|
2023-03-14 14:01:28 +08:00
|
|
|
/**
|
|
|
|
* @brief ApplicationInfo::tranPid2DesktopFp
|
|
|
|
* find the desktop file path of the process which corresponds to the pid
|
|
|
|
* @param pid: the pid of the process which need to get its desktop file path
|
|
|
|
* @param desktopFilePath: the desktop file path of the process corresponding to pid
|
|
|
|
* @return bool:true if success,else false
|
|
|
|
*/
|
2023-04-17 16:14:44 +08:00
|
|
|
bool tranPidToDesktopFp(int pid, QString &desktopFilePath);//obsolete
|
|
|
|
bool tranPidToDesktopFp(uint pid, QString &desktopFilePath);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ApplicationInfo::desktopFilePathFromName
|
|
|
|
* find the desktop file path of the process which corresponds to the desktop file name (without .desktop)
|
|
|
|
* @param desktopFileName: the desktop file name of the process which need to get its desktop file path
|
|
|
|
* @param desktopFilePath: the desktop file path of the process corresponding to pid
|
|
|
|
* @return bool:true if success,else false
|
|
|
|
*/
|
|
|
|
bool desktopFilePathFromName(const QString &desktopFileName, QString &desktopFilePath);
|
2023-03-14 14:01:28 +08:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void DBOpenFailed();
|
|
|
|
void appDBItems2BUpdate(ApplicationInfoMap);
|
|
|
|
void appDBItems2BUpdateAll(QStringList);
|
|
|
|
void appDBItems2BAdd(QStringList);
|
|
|
|
void appDBItems2BDelete(QStringList);
|
2023-03-07 17:33:08 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
ApplicationInfoPrivate *d = nullptr;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif // APPLICATIONINFO_H
|