本文整理汇总了C++中AddressTableModel::lookupAddress方法的典型用法代码示例。如果您正苦于以下问题:C++ AddressTableModel::lookupAddress方法的具体用法?C++ AddressTableModel::lookupAddress怎么用?C++ AddressTableModel::lookupAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AddressTableModel
的用法示例。
在下文中一共展示了AddressTableModel::lookupAddress方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: editLabel
void TransactionView::editLabel()
{
if(!transactionView->selectionModel() ||!model)
return;
QModelIndexList selection = transactionView->selectionModel()->selectedRows();
if(!selection.isEmpty())
{
AddressTableModel *addressBook = model->getAddressTableModel();
if(!addressBook)
return;
QString address = selection.at(0).data(TransactionTableModel::AddressRole).toString();
if(address.isEmpty())
{
// If this transaction has no associated address, exit
return;
}
// Is address in address book? Address book can miss address when a transaction is
// sent from outside the UI.
int idx = addressBook->lookupAddress(address);
if(idx != -1)
{
// Edit sending / receiving address
QModelIndex modelIdx = addressBook->index(idx, 0, QModelIndex());
// Determine type of address, launch appropriate editor dialog type
QString type = modelIdx.data(AddressTableModel::TypeRole).toString();
EditAddressDialog dlg(type==AddressTableModel::Receive
? EditAddressDialog::EditReceivingAddress
: EditAddressDialog::EditSendingAddress,
this);
dlg.setModel(addressBook);
dlg.loadRow(idx);
dlg.exec();
}
else
{
// Add sending address
EditAddressDialog dlg(EditAddressDialog::NewSendingAddress,
this);
dlg.setModel(addressBook);
dlg.setAddress(address);
dlg.exec();
}
}
}
示例2: editLabel
void TransactionView::editLabel()
{
if (!transactionView->selectionModel() || !model)
return;
QModelIndexList selection = transactionView->selectionModel()->selectedRows();
if (!selection.isEmpty()) {
AddressTableModel* addressBook = model->getAddressTableModel();
if (!addressBook)
return;
QString address = selection.at(0).data(TransactionTableModel::AddressRole).toString();
if (address.isEmpty()) {
return;
}
int idx = addressBook->lookupAddress(address);
if (idx != -1) {
QModelIndex modelIdx = addressBook->index(idx, 0, QModelIndex());
QString type = modelIdx.data(AddressTableModel::TypeRole).toString();
EditAddressDialog dlg(
type == AddressTableModel::Receive
? EditAddressDialog::EditReceivingAddress
: EditAddressDialog::EditSendingAddress,
this);
dlg.setModel(addressBook);
dlg.loadRow(idx);
dlg.exec();
} else {
EditAddressDialog dlg(EditAddressDialog::NewSendingAddress,
this);
dlg.setModel(addressBook);
dlg.setAddress(address);
dlg.exec();
}
}
}