#include "AutoCompleteComBoxWidget.h"

#include <QCompleter>
#include <QLineEdit>

const QString AutoCompleteComBoxWidget::type = "AutoCompleteComBox";

AutoCompleteComBoxWidget::AutoCompleteComBoxWidget(QWidget *parent)
    : ComboBoxWidget(parent)
{
	setEditable(true);
}

AutoCompleteComBoxWidget::~AutoCompleteComBoxWidget()
{
}

void AutoCompleteComBoxWidget::setOptions(const QVariantMap &options)
{
	ComboBoxWidget::setOptions(options);

	QCompleter *completer = new QCompleter(options.keys(), this);
	completer->setCompletionMode(QCompleter::PopupCompletion);
	completer->setFilterMode(Qt::MatchContains);
	setCompleter(completer);
}

void AutoCompleteComBoxWidget::clear()
{
	ComboBoxWidget::clear();
	lineEdit()->clear();
}

