import QtQuick          2.3
import QtQuick.Controls 1.2
import QtQuick.Layouts  1.2
import QtPositioning    5.3

import QGroundControl               1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controls      1.0
import QGroundControl.Palette       1.0

ColumnLayout {
    id:         root
    spacing:    ScreenTools.defaultFontPixelWidth * 0.5

    property var    model // list of lists (nested list contains all entries of ENTRY_NAME)
    property string headLine
    property bool   hideOnClicked: true

    enum EntryName  {
       Text = 0,
       Visible = 1,
       Enabled = 2,
       OnClicked = 3
    }

    QGCLabel { text: headLine }

    Repeater{
        model: root.model
        QGCButton {
            text:               modelData[QGCButtonColumn.EntryName.Text]
            visible:            modelData[QGCButtonColumn.EntryName.Visible]
            enabled:            modelData[QGCButtonColumn.EntryName.Enabled]
            Layout.fillWidth:   true

            onClicked: {
                if (hideOnClicked){
                dropPanel.hide()
                }
                root.model[index][QGCButtonColumn.EntryName.OnClicked]()
            }
        }
    }

} // ColumnLayout
