diff --git a/src/extension/favorite/app-favorite-model.cpp b/src/extension/favorite/app-favorite-model.cpp index 132f509..aaea837 100644 --- a/src/extension/favorite/app-favorite-model.cpp +++ b/src/extension/favorite/app-favorite-model.cpp @@ -91,9 +91,21 @@ void AppFavoritesModel::getFavoritesApps() void AppFavoritesModel::onAppUpdated(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles) { - for (const auto &role : roles) { - if (role == DataEntity::Favorite) { - updateFavoritesApps(m_sourceModel->appOfIndex(topLeft.row()), topLeft); + // 更新全部信息 + if (roles.isEmpty()) { + QPersistentModelIndex topLeftIndex(topLeft); + QPersistentModelIndex bottomRightIndex(bottomRight); + + int leftIndex = m_favoritesApps.indexOf(topLeftIndex); + int rightIndex = m_favoritesApps.indexOf(topLeftIndex); + + Q_EMIT dataChanged(index(leftIndex, 0, QModelIndex()), index(rightIndex, 0, QModelIndex())); + // 更新某一项信息 + } else { + for (int row = topLeft.row(); row <= bottomRight.row(); row ++) { + if (roles.contains(DataEntity::Favorite) ) { + updateFavoritesApps(m_sourceModel->appOfIndex(row), m_sourceModel->index(row, 0, QModelIndex())); + } } } } diff --git a/src/libappdata/app-database-interface.cpp b/src/libappdata/app-database-interface.cpp index c36d7e7..6526f59 100644 --- a/src/libappdata/app-database-interface.cpp +++ b/src/libappdata/app-database-interface.cpp @@ -258,7 +258,9 @@ void AppDatabaseWorkerPrivate::onAppDatabaseUpdate(const UkuiSearch::Application updates.append({app, roles}); } - Q_EMIT q->appUpdated(updates); + if (!updates.isEmpty()) { + Q_EMIT q->appUpdated(updates); + } } void AppDatabaseWorkerPrivate::onAppDatabaseDeleted(const QStringList &infos)