Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.12
- import QtQuick.Window 2.12
- import QtQuick.Controls 6.2
- Item {
- id: busStopSearchItem
- property var chosenBusStop: null
- // -------------------------------------------------------------------------------------------------
- function getStopPoints(name){
- var url = "https://www.peka.poznan.pl/vm/method.vm?ts=1649587369255";
- var xhr = new XMLHttpRequest();
- xhr.open("POST", url);
- xhr.setRequestHeader("Pragma", "no-cache");
- xhr.setRequestHeader("Origin", "https://www.peka.poznan.pl");
- xhr.setRequestHeader("Accept-Encoding", "gzip, deflate, br");
- xhr.setRequestHeader("Accept-Language", "en-GB,en-US;q=0.9,en;q=0.8");
- xhr.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36");
- xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
- xhr.setRequestHeader("Accept", "text/javascript, text/html, application/xml, text/xml, */*");
- xhr.setRequestHeader("X-Prototype-Version", "1.7");
- xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
- xhr.setRequestHeader("Cookie", "JSESSIONID=GkLiAkWImpuzrUNdT5y7vuZb.undefined");
- xhr.setRequestHeader("Connection", "keep-alive");
- xhr.setRequestHeader("Referer", "https://www.peka.poznan.pl/vm/");
- xhr.setRequestHeader("Cache-Control", "no-cache");
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- console.log(xhr.status);
- console.log(xhr.responseText);
- var jsonResponse = JSON.parse(xhr.responseText);
- var keyCount = Object.keys(jsonResponse.success).length;
- console.log(keyCount);
- for(var i = 0; i < keyCount; i++){
- modelBusStops.append(jsonResponse.success[i]);
- }
- }};
- var data = "method=getStopPoints&p0=%7B%22pattern%22%3A%22" + name + "%22%7D";
- xhr.send(data);
- }
- // -------------------------------------------------------------------------------------------------
- TextField {
- id: textField
- y: 116
- width: 417
- height: 27
- color: "#000000"
- horizontalAlignment: Text.AlignHCenter
- anchors.horizontalCenterOffset: 1
- scale: 1
- anchors.horizontalCenter: parent.horizontalCenter
- font.pointSize: 13
- placeholderText: qsTr("Nazwa przystanku")
- onTextEdited: {
- for(var i = 0; i < modelBusStops.count; ++i){
- modelBusStops.remove(i);
- }
- getStopPoints(textField.text);
- for(var i = 0; i < modelBusStops.count; ++i){
- modelBusStops.remove(i);
- }
- }
- }
- ListView {
- id: busStopList
- width: 417
- height: 413
- anchors.verticalCenter: parent.verticalCenter
- anchors.verticalCenterOffset: 58
- anchors.horizontalCenterOffset: 1
- anchors.horizontalCenter: parent.horizontalCenter
- delegate: Item {
- x: 5
- width: 80
- height: 40
- Row {
- id: row
- Text {
- id: txt
- text: name
- font.pointSize: 14
- color: "#ffffff"
- anchors.verticalCenter: parent.verticalCenter
- font.bold: true
- MouseArea{
- anchors.fill: parent
- onClicked: {
- chosenBusStop = txt.text;
- mainStack.push("BusStopView.qml");
- }
- }
- }
- spacing: 10
- }
- }
- model: ListModel {
- id: modelBusStops
- }
- }
- }
- /*##^##
- Designer {
- D{i:0;autoSize:true;height:700;width:480}D{i:1}D{i:2}
- }
- ##^##*/
Add Comment
Please, Sign In to add comment