mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-25 00:11:28 +02:00
Merge bitcoin-core/gui#593: Getting ready to Qt 6 (8/n). Use QRegularExpression
in AddressBookSortFilterProxyModel
class
e280087946184b37c8a1eb345fae30ebb07f3384 qt: Use `QRegularExpression` in `AddressBookSortFilterProxyModel` class (Hennadii Stepanov) 5c5d8f2465be70cbc256ec59913ac0a3c7c958be qt, test: Add tests for searching in `AddressBookPage` dialog (Hennadii Stepanov) Pull request description: This is a step in [migration](https://github.com/bitcoin/bitcoin/pull/24798) to Qt 6. Related: - bitcoin-core/gui#578 - bitcoin-core/gui#585 No behavior change. To ensure this, tests have been added. ACKs for top commit: hebasto: > tACK [e280087](e280087946
) on Ubuntu 21.10 Qt 5.15.2 promag: Tested ACK e280087946184b37c8a1eb345fae30ebb07f3384 with Qt6 on macOS 12 M1. w0xlt: tACKe280087946
on Ubuntu 21.10 Qt 5.15.2 jarolrod: Tested ACKe280087946
on M1 mac, x86 mac, x86 Linux with Qt5 and separately with Qt6 Tree-SHA512: 664baacc1504deb2f7fa651ea4a44f3942f5c9058befe4d2ce292beed032d4b1697710cfd10c0909602d8a4a6eeb680414e4a1f56d2038478c1ae2f34965d74f
This commit is contained in:
commit
8898906370
@ -19,6 +19,11 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#else
|
||||||
|
#include <QRegExp>
|
||||||
|
#endif
|
||||||
|
|
||||||
class AddressBookSortFilterProxyModel final : public QSortFilterProxyModel
|
class AddressBookSortFilterProxyModel final : public QSortFilterProxyModel
|
||||||
{
|
{
|
||||||
@ -46,12 +51,13 @@ protected:
|
|||||||
|
|
||||||
auto address = model->index(row, AddressTableModel::Address, parent);
|
auto address = model->index(row, AddressTableModel::Address, parent);
|
||||||
|
|
||||||
if (filterRegExp().indexIn(model->data(address).toString()) < 0 &&
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
filterRegExp().indexIn(model->data(label).toString()) < 0) {
|
const auto pattern = filterRegularExpression();
|
||||||
return false;
|
#else
|
||||||
}
|
const auto pattern = filterRegExp();
|
||||||
|
#endif
|
||||||
return true;
|
return (model->data(address).toString().contains(pattern) ||
|
||||||
|
model->data(label).toString().contains(pattern));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QLineEdit>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@ -102,11 +103,13 @@ void TestAddAddressesToSendBook(interfaces::Node& node)
|
|||||||
QString s_label("already here (s)");
|
QString s_label("already here (s)");
|
||||||
|
|
||||||
// Define a new address (which should add to the address book successfully).
|
// Define a new address (which should add to the address book successfully).
|
||||||
QString new_address;
|
QString new_address_a;
|
||||||
|
QString new_address_b;
|
||||||
|
|
||||||
std::tie(r_key_dest, preexisting_r_address) = build_address();
|
std::tie(r_key_dest, preexisting_r_address) = build_address();
|
||||||
std::tie(s_key_dest, preexisting_s_address) = build_address();
|
std::tie(s_key_dest, preexisting_s_address) = build_address();
|
||||||
std::tie(std::ignore, new_address) = build_address();
|
std::tie(std::ignore, new_address_a) = build_address();
|
||||||
|
std::tie(std::ignore, new_address_b) = build_address();
|
||||||
|
|
||||||
{
|
{
|
||||||
LOCK(wallet->cs_wallet);
|
LOCK(wallet->cs_wallet);
|
||||||
@ -159,9 +162,52 @@ void TestAddAddressesToSendBook(interfaces::Node& node)
|
|||||||
// Submit a new address which should add successfully - we expect the
|
// Submit a new address which should add successfully - we expect the
|
||||||
// warning message to be blank.
|
// warning message to be blank.
|
||||||
EditAddressAndSubmit(
|
EditAddressAndSubmit(
|
||||||
&editAddressDialog, QString("new"), new_address, QString(""));
|
&editAddressDialog, QString("io - new A"), new_address_a, QString(""));
|
||||||
check_addbook_size(3);
|
check_addbook_size(3);
|
||||||
QCOMPARE(table_view->model()->rowCount(), 2);
|
QCOMPARE(table_view->model()->rowCount(), 2);
|
||||||
|
|
||||||
|
EditAddressAndSubmit(
|
||||||
|
&editAddressDialog, QString("io - new B"), new_address_b, QString(""));
|
||||||
|
check_addbook_size(4);
|
||||||
|
QCOMPARE(table_view->model()->rowCount(), 3);
|
||||||
|
|
||||||
|
auto search_line = address_book.findChild<QLineEdit*>("searchLineEdit");
|
||||||
|
|
||||||
|
search_line->setText(r_label);
|
||||||
|
QCOMPARE(table_view->model()->rowCount(), 0);
|
||||||
|
|
||||||
|
search_line->setText(s_label);
|
||||||
|
QCOMPARE(table_view->model()->rowCount(), 1);
|
||||||
|
|
||||||
|
search_line->setText("io");
|
||||||
|
QCOMPARE(table_view->model()->rowCount(), 2);
|
||||||
|
|
||||||
|
// Check wilcard "?".
|
||||||
|
search_line->setText("io?new");
|
||||||
|
QCOMPARE(table_view->model()->rowCount(), 0);
|
||||||
|
search_line->setText("io???new");
|
||||||
|
QCOMPARE(table_view->model()->rowCount(), 2);
|
||||||
|
|
||||||
|
// Check wilcard "*".
|
||||||
|
search_line->setText("io*new");
|
||||||
|
QCOMPARE(table_view->model()->rowCount(), 2);
|
||||||
|
search_line->setText("*");
|
||||||
|
QCOMPARE(table_view->model()->rowCount(), 3);
|
||||||
|
|
||||||
|
search_line->setText(preexisting_r_address);
|
||||||
|
QCOMPARE(table_view->model()->rowCount(), 0);
|
||||||
|
|
||||||
|
search_line->setText(preexisting_s_address);
|
||||||
|
QCOMPARE(table_view->model()->rowCount(), 1);
|
||||||
|
|
||||||
|
search_line->setText(new_address_a);
|
||||||
|
QCOMPARE(table_view->model()->rowCount(), 1);
|
||||||
|
|
||||||
|
search_line->setText(new_address_b);
|
||||||
|
QCOMPARE(table_view->model()->rowCount(), 1);
|
||||||
|
|
||||||
|
search_line->setText("");
|
||||||
|
QCOMPARE(table_view->model()->rowCount(), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Loading…
x
Reference in New Issue
Block a user