1 /*
2 This file is part of the Kasten Framework, made within the KDE community.
3
4 SPDX-FileCopyrightText: 2008 Friedrich W. H. Kossebau <kossebau@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9 #include "person.hpp"
10 #include "person_p.hpp"
11
12 namespace Kasten {
13
14 static constexpr struct EgoDataStruct
15 {
16 const char* name;
17 const char* faceIconName;
18 }
19 EgoData[] =
20 {
21 {"Ego", "face-smile"},
22 {"Joe Developer", "face-surprise"},
23 {"Konqui", "face-laugh"},
24 {"Hans Entwickler", "user-identity"}
25 };
26 static constexpr int lastEgoDataIndex = sizeof(EgoData) / sizeof(EgoDataStruct) - 1;
27 static int currentEgoDataIndex = 0;
28
createEgo()29 Person Person::createEgo()
30 {
31 const EgoDataStruct* currentEgoData = &EgoData[currentEgoDataIndex];
32 const Person result(QLatin1String(currentEgoData->name),
33 QIcon::fromTheme(QLatin1String(currentEgoData->faceIconName)));
34 // if( currentEgoDataIndex < lastEgoDataIndex )
35 // ++currentEgoDataIndex;
36 return result;
37 }
38
setEgoId(int egoId)39 void Person::setEgoId(int egoId)
40 {
41 if (lastEgoDataIndex < egoId) {
42 egoId = lastEgoDataIndex;
43 }
44 currentEgoDataIndex = egoId;
45 }
46
Person(const QString & name,const QIcon & faceIcon)47 Person::Person(const QString& name, const QIcon& faceIcon)
48 : d(new PersonPrivate(name, faceIcon))
49 {
50 }
Person()51 Person::Person()
52 : d(new PersonPrivate(QString(), QIcon()))
53 {
54 }
55 Person::Person(const Person& other) = default;
56
57 Person::~Person() = default;
58
59 Person& Person::operator=(const Person& other) = default;
60
operator ==(const Person & other) const61 bool Person::operator==(const Person& other) const
62 {
63 return (name() == other.name()) && !name().isEmpty();
64 }
65
name() const66 QString Person::name() const { return d->name(); }
faceIcon() const67 QIcon Person::faceIcon() const { return d->faceIcon(); }
68
69 }
70