1 /***************************************************************************
2 * Copyright (c) 2006, 2007 *
3 * Nikolaj Hald Nielsen <nhnFreespirit@gmail.com> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (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 *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #ifndef MAGNATUNEDATABASEHANDLER_H
22 #define MAGNATUNEDATABASEHANDLER_H
24 #include "collectiondb.h"
25 #include "MagnatuneMeta.h"
27 #include <QStringList>
31 * This class wraps the database operations needed by the MagnatuneBrowser
32 * Uses the singleton pattern
34 * @author Nikolaj Hald Nielsen <nhnFreespirit@gmail.com>
36 class MagnatuneDatabaseHandler
{
41 * Private constructor (singleton pattern)
42 * @return Pointer to new object
44 MagnatuneDatabaseHandler();
47 ~MagnatuneDatabaseHandler();
50 * Creates the tables needed to store Magnatune info
52 void createDatabase();
55 * Destroys Magnatune tables
57 void destroyDatabase();
60 * Inserts a new track into the Magnatune database
61 * @param track pointer to the track to insert
62 * @return the database id of the newly inserted track
64 int insertTrack( ServiceTrack
*track
);
67 * inserts a new album into the Magnatune database
68 * @param album pointer to the album to insert
69 * @return the database id of the newly inserted album
71 int insertAlbum( ServiceAlbum
*album
);
74 * inserts a new artist into the Magnatune database
75 * @param artist pointer to the artist to insert
76 * @return the database id of the newly inserted artist
78 int insertArtist( ServiceArtist
*artist
);
81 * inserts a new genre into the Magnatune database
82 * @param genre pointer to the genre to insert
83 * @return the database id of the newly inserted genre
85 int insertGenre( ServiceGenre
*genre
);
88 void insertMoods( int trackId
, QStringList moods
);
91 * Retrieves the id of a named artist
92 * @param name artist name to retrieve
93 * @return id of artist. -1 if no artist is found
95 int getArtistIdByExactName(const QString
&name
);
98 * Retrieves the id of an album based on its unique album code.
99 * @param albumcode The album code.
100 * @return The id of the album, -1 if not foud.
102 int getAlbumIdByAlbumCode( const QString
&albumcode
);
107 * Begins a database transaction. Must be followed by a later call to commit()
112 * Completes (executes) a database transaction. Must be preceded by a call to begin()