本文整理汇总了C++中QDomNodeList::item方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNodeList::item方法的具体用法?C++ QDomNodeList::item怎么用?C++ QDomNodeList::item使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNodeList
的用法示例。
在下文中一共展示了QDomNodeList::item方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
NetworkObject::loadNodeInfo(QDomNodeList nnodes)
{
m_vertexAttribute.clear();
m_vertexCenters.clear();
m_nodeId.clear();
QVector<float> *vat; // not expecting more than 20 attributes
int nvat = m_nodeAtt.count();
vat = new QVector<float> [nvat];
int nn = nnodes.count();
for(int n=0; n<nn; n++)
{
QDomElement ele = nnodes.item(n).toElement();
QString id = ele.attributeNode("id").value();
m_nodeId << id;
Vec pos;
QDomNodeList nlist = nnodes.item(n).childNodes();
int nc = nlist.count();
for(int c=0; c<nc; c++)
{
QDomNode node = nlist.item(c);
QDomElement ele = node.toElement();
QString et = ele.text();
QDomNamedNodeMap attr = ele.attributes();
QString name = attr.item(0).nodeName();
QString val = attr.item(0).nodeValue();
if (val == "x") pos.x = et.toFloat();
else if (val == "y") pos.y = et.toFloat();
else if (val == "z") pos.z = et.toFloat();
else
{
int vi = m_nodeAtt.indexOf(val);
if (vi >= 0)
vat[vi] << et.toFloat();
}
}
m_vertexCenters << pos;
int nv = m_vertexCenters.count();
for(int c=0; c<m_nodeAtt.count(); c++)
{
if (vat[c].count() < nv)
vat[c] << 0.0;
}
}
for(int e=0; e<m_nodeAtt.count(); e++)
{
if (m_nodeAtt[e].contains("diameter", Qt::CaseInsensitive))
{
for(int vi=0; vi<vat[e].count(); vi++)
vat[e][vi] /= 2;
}
}
for(int vi=0; vi<m_nodeAtt.count(); vi++)
m_vertexAttribute << qMakePair(m_nodeAtt[vi], vat[vi]);
if (m_vertexRadiusAttribute == -1)
{
m_vertexRadiusAttribute = m_nodeAtt.count();
QVector<float> rad;
rad.resize(m_vertexCenters.count());
rad.fill(2);
m_nodeAtt << "vertex_radius";
m_vertexAttribute << qMakePair(QString("vertex_radius"), rad);
}
for(int i=0; i<nvat; i++)
vat[i].clear();
delete [] vat;
}
示例2: setDocument
bool ParameterEdit::setDocument(const QDomDocument & doc)
{
QDomElement root = doc.documentElement();
if(root.tagName() != "report")
{
QMessageBox::critical(this, tr("Not a Valid Report"),
tr("The report definition does not appear to be a valid report."
"\n\nThe root node is not 'report'."));
return false;
}
_list->show();
_new->hide();
_delete->hide();
for(QDomNode n = root.firstChild(); !n.isNull(); n = n.nextSibling())
{
if(n.nodeName() == "parameter")
{
QDomElement elemSource = n.toElement();
ORParameter param;
param.name = elemSource.attribute("name");
if(param.name.isEmpty())
continue;
param.type = elemSource.attribute("type");
param.defaultValue = elemSource.attribute("default");
param.active = (elemSource.attribute("active") == "true");
param.listtype = elemSource.attribute("listtype");
QList<QPair<QString,QString> > pairs;
if(param.listtype.isEmpty())
param.description = elemSource.text();
else
{
QDomNodeList section = elemSource.childNodes();
for(int nodeCounter = 0; nodeCounter < section.count(); nodeCounter++)
{
QDomElement elemThis = section.item(nodeCounter).toElement();
if(elemThis.tagName() == "description")
param.description = elemThis.text();
else if(elemThis.tagName() == "query")
param.query = elemThis.text();
else if(elemThis.tagName() == "item")
param.values.append(qMakePair(elemThis.attribute("value"), elemThis.text()));
else
qDebug("While parsing parameter encountered an unknown element: %s",(const char*)elemThis.tagName().toLatin1().data());
}
}
QVariant defaultVar;
if(!param.defaultValue.isEmpty())
defaultVar = QVariant(param.defaultValue);
if("integer" == param.type)
defaultVar = defaultVar.toInt();
else if("double" == param.type)
defaultVar = defaultVar.toDouble();
else if("bool" == param.type)
defaultVar = QVariant(defaultVar.toBool());
else
defaultVar = defaultVar.toString();
updateParam(param.name, defaultVar, param.active);
QList<QPair<QString, QString> > list;
if("static" == param.listtype)
list = param.values;
else if("dynamic" == param.listtype && !param.query.isEmpty())
{
QSqlQuery qry(param.query);
while(qry.next())
list.append(qMakePair(qry.value(0).toString(), qry.value(1).toString()));
}
if(!list.isEmpty())
_lists.insert(param.name, list);
}
}
if(_lists.isEmpty())
return false; // no defined parameters
else
return true;
}
示例3: if
SimpleParameterEdit::SimpleParameterEdit(SimpleParameter::Type _type,
Miro::CFG::Parameter const& _parameter,
QDomNode& _parentNode,
QDomNode& _node,
ItemXML * _parentItem,
ItemXML * _item,
QWidget * _parent,
const char * _name) :
Super(_parameter, _parentNode, _node,
_parentItem, _item,
_parent, _name),
config_(ConfigFile::instance()),
type_(_type),
lineEdit_(NULL),
textEdit_(NULL),
typeBox_(NULL),
listBox_(NULL),
typeBoxModified_(false),
listBoxModified_(false)
{
if (parameter_.type_ == "Miro::Enumeration" ||
parameter_.type_ == "Enumeration") {
typeBox_ = new QComboBox(_parent, "type_box");
editWidget_ = typeBox_;
} else if (parameter_.type_ == "Miro::EnumerationMultiple" ||
parameter_.type_ == "EnumerationMultiple") {
listBox_ = new Q3ListBox(_parent, "list_box");
editWidget_ = listBox_;
} else if (parameter_.type_ == "Miro::Text" ||
parameter_.type_ == "Text") {
textEdit_ = new QTextEdit(_parent, "text_edit");
textEdit_->setAcceptRichText(false);
textEdit_->setAutoFormatting(false);
editWidget_ = textEdit_;
} else {
lineEdit_ = new QLineEdit(_parent, "line_edit");
editWidget_ = lineEdit_;
}
assert(!parentNode_.isNull());
if (lineEdit_ != NULL) {
// customize lineEdit for typesafe editing
QValidator * v = NULL;
switch (_type) {
case SimpleParameter::BOOL:
v = new MyBoolValidator(this);
lineEdit_->setValidator(v);
break;
case SimpleParameter::CHAR:
lineEdit_->setMaxLength(1);
break;
case SimpleParameter::SHORT:
v = new MyIntValidator(SHRT_MIN, SHRT_MAX, this);
lineEdit_->setValidator(v);
break;
case SimpleParameter::USHORT:
v = new MyIntValidator(0, USHRT_MAX, this);
lineEdit_->setValidator(v);
break;
case SimpleParameter::INT:
v = new MyIntValidator(INT_MIN + 1, INT_MAX - 1, this);
lineEdit_->setValidator(v);
break;
case SimpleParameter::UINT:
v = new MyIntValidator(0, INT_MAX - 1, this);
lineEdit_->setValidator(v);
break;
case SimpleParameter::LONG:
v = new MyIntValidator(INT_MIN + 1, INT_MAX - 1, this);
lineEdit_->setValidator(v);
break;
case SimpleParameter::ULONG:
v = new MyIntValidator(0, INT_MAX - 1, this);
lineEdit_->setValidator(v);
break;
case SimpleParameter::FLOAT:
v = new MyFloatValidator(this);
lineEdit_->setValidator(v);
break;
case SimpleParameter::DOUBLE:
v = new MyDoubleValidator(this);
lineEdit_->setValidator(v);
break;
case SimpleParameter::ANGLE:
v = new MyDoubleValidator(this);
lineEdit_->setValidator(v);
break;
case SimpleParameter::MIRO_ANGLE:
v = new MyDoubleValidator(-180., 180., 6, this);
lineEdit_->setValidator(v);
break;
case SimpleParameter::STRING:
break;
case SimpleParameter::ACE_TIME_VALUE:
v = new MyDoubleValidator(0, ULONG_MAX, 6, this);
lineEdit_->setValidator(v);
break;
case SimpleParameter::ACE_INET_ADDR:
break;
//.........这里部分代码省略.........
示例4: elementToVariant
//.........这里部分代码省略.........
v = QVariant(f);
ok = true;
}
else if (e.tagName() == "sizepolicy")
{
QSizePolicy sp;
if (e.hasAttribute("hsizetype"))
sp.setHorData((QSizePolicy::SizeType)e.attribute("hsizetype").toInt());
if (e.hasAttribute("vsizetype"))
sp.setVerData((QSizePolicy::SizeType)e.attribute("vsizetype").toInt());
if (e.hasAttribute("horstretch"))
sp.setHorStretch(e.attribute("horstretch").toInt());
if (e.hasAttribute("verstretch"))
sp.setHorStretch(e.attribute("verstretch").toInt());
v = QVariant(sp);
ok = true;
}
else if (e.tagName() == "cursor")
{
if (e.hasAttribute("shape")) {
v = QVariant(QCursor((Qt::CursorShape)e.attribute("shape").toInt(&ok, 10)));
} else
qWarning("%s element without value!", (const char*)e.tagName());
}
else if (e.tagName() == "stringlist")
{
QDomNodeList stringNodeList = e.elementsByTagName("string");
QStringList stringList;
QDomElement stringElement;
for (uint i = 0; i < stringNodeList.length(); i++)
{
stringElement = stringNodeList.item(i).toElement();
if (!stringElement.hasAttribute("value"))
{
qWarning("%s element in %s without value! Ignoring!",
(const char*)stringElement.tagName(),
(const char*)e.tagName());
continue;
}
stringList.append(e.attribute("value"));
}
v = stringList;
ok = true;
}
else if (e.tagName() == "uint64")
{
QString value = e.attribute("value");
// borrowed more or less from Qt 3.2 (since we have to support older)
uint64_t val = 0;
const QChar* p = value.unicode();
int l = value.length();
const uint64_t max_mult = 0x0fffffffffffffffull/* UINT64_MAX / 16 */;
if (!p)
{
qWarning("Invalid value for tag: %s", (const char*)e.tagName());
return false;
}
while ( l && p->isSpace() ) // skip leading space
示例5: finishTable
void KWDWriter::finishTable(int tableno, QRect rect)
{
int ncols = 0;
int nrows = 0;
insidetable = false;
int x = rect.x();
int y = rect.y();
int w = rect.width();
int h = rect.height();
QDomNodeList nl = docroot().elementsByTagName("FRAMESET");
//FIXME calculate nrows and stuff.
//and add empty cells for missing ones.
// first, see how big the table is (cols & rows)
for (int i = 0;i < nl.count();i++) {
QDomElement k = nl.item(i).toElement();
if (k.attribute("grpMgr") == QString("Table %1").arg(tableno)) {
ncols = MAX(ncols, k.attribute("col").toInt() + 1);
nrows = MAX(nrows, k.attribute("row").toInt() + 1);
}
}
int curcol = 0;
int currow = 0;
int currow_inc = 0;
if (ncols == 0) ncols = 1; // FIXME (floating point division by zero)
if (nrows == 0) nrows = 1;
int step_x = (w - x) / ncols;
int step_y = (h - y) / nrows;
// then, let's create the missing cells and resize them if needed.
bool must_resize = false;
if (x > 0) must_resize = true;
while (currow < nrows) {
curcol = 0;
while (curcol < ncols) {
QDomElement e = fetchTableCell(tableno, currow, curcol);
if (e.isNull()) {
// a missing cell !
kDebug(30503) << QString("creating %1 %2").arg(currow).arg(curcol).toLatin1();
createTableCell(tableno, currow, curcol, 1,
QRect(x + step_x*curcol, y + step_y*currow, step_x, step_y)
);
// fixme: what to do if we don't have to resize ?
}
// resize this one FIXME optimize this routine
if (must_resize == true) {
QDomElement ee = e.firstChild().toElement(); // the frame in the frameset
int cs = e.attribute("cols").toInt();
int rs = e.attribute("rows").toInt();
kDebug(30503) << "resizing";
addRect(ee, QRect(x + step_x*curcol, 0, step_x*cs, step_y*rs));
}
if (curcol == 0) currow_inc = e.attribute("rows").toInt();
curcol += e.attribute("cols").toInt();
}
currow += currow_inc;
}
}
示例6: imprimir
/**
\param periodo1finicial
\param periodo1ffinal
\param periodo2finicial
\param periodo2ffinal
**/
void BcCuentasAnualesImprimirView::imprimir ( QString periodo1finicial, QString periodo1ffinal, QString periodo2finicial, QString periodo2ffinal )
{
BL_FUNC_DEBUG
/// Copiamos el archivo.
QString archivo = g_confpr->value( CONF_DIR_OPENREPORTS ) + "canuales.rml";
QString archivod = g_confpr->value( CONF_DIR_USER ) + "canuales.rml";
blCopyFile(archivo, archivod);
/// Copiamos el logo.
QString archivologo = g_confpr->value( CONF_DIR_OPENREPORTS ) + "logo.jpg";
QString logousuario = g_confpr->value( CONF_DIR_USER ) + "logo.jpg";
blCopyFile(archivologo, logousuario);
QFile file;
file.setFileName ( archivod );
file.open ( QIODevice::ReadOnly );
QTextStream stream ( &file );
QString buff = stream.readAll();
file.close();
QString fitxersortidatxt;
fitxersortidatxt = "";
/// Iteramos para cada componente del listado.
QDomNodeList componentes = m_doc.elementsByTagName ( "COMPONENTE" );
for ( int j = 0; j < componentes.count(); j++ ) {
QDomElement comp = componentes.item ( j ).toElement();
/// Escribimos el titulo del componente
QString debeohaber = comp.namedItem ( "SUBTITULO" ).toElement().text();
fitxersortidatxt += "" + debeohaber + "\n";
/// Cogemos los elementos del componente y los ponemos en forma de tabla.
fitxersortidatxt += "<blockTable style=\"tabla\" repeatRows=\"1\" colWidths=\"12cm,3cm,3cm\">\n";
fitxersortidatxt += "<tr><td><para style=\"debeohaber\">" + debeohaber + "</para></td>\n";
fitxersortidatxt += "<td><para style=\"periodo\">Periodo:</para><para style=\"periodo\">" + periodo1finicial + " ~ " + periodo1ffinal + "</para></td>\n";
fitxersortidatxt += "<td><para style=\"periodo\">Periodo:</para><para style=\"periodo\">" + periodo2finicial + " ~ " + periodo2ffinal + "</para></td></tr>\n";
QDomNodeList litems = comp.elementsByTagName ( "LBALANCE" );
QLocale::setDefault ( QLocale ( QLocale::Spanish, QLocale::Spain ) );
QLocale spanish;
for ( int i = 0; i < litems.count(); i++ ) {
QDomNode item = litems.item ( i );
QDomElement e1 = item.toElement(); /// Try to convert the node to an element.
if ( !e1.isNull() ) { /// The node was really an element.
QDomNode formul = item.firstChildElement ( "FORMULA" );
QString vact = formul.firstChildElement ( "VALORACT" ).toElement().text();
vact = spanish.toString ( vact.toDouble(), 'f', 2 );
QString vant = formul.firstChildElement ( "VALORANT" ).toElement().text();
vant = spanish.toString ( vant.toDouble(), 'f', 2 );
QString texto = item.firstChildElement ( "CONCEPTO" ).toElement().text();
fitxersortidatxt += "<tr>\n";
fitxersortidatxt += "<td>" + texto + "</td>\n";
fitxersortidatxt += "<td>" + vact + "</td>\n";
fitxersortidatxt += "<td>" + vant + "</td>\n";
fitxersortidatxt += "</tr>\n";
} // end if
} // end for
QLocale::setDefault ( QLocale::C );
fitxersortidatxt += "</blockTable>\n";
fitxersortidatxt += "<nextFrame/>\n";
} // end for
buff.replace ( "[story]", fitxersortidatxt );
QDomElement nodo = m_doc.namedItem ( "BALANCE" ).namedItem ( "TITULO" ).toElement();
buff.replace ( "[titulo]", nodo.text() );
if ( file.open ( QIODevice::WriteOnly ) ) {
QTextStream stream ( &file );
stream << buff;
file.close();
} // end if
blCreateAndLoadPDF ( "canuales" );
}
示例7: parseReportSection
bool parseReportSection(const QDomElement & elemSource, ORSectionData & sectionTarget)
{
sectionTarget.name = elemSource.tagName();
if(sectionTarget.name != "rpthead" && sectionTarget.name != "rptfoot" &&
sectionTarget.name != "pghead" && sectionTarget.name != "pgfoot" &&
sectionTarget.name != "grouphead" && sectionTarget.name != "groupfoot" &&
sectionTarget.name != "head" && sectionTarget.name != "foot" &&
sectionTarget.name != "detail" )
return false;
sectionTarget.extra = QString::null;
sectionTarget.height = -1;
QDomNodeList section = elemSource.childNodes();
for(int nodeCounter = 0; nodeCounter < section.count(); nodeCounter++)
{
QDomElement elemThis = section.item(nodeCounter).toElement();
if(elemThis.tagName() == "height")
{
bool valid;
int height = elemThis.text().toInt(&valid);
if(valid)
sectionTarget.height = height;
}
else if(elemThis.tagName() == "firstpage") {
if(sectionTarget.name == "pghead" || sectionTarget.name == "pgfoot")
sectionTarget.extra = elemThis.tagName();
}
else if(elemThis.tagName() == "odd")
{
if(sectionTarget.name == "pghead" || sectionTarget.name == "pgfoot")
sectionTarget.extra = elemThis.tagName();
}
else if(elemThis.tagName() == "even")
{
if(sectionTarget.name == "pghead" || sectionTarget.name == "pgfoot")
sectionTarget.extra = elemThis.tagName();
}
else if(elemThis.tagName() == "lastpage")
{
if(sectionTarget.name == "pghead" || sectionTarget.name == "pgfoot")
sectionTarget.extra = elemThis.tagName();
}
else if(elemThis.tagName() == "label")
{
ORLabelData * label = new ORLabelData();
if(parseReportLabel(elemThis, *label) == TRUE)
sectionTarget.objects.append(label);
else
delete label;
}
else if(elemThis.tagName() == "field")
{
ORFieldData * field = new ORFieldData();
if(parseReportField(elemThis, *field) == TRUE)
{
sectionTarget.objects.append(field);
if(field->trackTotal)
sectionTarget.trackTotal.append(field->data);
}
else
delete field;
}
else if(elemThis.tagName() == "text")
{
ORTextData * text = new ORTextData();
if(parseReportText(elemThis, *text) == TRUE)
sectionTarget.objects.append(text);
else
delete text;
}
else if(elemThis.tagName() == "line")
{
ORLineData * line = new ORLineData();
if(parseReportLine(elemThis, *line) == TRUE)
sectionTarget.objects.append(line);
else
delete line;
}
else if(elemThis.tagName() == "barcode")
{
ORBarcodeData * bc = new ORBarcodeData();
if(parseReportBarcode(elemThis, *bc) == TRUE)
sectionTarget.objects.append(bc);
else
delete bc;
}
else if(elemThis.tagName() == "image")
{
ORImageData * img = new ORImageData();
if(parseReportImage(elemThis, *img) == TRUE)
sectionTarget.objects.append(img);
else
delete img;
}
else if(elemThis.tagName() == "graph")
{
ORGraphData * graph = new ORGraphData();
if(parseReportGraphData(elemThis, *graph) == TRUE)
//.........这里部分代码省略.........
示例8: loadRegions
void QgsGrassNewMapset::loadRegions()
{
QString path = QgsApplication::pkgDataPath() + "/grass/locations.gml";
QgsDebugMsg( QString( "load:%1" ).arg( path.toLocal8Bit().constData() ) );
QFile file( path );
if ( !file.exists() )
{
QgsGrass::warning( tr( "Regions file (%1) not found." ).arg( path ) );
return;
}
if ( ! file.open( QIODevice::ReadOnly ) )
{
QgsGrass::warning( tr( "Cannot open locations file (%1)" ).arg( path ) );
return;
}
QDomDocument doc( "gml:FeatureCollection" );
QString err;
int line, column;
if ( !doc.setContent( &file, &err, &line, &column ) )
{
QString errmsg = tr( "Cannot read locations file (%1):" ).arg( path )
+ tr( "\n%1\nat line %2 column %3" ).arg( err ).arg( line ).arg( column );
QgsDebugMsg( errmsg );
QgsGrass::warning( errmsg );
file.close();
return;
}
QDomElement docElem = doc.documentElement();
QDomNodeList nodes = docElem.elementsByTagName( "gml:featureMember" );
for ( int i = 0; i < nodes.count(); i++ )
{
QDomNode node = nodes.item( i );
if ( node.isNull() )
{
continue;
}
QDomElement elem = node.toElement();
QDomNodeList nameNodes = elem.elementsByTagName( "gml:name" );
if ( nameNodes.count() == 0 )
continue;
if ( nameNodes.item( 0 ).isNull() )
continue;
QDomElement nameElem = nameNodes.item( 0 ).toElement();
if ( nameElem.text().isNull() )
continue;
QDomNodeList envNodes = elem.elementsByTagName( "gml:Envelope" );
if ( envNodes.count() == 0 )
continue;
if ( envNodes.item( 0 ).isNull() )
continue;
QDomElement envElem = envNodes.item( 0 ).toElement();
QDomNodeList coorNodes = envElem.elementsByTagName( "gml:coordinates" );
if ( coorNodes.count() == 0 )
continue;
if ( coorNodes.item( 0 ).isNull() )
continue;
QDomElement coorElem = coorNodes.item( 0 ).toElement();
if ( coorElem.text().isNull() )
continue;
QStringList coor = coorElem.text().split( " ", QString::SkipEmptyParts );
if ( coor.size() != 2 )
{
QgsDebugMsg( QString( "Cannot parse coordinates: %1" ).arg( coorElem.text() ) );
continue;
}
QStringList ll = coor[0].split( ",", QString::SkipEmptyParts );
QStringList ur = coor[1].split( ",", QString::SkipEmptyParts );
if ( ll.size() != 2 || ur.size() != 2 )
{
QgsDebugMsg( QString( "Cannot parse coordinates: %1" ).arg( coorElem.text() ) );
continue;
}
// Add region
mRegionsComboBox->addItem( nameElem.text() );
QgsPoint llp( ll[0].toDouble(), ll[1].toDouble() );
mRegionsPoints.push_back( llp );
QgsPoint urp( ur[0].toDouble(), ur[1].toDouble() );
mRegionsPoints.push_back( urp );
}
mRegionsComboBox->setCurrentIndex( -1 );
file.close();
}
示例9: parseReportGraphData
bool parseReportGraphData(const QDomElement & elemSource, ORGraphData & graphTarget)
{
if(elemSource.tagName() != "graph")
return FALSE;
bool have_data = FALSE;
bool have_rect = FALSE;
bool have_series = FALSE;
graphTarget.title.string = QString::null;
graphTarget.dataaxis.title.string = QString::null;
graphTarget.dataaxis.title.font_defined = FALSE;
graphTarget.dataaxis.column = QString::null;
graphTarget.dataaxis.font_defined = FALSE;
graphTarget.valueaxis.title.string = QString::null;
graphTarget.valueaxis.min = 0;
graphTarget.valueaxis.max = 100;
graphTarget.valueaxis.autominmax = TRUE;
graphTarget.valueaxis.font_defined = FALSE;
graphTarget.series.setAutoDelete(TRUE);
QDomNodeList nlist = elemSource.childNodes();
for(int nodeCounter = 0; nodeCounter < nlist.count(); nodeCounter++)
{
QDomElement elemThis = nlist.item(nodeCounter).toElement();
if(elemThis.tagName() == "data")
have_data = parseReportData(elemThis, graphTarget.data);
else if(elemThis.tagName() == "font")
parseReportFont(elemThis, graphTarget.font);
else if(elemThis.tagName() == "rect")
have_rect = parseReportRect(elemThis, graphTarget.rect);
else if(elemThis.tagName() == "title")
parseReportTitleData(elemThis, graphTarget.title);
else if(elemThis.tagName() == "dataaxis")
{
if(!parseReportDataAxisData(elemThis, graphTarget.dataaxis))
{
graphTarget.dataaxis.title.string = QString::null;
graphTarget.dataaxis.title.font_defined = FALSE;
graphTarget.dataaxis.column = QString::null;
graphTarget.dataaxis.font_defined = FALSE;
}
}
else if(elemThis.tagName() == "valueaxis")
{
if(!parseReportValueAxisData(elemThis, graphTarget.valueaxis))
{
graphTarget.valueaxis.title.string = QString::null;
graphTarget.valueaxis.min = 0;
graphTarget.valueaxis.max = 100;
graphTarget.valueaxis.autominmax = TRUE;
graphTarget.valueaxis.font_defined = FALSE;
}
}
else if(elemThis.tagName() == "series")
{
ORSeriesData * orsd = new ORSeriesData();
if(parseReportSeriesData(elemThis, *orsd))
{
graphTarget.series.append(orsd);
have_series = TRUE;
}
else
delete orsd;
orsd = 0;
}
else
qDebug("While parsing graph encountered an unknown element: %s",(const char*)elemThis.tagName());
}
if(have_data && have_rect && have_series)
return TRUE;
return FALSE;
}
示例10: parseReportBackground
bool parseReportBackground(const QDomElement & elemSource, ORBackgroundData & bgTarget)
{
if(elemSource.tagName() != "background")
return FALSE;
bgTarget.enabled = false;
bgTarget.staticImage = true;
bgTarget.image = QString::null;
bgTarget.data.query = QString::null;
bgTarget.data.column = QString::null;
bgTarget.opacity = 25;
bgTarget.mode = "clip";
bgTarget.rect = QRect();
int halign = Qt::AlignLeft;
int valign = Qt::AlignTop;
bool valid_rect = true;
QDomNodeList nlist = elemSource.childNodes();
for(int nodeCounter = 0; nodeCounter < nlist.count(); nodeCounter++)
{
QDomElement elemThis = nlist.item(nodeCounter).toElement();
if(elemThis.tagName() == "image")
bgTarget.image = elemThis.text();
else if(elemThis.tagName() == "mode")
bgTarget.mode = elemThis.text();
else if(elemThis.tagName() == "data")
bgTarget.staticImage = !parseReportData(elemThis, bgTarget.data);
else if(elemThis.tagName() == "left")
halign = Qt::AlignLeft;
else if(elemThis.tagName() == "hcenter")
halign = Qt::AlignHCenter;
else if(elemThis.tagName() == "right")
halign = Qt::AlignRight;
else if(elemThis.tagName() == "top")
valign = Qt::AlignTop;
else if(elemThis.tagName() == "vcenter")
valign = Qt::AlignVCenter;
else if(elemThis.tagName() == "bottom")
valign = Qt::AlignBottom;
else if(elemThis.tagName() == "rect")
valid_rect = parseReportRect(elemThis, bgTarget.rect);
else if(elemThis.tagName() == "opacity")
{
bool valid = false;
int i = elemThis.text().toInt(&valid);
if(valid) {
if(i < 0)
i = 0;
if(i > 255)
i = 255;
bgTarget.opacity = i;
}
}
else
qDebug("While parsing background encountered an unknown element: %s",(const char*)elemThis.tagName());
}
bgTarget.align = halign | valign;
bgTarget.enabled = (valid_rect && ((bgTarget.staticImage && !bgTarget.image.isEmpty())
|| (!bgTarget.staticImage && !bgTarget.data.query.isEmpty()
&& !bgTarget.data.column.isEmpty())));
return bgTarget.enabled;
}
示例11: parseReport
bool parseReport(const QDomElement & elemSource, ORReportData & reportTarget)
{
if(elemSource.tagName() != "report")
{
qDebug("QDomElement passed to parseReport() was not <report> tag");
return FALSE;
}
double d = 0.0;
bool valid = FALSE;
QDomNodeList section = elemSource.childNodes();
for(int nodeCounter = 0; nodeCounter < section.count(); nodeCounter++)
{
QDomElement elemThis = section.item(nodeCounter).toElement();
if(elemThis.tagName() == "title")
reportTarget.title = elemThis.text();
else if(elemThis.tagName() == "name")
reportTarget.name = elemThis.text();
else if(elemThis.tagName() == "description")
reportTarget.description = elemThis.text();
else if(elemThis.tagName() == "parameter")
{
parseReportParameter(elemThis, reportTarget);
}
else if(elemThis.tagName() == "watermark")
parseReportWatermark(elemThis, reportTarget.wmData);
else if(elemThis.tagName() == "background")
parseReportBackground(elemThis, reportTarget.bgData);
else if(elemThis.tagName() == "size")
{
if(elemThis.firstChild().isText())
reportTarget.page.setPageSize(elemThis.firstChild().nodeValue());
else
{
//bad code! bad code!
// this code doesn't check the elemts and assums they are what
// they should be.
QDomNode n1 = elemThis.firstChild();
QDomNode n2 = n1.nextSibling();
if(n1.nodeName() == "width")
{
reportTarget.page.setCustomWidth(n1.firstChild().nodeValue().toDouble() / 100.0);
reportTarget.page.setCustomHeight(n2.firstChild().nodeValue().toDouble() / 100.0);
}
else
{
reportTarget.page.setCustomWidth(n2.firstChild().nodeValue().toDouble() / 100.0);
reportTarget.page.setCustomHeight(n1.firstChild().nodeValue().toDouble() / 100.0);
}
reportTarget.page.setPageSize("Custom");
}
}
else if(elemThis.tagName() == "labeltype")
reportTarget.page.setLabelType(elemThis.firstChild().nodeValue());
else if(elemThis.tagName() == "portrait")
reportTarget.page.setPortrait(TRUE);
else if(elemThis.tagName() == "landscape")
reportTarget.page.setPortrait(FALSE);
else if(elemThis.tagName() == "topmargin")
{
d = elemThis.text().toDouble(&valid);
if(!valid || d < 0.0)
{
qDebug("Error converting topmargin value: %s",(const char*)elemThis.text());
d = 50.0;
}
reportTarget.page.setMarginTop((d / 100.0));
}
else if(elemThis.tagName() == "bottommargin")
{
d = elemThis.text().toDouble(&valid);
if(!valid || d < 0.0)
{
qDebug("Error converting bottommargin value: %s",(const char*)elemThis.text());
d = 50.0;
}
reportTarget.page.setMarginBottom((d / 100.0));
}
else if(elemThis.tagName() == "leftmargin")
{
d = elemThis.text().toDouble(&valid);
if(!valid || d < 0.0)
{
qDebug("Error converting leftmargin value: %s",(const char*)elemThis.text());
d = 50.0;
}
reportTarget.page.setMarginLeft(d/100.0);
}
else if(elemThis.tagName() == "rightmargin")
{
d = elemThis.text().toDouble(&valid);
if(!valid || d < 0.0)
{
qDebug("Error converting rightmargin value: %s",(const char*)elemThis.text());
d = 50.0;
}
reportTarget.page.setMarginRight(d/100.0);
}
else if(elemThis.tagName() == "querysource")
//.........这里部分代码省略.........
示例12: parseReportDetailSection
bool parseReportDetailSection(const QDomElement & elemSource, ORDetailSectionData & sectionTarget)
{
if(elemSource.tagName() != "section")
return FALSE;
bool have_name = FALSE;
bool have_detail = FALSE;
bool have_key = FALSE;
ORSectionData * old_head = 0;
ORSectionData * old_foot = 0;
QDomNodeList section = elemSource.childNodes();
for(int nodeCounter = 0; nodeCounter < section.count(); nodeCounter++)
{
QDomElement elemThis = section.item(nodeCounter).toElement();
if(elemThis.tagName() == "name")
{
sectionTarget.name = elemThis.text();
have_name = TRUE;
}
else if(elemThis.tagName() == "pagebreak")
{
if(elemThis.attribute("when") == "at end")
sectionTarget.pagebreak = ORDetailSectionData::BreakAtEnd;
}
else if(elemThis.tagName() == "grouphead")
{
ORSectionData * sd = new ORSectionData();
if(parseReportSection(elemThis, *sd) == TRUE)
{
old_head = sd;
sectionTarget.trackTotal += sd->trackTotal;
}
else
delete sd;
}
else if(elemThis.tagName() == "groupfoot")
{
ORSectionData * sd = new ORSectionData();
if(parseReportSection(elemThis, *sd) == TRUE)
{
old_foot = sd;
sectionTarget.trackTotal += sd->trackTotal;
}
else
delete sd;
}
else if(elemThis.tagName() == "group")
{
QDomNodeList nl = elemThis.childNodes();
QDomNode node;
ORDetailGroupSectionData * dgsd = new ORDetailGroupSectionData();
for(int i = 0; i < nl.count(); i++)
{
node = nl.item(i);
if(node.nodeName() == "name")
dgsd->name = node.firstChild().nodeValue();
else if(node.nodeName() == "column")
dgsd->column = node.firstChild().nodeValue();
else if(node.nodeName() == "pagebreak")
{
QDomElement elemThis = node.toElement();
QString n = elemThis.attribute("when");
if("after foot" == n)
dgsd->pagebreak = ORDetailGroupSectionData::BreakAfterGroupFoot;
}
else if(node.nodeName() == "head")
{
ORSectionData * sd = new ORSectionData();
if(parseReportSection(node.toElement(), *sd) == TRUE)
{
dgsd->head = sd;
sectionTarget.trackTotal += sd->trackTotal;
for(Q3ValueListIterator<ORDataData> it = sd->trackTotal.begin(); it != sd->trackTotal.end(); ++it)
dgsd->_subtotCheckPoints[*it] = 0.0;
}
else
delete sd;
}
else if(node.nodeName() == "foot")
{
ORSectionData * sd = new ORSectionData();
if(parseReportSection(node.toElement(), *sd) == TRUE)
{
dgsd->foot = sd;
sectionTarget.trackTotal += sd->trackTotal;
for(Q3ValueListIterator<ORDataData> it = sd->trackTotal.begin(); it != sd->trackTotal.end(); ++it)
dgsd->_subtotCheckPoints[*it] = 0.0;
}
else
delete sd;
}
else
qDebug("While parsing group section encountered an unknown element: %s", node.nodeName().latin1());
}
sectionTarget.groupList.append(dgsd);
}
else if(elemThis.tagName() == "detail")
{
//.........这里部分代码省略.........
示例13: qMakePair
void
NetworkObject::loadEdgeInfo(QDomNodeList nnodes)
{
m_edgeAttribute.clear();
m_edgeNeighbours.clear();
QVector<float> *vat; // not expecting more than 20 attributes
int nvat = m_edgeAtt.count();
vat = new QVector<float> [nvat];
int nn = nnodes.count();
for(int n=0; n<nn; n++)
{
QDomElement ele = nnodes.item(n).toElement();
QString id = ele.attributeNode("id").value();
QString src = ele.attributeNode("source").value();
QString tar = ele.attributeNode("target").value();
int a,b;
a = m_nodeId.indexOf(src);
b = m_nodeId.indexOf(tar);
if (a >= 0 && b >= 0)
m_edgeNeighbours << qMakePair(a,b);
QDomNodeList nlist = nnodes.item(n).childNodes();
int nc = nlist.count();
for(int c=0; c<nc; c++)
{
QDomNode node = nlist.item(c);
QDomElement ele = node.toElement();
QString et = ele.text();
QDomNamedNodeMap attr = ele.attributes();
QString name = attr.item(0).nodeName();
QString val = attr.item(0).nodeValue();
int vi = m_edgeAtt.indexOf(val);
if (vi >= 0)
vat[vi] << et.toFloat();
}
int nv = m_edgeNeighbours.count();
for(int c=0; c<m_edgeAtt.count(); c++)
{
if (vat[c].count() < nv)
vat[c] << 0.0;
}
}
for(int e=0; e<m_edgeAtt.count(); e++)
{
if (m_edgeAtt[e].contains("diameter", Qt::CaseInsensitive))
{
for(int vi=0; vi<vat[e].count(); vi++)
vat[e][vi] /= 2;
}
}
for(int vi=0; vi<m_edgeAtt.count(); vi++)
m_edgeAttribute << qMakePair(m_edgeAtt[vi], vat[vi]);
if (m_edgeRadiusAttribute == -1)
{
m_edgeRadiusAttribute = m_edgeAtt.count();
QVector<float> rad;
rad.resize(m_edgeNeighbours.count());
rad.fill(2);
m_edgeAtt << "edge_radius";
m_edgeAttribute << qMakePair(QString("edge_radius"), rad);
}
for(int i=0; i<nvat; i++)
vat[i].clear();
delete [] vat;
}
示例14: loadDetailsFromXML
static bool loadDetailsFromXML(const QString &filename, FileDetails *details)
{
QDomDocument doc("mydocument");
QFile file(filename);
if (!file.open(QIODevice::ReadOnly))
return false;
if (!doc.setContent(&file))
{
file.close();
return false;
}
file.close();
QString docType = doc.doctype().name();
if (docType == "MYTHARCHIVEITEM")
{
QDomNodeList itemNodeList = doc.elementsByTagName("item");
QString type, dbVersion;
if (itemNodeList.count() < 1)
{
LOG(VB_GENERAL, LOG_ERR,
"Couldn't find an 'item' element in XML file");
return false;
}
QDomNode n = itemNodeList.item(0);
QDomElement e = n.toElement();
type = e.attribute("type");
dbVersion = e.attribute("databaseversion");
if (type == "recording")
{
QDomNodeList nodeList = e.elementsByTagName("recorded");
if (nodeList.count() < 1)
{
LOG(VB_GENERAL, LOG_ERR,
"Couldn't find a 'recorded' element in XML file");
return false;
}
n = nodeList.item(0);
e = n.toElement();
n = e.firstChild();
while (!n.isNull())
{
e = n.toElement();
if (!e.isNull())
{
if (e.tagName() == "title")
details->title = e.text();
if (e.tagName() == "subtitle")
details->subtitle = e.text();
if (e.tagName() == "starttime")
details->startTime = MythDate::fromString(e.text());
if (e.tagName() == "description")
details->description = e.text();
}
n = n.nextSibling();
}
// get channel info
n = itemNodeList.item(0);
e = n.toElement();
nodeList = e.elementsByTagName("channel");
if (nodeList.count() < 1)
{
LOG(VB_GENERAL, LOG_ERR,
"Couldn't find a 'channel' element in XML file");
details->chanID = "";
details->chanNo = "";
details->chanName = "";
details->callsign = "";
return false;
}
n = nodeList.item(0);
e = n.toElement();
details->chanID = e.attribute("chanid");
details->chanNo = e.attribute("channum");
details->chanName = e.attribute("name");
details->callsign = e.attribute("callsign");
return true;
}
else if (type == "video")
{
QDomNodeList nodeList = e.elementsByTagName("videometadata");
if (nodeList.count() < 1)
{
LOG(VB_GENERAL, LOG_ERR,
"Couldn't find a 'videometadata' element in XML file");
return false;
}
n = nodeList.item(0);
e = n.toElement();
//.........这里部分代码省略.........
示例15: getParameterNode
QDomNode drawInterface::getParameterNode(QString pname, QDomNode& node) {
if(node.isNull())
return node;
QDomNodeList n = node.toElement().elementsByTagName(pname);
return n.item(0);
}