更新使用的文件夹接口
This commit is contained in:
parent
afabcfd593
commit
218ffacbfe
|
@ -32,6 +32,8 @@ AllAppDataProvider::AllAppDataProvider() : DataProviderPluginIFace()
|
||||||
connect(AppDataManager::instance(), &AppDataManager::appAdded, this, &AllAppDataProvider::onAppAdded);
|
connect(AppDataManager::instance(), &AppDataManager::appAdded, this, &AllAppDataProvider::onAppAdded);
|
||||||
connect(AppDataManager::instance(), &AppDataManager::appDeleted, this, &AllAppDataProvider::onAppDeleted);
|
connect(AppDataManager::instance(), &AppDataManager::appDeleted, this, &AllAppDataProvider::onAppDeleted);
|
||||||
connect(AppDataManager::instance(), &AppDataManager::appUpdated, this, &AllAppDataProvider::onAppUpdated);
|
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);
|
connect(AppFolderHelper::instance(), &AppFolderHelper::folderDataChanged, this, &AllAppDataProvider::onAppFolderChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,33 +84,36 @@ void AllAppDataProvider::forceUpdate()
|
||||||
void AllAppDataProvider::reloadAppData()
|
void AllAppDataProvider::reloadAppData()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
m_appData.clear();
|
QVector<DataEntity> appData;
|
||||||
|
|
||||||
QList<DataEntity> apps = AppDataManager::instance()->normalApps();
|
QList<DataEntity> apps = AppDataManager::instance()->normalApps();
|
||||||
if (apps.isEmpty()) {
|
if (apps.isEmpty()) {
|
||||||
|
m_appData.swap(appData);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Folder folder;
|
|
||||||
for (const auto &app : apps) {
|
for (const auto &app : apps) {
|
||||||
if (AppFolderHelper::instance()->searchFolderByAppName(app.id(), folder)) {
|
if (AppFolderHelper::instance()->containApp(app.id())) {
|
||||||
continue;
|
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());
|
return (a.top() > b.top()) || (a.launchTimes() > b.launchTimes());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
m_appData.swap(appData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AllAppDataProvider::reloadFolderData()
|
void AllAppDataProvider::reloadFolderData()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
m_folderData.clear();
|
QVector<DataEntity> folderData;
|
||||||
|
|
||||||
QList<Folder> folders = AppFolderHelper::instance()->folderData();
|
QList<Folder> folders = AppFolderHelper::instance()->folderData();
|
||||||
if (folders.isEmpty()) {
|
if (folders.isEmpty()) {
|
||||||
|
m_folderData.swap(folderData);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,8 +124,10 @@ void AllAppDataProvider::reloadFolderData()
|
||||||
folderItem.setIcon("image://appicon/text-plain");
|
folderItem.setIcon("image://appicon/text-plain");
|
||||||
folderItem.setName(folder.getName());
|
folderItem.setName(folder.getName());
|
||||||
|
|
||||||
m_folderData.append(folderItem);
|
folderData.append(folderItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_folderData.swap(folderData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AllAppDataProvider::mergeData(QVector<DataEntity> &data)
|
void AllAppDataProvider::mergeData(QVector<DataEntity> &data)
|
||||||
|
|
Loading…
Reference in New Issue