From e2b5911bd47ebabea84e68418e0ae3f495067eb8 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 29 Dec 2023 12:27:55 -0700 Subject: Add PdfSearchModel.count; disable search up/down buttons if empty A crash was possible if there are no search results and the user presses the up/down buttons alongside the search field on the toolbar. That was easily fixed (in a previous patch); but actually those buttons should be disabled if there are no results to navigate. To do that, we need a notifying property rather than depending on the invokable QAIM::rowCount(). Follow the usual pattern for a one-dimensional model: add a `count` property in the subclass (as in XmlListModel, FolderListModel, CalendarModel, and a few others). Task-number: QTBUG-119776 Change-Id: I51c75b58f3a440c1c470794518a572b384376ea7 Reviewed-by: Axel Spoerl --- examples/pdf/multipage/viewer.qml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'examples/pdf/multipage') diff --git a/examples/pdf/multipage/viewer.qml b/examples/pdf/multipage/viewer.qml index d0b0a7263..ec9a9fd91 100644 --- a/examples/pdf/multipage/viewer.qml +++ b/examples/pdf/multipage/viewer.qml @@ -398,6 +398,7 @@ ApplicationWindow { action: Action { icon.source: "qrc:/pdfviewer/resources/go-up-search.svg" shortcut: StandardKey.FindPrevious + enabled: view.searchModel.count > 0 onTriggered: view.searchBack() } ToolTip.visible: enabled && hovered @@ -432,6 +433,7 @@ ApplicationWindow { action: Action { icon.source: "qrc:/pdfviewer/resources/go-down-search.svg" shortcut: StandardKey.FindNext + enabled: view.searchModel.count > 0 onTriggered: view.searchForward() } ToolTip.visible: enabled && hovered -- cgit v1.2.3