#include "PropertyTypeCustomization_Font.h"
#include "QQuickDetailsViewLayoutBuilder.h"
#include "QQuickDetailsViewMananger.h"
#include "QPropertyHandle.h"

void PropertyTypeCustomization_Font::customizeHeaderRow(QPropertyHandle* inPropertyHandle, QQuickDetailsViewRowBuilder* inBuilder)
{
	// Same as makePropertyRow but uses the manager's registered type editor
	// instead of the Object impl's createValueEditor (which returns nullptr).
	auto slotPair = inBuilder->makeNameValueSlot();

	QQuickItem* nameEditor = inPropertyHandle->setupNameEditor(slotPair.first);
	QQuickItem* valueEditor = QQuickDetailsViewManager::Get()->createValueEditor(inPropertyHandle, slotPair.second);

	QQmlEngine* engine = qmlEngine(inBuilder->rootItem());
	QQmlContext* context = qmlContext(inBuilder->rootItem());
	context->parentContext()->setContextProperty("heightProxy", valueEditor ? valueEditor : nameEditor);
}

void PropertyTypeCustomization_Font::customizeChildren(QPropertyHandle* inPropertyHandle, QQuickDetailsViewLayoutBuilder* inBuilder)
{
	// QFont has no children — don't expand as tree
}
