test qml

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.ListItems 0.1 as ListItem
import "../../GValues.js" as GValues
import Ubuntu.Components.Popups 0.1
//test send qml request =)
PageStack {
id: pageStack
pageStack: clear
Component.onCompleted: {
push(tabs)
GValues.unsetCurentCassID();
}
Tabs {
id: tabs
Tab {
title: "Films"
page: Page {
title: "Films"
id: page1
visible: true
ListModel {
id: dataModel
}
Column {
anchors.margins: 10
anchors.fill: parent
spacing: 10
ListView {
id: view
width: parent.width
height: parent.height
spacing: 10
model: dataModel
clip: true
delegate: Rectangle {
id: element
width: view.width
height: 200
color: "skyblue"
Text {
anchors.centerIn: parent
width: 200
renderType: Text.NativeRendering
text: model.s_name
wrapMode: Text.WordWrap
}
// Text {
// anchors.centerIn: element
// text: "<a href='"+model.download_link+"'>Download</a>"
// MouseArea {
// anchors.fill: parent
// onClicked: {
// showImapAlert('DOWNLOAD');
// }
// }
// }
Image {
parent: element
id: logo
width: 100
height: parent.height
source: model.logo
}
}
}
// Button {
// id: button
// width: 100
// height: 40
// anchors.horizontalCenter: parent.horizontalCenter
// text: "NEXT"
// MouseArea {
// anchors.fill: parent
// onClicked: {
// console.log("Request sentssss");
// }
// }
// }
}
function showImapAlert(message) {
PopupUtils.open(Qt.resolvedUrl("InfoDialog.qml"), appWindow, {
title: qsTr("Server Message"),
text: message
})
}
tools: ToolbarItems {
ToolbarButton {
action: Action {
text: "Update"
iconSource: Qt.resolvedUrl("icon/update.svg")
onTriggered:
{
var doc = new XMLHttpRequest();
doc.onreadystatechange = function() {
if (doc.readyState == XMLHttpRequest.DONE) {
var film = JSON.parse(doc.responseText);
if(film.response == "ACCESS_TOKEN")
{
showImapAlert('Error Access token!');
}
else
{
if(film.response != "CASS_ID_NOT_FOUND")
{
dataModel.append(film);
}
else
{
showImapAlert('Fiml not FOUND!');
}
}
}
}
doc.open("GET", "http://localhost/intermovie/api/film/get/film_info.php?cass_id=1628&user_id=3&access_token=a1d12e387057a3e3cb38475c610d56af");
doc.send();
}
}
}
}
}
}
Tab {
title: "Tab 2"
page: Page {
Label {
anchors.centerIn: parent
text: "Use header to navigate between tabs"
}
}
}
}
Page {
id: page3
visible: false
title: "Page on stack"
Label {
anchors.centerIn: parent
text: "Press back to return to the tabs"
}
}
}