Sayonara Player
Loading...
Searching...
No Matches
AbstractLibrary.h
1/* AbstractLibrary.h */
2
3/* Copyright (C) 2011-2024 Michael Lugmair (Lucio Carreras)
4 *
5 * This file is part of sayonara player
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef ABSTRACTLIBRARY_H
22#define ABSTRACTLIBRARY_H
23
24#include "Utils/Library/LibraryNamespaces.h"
25#include "Utils/Library/Filter.h"
26#include "Utils/Library/Sorting.h"
27#include "Utils/Pimpl.h"
28
29#include <QFile>
30
31class Genre;
32namespace Gui
33{
34 class ExtensionSet;
35}
36
38
40 public QObject
41{
42 Q_OBJECT
43 PIMPL(AbstractLibrary)
44
45 public:
46 explicit AbstractLibrary(LibraryPlaylistInteractor* playlistInteractor, QObject* parent = nullptr);
47 ~AbstractLibrary() override;
48
49 virtual void init();
50
51 [[nodiscard]] Library::Sortings sortorder() const;
52 [[nodiscard]] Library::Filter filter() const;
53 // calls fetch_by_filter and emits
54 void changeFilter(Library::Filter, bool force = false);
55
56 [[nodiscard]] const MetaDataList& tracks() const;
57 [[nodiscard]] const AlbumList& albums() const;
58 [[nodiscard]] const ArtistList& artists() const;
59 [[nodiscard]] const MetaDataList& currentTracks() const;
60
61 [[nodiscard]] const Util::Set<AlbumId>& selectedAlbums() const;
62 [[nodiscard]] const Util::Set<ArtistId>& selectedArtists() const;
63
64 // emits new tracks, very similar to psl_selected_albums_changed
65 void changeCurrentDisc(Disc track);
66
67 [[nodiscard]] bool isLoaded() const;
68
69 void setExtensions(const Gui::ExtensionSet& extensions);
70 [[nodiscard]] Gui::ExtensionSet extensions() const;
71
72 [[nodiscard]] virtual bool isReloading() const;
73 [[nodiscard]] virtual bool isEmpty() const;
74
75 signals:
76 void sigAllTracksLoaded();
77 void sigAllAlbumsLoaded();
78 void sigAllArtistsLoaded();
79
80 void sigReloadingLibrary(const QString& message, int progress);
81 void sigReloadingLibraryFinished();
82
83 void sigDeleteAnswer(QString);
84
85 void sigCurrentAlbumChanged(int row);
86 void sigCurrentTrackChanged(int row);
87
88 public slots:
89 virtual void reloadLibrary(bool clear_first, Library::ReloadQuality quality) = 0;
90
91 virtual void refetch();
92
93 virtual void refreshCurrentView();
94
95 virtual void findTrack(TrackID id);
96
97 /* selection changed */
98 virtual void selectedArtistsChanged(const IndexSet& indexes);
99 virtual void selectedAlbumsChanged(const IndexSet& indexes, bool ignore_artists = false);
100 virtual void selectedTracksChanged(const IndexSet& indexes);
101
102 // Those two functions are identical (1) calls (2)
103 virtual void prepareCurrentTracksForPlaylist(bool new_playlist);
104 virtual void prepareFetchedTracksForPlaylist(bool new_playlist);
105 void prepareTracksForPlaylist(const QStringList& file_paths, bool new_playlist);
106
107 /* append tracks after current played track in playlist */
108 virtual void playNextFetchedTracks();
109 virtual void playNextCurrentTracks();
110
111 /* append tracks after last track in playlist */
112 virtual void appendFetchedTracks();
113 virtual void appendCurrentTracks();
114
115 /* a searchfilter has been entered, nothing is emitted */
116 virtual void fetchByFilter(const Library::Filter& filter, bool force);
117 virtual void fetchTracksByPath(const QStringList& paths);
118
119 virtual void deleteTracks(const MetaDataList& tracks, Library::TrackDeletionMode mode) = 0;
120
121 virtual void deleteFetchedTracks(Library::TrackDeletionMode mode);
122 virtual void deleteCurrentTracks(Library::TrackDeletionMode mode);
123 virtual void deleteAllTracks();
124
125 virtual void importFiles(const QStringList& files);
126
127 virtual void changeTrackSortorder(Library::SortOrder sortOrder);
128 virtual void changeAlbumSortorder(Library::SortOrder sortOrder);
129 virtual void changeArtistSortorder(Library::SortOrder sortOrder);
130
131 /* Check for current selected artist if out of date and
132 * fetch new data */
133 virtual void refreshArtists() = 0;
134 virtual void refreshAlbums() = 0;
135 virtual void refreshTracks() = 0;
136
137 protected:
138 /* Emit 3 signals with shown artists, shown album, shown tracks */
139 virtual void initLibraryImpl() = 0;
140 virtual void emitAll();
141
142 virtual void getAllArtists(ArtistList& artists) const = 0;
143 virtual void getAllArtistsBySearchstring(Library::Filter filter, ArtistList& artists) const = 0;
144
145 virtual void getAllAlbums(AlbumList& albums) const = 0;
146 virtual void getAllAlbumsByArtist(IdList artistIds, AlbumList& albums, Library::Filter filter) const = 0;
147 virtual void getAllAlbumsBySearchstring(Library::Filter filter, AlbumList& albums) const = 0;
148
149 [[nodiscard]] virtual int getTrackCount() const = 0;
150 virtual void getAllTracks(MetaDataList& tracks) const = 0;
151 virtual void getAllTracks(const QStringList& paths, MetaDataList& tracks) const = 0;
152 virtual void getAllTracksByArtist(IdList artistIds, MetaDataList& tracks, Library::Filter filter) const = 0;
153 virtual void getAllTracksByAlbum(IdList albumIds, MetaDataList& tracks, Library::Filter filter) const = 0;
154 virtual void getAllTracksBySearchstring(Library::Filter filter, MetaDataList& tracks) const = 0;
155 virtual void getAllTracksByPath(const QStringList& paths, MetaDataList& tracks) const = 0;
156
157 virtual void getTrackById(TrackID trackId, MetaData& md) const = 0;
158 virtual void getAlbumById(AlbumId albumId, Album& album) const = 0;
159 virtual void getArtistById(ArtistId artistId, Artist& artist) const = 0;
160
161 void replaceAlbum(int index, const Album& album);
162 void replaceTrack(int index, const MetaData& track);
163
164 void prepareTracks();
165 void prepareAlbums();
166 void prepareArtists();
167
168 private:
169 void changeTrackSelection(const IndexSet& indexes);
170 void changeArtistSelection(const IndexSet& indexes);
171 void changeAlbumSelection(const IndexSet& indexes, bool ignore_artists = false);
172};
173
174#endif // ABSTRACTLIBRARY_H
Definition: AbstractLibrary.h:41
Definition: Album.h:88
Definition: Album.h:37
Definition: Artist.h:61
Definition: Artist.h:34
Definition: Genre.h:31
Collection of extensions. Handles extensions currently active or inactive and the extension toolbar.
Definition: ExtensionSet.h:33
Definition: LibraryPlaylistInteractor.h:32
Definition: Filter.h:34
The Sortings class.
Definition: Sorting.h:37
Definition: MetaDataList.h:34
The MetaData class.
Definition: MetaData.h:47
Definition: EngineUtils.h:33
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:37