#ifndef TAGEDIT_H
#define TAGEDIT_H

#include <QLineEdit>
#include <QLabel>
#include <QHBoxLayout>
#include <QPushButton>
#include "IxWidgetFactory.h"
#include "IxWidget.h"
#include "Tag.h"

class TagEditWidget : public QLineEdit, public IxWidget
{
    Q_OBJECT
public:
	static const QString type;

public:
	TagEditWidget(QWidget *parent = nullptr);

    IXWIDGET_OBJECT_NAME

public:
    QVariant getValue() const override;

	void setValue(const QVariant &value) override;

    bool isValueNull() const override;

    void clearInput() override;

protected:
	bool eventFilter(QObject * watched, QEvent * event) override;

    void addTag(const QString &text);

Q_SIGNALS:
	void tagChanged(QStringList);

public slots:
    void onEnter();

private slots:
    void onTagRemoved(Tag* tag);

private:
    void renderTags();
    void outputValue();

protected:
    QVector<Tag *> tags;
};

#endif // TAGEDIT_H
