Browse Source

allow adding address to address book in send dialog

0.8
Wladimir J. van der Laan 14 years ago
parent
commit
38deedc1b5
  1. 7
      src/qt/clientmodel.cpp
  2. 2
      src/qt/clientmodel.h
  3. 30
      src/qt/forms/sendcoinsdialog.ui
  4. 14
      src/qt/sendcoinsdialog.cpp
  5. 1
      src/qt/sendcoinsdialog.h

7
src/qt/clientmodel.cpp

@ -60,7 +60,7 @@ void ClientModel::update() @@ -60,7 +60,7 @@ void ClientModel::update()
addressTableModel->update();
}
ClientModel::StatusCode ClientModel::sendCoins(const QString &payTo, qint64 payAmount)
ClientModel::StatusCode ClientModel::sendCoins(const QString &payTo, qint64 payAmount, const QString &addToAddressBookAs)
{
uint160 hash160 = 0;
bool valid = false;
@ -95,7 +95,7 @@ ClientModel::StatusCode ClientModel::sendCoins(const QString &payTo, qint64 payA @@ -95,7 +95,7 @@ ClientModel::StatusCode ClientModel::sendCoins(const QString &payTo, qint64 payA
std::string strError = SendMoney(scriptPubKey, payAmount, wtx, true);
if (strError == "")
{
return OK;
// OK
}
else if (strError == "ABORTED")
{
@ -107,11 +107,12 @@ ClientModel::StatusCode ClientModel::sendCoins(const QString &payTo, qint64 payA @@ -107,11 +107,12 @@ ClientModel::StatusCode ClientModel::sendCoins(const QString &payTo, qint64 payA
return MiscError;
}
}
// Add addresses that we've sent to to the address book
std::string strAddress = payTo.toStdString();
CRITICAL_BLOCK(cs_mapAddressBook)
if (!mapAddressBook.count(strAddress))
SetAddressBookName(strAddress, "");
SetAddressBookName(strAddress, addToAddressBookAs.toStdString());
return OK;
}

2
src/qt/clientmodel.h

@ -39,7 +39,7 @@ public: @@ -39,7 +39,7 @@ public:
int getTotalBlocksEstimate() const;
/* Send coins */
StatusCode sendCoins(const QString &payTo, qint64 payAmount);
StatusCode sendCoins(const QString &payTo, qint64 payAmount, const QString &addToAddressBookAs=QString());
private:
OptionsModel *optionsModel;
AddressTableModel *addressTableModel;

30
src/qt/forms/sendcoinsdialog.ui

@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&amp;Amount:</string>
@ -90,9 +90,33 @@ @@ -90,9 +90,33 @@
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="BitcoinAmountField" name="payAmount" native="true"/>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="addToAddressBook">
<property name="toolTip">
<string>Add specified destination address to address book</string>
</property>
<property name="text">
<string>Add to address book as</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="addAsLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Label to add address as</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
@ -170,6 +194,8 @@ @@ -170,6 +194,8 @@
</customwidgets>
<tabstops>
<tabstop>payTo</tabstop>
<tabstop>addToAddressBook</tabstop>
<tabstop>addAsLabel</tabstop>
<tabstop>payAmount</tabstop>
<tabstop>pasteButton</tabstop>
<tabstop>addressBookButton</tabstop>

14
src/qt/sendcoinsdialog.cpp

@ -46,6 +46,7 @@ void SendCoinsDialog::on_sendButton_clicked() @@ -46,6 +46,7 @@ void SendCoinsDialog::on_sendButton_clicked()
{
bool valid;
QString payAmount = ui->payAmount->text();
QString label;
qint64 payAmountParsed;
valid = ParseMoney(payAmount.toStdString(), payAmountParsed);
@ -58,7 +59,13 @@ void SendCoinsDialog::on_sendButton_clicked() @@ -58,7 +59,13 @@ void SendCoinsDialog::on_sendButton_clicked()
return;
}
switch(model->sendCoins(ui->payTo->text(), payAmountParsed))
if(ui->addToAddressBook->isChecked())
{
// Add address to address book under label, if specified
label = ui->addAsLabel->text();
}
switch(model->sendCoins(ui->payTo->text(), payAmountParsed, label))
{
case ClientModel::InvalidAddress:
QMessageBox::warning(this, tr("Send Coins"),
@ -110,3 +117,8 @@ void SendCoinsDialog::on_buttonBox_rejected() @@ -110,3 +117,8 @@ void SendCoinsDialog::on_buttonBox_rejected()
{
reject();
}
void SendCoinsDialog::on_addToAddressBook_toggled(bool checked)
{
ui->addAsLabel->setEnabled(checked);
}

1
src/qt/sendcoinsdialog.h

@ -23,6 +23,7 @@ private: @@ -23,6 +23,7 @@ private:
ClientModel *model;
private slots:
void on_addToAddressBook_toggled(bool checked);
void on_buttonBox_rejected();
void on_addressBookButton_clicked();
void on_pasteButton_clicked();

Loading…
Cancel
Save