Skip to content

Commit 3ef1f41

Browse files
committed
When a transaction is clicked on overview page, focus it on history page
1 parent 97ec4e5 commit 3ef1f41

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

src/qt/bitcoingui.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
157157

158158
// Clicking on a transaction on the overview page simply sends you to transaction history page
159159
connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage()));
160+
connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex)));
160161

161162
// Doubleclicking on a transaction on the transaction history page shows details
162163
connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));

src/qt/overviewpage.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ OverviewPage::OverviewPage(QWidget *parent) :
9494
ui(new Ui::OverviewPage),
9595
currentBalance(-1),
9696
currentUnconfirmedBalance(-1),
97-
txdelegate(new TxViewDelegate())
97+
txdelegate(new TxViewDelegate()), filter(0)
9898
{
9999
ui->setupUi(this);
100100

@@ -104,7 +104,13 @@ OverviewPage::OverviewPage(QWidget *parent) :
104104
ui->listTransactions->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2));
105105
ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect, false);
106106

107-
connect(ui->listTransactions, SIGNAL(clicked(QModelIndex)), this, SIGNAL(transactionClicked(QModelIndex)));
107+
connect(ui->listTransactions, SIGNAL(clicked(QModelIndex)), this, SLOT(handleTransactionClicked(QModelIndex)));
108+
}
109+
110+
void OverviewPage::handleTransactionClicked(const QModelIndex &index)
111+
{
112+
if(filter)
113+
emit transactionClicked(filter->mapToSource(index));
108114
}
109115

110116
OverviewPage::~OverviewPage()
@@ -132,7 +138,7 @@ void OverviewPage::setModel(WalletModel *model)
132138
if(model)
133139
{
134140
// Set up transaction list
135-
TransactionFilterProxy *filter = new TransactionFilterProxy();
141+
filter = new TransactionFilterProxy();
136142
filter->setSourceModel(model->getTransactionTableModel());
137143
filter->setLimit(NUM_ITEMS);
138144
filter->setDynamicSortFilter(true);

src/qt/overviewpage.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace Ui {
1212
}
1313
class WalletModel;
1414
class TxViewDelegate;
15+
class TransactionFilterProxy;
1516

1617
/** Overview ("home") page widget */
1718
class OverviewPage : public QWidget
@@ -38,9 +39,11 @@ public slots:
3839
qint64 currentUnconfirmedBalance;
3940

4041
TxViewDelegate *txdelegate;
42+
TransactionFilterProxy *filter;
4143

4244
private slots:
4345
void displayUnitChanged();
46+
void handleTransactionClicked(const QModelIndex &index);
4447
};
4548

4649
#endif // OVERVIEWPAGE_H

src/qt/transactionview.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,3 +417,13 @@ void TransactionView::dateRangeChanged()
417417
QDateTime(dateFrom->date()),
418418
QDateTime(dateTo->date()).addDays(1));
419419
}
420+
421+
void TransactionView::focusTransaction(const QModelIndex &idx)
422+
{
423+
if(!transactionProxyModel)
424+
return;
425+
QModelIndex targetIdx = transactionProxyModel->mapFromSource(idx);
426+
transactionView->scrollTo(targetIdx);
427+
transactionView->setCurrentIndex(targetIdx);
428+
transactionView->setFocus();
429+
}

src/qt/transactionview.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public slots:
7575
void changedPrefix(const QString &prefix);
7676
void changedAmount(const QString &amount);
7777
void exportClicked();
78+
void focusTransaction(const QModelIndex&);
7879

7980
};
8081

0 commit comments

Comments
 (0)