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


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

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


在下文中一共展示了Album::setTitle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: forId

Album* Album::forId(int albumId) {

    if (cache.contains(albumId)) {
        // get from cache
        // qDebug() << "Album was cached" << albumId;
        return cache.value(albumId);
    }

    QSqlDatabase db = Database::instance().getConnection();
    QSqlQuery query(db);
    query.prepare("select title, year, artist from albums where id=?");
    query.bindValue(0, albumId);
    bool success = query.exec();
    if (!success) qDebug() << query.lastQuery() << query.lastError().text();
    if (query.next()) {
        Album* album = new Album();
        album->setId(albumId);
        album->setTitle(query.value(0).toString());
        album->setYear(query.value(1).toInt());

        // relations
        int artistId = query.value(2).toInt();
        // TODO this could be made lazy
        album->setArtist(Artist::forId(artistId));

        // put into cache
        cache.insert(albumId, album);
        return album;
    }
    cache.insert(albumId, 0);
    return 0;
}
开发者ID:junwatu,项目名称:junwatunes,代码行数:32,代码来源:album.cpp

示例2: 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

示例3: handleRelease


//.........这里部分代码省略.........
                        //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()){
                            sep="";
                        }
                        album.setFormat( album.format() + sep + xml.attributes().value("name").toString() );
                    }else{
                        xml.skipCurrentElement();
                    }
                }
            }
            if(xml.name() == "title"){
                album.setTitle( xml.readElementText() );
            }
            if(xml.name() == "labels"){
                xml.readNext();
                while(xml.name()=="label"){
                    if( xml.attributes().hasAttribute("name") ){
                        QString sep=", ";
                        if(album.label().isEmpty()){
                            sep="";
                        }
                        album.setLabel( album.label()+sep+xml.attributes().value("name").toString() );
                    }
                    xml.readNext();
                }
            }
            if(xml.name() == "genres"){
                while(xml.readNextStartElement()){
                    if(xml.name() == "genre"){
                        QString sep=", ";
                        if(album.genre().isEmpty()){
                            sep="";
                        }
                        album.setGenre( album.genre() + sep + xml.readElementText() );
                    }else{
                        xml.skipCurrentElement();
                    }
                }
            }
            if(xml.name() == "styles"){
                while(xml.readNextStartElement()){
                    if(xml.name() == "style"){
                        QString sep=", ";
                        if(album.style().isEmpty()){
开发者ID:ivareske,项目名称:TagEditor,代码行数:67,代码来源:Discogs.cpp


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