#ifndef CONNECTION_EDIT_H
#define CONNECTION_EDIT_H

#include <QDialog>
#include "piconnection.h"

namespace Ui {
	class ConnectionEdit;
};

class FilterItem;
class DeviceItem;
class SenderItem;

class ConnectionEdit: public QDialog {
	Q_OBJECT
public:
	explicit ConnectionEdit(QWidget * parent = 0);
	~ConnectionEdit();
	
	QString configuration() const;
	QByteArray model() const;
	QString name() const;
	
	void setName(const QString & name);
	void addDevice(const QString & name, const QString & path);
	void setModel(const QByteArray & m);
	
private:
	void accept();
	void keyPressEvent(QKeyEvent *) {}
	void applyFilter(FilterItem * b);
	void applyDevice(DeviceItem * b);
	void applySender(SenderItem * b);
	int getOptions() const;
	void setOptions(int o);
	
	Ui::ConnectionEdit * ui;
	PIConnection * conn;
	bool loading;
	int udevicenum;
	
private slots:
	void recreateRequest() {if (!loading) QMetaObject::invokeMethod(this, "recreateConnection", Qt::QueuedConnection);}
	void on_buttonRemove_clicked();
	void on_buttonClear_clicked();
	void on_buttonFilterAdd_clicked();
	void on_buttonFilterModify_clicked();
	void on_buttonDeviceAdd_clicked();
	void on_buttonDeviceModify_clicked();
	void on_buttonSenderAdd_clicked();
	void on_buttonSenderModify_clicked();
	void on_comboSplit_currentIndexChanged(int index);
	void selectionChanged();
	
public slots:
	void recreateConnection();
	
};

#endif // CONNECTION_EDIT_H
