-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.qml
109 lines (89 loc) · 3.48 KB
/
Main.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
import QtQuick 2.0
import Ubuntu.Components 1.1
import QtQuick.LocalStorage 2.0
import "Pages"
MainView {
objectName: "mainView"
id:mainview
applicationName: "com.ubuntu.developer.dpdmancul.osmerarpafvg"
property var db
Timer {
id:updateTimer
property int minutes: 120
interval: 60000*minutes;
running: true;
repeat: true
onTriggered: upDate(db)
}
function load (db){
previsioni.page.load(db)
info.load_time(db)
}
function settime(db){
db.transaction(
function(tx) {
tx.executeSql('UPDATE LastUp SET last=CURRENT_TIMESTAMP WHERE id=1');
}
)
}
function upDate (db){
previsioni.page.updateAllTexts(db)
load(db)
console.log('Aggiornamento dati...')
settime(db)
}
function firsttime(db){
db.transaction(
function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS Previsioni(id TINYINT UNSIGNED,situazione TEXT, oggi TEXT, domani TEXT, dopodomani TEXT, piu3 TEXT, piu4 TEXT)');
tx.executeSql('INSERT INTO Previsioni VALUES (1,\'situazione\', \'oggi\', \'domani\' , \'dopodomani\' , \'piu3\' , \'piu4\')');
tx.executeSql('CREATE TABLE IF NOT EXISTS Img_previsioni(id TINYINT UNSIGNED,situazione BLOB, oggi BLOB, domani BLOB, dopodomani BLOB, piu3 BLOB, piu4 BLOB, radar BLOB)');
tx.executeSql('INSERT INTO Img_previsioni VALUES (1,\'situazione\', \'oggi\', \'domani\' , \'dopodomani\' , \'piu3\' , \'piu4\', \'radar\')');
tx.executeSql('CREATE TABLE IF NOT EXISTS lastUp(id TINYINT UNSIGNED,last DATETIME,every INT UNSIGNED)');
tx.executeSql('INSERT INTO LastUp VALUES (1,CURRENT_TIMESTAMP,120)');
}
)
upDate(db)
db.changeVersion("", "2.0.3");
}
function checktime(db){
db.transaction(
function(tx) {
var rs=tx.executeSql('SELECT * FROM LastUp WHERE id=1');
updateTimer.minutes=rs.rows[0].every
}
)
db.transaction(
function(tx) {
var rs=tx.executeSql('SELECT * FROM LastUp WHERE (strftime(\'%s\',\'now\') - strftime(\'%s\',last)) >= ?', [updateTimer.interval/1000]);
if (rs.rows.length>0)
upDate(db)
}
)
}
Component.onCompleted: {
db = LocalStorage.openDatabaseSync("OsmerArpaFVG_v2.0.3", "2.0.3", "meteo data for Osmer Arpa FVG app", 3000000, firsttime)
checktime(db)
load(db)
}
automaticOrientation: true
backgroundColor: pageStack.currentPage.currentPage.cBackground
headerColor: (pageStack.currentPage.currentPage.parent===previsioni?previsioni.page.headerColor:backgroundColor)
// Removes the old toolbar and enables new features of the new header.
useDeprecatedToolbar: false
width: units.gu(150)
height: units.gu(75)
PageStack {
id: pageStack
Component.onCompleted: push(rootTabs)
anchors.fill: parent
Tabs {
id: rootTabs
anchors.fill: parent
Previsioni{id:previsioni}
Radar{id:radar}
Webcam{id:webcam}
Info{id:info}
}
}
}