/* Copyright (C) 2005-2014 Mario Stephan This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ #ifndef COLLECTIONDB_H #define COLLECTIONDB_H #include "progressbar.h" #include #include #include #include //class sqlite; class CollectionDB : public QObject { Q_OBJECT public: CollectionDB(); ~CollectionDB(); bool isDbValid(); bool isEmpty(); void incSongCounter(const QString url); void setSongRate(const QString url, int rate); void updateDirStats(QString path, const long datetime); void removeSongsInDir(QString path); bool isDirInCollection(QString path); void removeDirFromCollection(QString path); void removePlaylist(QString name); void setFilterString(QString string); bool executeSql(const QString& statement); QList selectSql(const QString& statement); long selectSqlNumber(const QString& statement); int sqlInsertID(); QString escapeString(QString string); ulong getValueID(QString name, QString value, bool autocreate = true, bool useTempTables = false); ulong getCount(); uint getCount(QString path, QString genre, QString artist); QPair getCount(QStringList paths, QStringList genres, QStringList artists); long lastLengthSum(); uint lastMaxCount(); QList selectRandomEntry(QString rownum, QString path = "", QString genre = "", QString artist = ""); QStringList getRandomEntry(); QStringList getRandomEntry(QString path, QString genre, QString artist); void createTables(const bool temporary = false); void dropTables(const bool temporary = false); void moveTempTables(); void createStatsTable(); void dropStatsTable(); void resetSongCounter(); void purgeDirCache(); void scanModifiedDirs(bool recursively); void scan(const QStringList& folders, bool recursively); QList selectTracks(QString year, QString genre, QString artist, QString album); QList selectAlbums(QString year, QString genre, QString artist); QList selectArtists(QString year = "", QString genre = ""); QList selectYears(); QList selectGenres(); QList selectHotTracks(); QList selectLastTracks(); QList selectFavoritesTracks(); QList selectPlaylistData(); QList selectPlaylistTracks(QString name); signals: void scanDone(bool changed); private slots: private: struct CollectionDbPrivate* p; QSqlDatabase db; ProgressBar* m_progress; bool m_monitor; int m_lastInsertId; }; #endif /* COLLECTIONDB_H */