Convert all instances of foreach() to a C++11 for
find ext src -name '*.cpp' -exec \ sed -i -e 's/foreach(\([^,]\+\),/for (\1 :/' {} \;
This commit is contained in:
parent
89433be9aa
commit
3323c2d094
|
@ -245,7 +245,7 @@ void SpotifyClient::SendSearchResponse(sp_search* result) {
|
||||||
|
|
||||||
// Get the albums from the search. All these should be resolved by now.
|
// Get the albums from the search. All these should be resolved by now.
|
||||||
QList<sp_albumbrowse*> browses = pending_search_album_browses_.take(result);
|
QList<sp_albumbrowse*> browses = pending_search_album_browses_.take(result);
|
||||||
foreach(sp_albumbrowse * browse, browses) {
|
for (sp_albumbrowse* browse : browses) {
|
||||||
sp_album* album = sp_albumbrowse_album(browse);
|
sp_album* album = sp_albumbrowse_album(browse);
|
||||||
pb::spotify::Album* msg = response->add_album();
|
pb::spotify::Album* msg = response->add_album();
|
||||||
|
|
||||||
|
@ -548,7 +548,7 @@ void SpotifyClient::PlaylistStateChangedForLoadPlaylist(sp_playlist* pl,
|
||||||
}
|
}
|
||||||
|
|
||||||
// If any of the tracks aren't loaded yet we have to wait
|
// If any of the tracks aren't loaded yet we have to wait
|
||||||
foreach(sp_track * track, pending_load->tracks_) {
|
for (sp_track* track : pending_load->tracks_) {
|
||||||
if (!sp_track_is_loaded(track)) {
|
if (!sp_track_is_loaded(track)) {
|
||||||
qLog(Debug) << "One or more tracks aren't loaded yet, waiting";
|
qLog(Debug) << "One or more tracks aren't loaded yet, waiting";
|
||||||
return;
|
return;
|
||||||
|
@ -567,7 +567,7 @@ void SpotifyClient::PlaylistStateChangedForLoadPlaylist(sp_playlist* pl,
|
||||||
}
|
}
|
||||||
|
|
||||||
*response->mutable_request() = pending_load->request_;
|
*response->mutable_request() = pending_load->request_;
|
||||||
foreach(sp_track * track, pending_load->tracks_) {
|
for (sp_track* track : pending_load->tracks_) {
|
||||||
me->ConvertTrack(track, response->add_track());
|
me->ConvertTrack(track, response->add_track());
|
||||||
sp_track_release(track);
|
sp_track_release(track);
|
||||||
}
|
}
|
||||||
|
@ -660,11 +660,11 @@ void SpotifyClient::MetadataUpdatedCallback(sp_session* session) {
|
||||||
SpotifyClient* me =
|
SpotifyClient* me =
|
||||||
reinterpret_cast<SpotifyClient*>(sp_session_userdata(session));
|
reinterpret_cast<SpotifyClient*>(sp_session_userdata(session));
|
||||||
|
|
||||||
foreach(const PendingLoadPlaylist & load, me->pending_load_playlists_) {
|
for (const PendingLoadPlaylist& load : me->pending_load_playlists_) {
|
||||||
PlaylistStateChangedForLoadPlaylist(load.playlist_, me);
|
PlaylistStateChangedForLoadPlaylist(load.playlist_, me);
|
||||||
}
|
}
|
||||||
foreach(const PendingPlaybackRequest & playback,
|
for (const PendingPlaybackRequest& playback :
|
||||||
me->pending_playback_requests_) {
|
me->pending_playback_requests_) {
|
||||||
me->TryPlaybackAgain(playback);
|
me->TryPlaybackAgain(playback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ static void MessageHandler(QtMsgType type, const char* message) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(const QString & line, QString::fromLocal8Bit(message).split('\n')) {
|
for (const QString& line : QString::fromLocal8Bit(message).split('\n')) {
|
||||||
CreateLogger(level, "unknown", -1) << line.toLocal8Bit().constData();
|
CreateLogger(level, "unknown", -1) << line.toLocal8Bit().constData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ void Init() {
|
||||||
void SetLevels(const QString& levels) {
|
void SetLevels(const QString& levels) {
|
||||||
if (!sClassLevels) return;
|
if (!sClassLevels) return;
|
||||||
|
|
||||||
foreach(const QString & item, levels.split(',')) {
|
for (const QString& item : levels.split(',')) {
|
||||||
const QStringList class_level = item.split(':');
|
const QStringList class_level = item.split(':');
|
||||||
|
|
||||||
QString class_name;
|
QString class_name;
|
||||||
|
|
|
@ -175,7 +175,9 @@ bool AbstractMessageHandler<MT>::RawMessageArrived(const QByteArray& data) {
|
||||||
|
|
||||||
template <typename MT>
|
template <typename MT>
|
||||||
void AbstractMessageHandler<MT>::AbortAll() {
|
void AbstractMessageHandler<MT>::AbortAll() {
|
||||||
foreach(ReplyType * reply, pending_replies_) { reply->Abort(); }
|
for (ReplyType* reply : pending_replies_) {
|
||||||
|
reply->Abort();
|
||||||
|
}
|
||||||
pending_replies_.clear();
|
pending_replies_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,7 @@ WorkerPool<HandlerType>::WorkerPool(QObject* parent)
|
||||||
|
|
||||||
template <typename HandlerType>
|
template <typename HandlerType>
|
||||||
WorkerPool<HandlerType>::~WorkerPool() {
|
WorkerPool<HandlerType>::~WorkerPool() {
|
||||||
foreach(const Worker & worker, workers_) {
|
for (const Worker& worker : workers_) {
|
||||||
if (worker.local_socket_ && worker.process_) {
|
if (worker.local_socket_ && worker.process_) {
|
||||||
disconnect(worker.process_, SIGNAL(error(QProcess::ProcessError)), this,
|
disconnect(worker.process_, SIGNAL(error(QProcess::ProcessError)), this,
|
||||||
SLOT(ProcessError(QProcess::ProcessError)));
|
SLOT(ProcessError(QProcess::ProcessError)));
|
||||||
|
@ -188,7 +188,9 @@ WorkerPool<HandlerType>::~WorkerPool() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(ReplyType * reply, message_queue_) { reply->Abort(); }
|
for (ReplyType* reply : message_queue_) {
|
||||||
|
reply->Abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename HandlerType>
|
template <typename HandlerType>
|
||||||
|
@ -231,7 +233,7 @@ void WorkerPool<HandlerType>::DoStart() {
|
||||||
search_path << qApp->applicationDirPath() + "/../PlugIns";
|
search_path << qApp->applicationDirPath() + "/../PlugIns";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
foreach(const QString & path_prefix, search_path) {
|
for (const QString& path_prefix : search_path) {
|
||||||
const QString executable_path = path_prefix + "/" + executable_name_;
|
const QString executable_path = path_prefix + "/" + executable_name_;
|
||||||
if (QFile::exists(executable_path)) {
|
if (QFile::exists(executable_path)) {
|
||||||
executable_path_ = executable_path;
|
executable_path_ = executable_path;
|
||||||
|
|
|
@ -191,7 +191,7 @@ void CloudStream::truncate(long) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloudStream::SSLErrors(const QList<QSslError>& errors) {
|
void CloudStream::SSLErrors(const QList<QSslError>& errors) {
|
||||||
foreach(const QSslError & error, errors) {
|
for (const QSslError& error : errors) {
|
||||||
qLog(Debug) << error.error() << error.errorString();
|
qLog(Debug) << error.error() << error.errorString();
|
||||||
qLog(Debug) << error.certificate();
|
qLog(Debug) << error.certificate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,11 +128,17 @@ Application::~Application() {
|
||||||
delete device_manager_;
|
delete device_manager_;
|
||||||
device_manager_ = nullptr;
|
device_manager_ = nullptr;
|
||||||
|
|
||||||
foreach(QObject * object, objects_in_threads_) { object->deleteLater(); }
|
for (QObject* object : objects_in_threads_) {
|
||||||
|
object->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
foreach(QThread * thread, threads_) { thread->quit(); }
|
for (QThread* thread : threads_) {
|
||||||
|
thread->quit();
|
||||||
|
}
|
||||||
|
|
||||||
foreach(QThread * thread, threads_) { thread->wait(); }
|
for (QThread* thread : threads_) {
|
||||||
|
thread->wait();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::MoveToNewThread(QObject* object) {
|
void Application::MoveToNewThread(QObject* object) {
|
||||||
|
|
|
@ -152,7 +152,7 @@ void BackgroundStreams::StreamActionDestroyed() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(Stream * stream, streams_.values()) {
|
for (Stream* stream : streams_.values()) {
|
||||||
if (stream->action == action) {
|
if (stream->action == action) {
|
||||||
stream->action = nullptr;
|
stream->action = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ void BackgroundStreams::StreamActionToggled(bool checked) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(Stream * stream, streams_.values()) {
|
for (Stream* stream : streams_.values()) {
|
||||||
if (stream->action == action) {
|
if (stream->action == action) {
|
||||||
EnableStream(stream->name, checked);
|
EnableStream(stream->name, checked);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ void DeleteFiles::Start(const SongList& songs) {
|
||||||
|
|
||||||
void DeleteFiles::Start(const QStringList& filenames) {
|
void DeleteFiles::Start(const QStringList& filenames) {
|
||||||
SongList songs;
|
SongList songs;
|
||||||
foreach(const QString & filename, filenames) {
|
for (const QString& filename : filenames) {
|
||||||
Song song;
|
Song song;
|
||||||
song.set_url(QUrl::fromLocalFile(filename));
|
song.set_url(QUrl::fromLocalFile(filename));
|
||||||
songs << song;
|
songs << song;
|
||||||
|
|
|
@ -50,7 +50,7 @@ bool GnomeGlobalShortcutBackend::DoRegister() {
|
||||||
qLog(Debug) << "registering";
|
qLog(Debug) << "registering";
|
||||||
// Check if the GSD service is available
|
// Check if the GSD service is available
|
||||||
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(
|
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(
|
||||||
kGsdService)) {
|
kGsdService)) {
|
||||||
qLog(Warning) << "gnome settings daemon not registered";
|
qLog(Warning) << "gnome settings daemon not registered";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ void GnomeGlobalShortcutBackend::DoUnregister() {
|
||||||
#ifdef QT_DBUS_LIB
|
#ifdef QT_DBUS_LIB
|
||||||
// Check if the GSD service is available
|
// Check if the GSD service is available
|
||||||
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(
|
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(
|
||||||
kGsdService))
|
kGsdService))
|
||||||
return;
|
return;
|
||||||
if (!interface_ || !is_connected_) return;
|
if (!interface_ || !is_connected_) return;
|
||||||
|
|
||||||
|
|
|
@ -397,7 +397,7 @@ QStringList MergedProxyModel::mimeTypes() const {
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
ret << sourceModel()->mimeTypes();
|
ret << sourceModel()->mimeTypes();
|
||||||
|
|
||||||
foreach(const QAbstractItemModel * model, merge_points_.keys()) {
|
for (const QAbstractItemModel* model : merge_points_.keys()) {
|
||||||
ret << model->mimeTypes();
|
ret << model->mimeTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ QMimeData* MergedProxyModel::mimeData(const QModelIndexList& indexes) const {
|
||||||
// Only ask about the indexes that are actually in that model
|
// Only ask about the indexes that are actually in that model
|
||||||
QModelIndexList indexes_in_model;
|
QModelIndexList indexes_in_model;
|
||||||
|
|
||||||
foreach(const QModelIndex & proxy_index, indexes) {
|
for (const QModelIndex& proxy_index : indexes) {
|
||||||
QModelIndex source_index = mapToSource(proxy_index);
|
QModelIndex source_index = mapToSource(proxy_index);
|
||||||
if (source_index.model() != model) continue;
|
if (source_index.model() != model) continue;
|
||||||
indexes_in_model << source_index;
|
indexes_in_model << source_index;
|
||||||
|
@ -467,7 +467,7 @@ QAbstractItemModel* MergedProxyModel::GetModel(const QModelIndex& source_index)
|
||||||
// but without the const_cast
|
// but without the const_cast
|
||||||
const QAbstractItemModel* const_model = source_index.model();
|
const QAbstractItemModel* const_model = source_index.model();
|
||||||
if (const_model == sourceModel()) return sourceModel();
|
if (const_model == sourceModel()) return sourceModel();
|
||||||
foreach(QAbstractItemModel * submodel, merge_points_.keys()) {
|
for (QAbstractItemModel* submodel : merge_points_.keys()) {
|
||||||
if (submodel == const_model) return submodel;
|
if (submodel == const_model) return submodel;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -480,13 +480,13 @@ void MergedProxyModel::DataChanged(const QModelIndex& top_left,
|
||||||
|
|
||||||
void MergedProxyModel::LayoutAboutToBeChanged() {
|
void MergedProxyModel::LayoutAboutToBeChanged() {
|
||||||
old_merge_points_.clear();
|
old_merge_points_.clear();
|
||||||
foreach(QAbstractItemModel * key, merge_points_.keys()) {
|
for (QAbstractItemModel* key : merge_points_.keys()) {
|
||||||
old_merge_points_[key] = merge_points_.value(key);
|
old_merge_points_[key] = merge_points_.value(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MergedProxyModel::LayoutChanged() {
|
void MergedProxyModel::LayoutChanged() {
|
||||||
foreach(QAbstractItemModel * key, merge_points_.keys()) {
|
for (QAbstractItemModel* key : merge_points_.keys()) {
|
||||||
if (!old_merge_points_.contains(key)) continue;
|
if (!old_merge_points_.contains(key)) continue;
|
||||||
|
|
||||||
const int old_row = old_merge_points_[key].row();
|
const int old_row = old_merge_points_[key].row();
|
||||||
|
@ -509,7 +509,7 @@ bool MergedProxyModel::IsKnownModel(const QAbstractItemModel* model) const {
|
||||||
QModelIndexList MergedProxyModel::mapFromSource(
|
QModelIndexList MergedProxyModel::mapFromSource(
|
||||||
const QModelIndexList& source_indexes) const {
|
const QModelIndexList& source_indexes) const {
|
||||||
QModelIndexList ret;
|
QModelIndexList ret;
|
||||||
foreach(const QModelIndex & index, source_indexes) {
|
for (const QModelIndex& index : source_indexes) {
|
||||||
ret << mapFromSource(index);
|
ret << mapFromSource(index);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -518,7 +518,7 @@ QModelIndexList MergedProxyModel::mapFromSource(
|
||||||
QModelIndexList MergedProxyModel::mapToSource(
|
QModelIndexList MergedProxyModel::mapToSource(
|
||||||
const QModelIndexList& proxy_indexes) const {
|
const QModelIndexList& proxy_indexes) const {
|
||||||
QModelIndexList ret;
|
QModelIndexList ret;
|
||||||
foreach(const QModelIndex & index, proxy_indexes) {
|
for (const QModelIndex& index : proxy_indexes) {
|
||||||
ret << mapToSource(index);
|
ret << mapToSource(index);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -184,7 +184,7 @@ QString Mpris2::DesktopEntryAbsolutePath() const {
|
||||||
xdg_data_dirs.append("/usr/local/share/");
|
xdg_data_dirs.append("/usr/local/share/");
|
||||||
xdg_data_dirs.append("/usr/share/");
|
xdg_data_dirs.append("/usr/share/");
|
||||||
|
|
||||||
foreach(const QString & directory, xdg_data_dirs) {
|
for (const QString& directory : xdg_data_dirs) {
|
||||||
QString path = QString("%1/applications/%2.desktop").arg(
|
QString path = QString("%1/applications/%2.desktop").arg(
|
||||||
directory, QApplication::applicationName().toLower());
|
directory, QApplication::applicationName().toLower());
|
||||||
if (QFile::exists(path)) return path;
|
if (QFile::exists(path)) return path;
|
||||||
|
@ -534,7 +534,7 @@ MprisPlaylistList Mpris2::GetPlaylists(quint32 index, quint32 max_count,
|
||||||
const QString& order,
|
const QString& order,
|
||||||
bool reverse_order) {
|
bool reverse_order) {
|
||||||
MprisPlaylistList ret;
|
MprisPlaylistList ret;
|
||||||
foreach(Playlist * p, app_->playlist_manager()->GetAllPlaylists()) {
|
for (Playlist* p : app_->playlist_manager()->GetAllPlaylists()) {
|
||||||
MprisPlaylist mpris_playlist;
|
MprisPlaylist mpris_playlist;
|
||||||
mpris_playlist.id = MakePlaylistPath(p->id());
|
mpris_playlist.id = MakePlaylistPath(p->id());
|
||||||
mpris_playlist.name = app_->playlist_manager()->GetPlaylistName(p->id());
|
mpris_playlist.name = app_->playlist_manager()->GetPlaylistName(p->id());
|
||||||
|
|
|
@ -14,7 +14,7 @@ void MultiSortFilterProxy::AddSortSpec(int role, Qt::SortOrder order) {
|
||||||
|
|
||||||
bool MultiSortFilterProxy::lessThan(const QModelIndex& left,
|
bool MultiSortFilterProxy::lessThan(const QModelIndex& left,
|
||||||
const QModelIndex& right) const {
|
const QModelIndex& right) const {
|
||||||
foreach(const SortSpec & spec, sorting_) {
|
for (const SortSpec& spec : sorting_) {
|
||||||
const int ret = Compare(left.data(spec.first), right.data(spec.first));
|
const int ret = Compare(left.data(spec.first), right.data(spec.first));
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ NetworkProxyFactory::NetworkProxyFactory()
|
||||||
|
|
||||||
qLog(Debug) << "Detected system proxy URLs:" << urls;
|
qLog(Debug) << "Detected system proxy URLs:" << urls;
|
||||||
|
|
||||||
foreach(const QString & url_str, urls) {
|
for (const QString& url_str : urls) {
|
||||||
if (url_str.isEmpty()) continue;
|
if (url_str.isEmpty()) continue;
|
||||||
|
|
||||||
env_url_ = QUrl(url_str);
|
env_url_ = QUrl(url_str);
|
||||||
|
|
|
@ -28,8 +28,8 @@ QxtGlobalShortcutBackend::QxtGlobalShortcutBackend(GlobalShortcuts* parent)
|
||||||
|
|
||||||
bool QxtGlobalShortcutBackend::DoRegister() {
|
bool QxtGlobalShortcutBackend::DoRegister() {
|
||||||
qLog(Debug) << "registering";
|
qLog(Debug) << "registering";
|
||||||
foreach(const GlobalShortcuts::Shortcut & shortcut,
|
for (const GlobalShortcuts::Shortcut& shortcut :
|
||||||
manager_->shortcuts().values()) {
|
manager_->shortcuts().values()) {
|
||||||
AddShortcut(shortcut.action);
|
AddShortcut(shortcut.action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ void SimpleTreeItem<T>::Delete(int child_row) {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T* SimpleTreeItem<T>::ChildByKey(const QString& key) const {
|
T* SimpleTreeItem<T>::ChildByKey(const QString& key) const {
|
||||||
foreach(T * child, children) {
|
for (T* child : children) {
|
||||||
if (child->key == key) return child;
|
if (child->key == key) return child;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -225,7 +225,7 @@ void SongLoader::AudioCDTagsLoaded(
|
||||||
// and that we are going to fill it with new (more complete) ones
|
// and that we are going to fill it with new (more complete) ones
|
||||||
songs_.clear();
|
songs_.clear();
|
||||||
int track_number = 1;
|
int track_number = 1;
|
||||||
foreach(const MusicBrainzClient::Result & ret, results) {
|
for (const MusicBrainzClient::Result& ret : results) {
|
||||||
Song song;
|
Song song;
|
||||||
song.set_artist(artist);
|
song.set_artist(artist);
|
||||||
song.set_album(album);
|
song.set_album(album);
|
||||||
|
@ -313,7 +313,7 @@ SongLoader::Result SongLoader::LoadLocal(const QString& filename) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(const Song & song, song_list) {
|
for (const Song& song : song_list) {
|
||||||
if (song.is_valid()) {
|
if (song.is_valid()) {
|
||||||
songs_ << song;
|
songs_ << song;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ TagReaderReply* TagReaderClient::UpdateSongStatistics(const Song& metadata) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagReaderClient::UpdateSongsStatistics(const SongList& songs) {
|
void TagReaderClient::UpdateSongsStatistics(const SongList& songs) {
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
TagReaderReply* reply = UpdateSongStatistics(song);
|
TagReaderReply* reply = UpdateSongStatistics(song);
|
||||||
connect(reply, SIGNAL(Finished(bool)), reply, SLOT(deleteLater()));
|
connect(reply, SIGNAL(Finished(bool)), reply, SLOT(deleteLater()));
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ TagReaderReply* TagReaderClient::UpdateSongRating(const Song& metadata) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagReaderClient::UpdateSongsRating(const SongList& songs) {
|
void TagReaderClient::UpdateSongsRating(const SongList& songs) {
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
TagReaderReply* reply = UpdateSongRating(song);
|
TagReaderReply* reply = UpdateSongRating(song);
|
||||||
connect(reply, SIGNAL(Finished(bool)), reply, SLOT(deleteLater()));
|
connect(reply, SIGNAL(Finished(bool)), reply, SLOT(deleteLater()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ void TaskManager::SetTaskFinished(int id) {
|
||||||
|
|
||||||
if (tasks_[id].blocks_library_scans) {
|
if (tasks_[id].blocks_library_scans) {
|
||||||
resume_library_watchers = true;
|
resume_library_watchers = true;
|
||||||
foreach(const Task & task, tasks_.values()) {
|
for (const Task& task : tasks_.values()) {
|
||||||
if (task.id != id && task.blocks_library_scans) {
|
if (task.id != id && task.blocks_library_scans) {
|
||||||
resume_library_watchers = false;
|
resume_library_watchers = false;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -221,13 +221,13 @@ QString GetTemporaryFileName() {
|
||||||
|
|
||||||
void RemoveRecursive(const QString& path) {
|
void RemoveRecursive(const QString& path) {
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
foreach(const QString & child,
|
for (const QString& child :
|
||||||
dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden))
|
dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden))
|
||||||
RemoveRecursive(path + "/" + child);
|
RemoveRecursive(path + "/" + child);
|
||||||
|
|
||||||
foreach(const QString & child,
|
for (const QString& child :
|
||||||
dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden))
|
dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden))
|
||||||
QFile::remove(path + "/" + child);
|
QFile::remove(path + "/" + child);
|
||||||
|
|
||||||
dir.rmdir(path);
|
dir.rmdir(path);
|
||||||
}
|
}
|
||||||
|
@ -239,8 +239,8 @@ bool CopyRecursive(const QString& source, const QString& destination) {
|
||||||
QDir().mkpath(dest_path);
|
QDir().mkpath(dest_path);
|
||||||
|
|
||||||
QDir dir(source);
|
QDir dir(source);
|
||||||
foreach(const QString & child,
|
for (const QString& child :
|
||||||
dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs)) {
|
dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs)) {
|
||||||
if (!CopyRecursive(source + "/" + child, dest_path)) {
|
if (!CopyRecursive(source + "/" + child, dest_path)) {
|
||||||
qLog(Warning) << "Failed to copy dir" << source + "/" + child << "to"
|
qLog(Warning) << "Failed to copy dir" << source + "/" + child << "to"
|
||||||
<< dest_path;
|
<< dest_path;
|
||||||
|
@ -248,8 +248,8 @@ bool CopyRecursive(const QString& source, const QString& destination) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(const QString & child,
|
for (const QString& child :
|
||||||
dir.entryList(QDir::NoDotAndDotDot | QDir::Files)) {
|
dir.entryList(QDir::NoDotAndDotDot | QDir::Files)) {
|
||||||
if (!QFile::copy(source + "/" + child, dest_path + "/" + child)) {
|
if (!QFile::copy(source + "/" + child, dest_path + "/" + child)) {
|
||||||
qLog(Warning) << "Failed to copy file" << source + "/" + child << "to"
|
qLog(Warning) << "Failed to copy file" << source + "/" + child << "to"
|
||||||
<< dest_path;
|
<< dest_path;
|
||||||
|
@ -382,7 +382,7 @@ void ShowFileInExplorer(QString const& path) {
|
||||||
void OpenInFileBrowser(const QList<QUrl>& urls) {
|
void OpenInFileBrowser(const QList<QUrl>& urls) {
|
||||||
QSet<QString> dirs;
|
QSet<QString> dirs;
|
||||||
|
|
||||||
foreach(const QUrl & url, urls) {
|
for (const QUrl& url : urls) {
|
||||||
if (url.scheme() != "file") {
|
if (url.scheme() != "file") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ void AlbumCoverFetcher::AddRequest(const CoverSearchRequest& req) {
|
||||||
void AlbumCoverFetcher::Clear() {
|
void AlbumCoverFetcher::Clear() {
|
||||||
queued_requests_.clear();
|
queued_requests_.clear();
|
||||||
|
|
||||||
foreach(AlbumCoverFetcherSearch * search, active_requests_.values()) {
|
for (AlbumCoverFetcherSearch* search : active_requests_.values()) {
|
||||||
search->Cancel();
|
search->Cancel();
|
||||||
search->deleteLater();
|
search->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ AlbumCoverFetcherSearch::AlbumCoverFetcherSearch(
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlbumCoverFetcherSearch::TerminateSearch() {
|
void AlbumCoverFetcherSearch::TerminateSearch() {
|
||||||
foreach(int id, pending_requests_.keys()) {
|
for (int id : pending_requests_.keys()) {
|
||||||
pending_requests_.take(id)->CancelSearch(id);
|
pending_requests_.take(id)->CancelSearch(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ void AlbumCoverFetcherSearch::TerminateSearch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlbumCoverFetcherSearch::Start(CoverProviders* cover_providers) {
|
void AlbumCoverFetcherSearch::Start(CoverProviders* cover_providers) {
|
||||||
foreach(CoverProvider * provider, cover_providers->List()) {
|
for (CoverProvider* provider : cover_providers->List()) {
|
||||||
connect(provider, SIGNAL(SearchFinished(int, QList<CoverSearchResult>)),
|
connect(provider, SIGNAL(SearchFinished(int, QList<CoverSearchResult>)),
|
||||||
SLOT(ProviderSearchFinished(int, QList<CoverSearchResult>)));
|
SLOT(ProviderSearchFinished(int, QList<CoverSearchResult>)));
|
||||||
const int id = cover_providers->NextId();
|
const int id = cover_providers->NextId();
|
||||||
|
@ -248,7 +248,7 @@ void AlbumCoverFetcherSearch::Cancel() {
|
||||||
if (!pending_requests_.isEmpty()) {
|
if (!pending_requests_.isEmpty()) {
|
||||||
TerminateSearch();
|
TerminateSearch();
|
||||||
} else if (!pending_image_loads_.isEmpty()) {
|
} else if (!pending_image_loads_.isEmpty()) {
|
||||||
foreach(RedirectFollower * reply, pending_image_loads_.keys()) {
|
for (RedirectFollower* reply : pending_image_loads_.keys()) {
|
||||||
reply->abort();
|
reply->abort();
|
||||||
}
|
}
|
||||||
pending_image_loads_.clear();
|
pending_image_loads_.clear();
|
||||||
|
|
|
@ -62,7 +62,7 @@ bool AmazonCoverProvider::StartSearch(const QString& artist,
|
||||||
QStringList query_items;
|
QStringList query_items;
|
||||||
|
|
||||||
// Encode the arguments
|
// Encode the arguments
|
||||||
foreach(const Arg & arg, args) {
|
for (const Arg& arg : args) {
|
||||||
EncodedArg encoded_arg(QUrl::toPercentEncoding(arg.first),
|
EncodedArg encoded_arg(QUrl::toPercentEncoding(arg.first),
|
||||||
QUrl::toPercentEncoding(arg.second));
|
QUrl::toPercentEncoding(arg.second));
|
||||||
encoded_args << encoded_arg;
|
encoded_args << encoded_arg;
|
||||||
|
|
|
@ -30,10 +30,10 @@ CoverSearchStatistics& CoverSearchStatistics::operator+=(
|
||||||
network_requests_made_ += other.network_requests_made_;
|
network_requests_made_ += other.network_requests_made_;
|
||||||
bytes_transferred_ += other.bytes_transferred_;
|
bytes_transferred_ += other.bytes_transferred_;
|
||||||
|
|
||||||
foreach(const QString & key, other.chosen_images_by_provider_.keys()) {
|
for (const QString& key : other.chosen_images_by_provider_.keys()) {
|
||||||
chosen_images_by_provider_[key] += other.chosen_images_by_provider_[key];
|
chosen_images_by_provider_[key] += other.chosen_images_by_provider_[key];
|
||||||
}
|
}
|
||||||
foreach(const QString & key, other.total_images_by_provider_.keys()) {
|
for (const QString& key : other.total_images_by_provider_.keys()) {
|
||||||
total_images_by_provider_[key] += other.total_images_by_provider_[key];
|
total_images_by_provider_[key] += other.total_images_by_provider_[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ void CoverSearchStatisticsDialog::Show(
|
||||||
.arg(statistics.chosen_images_ + statistics.missing_images_)
|
.arg(statistics.chosen_images_ + statistics.missing_images_)
|
||||||
.arg(statistics.missing_images_));
|
.arg(statistics.missing_images_));
|
||||||
|
|
||||||
foreach(const QString & provider, providers) {
|
for (const QString& provider : providers) {
|
||||||
AddLine(tr("Covers from %1").arg(provider),
|
AddLine(tr("Covers from %1").arg(provider),
|
||||||
QString::number(statistics.chosen_images_by_provider_[provider]));
|
QString::number(statistics.chosen_images_by_provider_[provider]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ void DiscogsCoverProvider::SendSearchRequest(DiscogsCoverSearchContext* ctx) {
|
||||||
|
|
||||||
EncodedArgList encoded_args;
|
EncodedArgList encoded_args;
|
||||||
|
|
||||||
foreach(const Arg & arg, args) {
|
for (const Arg& arg : args) {
|
||||||
EncodedArg encoded_arg(QUrl::toPercentEncoding(arg.first),
|
EncodedArg encoded_arg(QUrl::toPercentEncoding(arg.first),
|
||||||
QUrl::toPercentEncoding(arg.second));
|
QUrl::toPercentEncoding(arg.second));
|
||||||
encoded_args << encoded_arg;
|
encoded_args << encoded_arg;
|
||||||
|
@ -126,7 +126,7 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply* reply, int id) {
|
||||||
|
|
||||||
QVariantList results = reply_map["results"].toList();
|
QVariantList results = reply_map["results"].toList();
|
||||||
|
|
||||||
foreach(const QVariant & result, results) {
|
for (const QVariant& result : results) {
|
||||||
QVariantMap result_map = result.toMap();
|
QVariantMap result_map = result.toMap();
|
||||||
// In order to use less round-trips, we cheat here. Instead of
|
// In order to use less round-trips, we cheat here. Instead of
|
||||||
// following the "resource_url", and then scan all images in the
|
// following the "resource_url", and then scan all images in the
|
||||||
|
|
|
@ -51,7 +51,7 @@ void LastFmCoverProvider::QueryFinished(QNetworkReply* reply, int id) {
|
||||||
QList<lastfm::XmlQuery> elements =
|
QList<lastfm::XmlQuery> elements =
|
||||||
query["results"]["albummatches"].children("album");
|
query["results"]["albummatches"].children("album");
|
||||||
|
|
||||||
foreach(const lastfm::XmlQuery & element, elements) {
|
for (const lastfm::XmlQuery& element : elements) {
|
||||||
CoverSearchResult result;
|
CoverSearchResult result;
|
||||||
result.description =
|
result.description =
|
||||||
element["artist"].text() + " - " + element["name"].text();
|
element["artist"].text() + " - " + element["name"].text();
|
||||||
|
|
|
@ -74,7 +74,7 @@ void MusicbrainzCoverProvider::ReleaseSearchFinished(QNetworkReply* reply,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(const QString & release_id, releases) {
|
for (const QString& release_id : releases) {
|
||||||
QUrl url(QString(kAlbumCoverUrl).arg(release_id));
|
QUrl url(QString(kAlbumCoverUrl).arg(release_id));
|
||||||
QNetworkReply* reply = network_->head(QNetworkRequest(url));
|
QNetworkReply* reply = network_->head(QNetworkRequest(url));
|
||||||
image_checks_.insert(id, reply);
|
image_checks_.insert(id, reply);
|
||||||
|
@ -90,7 +90,7 @@ void MusicbrainzCoverProvider::ImageCheckFinished(int id) {
|
||||||
if (finished_count == replies.size()) {
|
if (finished_count == replies.size()) {
|
||||||
QString cover_name = cover_names_.take(id);
|
QString cover_name = cover_names_.take(id);
|
||||||
QList<CoverSearchResult> results;
|
QList<CoverSearchResult> results;
|
||||||
foreach(QNetworkReply * reply, replies) {
|
for (QNetworkReply* reply : replies) {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() <
|
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() <
|
||||||
400) {
|
400) {
|
||||||
|
@ -107,7 +107,7 @@ void MusicbrainzCoverProvider::ImageCheckFinished(int id) {
|
||||||
|
|
||||||
void MusicbrainzCoverProvider::CancelSearch(int id) {
|
void MusicbrainzCoverProvider::CancelSearch(int id) {
|
||||||
QList<QNetworkReply*> replies = image_checks_.values(id);
|
QList<QNetworkReply*> replies = image_checks_.values(id);
|
||||||
foreach(QNetworkReply * reply, replies) {
|
for (QNetworkReply* reply : replies) {
|
||||||
reply->abort();
|
reply->abort();
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ void CddaDevice::AudioCDTagsLoaded(
|
||||||
int track_number = 1;
|
int track_number = 1;
|
||||||
if (results.size() == 0) return;
|
if (results.size() == 0) return;
|
||||||
model_->Reset();
|
model_->Reset();
|
||||||
foreach(const MusicBrainzClient::Result & ret, results) {
|
for (const MusicBrainzClient::Result& ret : results) {
|
||||||
Song song;
|
Song song;
|
||||||
song.set_artist(artist);
|
song.set_artist(artist);
|
||||||
song.set_album(album);
|
song.set_album(album);
|
||||||
|
|
|
@ -68,7 +68,7 @@ void DeviceKitLister::Init() {
|
||||||
|
|
||||||
// Get information about each one
|
// Get information about each one
|
||||||
QMap<QString, DeviceData> device_data;
|
QMap<QString, DeviceData> device_data;
|
||||||
foreach(const QDBusObjectPath & path, reply.value()) {
|
for (const QDBusObjectPath& path : reply.value()) {
|
||||||
DeviceData data = ReadDeviceData(path);
|
DeviceData data = ReadDeviceData(path);
|
||||||
if (data.suitable) device_data[data.unique_id()] = data;
|
if (data.suitable) device_data[data.unique_id()] = data;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,9 @@ void DeviceKitLister::Init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify about the changes
|
// Notify about the changes
|
||||||
foreach(const QString & id, device_data.keys()) { emit DeviceAdded(id); }
|
for (const QString& id : device_data.keys()) {
|
||||||
|
emit DeviceAdded(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList DeviceKitLister::DeviceUniqueIDs() {
|
QStringList DeviceKitLister::DeviceUniqueIDs() {
|
||||||
|
@ -225,7 +227,7 @@ void DeviceKitLister::DBusDeviceChanged(const QDBusObjectPath& path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DeviceKitLister::FindUniqueIdByPath(const QDBusObjectPath& path) const {
|
QString DeviceKitLister::FindUniqueIdByPath(const QDBusObjectPath& path) const {
|
||||||
foreach(const DeviceData & data, device_data_) {
|
for (const DeviceData& data : device_data_) {
|
||||||
if (data.dbus_path == path.path()) return data.unique_id();
|
if (data.dbus_path == path.path()) return data.unique_id();
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
|
|
|
@ -81,7 +81,7 @@ DeviceDatabaseBackend::Device DeviceManager::DeviceInfo::SaveToDb() const {
|
||||||
ret.transcode_format_ = transcode_format_;
|
ret.transcode_format_ = transcode_format_;
|
||||||
|
|
||||||
QStringList unique_ids;
|
QStringList unique_ids;
|
||||||
foreach(const Backend & backend, backends_) {
|
for (const Backend& backend : backends_) {
|
||||||
unique_ids << backend.unique_id_;
|
unique_ids << backend.unique_id_;
|
||||||
}
|
}
|
||||||
ret.unique_id_ = unique_ids.join(",");
|
ret.unique_id_ = unique_ids.join(",");
|
||||||
|
@ -99,12 +99,16 @@ void DeviceManager::DeviceInfo::InitFromDb(
|
||||||
|
|
||||||
QStringList icon_names = dev.icon_name_.split(',');
|
QStringList icon_names = dev.icon_name_.split(',');
|
||||||
QVariantList icons;
|
QVariantList icons;
|
||||||
foreach(const QString & icon_name, icon_names) { icons << icon_name; }
|
for (const QString& icon_name : icon_names) {
|
||||||
|
icons << icon_name;
|
||||||
|
}
|
||||||
|
|
||||||
LoadIcon(icons, friendly_name_);
|
LoadIcon(icons, friendly_name_);
|
||||||
|
|
||||||
QStringList unique_ids = dev.unique_id_.split(',');
|
QStringList unique_ids = dev.unique_id_.split(',');
|
||||||
foreach(const QString & id, unique_ids) { backends_ << Backend(nullptr, id); }
|
for (const QString& id : unique_ids) {
|
||||||
|
backends_ << Backend(nullptr, id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceManager::DeviceInfo::LoadIcon(const QVariantList& icons,
|
void DeviceManager::DeviceInfo::LoadIcon(const QVariantList& icons,
|
||||||
|
@ -116,7 +120,7 @@ void DeviceManager::DeviceInfo::LoadIcon(const QVariantList& icons,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to load the icon with that exact name first
|
// Try to load the icon with that exact name first
|
||||||
foreach(const QVariant & icon, icons) {
|
for (const QVariant& icon : icons) {
|
||||||
if (!icon.value<QPixmap>().isNull()) {
|
if (!icon.value<QPixmap>().isNull()) {
|
||||||
icon_ = QIcon(icon.value<QPixmap>());
|
icon_ = QIcon(icon.value<QPixmap>());
|
||||||
return;
|
return;
|
||||||
|
@ -210,7 +214,7 @@ DeviceManager::DeviceManager(Application* app, QObject* parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceManager::~DeviceManager() {
|
DeviceManager::~DeviceManager() {
|
||||||
foreach(DeviceLister * lister, listers_) {
|
for (DeviceLister* lister : listers_) {
|
||||||
lister->ShutDown();
|
lister->ShutDown();
|
||||||
delete lister;
|
delete lister;
|
||||||
}
|
}
|
||||||
|
@ -221,7 +225,7 @@ DeviceManager::~DeviceManager() {
|
||||||
void DeviceManager::LoadAllDevices() {
|
void DeviceManager::LoadAllDevices() {
|
||||||
Q_ASSERT(QThread::currentThread() != qApp->thread());
|
Q_ASSERT(QThread::currentThread() != qApp->thread());
|
||||||
DeviceDatabaseBackend::DeviceList devices = backend_->GetAllDevices();
|
DeviceDatabaseBackend::DeviceList devices = backend_->GetAllDevices();
|
||||||
foreach(const DeviceDatabaseBackend::Device & device, devices) {
|
for (const DeviceDatabaseBackend::Device& device : devices) {
|
||||||
DeviceInfo info;
|
DeviceInfo info;
|
||||||
info.InitFromDb(device);
|
info.InitFromDb(device);
|
||||||
devices_ << info;
|
devices_ << info;
|
||||||
|
@ -309,7 +313,7 @@ QVariant DeviceManager::data(const QModelIndex& index, int role) const {
|
||||||
if (!info.device_) {
|
if (!info.device_) {
|
||||||
if (info.database_id_ == -1 &&
|
if (info.database_id_ == -1 &&
|
||||||
!info.BestBackend()->lister_->DeviceNeedsMount(
|
!info.BestBackend()->lister_->DeviceNeedsMount(
|
||||||
info.BestBackend()->unique_id_)) {
|
info.BestBackend()->unique_id_)) {
|
||||||
|
|
||||||
if (info.BestBackend()->lister_->AskForScan(
|
if (info.BestBackend()->lister_->AskForScan(
|
||||||
info.BestBackend()->unique_id_)) {
|
info.BestBackend()->unique_id_)) {
|
||||||
|
@ -371,7 +375,7 @@ void DeviceManager::AddLister(DeviceLister* lister) {
|
||||||
|
|
||||||
int DeviceManager::FindDeviceById(const QString& id) const {
|
int DeviceManager::FindDeviceById(const QString& id) const {
|
||||||
for (int i = 0; i < devices_.count(); ++i) {
|
for (int i = 0; i < devices_.count(); ++i) {
|
||||||
foreach(const DeviceInfo::Backend & backend, devices_[i].backends_) {
|
for (const DeviceInfo::Backend& backend : devices_[i].backends_) {
|
||||||
if (backend.unique_id_ == id) return i;
|
if (backend.unique_id_ == id) return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -382,12 +386,12 @@ int DeviceManager::FindDeviceByUrl(const QList<QUrl>& urls) const {
|
||||||
if (urls.isEmpty()) return -1;
|
if (urls.isEmpty()) return -1;
|
||||||
|
|
||||||
for (int i = 0; i < devices_.count(); ++i) {
|
for (int i = 0; i < devices_.count(); ++i) {
|
||||||
foreach(const DeviceInfo::Backend & backend, devices_[i].backends_) {
|
for (const DeviceInfo::Backend& backend : devices_[i].backends_) {
|
||||||
if (!backend.lister_) continue;
|
if (!backend.lister_) continue;
|
||||||
|
|
||||||
QList<QUrl> device_urls =
|
QList<QUrl> device_urls =
|
||||||
backend.lister_->MakeDeviceUrls(backend.unique_id_);
|
backend.lister_->MakeDeviceUrls(backend.unique_id_);
|
||||||
foreach(const QUrl & url, device_urls) {
|
for (const QUrl& url : device_urls) {
|
||||||
if (urls.contains(url)) return i;
|
if (urls.contains(url)) return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -487,7 +491,7 @@ void DeviceManager::PhysicalDeviceRemoved(const QString& id) {
|
||||||
beginRemoveRows(QModelIndex(), i, i);
|
beginRemoveRows(QModelIndex(), i, i);
|
||||||
devices_.removeAt(i);
|
devices_.removeAt(i);
|
||||||
|
|
||||||
foreach(const QModelIndex & idx, persistentIndexList()) {
|
for (const QModelIndex& idx : persistentIndexList()) {
|
||||||
if (idx.row() == i)
|
if (idx.row() == i)
|
||||||
changePersistentIndex(idx, QModelIndex());
|
changePersistentIndex(idx, QModelIndex());
|
||||||
else if (idx.row() > i)
|
else if (idx.row() > i)
|
||||||
|
@ -542,7 +546,7 @@ std::shared_ptr<ConnectedDevice> DeviceManager::Connect(int row) {
|
||||||
|
|
||||||
// Take the first URL that we have a handler for
|
// Take the first URL that we have a handler for
|
||||||
QUrl device_url;
|
QUrl device_url;
|
||||||
foreach(const QUrl & url, urls) {
|
for (const QUrl& url : urls) {
|
||||||
qLog(Info) << "Connecting" << url;
|
qLog(Info) << "Connecting" << url;
|
||||||
|
|
||||||
// Find a device class for this URL's scheme
|
// Find a device class for this URL's scheme
|
||||||
|
@ -580,7 +584,9 @@ std::shared_ptr<ConnectedDevice> DeviceManager::Connect(int row) {
|
||||||
if (device_url.isEmpty()) {
|
if (device_url.isEmpty()) {
|
||||||
// Munge the URL list into a string list
|
// Munge the URL list into a string list
|
||||||
QStringList url_strings;
|
QStringList url_strings;
|
||||||
foreach(const QUrl & url, urls) { url_strings << url.toString(); }
|
for (const QUrl& url : urls) {
|
||||||
|
url_strings << url.toString();
|
||||||
|
}
|
||||||
|
|
||||||
app_->AddError(tr("This type of device is not supported: %1")
|
app_->AddError(tr("This type of device is not supported: %1")
|
||||||
.arg(url_strings.join(", ")));
|
.arg(url_strings.join(", ")));
|
||||||
|
@ -651,7 +657,7 @@ void DeviceManager::Forget(int row) {
|
||||||
beginRemoveRows(QModelIndex(), row, row);
|
beginRemoveRows(QModelIndex(), row, row);
|
||||||
devices_.removeAt(row);
|
devices_.removeAt(row);
|
||||||
|
|
||||||
foreach(const QModelIndex & idx, persistentIndexList()) {
|
for (const QModelIndex& idx : persistentIndexList()) {
|
||||||
if (idx.row() == row)
|
if (idx.row() == row)
|
||||||
changePersistentIndex(idx, QModelIndex());
|
changePersistentIndex(idx, QModelIndex());
|
||||||
else if (idx.row() > row)
|
else if (idx.row() > row)
|
||||||
|
@ -708,7 +714,7 @@ void DeviceManager::TasksChanged() {
|
||||||
QList<TaskManager::Task> tasks = app_->task_manager()->GetTasks();
|
QList<TaskManager::Task> tasks = app_->task_manager()->GetTasks();
|
||||||
QList<QPersistentModelIndex> finished_tasks = active_tasks_.values();
|
QList<QPersistentModelIndex> finished_tasks = active_tasks_.values();
|
||||||
|
|
||||||
foreach(const TaskManager::Task & task, tasks) {
|
for (const TaskManager::Task& task : tasks) {
|
||||||
if (!active_tasks_.contains(task.id)) continue;
|
if (!active_tasks_.contains(task.id)) continue;
|
||||||
|
|
||||||
QPersistentModelIndex index = active_tasks_[task.id];
|
QPersistentModelIndex index = active_tasks_[task.id];
|
||||||
|
@ -723,7 +729,7 @@ void DeviceManager::TasksChanged() {
|
||||||
finished_tasks.removeAll(index);
|
finished_tasks.removeAll(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(const QPersistentModelIndex & index, finished_tasks) {
|
for (const QPersistentModelIndex& index : finished_tasks) {
|
||||||
if (!index.isValid()) continue;
|
if (!index.isValid()) continue;
|
||||||
|
|
||||||
DeviceInfo& info = devices_[index.row()];
|
DeviceInfo& info = devices_[index.row()];
|
||||||
|
|
|
@ -192,7 +192,7 @@ void DeviceManager::AddDeviceClass() {
|
||||||
QStringList schemes = T::url_schemes();
|
QStringList schemes = T::url_schemes();
|
||||||
QMetaObject obj = T::staticMetaObject;
|
QMetaObject obj = T::staticMetaObject;
|
||||||
|
|
||||||
foreach(const QString & scheme, schemes) {
|
for (const QString& scheme : schemes) {
|
||||||
device_classes_.insert(scheme, obj);
|
device_classes_.insert(scheme, obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,14 +85,14 @@ void DeviceProperties::ShowDevice(int row) {
|
||||||
<< "phone-nokia-n900"
|
<< "phone-nokia-n900"
|
||||||
<< "phone-palm-pre";
|
<< "phone-palm-pre";
|
||||||
|
|
||||||
foreach(const QString & icon_name, icon_names) {
|
for (const QString& icon_name : icon_names) {
|
||||||
QListWidgetItem* item = new QListWidgetItem(IconLoader::Load(icon_name),
|
QListWidgetItem* item = new QListWidgetItem(IconLoader::Load(icon_name),
|
||||||
QString(), ui_->icon);
|
QString(), ui_->icon);
|
||||||
item->setData(Qt::UserRole, icon_name);
|
item->setData(Qt::UserRole, icon_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the transcode formats the first time the dialog is shown
|
// Load the transcode formats the first time the dialog is shown
|
||||||
foreach(const TranscoderPreset & preset, Transcoder::GetAllPresets()) {
|
for (const TranscoderPreset& preset : Transcoder::GetAllPresets()) {
|
||||||
ui_->transcode_format->addItem(preset.name_, preset.type_);
|
ui_->transcode_format->addItem(preset.name_, preset.type_);
|
||||||
}
|
}
|
||||||
ui_->transcode_format->model()->sort(0);
|
ui_->transcode_format->model()->sort(0);
|
||||||
|
@ -142,7 +142,7 @@ void DeviceProperties::UpdateHardwareInfo() {
|
||||||
QVariantMap info = lister->DeviceHardwareInfo(id);
|
QVariantMap info = lister->DeviceHardwareInfo(id);
|
||||||
|
|
||||||
// Remove empty items
|
// Remove empty items
|
||||||
foreach(const QString & key, info.keys()) {
|
for (const QString& key : info.keys()) {
|
||||||
if (info[key].isNull() || info[key].toString().isEmpty())
|
if (info[key].isNull() || info[key].toString().isEmpty())
|
||||||
info.remove(key);
|
info.remove(key);
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ void DeviceProperties::UpdateHardwareInfo() {
|
||||||
int row = 0;
|
int row = 0;
|
||||||
AddHardwareInfo(row++, tr("Model"), lister->DeviceModel(id));
|
AddHardwareInfo(row++, tr("Model"), lister->DeviceModel(id));
|
||||||
AddHardwareInfo(row++, tr("Manufacturer"), lister->DeviceManufacturer(id));
|
AddHardwareInfo(row++, tr("Manufacturer"), lister->DeviceManufacturer(id));
|
||||||
foreach(const QString & key, info.keys()) {
|
for (const QString& key : info.keys()) {
|
||||||
AddHardwareInfo(row++, tr(key.toAscii()), info[key].toString());
|
AddHardwareInfo(row++, tr(key.toAscii()), info[key].toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ void DeviceProperties::UpdateFormatsFinished() {
|
||||||
|
|
||||||
// Populate supported types list
|
// Populate supported types list
|
||||||
ui_->supported_formats->clear();
|
ui_->supported_formats->clear();
|
||||||
foreach(Song::FileType type, supported_formats_) {
|
for (Song::FileType type : supported_formats_) {
|
||||||
QListWidgetItem* item = new QListWidgetItem(Song::TextForFiletype(type));
|
QListWidgetItem* item = new QListWidgetItem(Song::TextForFiletype(type));
|
||||||
ui_->supported_formats->addItem(item);
|
ui_->supported_formats->addItem(item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,7 +361,7 @@ void DeviceView::mouseDoubleClickEvent(QMouseEvent* event) {
|
||||||
SongList DeviceView::GetSelectedSongs() const {
|
SongList DeviceView::GetSelectedSongs() const {
|
||||||
QModelIndexList selected_merged_indexes = selectionModel()->selectedRows();
|
QModelIndexList selected_merged_indexes = selectionModel()->selectedRows();
|
||||||
SongList songs;
|
SongList songs;
|
||||||
foreach(const QModelIndex & merged_index, selected_merged_indexes) {
|
for (const QModelIndex& merged_index : selected_merged_indexes) {
|
||||||
QModelIndex library_index = MapToLibrary(merged_index);
|
QModelIndex library_index = MapToLibrary(merged_index);
|
||||||
if (!library_index.isValid()) continue;
|
if (!library_index.isValid()) continue;
|
||||||
|
|
||||||
|
@ -421,7 +421,9 @@ void DeviceView::Delete() {
|
||||||
void DeviceView::Organise() {
|
void DeviceView::Organise() {
|
||||||
SongList songs = GetSelectedSongs();
|
SongList songs = GetSelectedSongs();
|
||||||
QStringList filenames;
|
QStringList filenames;
|
||||||
foreach(const Song & song, songs) { filenames << song.url().toLocalFile(); }
|
for (const Song& song : songs) {
|
||||||
|
filenames << song.url().toLocalFile();
|
||||||
|
}
|
||||||
|
|
||||||
organise_dialog_->SetCopy(true);
|
organise_dialog_->SetCopy(true);
|
||||||
organise_dialog_->SetFilenames(filenames);
|
organise_dialog_->SetFilenames(filenames);
|
||||||
|
|
|
@ -260,7 +260,7 @@ void GioLister::MountAdded(GMount* mount) {
|
||||||
QMutexLocker l(&mutex_);
|
QMutexLocker l(&mutex_);
|
||||||
|
|
||||||
// The volume might already exist - either mounted or unmounted.
|
// The volume might already exist - either mounted or unmounted.
|
||||||
foreach(const QString & id, devices_.keys()) {
|
for (const QString& id : devices_.keys()) {
|
||||||
if (devices_[id].volume == info.volume) {
|
if (devices_[id].volume == info.volume) {
|
||||||
old_id = id;
|
old_id = id;
|
||||||
break;
|
break;
|
||||||
|
@ -430,14 +430,14 @@ void GioLister::DeviceInfo::ReadDriveInfo(GDrive* drive) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GioLister::FindUniqueIdByMount(GMount* mount) const {
|
QString GioLister::FindUniqueIdByMount(GMount* mount) const {
|
||||||
foreach(const DeviceInfo & info, devices_) {
|
for (const DeviceInfo& info : devices_) {
|
||||||
if (info.mount == mount) return info.unique_id();
|
if (info.mount == mount) return info.unique_id();
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GioLister::FindUniqueIdByVolume(GVolume* volume) const {
|
QString GioLister::FindUniqueIdByVolume(GVolume* volume) const {
|
||||||
foreach(const DeviceInfo & info, devices_) {
|
for (const DeviceInfo& info : devices_) {
|
||||||
if (info.volume == volume) return info.unique_id();
|
if (info.volume == volume) return info.unique_id();
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
|
|
|
@ -659,7 +659,7 @@ shared_ptr<GstEnginePipeline> GstEngine::CreatePipeline() {
|
||||||
ret->set_mono_playback(mono_playback_);
|
ret->set_mono_playback(mono_playback_);
|
||||||
|
|
||||||
ret->AddBufferConsumer(this);
|
ret->AddBufferConsumer(this);
|
||||||
foreach(BufferConsumer * consumer, buffer_consumers_) {
|
for (BufferConsumer* consumer : buffer_consumers_) {
|
||||||
ret->AddBufferConsumer(consumer);
|
ret->AddBufferConsumer(consumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -694,7 +694,7 @@ bool GstEnginePipeline::HandoffCallback(GstPad*, GstBuffer* buf,
|
||||||
consumers = instance->buffer_consumers_;
|
consumers = instance->buffer_consumers_;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(BufferConsumer * consumer, consumers) {
|
for (BufferConsumer* consumer : consumers) {
|
||||||
gst_buffer_ref(buf);
|
gst_buffer_ref(buf);
|
||||||
consumer->ConsumeBuffer(buf, instance->id());
|
consumer->ConsumeBuffer(buf, instance->id());
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ void DigitallyImportedSearchProvider::RecreateItems() {
|
||||||
|
|
||||||
DigitallyImportedClient::ChannelList channels = service_->Channels();
|
DigitallyImportedClient::ChannelList channels = service_->Channels();
|
||||||
|
|
||||||
foreach(const DigitallyImportedClient::Channel & channel, channels) {
|
for (const DigitallyImportedClient::Channel& channel : channels) {
|
||||||
Song song;
|
Song song;
|
||||||
service_->SongFromChannel(channel, &song);
|
service_->SongFromChannel(channel, &song);
|
||||||
items << Item(song);
|
items << Item(song);
|
||||||
|
|
|
@ -89,7 +89,7 @@ int GlobalSearch::SearchAsync(const QString& query) {
|
||||||
if (url_provider_->LooksLikeUrl(query)) {
|
if (url_provider_->LooksLikeUrl(query)) {
|
||||||
url_provider_->SearchAsync(id, query);
|
url_provider_->SearchAsync(id, query);
|
||||||
} else {
|
} else {
|
||||||
foreach(SearchProvider * provider, providers_.keys()) {
|
for (SearchProvider* provider : providers_.keys()) {
|
||||||
if (!is_provider_usable(provider)) continue;
|
if (!is_provider_usable(provider)) continue;
|
||||||
|
|
||||||
pending_search_providers_[id]++;
|
pending_search_providers_[id]++;
|
||||||
|
@ -124,7 +124,7 @@ void GlobalSearch::CancelSearch(int id) {
|
||||||
void GlobalSearch::timerEvent(QTimerEvent* e) {
|
void GlobalSearch::timerEvent(QTimerEvent* e) {
|
||||||
QMap<int, DelayedSearch>::iterator it = delayed_searches_.find(e->timerId());
|
QMap<int, DelayedSearch>::iterator it = delayed_searches_.find(e->timerId());
|
||||||
if (it != delayed_searches_.end()) {
|
if (it != delayed_searches_.end()) {
|
||||||
foreach(SearchProvider * provider, it.value().providers_) {
|
for (SearchProvider* provider : it.value().providers_) {
|
||||||
provider->SearchAsync(it.value().id_, it.value().query_);
|
provider->SearchAsync(it.value().id_, it.value().query_);
|
||||||
}
|
}
|
||||||
delayed_searches_.erase(it);
|
delayed_searches_.erase(it);
|
||||||
|
@ -184,7 +184,9 @@ void GlobalSearch::ProviderDestroyedSlot(QObject* object) {
|
||||||
|
|
||||||
// We have to abort any pending searches since we can't tell whether they
|
// We have to abort any pending searches since we can't tell whether they
|
||||||
// were on this provider.
|
// were on this provider.
|
||||||
foreach(int id, pending_search_providers_.keys()) { emit SearchFinished(id); }
|
for (int id : pending_search_providers_.keys()) {
|
||||||
|
emit SearchFinished(id);
|
||||||
|
}
|
||||||
pending_search_providers_.clear();
|
pending_search_providers_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +281,7 @@ MimeData* GlobalSearch::LoadTracks(const SearchProvider::ResultList& results) {
|
||||||
|
|
||||||
SearchProvider* first_provider = results[0].provider_;
|
SearchProvider* first_provider = results[0].provider_;
|
||||||
SearchProvider::ResultList results_copy;
|
SearchProvider::ResultList results_copy;
|
||||||
foreach(const SearchProvider::Result & result, results) {
|
for (const SearchProvider::Result& result : results) {
|
||||||
if (result.provider_ == first_provider) {
|
if (result.provider_ == first_provider) {
|
||||||
results_copy << result;
|
results_copy << result;
|
||||||
}
|
}
|
||||||
|
@ -325,7 +327,7 @@ void GlobalSearch::ReloadSettings() {
|
||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
|
|
||||||
foreach(SearchProvider * provider, providers_.keys()) {
|
for (SearchProvider* provider : providers_.keys()) {
|
||||||
QVariant value = s.value("enabled_" + provider->id());
|
QVariant value = s.value("enabled_" + provider->id());
|
||||||
if (!value.isValid()) continue;
|
if (!value.isValid()) continue;
|
||||||
const bool enabled = value.toBool();
|
const bool enabled = value.toBool();
|
||||||
|
@ -340,7 +342,7 @@ void GlobalSearch::ReloadSettings() {
|
||||||
void GlobalSearch::SaveProvidersSettings() {
|
void GlobalSearch::SaveProvidersSettings() {
|
||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
foreach(SearchProvider * provider, providers_.keys()) {
|
for (SearchProvider* provider : providers_.keys()) {
|
||||||
s.setValue("enabled_" + provider->id(), providers_[provider].enabled_);
|
s.setValue("enabled_" + provider->id(), providers_[provider].enabled_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,9 +351,9 @@ QStringList GlobalSearch::GetSuggestions(int count) {
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
|
|
||||||
// Get count suggestions from each provider
|
// Get count suggestions from each provider
|
||||||
foreach(SearchProvider * provider, providers_.keys()) {
|
for (SearchProvider* provider : providers_.keys()) {
|
||||||
if (is_provider_enabled(provider) && provider->can_give_suggestions()) {
|
if (is_provider_enabled(provider) && provider->can_give_suggestions()) {
|
||||||
foreach(QString suggestion, provider->GetSuggestions(count)) {
|
for (QString suggestion : provider->GetSuggestions(count)) {
|
||||||
suggestion = suggestion.trimmed().toLower();
|
suggestion = suggestion.trimmed().toLower();
|
||||||
|
|
||||||
if (!suggestion.isEmpty()) {
|
if (!suggestion.isEmpty()) {
|
||||||
|
|
|
@ -64,7 +64,7 @@ void GlobalSearchModel::AddResults(const SearchProvider::ResultList& results) {
|
||||||
sort_index = provider_sort_indices_[provider];
|
sort_index = provider_sort_indices_[provider];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(const SearchProvider::Result & result, results) {
|
for (const SearchProvider::Result& result : results) {
|
||||||
QStandardItem* parent = invisibleRootItem();
|
QStandardItem* parent = invisibleRootItem();
|
||||||
|
|
||||||
// Find (or create) the container nodes for this result if we can.
|
// Find (or create) the container nodes for this result if we can.
|
||||||
|
@ -198,7 +198,9 @@ void GlobalSearchModel::Clear() {
|
||||||
SearchProvider::ResultList GlobalSearchModel::GetChildResults(
|
SearchProvider::ResultList GlobalSearchModel::GetChildResults(
|
||||||
const QModelIndexList& indexes) const {
|
const QModelIndexList& indexes) const {
|
||||||
QList<QStandardItem*> items;
|
QList<QStandardItem*> items;
|
||||||
foreach(const QModelIndex & index, indexes) { items << itemFromIndex(index); }
|
for (const QModelIndex& index : indexes) {
|
||||||
|
items << itemFromIndex(index);
|
||||||
|
}
|
||||||
return GetChildResults(items);
|
return GetChildResults(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +209,7 @@ SearchProvider::ResultList GlobalSearchModel::GetChildResults(
|
||||||
SearchProvider::ResultList results;
|
SearchProvider::ResultList results;
|
||||||
QSet<const QStandardItem*> visited;
|
QSet<const QStandardItem*> visited;
|
||||||
|
|
||||||
foreach(QStandardItem * item, items) {
|
for (QStandardItem* item : items) {
|
||||||
GetChildResults(item, &results, &visited);
|
GetChildResults(item, &results, &visited);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +274,7 @@ void GlobalSearchModel::SetGroupBy(const LibraryModel::Grouping& grouping,
|
||||||
// Reset the model and re-add all the results using the new grouping.
|
// Reset the model and re-add all the results using the new grouping.
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
foreach(const SearchProvider::ResultList & result_list, results) {
|
for (const SearchProvider::ResultList& result_list : results) {
|
||||||
AddResults(result_list);
|
AddResults(result_list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,9 +60,8 @@ void GlobalSearchSettingsPage::Load() {
|
||||||
|
|
||||||
// Add the ones in the configured list first
|
// Add the ones in the configured list first
|
||||||
ui_->sources->clear();
|
ui_->sources->clear();
|
||||||
foreach(
|
for (const QString& id :
|
||||||
const QString & id,
|
s.value("provider_order", QStringList() << "library").toStringList()) {
|
||||||
s.value("provider_order", QStringList() << "library").toStringList()) {
|
|
||||||
// Find a matching provider for this id
|
// Find a matching provider for this id
|
||||||
for (QList<SearchProvider*>::iterator it = providers.begin();
|
for (QList<SearchProvider*>::iterator it = providers.begin();
|
||||||
it != providers.end(); ++it) {
|
it != providers.end(); ++it) {
|
||||||
|
@ -75,7 +74,7 @@ void GlobalSearchSettingsPage::Load() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now add any others that are remaining
|
// Now add any others that are remaining
|
||||||
foreach(SearchProvider * provider, providers) {
|
for (SearchProvider* provider : providers) {
|
||||||
AddProviderItem(engine, provider);
|
AddProviderItem(engine, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -225,7 +225,7 @@ void GlobalSearchView::ReloadSettings() {
|
||||||
|
|
||||||
bool any_disabled = false;
|
bool any_disabled = false;
|
||||||
|
|
||||||
foreach(SearchProvider * provider, providers) {
|
for (SearchProvider* provider : providers) {
|
||||||
QWidget* parent = ui_->enabled_list;
|
QWidget* parent = ui_->enabled_list;
|
||||||
if (!engine_->is_provider_usable(provider)) {
|
if (!engine_->is_provider_usable(provider)) {
|
||||||
parent = ui_->disabled_list;
|
parent = ui_->disabled_list;
|
||||||
|
@ -389,7 +389,7 @@ MimeData* GlobalSearchView::SelectedMimeData() {
|
||||||
|
|
||||||
// Get items for these indexes
|
// Get items for these indexes
|
||||||
QList<QStandardItem*> items;
|
QList<QStandardItem*> items;
|
||||||
foreach(const QModelIndex & index, indexes) {
|
for (const QModelIndex& index : indexes) {
|
||||||
items << (front_model_->itemFromIndex(front_proxy_->mapToSource(index)));
|
items << (front_model_->itemFromIndex(front_proxy_->mapToSource(index)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,7 +471,7 @@ bool GlobalSearchView::ResultsContextMenuEvent(QContextMenuEvent* event) {
|
||||||
ui_->results->selectionModel() &&
|
ui_->results->selectionModel() &&
|
||||||
ui_->results->selectionModel()->hasSelection();
|
ui_->results->selectionModel()->hasSelection();
|
||||||
|
|
||||||
foreach(QAction * action, context_actions_) {
|
for (QAction* action : context_actions_) {
|
||||||
action->setEnabled(enable_context_actions);
|
action->setEnabled(enable_context_actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,7 +565,7 @@ void GlobalSearchView::SetGroupBy(const LibraryModel::Grouping& g) {
|
||||||
s.setValue("group_by3", int(g.third));
|
s.setValue("group_by3", int(g.third));
|
||||||
|
|
||||||
// Make sure the correct action is checked.
|
// Make sure the correct action is checked.
|
||||||
foreach(QAction * action, group_by_actions_->actions()) {
|
for (QAction* action : group_by_actions_->actions()) {
|
||||||
if (action->property("group_by").isNull()) continue;
|
if (action->property("group_by").isNull()) continue;
|
||||||
|
|
||||||
if (g == action->property("group_by").value<LibraryModel::Grouping>()) {
|
if (g == action->property("group_by").value<LibraryModel::Grouping>()) {
|
||||||
|
|
|
@ -64,7 +64,7 @@ void GroovesharkSearchProvider::SearchDone(int id, const SongList& songs) {
|
||||||
const int global_search_id = state.orig_id_;
|
const int global_search_id = state.orig_id_;
|
||||||
|
|
||||||
ResultList ret;
|
ResultList ret;
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
Result result(this);
|
Result result(this);
|
||||||
result.metadata_ = song;
|
result.metadata_ = song;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ void GroovesharkSearchProvider::AlbumSearchResult(
|
||||||
MaybeSearchFinished(global_search_id);
|
MaybeSearchFinished(global_search_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
foreach(const quint64 album_id, albums_ids) {
|
for (const quint64 album_id : albums_ids) {
|
||||||
pending_searches_[album_id] = PendingState(global_search_id, QStringList());
|
pending_searches_[album_id] = PendingState(global_search_id, QStringList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ void GroovesharkSearchProvider::AlbumSongsLoaded(quint64 id,
|
||||||
const PendingState state = pending_searches_.take(id);
|
const PendingState state = pending_searches_.take(id);
|
||||||
const int global_search_id = state.orig_id_;
|
const int global_search_id = state.orig_id_;
|
||||||
ResultList ret;
|
ResultList ret;
|
||||||
foreach(const Song & s, songs) {
|
for (const Song& s : songs) {
|
||||||
Result result(this);
|
Result result(this);
|
||||||
result.metadata_ = s;
|
result.metadata_ = s;
|
||||||
ret << result;
|
ret << result;
|
||||||
|
|
|
@ -30,7 +30,7 @@ SearchProvider::ResultList IcecastSearchProvider::Search(int id,
|
||||||
IcecastBackend::StationList stations = backend_->GetStations(query);
|
IcecastBackend::StationList stations = backend_->GetStations(query);
|
||||||
ResultList ret;
|
ResultList ret;
|
||||||
|
|
||||||
foreach(const IcecastBackend::Station & station, stations) {
|
for (const IcecastBackend::Station& station : stations) {
|
||||||
if (ret.count() > 3) break;
|
if (ret.count() > 3) break;
|
||||||
|
|
||||||
Result result(this);
|
Result result(this);
|
||||||
|
|
|
@ -59,17 +59,17 @@ void LastFMSearchProvider::RecreateItems() {
|
||||||
const QStringList tags = service_->SavedTagRadioNames();
|
const QStringList tags = service_->SavedTagRadioNames();
|
||||||
const QStringList friends = service_->FriendNames();
|
const QStringList friends = service_->FriendNames();
|
||||||
|
|
||||||
foreach(const QString & name, artists) {
|
for (const QString& name : artists) {
|
||||||
items << Item(tr(LastFMService::kTitleArtist).arg(name),
|
items << Item(tr(LastFMService::kTitleArtist).arg(name),
|
||||||
QUrl(QString(LastFMService::kUrlArtist).arg(name)), name);
|
QUrl(QString(LastFMService::kUrlArtist).arg(name)), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(const QString & name, tags) {
|
for (const QString& name : tags) {
|
||||||
items << Item(tr(LastFMService::kTitleTag).arg(name),
|
items << Item(tr(LastFMService::kTitleTag).arg(name),
|
||||||
QUrl(QString(LastFMService::kUrlTag).arg(name)), name);
|
QUrl(QString(LastFMService::kUrlTag).arg(name)), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(const QString & name, friends) {
|
for (const QString& name : friends) {
|
||||||
items << Item(tr("Last.fm Radio Station - %1").arg(name),
|
items << Item(tr("Last.fm Radio Station - %1").arg(name),
|
||||||
QUrl("lastfm://user/" + name + "/library"), name);
|
QUrl("lastfm://user/" + name + "/library"), name);
|
||||||
items << Item(tr("Last.fm Mix Radio - %1").arg(name),
|
items << Item(tr("Last.fm Mix Radio - %1").arg(name),
|
||||||
|
|
|
@ -37,7 +37,7 @@ SavedRadioSearchProvider::SavedRadioSearchProvider(SavedRadio* service,
|
||||||
void SavedRadioSearchProvider::RecreateItems() {
|
void SavedRadioSearchProvider::RecreateItems() {
|
||||||
QList<Item> items;
|
QList<Item> items;
|
||||||
|
|
||||||
foreach(const SavedRadio::Stream & stream, service_->Streams()) {
|
for (const SavedRadio::Stream& stream : service_->Streams()) {
|
||||||
Item item;
|
Item item;
|
||||||
item.metadata_.set_title(stream.name_);
|
item.metadata_.set_title(stream.name_);
|
||||||
item.metadata_.set_url(stream.url_);
|
item.metadata_.set_url(stream.url_);
|
||||||
|
|
|
@ -55,7 +55,7 @@ QStringList SearchProvider::TokenizeQuery(const QString& query) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SearchProvider::Matches(const QStringList& tokens, const QString& string) {
|
bool SearchProvider::Matches(const QStringList& tokens, const QString& string) {
|
||||||
foreach(const QString & token, tokens) {
|
for (const QString& token : tokens) {
|
||||||
if (!string.contains(token, Qt::CaseInsensitive)) {
|
if (!string.contains(token, Qt::CaseInsensitive)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,9 @@ MimeData* SearchProvider::LoadTracks(const ResultList& results) {
|
||||||
mime_data = new MimeData;
|
mime_data = new MimeData;
|
||||||
} else {
|
} else {
|
||||||
SongList songs;
|
SongList songs;
|
||||||
foreach(const Result & result, results) { songs << result.metadata_; }
|
for (const Result& result : results) {
|
||||||
|
songs << result.metadata_;
|
||||||
|
}
|
||||||
|
|
||||||
if (internet_service()) {
|
if (internet_service()) {
|
||||||
InternetSongMimeData* internet_song_mime_data =
|
InternetSongMimeData* internet_song_mime_data =
|
||||||
|
@ -140,7 +142,9 @@ MimeData* SearchProvider::LoadTracks(const ResultList& results) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QUrl> urls;
|
QList<QUrl> urls;
|
||||||
foreach(const Result & result, results) { urls << result.metadata_.url(); }
|
for (const Result& result : results) {
|
||||||
|
urls << result.metadata_.url();
|
||||||
|
}
|
||||||
mime_data->setUrls(urls);
|
mime_data->setUrls(urls);
|
||||||
|
|
||||||
return mime_data;
|
return mime_data;
|
||||||
|
|
|
@ -61,9 +61,9 @@ SearchProvider::ResultList SimpleSearchProvider::Search(int id,
|
||||||
const QStringList tokens = TokenizeQuery(query);
|
const QStringList tokens = TokenizeQuery(query);
|
||||||
|
|
||||||
QMutexLocker l(&items_mutex_);
|
QMutexLocker l(&items_mutex_);
|
||||||
foreach(const Item & item, items_) {
|
for (const Item& item : items_) {
|
||||||
bool matched = true;
|
bool matched = true;
|
||||||
foreach(const QString & token, tokens) {
|
for (const QString& token : tokens) {
|
||||||
if (!item.keyword_.contains(token, Qt::CaseInsensitive) &&
|
if (!item.keyword_.contains(token, Qt::CaseInsensitive) &&
|
||||||
!item.metadata_.title().contains(token, Qt::CaseInsensitive) &&
|
!item.metadata_.title().contains(token, Qt::CaseInsensitive) &&
|
||||||
!safe_words_.contains(token, Qt::CaseInsensitive)) {
|
!safe_words_.contains(token, Qt::CaseInsensitive)) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ void SomaFMSearchProvider::LoadArtAsync(int id, const Result& result) {
|
||||||
void SomaFMSearchProvider::RecreateItems() {
|
void SomaFMSearchProvider::RecreateItems() {
|
||||||
QList<Item> items;
|
QList<Item> items;
|
||||||
|
|
||||||
foreach(const SomaFMService::Stream & stream, service_->Streams()) {
|
for (const SomaFMService::Stream& stream : service_->Streams()) {
|
||||||
Item item;
|
Item item;
|
||||||
item.metadata_ = stream.ToSong(service_->name());
|
item.metadata_ = stream.ToSong(service_->name());
|
||||||
item.keyword_ = stream.title_;
|
item.keyword_ = stream.title_;
|
||||||
|
|
|
@ -57,7 +57,7 @@ void SoundCloudSearchProvider::SearchDone(int id, const SongList& songs) {
|
||||||
const int global_search_id = state.orig_id_;
|
const int global_search_id = state.orig_id_;
|
||||||
|
|
||||||
ResultList ret;
|
ResultList ret;
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
Result result(this);
|
Result result(this);
|
||||||
result.metadata_ = song;
|
result.metadata_ = song;
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ void BoxService::FetchFolderItemsFinished(QNetworkReply* reply,
|
||||||
FetchRecursiveFolderItems(folder_id, offset + entries.size());
|
FetchRecursiveFolderItems(folder_id, offset + entries.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(const QVariant & e, entries) {
|
for (const QVariant& e : entries) {
|
||||||
QVariantMap entry = e.toMap();
|
QVariantMap entry = e.toMap();
|
||||||
if (entry["type"].toString() == "folder") {
|
if (entry["type"].toString() == "folder") {
|
||||||
FetchRecursiveFolderItems(entry["id"].toInt());
|
FetchRecursiveFolderItems(entry["id"].toInt());
|
||||||
|
@ -273,7 +273,7 @@ void BoxService::FetchEventsFinished(QNetworkReply* reply) {
|
||||||
s.setValue("cursor", response["next_stream_position"]);
|
s.setValue("cursor", response["next_stream_position"]);
|
||||||
|
|
||||||
QVariantList entries = response["entries"].toList();
|
QVariantList entries = response["entries"].toList();
|
||||||
foreach(const QVariant & e, entries) {
|
for (const QVariant& e : entries) {
|
||||||
QVariantMap event = e.toMap();
|
QVariantMap event = e.toMap();
|
||||||
QString type = event["event_type"].toString();
|
QString type = event["event_type"].toString();
|
||||||
QVariantMap source = event["source"].toMap();
|
QVariantMap source = event["source"].toMap();
|
||||||
|
|
|
@ -127,7 +127,7 @@ DigitallyImportedClient::ChannelList DigitallyImportedClient::ParseChannelList(
|
||||||
|
|
||||||
QVariantList filters = data["channel_filters"].toList();
|
QVariantList filters = data["channel_filters"].toList();
|
||||||
|
|
||||||
foreach(const QVariant & filter, filters) {
|
for (const QVariant& filter : filters) {
|
||||||
// Find the filter called "All"
|
// Find the filter called "All"
|
||||||
QVariantMap filter_map = filter.toMap();
|
QVariantMap filter_map = filter.toMap();
|
||||||
if (filter_map.value("name", QString()).toString() != "All") continue;
|
if (filter_map.value("name", QString()).toString() != "All") continue;
|
||||||
|
@ -135,7 +135,7 @@ DigitallyImportedClient::ChannelList DigitallyImportedClient::ParseChannelList(
|
||||||
// Add all its stations to the result
|
// Add all its stations to the result
|
||||||
QVariantList channels =
|
QVariantList channels =
|
||||||
filter_map.value("channels", QVariantList()).toList();
|
filter_map.value("channels", QVariantList()).toList();
|
||||||
foreach(const QVariant & channel_var, channels) {
|
for (const QVariant& channel_var : channels) {
|
||||||
QVariantMap channel_map = channel_var.toMap();
|
QVariantMap channel_map = channel_var.toMap();
|
||||||
|
|
||||||
Channel channel;
|
Channel channel;
|
||||||
|
|
|
@ -127,7 +127,7 @@ void DigitallyImportedServiceBase::PopulateStreams() {
|
||||||
if (root_->hasChildren()) root_->removeRows(0, root_->rowCount());
|
if (root_->hasChildren()) root_->removeRows(0, root_->rowCount());
|
||||||
|
|
||||||
// Add each stream to the model
|
// Add each stream to the model
|
||||||
foreach(const DigitallyImportedClient::Channel & channel, saved_channels_) {
|
for (const DigitallyImportedClient::Channel& channel : saved_channels_) {
|
||||||
Song song;
|
Song song;
|
||||||
SongFromChannel(channel, &song);
|
SongFromChannel(channel, &song);
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace {
|
||||||
QMap<QString, QString> ParseParamList(const QString& params) {
|
QMap<QString, QString> ParseParamList(const QString& params) {
|
||||||
QMap<QString, QString> ret;
|
QMap<QString, QString> ret;
|
||||||
QStringList components = params.split("&");
|
QStringList components = params.split("&");
|
||||||
foreach(const QString & component, components) {
|
for (const QString& component : components) {
|
||||||
QStringList pairs = component.split("=");
|
QStringList pairs = component.split("=");
|
||||||
if (pairs.size() != 2) {
|
if (pairs.size() != 2) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -136,7 +136,7 @@ QByteArray DropboxAuthenticator::GenerateAuthorisationHeader(
|
||||||
params << Param("oauth_token", token);
|
params << Param("oauth_token", token);
|
||||||
}
|
}
|
||||||
QStringList encoded_params;
|
QStringList encoded_params;
|
||||||
foreach(const Param & p, params) {
|
for (const Param& p : params) {
|
||||||
encoded_params << QString("%1=\"%2\"").arg(p.first, p.second);
|
encoded_params << QString("%1=\"%2\"").arg(p.first, p.second);
|
||||||
}
|
}
|
||||||
QString authorisation_header = QString("OAuth ") + encoded_params.join(", ");
|
QString authorisation_header = QString("OAuth ") + encoded_params.join(", ");
|
||||||
|
|
|
@ -111,7 +111,7 @@ void DropboxService::RequestFileListFinished(QNetworkReply* reply) {
|
||||||
|
|
||||||
QVariantList contents = response["entries"].toList();
|
QVariantList contents = response["entries"].toList();
|
||||||
qLog(Debug) << "Delta found:" << contents.size();
|
qLog(Debug) << "Delta found:" << contents.size();
|
||||||
foreach(const QVariant & c, contents) {
|
for (const QVariant& c : contents) {
|
||||||
QVariantList item = c.toList();
|
QVariantList item = c.toList();
|
||||||
QString path = item[0].toString();
|
QString path = item[0].toString();
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ static const char* kClientSecret = "l3cWb8efUZsrBI4wmY3uKl6i";
|
||||||
QStringList File::parent_ids() const {
|
QStringList File::parent_ids() const {
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
|
|
||||||
foreach(const QVariant & var, data_["parents"].toList()) {
|
for (const QVariant& var : data_["parents"].toList()) {
|
||||||
QVariantMap map(var.toMap());
|
QVariantMap map(var.toMap());
|
||||||
|
|
||||||
if (map["isRoot"].toBool()) {
|
if (map["isRoot"].toBool()) {
|
||||||
|
@ -216,7 +216,7 @@ void Client::ListChangesFinished(ListChangesResponse* response,
|
||||||
// Emit the FilesFound signal for the files in the response.
|
// Emit the FilesFound signal for the files in the response.
|
||||||
FileList files;
|
FileList files;
|
||||||
QList<QUrl> files_deleted;
|
QList<QUrl> files_deleted;
|
||||||
foreach(const QVariant & v, result["items"].toList()) {
|
for (const QVariant& v : result["items"].toList()) {
|
||||||
QVariantMap change = v.toMap();
|
QVariantMap change = v.toMap();
|
||||||
if (!change["deleted"].toBool()) {
|
if (!change["deleted"].toBool()) {
|
||||||
files << File(change["file"].toMap());
|
files << File(change["file"].toMap());
|
||||||
|
|
|
@ -119,7 +119,7 @@ void GoogleDriveService::EnsureConnected() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GoogleDriveService::FilesFound(const QList<google_drive::File>& files) {
|
void GoogleDriveService::FilesFound(const QList<google_drive::File>& files) {
|
||||||
foreach(const google_drive::File & file, files) {
|
for (const google_drive::File& file : files) {
|
||||||
if (!IsSupportedMimeType(file.mime_type())) {
|
if (!IsSupportedMimeType(file.mime_type())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ void GoogleDriveService::FilesFound(const QList<google_drive::File>& files) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GoogleDriveService::FilesDeleted(const QList<QUrl>& files) {
|
void GoogleDriveService::FilesDeleted(const QList<QUrl>& files) {
|
||||||
foreach(const QUrl & url, files) {
|
for (const QUrl& url : files) {
|
||||||
Song song = library_backend_->GetSongByUrl(url);
|
Song song = library_backend_->GetSongByUrl(url);
|
||||||
qLog(Debug) << "Deleting:" << url << song.title();
|
qLog(Debug) << "Deleting:" << url << song.title();
|
||||||
if (song.is_valid()) {
|
if (song.is_valid()) {
|
||||||
|
@ -187,7 +187,7 @@ void GoogleDriveService::ShowContextMenu(const QPoint& global_pos) {
|
||||||
|
|
||||||
// Only show some actions if there are real songs selected
|
// Only show some actions if there are real songs selected
|
||||||
bool songs_selected = false;
|
bool songs_selected = false;
|
||||||
foreach(const QModelIndex & index, model()->selected_indexes()) {
|
for (const QModelIndex& index : model()->selected_indexes()) {
|
||||||
const int type = index.data(LibraryModel::Role_Type).toInt();
|
const int type = index.data(LibraryModel::Role_Type).toInt();
|
||||||
if (type == LibraryItem::Type_Song || type == LibraryItem::Type_Container) {
|
if (type == LibraryItem::Type_Song || type == LibraryItem::Type_Container) {
|
||||||
songs_selected = true;
|
songs_selected = true;
|
||||||
|
@ -203,14 +203,14 @@ void GoogleDriveService::ShowContextMenu(const QPoint& global_pos) {
|
||||||
void GoogleDriveService::OpenWithDrive() {
|
void GoogleDriveService::OpenWithDrive() {
|
||||||
// Map indexes to the actual library model.
|
// Map indexes to the actual library model.
|
||||||
QModelIndexList library_indexes;
|
QModelIndexList library_indexes;
|
||||||
foreach(const QModelIndex & index, model()->selected_indexes()) {
|
for (const QModelIndex& index : model()->selected_indexes()) {
|
||||||
if (index.model() == library_sort_model_) {
|
if (index.model() == library_sort_model_) {
|
||||||
library_indexes << library_sort_model_->mapToSource(index);
|
library_indexes << library_sort_model_->mapToSource(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ask the library for the songs for these indexes.
|
// Ask the library for the songs for these indexes.
|
||||||
foreach(const Song & song, library_model_->GetChildSongs(library_indexes)) {
|
for (const Song& song : library_model_->GetChildSongs(library_indexes)) {
|
||||||
QDesktopServices::openUrl(
|
QDesktopServices::openUrl(
|
||||||
QUrl(QString(kDriveEditFileUrl).arg(song.url().path())));
|
QUrl(QString(kDriveEditFileUrl).arg(song.url().path())));
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,7 +237,7 @@ void GroovesharkService::SearchAlbumsFinished(QNetworkReply* reply, int id) {
|
||||||
QVariantList albums = result["albums"].toList();
|
QVariantList albums = result["albums"].toList();
|
||||||
|
|
||||||
QList<quint64> ret;
|
QList<quint64> ret;
|
||||||
foreach(const QVariant & v, albums) {
|
for (const QVariant& v : albums) {
|
||||||
quint64 album_id = v.toMap()["AlbumID"].toULongLong();
|
quint64 album_id = v.toMap()["AlbumID"].toULongLong();
|
||||||
GetAlbumSongs(album_id);
|
GetAlbumSongs(album_id);
|
||||||
ret << album_id;
|
ret << album_id;
|
||||||
|
@ -292,7 +292,7 @@ void GroovesharkService::SearchSongsFinished(QNetworkReply* reply) {
|
||||||
task_search_id_ = 0;
|
task_search_id_ = 0;
|
||||||
|
|
||||||
// Fill results list
|
// Fill results list
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
QStandardItem* child = CreateSongItem(song);
|
QStandardItem* child = CreateSongItem(song);
|
||||||
search_->appendRow(child);
|
search_->appendRow(child);
|
||||||
}
|
}
|
||||||
|
@ -692,7 +692,7 @@ void GroovesharkService::UserPlaylistsRetrieved(QNetworkReply* reply) {
|
||||||
QVariantMap result = ExtractResult(reply);
|
QVariantMap result = ExtractResult(reply);
|
||||||
QList<PlaylistInfo> playlists = ExtractPlaylistInfo(result);
|
QList<PlaylistInfo> playlists = ExtractPlaylistInfo(result);
|
||||||
|
|
||||||
foreach(const PlaylistInfo & playlist_info, playlists) {
|
for (const PlaylistInfo& playlist_info : playlists) {
|
||||||
int playlist_id = playlist_info.id_;
|
int playlist_id = playlist_info.id_;
|
||||||
const QString& playlist_name = playlist_info.name_;
|
const QString& playlist_name = playlist_info.name_;
|
||||||
QStandardItem* playlist_item =
|
QStandardItem* playlist_item =
|
||||||
|
@ -725,7 +725,7 @@ void GroovesharkService::PlaylistSongsRetrieved(QNetworkReply* reply,
|
||||||
SongList songs = ExtractSongs(result);
|
SongList songs = ExtractSongs(result);
|
||||||
Song::SortSongsListAlphabetically(&songs);
|
Song::SortSongsListAlphabetically(&songs);
|
||||||
|
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
QStandardItem* child = CreateSongItem(song);
|
QStandardItem* child = CreateSongItem(song);
|
||||||
child->setData(playlist_info->id_, Role_UserPlaylistId);
|
child->setData(playlist_info->id_, Role_UserPlaylistId);
|
||||||
child->setData(true, InternetModel::Role_CanBeModified);
|
child->setData(true, InternetModel::Role_CanBeModified);
|
||||||
|
@ -766,7 +766,7 @@ void GroovesharkService::UserFavoritesRetrieved(QNetworkReply* reply,
|
||||||
SongList songs = ExtractSongs(result);
|
SongList songs = ExtractSongs(result);
|
||||||
Song::SortSongsListAlphabetically(&songs);
|
Song::SortSongsListAlphabetically(&songs);
|
||||||
|
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
QStandardItem* child = CreateSongItem(song);
|
QStandardItem* child = CreateSongItem(song);
|
||||||
child->setData(true, InternetModel::Role_CanBeModified);
|
child->setData(true, InternetModel::Role_CanBeModified);
|
||||||
|
|
||||||
|
@ -800,7 +800,7 @@ void GroovesharkService::UserLibrarySongsRetrieved(QNetworkReply* reply,
|
||||||
SongList songs = ExtractSongs(result);
|
SongList songs = ExtractSongs(result);
|
||||||
Song::SortSongsListAlphabetically(&songs);
|
Song::SortSongsListAlphabetically(&songs);
|
||||||
|
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
QStandardItem* child = CreateSongItem(song);
|
QStandardItem* child = CreateSongItem(song);
|
||||||
child->setData(true, InternetModel::Role_CanBeModified);
|
child->setData(true, InternetModel::Role_CanBeModified);
|
||||||
|
|
||||||
|
@ -835,7 +835,7 @@ void GroovesharkService::PopularSongsMonthRetrieved(QNetworkReply* reply) {
|
||||||
|
|
||||||
if (!popular_month_) return;
|
if (!popular_month_) return;
|
||||||
|
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
QStandardItem* child = CreateSongItem(song);
|
QStandardItem* child = CreateSongItem(song);
|
||||||
popular_month_->appendRow(child);
|
popular_month_->appendRow(child);
|
||||||
}
|
}
|
||||||
|
@ -861,7 +861,7 @@ void GroovesharkService::PopularSongsTodayRetrieved(QNetworkReply* reply) {
|
||||||
|
|
||||||
if (!popular_today_) return;
|
if (!popular_today_) return;
|
||||||
|
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
QStandardItem* child = CreateSongItem(song);
|
QStandardItem* child = CreateSongItem(song);
|
||||||
popular_today_->appendRow(child);
|
popular_today_->appendRow(child);
|
||||||
}
|
}
|
||||||
|
@ -880,7 +880,7 @@ void GroovesharkService::SubscribedPlaylistsRetrieved(QNetworkReply* reply) {
|
||||||
QVariantMap result = ExtractResult(reply);
|
QVariantMap result = ExtractResult(reply);
|
||||||
QList<PlaylistInfo> playlists = ExtractPlaylistInfo(result);
|
QList<PlaylistInfo> playlists = ExtractPlaylistInfo(result);
|
||||||
|
|
||||||
foreach(const PlaylistInfo & playlist_info, playlists) {
|
for (const PlaylistInfo& playlist_info : playlists) {
|
||||||
int playlist_id = playlist_info.id_;
|
int playlist_id = playlist_info.id_;
|
||||||
const QString& playlist_name = playlist_info.name_;
|
const QString& playlist_name = playlist_info.name_;
|
||||||
|
|
||||||
|
@ -947,11 +947,11 @@ Song GroovesharkService::StartAutoplayTag(int tag_id,
|
||||||
Song GroovesharkService::StartAutoplay(QVariantMap& autoplay_state) {
|
Song GroovesharkService::StartAutoplay(QVariantMap& autoplay_state) {
|
||||||
QList<Param> parameters;
|
QList<Param> parameters;
|
||||||
QVariantList artists_ids_qvariant;
|
QVariantList artists_ids_qvariant;
|
||||||
foreach(int artist_id, last_artists_ids_) {
|
for (int artist_id : last_artists_ids_) {
|
||||||
artists_ids_qvariant << QVariant(artist_id);
|
artists_ids_qvariant << QVariant(artist_id);
|
||||||
}
|
}
|
||||||
QVariantList songs_ids_qvariant;
|
QVariantList songs_ids_qvariant;
|
||||||
foreach(int song_id, last_songs_ids_) {
|
for (int song_id : last_songs_ids_) {
|
||||||
songs_ids_qvariant << QVariant(song_id);
|
songs_ids_qvariant << QVariant(song_id);
|
||||||
}
|
}
|
||||||
parameters << Param("artistIDs", artists_ids_qvariant)
|
parameters << Param("artistIDs", artists_ids_qvariant)
|
||||||
|
@ -1071,7 +1071,9 @@ void GroovesharkService::DropMimeData(const QMimeData* data,
|
||||||
// If dropped on Favorites list
|
// If dropped on Favorites list
|
||||||
if (playlist_type == UserFavorites ||
|
if (playlist_type == UserFavorites ||
|
||||||
parent_playlist_type == UserFavorites) {
|
parent_playlist_type == UserFavorites) {
|
||||||
foreach(int song_id, data_songs_ids) { AddUserFavoriteSong(song_id); }
|
for (int song_id : data_songs_ids) {
|
||||||
|
AddUserFavoriteSong(song_id);
|
||||||
|
}
|
||||||
} else if (playlist_type == UserLibrary ||
|
} else if (playlist_type == UserLibrary ||
|
||||||
parent_playlist_type == UserLibrary) {
|
parent_playlist_type == UserLibrary) {
|
||||||
// FIXME: Adding songs to user libray doesn't work atm, but the problem
|
// FIXME: Adding songs to user libray doesn't work atm, but the problem
|
||||||
|
@ -1123,7 +1125,7 @@ QList<QAction*> GroovesharkService::playlistitem_actions(const Song& song) {
|
||||||
QAction* add_to_playlists = new QAction(
|
QAction* add_to_playlists = new QAction(
|
||||||
IconLoader::Load("list-add"), tr("Add to Grooveshark playlists"), this);
|
IconLoader::Load("list-add"), tr("Add to Grooveshark playlists"), this);
|
||||||
QMenu* playlists_menu = new QMenu();
|
QMenu* playlists_menu = new QMenu();
|
||||||
foreach(PlaylistInfo playlist_info, playlists_.values()) {
|
for (PlaylistInfo playlist_info : playlists_.values()) {
|
||||||
QAction* add_to_playlist = new QAction(playlist_info.name_, this);
|
QAction* add_to_playlist = new QAction(playlist_info.name_, this);
|
||||||
add_to_playlist->setData(playlist_info.id_);
|
add_to_playlist->setData(playlist_info.id_);
|
||||||
playlists_menu->addAction(add_to_playlist);
|
playlists_menu->addAction(add_to_playlist);
|
||||||
|
@ -1229,7 +1231,9 @@ void GroovesharkService::SetPlaylistSongs(int playlist_id,
|
||||||
|
|
||||||
// Convert song ids to QVariant
|
// Convert song ids to QVariant
|
||||||
QVariantList songs_ids_qvariant;
|
QVariantList songs_ids_qvariant;
|
||||||
foreach(int song_id, songs_ids) { songs_ids_qvariant << QVariant(song_id); }
|
for (int song_id : songs_ids) {
|
||||||
|
songs_ids_qvariant << QVariant(song_id);
|
||||||
|
}
|
||||||
|
|
||||||
parameters << Param("playlistID", playlist_id)
|
parameters << Param("playlistID", playlist_id)
|
||||||
<< Param("songIDs", songs_ids_qvariant);
|
<< Param("songIDs", songs_ids_qvariant);
|
||||||
|
@ -1421,7 +1425,9 @@ void GroovesharkService::AddUserLibrarySongs(const QList<int>& songs_ids) {
|
||||||
|
|
||||||
// Convert songs ids to QVariant
|
// Convert songs ids to QVariant
|
||||||
QVariantList songs_ids_qvariant;
|
QVariantList songs_ids_qvariant;
|
||||||
foreach(int song_id, songs_ids) { songs_ids_qvariant << QVariant(song_id); }
|
for (int song_id : songs_ids) {
|
||||||
|
songs_ids_qvariant << QVariant(song_id);
|
||||||
|
}
|
||||||
QVariantList albums_ids_qvariant;
|
QVariantList albums_ids_qvariant;
|
||||||
QVariantList artists_ids_qvariant;
|
QVariantList artists_ids_qvariant;
|
||||||
|
|
||||||
|
@ -1452,7 +1458,7 @@ void GroovesharkService::UserLibrarySongAdded(QNetworkReply* reply,
|
||||||
void GroovesharkService::RemoveCurrentFromPlaylist() {
|
void GroovesharkService::RemoveCurrentFromPlaylist() {
|
||||||
const QModelIndexList& indexes(model()->selected_indexes());
|
const QModelIndexList& indexes(model()->selected_indexes());
|
||||||
QMap<int, QList<int> > playlists_songs_ids;
|
QMap<int, QList<int> > playlists_songs_ids;
|
||||||
foreach(const QModelIndex & index, indexes) {
|
for (const QModelIndex& index : indexes) {
|
||||||
|
|
||||||
if (index.parent().data(InternetModel::Role_Type).toInt() !=
|
if (index.parent().data(InternetModel::Role_Type).toInt() !=
|
||||||
InternetModel::Type_UserPlaylist) {
|
InternetModel::Type_UserPlaylist) {
|
||||||
|
@ -1480,7 +1486,7 @@ void GroovesharkService::RemoveFromPlaylist(
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<int> songs_ids = playlists_[playlist_id].songs_ids_;
|
QList<int> songs_ids = playlists_[playlist_id].songs_ids_;
|
||||||
foreach(const int song_id, songs_ids_to_remove) {
|
for (const int song_id : songs_ids_to_remove) {
|
||||||
songs_ids.removeOne(song_id);
|
songs_ids.removeOne(song_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1490,7 +1496,7 @@ void GroovesharkService::RemoveFromPlaylist(
|
||||||
void GroovesharkService::RemoveCurrentFromFavorites() {
|
void GroovesharkService::RemoveCurrentFromFavorites() {
|
||||||
const QModelIndexList& indexes(model()->selected_indexes());
|
const QModelIndexList& indexes(model()->selected_indexes());
|
||||||
QList<int> songs_ids;
|
QList<int> songs_ids;
|
||||||
foreach(const QModelIndex & index, indexes) {
|
for (const QModelIndex& index : indexes) {
|
||||||
|
|
||||||
if (index.parent().data(Role_PlaylistType).toInt() != UserFavorites) {
|
if (index.parent().data(Role_PlaylistType).toInt() != UserFavorites) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -1515,7 +1521,7 @@ void GroovesharkService::RemoveFromFavorites(
|
||||||
|
|
||||||
// Convert song ids to QVariant
|
// Convert song ids to QVariant
|
||||||
QVariantList songs_ids_qvariant;
|
QVariantList songs_ids_qvariant;
|
||||||
foreach(const int song_id, songs_ids_to_remove) {
|
for (const int song_id : songs_ids_to_remove) {
|
||||||
songs_ids_qvariant << QVariant(song_id);
|
songs_ids_qvariant << QVariant(song_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1543,7 +1549,7 @@ void GroovesharkService::RemoveCurrentFromLibrary() {
|
||||||
const QModelIndexList& indexes(model()->selected_indexes());
|
const QModelIndexList& indexes(model()->selected_indexes());
|
||||||
QList<int> songs_ids;
|
QList<int> songs_ids;
|
||||||
|
|
||||||
foreach(const QModelIndex & index, indexes) {
|
for (const QModelIndex& index : indexes) {
|
||||||
|
|
||||||
if (index.parent().data(Role_PlaylistType).toInt() != UserLibrary) {
|
if (index.parent().data(Role_PlaylistType).toInt() != UserLibrary) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -1568,7 +1574,7 @@ void GroovesharkService::RemoveFromLibrary(
|
||||||
|
|
||||||
// Convert song ids to QVariant
|
// Convert song ids to QVariant
|
||||||
QVariantList songs_ids_qvariant;
|
QVariantList songs_ids_qvariant;
|
||||||
foreach(const int song_id, songs_ids_to_remove) {
|
for (const int song_id : songs_ids_to_remove) {
|
||||||
songs_ids_qvariant << QVariant(song_id);
|
songs_ids_qvariant << QVariant(song_id);
|
||||||
}
|
}
|
||||||
QVariantList albums_ids_qvariant;
|
QVariantList albums_ids_qvariant;
|
||||||
|
@ -1620,7 +1626,7 @@ QNetworkReply* GroovesharkService::CreateRequest(const QString& method_name,
|
||||||
request_params.insert("header", header);
|
request_params.insert("header", header);
|
||||||
|
|
||||||
QVariantMap parameters;
|
QVariantMap parameters;
|
||||||
foreach(const Param & param, params) {
|
for (const Param& param : params) {
|
||||||
parameters.insert(param.first, param.second);
|
parameters.insert(param.first, param.second);
|
||||||
}
|
}
|
||||||
request_params.insert("parameters", parameters);
|
request_params.insert("parameters", parameters);
|
||||||
|
@ -1650,7 +1656,7 @@ QNetworkReply* GroovesharkService::CreateRequest(const QString& method_name,
|
||||||
void GroovesharkService::RequestSslErrors(const QList<QSslError>& errors) {
|
void GroovesharkService::RequestSslErrors(const QList<QSslError>& errors) {
|
||||||
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
|
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
|
||||||
|
|
||||||
foreach(const QSslError & error, errors) {
|
for (const QSslError& error : errors) {
|
||||||
emit StreamError("SSL error occurred in Grooveshark request for " +
|
emit StreamError("SSL error occurred in Grooveshark request for " +
|
||||||
reply->url().toString() + ": " + error.errorString());
|
reply->url().toString() + ": " + error.errorString());
|
||||||
}
|
}
|
||||||
|
@ -1760,7 +1766,7 @@ QList<int> GroovesharkService::ExtractSongsIds(const QVariantMap& result) {
|
||||||
|
|
||||||
QList<int> GroovesharkService::ExtractSongsIds(const QList<QUrl>& urls) {
|
QList<int> GroovesharkService::ExtractSongsIds(const QList<QUrl>& urls) {
|
||||||
QList<int> songs_ids;
|
QList<int> songs_ids;
|
||||||
foreach(const QUrl & url, urls) {
|
for (const QUrl& url : urls) {
|
||||||
int song_id = ExtractSongId(url);
|
int song_id = ExtractSongId(url);
|
||||||
if (song_id) {
|
if (song_id) {
|
||||||
songs_ids << song_id;
|
songs_ids << song_id;
|
||||||
|
@ -1786,7 +1792,7 @@ QList<GroovesharkService::PlaylistInfo> GroovesharkService::ExtractPlaylistInfo(
|
||||||
QList<PlaylistInfo> playlists;
|
QList<PlaylistInfo> playlists;
|
||||||
|
|
||||||
// Get playlists info
|
// Get playlists info
|
||||||
foreach(const QVariant & playlist_qvariant, playlists_qvariant) {
|
for (const QVariant& playlist_qvariant : playlists_qvariant) {
|
||||||
QVariantMap playlist = playlist_qvariant.toMap();
|
QVariantMap playlist = playlist_qvariant.toMap();
|
||||||
int playlist_id = playlist["PlaylistID"].toInt();
|
int playlist_id = playlist["PlaylistID"].toInt();
|
||||||
QString playlist_name = playlist["PlaylistName"].toString();
|
QString playlist_name = playlist["PlaylistName"].toString();
|
||||||
|
|
|
@ -105,7 +105,9 @@ IcecastBackend::StationList IcecastBackend::GetStations(const QString& filter,
|
||||||
sql += " WHERE " + where_clauses.join(" AND ");
|
sql += " WHERE " + where_clauses.join(" AND ");
|
||||||
}
|
}
|
||||||
QSqlQuery q(sql, db);
|
QSqlQuery q(sql, db);
|
||||||
foreach(const QString & value, bound_items) { q.addBindValue(value); }
|
for (const QString& value : bound_items) {
|
||||||
|
q.addBindValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
q.exec();
|
q.exec();
|
||||||
if (db_->CheckErrors(q)) return ret;
|
if (db_->CheckErrors(q)) return ret;
|
||||||
|
@ -152,7 +154,7 @@ void IcecastBackend::ClearAndAddStations(const StationList& stations) {
|
||||||
db);
|
db);
|
||||||
|
|
||||||
// Add these ones
|
// Add these ones
|
||||||
foreach(const Station & station, stations) {
|
for (const Station& station : stations) {
|
||||||
q.bindValue(":name", station.name);
|
q.bindValue(":name", station.name);
|
||||||
q.bindValue(":url", station.url);
|
q.bindValue(":url", station.url);
|
||||||
q.bindValue(":mime_type", station.mime_type);
|
q.bindValue(":mime_type", station.mime_type);
|
||||||
|
|
|
@ -81,7 +81,7 @@ void IcecastModel::PopulateGenre(IcecastItem* parent, const QString& genre,
|
||||||
QChar last_divider;
|
QChar last_divider;
|
||||||
|
|
||||||
IcecastBackend::StationList stations = backend_->GetStations(filter_, genre);
|
IcecastBackend::StationList stations = backend_->GetStations(filter_, genre);
|
||||||
foreach(const IcecastBackend::Station & station, stations) {
|
for (const IcecastBackend::Station& station : stations) {
|
||||||
QChar divider_char = DividerKey(station.name);
|
QChar divider_char = DividerKey(station.name);
|
||||||
if (create_dividers && !divider_char.isNull() &&
|
if (create_dividers && !divider_char.isNull() &&
|
||||||
divider_char != last_divider) {
|
divider_char != last_divider) {
|
||||||
|
@ -104,7 +104,7 @@ void IcecastModel::PopulateGenre(IcecastItem* parent, const QString& genre,
|
||||||
void IcecastModel::AddGenres(const QStringList& genres, bool create_dividers) {
|
void IcecastModel::AddGenres(const QStringList& genres, bool create_dividers) {
|
||||||
QChar last_divider;
|
QChar last_divider;
|
||||||
|
|
||||||
foreach(const QString & genre, genres) {
|
for (const QString& genre : genres) {
|
||||||
QChar divider_char = DividerKey(genre);
|
QChar divider_char = DividerKey(genre);
|
||||||
if (create_dividers && divider_char != last_divider) {
|
if (create_dividers && divider_char != last_divider) {
|
||||||
last_divider = divider_char;
|
last_divider = divider_char;
|
||||||
|
@ -196,7 +196,7 @@ QMimeData* IcecastModel::mimeData(const QModelIndexList& indexes) const {
|
||||||
SongMimeData* data = new SongMimeData;
|
SongMimeData* data = new SongMimeData;
|
||||||
QList<QUrl> urls;
|
QList<QUrl> urls;
|
||||||
|
|
||||||
foreach(const QModelIndex & index, indexes) {
|
for (const QModelIndex& index : indexes) {
|
||||||
IcecastItem* item = IndexToItem(index);
|
IcecastItem* item = IndexToItem(index);
|
||||||
if (!item || item->type != IcecastItem::Type_Station) continue;
|
if (!item || item->type != IcecastItem::Type_Station) continue;
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ struct StationEquality {
|
||||||
|
|
||||||
QStringList FilterGenres(const QStringList& genres) {
|
QStringList FilterGenres(const QStringList& genres) {
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
foreach(const QString & genre, genres) {
|
for (const QString& genre : genres) {
|
||||||
if (genre.length() < 2) continue;
|
if (genre.length() < 2) continue;
|
||||||
if (genre.contains("ÃÂ")) continue; // Broken unicode.
|
if (genre.contains("ÃÂ")) continue; // Broken unicode.
|
||||||
if (genre.contains(QRegExp("^#x[0-9a-f][0-9a-f]")))
|
if (genre.contains(QRegExp("^#x[0-9a-f][0-9a-f]")))
|
||||||
|
@ -210,10 +210,12 @@ void IcecastService::ParseDirectoryFinished(
|
||||||
QSet<QString> genre_set = genres.keys().toSet();
|
QSet<QString> genre_set = genres.keys().toSet();
|
||||||
|
|
||||||
// Merge genres with only 1 or 2 stations into "Other".
|
// Merge genres with only 1 or 2 stations into "Other".
|
||||||
foreach(const QString & genre, genre_set) {
|
for (const QString& genre : genre_set) {
|
||||||
if (genres.count(genre) < 3) {
|
if (genres.count(genre) < 3) {
|
||||||
const QList<IcecastBackend::Station*>& small_genre = genres.values(genre);
|
const QList<IcecastBackend::Station*>& small_genre = genres.values(genre);
|
||||||
foreach(IcecastBackend::Station * s, small_genre) { s->genre = "Other"; }
|
for (IcecastBackend::Station* s : small_genre) {
|
||||||
|
s->genre = "Other";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -249,7 +249,7 @@ QMimeData* InternetModel::mimeData(const QModelIndexList& indexes) const {
|
||||||
QModelIndexList new_indexes;
|
QModelIndexList new_indexes;
|
||||||
|
|
||||||
QModelIndex last_valid_index;
|
QModelIndex last_valid_index;
|
||||||
foreach(const QModelIndex & index, indexes) {
|
for (const QModelIndex& index : indexes) {
|
||||||
if (!IsPlayable(index)) continue;
|
if (!IsPlayable(index)) continue;
|
||||||
|
|
||||||
last_valid_index = index;
|
last_valid_index = index;
|
||||||
|
@ -299,7 +299,7 @@ void InternetModel::ShowContextMenu(
|
||||||
current_index_ = merged_model_->mapToSource(current_merged_model_index);
|
current_index_ = merged_model_->mapToSource(current_merged_model_index);
|
||||||
|
|
||||||
selected_indexes_.clear();
|
selected_indexes_.clear();
|
||||||
foreach(const QModelIndex & index, selected_merged_model_indexes) {
|
for (const QModelIndex& index : selected_merged_model_indexes) {
|
||||||
selected_indexes_ << merged_model_->mapToSource(index);
|
selected_indexes_ << merged_model_->mapToSource(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ void InternetModel::ShowContextMenu(
|
||||||
}
|
}
|
||||||
|
|
||||||
void InternetModel::ReloadSettings() {
|
void InternetModel::ReloadSettings() {
|
||||||
foreach(InternetService * service, sServices->values()) {
|
for (InternetService* service : sServices->values()) {
|
||||||
service->ReloadSettings();
|
service->ReloadSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ void InternetViewContainer::FocusOnFilter(QKeyEvent* event) {
|
||||||
void InternetViewContainer::SetHeaderHeight(int height) {
|
void InternetViewContainer::SetHeaderHeight(int height) {
|
||||||
QTimeLine* animation = qobject_cast<QTimeLine*>(sender());
|
QTimeLine* animation = qobject_cast<QTimeLine*>(sender());
|
||||||
QWidget* header = nullptr;
|
QWidget* header = nullptr;
|
||||||
foreach(QWidget * h, headers_.keys()) {
|
for (QWidget* h : headers_.keys()) {
|
||||||
if (headers_[h].animation_ == animation) {
|
if (headers_[h].animation_ == animation) {
|
||||||
header = h;
|
header = h;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -156,7 +156,7 @@ void JamendoDynamicPlaylist::Fetch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
current_items_.clear();
|
current_items_.clear();
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
if (song.is_valid())
|
if (song.is_valid())
|
||||||
current_items_ << PlaylistItemPtr(new JamendoPlaylistItem(song));
|
current_items_ << PlaylistItemPtr(new JamendoPlaylistItem(song));
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,7 +287,7 @@ void JamendoService::InsertTrackIds(const TrackIdList& ids) const {
|
||||||
.arg(kTrackIdsTable, kTrackIdsColumn),
|
.arg(kTrackIdsTable, kTrackIdsColumn),
|
||||||
db);
|
db);
|
||||||
|
|
||||||
foreach(int id, ids) {
|
for (int id : ids) {
|
||||||
insert.bindValue(":id", id);
|
insert.bindValue(":id", id);
|
||||||
if (!insert.exec()) {
|
if (!insert.exec()) {
|
||||||
qLog(Warning) << "Query failed" << insert.lastQuery();
|
qLog(Warning) << "Query failed" << insert.lastQuery();
|
||||||
|
|
|
@ -706,7 +706,9 @@ void LastFMService::RefreshFriendsFinished(QNetworkReply* reply) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList names;
|
QStringList names;
|
||||||
foreach(const lastfm::User & f, friends) { names << f.name(); }
|
for (const lastfm::User& f : friends) {
|
||||||
|
names << f.name();
|
||||||
|
}
|
||||||
|
|
||||||
friend_names_.Update(names);
|
friend_names_.Update(names);
|
||||||
|
|
||||||
|
@ -718,7 +720,7 @@ void LastFMService::PopulateFriendsList() {
|
||||||
if (friends_list_->hasChildren())
|
if (friends_list_->hasChildren())
|
||||||
friends_list_->removeRows(0, friends_list_->rowCount());
|
friends_list_->removeRows(0, friends_list_->rowCount());
|
||||||
|
|
||||||
foreach(const QString & name, friend_names_) {
|
for (const QString& name : friend_names_) {
|
||||||
Song song;
|
Song song;
|
||||||
song.set_url(QUrl("lastfm://user/" + name + "/library"));
|
song.set_url(QUrl("lastfm://user/" + name + "/library"));
|
||||||
song.set_title(tr("Last.fm Library - %1").arg(name));
|
song.set_title(tr("Last.fm Library - %1").arg(name));
|
||||||
|
@ -743,7 +745,7 @@ void LastFMService::RefreshNeighboursFinished(QNetworkReply* reply) {
|
||||||
if (neighbours_list_->hasChildren())
|
if (neighbours_list_->hasChildren())
|
||||||
neighbours_list_->removeRows(0, neighbours_list_->rowCount());
|
neighbours_list_->removeRows(0, neighbours_list_->rowCount());
|
||||||
|
|
||||||
foreach(const lastfm::User & n, neighbours) {
|
for (const lastfm::User& n : neighbours) {
|
||||||
Song song;
|
Song song;
|
||||||
song.set_url(QUrl("lastfm://user/" + n.name() + "/library"));
|
song.set_url(QUrl("lastfm://user/" + n.name() + "/library"));
|
||||||
song.set_title(tr("Last.fm Library - %1").arg(n.name()));
|
song.set_title(tr("Last.fm Library - %1").arg(n.name()));
|
||||||
|
@ -829,7 +831,7 @@ void LastFMService::RestoreList(const QString& name, const QString& url_pattern,
|
||||||
|
|
||||||
const QStringList keys = SavedArtistOrTagRadioNames(name);
|
const QStringList keys = SavedArtistOrTagRadioNames(name);
|
||||||
|
|
||||||
foreach(const QString & key, keys) {
|
for (const QString& key : keys) {
|
||||||
QString url;
|
QString url;
|
||||||
if (name == "custom" && key.startsWith("lastfm://")) {
|
if (name == "custom" && key.startsWith("lastfm://")) {
|
||||||
url = key;
|
url = key;
|
||||||
|
@ -883,7 +885,7 @@ void LastFMService::FetchMoreTracksFinished(QNetworkReply* reply) {
|
||||||
lastfm::XmlQuery query(lastfm::compat::EmptyXmlQuery());
|
lastfm::XmlQuery query(lastfm::compat::EmptyXmlQuery());
|
||||||
if (lastfm::compat::ParseQuery(reply->readAll(), &query)) {
|
if (lastfm::compat::ParseQuery(reply->readAll(), &query)) {
|
||||||
const XmlQuery& playlist = query["playlist"];
|
const XmlQuery& playlist = query["playlist"];
|
||||||
foreach(const XmlQuery & q, playlist["trackList"].children("track")) {
|
for (const XmlQuery& q : playlist["trackList"].children("track")) {
|
||||||
lastfm::MutableTrack t;
|
lastfm::MutableTrack t;
|
||||||
t.setUrl(QUrl(q["location"].text()));
|
t.setUrl(QUrl(q["location"].text()));
|
||||||
t.setExtra("trackauth", q["extension"]["trackauth"].text());
|
t.setExtra("trackauth", q["extension"]["trackauth"].text());
|
||||||
|
|
|
@ -70,7 +70,7 @@ void MagnatuneDownloadDialog::Show(const SongList& songs) {
|
||||||
ui_->albums->clear();
|
ui_->albums->clear();
|
||||||
|
|
||||||
QSet<QString> sku_codes;
|
QSet<QString> sku_codes;
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
if (!sku_codes.contains(song.comment())) {
|
if (!sku_codes.contains(song.comment())) {
|
||||||
sku_codes.insert(song.comment());
|
sku_codes.insert(song.comment());
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ void OAuthenticator::RequestAccessToken(const QByteArray& code,
|
||||||
<< Param("redirect_uri", url.toString());
|
<< Param("redirect_uri", url.toString());
|
||||||
|
|
||||||
QStringList params;
|
QStringList params;
|
||||||
foreach(const Param & p, parameters) {
|
for (const Param& p : parameters) {
|
||||||
params.append(QString("%1=%2").arg(
|
params.append(QString("%1=%2").arg(
|
||||||
p.first, QString(QUrl::toPercentEncoding(p.second))));
|
p.first, QString(QUrl::toPercentEncoding(p.second))));
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ void OAuthenticator::RefreshAuthorisation(const QString& token_endpoint,
|
||||||
<< Param("grant_type", "refresh_token")
|
<< Param("grant_type", "refresh_token")
|
||||||
<< Param("refresh_token", refresh_token);
|
<< Param("refresh_token", refresh_token);
|
||||||
QStringList params;
|
QStringList params;
|
||||||
foreach(const Param & p, parameters) {
|
for (const Param& p : parameters) {
|
||||||
params.append(QString("%1=%2").arg(
|
params.append(QString("%1=%2").arg(
|
||||||
p.first, QString(QUrl::toPercentEncoding(p.second))));
|
p.first, QString(QUrl::toPercentEncoding(p.second))));
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,7 @@ QStandardItem* SavedRadio::CreateRootItem() {
|
||||||
void SavedRadio::LazyPopulate(QStandardItem* item) {
|
void SavedRadio::LazyPopulate(QStandardItem* item) {
|
||||||
switch (item->data(InternetModel::Role_Type).toInt()) {
|
switch (item->data(InternetModel::Role_Type).toInt()) {
|
||||||
case InternetModel::Type_Service:
|
case InternetModel::Type_Service:
|
||||||
foreach(const Stream & stream, streams_)
|
for (const Stream& stream : streams_) AddStreamToList(stream, root_);
|
||||||
AddStreamToList(stream, root_);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ void SkydriveService::ListFilesFinished(QNetworkReply* reply) {
|
||||||
qLog(Debug) << response;
|
qLog(Debug) << response;
|
||||||
|
|
||||||
QVariantList files = response["data"].toList();
|
QVariantList files = response["data"].toList();
|
||||||
foreach(const QVariant & f, files) {
|
for (const QVariant& f : files) {
|
||||||
QVariantMap file = f.toMap();
|
QVariantMap file = f.toMap();
|
||||||
if (file["type"].toString() == "audio") {
|
if (file["type"].toString() == "audio") {
|
||||||
QString mime_type = GuessMimeTypeForFile(file["name"].toString());
|
QString mime_type = GuessMimeTypeForFile(file["name"].toString());
|
||||||
|
|
|
@ -226,7 +226,7 @@ void SomaFMServiceBase::RefreshStreams() {
|
||||||
void SomaFMServiceBase::PopulateStreams() {
|
void SomaFMServiceBase::PopulateStreams() {
|
||||||
if (root_->hasChildren()) root_->removeRows(0, root_->rowCount());
|
if (root_->hasChildren()) root_->removeRows(0, root_->rowCount());
|
||||||
|
|
||||||
foreach(const Stream & stream, streams_) {
|
for (const Stream& stream : streams_) {
|
||||||
QStandardItem* item =
|
QStandardItem* item =
|
||||||
new QStandardItem(QIcon(":last.fm/icon_radio.png"), QString());
|
new QStandardItem(QIcon(":last.fm/icon_radio.png"), QString());
|
||||||
item->setText(stream.title_);
|
item->setText(stream.title_);
|
||||||
|
|
|
@ -151,7 +151,7 @@ void SoundCloudService::SearchFinished(QNetworkReply* reply, int task_id) {
|
||||||
|
|
||||||
SongList songs = ExtractSongs(ExtractResult(reply));
|
SongList songs = ExtractSongs(ExtractResult(reply));
|
||||||
// Fill results list
|
// Fill results list
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
QStandardItem* child = CreateSongItem(song);
|
QStandardItem* child = CreateSongItem(song);
|
||||||
search_->appendRow(child);
|
search_->appendRow(child);
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ QNetworkReply* SoundCloudService::CreateRequest(const QString& ressource_name,
|
||||||
url.setPath(ressource_name);
|
url.setPath(ressource_name);
|
||||||
|
|
||||||
url.addQueryItem("client_id", kApiClientId);
|
url.addQueryItem("client_id", kApiClientId);
|
||||||
foreach(const Param & param, params) {
|
for (const Param& param : params) {
|
||||||
url.addQueryItem(param.first, param.second);
|
url.addQueryItem(param.first, param.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ SongList SoundCloudService::ExtractSongs(const QVariant& result) {
|
||||||
SongList songs;
|
SongList songs;
|
||||||
|
|
||||||
QVariantList q_variant_list = result.toList();
|
QVariantList q_variant_list = result.toList();
|
||||||
foreach(const QVariant & q, q_variant_list) {
|
for (const QVariant& q : q_variant_list) {
|
||||||
Song song = ExtractSong(q.toMap());
|
Song song = ExtractSong(q.toMap());
|
||||||
if (song.is_valid()) {
|
if (song.is_valid()) {
|
||||||
songs << song;
|
songs << song;
|
||||||
|
|
|
@ -78,7 +78,7 @@ void SpotifyBlobDownloader::Start() {
|
||||||
<< "libspotify.so.12.1.45"
|
<< "libspotify.so.12.1.45"
|
||||||
<< "libspotify.so.12.1.45" + QString(kSignatureSuffix);
|
<< "libspotify.so.12.1.45" + QString(kSignatureSuffix);
|
||||||
|
|
||||||
foreach(const QString & filename, filenames) {
|
for (const QString& filename : filenames) {
|
||||||
const QUrl url(SpotifyService::kBlobDownloadUrl + version_ + "/" +
|
const QUrl url(SpotifyService::kBlobDownloadUrl + version_ + "/" +
|
||||||
filename);
|
filename);
|
||||||
qLog(Info) << "Downloading" << url;
|
qLog(Info) << "Downloading" << url;
|
||||||
|
@ -103,7 +103,7 @@ void SpotifyBlobDownloader::ReplyFinished() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is everything finished?
|
// Is everything finished?
|
||||||
foreach(QNetworkReply * reply, replies_) {
|
for (QNetworkReply* reply : replies_) {
|
||||||
if (!reply->isFinished()) {
|
if (!reply->isFinished()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ void SpotifyBlobDownloader::ReplyFinished() {
|
||||||
QMap<QString, QByteArray> file_data;
|
QMap<QString, QByteArray> file_data;
|
||||||
QStringList signature_filenames;
|
QStringList signature_filenames;
|
||||||
|
|
||||||
foreach(QNetworkReply * reply, replies_) {
|
for (QNetworkReply* reply : replies_) {
|
||||||
const QString filename = reply->url().path().section('/', -1, -1);
|
const QString filename = reply->url().path().section('/', -1, -1);
|
||||||
|
|
||||||
if (filename.endsWith(kSignatureSuffix)) {
|
if (filename.endsWith(kSignatureSuffix)) {
|
||||||
|
@ -134,7 +134,7 @@ void SpotifyBlobDownloader::ReplyFinished() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify signatures
|
// Verify signatures
|
||||||
foreach(const QString & signature_filename, signature_filenames) {
|
for (const QString& signature_filename : signature_filenames) {
|
||||||
QString actual_filename = signature_filename;
|
QString actual_filename = signature_filename;
|
||||||
actual_filename.remove(kSignatureSuffix);
|
actual_filename.remove(kSignatureSuffix);
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ void SpotifyBlobDownloader::ReplyFinished() {
|
||||||
// Make the destination directory and write the files into it
|
// Make the destination directory and write the files into it
|
||||||
QDir().mkpath(path_);
|
QDir().mkpath(path_);
|
||||||
|
|
||||||
foreach(const QString & filename, file_data.keys()) {
|
for (const QString& filename : file_data.keys()) {
|
||||||
const QString dest_path = path_ + "/" + filename;
|
const QString dest_path = path_ + "/" + filename;
|
||||||
|
|
||||||
if (filename.endsWith(kSignatureSuffix)) continue;
|
if (filename.endsWith(kSignatureSuffix)) continue;
|
||||||
|
@ -197,7 +197,7 @@ void SpotifyBlobDownloader::ReplyProgress() {
|
||||||
int progress = 0;
|
int progress = 0;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
foreach(QNetworkReply * reply, replies_) {
|
for (QNetworkReply* reply : replies_) {
|
||||||
progress += reply->bytesAvailable();
|
progress += reply->bytesAvailable();
|
||||||
total += reply->rawHeader("Content-Length").toInt();
|
total += reply->rawHeader("Content-Length").toInt();
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ void SpotifyBlobDownloader::Cancel() { deleteLater(); }
|
||||||
void SpotifyBlobDownloader::ShowError(const QString& message) {
|
void SpotifyBlobDownloader::ShowError(const QString& message) {
|
||||||
// Stop any remaining replies before showing the dialog so they don't
|
// Stop any remaining replies before showing the dialog so they don't
|
||||||
// carry on in the background
|
// carry on in the background
|
||||||
foreach(QNetworkReply * reply, replies_) {
|
for (QNetworkReply* reply : replies_) {
|
||||||
disconnect(reply, 0, this, 0);
|
disconnect(reply, 0, this, 0);
|
||||||
reply->abort();
|
reply->abort();
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ void SpotifyServer::NewConnection() {
|
||||||
qLog(Info) << "Connection from port" << socket->peerPort();
|
qLog(Info) << "Connection from port" << socket->peerPort();
|
||||||
|
|
||||||
// Send any login messages that were queued before the client connected
|
// Send any login messages that were queued before the client connected
|
||||||
foreach(const pb::spotify::Message & message, queued_login_messages_) {
|
for (const pb::spotify::Message& message : queued_login_messages_) {
|
||||||
SendOrQueueMessage(message);
|
SendOrQueueMessage(message);
|
||||||
}
|
}
|
||||||
queued_login_messages_.clear();
|
queued_login_messages_.clear();
|
||||||
|
@ -105,7 +105,7 @@ void SpotifyServer::MessageArrived(const pb::spotify::Message& message) {
|
||||||
|
|
||||||
if (response.success()) {
|
if (response.success()) {
|
||||||
// Send any messages that were queued before the client logged in
|
// Send any messages that were queued before the client logged in
|
||||||
foreach(const pb::spotify::Message & message, queued_messages_) {
|
for (const pb::spotify::Message& message : queued_messages_) {
|
||||||
SendOrQueueMessage(message);
|
SendOrQueueMessage(message);
|
||||||
}
|
}
|
||||||
queued_messages_.clear();
|
queued_messages_.clear();
|
||||||
|
|
|
@ -393,7 +393,7 @@ void SpotifyService::PlaylistsUpdated(const pb::spotify::Playlists& response) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove and recreate the other playlists
|
// Remove and recreate the other playlists
|
||||||
foreach(QStandardItem * item, playlists_) {
|
for (QStandardItem* item : playlists_) {
|
||||||
item->parent()->removeRow(item->row());
|
item->parent()->removeRow(item->row());
|
||||||
}
|
}
|
||||||
playlists_.clear();
|
playlists_.clear();
|
||||||
|
@ -460,7 +460,7 @@ void SpotifyService::ToplistLoaded(
|
||||||
}
|
}
|
||||||
|
|
||||||
QStandardItem* SpotifyService::PlaylistBySpotifyIndex(int index) const {
|
QStandardItem* SpotifyService::PlaylistBySpotifyIndex(int index) const {
|
||||||
foreach(QStandardItem * item, playlists_) {
|
for (QStandardItem* item : playlists_) {
|
||||||
if (item->data(Role_UserPlaylistIndex).toInt() == index) {
|
if (item->data(Role_UserPlaylistIndex).toInt() == index) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
@ -637,7 +637,7 @@ void SpotifyService::SearchResults(
|
||||||
ClearSearchResults();
|
ClearSearchResults();
|
||||||
|
|
||||||
// Fill results list
|
// Fill results list
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
QStandardItem* child = CreateSongItem(song);
|
QStandardItem* child = CreateSongItem(song);
|
||||||
search_->appendRow(child);
|
search_->appendRow(child);
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ QByteArray UbuntuOneAuthenticator::GenerateAuthorisationHeader(
|
||||||
<< Param("oauth_signature_method", "PLAINTEXT");
|
<< Param("oauth_signature_method", "PLAINTEXT");
|
||||||
qSort(parameters.begin(), parameters.end());
|
qSort(parameters.begin(), parameters.end());
|
||||||
QStringList encoded_params;
|
QStringList encoded_params;
|
||||||
foreach(const Param & p, parameters) {
|
for (const Param& p : parameters) {
|
||||||
encoded_params << QString("%1=%2").arg(p.first, p.second);
|
encoded_params << QString("%1=%2").arg(p.first, p.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ QByteArray UbuntuOneAuthenticator::GenerateAuthorisationHeader(
|
||||||
// Construct authorisation header
|
// Construct authorisation header
|
||||||
parameters << Param("oauth_signature", signature);
|
parameters << Param("oauth_signature", signature);
|
||||||
QStringList header_params;
|
QStringList header_params;
|
||||||
foreach(const Param & p, parameters) {
|
for (const Param& p : parameters) {
|
||||||
header_params << QString("%1=\"%2\"").arg(p.first, p.second);
|
header_params << QString("%1=\"%2\"").arg(p.first, p.second);
|
||||||
}
|
}
|
||||||
QString authorisation_header = header_params.join(", ");
|
QString authorisation_header = header_params.join(", ");
|
||||||
|
|
|
@ -111,7 +111,7 @@ void UbuntuOneService::VolumeListRequestFinished(QNetworkReply* reply) {
|
||||||
|
|
||||||
QJson::Parser parser;
|
QJson::Parser parser;
|
||||||
QVariantList result = parser.parse(reply).toList();
|
QVariantList result = parser.parse(reply).toList();
|
||||||
foreach(const QVariant & v, result) {
|
for (const QVariant& v : result) {
|
||||||
RequestFileList(v.toMap()["node_path"].toString());
|
RequestFileList(v.toMap()["node_path"].toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ void UbuntuOneService::FileListRequestFinished(QNetworkReply* reply) {
|
||||||
QVariantMap result = parser.parse(reply).toMap();
|
QVariantMap result = parser.parse(reply).toMap();
|
||||||
|
|
||||||
QVariantList children = result["children"].toList();
|
QVariantList children = result["children"].toList();
|
||||||
foreach(const QVariant & c, children) {
|
for (const QVariant& c : children) {
|
||||||
QVariantMap child = c.toMap();
|
QVariantMap child = c.toMap();
|
||||||
if (child["kind"].toString() == "file") {
|
if (child["kind"].toString() == "file") {
|
||||||
QString content_path = child["content_path"].toString();
|
QString content_path = child["content_path"].toString();
|
||||||
|
|
|
@ -179,7 +179,7 @@ void Library::WriteAllSongsStatisticsToFiles() {
|
||||||
|
|
||||||
const int nb_songs = all_songs.size();
|
const int nb_songs = all_songs.size();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach(const Song & song, all_songs) {
|
for (const Song& song : all_songs) {
|
||||||
TagReaderClient::Instance()->UpdateSongStatisticsBlocking(song);
|
TagReaderClient::Instance()->UpdateSongStatisticsBlocking(song);
|
||||||
TagReaderClient::Instance()->UpdateSongRatingBlocking(song);
|
TagReaderClient::Instance()->UpdateSongRatingBlocking(song);
|
||||||
app_->task_manager()->SetTaskProgress(task_id, ++i, nb_songs);
|
app_->task_manager()->SetTaskProgress(task_id, ++i, nb_songs);
|
||||||
|
|
|
@ -93,7 +93,7 @@ void LibraryBackend::LoadDirectories() {
|
||||||
QMutexLocker l(db_->Mutex());
|
QMutexLocker l(db_->Mutex());
|
||||||
QSqlDatabase db(db_->Connect());
|
QSqlDatabase db(db_->Connect());
|
||||||
|
|
||||||
foreach(const Directory & dir, dirs) {
|
for (const Directory& dir : dirs) {
|
||||||
emit DirectoryDiscovered(dir, SubdirsInDirectory(dir.id, db));
|
emit DirectoryDiscovered(dir, SubdirsInDirectory(dir.id, db));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ void LibraryBackend::AddOrUpdateSubdirs(const SubdirectoryList& subdirs) {
|
||||||
db);
|
db);
|
||||||
|
|
||||||
ScopedTransaction transaction(&db);
|
ScopedTransaction transaction(&db);
|
||||||
foreach(const Subdirectory & subdir, subdirs) {
|
for (const Subdirectory& subdir : subdirs) {
|
||||||
if (subdir.mtime == 0) {
|
if (subdir.mtime == 0) {
|
||||||
// Delete the subdirectory
|
// Delete the subdirectory
|
||||||
delete_query.bindValue(":id", subdir.directory_id);
|
delete_query.bindValue(":id", subdir.directory_id);
|
||||||
|
@ -368,7 +368,7 @@ void LibraryBackend::AddOrUpdateSongs(const SongList& songs) {
|
||||||
SongList added_songs;
|
SongList added_songs;
|
||||||
SongList deleted_songs;
|
SongList deleted_songs;
|
||||||
|
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
// Do a sanity check first - make sure the song's directory still exists
|
// Do a sanity check first - make sure the song's directory still exists
|
||||||
// This is to fix a possible race condition when a directory is removed
|
// This is to fix a possible race condition when a directory is removed
|
||||||
// while LibraryWatcher is scanning it.
|
// while LibraryWatcher is scanning it.
|
||||||
|
@ -439,7 +439,7 @@ void LibraryBackend::UpdateMTimesOnly(const SongList& songs) {
|
||||||
db);
|
db);
|
||||||
|
|
||||||
ScopedTransaction transaction(&db);
|
ScopedTransaction transaction(&db);
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
q.bindValue(":mtime", song.mtime());
|
q.bindValue(":mtime", song.mtime());
|
||||||
q.bindValue(":id", song.id());
|
q.bindValue(":id", song.id());
|
||||||
q.exec();
|
q.exec();
|
||||||
|
@ -458,7 +458,7 @@ void LibraryBackend::DeleteSongs(const SongList& songs) {
|
||||||
QString("DELETE FROM %1 WHERE ROWID = :id").arg(fts_table_), db);
|
QString("DELETE FROM %1 WHERE ROWID = :id").arg(fts_table_), db);
|
||||||
|
|
||||||
ScopedTransaction transaction(&db);
|
ScopedTransaction transaction(&db);
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
remove.bindValue(":id", song.id());
|
remove.bindValue(":id", song.id());
|
||||||
remove.exec();
|
remove.exec();
|
||||||
db_->CheckErrors(remove);
|
db_->CheckErrors(remove);
|
||||||
|
@ -485,7 +485,7 @@ void LibraryBackend::MarkSongsUnavailable(const SongList& songs,
|
||||||
db);
|
db);
|
||||||
|
|
||||||
ScopedTransaction transaction(&db);
|
ScopedTransaction transaction(&db);
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
remove.bindValue(":id", song.id());
|
remove.bindValue(":id", song.id());
|
||||||
remove.exec();
|
remove.exec();
|
||||||
db_->CheckErrors(remove);
|
db_->CheckErrors(remove);
|
||||||
|
@ -584,7 +584,9 @@ SongList LibraryBackend::GetSongsById(const QList<int>& ids) {
|
||||||
QSqlDatabase db(db_->Connect());
|
QSqlDatabase db(db_->Connect());
|
||||||
|
|
||||||
QStringList str_ids;
|
QStringList str_ids;
|
||||||
foreach(int id, ids) { str_ids << QString::number(id); }
|
for (int id : ids) {
|
||||||
|
str_ids << QString::number(id);
|
||||||
|
}
|
||||||
|
|
||||||
return GetSongsById(str_ids, db);
|
return GetSongsById(str_ids, db);
|
||||||
}
|
}
|
||||||
|
@ -954,7 +956,7 @@ void LibraryBackend::ForceCompilation(const QString& album,
|
||||||
QSqlDatabase db(db_->Connect());
|
QSqlDatabase db(db_->Connect());
|
||||||
SongList deleted_songs, added_songs;
|
SongList deleted_songs, added_songs;
|
||||||
|
|
||||||
foreach(const QString & artist, artists) {
|
for (const QString& artist : artists) {
|
||||||
// Get the songs before they're updated
|
// Get the songs before they're updated
|
||||||
LibraryQuery query;
|
LibraryQuery query;
|
||||||
query.SetColumnSpec("ROWID, " + Song::kColumnSpec);
|
query.SetColumnSpec("ROWID, " + Song::kColumnSpec);
|
||||||
|
|
|
@ -211,7 +211,7 @@ void LibraryFilterWidget::GroupingChanged(const LibraryModel::Grouping& g) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now make sure the correct action is checked
|
// Now make sure the correct action is checked
|
||||||
foreach(QAction * action, group_by_group_->actions()) {
|
for (QAction* action : group_by_group_->actions()) {
|
||||||
if (action->property("group_by").isNull()) continue;
|
if (action->property("group_by").isNull()) continue;
|
||||||
|
|
||||||
if (g == action->property("group_by").value<LibraryModel::Grouping>()) {
|
if (g == action->property("group_by").value<LibraryModel::Grouping>()) {
|
||||||
|
|
|
@ -154,7 +154,7 @@ void LibraryModel::Init(bool async) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryModel::SongsDiscovered(const SongList& songs) {
|
void LibraryModel::SongsDiscovered(const SongList& songs) {
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
// Sanity check to make sure we don't add songs that are outside the user's
|
// Sanity check to make sure we don't add songs that are outside the user's
|
||||||
// filter
|
// filter
|
||||||
if (!query_options_.Matches(song)) continue;
|
if (!query_options_.Matches(song)) continue;
|
||||||
|
@ -250,7 +250,7 @@ void LibraryModel::SongsSlightlyChanged(const SongList& songs) {
|
||||||
// This is called if there was a minor change to the songs that will not
|
// This is called if there was a minor change to the songs that will not
|
||||||
// normally require the library to be restructured. We can just update our
|
// normally require the library to be restructured. We can just update our
|
||||||
// internal cache of Song objects without worrying about resetting the model.
|
// internal cache of Song objects without worrying about resetting the model.
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
if (song_nodes_.contains(song.id())) {
|
if (song_nodes_.contains(song.id())) {
|
||||||
song_nodes_[song.id()]->metadata = song;
|
song_nodes_[song.id()]->metadata = song;
|
||||||
}
|
}
|
||||||
|
@ -356,7 +356,7 @@ void LibraryModel::SongsDeleted(const SongList& songs) {
|
||||||
// Delete the actual song nodes first, keeping track of each parent so we
|
// Delete the actual song nodes first, keeping track of each parent so we
|
||||||
// might check to see if they're empty later.
|
// might check to see if they're empty later.
|
||||||
QSet<LibraryItem*> parents;
|
QSet<LibraryItem*> parents;
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
if (song_nodes_.contains(song.id())) {
|
if (song_nodes_.contains(song.id())) {
|
||||||
LibraryItem* node = song_nodes_[song.id()];
|
LibraryItem* node = song_nodes_[song.id()];
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ void LibraryModel::SongsDeleted(const SongList& songs) {
|
||||||
// Now delete empty parents
|
// Now delete empty parents
|
||||||
QSet<QString> divider_keys;
|
QSet<QString> divider_keys;
|
||||||
while (!parents.isEmpty()) {
|
while (!parents.isEmpty()) {
|
||||||
foreach(LibraryItem * node, parents) {
|
for (LibraryItem* node : parents) {
|
||||||
parents.remove(node);
|
parents.remove(node);
|
||||||
if (node->children.count() != 0) continue;
|
if (node->children.count() != 0) continue;
|
||||||
|
|
||||||
|
@ -405,12 +405,12 @@ void LibraryModel::SongsDeleted(const SongList& songs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete empty dividers
|
// Delete empty dividers
|
||||||
foreach(const QString & divider_key, divider_keys) {
|
for (const QString& divider_key : divider_keys) {
|
||||||
if (!divider_nodes_.contains(divider_key)) continue;
|
if (!divider_nodes_.contains(divider_key)) continue;
|
||||||
|
|
||||||
// Look to see if there are any other items still under this divider
|
// Look to see if there are any other items still under this divider
|
||||||
bool found = false;
|
bool found = false;
|
||||||
foreach(LibraryItem * node, container_nodes_[0].values()) {
|
for (LibraryItem* node : container_nodes_[0].values()) {
|
||||||
if (DividerKey(group_by_[0], node) == divider_key) {
|
if (DividerKey(group_by_[0], node) == divider_key) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
@ -571,7 +571,7 @@ QVariant LibraryModel::data(const LibraryItem* item, int role) const {
|
||||||
// if we have even one non editable item as a child, we ourselves
|
// if we have even one non editable item as a child, we ourselves
|
||||||
// are not available for edit
|
// are not available for edit
|
||||||
if (!item->children.isEmpty()) {
|
if (!item->children.isEmpty()) {
|
||||||
foreach(LibraryItem * child, item->children) {
|
for (LibraryItem* child : item->children) {
|
||||||
if (!data(child, role).toBool()) {
|
if (!data(child, role).toBool()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -655,7 +655,7 @@ void LibraryModel::PostQuery(LibraryItem* parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step through the results
|
// Step through the results
|
||||||
foreach(const SqlRow & row, result.rows) {
|
for (const SqlRow& row : result.rows) {
|
||||||
// Create the item - it will get inserted into the model here
|
// Create the item - it will get inserted into the model here
|
||||||
LibraryItem* item = ItemFromQuery(child_type, signal, child_level == 0,
|
LibraryItem* item = ItemFromQuery(child_type, signal, child_level == 0,
|
||||||
parent, row, child_level);
|
parent, row, child_level);
|
||||||
|
@ -1098,7 +1098,7 @@ QMimeData* LibraryModel::mimeData(const QModelIndexList& indexes) const {
|
||||||
|
|
||||||
data->backend = backend_;
|
data->backend = backend_;
|
||||||
|
|
||||||
foreach(const QModelIndex & index, indexes) {
|
for (const QModelIndex& index : indexes) {
|
||||||
GetChildSongs(IndexToItem(index), &urls, &data->songs, &song_ids);
|
GetChildSongs(IndexToItem(index), &urls, &data->songs, &song_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1128,8 +1128,8 @@ void LibraryModel::GetChildSongs(LibraryItem* item, QList<QUrl>* urls,
|
||||||
qSort(children.begin(), children.end(),
|
qSort(children.begin(), children.end(),
|
||||||
std::bind(&LibraryModel::CompareItems, this, _1, _2));
|
std::bind(&LibraryModel::CompareItems, this, _1, _2));
|
||||||
|
|
||||||
foreach(LibraryItem * child, children)
|
for (LibraryItem* child : children)
|
||||||
GetChildSongs(child, urls, songs, song_ids);
|
GetChildSongs(child, urls, songs, song_ids);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1151,7 +1151,7 @@ SongList LibraryModel::GetChildSongs(const QModelIndexList& indexes) const {
|
||||||
SongList ret;
|
SongList ret;
|
||||||
QSet<int> song_ids;
|
QSet<int> song_ids;
|
||||||
|
|
||||||
foreach(const QModelIndex & index, indexes) {
|
for (const QModelIndex& index : indexes) {
|
||||||
GetChildSongs(IndexToItem(index), &dontcare, &ret, &song_ids);
|
GetChildSongs(IndexToItem(index), &dontcare, &ret, &song_ids);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1244,8 +1244,8 @@ void LibraryModel::CreateSmartPlaylists() {
|
||||||
s.beginWriteArray(backend_->songs_table(),
|
s.beginWriteArray(backend_->songs_table(),
|
||||||
playlist_index + unwritten_defaults);
|
playlist_index + unwritten_defaults);
|
||||||
for (; version < default_smart_playlists_.count(); ++version) {
|
for (; version < default_smart_playlists_.count(); ++version) {
|
||||||
foreach(smart_playlists::GeneratorPtr gen,
|
for (smart_playlists::GeneratorPtr gen :
|
||||||
default_smart_playlists_[version]) {
|
default_smart_playlists_[version]) {
|
||||||
SaveGenerator(&s, playlist_index++, gen);
|
SaveGenerator(&s, playlist_index++, gen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1329,7 +1329,7 @@ void LibraryModel::DeleteGenerator(const QModelIndex& index) {
|
||||||
s.beginWriteArray(backend_->songs_table(),
|
s.beginWriteArray(backend_->songs_table(),
|
||||||
smart_playlist_node_->children.count());
|
smart_playlist_node_->children.count());
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach(LibraryItem * item, smart_playlist_node_->children) {
|
for (LibraryItem* item : smart_playlist_node_->children) {
|
||||||
s.setArrayIndex(i++);
|
s.setArrayIndex(i++);
|
||||||
s.setValue("name", item->display_text);
|
s.setValue("name", item->display_text);
|
||||||
s.setValue("type", item->key);
|
s.setValue("type", item->key);
|
||||||
|
|
|
@ -37,7 +37,7 @@ LibraryQuery::LibraryQuery(const QueryOptions& options)
|
||||||
QStringList tokens(
|
QStringList tokens(
|
||||||
options.filter().split(QRegExp("\\s+"), QString::SkipEmptyParts));
|
options.filter().split(QRegExp("\\s+"), QString::SkipEmptyParts));
|
||||||
QString query;
|
QString query;
|
||||||
foreach(QString token, tokens) {
|
for (QString token : tokens) {
|
||||||
token.remove('(');
|
token.remove('(');
|
||||||
token.remove(')');
|
token.remove(')');
|
||||||
token.remove('"');
|
token.remove('"');
|
||||||
|
@ -109,7 +109,7 @@ void LibraryQuery::AddWhere(const QString& column, const QVariant& value,
|
||||||
// ignore 'literal' for IN
|
// ignore 'literal' for IN
|
||||||
if (!op.compare("IN", Qt::CaseInsensitive)) {
|
if (!op.compare("IN", Qt::CaseInsensitive)) {
|
||||||
QStringList final;
|
QStringList final;
|
||||||
foreach(const QString & single_value, value.toStringList()) {
|
for (const QString& single_value : value.toStringList()) {
|
||||||
final.append("?");
|
final.append("?");
|
||||||
bound_values_ << single_value;
|
bound_values_ << single_value;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,9 @@ QSqlQuery LibraryQuery::Exec(QSqlDatabase db, const QString& songs_table,
|
||||||
query_ = QSqlQuery(sql, db);
|
query_ = QSqlQuery(sql, db);
|
||||||
|
|
||||||
// Bind values
|
// Bind values
|
||||||
foreach(const QVariant & value, bound_values_) { query_.addBindValue(value); }
|
for (const QVariant& value : bound_values_) {
|
||||||
|
query_.addBindValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
query_.exec();
|
query_.exec();
|
||||||
return query_;
|
return query_;
|
||||||
|
|
|
@ -256,7 +256,7 @@ bool LibraryView::RestoreLevelFocus(const QModelIndex& parent) {
|
||||||
QModelIndex index = qobject_cast<QSortFilterProxyModel*>(model())
|
QModelIndex index = qobject_cast<QSortFilterProxyModel*>(model())
|
||||||
->mapToSource(current);
|
->mapToSource(current);
|
||||||
SongList songs = app_->library_model()->GetChildSongs(index);
|
SongList songs = app_->library_model()->GetChildSongs(index);
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
if (song == last_selected_song_) {
|
if (song == last_selected_song_) {
|
||||||
setCurrentIndex(current);
|
setCurrentIndex(current);
|
||||||
return true;
|
return true;
|
||||||
|
@ -450,7 +450,7 @@ void LibraryView::contextMenuEvent(QContextMenuEvent* e) {
|
||||||
// number of editable non smart playlists selected
|
// number of editable non smart playlists selected
|
||||||
int regular_editable = 0;
|
int regular_editable = 0;
|
||||||
|
|
||||||
foreach(const QModelIndex & index, selected_indexes) {
|
for (const QModelIndex& index : selected_indexes) {
|
||||||
int type =
|
int type =
|
||||||
app_->library_model()->data(index, LibraryModel::Role_Type).toInt();
|
app_->library_model()->data(index, LibraryModel::Role_Type).toInt();
|
||||||
|
|
||||||
|
@ -530,7 +530,7 @@ void LibraryView::ShowInVarious(bool on) {
|
||||||
// node gets removed (due to all children removed), before the new one gets
|
// node gets removed (due to all children removed), before the new one gets
|
||||||
// added
|
// added
|
||||||
QMultiMap<QString, QString> albums;
|
QMultiMap<QString, QString> albums;
|
||||||
foreach(const Song & song, GetSelectedSongs()) {
|
for (const Song& song : GetSelectedSongs()) {
|
||||||
if (albums.find(song.album(), song.artist()) == albums.end())
|
if (albums.find(song.album(), song.artist()) == albums.end())
|
||||||
albums.insert(song.album(), song.artist());
|
albums.insert(song.album(), song.artist());
|
||||||
}
|
}
|
||||||
|
@ -543,7 +543,7 @@ void LibraryView::ShowInVarious(bool on) {
|
||||||
const QString album = albums.keys().first();
|
const QString album = albums.keys().first();
|
||||||
QList<Song> all_of_album = app_->library_backend()->GetSongsByAlbum(album);
|
QList<Song> all_of_album = app_->library_backend()->GetSongsByAlbum(album);
|
||||||
QSet<QString> other_artists;
|
QSet<QString> other_artists;
|
||||||
foreach(const Song & s, all_of_album) {
|
for (const Song& s : all_of_album) {
|
||||||
if (!albums.contains(album, s.artist()) &&
|
if (!albums.contains(album, s.artist()) &&
|
||||||
!other_artists.contains(s.artist())) {
|
!other_artists.contains(s.artist())) {
|
||||||
other_artists.insert(s.artist());
|
other_artists.insert(s.artist());
|
||||||
|
@ -555,12 +555,14 @@ void LibraryView::ShowInVarious(bool on) {
|
||||||
"this album to Various Artists as well?"),
|
"this album to Various Artists as well?"),
|
||||||
QMessageBox::Yes | QMessageBox::No,
|
QMessageBox::Yes | QMessageBox::No,
|
||||||
QMessageBox::Yes) == QMessageBox::Yes) {
|
QMessageBox::Yes) == QMessageBox::Yes) {
|
||||||
foreach(const QString & s, other_artists) { albums.insert(album, s); }
|
for (const QString& s : other_artists) {
|
||||||
|
albums.insert(album, s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(const QString & album, QSet<QString>::fromList(albums.keys())) {
|
for (const QString& album : QSet<QString>::fromList(albums.keys())) {
|
||||||
app_->library_backend()->ForceCompilation(album, albums.values(album), on);
|
app_->library_backend()->ForceCompilation(album, albums.values(album), on);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -733,7 +735,9 @@ void LibraryView::EditSmartPlaylistFinished() {
|
||||||
|
|
||||||
void LibraryView::ShowInBrowser() {
|
void LibraryView::ShowInBrowser() {
|
||||||
QList<QUrl> urls;
|
QList<QUrl> urls;
|
||||||
foreach(const Song & song, GetSelectedSongs()) { urls << song.url(); }
|
for (const Song& song : GetSelectedSongs()) {
|
||||||
|
urls << song.url();
|
||||||
|
}
|
||||||
|
|
||||||
Utilities::OpenInFileBrowser(urls);
|
Utilities::OpenInFileBrowser(urls);
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ LibraryWatcher::ScanTransaction::~ScanTransaction() {
|
||||||
|
|
||||||
if (watcher_->monitor_) {
|
if (watcher_->monitor_) {
|
||||||
// Watch the new subdirectories
|
// Watch the new subdirectories
|
||||||
foreach(const Subdirectory & subdir, new_subdirs) {
|
for (const Subdirectory& subdir : new_subdirs) {
|
||||||
watcher_->AddWatch(watcher_->watched_dirs_[dir_], subdir.path);
|
watcher_->AddWatch(watcher_->watched_dirs_[dir_], subdir.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ SongList LibraryWatcher::ScanTransaction::FindSongsInSubdirectory(
|
||||||
|
|
||||||
// TODO: Make this faster
|
// TODO: Make this faster
|
||||||
SongList ret;
|
SongList ret;
|
||||||
foreach(const Song & song, cached_songs_) {
|
for (const Song& song : cached_songs_) {
|
||||||
if (song.url().toLocalFile().section('/', 0, -2) == path) ret << song;
|
if (song.url().toLocalFile().section('/', 0, -2) == path) ret << song;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -159,7 +159,7 @@ bool LibraryWatcher::ScanTransaction::HasSeenSubdir(const QString& path) {
|
||||||
if (known_subdirs_dirty_)
|
if (known_subdirs_dirty_)
|
||||||
SetKnownSubdirs(watcher_->backend_->SubdirsInDirectory(dir_));
|
SetKnownSubdirs(watcher_->backend_->SubdirsInDirectory(dir_));
|
||||||
|
|
||||||
foreach(const Subdirectory & subdir, known_subdirs_) {
|
for (const Subdirectory& subdir : known_subdirs_) {
|
||||||
if (subdir.path == path && subdir.mtime != 0) return true;
|
if (subdir.path == path && subdir.mtime != 0) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -171,7 +171,7 @@ SubdirectoryList LibraryWatcher::ScanTransaction::GetImmediateSubdirs(
|
||||||
SetKnownSubdirs(watcher_->backend_->SubdirsInDirectory(dir_));
|
SetKnownSubdirs(watcher_->backend_->SubdirsInDirectory(dir_));
|
||||||
|
|
||||||
SubdirectoryList ret;
|
SubdirectoryList ret;
|
||||||
foreach(const Subdirectory & subdir, known_subdirs_) {
|
for (const Subdirectory& subdir : known_subdirs_) {
|
||||||
if (subdir.path.left(subdir.path.lastIndexOf(QDir::separator())) == path &&
|
if (subdir.path.left(subdir.path.lastIndexOf(QDir::separator())) == path &&
|
||||||
subdir.mtime != 0) {
|
subdir.mtime != 0) {
|
||||||
ret << subdir;
|
ret << subdir;
|
||||||
|
@ -204,7 +204,7 @@ void LibraryWatcher::AddDirectory(const Directory& dir,
|
||||||
ScanTransaction transaction(this, dir.id, true);
|
ScanTransaction transaction(this, dir.id, true);
|
||||||
transaction.SetKnownSubdirs(subdirs);
|
transaction.SetKnownSubdirs(subdirs);
|
||||||
transaction.AddToProgressMax(subdirs.count());
|
transaction.AddToProgressMax(subdirs.count());
|
||||||
foreach(const Subdirectory & subdir, subdirs) {
|
for (const Subdirectory& subdir : subdirs) {
|
||||||
if (stop_requested_) return;
|
if (stop_requested_) return;
|
||||||
|
|
||||||
if (scan_on_startup_) ScanSubdirectory(subdir.path, subdir, &transaction);
|
if (scan_on_startup_) ScanSubdirectory(subdir.path, subdir, &transaction);
|
||||||
|
@ -225,7 +225,7 @@ void LibraryWatcher::ScanSubdirectory(const QString& path,
|
||||||
// Do not scan symlinked dirs that are already in collection
|
// Do not scan symlinked dirs that are already in collection
|
||||||
if (path_info.isSymLink()) {
|
if (path_info.isSymLink()) {
|
||||||
QString real_path = path_info.symLinkTarget();
|
QString real_path = path_info.symLinkTarget();
|
||||||
foreach(const Directory & dir, watched_dirs_) {
|
for (const Directory& dir : watched_dirs_) {
|
||||||
if (real_path.startsWith(dir.path)) {
|
if (real_path.startsWith(dir.path)) {
|
||||||
t->AddToProgress(1);
|
t->AddToProgress(1);
|
||||||
return;
|
return;
|
||||||
|
@ -248,7 +248,7 @@ void LibraryWatcher::ScanSubdirectory(const QString& path,
|
||||||
// so we need to look and see if any of our children don't exist any more.
|
// so we need to look and see if any of our children don't exist any more.
|
||||||
// If one has been removed, "rescan" it to get the deleted songs
|
// If one has been removed, "rescan" it to get the deleted songs
|
||||||
SubdirectoryList previous_subdirs = t->GetImmediateSubdirs(path);
|
SubdirectoryList previous_subdirs = t->GetImmediateSubdirs(path);
|
||||||
foreach(const Subdirectory & subdir, previous_subdirs) {
|
for (const Subdirectory& subdir : previous_subdirs) {
|
||||||
if (!QFile::exists(subdir.path) && subdir.path != path) {
|
if (!QFile::exists(subdir.path) && subdir.path != path) {
|
||||||
t->AddToProgressMax(1);
|
t->AddToProgressMax(1);
|
||||||
ScanSubdirectory(subdir.path, subdir, t, true);
|
ScanSubdirectory(subdir.path, subdir, t, true);
|
||||||
|
@ -296,7 +296,7 @@ void LibraryWatcher::ScanSubdirectory(const QString& path,
|
||||||
QSet<QString> cues_processed;
|
QSet<QString> cues_processed;
|
||||||
|
|
||||||
// Now compare the list from the database with the list of files on disk
|
// Now compare the list from the database with the list of files on disk
|
||||||
foreach(const QString & file, files_on_disk) {
|
for (const QString& file : files_on_disk) {
|
||||||
if (stop_requested_) return;
|
if (stop_requested_) return;
|
||||||
|
|
||||||
// associated cue
|
// associated cue
|
||||||
|
@ -370,7 +370,7 @@ void LibraryWatcher::ScanSubdirectory(const QString& path,
|
||||||
// choose an image for the song(s)
|
// choose an image for the song(s)
|
||||||
QString image = ImageForSong(file, album_art);
|
QString image = ImageForSong(file, album_art);
|
||||||
|
|
||||||
foreach(Song song, song_list) {
|
for (Song song : song_list) {
|
||||||
song.set_directory_id(t->dir());
|
song.set_directory_id(t->dir());
|
||||||
if (song.art_automatic().isEmpty()) song.set_art_automatic(image);
|
if (song.art_automatic().isEmpty()) song.set_art_automatic(image);
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ void LibraryWatcher::ScanSubdirectory(const QString& path,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for deleted songs
|
// Look for deleted songs
|
||||||
foreach(const Song & song, songs_in_db) {
|
for (const Song& song : songs_in_db) {
|
||||||
if (!song.is_unavailable() &&
|
if (!song.is_unavailable() &&
|
||||||
!files_on_disk.contains(song.url().toLocalFile())) {
|
!files_on_disk.contains(song.url().toLocalFile())) {
|
||||||
qLog(Debug) << "Song deleted from disk:" << song.url().toLocalFile();
|
qLog(Debug) << "Song deleted from disk:" << song.url().toLocalFile();
|
||||||
|
@ -404,7 +404,7 @@ void LibraryWatcher::ScanSubdirectory(const QString& path,
|
||||||
|
|
||||||
// Recurse into the new subdirs that we found
|
// Recurse into the new subdirs that we found
|
||||||
t->AddToProgressMax(my_new_subdirs.count());
|
t->AddToProgressMax(my_new_subdirs.count());
|
||||||
foreach(const Subdirectory & my_new_subdir, my_new_subdirs) {
|
for (const Subdirectory& my_new_subdir : my_new_subdirs) {
|
||||||
if (stop_requested_) return;
|
if (stop_requested_) return;
|
||||||
ScanSubdirectory(my_new_subdir.path, my_new_subdir, t, true);
|
ScanSubdirectory(my_new_subdir.path, my_new_subdir, t, true);
|
||||||
}
|
}
|
||||||
|
@ -421,14 +421,14 @@ void LibraryWatcher::UpdateCueAssociatedSongs(const QString& file,
|
||||||
SongList old_sections = backend_->GetSongsByUrl(QUrl::fromLocalFile(file));
|
SongList old_sections = backend_->GetSongsByUrl(QUrl::fromLocalFile(file));
|
||||||
|
|
||||||
QHash<quint64, Song> sections_map;
|
QHash<quint64, Song> sections_map;
|
||||||
foreach(const Song & song, old_sections) {
|
for (const Song& song : old_sections) {
|
||||||
sections_map[song.beginning_nanosec()] = song;
|
sections_map[song.beginning_nanosec()] = song;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<int> used_ids;
|
QSet<int> used_ids;
|
||||||
|
|
||||||
// update every song that's in the cue and library
|
// update every song that's in the cue and library
|
||||||
foreach(Song cue_song, cue_parser_->Load(&cue, matching_cue, path)) {
|
for (Song cue_song : cue_parser_->Load(&cue, matching_cue, path)) {
|
||||||
cue_song.set_directory_id(t->dir());
|
cue_song.set_directory_id(t->dir());
|
||||||
|
|
||||||
Song matching = sections_map[cue_song.beginning_nanosec()];
|
Song matching = sections_map[cue_song.beginning_nanosec()];
|
||||||
|
@ -443,7 +443,7 @@ void LibraryWatcher::UpdateCueAssociatedSongs(const QString& file,
|
||||||
}
|
}
|
||||||
|
|
||||||
// sections that are now missing
|
// sections that are now missing
|
||||||
foreach(const Song & matching, old_sections) {
|
for (const Song& matching : old_sections) {
|
||||||
if (!used_ids.contains(matching.id())) {
|
if (!used_ids.contains(matching.id())) {
|
||||||
t->deleted_songs << matching;
|
t->deleted_songs << matching;
|
||||||
}
|
}
|
||||||
|
@ -459,8 +459,8 @@ void LibraryWatcher::UpdateNonCueAssociatedSong(const QString& file,
|
||||||
// 'raw' (cueless) song and we just remove the rest of the sections
|
// 'raw' (cueless) song and we just remove the rest of the sections
|
||||||
// from the library
|
// from the library
|
||||||
if (cue_deleted) {
|
if (cue_deleted) {
|
||||||
foreach(const Song & song,
|
for (const Song& song :
|
||||||
backend_->GetSongsByUrl(QUrl::fromLocalFile(file))) {
|
backend_->GetSongsByUrl(QUrl::fromLocalFile(file))) {
|
||||||
if (!song.IsMetadataEqual(matching_song)) {
|
if (!song.IsMetadataEqual(matching_song)) {
|
||||||
t->deleted_songs << song;
|
t->deleted_songs << song;
|
||||||
}
|
}
|
||||||
|
@ -493,8 +493,7 @@ SongList LibraryWatcher::ScanNewFile(const QString& file, const QString& path,
|
||||||
// Ignore FILEs pointing to other media files. Also, watch out for incorrect
|
// Ignore FILEs pointing to other media files. Also, watch out for incorrect
|
||||||
// media files. Playlist parser for CUEs considers every entry in sheet
|
// media files. Playlist parser for CUEs considers every entry in sheet
|
||||||
// valid and we don't want invalid media getting into library!
|
// valid and we don't want invalid media getting into library!
|
||||||
foreach(const Song & cue_song,
|
for (const Song& cue_song : cue_parser_->Load(&cue, matching_cue, path)) {
|
||||||
cue_parser_->Load(&cue, matching_cue, path)) {
|
|
||||||
if (cue_song.url().toLocalFile() == file) {
|
if (cue_song.url().toLocalFile() == file) {
|
||||||
if (TagReaderClient::Instance()->IsMediaFileBlocking(file)) {
|
if (TagReaderClient::Instance()->IsMediaFileBlocking(file)) {
|
||||||
song_list << cue_song;
|
song_list << cue_song;
|
||||||
|
@ -579,7 +578,7 @@ void LibraryWatcher::RemoveDirectory(const Directory& dir) {
|
||||||
watched_dirs_.remove(dir.id);
|
watched_dirs_.remove(dir.id);
|
||||||
|
|
||||||
// Stop watching the directory's subdirectories
|
// Stop watching the directory's subdirectories
|
||||||
foreach(const QString & subdir_path, subdir_mapping_.keys(dir)) {
|
for (const QString& subdir_path : subdir_mapping_.keys(dir)) {
|
||||||
fs_watcher_->RemovePath(subdir_path);
|
fs_watcher_->RemovePath(subdir_path);
|
||||||
subdir_mapping_.remove(subdir_path);
|
subdir_mapping_.remove(subdir_path);
|
||||||
}
|
}
|
||||||
|
@ -588,7 +587,7 @@ void LibraryWatcher::RemoveDirectory(const Directory& dir) {
|
||||||
bool LibraryWatcher::FindSongByPath(const SongList& list, const QString& path,
|
bool LibraryWatcher::FindSongByPath(const SongList& list, const QString& path,
|
||||||
Song* out) {
|
Song* out) {
|
||||||
// TODO: Make this faster
|
// TODO: Make this faster
|
||||||
foreach(const Song & song, list) {
|
for (const Song& song : list) {
|
||||||
if (song.url().toLocalFile() == path) {
|
if (song.url().toLocalFile() == path) {
|
||||||
*out = song;
|
*out = song;
|
||||||
return true;
|
return true;
|
||||||
|
@ -616,12 +615,12 @@ void LibraryWatcher::DirectoryChanged(const QString& subdir) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWatcher::RescanPathsNow() {
|
void LibraryWatcher::RescanPathsNow() {
|
||||||
foreach(int dir, rescan_queue_.keys()) {
|
for (int dir : rescan_queue_.keys()) {
|
||||||
if (stop_requested_) return;
|
if (stop_requested_) return;
|
||||||
ScanTransaction transaction(this, dir, false);
|
ScanTransaction transaction(this, dir, false);
|
||||||
transaction.AddToProgressMax(rescan_queue_[dir].count());
|
transaction.AddToProgressMax(rescan_queue_[dir].count());
|
||||||
|
|
||||||
foreach(const QString & path, rescan_queue_[dir]) {
|
for (const QString& path : rescan_queue_[dir]) {
|
||||||
if (stop_requested_) return;
|
if (stop_requested_) return;
|
||||||
Subdirectory subdir;
|
Subdirectory subdir;
|
||||||
subdir.directory_id = dir;
|
subdir.directory_id = dir;
|
||||||
|
@ -643,10 +642,10 @@ QString LibraryWatcher::PickBestImage(const QStringList& images) {
|
||||||
|
|
||||||
QStringList filtered;
|
QStringList filtered;
|
||||||
|
|
||||||
foreach(const QString & filter_text, best_image_filters_) {
|
for (const QString& filter_text : best_image_filters_) {
|
||||||
// the images in the images list are represented by a full path,
|
// the images in the images list are represented by a full path,
|
||||||
// so we need to isolate just the filename
|
// so we need to isolate just the filename
|
||||||
foreach(const QString & image, images) {
|
for (const QString& image : images) {
|
||||||
QFileInfo file_info(image);
|
QFileInfo file_info(image);
|
||||||
QString filename(file_info.fileName());
|
QString filename(file_info.fileName());
|
||||||
if (filename.contains(filter_text, Qt::CaseInsensitive))
|
if (filename.contains(filter_text, Qt::CaseInsensitive))
|
||||||
|
@ -667,7 +666,7 @@ QString LibraryWatcher::PickBestImage(const QStringList& images) {
|
||||||
int biggest_size = 0;
|
int biggest_size = 0;
|
||||||
QString biggest_path;
|
QString biggest_path;
|
||||||
|
|
||||||
foreach(const QString & path, filtered) {
|
for (const QString& path : filtered) {
|
||||||
QImage image(path);
|
QImage image(path);
|
||||||
if (image.isNull()) continue;
|
if (image.isNull()) continue;
|
||||||
|
|
||||||
|
@ -713,7 +712,7 @@ void LibraryWatcher::ReloadSettings() {
|
||||||
QStringList filters =
|
QStringList filters =
|
||||||
s.value("cover_art_patterns", QStringList() << "front"
|
s.value("cover_art_patterns", QStringList() << "front"
|
||||||
<< "cover").toStringList();
|
<< "cover").toStringList();
|
||||||
foreach(const QString & filter, filters) {
|
for (const QString& filter : filters) {
|
||||||
QString s = filter.trimmed();
|
QString s = filter.trimmed();
|
||||||
if (!s.isEmpty()) best_image_filters_ << s;
|
if (!s.isEmpty()) best_image_filters_ << s;
|
||||||
}
|
}
|
||||||
|
@ -722,9 +721,9 @@ void LibraryWatcher::ReloadSettings() {
|
||||||
fs_watcher_->Clear();
|
fs_watcher_->Clear();
|
||||||
} else if (monitor_ && !was_monitoring_before) {
|
} else if (monitor_ && !was_monitoring_before) {
|
||||||
// Add all directories to all QFileSystemWatchers again
|
// Add all directories to all QFileSystemWatchers again
|
||||||
foreach(const Directory & dir, watched_dirs_.values()) {
|
for (const Directory& dir : watched_dirs_.values()) {
|
||||||
SubdirectoryList subdirs = backend_->SubdirsInDirectory(dir.id);
|
SubdirectoryList subdirs = backend_->SubdirsInDirectory(dir.id);
|
||||||
foreach(const Subdirectory & subdir, subdirs) {
|
for (const Subdirectory& subdir : subdirs) {
|
||||||
AddWatch(dir, subdir.path);
|
AddWatch(dir, subdir.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -754,12 +753,12 @@ void LibraryWatcher::IncrementalScanNow() { PerformScan(true, false); }
|
||||||
void LibraryWatcher::FullScanNow() { PerformScan(false, true); }
|
void LibraryWatcher::FullScanNow() { PerformScan(false, true); }
|
||||||
|
|
||||||
void LibraryWatcher::PerformScan(bool incremental, bool ignore_mtimes) {
|
void LibraryWatcher::PerformScan(bool incremental, bool ignore_mtimes) {
|
||||||
foreach(const Directory & dir, watched_dirs_.values()) {
|
for (const Directory& dir : watched_dirs_.values()) {
|
||||||
ScanTransaction transaction(this, dir.id, incremental, ignore_mtimes);
|
ScanTransaction transaction(this, dir.id, incremental, ignore_mtimes);
|
||||||
SubdirectoryList subdirs(transaction.GetAllSubdirs());
|
SubdirectoryList subdirs(transaction.GetAllSubdirs());
|
||||||
transaction.AddToProgressMax(subdirs.count());
|
transaction.AddToProgressMax(subdirs.count());
|
||||||
|
|
||||||
foreach(const Subdirectory & subdir, subdirs) {
|
for (const Subdirectory& subdir : subdirs) {
|
||||||
if (stop_requested_) return;
|
if (stop_requested_) return;
|
||||||
|
|
||||||
ScanSubdirectory(subdir.path, subdir, &transaction);
|
ScanSubdirectory(subdir.path, subdir, &transaction);
|
||||||
|
|
|
@ -137,7 +137,7 @@ void MoodbarItemDelegate::StartLoadingData(const QUrl& url, Data* data) {
|
||||||
|
|
||||||
bool MoodbarItemDelegate::RemoveFromCacheIfIndexesInvalid(const QUrl& url,
|
bool MoodbarItemDelegate::RemoveFromCacheIfIndexesInvalid(const QUrl& url,
|
||||||
Data* data) {
|
Data* data) {
|
||||||
foreach(const QPersistentModelIndex & index, data->indexes_) {
|
for (const QPersistentModelIndex& index : data->indexes_) {
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ bool MoodbarItemDelegate::RemoveFromCacheIfIndexesInvalid(const QUrl& url,
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoodbarItemDelegate::ReloadAllColors() {
|
void MoodbarItemDelegate::ReloadAllColors() {
|
||||||
foreach(const QUrl & url, data_.keys()) {
|
for (const QUrl& url : data_.keys()) {
|
||||||
Data* data = data_[url];
|
Data* data = data_[url];
|
||||||
|
|
||||||
if (data->state_ == Data::State_Loaded) {
|
if (data->state_ == Data::State_Loaded) {
|
||||||
|
@ -252,7 +252,7 @@ void MoodbarItemDelegate::ImageLoaded(const QUrl& url,
|
||||||
const QSortFilterProxyModel* filter = playlist->proxy();
|
const QSortFilterProxyModel* filter = playlist->proxy();
|
||||||
|
|
||||||
// Update all the indices with the new pixmap.
|
// Update all the indices with the new pixmap.
|
||||||
foreach(const QPersistentModelIndex & index, data->indexes_) {
|
for (const QPersistentModelIndex& index : data->indexes_) {
|
||||||
if (index.isValid() &&
|
if (index.isValid() &&
|
||||||
index.sibling(index.row(), Playlist::Column_Filename).data().toUrl() ==
|
index.sibling(index.row(), Playlist::Column_Filename).data().toUrl() ==
|
||||||
url) {
|
url) {
|
||||||
|
|
|
@ -93,7 +93,7 @@ MoodbarLoader::Result MoodbarLoader::Load(const QUrl& url, QByteArray* data,
|
||||||
// Check if a mood file exists for this file already
|
// Check if a mood file exists for this file already
|
||||||
const QString filename(url.toLocalFile());
|
const QString filename(url.toLocalFile());
|
||||||
|
|
||||||
foreach(const QString & possible_mood_file, MoodFilenames(filename)) {
|
for (const QString& possible_mood_file : MoodFilenames(filename)) {
|
||||||
QFile f(possible_mood_file);
|
QFile f(possible_mood_file);
|
||||||
if (f.open(QIODevice::ReadOnly)) {
|
if (f.open(QIODevice::ReadOnly)) {
|
||||||
qLog(Info) << "Loading moodbar data from" << possible_mood_file;
|
qLog(Info) << "Loading moodbar data from" << possible_mood_file;
|
||||||
|
|
|
@ -362,7 +362,7 @@ void MoodbarProxyStyle::ShowContextMenu(const QPoint& pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the currently selected style
|
// Update the currently selected style
|
||||||
foreach(QAction * action, style_action_group_->actions()) {
|
for (QAction* action : style_action_group_->actions()) {
|
||||||
if (MoodbarRenderer::MoodbarStyle(action->data().toInt()) ==
|
if (MoodbarRenderer::MoodbarStyle(action->data().toInt()) ==
|
||||||
moodbar_style_) {
|
moodbar_style_) {
|
||||||
action->setChecked(true);
|
action->setChecked(true);
|
||||||
|
|
|
@ -91,11 +91,11 @@ void AcoustidClient::RequestFinished(QNetworkReply* reply, int id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QVariantList results = result["results"].toList();
|
QVariantList results = result["results"].toList();
|
||||||
foreach(const QVariant & v, results) {
|
for (const QVariant& v : results) {
|
||||||
QVariantMap r = v.toMap();
|
QVariantMap r = v.toMap();
|
||||||
if (r.contains("recordings")) {
|
if (r.contains("recordings")) {
|
||||||
QVariantList recordings = r["recordings"].toList();
|
QVariantList recordings = r["recordings"].toList();
|
||||||
foreach(const QVariant & recording, recordings) {
|
for (const QVariant& recording : recordings) {
|
||||||
QVariantMap o = recording.toMap();
|
QVariantMap o = recording.toMap();
|
||||||
if (o.contains("id")) {
|
if (o.contains("id")) {
|
||||||
emit Finished(id, o["id"].toString());
|
emit Finished(id, o["id"].toString());
|
||||||
|
|
|
@ -118,7 +118,7 @@ void MusicBrainzClient::DiscIdRequestFinished(QNetworkReply* reply) {
|
||||||
if (token == QXmlStreamReader::StartElement &&
|
if (token == QXmlStreamReader::StartElement &&
|
||||||
reader.name() == "recording") {
|
reader.name() == "recording") {
|
||||||
ResultList tracks = ParseTrack(&reader);
|
ResultList tracks = ParseTrack(&reader);
|
||||||
foreach(const Result & track, tracks) {
|
for (const Result& track : tracks) {
|
||||||
if (!track.title_.isEmpty()) {
|
if (!track.title_.isEmpty()) {
|
||||||
ret << track;
|
ret << track;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ void MusicBrainzClient::RequestFinished(QNetworkReply* reply, int id) {
|
||||||
if (reader.readNext() == QXmlStreamReader::StartElement &&
|
if (reader.readNext() == QXmlStreamReader::StartElement &&
|
||||||
reader.name() == "recording") {
|
reader.name() == "recording") {
|
||||||
ResultList tracks = ParseTrack(&reader);
|
ResultList tracks = ParseTrack(&reader);
|
||||||
foreach(const Result & track, tracks) {
|
for (const Result& track : tracks) {
|
||||||
if (!track.title_.isEmpty()) {
|
if (!track.title_.isEmpty()) {
|
||||||
ret << track;
|
ret << track;
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ MusicBrainzClient::ResultList MusicBrainzClient::ParseTrack(
|
||||||
if (releases.isEmpty()) {
|
if (releases.isEmpty()) {
|
||||||
ret << result;
|
ret << result;
|
||||||
} else {
|
} else {
|
||||||
foreach(const Release & release, releases) {
|
for (const Release& release : releases) {
|
||||||
ret << release.CopyAndMergeInto(result);
|
ret << release.CopyAndMergeInto(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ void TagFetcher::StartFetch(const SongList& songs) {
|
||||||
connect(fingerprint_watcher_, SIGNAL(resultReadyAt(int)),
|
connect(fingerprint_watcher_, SIGNAL(resultReadyAt(int)),
|
||||||
SLOT(FingerprintFound(int)));
|
SLOT(FingerprintFound(int)));
|
||||||
|
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
emit Progress(song, tr("Fingerprinting song"));
|
emit Progress(song, tr("Fingerprinting song"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ void TagFetcher::TagsFetched(int index,
|
||||||
const Song& original_song = songs_[index];
|
const Song& original_song = songs_[index];
|
||||||
SongList songs_guessed;
|
SongList songs_guessed;
|
||||||
|
|
||||||
foreach(const MusicBrainzClient::Result & result, results) {
|
for (const MusicBrainzClient::Result& result : results) {
|
||||||
Song song;
|
Song song;
|
||||||
song.Init(result.title_, result.artist_, result.album_,
|
song.Init(result.title_, result.artist_, result.album_,
|
||||||
result.duration_msec_ * kNsecPerMsec);
|
result.duration_msec_ * kNsecPerMsec);
|
||||||
|
|
|
@ -63,7 +63,7 @@ void OutgoingDataCreator::SetClients(QList<RemoteClient*>* clients) {
|
||||||
connect(fetcher_, SIGNAL(ResultReady(int, SongInfoFetcher::Result)),
|
connect(fetcher_, SIGNAL(ResultReady(int, SongInfoFetcher::Result)),
|
||||||
SLOT(SendLyrics(int, SongInfoFetcher::Result)));
|
SLOT(SendLyrics(int, SongInfoFetcher::Result)));
|
||||||
|
|
||||||
foreach(SongInfoProvider * provider, provider_list_) {
|
for (SongInfoProvider* provider : provider_list_) {
|
||||||
fetcher_->AddProvider(provider);
|
fetcher_->AddProvider(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,21 +98,21 @@ void OutgoingDataCreator::CheckEnabledProviders() {
|
||||||
<< "darklyrics.com";
|
<< "darklyrics.com";
|
||||||
|
|
||||||
QVariant saved_order = s.value("search_order", default_order);
|
QVariant saved_order = s.value("search_order", default_order);
|
||||||
foreach(const QVariant & name, saved_order.toList()) {
|
for (const QVariant& name : saved_order.toList()) {
|
||||||
SongInfoProvider* provider = ProviderByName(name.toString());
|
SongInfoProvider* provider = ProviderByName(name.toString());
|
||||||
if (provider) ordered_providers << provider;
|
if (provider) ordered_providers << provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable all the providers in the list and rank them
|
// Enable all the providers in the list and rank them
|
||||||
int relevance = 100;
|
int relevance = 100;
|
||||||
foreach(SongInfoProvider * provider, ordered_providers) {
|
for (SongInfoProvider* provider : ordered_providers) {
|
||||||
provider->set_enabled(true);
|
provider->set_enabled(true);
|
||||||
qobject_cast<UltimateLyricsProvider*>(provider)->set_relevance(relevance--);
|
qobject_cast<UltimateLyricsProvider*>(provider)->set_relevance(relevance--);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Any lyric providers we don't have in ordered_providers are considered
|
// Any lyric providers we don't have in ordered_providers are considered
|
||||||
// disabled
|
// disabled
|
||||||
foreach(SongInfoProvider * provider, fetcher_->providers()) {
|
for (SongInfoProvider* provider : fetcher_->providers()) {
|
||||||
if (qobject_cast<UltimateLyricsProvider*>(provider) &&
|
if (qobject_cast<UltimateLyricsProvider*>(provider) &&
|
||||||
!ordered_providers.contains(provider)) {
|
!ordered_providers.contains(provider)) {
|
||||||
provider->set_enabled(false);
|
provider->set_enabled(false);
|
||||||
|
@ -122,7 +122,7 @@ void OutgoingDataCreator::CheckEnabledProviders() {
|
||||||
|
|
||||||
SongInfoProvider* OutgoingDataCreator::ProviderByName(const QString& name)
|
SongInfoProvider* OutgoingDataCreator::ProviderByName(const QString& name)
|
||||||
const {
|
const {
|
||||||
foreach(SongInfoProvider * provider, fetcher_->providers()) {
|
for (SongInfoProvider* provider : fetcher_->providers()) {
|
||||||
if (UltimateLyricsProvider* lyrics =
|
if (UltimateLyricsProvider* lyrics =
|
||||||
qobject_cast<UltimateLyricsProvider*>(provider)) {
|
qobject_cast<UltimateLyricsProvider*>(provider)) {
|
||||||
if (lyrics->name() == name) return provider;
|
if (lyrics->name() == name) return provider;
|
||||||
|
@ -137,8 +137,7 @@ void OutgoingDataCreator::SendDataToClients(pb::remote::Message* msg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteClient* client;
|
for (RemoteClient* client : *clients_) {
|
||||||
foreach(client, *clients_) {
|
|
||||||
// Do not send data to downloaders
|
// Do not send data to downloaders
|
||||||
if (client->isDownloader()) {
|
if (client->isDownloader()) {
|
||||||
if (client->State() != QTcpSocket::ConnectedState) {
|
if (client->State() != QTcpSocket::ConnectedState) {
|
||||||
|
@ -207,8 +206,8 @@ void OutgoingDataCreator::SendAllPlaylists() {
|
||||||
pb::remote::ResponsePlaylists* playlists = msg.mutable_response_playlists();
|
pb::remote::ResponsePlaylists* playlists = msg.mutable_response_playlists();
|
||||||
|
|
||||||
// Get all playlists, even ones that are hidden in the UI.
|
// Get all playlists, even ones that are hidden in the UI.
|
||||||
foreach(const PlaylistBackend::Playlist & p,
|
for (const PlaylistBackend::Playlist& p :
|
||||||
app_->playlist_backend()->GetAllPlaylists()) {
|
app_->playlist_backend()->GetAllPlaylists()) {
|
||||||
bool playlist_open = app_->playlist_manager()->IsPlaylistOpen(p.id);
|
bool playlist_open = app_->playlist_manager()->IsPlaylistOpen(p.id);
|
||||||
int item_count = playlist_open ? app_playlists.at(p.id)->rowCount() : 0;
|
int item_count = playlist_open ? app_playlists.at(p.id)->rowCount() : 0;
|
||||||
|
|
||||||
|
@ -553,7 +552,7 @@ void OutgoingDataCreator::SendLyrics(int id,
|
||||||
msg.set_type(pb::remote::LYRICS);
|
msg.set_type(pb::remote::LYRICS);
|
||||||
pb::remote::ResponseLyrics* response = msg.mutable_response_lyrics();
|
pb::remote::ResponseLyrics* response = msg.mutable_response_lyrics();
|
||||||
|
|
||||||
foreach(const CollapsibleInfoPane::Data & data, result.info_) {
|
for (const CollapsibleInfoPane::Data& data : result.info_) {
|
||||||
// If the size is zero, do not send the provider
|
// If the size is zero, do not send the provider
|
||||||
UltimateLyricsLyric* editor =
|
UltimateLyricsLyric* editor =
|
||||||
qobject_cast<UltimateLyricsLyric*>(data.content_object_);
|
qobject_cast<UltimateLyricsLyric*>(data.content_object_);
|
||||||
|
@ -707,7 +706,7 @@ void OutgoingDataCreator::SendAlbum(RemoteClient* client, const Song& song) {
|
||||||
|
|
||||||
SongList album = app_->library_backend()->GetSongsByAlbum(song.album());
|
SongList album = app_->library_backend()->GetSongsByAlbum(song.album());
|
||||||
|
|
||||||
foreach(Song s, album) {
|
for (Song s : album) {
|
||||||
DownloadItem item(s, album.indexOf(s) + 1, album.size());
|
DownloadItem item(s, album.indexOf(s) + 1, album.size());
|
||||||
download_queue_[client].append(item);
|
download_queue_[client].append(item);
|
||||||
}
|
}
|
||||||
|
@ -723,13 +722,13 @@ void OutgoingDataCreator::SendPlaylist(RemoteClient* client, int playlist_id) {
|
||||||
|
|
||||||
// Count the local songs
|
// Count the local songs
|
||||||
int count = 0;
|
int count = 0;
|
||||||
foreach(Song s, song_list) {
|
for (Song s : song_list) {
|
||||||
if (s.url().scheme() == "file") {
|
if (s.url().scheme() == "file") {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(Song s, song_list) {
|
for (Song s : song_list) {
|
||||||
// Only local files!
|
// Only local files!
|
||||||
if (s.url().scheme() == "file") {
|
if (s.url().scheme() == "file") {
|
||||||
DownloadItem item(s, song_list.indexOf(s) + 1, count);
|
DownloadItem item(s, song_list.indexOf(s) + 1, count);
|
||||||
|
|
|
@ -29,7 +29,7 @@ TinySVCMDNS::TinySVCMDNS() {
|
||||||
// Get all network interfaces
|
// Get all network interfaces
|
||||||
QList<QNetworkInterface> network_interfaces =
|
QList<QNetworkInterface> network_interfaces =
|
||||||
QNetworkInterface::allInterfaces();
|
QNetworkInterface::allInterfaces();
|
||||||
foreach(QNetworkInterface network_interface, network_interfaces) {
|
for (QNetworkInterface network_interface : network_interfaces) {
|
||||||
// Only use up and non loopback interfaces
|
// Only use up and non loopback interfaces
|
||||||
if (network_interface.flags().testFlag(network_interface.IsUp) &&
|
if (network_interface.flags().testFlag(network_interface.IsUp) &&
|
||||||
!network_interface.flags().testFlag(network_interface.IsLoopBack)) {
|
!network_interface.flags().testFlag(network_interface.IsLoopBack)) {
|
||||||
|
@ -42,8 +42,8 @@ TinySVCMDNS::TinySVCMDNS() {
|
||||||
QList<QNetworkAddressEntry> network_address_entries =
|
QList<QNetworkAddressEntry> network_address_entries =
|
||||||
network_interface.addressEntries();
|
network_interface.addressEntries();
|
||||||
|
|
||||||
foreach(QNetworkAddressEntry network_address_entry,
|
for (QNetworkAddressEntry network_address_entry :
|
||||||
network_address_entries) {
|
network_address_entries) {
|
||||||
QHostAddress host_address = network_address_entry.ip();
|
QHostAddress host_address = network_address_entry.ip();
|
||||||
if (host_address.protocol() == QAbstractSocket::IPv4Protocol) {
|
if (host_address.protocol() == QAbstractSocket::IPv4Protocol) {
|
||||||
ipv4 = qToBigEndian(host_address.toIPv4Address());
|
ipv4 = qToBigEndian(host_address.toIPv4Address());
|
||||||
|
@ -61,7 +61,9 @@ TinySVCMDNS::TinySVCMDNS() {
|
||||||
}
|
}
|
||||||
|
|
||||||
TinySVCMDNS::~TinySVCMDNS() {
|
TinySVCMDNS::~TinySVCMDNS() {
|
||||||
foreach(mdnsd * mdnsd, mdnsd_) { mdnsd_stop(mdnsd); }
|
for (mdnsd* mdnsd : mdnsd_) {
|
||||||
|
mdnsd_stop(mdnsd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TinySVCMDNS::PublishInternal(const QString& domain, const QString& type,
|
void TinySVCMDNS::PublishInternal(const QString& domain, const QString& type,
|
||||||
|
@ -70,7 +72,7 @@ void TinySVCMDNS::PublishInternal(const QString& domain, const QString& type,
|
||||||
// Some pointless text, so tinymDNS publishes the service correctly.
|
// Some pointless text, so tinymDNS publishes the service correctly.
|
||||||
const char* txt[] = {"cat=nyan", nullptr};
|
const char* txt[] = {"cat=nyan", nullptr};
|
||||||
|
|
||||||
foreach(mdnsd * mdnsd, mdnsd_) {
|
for (mdnsd* mdnsd : mdnsd_) {
|
||||||
mdnsd_register_svc(mdnsd, name.constData(),
|
mdnsd_register_svc(mdnsd, name.constData(),
|
||||||
QString(type + ".local").toUtf8().constData(), port,
|
QString(type + ".local").toUtf8().constData(), port,
|
||||||
nullptr, txt);
|
nullptr, txt);
|
||||||
|
|
|
@ -39,7 +39,7 @@ Zeroconf* Zeroconf::GetZeroconf() {
|
||||||
QByteArray Zeroconf::TruncateName(const QString& name) {
|
QByteArray Zeroconf::TruncateName(const QString& name) {
|
||||||
QTextCodec* codec = QTextCodec::codecForName("UTF-8");
|
QTextCodec* codec = QTextCodec::codecForName("UTF-8");
|
||||||
QByteArray truncated_utf8;
|
QByteArray truncated_utf8;
|
||||||
foreach(QChar c, name) {
|
for (QChar c : name) {
|
||||||
QByteArray rendered = codec->fromUnicode(&c, 1, nullptr);
|
QByteArray rendered = codec->fromUnicode(&c, 1, nullptr);
|
||||||
if (truncated_utf8.size() + rendered.size() >= 63) {
|
if (truncated_utf8.size() + rendered.size() >= 63) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -149,7 +149,9 @@ void Playlist::InsertSongItems(const SongList& songs, int pos, bool play_now,
|
||||||
bool enqueue) {
|
bool enqueue) {
|
||||||
PlaylistItemList items;
|
PlaylistItemList items;
|
||||||
|
|
||||||
foreach(const Song & song, songs) { items << PlaylistItemPtr(new T(song)); }
|
for (const Song& song : songs) {
|
||||||
|
items << PlaylistItemPtr(new T(song));
|
||||||
|
}
|
||||||
|
|
||||||
InsertItems(items, pos, play_now, enqueue);
|
InsertItems(items, pos, play_now, enqueue);
|
||||||
}
|
}
|
||||||
|
@ -473,7 +475,8 @@ int Playlist::NextVirtualIndex(int i, bool ignore_repeat_track) const {
|
||||||
// Advance i until we find any track that is in the filter, skipping
|
// Advance i until we find any track that is in the filter, skipping
|
||||||
// the selected to be skipped
|
// the selected to be skipped
|
||||||
while (i < virtual_items_.count() &&
|
while (i < virtual_items_.count() &&
|
||||||
(!FilterContainsVirtualIndex(i) || item_at(virtual_items_[i])->GetShouldSkip())) {
|
(!FilterContainsVirtualIndex(i) ||
|
||||||
|
item_at(virtual_items_[i])->GetShouldSkip())) {
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
|
@ -481,7 +484,7 @@ int Playlist::NextVirtualIndex(int i, bool ignore_repeat_track) const {
|
||||||
|
|
||||||
// We need to advance i until we get something else on the same album
|
// We need to advance i until we get something else on the same album
|
||||||
Song last_song = current_item_metadata();
|
Song last_song = current_item_metadata();
|
||||||
for (int j=i+1 ; j<virtual_items_.count(); ++j) {
|
for (int j = i + 1; j < virtual_items_.count(); ++j) {
|
||||||
if (item_at(virtual_items_[j])->GetShouldSkip()) {
|
if (item_at(virtual_items_[j])->GetShouldSkip()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -517,14 +520,15 @@ int Playlist::PreviousVirtualIndex(int i, bool ignore_repeat_track) const {
|
||||||
--i;
|
--i;
|
||||||
|
|
||||||
// Decrement i until we find any track that is in the filter
|
// Decrement i until we find any track that is in the filter
|
||||||
while (i>=0 && (!FilterContainsVirtualIndex(i) || item_at(virtual_items_[i])->GetShouldSkip()))
|
while (i >= 0 && (!FilterContainsVirtualIndex(i) ||
|
||||||
|
item_at(virtual_items_[i])->GetShouldSkip()))
|
||||||
--i;
|
--i;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to decrement i until we get something else on the same album
|
// We need to decrement i until we get something else on the same album
|
||||||
Song last_song = current_item_metadata();
|
Song last_song = current_item_metadata();
|
||||||
for (int j=i-1 ; j>=0; --j) {
|
for (int j = i - 1; j >= 0; --j) {
|
||||||
if (item_at(virtual_items_[j])->GetShouldSkip()) {
|
if (item_at(virtual_items_[j])->GetShouldSkip()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -793,8 +797,7 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action,
|
||||||
} else if (pid == own_pid) {
|
} else if (pid == own_pid) {
|
||||||
// Drag from a different playlist
|
// Drag from a different playlist
|
||||||
PlaylistItemList items;
|
PlaylistItemList items;
|
||||||
foreach(int row, source_rows)
|
for (int row : source_rows) items << source_playlist->item_at(row);
|
||||||
items << source_playlist->item_at(row);
|
|
||||||
|
|
||||||
if (items.count() > kUndoItemLimit) {
|
if (items.count() > kUndoItemLimit) {
|
||||||
// Too big to keep in the undo stack. Also clear the stack because it
|
// Too big to keep in the undo stack. Also clear the stack because it
|
||||||
|
@ -808,7 +811,7 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action,
|
||||||
|
|
||||||
// Remove the items from the source playlist if it was a move event
|
// Remove the items from the source playlist if it was a move event
|
||||||
if (action == Qt::MoveAction) {
|
if (action == Qt::MoveAction) {
|
||||||
foreach(int row, source_rows) {
|
for (int row : source_rows) {
|
||||||
source_playlist->undo_stack()->push(
|
source_playlist->undo_stack()->push(
|
||||||
new PlaylistUndoCommands::RemoveItems(source_playlist, row, 1));
|
new PlaylistUndoCommands::RemoveItems(source_playlist, row, 1));
|
||||||
}
|
}
|
||||||
|
@ -878,7 +881,7 @@ void Playlist::MoveItemsWithoutUndo(const QList<int>& source_rows, int pos) {
|
||||||
// insertion point changes
|
// insertion point changes
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int start = pos;
|
int start = pos;
|
||||||
foreach(int source_row, source_rows) {
|
for (int source_row : source_rows) {
|
||||||
moved_items << items_.takeAt(source_row - offset);
|
moved_items << items_.takeAt(source_row - offset);
|
||||||
if (pos > source_row) {
|
if (pos > source_row) {
|
||||||
start--;
|
start--;
|
||||||
|
@ -893,7 +896,7 @@ void Playlist::MoveItemsWithoutUndo(const QList<int>& source_rows, int pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update persistent indexes
|
// Update persistent indexes
|
||||||
foreach(const QModelIndex & pidx, persistentIndexList()) {
|
for (const QModelIndex& pidx : persistentIndexList()) {
|
||||||
const int dest_offset = source_rows.indexOf(pidx.row());
|
const int dest_offset = source_rows.indexOf(pidx.row());
|
||||||
if (dest_offset != -1) {
|
if (dest_offset != -1) {
|
||||||
// This index was moved
|
// This index was moved
|
||||||
|
@ -901,7 +904,7 @@ void Playlist::MoveItemsWithoutUndo(const QList<int>& source_rows, int pos) {
|
||||||
pidx, index(start + dest_offset, pidx.column(), QModelIndex()));
|
pidx, index(start + dest_offset, pidx.column(), QModelIndex()));
|
||||||
} else {
|
} else {
|
||||||
int d = 0;
|
int d = 0;
|
||||||
foreach(int source_row, source_rows) {
|
for (int source_row : source_rows) {
|
||||||
if (pidx.row() > source_row) d--;
|
if (pidx.row() > source_row) d--;
|
||||||
}
|
}
|
||||||
if (pidx.row() + d >= start) d += source_rows.count();
|
if (pidx.row() + d >= start) d += source_rows.count();
|
||||||
|
@ -921,7 +924,7 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList<int>& dest_rows) {
|
||||||
PlaylistItemList moved_items;
|
PlaylistItemList moved_items;
|
||||||
|
|
||||||
int pos = start;
|
int pos = start;
|
||||||
foreach(int dest_row, dest_rows) {
|
for (int dest_row : dest_rows) {
|
||||||
if (dest_row < pos) start--;
|
if (dest_row < pos) start--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -935,13 +938,13 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList<int>& dest_rows) {
|
||||||
|
|
||||||
// Put the items back in
|
// Put the items back in
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
foreach(int dest_row, dest_rows) {
|
for (int dest_row : dest_rows) {
|
||||||
items_.insert(dest_row, moved_items[offset]);
|
items_.insert(dest_row, moved_items[offset]);
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update persistent indexes
|
// Update persistent indexes
|
||||||
foreach(const QModelIndex & pidx, persistentIndexList()) {
|
for (const QModelIndex& pidx : persistentIndexList()) {
|
||||||
if (pidx.row() >= start && pidx.row() < start + dest_rows.count()) {
|
if (pidx.row() >= start && pidx.row() < start + dest_rows.count()) {
|
||||||
// This index was moved
|
// This index was moved
|
||||||
const int i = pidx.row() - start;
|
const int i = pidx.row() - start;
|
||||||
|
@ -951,7 +954,7 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList<int>& dest_rows) {
|
||||||
int d = 0;
|
int d = 0;
|
||||||
if (pidx.row() >= start + dest_rows.count()) d -= dest_rows.count();
|
if (pidx.row() >= start + dest_rows.count()) d -= dest_rows.count();
|
||||||
|
|
||||||
foreach(int dest_row, dest_rows) {
|
for (int dest_row : dest_rows) {
|
||||||
if (pidx.row() + d > dest_row) d++;
|
if (pidx.row() + d > dest_row) d++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -974,13 +977,15 @@ void Playlist::InsertItems(const PlaylistItemList& itemsIn, int pos,
|
||||||
// exercise vetoes
|
// exercise vetoes
|
||||||
SongList songs;
|
SongList songs;
|
||||||
|
|
||||||
foreach(PlaylistItemPtr item, items) { songs << item->Metadata(); }
|
for (PlaylistItemPtr item : items) {
|
||||||
|
songs << item->Metadata();
|
||||||
|
}
|
||||||
|
|
||||||
const int song_count = songs.length();
|
const int song_count = songs.length();
|
||||||
QSet<Song> vetoed;
|
QSet<Song> vetoed;
|
||||||
foreach(SongInsertVetoListener * listener, veto_listeners_) {
|
for (SongInsertVetoListener* listener : veto_listeners_) {
|
||||||
foreach(const Song & song,
|
for (const Song& song :
|
||||||
listener->AboutToInsertSongs(GetAllSongs(), songs)) {
|
listener->AboutToInsertSongs(GetAllSongs(), songs)) {
|
||||||
// avoid veto-ing a song multiple times
|
// avoid veto-ing a song multiple times
|
||||||
vetoed.insert(song);
|
vetoed.insert(song);
|
||||||
}
|
}
|
||||||
|
@ -1077,7 +1082,7 @@ void Playlist::InsertSongs(const SongList& songs, int pos, bool play_now,
|
||||||
void Playlist::InsertSongsOrLibraryItems(const SongList& songs, int pos,
|
void Playlist::InsertSongsOrLibraryItems(const SongList& songs, int pos,
|
||||||
bool play_now, bool enqueue) {
|
bool play_now, bool enqueue) {
|
||||||
PlaylistItemList items;
|
PlaylistItemList items;
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
if (song.id() == -1)
|
if (song.id() == -1)
|
||||||
items << PlaylistItemPtr(new SongPlaylistItem(song));
|
items << PlaylistItemPtr(new SongPlaylistItem(song));
|
||||||
else
|
else
|
||||||
|
@ -1092,7 +1097,7 @@ void Playlist::InsertInternetItems(const InternetModel* model,
|
||||||
PlaylistItemList playlist_items;
|
PlaylistItemList playlist_items;
|
||||||
QList<QUrl> song_urls;
|
QList<QUrl> song_urls;
|
||||||
|
|
||||||
foreach(const QModelIndex & item, items) {
|
for (const QModelIndex& item : items) {
|
||||||
switch (item.data(InternetModel::Role_PlayBehaviour).toInt()) {
|
switch (item.data(InternetModel::Role_PlayBehaviour).toInt()) {
|
||||||
case InternetModel::PlayBehaviour_SingleItem:
|
case InternetModel::PlayBehaviour_SingleItem:
|
||||||
playlist_items << shared_ptr<PlaylistItem>(new InternetPlaylistItem(
|
playlist_items << shared_ptr<PlaylistItem>(new InternetPlaylistItem(
|
||||||
|
@ -1119,7 +1124,7 @@ void Playlist::InsertInternetItems(InternetService* service,
|
||||||
const SongList& songs, int pos,
|
const SongList& songs, int pos,
|
||||||
bool play_now, bool enqueue) {
|
bool play_now, bool enqueue) {
|
||||||
PlaylistItemList playlist_items;
|
PlaylistItemList playlist_items;
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
playlist_items << shared_ptr<PlaylistItem>(
|
playlist_items << shared_ptr<PlaylistItem>(
|
||||||
new InternetPlaylistItem(service, song));
|
new InternetPlaylistItem(service, song));
|
||||||
}
|
}
|
||||||
|
@ -1137,7 +1142,7 @@ void Playlist::UpdateItems(const SongList& songs) {
|
||||||
// our list because we will not need to check it again.
|
// our list because we will not need to check it again.
|
||||||
// And we also update undo actions.
|
// And we also update undo actions.
|
||||||
QLinkedList<Song> songs_list;
|
QLinkedList<Song> songs_list;
|
||||||
foreach(const Song & song, songs) songs_list.append(song);
|
for (const Song& song : songs) songs_list.append(song);
|
||||||
|
|
||||||
for (int i = 0; i < items_.size(); i++) {
|
for (int i = 0; i < items_.size(); i++) {
|
||||||
// Update current items list
|
// Update current items list
|
||||||
|
@ -1188,7 +1193,7 @@ QMimeData* Playlist::mimeData(const QModelIndexList& indexes) const {
|
||||||
|
|
||||||
QList<QUrl> urls;
|
QList<QUrl> urls;
|
||||||
QList<int> rows;
|
QList<int> rows;
|
||||||
foreach(const QModelIndex & index, indexes) {
|
for (const QModelIndex& index : indexes) {
|
||||||
if (index.column() != first_column) continue;
|
if (index.column() != first_column) continue;
|
||||||
|
|
||||||
urls << items_[index.row()]->Url();
|
urls << items_[index.row()]->Url();
|
||||||
|
@ -1395,7 +1400,7 @@ void Playlist::ReOrderWithoutUndo(const PlaylistItemList& new_items) {
|
||||||
|
|
||||||
// This is a slow and nasty way to keep the persistent indices
|
// This is a slow and nasty way to keep the persistent indices
|
||||||
QMap<int, shared_ptr<PlaylistItem> > old_persistent_mappings;
|
QMap<int, shared_ptr<PlaylistItem> > old_persistent_mappings;
|
||||||
foreach(const QModelIndex & index, persistentIndexList()) {
|
for (const QModelIndex& index : persistentIndexList()) {
|
||||||
old_persistent_mappings[index.row()] = items_[index.row()];
|
old_persistent_mappings[index.row()] = items_[index.row()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1783,7 +1788,7 @@ void Playlist::RemoveItemsNotInQueue() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playlist::ReloadItems(const QList<int>& rows) {
|
void Playlist::ReloadItems(const QList<int>& rows) {
|
||||||
foreach(int row, rows) {
|
for (int row : rows) {
|
||||||
PlaylistItemPtr item = item_at(row);
|
PlaylistItemPtr item = item_at(row);
|
||||||
|
|
||||||
item->Reload();
|
item->Reload();
|
||||||
|
@ -1938,7 +1943,9 @@ QSortFilterProxyModel* Playlist::proxy() const { return proxy_; }
|
||||||
|
|
||||||
SongList Playlist::GetAllSongs() const {
|
SongList Playlist::GetAllSongs() const {
|
||||||
SongList ret;
|
SongList ret;
|
||||||
foreach(PlaylistItemPtr item, items_) { ret << item->Metadata(); }
|
for (PlaylistItemPtr item : items_) {
|
||||||
|
ret << item->Metadata();
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1946,7 +1953,7 @@ PlaylistItemList Playlist::GetAllItems() const { return items_; }
|
||||||
|
|
||||||
quint64 Playlist::GetTotalLength() const {
|
quint64 Playlist::GetTotalLength() const {
|
||||||
quint64 ret = 0;
|
quint64 ret = 0;
|
||||||
foreach(PlaylistItemPtr item, items_) {
|
for (PlaylistItemPtr item : items_) {
|
||||||
quint64 length = item->Metadata().length_nanosec();
|
quint64 length = item->Metadata().length_nanosec();
|
||||||
if (length > 0) ret += length;
|
if (length > 0) ret += length;
|
||||||
}
|
}
|
||||||
|
@ -1965,7 +1972,7 @@ void Playlist::TracksAboutToBeDequeued(const QModelIndex&, int begin, int end) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playlist::TracksDequeued() {
|
void Playlist::TracksDequeued() {
|
||||||
foreach(const QModelIndex & index, temp_dequeue_change_indexes_) {
|
for (const QModelIndex& index : temp_dequeue_change_indexes_) {
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
}
|
}
|
||||||
temp_dequeue_change_indexes_.clear();
|
temp_dequeue_change_indexes_.clear();
|
||||||
|
@ -2117,8 +2124,8 @@ void Playlist::SetColumnAlignment(const ColumnAlignmentMap& alignment) {
|
||||||
column_alignments_ = alignment;
|
column_alignments_ = alignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playlist::SkipTracks(const QModelIndexList &source_indexes) {
|
void Playlist::SkipTracks(const QModelIndexList& source_indexes) {
|
||||||
foreach (const QModelIndex& source_index, source_indexes) {
|
for (const QModelIndex& source_index : source_indexes) {
|
||||||
PlaylistItemPtr track_to_skip = item_at(source_index.row());
|
PlaylistItemPtr track_to_skip = item_at(source_index.row());
|
||||||
track_to_skip->SetShouldSkip(!((track_to_skip)->GetShouldSkip()));
|
track_to_skip->SetShouldSkip(!((track_to_skip)->GetShouldSkip()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ class Playlist : public QAbstractListModel {
|
||||||
QObject* parent = 0);
|
QObject* parent = 0);
|
||||||
~Playlist();
|
~Playlist();
|
||||||
|
|
||||||
void SkipTracks(const QModelIndexList &source_indexes);
|
void SkipTracks(const QModelIndexList& source_indexes);
|
||||||
|
|
||||||
// Always add new columns to the end of this enum - the values are persisted
|
// Always add new columns to the end of this enum - the values are persisted
|
||||||
enum Column {
|
enum Column {
|
||||||
|
|
|
@ -259,7 +259,7 @@ PlaylistItemPtr PlaylistBackend::RestoreCueData(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(const Song & from_list, song_list) {
|
for (const Song& from_list : song_list) {
|
||||||
if (from_list.url().toEncoded() == song.url().toEncoded() &&
|
if (from_list.url().toEncoded() == song.url().toEncoded() &&
|
||||||
from_list.beginning_nanosec() == song.beginning_nanosec()) {
|
from_list.beginning_nanosec() == song.beginning_nanosec()) {
|
||||||
// we found a matching section; replace the input
|
// we found a matching section; replace the input
|
||||||
|
@ -313,7 +313,7 @@ void PlaylistBackend::SavePlaylist(int playlist, const PlaylistItemList& items,
|
||||||
if (db_->CheckErrors(clear)) return;
|
if (db_->CheckErrors(clear)) return;
|
||||||
|
|
||||||
// Save the new ones
|
// Save the new ones
|
||||||
foreach(PlaylistItemPtr item, items) {
|
for (PlaylistItemPtr item : items) {
|
||||||
insert.bindValue(":playlist", playlist);
|
insert.bindValue(":playlist", playlist);
|
||||||
item->BindToQuery(&insert);
|
item->BindToQuery(&insert);
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,7 @@ class FilterTerm : public FilterTree {
|
||||||
|
|
||||||
virtual bool accept(int row, const QModelIndex& parent,
|
virtual bool accept(int row, const QModelIndex& parent,
|
||||||
const QAbstractItemModel* const model) const {
|
const QAbstractItemModel* const model) const {
|
||||||
foreach(int i, columns_) {
|
for (int i : columns_) {
|
||||||
QModelIndex idx(model->index(row, i, parent));
|
QModelIndex idx(model->index(row, i, parent));
|
||||||
if (cmp_->Matches(idx.data().toString().toLower())) return true;
|
if (cmp_->Matches(idx.data().toString().toLower())) return true;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ class OrFilter : public FilterTree {
|
||||||
virtual void add(FilterTree* child) { children_.append(child); }
|
virtual void add(FilterTree* child) { children_.append(child); }
|
||||||
virtual bool accept(int row, const QModelIndex& parent,
|
virtual bool accept(int row, const QModelIndex& parent,
|
||||||
const QAbstractItemModel* const model) const {
|
const QAbstractItemModel* const model) const {
|
||||||
foreach(FilterTree * child, children_) {
|
for (FilterTree* child : children_) {
|
||||||
if (child->accept(row, parent, model)) return true;
|
if (child->accept(row, parent, model)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -259,7 +259,7 @@ class AndFilter : public FilterTree {
|
||||||
virtual void add(FilterTree* child) { children_.append(child); }
|
virtual void add(FilterTree* child) { children_.append(child); }
|
||||||
virtual bool accept(int row, const QModelIndex& parent,
|
virtual bool accept(int row, const QModelIndex& parent,
|
||||||
const QAbstractItemModel* const model) const {
|
const QAbstractItemModel* const model) const {
|
||||||
foreach(FilterTree * child, children_) {
|
for (FilterTree* child : children_) {
|
||||||
if (!child->accept(row, parent, model)) return false;
|
if (!child->accept(row, parent, model)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -523,7 +523,7 @@ int FilterParser::parseTime(const QString& time_str) const {
|
||||||
int seconds = 0;
|
int seconds = 0;
|
||||||
int accum = 0;
|
int accum = 0;
|
||||||
int colon_count = 0;
|
int colon_count = 0;
|
||||||
foreach(const QChar & c, time_str) {
|
for (const QChar& c : time_str) {
|
||||||
if (c.isDigit()) {
|
if (c.isDigit()) {
|
||||||
accum = accum * 10 + c.digitValue();
|
accum = accum * 10 + c.digitValue();
|
||||||
} else if (c == ':') {
|
} else if (c == ':') {
|
||||||
|
|
|
@ -113,9 +113,5 @@ QColor PlaylistItem::GetCurrentForegroundColor() const {
|
||||||
bool PlaylistItem::HasCurrentForegroundColor() const {
|
bool PlaylistItem::HasCurrentForegroundColor() const {
|
||||||
return !foreground_colors_.isEmpty();
|
return !foreground_colors_.isEmpty();
|
||||||
}
|
}
|
||||||
void PlaylistItem::SetShouldSkip(bool val) {
|
void PlaylistItem::SetShouldSkip(bool val) { should_skip_ = val; }
|
||||||
should_skip_ = val;
|
bool PlaylistItem::GetShouldSkip() const { return should_skip_; }
|
||||||
}
|
|
||||||
bool PlaylistItem::GetShouldSkip() const {
|
|
||||||
return should_skip_;
|
|
||||||
}
|
|
||||||
|
|
|
@ -156,8 +156,8 @@ void PlaylistListContainer::SetApplication(Application* app) {
|
||||||
connect(player, SIGNAL(Stopped()), SLOT(ActiveStopped()));
|
connect(player, SIGNAL(Stopped()), SLOT(ActiveStopped()));
|
||||||
|
|
||||||
// Get all playlists, even ones that are hidden in the UI.
|
// Get all playlists, even ones that are hidden in the UI.
|
||||||
foreach(const PlaylistBackend::Playlist & p,
|
for (const PlaylistBackend::Playlist& p :
|
||||||
app->playlist_backend()->GetAllFavoritePlaylists()) {
|
app->playlist_backend()->GetAllFavoritePlaylists()) {
|
||||||
QStandardItem* playlist_item = model_->NewPlaylist(p.name, p.id);
|
QStandardItem* playlist_item = model_->NewPlaylist(p.name, p.id);
|
||||||
QStandardItem* parent_folder = model_->FolderByPath(p.ui_path);
|
QStandardItem* parent_folder = model_->FolderByPath(p.ui_path);
|
||||||
parent_folder->appendRow(playlist_item);
|
parent_folder->appendRow(playlist_item);
|
||||||
|
@ -293,8 +293,8 @@ void PlaylistListContainer::DeleteClicked() {
|
||||||
QSet<int> ids;
|
QSet<int> ids;
|
||||||
QList<QPersistentModelIndex> folders_to_delete;
|
QList<QPersistentModelIndex> folders_to_delete;
|
||||||
|
|
||||||
foreach(const QModelIndex & proxy_index,
|
for (const QModelIndex& proxy_index :
|
||||||
ui_->tree->selectionModel()->selectedRows(0)) {
|
ui_->tree->selectionModel()->selectedRows(0)) {
|
||||||
const QModelIndex& index = proxy_->mapToSource(proxy_index);
|
const QModelIndex& index = proxy_->mapToSource(proxy_index);
|
||||||
|
|
||||||
// Is it a playlist?
|
// Is it a playlist?
|
||||||
|
@ -325,10 +325,12 @@ void PlaylistListContainer::DeleteClicked() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unfavorite the playlists
|
// Unfavorite the playlists
|
||||||
foreach(int id, ids) { app_->playlist_manager()->Favorite(id, false); }
|
for (int id : ids) {
|
||||||
|
app_->playlist_manager()->Favorite(id, false);
|
||||||
|
}
|
||||||
|
|
||||||
// Delete the top-level folders.
|
// Delete the top-level folders.
|
||||||
foreach(const QPersistentModelIndex & index, folders_to_delete) {
|
for (const QPersistentModelIndex& index : folders_to_delete) {
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
model_->removeRow(index.row(), index.parent());
|
model_->removeRow(index.row(), index.parent());
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ QStandardItem* PlaylistListModel::FolderByPath(const QString& path) {
|
||||||
QStandardItem* parent = invisibleRootItem();
|
QStandardItem* parent = invisibleRootItem();
|
||||||
|
|
||||||
const QStringList parts = path.split('/', QString::SkipEmptyParts);
|
const QStringList parts = path.split('/', QString::SkipEmptyParts);
|
||||||
foreach(const QString & part, parts) {
|
for (const QString& part : parts) {
|
||||||
QStandardItem* matching_child = nullptr;
|
QStandardItem* matching_child = nullptr;
|
||||||
|
|
||||||
const int child_count = parent->rowCount();
|
const int child_count = parent->rowCount();
|
||||||
|
|
|
@ -55,7 +55,9 @@ PlaylistManager::PlaylistManager(Application* app, QObject* parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaylistManager::~PlaylistManager() {
|
PlaylistManager::~PlaylistManager() {
|
||||||
foreach(const Data & data, playlists_.values()) { delete data.p; }
|
for (const Data& data : playlists_.values()) {
|
||||||
|
delete data.p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistManager::Init(LibraryBackend* library_backend,
|
void PlaylistManager::Init(LibraryBackend* library_backend,
|
||||||
|
@ -75,8 +77,8 @@ void PlaylistManager::Init(LibraryBackend* library_backend,
|
||||||
connect(library_backend_, SIGNAL(SongsRatingChanged(SongList)),
|
connect(library_backend_, SIGNAL(SongsRatingChanged(SongList)),
|
||||||
SLOT(SongsDiscovered(SongList)));
|
SLOT(SongsDiscovered(SongList)));
|
||||||
|
|
||||||
foreach(const PlaylistBackend::Playlist & p,
|
for (const PlaylistBackend::Playlist& p :
|
||||||
playlist_backend->GetAllOpenPlaylists()) {
|
playlist_backend->GetAllOpenPlaylists()) {
|
||||||
AddPlaylist(p.id, p.name, p.special_type, p.ui_path, p.favorite);
|
AddPlaylist(p.id, p.name, p.special_type, p.ui_path, p.favorite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +91,9 @@ void PlaylistManager::Init(LibraryBackend* library_backend,
|
||||||
QList<Playlist*> PlaylistManager::GetAllPlaylists() const {
|
QList<Playlist*> PlaylistManager::GetAllPlaylists() const {
|
||||||
QList<Playlist*> result;
|
QList<Playlist*> result;
|
||||||
|
|
||||||
foreach(const Data & data, playlists_.values()) { result.append(data.p); }
|
for (const Data& data : playlists_.values()) {
|
||||||
|
result.append(data.p);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -276,7 +280,7 @@ bool PlaylistManager::Close(int id) {
|
||||||
if (playlists_.count() <= 1 || !playlists_.contains(id)) return false;
|
if (playlists_.count() <= 1 || !playlists_.contains(id)) return false;
|
||||||
|
|
||||||
int next_id = -1;
|
int next_id = -1;
|
||||||
foreach(int possible_next_id, playlists_.keys()) {
|
for (int possible_next_id : playlists_.keys()) {
|
||||||
if (possible_next_id != id) {
|
if (possible_next_id != id) {
|
||||||
next_id = possible_next_id;
|
next_id = possible_next_id;
|
||||||
break;
|
break;
|
||||||
|
@ -379,8 +383,7 @@ void PlaylistManager::UpdateSummaryText() {
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
|
|
||||||
// Get the length of the selected tracks
|
// Get the length of the selected tracks
|
||||||
foreach(const QItemSelectionRange & range,
|
for (const QItemSelectionRange& range : playlists_[current_id()].selection) {
|
||||||
playlists_[current_id()].selection) {
|
|
||||||
if (!range.isValid()) continue;
|
if (!range.isValid()) continue;
|
||||||
|
|
||||||
selected += range.bottom() - range.top() + 1;
|
selected += range.bottom() - range.top() + 1;
|
||||||
|
@ -416,10 +419,10 @@ void PlaylistManager::SongsDiscovered(const SongList& songs) {
|
||||||
// Some songs might've changed in the library, let's update any playlist
|
// Some songs might've changed in the library, let's update any playlist
|
||||||
// items we have that match those songs
|
// items we have that match those songs
|
||||||
|
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
foreach(const Data & data, playlists_) {
|
for (const Data& data : playlists_) {
|
||||||
PlaylistItemList items = data.p->library_items_by_id(song.id());
|
PlaylistItemList items = data.p->library_items_by_id(song.id());
|
||||||
foreach(PlaylistItemPtr item, items) {
|
for (PlaylistItemPtr item : items) {
|
||||||
if (item->Metadata().directory_id() != song.directory_id()) continue;
|
if (item->Metadata().directory_id() != song.directory_id()) continue;
|
||||||
static_cast<LibraryPlaylistItem*>(item.get())->SetMetadata(song);
|
static_cast<LibraryPlaylistItem*>(item.get())->SetMetadata(song);
|
||||||
data.p->ItemChanged(item);
|
data.p->ItemChanged(item);
|
||||||
|
@ -443,7 +446,7 @@ void PlaylistManager::PlaySmartPlaylist(GeneratorPtr generator, bool as_new,
|
||||||
|
|
||||||
// When Player has processed the new song chosen by the user...
|
// When Player has processed the new song chosen by the user...
|
||||||
void PlaylistManager::SongChangeRequestProcessed(const QUrl& url, bool valid) {
|
void PlaylistManager::SongChangeRequestProcessed(const QUrl& url, bool valid) {
|
||||||
foreach(Playlist * playlist, GetAllPlaylists()) {
|
for (Playlist* playlist : GetAllPlaylists()) {
|
||||||
if (playlist->ApplyValidityOnCurrentSong(url, valid)) {
|
if (playlist->ApplyValidityOnCurrentSong(url, valid)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -465,13 +468,13 @@ void PlaylistManager::RemoveItemsWithoutUndo(int id,
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistManager::InvalidateDeletedSongs() {
|
void PlaylistManager::InvalidateDeletedSongs() {
|
||||||
foreach(Playlist * playlist, GetAllPlaylists()) {
|
for (Playlist* playlist : GetAllPlaylists()) {
|
||||||
playlist->InvalidateDeletedSongs();
|
playlist->InvalidateDeletedSongs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistManager::RemoveDeletedSongs() {
|
void PlaylistManager::RemoveDeletedSongs() {
|
||||||
foreach(Playlist * playlist, GetAllPlaylists()) {
|
for (Playlist* playlist : GetAllPlaylists()) {
|
||||||
playlist->RemoveDeletedSongs();
|
playlist->RemoveDeletedSongs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -484,7 +487,7 @@ QString PlaylistManager::GetNameForNewPlaylist(const SongList& songs) {
|
||||||
QSet<QString> artists;
|
QSet<QString> artists;
|
||||||
QSet<QString> albums;
|
QSet<QString> albums;
|
||||||
|
|
||||||
foreach(const Song & song, songs) {
|
for (const Song& song : songs) {
|
||||||
artists << (song.artist().isEmpty() ? tr("Unknown") : song.artist());
|
artists << (song.artist().isEmpty() ? tr("Unknown") : song.artist());
|
||||||
albums << (song.album().isEmpty() ? tr("Unknown") : song.album());
|
albums << (song.album().isEmpty() ? tr("Unknown") : song.album());
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue