Author Topic: Scripting : Listing local files  (Read 1223 times)

Hey there!

I need to list some local files from a directory relative to my plugin. I'm going to use the results to build a ComboBox with strings.

I'm using a FolderListModel, but I don't know how to populate the ListElements dynamically.

Any suggestions? Do I need to write it in JavaScript?

Here's come code:

Code: [Select]
           

    ComboBox {
                width: 200

                FolderListModel {
                    id: folderModel
                    nameFilters: [ "*.sbs" ]
                    folder: "file:///" + alg.plugin_root_directory + "/graphs"
                    showDirs: false
                    showFiles: true
                }

                Component {
                    id: fileDelegate
                    Text { text: fileName }
                }

                model: folderModel
            }

-Michael

Here's my solution:

Code: [Select]
    FolderListModel {
        id: folderListModel
        folder: "my_reletive_path/"
    }

    ListModel {
        id : comboBoxModel
    }

    Repeater {
        model: folderListModel
        Component {
            Item {
                Component.onCompleted: comboBoxModel.append( {
                    path: folderListModel.get(index, "filePath"),
                    base: folderListModel.get(index, "fileBaseName")
                })
            }
        }
    }