blob: 3a7992832d7d40d7a1fca79048c3530b95790183 (
plain)
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
|
#ifndef ANALYSISDAO_H
#define ANALYSISDAO_H
#include <QObject>
#include <QDir>
#include <QSqlDatabase>
#include "preferences/usersettings.h"
#include "library/dao/dao.h"
#include "track/trackid.h"
#include "waveform/waveform.h"
class AnalysisDao : public DAO {
public:
static const QString s_analysisTableName;
enum AnalysisType {
TYPE_UNKNOWN = 0,
TYPE_WAVEFORM,
TYPE_WAVESUMMARY
};
struct AnalysisInfo {
AnalysisInfo()
: analysisId(-1),
type(TYPE_UNKNOWN) {
}
int analysisId;
TrackId trackId;
AnalysisType type;
QString description;
QString version;
QByteArray data;
};
explicit AnalysisDao(UserSettingsPointer pConfig);
~AnalysisDao() override = default;
// The following functions can be used with a custom database
// connection and independent of whether the DAO has been
// initialized or not.
bool deleteAnalysesByType(
const QSqlDatabase& database,
AnalysisType type) const;
size_t getDiskUsageInBytes(
const QSqlDatabase& database,
AnalysisType type) const;
QList<AnalysisInfo> getAnalysesForTrackByType(TrackId trackId, AnalysisType type);
QList<AnalysisInfo> getAnalysesForTrack(TrackId trackId);
bool saveAnalysis(AnalysisInfo* analysis);
bool deleteAnalysis(const int analysisId);
void deleteAnalyses(const QList<TrackId>& trackIds);
bool deleteAnalysesForTrack(TrackId trackId);
void saveTrackAnalyses(
TrackId trackId,
ConstWaveformPointer pWaveform,
ConstWaveformPointer pWaveSummary);
private:
QDir getAnalysisStoragePath() const;
QByteArray loadDataFromFile(const QString& fileName) const;
bool saveDataToFile(const QString& fileName, const QByteArray& data) const;
bool deleteFile(const QString& filename) const;
QList<AnalysisInfo> loadAnalysesFromQuery(TrackId trackId, QSqlQuery* query);
const UserSettingsPointer m_pConfig;
};
#endif // ANALYSISDAO_H
|