/***************************************************************************
 * SPDX-FileCopyrightText: 2026 S. MANKOWSKI stephane@mankowski.fr
 * SPDX-License-Identifier: GPL-3.0-or-later
 ***************************************************************************/
#ifndef SKGMACCOUNTLISTMODEL_H
#define SKGMACCOUNTLISTMODEL_H

#include <QAbstractListModel>
#include <QVector>

class SKGMAccountListModel : public QAbstractListModel
{
    Q_OBJECT

public:
    enum RowKind {
        AccountRow = 0,
        TypeHeaderRow = 1,
        TypeTotalRow = 2
    };
    Q_ENUM(RowKind)

    struct AccountItem {
        QString name;
        QString bank;
        QString type;
        QString unit;
        QString amountText;
        double amount{0.0};
        bool closed{false};
        RowKind kind{AccountRow};
    };

    enum AccountRoles {
        NameRole = Qt::UserRole + 1,
        BankRole,
        TypeRole,
        UnitRole,
        AmountTextRole,
        AmountRole,
        ClosedRole,
        KindRole
    };
    Q_ENUM(AccountRoles)

    explicit SKGMAccountListModel(QObject *iParent = nullptr);

    int rowCount(const QModelIndex &iParent = QModelIndex()) const override;
    QVariant data(const QModelIndex &iIndex, int iRole = Qt::DisplayRole) const override;
    QHash<int, QByteArray> roleNames() const override;

    void setAccounts(QVector<AccountItem> iAccounts);
    void clear();

private:
    QVector<AccountItem> m_accounts;
};

#endif
