diff --git a/qml/AppUI/FullScreenAppList.qml b/qml/AppUI/FullScreenAppList.qml index 266f43f..16efd9d 100644 --- a/qml/AppUI/FullScreenAppList.qml +++ b/qml/AppUI/FullScreenAppList.qml @@ -76,7 +76,13 @@ ListView { model: DelegateModel { model: appGroupModel - rootIndex: modelIndex(index) + + Component.onCompleted: { + // Warning: rootIndex只需要设置一次,多次设置会导致对应关系错误, + // delegateModel使用persistedIndex保存rootIndex,会自动进行修正 + rootIndex = modelIndex(index); + } + delegate: Item { width: GridView.view.cellWidth height: GridView.view.cellHeight diff --git a/src/libappdata/app-group-model.cpp b/src/libappdata/app-group-model.cpp index 4dbb0d4..07fb317 100644 --- a/src/libappdata/app-group-model.cpp +++ b/src/libappdata/app-group-model.cpp @@ -340,13 +340,13 @@ void AppGroupModel::onRowsAboutToBeRemoved(const QModelIndex &parent, int first, break; } - // 删除组里的元素 - beginRemoveRows(index(groupIndex, 0, QModelIndex()), itemIndex, itemIndex); - subItems->removeAt(itemIndex); - endRemoveRows(); - - // 删除组 - if (subItems->isEmpty()) { + if (subItems->size() > 1) { + // 删除组里的元素 + beginRemoveRows(index(groupIndex, 0, QModelIndex()), itemIndex, itemIndex); + subItems->removeAt(itemIndex); + endRemoveRows(); + } else { + // 删除组 beginRemoveRows(QModelIndex(), groupIndex, groupIndex); delete m_groups.takeAt(groupIndex); endRemoveRows();