1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| void WTagEdit::on_save_clicked() {
TagLib::FileRef track(QFile::encodeName(filename));
TagLib::Tag *tag=track.tag();
if (!track.isNull() && tag!=NULL) {
tag->setAlbum(table->item(WTagEdit::ALBUM,0)->text().toStdString());
tag->setTitle(table->item(WTagEdit::TITLE,0)->text().toStdString());
tag->setArtist(table->item(WTagEdit::ARTIST,0)->text().toStdString());
tag->setGenre(table->item(WTagEdit::GENRE,0)->text().toStdString());
tag->setComment(table->item(WTagEdit::COMMENT,0)->text().toStdString());
bool ok;
int v;
v=table->item(WTagEdit::TRACK,0)->text().toInt(&ok);
if (ok) tag->setTrack((TagLib::uint)v);
v=table->item(WTagEdit::YEAR,0)->text().toInt(&ok);
if (ok) tag->setYear((TagLib::uint)v);
if (!track.save()) QMessageBox::information(this,tr("Tags can't be saved"),tr("Tag cannot be saved.\nMaybe this track is played."));
else QMessageBox::information(this,tr("Tags saved"),tr("Tag saved."));
} else {
QMessageBox::information(this,tr("Tags can't be read"),tr("Tag cannot be read.\nMaybe this track is played."));
return;
}
} |
Partager