Skip to content

Commit 4f2fcbd

Browse files
jonasschnelliPastaPastaPasta
authored andcommitted
Merge bitcoin#11395: Qt: Enable searching by transaction id
eac2abc Qt: Enable searching by transaction id (Luke Dashjr) c407c61 Qt: Avoid invalidating the search filter, when it doesn't really change (Luke Dashjr) b1f6342 Qt: Rename confusingly-named "address prefix" to "search string" (Luke Dashjr) Pull request description: Tree-SHA512: 1c67037d19689fbaff21d15ed7848ac86188e5de34728312e1f9758dada759cab50d913a5bc09e413ecaa3e07557cf253809b95b5637ff79f2e3cf24d86dd3ed
1 parent ff20819 commit 4f2fcbd

File tree

4 files changed

+26
-21
lines changed

4 files changed

+26
-21
lines changed

src/qt/transactionfilterproxy.cpp

+9-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ TransactionFilterProxy::TransactionFilterProxy(QObject *parent) :
2020
QSortFilterProxyModel(parent),
2121
dateFrom(MIN_DATE.toTime_t()),
2222
dateTo(MAX_DATE.toTime_t()),
23-
addrPrefix(),
23+
m_search_string(),
2424
typeFilter(COMMON_TYPES),
2525
watchOnlyFilter(WatchOnlyFilter_All),
2626
instantsendFilter(InstantSendFilter_All),
@@ -40,6 +40,7 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &
4040
bool lockedByInstantSend = index.data(TransactionTableModel::InstantSendRole).toBool();
4141
QString address = index.data(TransactionTableModel::AddressRole).toString();
4242
QString label = index.data(TransactionTableModel::LabelRole).toString();
43+
QString txid = index.data(TransactionTableModel::TxIDRole).toString();
4344
qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong());
4445
int status = index.data(TransactionTableModel::StatusRole).toInt();
4546

@@ -57,8 +58,11 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &
5758
return false;
5859
if(datetime < dateFrom || datetime > dateTo)
5960
return false;
60-
if (!address.contains(addrPrefix, Qt::CaseInsensitive) && !label.contains(addrPrefix, Qt::CaseInsensitive))
61+
if (!address.contains(m_search_string, Qt::CaseInsensitive) &&
62+
! label.contains(m_search_string, Qt::CaseInsensitive) &&
63+
! txid.contains(m_search_string, Qt::CaseInsensitive)) {
6164
return false;
65+
}
6266
if(amount < minAmount)
6367
return false;
6468

@@ -72,9 +76,10 @@ void TransactionFilterProxy::setDateRange(const QDateTime &from, const QDateTime
7276
invalidateFilter();
7377
}
7478

75-
void TransactionFilterProxy::setAddressPrefix(const QString &_addrPrefix)
79+
void TransactionFilterProxy::setSearchString(const QString &search_string)
7680
{
77-
this->addrPrefix = _addrPrefix;
81+
if (m_search_string == search_string) return;
82+
m_search_string = search_string;
7883
invalidateFilter();
7984
}
8085

src/qt/transactionfilterproxy.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class TransactionFilterProxy : public QSortFilterProxyModel
4444
};
4545

4646
void setDateRange(const QDateTime &from, const QDateTime &to);
47-
void setAddressPrefix(const QString &addrPrefix);
47+
void setSearchString(const QString &);
4848
/**
4949
@note Type filter takes a bit field created with TYPE() or ALL_TYPES
5050
*/
@@ -67,7 +67,7 @@ class TransactionFilterProxy : public QSortFilterProxyModel
6767
private:
6868
qint64 dateFrom;
6969
qint64 dateTo;
70-
QString addrPrefix;
70+
QString m_search_string;
7171
quint32 typeFilter;
7272
WatchOnlyFilter watchOnlyFilter;
7373
InstantSendFilter instantsendFilter;

src/qt/transactionview.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
113113

114114
hlayout->addWidget(typeWidget);
115115

116-
addressWidget = new QLineEdit(this);
116+
search_widget = new QLineEdit(this);
117117
#if QT_VERSION >= 0x040700
118-
addressWidget->setPlaceholderText(tr("Enter address or label to search"));
118+
search_widget->setPlaceholderText(tr("Enter address, transaction id, or label to search"));
119119
#endif
120120
addressWidget->setObjectName("addressWidget");
121-
hlayout->addWidget(addressWidget);
121+
hlayout->addWidget(search_widget);
122122

