File indexing completed on 2024-05-05 05:40:26
0001 /************************************************************************* 0002 * Copyright (C) 2011 by Joseph Boudou * 0003 * Copyright (C) 2014 by Renaud Guezennec * 0004 * * 0005 * https://rolisteam.org/ * 0006 * * 0007 * Rolisteam is free software; you can redistribute it and/or modify * 0008 * it under the terms of the GNU General Public License as published * 0009 * by the Free Software Foundation; either version 2 of the License, * 0010 * or (at your option) any later version. * 0011 * * 0012 * This program is distributed in the hope that it will be useful, * 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0015 * GNU General Public License for more details. * 0016 * * 0017 * You should have received a copy of the GNU General Public License * 0018 * along with this program; if not, write to the * 0019 * Free Software Foundation, Inc., * 0020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0021 *************************************************************************/ 0022 0023 #include "data/person.h" 0024 0025 #include <QIcon> 0026 #include <QUuid> 0027 0028 /********** 0029 * Person * 0030 **********/ 0031 Person::Person(QObject* parent) : QObject(parent), m_uuid(QUuid::createUuid().toString(QUuid::WithoutBraces)) {} 0032 0033 Person::Person(const QString& name, const QColor& color, const QString& uuid) 0034 : QObject(), m_name(name), m_uuid(uuid), m_color(color) 0035 { 0036 if(m_uuid.isNull()) 0037 m_uuid= QUuid::createUuid().toString(QUuid::WithoutBraces); 0038 } 0039 0040 QString Person::name() const 0041 { 0042 return m_name; 0043 } 0044 0045 Person::~Person()= default; 0046 0047 QColor Person::getColor() const 0048 { 0049 return m_color; 0050 } 0051 QString Person::uuid() const 0052 { 0053 return m_uuid; 0054 } 0055 Person* Person::parentPerson() const 0056 { 0057 return m_parentPerson; 0058 } 0059 0060 void Person::setParentPerson(Person* parent) 0061 { 0062 m_parentPerson= parent; 0063 } 0064 0065 bool Person::setColor(const QColor& color) 0066 { 0067 if(color == m_color) 0068 return false; 0069 0070 m_color= color; 0071 emit colorChanged(); 0072 return true; 0073 } 0074 0075 QByteArray Person::avatar() const 0076 { 0077 return m_avatar; 0078 } 0079 0080 void Person::setAvatar(const QByteArray& p) 0081 { 0082 if(p == m_avatar) 0083 return; 0084 0085 m_avatar= p; 0086 emit avatarChanged(); 0087 } 0088 bool Person::hasAvatar() const 0089 { 0090 return !m_avatar.isNull(); 0091 } 0092 0093 bool Person::isLeaf() const 0094 { 0095 return true; 0096 } 0097 0098 QIcon Person::icon() const 0099 { 0100 QPixmap pi; 0101 pi.loadFromData(m_avatar); 0102 return QIcon(pi); 0103 } 0104 0105 void Person::setName(const QString& name) 0106 { 0107 if(m_name == name) 0108 return; 0109 m_name= name; 0110 emit nameChanged(m_name); 0111 } 0112 0113 void Person::setUuid(const QString& uuid) 0114 { 0115 if(m_uuid == uuid) 0116 return; 0117 m_uuid= uuid; 0118 emit uuidChanged(m_uuid); 0119 }