本文整理汇总了C++中QDomNodeList::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomNodeList::isEmpty方法的具体用法?C++ QDomNodeList::isEmpty怎么用?C++ QDomNodeList::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomNodeList
的用法示例。
在下文中一共展示了QDomNodeList::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseBoundingBoxElement
int QgsSOAPRequestHandler::parseBoundingBoxElement( QMap<QString, QString>& parameterMap, const QDomElement& boundingBoxElement ) const
{
QString minx, miny, maxx, maxy;
//leftBound
QDomNodeList leftBoundList = boundingBoxElement.elementsByTagName( "leftBound" );
if ( !leftBoundList.isEmpty() )
{
minx = leftBoundList.item( 0 ).toElement().text();
}
//rightBound
QDomNodeList rightBoundList = boundingBoxElement.elementsByTagName( "rightBound" );
if ( !rightBoundList.isEmpty() )
{
maxx = rightBoundList.item( 0 ).toElement().text();
}
//lowerBound
QDomNodeList lowerBoundList = boundingBoxElement.elementsByTagName( "lowerBound" );
if ( !lowerBoundList.isEmpty() )
{
miny = lowerBoundList.item( 0 ).toElement().text();
}
//upperBound
QDomNodeList upperBoundList = boundingBoxElement.elementsByTagName( "upperBound" );
if ( !upperBoundList.isEmpty() )
{
maxy = upperBoundList.item( 0 ).toElement().text();
}
parameterMap.insert( "BBOX", minx + "," + miny + "," + maxx + "," + maxy );
return 0;
}
示例2: fromQDomElement
Event Event::fromQDomElement(const QDomElement& fr, const QString& srvcId, const QString& accountId, const QString& friendId)
{
Event ret = Event();
ret.setObjectId(fr.elementsByTagName(NODE_EVENT_ID).at(0).firstChild().toText().data());
//ret.setOwnerId(fr.elementsByTagName(NODE_EVENT_OWNER_ID).at(0).firstChild().toText().data());
ret.setTitle(fr.elementsByTagName(NODE_EVENT_TITLE).at(0).firstChild().toText().data());
QDomNodeList description = fr.elementsByTagName(NODE_EVENT_DESCRIPTION);
if (!description.isEmpty())
ret.setDescription(fr.elementsByTagName(NODE_EVENT_DESCRIPTION).at(0).firstChild().toText().data());
else
ret.setDescription("");
ret.setStartTime(fr.elementsByTagName(NODE_EVENT_START_TIME).at(0).firstChild().toText().data());
QDomNodeList endTime = fr.elementsByTagName(NODE_EVENT_END_TIME);
if (!endTime.isEmpty())
ret.setEndTime(fr.elementsByTagName(NODE_EVENT_END_TIME).at(0).firstChild().toText().data());
else
ret.setEndTime("");
ret.setUpdateTime(fr.elementsByTagName(NODE_EVENT_UPDATE_TIME).at(0).firstChild().toText().data());
QDomNodeList location = fr.elementsByTagName(NODE_EVENT_END_TIME);
if (!location.isEmpty())
ret.setLocation(fr.elementsByTagName(NODE_EVENT_LOCATION).at(0).firstChild().toText().data());
else
ret.setLocation("");
ret.setCreator(fr.elementsByTagName(NODE_EVENT_CREATOR).at(0).firstChild().toText().data());
ret.setPrivacy(fr.elementsByTagName(NODE_EVENT_PRIVACY).at(0).firstChild().toText().data());
ret.setIconUrl(fr.elementsByTagName(NODE_EVENT_ICON_URL).at(0).firstChild().toText().data());
ret.setRsvpStatus(fr.elementsByTagName(NODE_EVENT_RSVP_STATUS).at(0).firstChild().toText().data());
ret.setOwnerId(friendId);
ret.setServiceId(srvcId);
ret.setAccountId(accountId);
return ret;
}
示例3: outgoingStanza
bool AttentionPlugin::outgoingStanza(int /*account*/, QDomElement& xml) {
if(enabled) {
if(xml.tagName() == "iq" && xml.attribute("type") == "result")
{
QDomNodeList list = xml.elementsByTagNameNS("http://jabber.org/protocol/disco#info", "query");
if(!list.isEmpty())
{
QDomElement query = list.at(0).toElement();
if(!query.hasAttribute("node")) {
QDomDocument doc = xml.ownerDocument();
QDomElement feature = doc.createElement("feature");
feature.setAttribute("var", "urn:xmpp:attention:0");
query.appendChild(feature);
}
}
}
else if(xml.tagName() == "presence")
{
QDomNodeList list = xml.elementsByTagNameNS("http://jabber.org/protocol/caps", "c");
if(!list.isEmpty())
{
QDomElement c = list.at(0).toElement();
if(c.hasAttribute("ext")) {
QString ext = c.attribute("ext");
ext += " at-pl";
c.setAttribute("ext", ext);
}
}
}
}
return false;
}
示例4: query
QList<CollinsInfo> Collins::zhCollins(QString word)
{
QList<CollinsInfo> empty;
QSqlQuery query(zhCollinsdb_);
// QString sql = QString("select * from zhmultiwords where word='%1'").arg(word);
query.prepare("select * from zhmultiwords where word=:word and type=1");
query.bindValue(":word",word);
if (query.exec()) {
while (query.next()) {
CollinsInfo info;
info.wordID = query.value(0).toInt();
info.word = query.value(1).toString();
info.frequency = query.value(2).toInt();
info.type = query.value(3).toInt();
info.num = query.value(4).toInt();
info.st = query.value(5).toString();
info.cn = query.value(6).toString();
info.sentences = query.value(7).toString();
info.grammer = query.value(8).toString();
info.explain = query.value(9).toString();
info.usagenote = query.value(10).toString();
info.exampleXML = query.value(11).toString();
QDomDocument doc;
if (doc.setContent(info.exampleXML)) {
QDomNodeList list = doc.elementsByTagName("pair");
for (int i = 0; i < list.size(); ++i) {
QString entext;
QString zhtext;
QDomNode one = list.at(i);
if (one.isElement()) {
QDomElement ele = one.toElement();
QDomNodeList enlist = ele.elementsByTagName("en");
if (!enlist.isEmpty()) {
QDomElement en = enlist.at(0).toElement();
entext = en.text();
}
QDomNodeList znlist = ele.elementsByTagName("zh");
if (!znlist.isEmpty()) {
QDomElement zh = znlist.at(0).toElement();
zhtext = zh.text();
}
info.example.insert(entext,zhtext);
}
}
}
empty.append(info);
}
}else {
qDebug() << "sql exec ERROR"<< query.lastError().text()<<query.lastQuery();
}
return empty;
}
示例5: parseGetMapElement
int QgsSOAPRequestHandler::parseGetMapElement( QMap<QString, QString>& parameterMap, const QDomElement& getMapElement ) const
{
QDomNodeList boundingBoxList = getMapElement.elementsByTagName( "BoundingBox" );
if ( !boundingBoxList.isEmpty() )
{
parseBoundingBoxElement( parameterMap, boundingBoxList.item( 0 ).toElement() );
}
QDomNodeList CRSList = getMapElement.elementsByTagName( "coordinateReferenceSystem" );
if ( !CRSList.isEmpty() )
{
QString crsText = CRSList.item( 0 ).toElement().text();
QString epsgNumber;
if ( !crsText.startsWith( "EPSG_" ) ) //use underscore in SOAP because ':' is reserved for namespaces
{
//error
}
else
{
epsgNumber = crsText.replace( 4, 1, ":" );//replace the underscore with a ':' to make it WMS compatible
}
parameterMap.insert( "CRS", epsgNumber );
}
QDomNodeList GMLList = getMapElement.elementsByTagNameNS( "http://www.eu-orchestra.org/services/ms", "GML" );
if ( !GMLList.isEmpty() )
{
QString gmlText;
QTextStream gmlStream( &gmlText );
GMLList.at( 0 ).save( gmlStream, 2 );
parameterMap.insert( "GML", gmlText );
}
//outputAttributes
QDomNodeList imageDocumentAttributesList = getMapElement.elementsByTagName( "Output" );
if ( !imageDocumentAttributesList.isEmpty() )
{
parseOutputAttributesElement( parameterMap, imageDocumentAttributesList.item( 0 ).toElement() );
}
//SLD
QDomNodeList sldList = getMapElement.elementsByTagName( "StyledLayerDescriptor" );
if ( !sldList.isEmpty() )
{
QString sldString;
QTextStream sldStream( &sldString );
sldList.item( 0 ).save( sldStream, 0 );
//Replace some special characters
sldString.replace( "<", "<" );
sldString.replace( ">", ">" );
parameterMap.insert( "SLD", sldString );
}
return 0;
}
示例6: GLVector
GLVector * GLVector::fromXml(const QDomElement &object)
{
if (object.isNull() || object.attribute("type","") != "vector")
return NULL;
QString id = object.attribute("id","");
GLdouble sx = 0.0;
GLdouble sy = 0.0;
GLdouble sz = 0.0;
GLdouble ex = 0.0;
GLdouble ey = 0.0;
GLdouble ez = 0.0;
QDomNodeList points = object.elementsByTagName("point");
if (points.count() == 2)
{
QDomElement point = points.at(0).toElement();
sx = point.attribute("x","0").toDouble();
sy = point.attribute("y","0").toDouble();
sz = point.attribute("z","0").toDouble();
point = points.at(1).toElement();
ex = point.attribute("x","0").toDouble();
ey = point.attribute("y","0").toDouble();
ez = point.attribute("z","0").toDouble();
}
uchar r=0,g=0,b=0,a=255;
QDomNodeList colors = object.elementsByTagName("color");
if (!colors.isEmpty())
{
QDomElement colorNode = colors.at(0).toElement();
r = (uchar)colorNode.attribute("r","0").toUShort(NULL, 16);
g = (uchar)colorNode.attribute("g","0").toUShort(NULL, 16);
b = (uchar)colorNode.attribute("b","0").toUShort(NULL, 16);
a = (uchar)colorNode.attribute("a","ff").toUShort(NULL, 16);
}
int time = 0;
QDomNodeList times = object.elementsByTagName("time");
if (!times.isEmpty())
{
QDomElement timeNode = times.at(0).toElement();
time = timeNode.text().toInt();
}
return new GLVector(sx,sy,sz,ex,ey,ez,GLColor(r,g,b,a),id,time);
}
示例7: standardizeFormula
/// Returns a string containing the standardized version of
/// \p formula from \p inputFormat in \p outputFormat. If an error
/// occurs an empty string is returned.
///
/// For example, to convert an InChI string to standardized SMILES:
/// \code
/// std::string formula = pubchem.standardizeFormula("InChI=1/C6H6/c1-2-4-6-5-3-1/h1-6H", "inchi", "smiles");
/// \endcode
std::string PubChem::standardizeFormula(const std::string &formula, const std::string &inputFormat, const std::string &outputFormat) const
{
if(formula.empty()){
return std::string();
}
PubChemQuery query = PubChemQuery::standardizationQuery(formula, inputFormat, outputFormat);
PubChemQueryThread thread(query);
thread.start();
thread.wait();
QByteArray response = thread.response();
QDomDocument document;
document.setContent(response, false);
QDomNodeList nodes = document.elementsByTagName("PCT-Structure_structure_string");
if(nodes.isEmpty()){
return std::string();
}
QDomNode node = nodes.at(0);
QDomElement element = node.toElement();
QByteArray elementText = element.text().toAscii();
std::string standardizedFormula = elementText.constData();
return standardizedFormula;
}
示例8: downloadFileData
/// Downloads and returns the file data for the compounds with ID's
/// in the list \p ids. If an error occurs an empty QByteArray is
/// returned.
QByteArray PubChem::downloadFileData(const QStringList &ids, const QString &format) const
{
PubChemQuery query = PubChemQuery::downloadQuery(ids, format);
PubChemQueryThread thread(query);
thread.start();
thread.wait();
// the response contains a URL where the file can be downloaded
QByteArray response = thread.response();
QDomDocument document;
document.setContent(response, false);
QDomNodeList nodes = document.elementsByTagName("PCT-Download-URL_url");
if(nodes.isEmpty()){
return QByteArray();
}
QDomNode node = nodes.at(0);
QDomElement element = node.toElement();
QString url = element.text();
return DownloadThread::download(QUrl(url));
}
示例9: QStringLiteral
void QgsProjectFileTransform::transform1400to1500()
{
//Adapt the XML description of the composer legend model to version 1.5
if ( mDom.isNull() )
{
return;
}
//Add layer id to <VectorClassificationItem>
QDomNodeList layerItemList = mDom.elementsByTagName( QStringLiteral( "LayerItem" ) );
QDomElement currentLayerItemElem;
QString currentLayerId;
for ( int i = 0; i < layerItemList.size(); ++i )
{
currentLayerItemElem = layerItemList.at( i ).toElement();
if ( currentLayerItemElem.isNull() )
{
continue;
}
currentLayerId = currentLayerItemElem.attribute( QStringLiteral( "layerId" ) );
QDomNodeList vectorClassificationList = currentLayerItemElem.elementsByTagName( QStringLiteral( "VectorClassificationItem" ) );
QDomElement currentClassificationElem;
for ( int j = 0; j < vectorClassificationList.size(); ++j )
{
currentClassificationElem = vectorClassificationList.at( j ).toElement();
if ( !currentClassificationElem.isNull() )
{
currentClassificationElem.setAttribute( QStringLiteral( "layerId" ), currentLayerId );
}
}
//replace the text items with VectorClassification or RasterClassification items
QDomNodeList textItemList = currentLayerItemElem.elementsByTagName( QStringLiteral( "TextItem" ) );
QDomElement currentTextItem;
for ( int j = 0; j < textItemList.size(); ++j )
{
currentTextItem = textItemList.at( j ).toElement();
if ( currentTextItem.isNull() )
{
continue;
}
QDomElement classificationElement;
if ( !vectorClassificationList.isEmpty() ) //we guess it is a vector layer
{
classificationElement = mDom.createElement( QStringLiteral( "VectorClassificationItem" ) );
}
else
{
classificationElement = mDom.createElement( QStringLiteral( "RasterClassificationItem" ) );
}
classificationElement.setAttribute( QStringLiteral( "layerId" ), currentLayerId );
classificationElement.setAttribute( QStringLiteral( "text" ), currentTextItem.attribute( QStringLiteral( "text" ) ) );
currentLayerItemElem.replaceChild( classificationElement, currentTextItem );
}
}
}
示例10: createMaterial
TrussMaterial& TrussMaterialLibrary::createMaterial ( const QString& xmlProps )
{
// Create empty material
TrussMaterial& material = createMaterial( 0, 0, 0, "" );
// Save material UUID
QString mUUID = material.getUUID();
QDomDocument doc;
if ( ! doc.setContent( xmlProps ) )
return material;
QDomNodeList nodeList = doc.elementsByTagName( "TrussMaterial" );
if ( nodeList.isEmpty() )
return material;
QDomElement materialElem = nodeList.at( 0 ).toElement();
if ( materialElem.isNull() )
return material;
material.loadFromXML( materialElem );
// Restore UUID
material.setUUID( mUUID );
return material;
}
示例11: info
void
MusixMatchPlugin::trackSearchSlot()
{
tDebug() << Q_FUNC_INFO;
QNetworkReply* oldReply = qobject_cast<QNetworkReply*>( sender() );
if ( !oldReply )
return; //timeout will handle it
oldReply->deleteLater();
QDomDocument doc;
doc.setContent(oldReply->readAll());
qDebug() << Q_FUNC_INFO << doc.toString();
QDomNodeList domNodeList = doc.elementsByTagName("track_id");
if ( domNodeList.isEmpty() )
{
emit info( oldReply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
return;
}
QString track_id = domNodeList.at(0).toElement().text();
QString requestString( "http://api.musixmatch.com/ws/1.1/track.lyrics.get?track_id=%1&format=xml&apikey=%2" );
QUrl url( requestString );
TomahawkUtils::urlAddQueryItem( url, "apikey", m_apiKey );
TomahawkUtils::urlAddQueryItem( url, "track_id", track_id );
QNetworkReply* newReply = Tomahawk::Utils::nam()->get( QNetworkRequest( url ) );
newReply->setProperty( "requestData", oldReply->property( "requestData" ) );
connect( newReply, SIGNAL( finished() ), SLOT( trackLyricsSlot() ) );
}
示例12: searchFinished
void WSettings::searchFinished(QNetworkReply *reply)
{
reply->deleteLater();
ui.addButton->setEnabled(true);
ui.searchEdit->clear();
QDomDocument doc;
if (!doc.setContent(reply->readAll()))
return;
QDomElement rootElement = doc.documentElement();
QDomNodeList locations = rootElement.elementsByTagName(QLatin1String("location"));
if (locations.isEmpty())
ui.searchEdit->addItem(tr("Not found"));
for (int i = 0; i < locations.count(); i++) {
QDomNamedNodeMap attributes = locations.at(i).attributes();
QString cityId = attributes.namedItem(QLatin1String("location")).nodeValue();
QString cityName = attributes.namedItem(QLatin1String("city")).nodeValue();
QString stateName = attributes.namedItem(QLatin1String("state")).nodeValue();
QString cityFullName = cityName + ", " + stateName;
int index = ui.searchEdit->count();
ui.searchEdit->addItem(cityFullName);
ui.searchEdit->setItemData(index, cityId, CodeRole);
ui.searchEdit->setItemData(index, cityName, CityRole);
ui.searchEdit->setItemData(index, stateName, StateRole);
}
}
示例13: info
void
MusicBrainzPlugin::albumSearchSlot()
{
QNetworkReply* oldReply = qobject_cast<QNetworkReply*>( sender() );
if ( !oldReply )
return; //timeout will handle it
QDomDocument doc;
doc.setContent( oldReply->readAll() );
QDomNodeList domNodeList = doc.elementsByTagName( "artist" );
if ( domNodeList.isEmpty() )
{
emit info( oldReply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >(), QVariant() );
return;
}
QString artist_id = domNodeList.at( 0 ).toElement().attribute( "id" );
QString requestString( "http://musicbrainz.org/ws/2/release?status=official&type=album|ep" );
QUrl url( requestString );
url.addQueryItem( "artist", artist_id );
QNetworkReply* newReply = TomahawkUtils::nam()->get( QNetworkRequest( url ) );
newReply->setProperty( "requestData", oldReply->property( "requestData" ) );
connect( newReply, SIGNAL( finished() ), SLOT( tracksSearchSlot() ) );
}
示例14: readXml
bool QgsComposerTableColumn::readXml( const QDomElement &columnElem )
{
mHAlignment = static_cast< Qt::AlignmentFlag >( columnElem.attribute( QStringLiteral( "hAlignment" ), QString::number( Qt::AlignLeft ) ).toInt() );
mVAlignment = static_cast< Qt::AlignmentFlag >( columnElem.attribute( QStringLiteral( "vAlignment" ), QString::number( Qt::AlignVCenter ) ).toInt() );
mHeading = columnElem.attribute( QStringLiteral( "heading" ), QLatin1String( "" ) );
mAttribute = columnElem.attribute( QStringLiteral( "attribute" ), QLatin1String( "" ) );
mSortByRank = columnElem.attribute( QStringLiteral( "sortByRank" ), QStringLiteral( "0" ) ).toInt();
mSortOrder = static_cast< Qt::SortOrder >( columnElem.attribute( QStringLiteral( "sortOrder" ), QString::number( Qt::AscendingOrder ) ).toInt() );
mWidth = columnElem.attribute( QStringLiteral( "width" ), QStringLiteral( "0.0" ) ).toDouble();
QDomNodeList bgColorList = columnElem.elementsByTagName( QStringLiteral( "backgroundColor" ) );
if ( !bgColorList.isEmpty() )
{
QDomElement bgColorElem = bgColorList.at( 0 ).toElement();
bool redOk, greenOk, blueOk, alphaOk;
int bgRed, bgGreen, bgBlue, bgAlpha;
bgRed = bgColorElem.attribute( QStringLiteral( "red" ) ).toDouble( &redOk );
bgGreen = bgColorElem.attribute( QStringLiteral( "green" ) ).toDouble( &greenOk );
bgBlue = bgColorElem.attribute( QStringLiteral( "blue" ) ).toDouble( &blueOk );
bgAlpha = bgColorElem.attribute( QStringLiteral( "alpha" ) ).toDouble( &alphaOk );
if ( redOk && greenOk && blueOk && alphaOk )
{
mBackgroundColor = QColor( bgRed, bgGreen, bgBlue, bgAlpha );
}
}
return true;
}
示例15: readXML
bool QgsComposerNodesItem::readXML( const QDomElement& itemElem,
const QDomDocument& doc )
{
// restore general composer item properties
const QDomNodeList composerItemList = itemElem.elementsByTagName( "ComposerItem" );
if ( !composerItemList.isEmpty() )
{
QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
if ( !qgsDoubleNear( composerItemElem.attribute( "rotation", "0" ).toDouble(), 0.0 ) )
setItemRotation( composerItemElem.attribute( "rotation", "0" ).toDouble() );
_readXML( composerItemElem, doc );
}
// restore style
QDomElement styleSymbolElem = itemElem.firstChildElement( "symbol" );
if ( !styleSymbolElem.isNull() )
_readXMLStyle( styleSymbolElem );
// restore nodes
mPolygon.clear();
QDomNodeList nodesList = itemElem.elementsByTagName( "node" );
for ( int i = 0; i < nodesList.size(); i++ )
{
QDomElement nodeElem = nodesList.at( i ).toElement();
QPointF newPt;
newPt.setX( nodeElem.attribute( "x" ).toDouble() );
newPt.setY( nodeElem.attribute( "y" ).toDouble() );
mPolygon.append( newPt );
}
emit itemChanged();
return true;
}