Files
qcma/src/sqlitedb.h
codestation b7ad2b13f4 Create a unified base class to access the database.
Moved the default database class to QListDB and disallow leaking CMAObjects outside this class.
Rewrote QListDB and CMAEvent to use the new internal API.
Moved the file format constants to the base database class.
Moved the metadata loading methods to the base database class.
2014-01-28 14:00:15 -04:30

73 lines
1.8 KiB
C++

#ifndef SQLITEDB_H
#define SQLITEDB_H
#include "database.h"
#include <vitamtp.h>
#include <QObject>
#include <QSqlDatabase>
#include <QSqlError>
#define OBJECT_FILE 0x10000000
#define OBJECT_FOLDER 0x20000000
#define OBJECT_SPECIAL 0x40000000
#define OBJECT_MUSIC 0x00000100
#define OBJECT_PHOTO 0x00000200
#define OBJECT_VIDEO 0x00000400
#define OBJECT_ALBUM 0x00000002
#define OBJECT_ARTIST 0x00000005
#define OBJECT_ALBUM_ARTIST 0x00000008
#define OBJECT_GENRE 0x0000000B
#define OBJECT_SAVEDATA 0x00040000
#define OBJECT_SAVEDATA_FILE 0x00000002
#define OBJECT_APPLICATION 0x00080000
class SQLiteDB : public Database
{
Q_OBJECT
public:
explicit SQLiteDB(QObject *parent = 0);
~SQLiteDB();
bool open();
int create();
void remove();
bool initialize();
QSqlError getLastError();
int getPathId(const QString &path);
QString getPathFromId(int ohfi);
bool updateSize(int ohfi, quint64 size);
bool deleteEntry(int ohfi);
bool deleteEntry(const QString &path);
uint insertObjectEntry(const char *title, int type);
bool insertSourceEntry(uint object_id, const QString &path);
uint insertMusicEntry(const QString &path, int type, int parent);
uint insertVideoEntry(const QString &path, int type, int parent);
uint insertPhotoEntry(const QString &path, int type, int parent);
uint insertSavedataEntry(const QString &path, int type, int parent);
uint insertApplicationEntry(const QString &path, int type, int parent, int app_type);
bool getObjectMetadata(int ohfi, metadata_t &metadata);
private:
int recursiveScanRootDirectory(const QString &base_path, int parent, int type);
uint insertDirectoryEntry(const QString &path, int type, int parent);
bool updateAdjacencyList(int ohfi, int parent);
QString uuid;
QSqlDatabase db;
signals:
public slots:
};
#endif // SQLITEDB_H