fix(favorite):修复应用更新信息后,收藏区域不刷新问题
This commit is contained in:
parent
a6bbbd3cce
commit
f62d0dc8fb
|
@ -91,9 +91,21 @@ void AppFavoritesModel::getFavoritesApps()
|
||||||
|
|
||||||
void AppFavoritesModel::onAppUpdated(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
|
void AppFavoritesModel::onAppUpdated(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
|
||||||
{
|
{
|
||||||
for (const auto &role : roles) {
|
// 更新全部信息
|
||||||
if (role == DataEntity::Favorite) {
|
if (roles.isEmpty()) {
|
||||||
updateFavoritesApps(m_sourceModel->appOfIndex(topLeft.row()), topLeft);
|
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()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,7 +258,9 @@ void AppDatabaseWorkerPrivate::onAppDatabaseUpdate(const UkuiSearch::Application
|
||||||
updates.append({app, roles});
|
updates.append({app, roles});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!updates.isEmpty()) {
|
||||||
Q_EMIT q->appUpdated(updates);
|
Q_EMIT q->appUpdated(updates);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppDatabaseWorkerPrivate::onAppDatabaseDeleted(const QStringList &infos)
|
void AppDatabaseWorkerPrivate::onAppDatabaseDeleted(const QStringList &infos)
|
||||||
|
|
Loading…
Reference in New Issue