2 * SomePlayer - An alternate music player for Maemo 5
3 * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #include "someplayer.h"
25 #include <QSqlDatabase>
30 #define _DATABASE_NAME_ "/library.sqlite3"
32 // represents database storage
33 // it store date into some database (e.g. tracks)
35 using SomePlayer::DataObjects::Playlist;
36 using SomePlayer::DataObjects::Track;
38 namespace SomePlayer {
43 DbStorage(QString path);
45 QList<QString> getArtists();
46 QList<QString> getAlbumsForArtist(QString artist);
47 QList<Track> getTracksForAlbum(QString album, QString artist); // hm...
49 Playlist getFavorites();
50 Playlist getMostPlayed();
51 Playlist getNeverPlayed();
52 Playlist getRecentlyAdded();
54 void removeTrack(Track track);
55 void addToFavorites(Track track);
57 void updateTrackCount(Track track);
58 Track updateTrack(Track);
59 void addTrack(Track track);
63 void _create_database_structure();
64 void _prepare_queries();
66 int _check_add_artist(QString artist);
67 int _check_add_album(QString album, int artist_id);
70 QSqlQuery *_get_artists_query;
71 QSqlQuery *_get_albums_for_artist_query;
72 QSqlQuery *_get_tracks_for_album_query;
73 QSqlQuery *_get_favorites_query;
74 QSqlQuery *_get_most_played_query;
75 QSqlQuery *_get_never_played_query;
76 QSqlQuery *_get_recently_added_query;
77 QSqlQuery *_get_track_count;
78 QSqlQuery *_get_track_by_source_query;
80 QSqlQuery *_check_artist_query;
81 QSqlQuery *_check_album_query;
82 QSqlQuery *_check_track_query;
84 QSqlQuery *_insert_artist_query;
85 QSqlQuery *_insert_album_query;
86 QSqlQuery *_insert_track_query;
87 QSqlQuery *_insert_date_query;
88 QSqlQuery *_insert_favorites_query;
90 QSqlQuery *_update_track_count_query;
92 QSqlQuery *_remove_track_query;