Fix the problem that the DONT_DISPLAY field is null in database.

This commit is contained in:
JunjieBai 2023-03-22 15:47:27 +08:00 committed by iaom
parent 00631cc1e5
commit f385302b05
4 changed files with 11 additions and 7 deletions

View File

@ -80,7 +80,7 @@ AppDBManager::AppDBManager(QObject *parent) : QThread(parent), m_database(QSqlDa
QStringList appPaths; QStringList appPaths;
appPaths << GENERAL_APP_DESKTOP_PATH << ANDROID_APP_DESKTOP_PATH appPaths << GENERAL_APP_DESKTOP_PATH << ANDROID_APP_DESKTOP_PATH
<< SNAPD_APP_DESKTOP_PATH << AUTOSTART_APP_DESKTOP_PATH; << SNAPD_APP_DESKTOP_PATH << AUTOSTART_APP_DESKTOP_PATH;
refreshAllData2DB(appPaths); refreshAllData2DB(appPaths, m_dbVersionNeedUpdate);
if (m_dbVersionNeedUpdate) { if (m_dbVersionNeedUpdate) {
m_dbVersionQsettings->beginGroup(APP_DATABASE_VERSION_VALUE); m_dbVersionQsettings->beginGroup(APP_DATABASE_VERSION_VALUE);
@ -363,11 +363,12 @@ bool AppDBManager::addItem2BackIfNotExist(QString itemName, QString itemDataType
return res; return res;
} }
void AppDBManager::refreshAllData2DB(const QStringList &appPaths) void AppDBManager::refreshAllData2DB(const QStringList &appPaths, bool dbVersionNeedUpdate)
{ {
PendingAppInfo items; PendingAppInfo items;
items.setHandleType(PendingAppInfo::RefreshDataBase); items.setHandleType(PendingAppInfo::RefreshDataBase);
items.setPathsNeedRefreshData(appPaths); items.setPathsNeedRefreshData(appPaths);
items.setDBUpdate(dbVersionNeedUpdate);
PendingAppInfoQueue::getAppInfoQueue().enqueue(items); PendingAppInfoQueue::getAppInfoQueue().enqueue(items);
} }
@ -869,7 +870,7 @@ bool AppDBManager::handleLockStateUpdate(const QString &desktopFilePath, int num
return res; return res;
} }
void AppDBManager::handleDataBaseRefresh(const QStringList &appPaths) void AppDBManager::handleDataBaseRefresh(const QStringList &appPaths, bool dbVersionNeedUpdate)
{ {
QMap<QString, QString> dataMap; QMap<QString, QString> dataMap;
QSqlQuery query(m_database); QSqlQuery query(m_database);
@ -925,7 +926,7 @@ void AppDBManager::handleDataBaseRefresh(const QStringList &appPaths)
if (!dataMap.isEmpty()) { if (!dataMap.isEmpty()) {
//数据库有记录 //数据库有记录
if (dataMap.contains(path)) { if (dataMap.contains(path)) {
if (!QString::compare(dataMap.value(path), getAppDesktopMd5(path)) && !m_dbVersionNeedUpdate) { if (!QString::compare(dataMap.value(path), getAppDesktopMd5(path)) && !dbVersionNeedUpdate) {
//判断系统语言是否改变 //判断系统语言是否改变
if (m_localeChanged) { if (m_localeChanged) {
this->handleLocaleDataUpdate(path); this->handleLocaleDataUpdate(path);

View File

@ -42,7 +42,7 @@ public:
static AppDBManager *getInstance(); static AppDBManager *getInstance();
//刷新数据库数据 //刷新数据库数据
void refreshAllData2DB(const QStringList &appPaths); void refreshAllData2DB(const QStringList &appPaths, bool dbVersionNeedUpdate = false);
//获取desktop文件的md5值 //获取desktop文件的md5值
QString getAppDesktopMd5(const QString &desktopfd); QString getAppDesktopMd5(const QString &desktopfd);
@ -59,7 +59,7 @@ public:
bool handleFavoritesStateUpdate(const QString &desktopFilePath, int num, bool isOrderChanged = false); bool handleFavoritesStateUpdate(const QString &desktopFilePath, int num, bool isOrderChanged = false);
bool handleTopStateUpdate(const QString &desktopFilePath, int num, bool isOrderChanged = false); bool handleTopStateUpdate(const QString &desktopFilePath, int num, bool isOrderChanged = false);
bool handleLockStateUpdate(const QString &desktopFilePath, int num); bool handleLockStateUpdate(const QString &desktopFilePath, int num);
void handleDataBaseRefresh(const QStringList &appPaths); void handleDataBaseRefresh(const QStringList &appPaths, bool dbVersionNeedUpdate);
public Q_SLOTS: public Q_SLOTS:
//通过pid查找对应的desktop文件 //通过pid查找对应的desktop文件

View File

@ -146,7 +146,7 @@ void PendingAppInfoQueue::processCache()
AppDBManager::getInstance()->handleLocaleDataUpdate(info.path()); AppDBManager::getInstance()->handleLocaleDataUpdate(info.path());
break; break;
case PendingAppInfo::RefreshDataBase: case PendingAppInfo::RefreshDataBase:
AppDBManager::getInstance()->handleDataBaseRefresh(info.pathsNeedRefreshData()); AppDBManager::getInstance()->handleDataBaseRefresh(info.pathsNeedRefreshData(), info.dbVersionNeedUpdate());
break; break;
default: default:
break; break;

View File

@ -48,6 +48,7 @@ public:
bool willAddLunchTimes() const {return m_willAddLaunch;} bool willAddLunchTimes() const {return m_willAddLaunch;}
bool isFavoritePosChanged() const {return m_isFavoritePosChanged;} bool isFavoritePosChanged() const {return m_isFavoritePosChanged;}
bool isTopPosChanged() const {return m_isTopPosChanged;} bool isTopPosChanged() const {return m_isTopPosChanged;}
bool dbVersionNeedUpdate() const {return m_dbVersionNeedUpdate;}
void setDesktopFp(const QString& desktopfp) {m_desktopfp = desktopfp;} void setDesktopFp(const QString& desktopfp) {m_desktopfp = desktopfp;}
void setHandleType(const PendingAppInfo& info) {m_handleType = info.handleType();} void setHandleType(const PendingAppInfo& info) {m_handleType = info.handleType();}
@ -60,6 +61,7 @@ public:
void setChangeFavoritePos(bool isOrderChanged) {m_isFavoritePosChanged = isOrderChanged;} void setChangeFavoritePos(bool isOrderChanged) {m_isFavoritePosChanged = isOrderChanged;}
void setChangeTopPos(bool isOrderChanged) {m_isTopPosChanged = isOrderChanged;} void setChangeTopPos(bool isOrderChanged) {m_isTopPosChanged = isOrderChanged;}
void setPathsNeedRefreshData (const QStringList& paths) {m_pathsNeedRefreshData = paths;} void setPathsNeedRefreshData (const QStringList& paths) {m_pathsNeedRefreshData = paths;}
void setDBUpdate(bool versionNeedUpdate) {m_dbVersionNeedUpdate = versionNeedUpdate;}
void merge(const PendingAppInfo& info) void merge(const PendingAppInfo& info)
{ {
m_handleType |= info.handleType(); m_handleType |= info.handleType();
@ -94,6 +96,7 @@ private:
bool m_isFavoritePosChanged = false; bool m_isFavoritePosChanged = false;
bool m_isTopPosChanged = false; bool m_isTopPosChanged = false;
QStringList m_pathsNeedRefreshData; QStringList m_pathsNeedRefreshData;
bool m_dbVersionNeedUpdate = false;
}; };
} }