mirror of
https://github.com/feather-wallet/feather.git
synced 2025-02-27 21:40:36 +00:00
69 lines
No EOL
1.5 KiB
C++
69 lines
No EOL
1.5 KiB
C++
// SPDX-License-Identifier: BSD-3-Clause
|
|
// SPDX-FileCopyrightText: 2014-2022 The Monero Project
|
|
|
|
#include "SubaddressAccount.h"
|
|
#include <QDebug>
|
|
|
|
SubaddressAccount::SubaddressAccount(Monero::SubaddressAccount *subaddressAccountImpl, QObject *parent)
|
|
: QObject(parent), m_subaddressAccountImpl(subaddressAccountImpl)
|
|
{
|
|
getAll();
|
|
}
|
|
|
|
void SubaddressAccount::getAll() const
|
|
{
|
|
emit refreshStarted();
|
|
|
|
{
|
|
QWriteLocker locker(&m_lock);
|
|
m_rows.clear();
|
|
for (auto &row: m_subaddressAccountImpl->getAll()) {
|
|
m_rows.append(row);
|
|
}
|
|
}
|
|
|
|
emit refreshFinished();
|
|
}
|
|
|
|
bool SubaddressAccount::getRow(int index, std::function<void (Monero::SubaddressAccountRow &)> callback) const
|
|
{
|
|
QReadLocker locker(&m_lock);
|
|
|
|
if (index < 0 || index >= m_rows.size())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
callback(*m_rows.value(index));
|
|
return true;
|
|
}
|
|
|
|
void SubaddressAccount::addRow(const QString &label) const
|
|
{
|
|
m_subaddressAccountImpl->addRow(label.toStdString());
|
|
getAll();
|
|
}
|
|
|
|
void SubaddressAccount::setLabel(quint32 accountIndex, const QString &label) const
|
|
{
|
|
m_subaddressAccountImpl->setLabel(accountIndex, label.toStdString());
|
|
getAll();
|
|
}
|
|
|
|
void SubaddressAccount::refresh() const
|
|
{
|
|
m_subaddressAccountImpl->refresh();
|
|
getAll();
|
|
}
|
|
|
|
quint64 SubaddressAccount::count() const
|
|
{
|
|
QReadLocker locker(&m_lock);
|
|
|
|
return m_rows.size();
|
|
}
|
|
|
|
Monero::SubaddressAccountRow* SubaddressAccount::row(int index) const
|
|
{
|
|
return m_rows.value(index);
|
|
} |