import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Dialogs 1.0
import QtQuick.Controls.Styles 1.0
import QtQuick.Layouts 1.0

Item {

    width: 300; height: 300
    ListModel {
        id: contactModel
        ListElement {
            name: "Jim Williams"
            portrait: "pics/favicon.png"
        }
        ListElement {
            name: "John Brown"
            portrait: "pics/favicon.png"
        }
        ListElement {
            name: "Bill Smyth"
            portrait: "pics/favicon.png"
        }
        ListElement {
            name: "Sam Wise"
            portrait: "pics/favicon.png"
        }
    }

    ToolBar {
        id:tool
        anchors.topMargin: 0
        anchors.top: parent.top
        height: 32

        width: parent.width

    }



        ScrollView{
            anchors.top: tool.bottom
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.bottom: parent.bottom



            focus: true
            GridView {
                id: gridView
                anchors.fill: parent
                cellWidth: 100; cellHeight: 100
                focus: true
                model: contactModel
                //keyNavigationWraps: true
                highlight: Rectangle { width: 80; height: 80; color: "lightsteelblue" }

                delegate: Item {
                    width: gridView.cellWidth; height: gridView.cellHeight
                    focus: true
                    Image {
                        id: myIcon
                        y: 18; anchors.horizontalCenter: parent.horizontalCenter
                        //source: "image://awfan.cn/data#"+ ICON
                        source: portrait
                        sourceSize.width: 48
                        sourceSize.height: 48
                    }
                    Label {
                        anchors { top: myIcon.bottom; topMargin: 12; horizontalCenter: parent.horizontalCenter }
                        text: "TITLE"
                    }
                    Keys.onPressed: {
                        console.log("...presss")
                        if ((event.key === Qt.Key_V) && (event.modifiers & Qt.ControlModifier)) {

                            console.log("...ctrl + v")
                            event.accepted = true
                        }
                    }

                    MouseArea {
                        anchors.fill: parent
                        onClicked: gridView.currentIndex = index
                    }

                }


            }

        }

}
