mirror of
https://github.com/logos-blockchain/logos-execution-zone-wallet-ui.git
synced 2026-03-05 06:33:08 +00:00
39 lines
1.3 KiB
C++
39 lines
1.3 KiB
C++
|
|
#include "LEZAccountFilterModel.h"
|
||
|
|
|
||
|
|
LEZAccountFilterModel::LEZAccountFilterModel(QObject* parent)
|
||
|
|
: QSortFilterProxyModel(parent)
|
||
|
|
{
|
||
|
|
connect(this, &QAbstractItemModel::rowsInserted, this, &LEZAccountFilterModel::countChanged);
|
||
|
|
connect(this, &QAbstractItemModel::rowsRemoved, this, &LEZAccountFilterModel::countChanged);
|
||
|
|
connect(this, &QAbstractItemModel::modelReset, this, &LEZAccountFilterModel::countChanged);
|
||
|
|
connect(this, &QAbstractItemModel::layoutChanged, this, &LEZAccountFilterModel::countChanged);
|
||
|
|
}
|
||
|
|
|
||
|
|
void LEZAccountFilterModel::setFilterByPublic(bool value)
|
||
|
|
{
|
||
|
|
if (m_filterByPublic == value)
|
||
|
|
return;
|
||
|
|
m_filterByPublic = value;
|
||
|
|
invalidateFilter();
|
||
|
|
emit filterByPublicChanged();
|
||
|
|
emit countChanged();
|
||
|
|
}
|
||
|
|
|
||
|
|
bool LEZAccountFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
|
||
|
|
{
|
||
|
|
if (!sourceModel())
|
||
|
|
return false;
|
||
|
|
const QModelIndex idx = sourceModel()->index(sourceRow, 0, sourceParent);
|
||
|
|
const bool isPublic = sourceModel()->data(idx, LEZWalletAccountModel::IsPublicRole).toBool();
|
||
|
|
return isPublic == m_filterByPublic;
|
||
|
|
}
|
||
|
|
|
||
|
|
int LEZAccountFilterModel::rowForAddress(const QString& address) const
|
||
|
|
{
|
||
|
|
for (int i = 0; i < rowCount(); ++i) {
|
||
|
|
if (data(index(i, 0), LEZWalletAccountModel::AddressRole).toString() == address)
|
||
|
|
return i;
|
||
|
|
}
|
||
|
|
return -1;
|
||
|
|
}
|