mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-16 19:31:02 +01:00
Use constructor for QString and make format
This commit is contained in:
parent
942fda88bf
commit
5a2348fae6
@ -502,10 +502,9 @@ void TagReader::ParseOggTag(const TagLib::Ogg::FieldListMap& map,
|
||||
100);
|
||||
}
|
||||
|
||||
void TagReader::SetVorbisComments(TagLib::Ogg::XiphComment* vorbis_comments,
|
||||
const pb::tagreader::SongMetadata& song)
|
||||
const {
|
||||
|
||||
void TagReader::SetVorbisComments(
|
||||
TagLib::Ogg::XiphComment* vorbis_comments,
|
||||
const pb::tagreader::SongMetadata& song) const {
|
||||
vorbis_comments->addField("COMPOSER",
|
||||
StdStringToTaglibString(song.composer()), true);
|
||||
vorbis_comments->addField("PERFORMER",
|
||||
@ -540,7 +539,6 @@ void TagReader::SetFMPSStatisticsVorbisComments(
|
||||
void TagReader::SetFMPSRatingVorbisComments(
|
||||
TagLib::Ogg::XiphComment* vorbis_comments,
|
||||
const pb::tagreader::SongMetadata& song) const {
|
||||
|
||||
vorbis_comments->addField(
|
||||
"FMPS_RATING", QStringToTaglibString(QString::number(song.rating())));
|
||||
}
|
||||
@ -953,8 +951,8 @@ bool TagReader::ReadCloudFile(const QUrl& download_url, const QString& title,
|
||||
pb::tagreader::SongMetadata* song) const {
|
||||
qLog(Debug) << "Loading tags from" << title;
|
||||
|
||||
std::unique_ptr<CloudStream> stream(
|
||||
new CloudStream(download_url, title, size, authorisation_header, network_));
|
||||
std::unique_ptr<CloudStream> stream(new CloudStream(
|
||||
download_url, title, size, authorisation_header, network_));
|
||||
stream->Precache();
|
||||
std::unique_ptr<TagLib::File> tag;
|
||||
if (mime_type == "audio/mpeg" && title.endsWith(".mp3")) {
|
||||
@ -963,8 +961,8 @@ bool TagReader::ReadCloudFile(const QUrl& download_url, const QString& title,
|
||||
TagLib::AudioProperties::Accurate));
|
||||
} else if (mime_type == "audio/mp4" ||
|
||||
(mime_type == "audio/mpeg" && title.endsWith(".m4a"))) {
|
||||
tag.reset(
|
||||
new TagLib::MP4::File(stream.get(), true, TagLib::AudioProperties::Accurate));
|
||||
tag.reset(new TagLib::MP4::File(stream.get(), true,
|
||||
TagLib::AudioProperties::Accurate));
|
||||
}
|
||||
#ifdef TAGLIB_HAS_OPUS
|
||||
else if ((mime_type == "application/opus" || mime_type == "audio/opus" ||
|
||||
@ -983,8 +981,8 @@ bool TagReader::ReadCloudFile(const QUrl& download_url, const QString& title,
|
||||
TagLib::ID3v2::FrameFactory::instance(),
|
||||
true, TagLib::AudioProperties::Accurate));
|
||||
} else if (mime_type == "audio/x-ms-wma") {
|
||||
tag.reset(
|
||||
new TagLib::ASF::File(stream.get(), true, TagLib::AudioProperties::Accurate));
|
||||
tag.reset(new TagLib::ASF::File(stream.get(), true,
|
||||
TagLib::AudioProperties::Accurate));
|
||||
} else {
|
||||
qLog(Debug) << "Unknown mime type for tagging:" << mime_type;
|
||||
return false;
|
||||
|
@ -534,7 +534,7 @@ void Song::ToProtobuf(pb::tagreader::SongMetadata* pb) const {
|
||||
pb->set_filesize(d->filesize_);
|
||||
pb->set_suspicious_tags(d->suspicious_tags_);
|
||||
pb->set_art_automatic(DataCommaSizeFromQString(d->art_automatic_));
|
||||
pb->set_type(static_cast< ::pb::tagreader::SongMetadata_Type>(d->filetype_));
|
||||
pb->set_type(static_cast<::pb::tagreader::SongMetadata_Type>(d->filetype_));
|
||||
}
|
||||
|
||||
void Song::InitFromQuery(const SqlRow& q, bool reliable_metadata, int col) {
|
||||
@ -887,8 +887,8 @@ void Song::BindToQuery(QSqlQuery* query) const {
|
||||
|
||||
if (Application::kIsPortable &&
|
||||
Utilities::UrlOnSameDriveAsClementine(d->url_)) {
|
||||
query->bindValue(":filename",
|
||||
Utilities::GetRelativePathToClementineBin(d->url_).toEncoded());
|
||||
query->bindValue(":filename", Utilities::GetRelativePathToClementineBin(
|
||||
d->url_).toEncoded());
|
||||
} else {
|
||||
query->bindValue(":filename", d->url_.toEncoded());
|
||||
}
|
||||
|
@ -139,10 +139,10 @@ SongLoader::Result SongLoader::LoadLocalPartial(const QString& filename) {
|
||||
SongLoader::Result SongLoader::LoadAudioCD() {
|
||||
#ifdef HAVE_AUDIOCD
|
||||
CddaSongLoader* cdda_song_loader = new CddaSongLoader;
|
||||
connect(cdda_song_loader, SIGNAL(SongsDurationLoaded(SongList)),
|
||||
this, SLOT(AudioCDTracksLoadedSlot(SongList)));
|
||||
connect(cdda_song_loader, SIGNAL(SongsMetadataLoaded(SongList)),
|
||||
this, SLOT(AudioCDTracksTagsLoaded(SongList)));
|
||||
connect(cdda_song_loader, SIGNAL(SongsDurationLoaded(SongList)), this,
|
||||
SLOT(AudioCDTracksLoadedSlot(SongList)));
|
||||
connect(cdda_song_loader, SIGNAL(SongsMetadataLoaded(SongList)), this,
|
||||
SLOT(AudioCDTracksTagsLoaded(SongList)));
|
||||
cdda_song_loader->LoadSongs();
|
||||
return Success;
|
||||
#else // HAVE_AUDIOCD
|
||||
@ -162,7 +162,7 @@ void SongLoader::AudioCDTracksTagsLoaded(const SongList& songs) {
|
||||
songs_ = songs;
|
||||
emit LoadAudioCDFinished(true);
|
||||
}
|
||||
#endif // HAVE_AUDIOCD
|
||||
#endif // HAVE_AUDIOCD
|
||||
|
||||
SongLoader::Result SongLoader::LoadLocal(const QString& filename) {
|
||||
qLog(Debug) << "Loading local file" << filename;
|
||||
@ -189,13 +189,11 @@ SongLoader::Result SongLoader::LoadLocal(const QString& filename) {
|
||||
}
|
||||
|
||||
// It's not in the database, load it asynchronously.
|
||||
preload_func_ =
|
||||
std::bind(&SongLoader::LoadLocalAsync, this, filename);
|
||||
preload_func_ = std::bind(&SongLoader::LoadLocalAsync, this, filename);
|
||||
return BlockingLoadRequired;
|
||||
}
|
||||
|
||||
void SongLoader::LoadLocalAsync(const QString& filename) {
|
||||
|
||||
// First check to see if it's a directory - if so we will load all the songs
|
||||
// inside right away.
|
||||
if (QFileInfo(filename).isDir()) {
|
||||
@ -213,7 +211,8 @@ void SongLoader::LoadLocalAsync(const QString& filename) {
|
||||
if (!parser) {
|
||||
// Check the file extension as well, maybe the magic failed, or it was a
|
||||
// basic M3U file which is just a plain list of filenames.
|
||||
parser = playlist_parser_->ParserForExtension(QFileInfo(filename).suffix().toLower());
|
||||
parser = playlist_parser_->ParserForExtension(
|
||||
QFileInfo(filename).suffix().toLower());
|
||||
}
|
||||
|
||||
if (parser) {
|
||||
@ -233,7 +232,7 @@ void SongLoader::LoadLocalAsync(const QString& filename) {
|
||||
|
||||
SongList song_list = cue_parser_->Load(&cue, matching_cue,
|
||||
QDir(filename.section('/', 0, -2)));
|
||||
for (Song song: song_list){
|
||||
for (Song song : song_list) {
|
||||
if (song.is_valid()) songs_ << song;
|
||||
}
|
||||
return;
|
||||
@ -403,8 +402,7 @@ void SongLoader::LoadRemote() {
|
||||
|
||||
// Add a probe to the sink so we can capture the data if it's a playlist
|
||||
GstPad* pad = gst_element_get_static_pad(fakesink, "sink");
|
||||
gst_pad_add_probe(
|
||||
pad, GST_PAD_PROBE_TYPE_BUFFER, &DataReady, this, NULL);
|
||||
gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_BUFFER, &DataReady, this, NULL);
|
||||
gst_object_unref(pad);
|
||||
|
||||
QEventLoop loop;
|
||||
@ -440,12 +438,11 @@ void SongLoader::TypeFound(GstElement*, uint, GstCaps* caps, void* self) {
|
||||
instance->StopTypefindAsync(true);
|
||||
}
|
||||
|
||||
GstPadProbeReturn SongLoader::DataReady(
|
||||
GstPad*, GstPadProbeInfo* info, gpointer self) {
|
||||
GstPadProbeReturn SongLoader::DataReady(GstPad*, GstPadProbeInfo* info,
|
||||
gpointer self) {
|
||||
SongLoader* instance = reinterpret_cast<SongLoader*>(self);
|
||||
|
||||
if (instance->state_ == Finished)
|
||||
return GST_PAD_PROBE_OK;
|
||||
if (instance->state_ == Finished) return GST_PAD_PROBE_OK;
|
||||
|
||||
GstBuffer* buffer = gst_pad_probe_info_get_buffer(info);
|
||||
GstMapInfo map;
|
||||
|
@ -84,10 +84,15 @@ signals:
|
||||
#ifdef HAVE_AUDIOCD
|
||||
void AudioCDTracksLoadedSlot(const SongList& songs);
|
||||
void AudioCDTracksTagsLoaded(const SongList& songs);
|
||||
#endif // HAVE_AUDIOCD
|
||||
#endif // HAVE_AUDIOCD
|
||||
|
||||
private:
|
||||
enum State { WaitingForType, WaitingForMagic, WaitingForData, Finished, };
|
||||
enum State {
|
||||
WaitingForType,
|
||||
WaitingForMagic,
|
||||
WaitingForData,
|
||||
Finished,
|
||||
};
|
||||
|
||||
Result LoadLocal(const QString& filename);
|
||||
void LoadLocalAsync(const QString& filename);
|
||||
|
@ -28,14 +28,14 @@ CddaDevice::CddaDevice(const QUrl& url, DeviceLister* lister,
|
||||
: ConnectedDevice(url, lister, unique_id, manager, app, database_id,
|
||||
first_time),
|
||||
cdda_song_loader_(url) {
|
||||
connect(&cdda_song_loader_, SIGNAL(SongsLoaded(SongList)),
|
||||
this, SLOT(SongsLoaded(SongList)));
|
||||
connect(&cdda_song_loader_, SIGNAL(SongsDurationLoaded(SongList)),
|
||||
this, SLOT(SongsLoaded(SongList)));
|
||||
connect(&cdda_song_loader_, SIGNAL(SongsMetadataLoaded(SongList)),
|
||||
this, SLOT(SongsLoaded(SongList)));
|
||||
connect(this, SIGNAL(SongsDiscovered(SongList)),
|
||||
model_, SLOT(SongsDiscovered(SongList)));
|
||||
connect(&cdda_song_loader_, SIGNAL(SongsLoaded(SongList)), this,
|
||||
SLOT(SongsLoaded(SongList)));
|
||||
connect(&cdda_song_loader_, SIGNAL(SongsDurationLoaded(SongList)), this,
|
||||
SLOT(SongsLoaded(SongList)));
|
||||
connect(&cdda_song_loader_, SIGNAL(SongsMetadataLoaded(SongList)), this,
|
||||
SLOT(SongsLoaded(SongList)));
|
||||
connect(this, SIGNAL(SongsDiscovered(SongList)), model_,
|
||||
SLOT(SongsDiscovered(SongList)));
|
||||
}
|
||||
|
||||
CddaDevice::~CddaDevice() {}
|
||||
|
@ -24,10 +24,7 @@
|
||||
#include "cddasongloader.h"
|
||||
|
||||
CddaSongLoader::CddaSongLoader(const QUrl& url, QObject* parent)
|
||||
: QObject(parent),
|
||||
url_(url),
|
||||
cdda_(nullptr),
|
||||
cdio_(nullptr) {}
|
||||
: QObject(parent), url_(url), cdda_(nullptr), cdio_(nullptr) {}
|
||||
|
||||
CddaSongLoader::~CddaSongLoader() {
|
||||
if (cdio_) cdio_destroy(cdio_);
|
||||
@ -58,11 +55,12 @@ void CddaSongLoader::LoadSongs() {
|
||||
}
|
||||
|
||||
if (!url_.isEmpty()) {
|
||||
g_object_set(cdda_, "device", g_strdup(url_.path().toLocal8Bit().constData()),
|
||||
nullptr);
|
||||
g_object_set(cdda_, "device",
|
||||
g_strdup(url_.path().toLocal8Bit().constData()), nullptr);
|
||||
}
|
||||
if (g_object_class_find_property (G_OBJECT_GET_CLASS (cdda_), "paranoia-mode")) {
|
||||
g_object_set (cdda_, "paranoia-mode", 0, NULL);
|
||||
if (g_object_class_find_property(G_OBJECT_GET_CLASS(cdda_),
|
||||
"paranoia-mode")) {
|
||||
g_object_set(cdda_, "paranoia-mode", 0, NULL);
|
||||
}
|
||||
|
||||
// Change the element's state to ready and paused, to be able to query it
|
||||
@ -93,21 +91,19 @@ void CddaSongLoader::LoadSongs() {
|
||||
song.set_id(track_number);
|
||||
song.set_valid(true);
|
||||
song.set_filetype(Song::Type_Cdda);
|
||||
song.set_url(
|
||||
GetUrlFromTrack(track_number));
|
||||
song.set_url(GetUrlFromTrack(track_number));
|
||||
song.set_title(QString("Track %1").arg(track_number));
|
||||
song.set_track(track_number);
|
||||
songs << song;
|
||||
}
|
||||
emit SongsLoaded(songs);
|
||||
|
||||
|
||||
gst_tag_register_musicbrainz_tags();
|
||||
|
||||
GstElement* pipeline = gst_pipeline_new("pipeline");
|
||||
GstElement* sink = gst_element_factory_make ("fakesink", NULL);
|
||||
gst_bin_add_many (GST_BIN (pipeline), cdda_, sink, NULL);
|
||||
gst_element_link (cdda_, sink);
|
||||
GstElement* sink = gst_element_factory_make("fakesink", NULL);
|
||||
gst_bin_add_many(GST_BIN(pipeline), cdda_, sink, NULL);
|
||||
gst_element_link(cdda_, sink);
|
||||
gst_element_set_state(pipeline, GST_STATE_READY);
|
||||
gst_element_set_state(pipeline, GST_STATE_PAUSED);
|
||||
|
||||
@ -115,10 +111,12 @@ void CddaSongLoader::LoadSongs() {
|
||||
GstMessage* msg = nullptr;
|
||||
GstMessage* msg_toc = nullptr;
|
||||
GstMessage* msg_tag = nullptr;
|
||||
while ((msg = gst_bus_timed_pop_filtered(GST_ELEMENT_BUS(pipeline),
|
||||
GST_SECOND, (GstMessageType)(GST_MESSAGE_TOC | GST_MESSAGE_TAG)))) {
|
||||
while ((msg = gst_bus_timed_pop_filtered(
|
||||
GST_ELEMENT_BUS(pipeline), GST_SECOND,
|
||||
(GstMessageType)(GST_MESSAGE_TOC | GST_MESSAGE_TAG)))) {
|
||||
if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_TOC) {
|
||||
if (msg_toc) gst_message_unref(msg_toc); // Shouldn't happen, but just in case
|
||||
if (msg_toc)
|
||||
gst_message_unref(msg_toc); // Shouldn't happen, but just in case
|
||||
msg_toc = msg;
|
||||
} else if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_TAG) {
|
||||
if (msg_tag) gst_message_unref(msg_tag);
|
||||
@ -129,16 +127,16 @@ void CddaSongLoader::LoadSongs() {
|
||||
// Handle TOC message: get tracks duration
|
||||
if (msg_toc) {
|
||||
GstToc* toc;
|
||||
gst_message_parse_toc (msg_toc, &toc, nullptr);
|
||||
gst_message_parse_toc(msg_toc, &toc, nullptr);
|
||||
if (toc) {
|
||||
GList* entries = gst_toc_get_entries(toc);
|
||||
if (entries && songs.size() <= g_list_length (entries)) {
|
||||
if (entries && songs.size() <= g_list_length(entries)) {
|
||||
int i = 0;
|
||||
for (GList* node = entries; node != nullptr; node = node->next) {
|
||||
GstTocEntry *entry = static_cast<GstTocEntry*>(node->data);
|
||||
GstTocEntry* entry = static_cast<GstTocEntry*>(node->data);
|
||||
quint64 duration = 0;
|
||||
gint64 start, stop;
|
||||
if (gst_toc_entry_get_start_stop_times (entry, &start, &stop))
|
||||
if (gst_toc_entry_get_start_stop_times(entry, &start, &stop))
|
||||
duration = stop - start;
|
||||
songs[i++].set_length_nanosec(duration);
|
||||
}
|
||||
@ -159,8 +157,9 @@ void CddaSongLoader::LoadSongs() {
|
||||
qLog(Info) << "MusicBrainz discid: " << musicbrainz_discid;
|
||||
|
||||
MusicBrainzClient* musicbrainz_client = new MusicBrainzClient;
|
||||
connect(musicbrainz_client, SIGNAL(Finished(const QString&, const QString&,
|
||||
MusicBrainzClient::ResultList)),
|
||||
connect(musicbrainz_client,
|
||||
SIGNAL(Finished(const QString&, const QString&,
|
||||
MusicBrainzClient::ResultList)),
|
||||
SLOT(AudioCDTagsLoaded(const QString&, const QString&,
|
||||
MusicBrainzClient::ResultList)));
|
||||
musicbrainz_client->StartDiscIdRequest(musicbrainz_discid);
|
||||
|
@ -37,23 +37,23 @@ class CddaSongLoader : public QObject {
|
||||
public:
|
||||
CddaSongLoader(
|
||||
// Url of the CD device. Will use the default device if empty
|
||||
const QUrl& url = QUrl(),
|
||||
QObject* parent = nullptr);
|
||||
const QUrl& url = QUrl(), QObject* parent = nullptr);
|
||||
~CddaSongLoader();
|
||||
|
||||
// Load songs.
|
||||
// Signals declared below will be emitted anytime new information will be available.
|
||||
// Signals declared below will be emitted anytime new information will be
|
||||
// available.
|
||||
void LoadSongs();
|
||||
bool HasChanged();
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void SongsLoaded(const SongList& songs);
|
||||
void SongsDurationLoaded(const SongList& songs);
|
||||
void SongsMetadataLoaded(const SongList& songs);
|
||||
|
||||
private slots:
|
||||
void AudioCDTagsLoaded(const QString& artist, const QString& album,
|
||||
const MusicBrainzClient::ResultList& results);
|
||||
const MusicBrainzClient::ResultList& results);
|
||||
|
||||
private:
|
||||
QUrl GetUrlFromTrack(int track_number) const;
|
||||
@ -64,4 +64,4 @@ class CddaSongLoader : public QObject {
|
||||
QMutex mutex_load_;
|
||||
};
|
||||
|
||||
#endif // CDDASONGLOADER_H
|
||||
#endif // CDDASONGLOADER_H
|
||||
|
@ -253,13 +253,13 @@ void DeviceProperties::accept() {
|
||||
.toInt());
|
||||
|
||||
// By default no icon is selected and thus no current item is selected
|
||||
QString icon_name = "";
|
||||
if(ui_->icon->currentItem() != nullptr) {
|
||||
QString icon_name;
|
||||
if (ui_->icon->currentItem() != nullptr) {
|
||||
icon_name = ui_->icon->currentItem()->data(Qt::UserRole).toString();
|
||||
}
|
||||
|
||||
manager_->SetDeviceOptions(
|
||||
index_.row(), ui_->name->text(), icon_name, mode,format);
|
||||
manager_->SetDeviceOptions(index_.row(), ui_->name->text(), icon_name, mode,
|
||||
format);
|
||||
}
|
||||
|
||||
void DeviceProperties::OpenDevice() { manager_->Connect(index_.row()); }
|
||||
|
@ -285,8 +285,8 @@ void GstEngine::UpdateScope(int chunk_length) {
|
||||
gst_buffer_map(latest_buffer_, &map, GST_MAP_READ);
|
||||
|
||||
// determine where to split the buffer
|
||||
int chunk_density = (map.size * kNsecPerMsec) /
|
||||
GST_BUFFER_DURATION(latest_buffer_);
|
||||
int chunk_density =
|
||||
(map.size * kNsecPerMsec) / GST_BUFFER_DURATION(latest_buffer_);
|
||||
|
||||
int chunk_size = chunk_length * chunk_density;
|
||||
|
||||
@ -304,10 +304,9 @@ void GstEngine::UpdateScope(int chunk_length) {
|
||||
|
||||
// make sure we don't go beyond the end of the buffer
|
||||
if (scope_chunk_ == scope_chunks_ - 1) {
|
||||
bytes =
|
||||
qMin(static_cast<Engine::Scope::size_type>(
|
||||
map.size - (chunk_size * scope_chunk_)),
|
||||
scope_.size() * sizeof(sample_type));
|
||||
bytes = qMin(static_cast<Engine::Scope::size_type>(
|
||||
map.size - (chunk_size * scope_chunk_)),
|
||||
scope_.size() * sizeof(sample_type));
|
||||
} else {
|
||||
bytes = qMin(static_cast<Engine::Scope::size_type>(chunk_size),
|
||||
scope_.size() * sizeof(sample_type));
|
||||
@ -739,9 +738,8 @@ GstEngine::PluginDetailsList GstEngine::GetPluginList(
|
||||
if (QString(gst_element_factory_get_klass(factory)).contains(classname)) {
|
||||
PluginDetails details;
|
||||
details.name = QString::fromUtf8(gst_plugin_feature_get_name(p->data));
|
||||
details.description = QString::fromUtf8(
|
||||
gst_element_factory_get_metadata(factory,
|
||||
GST_ELEMENT_METADATA_DESCRIPTION));
|
||||
details.description = QString::fromUtf8(gst_element_factory_get_metadata(
|
||||
factory, GST_ELEMENT_METADATA_DESCRIPTION));
|
||||
ret << details;
|
||||
}
|
||||
p = g_list_next(p);
|
||||
|
@ -249,7 +249,8 @@ void GlobalSearchModel::GetChildResults(
|
||||
if (is_provider) {
|
||||
// Go through all the items (through the proxy to keep them ordered) and
|
||||
// add the ones belonging to this provider to our list
|
||||
for (int i = 0; i < proxy_->rowCount(invisibleRootItem()->index()); ++i) {
|
||||
for (int i = 0; i < proxy_->rowCount(invisibleRootItem()->index());
|
||||
++i) {
|
||||
QModelIndex child_index =
|
||||
proxy_->index(i, 0, invisibleRootItem()->index());
|
||||
const QStandardItem* child_item =
|
||||
|
@ -249,16 +249,14 @@ SkyFmService::SkyFmService(Application* app, InternetModel* model,
|
||||
|
||||
JazzRadioService::JazzRadioService(Application* app, InternetModel* model,
|
||||
QObject* parent)
|
||||
: DigitallyImportedServiceBase(
|
||||
"JazzRadio", "JAZZRADIO.com", QUrl("http://www.jazzradio.com"),
|
||||
QIcon(":/providers/jazzradio.png"), "jazzradio", app, model, true,
|
||||
parent) {
|
||||
}
|
||||
: DigitallyImportedServiceBase("JazzRadio", "JAZZRADIO.com",
|
||||
QUrl("http://www.jazzradio.com"),
|
||||
QIcon(":/providers/jazzradio.png"),
|
||||
"jazzradio", app, model, true, parent) {}
|
||||
|
||||
RockRadioService::RockRadioService(Application* app, InternetModel* model,
|
||||
QObject* parent)
|
||||
: DigitallyImportedServiceBase(
|
||||
"RockRadio", "ROCKRADIO.com", QUrl("http://www.rockradio.com"),
|
||||
QIcon(":/providers/rockradio.png"), "rockradio", app, model, false,
|
||||
parent) {
|
||||
}
|
||||
: DigitallyImportedServiceBase("RockRadio", "ROCKRADIO.com",
|
||||
QUrl("http://www.rockradio.com"),
|
||||
QIcon(":/providers/rockradio.png"),
|
||||
"rockradio", app, model, false, parent) {}
|
||||
|
@ -38,8 +38,7 @@ class DigitallyImportedServiceBase : public InternetService {
|
||||
const QUrl& homepage_url, const QIcon& icon,
|
||||
const QString& api_service_name,
|
||||
Application* app, InternetModel* model,
|
||||
bool has_premium,
|
||||
QObject* parent = nullptr);
|
||||
bool has_premium, QObject* parent = nullptr);
|
||||
~DigitallyImportedServiceBase();
|
||||
|
||||
static const char* kSettingsGroup;
|
||||
@ -98,7 +97,7 @@ signals:
|
||||
int premium_audio_type_;
|
||||
QString username_;
|
||||
QString listen_hash_;
|
||||
bool has_premium_; // Does the service has premium features?
|
||||
bool has_premium_; // Does the service has premium features?
|
||||
|
||||
QStandardItem* root_;
|
||||
|
||||
@ -118,7 +117,8 @@ class DigitallyImportedService : public DigitallyImportedServiceBase {
|
||||
|
||||
class SkyFmService : public DigitallyImportedServiceBase {
|
||||
public:
|
||||
SkyFmService(Application* app, InternetModel* model, QObject* parent = nullptr);
|
||||
SkyFmService(Application* app, InternetModel* model,
|
||||
QObject* parent = nullptr);
|
||||
};
|
||||
|
||||
class JazzRadioService : public DigitallyImportedServiceBase {
|
||||
|
@ -54,10 +54,10 @@ class GroupByDialogPrivate {
|
||||
Mapping,
|
||||
indexed_by<
|
||||
ordered_unique<tag<tag_index>,
|
||||
member<Mapping, int, &Mapping::combo_box_index> >,
|
||||
member<Mapping, int, &Mapping::combo_box_index>>,
|
||||
ordered_unique<tag<tag_group_by>,
|
||||
member<Mapping, LibraryModel::GroupBy,
|
||||
&Mapping::group_by> > > > MappingContainer;
|
||||
&Mapping::group_by>>>> MappingContainer;
|
||||
|
||||
public:
|
||||
MappingContainer mapping_;
|
||||
|
@ -918,7 +918,8 @@ LibraryItem* LibraryModel::ItemFromQuery(GroupBy type, bool signal,
|
||||
item->metadata.set_album(row.value(1).toString());
|
||||
item->metadata.set_grouping(row.value(2).toString());
|
||||
item->key = PrettyYearAlbum(year, item->metadata.album());
|
||||
item->sort_text = SortTextForYear(year) + item->metadata.grouping() + item->metadata.album();
|
||||
item->sort_text = SortTextForYear(year) + item->metadata.grouping() +
|
||||
item->metadata.album();
|
||||
break;
|
||||
|
||||
case GroupBy_Year:
|
||||
|
@ -55,8 +55,8 @@ void MusicBrainzClient::Start(int id, const QStringList& mbid_list) {
|
||||
|
||||
QNetworkReply* reply = network_->get(req);
|
||||
NewClosure(reply, SIGNAL(finished()), this,
|
||||
SLOT(RequestFinished(QNetworkReply*, int, int)),
|
||||
reply, id, request_number++);
|
||||
SLOT(RequestFinished(QNetworkReply*, int, int)), reply, id,
|
||||
request_number++);
|
||||
requests_.insert(id, reply);
|
||||
|
||||
timeouts_->AddReply(reply);
|
||||
@ -102,9 +102,9 @@ void MusicBrainzClient::DiscIdRequestFinished(const QString& discid,
|
||||
|
||||
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() !=
|
||||
200) {
|
||||
qLog(Error) << "Error:" <<
|
||||
reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() <<
|
||||
"http status code received";
|
||||
qLog(Error) << "Error:"
|
||||
<< reply->attribute(QNetworkRequest::HttpStatusCodeAttribute)
|
||||
.toInt() << "http status code received";
|
||||
qLog(Error) << reply->readAll();
|
||||
emit Finished(artist, album, ret);
|
||||
return;
|
||||
@ -154,13 +154,15 @@ void MusicBrainzClient::DiscIdRequestFinished(const QString& discid,
|
||||
emit Finished(artist, album, UniqueResults(ret, SortResults));
|
||||
}
|
||||
|
||||
void MusicBrainzClient::RequestFinished(QNetworkReply* reply, int id, int request_number) {
|
||||
void MusicBrainzClient::RequestFinished(QNetworkReply* reply, int id,
|
||||
int request_number) {
|
||||
reply->deleteLater();
|
||||
|
||||
const int nb_removed = requests_.remove(id, reply);
|
||||
if (nb_removed != 1) {
|
||||
qLog(Error) << "Error: unknown reply received:" << nb_removed <<
|
||||
"requests removed, while only one was supposed to be removed";
|
||||
qLog(Error)
|
||||
<< "Error: unknown reply received:" << nb_removed
|
||||
<< "requests removed, while only one was supposed to be removed";
|
||||
}
|
||||
|
||||
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() ==
|
||||
@ -180,8 +182,9 @@ void MusicBrainzClient::RequestFinished(QNetworkReply* reply, int id, int reques
|
||||
}
|
||||
pending_results_[id] << PendingResults(request_number, res);
|
||||
} else {
|
||||
qLog(Error) << "Error:" << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() <<
|
||||
"http status code received";
|
||||
qLog(Error) << "Error:"
|
||||
<< reply->attribute(QNetworkRequest::HttpStatusCodeAttribute)
|
||||
.toInt() << "http status code received";
|
||||
qLog(Error) << reply->readAll();
|
||||
}
|
||||
|
||||
@ -358,7 +361,6 @@ MusicBrainzClient::Release MusicBrainzClient::ParseRelease(
|
||||
|
||||
MusicBrainzClient::ResultList MusicBrainzClient::UniqueResults(
|
||||
const ResultList& results, UniqueResultsSortOption opt) {
|
||||
|
||||
ResultList ret;
|
||||
if (opt == SortResults) {
|
||||
ret = QSet<Result>::fromList(results).toList();
|
||||
|
@ -295,7 +295,8 @@ void IncomingDataParser::RateSong(const pb::remote::Message& msg) {
|
||||
emit RateCurrentSong(rating);
|
||||
}
|
||||
|
||||
void IncomingDataParser::GlobalSearch(RemoteClient *client, const pb::remote::Message &msg) {
|
||||
void IncomingDataParser::GlobalSearch(RemoteClient* client,
|
||||
const pb::remote::Message& msg) {
|
||||
emit DoGlobalSearch(QStringFromStdString(msg.request_global_search().query()),
|
||||
client);
|
||||
}
|
||||
|
@ -75,8 +75,7 @@ void OutgoingDataCreator::SetClients(QList<RemoteClient*>* clients) {
|
||||
SLOT(ResultsAvailable(int, SearchProvider::ResultList)),
|
||||
Qt::QueuedConnection);
|
||||
|
||||
connect(app_->global_search(),
|
||||
SIGNAL(SearchFinished(int)),
|
||||
connect(app_->global_search(), SIGNAL(SearchFinished(int)),
|
||||
SLOT(SearchFinished(int)));
|
||||
}
|
||||
|
||||
@ -130,8 +129,8 @@ void OutgoingDataCreator::CheckEnabledProviders() {
|
||||
}
|
||||
}
|
||||
|
||||
SongInfoProvider* OutgoingDataCreator::ProviderByName(const QString& name)
|
||||
const {
|
||||
SongInfoProvider* OutgoingDataCreator::ProviderByName(
|
||||
const QString& name) const {
|
||||
for (SongInfoProvider* provider : fetcher_->providers()) {
|
||||
if (UltimateLyricsProvider* lyrics =
|
||||
qobject_cast<UltimateLyricsProvider*>(provider)) {
|
||||
@ -581,7 +580,6 @@ void OutgoingDataCreator::SendLyrics(int id,
|
||||
|
||||
void OutgoingDataCreator::SendSongs(
|
||||
const pb::remote::RequestDownloadSongs& request, RemoteClient* client) {
|
||||
|
||||
if (!download_queue_.contains(client)) {
|
||||
download_queue_.insert(client, QQueue<DownloadItem>());
|
||||
}
|
||||
@ -612,7 +610,7 @@ void OutgoingDataCreator::SendSongs(
|
||||
OfferNextSong(client);
|
||||
}
|
||||
|
||||
void OutgoingDataCreator::SendTotalFileSize(RemoteClient *client) {
|
||||
void OutgoingDataCreator::SendTotalFileSize(RemoteClient* client) {
|
||||
if (!download_queue_.contains(client)) return;
|
||||
|
||||
pb::remote::Message msg;
|
||||
@ -774,8 +772,8 @@ void OutgoingDataCreator::SendPlaylist(RemoteClient* client, int playlist_id) {
|
||||
}
|
||||
}
|
||||
|
||||
void OutgoingDataCreator::SendUrls(RemoteClient *client,
|
||||
const pb::remote::RequestDownloadSongs &request) {
|
||||
void OutgoingDataCreator::SendUrls(
|
||||
RemoteClient* client, const pb::remote::RequestDownloadSongs& request) {
|
||||
SongList song_list;
|
||||
|
||||
// First gather all valid songs
|
||||
@ -871,14 +869,16 @@ void OutgoingDataCreator::SendKitten(const QImage& kitten) {
|
||||
}
|
||||
}
|
||||
|
||||
void OutgoingDataCreator::DoGlobalSearch(const QString &query, RemoteClient *client) {
|
||||
void OutgoingDataCreator::DoGlobalSearch(const QString& query,
|
||||
RemoteClient* client) {
|
||||
int id = app_->global_search()->SearchAsync(query);
|
||||
|
||||
GlobalSearchRequest request(id, query, client);
|
||||
global_search_result_map_.insert(id, request);
|
||||
}
|
||||
|
||||
void OutgoingDataCreator::ResultsAvailable(int id, const SearchProvider::ResultList& results) {
|
||||
void OutgoingDataCreator::ResultsAvailable(
|
||||
int id, const SearchProvider::ResultList& results) {
|
||||
if (!global_search_result_map_.contains(id)) return;
|
||||
|
||||
GlobalSearchRequest search_request = global_search_result_map_.value(id);
|
||||
@ -886,12 +886,14 @@ void OutgoingDataCreator::ResultsAvailable(int id, const SearchProvider::ResultL
|
||||
QImage null_img;
|
||||
|
||||
pb::remote::Message msg;
|
||||
pb::remote::ResponseGlobalSearch* response = msg.mutable_response_global_search();
|
||||
pb::remote::ResponseGlobalSearch* response =
|
||||
msg.mutable_response_global_search();
|
||||
|
||||
msg.set_type(pb::remote::GLOBAL_SEARCH_RESULT);
|
||||
response->set_id(search_request.id_);
|
||||
response->set_query(DataCommaSizeFromQString(search_request.query_));
|
||||
response->set_search_provider(DataCommaSizeFromQString(results.first().provider_->name()));
|
||||
response->set_search_provider(
|
||||
DataCommaSizeFromQString(results.first().provider_->name()));
|
||||
|
||||
for (const SearchProvider::Result& result : results) {
|
||||
pb::remote::SongMetadata* pb_song = response->add_song_metadata();
|
||||
|
@ -42,10 +42,9 @@ struct GlobalSearchRequest {
|
||||
int id_;
|
||||
QString query_;
|
||||
RemoteClient* client_;
|
||||
GlobalSearchRequest()
|
||||
: id_(-1), client_(nullptr) {}
|
||||
GlobalSearchRequest() : id_(-1), client_(nullptr) {}
|
||||
GlobalSearchRequest(int i, const QString& q, RemoteClient* c)
|
||||
: id_(i), query_(q), client_(c) {}
|
||||
: id_(i), query_(q), client_(c) {}
|
||||
};
|
||||
|
||||
class OutgoingDataCreator : public QObject {
|
||||
@ -103,7 +102,7 @@ class OutgoingDataCreator : public QObject {
|
||||
QTimer* keep_alive_timer_;
|
||||
QTimer* track_position_timer_;
|
||||
int keep_alive_timeout_;
|
||||
QMap<RemoteClient*, QQueue<DownloadItem> > download_queue_;
|
||||
QMap<RemoteClient*, QQueue<DownloadItem>> download_queue_;
|
||||
int last_track_position_;
|
||||
bool aww_;
|
||||
|
||||
@ -124,7 +123,8 @@ class OutgoingDataCreator : public QObject {
|
||||
int song_count);
|
||||
void SendAlbum(RemoteClient* client, const Song& song);
|
||||
void SendPlaylist(RemoteClient* client, int playlist_id);
|
||||
void SendUrls(RemoteClient* client, const pb::remote::RequestDownloadSongs& request);
|
||||
void SendUrls(RemoteClient* client,
|
||||
const pb::remote::RequestDownloadSongs& request);
|
||||
void OfferNextSong(RemoteClient* client);
|
||||
void SendTotalFileSize(RemoteClient* client);
|
||||
};
|
||||
|
@ -421,7 +421,6 @@ void TagCompleter::ModelReady() {
|
||||
QWidget* TagCompletionItemDelegate::createEditor(QWidget* parent,
|
||||
const QStyleOptionViewItem&,
|
||||
const QModelIndex&) const {
|
||||
|
||||
QLineEdit* editor = new QLineEdit(parent);
|
||||
new TagCompleter(backend_, column_, editor);
|
||||
|
||||
|
@ -85,16 +85,18 @@ void SongLoaderInserter::LoadAudioCD(Playlist* destination, int row,
|
||||
enqueue_ = enqueue;
|
||||
|
||||
SongLoader* loader = new SongLoader(library_, player_, this);
|
||||
NewClosure(loader, SIGNAL(AudioCDTracksLoaded()),
|
||||
this, SLOT(AudioCDTracksLoaded(SongLoader*)), loader);
|
||||
connect(loader, SIGNAL(LoadAudioCDFinished(bool)), SLOT(AudioCDTagsLoaded(bool)));
|
||||
NewClosure(loader, SIGNAL(AudioCDTracksLoaded()), this,
|
||||
SLOT(AudioCDTracksLoaded(SongLoader*)), loader);
|
||||
connect(loader, SIGNAL(LoadAudioCDFinished(bool)),
|
||||
SLOT(AudioCDTagsLoaded(bool)));
|
||||
qLog(Info) << "Loading audio CD...";
|
||||
SongLoader::Result ret = loader->LoadAudioCD();
|
||||
if (ret == SongLoader::Error) {
|
||||
emit Error(tr("Error while loading audio CD"));
|
||||
delete loader;
|
||||
}
|
||||
// Songs will be loaded later: see AudioCDTracksLoaded and AudioCDTagsLoaded slots
|
||||
// Songs will be loaded later: see AudioCDTracksLoaded and AudioCDTagsLoaded
|
||||
// slots
|
||||
}
|
||||
|
||||
void SongLoaderInserter::DestinationDestroyed() { destination_ = nullptr; }
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "tagreader.h"
|
||||
#include "core/song.h"
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
#include "internet/lastfmcompat.h"
|
||||
#include "internet/lastfmcompat.h"
|
||||
#endif
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
@ -64,7 +64,8 @@ class SongTest : public ::testing::Test {
|
||||
tag_reader.SaveFile(filename, pb_song);
|
||||
}
|
||||
|
||||
static void WriteSongStatisticsToFile(const Song& song, const QString& filename) {
|
||||
static void WriteSongStatisticsToFile(const Song& song,
|
||||
const QString& filename) {
|
||||
TagReader tag_reader;
|
||||
::pb::tagreader::SongMetadata pb_song;
|
||||
song.ToProtobuf(&pb_song);
|
||||
@ -79,7 +80,6 @@ class SongTest : public ::testing::Test {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#ifdef HAVE_LIBLASTFM
|
||||
TEST_F(SongTest, InitsFromLastFM) {
|
||||
Song song;
|
||||
@ -95,7 +95,7 @@ TEST_F(SongTest, InitsFromLastFM) {
|
||||
EXPECT_EQ("Baz", song.album());
|
||||
EXPECT_EQ("Bar", song.artist());
|
||||
}
|
||||
#endif // HAVE_LIBLASTFM
|
||||
#endif // HAVE_LIBLASTFM
|
||||
|
||||
/*TEST_F(SongTest, InitsFromFile) {
|
||||
QTemporaryFile temp;
|
||||
@ -156,14 +156,13 @@ TEST_F(SongTest, FMPSPlayCountBoth) {
|
||||
|
||||
TEST_F(SongTest, FMPSUnrated) {
|
||||
QStringList files_to_test;
|
||||
files_to_test <<
|
||||
":/testdata/beep.m4a" <<
|
||||
":/testdata/beep.mp3" <<
|
||||
":/testdata/beep.flac" <<
|
||||
":/testdata/beep.ogg" <<
|
||||
":/testdata/beep.spx" <<
|
||||
":/testdata/beep.wav" <<
|
||||
":/testdata/beep.wma";
|
||||
files_to_test << ":/testdata/beep.m4a"
|
||||
<< ":/testdata/beep.mp3"
|
||||
<< ":/testdata/beep.flac"
|
||||
<< ":/testdata/beep.ogg"
|
||||
<< ":/testdata/beep.spx"
|
||||
<< ":/testdata/beep.wav"
|
||||
<< ":/testdata/beep.wma";
|
||||
for (const QString& test_filename : files_to_test) {
|
||||
TemporaryResource r(test_filename);
|
||||
Song song = ReadSongFromFile(r.fileName());
|
||||
@ -295,7 +294,7 @@ TEST_F(SongTest, StatisticsASF) {
|
||||
EXPECT_EQ(1337, new_song.playcount());
|
||||
EXPECT_EQ(87, new_song.score());
|
||||
}
|
||||
#endif // TAGLIB_WITH_ASF
|
||||
#endif // TAGLIB_WITH_ASF
|
||||
|
||||
TEST_F(SongTest, RatingMP4) {
|
||||
TemporaryResource r(":/testdata/beep.m4a");
|
||||
|
Loading…
Reference in New Issue
Block a user