本文整理汇总了C++中Album::setYear方法的典型用法代码示例。如果您正苦于以下问题:C++ Album::setYear方法的具体用法?C++ Album::setYear怎么用?C++ Album::setYear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album
的用法示例。
在下文中一共展示了Album::setYear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: handleRelease
//.........这里部分代码省略.........
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()){
sep="";
}
album.setStyle( album.style() + sep + xml.readElementText() );
}else{
xml.skipCurrentElement();
}
}
}
if(xml.name() == "country"){
album.setCountry( xml.readElementText() );
}
if(xml.name() == "released"){
album.setYear( xml.readElementText().toInt() );
}
if(xml.name() == "notes"){
album.setNotes( xml.readElementText() );
}
if(xml.name() == "tracklist"){
while(xml.readNextStartElement()){
if(xml.name() == "track"){
Song s;
while(xml.readNextStartElement()){
//qDebug()<<xml.name()<<xml.readElementText();
if(xml.name() == "position"){
s.setTrack( xml.readElementText() );
}else if(xml.name() == "title"){
s.setTitle( xml.readElementText() );
}else if(xml.name() == "duration"){
QStringList tmp = xml.readElementText().split(":");
int sum=0;
for(int j=0;j<tmp.size();j++){
sum = sum + ( tmp[j].toInt()*pow(60,tmp.size()-j-1) );
}
s.setLength(sum);
}else{
xml.skipCurrentElement();
}
}
songs.append(s);
}else{
xml.skipCurrentElement();
}
}
}
}