<commit_before>import QtQuick 2.4
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import Qt.labs.settings 1.0
import "qml"

Window {
    id: window
    visible: true

    width: 640
    height: 480
    color: "#112211"

    property string boardId: "550c1275568fdb3ffd27de9d" // testing board
    property string devKey: "c4ee8aed0832024bb0c28de3d1d265f8"
    property string token
    property real listWidth: width / 1.5
    property real margin: 8

    Settings {
        id: settings
        property alias boardId: window.boardId
        property alias devKey: window.devKey
        property alias token: window.token
    }

    Dialog {
        id: credentialsDialog
        title: "Log in to Trello"

        GridLayout {
            columns: 2
            width: parent ? parent.width : implicitWidth
            Text { text: "Board ID" }
            TextField {
                id: boardIdField
                Layout.fillWidth: true
                text: boardId
            }

            Text { text: "Dev Key" }
            TextField {
                id: devKeyField
                Layout.fillWidth: true
                text: devKey
            }

            Text { text: "Token" }
            TextField {
                id: tokenField
                Layout.fillWidth: true
                text: token
            }
            Text {
                text: 'Please get an <a href="xxx">access token</a> and paste it above'
                onLinkActivated: Qt.openUrlExternally("https://trello.com/1/authorize?key=" + devKeyField.text +
                         "&name=QtQuick+Trello+Client&expiration=never&response_type=token")
                Layout.columnSpan: 2
            }
        }
        onAccepted: {
            window.boardId = boardIdField.text
            window.devKey = devKeyField.text
            window.token = tokenField.text
            getLists()
        }
    }

    function getJson(url, callback) {
        console.log("getJson " + url)
        var request = new XMLHttpRequest()
        request.open('GET', url)
        request.onreadystatechange = function(event) {
            if (request.readyState === XMLHttpRequest.DONE) {
                console.log(request.responseText)
                if (request.responseText.indexOf("invalid token") >= 0) {
                    credentialsDialog.setTitle("Please use a valid access token")
                    credentialsDialog.open()
                    tokenField.selectAll()
                }
                else
                    callback(JSON.parse(request.responseText))
            }
        }
        request.send()
    }

    function getLists() {
        getJson("https://api.trello.com/1/boards/" + boardId +
            "/lists?key=" + devKey +
            "&token=" + token, gotLists)
    }

    function gotLists(json) {
        console.log("got lists " + json)
        lists.model = json
    }

    Flickable {
        id: listsFlick
        flickableDirection: Flickable.HorizontalFlick
        anchors.fill: parent
        anchors.margins: margin
        Row {
            id: listRow
            spacing: margin * 1.5
        }
        Instantiator {
            id: lists
            CardsList {
                parent: listRow
                objectName: "CardsList " + name
                height: listsFlick.height
                width: listWidth
                name: modelData.name
                listId: modelData.id
            }
        }
    }

    Component.onCompleted: {
        if (token && boardId && devKey)
            getLists()
        else
            credentialsDialog.visible = true
    }

    FontLoader { id: iconFont; source: "qrc:/resources/fontawesome-webfont.ttf" }
}<commit_msg>nevermind about the Instantiator... JSON works for a ListView model<commit_after>import QtQuick 2.4
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import Qt.labs.settings 1.0
import "qml"

Window {
    id: window
    visible: true

    width: 640
    height: 480
    color: "#112211"

    property string boardId: "550c1275568fdb3ffd27de9d" // testing board
    property string devKey: "c4ee8aed0832024bb0c28de3d1d265f8"
    property string token
    property real listWidth: width / 1.5
    property real margin: 8

    Settings {
        id: settings
        property alias boardId: window.boardId
        property alias devKey: window.devKey
        property alias token: window.token
    }

    Dialog {
        id: credentialsDialog
        title: "Log in to Trello"

        GridLayout {
            columns: 2
            width: parent ? parent.width : implicitWidth
            Text { text: "Board ID" }
            TextField {
                id: boardIdField
                Layout.fillWidth: true
                text: boardId
            }

            Text { text: "Dev Key" }
            TextField {
                id: devKeyField
                Layout.fillWidth: true
                text: devKey
            }

            Text { text: "Token" }
            TextField {
                id: tokenField
                Layout.fillWidth: true
                text: token
            }
            Text {
                text: 'Please get an <a href="xxx">access token</a> and paste it above'
                onLinkActivated: Qt.openUrlExternally("https://trello.com/1/authorize?key=" + devKeyField.text +
                         "&name=QtQuick+Trello+Client&expiration=never&response_type=token")
                Layout.columnSpan: 2
            }
        }
        onAccepted: {
            window.boardId = boardIdField.text
            window.devKey = devKeyField.text
            window.token = tokenField.text
            getLists()
        }
    }

    function getJson(url, callback) {
        console.log("getJson " + url)
        var request = new XMLHttpRequest()
        request.open('GET', url)
        request.onreadystatechange = function(event) {
            if (request.readyState === XMLHttpRequest.DONE) {
                console.log(request.responseText)
                if (request.responseText.indexOf("invalid token") >= 0) {
                    credentialsDialog.setTitle("Please use a valid access token")
                    credentialsDialog.open()
                    tokenField.selectAll()
                }
                else
                    callback(JSON.parse(request.responseText))
            }
        }
        request.send()
    }

    function getLists() {
        getJson("https://api.trello.com/1/boards/" + boardId +
            "/lists?key=" + devKey +
            "&token=" + token, gotLists)
    }

    function gotLists(json) {
        console.log("got lists " + json)
        lists.model = json
    }

    ListView {
        id: lists
        orientation: Qt.Horizontal
        anchors.fill: parent
        anchors.margins: margin
        spacing: margin * 1.5
        delegate: CardsList {
            objectName: "CardsList " + name
            height: lists.height
            width: listWidth
            name: modelData.name
            listId: modelData.id
        }
    }

    Component.onCompleted: {
        if (token && boardId && devKey)
            getLists()
        else
            credentialsDialog.visible = true
    }

    FontLoader { id: iconFont; source: "qrc:/resources/fontawesome-webfont.ttf" }
}
{'fraction_non_alphanumeric': 0.08628348364517431, 'fraction_numerical': 0.017768205680441514, 'mean_word_length': 1.5186440677966102, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '689736', 'n_tokens_mistral': 2153, 'n_tokens_neox': 1981, 'n_words': 472}