Skip to content

Commit

Permalink
Merge #11395: Qt: Enable searching by transaction id
Browse files Browse the repository at this point in the history
Summary:
eac2abca0 Qt: Enable searching by transaction id (Luke Dashjr)
c407c61c5 Qt: Avoid invalidating the search filter, when it doesn't really change (Luke Dashjr)
b1f634242 Qt: Rename confusingly-named "address prefix" to "search string" (Luke Dashjr)

Pull request description:

Tree-SHA512: 1c67037d19689fbaff21d15ed7848ac86188e5de34728312e1f9758dada759cab50d913a5bc09e413ecaa3e07557cf253809b95b5637ff79f2e3cf24d86dd3ed

Backport of Core PR11395
bitcoin/bitcoin#11395

Depends on D3832

Test Plan:
  make check
  ./bitcoin-qt -> transactions -> enter transaction id to filter by

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: Fabien, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D3833
  • Loading branch information
jonasschnelli authored and jonspock committed Dec 8, 2019
1 parent 09fa1b3 commit 5e0d0bb
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
4 changes: 2 additions & 2 deletions doc/abc_update_logs.md
Expand Up @@ -568,8 +568,8 @@
Merge #11842: [build] Add missing stuff to clean-local
Merge #12489: Bugfix: respect user defined configuration file (-conf) in QT settings
Merge #12996: tests: Remove redundant bytes(…) calls
Merge #11395: Qt: Enable searching by transaction id
Merge #11015: [Qt] Add delay before filtering transactions
# Merge #11395: Qt: Enable searching by transaction id
# Merge #11015: [Qt] Add delay before filtering transactions
[teamcity/gitian] Do not remove src tarball from results
# Merge #10642: Remove obsolete _MSC_VER check
Merge #12447: test: Add missing signal.h header
Expand Down
18 changes: 12 additions & 6 deletions src/qt/transactionfilterproxy.cpp
Expand Up @@ -19,8 +19,9 @@ const QDateTime TransactionFilterProxy::MAX_DATE =

TransactionFilterProxy::TransactionFilterProxy(QObject *parent)
: QSortFilterProxyModel(parent), dateFrom(MIN_DATE), dateTo(MAX_DATE),
addrPrefix(), typeFilter(ALL_TYPES), watchOnlyFilter(WatchOnlyFilter_All),
minAmount(), limitRows(-1), showInactive(true) {}
m_search_string(), typeFilter(ALL_TYPES),
watchOnlyFilter(WatchOnlyFilter_All), minAmount(), limitRows(-1),
showInactive(true) {}

