forked from openkylin/ukui-menu
修改数据更新时冗余的问题
This commit is contained in:
parent
50e26f8676
commit
71a42aaa82
|
@ -136,6 +136,21 @@ void AllAppDataProvider::mergeData(QVector<DataEntity> &data)
|
|||
data.append(m_appData);
|
||||
}
|
||||
|
||||
void AllAppDataProvider::updateData(const QList<DataEntity> &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<DataEntity>& apps)
|
||||
{
|
||||
Q_UNUSED(apps);
|
||||
reloadAppData();
|
||||
updateData(apps);
|
||||
sendData();
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ private:
|
|||
void reloadAppData();
|
||||
void reloadFolderData();
|
||||
void mergeData(QVector<DataEntity> &data);
|
||||
void updateData(const QList<DataEntity>& apps);
|
||||
static bool appDataSort(const DataEntity &a, const DataEntity &b);
|
||||
static void setRecentState(DataEntity &app);
|
||||
|
||||
|
|
Loading…
Reference in New Issue