<commit_before>// Copyright (c) 2015 <NAME>.
// Uranium is released under the terms of the AGPLv3 or higher.

import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1

import UM 1.2 as UM
import Cura 1.0 as Cura

Item
{
    id: base;

    property Action configureSettings;
    signal showTooltip(Item item, point location, string text);
    signal hideTooltip();

    TextField
    {
        id: filter;
        visible: !monitoringPrint

        anchors
        {
            top: parent.top
            left: parent.left
            leftMargin: UM.Theme.getSize("default_margin").width
            //right: parent.right
        }

        placeholderText: catalog.i18nc("@label:textbox", "Filter...")

        onTextChanged: {
            definitionsModel.filter = {"label": "*" + text};
            definitionsModel.expanded = text.length > 0 ? ["*"] : [""]
        }
    }

    ScrollView
    {
        anchors.top: filter.bottom;
        anchors.bottom: parent.bottom;
        anchors.right: parent.right;
        anchors.left: parent.left;
        anchors.topMargin: UM.Theme.getSize("default_margin").width

        style: UM.Theme.styles.scrollview;
        flickableItem.flickableDirection: Flickable.VerticalFlick;

        ListView
        {
            id: contents
            spacing: UM.Theme.getSize("default_lining").height;
            cacheBuffer: 1000000;   // Set a large cache to effectively just cache every list item.

            model: UM.SettingDefinitionsModel {
                id: definitionsModel;
                containerId: Cura.MachineManager.activeDefinitionId
                visibilityHandler: UM.SettingPreferenceVisibilityHandler { }
                exclude: ["machine_settings", "command_line_settings", "infill_mesh", "infill_mesh_order"] // TODO: infill_mesh settigns are excluded hardcoded, but should be based on the fact that settable_globally, settable_per_meshgroup and settable_per_extruder are false.
                expanded: Printer.expandedCategories
                onExpandedChanged: Printer.setExpandedCategories(expanded)
                onVisibilityChanged: Cura.SettingInheritanceManager.forceUpdate()
            }

            delegate: Loader
            {
                id: delegate

                width: UM.Theme.getSize("sidebar").width;
                height: provider.properties.enabled == "True" ? UM.Theme.getSize("section").height : - contents.spacing
                Behavior on height { NumberAnimation { duration: 100 } }
                opacity: provider.properties.enabled == "True" ? 1 : 0
                Behavior on opacity { NumberAnimation { duration: 100 } }
                enabled:
                {<commit_msg>Restore expanded categories when clearing filter<commit_after>// Copyright (c) 2015 Ultimaker B.V.
// Uranium is released under the terms of the AGPLv3 or higher.

import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1

import UM 1.2 as UM
import Cura 1.0 as Cura

Item
{
    id: base;

    property Action configureSettings;
    signal showTooltip(Item item, point location, string text);
    signal hideTooltip();

    TextField
    {
        id: filter;
        visible: !monitoringPrint

        anchors
        {
            top: parent.top
            left: parent.left
            leftMargin: UM.Theme.getSize("default_margin").width
            //right: parent.right
        }

        placeholderText: catalog.i18nc("@label:textbox", "Filter...")

        property var expandedCategories
        property bool lastFilterEmpty: true

        onTextChanged: {
            definitionsModel.filter = {"label": "*" + text};
            var _filterEmpty = (text.length == 0);
            if(_filterEmpty != lastFilterEmpty)
            {
                if(!_filterEmpty)
                {
                    expandedCategories = definitionsModel.expanded.slice();
                    definitionsModel.expanded = ["*"];
                }
                else
                {
                    definitionsModel.expanded = expandedCategories;
                }
                lastFilterEmpty = _filterEmpty;
            }
        }
    }

    ScrollView
    {
        anchors.top: filter.bottom;
        anchors.bottom: parent.bottom;
        anchors.right: parent.right;
        anchors.left: parent.left;
        anchors.topMargin: UM.Theme.getSize("default_margin").width

        style: UM.Theme.styles.scrollview;
        flickableItem.flickableDirection: Flickable.VerticalFlick;

        ListView
        {
            id: contents
            spacing: UM.Theme.getSize("default_lining").height;
            cacheBuffer: 1000000;   // Set a large cache to effectively just cache every list item.

            model: UM.SettingDefinitionsModel
            {
                id: definitionsModel;
                containerId: Cura.MachineManager.activeDefinitionId
                visibilityHandler: UM.SettingPreferenceVisibilityHandler { }
                exclude: ["machine_settings", "command_line_settings", "infill_mesh", "infill_mesh_order"] // TODO: infill_mesh settigns are excluded hardcoded, but should be based on the fact that settable_globally, settable_per_meshgroup and settable_per_extruder are false.
                expanded: Printer.expandedCategories
                onExpandedChanged: Printer.setExpandedCategories(expanded)
                onVisibilityChanged: Cura.SettingInheritanceManager.forceUpdate()
            }

            delegate: Loader
            {
                id: delegate

                width: UM.Theme.getSize("sidebar").width;
                height: provider.properties.enabled == "True" ? UM.Theme.getSize("section").height : - contents.spacing
                Behavior on height { NumberAnimation { duration: 100 } }
                opacity: provider.properties.enabled == "True" ? 1 : 0
                Behavior on opacity { NumberAnimation { duration: 100 } }
                enabled:
                {
{'fraction_non_alphanumeric': 0.085954223612712, 'fraction_numerical': 0.011526428453811955, 'mean_word_length': 1.9847665847665847, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2257142', 'n_tokens_mistral': 1681, 'n_tokens_neox': 1534, 'n_words': 381}