#ifndef QT_COMPOSITE_ITEM
#define QT_COMPOSITE_ITEM

#include <qwidget.h>
#include <qobject.h>
#include <qstring.h>
#include <map>

class ScienceLeafNode;

/** Composite item of some leaf */
class CompositeItem : public QObject
{
	Q_OBJECT
public:
	/** Constructor 
	* @param graphicalName Graphical name of composite item
	* @param nodeName Logical name of composite item
	*/
	CompositeItem(const std::string & nodeName, QString graphicalName);

	/** Gets name of composite item 
	* @return Name of composite item
	*/
	QString getGraphicalName();

	/** Gets amount of created scientific points
	* @return Amount of created scientific points
	*/
	double getCreatedPoints();

	/** Sets amount of created scientific points
	* @param value Amount of created scientific points
	*/
	void setCreatedPoints(double value);

	/** Gets amount of assigned percents
	* @return Amount of assigned percents 
	*/
	int getAssignedPercents();

	/** Sets amount of assigned percents
	* @param value Amount of assigned percents 
	*/
	void setAssignedPercents(int value);

	/** Gets parent leaf, that contains this item
	* @return Returns parent leaf, that contains this item
	*/
	ScienceLeafNode * getParentLeaf();

	/** Sets reference to parent leaf, that contains this item
	* @param leaf Parent leaf, that contains this item
	*/
	void setParentLeaf(ScienceLeafNode * leaf);

	/** Clears complete state of the parameters, that means percents and created scientific points. */
	void clearState();

	/** Refreshes graphic of widget bases on logical values */
	void refreshWidget();
public slots:
	 /** Slot for handling change of assigned percents 
	 @param value Assigned percents
	 */
     void assignedPercentsChanged(int value);

signals:
	/** Signal for change of free percents in parent leaf */
	void freePercentsChanged();

private:
	/** Assigned percents from parent leaf */
	int assignedPercents_;

	/** Created real scientific points */
	double createdPoints_;

	/** Graphical name of composite parameter */
	QString name_;

	/* Logical name of composite parameter */
	std::string compositeName_;

	/** Parent leaf that contains this item */
	ScienceLeafNode * parentLeaf_;
};

#endif