From 71a42aaa82f72b1dec5a5a835e7d221777207268 Mon Sep 17 00:00:00 2001 From: youdiansaodongxi Date: Fri, 21 Apr 2023 13:41:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=97=B6=E5=86=97=E4=BD=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdata/plugin/all-app-data-provider.cpp | 18 ++++++++++++++++-- src/appdata/plugin/all-app-data-provider.h | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/appdata/plugin/all-app-data-provider.cpp b/src/appdata/plugin/all-app-data-provider.cpp index a75f8a2..9ba77c9 100644 --- a/src/appdata/plugin/all-app-data-provider.cpp +++ b/src/appdata/plugin/all-app-data-provider.cpp @@ -136,6 +136,21 @@ void AllAppDataProvider::mergeData(QVector &data) data.append(m_appData); } +void AllAppDataProvider::updateData(const QList &apps) +{ + QMutexLocker locker(&m_mutex); + for (const DataEntity & app : apps) { + for (DataEntity & appdata : m_appData) { + if (appdata.id() == app.id()) { + appdata = app; + setRecentState(appdata); + break; + } + } + } + std::sort(m_appData.begin(), m_appData.end(), appDataSort); +} + bool AllAppDataProvider::appDataSort(const DataEntity &a, const DataEntity &b) { if ((a.top() != 0) && (b.top() != 0)) { @@ -221,8 +236,7 @@ void AllAppDataProvider::removeApps(QStringList &idList) void AllAppDataProvider::onAppUpdated(const QList& apps) { - Q_UNUSED(apps); - reloadAppData(); + updateData(apps); sendData(); } diff --git a/src/appdata/plugin/all-app-data-provider.h b/src/appdata/plugin/all-app-data-provider.h index 4e81c1f..8b5f190 100644 --- a/src/appdata/plugin/all-app-data-provider.h +++ b/src/appdata/plugin/all-app-data-provider.h @@ -52,6 +52,7 @@ private: void reloadAppData(); void reloadFolderData(); void mergeData(QVector &data); + void updateData(const QList& apps); static bool appDataSort(const DataEntity &a, const DataEntity &b); static void setRecentState(DataEntity &app);