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

#include "CompositeItem.h"
#include "ScienceNode.h"

ScienceLeafNode * CompositeItem::getParentLeaf()
{
	return parentLeaf_;
}

void CompositeItem::setParentLeaf(ScienceLeafNode * leaf)
{
	parentLeaf_ = leaf;
}

void CompositeItem::assignedPercentsChanged(int value) {
	if (parentLeaf_->assignedPercentsChanged(this, value))
	{
		emit freePercentsChanged();
	}
}

CompositeItem::CompositeItem(const std::string & compositeName, QString graphicalName)
{
	name_ = graphicalName;
	compositeName_ = compositeName;

	assignedPercents_ = 0;
	createdPoints_ = 0;
}

QString CompositeItem::getGraphicalName()
{
	return name_;
}

double CompositeItem::getCreatedPoints()
{
	return createdPoints_;
}

void CompositeItem::setCreatedPoints(double value)
{
	createdPoints_ = value;
}

int CompositeItem::getAssignedPercents()
{
	return assignedPercents_;
}

void CompositeItem::setAssignedPercents(int value)
{
	assignedPercents_ = value;
}

void CompositeItem::clearState() {
	assignedPercents_ = 0;
	createdPoints_ = 0;
}