From 942fda88bfad4a979632aa29b55afb328c280f37 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 4 Nov 2014 21:46:10 +0100 Subject: [PATCH 1/5] Check if there is a current icon item in the device manager. Fixes #4604 #4555 --- src/devices/deviceproperties.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/devices/deviceproperties.cpp b/src/devices/deviceproperties.cpp index cc8f85067..0dbf64dd2 100644 --- a/src/devices/deviceproperties.cpp +++ b/src/devices/deviceproperties.cpp @@ -252,9 +252,14 @@ void DeviceProperties::accept() { ui_->transcode_format->itemData(ui_->transcode_format->currentIndex()) .toInt()); + // By default no icon is selected and thus no current item is selected + QString icon_name = ""; + if(ui_->icon->currentItem() != nullptr) { + icon_name = ui_->icon->currentItem()->data(Qt::UserRole).toString(); + } + manager_->SetDeviceOptions( - index_.row(), ui_->name->text(), - ui_->icon->currentItem()->data(Qt::UserRole).toString(), mode, format); + index_.row(), ui_->name->text(), icon_name, mode,format); } void DeviceProperties::OpenDevice() { manager_->Connect(index_.row()); } From 5a2348fae6ea545d793e612414571caafbd5ad6f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 5 Nov 2014 11:51:38 +0100 Subject: [PATCH 2/5] Use constructor for QString and make format --- ext/libclementine-tagreader/tagreader.cpp | 20 ++++----- src/core/song.cpp | 6 +-- src/core/songloader.cpp | 29 ++++++------ src/core/songloader.h | 9 +++- src/devices/cddadevice.cpp | 16 +++---- src/devices/cddasongloader.cpp | 45 +++++++++---------- src/devices/cddasongloader.h | 12 ++--- src/devices/deviceproperties.cpp | 8 ++-- src/engines/gstengine.cpp | 16 +++---- src/globalsearch/globalsearchmodel.cpp | 3 +- src/internet/digitallyimportedservicebase.cpp | 18 ++++---- src/internet/digitallyimportedservicebase.h | 8 ++-- src/library/groupbydialog.cpp | 4 +- src/library/librarymodel.cpp | 3 +- src/musicbrainz/musicbrainzclient.cpp | 24 +++++----- src/networkremote/incomingdataparser.cpp | 3 +- src/networkremote/outgoingdatacreator.cpp | 26 ++++++----- src/networkremote/outgoingdatacreator.h | 10 ++--- src/playlist/playlistdelegates.cpp | 1 - src/playlist/songloaderinserter.cpp | 10 +++-- tests/song_test.cpp | 25 +++++------ 21 files changed, 149 insertions(+), 147 deletions(-) diff --git a/ext/libclementine-tagreader/tagreader.cpp b/ext/libclementine-tagreader/tagreader.cpp index 5a35d680a..dfadc4017 100644 --- a/ext/libclementine-tagreader/tagreader.cpp +++ b/ext/libclementine-tagreader/tagreader.cpp @@ -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 stream( - new CloudStream(download_url, title, size, authorisation_header, network_)); + std::unique_ptr stream(new CloudStream( + download_url, title, size, authorisation_header, network_)); stream->Precache(); std::unique_ptr 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; diff --git a/src/core/song.cpp b/src/core/song.cpp index f5ff92e8b..392464bcf 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -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()); } diff --git a/src/core/songloader.cpp b/src/core/songloader.cpp index 440944f9a..92d5dd9a6 100644 --- a/src/core/songloader.cpp +++ b/src/core/songloader.cpp @@ -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(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; diff --git a/src/core/songloader.h b/src/core/songloader.h index a794e2663..32ec35d70 100644 --- a/src/core/songloader.h +++ b/src/core/songloader.h @@ -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); diff --git a/src/devices/cddadevice.cpp b/src/devices/cddadevice.cpp index 91bd77a5d..fd64beab7 100644 --- a/src/devices/cddadevice.cpp +++ b/src/devices/cddadevice.cpp @@ -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() {} diff --git a/src/devices/cddasongloader.cpp b/src/devices/cddasongloader.cpp index 9a584b10b..d8f5f23b5 100644 --- a/src/devices/cddasongloader.cpp +++ b/src/devices/cddasongloader.cpp @@ -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(node->data); + GstTocEntry* entry = static_cast(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); diff --git a/src/devices/cddasongloader.h b/src/devices/cddasongloader.h index d62bcbac4..9fa5cebbc 100644 --- a/src/devices/cddasongloader.h +++ b/src/devices/cddasongloader.h @@ -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 diff --git a/src/devices/deviceproperties.cpp b/src/devices/deviceproperties.cpp index 0dbf64dd2..c097d409d 100644 --- a/src/devices/deviceproperties.cpp +++ b/src/devices/deviceproperties.cpp @@ -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()); } diff --git a/src/engines/gstengine.cpp b/src/engines/gstengine.cpp index 7f903ff7b..9bbccad6c 100755 --- a/src/engines/gstengine.cpp +++ b/src/engines/gstengine.cpp @@ -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( - map.size - (chunk_size * scope_chunk_)), - scope_.size() * sizeof(sample_type)); + bytes = qMin(static_cast( + map.size - (chunk_size * scope_chunk_)), + scope_.size() * sizeof(sample_type)); } else { bytes = qMin(static_cast(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); diff --git a/src/globalsearch/globalsearchmodel.cpp b/src/globalsearch/globalsearchmodel.cpp index 65a2b57ff..4be0b6125 100644 --- a/src/globalsearch/globalsearchmodel.cpp +++ b/src/globalsearch/globalsearchmodel.cpp @@ -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 = diff --git a/src/internet/digitallyimportedservicebase.cpp b/src/internet/digitallyimportedservicebase.cpp index 3098a5571..7e19f852f 100644 --- a/src/internet/digitallyimportedservicebase.cpp +++ b/src/internet/digitallyimportedservicebase.cpp @@ -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) {} diff --git a/src/internet/digitallyimportedservicebase.h b/src/internet/digitallyimportedservicebase.h index f210f5abf..1b61e955f 100644 --- a/src/internet/digitallyimportedservicebase.h +++ b/src/internet/digitallyimportedservicebase.h @@ -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 { diff --git a/src/library/groupbydialog.cpp b/src/library/groupbydialog.cpp index 1b3e84571..b7676852a 100644 --- a/src/library/groupbydialog.cpp +++ b/src/library/groupbydialog.cpp @@ -54,10 +54,10 @@ class GroupByDialogPrivate { Mapping, indexed_by< ordered_unique, - member >, + member>, ordered_unique, member > > > MappingContainer; + &Mapping::group_by>>>> MappingContainer; public: MappingContainer mapping_; diff --git a/src/library/librarymodel.cpp b/src/library/librarymodel.cpp index 9d5e1e39f..0486b21c4 100644 --- a/src/library/librarymodel.cpp +++ b/src/library/librarymodel.cpp @@ -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: diff --git a/src/musicbrainz/musicbrainzclient.cpp b/src/musicbrainz/musicbrainzclient.cpp index 149cd9b79..a3c5bb2b3 100644 --- a/src/musicbrainz/musicbrainzclient.cpp +++ b/src/musicbrainz/musicbrainzclient.cpp @@ -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::fromList(results).toList(); diff --git a/src/networkremote/incomingdataparser.cpp b/src/networkremote/incomingdataparser.cpp index d78832746..961a14dff 100644 --- a/src/networkremote/incomingdataparser.cpp +++ b/src/networkremote/incomingdataparser.cpp @@ -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); } diff --git a/src/networkremote/outgoingdatacreator.cpp b/src/networkremote/outgoingdatacreator.cpp index d5db3bac4..1d7c3dc70 100644 --- a/src/networkremote/outgoingdatacreator.cpp +++ b/src/networkremote/outgoingdatacreator.cpp @@ -75,8 +75,7 @@ void OutgoingDataCreator::SetClients(QList* 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(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()); } @@ -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(); diff --git a/src/networkremote/outgoingdatacreator.h b/src/networkremote/outgoingdatacreator.h index d4eabe735..9140a4e22 100644 --- a/src/networkremote/outgoingdatacreator.h +++ b/src/networkremote/outgoingdatacreator.h @@ -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 > download_queue_; + QMap> 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); }; diff --git a/src/playlist/playlistdelegates.cpp b/src/playlist/playlistdelegates.cpp index 76b15544c..e38e6a35b 100644 --- a/src/playlist/playlistdelegates.cpp +++ b/src/playlist/playlistdelegates.cpp @@ -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); diff --git a/src/playlist/songloaderinserter.cpp b/src/playlist/songloaderinserter.cpp index 031c64518..75e48d551 100644 --- a/src/playlist/songloaderinserter.cpp +++ b/src/playlist/songloaderinserter.cpp @@ -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; } diff --git a/tests/song_test.cpp b/tests/song_test.cpp index 1fe39ae42..cf7097bff 100644 --- a/tests/song_test.cpp +++ b/tests/song_test.cpp @@ -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"); From 2e64b24290b04ff39d7dae708fbd091c4ba28331 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 5 Nov 2014 12:25:09 +0100 Subject: [PATCH 3/5] Revert "Use constructor for QString and make format" This reverts commit 5a2348fae6ea545d793e612414571caafbd5ad6f. --- ext/libclementine-tagreader/tagreader.cpp | 20 +++++---- src/core/song.cpp | 6 +-- src/core/songloader.cpp | 29 ++++++------ src/core/songloader.h | 9 +--- src/devices/cddadevice.cpp | 16 +++---- src/devices/cddasongloader.cpp | 45 ++++++++++--------- src/devices/cddasongloader.h | 12 ++--- src/devices/deviceproperties.cpp | 8 ++-- src/engines/gstengine.cpp | 16 ++++--- src/globalsearch/globalsearchmodel.cpp | 3 +- src/internet/digitallyimportedservicebase.cpp | 18 ++++---- src/internet/digitallyimportedservicebase.h | 8 ++-- src/library/groupbydialog.cpp | 4 +- src/library/librarymodel.cpp | 3 +- src/musicbrainz/musicbrainzclient.cpp | 24 +++++----- src/networkremote/incomingdataparser.cpp | 3 +- src/networkremote/outgoingdatacreator.cpp | 26 +++++------ src/networkremote/outgoingdatacreator.h | 10 ++--- src/playlist/playlistdelegates.cpp | 1 + src/playlist/songloaderinserter.cpp | 10 ++--- tests/song_test.cpp | 25 ++++++----- 21 files changed, 147 insertions(+), 149 deletions(-) diff --git a/ext/libclementine-tagreader/tagreader.cpp b/ext/libclementine-tagreader/tagreader.cpp index dfadc4017..5a35d680a 100644 --- a/ext/libclementine-tagreader/tagreader.cpp +++ b/ext/libclementine-tagreader/tagreader.cpp @@ -502,9 +502,10 @@ 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", @@ -539,6 +540,7 @@ 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()))); } @@ -951,8 +953,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 stream(new CloudStream( - download_url, title, size, authorisation_header, network_)); + std::unique_ptr stream( + new CloudStream(download_url, title, size, authorisation_header, network_)); stream->Precache(); std::unique_ptr tag; if (mime_type == "audio/mpeg" && title.endsWith(".mp3")) { @@ -961,8 +963,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" || @@ -981,8 +983,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; diff --git a/src/core/song.cpp b/src/core/song.cpp index 392464bcf..f5ff92e8b 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -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()); } diff --git a/src/core/songloader.cpp b/src/core/songloader.cpp index 92d5dd9a6..440944f9a 100644 --- a/src/core/songloader.cpp +++ b/src/core/songloader.cpp @@ -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,11 +189,13 @@ 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()) { @@ -211,8 +213,7 @@ 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) { @@ -232,7 +233,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; @@ -402,7 +403,8 @@ 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; @@ -438,11 +440,12 @@ 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(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; diff --git a/src/core/songloader.h b/src/core/songloader.h index 32ec35d70..a794e2663 100644 --- a/src/core/songloader.h +++ b/src/core/songloader.h @@ -84,15 +84,10 @@ 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); diff --git a/src/devices/cddadevice.cpp b/src/devices/cddadevice.cpp index fd64beab7..91bd77a5d 100644 --- a/src/devices/cddadevice.cpp +++ b/src/devices/cddadevice.cpp @@ -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() {} diff --git a/src/devices/cddasongloader.cpp b/src/devices/cddasongloader.cpp index d8f5f23b5..9a584b10b 100644 --- a/src/devices/cddasongloader.cpp +++ b/src/devices/cddasongloader.cpp @@ -24,7 +24,10 @@ #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_); @@ -55,12 +58,11 @@ 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 @@ -91,19 +93,21 @@ 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); @@ -111,12 +115,10 @@ 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); @@ -127,16 +129,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(node->data); + GstTocEntry *entry = static_cast(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); } @@ -157,9 +159,8 @@ 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); diff --git a/src/devices/cddasongloader.h b/src/devices/cddasongloader.h index 9fa5cebbc..d62bcbac4 100644 --- a/src/devices/cddasongloader.h +++ b/src/devices/cddasongloader.h @@ -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 @@ signals: QMutex mutex_load_; }; -#endif // CDDASONGLOADER_H +#endif // CDDASONGLOADER_H diff --git a/src/devices/deviceproperties.cpp b/src/devices/deviceproperties.cpp index c097d409d..0dbf64dd2 100644 --- a/src/devices/deviceproperties.cpp +++ b/src/devices/deviceproperties.cpp @@ -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()); } diff --git a/src/engines/gstengine.cpp b/src/engines/gstengine.cpp index 9bbccad6c..7f903ff7b 100755 --- a/src/engines/gstengine.cpp +++ b/src/engines/gstengine.cpp @@ -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,9 +304,10 @@ 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( - map.size - (chunk_size * scope_chunk_)), - scope_.size() * sizeof(sample_type)); + bytes = + qMin(static_cast( + map.size - (chunk_size * scope_chunk_)), + scope_.size() * sizeof(sample_type)); } else { bytes = qMin(static_cast(chunk_size), scope_.size() * sizeof(sample_type)); @@ -738,8 +739,9 @@ 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); diff --git a/src/globalsearch/globalsearchmodel.cpp b/src/globalsearch/globalsearchmodel.cpp index 4be0b6125..65a2b57ff 100644 --- a/src/globalsearch/globalsearchmodel.cpp +++ b/src/globalsearch/globalsearchmodel.cpp @@ -249,8 +249,7 @@ 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 = diff --git a/src/internet/digitallyimportedservicebase.cpp b/src/internet/digitallyimportedservicebase.cpp index 7e19f852f..3098a5571 100644 --- a/src/internet/digitallyimportedservicebase.cpp +++ b/src/internet/digitallyimportedservicebase.cpp @@ -249,14 +249,16 @@ 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) { +} diff --git a/src/internet/digitallyimportedservicebase.h b/src/internet/digitallyimportedservicebase.h index 1b61e955f..f210f5abf 100644 --- a/src/internet/digitallyimportedservicebase.h +++ b/src/internet/digitallyimportedservicebase.h @@ -38,7 +38,8 @@ 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; @@ -97,7 +98,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_; @@ -117,8 +118,7 @@ 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 { diff --git a/src/library/groupbydialog.cpp b/src/library/groupbydialog.cpp index b7676852a..1b3e84571 100644 --- a/src/library/groupbydialog.cpp +++ b/src/library/groupbydialog.cpp @@ -54,10 +54,10 @@ class GroupByDialogPrivate { Mapping, indexed_by< ordered_unique, - member>, + member >, ordered_unique, member>>> MappingContainer; + &Mapping::group_by> > > > MappingContainer; public: MappingContainer mapping_; diff --git a/src/library/librarymodel.cpp b/src/library/librarymodel.cpp index 0486b21c4..9d5e1e39f 100644 --- a/src/library/librarymodel.cpp +++ b/src/library/librarymodel.cpp @@ -918,8 +918,7 @@ 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: diff --git a/src/musicbrainz/musicbrainzclient.cpp b/src/musicbrainz/musicbrainzclient.cpp index a3c5bb2b3..149cd9b79 100644 --- a/src/musicbrainz/musicbrainzclient.cpp +++ b/src/musicbrainz/musicbrainzclient.cpp @@ -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,15 +154,13 @@ 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() == @@ -182,9 +180,8 @@ void MusicBrainzClient::RequestFinished(QNetworkReply* reply, int id, } 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(); } @@ -361,6 +358,7 @@ MusicBrainzClient::Release MusicBrainzClient::ParseRelease( MusicBrainzClient::ResultList MusicBrainzClient::UniqueResults( const ResultList& results, UniqueResultsSortOption opt) { + ResultList ret; if (opt == SortResults) { ret = QSet::fromList(results).toList(); diff --git a/src/networkremote/incomingdataparser.cpp b/src/networkremote/incomingdataparser.cpp index 961a14dff..d78832746 100644 --- a/src/networkremote/incomingdataparser.cpp +++ b/src/networkremote/incomingdataparser.cpp @@ -295,8 +295,7 @@ 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); } diff --git a/src/networkremote/outgoingdatacreator.cpp b/src/networkremote/outgoingdatacreator.cpp index 1d7c3dc70..d5db3bac4 100644 --- a/src/networkremote/outgoingdatacreator.cpp +++ b/src/networkremote/outgoingdatacreator.cpp @@ -75,7 +75,8 @@ void OutgoingDataCreator::SetClients(QList* 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))); } @@ -129,8 +130,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(provider)) { @@ -580,6 +581,7 @@ 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()); } @@ -610,7 +612,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; @@ -772,8 +774,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 @@ -869,16 +871,14 @@ 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,14 +886,12 @@ void OutgoingDataCreator::ResultsAvailable( 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(); diff --git a/src/networkremote/outgoingdatacreator.h b/src/networkremote/outgoingdatacreator.h index 9140a4e22..d4eabe735 100644 --- a/src/networkremote/outgoingdatacreator.h +++ b/src/networkremote/outgoingdatacreator.h @@ -42,9 +42,10 @@ 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 { @@ -102,7 +103,7 @@ class OutgoingDataCreator : public QObject { QTimer* keep_alive_timer_; QTimer* track_position_timer_; int keep_alive_timeout_; - QMap> download_queue_; + QMap > download_queue_; int last_track_position_; bool aww_; @@ -123,8 +124,7 @@ 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); }; diff --git a/src/playlist/playlistdelegates.cpp b/src/playlist/playlistdelegates.cpp index e38e6a35b..76b15544c 100644 --- a/src/playlist/playlistdelegates.cpp +++ b/src/playlist/playlistdelegates.cpp @@ -421,6 +421,7 @@ void TagCompleter::ModelReady() { QWidget* TagCompletionItemDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem&, const QModelIndex&) const { + QLineEdit* editor = new QLineEdit(parent); new TagCompleter(backend_, column_, editor); diff --git a/src/playlist/songloaderinserter.cpp b/src/playlist/songloaderinserter.cpp index 75e48d551..031c64518 100644 --- a/src/playlist/songloaderinserter.cpp +++ b/src/playlist/songloaderinserter.cpp @@ -85,18 +85,16 @@ 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; } diff --git a/tests/song_test.cpp b/tests/song_test.cpp index cf7097bff..1fe39ae42 100644 --- a/tests/song_test.cpp +++ b/tests/song_test.cpp @@ -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,8 +64,7 @@ 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); @@ -80,6 +79,7 @@ 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,13 +156,14 @@ 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()); @@ -294,7 +295,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"); From da99c55eeda5bf7b573c09027f6637c5c0e74dd5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 5 Nov 2014 12:25:55 +0100 Subject: [PATCH 4/5] Use constructor for QString --- src/devices/deviceproperties.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/devices/deviceproperties.cpp b/src/devices/deviceproperties.cpp index 0dbf64dd2..391ffc7d0 100644 --- a/src/devices/deviceproperties.cpp +++ b/src/devices/deviceproperties.cpp @@ -253,7 +253,7 @@ void DeviceProperties::accept() { .toInt()); // By default no icon is selected and thus no current item is selected - QString icon_name = ""; + QString icon_name; if(ui_->icon->currentItem() != nullptr) { icon_name = ui_->icon->currentItem()->data(Qt::UserRole).toString(); } From 8fba1c30f423cbbb832cfdaa29014fb5ae432b1f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 5 Nov 2014 13:05:58 +0100 Subject: [PATCH 5/5] Make format --- src/devices/deviceproperties.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/devices/deviceproperties.cpp b/src/devices/deviceproperties.cpp index 391ffc7d0..c097d409d 100644 --- a/src/devices/deviceproperties.cpp +++ b/src/devices/deviceproperties.cpp @@ -254,12 +254,12 @@ void DeviceProperties::accept() { // By default no icon is selected and thus no current item is selected QString icon_name; - if(ui_->icon->currentItem() != nullptr) { + 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()); }