本文整理汇总了C++中Song类的典型用法代码示例。如果您正苦于以下问题:C++ Song类的具体用法?C++ Song怎么用?C++ Song使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Song类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MergeUserSetData
void Song::MergeUserSetData(const Song& other) {
set_playcount(other.playcount());
set_skipcount(other.skipcount());
set_lastplayed(other.lastplayed());
set_score(other.score());
set_art_manual(other.art_manual());
if (rating() == -1.0f) {
set_rating(other.rating());
}
}
示例2: IsOnSameAlbum
bool Song::IsOnSameAlbum(const Song& other) const {
if (is_compilation() != other.is_compilation()) return false;
if (has_cue() && other.has_cue() && cue_path() == other.cue_path())
return true;
if (is_compilation() && album() == other.album()) return true;
return album() == other.album() && artist() == other.artist();
}
示例3: foreach
void SongLoader::AudioCDTagsLoaded(const QString& artist, const QString& album,
const MusicBrainzClient::ResultList& results) {
// Remove previously added songs metadata, because there are not needed
// and that we are going to fill it with new (more complete) ones
songs_.clear();
int track_number = 1;
foreach (const MusicBrainzClient::Result& ret, results) {
Song song;
song.set_artist(artist);
song.set_album(album);
song.set_title(ret.title_);
song.set_length_nanosec(ret.duration_msec_ * kNsecPerMsec);
song.set_track(track_number);
song.set_year(ret.year_);
// We need to set url: that's how playlist will find the correct item to update
song.set_url(QUrl(QString("cdda://%1").arg(track_number++)));
songs_ << song;
}
示例4: foreach
void CddaDevice::AudioCDTagsLoaded(const QString& artist, const QString& album,
const MusicBrainzClient::ResultList& results) {
MusicBrainzClient *musicbrainz_client = qobject_cast<MusicBrainzClient*>(sender());
musicbrainz_client->deleteLater();
SongList songs;
int track_number = 1;
if (results.size() == 0)
return;
model_->Reset();
foreach (const MusicBrainzClient::Result& ret, results) {
Song song;
song.set_artist(artist);
song.set_album(album);
song.set_title(ret.title_);
song.set_length_nanosec(ret.duration_msec_ * kNsecPerMsec);
song.set_track(track_number);
song.set_year(ret.year_);
song.set_id(track_number);
// We need to set url: that's how playlist will find the correct item to update
song.set_url(QUrl(QString("cdda://%1/%2").arg(unique_id()).arg(track_number++)));
songs << song;
}
示例5: GetSingleSelectionAsSong
void AlbumCoverManager::SaveCoverToFile() {
Song song = GetSingleSelectionAsSong();
if (!song.is_valid()) return;
QImage image;
// load the image from disk
if (song.has_manually_unset_cover()) {
image = QImage(":/nocover.png");
} else {
if (!song.art_manual().isEmpty() && QFile::exists(song.art_manual())) {
image = QImage(song.art_manual());
} else if (!song.art_automatic().isEmpty() &&
QFile::exists(song.art_automatic())) {
image = QImage(song.art_automatic());
} else {
image = QImage(":/nocover.png");
}
}
album_cover_choice_controller_->SaveCoverToFile(song, image);
}
示例6: GetFilenameForSong
QString OrganiseFormat::GetFilenameForSong(const Song& song) const {
QString filename = ParseBlock(format_, song);
if (QFileInfo(filename).completeBaseName().isEmpty()) {
// Avoid having empty filenames, or filenames with extension only: in this
// case, keep the original filename.
// We remove the extension from "filename" if it exists, as
// song.basefilename()
// also contains the extension.
filename =
Utilities::PathWithoutFilenameExtension(filename) + song.basefilename();
}
if (replace_spaces_) filename.replace(QRegExp("\\s"), "_");
if (replace_non_ascii_) {
QString stripped;
for (int i = 0; i < filename.length(); ++i) {
const QCharRef c = filename[i];
if (c < 128) {
stripped.append(c);
} else {
const QString decomposition = c.decomposition();
if (!decomposition.isEmpty() && decomposition[0] < 128)
stripped.append(decomposition[0]);
else
stripped.append("_");
}
}
filename = stripped;
}
// Fix any parts of the path that start with dots.
QStringList parts = filename.split("/");
for (int i = 0; i < parts.count(); ++i) {
QString* part = &parts[i];
for (int j = 0; j < kInvalidPrefixCharactersCount; ++j) {
if (part->startsWith(kInvalidPrefixCharacters[j])) {
part->replace(0, 1, '_');
break;
}
}
}
return parts.join("/");
}
示例7: update
void OnlineView::update(const Song &song, bool force)
{
if (force || song!=currentSong) {
currentSong=song;
if (!isVisible()) {
needToUpdate=true;
return;
}
setHeader(song.describe(true));
Covers::Image cImg=Covers::self()->requestImage(song, true);
if (!cImg.img.isNull()) {
setHtml(createPicTag(cImg.img, cImg.fileName));
} else {
setHtml(QString());
}
}
}
示例8: UpdateStatisticsTab
void EditTagDialog::UpdateStatisticsTab(const Song& song) {
ui_->playcount->setText(QString::number(qMax(0, song.playcount())));
ui_->skipcount->setText(QString::number(qMax(0, song.skipcount())));
ui_->score->setText(QString::number(qMax(0, song.score())));
ui_->rating->set_rating(song.rating());
ui_->lastplayed->setText(
song.lastplayed() <= 0
? tr("Never")
: QDateTime::fromTime_t(song.lastplayed()).toString(
QLocale::system().dateTimeFormat(QLocale::LongFormat)));
}
示例9: update
void TitleWidget::update(const Song &sng, const QIcon &icon, const QString &text, const QString &sub, bool showControls)
{
song=sng;
image->setVisible(true);
mainText->setText(text);
subText->setText(sub);
if (!showControls) {
if (controls) {
controls->setVisible(false);
}
} else {
if (!controls) {
controls=new QWidget(this);
QVBoxLayout *l=new QVBoxLayout(controls);
l->setMargin(0);
l->setSpacing(0);
ToolButton *add=new ToolButton(this);
ToolButton *replace=new ToolButton(this);
add->QAbstractButton::setIcon(StdActions::self()->appendToPlayQueueAction->icon());
replace->QAbstractButton::setIcon(StdActions::self()->replacePlayQueueAction->icon());
add->setToolTip(i18n("Add All To Play Queue"));
replace->setToolTip(i18n("Add All And Replace Play Queue"));
l->addWidget(replace);
l->addWidget(add);
connect(add, SIGNAL(clicked()), this, SIGNAL(addToPlayQueue()));
connect(replace, SIGNAL(clicked()), this, SIGNAL(replacePlayQueue()));
static_cast<QGridLayout *>(layout())->addWidget(controls, 0, 4, 2, 1);
}
controls->setVisible(true);
}
subText->setVisible(!sub.isEmpty());
mainText->setAlignment(sub.isEmpty() ? Qt::AlignVCenter : Qt::AlignBottom);
if (!sng.isEmpty()) {
Covers::Image cImg=Covers::self()->requestImage(sng, true);
if (!cImg.img.isNull()) {
image->setPixmap(QPixmap::fromImage(cImg.img.scaled(image->width()-2, image->height()-2, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
return;
}
}
if (icon.isNull()) {
image->setVisible(false);
} else {
image->setPixmap(Icon::getScaledPixmap(icon, image->width(), image->height(), 96));
}
}
示例10: ResetPlayCounts
void EditTagDialog::ResetPlayCounts() {
const QModelIndexList sel =
ui_->song_list->selectionModel()->selectedIndexes();
if (sel.isEmpty()) return;
Song* song = &data_[sel.first().row()].original_;
if (!song->is_valid() || song->id() == -1) return;
if (QMessageBox::question(
this, tr("Reset play counts"),
tr("Are you sure you want to reset this song's statistics?"),
QMessageBox::Reset, QMessageBox::Cancel) != QMessageBox::Reset) {
return;
}
song->set_playcount(0);
song->set_skipcount(0);
song->set_lastplayed(-1);
song->set_score(0);
app_->library_backend()->ResetStatisticsAsync(song->id());
UpdateStatisticsTab(*song);
}
示例11: while
QList<QAction*> SpotifyService::playlistitem_actions(const Song& song) {
// Clear previous actions
while (!playlistitem_actions_.isEmpty()) {
QAction* action = playlistitem_actions_.takeFirst();
delete action->menu();
delete action;
}
QAction* add_to_starred =
new QAction(QIcon(":/star-on.png"), tr("Add to Spotify starred"), this);
connect(add_to_starred, SIGNAL(triggered()),
SLOT(AddCurrentSongToStarredPlaylist()));
playlistitem_actions_.append(add_to_starred);
// Create a menu with 'add to playlist' actions for each Spotify playlist
QAction* add_to_playlists = new QAction(IconLoader::Load("list-add",
IconLoader::Base),
tr("Add to Spotify playlists"), this);
QMenu* playlists_menu = new QMenu();
for (const QStandardItem* playlist_item : playlists_) {
if (!playlist_item->data(InternetModel::Role_CanBeModified).toBool()) {
continue;
}
QAction* add_to_playlist = new QAction(playlist_item->text(), this);
add_to_playlist->setData(playlist_item->data(Role_UserPlaylistIndex));
playlists_menu->addAction(add_to_playlist);
}
connect(playlists_menu, SIGNAL(triggered(QAction*)),
SLOT(AddCurrentSongToUserPlaylist(QAction*)));
add_to_playlists->setMenu(playlists_menu);
playlistitem_actions_.append(add_to_playlists);
QAction* share_song =
new QAction(tr("Get a URL to share this Spotify song"), this);
connect(share_song, SIGNAL(triggered()), SLOT(GetCurrentSongUrlToShare()));
playlistitem_actions_.append(share_song);
// Keep in mind the current song URL
current_song_url_ = song.url();
return playlistitem_actions_;
}
示例12: FetchTagProgress
void TrackSelectionDialog::FetchTagProgress(const Song& original_song,
const QString& progress) {
// Find the item with this filename
int row = -1;
for (int i = 0; i < data_.count(); ++i) {
if (data_[i].original_song_.url() == original_song.url()) {
row = i;
break;
}
}
if (row == -1) return;
data_[row].progress_string_ = progress;
// If it's the current item, update the display
if (ui_->song_list->currentIndex().row() == row) {
UpdateStack();
}
}
示例13: IsMetadataEqual
bool Song::IsMetadataEqual(const Song& other) const {
return d->title_ == other.d->title_ &&
d->album_ == other.d->album_ &&
d->artist_ == other.d->artist_ &&
d->albumartist_ == other.d->albumartist_ &&
d->composer_ == other.d->composer_ &&
d->track_ == other.d->track_ &&
d->disc_ == other.d->disc_ &&
qFuzzyCompare(d->bpm_, other.d->bpm_) &&
d->year_ == other.d->year_ &&
d->genre_ == other.d->genre_ &&
d->comment_ == other.d->comment_ &&
d->compilation_ == other.d->compilation_ &&
d->beginning_ == other.d->beginning_ &&
length_nanosec() == other.length_nanosec() &&
d->bitrate_ == other.d->bitrate_ &&
d->samplerate_ == other.d->samplerate_ &&
d->art_automatic_ == other.d->art_automatic_ &&
d->art_manual_ == other.d->art_manual_ &&
d->cue_path_ == other.d->cue_path_;
}
示例14: SongFromUrl
static Song SongFromUrl(const QUrl& url) {
Song result;
if (url.scheme() == "vk" && url.host() == "song") {
QStringList ids = url.path().split('/');
if (ids.size() == 4) {
result.set_artist(ids[2]);
result.set_title(ids[3]);
result.set_valid(true);
} else {
qLog(Error) << "Wrong song url" << url;
result.set_valid(false);
}
result.set_url(url);
} else {
qLog(Error) << "Wrong song url" << url;
result.set_valid(false);
}
return result;
}
示例15: ShowCover
void AlbumCoverChoiceController::ShowCover(const Song& song) {
QDialog* dialog = new QDialog(this);
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
// Use Artist - Album as the window title
QString title_text(song.albumartist());
if (title_text.isEmpty()) title_text = song.artist();
if (!song.album().isEmpty()) title_text += " - " + song.album();
dialog->setWindowTitle(title_text);
QLabel* label = new QLabel(dialog);
label->setPixmap(AlbumCoverLoader::TryLoadPixmap(
song.art_automatic(), song.art_manual(), song.url().toLocalFile()));
dialog->resize(label->pixmap()->size());
dialog->show();
}