From c0639b8845e5dfa7e8994c66223f8193d8b2b0c7 Mon Sep 17 00:00:00 2001 From: youdiansaodongxi Date: Thu, 16 May 2024 19:49:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(libappdata):=20=E7=AC=AC=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E6=97=B6=E4=B8=8D=E6=98=BE=E7=A4=BA=E6=9C=80?= =?UTF-8?q?=E8=BF=91=E5=AE=89=E8=A3=85=E5=BA=94=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libappdata/basic-app-model.cpp | 2 ++ src/libappdata/recently-installed-model.cpp | 5 +++++ src/settings/user-config.cpp | 7 +++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/libappdata/basic-app-model.cpp b/src/libappdata/basic-app-model.cpp index 0c4662e..16da5ed 100644 --- a/src/libappdata/basic-app-model.cpp +++ b/src/libappdata/basic-app-model.cpp @@ -19,6 +19,7 @@ */ #include "basic-app-model.h" +#include "user-config.h" #include @@ -149,6 +150,7 @@ void BasicAppModel::onAppUpdated(const QVector > void BasicAppModel::onAppDeleted(const QStringList &apps) { for (const auto &appid : apps) { + UserConfig::instance()->removePreInstalledApp(appid); int index = indexOfApp(appid); if (index < 0) { continue; diff --git a/src/libappdata/recently-installed-model.cpp b/src/libappdata/recently-installed-model.cpp index 006fbb8..981a500 100644 --- a/src/libappdata/recently-installed-model.cpp +++ b/src/libappdata/recently-installed-model.cpp @@ -20,6 +20,7 @@ #include "recently-installed-model.h" #include "basic-app-model.h" +#include "user-config.h" #include #include @@ -44,6 +45,10 @@ RecentlyInstalledModel::RecentlyInstalledModel(QObject *parent) : QSortFilterPro bool RecentlyInstalledModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { QModelIndex sourceIndex = sourceModel()->index(source_row, 0, source_parent); + // 是否为预装应用 + if (UserConfig::instance()->isPreInstalledApps(sourceIndex.data(DataEntity::Id).toString())) { + return false; + } // 是否打开过 if (sourceIndex.data(DataEntity::IsLaunched).toInt() != 0) { return false; diff --git a/src/settings/user-config.cpp b/src/settings/user-config.cpp index de211a9..9bc8a52 100644 --- a/src/settings/user-config.cpp +++ b/src/settings/user-config.cpp @@ -111,8 +111,11 @@ bool UserConfig::isPreInstalledApps(const QString &appid) const void UserConfig::removePreInstalledApp(const QString &appid) { - QMutexLocker mutexLocker(&m_mutex); - m_preInstalledApps.remove(appid); + { + QMutexLocker mutexLocker(&m_mutex); + m_preInstalledApps.remove(appid); + } + sync(); } void UserConfig::readConfigFile()