Implement filter row instead of tabs, allows for more expressive filters
[novacoin.git] / src / qt / sendcoinsdialog.cpp
index 721ab14..33d9a25 100644 (file)
@@ -12,9 +12,6 @@
 #include <QLocale>
 #include <QDebug>
 
-#include "util.h"
-#include "base58.h"
-
 SendCoinsDialog::SendCoinsDialog(QWidget *parent, const QString &address) :
     QDialog(parent),
     ui(new Ui::SendCoinsDialog),
@@ -23,9 +20,8 @@ SendCoinsDialog::SendCoinsDialog(QWidget *parent, const QString &address) :
     ui->setupUi(this);
 
     GUIUtil::setupAddressWidget(ui->payTo, this);
-    GUIUtil::setupAmountWidget(ui->payAmount, this);
 
-    /* Set initial address if provided */
+    // Set initial send-to address if provided
     if(!address.isEmpty())
     {
         ui->payTo->setText(address);
@@ -47,9 +43,10 @@ void SendCoinsDialog::on_sendButton_clicked()
 {
     bool valid;
     QString payAmount = ui->payAmount->text();
+    QString label;
     qint64 payAmountParsed;
 
-    valid = ParseMoney(payAmount.toStdString(), payAmountParsed);
+    valid = GUIUtil::parseMoney(payAmount, &payAmountParsed);
 
     if(!valid)
     {
@@ -59,7 +56,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"),
@@ -82,7 +85,7 @@ void SendCoinsDialog::on_sendButton_clicked()
     case ClientModel::AmountWithFeeExceedsBalance:
         QMessageBox::warning(this, tr("Send Coins"),
             tr("Total exceeds your balance when the %1 transaction fee is included").
-                arg(QString::fromStdString(FormatMoney(model->getOptionsModel()->getTransactionFee()))),
+            arg(GUIUtil::formatMoney(model->getOptionsModel()->getTransactionFee())),
             QMessageBox::Ok, QMessageBox::Ok);
         ui->payAmount->setFocus();
         break;
@@ -94,13 +97,13 @@ void SendCoinsDialog::on_sendButton_clicked()
 
 void SendCoinsDialog::on_pasteButton_clicked()
 {
-    /* Paste text from clipboard into recipient field */
+    // Paste text from clipboard into recipient field
     ui->payTo->setText(QApplication::clipboard()->text());
 }
 
 void SendCoinsDialog::on_addressBookButton_clicked()
 {
-    AddressBookDialog dlg;
+    AddressBookDialog dlg(AddressBookDialog::ForSending);
     dlg.setModel(model->getAddressTableModel());
     dlg.setTab(AddressBookDialog::SendingTab);
     dlg.exec();
@@ -111,3 +114,8 @@ void SendCoinsDialog::on_buttonBox_rejected()
 {
     reject();
 }
+
+void SendCoinsDialog::on_addToAddressBook_toggled(bool checked)
+{
+    ui->addAsLabel->setEnabled(checked);
+}