Advertisement
Guest User

stockkarte.qml

a guest
Dec 10th, 2022
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 26.77 KB | None | 0 0
  1.  
  2.  import QtQuick 2.7
  3. import Ubuntu.Components 1.3
  4. import QtQuick.Controls 2.2
  5. import QtQuick.Layouts 1.3
  6. import Qt.labs.settings 1.0
  7. import Qt.labs.platform 1.0
  8. import io.thp.pyotherside 1.3
  9. import QtQuick.LocalStorage 2.0
  10. import Ubuntu.Components.Popups 1.0
  11.  
  12. MainView {
  13.             id: root
  14.             objectName: 'mainView'
  15.             applicationName: 'mienimmen.dl8aax'
  16.             automaticOrientation: true
  17.  
  18.             width: units.gu(45)
  19.             height: units.gu(70)
  20.  
  21.         function speichern() {
  22.                                 var db = LocalStorage.openDatabaseSync("MienImmen", "1.0", "", 1000000);
  23.                                 try {
  24.                                      db.transaction(
  25.                                                     function(tx) {
  26.                                                              /*        DB Tabelle = id INTEGER PRIMARY KEY AUTOINCREMENT,
  27.                                                                                     qth TEXT,
  28.                                                                                     bemerk TEXT,
  29.                                                                                     plz TEXT
  30.                                                                                     strnr TEXT,
  31.                                                                                     breiteng TEXT,
  32.                                                                                     lengeng TEXT
  33.                                                          
  34.                                                          */
  35.                                                                 // 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 ]);
  36.                                                                  tx.executeSql('INSERT INTO staende VALUES(?,?,?,?,?,?)',[,inp_ortt.text,inp_bemt.text, inp_plz.text, inp_strt.text, inp_bgt.text, inp_lgt.text ]);
  37.                                                                   }
  38.                                                  )    
  39.                                     }
  40.                                     catch (err) {
  41.                                                  console.log("Error Fehler beim schreiben in Tabelle stande: " + err)
  42.                                                     };
  43.                                 //eingabe felder wieder löschen
  44.                                 inp_ortt.text=""
  45.                                 inp_bemt.text=""
  46.                                 inp_plz.text=""
  47.                                 inp_strt.text=""
  48.                                 inp_bgt.text=""
  49.                                 inp_lgt.text=""  
  50.                                 liesmadb()
  51.         }  
  52.         function liesmadb() {
  53.                              var db = LocalStorage.openDatabaseSync("MienImmen", "1.0", "", 1000000);
  54.                              try {
  55.                                     db.transaction(
  56.                                                     function(tx) {
  57.                                                                    var rs = tx.executeSql('SELECT * FROM staende');
  58.  
  59.                                                                     var r = ""
  60.                                                                     for (var i = 0; i < rs.rows.length; i++) {
  61.                                                                                             r += rs.rows.item(i).id + ", " + rs.rows.item(i).qth + ", " + rs.rows.item(i).plz + ", " + rs.rows.item(i).strnr+ "\n"
  62.                                                                                            standelistModel.append({
  63.                                                                                                             "id": rs.rows.item(i).id,
  64.                                                                                                             "lg": rs.rows.item(i).lengeng,
  65.                                                                                                             "bg": rs.rows.item(i).breiteng,
  66.                                                                                                             "plz": rs.rows.item(i).plz,
  67.                                                                                                             "ort": rs.rows.item(i).qth,
  68.                                                                                                             "strnr": rs.rows.item(i).strnr,
  69.                                                                                                             "bemerk": rs.rows.item(i).bemerk })
  70.                                                                                            console.log( r )
  71.                                                                                            
  72.                                                                                                             }
  73.                                                                                                //  )          
  74.                                                                                                 }
  75.                                                                    
  76.                                                        
  77.                                                                  
  78.                                                     )
  79.                                  }
  80.                                 catch (err) {
  81.                                                  console.log("Error Fehler in der Tabelle stande: " + err)
  82.                                                     };
  83.                             }
  84.         function killen(index) {
  85.                              standelistModel.remove(index)  
  86.  
  87.                             }
  88.                            
  89.           Item {
  90.               Component.onCompleted: {  
  91.                                         liesmadb()
  92.                                     }  
  93.              
  94.                 }              
  95.         Page {
  96.               anchors.fill: parent
  97.               id:page
  98.  
  99.  
  100.               Rectangle {
  101.                         id: rectangle_1
  102.                         x: units.gu(0.5)
  103.                         y: units.gu(0.5)
  104.                         width: units.gu(45)-units.gu(1)
  105.                         height: page.height / 2 - units.gu(1)
  106.                         color: "#ddd9d9"
  107.                         radius: 4
  108.                         border.color: "#be0cc4"
  109.                         border.width: units.gu(0.2)
  110.                        
  111.                         Text {
  112.                                 id: utext
  113.                                 text: i18n.tr('Bienenvolk anlegen')
  114.                                 color: "darkorange"
  115.                                 anchors.horizontalCenter: rectangle_1.horizontalCenter
  116.                                 y:units.gu(2)
  117.                                 font.pointSize: units.gu(2)
  118.                             }
  119.                                                  
  120.  
  121.                         ScrollView {
  122.                                     width:  rectangle_1.width
  123.                                     height: rectangle_1.height
  124.                                     id : srolli
  125.  
  126.                                     Text {
  127.                                id:lgt
  128.                                text: i18n.tr('Lämgengrad :')
  129.                                             color: "blue"
  130.                                             x : srolli.x + units.gu(0.8)
  131.                                             y : utext.y + utext.height+units.gu(1)
  132.                                //anchors.top : srolli.top
  133.                                             anchors.topMargin: units.gu(1)
  134.                                         }
  135.                                     Text {
  136.                                             id:bgt
  137.                                             text: i18n.tr('Breitengrad :')
  138.                                             color: "blue"
  139.                                             x :rectangle_1.x + units.gu(0.3)
  140.                                             anchors.top : lgt.bottom
  141.                                             anchors.topMargin: units.gu(1.2)
  142.                                         }
  143.                                     Text {
  144.                                             id:strt
  145.                                             text: i18n.tr('Straße Nr. :')
  146.                                             color: "blue"
  147.                                             x :rectangle_1.x + units.gu(0.3)
  148.                                             anchors.top : bgt.bottom
  149.                                         anchors.topMargin: units.gu(1.2)
  150.                                         }
  151.                                     Text { 
  152.                                             id:plz
  153.                                             text: i18n.tr('PLZ :')
  154.                                             color: "blue"
  155.                                             x :rectangle_1.x + units.gu(0.3)
  156.                                             anchors.top : strt.bottom
  157.                                             anchors.topMargin: units.gu(1.2)
  158.                                         }  
  159.                                     Text {
  160.                                             id:ortt
  161.                                             text: i18n.tr('Ort :')
  162.                                             color: "blue"
  163.                                             x :rectangle_1.x + units.gu(0.3)
  164.                                             anchors.top : plz.bottom
  165.                                             anchors.topMargin: units.gu(1.2)
  166.                                         }
  167.                                     Text {
  168.                                             id:bemt
  169.                                             text: i18n.tr('Bemerkung :')
  170.                                             color: "blue"
  171.                                             x :rectangle_1.x + units.gu(0.3)
  172.                                             anchors.top : ortt.bottom
  173.                                             anchors.topMargin: units.gu(1.2)
  174.                                         }  
  175.                                     TextField {
  176.                                                 //anchors.top: lgt.top
  177.                                                 anchors.left : lgt.right
  178.                                                 anchors.leftMargin : units.gu(1)
  179.                                                 anchors.verticalCenter : lgt.verticalCenter
  180.                                                 id : inp_lgt
  181.                                                 inputMethodHints : Qt.ImhNoPredictiveText
  182.                                                 width : units.gu(20)
  183.                                                 placeholderText: i18n.tr("längengrad")
  184.                                                 font.pointSize:  units.gu(1.5)
  185.                                                 height:  units.gu(3)
  186.                                                 bottomPadding: units.gu(0.2)
  187.                                                 }
  188.                                     TextField {
  189.                                                     id : inp_bgt
  190.                                                     anchors.left : inp_lgt.left
  191.                                                     anchors.topMargin : units.gu(1)
  192.                                                     anchors.verticalCenter : bgt.verticalCenter
  193.                                                     placeholderText: i18n.tr("Breitengrad")
  194.                                                     inputMethodHints : Qt.ImhNoPredictiveText
  195.                                                     width : units.gu(20)
  196.                                                     height: units.gu(3)
  197.                                                     font.pointSize: units.gu(1.5)
  198.                                                     bottomPadding: units.gu(0.2)
  199.                                                     }
  200.                                     TextField {
  201.                                                     id : inp_strt
  202.                                                     anchors.left : inp_lgt.left
  203.                                                     anchors.topMargin : units.gu(1)
  204.                                                     anchors.verticalCenter : strt.verticalCenter
  205.                                                     placeholderText: i18n.tr("Straße Nr.")
  206.                                                     inputMethodHints : Qt.ImhNoPredictiveText
  207.                                                     width : units.gu(20)
  208.                                                     height: units.gu(3)
  209.                                                     font.pointSize: units.gu(1.5)
  210.                                                     bottomPadding: units.gu(0.2)
  211.                                                     }
  212.                        
  213.                                     TextField {
  214.                                                     id : inp_plz
  215.                                                     anchors.left : inp_lgt.left
  216.                                                     anchors.topMargin : units.gu(1)
  217.                                                     anchors.verticalCenter : plz.verticalCenter
  218.                                                     placeholderText: i18n.tr("PLZ")
  219.                                                     inputMethodHints : Qt.ImhNoPredictiveText
  220.                                                     width : units.gu(20)
  221.                                                     height: units.gu(3)
  222.                                                     font.pointSize: units.gu(1.5)
  223.                                                     bottomPadding: units.gu(0.2)
  224.                                                     }
  225.                                     TextField {
  226.                                     id : inp_ortt
  227.                                     anchors.left : inp_lgt.left
  228.                                     anchors.topMargin : units.gu(1)
  229.                                     anchors.verticalCenter : ortt.verticalCenter
  230.                                     placeholderText: i18n.tr("Ort")
  231.                                     inputMethodHints : Qt.ImhNoPredictiveText
  232.                                     width : units.gu(20)
  233.                                     height: units.gu(3)
  234.                                     font.pointSize: units.gu(1.5)
  235.                                     bottomPadding: units.gu(0.2)
  236.                                     }
  237.                                     TextField {
  238.                                     id : inp_bemt
  239.                                     anchors.left : inp_lgt.left
  240.                                     anchors.topMargin : units.gu(1)
  241.                                     anchors.verticalCenter : bemt.verticalCenter
  242.                                     placeholderText: i18n.tr("Bemerkung")
  243.                                     inputMethodHints : Qt.ImhNoPredictiveText
  244.                                     width : units.gu(31)
  245.                                     height: units.gu(3)
  246.                                     font.pointSize: units.gu(1.5)
  247.                                     bottomPadding: units.gu(0.2)
  248.                                     }
  249.                                     Button {
  250.                                             id: button
  251.                                             x: srolli.width / 2 - button.width / 2
  252.                                             y: inp_bemt.y + units.gu(4)
  253.                                             width: units.gu(15)
  254.                                             height: units.gu(3)
  255.                                             text: i18n.tr("Eintragen")
  256.                                             font.pointSize: units.gu(1.5)
  257.                                             hoverEnabled: false
  258.                                             onClicked: speichern()
  259.                                  
  260.                                             }
  261.                                    }//ende scrollview
  262.                         }
  263.     // ----------------------------------------------------------------------------
  264.              Rectangle {
  265.                         id: rectangle_2
  266.                         x: units.gu(0.5)
  267.                         anchors.topMargin: units.gu(0.25)
  268.                         anchors.top : rectangle_1.bottom
  269.                         anchors.bottom : page.bottom
  270.                         width: units.gu(45)-units.gu(1)
  271.                         height: page.height / 2
  272.                         color: "#ddd9d9"
  273.                         radius: 4
  274.                         border.color: "#be0cc4"
  275.                         border.width: units.gu(0.2)
  276.                        
  277.                         Text {
  278.                                         id : bsttext
  279.                             text: i18n.tr('Alle Völker')
  280.                                         color: "darkorange"
  281.                     anchors.horizontalCenter: rectangle_2.horizontalCenter
  282.                                         y:units.gu(2)
  283.                                         font.pointSize: units.gu(2)            
  284.                                     }
  285.                         //horizontalAlignment: page.AlignHCenter
  286.                         anchors.horizontalCenter: root.horizontalCenter
  287.                        
  288.                         ScrollView {
  289.                                     width:  rectangle_2.width - units.gu(1.5)
  290.                                     height: rectangle_2.height
  291.                                     x :  units.gu(0.5)
  292.                                     ScrollBar.vertical.policy: ScrollBar.AlwaysOn    
  293.                                     //clip: true
  294.                                     anchors {
  295.                                             top: bsttext.bottom
  296.                                             topMargin: units.gu(1.2)
  297.                                             bottom: rectangle_2.bottom
  298.                                          }
  299.                                     ListModel {
  300.                                                 id: standelistModel
  301.                                                 }
  302.                                     ListView {
  303.                                                 id: standelistView
  304.                                                 anchors {
  305.                                                         left: parent.left
  306.                                                         right: parent.right
  307.                                                         topMargin: units.gu(2)
  308.                                                         }
  309.                                                 model: standelistModel
  310.                                                 delegate: ListItem {
  311.                                                                     width: parent.width-units.gu(1)
  312.                                                                     height: units.gu(7)
  313.                                                                     anchors.topMargin: units.gu(4)
  314.                                                                     color: "#CDCDCD"
  315.                                                                    
  316.                                                                     Text {
  317.                                                                             id: t_id
  318.                                                                             text: id
  319.                                                                             font.pointSize: units.gu(1.2)
  320.                                                                             anchors {
  321.                                                                                     leftMargin: units.gu(1)
  322.                                                                                     topMargin: units.gu(2)
  323.                                                                                     }
  324.                                                                           }
  325.                                                                      Text {
  326.                                                                             id: t_lg
  327.                                                                             text: lg
  328.                                                                             font.pointSize: units.gu(1.2)
  329.                                                                             anchors {
  330.                                                                                     left: t_id.right
  331.                                                                                     leftMargin: units.gu(1)
  332.                                                                                     topMargin: units.gu(2)
  333.                                                                                     }
  334.                                                                           }
  335.                                                                      Text {
  336.                                                                             id: t_bg
  337.                                                                             text: bg
  338.                                                                             font.pointSize: units.gu(1.2)
  339.                                                                             anchors {
  340.                                                                                     left: t_lg.right
  341.                                                                                     leftMargin: units.gu(1)
  342.                                                                                     topMargin: units.gu(2)
  343.                                                                                     }
  344.                                                                          }          
  345.                                                                      Text {
  346.                                                                             id: t_strnr
  347.                                                                             text: strnr
  348.                                                                             font.pointSize: units.gu(1.2)
  349.                                                                             anchors {
  350.                                                                                     left: t_id.left
  351.                                                                                     top: t_id.bottom
  352.                                                                                     leftMargin: units.gu(1)
  353.                                                                                     topMargin: units.gu(1)
  354.                                                                                     }
  355.                                                                          }        
  356.                                                                       Text {
  357.                                                                             id: t_plz
  358.                                                                             text: plz
  359.                                                                             font.pointSize: units.gu(1.2)
  360.                                                                             anchors {
  361.                                                                                     left: t_strnr.right
  362.                                                                                     top: t_id.bottom
  363.                                                                                     leftMargin: units.gu(1)
  364.                                                                                     topMargin: units.gu(1)
  365.                                                                                     }
  366.                                                                          }  
  367.                                                                     Text {
  368.                                                                             id: t_ort
  369.                                                                             text: ort
  370.                                                                             font.pointSize: units.gu(1.2)
  371.                                                                             anchors {
  372.                                                                                     left: t_plz.right
  373.                                                                                     top: t_id.bottom
  374.                                                                                     leftMargin: units.gu(1)
  375.                                                                                     topMargin: units.gu(1)
  376.                                                                                     }
  377.                                                                          }  
  378.                                                                     Text {
  379.                                                                             id: t_bemerk
  380.                                                                             text: bemerk
  381.                                                                             font.pointSize: units.gu(1.2)
  382.                                                                             anchors {
  383.                                                                                     left: t_strnr.right
  384.                                                                                     top: t_strnr.bottom
  385.                                                                                     leftMargin: units.gu(1)
  386.                                                                                     topMargin: units.gu(2)
  387.                                                                                     }
  388.                                                                          }  
  389.                                                                        leadingActions: ListItemActions {
  390.                                                                                                         actions: [
  391.                                                                                                                 Action {
  392.                                                                                                                         iconName: "delete"
  393.                                                                                                                         onTriggered: killen(index)
  394.                                                                                                                         }
  395.                                                                                                                 ]
  396.                                                                                                         }  
  397.                                                                     }// ende delegate
  398.                                              }// ende listview  
  399.                                     }// ende ScrollView
  400.                         }// ende rectangle_2
  401.             }//ende page
  402.  
  403.  
  404.  
  405.        }// ende  MainView
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement