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