#pragma once

#include <qitemdelegate.h>
#include "QxOrm.h"
#include "IxWidget.h"
#include "WidgetFactory.h"

class CustomDelegate : public QItemDelegate
{
	Q_OBJECT

public:
	CustomDelegate(QObject *parent = nullptr);
	~CustomDelegate();

	template<typename T>
	void setClass()
	{
		dataMembers = qx::QxClass<T>::getSingleton()->getDataMemberX();
	}

	QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;

	void setEditorData(QWidget *editor, const QModelIndex &index) const override;

	void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;

private:
	qx::IxDataMemberX *dataMembers;
	WidgetFactory *factorys;
};