bool TransactionFilterProxy::filterAcceptsRow(
int sourceRow, const QModelIndex &sourceParent) const {
Expand All @@ -33,6 +34,7 @@ bool TransactionFilterProxy::filterAcceptsRow(
index.data(TransactionTableModel::WatchonlyRole).toBool();
QString address = index.data(TransactionTableModel::AddressRole).toString();
QString label = index.data(TransactionTableModel::LabelRole).toString();
QString txid = index.data(TransactionTableModel::TxIDRole).toString();
Amount amount(
int64_t(
llabs(index.data(TransactionTableModel::AmountRole).toLongLong())));
Expand All @@ -53,8 +55,9 @@ bool TransactionFilterProxy::filterAcceptsRow(
if (datetime < dateFrom || datetime > dateTo) {
return false;
}
if (!address.contains(addrPrefix, Qt::CaseInsensitive) &&
!label.contains(addrPrefix, Qt::CaseInsensitive)) {
if (!address.contains(m_search_string, Qt::CaseInsensitive) &&
!label.contains(m_search_string, Qt::CaseInsensitive) &&
!txid.contains(m_search_string, Qt::CaseInsensitive)) {
return false;
}
if (amount < minAmount) {
Expand All @@ -71,8 +74,11 @@ void TransactionFilterProxy::setDateRange(const QDateTime &from,
invalidateFilter();
}

void TransactionFilterProxy::setAddressPrefix(const QString &_addrPrefix) {
this->addrPrefix = _addrPrefix;
void TransactionFilterProxy::setSearchString(const QString &search_string) {
if (m_search_string == search_string) {
return;
}
m_search_string = search_string;
invalidateFilter();
}

Expand Down
4 changes: 2 additions & 2 deletions src/qt/transactionfilterproxy.h
Expand Up @@ -41,7 +41,7 @@ class TransactionFilterProxy : public QSortFilterProxyModel {
};

void setDateRange(const QDateTime &from, const QDateTime &to);
void setAddressPrefix(const QString &addrPrefix);
void setSearchString(const QString &);
/**
* @note Type filter takes a bit field created with TYPE() or ALL_TYPES
*/
Expand All @@ -68,7 +68,7 @@ class TransactionFilterProxy : public QSortFilterProxyModel {
private:
QDateTime dateFrom;
QDateTime dateTo;
QString addrPrefix;
QString m_search_string;
quint32 typeFilter;
WatchOnlyFilter watchOnlyFilter;
Amount minAmount;
Expand Down
16 changes: 8 additions & 8 deletions src/qt/transactionview.cpp
Expand Up @@ -109,10 +109,10 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle,
hlayout->addWidget(typeWidget);
hlayout->addSpacing(15);

addressWidget = new QLineEdit(this);
addressWidget->setPlaceholderText(tr("Enter address or label to search"));
hlayout->addWidget(addressWidget);
hlayout->addSpacing(15);
search_widget = new QLineEdit(this);
search_widget->setPlaceholderText(
tr("Enter address, transaction id, or label to search"));
hlayout->addWidget(search_widget);

amountWidget = new QLineEdit(this);
amountWidget->setPlaceholderText(tr("Min amount"));
Expand Down Expand Up @@ -190,8 +190,8 @@ TransactionView::TransactionView(const PlatformStyle *platformStyle,
// Connect actions
connect(amountWidget, SIGNAL(textChanged(QString)), amount_typing_delay, SLOT(start()));
connect(amount_typing_delay, SIGNAL(timeout()), this, SLOT(changedAmount()));
connect(addressWidget, SIGNAL(textChanged(QString)), prefix_typing_delay, SLOT(start()));
connect(prefix_typing_delay, SIGNAL(timeout()), this, SLOT(changedPrefix()));
connect(search_widget, SIGNAL(textChanged(QString)), prefix_typing_delay, SLOT(start()));
connect(prefix_typing_delay, SIGNAL(timeout()), this, SLOT(changedSearch()));

connect(dateWidget,
static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this,
Expand Down Expand Up @@ -353,12 +353,12 @@ void TransactionView::chooseWatchonly(int idx) {
watchOnlyWidget->itemData(idx).toInt()));
}

void TransactionView::changedPrefix() {
void TransactionView::changedSearch() {
if (!transactionProxyModel) {
return;
}

transactionProxyModel->setAddressPrefix(addressWidget->text());
transactionProxyModel->setSearchString(search_widget->text());
}

void TransactionView::changedAmount() {
Expand Down
4 changes: 2 additions & 2 deletions src/qt/transactionview.h
Expand Up @@ -68,7 +68,7 @@ class TransactionView : public QWidget {
QComboBox *dateWidget;
QComboBox *typeWidget;
QComboBox *watchOnlyWidget;
QLineEdit *addressWidget;
QLineEdit *search_widget;
QLineEdit *amountWidget;

QMenu *contextMenu;
Expand Down Expand Up @@ -116,7 +116,7 @@ public Q_SLOTS:
void chooseType(int idx);
void chooseWatchonly(int idx);
void changedAmount();
void changedPrefix();
void changedSearch();
void exportClicked();
void focusTransaction(const QModelIndex &);
void focusTransaction(const uint256 &txid);
Expand Down

0 comments on commit 5e0d0bb

Please sign in to comment.