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

import QtQuick 2.1
import QtQuick.Controls 1.1
import QtQuick.Dialogs 1.2

import UM 1.2 as UM
import Cura 1.0 as Cura

UM.ManagementPage
{
    id: base;

    title: catalog.i18nc("@title:tab", "Materials");

    model: UM.InstanceContainersModel
    {
        filter:
        {
            var result = { "type": "material" }
            if(Cura.MachineManager.filterMaterialsByMachine)
            {
                result.definition = Cura.MachineManager.activeDefinitionId
                if(Cura.MachineManager.hasVariants)
                {
                    result.variant = Cura.MachineManager.activeVariantId
                }
            }
            else
            {
                result.definition = "fdmprinter"
            }
            return result
        }

        sectionProperty: "brand"
    }

    delegate: Rectangle
    {
        width: objectList.width;
        height: childrenRect.height;
        color: isCurrentItem ? palette.highlight : index % 2 ? palette.base : palette.alternateBase
        property bool isCurrentItem: ListView.isCurrentItem

        Row
        {
            spacing: UM.Theme.getSize("default_margin").width / 2;
            anchors.left: parent.left;
            anchors.leftMargin: UM.Theme.getSize("default_margin").width;
            anchors.right: parent.right;
            Rectangle
            {
                width: parent.height * 0.8
                height: parent.height * 0.8
                color: model.metadata.color_code
                border.color: isCurrentItem ? palette.highlightedText : palette.text;
                anchors.verticalCenter: parent.verticalCenter
            }
            Label
            {
                width: parent.width * 0.3
                text: model.metadata.material
                elide: Text.ElideRight
                font.italic: model.id == activeId
                color: isCurrentItem ? palette.highlightedText : palette.text;
            }
            Label
            {
                text: (model.name != model.metadata.material) ? model.metadata.color_name : ""
                elide: Text.ElideRight
                font.italic: model.id == activeId
                color: isCurrentItem ? palette.highlightedText : palette.text;
            }<commit_msg>Show material by its displayname instead of its color<commit_after>// Copyright (c) 2016 <NAME>.
// Uranium is released under the terms of the AGPLv3 or higher.

import QtQuick 2.1
import QtQuick.Controls 1.1
import QtQuick.Dialogs 1.2

import UM 1.2 as UM
import Cura 1.0 as Cura

UM.ManagementPage
{
    id: base;

    title: catalog.i18nc("@title:tab", "Materials");

    model: UM.InstanceContainersModel
    {
        filter:
        {
            var result = { "type": "material" }
            if(Cura.MachineManager.filterMaterialsByMachine)
            {
                result.definition = Cura.MachineManager.activeDefinitionId
                if(Cura.MachineManager.hasVariants)
                {
                    result.variant = Cura.MachineManager.activeVariantId
                }
            }
            else
            {
                result.definition = "fdmprinter"
            }
            return result
        }

        sectionProperty: "brand"
    }

    delegate: Rectangle
    {
        width: objectList.width;
        height: childrenRect.height;
        color: isCurrentItem ? palette.highlight : index % 2 ? palette.base : palette.alternateBase
        property bool isCurrentItem: ListView.isCurrentItem

        Row
        {
            spacing: UM.Theme.getSize("default_margin").width / 2;
            anchors.left: parent.left;
            anchors.leftMargin: UM.Theme.getSize("default_margin").width;
            anchors.right: parent.right;
            Rectangle
            {
                width: parent.height * 0.8
                height: parent.height * 0.8
                color: model.metadata.color_code
                border.color: isCurrentItem ? palette.highlightedText : palette.text;
                anchors.verticalCenter: parent.verticalCenter
            }
            Label
            {
                width: parent.width * 0.3
                text: model.metadata.material
                elide: Text.ElideRight
                font.italic: model.id == activeId
                color: isCurrentItem ? palette.highlightedText : palette.text;
            }
            Label
            {
                text: (model.name != model.metadata.material) ? model.name : ""
                elide: Text.ElideRight
                font.italic: model.id == activeId
                color: isCurrentItem ? palette.highlightedText : palette.text;
            }
{'fraction_non_alphanumeric': 0.08376636873830805, 'fraction_numerical': 0.010392849719393058, 'mean_word_length': 1.5353003161222338, 'pattern_counts': {'":': 2, '<': 5, '<?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': '6071232', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1228, 'n_words': 272}