mirror of
https://github.com/dogecoin/dogecoin.git
synced 2026-03-15 07:52:27 +00:00
a720b92 Remove includes in .cpp files for things the corresponding .h file already included (practicalswift) Pull request description: Remove includes in .cpp files for things the corresponding .h file already included. Example case: * `addrdb.cpp` includes `addrdb.h` and `fs.h` * `addrdb.h` includes `fs.h` Then remove the direct inclusion of `fs.h` in `addrman.cpp` and rely on the indirect inclusion of `fs.h` via the included `addrdb.h`. In line with the header include guideline (see #10575). Tree-SHA512: 8704b9de3011a4c234db336a39f7d2c139e741cf0f7aef08a5d3e05197e1e18286b863fdab25ae9638af4ff86b3d52e5cab9eed66bfa2476063aa5c79f9b0346
118 lines
3.6 KiB
C++
118 lines
3.6 KiB
C++
// Copyright (c) 2011-2016 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <qt/transactionfilterproxy.h>
|
|
|
|
#include <qt/transactiontablemodel.h>
|
|
#include <qt/transactionrecord.h>
|
|
|
|
#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),
|
|
minAmount(0),
|
|
limitRows(-1),
|
|
showInactive(true)
|
|
{
|
|
}
|
|
|
|
bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
|
{
|
|
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
|
|
|
int type = index.data(TransactionTableModel::TypeRole).toInt();
|
|
QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime();
|
|
bool involvesWatchAddress = 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();
|
|
qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong());
|
|
int status = index.data(TransactionTableModel::StatusRole).toInt();
|
|
|
|
if(!showInactive && status == TransactionStatus::Conflicted)
|
|
return false;
|
|
if(!(TYPE(type) & typeFilter))
|
|
return false;
|
|
if (involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_No)
|
|
return false;
|
|
if (!involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_Yes)
|
|
return false;
|
|
if(datetime < dateFrom || datetime > dateTo)
|
|
return false;
|
|
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)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
void TransactionFilterProxy::setDateRange(const QDateTime &from, const QDateTime &to)
|
|
{
|
|
this->dateFrom = from;
|
|
this->dateTo = to;
|
|
invalidateFilter();
|
|
}
|
|
|
|
void TransactionFilterProxy::setSearchString(const QString &search_string)
|
|
{
|
|
if (m_search_string == search_string) return;
|
|
m_search_string = search_string;
|
|
invalidateFilter();
|
|
}
|
|
|
|
void TransactionFilterProxy::setTypeFilter(quint32 modes)
|
|
{
|
|
this->typeFilter = modes;
|
|
invalidateFilter();
|
|
}
|
|
|
|
void TransactionFilterProxy::setMinAmount(const CAmount& minimum)
|
|
{
|
|
this->minAmount = minimum;
|
|
invalidateFilter();
|
|
}
|
|
|
|
void TransactionFilterProxy::setWatchOnlyFilter(WatchOnlyFilter filter)
|
|
{
|
|
this->watchOnlyFilter = filter;
|
|
invalidateFilter();
|
|
}
|
|
|
|
void TransactionFilterProxy::setLimit(int limit)
|
|
{
|
|
this->limitRows = limit;
|
|
}
|
|
|
|
void TransactionFilterProxy::setShowInactive(bool _showInactive)
|
|
{
|
|
this->showInactive = _showInactive;
|
|
invalidateFilter();
|
|
}
|
|
|
|
int TransactionFilterProxy::rowCount(const QModelIndex &parent) const
|
|
{
|
|
if(limitRows != -1)
|
|
{
|
|
return std::min(QSortFilterProxyModel::rowCount(parent), limitRows);
|
|
}
|
|
else
|
|
{
|
|
return QSortFilterProxyModel::rowCount(parent);
|
|
}
|
|
}
|