#include "AutoCompleteComBoxWidgetFactory.h"
#include "AutoCompleteComBoxWidget.h"

AutoCompleteComBoxWidgetFactory::AutoCompleteComBoxWidgetFactory()
	: IxWidgetFactory()
{
}

AutoCompleteComBoxWidgetFactory::~AutoCompleteComBoxWidgetFactory()
{
}

void AutoCompleteComBoxWidgetFactory::create(qx::IxDataMember* dataMember, QWidget* parent)
{
	widget = new AutoCompleteComBoxWidget(parent);

	QVariantMap options;
	if (dataMember->getPropertyBag("dict").isValid())
	{
		options = dataMember->getPropertyBag("dict").toMap();
	}
	else
	{
		QString param = dataMember->getPropertyBag("param").toString();
		qx::any any = invokeStatic(dataMember, dataMember->getName() + "Options", param);
		if (any.empty())
			return;
		options = qx::any_cast<QVariantMap>(any);
	}
	widget->setOptions(options);
}

QString AutoCompleteComBoxWidgetFactory::type() const
{
	return AutoCompleteComBoxWidget::type;
}

QWidget* AutoCompleteComBoxWidgetFactory::getWidget() const
{
	return widget;
}

IxWidget* AutoCompleteComBoxWidgetFactory::getIxWidget() const
{
	return widget;
}
