-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddAttribute.qml
55 lines (54 loc) · 1.84 KB
/
addAttribute.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
import QtQuick 2.2
import QtQuick.Layouts 1.1
import QtQuick.Window 2.0
import QtQuick.Controls 2.2
import QtLocation 5.9
import QtPositioning 5.5
import QtQuick.LocalStorage 2.0 as Sql
Window {
id: mypopDialog
title: "Set Attributes"
width: 450
height: 150
flags: Qt.Dialog
modality: Qt.WindowModal
property var sqlPosition
GridLayout{
rowSpacing: 12
columnSpacing: 30
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
anchors.margins: 30
Label {
text: "Your Name"
}
TextField {
id: text
placeholderText: qsTr("Enter name")
}
Button {
text: "Submit"
onClicked: {
var db = Sql.LocalStorage.openDatabaseSync("db_attr", "1.0", "DB for Storing Attributes!", 1000000)
db.transaction(
function(tx) {
tx.executeSql("CREATE TABLE IF NOT EXISTS Pin(ID INTEGER PRIMARY KEY AUTOINCREMENT, Name VARCHAR(255), Latitude FLOAT, Longitude FLOAT, unique (Name))")
tx.executeSql("INSERT INTO Pin VALUES(NULL, ?, ?, ?)", [text.text, (mypopDialog.sqlPosition.latitude).toFixed(3), (mypopDialog.sqlPosition.longitude).toFixed(3) ])
var print = tx.executeSql("SELECT * FROM Pin")
for(var i = 0; i < print.rows.length; i++) {
var dbItem = print.rows.item(i)
console.warn("ID: " + dbItem.ID + ", Name: " + dbItem.Name + ", Latitude: " + dbItem.Latitude + ", Longitude: " + dbItem.Longitude )
}
}
)
mypopDialog.close()
}
}
}
Button{
text: "Close"
x: 342
y: 100
onClicked: mypopDialog.close()
}
}