Skip to content

Commit 6ba8fbf

Browse files
wjyrichdeepin-bot[bot]
authored andcommitted
fix: reset view position on category type change
1. Added Connections in AppListView.qml to reset list position when category type changes 2. Modified CategorizedSortProxyModel.cpp to properly emit signals and reset model 3. Now emits categoryTypeChanged after model reset and sorting completes 4. Ensures consistent view behavior when switching between different category types fix: 类别类型更改时重置视图位置 1. 在 AppListView.qml 中添加连接,当类别类型改变时重置列表位置 2. 修改 CategorizedSortProxyModel.cpp 以正确发出信号并重置模型 3. 现在在模型重置和排序完成后发出 categoryTypeChanged 信号 4. 确保在不同类别类型之间切换时视图行为一致 Pms: BUG-322771
1 parent 2286b66 commit 6ba8fbf

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

qml/windowed/AppListView.qml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,13 @@ FocusScope {
361361
}
362362
}
363363

364+
Connections {
365+
target: CategorizedSortProxyModel
366+
function onCategoryTypeChanged() {
367+
listView.positionViewAtBeginning()
368+
}
369+
}
370+
364371
section.property: CategorizedSortProxyModel.sortRoleName // "transliterated" // "category"
365372
section.criteria: section.property === "transliterated" ? ViewSection.FirstCharacter : ViewSection.FullString
366373
section.delegate: sectionHeading

src/models/categorizedsortproxymodel.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ DCORE_USE_NAMESPACE
1515
void CategorizedSortProxyModel::setCategoryType(CategoryType categoryType)
1616
{
1717
CategoryType oldCategoryType = this->categoryType();
18-
18+
19+
beginResetModel();
1920
isFreeSort = (categoryType == FreeCategory);
2021
switch (categoryType) {
2122
case Alphabetary:
@@ -31,10 +32,12 @@ void CategorizedSortProxyModel::setCategoryType(CategoryType categoryType)
3132
if (oldCategoryType != categoryType) {
3233
QScopedPointer<DConfig> config(DConfig::create("org.deepin.dde.shell", "org.deepin.ds.launchpad"));
3334
config->setValue("categoryType", categoryType);
34-
emit categoryTypeChanged();
3535
}
3636

3737
sort(0);
38+
endResetModel();
39+
40+
emit categoryTypeChanged();
3841
}
3942

4043
CategorizedSortProxyModel::CategoryType CategorizedSortProxyModel::categoryType() const

0 commit comments

Comments
 (0)