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/>.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2022-10-21 11:21:35 +08:00
|
|
|
#ifndef PENDINGAPPINFO_H
|
|
|
|
#define PENDINGAPPINFO_H
|
|
|
|
|
|
|
|
#include <QString>
|
2023-03-15 11:32:42 +08:00
|
|
|
#include <QStringList>
|
2022-10-21 11:21:35 +08:00
|
|
|
#include <QFlags>
|
|
|
|
|
|
|
|
namespace UkuiSearch {
|
|
|
|
|
|
|
|
class PendingAppInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum HandleType{
|
|
|
|
Delete = 0,
|
|
|
|
Insert = 1u,
|
|
|
|
UpdateAll = 1u << 1,
|
|
|
|
UpdateLocaleData = 1u << 2,
|
|
|
|
UpdateLaunchTimes = 1u << 3,
|
|
|
|
UpdateFavorites = 1u << 4,
|
|
|
|
UpdateTop = 1u << 5,
|
2023-03-15 11:32:42 +08:00
|
|
|
UpdateLock = 1u << 6,
|
|
|
|
RefreshDataBase = 1u << 7
|
2022-10-21 11:21:35 +08:00
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(HandleTypes, HandleType)
|
|
|
|
|
|
|
|
PendingAppInfo() = default;
|
2023-02-15 17:17:11 +08:00
|
|
|
PendingAppInfo(QString desktopfp, HandleTypes type,
|
|
|
|
int favorites = -1, int top = -1, int lock = -1,
|
2023-03-31 17:24:06 +08:00
|
|
|
bool addLaunch = false, int launchTimes = 0)
|
2022-10-21 11:21:35 +08:00
|
|
|
: m_desktopfp(desktopfp),
|
|
|
|
m_handleType(type),
|
|
|
|
m_favoritesState(favorites),
|
|
|
|
m_topState(top),
|
|
|
|
m_lockState(lock),
|
|
|
|
m_willAddLaunch(addLaunch),
|
2023-03-31 17:24:06 +08:00
|
|
|
m_launchTimes(launchTimes) {}
|
2022-10-21 11:21:35 +08:00
|
|
|
|
|
|
|
QString path() const {return m_desktopfp;}
|
2023-03-15 11:32:42 +08:00
|
|
|
QStringList pathsNeedRefreshData() const {return m_pathsNeedRefreshData;}
|
2022-10-21 11:21:35 +08:00
|
|
|
HandleTypes handleType() const {return m_handleType;}
|
|
|
|
int favoritesState() const {return m_favoritesState;}
|
|
|
|
int topState() const {return m_topState;}
|
|
|
|
int lockState() const {return m_lockState;}
|
|
|
|
int launchTimes() const {return m_launchTimes;}
|
|
|
|
bool willAddLunchTimes() const {return m_willAddLaunch;}
|
2023-03-22 15:47:27 +08:00
|
|
|
bool dbVersionNeedUpdate() const {return m_dbVersionNeedUpdate;}
|
2022-10-21 11:21:35 +08:00
|
|
|
|
2023-02-15 17:17:11 +08:00
|
|
|
void setDesktopFp(const QString& desktopfp) {m_desktopfp = desktopfp;}
|
|
|
|
void setHandleType(const PendingAppInfo& info) {m_handleType = info.handleType();}
|
2022-10-21 11:21:35 +08:00
|
|
|
void setHandleType(HandleTypes type) {m_handleType = type;}
|
|
|
|
void setFavorites(int favoritesState) {m_favoritesState = favoritesState;}
|
|
|
|
void setTop(int top) {m_topState = top;}
|
|
|
|
void setLock(int lock) {m_lockState = lock;}
|
|
|
|
void setLaunchWillAdd(bool willAdd) {m_willAddLaunch = willAdd;}
|
|
|
|
void setLaunchTimes(int times) {m_launchTimes = times;}
|
2023-03-15 11:32:42 +08:00
|
|
|
void setPathsNeedRefreshData (const QStringList& paths) {m_pathsNeedRefreshData = paths;}
|
2023-03-22 15:47:27 +08:00
|
|
|
void setDBUpdate(bool versionNeedUpdate) {m_dbVersionNeedUpdate = versionNeedUpdate;}
|
2023-02-15 17:17:11 +08:00
|
|
|
void merge(const PendingAppInfo& info)
|
2022-10-21 11:21:35 +08:00
|
|
|
{
|
|
|
|
m_handleType |= info.handleType();
|
|
|
|
|
|
|
|
if (info.favoritesState() != -1) {
|
|
|
|
m_favoritesState = info.favoritesState();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info.topState() != -1) {
|
|
|
|
m_topState = info.topState();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info.lockState() != -1) {
|
|
|
|
m_lockState = info.lockState();
|
|
|
|
}
|
|
|
|
if (info.willAddLunchTimes()) {
|
|
|
|
m_launchTimes++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator ==(const PendingAppInfo& rhs) const {
|
|
|
|
return (m_desktopfp == rhs.m_desktopfp);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
QString m_desktopfp;
|
|
|
|
HandleTypes m_handleType;
|
2023-02-15 17:17:11 +08:00
|
|
|
int m_favoritesState = -1;
|
|
|
|
int m_topState = -1;
|
|
|
|
int m_lockState = -1;
|
|
|
|
bool m_willAddLaunch = false;
|
|
|
|
int m_launchTimes = 0;
|
2023-03-15 11:32:42 +08:00
|
|
|
QStringList m_pathsNeedRefreshData;
|
2023-03-22 15:47:27 +08:00
|
|
|
bool m_dbVersionNeedUpdate = false;
|
2022-10-21 11:21:35 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(UkuiSearch::PendingAppInfo::HandleTypes)
|
|
|
|
|
|
|
|
#endif // PENDINGAPPINFO_H
|