2020-05-24 13:20:03 +02:00
|
|
|
/*
|
|
|
|
|
* This file is part of the Flowee project
|
2021-01-05 14:03:30 +01:00
|
|
|
* Copyright (C) 2020 Tom Zander <tom@flowee.org>
|
2020-05-24 13:20:03 +02:00
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
#ifndef PORTFOLIODATAPROVIDER_H
|
|
|
|
|
#define PORTFOLIODATAPROVIDER_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
2020-10-14 15:12:33 +02:00
|
|
|
#include "AccountInfo.h"
|
2020-06-08 14:37:29 +02:00
|
|
|
|
2020-10-14 15:12:33 +02:00
|
|
|
class Wallet;
|
|
|
|
|
class BitcoinValue;
|
2020-10-23 22:34:34 +02:00
|
|
|
class Payment;
|
2020-06-08 14:37:29 +02:00
|
|
|
|
2020-05-24 13:20:03 +02:00
|
|
|
class PortfolioDataProvider : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2021-11-29 20:57:41 +01:00
|
|
|
Q_PROPERTY(QList<QObject*> accounts READ accounts NOTIFY accountsChanged)
|
2021-12-04 11:25:27 +01:00
|
|
|
Q_PROPERTY(QList<QObject*> archivedAccounts READ archivedAccounts NOTIFY accountsChanged)
|
2020-05-24 13:20:03 +02:00
|
|
|
Q_PROPERTY(AccountInfo* current READ current WRITE setCurrent NOTIFY currentChanged)
|
2021-04-29 12:26:02 +02:00
|
|
|
Q_PROPERTY(double totalBalance READ totalBalance NOTIFY totalBalanceChanged)
|
2020-05-24 13:20:03 +02:00
|
|
|
public:
|
|
|
|
|
explicit PortfolioDataProvider(QObject *parent = nullptr);
|
|
|
|
|
|
2021-11-29 20:57:41 +01:00
|
|
|
QList<QObject*> accounts() const;
|
2021-12-04 11:25:27 +01:00
|
|
|
QList<QObject*> archivedAccounts() const;
|
2020-05-24 13:20:03 +02:00
|
|
|
|
|
|
|
|
AccountInfo *current() const;
|
|
|
|
|
void setCurrent(AccountInfo *item);
|
|
|
|
|
|
2021-11-16 11:47:33 +01:00
|
|
|
/// find the highest priority wallet and make it the selected one
|
2020-06-11 17:41:18 +02:00
|
|
|
void selectDefaultWallet();
|
|
|
|
|
|
2021-04-29 12:26:02 +02:00
|
|
|
double totalBalance() const;
|
|
|
|
|
|
2020-05-24 13:20:03 +02:00
|
|
|
public slots:
|
|
|
|
|
void addWalletAccount(Wallet *wallet);
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void accountsChanged();
|
|
|
|
|
void currentChanged();
|
2021-04-29 12:26:02 +02:00
|
|
|
void totalBalanceChanged();
|
2020-05-24 13:20:03 +02:00
|
|
|
|
2020-10-19 16:50:36 +02:00
|
|
|
private slots:
|
|
|
|
|
void walletChangedPriority();
|
|
|
|
|
|
2020-05-24 13:20:03 +02:00
|
|
|
private:
|
2021-11-16 11:47:33 +01:00
|
|
|
Payment* createPaymentObject(const QString &address, double value) const;
|
2020-10-23 22:34:34 +02:00
|
|
|
|
2020-05-24 13:20:03 +02:00
|
|
|
QList<Wallet*> m_accounts;
|
|
|
|
|
QList<AccountInfo*> m_accountInfos;
|
|
|
|
|
|
|
|
|
|
int m_currentAccount = -1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|