本文整理汇总了C++中taglib::FileRef::save方法的典型用法代码示例。如果您正苦于以下问题:C++ FileRef::save方法的具体用法?C++ FileRef::save怎么用?C++ FileRef::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taglib::FileRef
的用法示例。
在下文中一共展示了FileRef::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: replace
void ReplaceDialog::replace(){
QProgressDialog p("Replacing tags...", "Cancel", 0, items_.size(), 0);
p.setWindowModality(Qt::WindowModal);
Qt::CaseSensitivity case_sens = Qt::CaseInsensitive;
if(CaseSensitive->isChecked()){
case_sens = Qt::CaseSensitive;
}
QString log; int nReplaced=0;
TagLib::FileRef f; QString before;
for(int i=0;i<items_.size();i++){
p.setValue(i);
if( p.wasCanceled() ){
break;
}
f = TagLib::FileRef( items_[i]->fileInfo().absoluteFilePath().toStdString().c_str() );
if( f.tag() ){
QString field = TagComboBox->currentText().toLower();
QString tagtxt;
if( field=="artist" ){
tagtxt = f.tag()->artist().toCString(); before=tagtxt;
tagtxt.replace( Before->text(), After->text(), case_sens );
if(before!=tagtxt){
nReplaced++;
}
f.tag()->setArtist( tagtxt.toStdString().c_str() );
}else if(field=="album"){
tagtxt = f.tag()->album().toCString(); before=tagtxt;
tagtxt.replace( Before->text(), After->text(), case_sens );
if(before!=tagtxt){
nReplaced++;
}
f.tag()->setAlbum( tagtxt.toStdString().c_str() );
}else if(field=="title"){
tagtxt = f.tag()->title().toCString(); before=tagtxt;
tagtxt.replace( Before->text(), After->text(), case_sens );
if(before!=tagtxt){
nReplaced++;
}
f.tag()->setTitle( tagtxt.toStdString().c_str() );
}else if(field=="genre"){
tagtxt = f.tag()->genre().toCString(); before=tagtxt;
tagtxt.replace( Before->text(), After->text(), case_sens );
if(before!=tagtxt){
nReplaced++;
}
f.tag()->setGenre( tagtxt.toStdString().c_str() );
}else if(field=="comment"){
tagtxt = f.tag()->comment().toCString(); before=tagtxt;
tagtxt.replace( Before->text(), After->text(), case_sens );
if(before!=tagtxt){
nReplaced++;
}
f.tag()->setComment( tagtxt.toStdString().c_str() );
}else if(field=="track"){
tagtxt = QString::number(f.tag()->track()); before=tagtxt;
tagtxt.replace( Before->text(), After->text(), case_sens );
bool ok; int tmp=tagtxt.toInt(&ok);
if(ok){
if(before!=tagtxt){
nReplaced++;
}
f.tag()->setTrack( tmp );
}else{
log.append("\nInvalid value for "+field+": "+tagtxt+". "+field+" must be uint");
}
}else if(field=="year"){
tagtxt = QString::number(f.tag()->year()); before=tagtxt;
tagtxt.replace( Before->text(), After->text(), case_sens );
bool ok; int tmp=tagtxt.toInt(&ok);
if(ok){
if(before!=tagtxt){
nReplaced++;
}
f.tag()->setYear( tmp );
}else{
log.append("\nInvalid value for "+field+": "+tagtxt+". "+field+" must be uint");
}
}
f.save();
items_[i]->clearTags();
items_[i]->readTags();
}else{
log.append("\n Could not get tag for "+items_[i]->fileInfo().absoluteFilePath());
}
}
log.append("\n\nReplaced "+Before->text()+" with "+After->text()+" in "+QString::number(nReplaced)+" tags");
p.setValue(items_.size());
TextViewer t(log);
t.exec();
accept();
}