本文整理汇总了C++中Album::setUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ Album::setUrl方法的具体用法?C++ Album::setUrl怎么用?C++ Album::setUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album
的用法示例。
在下文中一共展示了Album::setUrl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleResults
void Discogs::handleResults( QNetworkReply* reply ){
//a serach result, not the same as a release. Contains less info
qDebug()<<"Discogs handleResults";
QString err="";
//QList<SearchResult> Results;
//if (!reply->error()) {
QByteArray response(reply->readAll());
QXmlStreamReader xml(response);
while (!xml.atEnd()) {
xml.readNext();
//qDebug()<<xml.name();
if (xml.tokenType() == QXmlStreamReader::StartElement){
if (xml.name() == "resp") {
if( xml.attributes().hasAttribute("stat") ){
QString stat = xml.attributes().value("stat").toString();
if(stat=="fail"){
while(xml.readNextStartElement()){
if( xml.name() == "error" ){
err.append(xml.readElementText()+"\n");
}else{
xml.skipCurrentElement();
}
}
}
}else if( xml.attributes().hasAttribute("requests") ){
//int nSearches = xml.attributes().value("requests").toString().toInt();
//qDebug()<<nSearches;
//info->setText(QString::number(nSearches)+" searches performed within the last 24 hours");
}else{
xml.skipCurrentElement();
}
}
if (xml.name() == "result") {
if( xml.attributes().value("type").toString()=="release" ){
//SearchResult res;
Album res;
//QHash<QString,Album> albums_ = albums();
while (xml.readNextStartElement()) {
if (xml.name() == "title"){
res.setTitle( xml.readElementText() );
}else if (xml.name() == "uri"){
QString tmp = xml.readElementText();
int ind = tmp.lastIndexOf("/")+1;
if(ind!=-1){
//qDebug()<<tmp;
tmp=tmp.right(tmp.size()-ind);
//qDebug()<<tmp;
res.setUrl( QUrl( "http://www.discogs.com/release/"+tmp+"?f=xml&api_key="+api_key ) );
res.setRelease( tmp );
}
}else if (xml.name() == "summary"){
//res.summary = xml.readElementText();
}else{
xml.skipCurrentElement();
}
}
//qDebug()<<res.title<<" "<<res.url<<" "<<res.summary;
//Results.insert(res.release+res.format,res);
albums_.insert(res.key(),res);
setAlbums( albums_ );
}
}
}
}
if( reply->error() || !err.isEmpty() ){
if( reply->error() ){
err = reply->errorString()+":\n"+err;
}
QMessageBox::critical(0, "Error",
err, QMessageBox::Ok, QMessageBox::Ok);
}
reply->deleteLater();
if( !downloadImmediately() ){
emit resultsDownloaded( albums_ );
}else{
if( albums_.size()==0 ){
emit albumsDownloaded( albums_ );
}else{
downloadAllAlbums( albums_ );
}
}
}