mirror of
https://git.wownero.com/wowlet/wowlet.git
synced 2024-08-15 01:03:14 +00:00
133700160a
Co-Authored-By: tobtoht <thotbot@protonmail.com>
64 lines
1.4 KiB
C++
64 lines
1.4 KiB
C++
// SPDX-License-Identifier: BSD-3-Clause
|
|
// Copyright (c) 2014-2020, 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();
|
|
}
|