Copy // Search.qml
import QtQuick 2.15
import QtQuick.Controls 2.15
import org.mauikit.controls 1.3 as Maui
Maui.Page {
id: searchPage
showCSDControls: true
headBar.background: Rectangle {
anchors.fill: parent
Maui.Theme.inherit: false
Maui.Theme.colorSet: Maui.Theme.View
color: Maui.Theme.backgroundColor
}
headBar.middleContent: Maui.SearchField {
anchors.horizontalCenter: parent.horizontalCenter
onAccepted: {
stationsModel.clear()
search(text)
}
}
function search(query) {
// RADIO BROWSER
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
print('HEADERS_RECEIVED')
} else if(xhr.readyState === XMLHttpRequest.DONE) {
print('DONE');
var obj = JSON.parse(xhr.responseText.toString());
for(var i=0; i<obj.length; i++) {
stationsModel.append({"changeuuid": obj[i].changeuuid,"stationuuid": obj[i].stationuuid, "serveruuid": obj[i].serveruuid,"name": obj[i].name,"url": obj[i].url,"url_resolved": obj[i].url_resolved,"homepage": obj[i].homepage,"favicon": obj[i].favicon,"tags": obj[i].tags,"country": obj[i].country, "countrycode": obj[i].countrycode, "iso_3166_2": obj[i].iso_3166_2,"state": obj[i].state, "language": obj[i].language, "languagecodes": obj[i].languagecodecs, "votes": obj[i].votes,"lastchangetime": obj[i].lastchangetime,"lastchangetime_iso8601": obj[i].lastchangetime_iso8601,"codec": obj[i].codec,"bitrate": obj[i].bitrate,"hls": obj[i].hls,"lastcheckok": obj[i].lastcheckok,"lastchecktime": obj[i].lastchecktime,"lastchecktime_iso8601": obj[i].lastchecktime_iso8601,"lastcheckoktime": obj[i].lastcheckoktime,"lastcheckoktime_iso8601": obj[i].lastcheckoktime_iso8601,"lastlocalchecktime": obj[i].lastlocalchecktime,"lastlocalchecktime_iso8601": obj[i].lastlocalchecktime_iso8601,"clicktimestamp": obj[i].clicktimestamp,"clicktimestamp_iso8601": obj[i].clicktimestamp_iso8601,"clickcount": obj[i].clickcount,"clicktrend": obj[i].clicktrend,"ssl_error": obj[i].ssl_error,"geo_lat null": obj[i].geo_latnull,"geo_long": obj[i].geo_long, "has_extended_info": obj[i].has_extended_info})
}
}
}
xhr.open("GET", "https://nl1.api.radio-browser.info/json/stations/search?limit=999&name=" + query + "&hidebroken=true&order=clickcount&reverse=true");
xhr.send();
}
Maui.ListBrowser {
anchors.fill: parent
anchors.margins: 20
horizontalScrollBarPolicy: ScrollBar.AsNeeded
verticalScrollBarPolicy: ScrollBar.AsNeeded
spacing: 10
model: stationsModel
delegate: Rectangle {
color: "transparent"
width: ListView.view.width
height: 80
Maui.SwipeBrowserDelegate
{
anchors.fill: parent
label1.text: name
label2.text: tags
iconSource: favicon
iconSizeHint: Maui.Style.iconSizes.medium
quickActions: [
Action
{
icon.name: "love"
},
Action
{
icon.name: "documentinfo"
}
]
}
}
}
}