当前位置: 首页>>代码示例>>C++>>正文


C++ Album::setRelease方法代码示例

本文整理汇总了C++中Album::setRelease方法的典型用法代码示例。如果您正苦于以下问题:C++ Album::setRelease方法的具体用法?C++ Album::setRelease怎么用?C++ Album::setRelease使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Album的用法示例。


在下文中一共展示了Album::setRelease方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_ );
        }
    }

}
开发者ID:ivareske,项目名称:TagEditor,代码行数:89,代码来源:Discogs.cpp

示例2: handleRelease

void Discogs::handleRelease( QNetworkReply* reply ){

    Album album;
    QNetworkRequest request = reply->request();
    QString key = request.attribute(QNetworkRequest::User).toString();

    if( albums_.contains(key) ){
        album = albums_[key];
        //album.setArtists( QStringList() );
        //album.setSongs( QList<Song>() );
    }


    //cover->setText("");
    QString err;
    QByteArray response(reply->readAll());
    QXmlStreamReader xml(response);

    QList<Artist> Artists;
    QList<QUrl> images;
    QStringList artists,roles;
    QList<Song> songs;
    while (!xml.atEnd()) {
        xml.readNext();
        //qDebug()<<xml.name();

        if( xml.name() == "release" && xml.attributes().hasAttribute("id") ){
            QString id = xml.attributes().value("id").toString();
            album.setRelease(id);
        }

        if(xml.tokenType() == QXmlStreamReader::StartElement){
            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();
                        }
                    }
                }
            }
            if( xml.attributes().hasAttribute("requests") ){
                //&nSearches = xml.attributes().value("requests").toString().toInt();
                //info->setText(QString::number(nSearches)+" searches performed within the last 24 hours");
            }
            if(xml.name() == "images"){
                xml.readNext();
                while(xml.name()=="image"){
                    if( xml.attributes().hasAttribute("uri") ){
                        images.append( QUrl( xml.attributes().value("uri").toString() ) );
                        //qDebug()<<"found image "<<xml.attributes().value("uri").toString();
                    }
                    xml.readNext();
                }
            }
            if(xml.name() == "artists"){
                while(xml.readNextStartElement()){
                    if(xml.name() == "artist"){
                        while(xml.readNextStartElement()){
                            if(xml.name() == "name"){
                                artists.append( xml.readElementText() );
                            }else{
                                xml.skipCurrentElement();
                            }
                        }
                    }else{
                        xml.skipCurrentElement();
                    }
                }
            }
            if(xml.name() == "extraartists"){
                while(xml.readNextStartElement()){
                    if(xml.name() == "artist"){
                        //QString name;QString role;
                        Artist a;
                        while(xml.readNextStartElement()){
                            if(xml.name() == "name"){
                                a.setName( xml.readElementText() );
                            }else if(xml.name() == "role"){
                                a.setRole( xml.readElementText() );
                            }else{
                                xml.skipCurrentElement();
                            }
                            Artists.append(a);
                        }
                        //qDebug()<<role+": "+name;
                        //album.roles.append( role+": "+name );
                    }else{
                        xml.skipCurrentElement();
                    }
                }
            }
            if(xml.name() == "formats"){
                while(xml.readNextStartElement()){
                    if( xml.name()=="format" && xml.attributes().hasAttribute("name") ){
                        QString sep=", ";
                        if(album.format().isEmpty()){
//.........这里部分代码省略.........
开发者ID:ivareske,项目名称:TagEditor,代码行数:101,代码来源:Discogs.cpp


注:本文中的Album::setRelease方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。