2020-10-07 10:36:04 +00:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2020-12-26 19:56:06 +00:00
|
|
|
// Copyright (c) 2020-2021, The Monero Project.
|
2020-10-07 10:36:04 +00:00
|
|
|
|
|
|
|
#include "CoinsProxyModel.h"
|
|
|
|
#include "CoinsModel.h"
|
2021-02-03 23:14:20 +00:00
|
|
|
#include "libwalletqt/CoinsInfo.h"
|
2020-10-07 10:36:04 +00:00
|
|
|
|
2021-02-03 23:14:20 +00:00
|
|
|
CoinsProxyModel::CoinsProxyModel(QObject *parent, Coins *coins)
|
|
|
|
: QSortFilterProxyModel(parent), m_coins(coins)
|
2020-10-07 10:36:04 +00:00
|
|
|
{
|
2020-10-21 14:53:17 +00:00
|
|
|
setSortRole(Qt::UserRole);
|
2020-10-07 10:36:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CoinsProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
|
|
|
{
|
2021-02-03 23:14:20 +00:00
|
|
|
bool isSpent;
|
|
|
|
int accountIndex;
|
|
|
|
m_coins->coin(sourceRow, [&isSpent, &accountIndex](const CoinsInfo &c){
|
|
|
|
isSpent = c.spent();
|
|
|
|
accountIndex = c.subaddrAccount();
|
|
|
|
});
|
2020-10-07 10:36:04 +00:00
|
|
|
|
2021-02-03 23:14:20 +00:00
|
|
|
return !(!m_showSpent && isSpent) && accountIndex == 0;
|
2020-10-07 10:36:04 +00:00
|
|
|
}
|