Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.7
- import Ubuntu.Components 1.3
- import QtQuick.Controls 2.2
- import QtQuick.Layouts 1.3
- import Qt.labs.settings 1.0
- import Qt.labs.platform 1.0
- import io.thp.pyotherside 1.3
- import QtQuick.LocalStorage 2.0
- import Ubuntu.Components.Popups 1.0
- MainView {
- id: root
- objectName: 'mainView'
- applicationName: 'mienimmen.dl8aax'
- automaticOrientation: true
- width: units.gu(45)
- height: units.gu(70)
- function speichern() {
- var db = LocalStorage.openDatabaseSync("MienImmen", "1.0", "", 1000000);
- try {
- db.transaction(
- function(tx) {
- /* DB Tabelle = id INTEGER PRIMARY KEY AUTOINCREMENT,
- qth TEXT,
- bemerk TEXT,
- plz TEXT
- strnr TEXT,
- breiteng TEXT,
- lengeng TEXT
- */
- // tx.executeSql('INSERT INTO stande VALUES(qth,bemerk,plz,strnr,breiteng,lengeng)',[inp_ortt.text,inp_bemt.text, inp_plz.text, inp_strt.text, inp_bgt.text, inp_lgt.text ]);
- tx.executeSql('INSERT INTO staende VALUES(?,?,?,?,?,?)',[,inp_ortt.text,inp_bemt.text, inp_plz.text, inp_strt.text, inp_bgt.text, inp_lgt.text ]);
- }
- )
- }
- catch (err) {
- console.log("Error Fehler beim schreiben in Tabelle stande: " + err)
- };
- //eingabe felder wieder löschen
- inp_ortt.text=""
- inp_bemt.text=""
- inp_plz.text=""
- inp_strt.text=""
- inp_bgt.text=""
- inp_lgt.text=""
- liesmadb()
- }
- function liesmadb() {
- var db = LocalStorage.openDatabaseSync("MienImmen", "1.0", "", 1000000);
- try {
- db.transaction(
- function(tx) {
- var rs = tx.executeSql('SELECT * FROM staende');
- var r = ""
- for (var i = 0; i < rs.rows.length; i++) {
- r += rs.rows.item(i).id + ", " + rs.rows.item(i).qth + ", " + rs.rows.item(i).plz + ", " + rs.rows.item(i).strnr+ "\n"
- standelistModel.append({
- "id": rs.rows.item(i).id,
- "lg": rs.rows.item(i).lengeng,
- "bg": rs.rows.item(i).breiteng,
- "plz": rs.rows.item(i).plz,
- "ort": rs.rows.item(i).qth,
- "strnr": rs.rows.item(i).strnr,
- "bemerk": rs.rows.item(i).bemerk })
- console.log( r )
- }
- // )
- }
- )
- }
- catch (err) {
- console.log("Error Fehler in der Tabelle stande: " + err)
- };
- }
- function killen(index) {
- standelistModel.remove(index)
- }
- Item {
- Component.onCompleted: {
- liesmadb()
- }
- }
- Page {
- anchors.fill: parent
- id:page
- Rectangle {
- id: rectangle_1
- x: units.gu(0.5)
- y: units.gu(0.5)
- width: units.gu(45)-units.gu(1)
- height: page.height / 2 - units.gu(1)
- color: "#ddd9d9"
- radius: 4
- border.color: "#be0cc4"
- border.width: units.gu(0.2)
- Text {
- id: utext
- text: i18n.tr('Bienenvolk anlegen')
- color: "darkorange"
- anchors.horizontalCenter: rectangle_1.horizontalCenter
- y:units.gu(2)
- font.pointSize: units.gu(2)
- }
- ScrollView {
- width: rectangle_1.width
- height: rectangle_1.height
- id : srolli
- Text {
- id:lgt
- text: i18n.tr('Lämgengrad :')
- color: "blue"
- x : srolli.x + units.gu(0.8)
- y : utext.y + utext.height+units.gu(1)
- //anchors.top : srolli.top
- anchors.topMargin: units.gu(1)
- }
- Text {
- id:bgt
- text: i18n.tr('Breitengrad :')
- color: "blue"
- x :rectangle_1.x + units.gu(0.3)
- anchors.top : lgt.bottom
- anchors.topMargin: units.gu(1.2)
- }
- Text {
- id:strt
- text: i18n.tr('Straße Nr. :')
- color: "blue"
- x :rectangle_1.x + units.gu(0.3)
- anchors.top : bgt.bottom
- anchors.topMargin: units.gu(1.2)
- }
- Text {
- id:plz
- text: i18n.tr('PLZ :')
- color: "blue"
- x :rectangle_1.x + units.gu(0.3)
- anchors.top : strt.bottom
- anchors.topMargin: units.gu(1.2)
- }
- Text {
- id:ortt
- text: i18n.tr('Ort :')
- color: "blue"
- x :rectangle_1.x + units.gu(0.3)
- anchors.top : plz.bottom
- anchors.topMargin: units.gu(1.2)
- }
- Text {
- id:bemt
- text: i18n.tr('Bemerkung :')
- color: "blue"
- x :rectangle_1.x + units.gu(0.3)
- anchors.top : ortt.bottom
- anchors.topMargin: units.gu(1.2)
- }
- TextField {
- //anchors.top: lgt.top
- anchors.left : lgt.right
- anchors.leftMargin : units.gu(1)
- anchors.verticalCenter : lgt.verticalCenter
- id : inp_lgt
- inputMethodHints : Qt.ImhNoPredictiveText
- width : units.gu(20)
- placeholderText: i18n.tr("längengrad")
- font.pointSize: units.gu(1.5)
- height: units.gu(3)
- bottomPadding: units.gu(0.2)
- }
- TextField {
- id : inp_bgt
- anchors.left : inp_lgt.left
- anchors.topMargin : units.gu(1)
- anchors.verticalCenter : bgt.verticalCenter
- placeholderText: i18n.tr("Breitengrad")
- inputMethodHints : Qt.ImhNoPredictiveText
- width : units.gu(20)
- height: units.gu(3)
- font.pointSize: units.gu(1.5)
- bottomPadding: units.gu(0.2)
- }
- TextField {
- id : inp_strt
- anchors.left : inp_lgt.left
- anchors.topMargin : units.gu(1)
- anchors.verticalCenter : strt.verticalCenter
- placeholderText: i18n.tr("Straße Nr.")
- inputMethodHints : Qt.ImhNoPredictiveText
- width : units.gu(20)
- height: units.gu(3)
- font.pointSize: units.gu(1.5)
- bottomPadding: units.gu(0.2)
- }
- TextField {
- id : inp_plz
- anchors.left : inp_lgt.left
- anchors.topMargin : units.gu(1)
- anchors.verticalCenter : plz.verticalCenter
- placeholderText: i18n.tr("PLZ")
- inputMethodHints : Qt.ImhNoPredictiveText
- width : units.gu(20)
- height: units.gu(3)
- font.pointSize: units.gu(1.5)
- bottomPadding: units.gu(0.2)
- }
- TextField {
- id : inp_ortt
- anchors.left : inp_lgt.left
- anchors.topMargin : units.gu(1)
- anchors.verticalCenter : ortt.verticalCenter
- placeholderText: i18n.tr("Ort")
- inputMethodHints : Qt.ImhNoPredictiveText
- width : units.gu(20)
- height: units.gu(3)
- font.pointSize: units.gu(1.5)
- bottomPadding: units.gu(0.2)
- }
- TextField {
- id : inp_bemt
- anchors.left : inp_lgt.left
- anchors.topMargin : units.gu(1)
- anchors.verticalCenter : bemt.verticalCenter
- placeholderText: i18n.tr("Bemerkung")
- inputMethodHints : Qt.ImhNoPredictiveText
- width : units.gu(31)
- height: units.gu(3)
- font.pointSize: units.gu(1.5)
- bottomPadding: units.gu(0.2)
- }
- Button {
- id: button
- x: srolli.width / 2 - button.width / 2
- y: inp_bemt.y + units.gu(4)
- width: units.gu(15)
- height: units.gu(3)
- text: i18n.tr("Eintragen")
- font.pointSize: units.gu(1.5)
- hoverEnabled: false
- onClicked: speichern()
- }
- }//ende scrollview
- }
- // ----------------------------------------------------------------------------
- Rectangle {
- id: rectangle_2
- x: units.gu(0.5)
- anchors.topMargin: units.gu(0.25)
- anchors.top : rectangle_1.bottom
- anchors.bottom : page.bottom
- width: units.gu(45)-units.gu(1)
- height: page.height / 2
- color: "#ddd9d9"
- radius: 4
- border.color: "#be0cc4"
- border.width: units.gu(0.2)
- Text {
- id : bsttext
- text: i18n.tr('Alle Völker')
- color: "darkorange"
- anchors.horizontalCenter: rectangle_2.horizontalCenter
- y:units.gu(2)
- font.pointSize: units.gu(2)
- }
- //horizontalAlignment: page.AlignHCenter
- anchors.horizontalCenter: root.horizontalCenter
- ScrollView {
- width: rectangle_2.width - units.gu(1.5)
- height: rectangle_2.height
- x : units.gu(0.5)
- ScrollBar.vertical.policy: ScrollBar.AlwaysOn
- //clip: true
- anchors {
- top: bsttext.bottom
- topMargin: units.gu(1.2)
- bottom: rectangle_2.bottom
- }
- ListModel {
- id: standelistModel
- }
- ListView {
- id: standelistView
- anchors {
- left: parent.left
- right: parent.right
- topMargin: units.gu(2)
- }
- model: standelistModel
- delegate: ListItem {
- width: parent.width-units.gu(1)
- height: units.gu(7)
- anchors.topMargin: units.gu(4)
- color: "#CDCDCD"
- Text {
- id: t_id
- text: id
- font.pointSize: units.gu(1.2)
- anchors {
- leftMargin: units.gu(1)
- topMargin: units.gu(2)
- }
- }
- Text {
- id: t_lg
- text: lg
- font.pointSize: units.gu(1.2)
- anchors {
- left: t_id.right
- leftMargin: units.gu(1)
- topMargin: units.gu(2)
- }
- }
- Text {
- id: t_bg
- text: bg
- font.pointSize: units.gu(1.2)
- anchors {
- left: t_lg.right
- leftMargin: units.gu(1)
- topMargin: units.gu(2)
- }
- }
- Text {
- id: t_strnr
- text: strnr
- font.pointSize: units.gu(1.2)
- anchors {
- left: t_id.left
- top: t_id.bottom
- leftMargin: units.gu(1)
- topMargin: units.gu(1)
- }
- }
- Text {
- id: t_plz
- text: plz
- font.pointSize: units.gu(1.2)
- anchors {
- left: t_strnr.right
- top: t_id.bottom
- leftMargin: units.gu(1)
- topMargin: units.gu(1)
- }
- }
- Text {
- id: t_ort
- text: ort
- font.pointSize: units.gu(1.2)
- anchors {
- left: t_plz.right
- top: t_id.bottom
- leftMargin: units.gu(1)
- topMargin: units.gu(1)
- }
- }
- Text {
- id: t_bemerk
- text: bemerk
- font.pointSize: units.gu(1.2)
- anchors {
- left: t_strnr.right
- top: t_strnr.bottom
- leftMargin: units.gu(1)
- topMargin: units.gu(2)
- }
- }
- leadingActions: ListItemActions {
- actions: [
- Action {
- iconName: "delete"
- onTriggered: killen(index)
- }
- ]
- }
- }// ende delegate
- }// ende listview
- }// ende ScrollView
- }// ende rectangle_2
- }//ende page
- }// ende MainView
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement