mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
qt: Refactor open date range to use std::optional
This commit is contained in:
@@ -9,15 +9,8 @@
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
// Earliest date that can be represented (far in the past)
|
||||
const QDateTime TransactionFilterProxy::MIN_DATE = QDateTime::fromTime_t(0);
|
||||
// Last date that can be represented (far in the future)
|
||||
const QDateTime TransactionFilterProxy::MAX_DATE = QDateTime::fromTime_t(0xFFFFFFFF);
|
||||
|
||||
TransactionFilterProxy::TransactionFilterProxy(QObject *parent) :
|
||||
QSortFilterProxyModel(parent),
|
||||
dateFrom(MIN_DATE),
|
||||
dateTo(MAX_DATE),
|
||||
m_search_string(),
|
||||
typeFilter(ALL_TYPES),
|
||||
watchOnlyFilter(WatchOnlyFilter_All),
|
||||
@@ -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;
|
||||
if (dateTo && datetime > *dateTo) return false;
|
||||
|
||||
QString address = index.data(TransactionTableModel::AddressRole).toString();
|
||||
QString label = index.data(TransactionTableModel::LabelRole).toString();
|
||||
@@ -65,10 +58,10 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &
|
||||
return true;
|
||||
}
|
||||
|
||||
void TransactionFilterProxy::setDateRange(const QDateTime &from, const QDateTime &to)
|
||||
void TransactionFilterProxy::setDateRange(const std::optional<QDateTime>& from, const std::optional<QDateTime>& to)
|
||||
{
|
||||
this->dateFrom = from;
|
||||
this->dateTo = to;
|
||||
dateFrom = from;
|
||||
dateTo = to;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user