34 type(_type), label(_label), address(_address) {}
58 if (strPurpose ==
"send")
60 else if (strPurpose ==
"receive")
62 else if (strPurpose ==
"unknown" || strPurpose ==
"")
76 wallet(_wallet), parent(_parent) {}
80 cachedAddressTable.clear();
83 for (
const std::pair<CTxDestination, CAddressBookData>& item : wallet->
mapAddressBook)
86 bool fMine =
IsMine(*wallet, address.
Get());
88 QString::fromStdString(item.second.purpose), fMine);
89 const std::string& strName = item.second.name;
91 QString::fromStdString(strName),
92 QString::fromStdString(address.
ToString())));
104 QList<AddressTableEntry>::iterator lower = qLowerBound(
106 QList<AddressTableEntry>::iterator upper = qUpperBound(
108 int lowerIndex = (lower - cachedAddressTable.begin());
109 int upperIndex = (upper - cachedAddressTable.begin());
110 bool inModel = (lower != upper);
118 qWarning() <<
"AddressTablePriv::updateEntry: Warning: Got CT_NEW, but entry is already in model";
121 parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
122 cachedAddressTable.insert(lowerIndex,
AddressTableEntry(newEntryType, label, address));
123 parent->endInsertRows();
128 qWarning() <<
"AddressTablePriv::updateEntry: Warning: Got CT_UPDATED, but entry is not in model";
131 lower->type = newEntryType;
132 lower->label =
label;
138 qWarning() <<
"AddressTablePriv::updateEntry: Warning: Got CT_DELETED, but entry is not in model";
141 parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
142 cachedAddressTable.erase(lower, upper);
143 parent->endRemoveRows();
150 return cachedAddressTable.size();
155 if(idx >= 0 && idx < cachedAddressTable.size())
157 return &cachedAddressTable[idx];
167 QAbstractTableModel(parent),walletModel(parent),wallet(_wallet),priv(0)
169 columns << tr(
"Label") << tr(
"Address");
198 if(role == Qt::DisplayRole || role == Qt::EditRole)
200 switch(index.column())
203 if(rec->
label.isEmpty() && role == Qt::DisplayRole)
205 return tr(
"(no label)");
215 else if (role == Qt::FontRole)
246 if(role == Qt::EditRole)
250 if(index.column() ==
Label)
253 if(rec->
label == value.toString())
259 }
else if(index.column() ==
Address) {
262 if(boost::get<CNoDestination>(&newAddress))
268 else if(newAddress == curAddress)
296 if(orientation == Qt::Horizontal)
298 if(role == Qt::DisplayRole && section <
columns.size())
312 Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
318 retval |= Qt::ItemIsEditable;
329 return createIndex(row, column,
priv->
index(row));
333 return QModelIndex();
338 const QString &label,
bool isMine,
const QString &purpose,
int status)
346 std::string strLabel = label.toStdString();
347 std::string strAddress = address.toStdString();
398 (type ==
Send ?
"send" :
"receive"));
400 return QString::fromStdString(strAddress);
427 std::map<CTxDestination, CAddressBookData>::iterator mi =
wallet->
mapAddressBook.find(address_parsed.Get());
430 return QString::fromStdString(mi->second.name);
438 QModelIndexList lst = match(
index(0,
Address, QModelIndex()),
439 Qt::EditRole, address, 1, Qt::MatchExactly);
446 return lst.at(0).row();
452 Q_EMIT dataChanged(
index(idx, 0, QModelIndex()),
index(idx,
columns.length()-1, QModelIndex()));
AddressTableModel(CWallet *wallet, WalletModel *parent=0)
QModelIndex index(int row, int column, const QModelIndex &parent) const
Generating a new public key for a receiving address failed.
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
AddressTablePriv(CWallet *_wallet, AddressTableModel *_parent)
bool operator()(const AddressTableEntry &a, const QString &b) const
WalletModel * walletModel
std::map< CTxDestination, CAddressBookData > mapAddressBook
CCriticalSection cs_wallet
int lookupAddress(const QString &address) const
UnlockContext requestUnlock()
AddressTableEntry * index(int idx)
Address already in address book.
base58-encoded Fabcoin addresses.
isminetype IsMine(const CKeyStore &keystore, const CScript &scriptPubKey, SigVersion sigversion)
static const QString Send
Specifies send address.
bool operator()(const AddressTableEntry &a, const AddressTableEntry &b) const
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
bool DelAddressBook(const CTxDestination &address)
Wallet could not be unlocked to create new receiving address.
QList< AddressTableEntry > cachedAddressTable
bool operator()(const QString &a, const AddressTableEntry &b) const
An encapsulated public key.
int rowCount(const QModelIndex &parent) const
AddressTableModel * parent
std::string ToString() const
CTxDestination Get() const
Qt model of the address book in the core.
AddressTableEntry(Type _type, const QString &_label, const QString &_address)
bool validateAddress(const QString &address)
QString addRow(const QString &type, const QString &label, const QString &address)
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
QString labelForAddress(const QString &address) const
PlatformStyle::TableColorType type
QVariant data(const QModelIndex &index, int role) const
Interface to Fabcoin wallet from Qt view code.
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
static const QString Receive
Specifies receive address.
QVariant headerData(int section, Qt::Orientation orientation, int role) const
void emitDataChanged(int index)
Notify listeners that data changed.
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
void refreshAddressTable()
bool GetKeyFromPool(CPubKey &key, bool internal=false)
bool setData(const QModelIndex &index, const QVariant &value, int role)
struct evm_uint160be address(struct evm_env *env)
No changes were made during edit operation.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
friend class AddressTablePriv
Qt::ItemFlags flags(const QModelIndex &index) const
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
Type of address (Send or Receive)
int columnCount(const QModelIndex &parent) const