summaryrefslogtreecommitdiffstats
path: root/src/library/coverart.cpp
blob: 89f324ade480b0546884e7199fa5aa7979ea2fc9 (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
#include <QtDebug>

#include "library/coverart.h"
#include "library/coverartutils.h"
#include "util/debug.h"

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";
}

QDebug operator<<(QDebug dbg, const CoverInfoRelative& info) {
    return dbg.maybeSpace() << QString("CoverInfo(%1,%2,%3,%4)")
            .arg(typeToString(info.type),
                 sourceToString(info.source),
                 info.coverLocation,
                 QString::number(info.hash));
}

QDebug operator<<(QDebug dbg, const CoverInfo& info) {
    return dbg.maybeSpace() << QString("CoverInfo(%1,%2)")
            .arg(toDebugString(static_cast<CoverInfoRelative>(info)),
                 info.trackLocation);
}

QDebug operator<<(QDebug dbg, const CoverArt& art) {
    return dbg.maybeSpace() << QString("CoverArt(%1,%2)")
            .arg(toDebugString(art.image.size()),
                 toDebugString(static_cast<CoverInfo>(art)));
}

const quint16 CoverInfoRelative::kNullImageHash = CoverArtUtils::calculateHash(QImage());