27 type(type), label(label), address(address) {}
55 wallet(wallet), parent(parent) {}
59 cachedAddressTable.clear();
65 const std::string& strName = item.second;
66 bool fMine =
IsMine(*wallet, address.
Get());
68 QString::fromStdString(strName),
69 QString::fromStdString(address.
ToString())));
76 void updateEntry(
const QString &address,
const QString &label,
bool isMine,
int status)
79 QList<AddressTableEntry>::iterator lower = qLowerBound(
81 QList<AddressTableEntry>::iterator upper = qUpperBound(
83 int lowerIndex = (lower - cachedAddressTable.begin());
84 int upperIndex = (upper - cachedAddressTable.begin());
85 bool inModel = (lower != upper);
93 OutputDebugStringF(
"Warning: AddressTablePriv::updateEntry: Got CT_NOW, but entry is already in model\n");
96 parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
97 cachedAddressTable.insert(lowerIndex,
AddressTableEntry(newEntryType, label, address));
98 parent->endInsertRows();
103 OutputDebugStringF(
"Warning: AddressTablePriv::updateEntry: Got CT_UPDATED, but entry is not in model\n");
106 lower->type = newEntryType;
107 lower->label = label;
113 OutputDebugStringF(
"Warning: AddressTablePriv::updateEntry: Got CT_DELETED, but entry is not in model\n");
116 parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
117 cachedAddressTable.erase(lower, upper);
118 parent->endRemoveRows();
125 return cachedAddressTable.size();
130 if(idx >= 0 && idx < cachedAddressTable.size())
132 return &cachedAddressTable[idx];
142 QAbstractTableModel(parent),walletModel(parent),wallet(wallet),priv(0)
144 columns << tr(
"Label") << tr(
"Address");
173 if(role == Qt::DisplayRole || role == Qt::EditRole)
175 switch(index.column())
178 if(rec->
label.isEmpty() && role == Qt::DisplayRole)
180 return tr(
"(no label)");
190 else if (role == Qt::FontRole)
221 if(role == Qt::EditRole)
223 switch(index.column())
227 if(rec->
label == value.toString())
274 if(orientation == Qt::Horizontal)
276 if(role == Qt::DisplayRole)
290 Qt::ItemFlags retval = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
296 retval |= Qt::ItemIsEditable;
307 return createIndex(row, column,
priv->
index(row));
311 return QModelIndex();
323 std::string strLabel = label.toStdString();
324 std::string strAddress = address.toStdString();
373 return QString::fromStdString(strAddress);
400 std::map<CTxDestination, std::string>::iterator mi =
wallet->
mapAddressBook.find(address_parsed.Get());
403 return QString::fromStdString(mi->second);
411 QModelIndexList lst = match(
index(0,
Address, QModelIndex()),
412 Qt::EditRole, address, 1, Qt::MatchExactly);
419 return lst.at(0).row();
425 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.
bool operator()(const AddressTableEntry &a, const QString &b) const
WalletModel * walletModel
CCriticalSection cs_wallet
int lookupAddress(const QString &address) const
UnlockContext requestUnlock()
AddressTableEntry * index(int idx)
Address already in address book.
void updateEntry(const QString &address, const QString &label, bool isMine, int status)
CTxDestination Get() const
static const QString Send
Specifies send address.
bool SetAddressBookName(const CTxDestination &address, const std::string &strName)
bool operator()(const AddressTableEntry &a, const AddressTableEntry &b) const
AddressTableEntry(Type type, const QString &label, const QString &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
bool DelAddressBookName(const CTxDestination &address)
std::string ToString() const
int OutputDebugStringF(const char *pszFormat,...)
Qt model of the address book in the core.
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
QVariant data(const QModelIndex &index, int role) const
Interface to Bitcoin wallet from Qt view code.
void updateEntry(const QString &address, const QString &label, bool isMine, int status)
static const QString Receive
Specifies receive address.
QVariant headerData(int section, Qt::Orientation orientation, int role) const
bool IsMine(const CKeyStore &keystore, const CTxDestination &dest)
void emitDataChanged(int index)
Notify listeners that data changed.
bool GetKeyFromPool(CPubKey &key, bool fAllowReuse=true)
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
void refreshAddressTable()
std::map< CTxDestination, std::string > mapAddressBook
bool setData(const QModelIndex &index, const QVariant &value, int role)
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
No changes were made during edit operation.
friend class AddressTablePriv
Qt::ItemFlags flags(const QModelIndex &index) const
Type of address (Send or Receive)
QFont bitcoinAddressFont()
int columnCount(const QModelIndex &parent) const
AddressTablePriv(CWallet *wallet, AddressTableModel *parent)