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
|
#include <QtDebug>
#include <QLatin1Literal>
#include "library/coverart.h"
#include "library/coverartutils.h"
#include "util/debug.h"
namespace {
QString sourceToString(CoverInfo::Source source) {
switch (source) {
case CoverInfo::UNKNOWN:
return "UNKNOWN";
case CoverInfo::GUESSED:
return "GUESSED";
case CoverInfo::USER_SELECTED:
return "USER_SELECTED";
}
return "INVALID INFO VALUE";
}
QString typeToString(CoverInfo::Type type) {
switch (type) {
case CoverInfo::NONE:
return "NONE";
case CoverInfo::METADATA:
return "METADATA";
case CoverInfo::FILE:
return "FILE";
}
return "INVALID TYPE VALUE";
}
QString coverInfoRelativeToString(const CoverInfoRelative& infoRelative) {
return typeToString(infoRelative.type) % QLatin1Literal(",") %
sourceToString(infoRelative.source) % QLatin1Literal(",") %
infoRelative.coverLocation % QLatin1Literal(",") %
QLatin1Literal("0x") % QString::number(infoRelative.hash, 16);
}
QString coverInfoToString(const CoverInfo& info) {
return coverInfoRelativeToString(info) % QLatin1Literal(",") %
info.trackLocation % QLatin1Literal(",");
}
} // anonymous namespace
bool operator==(const CoverInfoRelative& a, const CoverInfoRelative& b) {
return a.source == b.source &&
a.type == b.type &&
a.hash == b.hash &&
a.coverLocation == b.coverLocation;
}
bool operator!=(const CoverInfoRelative& a, const CoverInfoRelative& b) {
return !(a == b);
}
QDebug operator<<(QDebug dbg, const CoverInfoRelative& infoRelative) {
return dbg.maybeSpace() << QString("CoverInfoRelative(%1)")
.arg(coverInfoRelativeToString(infoRelative));
}
bool operator==(const CoverInfo& a, const CoverInfo& b) {
return static_cast<const CoverInfoRelative&>(a) ==
static_cast<const CoverInfoRelative&>(b) &&
a.trackLocation == b.trackLocation;
}
bool operator!=(const CoverInfo& a, const CoverInfo& b) {
return !(a == b);
}
QDebug operator<<(QDebug dbg, const CoverInfo& info) {
return dbg.maybeSpace() << QString("CoverInfo(%1)")
.arg(coverInfoToString(info));
}
QDebug operator<<(QDebug dbg, const CoverArt& art) {
return dbg.maybeSpace() << QString("CoverArt(%1,%2,%3)")
.arg(coverInfoToString(art),
toDebugString(art.image.size()),
QString::number(art.resizedToWidth));
}
const quint16 CoverInfoRelative::kNullImageHash = CoverArtUtils::calculateHash(QImage());
|