MCPcopy Create free account
hub / github.com/RetroShare/RetroShare / buildNodeText

Function buildNodeText

plugins/FeedReader/gui/PreviewFeedDialog.cpp:622–692  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

620}
621
622static void buildNodeText(HTMLWrapper &html, xmlNodePtr node, QString &text)
623{
624 switch (node->type) {
625 case XML_ELEMENT_NODE:
626 text = QString("<%1 ").arg(QString::fromUtf8(html.nodeName(node).c_str()));
627
628 for (xmlAttrPtr attr = node->properties; attr; attr = attr->next) {
629 QString value = QString::fromUtf8(html.getAttr(node, attr).c_str());
630 if (value.length() > 100) {
631 value = value.left(100) + "...";
632 }
633 text += QString("%1=\"%2\" ").arg(QString::fromUtf8(html.attrName(attr).c_str()), value);
634 }
635 text = text.trimmed() + ">";
636
637 if (node->children && !node->children->next && node->children->type == XML_TEXT_NODE) {
638 /* only one text node as child */
639 std::string content;
640 if (html.getContent(node->children, content, false)) {
641 text += QString::fromUtf8(content.c_str());
642 } else {
643 text += QApplication::translate("PreviewFeedDialog", "Error getting content");
644 }
645 text += QString("<%1>").arg(QString::fromUtf8(html.nodeName(node).c_str()));
646
647 xmlUnlinkNode(node->children);
648 xmlFreeNode(node->children);
649 }
650 break;
651 case XML_TEXT_NODE:
652 case XML_COMMENT_NODE:
653 {
654 if (node->type == XML_COMMENT_NODE) {
655 text = "<!-- ";
656 }
657
658 std::string content;
659 if (html.getContent(node, content, false)) {
660 text += QString::fromUtf8(content.c_str());
661 } else {
662 text += QApplication::translate("PreviewFeedDialog", "Error getting content");
663 }
664
665 if (node->type == XML_COMMENT_NODE) {
666 text += " -->";
667 }
668 }
669 break;
670 case XML_ATTRIBUTE_NODE:
671 case XML_CDATA_SECTION_NODE:
672 case XML_ENTITY_REF_NODE:
673 case XML_ENTITY_NODE:
674 case XML_PI_NODE:
675 case XML_DOCUMENT_NODE:
676 case XML_DOCUMENT_TYPE_NODE:
677 case XML_DOCUMENT_FRAG_NODE:
678 case XML_NOTATION_NODE:
679 case XML_HTML_DOCUMENT_NODE:

Callers 1

foreachFunction · 0.85

Calls 6

argMethod · 0.80
nodeNameMethod · 0.80
getAttrMethod · 0.80
attrNameMethod · 0.80
getContentMethod · 0.80
QStringClass · 0.50

Tested by

no test coverage detected