// Helper function, get the source XML of a node. QString XmlFunctions::getSource( const QDomNode &node, int indent ) { QString source; QTextStream textStream( &source, QIODevice::WriteOnly ); node.save( textStream, indent ); return source; }
void BlackJackDealer::word_article_get(http_request message) { // message.method() auto r_uri = message.request_uri(); uri_builder uri_b(r_uri); string s_q = uri_b.query(); // stringstream ss; // auto json = dictHandler->PrefixMatch(); // json.serialize(ss); // auto str = ss.str(); UrlParameter url_par(s_q); string s_res; dictHandler->FindArticle(url_par.value, s_res); cout << s_res << endl; QString qt_str = QString::fromStdString(s_res); QDomDocument qdoc; qdoc.setContent(qt_str); QDomNode child = qdoc.firstChild(); QString body_str; QTextStream stream(&body_str); child.save(stream, QDomNode::CDATASectionNode /* = 4 */); s_res = body_str.toUtf8().constData();; http_response http_resp(status_codes::OK); // http_resp.set_body(s_res); http_resp.set_body(s_res); http_resp.headers().add("Access-Control-Allow-Origin", "*"); http_resp.headers().add("Content-Type","application/json"); message.reply(http_resp); }
QMap<QString,QString> GraphicsWorkflow::extractSvgElements(const QString& xmltext) { QDomDocument doc; QMap<QString,QString> result; bool isopen = doc.setContent(xmltext); if ( !isopen) { SafetYAWL::streamlog << SafetLog::Error << tr("Se presentó un error al tratar de extraer los elementos del archivo de flujo " "de trabajo tipo SVG"); return result; } QDomNodeList list = doc.elementsByTagName("g"); for(int i = 0; i < list.count();i++) { QString nodeid, nodetext; QTextStream mystream(&nodetext); QDomNode node = list.at(i); QDomNamedNodeMap attrs = node.attributes(); nodeid = attrs.namedItem("id").nodeValue().trimmed(); if ( nodeid != "graph0") { node.save(mystream,0); mystream.flush(); // SafetYAWL::streamlog // << SafetLog::Debug // << tr("Grafico SVG nodetext numero \"%2\": \"%1\"") // .arg(nodetext) // .arg(i); QString newdoc = Safet::templateSVGString1.arg(nodetext); //result[nodeid] = localeNormalize(newdoc); result[nodeid] = newdoc; } } return result; }
void QDomNodeProto:: save(QTextStream& stream, int intarg, int policy) const { QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject()); if (item) item->save(stream, intarg, (QDomNode::EncodingPolicy)policy); }
void QDomNodeProto:: save(QTextStream& stream, int intarg) const { QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject()); if (item) item->save(stream, intarg); }
void DistroMesas::importXML(const QString val) { QFile file ( g_confpr->value( CONF_DIR_USER ) + "distromesas_" + mainCompany()->dbName() + ".cfn" ); if (file.exists()) { if ( !file.open ( QIODevice::ReadOnly ) ) { return; } // end if QString result (file.readAll()); file.close(); QDomDocument doc ( "mydocument" ); if ( !doc.setContent ( result ) ) { return; } // end if QDomElement docElem = doc.documentElement(); QDomElement principal = docElem.firstChildElement ( "BACKGROUND" ); m_background = principal.text(); principal = docElem.firstChildElement ( "ESCALA" ); g_escala = principal.text().toInt(); QDomNodeList nodos = docElem.elementsByTagName ( "MESA" ); int i = 0; while (i < nodos.count() ) { QDomNode ventana = nodos.item ( i++ ); QDomElement e1 = ventana.toElement(); /// try to convert the node to an element. if ( !e1.isNull() ) { /// the node was really an element. QString nodoText = e1.text(); /// Pasamos el XML a texto para poder procesarlo como tal. QString result; QTextStream stream ( &result ); ventana.save(stream,5); Mesa *mesa = new Mesa((BtCompany *) mainCompany(), mui_widget); mesa->importXML(result); if (! m_listapantallas.contains(mesa->m_pantalla)) { if (m_pantallaactual == "") { m_pantallaactual = mesa->m_pantalla; } // end if m_listapantallas.append(mesa->m_pantalla); QToolButton *but = new QToolButton(this); but->setObjectName("p_"+mesa->m_pantalla); but->setText(mesa->m_pantalla); but->setMinimumHeight(42); but->setMinimumWidth(42); but->setCheckable(TRUE); mui_espaciopantallas->addWidget(but); connect(but, SIGNAL(clicked()), this, SLOT(cambiarPantalla())); } // end if if (mesa->m_pantalla == m_pantallaactual) mesa->show(); } // end if } // end while } // end if }