更新使用的文件夹接口

This commit is contained in:
hewenfei 2023-03-30 15:27:15 +08:00
parent afabcfd593
commit 218ffacbfe
1 changed files with 14 additions and 7 deletions

View File

@ -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<DataEntity> appData;
QList<DataEntity> 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<DataEntity> folderData;
QList<Folder> 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<DataEntity> &data)