Exemplo n.º 1
0
void
Filter::loadSettings(
	ProjectReader const& reader, QDomElement const& filters_el)
{
	m_ptrSettings->clear();
	
	QDomElement const filter_el(filters_el.namedItem("page-split").toElement());
	QString const default_layout_type(
		filter_el.attribute("defaultLayoutType")
	);
	m_ptrSettings->setLayoutTypeForAllPages(
		layoutTypeFromString(default_layout_type)
	);
	
	QString const image_tag_name("image");
	QDomNode node(filter_el.firstChild());
	for (; !node.isNull(); node = node.nextSibling()) {
		if (!node.isElement()) {
			continue;
		}
		if (node.nodeName() != image_tag_name) {
			continue;
		}
		QDomElement el(node.toElement());
		
		bool ok = true;
		int const id = el.attribute("id").toInt(&ok);
		if (!ok) {
			continue;
		}
		
		ImageId const image_id(reader.imageId(id));
		if (image_id.isNull()) {
			continue;
		}
		
		Settings::UpdateAction update;
		
		QString const layout_type(el.attribute("layoutType"));
		if (!layout_type.isEmpty()) {
			update.setLayoutType(layoutTypeFromString(layout_type));
		}
		
		QDomElement params_el(el.namedItem("params").toElement());
		if (!params_el.isNull()) {
			update.setParams(Params(params_el));
		}
		
		m_ptrSettings->updatePage(image_id, update);
	}
}
Exemplo n.º 2
0
void
Filter::loadSettings(ProjectReader const& reader, QDomElement const& filters_el)
{
	m_ptrSettings->clear();
	
	QDomElement filter_el(filters_el.namedItem("fix-orientation").toElement());
	
	QString const image_tag_name("image");
	QDomNode node(filter_el.firstChild());
	for (; !node.isNull(); node = node.nextSibling()) {
		if (!node.isElement()) {
			continue;
		}
		if (node.nodeName() != image_tag_name) {
			continue;
		}
		QDomElement el(node.toElement());
		
		bool ok = true;
		int const id = el.attribute("id").toInt(&ok);
		if (!ok) {
			continue;
		}
		
		ImageId const image_id(reader.imageId(id));
		if (image_id.isNull()) {
			continue;
		}
		
		OrthogonalRotation const rotation(
			XmlUnmarshaller::rotation(
				el.namedItem("rotation").toElement()
			)
		);
		
		m_ptrSettings->applyRotation(image_id, rotation);
	}
}