Bitcoin-Qt: cleanup / optimise addressbookpage
- don't show QR Code context menu, when USE_QRCODE=1 was not specified when compiling the client - re-work on_showQRCode_clicked() for better readability and remove an unneeded duplicate check - re-work on_signMessage_clicked() and on_verifyMessage_clicked() to match foreach in on_showQRCode_clicked(), which seems more robust / cleaner - re-order context menu stuff to match real context menu layout - add comments for all private slots in the class
This commit is contained in:
parent
09c69c03f7
commit
bb0726a8cf
2 changed files with 24 additions and 21 deletions
|
@ -62,8 +62,8 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
|
||||||
}
|
}
|
||||||
|
|
||||||
// Context menu actions
|
// Context menu actions
|
||||||
QAction *copyLabelAction = new QAction(tr("Copy &Label"), this);
|
|
||||||
QAction *copyAddressAction = new QAction(ui->copyToClipboard->text(), this);
|
QAction *copyAddressAction = new QAction(ui->copyToClipboard->text(), this);
|
||||||
|
QAction *copyLabelAction = new QAction(tr("Copy &Label"), this);
|
||||||
QAction *editAction = new QAction(tr("&Edit"), this);
|
QAction *editAction = new QAction(tr("&Edit"), this);
|
||||||
QAction *showQRCodeAction = new QAction(ui->showQRCode->text(), this);
|
QAction *showQRCodeAction = new QAction(ui->showQRCode->text(), this);
|
||||||
QAction *signMessageAction = new QAction(ui->signMessage->text(), this);
|
QAction *signMessageAction = new QAction(ui->signMessage->text(), this);
|
||||||
|
@ -78,7 +78,9 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
|
||||||
if(tab == SendingTab)
|
if(tab == SendingTab)
|
||||||
contextMenu->addAction(deleteAction);
|
contextMenu->addAction(deleteAction);
|
||||||
contextMenu->addSeparator();
|
contextMenu->addSeparator();
|
||||||
|
#ifdef USE_QRCODE
|
||||||
contextMenu->addAction(showQRCodeAction);
|
contextMenu->addAction(showQRCodeAction);
|
||||||
|
#endif
|
||||||
if(tab == ReceivingTab)
|
if(tab == ReceivingTab)
|
||||||
contextMenu->addAction(signMessageAction);
|
contextMenu->addAction(signMessageAction);
|
||||||
else if(tab == SendingTab)
|
else if(tab == SendingTab)
|
||||||
|
@ -184,36 +186,31 @@ void AddressBookPage::on_signMessage_clicked()
|
||||||
{
|
{
|
||||||
QTableView *table = ui->tableView;
|
QTableView *table = ui->tableView;
|
||||||
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
|
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
|
||||||
QString addr;
|
|
||||||
|
|
||||||
foreach (QModelIndex index, indexes)
|
foreach (QModelIndex index, indexes)
|
||||||
{
|
{
|
||||||
QVariant address = index.data();
|
QString address = index.data().toString();
|
||||||
addr = address.toString();
|
emit signMessage(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit signMessage(addr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressBookPage::on_verifyMessage_clicked()
|
void AddressBookPage::on_verifyMessage_clicked()
|
||||||
{
|
{
|
||||||
QTableView *table = ui->tableView;
|
QTableView *table = ui->tableView;
|
||||||
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
|
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
|
||||||
QString addr;
|
|
||||||
|
|
||||||
foreach (QModelIndex index, indexes)
|
foreach (QModelIndex index, indexes)
|
||||||
{
|
{
|
||||||
QVariant address = index.data();
|
QString address = index.data().toString();
|
||||||
addr = address.toString();
|
emit verifyMessage(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit verifyMessage(addr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressBookPage::on_newAddressButton_clicked()
|
void AddressBookPage::on_newAddressButton_clicked()
|
||||||
{
|
{
|
||||||
if(!model)
|
if(!model)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EditAddressDialog dlg(
|
EditAddressDialog dlg(
|
||||||
tab == SendingTab ?
|
tab == SendingTab ?
|
||||||
EditAddressDialog::NewSendingAddress :
|
EditAddressDialog::NewSendingAddress :
|
||||||
|
@ -230,6 +227,7 @@ void AddressBookPage::on_deleteButton_clicked()
|
||||||
QTableView *table = ui->tableView;
|
QTableView *table = ui->tableView;
|
||||||
if(!table->selectionModel())
|
if(!table->selectionModel())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QModelIndexList indexes = table->selectionModel()->selectedRows();
|
QModelIndexList indexes = table->selectionModel()->selectedRows();
|
||||||
if(!indexes.isEmpty())
|
if(!indexes.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -341,11 +339,11 @@ void AddressBookPage::on_showQRCode_clicked()
|
||||||
|
|
||||||
foreach (QModelIndex index, indexes)
|
foreach (QModelIndex index, indexes)
|
||||||
{
|
{
|
||||||
QString address = index.data().toString(), label = index.sibling(index.row(), 0).data(Qt::EditRole).toString();
|
QString address = index.data().toString();
|
||||||
|
QString label = index.sibling(index.row(), 0).data(Qt::EditRole).toString();
|
||||||
|
|
||||||
QRCodeDialog *dialog = new QRCodeDialog(address, label, tab == ReceivingTab, this);
|
QRCodeDialog *dialog = new QRCodeDialog(address, label, tab == ReceivingTab, this);
|
||||||
if(optionsModel)
|
dialog->setModel(optionsModel);
|
||||||
dialog->setModel(optionsModel);
|
|
||||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
dialog->show();
|
dialog->show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,26 +54,31 @@ private:
|
||||||
QString returnValue;
|
QString returnValue;
|
||||||
QSortFilterProxyModel *proxyModel;
|
QSortFilterProxyModel *proxyModel;
|
||||||
QMenu *contextMenu;
|
QMenu *contextMenu;
|
||||||
QAction *deleteAction;
|
QAction *deleteAction; // to be able to explicitly disable it
|
||||||
QString newAddressToSelect;
|
QString newAddressToSelect;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
/** Delete currently selected address entry */
|
||||||
void on_deleteButton_clicked();
|
void on_deleteButton_clicked();
|
||||||
|
/** Create a new address for receiving coins and / or add a new address book entry */
|
||||||
void on_newAddressButton_clicked();
|
void on_newAddressButton_clicked();
|
||||||
/** Copy address of currently selected address entry to clipboard */
|
/** Copy address of currently selected address entry to clipboard */
|
||||||
void on_copyToClipboard_clicked();
|
void on_copyToClipboard_clicked();
|
||||||
|
/** Open the sign message tab in the Sign/Verify Message dialog with currently selected address */
|
||||||
void on_signMessage_clicked();
|
void on_signMessage_clicked();
|
||||||
|
/** Open the verify message tab in the Sign/Verify Message dialog with currently selected address */
|
||||||
void on_verifyMessage_clicked();
|
void on_verifyMessage_clicked();
|
||||||
void selectionChanged();
|
/** Generate a QR Code from the currently selected address */
|
||||||
void on_showQRCode_clicked();
|
void on_showQRCode_clicked();
|
||||||
/** Spawn contextual menu (right mouse menu) for address book entry */
|
/** Copy label of currently selected address entry to clipboard (no button) */
|
||||||
void contextualMenu(const QPoint &point);
|
|
||||||
|
|
||||||
/** Copy label of currently selected address entry to clipboard */
|
|
||||||
void onCopyLabelAction();
|
void onCopyLabelAction();
|
||||||
/** Edit currently selected address entry */
|
/** Edit currently selected address entry (no button) */
|
||||||
void onEditAction();
|
void onEditAction();
|
||||||
|
|
||||||
|
/** Set button states based on selected tab and selection */
|
||||||
|
void selectionChanged();
|
||||||
|
/** Spawn contextual menu (right mouse menu) for address book entry */
|
||||||
|
void contextualMenu(const QPoint &point);
|
||||||
/** New entry/entries were added to address table */
|
/** New entry/entries were added to address table */
|
||||||
void selectNewAddress(const QModelIndex &parent, int begin, int /*end*/);
|
void selectNewAddress(const QModelIndex &parent, int begin, int /*end*/);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue