Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor open date range to use std::optional #354

Merged
merged 1 commit into from
Aug 11, 2021

Conversation

promag
Copy link
Contributor

@promag promag commented Jun 3, 2021

Use std::nullopt for open date range instead of TransactionFilterProxy::MIN_DATE and TransactionFilterProxy::MAX_DATE.

@hebasto
Copy link
Member

hebasto commented Jun 9, 2021

Concept ACK

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK a7837ba, I have reviewed the code and it looks OK, I agree it can be merged.

@hebasto
Copy link
Member

hebasto commented Jun 11, 2021

nit: include <optional> to the src/qt/transactionview.cpp as std::nullopt are used there.

@promag promag force-pushed the 2021-06-date-range branch from a7837ba to 4830f49 Compare June 11, 2021 22:39
Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK 4830f49, only missed header included since my previous review.

Copy link

@Talkless Talkless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK 4830f49, tested on Debian Sid, filtering seems to work as expected.

@@ -46,8 +39,8 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &
return false;

QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime();
if (datetime < dateFrom || datetime > dateTo)
return false;
if (dateFrom && datetime < *dateFrom) return false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::optional does support comparison without dereferencing (see (26) in https://en.cppreference.com/w/cpp/utility/optional/operator_cmp) but your variant is better as operator< would repeat if (opt) check you already (rightly) did.

@hebasto hebasto merged commit 3d9cdb1 into bitcoin-core:master Aug 11, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 15, 2021
…onal

4830f49 qt: Refactor open date range to use std::optional (João Barbosa)

Pull request description:

  Use `std::nullopt` for open date range instead of `TransactionFilterProxy::MIN_DATE` and `TransactionFilterProxy::MAX_DATE`.

ACKs for top commit:
  hebasto:
    re-ACK 4830f49, only missed header included since my [previous](bitcoin-core/gui#354 (review)) review.
  Talkless:
    tACK 4830f49, tested on Debian Sid, filtering seems to work as expected.

Tree-SHA512: dcecbcc129cb401d6ac13a20f015b8cb2a7434fae6bd3e5b19fca5531e8bd915e2a0835f9c601371381750cdc8cd6fcf4f8c6669177d679773046cbe13bed68b
@bitcoin-core bitcoin-core locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants