2018-02-27 18:06:05 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* This file was part of Clementine.
|
|
|
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
2024-04-21 15:42:22 +02:00
|
|
|
* Copyright 2018-2024, Jonas Kvinge <jonas@jkvinge.net>
|
2018-02-27 18:06:05 +01:00
|
|
|
*
|
|
|
|
* Strawberry is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Strawberry is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
2018-08-09 18:39:44 +02:00
|
|
|
*
|
2018-02-27 18:06:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef COLLECTIONBACKEND_H
|
|
|
|
#define COLLECTIONBACKEND_H
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2021-09-27 19:29:12 +02:00
|
|
|
#include <optional>
|
2023-07-21 05:55:24 +02:00
|
|
|
#include <memory>
|
2021-09-27 19:29:12 +02:00
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QtGlobal>
|
2018-02-27 18:06:05 +01:00
|
|
|
#include <QObject>
|
2019-03-25 00:53:12 +01:00
|
|
|
#include <QFileInfo>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QList>
|
|
|
|
#include <QString>
|
|
|
|
#include <QStringList>
|
2018-02-27 18:06:05 +01:00
|
|
|
#include <QUrl>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QSqlDatabase>
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2023-07-21 05:55:24 +02:00
|
|
|
#include "core/shared_ptr.h"
|
2018-02-27 18:06:05 +01:00
|
|
|
#include "core/song.h"
|
2023-01-08 15:40:54 +01:00
|
|
|
#include "collectionfilteroptions.h"
|
2018-05-01 00:41:33 +02:00
|
|
|
#include "collectionquery.h"
|
2023-01-08 15:40:54 +01:00
|
|
|
#include "collectiondirectory.h"
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2019-07-24 19:16:51 +02:00
|
|
|
class QThread;
|
2021-09-19 15:41:36 +02:00
|
|
|
class TaskManager;
|
2018-02-27 18:06:05 +01:00
|
|
|
class Database;
|
2020-09-17 17:50:17 +02:00
|
|
|
class SmartPlaylistSearch;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
class CollectionBackendInterface : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-04-07 16:49:15 +02:00
|
|
|
explicit CollectionBackendInterface(QObject *parent = nullptr) : QObject(parent) {}
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
struct Album {
|
2023-05-14 11:34:55 +02:00
|
|
|
Album() : art_embedded(false), art_unset(false), filetype(Song::FileType::Unknown) {}
|
|
|
|
Album(const QString &_album_artist, const QString &_album, const bool _art_embedded, const QUrl &_art_automatic, const QUrl &_art_manual, const bool _art_unset, const QList<QUrl> &_urls, const Song::FileType _filetype, const QString &_cue_path)
|
2021-07-11 09:49:38 +02:00
|
|
|
: album_artist(_album_artist),
|
|
|
|
album(_album),
|
2023-05-14 11:34:55 +02:00
|
|
|
art_embedded(_art_embedded),
|
2021-07-11 09:49:38 +02:00
|
|
|
art_automatic(_art_automatic),
|
|
|
|
art_manual(_art_manual),
|
2023-05-14 11:34:55 +02:00
|
|
|
art_unset(_art_unset),
|
2021-07-11 09:49:38 +02:00
|
|
|
urls(_urls),
|
|
|
|
filetype(_filetype),
|
|
|
|
cue_path(_cue_path) {}
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
QString album_artist;
|
2021-02-26 21:03:51 +01:00
|
|
|
QString album;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2023-05-14 11:34:55 +02:00
|
|
|
bool art_embedded;
|
2019-07-07 21:14:24 +02:00
|
|
|
QUrl art_automatic;
|
|
|
|
QUrl art_manual;
|
2023-05-14 11:34:55 +02:00
|
|
|
bool art_unset;
|
2021-02-26 21:03:51 +01:00
|
|
|
QList<QUrl> urls;
|
|
|
|
Song::FileType filetype;
|
|
|
|
QString cue_path;
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
2022-10-13 22:39:31 +02:00
|
|
|
using AlbumList = QList<Album>;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
virtual QString songs_table() const = 0;
|
2021-04-10 03:20:25 +02:00
|
|
|
|
2022-10-19 17:11:56 +02:00
|
|
|
virtual Song::Source source() const = 0;
|
|
|
|
|
2023-07-21 05:55:24 +02:00
|
|
|
virtual SharedPtr<Database> db() const = 0;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2021-06-27 22:54:08 +02:00
|
|
|
virtual void GetAllSongsAsync(const int id = 0) = 0;
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
// Get a list of directories in the collection. Emits DirectoriesDiscovered.
|
|
|
|
virtual void LoadDirectoriesAsync() = 0;
|
|
|
|
|
|
|
|
virtual void UpdateTotalSongCountAsync() = 0;
|
|
|
|
virtual void UpdateTotalArtistCountAsync() = 0;
|
|
|
|
virtual void UpdateTotalAlbumCountAsync() = 0;
|
|
|
|
|
2020-09-10 22:05:12 +02:00
|
|
|
virtual SongList FindSongsInDirectory(const int id) = 0;
|
2021-04-25 21:16:44 +02:00
|
|
|
virtual SongList SongsWithMissingFingerprint(const int id) = 0;
|
2023-06-27 04:01:26 +02:00
|
|
|
virtual SongList SongsWithMissingLoudnessCharacteristics(const int id) = 0;
|
2023-01-08 15:40:54 +01:00
|
|
|
virtual CollectionSubdirectoryList SubdirsInDirectory(const int id) = 0;
|
|
|
|
virtual CollectionDirectoryList GetAllDirectories() = 0;
|
2020-09-10 22:05:12 +02:00
|
|
|
virtual void ChangeDirPath(const int id, const QString &old_path, const QString &new_path) = 0;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2021-10-24 16:08:17 +02:00
|
|
|
virtual SongList GetAllSongs() = 0;
|
|
|
|
|
2023-01-08 15:40:54 +01:00
|
|
|
virtual QStringList GetAllArtists(const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
|
|
|
virtual QStringList GetAllArtistsWithAlbums(const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
|
|
|
virtual SongList GetArtistSongs(const QString &effective_albumartist, const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
|
|
|
virtual SongList GetAlbumSongs(const QString &effective_albumartist, const QString &album, const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
|
|
|
virtual SongList GetSongsByAlbum(const QString &album, const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2023-01-08 15:40:54 +01:00
|
|
|
virtual SongList GetCompilationSongs(const QString &album, const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2023-01-08 15:40:54 +01:00
|
|
|
virtual AlbumList GetAllAlbums(const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
|
|
|
virtual AlbumList GetAlbumsByArtist(const QString &artist, const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
|
|
|
virtual AlbumList GetCompilationAlbums(const CollectionFilterOptions &opt = CollectionFilterOptions()) = 0;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2023-05-14 11:34:55 +02:00
|
|
|
virtual void UpdateEmbeddedAlbumArtAsync(const QString &effective_albumartist, const QString &album, const bool art_embedded) = 0;
|
|
|
|
virtual void UpdateManualAlbumArtAsync(const QString &effective_albumartist, const QString &album, const QUrl &art_manual) = 0;
|
|
|
|
virtual void UnsetAlbumArtAsync(const QString &effective_albumartist, const QString &album) = 0;
|
|
|
|
virtual void ClearAlbumArtAsync(const QString &effective_albumartist, const QString &album, const bool art_unset) = 0;
|
2021-02-26 21:03:51 +01:00
|
|
|
|
|
|
|
virtual Album GetAlbumArt(const QString &effective_albumartist, const QString &album) = 0;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-09-10 22:05:12 +02:00
|
|
|
virtual Song GetSongById(const int id) = 0;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2021-04-25 21:16:44 +02:00
|
|
|
virtual SongList GetSongsByFingerprint(const QString &fingerprint) = 0;
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
// Returns all sections of a song with the given filename. If there's just one section the resulting list will have it's size equal to 1.
|
2021-06-05 02:50:20 +02:00
|
|
|
virtual SongList GetSongsByUrl(const QUrl &url, const bool unavailable = false) = 0;
|
2018-05-01 00:41:33 +02:00
|
|
|
// Returns a section of a song with the given filename and beginning. If the section is not present in collection, returns invalid song.
|
2018-02-27 18:06:05 +01:00
|
|
|
// Using default beginning value is suitable when searching for single-section songs.
|
2019-11-25 00:28:49 +01:00
|
|
|
virtual Song GetSongByUrl(const QUrl &url, const qint64 beginning = 0) = 0;
|
2024-04-04 22:22:02 +02:00
|
|
|
virtual Song GetSongByUrlAndTrack(const QUrl &url, const int track) = 0;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2024-05-12 21:40:51 +02:00
|
|
|
virtual void AddDirectoryAsync(const QString &path) = 0;
|
|
|
|
virtual void RemoveDirectoryAsync(const CollectionDirectory &dir) = 0;
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class CollectionBackend : public CollectionBackendInterface {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2020-06-15 21:55:05 +02:00
|
|
|
Q_INVOKABLE explicit CollectionBackend(QObject *parent = nullptr);
|
2019-07-24 19:16:51 +02:00
|
|
|
|
2023-07-21 05:55:24 +02:00
|
|
|
~CollectionBackend();
|
|
|
|
|
2021-06-27 22:54:08 +02:00
|
|
|
void Init(SharedPtr<Database> db, SharedPtr<TaskManager> task_manager, const Song::Source source, const QString &songs_table, const QString &dirs_table = QString(), const QString &subdirs_table = QString());
|
|
|
|
|
2019-07-24 19:16:51 +02:00
|
|
|
void Close();
|
|
|
|
|
|
|
|
void ExitAsync();
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2021-09-09 21:45:46 +02:00
|
|
|
void ReportErrors(const CollectionQuery &query);
|
|
|
|
|
2022-10-19 17:11:56 +02:00
|
|
|
Song::Source source() const override { return source_; }
|
|
|
|
|
2023-07-21 05:55:24 +02:00
|
|
|
SharedPtr<Database> db() const override { return db_; }
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-06-15 21:55:05 +02:00
|
|
|
QString songs_table() const override { return songs_table_; }
|
2018-02-27 18:06:05 +01:00
|
|
|
QString dirs_table() const { return dirs_table_; }
|
|
|
|
QString subdirs_table() const { return subdirs_table_; }
|
|
|
|
|
2021-06-27 22:54:08 +02:00
|
|
|
void GetAllSongsAsync(const int id = 0) override;
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
// Get a list of directories in the collection. Emits DirectoriesDiscovered.
|
2020-06-15 21:55:05 +02:00
|
|
|
void LoadDirectoriesAsync() override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-06-15 21:55:05 +02:00
|
|
|
void UpdateTotalSongCountAsync() override;
|
|
|
|
void UpdateTotalArtistCountAsync() override;
|
|
|
|
void UpdateTotalAlbumCountAsync() override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-06-15 21:55:05 +02:00
|
|
|
SongList FindSongsInDirectory(const int id) override;
|
2021-04-25 21:16:44 +02:00
|
|
|
SongList SongsWithMissingFingerprint(const int id) override;
|
2023-06-27 04:01:26 +02:00
|
|
|
SongList SongsWithMissingLoudnessCharacteristics(const int id) override;
|
2023-01-08 15:40:54 +01:00
|
|
|
CollectionSubdirectoryList SubdirsInDirectory(const int id) override;
|
|
|
|
CollectionDirectoryList GetAllDirectories() override;
|
2020-06-15 21:55:05 +02:00
|
|
|
void ChangeDirPath(const int id, const QString &old_path, const QString &new_path) override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2021-10-24 16:08:17 +02:00
|
|
|
SongList GetAllSongs() override;
|
|
|
|
|
2023-01-08 15:40:54 +01:00
|
|
|
QStringList GetAll(const QString &column, const CollectionFilterOptions &filter_options = CollectionFilterOptions());
|
|
|
|
QStringList GetAllArtists(const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
|
|
|
QStringList GetAllArtistsWithAlbums(const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
|
|
|
SongList GetArtistSongs(const QString &effective_albumartist, const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
|
|
|
SongList GetAlbumSongs(const QString &effective_albumartist, const QString &album, const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
|
|
|
SongList GetSongsByAlbum(const QString &album, const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2023-01-08 15:40:54 +01:00
|
|
|
SongList GetCompilationSongs(const QString &album, const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2023-01-08 15:40:54 +01:00
|
|
|
AlbumList GetAllAlbums(const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
|
|
|
AlbumList GetCompilationAlbums(const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
|
|
|
AlbumList GetAlbumsByArtist(const QString &artist, const CollectionFilterOptions &opt = CollectionFilterOptions()) override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2023-05-14 11:34:55 +02:00
|
|
|
void UpdateEmbeddedAlbumArtAsync(const QString &effective_albumartist, const QString &album, const bool art_embedded) override;
|
|
|
|
void UpdateManualAlbumArtAsync(const QString &effective_albumartist, const QString &album, const QUrl &art_manual) override;
|
|
|
|
void UnsetAlbumArtAsync(const QString &effective_albumartist, const QString &album) override;
|
|
|
|
void ClearAlbumArtAsync(const QString &effective_albumartist, const QString &album, const bool art_unset) override;
|
2021-02-26 21:03:51 +01:00
|
|
|
|
2021-06-22 13:56:27 +02:00
|
|
|
Album GetAlbumArt(const QString &effective_albumartist, const QString &album) override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-06-15 21:55:05 +02:00
|
|
|
Song GetSongById(const int id) override;
|
2018-02-27 18:06:05 +01:00
|
|
|
SongList GetSongsById(const QList<int> &ids);
|
|
|
|
SongList GetSongsById(const QStringList &ids);
|
|
|
|
SongList GetSongsByForeignId(const QStringList &ids, const QString &table, const QString &column);
|
|
|
|
|
2021-06-05 02:50:20 +02:00
|
|
|
SongList GetSongsByUrl(const QUrl &url, const bool unavailable = false) override;
|
2020-06-15 21:55:05 +02:00
|
|
|
Song GetSongByUrl(const QUrl &url, qint64 beginning = 0) override;
|
2024-04-04 22:22:02 +02:00
|
|
|
Song GetSongByUrlAndTrack(const QUrl &url, const int track) override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2024-05-12 21:40:51 +02:00
|
|
|
void AddDirectoryAsync(const QString &path) override;
|
|
|
|
void RemoveDirectoryAsync(const CollectionDirectory &dir) override;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2021-09-09 21:45:46 +02:00
|
|
|
bool ExecCollectionQuery(CollectionQuery *query, SongList &songs);
|
2021-09-19 15:41:36 +02:00
|
|
|
bool ExecCollectionQuery(CollectionQuery *query, SongMap &songs);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-04-23 21:08:28 +02:00
|
|
|
void IncrementPlayCountAsync(const int id);
|
|
|
|
void IncrementSkipCountAsync(const int id, const float progress);
|
2023-03-18 20:03:07 +01:00
|
|
|
void ResetPlayStatisticsAsync(const int id, const bool save_tags = false);
|
|
|
|
void ResetPlayStatisticsAsync(const QList<int> &id_list, const bool save_tags = false);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2022-01-28 21:25:44 +01:00
|
|
|
void DeleteAllAsync();
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-04-13 03:39:51 +02:00
|
|
|
Song GetSongBySongId(const QString &song_id);
|
2019-06-07 23:02:43 +02:00
|
|
|
SongList GetSongsBySongId(const QStringList &song_ids);
|
|
|
|
|
2021-04-25 21:16:44 +02:00
|
|
|
SongList GetSongsByFingerprint(const QString &fingerprint) override;
|
|
|
|
|
2021-06-28 00:16:22 +02:00
|
|
|
SongList SmartPlaylistsGetAllSongs();
|
|
|
|
SongList SmartPlaylistsFindSongs(const SmartPlaylistSearch &search);
|
2020-09-17 17:50:17 +02:00
|
|
|
|
2020-05-12 18:45:24 +02:00
|
|
|
void AddOrUpdateSongsAsync(const SongList &songs);
|
2021-09-19 15:41:36 +02:00
|
|
|
void UpdateSongsBySongIDAsync(const SongMap &new_songs);
|
2020-05-12 18:45:24 +02:00
|
|
|
|
2021-10-30 18:53:14 +02:00
|
|
|
void UpdateSongRatingAsync(const int id, const float rating, const bool save_tags = false);
|
|
|
|
void UpdateSongsRatingAsync(const QList<int> &ids, const float rating, const bool save_tags = false);
|
2020-09-17 17:50:17 +02:00
|
|
|
|
2024-08-12 01:06:15 +02:00
|
|
|
public Q_SLOTS:
|
2019-07-24 19:16:51 +02:00
|
|
|
void Exit();
|
2021-06-27 22:54:08 +02:00
|
|
|
void GetAllSongs(const int id);
|
2018-02-27 18:06:05 +01:00
|
|
|
void LoadDirectories();
|
|
|
|
void UpdateTotalSongCount();
|
|
|
|
void UpdateTotalArtistCount();
|
|
|
|
void UpdateTotalAlbumCount();
|
2024-05-12 21:40:51 +02:00
|
|
|
void AddDirectory(const QString &path);
|
|
|
|
void RemoveDirectory(const CollectionDirectory &dir);
|
2018-02-27 18:06:05 +01:00
|
|
|
void AddOrUpdateSongs(const SongList &songs);
|
2021-09-19 15:41:36 +02:00
|
|
|
void UpdateSongsBySongID(const SongMap &new_songs);
|
2018-02-27 18:06:05 +01:00
|
|
|
void UpdateMTimesOnly(const SongList &songs);
|
|
|
|
void DeleteSongs(const SongList &songs);
|
2020-09-10 22:05:12 +02:00
|
|
|
void MarkSongsUnavailable(const SongList &songs, const bool unavailable = true);
|
2023-01-08 15:40:54 +01:00
|
|
|
void AddOrUpdateSubdirs(const CollectionSubdirectoryList &subdirs);
|
2021-01-26 16:48:04 +01:00
|
|
|
void CompilationsNeedUpdating();
|
2023-05-14 11:34:55 +02:00
|
|
|
void UpdateEmbeddedAlbumArt(const QString &effective_albumartist, const QString &album, const bool art_embedded);
|
|
|
|
void UpdateManualAlbumArt(const QString &effective_albumartist, const QString &album, const QUrl &art_manual);
|
|
|
|
void UnsetAlbumArt(const QString &effective_albumartist, const QString &album);
|
|
|
|
void ClearAlbumArt(const QString &effective_albumartist, const QString &album, const bool art_unset);
|
2024-04-23 16:51:42 +02:00
|
|
|
void ForceCompilation(const QString &album, const QStringList &artists, const bool on);
|
2020-04-23 21:08:28 +02:00
|
|
|
void IncrementPlayCount(const int id);
|
|
|
|
void IncrementSkipCount(const int id, const float progress);
|
2023-03-18 20:03:07 +01:00
|
|
|
void ResetPlayStatistics(const int id, const bool save_tags = false);
|
|
|
|
void ResetPlayStatistics(const QList<int> &id_list, const bool save_tags = false);
|
|
|
|
bool ResetPlayStatistics(const QStringList &id_str_list);
|
2022-01-28 21:25:44 +01:00
|
|
|
void DeleteAll();
|
2021-09-27 19:29:12 +02:00
|
|
|
void SongPathChanged(const Song &song, const QFileInfo &new_file, const std::optional<int> new_collection_directory_id);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-08-30 18:09:13 +02:00
|
|
|
SongList GetSongsBy(const QString &artist, const QString &album, const QString &title);
|
2020-11-22 19:01:53 +01:00
|
|
|
void UpdateLastPlayed(const QString &artist, const QString &album, const QString &title, const qint64 lastplayed);
|
2023-02-10 22:51:48 +01:00
|
|
|
void UpdatePlayCount(const QString &artist, const QString &title, const int playcount, const bool save_tags = false);
|
2020-08-30 18:09:13 +02:00
|
|
|
|
2021-10-30 18:53:14 +02:00
|
|
|
void UpdateSongRating(const int id, const float rating, const bool save_tags = false);
|
|
|
|
void UpdateSongsRating(const QList<int> &id_list, const float rating, const bool save_tags = false);
|
2020-09-17 17:50:17 +02:00
|
|
|
|
2021-04-25 21:16:44 +02:00
|
|
|
void UpdateLastSeen(const int directory_id, const int expire_unavailable_songs_days);
|
|
|
|
void ExpireSongs(const int directory_id, const int expire_unavailable_songs_days);
|
|
|
|
|
2024-08-11 23:23:12 +02:00
|
|
|
Q_SIGNALS:
|
2024-05-12 21:40:51 +02:00
|
|
|
void DirectoryAdded(const CollectionDirectory &dir, const CollectionSubdirectoryList &subdir);
|
2023-04-09 20:23:42 +02:00
|
|
|
void DirectoryDeleted(const CollectionDirectory &dir);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2021-06-27 22:54:08 +02:00
|
|
|
void GotSongs(const SongList &songs, const int id);
|
|
|
|
void SongsAdded(const SongList &songs);
|
2023-04-09 20:23:42 +02:00
|
|
|
void SongsDeleted(const SongList &songs);
|
2021-06-27 22:54:08 +02:00
|
|
|
void SongsChanged(const SongList &songs);
|
2023-04-09 20:23:42 +02:00
|
|
|
void SongsStatisticsChanged(const SongList &songs, const bool save_tags = false);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
void DatabaseReset();
|
|
|
|
|
2023-04-09 20:23:42 +02:00
|
|
|
void TotalSongCountUpdated(const int count);
|
|
|
|
void TotalArtistCountUpdated(const int count);
|
|
|
|
void TotalAlbumCountUpdated(const int count);
|
|
|
|
void SongsRatingChanged(const SongList &songs, const bool save_tags);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2019-07-24 19:16:51 +02:00
|
|
|
void ExitFinished();
|
|
|
|
|
2023-04-09 20:23:42 +02:00
|
|
|
void Error(const QString &error);
|
2021-09-09 21:45:46 +02:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
private:
|
|
|
|
struct CompilationInfo {
|
2019-11-03 23:23:04 +01:00
|
|
|
CompilationInfo() : has_compilation_detected(0), has_not_compilation_detected(0) {}
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2019-11-03 23:23:04 +01:00
|
|
|
QList<QUrl> urls;
|
2019-11-13 21:27:04 +01:00
|
|
|
QStringList artists;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2019-11-03 23:23:04 +01:00
|
|
|
int has_compilation_detected;
|
|
|
|
int has_not_compilation_detected;
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
|
|
|
|
2021-06-27 22:54:08 +02:00
|
|
|
bool UpdateCompilations(const QSqlDatabase &db, SongList &changed_songs, const QUrl &url, const bool compilation_detected);
|
2023-01-08 15:40:54 +01:00
|
|
|
AlbumList GetAlbums(const QString &artist, const QString &album_artist, const bool compilation_required = false, const CollectionFilterOptions &opt = CollectionFilterOptions());
|
|
|
|
AlbumList GetAlbums(const QString &artist, const bool compilation_required, const CollectionFilterOptions &opt = CollectionFilterOptions());
|
|
|
|
CollectionSubdirectoryList SubdirsInDirectory(const int id, QSqlDatabase &db);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-04-23 21:08:28 +02:00
|
|
|
Song GetSongById(const int id, QSqlDatabase &db);
|
2018-02-27 18:06:05 +01:00
|
|
|
SongList GetSongsById(const QStringList &ids, QSqlDatabase &db);
|
|
|
|
|
2020-04-13 03:39:51 +02:00
|
|
|
Song GetSongBySongId(const QString &song_id, QSqlDatabase &db);
|
2019-06-08 12:03:48 +02:00
|
|
|
SongList GetSongsBySongId(const QStringList &song_ids, QSqlDatabase &db);
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
private:
|
2023-07-21 05:55:24 +02:00
|
|
|
SharedPtr<Database> db_;
|
|
|
|
SharedPtr<TaskManager> task_manager_;
|
2019-07-02 00:48:40 +02:00
|
|
|
Song::Source source_;
|
2018-02-27 18:06:05 +01:00
|
|
|
QString songs_table_;
|
|
|
|
QString dirs_table_;
|
|
|
|
QString subdirs_table_;
|
2019-07-24 19:16:51 +02:00
|
|
|
QThread *original_thread_;
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // COLLECTIONBACKEND_H
|
|
|
|
|