<commit_before>import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Window 2.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.1

BasicWindow {
    id: keyWindow

    property alias  nameLabel: nameLabel
    property alias  addButton: addButton
    property alias  qmlMetaKeyModel: qmlMetaKeyModel
    property alias  nameTextField: nameTextField
    property alias  valueLabel: valueLabel
    property alias  valueTextField: valueTextField
    property bool   nameReadOnly: false
    property string valuePlaceHolder: "Meta Key Value..."
    property int    modelIndex: 0
    property bool   isArray: false
    property string path: ""
    property string keyName: ""
    property string keyValue: ""
    property bool   isEdited: false

    contents: ColumnLayout {
        anchors.fill: parent
        anchors.margins: defaultMargins
        anchors.centerIn: parent
        spacing: defaultMargins

        Text{
            id: pathInfo
            text: path
            color: disabledPalette.text
        }
        GridLayout {
            columns: 2
            Label {
                id:nameLabel
                text: qsTr("Key Name: ")
            }
            TextField {
                id: nameTextField
                Layout.fillWidth: true
                focus: true
                text: keyName
            }
            Label {
                id: valueLabel
                text: qsTr("Key Value: ")
            }
            TextField {
                id: valueTextField
                Layout.fillWidth: true
                text: keyValue
            }
        }

        BasicRectangle {
            id: metaArea
            Layout.fillWidth: true
            Layout.fillHeight: true

            ScrollView {
                anchors.fill: parent
                anchors.margins: defaultSpacing
                ListView {
                    id: metaKeyListView
                    anchors.fill: parent
                    spacing: defaultMargins
                    model: qmlMetaKeyModel
                    delegate: metaKeyDelegate
                }
            }

            ListModel {
                id: qmlMetaKeyModel
            }
            Component {
                id: metaKeyDelegate

                NewMetaKey {
                    //check if user has edited metakeyname or metakeyvalue. This comparison can only happen here since
                    //"metaNameField.text" cannot be accessed outside the delegate.
                    Component.onCompleted: modelIndex = modelIndex + 1
                    metaNameField.readOnly: nameReadOnly
                    metaValueField.placeholderText: qsTr(valuePlaceHolder)

                    metaNameField.onTextChanged:  {
                        if(metaName !== metaNameField.text){
                            qmlMetaKeyModel.set(index, {"metaName": metaNameField.text})
                            isEdited = true
                        }
                    }
                    metaValueField.onTextChanged: {
                        if(metaValue !== metaValueField.text){
                            qmlMetaKeyModel.set(index, {"metaValue": metaValueField.text})
                            isEdited = true
                        }
                    }
                }
            }
        }
        Button {
            id: addButton

            anchors.horizontalCenter: parent.horizontalCenter
            text: qsTr("New Meta Key")
        }
    }
    cancelButton.onClicked: {<commit_msg>fixed naming if item is removed<commit_after>import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Window 2.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.1

BasicWindow {
    id: keyWindow

    property alias  nameLabel: nameLabel
    property alias  addButton: addButton
    property alias  qmlMetaKeyModel: qmlMetaKeyModel
    property alias  nameTextField: nameTextField
    property alias  valueLabel: valueLabel
    property alias  valueTextField: valueTextField
    property bool   nameReadOnly: false
    property string valuePlaceHolder: "Meta Key Value..."
    property int    modelIndex: 0
    property bool   isArray: false
    property string path: ""
    property string keyName: ""
    property string keyValue: ""
    property bool   isEdited: false

    contents: ColumnLayout {
        anchors.fill: parent
        anchors.margins: defaultMargins
        anchors.centerIn: parent
        spacing: defaultMargins

        Text{
            id: pathInfo
            text: path
            color: disabledPalette.text
        }
        GridLayout {
            columns: 2
            Label {
                id:nameLabel
                text: qsTr("Key Name: ")
            }
            TextField {
                id: nameTextField
                Layout.fillWidth: true
                focus: true
                text: keyName
            }
            Label {
                id: valueLabel
                text: qsTr("Key Value: ")
            }
            TextField {
                id: valueTextField
                Layout.fillWidth: true
                text: keyValue
            }
        }

        BasicRectangle {
            id: metaArea
            Layout.fillWidth: true
            Layout.fillHeight: true

            ScrollView {
                anchors.fill: parent
                anchors.margins: defaultSpacing
                ListView {
                    id: metaKeyListView
                    anchors.fill: parent
                    spacing: defaultMargins
                    model: qmlMetaKeyModel
                    delegate: metaKeyDelegate
                }
            }

            ListModel {
                id: qmlMetaKeyModel

                onCountChanged: modelIndex = count
            }
            Component {
                id: metaKeyDelegate

                NewMetaKey {
                    //check if user has edited metakeyname or metakeyvalue. This comparison can only happen here since
                    //"metaNameField.text" cannot be accessed outside the delegate.
                    Component.onCompleted: modelIndex
                    metaNameField.readOnly: nameReadOnly
                    metaValueField.placeholderText: qsTr(valuePlaceHolder)

                    metaNameField.onTextChanged:  {
                        if(metaName !== metaNameField.text){
                            qmlMetaKeyModel.set(index, {"metaName": metaNameField.text})
                            isEdited = true
                        }
                    }
                    metaValueField.onTextChanged: {
                        if(metaValue !== metaValueField.text){
                            qmlMetaKeyModel.set(index, {"metaValue": metaValueField.text})
                            isEdited = true
                        }
                    }
                }
            }
        }
        Button {
            id: addButton

            anchors.horizontalCenter: parent.horizontalCenter
            text: qsTr("New Meta Key")
        }
    }
    cancelButton.onClicked: {
{'fraction_non_alphanumeric': 0.055858120374249406, 'fraction_numerical': 0.004049713727133082, 'mean_word_length': 1.2571698707847463, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, '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': '5267465', 'n_tokens_mistral': 1755, 'n_tokens_neox': 1628, 'n_words': 426}