From 6ace2da5999f3bb3452167193e46a6f824107052 Mon Sep 17 00:00:00 2001 From: kateleet Date: Sun, 5 Dec 2021 15:15:35 +0800 Subject: [PATCH] Scroll to current item after search --- model/foldermodel.cpp | 2 ++ model/foldermodel.h | 1 + qml/FolderPage.qml | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/model/foldermodel.cpp b/model/foldermodel.cpp index 55ea42c..ac9f47f 100644 --- a/model/foldermodel.cpp +++ b/model/foldermodel.cpp @@ -1339,6 +1339,8 @@ void FolderModel::keyboardSearch(const QString &text) if (index >= 0) { clearSelection(); setSelected(index); + + emit scrollToItem(index); } } diff --git a/model/foldermodel.h b/model/foldermodel.h index 7877075..13bd6b3 100644 --- a/model/foldermodel.h +++ b/model/foldermodel.h @@ -244,6 +244,7 @@ signals: void filterMimeTypesChanged(); void selectedItemSizeChanged(); void showHiddenFilesChanged(); + void scrollToItem(int index); void notification(const QString &message); void move(int x, int y, QList urls); diff --git a/qml/FolderPage.qml b/qml/FolderPage.qml index bf6c6b0..31486a0 100644 --- a/qml/FolderPage.qml +++ b/qml/FolderPage.qml @@ -168,6 +168,11 @@ Item { function onNotification(text) { root.showPassiveNotification(text, 3000) } + + // Scroll to item. + function onScrollToItem(index) { + _viewLoader.item.currentIndex = index + } } FM.ItemViewAdapter {