void ArticuloList::on_mui_exportar_clicked() { BL_FUNC_DEBUG BlFile filexml ( QFileDialog::getSaveFileName ( this, _ ( "Elija el archivo" ), g_confpr->value( CONF_DIR_USER ), _ ( "Articulos (*.xml)" ) ) ); if ( filexml.open ( QIODevice::WriteOnly ) ) { bulmafact2XML ( filexml, IMPORT_ARTICULOS ); filexml.close(); } else { BlDebug::blDebug ( Q_FUNC_INFO, 0, _("Error al abrir el archivo.") ); } // end if }
bool PathManager::ReplaceAppPakNameInManifest(QString &path, QString &oldName, QString &newName) { QString manifest = path + "/" + "AndroidManifest.xml"; QFile file(manifest); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){ return false; } QDomDocument doc; if (!doc.setContent(&file)){ file.close(); return false; } file.close(); QDomElement root = doc.documentElement(); if (root.tagName() != "manifest"){ return false; } QString pack = root.attribute("package"); if (pack.isEmpty()){ return false; } root.setAttribute("package", newName); QList<QDomElement> allNode; if (!root.firstChildElement().isNull()){ QList<QDomElement> traversal; traversal.push_back(root.firstChildElement()); for (int i = 0; i < traversal.size(); i++) { QDomElement indexNode = traversal.at(i); while (!indexNode.isNull()) { if (indexNode.hasChildNodes()){ traversal.push_back(indexNode.firstChildElement()); } allNode.push_back(indexNode); indexNode = indexNode.nextSiblingElement(); } } } for (QList<QDomElement>::Iterator ite = allNode.begin(); ite != allNode.end(); ite++) { QDomElement element = *ite; if (!element.isNull()){ QString androidNm = element.attribute("android:name", ""); androidNm = androidNm.toLower(); QString fileStr = androidNm; fileStr.replace(".", "/"); fileStr = path + "/src/" + fileStr + ".java"; QFile fileClass(fileStr); if (androidNm.contains(oldName) && !fileClass.exists()){ androidNm.replace(oldName, newName); element.setAttribute("android:name", androidNm); } } } QFile filexml(manifest); if (!filexml.open(QFile::WriteOnly | QFile::Truncate)){ qWarning("error::ParserXML->writeOperateXml->file.open\n"); return false; } QTextStream ts(&filexml); ts.reset(); ts.setCodec("utf-8"); doc.save(ts, 4, QDomNode::EncodingFromTextStream); filexml.close(); return true; }