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); } } }
//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; }
//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; }
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; }
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" || type == "video") { // We don't want widgets in base.xml // depending on each other so ignore dependsMap QMap<QString, QString> dependsMap; MythUIType *uitype = NULL; uitype = ParseUIType(filename, e, type, parent, NULL, showWarnings, dependsMap); if (uitype) uitype->ConnectDependants(true); } else { VERBOSE_XML(VB_GENERAL, LOG_ERR, filename, e, "Unknown widget type"); } } } n = n.nextSibling(); } if (onlywindows) return false; return true; }
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")); for (i = 0; i < (int) nl.length(); i++) { n = nl.item(i).toElement(); if (n.parentNode().toElement().tagName() != QLatin1String("functions")) 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("protected")) { protectedFuncts += functionName; protectedFunctRetTyp += returnType; protectedFunctSpec += specifier; } else if (access == QLatin1String("private")) { privateFuncts += functionName; privateFunctRetTyp += returnType; privateFunctSpec += specifier; } else { publicFuncts += functionName; publicFunctRetTyp += returnType; publicFunctSpec += specifier; } } QStringList publicVars, protectedVars, privateVars; nl = e.parentNode().toElement().elementsByTagName(QLatin1String("variable")); for (i = 0; i < (int)nl.length(); i++) { n = nl.item(i).toElement(); // Because of compatibility the next lines have to be commented out. // Someday it should be uncommented. //if (n.parentNode().toElement().tagName() != QLatin1String("variables")) // continue; QString access = n.attribute(QLatin1String("access"), QLatin1String("protected")); QString var = fixDeclaration(n.firstChild().toText().data().trimmed()); if (!var.endsWith(QLatin1Char(';'))) var += QLatin1Char(';'); if (access == QLatin1String("public")) publicVars += var; else if (access == QLatin1String("private")) privateVars += var; else protectedVars += var; } if (!publicVars.isEmpty()) { for (it = publicVars.constBegin(); it != publicVars.constEnd(); ++it) out << indent << *it << endl; out << endl; } if (!publicFuncts.isEmpty()) writeFunctionsDecl(publicFuncts, publicFunctRetTyp, publicFunctSpec); if (!publicSlots.isEmpty()) { out << "public slots:" << endl; if (!publicSlots.isEmpty()) writeFunctionsDecl(publicSlots, publicSlotTypes, publicSlotSpecifier); } // find signals QStringList extraSignals; nl = e.parentNode().toElement().elementsByTagName(QLatin1String("signal")); for (i = 0; i < (int) nl.length(); i++) { n = nl.item(i).toElement(); if (n.parentNode().toElement().tagName() != QLatin1String("signals") && n.parentNode().toElement().tagName() != QLatin1String("connections")) continue; if (n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++")) continue; QString sigName = n.firstChild().toText().data().trimmed(); if (sigName.endsWith(QLatin1Char(';'))) sigName = sigName.left(sigName.length() - 1); extraSignals += fixDeclaration(sigName); } // create signals if (!extraSignals.isEmpty()) { out << "signals:" << endl; for (it = extraSignals.constBegin(); it != extraSignals.constEnd(); ++it) out << " void " << (*it) << ';' << endl; out << endl; } if (!protectedVars.isEmpty()) { out << "protected:" << endl; for (it = protectedVars.constBegin(); it != protectedVars.constEnd(); ++it) out << indent << *it << endl; out << endl; } if (!protectedFuncts.isEmpty()) { if (protectedVars.isEmpty()) out << "protected:" << endl; writeFunctionsDecl(protectedFuncts, protectedFunctRetTyp, protectedFunctSpec); } out << "protected slots:" << endl; out << " virtual void languageChange();" << endl; if (!protectedSlots.isEmpty()) { out << endl; writeFunctionsDecl(protectedSlots, protectedSlotTypes, protectedSlotSpecifier); } out << endl; // create all private stuff if (!privateFuncts.isEmpty() || !privateVars.isEmpty()) { out << "private:" << endl; if (!privateVars.isEmpty()) { for (it = privateVars.constBegin(); it != privateVars.constEnd(); ++it) out << indent << *it << endl; out << endl; } if (!privateFuncts.isEmpty()) writeFunctionsDecl(privateFuncts, privateFunctRetTyp, privateFunctSpec); } if (!privateSlots.isEmpty()) { out << "private slots:" << endl; writeFunctionsDecl(privateSlots, privateSlotTypes, privateSlotSpecifier); } out << "};" << endl; for (i = 0; i < (int) namespaces.count(); i++) out << '}' << endl; out << endl; }
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"; }
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); }
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(); } } node = node.nextSibling(); } } else { qWarning() << "Couldn't find config file" << configFile.filePath(); } // first try to load plugins from the executable's directory QLibrary lib(app.applicationDirPath() + "/generator_" + generator); lib.load(); if (!lib.isLoaded()) { lib.unload(); lib.setFileName(app.applicationDirPath() + "/../lib" + LIB_SUFFIX + "/smokegen/generator_" + generator); lib.load(); } if (!lib.isLoaded()) { lib.unload(); lib.setFileName("generator_" + generator); lib.load(); } if (!lib.isLoaded()) { qCritical() << lib.errorString(); return EXIT_FAILURE; } qDebug() << "using generator" << lib.fileName(); GenerateFn generate = (GenerateFn) lib.resolve("generate"); if (!generate) { qCritical() << "couldn't resolve symbol 'generate', aborting"; return EXIT_FAILURE; } foreach (QDir dir, ParserOptions::includeDirs) { if (!dir.exists()) { qWarning() << "include directory" << dir.path() << "doesn't exist"; ParserOptions::includeDirs.removeAll(dir); } } QStringList defines; if (ParserOptions::definesList.exists()) { QFile file(ParserOptions::definesList.filePath()); file.open(QIODevice::ReadOnly); while (!file.atEnd()) { QByteArray array = file.readLine(); if (!array.isEmpty()) defines << array.trimmed(); } file.close(); } else if (!ParserOptions::definesList.filePath().isEmpty()) { qWarning() << "didn't find file" << ParserOptions::definesList.filePath(); } QFile log("generator.log"); bool logErrors = log.open(QFile::WriteOnly | QFile::Truncate); QTextStream logOut(&log); foreach (QFileInfo file, ParserOptions::headerList) { qDebug() << "parsing" << file.absoluteFilePath(); // this has already been parsed because it was included by some header if (parsedHeaders.contains(file.absoluteFilePath())) continue; Preprocessor pp(ParserOptions::includeDirs, defines, file); Control c; Parser parser(&c); ParseSession session; session.setContentsAndGenerateLocationTable(pp.preprocess()); TranslationUnitAST* ast = parser.parse(&session); // TODO: improve 'header => class' association GeneratorVisitor visitor(&session, file.fileName()); visitor.visit(ast); if (!logErrors) continue; foreach (const Problem* p, c.problems()) { logOut << file.fileName() << ": " << p->file << "(" << p->position.line << ", " << p->position.column << "): " << p->description << "\n"; } }
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(); }
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 ); }
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; } return otherConfig->createLayerFromElement( layerIt.value() ); */ } if ( layer ) { layer->readLayerXML( const_cast<QDomElement&>( elem ) ); //should be changed to const in QgsMapLayer layer->setLayerName( layerName( elem ) ); if ( useCache ) { QgsMSLayerCache::instance()->insertLayer( absoluteUri, id, layer, mProjectPath ); } else { //todo: fixme //mLayersToRemove.push_back( layer ); } } return layer; }
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(); this->midiMap.id.append(test); this->midiMap.level.append(section); node = node.nextSibling(); }; }
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(); }
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)); m_attributes.push_back(attr); } else { Attribute attr(name, boost::lexical_cast<double>(value), units); m_attributes.push_back(attr); } } else if (datatype == "int") { if (units.empty()) { Attribute attr(name, boost::lexical_cast<int>(value)); m_attributes.push_back(attr); } else { Attribute attr(name, boost::lexical_cast<int>(value), units); m_attributes.push_back(attr); } } // Assume string else {*/ if (units.empty()) { Attribute attr(name, value); m_attributes.push_back(attr); } else { Attribute attr(name, value, units); m_attributes.push_back(attr); } //LOG(Error, "Error: Unrecognized attribute datatype \"" << datatype << "\""); //} } else { break; } attributeElement = attributeElement.nextSiblingElement("attribute"); } QDomElement fileElement = filesElement.firstChildElement("file"); while (!fileElement.isNull()) { if (fileElement.hasChildNodes()) { m_files.push_back(BCLFile(fileElement)); } else { break; } fileElement = fileElement.nextSiblingElement("file"); } if (m_componentType == "component") { QDomElement costElement = costsElement.firstChildElement("cost"); while (!costElement.isNull()) { if (costElement.hasChildNodes()) { m_costs.push_back(BCLCost(costElement)); } else { break; } costElement = costElement.nextSiblingElement("cost"); } } }
void MainWindow::on_actionOpen_Project_triggered() { if(project_open) on_actionClose_Project_triggered(); if(project_open) return; editor = new DocumentEditorView(this); editor->hide(); QDomDocument doc; QString filename = QFileDialog::getOpenFileName(this, QString("Choose Project"), ".", "TRX Project (*.trx)"); QFile file(filename); current_project_directory = QFileInfo(filename).absoluteDir(); current_project_name = QFileInfo(filename).baseName(); qDebug() << "filename: " << filename; if (!file.open(QIODevice::ReadOnly | QFile::Text)) return; QString message; if (!doc.setContent(&file ,false, &message)) { file.close(); return; } file.close(); QDomElement docEl = doc.documentElement(); QString docName = docEl.toElement().firstChild().nodeValue(); qDebug() << docEl.toElement().firstChild().nodeValue(); QDomNode child = docEl.firstChild().nextSibling(); qDebug() << child.toElement().firstChild().nodeValue(); qDebug() << QFileInfo(filename).absoluteDir().filePath(child.toElement().firstChild().nodeValue()); requirements = DocumentView::loadDocument(QFileInfo(filename).absoluteDir().filePath(child.toElement().firstChild().nodeValue())); requirements->hide(); traceability = new TraceabilityView(requirements, this); ui->centralWidget->layout()->addWidget(traceability); QObject::connect(ui->showReq, SIGNAL(pressed()), this, SLOT(showRequirements())); QObject::connect(ui->showEdit, SIGNAL(pressed()), this, SLOT(showEditor())); QObject::connect(ui->showTrace, SIGNAL(pressed()), this, SLOT(showTraceability())); QObject::connect(editor, SIGNAL(docAdded(DocumentView*)), traceability, SLOT(addModels(DocumentView*))); QObject::connect(editor, SIGNAL(removeDocument(int)), traceability, SLOT(removeDocument(int))); QHash<DocumentView*, QStandardItemModel*> *traceModelList = traceability->getTraceModelList(); bool modelset = false; child = child.nextSibling(); while (!child.isNull()) { QDomNode subchild = child.firstChild(); qDebug() << subchild.toElement().firstChild().nodeValue(); DocumentView* docview = DocumentView::loadDocument(current_project_directory.dirName() + "/" + subchild.toElement().firstChild().nodeValue()); subchild = subchild.nextSibling(); qDebug() << subchild.toElement().firstChild().nodeValue(); QStandardItemModel *matrix = TraceabilityView::loadMatrix(current_project_directory.dirName() + "/" + subchild.toElement().firstChild().nodeValue()+ "_matrix"); //traceability->addModels(docview, matrix); editor->addLoadedTab(docview); matrix->setHorizontalHeaderLabels(docview->getHeader()); traceModelList->insert(docview, matrix); if(!modelset){ traceability->setMatrixModel(matrix); modelset = true; } child = child.nextSibling(); } traceability->addRowToDocument(requirements, -1); traceability->updateReqListModel(); project_open = true; ui->frame_2->hide(); ui->frame->show(); }
/*! Creates a declaration (header file) for the form given in \a e \sa createFormImpl() */ void Ui3Reader::createFormDecl(const QDomElement &e) { QDomElement body = e; QDomElement n; QDomNodeList nl; int i; QString objClass = getClassName(e); if (objClass.isEmpty()) return; QString objName = getObjectName(e); QStringList typeDefs; QMap<QString, CustomInclude> customWidgetIncludes; /* We are generating a few QImage members that are not strictly necessary in some cases. Ideally, we would use requiredImage, which is computed elsewhere, to keep the generated .h and .cpp files synchronized. */ // at first the images QMap<QString, int> customWidgets; QStringList forwardDecl; QStringList forwardDecl2; for (n = e; !n.isNull(); n = n.nextSibling().toElement()) { if (n.tagName().toLower() == QLatin1String("customwidgets")) { QDomElement n2 = n.firstChild().toElement(); while (!n2.isNull()) { if (n2.tagName().toLower() == QLatin1String("customwidget")) { QDomElement n3 = n2.firstChild().toElement(); QString cl; while (!n3.isNull()) { QString tagName = n3.tagName().toLower(); if (tagName == QLatin1String("class")) { cl = n3.firstChild().toText().data(); if (m_options & CustomWidgetForwardDeclarations) forwardDecl << cl; customWidgets.insert(cl, 0); } else if (tagName == QLatin1String("header")) { CustomInclude ci; ci.header = n3.firstChild().toText().data(); ci.location = n3.attribute(QLatin1String("location"), QLatin1String("global")); if (!ci.header.isEmpty()) forwardDecl.removeAll(cl); customWidgetIncludes.insert(cl, ci); } n3 = n3.nextSibling().toElement(); } } n2 = n2.nextSibling().toElement(); } } } // register the object and unify its name objName = registerObject(objName); QString protector = objName.toUpper() + QLatin1String("_H"); protector.replace(QLatin1String("::"), QLatin1String("_")); out << "#ifndef " << protector << endl; out << "#define " << protector << endl; out << endl; out << "#include <qvariant.h>" << endl; // for broken HP-UX compilers QStringList globalIncludes, localIncludes; { QMap<QString, CustomInclude>::Iterator it = customWidgetIncludes.find(objClass); if (it != customWidgetIncludes.end()) { if ((*it).location == QLatin1String("global")) globalIncludes += (*it).header; else localIncludes += (*it).header; } } QStringList::ConstIterator it; globalIncludes = unique(globalIncludes); for (it = globalIncludes.constBegin(); it != globalIncludes.constEnd(); ++it) { if (!(*it).isEmpty()) { QString header = fixHeaderName(*it); out << "#include <" << header << '>' << endl; } } localIncludes = unique(localIncludes); for (it = localIncludes.constBegin(); it != localIncludes.constEnd(); ++it) { if (!(*it).isEmpty()) { QString header = fixHeaderName(*it); out << "#include \"" << header << '\"' << endl; } } out << endl; registerDatabases(e); dbConnections = unique(dbConnections); // some typedefs, maybe typeDefs = unique(typeDefs); for (it = typeDefs.constBegin(); it != typeDefs.constEnd(); ++it) { if (!(*it).isEmpty()) out << "typedef " << *it << ';' << endl; } nl = e.parentNode().toElement().elementsByTagName(QLatin1String("forward")); for (i = 0; i < (int) nl.length(); i++) forwardDecl2 << fixDeclaration(nl.item(i).toElement().firstChild().toText().data()); forwardDecl = unique(forwardDecl); for (it = forwardDecl.constBegin(); it != forwardDecl.constEnd(); ++it) { if (!(*it).isEmpty() && (*it) != objClass) { QString forwardName = *it; QStringList forwardNamespaces = forwardName.split(QLatin1String("::")); forwardName = forwardNamespaces.last(); forwardNamespaces.removeAt(forwardNamespaces.size()-1); QStringList::ConstIterator ns = forwardNamespaces.constBegin(); while (ns != forwardNamespaces.constEnd()) { out << "namespace " << *ns << " {" << endl; ++ns; } out << "class " << forwardName << ';' << endl; for (int i = 0; i < (int) forwardNamespaces.count(); i++) out << '}' << endl; } } for (it = forwardDecl2.constBegin(); it != forwardDecl2.constEnd(); ++it) { QString fd = *it; fd = fd.trimmed(); if (!fd.endsWith(QLatin1Char(';'))) fd += QLatin1Char(';'); out << fd << endl; } out << endl; Driver d; d.option().headerProtection = false; d.option().copyrightHeader = false; d.option().extractImages = m_extractImages; d.option().limitXPM_LineLength = (m_options & LimitXPM_LineLength) ? 1 : 0; d.option().qrcOutputFile = m_qrcOutputFile; d.option().implicitIncludes = (m_options & ImplicitIncludes) ? 1 : 0; if (trmacro.size()) d.option().translateFunction = trmacro; DomUI *ui = generateUi4(e); d.uic(fileName, ui, &out); delete ui; createWrapperDeclContents(e); out << "#endif // " << protector << endl; }
void Project::slotOptions() { KURL url; KDialogBase optionsDlg(KDialogBase::Tabbed, WStyle_DialogBorder, d->m_mainWindow, "project_options", true, i18n("Project Settings"), KDialogBase::Ok | KDialogBase::Cancel); // optionsDlg.setMainWidget(&optionsPage); //add the main options page QFrame *page = optionsDlg.addPage(i18n("Options")); ProjectOptions optionsPage(page); QVBoxLayout *topLayout = new QVBoxLayout( page, 0, KDialog::spacingHint() ); topLayout->addWidget(&optionsPage); optionsPage.linePrjName->setText( d->projectName ); url = QExtFileInfo::toRelative(d->templateURL, d->baseURL); optionsPage.linePrjTmpl->setText(QuantaCommon::qUrl(url)); url = QExtFileInfo::toRelative(d->toolbarURL, d->baseURL); optionsPage.linePrjToolbar->setText( QuantaCommon::qUrl(url) ); optionsPage.lineAuthor->setText( d->author ); optionsPage.lineEmail->setText( d->email ); // Signals to handle debugger settings connect(optionsPage.buttonDebuggerOptions, SIGNAL(clicked()), d, SLOT(slotDebuggerOptions())); connect(optionsPage.comboDebuggerClient, SIGNAL(activated(const QString &)), d, SLOT(slotDebuggerChanged(const QString &))); // Debuggers Combo KTrader::OfferList offers = KTrader::self()->query("Quanta/Debugger"); KTrader::OfferList::ConstIterator iterDbg; optionsPage.comboDebuggerClient->clear(); optionsPage.comboDebuggerClient->insertItem(i18n("No Debugger")); int idxDbg = 0; d->m_debuggerClientEdit = d->debuggerClient; optionsPage.buttonDebuggerOptions->setEnabled(false); for(iterDbg = offers.begin(); iterDbg != offers.end(); ++iterDbg) { KService::Ptr service = *iterDbg; optionsPage.comboDebuggerClient->insertItem(service->name()); idxDbg++; if(d->debuggerClient == service->name()) { optionsPage.comboDebuggerClient->setCurrentItem(idxDbg); optionsPage.buttonDebuggerOptions->setEnabled(true); } } optionsPage.checkDebuggerPersistentBreakpoints->setChecked(d->m_debuggerPersistentBreakpoints); optionsPage.checkDebuggerPersistentWatches->setChecked(d->m_debuggerPersistentWatches); QString excludeStr; for (uint i = 0; i < d->excludeList.count(); i++) { excludeStr.append(d->excludeList[i]); excludeStr.append(";"); } optionsPage.lineExclude->setText(excludeStr); optionsPage.checkCvsignore->setChecked(d->m_excludeCvsignore); optionsPage.linePrefix->setText(d->previewPrefix.prettyURL()); QStringList lst = DTDs::ref()->nickNameList(true); uint pos = 0; for (uint i = 0; i < lst.count(); i++) { optionsPage.dtdCombo->insertItem(lst[i]); if (lst[i] == DTDs::ref()->getDTDNickNameFromName(d->m_defaultDTD)) pos = i; } optionsPage.dtdCombo->setCurrentItem(pos); QStringList availableEncodingNames(KGlobal::charsets()->availableEncodingNames()); optionsPage.encodingCombo->insertStringList( availableEncodingNames ); QStringList::ConstIterator iter; int iIndex = -1; for (iter = availableEncodingNames.begin(); iter != availableEncodingNames.end(); ++iter) { ++iIndex; if ((*iter).lower() == d->m_defaultEncoding.lower()) { optionsPage.encodingCombo->setCurrentItem(iIndex); break; } } QStringList list = d->projectViewList(); QString defaultView = d->dom.firstChild().firstChild().namedItem("autoload").toElement().attribute("projectview"); if (list.count() > 0) { optionsPage.viewCombo->insertStringList(list); for (uint i = 0; i < list.count(); i++) { if (list[i] == defaultView) { optionsPage.viewCombo->setCurrentItem(i); break; } } } else { optionsPage.viewCombo->insertItem(i18n("No view was saved yet.")); optionsPage.viewCombo->setEnabled(false); } optionsPage.checkPrefix->setChecked(d->usePreviewPrefix); optionsPage.checkPersistentBookmarks->setChecked(d->m_persistentBookmarks); //add upload profiles page page = optionsDlg.addPage(i18n("Up&load Profiles")); UploadProfilesPage uploadProfilesPage(page); topLayout = new QVBoxLayout( page, 0, KDialog::spacingHint() ); topLayout->addWidget(&uploadProfilesPage); QDomElement uploadEl = d->m_sessionDom.firstChild().firstChild().namedItem("uploadprofiles").toElement(); uploadProfilesPage.profileLabel->setText(uploadEl.attribute("defaultProfile")); uploadProfilesPage.checkShowUploadTreeviews->setChecked(d->m_showUploadTreeviews); //add the team members page page = optionsDlg.addPage(i18n("Team Configuration")); TeamMembersDlg membersPage(page); topLayout = new QVBoxLayout( page, 0, KDialog::spacingHint() ); topLayout->addWidget(&membersPage); QListViewItem *item; if (!teamLeader().name.isEmpty()) { TeamMember member = teamLeader(); item = new QListViewItem(membersPage.membersListView, member.name, member.nickName, member.email, i18n("Team Leader"), member.task); membersPage.membersListView->insertItem(item); } for (QMap<QString, TeamMember>::ConstIterator it = d->m_subprojectLeaders.constBegin(); it != d->m_subprojectLeaders.constEnd(); ++it) { TeamMember member = it.data(); item = new QListViewItem(membersPage.membersListView, member.name, member.nickName, member.email, i18n("Subproject Leader"), member.task, it.key()); } for (QMap<QString, TeamMember>::ConstIterator it = d->m_taskLeaders.constBegin(); it != d->m_taskLeaders.constEnd(); ++it) { TeamMember member = it.data(); item = new QListViewItem(membersPage.membersListView, member.name, member.nickName, member.email, i18n("Task Leader"), it.key()); } for (QValueList<TeamMember>::ConstIterator it = d->m_simpleMembers.constBegin(); it != d->m_simpleMembers.constEnd(); ++it) { TeamMember member = *it; item = new QListViewItem(membersPage.membersListView, member.name, member.nickName, member.email, i18n("Simple Member"), member.task); } membersPage.mailingListEdit->setText(d->m_mailingList); membersPage.setYourself(d->m_yourself); //add the event configuration page page = optionsDlg.addPage(i18n("Event Configuration")); EventConfigurationDlg eventsPage(d->m_mainWindow->actionCollection(), page); topLayout = new QVBoxLayout( page, 0, KDialog::spacingHint() ); topLayout->addWidget(&eventsPage); eventsPage.initEvents(d->m_events); eventsPage.enableEventsBox->setChecked(d->m_eventsEnabled); if ( optionsDlg.exec() ) { d->projectName = optionsPage.linePrjName->text(); d->author = optionsPage.lineAuthor ->text(); d->email = optionsPage.lineEmail ->text(); // Debugger d->debuggerClient = optionsPage.comboDebuggerClient->currentText(); d->m_debuggerPersistentBreakpoints = optionsPage.checkDebuggerPersistentBreakpoints->isChecked(); d->m_debuggerPersistentWatches = optionsPage.checkDebuggerPersistentWatches->isChecked(); d->m_defaultDTD = DTDs::ref()->getDTDNameFromNickName(optionsPage.dtdCombo->currentText()).lower(); d->m_defaultEncoding = optionsPage.encodingCombo->currentText(); QuantaCommon::setUrl(d->templateURL, optionsPage.linePrjTmpl->text()); d->templateURL.adjustPath(1); d->templateURL = QExtFileInfo::toAbsolute(d->templateURL, d->baseURL); if (!QExtFileInfo::createDir(d->templateURL, d->m_mainWindow)) { QuantaCommon::dirCreationError(d->m_mainWindow, d->templateURL); } QuantaCommon::setUrl(d->toolbarURL, optionsPage.linePrjToolbar->text()); d->toolbarURL.adjustPath(1); d->toolbarURL = QExtFileInfo::toAbsolute(d->toolbarURL, d->baseURL); if (!QExtFileInfo::createDir(d->toolbarURL, d->m_mainWindow)) { QuantaCommon::dirCreationError(d->m_mainWindow, d->toolbarURL); } d->previewPrefix = KURL::fromPathOrURL( optionsPage.linePrefix->text() ); d->usePreviewPrefix = optionsPage.checkPrefix->isChecked(); d->m_persistentBookmarks = optionsPage.checkPersistentBookmarks->isChecked(); QDomNode projectNode = d->dom.firstChild().firstChild(); QDomElement el; el = projectNode.toElement(); el.setAttribute("name",d->projectName); el.setAttribute("encoding", d->m_defaultEncoding); el = d->m_sessionDom.firstChild().firstChild().toElement(); el.setAttribute("previewPrefix", d->previewPrefix.url() ); el.setAttribute("usePreviewPrefix", d->usePreviewPrefix ); el.setAttribute("usePersistentBookmarks", d->m_persistentBookmarks); el = projectNode.namedItem("author").toElement(); if (!el.isNull()) el.parentNode().removeChild(el); el =d->dom.createElement("author"); projectNode.appendChild( el ); el.appendChild(d->dom.createTextNode( d->author ) ); el = projectNode.namedItem("email").toElement(); if (!el.isNull()) el.parentNode().removeChild(el); el =d->dom.createElement("email"); projectNode.appendChild( el ); el.appendChild(d->dom.createTextNode( d->email ) ); // Debugger el =projectNode.namedItem("debuggerclient").toElement(); if (!el.isNull()) el.parentNode().removeChild(el); el =d->dom.createElement("debuggerclient"); projectNode.appendChild( el ); el.appendChild(d->dom.createTextNode( d->debuggerClient ) ); el.setAttribute("persistentBreakpoints", d->m_debuggerPersistentBreakpoints); el.setAttribute("persistentWatches", d->m_debuggerPersistentWatches); d->m_excludeCvsignore = optionsPage.checkCvsignore->isChecked(); excludeStr = optionsPage.lineExclude->text(); el =projectNode.namedItem("exclude").toElement(); if (!el.isNull()) el.parentNode().removeChild(el); el =d->dom.createElement("exclude"); if (d->m_excludeCvsignore) el.setAttribute("cvsignore", "true"); else el.setAttribute("cvsignore", "false"); projectNode.appendChild( el ); el.appendChild(d->dom.createTextNode( excludeStr ) ); el =projectNode.namedItem("defaultDTD").toElement(); if(el.isNull()) { el =d->dom.createElement("defaultDTD"); projectNode.appendChild(el); el.appendChild(d->dom.createTextNode(d->m_defaultDTD)); } else { el.firstChild().setNodeValue(d->m_defaultDTD); } el = projectNode.namedItem("templates").toElement(); url = QExtFileInfo::toRelative(d->templateURL, d->baseURL); if(el.isNull()) { el =d->dom.createElement("templates"); projectNode.appendChild(el); el.appendChild(d->dom.createTextNode(QuantaCommon::qUrl(url))); } else { el.firstChild().setNodeValue(QuantaCommon::qUrl(url)); } url = QExtFileInfo::toRelative(d->toolbarURL, d->baseURL); el = projectNode.namedItem("toolbars").toElement(); if(el.isNull()) { el =d->dom.createElement("toolbars"); projectNode.appendChild(el); el.appendChild(d->dom.createTextNode(QuantaCommon::qUrl(url))); } else { el.firstChild().setNodeValue(QuantaCommon::qUrl(url)); } if (optionsPage.viewCombo->isEnabled()) { defaultView = optionsPage.viewCombo->currentText(); el = projectNode.namedItem("autoload").toElement(); if (el.isNull()) { el =d->dom.createElement("autoload"); el.setAttribute("projectview", defaultView); projectNode.appendChild( el ); } else { el.setAttribute("projectview", defaultView); } } uploadEl.setAttribute("showtreeviews", uploadProfilesPage.checkShowUploadTreeviews->isChecked() ? "true" : "false"); QDomNode teamNode = projectNode.namedItem("teamdata"); if (!teamNode.isNull()) projectNode.removeChild(teamNode); teamNode = d->dom.createElement("teamdata"); QDomNode taskLeadersNode = d->dom.createElement("taskleaders"); teamNode.appendChild(taskLeadersNode); QDomNode subLeadersNode = d->dom.createElement("subprojectleaders"); teamNode.appendChild(subLeadersNode); QListViewItemIterator it(membersPage.membersListView); QListViewItem *item; QStringList savedSubprojects; while (it.current()) { item = it.current(); QString role = item->text(3); if (role == i18n(teamLeaderStr.utf8())) { QDomElement leaderEl = d->dom.createElement("leader"); teamNode.appendChild(leaderEl); el = d->dom.createElement("name"); leaderEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(0))); el = d->dom.createElement("nickName"); leaderEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(1))); el = d->dom.createElement("email"); leaderEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(2))); } else if (role == i18n(subprojectLeaderStr.utf8())) { QString prjName = item->text(5); savedSubprojects.append(prjName); QDomElement subEl = d->dom.createElement("subproject"); for (uint i = 0; i < d->m_subprojects.count(); i++) { if (d->m_subprojects[i].name == prjName) { subEl.setAttribute("location", d->m_subprojects[i].location); break; } } subEl.setAttribute("name", prjName); subLeadersNode.appendChild(subEl); el = d->dom.createElement("subprojectleader"); el.setAttribute("name", item->text(0)); el.setAttribute("nickName", item->text(1)); el.setAttribute("email", item->text(2)); subEl.appendChild(el); } else if (role == i18n(taskLeaderStr.utf8())) { el = d->dom.createElement("projecttask"); el.setAttribute("tasklead", item->text(0)); el.setAttribute("nickName", item->text(1)); el.setAttribute("email", item->text(2)); el.setAttribute("task", item->text(4)); taskLeadersNode.appendChild(el); } else if (role == i18n(simpleMemberStr.utf8())) { QDomElement memberEl = d->dom.createElement("member"); memberEl.setAttribute("task", item->text(4)); teamNode.appendChild(memberEl); el = d->dom.createElement("name"); memberEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(0))); el = d->dom.createElement("nickName"); memberEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(1))); el = d->dom.createElement("email"); memberEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(2))); } ++it; } //subprojects without a leader for (uint i = 0; i < d->m_subprojects.count(); i++) { if (!savedSubprojects.contains(d->m_subprojects[i].name)) { el = d->dom.createElement("subproject"); el.setAttribute("name", d->m_subprojects[i].name); el.setAttribute("location", d->m_subprojects[i].location); } } el = d->dom.createElement("mailinglist"); el.setAttribute("address", membersPage.mailingListEdit->text()); teamNode.appendChild(el); projectNode.appendChild(teamNode); teamNode = d->m_sessionDom.firstChild().namedItem("teamdata"); if (!teamNode.isNull()) d->m_sessionDom.firstChild().removeChild(teamNode); d->m_yourself = membersPage.yourself(); el = d->m_sessionDom.createElement("teamdata"); el.setAttribute("yourself", d->m_yourself); d->m_sessionDom.firstChild().appendChild(el); eventsPage.saveEvents(d->dom); d->m_eventsEnabled = eventsPage.enableEventsBox->isChecked(); projectNode.toElement().setAttribute("enableEvents", d->m_eventsEnabled?"true":"false"); setModified(); d->loadProjectXML(); } }
/*! Creates an implementation (cpp-file) for the form given in \a e. \sa createFormDecl(), createObjectImpl() */ void Ui3Reader::createFormImpl(const QDomElement &e) { QDomElement n; QDomNodeList nl; int i; QString objClass = getClassName(e); if (objClass.isEmpty()) return; QString objName = getObjectName(e); // generate local and local includes required QStringList globalIncludes, localIncludes; QStringList::Iterator it; QMap<QString, CustomInclude> customWidgetIncludes; // find additional slots and functions QStringList extraFuncts; QStringList extraFunctTyp; QStringList extraFunctSpecifier; 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 functionName = n.firstChild().toText().data().trimmed(); if (functionName.endsWith(QLatin1Char(';'))) functionName.chop(1); extraFuncts += functionName; extraFunctTyp += n.attribute(QLatin1String("returnType"), QLatin1String("void")); extraFunctSpecifier += n.attribute(QLatin1String("specifier"), QLatin1String("virtual")); } nl = e.parentNode().toElement().elementsByTagName(QLatin1String("function")); for (i = 0; i < (int) nl.length(); i++) { n = nl.item(i).toElement(); if (n.parentNode().toElement().tagName() != QLatin1String("functions")) continue; if (n.attribute(QLatin1String("language"), QLatin1String("C++")) != QLatin1String("C++")) continue; QString functionName = n.firstChild().toText().data().trimmed(); if (functionName.endsWith(QLatin1Char(';'))) functionName.chop(1); extraFuncts += functionName; extraFunctTyp += n.attribute(QLatin1String("returnType"), QLatin1String("void")); extraFunctSpecifier += n.attribute(QLatin1String("specifier"), QLatin1String("virtual")); } // additional includes (local or global) and forward declaractions nl = e.parentNode().toElement().elementsByTagName(QLatin1String("include")); for (i = 0; i < (int) nl.length(); i++) { QDomElement n2 = nl.item(i).toElement(); QString s = n2.firstChild().toText().data(); if (n2.attribute(QLatin1String("location")) != QLatin1String("local")) { if (s.right(5) == QLatin1String(".ui.h") && !QFile::exists(s)) continue; if (n2.attribute(QLatin1String("impldecl"), QLatin1String("in implementation")) != QLatin1String("in implementation")) continue; globalIncludes += s; } } registerDatabases(e); dbConnections = unique(dbConnections); bool dbForm = false; if (dbForms[QLatin1String("(default)")].count()) dbForm = true; bool subDbForms = false; for (it = dbConnections.begin(); it != dbConnections.end(); ++it) { if (!(*it).isEmpty() && (*it) != QLatin1String("(default)")) { if (dbForms[(*it)].count()) { subDbForms = true; break; } } } // do the local includes afterwards, since global includes have priority on clashes for (i = 0; i < (int) nl.length(); i++) { QDomElement n2 = nl.item(i).toElement(); QString s = n2.firstChild().toText().data(); if (n2.attribute(QLatin1String("location")) == QLatin1String("local") && !globalIncludes.contains(s)) { if (s.right(5) == QLatin1String(".ui.h") && !QFile::exists(s)) continue; if (n2.attribute(QLatin1String("impldecl"), QLatin1String("in implementation")) != QLatin1String("in implementation")) continue; localIncludes += s; } } // additional custom widget headers nl = e.parentNode().toElement().elementsByTagName(QLatin1String("header")); for (i = 0; i < (int) nl.length(); i++) { QDomElement n2 = nl.item(i).toElement(); QString s = n2.firstChild().toText().data(); if (n2.attribute(QLatin1String("location")) != QLatin1String("local")) globalIncludes += s; else localIncludes += s; } out << "#include <qvariant.h>" << endl; // first for gcc 2.7.2 globalIncludes = unique(globalIncludes); for (it = globalIncludes.begin(); it != globalIncludes.end(); ++it) { if (!(*it).isEmpty()) out << "#include <" << fixHeaderName(*it) << '>' << endl; } if (externPixmaps) { out << "#include <qimage.h>" << endl; out << "#include <qpixmap.h>" << endl << endl; } /* Put local includes after all global includes */ localIncludes = unique(localIncludes); for (it = localIncludes.begin(); it != localIncludes.end(); ++it) { if (!(*it).isEmpty() && *it != QFileInfo(fileName + QLatin1String(".h")).fileName()) out << "#include \"" << fixHeaderName(*it) << '\"' << endl; } QString uiDotH = fileName + QLatin1String(".h"); if (QFile::exists(uiDotH)) { if (!outputFileName.isEmpty()) uiDotH = QString::fromUtf8(combinePath(uiDotH.ascii(), outputFileName.ascii())); out << "#include \"" << uiDotH << '\"' << endl; writeFunctImpl = false; } // register the object and unify its name objName = registerObject(objName); if (externPixmaps) { pixmapLoaderFunction = QLatin1String("QPixmap::fromMimeSource"); } // constructor if (objClass == QLatin1String("QDialog") || objClass == QLatin1String("QWizard")) { out << "/*" << endl; out << " * Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl; out << " * name 'name' and widget flags set to 'f'." << endl; out << " *" << endl; out << " * The " << objClass.mid(1).toLower() << " will by default be modeless, unless you set 'modal' to" << endl; out << " * true to construct a modal " << objClass.mid(1).toLower() << '.' << endl; out << " */" << endl; out << nameOfClass << "::" << bareNameOfClass << "(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)" << endl; out << " : " << objClass << "(parent, name, modal, fl)"; } else if (objClass == QLatin1String("QWidget")) { out << "/*" << endl; out << " * Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl; out << " * name 'name' and widget flags set to 'f'." << endl; out << " */" << endl; out << nameOfClass << "::" << bareNameOfClass << "(QWidget* parent, const char* name, Qt::WindowFlags fl)" << endl; out << " : " << objClass << "(parent, name, fl)"; } else if (objClass == QLatin1String("QMainWindow") || objClass == QLatin1String("Q3MainWindow")) { out << "/*" << endl; out << " * Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl; out << " * name 'name' and widget flags set to 'f'." << endl; out << " *" << endl; out << " */" << endl; out << nameOfClass << "::" << bareNameOfClass << "(QWidget* parent, const char* name, Qt::WindowFlags fl)" << endl; out << " : " << objClass << "(parent, name, fl)"; isMainWindow = true; } else { out << "/*" << endl; out << " * Constructs a " << nameOfClass << " which is a child of 'parent', with the" << endl; out << " * name 'name'.' " << endl; out << " */" << endl; out << nameOfClass << "::" << bareNameOfClass << "(QWidget* parent, const char* name)" << endl; out << " : " << objClass << "(parent, name)"; } out << endl; out << '{' << endl; // // setup the gui // out << indent << "setupUi(this);" << endl << endl; if (isMainWindow) out << indent << "(void)statusBar();" << endl; // database support dbConnections = unique(dbConnections); if (dbConnections.count()) out << endl; for (it = dbConnections.begin(); it != dbConnections.end(); ++it) { if (!(*it).isEmpty() && (*it) != QLatin1String("(default)")) { out << indent << (*it) << "Connection = QSqlDatabase::database(\"" <<(*it) << "\");" << endl; } } nl = e.parentNode().toElement().elementsByTagName(QLatin1String("widget")); for (i = 1; i < (int) nl.length(); i++) { // start at 1, 0 is the toplevel widget n = nl.item(i).toElement(); QString s = getClassName(n); if ((dbForm || subDbForms) && (s == QLatin1String("QDataBrowser") || s == QLatin1String("QDataView"))) { QString objName = getObjectName(n); QString tab = getDatabaseInfo(n, QLatin1String("table")); QString con = getDatabaseInfo(n, QLatin1String("connection")); out << indent << "QSqlForm* " << objName << "Form = new QSqlForm(this);" << endl; out << indent << objName << "Form->setObjectName(\"" << objName << "Form\");" << endl; QDomElement n2; for (n2 = n.firstChild().toElement(); !n2.isNull(); n2 = n2.nextSibling().toElement()) createFormImpl(n2, objName, con, tab); out << indent << objName << "->setForm(" << objName << "Form);" << endl; } } if (extraFuncts.contains(QLatin1String("init()"))) out << indent << "init();" << endl; // end of constructor out << '}' << endl; out << endl; // destructor out << "/*" << endl; out << " * Destroys the object and frees any allocated resources" << endl; out << " */" << endl; out << nameOfClass << "::~" << bareNameOfClass << "()" << endl; out << '{' << endl; if (extraFuncts.contains(QLatin1String("destroy()"))) out << indent << "destroy();" << endl; out << indent << "// no need to delete child widgets, Qt does it all for us" << endl; out << '}' << endl; out << endl; // handle application events if required bool needFontEventHandler = false; bool needSqlTableEventHandler = false; bool needSqlDataBrowserEventHandler = false; nl = e.elementsByTagName(QLatin1String("widget")); for (i = 0; i < (int) nl.length(); i++) { if (!DomTool::propertiesOfType(nl.item(i).toElement() , QLatin1String("font")).isEmpty()) needFontEventHandler = true; QString s = getClassName(nl.item(i).toElement()); if (s == QLatin1String("QDataTable") || s == QLatin1String("QDataBrowser")) { if (!isFrameworkCodeGenerated(nl.item(i).toElement())) continue; if (s == QLatin1String("QDataTable")) needSqlTableEventHandler = true; if (s == QLatin1String("QDataBrowser")) needSqlDataBrowserEventHandler = true; } if (needFontEventHandler && needSqlTableEventHandler && needSqlDataBrowserEventHandler) break; } out << "/*" << endl; out << " * Sets the strings of the subwidgets using the current" << endl; out << " * language." << endl; out << " */" << endl; out << "void " << nameOfClass << "::languageChange()" << endl; out << '{' << endl; out << " retranslateUi(this);" << endl; out << '}' << endl; out << endl; // create stubs for additional slots if necessary if (!extraFuncts.isEmpty() && writeFunctImpl) { it = extraFuncts.begin(); QStringList::Iterator it2 = extraFunctTyp.begin(); QStringList::Iterator it3 = extraFunctSpecifier.begin(); while (it != extraFuncts.end()) { QString type = fixDeclaration(*it2); if (type.isEmpty()) type = QLatin1String("void"); type = type.simplified(); QString fname = fixDeclaration(Parser::cleanArgs(*it)); if (!(*it3).startsWith(QLatin1String("pure"))) { // "pure virtual" or "pureVirtual" out << type << ' ' << nameOfClass << "::" << fname << endl; out << '{' << endl; if (*it != QLatin1String("init()") && *it != QLatin1String("destroy()")) { QRegExp numeric(QLatin1String("^(?:signed|unsigned|u?char|u?short|u?int" "|u?long|Q_U?INT(?:8|16|32)|Q_U?LONG|float" "|double)$")); QString retVal; /* We return some kind of dummy value to shut the compiler up. 1. If the type is 'void', we return nothing. 2. If the type is 'bool', we return 'false'. 3. If the type is 'unsigned long' or 'quint16' or 'double' or similar, we return '0'. 4. If the type is 'Foo *', we return '0'. 5. If the type is 'Foo &', we create a static variable of type 'Foo' and return it. 6. If the type is 'Foo', we assume there's a default constructor and use it. */ if (type != QLatin1String("void")) { QStringList toks = type.split(QLatin1String(" ")); bool isBasicNumericType = (toks.filter(numeric).count() == toks.count()); if (type == QLatin1String("bool")) { retVal = QLatin1String("false"); } else if (isBasicNumericType || type.endsWith(QLatin1Char('*'))) { retVal = QLatin1String("0"); } else if (type.endsWith(QLatin1Char('&'))) { do { type.chop(1); } while (type.endsWith(QLatin1Char(' '))); retVal = QLatin1String("uic_temp_var"); out << indent << "static " << type << ' ' << retVal << ';' << endl; } else { retVal = type + QLatin1String("()"); } } out << indent << "qWarning(\"" << nameOfClass << "::" << fname << ": Not implemented yet\");" << endl; if (!retVal.isEmpty()) out << indent << "return " << retVal << ';' << endl; } out << '}' << endl; out << endl; } ++it; ++it2; ++it3; } } }
bool QgsMapLayer::readLayerXML( const QDomElement& layerElement ) { QgsCoordinateReferenceSystem savedCRS; CUSTOM_CRS_VALIDATION savedValidation; bool layerError; QDomNode mnl; QDomElement mne; // read provider QString provider; mnl = layerElement.namedItem( "provider" ); mne = mnl.toElement(); provider = mne.text(); // set data source mnl = layerElement.namedItem( "datasource" ); mne = mnl.toElement(); mDataSource = mne.text(); // if the layer needs authentication, ensure the master password is set QRegExp rx( "authcfg=([a-z]|[A-Z]|[0-9]){7}" ); if (( rx.indexIn( mDataSource ) != -1 ) && !QgsAuthManager::instance()->setMasterPassword( true ) ) { return false; } // TODO: this should go to providers // see also QgsProject::createEmbeddedLayer if ( provider == "spatialite" ) { QgsDataSourceURI uri( mDataSource ); uri.setDatabase( QgsProject::instance()->readPath( uri.database() ) ); mDataSource = uri.uri(); } else if ( provider == "ogr" ) { QStringList theURIParts = mDataSource.split( "|" ); theURIParts[0] = QgsProject::instance()->readPath( theURIParts[0] ); mDataSource = theURIParts.join( "|" ); } else if ( provider == "gpx" ) { QStringList theURIParts = mDataSource.split( "?" ); theURIParts[0] = QgsProject::instance()->readPath( theURIParts[0] ); mDataSource = theURIParts.join( "?" ); } else if ( provider == "delimitedtext" ) { QUrl urlSource = QUrl::fromEncoded( mDataSource.toAscii() ); if ( !mDataSource.startsWith( "file:" ) ) { QUrl file = QUrl::fromLocalFile( mDataSource.left( mDataSource.indexOf( "?" ) ) ); urlSource.setScheme( "file" ); urlSource.setPath( file.path() ); } QUrl urlDest = QUrl::fromLocalFile( QgsProject::instance()->readPath( urlSource.toLocalFile() ) ); urlDest.setQueryItems( urlSource.queryItems() ); mDataSource = QString::fromAscii( urlDest.toEncoded() ); } else if ( provider == "wms" ) { // >>> BACKWARD COMPATIBILITY < 1.9 // For project file backward compatibility we must support old format: // 1. mode: <url> // example: http://example.org/wms? // 2. mode: tiled=<width>;<height>;<resolution>;<resolution>...,ignoreUrl=GetMap;GetFeatureInfo,featureCount=<count>,username=<name>,password=<password>,url=<url> // example: tiled=256;256;0.703;0.351,url=http://example.org/tilecache? // example: featureCount=10,http://example.org/wms? // example: ignoreUrl=GetMap;GetFeatureInfo,username=cimrman,password=jara,url=http://example.org/wms? // This is modified version of old QgsWmsProvider::parseUri // The new format has always params crs,format,layers,styles and that params // should not appear in old format url -> use them to identify version if ( !mDataSource.contains( "crs=" ) && !mDataSource.contains( "format=" ) ) { QgsDebugMsg( "Old WMS URI format detected -> converting to new format" ); QgsDataSourceURI uri; if ( !mDataSource.startsWith( "http:" ) ) { QStringList parts = mDataSource.split( "," ); QStringListIterator iter( parts ); while ( iter.hasNext() ) { QString item = iter.next(); if ( item.startsWith( "username="******"username", item.mid( 9 ) ); } else if ( item.startsWith( "password="******"password", item.mid( 9 ) ); } else if ( item.startsWith( "tiled=" ) ) { // in < 1.9 tiled= may apper in to variants: // tiled=width;height - non tiled mode, specifies max width and max height // tiled=width;height;resolutions-1;resolution2;... - tile mode QStringList params = item.mid( 6 ).split( ";" ); if ( params.size() == 2 ) // non tiled mode { uri.setParam( "maxWidth", params.takeFirst() ); uri.setParam( "maxHeight", params.takeFirst() ); } else if ( params.size() > 2 ) // tiled mode { // resolutions are no more needed and size limit is not used for tiles // we have to tell to the provider however that it is tiled uri.setParam( "tileMatrixSet", "" ); } } else if ( item.startsWith( "featureCount=" ) ) { uri.setParam( "featureCount", item.mid( 13 ) ); } else if ( item.startsWith( "url=" ) ) { uri.setParam( "url", item.mid( 4 ) ); } else if ( item.startsWith( "ignoreUrl=" ) ) { uri.setParam( "ignoreUrl", item.mid( 10 ).split( ";" ) ); } } } else { uri.setParam( "url", mDataSource ); } mDataSource = uri.encodedUri(); // At this point, the URI is obviously incomplete, we add additional params // in QgsRasterLayer::readXml } // <<< BACKWARD COMPATIBILITY < 1.9 } else { bool handled = false; if ( provider == "gdal" ) { if ( mDataSource.startsWith( "NETCDF:" ) ) { // NETCDF:filename:variable // filename can be quoted with " as it can contain colons QRegExp r( "NETCDF:(.+):([^:]+)" ); if ( r.exactMatch( mDataSource ) ) { QString filename = r.cap( 1 ); if ( filename.startsWith( '"' ) && filename.endsWith( '"' ) ) filename = filename.mid( 1, filename.length() - 2 ); mDataSource = "NETCDF:\"" + QgsProject::instance()->readPath( filename ) + "\":" + r.cap( 2 ); handled = true; } } else if ( mDataSource.startsWith( "HDF4_SDS:" ) ) { // HDF4_SDS:subdataset_type:file_name:subdataset_index // filename can be quoted with " as it can contain colons QRegExp r( "HDF4_SDS:([^:]+):(.+):([^:]+)" ); if ( r.exactMatch( mDataSource ) ) { QString filename = r.cap( 2 ); if ( filename.startsWith( '"' ) && filename.endsWith( '"' ) ) filename = filename.mid( 1, filename.length() - 2 ); mDataSource = "HDF4_SDS:" + r.cap( 1 ) + ":\"" + QgsProject::instance()->readPath( filename ) + "\":" + r.cap( 3 ); handled = true; } } else if ( mDataSource.startsWith( "HDF5:" ) ) { // HDF5:file_name:subdataset // filename can be quoted with " as it can contain colons QRegExp r( "HDF5:(.+):([^:]+)" ); if ( r.exactMatch( mDataSource ) ) { QString filename = r.cap( 1 ); if ( filename.startsWith( '"' ) && filename.endsWith( '"' ) ) filename = filename.mid( 1, filename.length() - 2 ); mDataSource = "HDF5:\"" + QgsProject::instance()->readPath( filename ) + "\":" + r.cap( 2 ); handled = true; } } else if ( mDataSource.contains( QRegExp( "^(NITF_IM|RADARSAT_2_CALIB):" ) ) ) { // NITF_IM:0:filename // RADARSAT_2_CALIB:?:filename QRegExp r( "([^:]+):([^:]+):(.+)" ); if ( r.exactMatch( mDataSource ) ) { mDataSource = r.cap( 1 ) + ":" + r.cap( 2 ) + ":" + QgsProject::instance()->readPath( r.cap( 3 ) ); handled = true; } } } if ( !handled ) mDataSource = QgsProject::instance()->readPath( mDataSource ); } // Set the CRS from project file, asking the user if necessary. // Make it the saved CRS to have WMS layer projected correctly. // We will still overwrite whatever GDAL etc picks up anyway // further down this function. mnl = layerElement.namedItem( "layername" ); mne = mnl.toElement(); QDomNode srsNode = layerElement.namedItem( "srs" ); mCRS->readXML( srsNode ); mCRS->setValidationHint( tr( "Specify CRS for layer %1" ).arg( mne.text() ) ); mCRS->validate(); savedCRS = *mCRS; // Do not validate any projections in children, they will be overwritten anyway. // No need to ask the user for a projections when it is overwritten, is there? savedValidation = QgsCoordinateReferenceSystem::customSrsValidation(); QgsCoordinateReferenceSystem::setCustomSrsValidation( NULL ); // now let the children grab what they need from the Dom node. layerError = !readXml( layerElement ); // overwrite CRS with what we read from project file before the raster/vector // file readnig functions changed it. They will if projections is specfied in the file. // FIXME: is this necessary? QgsCoordinateReferenceSystem::setCustomSrsValidation( savedValidation ); *mCRS = savedCRS; // Abort if any error in layer, such as not found. if ( layerError ) { return false; } // the internal name is just the data source basename //QFileInfo dataSourceFileInfo( mDataSource ); //internalName = dataSourceFileInfo.baseName(); // set ID mnl = layerElement.namedItem( "id" ); if ( ! mnl.isNull() ) { mne = mnl.toElement(); if ( ! mne.isNull() && mne.text().length() > 10 ) // should be at least 17 (yyyyMMddhhmmsszzz) { mID = mne.text(); } } // use scale dependent visibility flag setScaleBasedVisibility( layerElement.attribute( "hasScaleBasedVisibilityFlag" ).toInt() == 1 ); setMinimumScale( layerElement.attribute( "minimumScale" ).toFloat() ); setMaximumScale( layerElement.attribute( "maximumScale" ).toFloat() ); // set name mnl = layerElement.namedItem( "layername" ); mne = mnl.toElement(); setLayerName( mne.text() ); //title QDomElement titleElem = layerElement.firstChildElement( "title" ); if ( !titleElem.isNull() ) { mTitle = titleElem.text(); } //abstract QDomElement abstractElem = layerElement.firstChildElement( "abstract" ); if ( !abstractElem.isNull() ) { mAbstract = abstractElem.text(); } //keywordList QDomElement keywordListElem = layerElement.firstChildElement( "keywordList" ); if ( !keywordListElem.isNull() ) { QStringList kwdList; for ( QDomNode n = keywordListElem.firstChild(); !n.isNull(); n = n.nextSibling() ) { kwdList << n.toElement().text(); } mKeywordList = kwdList.join( ", " ); } //metadataUrl QDomElement dataUrlElem = layerElement.firstChildElement( "dataUrl" ); if ( !dataUrlElem.isNull() ) { mDataUrl = dataUrlElem.text(); mDataUrlFormat = dataUrlElem.attribute( "format", "" ); } //legendUrl QDomElement legendUrlElem = layerElement.firstChildElement( "legendUrl" ); if ( !legendUrlElem.isNull() ) { mLegendUrl = legendUrlElem.text(); mLegendUrlFormat = legendUrlElem.attribute( "format", "" ); } //attribution QDomElement attribElem = layerElement.firstChildElement( "attribution" ); if ( !attribElem.isNull() ) { mAttribution = attribElem.text(); mAttributionUrl = attribElem.attribute( "href", "" ); } //metadataUrl QDomElement metaUrlElem = layerElement.firstChildElement( "metadataUrl" ); if ( !metaUrlElem.isNull() ) { mMetadataUrl = metaUrlElem.text(); mMetadataUrlType = metaUrlElem.attribute( "type", "" ); mMetadataUrlFormat = metaUrlElem.attribute( "format", "" ); } #if 0 //read transparency level QDomNode transparencyNode = layer_node.namedItem( "transparencyLevelInt" ); if ( ! transparencyNode.isNull() ) { // set transparency level only if it's in project // (otherwise it sets the layer transparent) QDomElement myElement = transparencyNode.toElement(); setTransparency( myElement.text().toInt() ); } #endif readCustomProperties( layerElement ); return true; } // bool QgsMapLayer::readLayerXML
KstCPlugin::KstCPlugin(const QDomElement& e) : KstDataObject(e) { QString pluginName; _inStringCnt = 0; _outStringCnt = 0; commonConstructor(); QDomNode n = e.firstChild(); while (!n.isNull()) { QDomElement e = n.toElement(); if (!e.isNull()) { if (e.tagName() == "tag") { setTagName(e.text()); } else if (e.tagName() == "name") { pluginName = e.text(); } else if (e.tagName() == "ivector") { _inputVectorLoadQueue.append(qMakePair(e.attribute("name"), e.text())); } else if (e.tagName() == "iscalar") { _inputScalarLoadQueue.append(qMakePair(e.attribute("name"), e.text())); } else if (e.tagName() == "istring") { _inputStringLoadQueue.append(qMakePair(e.attribute("name"), e.text())); } else if (e.tagName() == "ovector") { KstVectorPtr v; if (e.attribute("scalarList", "0").toInt()) { v = new KstVector(e.text(), 0, this, true); } else { v = new KstVector(e.text(), 0, this, false); } _outputVectors.insert(e.attribute("name"), v); KST::addVectorToList(v); } else if (e.tagName() == "oscalar") { KstScalarPtr sp = new KstScalar(e.text(), this); _outputScalars.insert(e.attribute("name"), sp); } else if (e.tagName() == "ostring") { KstStringPtr sp = new KstString(e.text(), this); _outputStrings.insert(e.attribute("name"), sp); } } n = n.nextSibling(); } _plugin = PluginCollection::self()->plugin(pluginName); if (!_plugin.data()) { KstDebug::self()->log(i18n("Unable to load plugin %1 for \"%2\".").arg(pluginName).arg(tagName()), KstDebug::Warning); } else { Plugin::countScalarsVectorsAndStrings(_plugin->data()._inputs, _inScalarCnt, _inArrayCnt, _inStringCnt, _inPid); const QValueList<Plugin::Data::IOValue>& otable = _plugin->data()._outputs; for (QValueList<Plugin::Data::IOValue>::ConstIterator it = otable.begin(); it != otable.end(); ++it) { // FIXME: i18n? if ((*it)._type == Plugin::Data::IOValue::TableType) { _outArrayCnt++; if (!_outputVectors.contains((*it)._name)) { KstVectorPtr v; if ((*it)._subType == Plugin::Data::IOValue::FloatNonVectorSubType) { v = new KstVector(tagName() + " vector - " + (*it)._name, 0, this, true); } else { v = new KstVector(tagName() + " vector - " + (*it)._name, 0, this, false); } _outputVectors.insert((*it)._name, v); KST::addVectorToList(v); } } else if ((*it)._type == Plugin::Data::IOValue::MatrixType) { abort(); // FIXME: #if 0 _outArrayCnt += 2; if (!_outputMatrices.contains((*it)._name)) { KstMatrixPtr m; if ((*it)._subType == Plugin::Data::IOValue::FloatNonVectorSubType) { m = new KstMatrix(tagName() + " matrix - " + (*it)._name, 0, true); } else { m = new KstMatrix(tagName() + " matrix - " + (*it)._name, 0, false); } m->setProvider(this); _outputMatrices.insert((*it)._name, m); KST::addVectorToList(v); } #endif } else if ((*it)._type == Plugin::Data::IOValue::FloatType) { _outScalarCnt++; if (!_outputScalars.contains((*it)._name)) { KstScalarPtr s = new KstScalar(tagName() + " scalar - " + (*it)._name, this); _outputScalars.insert((*it)._name, s); } } else if ((*it)._type == Plugin::Data::IOValue::StringType) { _outStringCnt++; if (!_outputStrings.contains((*it)._name)) { KstStringPtr s = new KstString(tagName() + " string - " + (*it)._name, this); _outputStrings.insert((*it)._name, s); } } } allocateParameters(); } }
void QgsGrassTools::addModules( QTreeWidgetItem *parent, QDomElement &element ) { QDomNode n = element.firstChild(); QTreeWidgetItem *item; QTreeWidgetItem *lastItem = 0; while ( !n.isNull() ) { QDomElement e = n.toElement(); if ( !e.isNull() ) { // QgsDebugMsg(QString("tag = %1").arg(e.tagName())); if ( e.tagName() == "section" && e.tagName() == "grass" ) { QgsDebugMsg( QString( "Unknown tag: %1" ).arg( e.tagName() ) ); continue; } if ( parent ) { item = new QTreeWidgetItem( parent, lastItem ); } else { item = new QTreeWidgetItem( mModulesTree, lastItem ); } if ( e.tagName() == "section" ) { QString label = e.attribute( "label" ); QgsDebugMsg( QString( "label = %1" ).arg( label ) ); item->setText( 0, label ); item->setExpanded( false ); addModules( item, e ); lastItem = item; } else if ( e.tagName() == "grass" ) { // GRASS module QString name = e.attribute( "name" ); QgsDebugMsg( QString( "name = %1" ).arg( name ) ); QString path = QgsApplication::pkgDataPath() + "/grass/modules/" + name; QString label = QgsGrassModule::label( path ); QPixmap pixmap = QgsGrassModule::pixmap( path, 25 ); item->setText( 0, name + " - " + label ); item->setIcon( 0, QIcon( pixmap ) ); item->setText( 1, name ); lastItem = item; // // Experimental work by Tim - add this item to our list model // QStandardItem * mypDetailItem = new QStandardItem( name ); mypDetailItem->setData( name, Qt::UserRole + 1 ); //for calling runModule later QString mySearchText = name + " - " + label; mypDetailItem->setData( mySearchText, Qt::UserRole + 2 ); //for filtering later mypDetailItem->setData( pixmap, Qt::DecorationRole ); mypDetailItem->setCheckable( false ); mypDetailItem->setEditable( false ); // setData in the delegate with a variantised QgsDetailedItemData QgsDetailedItemData myData; myData.setTitle( name ); myData.setDetail( label ); myData.setIcon( pixmap ); myData.setCheckable( false ); myData.setRenderAsWidget( true ); QVariant myVariant = qVariantFromValue( myData ); mypDetailItem->setData( myVariant, Qt::UserRole ); mModelTools->appendRow( mypDetailItem ); // // End of experimental work by Tim // } } n = n.nextSibling(); } }
void XMLParseBase::ParseChildren(const QString &filename, QDomElement &element, MythUIType *parent, bool showWarnings) { if (!parent) { LOG(VB_GENERAL, LOG_ERR, LOC + "Parent is NULL"); return; } QMap<QString, QString> dependsMap; for (QDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) { QDomElement info = child.toElement(); if (!info.isNull()) { QString type = info.tagName(); if (parent->ParseElement(filename, info, showWarnings)) { } else if (type == "font" || type == "fontdef") { bool global = (GetGlobalObjectStore() == parent); MythFontProperties *font = MythFontProperties::ParseFromXml( filename, info, parent, global, showWarnings); if (!global && font) { QString name = info.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 == "clock" || type == "progressbar" || type == "scrollbar" || type == "webbrowser" || type == "guidegrid" || type == "shape" || type == "editbar" || type == "video") { ParseUIType(filename, info, type, parent, NULL, showWarnings, dependsMap); } else { VERBOSE_XML(VB_GENERAL, LOG_ERR, filename, info, "Unknown widget type"); } } } parent->SetDependsMap(dependsMap); parent->ConnectDependants(true); parent->Finalize(); }
QgsSymbolLayerV2* QgsMarkerLineSymbolLayerV2::createFromSld( QDomElement &element ) { QgsDebugMsg( "Entered." ); QDomElement strokeElem = element.firstChildElement( "Stroke" ); if ( strokeElem.isNull() ) return NULL; QDomElement graphicStrokeElem = strokeElem.firstChildElement( "GraphicStroke" ); if ( graphicStrokeElem.isNull() ) return NULL; // retrieve vendor options bool rotateMarker = true; Placement placement = Interval; QgsStringMap vendorOptions = QgsSymbolLayerV2Utils::getVendorOptionList( element ); for ( QgsStringMap::iterator it = vendorOptions.begin(); it != vendorOptions.end(); ++it ) { if ( it.key() == "placement" ) { if ( it.value() == "points" ) placement = Vertex; else if ( it.value() == "firstPoint" ) placement = FirstVertex; else if ( it.value() == "lastPoint" ) placement = LastVertex; else if ( it.value() == "centralPoint" ) placement = CentralPoint; } else if ( it.value() == "rotateMarker" ) { rotateMarker = it.value() == "0"; } } QgsMarkerSymbolV2 *marker = 0; QgsSymbolLayerV2 *l = QgsSymbolLayerV2Utils::createMarkerLayerFromSld( graphicStrokeElem ); if ( l ) { QgsSymbolLayerV2List layers; layers.append( l ); marker = new QgsMarkerSymbolV2( layers ); } if ( !marker ) return NULL; double interval = 0.0; QDomElement gapElem = graphicStrokeElem.firstChildElement( "Gap" ); if ( !gapElem.isNull() ) { bool ok; double d = gapElem.firstChild().nodeValue().toDouble( &ok ); if ( ok ) interval = d; } double offset = 0.0; QDomElement perpOffsetElem = graphicStrokeElem.firstChildElement( "PerpendicularOffset" ); if ( !perpOffsetElem.isNull() ) { bool ok; double d = perpOffsetElem.firstChild().nodeValue().toDouble( &ok ); if ( ok ) offset = d; } QgsMarkerLineSymbolLayerV2* x = new QgsMarkerLineSymbolLayerV2( rotateMarker ); x->setPlacement( placement ); x->setInterval( interval ); x->setSubSymbol( marker ); x->setOffset( offset ); return x; }
//Lecture des paragraphes bool OpenDocument::contenu_paragraphe(QDomElement e, QTextCursor &curseur, bool puces, bool h_item, bool tableau){ ErrorManager instance_erreur; p_current++; case_tableau = ""; //On change la QProgressBar //chargement-> QString nom_style = e.attribute("text:style-name", "default"); QTextCharFormat format = cree_bloc_format(nom_style); //On récupère le format de bloc QTextBlockFormat format_bloc = cree_bloc_format2(nom_style); //On ajoute un marginTop de 5 pour plus de lisibilité format_bloc.setTopMargin(2); //Style spécifique aux puces if(puces || h_item){ int id_style = -1; for(int i=0; i<styles.size(); i++){ //On parcourt les styles if(id_style >= 0){ break; } for(int j=0; j<styles.at(i).size(); j++){ //On rentre dans le QMultiMap if(puces){ if(styles.at(i).value("style-puces") == nom_style){ id_style = i; //On sort de la boucle break; } } else{ //Ce ne peut être que le "h_item" sinon la boucle ne se déclencherait pas if(styles.at(i).value("style-h") == nom_style){ id_style = i; //On se casse break; } } } } if(id_style != -1){ //On merge le style format.merge(cree_bloc_format(styles.at(id_style).value("style-puces"))); } } //On applique le format au curseur curseur.setCharFormat(format); if(!tableau){ curseur.beginEditBlock(); } curseur.setBlockCharFormat(format); curseur.setBlockFormat(format_bloc); if(puces){ contenu_puce.append("<li>"); //On vérifie la taille int taille = format.fontPointSize(); if(taille == 0){ //Il y a eu un bug lors de la sélection du style, on applique la taille par défaut format.setFontPointSize(12); } } //Maintenant on lit les <span> QDomNode enfants = e.firstChild(); while(!enfants.isNull()){ if(enfants.isElement()){ QDomElement type = enfants.toElement(); //On parcours le type d'élément if(type.tagName() == "text:span"){ traite_span(format, curseur, type, puces, tableau); } else if(type.tagName() == "text:a"){ //Il s'agit d'un lien traite_lien(curseur, type, format); } else if(type.tagName() == "text:line-break"){ } else if(type.tagName() == "text:s"){ curseur.insertText(QString(" ")); } else if(type.tagName() == "text:tab"){ curseur.insertText(QString(" ")); } else if(type.tagName() == "draw:frame"){ QDomNode enfants_image = type.firstChild(); QString style_image = type.attribute("draw:style-name"); if(enfants_image.toElement().tagName() == "draw:image"){ if(!traite_image(curseur, enfants_image.toElement(), style_image)){ instance_erreur.Erreur_msg(tr("ODT : Erreur lors de la lecture des images (return false)"), QMessageBox::Ignore); } } } else if(type.tagName() == "text:list"){ if(!contenu_puces(type, curseur)){ instance_erreur.Erreur_msg(tr("ODT : Une erreur est survenue lors de la lecture d'une liste à puces; elle ne sera pas affichée"), QMessageBox::Warning); } else{ QTextCursor curseur(document); curseur.movePosition(QTextCursor::End); curseur.movePosition(QTextCursor::PreviousBlock); curseur.insertHtml(contenu_puce); contenu_puce = ""; } } else if(type.tagName() == "text:soft-page-break"){ } else{ instance_erreur.Erreur_msg(tr("ODT: Type de contenu non supporté : %1").arg(type.tagName()), QMessageBox::Ignore); } } else if(enfants.isText()){ //On gére le texte if(!puces && !tableau){ curseur.insertText(enfants.nodeValue(), format); } else if(tableau){ case_tableau.append(enfants.nodeValue()); } else{ //Insertion du contenu des puces si on est dans un "p" //On récupère le style par défaut QTextDocument *temp = new QTextDocument; QTextCursor curseur(temp); curseur.insertText(enfants.nodeValue(), format); contenu_puce.append(nettoye_code(temp->toHtml())); delete temp; } } else{ instance_erreur.Erreur_msg(tr("ODT : type de données non supporté"), QMessageBox::Ignore); } enfants = enfants.nextSibling(); } //On a fini la boucle OU il n'y avait pas de <span> //On récupère le contenu if(!puces && !tableau){ curseur.insertText("\n"); } if(puces){ contenu_puce.append("</li>"); } if(!tableau){ curseur.endEditBlock(); } if(tableau){ ligne_tableau.append(case_tableau); } //std::cout << e.text().toStdString() << std::endl; return true; }
void FrmInformacionFarmaco::finishedSlotBuscarMedicamento(QNetworkReply* reply) { //qDebug()<<reply->readAll(); QString data=(QString)reply->readAll(); QString cXML = data; // Extract values from XML QDomDocument document("XmlDoc"); document.setContent(cXML); QDomElement root = document.documentElement(); if (root .tagName() != "object") qDebug("Bad root element."); QDomNode drugList = root.firstChild(); QDomNode n = drugList.firstChild(); QDomNode n2 = n.firstChild(); QDomNode n3 = n2.firstChild(); while (!n.isNull()) { if (n.isElement()) { QDomNodeList attributes = n.childNodes(); for (int i = 0; i < attributes.count(); i ++) { QDomElement e = attributes.at(i).toElement(); if (e.tagName() == "name_speciality") { ui->txtNombre->setText(e.text()); } if (e.tagName() == "dosage_form") { ui->txtDosificacion->setText(e.text()); } if (e.tagName() == "national_code") { ui->txtcodigo_nacional->setText(e.text()); } if (e.tagName() == "name_laboratory") { ui->txtLaboratorio->setText(e.text()); } if (e.tagName() == "name_atc") { ui->txtNombreATC->setText(e.text()); } if (e.tagName() == "drug_type") { ui->txtTipoMedicamento->setText(e.text()); } if (e.tagName() == "package") { ui->txtCaja->setText(e.text()); } if (e.tagName() == "price") { ui->txtPVP->setText(e.text()); } if (e.tagName() == "laboratory_price") { ui->txtPVC->setText(e.text()); } if (e.tagName() == "TLD") { ui->txtTLD->setText(e.text()); } if (e.tagName() == "RECETA") { ui->txtReceta->setText(e.text()); } if (e.tagName() == "FINAN") { ui->txtFinanciado->setText(e.text()); } if (e.tagName() == "fecha_alta") { QDate alta; int ano,mes,dia; ano = e.text().left(4).toInt(); mes = e.text().mid(5,2).toInt(); dia = e.text().mid(8,2).toInt(); alta.setDate(ano,mes,dia); ui->txtfecha_alta->setDate(alta); } if (e.tagName() == "fecha_baja") { if (e.text()!="0" && !e.text().isEmpty()) { QDate baja; int ano,mes,dia; ano = e.text().left(4).toInt(); mes = e.text().mid(5,2).toInt(); dia = e.text().mid(8,2).toInt(); baja.setDate(ano,mes,dia); ui->txtFechaBaja->setVisible(true); ui->lblfechabaja->setVisible(true); ui->txtFechaBaja->setDate(baja); } else { ui->txtFechaBaja->setVisible(false); ui->lblfechabaja->setVisible(false); } } if (e.tagName() == "baja") { if(e.text()=="1") ui->lblDadodeBaja->setVisible(true); else ui->lblDadodeBaja->setVisible(false); } if (e.tagName() == "id_laboratory") { QUrl uUrl; QString cUrl = "http://svadcf.es/documentos/image/fotos/laboratorio/"+e.text().trimmed()+".gif"; uUrl.setUrl(cUrl); ui->webLogoLaboratorio->load(uUrl); } if (e.tagName() == "id_speciality") { connect(ui->webimagen1,SIGNAL(loadFinished(bool)),this, SLOT(cargaFinalizada1(bool))); connect(ui->webimagen2,SIGNAL(loadFinished(bool)),this, SLOT(cargaFinalizada2(bool))); connect(ui->webimagen3,SIGNAL(loadFinished(bool)),this, SLOT(cargaFinalizada3(bool))); connect(ui->webLogoLaboratorio,SIGNAL(loadFinished(bool)),this, SLOT(cargaFinalizadaLogo(bool))); QUrl uUrl; QString cUrl = "http://svadcf.es/documentos/image/fotos/medicamento/"+e.text().trimmed()+"_1.jpg"; uUrl.setUrl(cUrl); ui->webimagen1->load(uUrl); cUrl = "http://svadcf.es/documentos/image/fotos/medicamento/"+e.text().trimmed()+"_2.jpg"; uUrl.setUrl(cUrl); ui->webimagen2->load(uUrl); cUrl = "http://svadcf.es/documentos/image/fotos/medicamento/"+e.text().trimmed()+"_3.jpg"; uUrl.setUrl(cUrl); ui->webimagen3->load(uUrl); } //---------------------------- // Llenar tabla indicaciones //---------------------------- if (e.tagName() == "Indications_set") { ui->listaIndicaciones->setColumnCount(2); ui->listaIndicaciones->setColumnWidth(0,200); ui->listaIndicaciones->setColumnWidth(1,0); int nrow = 0; int pos = 0; while (!n2.isNull()) { if (n2.isElement()) { QDomNodeList attributes = n2.childNodes(); for (int i = 0; i < attributes.count(); i ++) { QDomElement e2 = attributes.at(i).toElement(); if (e2.tagName() == "") while (!n3.isNull()) { if (n3.isElement()) { QDomNodeList attributes = n3.childNodes(); for (int i = 0; i < attributes.count(); i ++) { QDomElement e3 = attributes.at(i).toElement(); if (e3.tagName() == "id_IND") { ui->listaIndicaciones->setRowCount(pos+1); QTableWidgetItem *newItem = new QTableWidgetItem(e3.text()); // para que los elementos no sean editables newItem->setFlags(newItem->flags() & (~Qt::ItemIsEditable)); newItem->setTextColor(Qt::blue); // color de los items ui->listaIndicaciones->setItem(pos,1,newItem); } if (e3.tagName() == "TITINDMIN") { ui->listaIndicaciones->setRowCount(pos+1); QTableWidgetItem *newItem = new QTableWidgetItem(e3.text()); // para que los elementos no sean editables newItem->setFlags(newItem->flags() & (~Qt::ItemIsEditable)); newItem->setTextColor(Qt::blue); // color de los items ui->listaIndicaciones->setItem(pos,0,newItem); } } pos++; //data.append(s); } n3 = n3.nextSibling(); } } n2 = n2.nextSibling(); } } } } n = n.nextSibling(); }
//Lecture des tableaux bool OpenDocument::contenu_tableaux(QDomElement e, QTextCursor &curseur){ //Création de l'instance d'erreur ErrorManager instance_erreur; QList<QStringList> full_table; QDomNode enfants = e.firstChild(); while(!enfants.isNull()){ if(enfants.isElement()){ QDomElement type = enfants.toElement(); //On parcours le type d'élément //Table-column ne sert à rien. L'important, c'est table-row et table-cell /*if(type.tagName() == "table:table-column"){//Tout roule QDomNode ligne = type.firstChildElement("table:table-row"); QDomElement elem_ligne = ligne.toElement(); QMessageBox::critical(0, "t", elem_ligne.tagName()); if(elem_ligne.tagName() == "table:table-row"){ QMessageBox::information(0, "t", "On z'y est!"); } //QMessageBox::information(0, "col", "<col></col>"); }*/ if(type.tagName() == "table:table-row"){ if(!type.hasChildNodes()){ instance_erreur.Erreur_msg(tr("ODT : aucune cellule détectée dans le tableau"), QMessageBox::Ignore); return false; } //NADA else{ //Si on a trouvé du contenu QDomNode node_cell = type.firstChildElement("table:table-cell"); while(!node_cell.isNull()){ //Normalement, ce sont de simples paragraphes, donc on les envoie à la fonction de lecture des paragraphes contenu_paragraphe(node_cell.firstChild().toElement(), curseur, false, false, true); node_cell = node_cell.nextSibling(); } //Si on est ici, c'est qu'on a fini de lire la ligne du tableau -> on l'insère dans la QList full_table.append(ligne_tableau); //On vide la QStringList ligne_tableau.clear(); } } } //On passe au suivant (sinon, boucle infinie, ouille!) enfants = enfants.nextSibling(); } //Si on est ici, c'est que le tableau est rempli. //On le fourgue dans le curseur et hop, à l'affichage //HA! Ça a marché du premier coup!!! Je m'améliore :D //On insère le tableau en HTML comme ça on gère en même temps les anomalies de cases (cases soudées/divisées) QString mon_tableau = "<table border=\"1\">"; for(int i=0; i<full_table.size(); i++){ mon_tableau.append("<tr>"); for(int j=0; j<full_table.at(i).size(); j++){ mon_tableau.append("<td>"); mon_tableau.append(full_table.at(i).at(j)); mon_tableau.append("</td>"); } mon_tableau.append("</tr>"); } //On ferme le tableau et on l'insère mon_tableau.append("</table>"); curseur.insertHtml(mon_tableau); return true; }
BCLCost::BCLCost(const QDomElement& costElement) { QDomElement instanceNameElement = costElement.firstChildElement("instance_name"); QDomElement costTypeElement = costElement.firstChildElement("cost_type"); QDomElement categoryElement = costElement.firstChildElement("category"); QDomElement valueElement = costElement.firstChildElement("value"); QDomElement unitsElement = costElement.firstChildElement("units"); QDomElement intervalElement = costElement.firstChildElement("interval"); QDomElement intervalUnitsElement = costElement.firstChildElement("interval_units"); QDomElement yearElement = costElement.firstChildElement("year"); QDomElement locationElement = costElement.firstChildElement("location"); QDomElement currencyElement = costElement.firstChildElement("currency"); QDomElement sourceElement = costElement.firstChildElement("source"); QDomElement referenceComponentNameElement = costElement.firstChildElement("reference_component_name"); QDomElement referenceComponentIdElement = costElement.firstChildElement("reference_component_id"); m_instanceName = instanceNameElement.firstChild().nodeValue().toStdString(); m_costType = costTypeElement.firstChild().nodeValue().toStdString(); m_category = categoryElement.firstChild().nodeValue().toStdString(); m_value = valueElement.firstChild().nodeValue().toDouble(); if (!unitsElement.isNull()){ m_units = unitsElement.firstChild().nodeValue().toStdString(); } if (!intervalElement.isNull()){ m_interval = intervalElement.firstChild().nodeValue().toStdString(); } if (!intervalUnitsElement.isNull()){ m_intervalUnits = intervalUnitsElement.firstChild().nodeValue().toStdString(); } if (!yearElement.isNull()){ m_year = yearElement.firstChild().nodeValue().toUInt(); }else{ m_year = 0; } if (!locationElement.isNull()){ m_location = locationElement.firstChild().nodeValue().toStdString(); } if (!currencyElement.isNull()){ m_currency = currencyElement.firstChild().nodeValue().toStdString(); } if (!sourceElement.isNull()){ m_source = sourceElement.firstChild().nodeValue().toStdString(); } if (!referenceComponentNameElement.isNull()){ m_referenceComponentName = referenceComponentNameElement.firstChild().nodeValue().toStdString(); } if (!referenceComponentIdElement.isNull()){ m_referenceComponentId = referenceComponentIdElement.firstChild().nodeValue().toStdString(); } }
void QLCPhysical_Test::save() { QDomDocument doc; QDomElement root = doc.createElement("Test Root"); bool bulb = false, dim = false, lens = false, focus = false, technical = false; QVERIFY(p.saveXML(&doc, &root) == true); QVERIFY(root.firstChild().toElement().tagName() == "Physical"); QDomNode node = root.firstChild().firstChild(); while (node.isNull() == false) { QDomElement e = node.toElement(); if (e.tagName() == "Bulb") { bulb = true; QVERIFY(e.attribute("Type") == "LED"); QVERIFY(e.attribute("Lumens") == "18000"); QVERIFY(e.attribute("ColourTemperature") == "6500"); } else if (e.tagName() == "Dimensions") { dim = true; QVERIFY(e.attribute("Width") == "530"); QVERIFY(e.attribute("Depth") == "260"); QVERIFY(e.attribute("Height") == "320"); QVERIFY(e.attribute("Weight") == "39"); } else if (e.tagName() == "Lens") { lens = true; QVERIFY(e.attribute("Name") == "Fresnel"); QVERIFY(e.attribute("DegreesMin") == "8"); QVERIFY(e.attribute("DegreesMax") == "38"); } else if (e.tagName() == "Focus") { focus = true; QVERIFY(e.attribute("Type") == "Head"); QVERIFY(e.attribute("PanMax") == "520"); QVERIFY(e.attribute("TiltMax") == "270"); } else if (e.tagName() == "Technical") { technical = true; QVERIFY(e.attribute("PowerConsumption") == "250"); QVERIFY(e.attribute("DmxConnector") == "5-pin"); } else { QFAIL(QString("Unexpected tag: %1").arg(e.tagName()) .toAscii()); } node = node.nextSibling(); } QVERIFY(bulb == true); QVERIFY(dim == true); QVERIFY(lens == true); QVERIFY(focus == true); QVERIFY(technical == true); }
void ClsQHarborImpl::loadConfig(string strConfigName) { #ifdef DEBUG_CLSQHARBORIMPL cout << "ClsQHarborImpl::loadConfig(string strConfigName)" << endl; #endif if(strConfigName.length()>0) { QFile qfile( strConfigName ); if ( !qfile.open( IO_ReadOnly ) ) { QMessageBox::critical( 0, tr( "Critical Error" ), tr( "Cannot open file %1" ).arg( strConfigName ) ); return; } QDomDocument domTree; if ( !domTree.setContent( &qfile ) ) { QMessageBox::critical( 0, tr( "Critical Error" ), tr( "Parsing error for file %1" ).arg( strConfigName ) ); qfile.close(); return; } qfile.close(); // clearTable(); // get the header information from the DOM QDomElement root = domTree.documentElement(); QDomNode node; node = root.firstChild(); /* ParamTrade */ while ( !node.isNull() ) { string strItemType = node.toElement().attribute("itemType"); string strItemID = node.toElement().attribute("itemID"); string strSubItemName = node.toElement().attribute("itemChild"); string strParamName = node.toElement().attribute("ParamName"); string strParamLabel = node.toElement().attribute("ParamLabel"); string strItemName = ""; ClsItem* clsItemTemp = NULL; if(!strItemType.compare("Group")) { clsItemTemp = ClsFESystemManager::Instance()->getFEGroup( strItemID ); if(clsItemTemp!=NULL) { strItemName = dynamic_cast<ClsFEGroup*>(clsItemTemp)->getGroupName(); } } else if(!strItemType.compare("Connection")) { clsItemTemp = ClsFESystemManager::Instance()->getFEConnection( strItemID ); if(clsItemTemp!=NULL) { strItemName = dynamic_cast<ClsFEConnection*>(clsItemTemp)->getConnectionName(); } } qtableEntries->insertRows(0,1); qtableEntries->setText(0, COL_ID, strItemID); qtableEntries->setText(0, COL_TYPE, strItemType); qtableEntries->setText(0, COL_CHILD, strSubItemName); if(clsItemTemp!=NULL) { qtableEntries->setText(0, COL_NAME, strItemName); qtableEntries->setText(0, COL_PARAM_LABEL, strParamLabel); qtableEntries->setText(0, COL_PARAM_NAME, strParamName); fillMinMaxValueField(clsItemTemp, strParamName, 0); } node = node.nextSibling(); } for(int ii = 0; ii<qtableEntries->numCols(); ii++) { qtableEntries->adjustColumn(ii); } } }