Sayonara Player
Tracks.h
1 /* DatabaseTracks.h */
2 
3 /* Copyright (C) 2011-2020 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 "Query.h"
25 #include "Utils/Pimpl.h"
26 
27 #include <QMap>
28 
29 namespace Library
30 {
31  class Filter;
32 }
33 
34 class Genre;
35 
36 namespace DB
37 {
38  class Tracks
39  {
40  public:
41  Tracks();
42  virtual ~Tracks();
43 
44  void initViews();
45 
46  virtual bool dbFetchTracks(Query& q, MetaDataList& result) const;
47 
48  virtual int getNumTracks() const;
49  virtual bool getAllTracks(MetaDataList& result) const;
50 
51  virtual bool getAllTracksByAlbum(const IdList& albumsIds, MetaDataList& result) const;
52  virtual bool getAllTracksByAlbum(const IdList& albumIds, MetaDataList& result,
53  const ::Library::Filter& filter, int discnumber) const;
54  virtual bool getAllTracksByAlbumArtist(const IdList& artistIds, MetaDataList& result) const;
55  virtual bool getAllTracksByAlbumArtist(const IdList& artistIds, MetaDataList& result,
56  const ::Library::Filter& filter) 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& v_md) const;
62 
63  virtual MetaData getTrackById(TrackID id) const;
64  virtual bool getTracksByIds(const QList<TrackID> &ids, MetaDataList &v_md) const;
65  virtual MetaData getTrackByPath(const QString& path) const;
66  virtual bool getMultipleTracksByPath(const QStringList& paths, MetaDataList& v_md) const;
67 
68  virtual bool insertTrackIntoDatabase(const MetaData& data, ArtistId artistId, AlbumId albumId);
69  virtual bool insertTrackIntoDatabase(const MetaData& data, ArtistId artistId, AlbumId albumId, ArtistId album_artistId);
70  virtual bool updateTrack(const MetaData& data);
71  virtual bool updateTracks(const MetaDataList& lst);
72 
73  virtual bool renameFilepaths(const QMap<QString, QString>& paths, LibraryId libraryId);
74  virtual bool renameFilepath(const QString& old_path, const QString& new_path, LibraryId libraryId);
75 
76  virtual bool deleteTrack(TrackID id);
77  virtual bool deleteTracks(const MetaDataList&);
78  virtual bool deleteTracks(const IdList& ids);
79 
80 
81  // some tracks may be inserted two times
82  // this function deletes BOTH copies but returns those tracks
83  // which were found twice. Those tracks should be inserted by the store_metadata()
84  // function of LibraryDatabase
85  virtual bool deleteInvalidTracks(const QString& library_path, MetaDataList& double_metadata);
86 
87  virtual QString fetchQueryTracks() const;
88 
89  virtual Util::Set<Genre> getAllGenres() const;
90 
91  void deleteAllTracks(bool also_views);
92 
93  protected:
94  virtual QString artistIdField() const=0;
95  virtual QString artistNameField() const=0;
96  virtual QString trackView() const=0;
97  virtual QString trackSearchView() const=0;
98  virtual LibraryId libraryId() const=0;
99 
100  virtual Module* module()=0;
101  virtual const Module* module() const=0;
102 
103  virtual void updateTrackCissearch();
104  };
105 }
106 
107 #endif // DATABASETRACKS_H
DB::Module
Definition: Module.h:33
MetaDataList
The MetaDataList class.
Definition: MetaDataList.h:37
Util::Set
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:37
Genre
Definition: Genre.h:31
QList
Definition: EngineUtils.h:33
QMap
Definition: org_mpris_media_player2_adaptor.h:21
Library
An interface class needed when implementing a library plugin.
Definition: LocalLibraryWatcher.h:31
DB::Query
Definition: Query.h:37
DB::Tracks
Definition: Tracks.h:39
MetaData
The MetaData class.
Definition: MetaData.h:47