diff --git a/pages/AddressBook.qml b/pages/AddressBook.qml index 315892ff..9bb4718e 100644 --- a/pages/AddressBook.qml +++ b/pages/AddressBook.qml @@ -286,11 +286,12 @@ Rectangle { MoneroComponents.Label { fontSize: 32 wrapMode: Text.WordWrap - text: (root.editEntry ? qsTr("Edit an address") : qsTr("Add an address")) + translationManager.emptyString + text: (root.editEntry ? qsTr("Edit entry") : qsTr("Add an address")) + translationManager.emptyString } MoneroComponents.LineEditMulti { id: addressLine + visible: !root.editEntry Layout.topMargin: 20 labelText: " %1" .arg(qsTr("Address")) + translationManager.emptyString @@ -380,7 +381,7 @@ Rectangle { enabled: root.checkInformation(addressLine.text, appWindow.persistentSettings.nettype) onClicked: { console.log("Add") - if (!currentWallet.addressBook.addRow(addressLine.text.trim(),"", descriptionLine.text)) { + if (!root.editEntry && !currentWallet.addressBook.addRow(addressLine.text.trim(),"", descriptionLine.text)) { informationPopup.title = qsTr("Error") + translationManager.emptyString; // TODO: check currentWallet.addressBook.errorString() instead. if(currentWallet.addressBook.errorCode() === AddressBook.Invalid_Address) @@ -393,11 +394,9 @@ Rectangle { informationPopup.onCloseCallback = null informationPopup.open(); } else { - if (root.editEntry) { - currentWallet.addressBook.deleteRow(addressBookListView.currentIndex); - } - root.showAddressBook(); + currentWallet.addressBook.setDescription(addressBookListView.currentIndex, descriptionLine.text); } + root.showAddressBook() } } diff --git a/src/libwalletqt/AddressBook.cpp b/src/libwalletqt/AddressBook.cpp index fbcbc4ab..f16e7df7 100644 --- a/src/libwalletqt/AddressBook.cpp +++ b/src/libwalletqt/AddressBook.cpp @@ -139,3 +139,19 @@ QString AddressBook::getDescription(const QString &address) const } return QString::fromStdString(m_rows.value(*it)->getDescription()); } + +void AddressBook::setDescription(int index, const QString &description) +{ + bool result; + + { + QWriteLocker locker(&m_lock); + + result = m_addressBookImpl->setDescription(index, description.toStdString()); + } + + if (result) + { + getAll(); + } + } diff --git a/src/libwalletqt/AddressBook.h b/src/libwalletqt/AddressBook.h index 39551e66..7e666dca 100644 --- a/src/libwalletqt/AddressBook.h +++ b/src/libwalletqt/AddressBook.h @@ -53,6 +53,7 @@ public: Q_INVOKABLE int errorCode() const; Q_INVOKABLE int lookupPaymentID(const QString &payment_id) const; Q_INVOKABLE QString getDescription(const QString &address) const; + Q_INVOKABLE void setDescription(int index, const QString &label); enum ErrorCode { Status_Ok,