Go to the documentation of this file.
14 #include "../CRESettings.h"
18 #include <QTextStream>
23 setProperty(
tipProperty, tr(
"Display all sound files."));
45 std::map<std::string, std::string> soundConf;
46 QFile
file(dir.filePath(
"sounds.conf"));
47 if (
file.open(QIODevice::ReadOnly | QIODevice::Text)) {
48 QTextStream in(&
file);
50 QString
line = in.readLine();
51 if (
line.isEmpty() ||
line.startsWith(
'#')) {
55 if (
split.length() != 3) {
58 soundConf[
split[0].toStdString()] =
split[2].toStdString();
61 qDebug() << tr(
"Unable to open sound configuration file %1/sounds.conf").arg(
path);
64 auto files = dir.entryList(QDir::Files, QDir::SortFlag::IgnoreCase |
QDir::Name);
65 for (
auto file : files) {
66 if (
file.endsWith(
".ogg") ||
file.endsWith(
".wav")) {
67 std::vector<std::string>
events;
68 for (
const auto &sc : soundConf) {
69 if (sc.second ==
file.toStdString()) {
70 events.push_back(sc.first);
76 if (
file.endsWith(
".LICENSE")) {
78 auto it = std::find_if(
mySounds.cbegin(),
mySounds.cend(), [&
name] (
const auto &sound) { return sound->displayName() == name; });
98 for (
size_t i = 0; i <
mySounds.size(); ++i) {
100 return static_cast<int>(i);
108 return tr(
"No sound file found");
111 for (
const auto &sound :
mySounds) {
112 if (!sound->license().empty()) {
116 size_t percent = 100 * with /
mySounds.size();
117 if (percent == 100 && with <
mySounds.size()) {
120 return tr(
"%1 sound files with license information on %2 (%3%)").arg(with).arg(
mySounds.size()).arg(percent);
SoundFiles(AssetWrapper *parent)
void bufferreader_destroy(BufferReader *br)
static const char * tipProperty
BufferReader * bufferreader_init_from_file(BufferReader *br, const char *filepath, const char *failureMessage, LogLevel failureLevel)
static QHash< QString, archetype * > events
std::vector< SoundFile * > mySounds
virtual int childIndex(AssetWrapper *child) override
static void parseLicenseFile(BufferReader *reader, const char *filename, std::vector< LicenseItem > &items)
void markModified(ChangeType change, int extra=0)
virtual AssetWrapper * child(int index) override
static std::vector< std::string > split(const std::string &field, const std::string &by)
QString licenseInformation