Skip to content

Commit 3cc4074

Browse files
committed
refactor: remove redundant positionViewAtBeginning functions
Removed multiple positionViewAtBeginning() functions from various QML view components (GridViewContainer, AnalysisView, FreeSortListView, FrequentlyUsedView, RecentlyInstalledView, SearchResultView) as they were redundant wrapper functions that simply called the underlying QML view's positionViewAtBeginning() method. Added a new itemBroughtToFront() signal to ItemArrangementProxyModel that triggers automatic view repositioning in FreeSortListView when items are brought to front, eliminating the need for manual view positioning calls. Log: N/A Influence: 1. Test that bringing items to front in free sort mode automatically scrolls the view to beginning 2. Verify all grid and list views still function correctly without explicit positionViewAtBeginning calls 3. Test search results display and navigation 4. Verify frequently used and recently installed views maintain proper scrolling behavior 5. Test drag and drop operations in free sort mode 6. Verify view focus behavior remains intact refactor: 移除冗余的positionViewAtBeginning函数 从多个QML视图组件(GridViewContainer、AnalysisView、FreeSortListView、 FrequentlyUsedView、RecentlyInstalledView、SearchResultView)中移除了 positionViewAtBeginning()函数,这些函数是冗余的包装函数,仅调用底层QML视 图的positionViewAtBeginning()方法。在ItemArrangementProxyModel中添加了新 的itemBroughtToFront()信号,当项目被置顶时自动触发FreeSortListView中的视 图重新定位,消除了手动调用视图定位的需求。 Log: 无 Influence: 1. 测试在自由排序模式下将项目置顶时是否自动滚动视图到起始位置 2. 验证所有网格和列表视图在没有显式positionViewAtBeginning调用的情况下仍 能正常工作 3. 测试搜索结果展示和导航功能 4. 验证常用应用和最近安装视图保持正确的滚动行为 5. 测试自由排序模式下的拖放操作 6. 验证视图焦点行为保持完整 PMS: BUG-335535
1 parent 80fe34c commit 3cc4074

9 files changed

Lines changed: 16 additions & 35 deletions

qml/GridViewContainer.qml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -44,10 +44,6 @@ FocusScope {
4444
gridView.currentIndex = 0
4545
}
4646

47-
function positionViewAtBeginning() {
48-
gridView.positionViewAtBeginning()
49-
}
50-
5147
function itemAt(x, y) {
5248
let point = mapToItem(gridView, x, y)
5349
return gridView.itemAt(point.x, point.y)

qml/windowed/AnalysisView.qml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -21,11 +21,6 @@ Control {
2121
frequentlyUsedView.focus = true
2222
}
2323

24-
function positionViewAtBeginning() {
25-
frequentlyUsedView.positionViewAtBeginning()
26-
recentlyInstalledView.positionViewAtBeginning()
27-
}
28-
2924
contentItem: ColumnLayout {
3025
spacing: 0
3126

qml/windowed/FreeSortListView.qml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ Item {
3535
listView.focus = true
3636
}
3737

38-
function positionViewAtBeginning() {
39-
listView.positionViewAtBeginning()
38+
Connections {
39+
target: ItemArrangementProxyModel
40+
function onItemBroughtToFront() {
41+
listView.positionViewAtBeginning()
42+
}
4043
}
4144

4245
function resetViewState() {

qml/windowed/FrequentlyUsedView.qml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -25,10 +25,6 @@ Control {
2525
property int count: frequentlyUsedViewContainer.count
2626
property int maxCount: 16
2727

28-
function positionViewAtBeginning() {
29-
frequentlyUsedViewContainer.positionViewAtBeginning()
30-
}
31-
3228
contentItem: ColumnLayout {
3329
spacing: 0
3430

qml/windowed/GridViewContainer.qml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -39,10 +39,6 @@ FocusScope {
3939
property ScrollBar vScrollBar
4040
property alias currentIndex: gridView.currentIndex
4141

42-
function positionViewAtBeginning() {
43-
gridView.positionViewAtBeginning()
44-
}
45-
4642
function itemAt(x, y) {
4743
let point = mapToItem(gridView, x, y)
4844
return gridView.itemAt(point.x, point.y)

qml/windowed/RecentlyInstalledView.qml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -24,10 +24,6 @@ Control {
2424
recentlyInstalledViewContainer.focus = true
2525
}
2626

27-
function positionViewAtBeginning() {
28-
recentlyInstalledViewContainer.positionViewAtBeginning()
29-
}
30-
3127
contentItem: ColumnLayout {
3228
spacing: 0
3329
Label {

qml/windowed/SearchResultView.qml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -25,10 +25,6 @@ Control {
2525
searchResultViewContainer.currentItem?.itemClicked()
2626
}
2727

28-
function positionViewAtBeginning() {
29-
searchResultViewContainer.positionViewAtBeginning()
30-
}
31-
3228
contentItem: ColumnLayout {
3329
spacing: 0
3430
visible: searchResultViewContainer.count > 0

src/models/itemarrangementproxymodel.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2023-2026 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -66,6 +66,8 @@ void ItemArrangementProxyModel::bringToFront(const QString & id)
6666
emit dataChanged(index(0, 0), index(rowCount() - 1, 0), {
6767
PageRole, IndexInPageRole, FolderIdNumberRole, IconsNameRole
6868
});
69+
70+
emit itemBroughtToFront();
6971
}
7072

7173
void ItemArrangementProxyModel::commitDndOperation(const QString &dragId, const QString &dropId, const DndOperation op, int pageHint)

src/models/itemarrangementproxymodel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -71,6 +71,7 @@ class ItemArrangementProxyModel : public QConcatenateTablesProxyModel
7171
signals:
7272
void topLevelPageCountChanged();
7373
void folderPageCountChanged(int folderId);
74+
void itemBroughtToFront();
7475

7576
private:
7677
explicit ItemArrangementProxyModel(QObject *parent = nullptr);

0 commit comments

Comments
 (0)