// This file was generated automatically by Qleany's generator, edit at your own risk! 
// If you do, be careful to not overwrite it when you run the generator again.
#pragma once

#include "{{ model.entity_name_snake }}/{{ model.entity_name_snake }}_dto.h"
#include "{{ export_header_file }}"
#include <QAbstractListModel>

using namespace {{ application_cpp_domain_name }}::Contracts::DTO::{{ model.entity_name_pascal }};

namespace {{ application_cpp_domain_name }}::Presenter
{
class {{ export }} {{ model.class_name_pascal }} : public QAbstractListModel
{
    Q_OBJECT

  public:
    enum Roles
    {
        {% for field in model.fields %}
        {{ field.pascal_name }}Role = Qt::UserRole + {{ loop.index0 }}{{ "," if not loop.last }}  
        {%- endfor %}      
    };
    Q_ENUM(Roles)

    explicit {{ model.class_name_pascal }}(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;

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

    Qt::ItemFlags flags(const QModelIndex &index) const override;
    {% if not model.read_only %}
    bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
    {% endif %}
    QHash<int, QByteArray> roleNames() const override;

  Q_SIGNALS:

  private:
    void populate();

    QList<{{ model.entity_name_pascal }}DTO> m_{{ model.entity_name_camel }}List;
    QList<int> m_{{ model.entity_name_camel }}IdList;
};

} // namespace {{ application_cpp_domain_name }}::Presenter
