File indexing completed on 2024-05-12 16:25:36

0001 /*
0002    SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "customsoundinfo.h"
0008 #include <QJsonObject>
0009 
0010 CustomSoundInfo::CustomSoundInfo() = default;
0011 
0012 const QString &CustomSoundInfo::identifier() const
0013 {
0014     return mIdentifier;
0015 }
0016 
0017 void CustomSoundInfo::setIdentifier(const QString &newIdentifier)
0018 {
0019     mIdentifier = newIdentifier;
0020 }
0021 
0022 const QString &CustomSoundInfo::name() const
0023 {
0024     return mName;
0025 }
0026 
0027 void CustomSoundInfo::setName(const QString &newName)
0028 {
0029     mName = newName;
0030 }
0031 
0032 void CustomSoundInfo::parseCustomSoundInfo(const QJsonObject &obj)
0033 {
0034     mName = obj[QLatin1String("name")].toString();
0035     mIdentifier = obj[QLatin1String("_id")].toString();
0036     mExtension = obj[QLatin1String("extension")].toString();
0037 }
0038 
0039 const QString &CustomSoundInfo::extension() const
0040 {
0041     return mExtension;
0042 }
0043 
0044 void CustomSoundInfo::setExtension(const QString &newExtension)
0045 {
0046     mExtension = newExtension;
0047 }
0048 
0049 bool CustomSoundInfo::isValid() const
0050 {
0051     return !mIdentifier.isEmpty() && !mName.isEmpty();
0052 }
0053 
0054 QDebug operator<<(QDebug d, const CustomSoundInfo &t)
0055 {
0056     d.space() << "Identifier:" << t.identifier();
0057     d.space() << "Name:" << t.name();
0058     d.space() << "Extension:" << t.extension();
0059     return d;
0060 }