-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainPage.qml
126 lines (113 loc) · 4.61 KB
/
MainPage.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
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtQuick.XmlListModel 2.12
import Qt.labs.settings 1.1
import br.edu.ifba.gsort.webscraping 1.0
Page {
property string currentUser
property Settings userSettings
property Settings serverSettings
property WebScraper processesScraper
title: qsTr("SEI Mobile - " + currentUser)
Text {
id: errorText
color: "#607D8B"
horizontalAlignment: Label.AlignHCenter
anchors.centerIn: parent
}
ColumnLayout {
anchors.fill: parent
ComboBox {
id: unityComboBox
function findCurrentIndex() {
var i;
for (i = 0; i < comboBoxModel.count; ++i)
if (comboBoxModel.get(i).selected === "selected")
return i;
}
function handleCurrentIndexChanged() {
if (currentIndex !== -1) {
processesScraper.source = serverSettings.serverURL + "/sei/inicializar.php"
processesScraper.postData = { "selInfraUnidades": unityComboBox.model.get(unityComboBox.currentIndex).value }
processesScraper.load()
}
}
Layout.fillWidth: true
Layout.rightMargin: 10; Layout.leftMargin: 10; Layout.topMargin: 6
model: XmlListModel {
id: comboBoxModel
xml: processesScraper.payload
query: "//*[@id=\"selInfraUnidades\"]/option"
XmlRole { name: "unity"; query: "string()" }
XmlRole { name: "value"; query: "@value/string()" }
XmlRole { name: "selected"; query: "@selected/string()" }
onStatusChanged: {
if (status === XmlListModel.Ready) {
unityComboBox.currentIndexChanged.disconnect(unityComboBox.handleCurrentIndexChanged)
unityComboBox.currentIndex = unityComboBox.findCurrentIndex()
unityComboBox.currentIndexChanged.connect(unityComboBox.handleCurrentIndexChanged)
}
}
}
textRole: "unity"
}
SwipeView {
id: swipeView
Layout.preferredWidth: parent.width
Layout.fillHeight: true
currentIndex: tabBar.currentIndex
Component {
id: processDelegate
ProcessDelegate {
width: parent.width
anchors { left: parent.left; leftMargin: 10; right: parent.right; rightMargin: 10 }
processId: id
processType: /infraTooltipMostrar\('(.*)','(.*)'\)/.exec(typeAndSpecification)[2]
processSpecification: /infraTooltipMostrar\('(.*)','(.*)'\)/.exec(typeAndSpecification)[1]
processAssignment: assignedTo
}
}
ListView {
clip: true
spacing: 10
model: XmlListModel {
xml: processesScraper.payload
query: "//*[@id=\"tblProcessosRecebidos\"]/tr[@class=\"infraTrClara\"]"
XmlRole { name: "id"; query: "td[1]/input/@title/string()" }
XmlRole { name: "typeAndSpecification"; query: "td[3]/a/@onmouseover/string()" }
XmlRole { name: "assignedTo"; query: "td[4]/a/string()" }
}
delegate: processDelegate
ScrollIndicator.vertical: ScrollIndicator { }
}
ListView {
clip: true
spacing: 10
model: XmlListModel {
xml: processesScraper.payload
query: "//*[@id=\"tblProcessosGerados\"]/tr[@class=\"infraTrClara\"]"
XmlRole { name: "id"; query: "td[1]/input/@title/string()" }
XmlRole { name: "typeAndSpecification"; query: "td[3]/a/@onmouseover/string()" }
XmlRole { name: "assignedTo"; query: "td[4]/a/string()" }
}
delegate: processDelegate
ScrollIndicator.vertical: ScrollIndicator { }
}
}
}
footer: TabBar {
id: tabBar
currentIndex: swipeView.currentIndex
TabButton { text: "Recebidos" }
TabButton { text: "Gerados" }
}
StackView.onRemoved: {
userSettings.user = ""
userSettings.password = ""
if (Qt.platform.os == "android") {
configurator.username = ""
configurator.password = ""
}
}
}