35 type(_type), label(_label), address(_address) {}
59 if (strPurpose ==
"send")
61 else if (strPurpose ==
"receive")
63 else if (strPurpose ==
"unknown" || strPurpose ==
"")
77 wallet(_wallet), parent(_parent) {}
81 cachedAddressTable.clear();
84 for (
const std::pair<CTxDestination, CAddressBookData>& item : wallet->
mapAddressBook)
87 bool fMine =
IsMine(*wallet, address);
89 QString::fromStdString(item.second.purpose), fMine);
90 const std::string& strName = item.second.name;
92 QString::fromStdString(strName),
105 QList<AddressTableEntry>::iterator lower = qLowerBound(
107 QList<AddressTableEntry>::iterator upper = qUpperBound(
109 int lowerIndex = (lower - cachedAddressTable.begin());
110 int upperIndex = (upper - cachedAddressTable.begin());
111 bool inModel = (lower != upper);
119 qWarning() <<
"AddressTablePriv::updateEntry: Warning: Got CT_NEW, but entry is already in model";
122 parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
123 cachedAddressTable.insert(lowerIndex,
AddressTableEntry(newEntryType, label, address));
124 parent->endInsertRows();
129 qWarning() <<
"AddressTablePriv::updateEntry: Warning: Got CT_UPDATED, but entry is not in model";
132 lower->type = newEntryType;
133 lower->label =
label;
139 qWarning() <<
"AddressTablePriv::updateEntry: Warning: Got CT_DELETED, but entry is not in model";
142 parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
143 cachedAddressTable.erase(lower, upper);
144 parent->endRemoveRows();
151 return cachedAddressTable.size();
156 if(idx >= 0 && idx < cachedAddressTable.size())
158 return &cachedAddressTable[idx];
168 QAbstractTableModel(parent),walletModel(parent),wallet(_wallet),priv(0)
170 columns << tr(
"Label") << tr(
"Address");
199 if(role == Qt::DisplayRole || role == Qt::EditRole)
201 switch(index.column())
204 if(rec->
label.isEmpty() && role == Qt::DisplayRole)
206 return tr(
"(no label)");
216 else if (role == Qt::FontRole)
247 if(role == Qt::EditRole)
251 if(index.column() ==
Label)
254 if(rec->
label == value.toString())
260 }
else if(index.column() ==
Address) {
263 if(boost::get<CNoDestination>(&newAddress))
269 else if(newAddress == curAddress)
297 if(orientation == Qt::Horizontal)
299 if(role == Qt::DisplayRole && section <
columns.size())
313 Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
319 retval |= Qt::ItemIsEditable;
330 return createIndex(row, column,
priv->
index(row));
334 return QModelIndex();
339 const QString &label,
bool isMine,
const QString &purpose,
int status)
347 std::string strLabel = label.toStdString();
348 std::string strAddress = address.toStdString();
399 (type ==
Send ?
"send" :
"receive"));
401 return QString::fromStdString(strAddress);
428 std::map<CTxDestination, CAddressBookData>::iterator mi =
wallet->
mapAddressBook.find(destination);
431 return QString::fromStdString(mi->second.name);
439 QModelIndexList lst = match(
index(0,
Address, QModelIndex()),
440 Qt::EditRole, address, 1, Qt::MatchExactly);
447 return lst.at(0).row();
453 Q_EMIT dataChanged(
index(idx, 0, QModelIndex()),
index(idx,
columns.length()-1, QModelIndex()));
AddressTableModel(CWallet *wallet, WalletModel *parent=0)
Generating a new public key for a receiving address failed.
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
bool operator()(const QString &a, const AddressTableEntry &b) const
QModelIndex index(int row, int column, const QModelIndex &parent) const
AddressTablePriv(CWallet *_wallet, AddressTableModel *_parent)
int lookupAddress(const QString &address) const
Qt::ItemFlags flags(const QModelIndex &index) const
WalletModel * walletModel
std::map< CTxDestination, CAddressBookData > mapAddressBook
CCriticalSection cs_wallet
UnlockContext requestUnlock()
AddressTableEntry * index(int idx)
Address already in address book.
CTxDestination DecodeDestination(const std::string &str)
isminetype IsMine(const CKeyStore &keystore, const CScript &scriptPubKey, SigVersion sigversion)
QVariant headerData(int section, Qt::Orientation orientation, int role) const
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
static const QString Send
Specifies send address.
int rowCount(const QModelIndex &parent) const
int columnCount(const QModelIndex &parent) const
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
An encapsulated public key.
QString labelForAddress(const QString &address) const
AddressTableModel * parent
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())
bool operator()(const AddressTableEntry &a, const QString &b) const
std::string EncodeDestination(const CTxDestination &dest)
Interface to Raven 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.
void emitDataChanged(int index)
Notify listeners that data changed.
QVariant data(const QModelIndex &index, int role) const
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)
No changes were made during edit operation.
friend class AddressTablePriv
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
Type of address (Send or Receive)