File indexing completed on 2024-06-02 06:03:17
0001 /* 0002 This file is part of the Kasten Framework, made within the KDE community. 0003 0004 SPDX-FileCopyrightText: 2008 Friedrich W. H. Kossebau <kossebau@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #include "person.hpp" 0010 #include "person_p.hpp" 0011 0012 namespace Kasten { 0013 0014 static constexpr struct EgoDataStruct 0015 { 0016 const char* name; 0017 const char* faceIconName; 0018 } 0019 EgoData[] = 0020 { 0021 {"Ego", "face-smile"}, 0022 {"Joe Developer", "face-surprise"}, 0023 {"Konqui", "face-laugh"}, 0024 {"Hans Entwickler", "user-identity"} 0025 }; 0026 static constexpr int lastEgoDataIndex = sizeof(EgoData) / sizeof(EgoDataStruct) - 1; 0027 static int currentEgoDataIndex = 0; 0028 0029 Person Person::createEgo() 0030 { 0031 const EgoDataStruct* currentEgoData = &EgoData[currentEgoDataIndex]; 0032 const Person result(QLatin1String(currentEgoData->name), 0033 QIcon::fromTheme(QLatin1String(currentEgoData->faceIconName))); 0034 // if( currentEgoDataIndex < lastEgoDataIndex ) 0035 // ++currentEgoDataIndex; 0036 return result; 0037 } 0038 0039 void Person::setEgoId(int egoId) 0040 { 0041 if (lastEgoDataIndex < egoId) { 0042 egoId = lastEgoDataIndex; 0043 } 0044 currentEgoDataIndex = egoId; 0045 } 0046 0047 Person::Person(const QString& name, const QIcon& faceIcon) 0048 : d(new PersonPrivate(name, faceIcon)) 0049 { 0050 } 0051 Person::Person() 0052 : d(new PersonPrivate(QString(), QIcon())) 0053 { 0054 } 0055 Person::Person(const Person& other) = default; 0056 0057 Person::~Person() = default; 0058 0059 Person& Person::operator=(const Person& other) = default; 0060 0061 bool Person::operator==(const Person& other) const 0062 { 0063 return (name() == other.name()) && !name().isEmpty(); 0064 } 0065 0066 QString Person::name() const { return d->name(); } 0067 QIcon Person::faceIcon() const { return d->faceIcon(); } 0068 0069 }