[qt] navigate to transaction history page after send

The transaction will be selected. When sending to multiple
destinations, all will be selected (thanks @promag).
This commit is contained in:
Sjors Provoost
2018-03-01 10:40:36 +01:00
parent c997f88082
commit e7d9fc5c53
6 changed files with 42 additions and 3 deletions

View File

@@ -263,8 +263,7 @@ void TransactionView::setModel(WalletModel *_model)
void TransactionView::chooseDate(int idx)
{
if(!transactionProxyModel)
return;
if (!transactionProxyModel) return;
QDate current = QDate::currentDate();
dateRangeWidget->setVisible(false);
switch(dateWidget->itemData(idx).toInt())
@@ -592,6 +591,32 @@ void TransactionView::focusTransaction(const QModelIndex &idx)
transactionView->setFocus();
}
void TransactionView::focusTransaction(const uint256& txid)
{
if (!transactionProxyModel)
return;
const QModelIndexList results = this->model->getTransactionTableModel()->match(
this->model->getTransactionTableModel()->index(0,0),
TransactionTableModel::TxHashRole,
QString::fromStdString(txid.ToString()), -1);
transactionView->setFocus();
transactionView->selectionModel()->clearSelection();
for (const QModelIndex& index : results) {
const QModelIndex targetIndex = transactionProxyModel->mapFromSource(index);
transactionView->selectionModel()->select(
targetIndex,
QItemSelectionModel::Rows | QItemSelectionModel::Select);
// Called once per destination to ensure all results are in view, unless
// transactions are not ordered by (ascending or descending) date.
transactionView->scrollTo(targetIndex);
// scrollTo() does not scroll far enough the first time when transactions
// are ordered by ascending date.
if (index == results[0]) transactionView->scrollTo(targetIndex);
}
}
// We override the virtual resizeEvent of the QWidget to adjust tables column
// sizes as the tables width is proportional to the dialogs width.
void TransactionView::resizeEvent(QResizeEvent* event)