Making a filesystem model from a folder list.



  • Hi,
    I am using PyQt4. I get the list of files from a server in json format and I want to use this with filesystem model. How can I do this? It seems I need to inherit the filesystem model and do some magic there but I hope to find an easier way. This is the structure:

    {
      "files": [
        {
          "name": "whistle_v2.gcode",
          "type": "machinecode",
          "size": 1468987,
          "refs": {
            "resource": "http://example.com/api/files/local/whistle_v2.gcode",
          },
        },
        {
          "name": "whistle_.gco",
          "type": "machinecode",
          "refs": {
            "resource": "http://example.com/api/files/sdcard/whistle_.gco"
          }
        },
        {
          "name": "folderA",
          "type": "folder",
          "children": [
            {
              "name": "test.gcode",
              "type": "machinecode",
              "size": 1234,
              "refs": {
                "resource": "http://example.com/api/files/local/folderA/test.gcode",
              }
            },
            {
              "name": "subfolder",
              "type": "folder",
              "children": [
                {
                  "name": "test.gcode",
                  "type": "machinecode",
                  "size": 100,
                  "refs": {
                    "resource": "http://example.com/api/files/local/folderA/subfolder/test2.gcode",
                  }
                },
              ],
              "size": 100,
              "refs": {
                "resource": "http://example.com/api/files/local/folderA/subfolder",
              }
          ],
          "size": 1334,
          "refs": {
            "resource": "http://example.com/api/files/local/folderA",
          }
        }
      ],
      "free": "3.2GB"
    }
    
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.