File indexing completed on 2024-04-28 04:43:00

0001 /*
0002  * Copyright (C) 2014 David Faure <faure@kde.org>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #include "personlist.h"
0021 #include "configuration.h"
0022 
0023 #include <QDebug>
0024 #include <QJsonObject>
0025 
0026 using namespace TmdbQt;
0027 
0028 class TmdbQt::PersonPrivate : public QSharedData
0029 {
0030 public:
0031     PersonPrivate(const Configuration &config)
0032         : m_configuration(config) {}
0033 
0034     const Configuration &m_configuration;
0035     Person::PersonType m_personType;
0036 
0037     QString m_name;
0038     QString m_character;
0039     QString m_profilePath;
0040     QString m_department;
0041     QString m_job;
0042 };
0043 
0044 Person::Person(const Configuration &configuration)
0045     : d(new PersonPrivate(configuration))
0046 {
0047 }
0048 
0049 Person::Person(const Person &other)
0050     : d(other.d)
0051 {
0052 }
0053 
0054 Person::~Person()
0055 {
0056 }
0057 
0058 Person &Person::operator=(const Person &other)
0059 {
0060     d = other.d;
0061     return *this;
0062 }
0063 
0064 QString Person::name() const
0065 {
0066     return d->m_name;
0067 }
0068 
0069 QString Person::character() const
0070 {
0071     return d->m_character;
0072 }
0073 
0074 QString Person::profilePath() const
0075 {
0076     return d->m_profilePath;
0077 }
0078 
0079 QString Person::department() const
0080 {
0081     return d->m_department;
0082 }
0083 
0084 QString Person::job() const
0085 {
0086     return d->m_job;
0087 }
0088 
0089 void Person::load(const QJsonObject &json, PersonType personType)
0090 {
0091     d->m_personType = personType;
0092     d->m_name = json.value(QStringLiteral("name")).toString();
0093     d->m_character = json.value(QStringLiteral("character")).toString();
0094     d->m_department = json.value(QStringLiteral("department")).toString();
0095     d->m_job = json.value(QStringLiteral("job")).toString();
0096     d->m_profilePath = json.value(QStringLiteral("profile_path")).toString();
0097 }