import QtQuick
import QtQuick.Controls
import QtQuick.Layouts


RowLayout
{
    id: searchBar


    TextField
    {
        id: searchField
        placeholderText: qsTr("Suche")
        leftPadding: 3
        rightPadding: 3
        Layout.preferredWidth: 300

        Button
        {
            icon.source: "qrc:/images/search.svg"
            icon.color: "olive"
            x: parent.x + parent.width - width
            height: parent.height
            flat: true
        }


        Button
        {
            id: filterBtn
            icon.source: "qrc:/images/filter.svg"
            icon.color: "olive"
            x: parent.x + parent.width
            height: searchField.height
            flat: true
            onClicked: filterPopup.open()
        }
    }

    Popup
    {
        id: filterPopup
        x: filterBtn.x + filterBtn.width
        y: filterBtn.y
        width: 100
        height: 150
        modal: true
        focus: true
        closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
        contentItem: Item
        {
            ColumnLayout
            {
                anchors.fill: parent
                //id: filterContent

                Repeater
                {
                    model: availableFilters

                    CheckBox
                    {
                        text: model.modelData
                        onClicked:
                        {
                            setFilter(text, checkState)
                        }
                    }

                }
            }
        }
    }

    function setFilter(filter,activated)
    {
        console.log(filter)
        console.log(activated)

    }
}
