本文整理汇总了C++中QDomElement::firstChild方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomElement::firstChild方法的具体用法?C++ QDomElement::firstChild怎么用?C++ QDomElement::firstChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomElement
的用法示例。
在下文中一共展示了QDomElement::firstChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadParamSet
void ClsQHarborImpl::loadParamSet(string strParamSetName) {
#ifdef DEBUG_CLSQHARBORIMPL
cout << "ClsQHarborImpl::loadParamSet(string strParamSetName)" << endl;
#endif
if(strParamSetName.length()>0) {
QFile qfile( strParamSetName );
if ( !qfile.open( IO_ReadOnly ) ) {
QMessageBox::critical( 0, tr( "Critical Error" ),
tr( "Cannot open file %1" ).arg( strParamSetName ) );
return;
}
QDomDocument domTree;
if ( !domTree.setContent( &qfile ) ) {
QMessageBox::critical( 0, tr( "Critical Error" ),
tr( "Parsing error for file %1" ).arg( strParamSetName ) );
qfile.close();
return;
}
qfile.close();
// get the header information from the DOM
QDomElement root = domTree.documentElement();
QDomNode node;
node = root.firstChild(); /* Parameter */
while ( !node.isNull() ) {
string strItemType = node.toElement().attribute("itemType");
string strItemID = node.toElement().attribute("itemID");
string strParamName = node.toElement().attribute("name");
string strParamValue = node.toElement().attribute("value");
string strItemName = "";
if(!setTableItemValue(strItemID, strParamName,strParamValue)) {
cerr << "parameter not found" << endl;
string strError = string("Cannot find parameter \"") + strParamName + string("\"\nfor item \"") + strItemID + string("\"\n");
QMessageBox::warning( this, "iqr Harbor",
strError,
"Ok");
} else {
if(!strItemType.compare("Group")) {
ClsFEGroup* clsFEGroup = ClsFESystemManager::Instance()->getFEGroup( strItemID );
if(clsFEGroup!=NULL) {
clsFEGroup->setNeuronParameter(strParamName, strParamValue);
} else {
cerr << "ClsQHarborImpl::slotChangeValue: group not found" << endl;
}
}
else if(!strItemType.compare("Connection")) {
ClsFEConnection* clsFEConnection = ClsFESystemManager::Instance()->getFEConnection( strItemID );
if(clsFEConnection!=NULL) {
clsFEConnection->setSynapseParameter(strParamName, strParamValue);
} else {
cerr << "ClsQHarborImpl::slotChangeValue: connection not found" << endl;
}
}
}
node = node.nextSibling();
}
for(int ii = 0; ii<qtableEntries->numCols(); ii++) {
qtableEntries->adjustColumn(ii);
}
}
}
示例2: contenu_puces
//Lecture des puces et numérotations
bool OpenDocument::contenu_puces(QDomElement e, QTextCursor &curseur, int niveau, QString style){
//Erreurs
ErrorManager instance_erreur;
//Nom de style
QString nom_style;
if(niveau == 1 && contenu_puce == ""){
nom_style = e.attribute("text:style-name");
}
else{
nom_style = style;
}
//Si c'est vide, on se casse
if(nom_style.isNull() || nom_style.isEmpty()){
instance_erreur.Erreur_msg(tr("ODT : style de puces invalide, annulation"), QMessageBox::Ignore);
return false;
}
//Début de liste
contenu_puce.append("<ul>");
//Création des formats
QTextCharFormat char_style = cree_bloc_format(nom_style);
QTextListFormat list_format;
//indentation
list_format.setIndent(niveau);
QDomNode enfants = e.firstChild();
while(!enfants.isNull()){
QDomElement elem = enfants.toElement();
if(elem.isElement()){
/*if(elem.tagName() == "text:list"){ //Nouvelle liste
//On repasse par la fonction
contenu_puces(elem, (niveau+1));
}*/
if(elem.tagName() == "text:list-item"){//Ce ne peut être que ça
QDomNode contenu = elem.firstChild();
if(contenu.toElement().tagName() == "text:p"){
contenu_paragraphe(contenu.toElement(), curseur, true);
}
else if(contenu.toElement().isText()){
contenu_puce += "<li>";
contenu_puce += contenu.nodeValue();
contenu_puce += "</li>";
}
else if(contenu.toElement().tagName() == "text:list"){
//On ne fait rien, ce sera traité par le "if" suivant.
//Ce «else if» sert juste à éviter le message d'erreur du «else»
}
else{
instance_erreur.Erreur_msg(tr("ODT : Puces : exception dans le contenu des puces"), QMessageBox::Ignore);
}
QDomNode sous_enfants = enfants.firstChildElement("text:list");
//Détection d'éventuels sous-nœuds
if(!sous_enfants.isNull()){
//Quoi que ce soit, ce n'est pas un <p>, on le rebalance à la fonction
contenu_puces(sous_enfants.toElement(), curseur, (niveau+1));
}
}
}
enfants = enfants.nextSibling();
}
contenu_puce += "</ul>";
return true;
}
示例3: traite_span
//Fonction qui traite les <span> (styles internes aux paragraphes)
bool OpenDocument::traite_span(QTextCharFormat format, QTextCursor &curseur, QDomElement e, bool puces, bool tableau){
SettingsManager settings;
ErrorManager instance_erreur;
QTextCharFormat format_span;
if(e.tagName() == "text:span"){
QString nom_format = e.attribute("text:style-name");
format_span = cree_bloc_format(nom_format);
//On merge le format
format.merge(format_span);
if(!format.hasProperty(QTextFormat::FontPointSize)){
format.setFontPointSize(settings.getSettings(Taille).toInt());
}
}
else{
instance_erreur.Erreur_msg(tr("ODT : <span> invalide"), QMessageBox::Ignore);
}
//Maintenant on lit les <span>
QDomNode enfants = e.firstChild();
while(!enfants.isNull()){
QDomNode sous_enfants = enfants.firstChild();
//Détection d'éventuels sous-nœuds
if(!sous_enfants.isNull() && sous_enfants.isElement()){
//Si c'est une note, on se défausse
if(sous_enfants.toElement().tagName() == "text:note-citation"){
//On ne fait rien, les notes de bas de page ne sont pas encore gérées.
}
else{
//Quoi que ce soit, ce n'est pas un <p>, on le rebalance à la fonction
traite_span(format, curseur, e);
}
}
//Type d'élément
if(enfants.isElement()){
QDomElement elem = enfants.toElement();
if(elem.tagName() == "text:line-break"){
curseur.insertText(QString(QChar::LineSeparator));
}
else if(elem.tagName() == "text:span"){
traite_span(format, curseur, e, puces, tableau);
}
else if(elem.tagName() == "draw:frame"){
}
else if(elem.tagName() == "text:s"){
curseur.insertText(QString(" "));
}
else if(elem.tagName() == "text:a"){
traite_lien(curseur, elem, format);
}
else if(elem.tagName() == "text:tab"){
curseur.insertText(QString(" "));
}
else{
instance_erreur.Erreur_msg(tr("ODT : type de <span> non détecté"), QMessageBox::Ignore);
}
}
else if(enfants.isText()){
//On gére le texte
QStringList contenu = enfants.nodeValue().split("\n");
for(int i=0; i<contenu.size(); i++){
if(puces){
//On récupère le style par défaut
QTextDocument *temp = new QTextDocument;
QTextCursor curseur2(temp);
curseur2.insertText(contenu.at(i), format);
contenu_puce.append(nettoye_code(temp->toHtml()));
delete temp;
}
else if(tableau){
QTextDocument *temp = new QTextDocument;
QTextCursor curseur2(temp);
curseur2.insertText(contenu.at(i), format);
case_tableau.append(nettoye_code(temp->toHtml()));
}
else{
curseur.insertText(contenu.at(i), format);
}
}
}
enfants = enfants.nextSibling();
}
return true;
}
示例4: parseGradient
QBrush XMLParseBase::parseGradient(const QDomElement &element)
{
QBrush brush;
QString gradientStart = element.attribute("start", "");
QString gradientEnd = element.attribute("end", "");
int gradientAlpha = element.attribute("alpha", "255").toInt();
QString direction = element.attribute("direction", "vertical");
QGradientStops stops;
if (!gradientStart.isEmpty())
{
QColor startColor = QColor(gradientStart);
startColor.setAlpha(gradientAlpha);
QGradientStop stop(0.0, startColor);
stops.append(stop);
}
for (QDomNode child = element.firstChild(); !child.isNull();
child = child.nextSibling())
{
QDomElement childElem = child.toElement();
if (childElem.tagName() == "stop")
{
float position = childElem.attribute("position", "0").toFloat();
QString color = childElem.attribute("color", "");
int alpha = childElem.attribute("alpha", "-1").toInt();
if (alpha < 0)
alpha = gradientAlpha;
QColor stopColor = QColor(color);
stopColor.setAlpha(alpha);
QGradientStop stop((position / 100), stopColor);
stops.append(stop);
}
}
if (!gradientEnd.isEmpty())
{
QColor endColor = QColor(gradientEnd);
endColor.setAlpha(gradientAlpha);
QGradientStop stop(1.0, endColor);
stops.append(stop);
}
if (direction == "radial")
{
QRadialGradient gradient;
gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
float x1 = 0.5, y1 = 0.5, radius = 0.5;
gradient.setCenter(x1,y1);
gradient.setFocalPoint(x1,y1);
gradient.setRadius(radius);
gradient.setStops(stops);
brush = QBrush(gradient);
}
else // Linear
{
QLinearGradient gradient;
gradient.setCoordinateMode(QGradient::ObjectBoundingMode);
float x1 = 0.0, y1 = 0.0, x2 = 0.0, y2 = 0.0;
if (direction == "vertical")
{
x1 = 0.5;
x2 = 0.5;
y1 = 0.0;
y2 = 1.0;
}
else if (direction == "diagonal")
{
x1 = 0.0;
x2 = 1.0;
y1 = 0.0;
y2 = 1.0;
}
else // Horizontal
{
x1 = 0.0;
x2 = 1.0;
y1 = 0.5;
y2 = 0.5;
}
gradient.setStart(x1, y1);
gradient.setFinalStop(x2, y2);
gradient.setStops(stops);
brush = QBrush(gradient);
}
return brush;
}
示例5: doLoad
bool XMLParseBase::doLoad(const QString &windowname,
MythUIType *parent,
const QString &filename,
bool onlywindows,
bool showWarnings)
{
QDomDocument doc;
QFile f(filename);
if (!f.open(QIODevice::ReadOnly))
return false;
QString errorMsg;
int errorLine = 0;
int errorColumn = 0;
if (!doc.setContent(&f, false, &errorMsg, &errorLine, &errorColumn))
{
LOG(VB_GENERAL, LOG_ERR, LOC +
QString("Location: '%1' @ %2 column: %3"
"\n\t\t\tError: %4")
.arg(qPrintable(filename)).arg(errorLine).arg(errorColumn)
.arg(qPrintable(errorMsg)));
f.close();
return false;
}
f.close();
QDomElement docElem = doc.documentElement();
QDomNode n = docElem.firstChild();
while (!n.isNull())
{
QDomElement e = n.toElement();
if (!e.isNull())
{
if (e.tagName() == "include")
{
QString include = getFirstText(e);
if (!include.isEmpty())
LoadBaseTheme(include);
}
if (onlywindows && e.tagName() == "window")
{
QString name = e.attribute("name", "");
QString include = e.attribute("include", "");
if (name.isEmpty())
{
VERBOSE_XML(VB_GENERAL, LOG_ERR, filename, e,
"Window needs a name");
return false;
}
if (!include.isEmpty())
LoadBaseTheme(include);
if (name == windowname)
{
ParseChildren(filename, e, parent, showWarnings);
return true;
}
}
if (!onlywindows)
{
QString type = e.tagName();
if (type == "font" || type == "fontdef")
{
bool global = (GetGlobalObjectStore() == parent);
MythFontProperties *font = MythFontProperties::ParseFromXml(
filename, e, parent, global, showWarnings);
if (!global && font)
{
QString name = e.attribute("name");
parent->AddFont(name, font);
}
delete font;
}
else if (type == "imagetype" ||
type == "textarea" ||
type == "group" ||
type == "textedit" ||
type == "button" ||
type == "buttonlist" ||
type == "buttonlist2" ||
type == "buttontree" ||
type == "spinbox" ||
type == "checkbox" ||
type == "statetype" ||
type == "window" ||
type == "clock" ||
type == "progressbar" ||
type == "scrollbar" ||
type == "webbrowser" ||
type == "guidegrid" ||
type == "shape" ||
type == "editbar" ||
//.........这里部分代码省略.........
示例6: if
void Ui3Reader::createWrapperDeclContents(const QDomElement &e)
{
QString objClass = getClassName(e);
if (objClass.isEmpty())
return;
QDomNodeList nl;
QString exportMacro;
int i;
QDomElement n;
QStringList::ConstIterator it;
nl = e.parentNode().toElement().elementsByTagName(QLatin1String("exportmacro"));
if (nl.length() == 1)
exportMacro = nl.item(0).firstChild().toText().data();
QStringList::ConstIterator ns = namespaces.constBegin();
while (ns != namespaces.constEnd()) {
out << "namespace " << *ns << " {" << endl;
++ns;
}
out << "class ";
if (!exportMacro.isEmpty())
out << exportMacro << ' ';
out << bareNameOfClass << " : public " << objClass << ", public Ui::" << bareNameOfClass << endl << '{' << endl;
/* qmake ignore Q_OBJECT */
out << " Q_OBJECT" << endl;
out << endl;
out << "public:" << endl;
// constructor
if (objClass == QLatin1String("QDialog") || objClass == QLatin1String("QWizard")) {
out << " " << bareNameOfClass << "(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);" << endl;
} else if (objClass == QLatin1String("QWidget")) {
out << " " << bareNameOfClass << "(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = 0);" << endl;
} else if (objClass == QLatin1String("QMainWindow") || objClass == QLatin1String("Q3MainWindow")) {
out << " " << bareNameOfClass << "(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = Qt::WType_TopLevel);" << endl;
isMainWindow = true;
} else {
out << " " << bareNameOfClass << "(QWidget* parent = 0, const char* name = 0);" << endl;
}
// destructor
out << " ~" << bareNameOfClass << "();" << endl;
out << endl;
// database connections
dbConnections = unique(dbConnections);
bool hadOutput = false;
for (it = dbConnections.constBegin(); it != dbConnections.constEnd(); ++it) {
if (!(*it).isEmpty()) {
// only need pointers to non-default connections
if ((*it) != QLatin1String("(default)") && !(*it).isEmpty()) {
out << indent << "QSqlDatabase* " << *it << "Connection;" << endl;
hadOutput = true;
}
}
}
if (hadOutput)
out << endl;
QStringList publicSlots, protectedSlots, privateSlots;
QStringList publicSlotTypes, protectedSlotTypes, privateSlotTypes;
QStringList publicSlotSpecifier, protectedSlotSpecifier, privateSlotSpecifier;
nl = e.parentNode().toElement().elementsByTagName(QLatin1String("slot"));
for (i = 0; i < (int) nl.length(); i++) {
n = nl.item(i).toElement();
if (n.parentNode().toElement().tagName() != QLatin1String("slots")
&& n.parentNode().toElement().tagName() != QLatin1String("connections"))
continue;
if (n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++"))
continue;
QString returnType = n.attribute(QLatin1String("returnType"), QLatin1String("void"));
QString functionName = n.firstChild().toText().data().trimmed();
if (functionName.endsWith(QLatin1Char(';')))
functionName.chop(1);
QString specifier = n.attribute(QLatin1String("specifier"));
QString access = n.attribute(QLatin1String("access"));
if (access == QLatin1String(QLatin1String("protected"))) {
protectedSlots += functionName;
protectedSlotTypes += returnType;
protectedSlotSpecifier += specifier;
} else if (access == QLatin1String("private")) {
privateSlots += functionName;
privateSlotTypes += returnType;
privateSlotSpecifier += specifier;
} else {
publicSlots += functionName;
publicSlotTypes += returnType;
publicSlotSpecifier += specifier;
}
}
QStringList publicFuncts, protectedFuncts, privateFuncts;
QStringList publicFunctRetTyp, protectedFunctRetTyp, privateFunctRetTyp;
QStringList publicFunctSpec, protectedFunctSpec, privateFunctSpec;
nl = e.parentNode().toElement().elementsByTagName(QLatin1String("function"));
//.........这里部分代码省略.........
示例7: initialiseDefaultPrefs
void ColorSetManager::initialiseDefaultPrefs(struct ApplicationPrefs& appPrefs)
{
QString defaultSwatch = ScPaths::instance().shareDir() + "swatches/" + "Scribus_Basic.xml";
QFile fiC(defaultSwatch);
if (!fiC.exists())
{
appPrefs.colorPrefs.DColors.insert("White", ScColor(0, 0, 0, 0));
appPrefs.colorPrefs.DColors.insert("Black", ScColor(0, 0, 0, 255));
ScColor cc = ScColor(255, 255, 255, 255);
cc.setRegistrationColor(true);
appPrefs.colorPrefs.DColors.insert("Registration", cc);
appPrefs.colorPrefs.DColors.insert("Blue", ScColor(255, 255, 0, 0));
appPrefs.colorPrefs.DColors.insert("Cyan", ScColor(255, 0, 0, 0));
appPrefs.colorPrefs.DColors.insert("Green", ScColor(255, 0, 255, 0));
appPrefs.colorPrefs.DColors.insert("Red", ScColor(0, 255, 255, 0));
appPrefs.colorPrefs.DColors.insert("Yellow", ScColor(0, 0, 255, 0));
appPrefs.colorPrefs.DColors.insert("Magenta", ScColor(0, 255, 0, 0));
appPrefs.colorPrefs.DColorSet = "Scribus_Small";
}
else
{
if (fiC.open(QIODevice::ReadOnly))
{
QString ColorEn, Cname;
int Rval, Gval, Bval;
QTextStream tsC(&fiC);
ColorEn = tsC.readLine();
if (ColorEn.startsWith("<?xml version="))
{
QByteArray docBytes("");
loadRawText(defaultSwatch, docBytes);
QString docText("");
docText = QString::fromUtf8(docBytes);
QDomDocument docu("scridoc");
docu.setContent(docText);
ScColor lf = ScColor();
QDomElement elem = docu.documentElement();
QDomNode PAGE = elem.firstChild();
while(!PAGE.isNull())
{
QDomElement pg = PAGE.toElement();
if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
{
if (pg.hasAttribute("CMYK"))
lf.setNamedColor(pg.attribute("CMYK"));
else
lf.fromQColor(QColor(pg.attribute("RGB")));
if (pg.hasAttribute("Spot"))
lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
else
lf.setSpotColor(false);
if (pg.hasAttribute("Register"))
lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
else
lf.setRegistrationColor(false);
appPrefs.colorPrefs.DColors.insert(pg.attribute("NAME"), lf);
}
PAGE=PAGE.nextSibling();
}
}
else
{
while (!tsC.atEnd())
{
ColorEn = tsC.readLine();
QTextStream CoE(&ColorEn, QIODevice::ReadOnly);
CoE >> Rval;
CoE >> Gval;
CoE >> Bval;
CoE >> Cname;
ScColor tmp;
tmp.setColorRGB(Rval, Gval, Bval);
appPrefs.colorPrefs.DColors.insert(Cname, tmp);
}
}
fiC.close();
}
appPrefs.colorPrefs.DColorSet = ScPaths::instance().shareDir() + "swatches/" + "Scribus Basic";
}
示例8: importFile
bool PaletteLoader_Autocad_acb::importFile(const QString& fileName, bool /*merge*/)
{
QByteArray docBytes;
loadRawText(fileName, docBytes);
QString docText = QString::fromUtf8(docBytes);
QDomDocument docu("scridoc");
if (!docu.setContent(docText))
return false;
ScColor lf;
int oldCount = m_colors->count();
QDomElement elem = docu.documentElement();
QDomNode PAGE = elem.firstChild();
while (!PAGE.isNull())
{
QDomElement pg = PAGE.toElement();
if (pg.tagName() == "colorPage")
{
QDomNode colNode = pg.firstChild();
while (!colNode.isNull())
{
QDomElement cg = colNode.toElement();
if (cg.tagName() == "colorEntry")
{
int r (0), g(0), b(0);
QString colorName = "";
QDomNode colEntry = cg.firstChild();
while (!colEntry.isNull())
{
QDomElement cc = colEntry.toElement();
if (cc.tagName() == "colorName")
colorName = cc.text();
else if (cc.tagName() == "RGB8")
{
QDomNode colVal = cc.firstChild();
while (!colVal.isNull())
{
QDomElement cv = colVal.toElement();
if (cv.tagName() == "red")
r = cv.text().toInt();
else if (cv.tagName() == "green")
g = cv.text().toInt();
else if (cv.tagName() == "blue")
b = cv.text().toInt();
colVal = colVal.nextSibling();
}
}
colEntry = colEntry.nextSibling();
}
if (!colorName.isEmpty())
{
lf.setRgbColor(r, g, b);
lf.setSpotColor(false);
lf.setRegistrationColor(false);
m_colors->tryAddColor(colorName, lf);
}
}
colNode = colNode.nextSibling();
}
}
PAGE = PAGE.nextSibling();
}
return (m_colors->count() != oldCount);
}
示例9: main
int main(int argc, char **argv)
{
if (argc == 1) {
showUsage();
return EXIT_SUCCESS;
}
QCoreApplication app(argc, argv);
const QStringList& args = app.arguments();
QFileInfo configFile;
QString generator;
bool addHeaders = false;
bool hasCommandLineGenerator = false;
QStringList classes;
ParserOptions::notToBeResolved << "FILE";
for (int i = 1; i < args.count(); i++) {
if ((args[i] == "-I" || args[i] == "-d" || args[i] == "-dm" ||
args[i] == "-g" || args[i] == "-config") && i + 1 >= args.count())
{
qCritical() << "not enough parameters for option" << args[i];
return EXIT_FAILURE;
}
if (args[i] == "-I") {
ParserOptions::includeDirs << QDir(args[++i]);
} else if (args[i] == "-config") {
configFile = QFileInfo(args[++i]);
} else if (args[i] == "-d") {
ParserOptions::definesList = QFileInfo(args[++i]);
} else if (args[i] == "-dm") {
ParserOptions::dropMacros += args[++i].split(',');
} else if (args[i] == "-g") {
generator = args[++i];
hasCommandLineGenerator = true;
} else if ((args[i] == "-h" || args[i] == "--help") && argc == 2) {
showUsage();
return EXIT_SUCCESS;
} else if (args[i] == "-t") {
ParserOptions::resolveTypedefs = true;
} else if (args[i] == "-qt") {
ParserOptions::qtMode = true;
} else if (args[i] == "--") {
addHeaders = true;
} else if (addHeaders) {
ParserOptions::headerList << QFileInfo(args[i]);
}
}
if (configFile.exists()) {
QFile file(configFile.filePath());
file.open(QIODevice::ReadOnly);
QDomDocument doc;
doc.setContent(file.readAll());
file.close();
QDomElement root = doc.documentElement();
QDomNode node = root.firstChild();
while (!node.isNull()) {
QDomElement elem = node.toElement();
if (elem.isNull()) {
node = node.nextSibling();
continue;
}
if (elem.tagName() == "resolveTypedefs") {
ParserOptions::resolveTypedefs = (elem.text() == "true");
} else if (elem.tagName() == "qtMode") {
ParserOptions::qtMode = (elem.text() == "true");
} else if (!hasCommandLineGenerator && elem.tagName() == "generator") {
generator = elem.text();
} else if (elem.tagName() == "includeDirs") {
QDomNode dir = elem.firstChild();
while (!dir.isNull()) {
QDomElement elem = dir.toElement();
if (elem.isNull()) {
dir = dir.nextSibling();
continue;
}
if (elem.tagName() == "dir") {
ParserOptions::includeDirs << QDir(elem.text());
}
dir = dir.nextSibling();
}
} else if (elem.tagName() == "definesList") {
// reference to an external file, so it can be auto-generated
ParserOptions::definesList = QFileInfo(elem.text());
} else if (elem.tagName() == "dropMacros") {
QDomNode macro = elem.firstChild();
while (!macro.isNull()) {
QDomElement elem = macro.toElement();
if (elem.isNull()) {
macro = macro.nextSibling();
continue;
}
if (elem.tagName() == "name") {
ParserOptions::dropMacros << elem.text();
}
macro = macro.nextSibling();
}
}
//.........这里部分代码省略.........
示例10: demarshall
QVariant XMLRPC::demarshall(const QDomElement &elem, QStringList &errors)
{
if ( elem.tagName().toLower() != "value" )
{
errors << "Bad param value";
return QVariant();
}
if ( !elem.firstChild().isElement() )
{
return QVariant( elem.text() );
}
const QDomElement typeData = elem.firstChild().toElement();
const QString typeName = typeData.tagName().toLower();
if (typeName == "nil")
{
return QVariant();
}
if ( typeName == "string" )
{
return QVariant( typeData.text() );
}
else if (typeName == "int" || typeName == "i4" )
{
bool ok = false;
QVariant val( typeData.text().toInt( &ok ) );
if (ok)
return val;
errors << "I was looking for an integer but data was courupt";
return QVariant();
}
else if( typeName == "double" )
{
bool ok = false;
QVariant val( typeData.text().toDouble( &ok ) );
if (ok)
return val;
errors << "I was looking for an double but data was corrupt";
}
else if( typeName == "boolean" )
return QVariant( typeData.text() == "1" || typeData.text().toLower() == "true" );
else if( typeName == "datetime" || typeName == "datetime.iso8601" )
return QVariant( QDateTime::fromString( typeData.text(), Qt::ISODate ) );
else if( typeName == "array" )
{
QVariantList arr;
QDomElement valueNode = typeData.firstChildElement("data").firstChildElement();
while (!valueNode.isNull() && errors.isEmpty())
{
arr.append(demarshall(valueNode, errors));
valueNode = valueNode.nextSiblingElement();
}
return QVariant( arr );
}
else if( typeName == "struct" )
{
QMap<QString,QVariant> stct;
QDomNode valueNode = typeData.firstChild();
while(!valueNode.isNull() && errors.isEmpty())
{
const QDomElement memberNode = valueNode.toElement().elementsByTagName("name").item(0).toElement();
const QDomElement dataNode = valueNode.toElement().elementsByTagName("value").item(0).toElement();
stct[ memberNode.text() ] = demarshall(dataNode, errors);
valueNode = valueNode.nextSibling();
}
return QVariant(stct);
}
else if( typeName == "base64" )
{
QVariant returnVariant;
QByteArray dest;
QByteArray src = typeData.text().toLatin1();
return QVariant(QByteArray::fromBase64(src));
}
errors << QString( "Cannot handle type %1").arg(typeName);
return QVariant();
}
示例11: loadACLs
void cCommands::loadACLs( void )
{
// make sure it's clean
QMap< QString, cAcl* >::iterator itA (_acls.begin());
for ( ; itA != _acls.end(); ++itA )
delete itA.data();
_acls.clear();
QStringList ScriptSections = DefManager->getSections( WPDT_PRIVLEVEL );
if( ScriptSections.isEmpty() )
{
clConsole.ChangeColor( WPC_RED );
clConsole.send( tr("WARNING: No ACLs for players, counselors, gms and admins defined!\n") );
clConsole.ChangeColor( WPC_NORMAL );
return;
}
// We are iterating trough a list of ACLs
// In each loop we create one acl
for( QStringList::iterator it = ScriptSections.begin(); it != ScriptSections.end(); ++it )
{
const QDomElement *Tag = DefManager->getSection( WPDT_PRIVLEVEL, *it );
if( Tag->isNull() )
continue;
QString ACLname = Tag->attribute("id");
if ( ACLname == QString::null )
{
clConsole.ChangeColor( WPC_RED );
clConsole.send( tr("WARNING: Tag %1 lacks \"id\" attribute").arg(Tag->tagName()) );
clConsole.ChangeColor( WPC_NORMAL );
continue;
}
// While we are in this loop we are building an ACL
cAcl *acl = new cAcl;
acl->name = ACLname;
QMap< QString, bool > group;
QString groupName;
QDomNode childNode = Tag->firstChild();
while( !childNode.isNull() )
{
if( childNode.isElement() )
{
QDomElement childTag = childNode.toElement();
if( childTag.nodeName() == "group" )
{
groupName = childTag.attribute("name", QString::null);
QDomNode chchildNode = childTag.firstChild();
while( !chchildNode.isNull() )
{
if( chchildNode.isElement() )
{
QDomElement chchildTag = chchildNode.toElement();
if( chchildTag.nodeName() == "action" )
{
QString name = chchildTag.attribute( "name", "any" );
bool permit = chchildTag.attribute( "permit", "false" ) == "true" ? true : false;
group.insert( name, permit );
}
}
chchildNode = chchildNode.nextSibling();
}
if( !group.isEmpty() )
{
acl->groups.insert( groupName, group );
group.clear();
}
}
}
childNode = childNode.nextSibling();
}
_acls.insert( ACLname, acl );
}
DefManager->unload( WPDT_PRIVLEVEL );
}
示例12: createLayerFromElement
QgsMapLayer* QgsServerProjectParser::createLayerFromElement( const QDomElement& elem, bool useCache ) const
{
if ( elem.isNull() || !mXMLDoc )
{
return 0;
}
addJoinLayersForElement( elem, useCache );
addValueRelationLayersForElement( elem, useCache );
QDomElement dataSourceElem = elem.firstChildElement( "datasource" );
QString uri = dataSourceElem.text();
QString absoluteUri;
if ( !dataSourceElem.isNull() )
{
//convert relative pathes to absolute ones if necessary
if ( uri.startsWith( "dbname" ) ) //database
{
QgsDataSourceURI dsUri( uri );
if ( dsUri.host().isEmpty() ) //only convert path for file based databases
{
QString dbnameUri = dsUri.database();
QString dbNameUriAbsolute = convertToAbsolutePath( dbnameUri );
if ( dbnameUri != dbNameUriAbsolute )
{
dsUri.setDatabase( dbNameUriAbsolute );
absoluteUri = dsUri.uri();
QDomText absoluteTextNode = mXMLDoc->createTextNode( absoluteUri );
dataSourceElem.replaceChild( absoluteTextNode, dataSourceElem.firstChild() );
}
}
}
else if ( uri.startsWith( "file:" ) ) //a file based datasource in url notation (e.g. delimited text layer)
{
QString filePath = uri.mid( 5, uri.indexOf( "?" ) - 5 );
QString absoluteFilePath = convertToAbsolutePath( filePath );
if ( filePath != absoluteFilePath )
{
QUrl destUrl = QUrl::fromEncoded( uri.toAscii() );
destUrl.setScheme( "file" );
destUrl.setPath( absoluteFilePath );
absoluteUri = destUrl.toEncoded();
QDomText absoluteTextNode = mXMLDoc->createTextNode( absoluteUri );
dataSourceElem.replaceChild( absoluteTextNode, dataSourceElem.firstChild() );
}
else
{
absoluteUri = uri;
}
}
else //file based data source
{
absoluteUri = convertToAbsolutePath( uri );
if ( uri != absoluteUri )
{
QDomText absoluteTextNode = mXMLDoc->createTextNode( absoluteUri );
dataSourceElem.replaceChild( absoluteTextNode, dataSourceElem.firstChild() );
}
}
}
QString id = layerId( elem );
QgsMapLayer* layer = 0;
if ( useCache )
{
layer = QgsMSLayerCache::instance()->searchLayer( absoluteUri, id );
}
if ( layer )
{
return layer;
}
QString type = elem.attribute( "type" );
if ( type == "vector" )
{
layer = new QgsVectorLayer();
}
else if ( type == "raster" )
{
layer = new QgsRasterLayer();
}
else if ( elem.attribute( "embedded" ) == "1" ) //layer is embedded from another project file
{
//todo: fixme
/*
QString project = convertToAbsolutePath( elem.attribute( "project" ) );
QgsDebugMsg( QString( "Project path: %1" ).arg( project ) );
QgsProjectParser* otherConfig = dynamic_cast<QgsProjectParser*>( QgsConfigCache::instance()->searchConfiguration( project ) );
if ( !otherConfig )
{
return 0;
}
QHash< QString, QDomElement >::const_iterator layerIt = otherConfig->mProjectLayerElementsById.find( elem.attribute( "id" ) );
if ( layerIt == otherConfig->mProjectLayerElementsById.constEnd() )
{
return 0;
}
//.........这里部分代码省略.........
示例13: loadMidiMap
void MidiTable::loadMidiMap()
{
QDomDocument doc( "MIDI Transalation" );
QFile file( ":midi.xml" );
doc.setContent( &file ); // file is a QFile
file.close();
QDomElement root = doc.documentElement(); // Points to <SysX>
this->root = root;
//QList<Midi> midiMap;
QDomNode node = root.firstChild();
while ( !node.isNull() )
{
Midi section;
section.type.append(node.nodeName());
QDomNode level1Node = node.firstChild();
while ( !level1Node.isNull() )
{
Midi level1;
level1.type.append(level1Node.nodeName());
level1.name = level1Node.attributes().namedItem("name").nodeValue();
level1.value = level1Node.attributes().namedItem("value").nodeValue();
level1.abbr = level1Node.attributes().namedItem("abbr").nodeValue();
level1.desc = level1Node.attributes().namedItem("desc").nodeValue();
level1.customdesc = level1Node.attributes().namedItem("customdesc").nodeValue();
QDomNode level2Node = level1Node.firstChild();
while ( !level2Node.isNull() )
{
Midi level2;
level2.type.append(level2Node.nodeName());
level2.name = level2Node.attributes().namedItem("name").nodeValue();
level2.value = level2Node.attributes().namedItem("value").nodeValue();
level2.abbr = level2Node.attributes().namedItem("abbr").nodeValue();
level2.desc = level2Node.attributes().namedItem("desc").nodeValue();
level2.customdesc = level2Node.attributes().namedItem("customdesc").nodeValue();
QDomNode level3Node = level2Node.firstChild();
while ( !level3Node.isNull() )
{
Midi level3;
level3.type.append(level3Node.nodeName());
level3.name = level3Node.attributes().namedItem("name").nodeValue();
level3.value = level3Node.attributes().namedItem("value").nodeValue();
level3.abbr = level3Node.attributes().namedItem("abbr").nodeValue();
level3.desc = level3Node.attributes().namedItem("desc").nodeValue();
level3.customdesc = level3Node.attributes().namedItem("customdesc").nodeValue();
QDomNode level4Node = level3Node.firstChild();
while ( !level4Node.isNull() )
{
Midi level4;
level4.type.append(level4Node.nodeName());
level4.name = level4Node.attributes().namedItem("name").nodeValue();
level4.value = level4Node.attributes().namedItem("value").nodeValue();
level4.abbr = level4Node.attributes().namedItem("abbr").nodeValue();
level4.desc = level4Node.attributes().namedItem("desc").nodeValue();
level4.customdesc = level4Node.attributes().namedItem("customdesc").nodeValue();
QDomNode level5Node = level4Node.firstChild();
while ( !level5Node.isNull() )
{
Midi level5;
level5.type.append(level5Node.nodeName());
level5.name = level5Node.attributes().namedItem("name").nodeValue();
level5.value = level5Node.attributes().namedItem("value").nodeValue();
level5.desc = level5Node.attributes().namedItem("desc").nodeValue();
level5.customdesc = level5Node.attributes().namedItem("customdesc").nodeValue();
level4.id.append(level5.value);
level4.level.append(level5);
level5Node = level5Node.nextSibling();
};
level3.id.append(level4.value);
level3.level.append(level4);
level4Node = level4Node.nextSibling();
};
level2.id.append(level3.value);
level2.level.append(level3);
level3Node = level3Node.nextSibling();
};
level1.id.append(level2.value);
level1.level.append(level2);
level2Node = level2Node.nextSibling();
};
section.id.append(level1.value);
section.level.append(level1);
level1Node = level1Node.nextSibling();
};
QString test = node.nodeName();
//.........这里部分代码省略.........
示例14: load
void HighlightConfig::load()
{
m_filters.clear(); //clear filters
QString filename = locateLocal( "appdata", QString::fromLatin1( "highlight.xml" ) );
if( filename.isEmpty() )
return ;
QDomDocument filterList( QString::fromLatin1( "highlight-plugin" ) );
QFile filterListFile( filename );
filterListFile.open( IO_ReadOnly );
filterList.setContent( &filterListFile );
QDomElement list = filterList.documentElement();
QDomNode node = list.firstChild();
while( !node.isNull() )
{
QDomElement element = node.toElement();
if( !element.isNull() )
{
// if( element.tagName() == QString::fromLatin1("filter")
// {
Filter *filtre=newFilter();
QDomNode filterNode = node.firstChild();
while( !filterNode.isNull() )
{
QDomElement filterElement = filterNode.toElement();
if( !filterElement.isNull() )
{
if( filterElement.tagName() == QString::fromLatin1( "display-name" ) )
{
filtre->displayName = filterElement.text();
}
else if( filterElement.tagName() == QString::fromLatin1( "search" ) )
{
filtre->search = filterElement.text();
filtre->caseSensitive= ( filterElement.attribute( QString::fromLatin1( "caseSensitive" ), QString::fromLatin1( "1" ) ) == QString::fromLatin1( "1" ) );
filtre->isRegExp= ( filterElement.attribute( QString::fromLatin1( "regExp" ), QString::fromLatin1( "0" ) ) == QString::fromLatin1( "1" ) );
}
else if( filterElement.tagName() == QString::fromLatin1( "FG" ) )
{
filtre->FG = filterElement.text();
filtre->setFG= ( filterElement.attribute( QString::fromLatin1( "set" ), QString::fromLatin1( "0" ) ) == QString::fromLatin1( "1" ) );
}
else if( filterElement.tagName() == QString::fromLatin1( "BG" ) )
{
filtre->BG = filterElement.text();
filtre->setBG= ( filterElement.attribute( QString::fromLatin1( "set" ), QString::fromLatin1( "0" ) ) == QString::fromLatin1( "1" ) );
}
else if( filterElement.tagName() == QString::fromLatin1( "importance" ) )
{
filtre->importance = filterElement.text().toUInt();
filtre->setImportance= ( filterElement.attribute( QString::fromLatin1( "set" ), QString::fromLatin1( "0" ) ) == QString::fromLatin1( "1" ) );
}
else if( filterElement.tagName() == QString::fromLatin1( "sound" ) )
{
filtre->soundFN = filterElement.text();
filtre->playSound = ( filterElement.attribute( QString::fromLatin1( "set" ), QString::fromLatin1( "0" ) ) == QString::fromLatin1( "1" ) );
}
else if( filterElement.tagName() == QString::fromLatin1( "raise" ) )
{
filtre->raiseView = ( filterElement.attribute( QString::fromLatin1( "set" ), QString::fromLatin1( "0" ) ) == QString::fromLatin1( "1" ) );
}
}
filterNode = filterNode.nextSibling();
}
// }
}
node = node.nextSibling();
}
filterListFile.close();
}
示例15: attr
BCLSearchResult::BCLSearchResult(const QDomElement& componentElement)
{
m_componentType = componentElement.tagName().toStdString();
QDomElement uidElement = componentElement.firstChildElement("uuid");
QDomElement versionIdElement = componentElement.firstChildElement("vuuid");
QDomElement nameElement = componentElement.firstChildElement("name");
QDomElement descriptionElement = componentElement.firstChildElement("description");
QDomElement modelerDescriptionElement = componentElement.firstChildElement("modeler_description");
QDomElement fidelityLevelElement = componentElement.firstChildElement("fidelity_level");
QDomElement provenancesElement = componentElement.firstChildElement("provenances");
QDomElement tagsElement = componentElement.firstChildElement("tags");
QDomElement attributesElement = componentElement.firstChildElement("attributes");
QDomElement filesElement = componentElement.firstChildElement("files");
QDomElement costsElement = componentElement.firstChildElement("costs");
OS_ASSERT(!nameElement.isNull());
OS_ASSERT(!uidElement.isNull());
OS_ASSERT(!versionIdElement.isNull());
QString name = nameElement.firstChild().nodeValue().replace('_', ' ');
while (name.indexOf(" ") != -1) {
name = name.replace(" ", " ");
}
name[0] = name[0].toUpper();
m_name = name.toStdString();
if (!uidElement.isNull() && uidElement.firstChild().nodeValue().length() == 36)
{
m_uid = uidElement.firstChild().nodeValue().toStdString();
}
if (!versionIdElement.isNull() && versionIdElement.firstChild().nodeValue().length() == 36)
{
m_versionId = versionIdElement.firstChild().nodeValue().toStdString();
}
if (!descriptionElement.isNull())
{
m_description = descriptionElement.firstChild().nodeValue().toStdString();
}
if (!modelerDescriptionElement.isNull())
{
m_modelerDescription = modelerDescriptionElement.firstChild().nodeValue().toStdString();
}
if (!fidelityLevelElement.isNull())
{
m_fidelityLevel= fidelityLevelElement.firstChild().nodeValue().toStdString();
}
QDomElement provenanceElement = provenancesElement.firstChildElement("provenance");
while (!provenanceElement.isNull())
{
if (provenanceElement.hasChildNodes())
{
m_provenances.push_back(BCLProvenance(provenanceElement));
}
else
{
break;
}
provenanceElement = provenanceElement.nextSiblingElement("provenance");
}
QDomElement provenanceRequiredElement = provenancesElement.firstChildElement("provenance_required");
if (!provenanceRequiredElement.isNull())
{
std::string required = provenanceRequiredElement.firstChild().nodeValue().toStdString();
m_provenanceRequired = (required == "true") ? true : false;
}
QDomElement tagElement = tagsElement.firstChildElement("tag");
while (!tagElement.isNull())
{
m_tags.push_back(tagElement.firstChild().nodeValue().toStdString());
tagElement = tagElement.nextSiblingElement("tag");
}
QDomElement attributeElement = attributesElement.firstChildElement("attribute");
while (!attributeElement.isNull())
{
if (attributeElement.hasChildNodes())
{
std::string name = attributeElement.firstChildElement("name").firstChild()
.nodeValue().toStdString();
std::string value = attributeElement.firstChildElement("value").firstChild()
.nodeValue().toStdString();
//std::string datatype = attributeElement.firstChildElement("datatype").firstChild()
// .nodeValue().toStdString();
// Units are optional
std::string units = attributeElement.firstChildElement("units").firstChild()
.nodeValue().toStdString();
/*if (datatype == "float")
{
if (units.empty())
{
Attribute attr(name, boost::lexical_cast<double>(value));
//.........这里部分代码省略.........