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

#include <QIdentityProxyModel>

class SKGObjectModelBase;
class QModelIndex;

class SKGMReferenceProxyModel : public QIdentityProxyModel
{
    Q_OBJECT

public:
    enum ReferenceKind {
        TrackerKind = 0,
        PayeeKind = 1,
        CategoryKind = 2,
        UnitKind = 3
    };
    Q_ENUM(ReferenceKind)

    enum Roles {
        NameRole = Qt::UserRole + 1,
        SubtitleRole,
        AmountRole,
        AmountTextRole,
        ClosedRole
    };
    Q_ENUM(Roles)

    explicit SKGMReferenceProxyModel(QObject *iParent = nullptr);

    void setKind(ReferenceKind iKind);
    void setObjectModel(const SKGObjectModelBase *iObjectModel);
    void setAmountUnitSymbol(const QString &iSymbol);

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

private:
    QModelIndex mapToObjectModelIndex(const QModelIndex &iSourceIndex) const;
    QString stringAttribute(const QModelIndex &iSourceIndex, const QString &iAttribute) const;
    double doubleAttribute(const QModelIndex &iSourceIndex, const QString &iAttribute) const;
    QString formatAmount(double iAmount) const;

    const SKGObjectModelBase *m_objectModel{nullptr};
    ReferenceKind m_kind{TrackerKind};
    QString m_amountUnitSymbol;
};

#endif
