Sayonara Player
Loading...
Searching...
No Matches
Tracks.h
1/* DatabaseTracks.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 DATABASETRACKS_H
22#define DATABASETRACKS_H
23
24#include "Database/Utils.h"
25#include "Utils/typedefs.h"
26#include <QMap>
27#include <functional>
28
29namespace Library
30{
31 class Filter;
32}
33
34class QSqlQuery;
35class Genre;
36class MetaDataList;
37
38namespace DB
39{
40 class Module;
41 class Tracks
42 {
43 public:
44 Tracks();
45 virtual ~Tracks();
46
47 void initViews();
48
49 virtual bool dbFetchTracks(QSqlQuery& q, MetaDataList& result) const;
50
51 virtual int getNumTracks() const;
52 virtual bool getAllTracks(MetaDataList& result) const;
53
54 virtual bool getAllTracksByAlbum(const IdList& albumsIds, MetaDataList& result) const;
55 virtual bool getAllTracksByAlbum(const IdList& track, MetaDataList& result,
56 const ::Library::Filter& filter, int discnumber) const;
57 virtual bool getAllTracksByArtist(const IdList& artistIds, MetaDataList& result) const;
58 virtual bool getAllTracksByArtist(const IdList& artistIds, MetaDataList& result,
59 const ::Library::Filter& filter) const;
60 virtual bool getAllTracksBySearchString(const ::Library::Filter& filter, MetaDataList& result) const;
61 virtual bool getAllTracksByPaths(const QStringList& paths, MetaDataList& tracks) const;
62
63 virtual MetaData getTrackById(TrackID id) const;
64 virtual MetaData getTrackByPath(const QString& path) const;
65 virtual bool getMultipleTracksByPath(const QStringList& paths, MetaDataList& tracks) const;
66
67 virtual bool
68 insertTrackIntoDatabase(const MetaData& track, ArtistId artistId, AlbumId albumId, ArtistId albumArtistId);
69 virtual bool updateTrack(const MetaData& track);
70
71 virtual bool renameFilepaths(const QMap<QString, QString>& paths, LibraryId libraryId);
72 virtual bool renameFilepath(const QString& oldPath, const QString& newPath, LibraryId libraryId);
73
74 virtual bool deleteTrack(TrackID id);
75 virtual bool deleteTracks(const IdList& ids);
76
77 // some tracks may be inserted two times
78 // this function deletes BOTH copies but returns those tracks
79 // which were found twice. Those tracks should be inserted by the store_metadata()
80 // function of LibraryDatabase
81 virtual bool deleteInvalidTracks(const QString& libraryPath, MetaDataList& doubleMetadata);
82
83 virtual QString fetchQueryTracks(const QString& where) const;
84
85 virtual Util::Set<Genre> getAllGenres() const;
86
87 void deleteAllTracks(bool alsoViews);
88
89 protected:
90 [[nodiscard]] virtual ArtistIdInfo artistIdInfo() const = 0;
91 [[nodiscard]] virtual QString trackView() const = 0;
92 [[nodiscard]] virtual QString trackSearchView() const = 0;
93 [[nodiscard]] virtual LibraryId libraryId() const = 0;
94
95 virtual Module* module() = 0;
96 virtual const Module* module() const = 0;
97
98 virtual void updateTrackCissearch();
99
100 private:
101 MetaData getSingleTrack(const QString& queryText, const std::pair<QString, QVariant>& binding,
102 const QString& errorMessage) const;
103 [[nodiscard]] MetaDataList getAllTracksByIdList(const IdList& ids, const ::Library::Filter& filter,
104 std::function<Id(MetaData)>&& whichId) const;
105
106 MetaDataList getAllTracks(const ::Library::Filter& filter) const;
107 };
108}
109
110#endif // DATABASETRACKS_H
Definition Module.h:32
Definition Tracks.h:42
Definition Genre.h:31
Definition MetaDataList.h:34
Definition MetaData.h:43
Definition EngineUtils.h:33
Definition org_mpris_media_player2_adaptor.h:21
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition Set.h:37
Definition Utils.h:48