.pragma library

function firstConf(tabs)
{
    let pyqcrm_conf = {};
    pyqcrm_conf[tabs.name] = {}
    for (var i = 0; i < tabs.children.length; i++)
    {
        if (tabs.children[i].name)
        {
            if (!tabs.children[i].text.trim())
            return false
            if (pyqcrm_conf[tabs.name][tabs.children[i].name] !== "DB_PASS")
                pyqcrm_conf[tabs.name] [tabs.children[i].name] = tabs.children[i].text.trim()
            else
                pyqcrm_conf[tabs.name] [tabs.children[i].name] = tabs.children[i].text
        }
    }
    return pyqcrm_conf
}


function parseForm(...form)
{
    let data_form = {};
    for (var i = 0; i < form.length; i++)
    {
        for (var j = 0; j < form[i].children.length; j++)
        {
            if (form[i].children[j].toString().startsWith("Combo"))
            {
                if(form[i].children[j].editText)
                {
                    data_form[form[i].children[j].name] = form[i].children[j].editText
                }
                else
                {
                    data_form[form[i].children[j].name] = form[i].children[j].currentText
                }
            }
            else if (form[i].children[j].toString().startsWith("TextField"))
            {
                data_form[form[i].children[j].name] = form[i].children[j].text.trim()
            }
            else if (form[i].children[j].toString().startsWith("Scroll"))
            {
                data_form[form[i].children[j].contentChildren[0].name] = form[i].children[j].contentChildren[0].text.trim()
            }
            else if (form[i].children[j].toString().startsWith("CheckBox"))
            {
                data_form[form[i].children[j].name] = form[i].children[j].checked
            }
            else if (form[i].children[j].toString().startsWith("SpinBox"))
            {
                data_form[form[i].children[j].name] = form[i].children[j].value
            }
            // else if (form[i].children[j].toString().startsWith("QQuickContentItem"))
            // {
            //     console.log(form[i].children[j].children.children)

            //     for (var k = 0; k < form[i].children[j].length; k++)
            //     {
            //         console.log(form[i].children[j].name)
            //     }
            // }
        }
    }
    return data_form
}

