-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdecodersc68factory.cpp
107 lines (94 loc) · 2.74 KB
/
decodersc68factory.cpp
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
#include "decodersc68factory.h"
#include "sc68helper.h"
#include "decoder_sc68.h"
#include <QMessageBox>
bool DecoderSC68Factory::canDecode(QIODevice *input) const
{
const QFile * const file = qobject_cast<QFile*>(input);
if(!file)
{
return false;
}
SC68Helper helper(file->fileName());
return helper.initialize();
}
DecoderProperties DecoderSC68Factory::properties() const
{
DecoderProperties properties;
properties.name = tr("SC68 Plugin");
properties.shortName = "sc68";
properties.filters << "*.sc68" << "*.snd" << "*.sndh";
properties.description = "Atari ST(E) And Amiga Audio File";
properties.protocols << "file" << "sc68";
properties.noInput = true;
properties.hasAbout = true;
return properties;
}
Decoder *DecoderSC68Factory::create(const QString &path, QIODevice *input)
{
Q_UNUSED(input);
return new DecoderSC68(path);
}
QList<TrackInfo*> DecoderSC68Factory::createPlayList(const QString &path, TrackInfo::Parts parts, QStringList *ignoredPaths)
{
if(path.contains("://")) //is it one track?
{
QString filePath = path;
filePath.remove("sc68://");
filePath.remove(RegularExpression("#\\d+$"));
const int track = path.section("#", -1).toInt();
QList<TrackInfo*> playlist = createPlayList(filePath, parts, ignoredPaths);
if(playlist.isEmpty() || track <= 0 || track > playlist.count())
{
qDeleteAll(playlist);
playlist.clear();
return playlist;
}
TrackInfo *info = playlist.takeAt(track - 1);
qDeleteAll(playlist);
playlist.clear();
return playlist << info;
}
else
{
if(ignoredPaths)
{
ignoredPaths->push_back(path);
}
}
SC68Helper helper(path);
if(!helper.initialize())
{
qWarning("DecoderSC68Factory: unable to open file");
return QList<TrackInfo*>();
}
return helper.createPlayList(parts);
}
MetaDataModel* DecoderSC68Factory::createMetaDataModel(const QString &path, bool readOnly)
{
Q_UNUSED(path);
Q_UNUSED(readOnly);
return nullptr;
}
#if (QMMP_VERSION_INT < 0x10700) || (0x20000 <= QMMP_VERSION_INT && QMMP_VERSION_INT < 0x20200)
void DecoderSC68Factory::showSettings(QWidget *parent)
{
Q_UNUSED(parent);
}
#else
QDialog *DecoderSC68Factory::createSettings(QWidget *parent)
{
Q_UNUSED(parent);
return nullptr;
}
#endif
void DecoderSC68Factory::showAbout(QWidget *parent)
{
QMessageBox::about(parent, tr("About SC68 Reader Plugin"),
tr("Qmmp SC68 Reader Plugin") + "\n" +
tr("Written by: Greedysky <[email protected]>"));
}
QString DecoderSC68Factory::translation() const
{
return QString();
}