mediadb.h
1 #ifndef MEDIADB_H
2 #define MEDIADB_H
3 
4 #include <QObject>
5 #include <QtSql>
6 #include <QSqlRecord>
7 #include <QString>
8 #include <QStringList>
9 #include <QVariant>
10 
58 class MediaDB : public QObject
59 {
60  Q_OBJECT
61 public:
67  explicit MediaDB(QObject *parent = 0);
78  int addLocation(QString name, QString v_unique_id, QString v_path, QString relative_path);
91  int addScannedFolder(int location_id, QString name, QString relative_path, qint64 last_modified, QString thumbnail);
105  int addMediaFiles(QVariantList filenames, QVariantList folder_id, QVariantList media_types, QVariantList artist, QVariantList title, QVariantList album, QVariantList genre);
121  QVariantMap getLocationInfo(int location_id);
130  int updateFolderInfo(int folder_id, bool hasAudio, bool hasVideo, QString thumbnail);
141  int setLocationAvailability(int location_id, bool isAvailable);
148  QVariantList getLocations(bool onlyAvailable);
155  QVariantList getListFromQuery(QSqlQuery q);
162  QVariantMap getListWithFirstLetterFromQuery(QSqlQuery q);
169  QVariantMap getMediaFolders(int mediaType);
177  QVariantMap getFolderContent(int folder_id, int mediaType);
184  QVariantMap getAlbumContent(QString album);
190  QVariantMap getPlaylists();
196  QVariantMap getAudioFiles();
202  enum ListType {albums,artists,genres,playlists,songs};
203 
210  QVariantMap getList(ListType listType);
218  QVariantMap getListContent(ListType listType, QString key);
219 
220  static const int AUDIO = 1;
221  static const int VIDEO = 2;
222  static const int PLAYLIST = 3;
223 private:
224  QSqlDatabase db;
225 signals:
226 
227 public slots:
228 };
229 
230 #endif // MEDIADB_H
QVariantMap getAlbumContent(QString album)
Definition: mediadb.cpp:264
int addScannedFolder(int location_id, QString name, QString relative_path, qint64 last_modified, QString thumbnail)
Checks if a folder is in the database if not then adds it to the DB.
Definition: mediadb.cpp:95
QVariantList getListFromQuery(QSqlQuery q)
Definition: mediadb.cpp:347
MediaDB(QObject *parent=0)
The constructor opens the SQLITE DB file and checks if all the tables are created, if not it creates them.
Definition: mediadb.cpp:3
static const int AUDIO
Definition: mediadb.h:220
static const int VIDEO
Definition: mediadb.h:221
int addMediaFiles(QVariantList filenames, QVariantList folder_id, QVariantList media_types, QVariantList artist, QVariantList title, QVariantList album, QVariantList genre)
Definition: mediadb.cpp:147
int setLocationAvailability(int location_id, bool isAvailable)
Set the availability of location_id to isAvailable.
Definition: mediadb.cpp:383
QVariantMap getLocationInfo(int location_id)
Fetches the info for the location that matches location_id.
Definition: mediadb.cpp:167
static const int PLAYLIST
Definition: mediadb.h:222
int updateFolderInfo(int folder_id, bool hasAudio, bool hasVideo, QString thumbnail)
Updates the has_audio, has_video and thumbnail fields for the folder matched by folder_id.
Definition: mediadb.cpp:129
ListType
Contains all the possible list types that we can fetch from the database (albums,artists,genres)
Definition: mediadb.h:202
QVariantMap getListContent(ListType listType, QString key)
Definition: mediadb.cpp:425
QVariantMap getMediaFolders(int mediaType)
Definition: mediadb.cpp:202
int addLocation(QString name, QString v_unique_id, QString v_path, QString relative_path)
Checks if a location already exits in the database and if not then adds the location to the database...
Definition: mediadb.cpp:62
QVariantMap getPlaylists()
Definition: mediadb.cpp:289
QVariantMap getList(ListType listType)
Definition: mediadb.cpp:402
Database abstraction class, used to fetch and insert/update data to/from the media library&#39;s SQLITE d...
Definition: mediadb.h:58
QVariantMap getFolderContent(int folder_id, int mediaType)
Definition: mediadb.cpp:236
QVariantList getLocations(bool onlyAvailable)
Definition: mediadb.cpp:185
QVariantMap getListWithFirstLetterFromQuery(QSqlQuery q)
Definition: mediadb.cpp:360
QVariantMap getAudioFiles()
Definition: mediadb.cpp:317