#ifndef QCD_KVIEW_H
#define QCD_KVIEW_H

#include "piobject.h"
#include <QTreeView>

class CDKItemModel;

class CDKView: public QTreeView, public PIObject
{
	Q_OBJECT
	PIOBJECT(CDKView)
public:
	explicit CDKView(QWidget *parent = 0);
	~CDKView();

	void setKFile(const QString & filename);
	void startPing();

	CDKItemModel * CDKModel() {return kmodel;}

public slots:
	void refresh();
	void sendK();
	void receiveK();
	void saveK();
	void loadK();
	void clearK();
	void buildFromHeader(const QString & kdescription, int mode = 2);
	void calculateK();

private slots:
	void k_sendFailed();
	void k_sendSucceed();
	void k_receiveFailed();
	void k_receiveSucceed();

private:
	EVENT_HANDLER(void, cdk_sendFailed) {emit _qcdk_sendFailed();}
	EVENT_HANDLER(void, cdk_sendSucceed) {emit _qcdk_sendSucceed();}
	EVENT_HANDLER(void, cdk_receiveFailed) {emit _qcdk_receiveFailed();}
	EVENT_HANDLER(void, cdk_receiveSucceed) {emit _qcdk_receiveSucceed();}

	CDKItemModel * kmodel;

signals:
	void KSendFailed();
	void KSendSucceed();
	void KReceiveFailed();
	void KReceiveSucceed();
	void messageStatus(QString msg);
	void busyStatusChanged(bool busy);

	void _qcdk_sendFailed(); // PRIVATE
	void _qcdk_sendSucceed(); // PRIVATE
	void _qcdk_receiveFailed(); // PRIVATE
	void _qcdk_receiveSucceed(); // PRIVATE

};

#endif // QCD_KVIEW_H
