DataPtr DataManagerImpl::loadData(const QString& uid, const QString& path)
{
	if (mData.count(uid)) // dont load same image twice
		return mData[uid];

	QString type = DataReaderWriter().findDataTypeFromFile(path);
	if(!mDataFactory)
		reportError("DataManagerImpl::loadData() Got no DataFactory");
	DataPtr data = mDataFactory->create(type, uid);

	if (!data)
	{
		reportError("Failed to find loaded for: [" + path + "]");
		return DataPtr();
	}

	bool loaded = data->load(path);

	if (!loaded)
	{
		reportError("Failed to load file: [" + path + "]");
		return DataPtr();
	}

	this->loadData(data);
	return data;
}
DataPtr DataManagerImpl::loadData(QDomElement node, QString rootPath)
{
	QString uid = node.toElement().attribute("uid");
	QString name = node.toElement().attribute("name");
	QString type = node.toElement().attribute("type");

	QDir relativePath = this->findRelativePath(node, rootPath);
	QString absolutePath = this->findAbsolutePath(relativePath, rootPath);

	if (mData.count(uid)) // dont load same image twice
		return mData[uid];

	DataPtr data = mDataFactory->create(type, uid, name);
	if (!data)
	{
		reportWarning(QString("Unknown type: %1 for file %2").arg(type).arg(absolutePath));
		return DataPtr();
	}
	bool loaded = data->load(absolutePath);

	if (!loaded)
	{
		reportWarning("Unknown file: " + absolutePath);
		return DataPtr();
	}

	if (!name.isEmpty())
		data->setName(name);
	data->setFilename(relativePath.path());

	this->loadData(data);

	// conversion for change in format 2013-10-29
	QString newPath = rootPath+"/"+data->getFilename();
	if (QDir::cleanPath(absolutePath) != QDir::cleanPath(newPath))
	{
		reportWarning(QString("Detected old data format, converting from %1 to %2").arg(absolutePath).arg(newPath));
		data->save(rootPath);
	}

	return data;
}