#ifndef OBJECT_TREE_H
#define OBJECT_TREE_H

#include <QTreeWidget>
#include "SH_types.h"

namespace Ui {
	class ObjectTree;
};


class ObjectTree: public QWidget {
	Q_OBJECT
public:
	explicit ObjectTree(QWidget * parent = 0);

	void clear();
	void create(const SHS::Object & root);
	void setFilterButtonsVisible(bool yes);
	void setPropertiesVisible(bool yes);
	void setEventsVisible    (bool yes);
	void setCommandsVisible  (bool yes);

private:
	void createObjectsTree(QTreeWidgetItem * root, const SHS::Object & o);
	void addBlockPacketItem(const SHS::Command & c, const QString & name, QTreeWidgetItem * ni, SHS::PacketFlag flag, const QIcon & icon);
	void addBlockPropertyItem(const QString & p, const QString & v, const QStringList & obj_path, QTreeWidgetItem * ni, const QIcon & icon);

	bool filterBlockTree(QTreeWidgetItem * root, bool obj_vis);

	Ui::ObjectTree * ui;
	QIcon icon_signal, icon_command, icon_property, icon_object;

public slots:

private slots:
	void on_tree_itemDoubleClicked(QTreeWidgetItem * item, int );
	void on_tree_currentItemChanged(QTreeWidgetItem * item, QTreeWidgetItem*);
	void sessionSave(QByteArray * data);
	void sessionLoad(QByteArray * data);
	void filterBlocks();

signals:
	void propertyDoubleClicked(QStringList path);
	void commandDoubleClicked(SHS::Command cmd);
	void currentPropertyChanged(QStringList path);
	void currentCommandChanged(SHS::Command cmd);


};


#endif // OBJECT_TREE_H
