fix(full-screen): 修复全屏应用列表在安装或卸载应用时列表错乱问题,优化model删除操作
This commit is contained in:
parent
f643dd14df
commit
7f2785c5bb
|
@ -76,7 +76,13 @@ ListView {
|
||||||
|
|
||||||
model: DelegateModel {
|
model: DelegateModel {
|
||||||
model: appGroupModel
|
model: appGroupModel
|
||||||
rootIndex: modelIndex(index)
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
// Warning: rootIndex只需要设置一次,多次设置会导致对应关系错误,
|
||||||
|
// delegateModel使用persistedIndex保存rootIndex,会自动进行修正
|
||||||
|
rootIndex = modelIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
width: GridView.view.cellWidth
|
width: GridView.view.cellWidth
|
||||||
height: GridView.view.cellHeight
|
height: GridView.view.cellHeight
|
||||||
|
|
|
@ -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);
|
beginRemoveRows(index(groupIndex, 0, QModelIndex()), itemIndex, itemIndex);
|
||||||
subItems->removeAt(itemIndex);
|
subItems->removeAt(itemIndex);
|
||||||
endRemoveRows();
|
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();
|
||||||
|
|
Loading…
Reference in New Issue