aboutsummaryrefslogtreecommitdiff
path: root/src/qt/addresstablemodel.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-07-16 19:01:05 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2011-07-16 19:25:02 +0200
commita5e6d72339f28699bc356603f695bd620be37e83 (patch)
treee1e0501a5b58cbc018f5f6ad60c064f84d747a9c /src/qt/addresstablemodel.cpp
parentd4211176208b5e4ae4a699c6ce3239447752cdb2 (diff)
add sendmany support
Diffstat (limited to 'src/qt/addresstablemodel.cpp')
-rw-r--r--src/qt/addresstablemodel.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp
index 4578ca740f..125ceebb33 100644
--- a/src/qt/addresstablemodel.cpp
+++ b/src/qt/addresstablemodel.cpp
@@ -1,5 +1,6 @@
#include "addresstablemodel.h"
#include "guiutil.h"
+#include "walletmodel.h"
#include "headers.h"
@@ -72,8 +73,8 @@ struct AddressTablePriv
}
};
-AddressTableModel::AddressTableModel(CWallet *wallet, QObject *parent) :
- QAbstractTableModel(parent),wallet(wallet),priv(0)
+AddressTableModel::AddressTableModel(CWallet *wallet, WalletModel *parent) :
+ QAbstractTableModel(parent),walletModel(parent),wallet(wallet),priv(0)
{
columns << tr("Label") << tr("Address");
priv = new AddressTablePriv(wallet);
@@ -150,6 +151,8 @@ bool AddressTableModel::setData(const QModelIndex & index, const QVariant & valu
return false;
AddressTableEntry *rec = static_cast<AddressTableEntry*>(index.internalPointer());
+ editStatus = OK;
+
if(role == Qt::EditRole)
{
switch(index.column())
@@ -160,8 +163,11 @@ bool AddressTableModel::setData(const QModelIndex & index, const QVariant & valu
break;
case Address:
// Refuse to set invalid address
- if(!validateAddress(value.toString()))
+ if(!walletModel->validateAddress(value.toString()))
+ {
+ editStatus = INVALID_ADDRESS;
return false;
+ }
// Double-check that we're not overwriting receiving address
if(rec->type == AddressTableEntry::Sending)
{
@@ -240,13 +246,22 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
std::string strLabel = label.toStdString();
std::string strAddress = address.toStdString();
+ editStatus = OK;
+
+
if(type == Send)
{
+ if(!walletModel->validateAddress(address))
+ {
+ editStatus = INVALID_ADDRESS;
+ return QString();
+ }
// Check for duplicate
CRITICAL_BLOCK(wallet->cs_mapAddressBook)
{
if(wallet->mapAddressBook.count(strAddress))
{
+ editStatus = DUPLICATE_ADDRESS;
return QString();
}
}
@@ -291,13 +306,6 @@ void AddressTableModel::update()
}
-bool AddressTableModel::validateAddress(const QString &address)
-{
- uint160 hash160 = 0;
-
- return AddressToHash160(address.toStdString(), hash160);
-}
-
/* Look up label for address in address book, if not found return empty string.
*/
QString AddressTableModel::labelForAddress(const QString &address) const