|
|
|
@ -69,6 +69,8 @@ public:
@@ -69,6 +69,8 @@ public:
|
|
|
|
|
QString::fromStdString(address.ToString()))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// qLowerBound() and qUpperBound() require our cachedAddressTable list to be sorted in asc order
|
|
|
|
|
qSort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLessThan()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void updateEntry(const QString &address, const QString &label, bool isMine, int status) |
|
|
|
@ -208,7 +210,7 @@ QVariant AddressTableModel::data(const QModelIndex &index, int role) const
@@ -208,7 +210,7 @@ QVariant AddressTableModel::data(const QModelIndex &index, int role) const
|
|
|
|
|
return QVariant(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool AddressTableModel::setData(const QModelIndex & index, const QVariant & value, int role) |
|
|
|
|
bool AddressTableModel::setData(const QModelIndex &index, const QVariant &value, int role) |
|
|
|
|
{ |
|
|
|
|
if(!index.isValid()) |
|
|
|
|
return false; |
|
|
|
@ -221,18 +223,36 @@ bool AddressTableModel::setData(const QModelIndex & index, const QVariant & valu
@@ -221,18 +223,36 @@ bool AddressTableModel::setData(const QModelIndex & index, const QVariant & valu
|
|
|
|
|
switch(index.column()) |
|
|
|
|
{ |
|
|
|
|
case Label: |
|
|
|
|
// Do nothing, if old label == new label
|
|
|
|
|
if(rec->label == value.toString()) |
|
|
|
|
{ |
|
|
|
|
editStatus = NO_CHANGES; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
wallet->SetAddressBookName(CBitcoinAddress(rec->address.toStdString()).Get(), value.toString().toStdString()); |
|
|
|
|
rec->label = value.toString(); |
|
|
|
|
break; |
|
|
|
|
case Address: |
|
|
|
|
// Do nothing, if old address == new address
|
|
|
|
|
if(CBitcoinAddress(rec->address.toStdString()) == CBitcoinAddress(value.toString().toStdString())) |
|
|
|
|
{ |
|
|
|
|
editStatus = NO_CHANGES; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
// Refuse to set invalid address, set error status and return false
|
|
|
|
|
if(!walletModel->validateAddress(value.toString())) |
|
|
|
|
else if(!walletModel->validateAddress(value.toString())) |
|
|
|
|
{ |
|
|
|
|
editStatus = INVALID_ADDRESS; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
// Check for duplicate addresses to prevent accidental deletion of addresses, if you try
|
|
|
|
|
// to paste an existing address over another address (with a different label)
|
|
|
|
|
else if(wallet->mapAddressBook.count(CBitcoinAddress(value.toString().toStdString()).Get())) |
|
|
|
|
{ |
|
|
|
|
editStatus = DUPLICATE_ADDRESS; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
// Double-check that we're not overwriting a receiving address
|
|
|
|
|
if(rec->type == AddressTableEntry::Sending) |
|
|
|
|
else if(rec->type == AddressTableEntry::Sending) |
|
|
|
|
{ |
|
|
|
|
{ |
|
|
|
|
LOCK(wallet->cs_wallet); |
|
|
|
@ -244,7 +264,6 @@ bool AddressTableModel::setData(const QModelIndex & index, const QVariant & valu
@@ -244,7 +264,6 @@ bool AddressTableModel::setData(const QModelIndex & index, const QVariant & valu
|
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
@ -262,7 +281,7 @@ QVariant AddressTableModel::headerData(int section, Qt::Orientation orientation,
@@ -262,7 +281,7 @@ QVariant AddressTableModel::headerData(int section, Qt::Orientation orientation,
|
|
|
|
|
return QVariant(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Qt::ItemFlags AddressTableModel::flags(const QModelIndex & index) const |
|
|
|
|
Qt::ItemFlags AddressTableModel::flags(const QModelIndex &index) const |
|
|
|
|
{ |
|
|
|
|
if(!index.isValid()) |
|
|
|
|
return 0; |
|
|
|
@ -279,7 +298,7 @@ Qt::ItemFlags AddressTableModel::flags(const QModelIndex & index) const
@@ -279,7 +298,7 @@ Qt::ItemFlags AddressTableModel::flags(const QModelIndex & index) const
|
|
|
|
|
return retval; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QModelIndex AddressTableModel::index(int row, int column, const QModelIndex & parent) const |
|
|
|
|
QModelIndex AddressTableModel::index(int row, int column, const QModelIndex &parent) const |
|
|
|
|
{ |
|
|
|
|
Q_UNUSED(parent); |
|
|
|
|
AddressTableEntry *data = priv->index(row); |
|
|
|
@ -345,6 +364,7 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
@@ -345,6 +364,7 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
|
|
|
|
|
{ |
|
|
|
|
return QString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Add entry
|
|
|
|
|
{ |
|
|
|
|
LOCK(wallet->cs_wallet); |
|
|
|
@ -353,7 +373,7 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
@@ -353,7 +373,7 @@ QString AddressTableModel::addRow(const QString &type, const QString &label, con
|
|
|
|
|
return QString::fromStdString(strAddress); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool AddressTableModel::removeRows(int row, int count, const QModelIndex & parent) |
|
|
|
|
bool AddressTableModel::removeRows(int row, int count, const QModelIndex &parent) |
|
|
|
|
{ |
|
|
|
|
Q_UNUSED(parent); |
|
|
|
|
AddressTableEntry *rec = priv->index(row); |
|
|
|
|