@@ -22,6 +22,7 @@ Popup {
2222
2323 property alias existingSections: alphabetCategoryDelegateModel .model
2424 property int columns: 5
25+ property string currentCategory: " "
2526
2627 readonly property int cellWidth: 24
2728 readonly property int cellHeight: 24
@@ -31,6 +32,41 @@ Popup {
3132 width: alphabetCategoryContainer .width + 20
3233 height: alphabetCategoryContainer .height + 20
3334
35+ function setCurrentCategory (category ) {
36+ currentCategory = category
37+ // 使用Timer延迟设置,确保model已经更新
38+ setIndexTimer .category = category
39+ setIndexTimer .restart ()
40+ }
41+
42+ Timer {
43+ id: setIndexTimer
44+ interval: 10
45+ property string category: " "
46+ onTriggered: {
47+ if (category !== " " ) {
48+ for (let i = 0 ; i < alphabetCategoryDelegateModel .model .length ; i++ ) {
49+ if (alphabetCategoryDelegateModel .model [i] === category) {
50+ // 临时禁用高亮移动动画,直接跳转到目标位置
51+ var originalDuration = alphabetCategoryContainer .highlightMoveDuration
52+ alphabetCategoryContainer .highlightMoveDuration = 0
53+ alphabetCategoryContainer .currentIndex = i
54+ // 恢复原来的动画时间
55+ alphabetCategoryContainer .highlightMoveDuration = originalDuration
56+ break
57+ }
58+ }
59+ }
60+ }
61+ }
62+
63+ onCurrentCategoryChanged: {
64+ if (currentCategory !== " " ) {
65+ setIndexTimer .category = currentCategory
66+ setIndexTimer .restart ()
67+ }
68+ }
69+
3470 DelegateModel {
3571 id: alphabetCategoryDelegateModel
3672
0 commit comments