From 218ffacbfe2c2fc4caecf692482aec1202e4f201 Mon Sep 17 00:00:00 2001 From: hewenfei Date: Thu, 30 Mar 2023 15:27:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BD=BF=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/appdata/plugin/all-app-data-provider.cpp | 21 +++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/appdata/plugin/all-app-data-provider.cpp b/src/appdata/plugin/all-app-data-provider.cpp index d00c2f3..591d073 100644 --- a/src/appdata/plugin/all-app-data-provider.cpp +++ b/src/appdata/plugin/all-app-data-provider.cpp @@ -32,6 +32,8 @@ AllAppDataProvider::AllAppDataProvider() : DataProviderPluginIFace() connect(AppDataManager::instance(), &AppDataManager::appAdded, this, &AllAppDataProvider::onAppAdded); connect(AppDataManager::instance(), &AppDataManager::appDeleted, this, &AllAppDataProvider::onAppDeleted); connect(AppDataManager::instance(), &AppDataManager::appUpdated, this, &AllAppDataProvider::onAppUpdated); + connect(AppFolderHelper::instance(), &AppFolderHelper::folderAdded, this, &AllAppDataProvider::onAppFolderChanged); + connect(AppFolderHelper::instance(), &AppFolderHelper::folderDeleted, this, &AllAppDataProvider::onAppFolderChanged); connect(AppFolderHelper::instance(), &AppFolderHelper::folderDataChanged, this, &AllAppDataProvider::onAppFolderChanged); } @@ -82,33 +84,36 @@ void AllAppDataProvider::forceUpdate() void AllAppDataProvider::reloadAppData() { QMutexLocker locker(&m_mutex); - m_appData.clear(); + QVector appData; QList apps = AppDataManager::instance()->normalApps(); if (apps.isEmpty()) { + m_appData.swap(appData); return; } - Folder folder; for (const auto &app : apps) { - if (AppFolderHelper::instance()->searchFolderByAppName(app.id(), folder)) { + if (AppFolderHelper::instance()->containApp(app.id())) { continue; } - m_appData.append(app); + appData.append(app); } - std::sort(m_appData.begin(), m_appData.end(), [](const DataEntity &a, const DataEntity &b) { + std::sort(appData.begin(), appData.end(), [](const DataEntity &a, const DataEntity &b) { return (a.top() > b.top()) || (a.launchTimes() > b.launchTimes()); }); + + m_appData.swap(appData); } void AllAppDataProvider::reloadFolderData() { QMutexLocker locker(&m_mutex); - m_folderData.clear(); + QVector folderData; QList folders = AppFolderHelper::instance()->folderData(); if (folders.isEmpty()) { + m_folderData.swap(folderData); return; } @@ -119,8 +124,10 @@ void AllAppDataProvider::reloadFolderData() folderItem.setIcon("image://appicon/text-plain"); folderItem.setName(folder.getName()); - m_folderData.append(folderItem); + folderData.append(folderItem); } + + m_folderData.swap(folderData); } void AllAppDataProvider::mergeData(QVector &data)