#ifndef RELAYWIDGET_H
#define RELAYWIDGET_H

#include <QWidget>
#include <memory>
#include "../items/item.h"

namespace Ui
{
class ItemWidget;
}

class ItemWidget : public QWidget
{
	Q_OBJECT
private:
	std::weak_ptr<Item> item_;
	bool noGroupEdit_;

	void disable();

signals:

	void deleteRequest(const ItemData& item);

private slots:
	void showSettingsDialog();
	void moveToState(bool state);
	void moveToValue(int value);
	void deleteItem();

public:
	explicit ItemWidget(std::weak_ptr<Item> item, bool noGroupEdit = false, QWidget *parent = nullptr);
	std::weak_ptr<Item> getItem();
	bool controles(const ItemData& relay);
	~ItemWidget();

public slots:

	void stateChanged(int state);
	void onItemUpdated(ItemUpdateRequest update);

private:
	Ui::ItemWidget *ui;
};

#endif // RELAYWIDGET_H
