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

#include <QAbstractListModel>
#include <QVector>

class SKGMTransactionListModel : public QAbstractListModel
{
    Q_OBJECT

public:
    struct TransactionItem {
        int operationId{-1};
        QString date;
        QString payee;
        QString category;
        QString comment;
        QString mode;
        QString number;
        QString amountText;
        double amount{0.0};
    };

    enum TransactionRoles {
        DateRole = Qt::UserRole + 1,
        OperationIdRole,
        PayeeRole,
        CategoryRole,
        CommentRole,
        ModeRole,
        NumberRole,
        AmountTextRole,
        AmountRole
    };
    Q_ENUM(TransactionRoles)

    explicit SKGMTransactionListModel(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 setTransactions(QVector<TransactionItem> iTransactions);
    void clear();

private:
    QVector<TransactionItem> m_transactions;
};

#endif
