Add function initiateSearch().
This commit is contained in:
parent
7c85c579a9
commit
9598108d43
@ -25,7 +25,7 @@ Kirigami.ScrollablePage {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.leftMargin: Kirigami.Units.smallSpacing
|
Layout.leftMargin: Kirigami.Units.smallSpacing
|
||||||
Keys.onReturnPressed: {
|
Keys.onReturnPressed: {
|
||||||
searchButton.clicked()
|
initiateSearch(textField.text)
|
||||||
}
|
}
|
||||||
Controls.Popup {
|
Controls.Popup {
|
||||||
id: historyPopup
|
id: historyPopup
|
||||||
@ -34,7 +34,7 @@ Kirigami.ScrollablePage {
|
|||||||
width: parent.width
|
width: parent.width
|
||||||
visible: view.count > 0 && textField.activeFocus
|
visible: view.count > 0 && textField.activeFocus
|
||||||
padding: Kirigami.Units.smallSpacing
|
padding: Kirigami.Units.smallSpacing
|
||||||
height: Math.min(Kirigami.Units.gridUnit * 10, view.contentHeight)
|
height: Math.min(Kirigami.Units.gridUnit * 10, view.contentHeight + 2 * Kirigami.Units.smallSpacing)
|
||||||
contentItem: Controls.ScrollView {
|
contentItem: Controls.ScrollView {
|
||||||
Controls.ScrollBar.horizontal.policy: Controls.ScrollBar.AlwaysOff
|
Controls.ScrollBar.horizontal.policy: Controls.ScrollBar.AlwaysOff
|
||||||
ListView {
|
ListView {
|
||||||
@ -45,7 +45,7 @@ Kirigami.ScrollablePage {
|
|||||||
delegate: Kirigami.BasicListItem {
|
delegate: Kirigami.BasicListItem {
|
||||||
text: search.searchTerm
|
text: search.searchTerm
|
||||||
onClicked: {
|
onClicked: {
|
||||||
textField.text = text;
|
initiateSearch(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,12 +61,19 @@ Kirigami.ScrollablePage {
|
|||||||
Layout.rightMargin: Kirigami.Units.smallSpacing
|
Layout.rightMargin: Kirigami.Units.smallSpacing
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if(textField.text.length > 0) {
|
if(textField.text.length > 0) {
|
||||||
podcastSearchModel.search(textField.text);
|
initiateSearch(textField.text);
|
||||||
SearchHistoryModel.insertSearchResult(textField.text);
|
}
|
||||||
|
else {
|
||||||
|
console.log("ERROR! Enter a search term!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function initiateSearch(term) {
|
||||||
|
textField.text = term;
|
||||||
historyPopup.close();
|
historyPopup.close();
|
||||||
}
|
podcastSearchModel.search(term);
|
||||||
}
|
SearchHistoryModel.insertSearchResult(term);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
textField.forceActiveFocus();
|
textField.forceActiveFocus();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user