Advertisement
Guest User

Untitled

a guest
Sep 21st, 2015
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 8.49 KB | None | 0 0
  1.     Dialog {
  2.         width: 400
  3.         property int idx: 0;
  4.         standardButtons: StandardButton.Ok | StandardButton.Cancel
  5.         property ListModel upTempAttr;
  6.         property ListModel upTempAttrSave: ListModel {}
  7.         property string name: templates.get(upTemplateDialog.idx).name
  8.         property int wat: 0
  9.         id: upTemplateDialog
  10.         height: 400
  11.         title: "Template ändern"
  12.  
  13.         ListModel {
  14.             id: testlistview
  15.         }
  16.  
  17.  
  18.         onVisibleChanged: {
  19.             wat = upTemplateDialog.upTempAttr.count;
  20.             console.log(wat)
  21.             console.log(upTemplateDialog.upTempAttr.count)
  22.             //rep1.model = 4
  23.             if (!visible) {
  24.                 templates.get(idx).attr.clear();
  25.                 for (var i = 1; i < upTempAttrSave.count; i++) {
  26.                     templates.get(idx).attr.append({name: upTempAttrSave.get(i).name, type: upTempAttrSave.get(i).type})
  27.                 }
  28.             }
  29.         }
  30.  
  31.  
  32.         contentItem: Rectangle {
  33.             color: "#eeeeee"
  34.             anchors.fill: parent
  35.  
  36.             GridLayout {
  37.                 id:tempcolumn1
  38.                 anchors.fill: parent
  39.                 anchors.margins: 20
  40.                 columns: 1
  41.  
  42.                 GridLayout {
  43.                     columns: 1
  44.                     anchors.right: parent.right
  45.                     anchors.left: parent.left
  46.                     height: 140
  47.                     id: temprow1
  48.                     FlatInputLabel {
  49.  
  50.                         anchors.left: parent.left
  51.                         anchors.right: upTempColorRect.left
  52.                         anchors.rightMargin: 20
  53.                         label: "Name"
  54.                         id: upTextEditTemplateName
  55.                         text: templates.get(upTemplateDialog.idx).name
  56.                         placeholderText: qsTr("Name")
  57.  
  58.                     }
  59.  
  60.                     Rectangle {
  61.                         anchors.right: parent.right
  62.                         anchors.rightMargin: 2
  63.                         anchors.verticalCenter: upTextEditTemplateName.verticalCenter
  64.  
  65.                         id: upTempColorRect
  66.                         color: templates.get(upTemplateDialog.idx).colorTemp
  67.                         width: 40
  68.                         height: 40
  69.                         radius: 21
  70.                         border.color: "#dddddd"
  71.                         border.width: 1
  72.  
  73.                         MouseArea {
  74.                             anchors.fill: parent
  75.                             onClicked: {
  76.                                 colorDialog.origin = "update"
  77.                                 colorDialog.color = upTempColorRect.color
  78.                                 colorDialog.open()
  79.                                 console.log(upTemplateDialog.upTempAttr.toString())
  80.                             }
  81.                         }
  82.                     }
  83.                 }
  84.  
  85.                     Repeater {
  86.                         id: rep1
  87.                         model: upTemplateDialog.upTempAttr
  88.                         anchors.right: parent.right
  89.                         anchors.left: parent.left
  90.                         height: 400
  91.                         y: 0
  92.                         delegate: Rectangle {
  93.                             height: 60
  94.                             anchors.right: rep1.right
  95.                             anchors.left: rep1.left
  96.                             color: "transparent"
  97.                             GridLayout {
  98.                                 anchors.fill: parent
  99.                                 columns: 3
  100.  
  101.                                 FlatInputLabel {
  102.                                     id:templateflatinput1_
  103.                                     anchors.left: parent.left
  104.                                     anchors.right: templateflatinput3.left
  105.                                     anchors.rightMargin: 14
  106.                                     label: upTemplateDialog.upTempAttr.get(index).name;
  107.                                     text: index
  108.                                     onTextChanged: {
  109.                                         upTemplateDialog.upTempAttr.set(index, {name: text});
  110.                                     }
  111.                                 }
  112.  
  113.                                 FlatComboBox {
  114.                                     id: templateflatinput3
  115.                                     width: 70
  116.  
  117.                                     anchors.right: tempremovebtn1.left
  118.                                     anchors.rightMargin: 20
  119.                                     label: "Datentyp"
  120.                                     model: [type, "string", "int", "float", "bool", "date", "link", "path"]
  121.                                     onCurrentTextChanged: {
  122.  
  123.                                         upTemplateDialog.upTempAttr.set(index, {
  124.                                                                             type: value
  125.                                                                         })
  126.                                     }
  127.                                 }
  128.  
  129.                                 FlatButtonRound {
  130.                                     id: tempremovebtn1
  131.                                     anchors.right: parent.right
  132.                                     anchors.rightMargin: 0
  133.                                     text1: awesome.icons.fa_remove
  134.                                     family: awesome.family
  135.                                     onClicked: {
  136.                                         console.log("hiterl" + index)
  137.                                         upTemplateDialog.upTempAttr.remove(index)
  138.  
  139.                                     }
  140.                                 }
  141.                             }
  142.                         }
  143.                 }
  144.  
  145.                 GridLayout {
  146.  
  147.                     anchors.margins: 0
  148.                     anchors.topMargin: 10
  149.                     anchors.right: parent.right
  150.                     anchors.rightMargin: 0
  151.                     anchors.bottom: parent.bottom
  152.  
  153.                     id: tempgrid2
  154.                     columns: 3
  155.                     rowSpacing: 20
  156.  
  157.                     FlatButton {
  158.                         id: attributbutton12
  159.                         text1: "Attribut"
  160.                         onClicked: {
  161.                             /*upTemplateDialog.upTempAttr.append({type: "string",
  162.                                                                    name: ""
  163.                                                                })*/
  164.  
  165.  
  166.                             //testlistview.clear()
  167.                             for (var i = 0; i < upTemplateDialog.upTempAttr.count; i++) {
  168.                                 //testlistview.append({p:1})
  169.                             }
  170.  
  171.                             rep1.model = testlistview
  172.                         }
  173.                     }
  174.  
  175.                     FlatButton {
  176.                         id: attributbutton22
  177.                         text1: "Speichern"
  178.                         onClicked: {
  179.                             var nameList = [];
  180.                             var typeList = [];
  181.  
  182.                             for (var i = 1; i < upTemplateDialog.upTempAttr.count; i++) {
  183.                                 nameList.push(upTemplateDialog.upTempAttr.get(i).name)
  184.                                 typeList.push(upTemplateDialog.upTempAttr.get(i).type)
  185.                                 //nameList.reduce("reduce");
  186.                             }
  187.                             itemController.updateTemplate(upTextEditTemplateName.text, upTempColorRect.color, nameList, typeList);
  188.                             //js Funktion updateTemplate(oid, name, color)// braucht nur die beiden parameter da der rest
  189.                             upTemplateDialog.close()
  190.                         }
  191.                     }
  192.  
  193.                     FlatButton {
  194.                         id: attributbutton13
  195.                         text1: "Abbrechen"
  196.                         onClicked: {
  197.                             templates.get(upTemplateDialog.idx).attr.clear();
  198.                             for (var i = 1; i < upTemplateDialog.upTempAttrSave.count; i++) {
  199.                                 templates.get(upTemplateDialog.idx).attr.append({name: upTemplateDialog.upTempAttrSave.get(i).name, type: upTemplateDialog.upTempAttrSave.get(i).type})
  200.                             }
  201.                             upTemplateDialog.close()
  202.                         }
  203.                     }
  204.                 }
  205.             }
  206.         }
  207.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement