1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/***************************************************************************
trackcollection.h
-------------------
begin : 10/27/2008
copyright : (C) 2008 Albert Santoni
email : gamegod \a\t users.sf.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef TRACKCOLLECTION_H
#define TRACKCOLLECTION_H
#include <QtSql>
#include <QList>
#include <QSharedPointer>
#include <QSqlDatabase>
#include "preferences/usersettings.h"
#include "library/basetrackcache.h"
#include "library/dao/trackdao.h"
#include "library/dao/cratedao.h"
#include "library/dao/cuedao.h"
#include "library/dao/playlistdao.h"
#include "library/dao/analysisdao.h"
#include "library/dao/directorydao.h"
#include "library/dao/libraryhashdao.h"
#ifdef __SQLITE3__
typedef struct sqlite3_context sqlite3_context;
typedef struct Mem sqlite3_value;
#endif
class TrackInfoObject;
#define AUTODJ_TABLE "Auto DJ"
class BpmDetector;
/**
@author Albert Santoni
*/
class TrackCollection : public QObject {
Q_OBJECT
public:
static const int kRequiredSchemaVersion;
TrackCollection(UserSettingsPointer pConfig);
virtual ~TrackCollection();
bool checkForTables();
void resetLibaryCancellation();
QSqlDatabase& getDatabase();
CrateDAO& getCrateDAO();
TrackDAO& getTrackDAO();
PlaylistDAO& getPlaylistDAO();
DirectoryDAO& getDirectoryDAO();
QSharedPointer<BaseTrackCache> getTrackSource();
void setTrackSource(QSharedPointer<BaseTrackCache> trackSource);
void cancelLibraryScan();
UserSettingsPointer getConfig() {
return m_pConfig;
}
protected:
#ifdef __SQLITE3__
void installSorting(QSqlDatabase &db);
static int sqliteLocaleAwareCompare(void* pArg,
int len1, const void* data1,
int len2, const void* data2);
static void sqliteLike(sqlite3_context *p,
int aArgc,
sqlite3_value **aArgv);
static void makeLatinLow(QChar* c, int count);
static int likeCompareLatinLow(
QString* pattern,
QString* string,
const QChar esc);
static int likeCompareInner(
const QChar* pattern,
int patterenSize,
const QChar* string,
int stringSize,
const QChar esc);
#endif // __SQLITE3__
private:
UserSettingsPointer m_pConfig;
QSqlDatabase m_db;
QSharedPointer<BaseTrackCache> m_defaultTrackSource;
PlaylistDAO m_playlistDao;
CrateDAO m_crateDao;
CueDAO m_cueDao;
DirectoryDAO m_directoryDao;
AnalysisDao m_analysisDao;
LibraryHashDAO m_libraryHashDao;
TrackDAO m_trackDao;
};
#endif // TRACKCOLLECTION_H
|