本文整理汇总了C++中QDomElement::attributeNS方法的典型用法代码示例。如果您正苦于以下问题:C++ QDomElement::attributeNS方法的具体用法?C++ QDomElement::attributeNS怎么用?C++ QDomElement::attributeNS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDomElement
的用法示例。
在下文中一共展示了QDomElement::attributeNS方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xmlBase
QString ElementWrapper::xmlBase() const
{
if (!d->xmlBaseParsed) // xmlBase not computed yet
{
QDomElement current = d->element;
while (!current.isNull())
{
if (current.hasAttributeNS(xmlNamespace(), QLatin1String("base")))
{
d->xmlBase = current.attributeNS(xmlNamespace(), QLatin1String("base"));
return d->xmlBase;
}
QDomNode parent = current.parentNode();
if (!parent.isNull() && parent.isElement())
current = parent.toElement();
else
current = QDomElement();
}
d->xmlBaseParsed = true;
}
return d->xmlBase;
}
示例2: finishedRead
void AppUpdater::finishedRead( int id, bool errors )
{
(void)errors;
// we'll get called here alternately by the setHost( ) request and the actual GET request
// we don't care about setHost, so just return and wait for the GET response
if( id != httpGetID )
return;
QDomDocument doc;
QString err;
int line, col;
if (!doc.setContent(http.readAll(), true, &err, &line, &col))
{
headline.setText( "<font size=4>Couldn't contact the update server...</font>" );
details.setText( QString( "Make sure you're connected to the internet." ) );
acceptButton.setText( tr("OK") );
acceptButton.disconnect( ); // make sure it wasn't connected by anything else previously
connect( &acceptButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
removeBrowserAndIgnoreButton( );
if(!checkingOnStartup)
this->show( );
return;
}
QDomElement channel = doc.documentElement().firstChild().toElement();
QDomNodeList items = channel.elementsByTagName("item");
QPair<QString, QString> latest(MCBUILDER_VERSION, "");
bool updateAvailable = false;
for (int i=0, j=items.size(); i<j; i++)
{
QDomElement item = items.item(i).toElement();
if( item.isNull() )
continue;
QDomNodeList enclosures = item.elementsByTagName("enclosure");
for (int k=0, l=enclosures.size(); k<l; k++)
{
QDomElement enclosure = enclosures.item(k).toElement();
if (enclosure.isNull()) continue;
QString version = enclosure.attributeNS(
"http://www.andymatuschak.org/xml-namespaces/sparkle", "version", "not-found" );
// each item can have multiple enclosures, of which at least one
// should have a version field
if (version == "not-found") continue;
if( versionCompare(version, latest.first) > 0 )
{
latest.first = version;
QDomNodeList descs = item.elementsByTagName("description");
//I(descs.size() == 1);
QDomElement desc = descs.item(0).toElement();
//I(!desc.isNull());
latest.second = desc.text();
updateAvailable = true;
}
}
}
// add the appropriate elements/info depending on whether an update is available
if( updateAvailable )
{
headline.setText( "<font size=4>A new version of mcbuilder is available!</font>" );
QString d = QString( "mcbuilder %1 is now available (you have %2). Would you like to download it?" )
.arg(latest.first).arg( MCBUILDER_VERSION );
details.setText( d );
browser.setHtml( latest.second );
acceptButton.setText( tr("Visit Download Page") );
acceptButton.disconnect( );
ignoreButton.disconnect( );
connect( &acceptButton, SIGNAL( clicked() ), this, SLOT( visitDownloadsPage() ) );
connect( &ignoreButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
if( textLayout.indexOf( &browser ) < 0 ) // if the browser's not in the layout, then insert it after the details line
textLayout.insertWidget( textLayout.indexOf( &details ) + 1, &browser );
if( buttonLayout.indexOf( &ignoreButton ) < 0 ) // put the ignore button on the left
buttonLayout.insertWidget( 0, &ignoreButton );
this->show( );
}
else
{
headline.setText( "<font size=4>You're up to date!</font>" );
details.setText( QString( "You're running the latest version of mcbuilder, version %1." ).arg( MCBUILDER_VERSION ) );
acceptButton.setText( tr("OK") );
acceptButton.disconnect( );
connect( &acceptButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
removeBrowserAndIgnoreButton( );
if(!checkingOnStartup)
this->show( );
}
}
示例3: channel
channels_container_t RSS10Parser::Parse (const QDomDocument& doc,
const IDType_t& feedId) const
{
channels_container_t result;
QMap<QString, Channel_ptr> item2Channel;
QDomElement root = doc.documentElement ();
QDomElement channelDescr = root.firstChildElement ("channel");
while (!channelDescr.isNull ())
{
Channel_ptr channel (new Channel (feedId));
channel->Title_ = channelDescr.firstChildElement ("title").text ().trimmed ();
channel->Link_ = channelDescr.firstChildElement ("link").text ();
channel->Description_ =
channelDescr.firstChildElement ("description").text ();
channel->PixmapURL_ =
channelDescr.firstChildElement ("image")
.firstChildElement ("url").text ();
channel->LastBuild_ = GetDCDateTime (channelDescr);
QDomElement itemsRoot = channelDescr.firstChildElement ("items");
QDomNodeList seqs = itemsRoot.elementsByTagNameNS (RDF_, "Seq");
channelDescr = channelDescr.nextSiblingElement ("channel");
if (!seqs.size ())
continue;
QDomElement seqElem = seqs.at (0).toElement ();
QDomNodeList lis = seqElem.elementsByTagNameNS (RDF_, "li");
for (int i = 0; i < lis.size (); ++i)
item2Channel [lis.at (i).toElement ().attribute ("resource")] = channel;
result.push_back (channel);
}
QDomElement itemDescr = root.firstChildElement ("item");
while (!itemDescr.isNull ())
{
QString about = itemDescr.attributeNS (RDF_, "about");
if (item2Channel.contains (about))
{
Item_ptr item (new Item (item2Channel [about]->ChannelID_));
item->Title_ = itemDescr.firstChildElement ("title").text ();
item->Link_ = itemDescr.firstChildElement ("link").text ();
item->Description_ = itemDescr.firstChildElement ("description").text ();
GetDescription (itemDescr, item->Description_);
item->Categories_ = GetAllCategories (itemDescr);
item->Author_ = GetAuthor (itemDescr);
item->PubDate_ = GetDCDateTime (itemDescr);
item->Unread_ = true;
item->NumComments_ = GetNumComments (itemDescr);
item->CommentsLink_ = GetCommentsRSS (itemDescr);
item->CommentsPageLink_ = GetCommentsLink (itemDescr);
item->Enclosures_ = GetEncEnclosures (itemDescr, item->ItemID_);
QPair<double, double> point = GetGeoPoint (itemDescr);
item->Latitude_ = point.first;
item->Longitude_ = point.second;
if (item->Guid_.isEmpty ())
item->Guid_ = "empty";
item2Channel [about]->Items_.push_back (item);
}
itemDescr = itemDescr.nextSiblingElement ("item");
}
return result;
}