Debian Codegraph @

src/collectiondb.h

raw symbols SCIP
1 /*
2 Copyright (C) 2005-2014 Mario Stephan <[email protected]>
3
4 This library is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published
6 by the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef COLLECTIONDB_H
19 #define COLLECTIONDB_H
20
21 #include "progressbar.h"
22 #include <QtSql>
23 #include <qdir.h>
24 #include <qobject.h>
25 #include <qstringlist.h>
26
27 //class sqlite;
28
29 class CollectionDB : public QObject {
30 Q_OBJECT
31
32 public:
33 CollectionDB();
34 ~CollectionDB();
35
36 bool isDbValid();
37 bool isEmpty();
38
39 void incSongCounter(const QString url);
40 void setSongRate(const QString url, int rate);
41 void updateDirStats(QString path, const long datetime);
42 void removeSongsInDir(QString path);
43 bool isDirInCollection(QString path);
44 void removeDirFromCollection(QString path);
45 void removePlaylist(QString name);
46 void setFilterString(QString string);
47
48 bool executeSql(const QString& statement);
49 QList<QStringList> selectSql(const QString& statement);
50 long selectSqlNumber(const QString& statement);
51
52 int sqlInsertID();
53 QString escapeString(QString string);
54
55 ulong getValueID(QString name, QString value, bool autocreate = true, bool useTempTables = false);
56 ulong getCount();
57 uint getCount(QString path, QString genre, QString artist);
58 QPair<int, int> getCount(QStringList paths, QStringList genres, QStringList artists);
59 long lastLengthSum();
60 uint lastMaxCount();
61
62 QList<QStringList> selectRandomEntry(QString rownum, QString path = "", QString genre = "", QString artist = "");
63 QStringList getRandomEntry();
64 QStringList getRandomEntry(QString path, QString genre, QString artist);
65
66 void createTables(const bool temporary = false);
67 void dropTables(const bool temporary = false);
68 void moveTempTables();
69 void createStatsTable();
70 void dropStatsTable();
71 void resetSongCounter();
72
73 void purgeDirCache();
74 void scanModifiedDirs(bool recursively);
75 void scan(const QStringList& folders, bool recursively);
76
77 QList<QStringList> selectTracks(QString year, QString genre, QString artist, QString album);
78 QList<QStringList> selectAlbums(QString year, QString genre, QString artist);
79 QList<QStringList> selectArtists(QString year = "", QString genre = "");
80 QList<QStringList> selectYears();
81 QList<QStringList> selectGenres();
82 QList<QStringList> selectHotTracks();
83 QList<QStringList> selectLastTracks();
84 QList<QStringList> selectFavoritesTracks();
85 QList<QStringList> selectPlaylistData();
86 QList<QStringList> selectPlaylistTracks(QString name);
87
88 signals:
89 void scanDone(bool changed);
90
91 private slots:
92
93 private:
94 struct CollectionDbPrivate* p;
95 QSqlDatabase db;
96 ProgressBar* m_progress;
97 bool m_monitor;
98 int m_lastInsertId;
99 };
100
101 #endif /* COLLECTIONDB_H */