fix(full-screen): 修复全屏应用列表在安装或卸载应用时列表错乱问题,优化model删除操作

This commit is contained in:
hewenfei 2024-06-13 14:11:54 +08:00 committed by He Sir
parent f643dd14df
commit 7f2785c5bb
2 changed files with 14 additions and 8 deletions

View File

@ -76,7 +76,13 @@ ListView {
model: DelegateModel { model: DelegateModel {
model: appGroupModel model: appGroupModel
rootIndex: modelIndex(index)
Component.onCompleted: {
// Warning: rootIndex
// delegateModel使persistedIndexrootIndex
rootIndex = modelIndex(index);
}
delegate: Item { delegate: Item {
width: GridView.view.cellWidth width: GridView.view.cellWidth
height: GridView.view.cellHeight height: GridView.view.cellHeight

View File

@ -340,13 +340,13 @@ void AppGroupModel::onRowsAboutToBeRemoved(const QModelIndex &parent, int first,
break; break;
} }
// 删除组里的元素 if (subItems->size() > 1) {
beginRemoveRows(index(groupIndex, 0, QModelIndex()), itemIndex, itemIndex); // 删除组里的元素
subItems->removeAt(itemIndex); beginRemoveRows(index(groupIndex, 0, QModelIndex()), itemIndex, itemIndex);
endRemoveRows(); subItems->removeAt(itemIndex);
endRemoveRows();
// 删除组 } else {
if (subItems->isEmpty()) { // 删除组
beginRemoveRows(QModelIndex(), groupIndex, groupIndex); beginRemoveRows(QModelIndex(), groupIndex, groupIndex);
delete m_groups.takeAt(groupIndex); delete m_groups.takeAt(groupIndex);
endRemoveRows(); endRemoveRows();