<commit_before>import QtQuick 2.6
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import Esri.ArcGISExtras 1.1

Item {
    id: attributeListView
    height: 300 * scaleFactor
    width: 250 * scaleFactor
    visible: false

    // user configurable properties

    // The color of the title bar of the view. The default color is "#3F51B5".
    property color barColor: "#3F51B5"

    // The color of the text and buttons in the title bar. The default color is "#FFFFFF".
    property color barTextColor: "#FFFFFF"

    // The background color of the cells in the view. The default color is "#F5F5F5".
    property color cellColor: "#F5F5F5"

    // The color of the cell borders in the view. The default color is "#000000".
    property color cellBorderColor: "#000000"

    // The height of the rows. The default height is 20.
    property real rowHeight: 20 * scaleFactor

    // Whether the view should stay permanently expanded. The default value is false.
    property bool alwaysExpanded: false

    // This property holds the model that provides data for the list of attributes.
    // When displaying the attributes of a Feature, the Feature must be loaded before using its attributes as a model.
    property var model: null

    // Emitted when an attributeValue has been modified.
    signal attributeValueChanged();

    // internal properties
    property int attributeCount
    property real columnWidth: width / 2
    property bool expanded: false

    Column {
        id: view
        height: attributeListView.height
        width: attributeListView.width
        anchors.fill: parent

        Rectangle {
            id: topBar
            width: columnWidth
            height: rowHeight
            color: attributeListView.barColor

            // animate on expand and collapse
            Behavior on width {
                SpringAnimation {
                    spring: 3
                    damping: .4
                }
            }

            // title
            Text {
                anchors {
                    verticalCenter: parent.verticalCenter
                    left: parent.left
                    margins: 5 * scaleFactor
                }
                width: topBar.width / 2
                elide: Text.ElideRight
                color: attributeListView.barTextColor
                renderType: Text.NativeRendering
                text: model !== null ? attributeCount + " Attributes" : "Attributes"
            }

            // controls to exit and expand/collapse view
            Row {
                anchors {
                    verticalCenter: parent.verticalCenter
                    right: parent.right
                    margins: 3 * scaleFactor
                }

                spacing: 2 * scaleFactor

                Rectangle {
                    color: "transparent"
                    width: attributeListView.height / 20
                    height: width
                    border.color: attributeListView.barTextColor
                    radius: 90
                    visible: !alwaysExpanded

                    Text {
                        anchors.centerIn: parent
                        verticalAlignment: Text.AlignVCenter
                        font.pixelSize: attributeListView.height / 33
                        color: attributeListView.barTextColor
                        renderType: Text.NativeRendering
                        text: expanded ? "-" : "+"
                    }

                    MouseArea {
                        anchors.fill: parent
                        onClicked: {
                            // ignore if user sets view to always be expanded
                            if (!alwaysExpanded) {

                                // if view is currently expanded, collapse it
                                if (expanded) {
                                    listView.height = 0;
                                    listView.width = 0;
                                    topBar.width = columnWidth;
                                }

                                // otherwise expand
                                else {
                                    listView.height = attributeListView.height - topBar.height;
                                    listView.width = attributeListView.columnWidth * 2 + 80 * scaleFactor;
                                    topBar.width = attributeListView.columnWidth * 2;
                                }

                                expanded = !expanded;
                            }
                        }
                    }
                }

                Rectangle {
                    color: "transparent"
                    width: attributeListView.height / 20
                    height: width
                    border.color: attributeListView.barTextColor
                    radius: 90

                    Text {
                        anchors.centerIn: parent
                        color: attributeListView.barTextColor
                        renderType: Text.NativeRendering
                        verticalAlignment: Text.AlignVCenter
                        horizontalAlignment: Text.AlignHCenter
                        text: "x"
                    }

                    MouseArea {
                        anchors.fill: parent
                        onClicked: {
                            attributeListView.visible = false;
                        }
                    }
                }
            }
        }

        // displays the attribute names on the left column and attribute values on the right
        ListView {
            id: listView
            height: 0
            width: 0
            model: attributeListView.model
            clip: true

            // animate on expand and collapse
            Behavior on height {
                SpringAnimation {
                    spring: 3
                    damping: .4
                }
            }

            Behavior on width {
                SpringAnimation {
                    spring: 3
                    damping: .4
                }
            }

            delegate: Row {

                // used to store old value in case user decides to cancel edits
                property var originalValue

                Rectangle {
                    height: rowHeight
                    width: listView.width / 2 - 80 * scaleFactor
                    color: cellColor
                    border.color: cellBorderColor

                    Text {
                        anchors.centerIn: parent
                        horizontalAlignment: Text.AlignHCenter
                        renderType: Text.NativeRendering
                        text: attributeName
                    }
                }

                TextField {
                    id: textField
                    text: attributeValue ? attributeValue : ""
                    height: rowHeight
                    width: listView.width / 2
                    horizontalAlignment: TextInput.AlignLeft

                    // controls to confirm or cancel edit
                    Row {
                        id: editControls
                        visible: false
                        anchors.right: parent.right

                        Rectangle {
                            height: rowHeight
                            width: 25 * scaleFactor
                            color: cellColor
                            border.color: cellBorderColor

                            Text {
                                anchors.centerIn: parent
                                horizontalAlignment: Text.AlignHCenter
                                renderType: Text.NativeRendering
                                text: "ok"
                            }<commit_msg>added doc for AttributeListView<commit_after>/*******************************************************************************
 * Copyright 2012-2016 Esri
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 ******************************************************************************/

import QtQuick 2.6
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import Esri.ArcGISExtras 1.1

/*!
    \qmltype AttributeListModel
    \ingroup ArcGISQtToolkit
    \inqmlmodule Esri.ArcGISRuntime.Toolkit.Controls
    \since 2.0
    \brief A view for displaying and editing attributes from an AttributeListModel from a \l Feature or a \l Graphic.
*/

Item {
    id: attributeListView
    visible: false

    /*========================================
         Configurable properties
    ========================================*/

    /*!
        \brief The color of the title bar of the view.

        The default color is \c "#3F51B5".
    */
    property color barColor: "#3F51B5"

    /*!
        \brief The color of the text and buttons in the title bar.

        The default color is \c "#FFFFFF".
    */
    property color barTextColor: "#FFFFFF"

    /*!
        \brief The background color of the cells in the view.

        The default color is \c "#F5F5F5".
    */
    property color cellColor: "#F5F5F5"

    /*!
        \brief The color of the cell borders in the view.

        The default color is \c "#000000".
    */
    property color cellBorderColor: "#000000"

    /*!
        \brief The height of the rows in the list.

        The default value is \c 20.
    */
    property real rowHeight: 20 * scaleFactor

    /*!
        \brief Whether the view should stay permanently expanded.

        The default value is \c false.
    */
    property bool alwaysExpanded: false

    /*!
        \brief This property holds the model that provides data for the list of attributes.

        When displaying the attributes of a Feature, the Feature must be loaded before using its attributes as a model.
    */
    property var model: null

    /*!
      \qmlsignal AttributeListModel::countChanged()
      \brief Emitted when an attribute value inside the model has been modified.
     */
    signal attributeValueChanged();

    // internal properties
     /*! \internal */
    property int attributeCount
     /*! \internal */
    property real columnWidth: width / 2
     /*! \internal */
    property bool expanded: false

    Column {
        id: view
        height: attributeListView.height
        width: attributeListView.width
        anchors.fill: parent

        Rectangle {
            id: topBar
            width: columnWidth
            height: rowHeight
            color: attributeListView.barColor

            // animate on expand and collapse
            Behavior on width {
                SpringAnimation {
                    spring: 3
                    damping: .4
                }
            }

            // title
            Text {
                anchors {
                    verticalCenter: parent.verticalCenter
                    left: parent.left
                    margins: 5 * scaleFactor
                }
                width: topBar.width / 2
                elide: Text.ElideRight
                color: attributeListView.barTextColor
                renderType: Text.NativeRendering
                text: model !== null ? attributeCount + " Attributes" : "Attributes"
            }

            // controls to exit and expand/collapse view
            Row {
                anchors {
                    verticalCenter: parent.verticalCenter
                    right: parent.right
                    margins: 3 * scaleFactor
                }

                spacing: 2 * scaleFactor

                Rectangle {
                    color: "transparent"
                    width: attributeListView.height / 20
                    height: width
                    border.color: attributeListView.barTextColor
                    radius: 90
                    visible: !alwaysExpanded

                    Text {
                        anchors.centerIn: parent
                        verticalAlignment: Text.AlignVCenter
                        font.pixelSize: attributeListView.height / 33
                        color: attributeListView.barTextColor
                        renderType: Text.NativeRendering
                        text: expanded ? "-" : "+"
                    }

                    MouseArea {
                        anchors.fill: parent
                        onClicked: {
                            // ignore if user sets view to always be expanded
                            if (!alwaysExpanded) {

                                // if view is currently expanded, collapse it
                                if (expanded) {
                                    listView.height = 0;
                                    listView.width = 0;
                                    topBar.width = columnWidth;
                                }

                                // otherwise expand
                                else {
                                    listView.height = attributeListView.height - topBar.height;
                                    listView.width = attributeListView.columnWidth * 2 + 50 * scaleFactor;
                                    topBar.width = attributeListView.columnWidth * 2;
                                }

                                expanded = !expanded;
                            }
                        }
                    }
                }

                Rectangle {
                    color: "transparent"
                    width: attributeListView.height / 20
                    height: width
                    border.color: attributeListView.barTextColor
                    radius: 90

                    Text {
                        anchors.centerIn: parent
                        color: attributeListView.barTextColor
                        renderType: Text.NativeRendering
                        verticalAlignment: Text.AlignVCenter
                        horizontalAlignment: Text.AlignHCenter
                        text: "x"
                    }

                    MouseArea {
                        anchors.fill: parent
                        onClicked: {
                            attributeListView.visible = false;
                        }
                    }
                }
            }
        }

        // displays the attribute names on the left column and attribute values on the right
        ListView {
            id: listView
            height: 0
            width: 0
            model: attributeListView.model
            clip: true

            // animate on expand and collapse
            Behavior on height {
                SpringAnimation {
                    spring: 3
                    damping: .4
                }
            }

            Behavior on width {
                SpringAnimation {
                    spring: 3
                    damping: .4
                }
            }

            delegate: Row {

                // used to store old value in case user decides to cancel edits
                property var originalValue

                Rectangle {
                    height: rowHeight
                    width: listView.width / 2 - 50 * scaleFactor
                    color: cellColor
                    border.color: cellBorderColor

                    Text {
                        anchors.centerIn: parent
                        horizontalAlignment: Text.AlignLeft
                        renderType: Text.NativeRendering
                        text: attributeName
                    }
                }

                TextField {
                    id: textField
                    text: attributeValue ? attributeValue : ""
                    height: rowHeight
                    width: listView.width / 2
                    horizontalAlignment: TextInput.AlignLeft

                    // controls to confirm or cancel edit
                    Row {
                        id: editControls
                        visible: false
                        anchors.right: parent.right

                        Rectangle {
                            height: rowHeight
                            width: 25 * scaleFactor
                            color: cellColor
                            border.color: cellBorderColor

                            Text {
                                anchors.centerIn: parent
                                horizontalAlignment: Text.AlignHCenter
                                renderType: Text.NativeRendering
                                text: "ok"
                            }
{'fraction_non_alphanumeric': 0.065213590535579, 'fraction_numerical': 0.009674223439594383, 'mean_word_length': 1.0329344864352565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5217021', 'n_tokens_mistral': 3826, 'n_tokens_neox': 3358, 'n_words': 1127}