#pragma once

#include "qsacnnode_global.h"
#include <QAbstractTableModel>
#include "qsacnuniverse.h"

class QT_EXPORT UniverseModel
    : public QAbstractTableModel
{
    Q_OBJECT

public:
    enum data_modes {
        Decimal,
        Hex,
        Percent
    };
    Q_ENUM(data_modes)

    explicit UniverseModel(QObject *parent = nullptr);

    // Header:
    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;

    // Basic functionality:
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;

    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;

    // Editable:
    bool setData(const QModelIndex &index, const QVariant &value,
                 int role = Qt::EditRole) override;

    Qt::ItemFlags flags(const QModelIndex& index) const override;

    // Data source:
    void setUniverse(QSacnUniverse *universe);
    QSacnUniverse * universe() const { return universe_; }
    data_modes dataMode() { return data_mode_; }

signals:
    void recievedUpdate(const QSacnUniverse*);

public slots:
    void universeRefreshed();
    void setDataMode(const QString mode);

private:
    QSacnUniverse * universe_ = nullptr;
    data_modes data_mode_ = Decimal;
};
