Sayonara Player
Tracks.h
1 /* DatabaseTracks.h */
2 
3 /* Copyright (C) 2011-2019 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/SearchableModule.h"
25 #include "Utils/Pimpl.h"
26 
27 namespace Library
28 {
29  class Filter;
30 }
31 
32 class Genre;
33 
34 namespace DB
35 {
36  class Tracks :
37  private SearchableModule
38  {
39  PIMPL(Tracks)
40 
41  public:
42  Tracks(const QString& connection_name, DbId db_id, LibraryId _library_id);
43  ~Tracks();
44 
45  virtual bool db_fetch_tracks(Query& q, MetaDataList& result);
46 
47  virtual bool getAllTracksByAlbum(IdList albums, MetaDataList& result);
48  virtual bool getAllTracksByAlbum(IdList albums, MetaDataList& result, const ::Library::Filter& filter, int discnumber=-1);
49 
50  virtual bool getAllTracksByArtist(IdList artists, MetaDataList& result);
51  virtual bool getAllTracksByArtist(IdList artists, MetaDataList& result, const ::Library::Filter& filter);
52 
53  virtual bool getAllTracksBySearchString(const ::Library::Filter& filter, MetaDataList& result);
54 
55  virtual bool insertTrackIntoDatabase (const MetaData& data, ArtistId artist_id, AlbumId album_id);
56  virtual bool insertTrackIntoDatabase (const MetaData& data, ArtistId artist_id, AlbumId album_id, ArtistId album_artist_id);
57  virtual bool updateTrack(const MetaData& data);
58  virtual bool updateTracks(const MetaDataList& lst);
59 
60  virtual bool getAllTracks(MetaDataList& returndata);
61 
62  virtual MetaData getTrackById(int id);
63  virtual bool getTracksbyIds(const QList<TrackID>& ids, MetaDataList& v_md);
64  virtual MetaData getTrackByPath(const QString& path);
65  virtual bool getMultipleTracksByPath(const QStringList& paths, MetaDataList& v_md);
66 
67  virtual bool deleteTrack(TrackID id);
68  virtual bool deleteTracks(const MetaDataList&);
69  virtual bool deleteTracks(const IdList& ids);
70 
71 
72  // some tracks may be inserted two times
73  // this function deletes BOTH copies but returns those tracks
74  // which were found twice. Those tracks should be inserted by the store_metadata()
75  // function of LibraryDatabase
76  virtual bool deleteInvalidTracks(const QString& library_path, MetaDataList& double_metadata);
77 
78  virtual QString fetch_query_tracks() const;
79 
80  virtual Util::Set<Genre> getAllGenres();
81  virtual void updateTrackCissearch();
82 
83  void deleteAllTracks(bool also_views);
84  void drop_track_view();
85  void drop_search_view();
86 
87  protected:
88  virtual QString artistid_field() const=0;
89  virtual QString artistname_field() const=0;
90 
91  private:
92  void create_track_view(const QString& select_statement);
93  void create_track_search_view(const QString& select_statement);
94  };
95 }
96 
97 #endif // DATABASETRACKS_H
Definition: Query.h:35
The MetaData class.
Definition: MetaData.h:44
Definition: Tracks.h:36
The MetaDataList class.
Definition: MetaDataList.h:37
Definition: SearchableModule.h:32
A set structure. Inherited from std::set with some useful methods. For integer and String this set is...
Definition: Set.h:35
Definition: Albums.h:30
Definition: Genre.h:30
An interface class needed when implementing a library plugin.
Definition: CachingThread.h:29
Definition: org_mpris_media_player2_adaptor.h:20