Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddressBook: description edits, remove hack #3096

Merged
merged 1 commit into from
Sep 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions pages/AddressBook.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "<style type='text/css'>a {text-decoration: none; color: #858585; font-size: 14px;}</style> %1"
.arg(qsTr("Address")) + translationManager.emptyString
Expand Down Expand Up @@ -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)
Expand All @@ -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()
}
}

Expand Down
16 changes: 16 additions & 0 deletions src/libwalletqt/AddressBook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
1 change: 1 addition & 0 deletions src/libwalletqt/AddressBook.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class AddressBook : public QObject
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,
Expand Down