Beispiel #1
0
void DataStore::xmlToNode(Node* parentNode, QDomNode &xmlNode, QDomDocument &doc)
{
	// node erstellen
	int index = parentNode->getChildCount();
	if (!parentNode->addChildren(index, 1))
		return; // TODO: richtig behandeln
	Node *node = parentNode->getChild(index);
	
	node->setId(NodeId(xmlNode.toElement().attribute("id", "-1").toInt()));

	QDateTime modificationDate = QDateTime::currentDateTime();

	QDomNode n = xmlNode.firstChild();
	while (!n.isNull())
	{
		QDomElement e = n.toElement();
		if (e.tagName() == "caption")
			node->setCaption(e.text());
		if (e.tagName() == "creationdate")
			node->setCreationDate(QDateTime::fromString(e.text()));
		if (e.tagName() == "modificationdate")
			modificationDate = QDateTime::fromString(e.text());
		if (e.tagName() == "label")
			node->addLabel(e.text());
		if (e.tagName() == "content")
		{
			if (e.attribute("mimetype", "") == "text/plain")
			{
				TextNodeContent *content = new TextNodeContent;
				content->setXmlData(e);
				node->setContent(content);
			}
			if (e.attribute("mimetype", "") == "text/richtext")
			{
				RichTextNodeContent *content = new RichTextNodeContent;
				content->setXmlData(e);
				node->setContent(content);
			}
		}

		if (e.tagName() == "node")
			xmlToNode(node, n, doc);

		n = n.nextSibling();
	}
	node->setModificationDate(modificationDate);
	
	connect(node, SIGNAL(changed(Node*)), this, SLOT(save(Node*)));
}
Beispiel #2
0
AbstractNodeContent* NewNodeDialog::getContent() const
{
    switch (typebox->currentIndex())
    {
    case 0:
        return new RichTextNodeContent;
        break;
    case 1:
        TextNodeContent *content;
        content = new TextNodeContent;
        content->setSyntax(synbox->currentText());
        return content;
        break;
    default:
        return new RichTextNodeContent;
        break;
    }
}
Beispiel #3
0
AbstractNodeContent* NewNodeDialog::getContent() const
{
	switch (typebox->currentIndex())
	{
		case 0:
			return new RichTextNodeContent;
			break;
		case 1:
			TextNodeContent *content;
			content = new TextNodeContent;
			content->setSyntax(syntaxbox->getSyntax());
			return content;
			break;
		case 2:
			BookNodeContent *bookContent;
			bookContent = new BookNodeContent;
			return bookContent;
			break;
		default:
			return new CustomNodeContent(Controller::create()->getDataStore()->getCustomNodeType(typebox->currentText()));
//			return new RichTextNodeContent;
			break;
	}
}