File indexing completed on 2024-05-19 04:50:23
0001 /**************************************************************************************** 0002 * Copyright (c) 2008 Nikolaj Hald Nielsen <nhn@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef OPMLDIRECTORYDATABASEHANDLER_H 0018 #define OPMLDIRECTORYDATABASEHANDLER_H 0019 0020 #include "OpmlDirectoryMeta.h" 0021 0022 0023 #include <QStringList> 0024 #include <QMap> 0025 0026 0027 /** 0028 * This class wraps the database operations needed by the OpmlDirectory 0029 * 0030 * @author Nikolaj Hald Nielsen <nhn@kde.org> 0031 */ 0032 class OpmlDirectoryDatabaseHandler { 0033 public: 0034 /** 0035 * Private constructor (singleton pattern) 0036 * @return Pointer to new object 0037 */ 0038 OpmlDirectoryDatabaseHandler(); 0039 ~OpmlDirectoryDatabaseHandler(); 0040 0041 /** 0042 * Creates the tables needed to store OpmlDirectory info 0043 */ 0044 void createDatabase(); 0045 0046 /** 0047 * Destroys OpmlDirectory tables 0048 */ 0049 void destroyDatabase(); 0050 0051 /** 0052 * Inserts a new track into the OpmlDirectory database 0053 * @param track pointer to the track to insert 0054 * @return the database id of the newly inserted track 0055 */ 0056 int insertTrack( Meta::ServiceTrackPtr track ); 0057 0058 /** 0059 * inserts a new album into the OpmlDirectory database 0060 * @param album pointer to the album to insert 0061 * @return the database id of the newly inserted album 0062 */ 0063 int insertAlbum( Meta::ServiceAlbumPtr album ); 0064 0065 /** 0066 * Begins a database transaction. Must be followed by a later call to commit() 0067 */ 0068 void begin(); 0069 0070 /** 0071 * Completes (executes) a database transaction. Must be preceded by a call to begin() 0072 */ 0073 void commit(); 0074 0075 /** 0076 * Remove all genres that are applied to too few albums in an attempt to weed out the worst mistags and 0077 * speed up queries a bit! 0078 * @param minCount cutoff value... 0079 */ 0080 void trimGenres( int minCount ); 0081 }; 0082 0083 #endif