/* * This file is part of the Flowee project * Copyright (C) 2020 Tom Zander * * 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 . */ #ifndef PORTFOLIODATAPROVIDER_H #define PORTFOLIODATAPROVIDER_H #include #include "AccountInfo.h" class Wallet; class BitcoinValue; class Payment; class PortfolioDataProvider : public QObject { Q_OBJECT Q_PROPERTY(QList accounts READ accounts NOTIFY accountsChanged) Q_PROPERTY(AccountInfo* current READ current WRITE setCurrent NOTIFY currentChanged) Q_PROPERTY(double totalBalance READ totalBalance NOTIFY totalBalanceChanged) public: explicit PortfolioDataProvider(QObject *parent = nullptr); QList accounts() const; AccountInfo *current() const; void setCurrent(AccountInfo *item); /// find the highest priority wallet and make it the selected one void selectDefaultWallet(); double totalBalance() const; public slots: void addWalletAccount(Wallet *wallet); signals: void accountsChanged(); void currentChanged(); void totalBalanceChanged(); private slots: void walletChangedPriority(); private: Payment* createPaymentObject(const QString &address, double value) const; QList m_accounts; QList m_accountInfos; int m_currentAccount = -1; }; #endif