import QtQuick
import QtQuick.Layouts
import QtQuick.Controls

ColumnLayout
{
    property alias name: companyName
    property alias street: street
    property alias house: houseno
    property alias zipcode: zipcode
    property alias city: city
    anchors.fill: parent
    anchors.topMargin: 50

    RowLayout
    {
        Layout.fillWidth: true
        Label
        {
            text: qsTr("Namen")
            // font.pixelSize: 57
            // font.bold: true
        }

        TextField
        {
            id: companyName
            Layout.fillWidth: true
        }
    }

    RowLayout
    {
        Layout.fillWidth: true
        Label
        {
            text: qsTr("Straße")
            // font.pixelSize: 57
            // font.bold: true
        }

        TextField
        {
            id: street
            Layout.fillWidth: true
        }

        Label
        {
            text: qsTr("Haus-Nr.")
            // font.pixelSize: 57
            // font.bold: true
        }

        TextField
        {
            id: houseno
            Layout.fillWidth: true
        }
    }


    RowLayout
    {
        Layout.fillWidth: true
        Label
        {
            text: qsTr("PLZ")
        }

        ComboBox
        {
            id: zipcode
            Layout.fillWidth: true
            editable: true
            model: address_model
            textRole: "display"
            popup.height: 300
            onCurrentIndexChanged: city.currentIndex = zipcode.currentIndex
            validator: RegularExpressionValidator
            {
                regularExpression: /([0-9]{1,5})/
            }
        }

        Label
        {
            text: qsTr("Stadt")
            // font.pixelSize: 57
            // font.bold: true
        }

        ComboBox
        {
            id: city
            Layout.fillWidth: true
            editable: true
            model: address_model
            textRole: "city"
            popup.height: 300
            currentIndex: -1
        }
    }

    Item
    {
        Layout.fillHeight: true
    }

    Component.onCompleted:
    {
        var c = config.getCompanyInfo()
        if (Object.keys(c).length)
        {
          companyName.text = c['NAME']
          street.text = c['STREET']
          houseno.text = c['HOUSE']
          zipcode.editText = c['ZIPCODE']
          city.editText = c['CITY']
        }
    }
}
