#ifndef SH_PLUGIN_WIDGETS_H
#define SH_PLUGIN_WIDGETS_H

#include <QWidget>
#include <session_manager.h>
#include "SH_plugin_base.h"


class SHPacketWidgetBase: public QWidget {
	Q_OBJECT
public:
	explicit SHPacketWidgetBase(QWidget * parent = 0): QWidget(parent) {}

	virtual SHS::Command saveCommand() = 0;
	virtual bool loadCommand(const SHS::Command & cmd) = 0;

	/// Return string representation of command "command"
	virtual QString commandToString(const SHS::Command & command) {Q_UNUSED(command); return QString();}

};


class SHBlockWidgetBaseInterface: public QObject {
	Q_OBJECT
public:

signals:
	void changed();

};


class SHBlockWidgetBase {
public:
	explicit SHBlockWidgetBase(QObject * parent = 0) {
		plugin = nullptr;
		device = nullptr;
		_interface = new SHBlockWidgetBaseInterface();
	}

	virtual ~SHBlockWidgetBase() {delete _interface;}

	/// Return configuration file extension (e.g. "dcp")
	virtual QString fileExtension() const {return QString();}

	/// Implement to reset configuration
	virtual void reset() {;}

	/// Implement to load configuration
	virtual bool load(QByteArray data) {Q_UNUSED(data); return true;}

	/// Implement to save configuration
	virtual QByteArray save() const {return QByteArray();}

	virtual void loadSession() {}
	virtual void saveSession() {}

	virtual void setAddress(int a) {}
	virtual void deviceOpened() {}
	virtual void deviceClosed() {}
	virtual void deviceReaded(QByteArray data) {Q_UNUSED(data);}

	/// Return editor widget here (can be 'this')
	/// class may be any QWidget-derived
	/// in case of QMainWindow menus, toolbars, docks and central
	/// widget will be used
	virtual QWidget * widget() = 0;

	SHBlockWidgetBaseInterface * interface() {return _interface;}

	SHPluginBase * plugin;
	DeviceWidget * device;

protected:
	SessionManager session;

private:
	SHBlockWidgetBaseInterface * _interface;

};


#endif
