AddressBookTable.qml 4.32 KB
Newer Older
Baked Alaska's avatar
Baked Alaska committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
//17copyright   

                                                

import QtQuick 2.0
import moneroComponents.Clipboard 1.0

ListView {
    id: listView
    clip: true
    boundsBehavior: ListView.StopAtBounds

    footer: Rectangle {
        height: 127
        width: listView.width
        color: "#FFFFFF"

        Text {
            anchors.centerIn: parent
            font.family: "Arial"
            font.pixelSize: 14
            color: "#545454"
            text: qsTr("No more results") + translationManager.emptyString
        }
    }

    property var previousItem
    delegate: Rectangle {
        id: delegate
        height: 64
        width: listView.width
        color: index % 2 ? "#F8F8F8" : "#FFFFFF"
        z: listView.count - index
        function collapseDropdown() { dropdown.expanded = false }

        Text {
            id: descriptionText
            anchors.left: parent.left
            anchors.top: parent.top
            anchors.topMargin: 12
            width: text.length ? (descriptionArea.containsMouse ? dropdown.x - x - 12 : 139) : 0
            font.family: "Arial"
            font.bold: true
            font.pixelSize: 19
            color: "#444444"
            elide: Text.ElideRight
            text: description

            MouseArea {
                id: descriptionArea
                anchors.fill: parent
                hoverEnabled: true
            }
        }

        TextEdit {
            id: addressText
            selectByMouse: true
            anchors.bottom: descriptionText.bottom
            anchors.left: descriptionText.right
            anchors.right: dropdown.left
            anchors.leftMargin: description.length > 0 ? 12 : 0
            anchors.rightMargin: 40
            font.family: "Arial"
            font.pixelSize: 16
            color: "#545454"
            text: address
        }

        Text {
            id: paymentLabel
            anchors.left: parent.left
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 12

            width: 139
            font.family: "Arial"
            font.pixelSize: 12
            color: "#535353"
            text: qsTr("Payment ID:") + translationManager.emptyString
        }

        TextEdit {
            selectByMouse: true;
            anchors.bottom: paymentLabel.bottom
            anchors.left: paymentLabel.right
            anchors.leftMargin: 12
            anchors.rightMargin: 12
            anchors.right: dropdown.left


            font.family: "Arial"
            font.pixelSize: 13
            color: "#545454"
            text: paymentId
        }

        ListModel {
            id: dropModel
            ListElement { name: "<b>Copy address to clipboard</b>"; icon: "../images/dropdownCopy.png" }
            ListElement { name: "<b>Send to this address</b>"; icon: "../images/dropdownSend.png" }
//            ListElement { name: "<b>Find similar transactions</b>"; icon: "../images/dropdownSearch.png" }
            ListElement { name: "<b>Remove from address book</b>"; icon: "../images/dropdownDel.png" }
        }

        Clipboard { id: clipboard }
        TableDropdown {
            id: dropdown
            anchors.right: parent.right
            anchors.verticalCenter: parent.verticalCenter
            anchors.rightMargin: 5
            dataModel: dropModel
            z: 1
            onExpandedChanged: {
                if(expanded) {
                    listView.previousItem = delegate
                    listView.currentIndex = index
                }
            }
            onOptionClicked: {
                // Ensure tooltip is closed
                appWindow.toolTip.visible = false;
                if(option === 0)
                    clipboard.setText(address)
                else if(option === 1){
                   console.log("Sending to: ", address +" "+ paymentId);
                   middlePanel.sendTo(address, paymentId, description);
                   leftPanel.selectItem(middlePanel.state)
                } else if(option === 2){
                    console.log("Delete: ", rowId);
                    currentWallet.addressBookModel.deleteRow(rowId);
                }
            }
        }

        Rectangle {
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.bottom: parent.bottom
            height: 1
            color: "#DBDBDB"
        }
    }
}