Exemple #1
0
 def actionAddObject(self, par, obj):
     if isinstance(par, Jso.JObject):
         child = Jso.JObject()
         new_item = Jso.JKey("<new key>", "")
         child.addKey(new_item)
         new = Jso.JKey("<new key>", child)
         if obj is not None:
             inx = par.index(obj) + 1
         else:
             inx = -1
         par.addKey(new, inx)
     elif isinstance(par, Jso.JList):
         child = Jso.JObject()
         new_item = Jso.JKey("<new key>", "")
         child.addKey(new_item)
         if obj is not None:
             inx = par.index(obj) + 1
             new = Jso.JIndex(inx, child)
         else:
             inx = -1
             new = Jso.JIndex(par.count(), child)
         par.append(new, inx)
     self.treeView.refresh()
     self.flow.add(copy.deepcopy(self.jsonData))
 def createJsonUi(self, obj, parent: QStandardItem):
     if isinstance(obj.value, Jso.JObject):
         items = []
         for h in self.headerData:
             if h['key'] in obj.value:
                 item = QStandardItem(
                     obj.value.getItem(h['key']).getValueStr())
                 item.setEditable(h['editable'])
                 item.setData(
                     self.getItemData(obj.value.getItem(h['key']), obj))
             else:
                 key = Jso.JKey(h['key'], "")
                 obj.value.addKey(key)
                 item = QStandardItem('')
                 item.setEditable(True)
                 item.setData(self.getItemData(key, obj))
             items.append(item)
         parent.appendRow(items)
 def createLine(self):
     obj = Jso.JObject()
     for col in self.headerData:
         obj.addKey(Jso.JKey(col['key'], ""))
     return obj