From 7fbd3cbdadb5bfb509b9bc396d949fe38a067072 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 21 Feb 2018 13:35:11 +0100 Subject: Search in conversationview ...via syntax highligher or search api. --- components/mailviewer/qml/HtmlContent.qml | 5 ++++- components/mailviewer/qml/MailDataModel.qml | 8 ++++++++ components/mailviewer/qml/MailViewer.qml | 1 + components/mailviewer/qml/TextContent.qml | 10 ++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) (limited to 'components/mailviewer/qml') diff --git a/components/mailviewer/qml/HtmlContent.qml b/components/mailviewer/qml/HtmlContent.qml index f0249a01..c775a3ca 100644 --- a/components/mailviewer/qml/HtmlContent.qml +++ b/components/mailviewer/qml/HtmlContent.qml @@ -27,7 +27,10 @@ Item { property string content //We have to give it a minimum size so the html content starts to expand property int contentHeight: 10; - + property string searchString + onSearchStringChanged: { + htmlView.findText(searchString) + } WebEngineView { id: htmlView diff --git a/components/mailviewer/qml/MailDataModel.qml b/components/mailviewer/qml/MailDataModel.qml index d960b2ac..fdc3ce22 100644 --- a/components/mailviewer/qml/MailDataModel.qml +++ b/components/mailviewer/qml/MailDataModel.qml @@ -23,6 +23,8 @@ import org.kube.framework 1.0 as Kube DelegateModel { id: root + property string searchString: "" + delegate: Item { id: partColumn @@ -124,6 +126,12 @@ DelegateModel { } height: item ? item.contentHeight : 0 width: parent.width + Binding { + target: partLoader.item + property: "searchString" + value: root.searchString + when: partLoader.status == Loader.Ready + } } Component.onCompleted: { switch (model.type) { diff --git a/components/mailviewer/qml/MailViewer.qml b/components/mailviewer/qml/MailViewer.qml index 9031ec17..faf3bc61 100644 --- a/components/mailviewer/qml/MailViewer.qml +++ b/components/mailviewer/qml/MailViewer.qml @@ -22,6 +22,7 @@ Item { id: root property alias rootIndex: visualModel.rootIndex property alias model: visualModel.model + property alias searchString: visualModel.searchString height: partListView.height MailDataModel { diff --git a/components/mailviewer/qml/TextContent.qml b/components/mailviewer/qml/TextContent.qml index 316786ef..95e196b4 100644 --- a/components/mailviewer/qml/TextContent.qml +++ b/components/mailviewer/qml/TextContent.qml @@ -27,8 +27,14 @@ Item { property bool embedded: true property string type + property string searchString property int contentHeight: textEdit.height + onSearchStringChanged: { + //This is a workaround because otherwise the view will not take the ViewHighlighter changes into account. + textEdit.text = root.content + } + TextEdit { id: textEdit @@ -56,5 +62,9 @@ Item { acceptedButtons: Qt.NoButton // we don't want to eat clicks on the Text cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor } + Kube.ViewHighlighter { + textDocument: textEdit.textDocument + searchString: root.searchString + } } } -- cgit v1.2.3