summaryrefslogtreecommitdiffstats
path: root/examples/pdf/pdfviewer
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-02-25 17:49:56 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2020-02-26 15:40:24 +0100
commit926afcaa6f3ce02b51cd535d82454f4b25e0b7f6 (patch)
tree66773defe3e53fc4a37f3fc10eb2f2649d27f668 /examples/pdf/pdfviewer
parent8091944ae8ccfb4e0b3e7518912802c9c75704d0 (diff)
PdfSearchModel: provide ContextBefore and ContextAfter
...as separate roles, to make alignment easier, and to avoid hard-coding HTML tags in the Context role as it was before. But the strings in these context roles are not always adjacent to the search results in geometric coordinates sometimes, in some PDF files, despite having adjacent character indices. I.e. the "next" character after the search string, or the "previous" character before it, could be anywhere on the page. Change-Id: Ief0a490b64fdb3c3ca98506926650648b609ece1 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'examples/pdf/pdfviewer')
-rw-r--r--examples/pdf/pdfviewer/viewer.qml26
1 files changed, 25 insertions, 1 deletions
diff --git a/examples/pdf/pdfviewer/viewer.qml b/examples/pdf/pdfviewer/viewer.qml
index e3bb4b474..b47a7dd36 100644
--- a/examples/pdf/pdfviewer/viewer.qml
+++ b/examples/pdf/pdfviewer/viewer.qml
@@ -231,7 +231,31 @@ ApplicationWindow {
ScrollBar.vertical: ScrollBar { }
delegate: ItemDelegate {
width: parent ? parent.width : 0
- text: "page " + (page + 1) + ": " + context
+ RowLayout {
+ anchors.fill: parent
+ spacing: 0
+ Label {
+ text: "Page " + (page + 1) + ": "
+ }
+ Label {
+ text: contextBefore
+ elide: Text.ElideLeft
+ horizontalAlignment: Text.AlignRight
+ Layout.fillWidth: true
+ Layout.preferredWidth: parent.width / 2
+ }
+ Label {
+ font.bold: true
+ text: view.searchString
+ width: implicitWidth
+ }
+ Label {
+ text: contextAfter
+ elide: Text.ElideRight
+ Layout.fillWidth: true
+ Layout.preferredWidth: parent.width / 2
+ }
+ }
highlighted: ListView.isCurrentItem
onClicked: {
searchResultsList.currentIndex = index