123123
amountWidget = new QLineEdit(this);
124124
#if QT_VERSION >= 0x040700
@@ -128,7 +128,7 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
128128
amountWidget->setFixedWidth(118);
129129
} else {
130130
amountWidget->setFixedWidth(125);
131-
}
131+
}
132132
amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this));
133133
amountWidget->setObjectName("amountWidget");
134134
hlayout->addWidget(amountWidget);
@@ -207,8 +207,8 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *pa
207207
connect(instantsendWidget, SIGNAL(activated(int)), this, SLOT(chooseInstantSend(int)));
208208
connect(amountWidget, SIGNAL(textChanged(QString)), amount_typing_delay, SLOT(start()));
209209
connect(amount_typing_delay, SIGNAL(timeout()), this, SLOT(changedAmount()));
210-
connect(addressWidget, SIGNAL(textChanged(QString)), prefix_typing_delay, SLOT(start()));
211-
connect(prefix_typing_delay, SIGNAL(timeout()), this, SLOT(changedPrefix()));
210+
connect(search_widget, SIGNAL(textChanged(QString)), prefix_typing_delay, SLOT(start()));
211+
connect(prefix_typing_delay, SIGNAL(timeout()), this, SLOT(changedSearch()));
212212

213213
connect(view, SIGNAL(doubleClicked(QModelIndex)), this, SIGNAL(doubleClicked(QModelIndex)));
214214
connect(view, SIGNAL(clicked(QModelIndex)), this, SLOT(computeSum()));
@@ -285,7 +285,7 @@ void TransactionView::setModel(WalletModel *_model)
285285

286286
// Watch-only signal
287287
connect(_model, SIGNAL(notifyWatchonlyChanged(bool)), this, SLOT(updateWatchOnlyColumn(bool)));
288-
288+
289289
// Update transaction list with persisted settings
290290
chooseType(settings.value("transactionType").toInt());
291291
chooseDate(settings.value("transactionDate").toInt());
@@ -296,7 +296,7 @@ void TransactionView::chooseDate(int idx)
296296
{
297297
if(!transactionProxyModel)
298298
return;
299-
299+
300300
QSettings settings;
301301
QDate current = QDate::currentDate();
302302
dateRangeWidget->setVisible(false);
@@ -375,11 +375,11 @@ void TransactionView::chooseInstantSend(int idx)
375375
(TransactionFilterProxy::InstantSendFilter)instantsendWidget->itemData(idx).toInt());
376376
}
377377

378-
void TransactionView::changedPrefix()
378+
void TransactionView::changedSearch()
379379
{
380380
if(!transactionProxyModel)
381381
return;
382-
transactionProxyModel->setAddressPrefix(addressWidget->text());
382+
transactionProxyModel->setSearchString(search_widget->text());
383383
}
384384

385385
void TransactionView::changedAmount()
@@ -615,7 +615,7 @@ QWidget *TransactionView::createDateRangeWidget()
615615
QString defaultDateFrom = QDate::currentDate().toString(PERSISTENCE_DATE_FORMAT);
616616
QString defaultDateTo = QDate::currentDate().addDays(1).toString(PERSISTENCE_DATE_FORMAT);
617617
QSettings settings;
618-
618+
619619
dateRangeWidget = new QFrame();
620620
dateRangeWidget->setFrameStyle(QFrame::Panel | QFrame::Raised);
621621
dateRangeWidget->setContentsMargins(1,1,1,1);
@@ -656,12 +656,12 @@ void TransactionView::dateRangeChanged()
656656
{
657657
if(!transactionProxyModel)
658658
return;
659-
659+
660660
// Persist new date range
661661
QSettings settings;
662662
settings.setValue("transactionDateFrom", dateFrom->date().toString(PERSISTENCE_DATE_FORMAT));
663663
settings.setValue("transactionDateTo", dateTo->date().toString(PERSISTENCE_DATE_FORMAT));
664-
664+
665665
transactionProxyModel->setDateRange(
666666
QDateTime(dateFrom->date()),
667667
QDateTime(dateTo->date()));

src/qt/transactionview.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class TransactionView : public QWidget
6868
QComboBox *typeWidget;
6969
QComboBox *watchOnlyWidget;
7070
QComboBox *instantsendWidget;
71-
QLineEdit *addressWidget;
71+
QLineEdit *search_widget;
7272
QLineEdit *amountWidget;
7373

7474
QMenu *contextMenu;
@@ -118,7 +118,7 @@ public Q_SLOTS:
118118
void chooseWatchonly(int idx);
119119
void chooseInstantSend(int idx);
120120
void changedAmount();
121-
void changedPrefix();
121+
void changedSearch();
122122
void exportClicked();
123123
void focusTransaction(const QModelIndex&);
124124
void computeSum();

0 commit comments

Comments
 (0)