KCalendarCore

person.h
Go to the documentation of this file.
1/*
2 This file is part of the kcalcore library.
3
4 SPDX-FileCopyrightText: 2001-2003 Cornelius Schumacher <schumacher@kde.org>
5 SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9/**
10 @file
11 This file is part of the API for handling calendar data and
12 defines the Person class.
13
14 @author Cornelius Schumacher <schumacher@kde.org>
15 @author Reinhold Kainhofer <reinhold@kainhofer.com>
16*/
17
18#ifndef KCALCORE_PERSON_H
19#define KCALCORE_PERSON_H
20
21#include "kcalendarcore_export.h"
22
23#include <QHash>
24#include <QMetaType>
25#include <QSharedDataPointer>
26#include <QString>
27
28namespace KCalendarCore
29{
30/**
31 @brief
32 Represents a person, by name and email address.
33
34 This class represents a person, with a name and an email address.
35 It supports the "FirstName LastName\ <mail@domain>" format.
36*/
37class KCALENDARCORE_EXPORT Person
38{
39 Q_GADGET
40 Q_PROPERTY(bool isEmpty READ isEmpty)
41 Q_PROPERTY(QString fullName READ fullName)
42 Q_PROPERTY(QString name READ name WRITE setName)
43 Q_PROPERTY(QString email READ email WRITE setEmail)
44
45public:
46 /**
47 List of persons.
48 */
50
51 /**
52 Constructs a blank person.
53 */
54 Person();
55
56 /**
57 Constructs a person with name and email address taken from @p fullName.
58
59 @param fullName is the name and email of the person in the form
60 "FirstName LastName <mail@domain>".
61 @return A Person object.
62 */
63 static Person fromFullName(const QString &fullName);
64
65 /**
66 Constructs a person with the name @p name and email address @p email.
67
68 @param name is the name of this person.
69 @param email is the email address of this person.
70 */
71 Person(const QString &name, const QString &email);
72
73 /**
74 Constructs a person as a copy of another person object.
75 @param person is the person to copy.
76 */
77 Person(const Person &person);
78
79 /**
80 Destroys a person.
81 */
82 virtual ~Person();
83
84 /**
85 Returns true if the person name and email address are empty.
86 */
87 Q_REQUIRED_RESULT bool isEmpty() const;
88
89 /**
90 Returns the full name of this person.
91 @return A QString containing the person's full name in the form
92 "FirstName LastName <mail@domain>".
93 */
94 Q_REQUIRED_RESULT QString fullName() const;
95
96 /**
97 Sets the name of the person to @p name.
98
99 @param name is the name of this person.
100
101 @see name()
102 */
103 void setName(const QString &name);
104
105 /**
106 Returns the person name string.
107
108 @see setName()
109 */
110 Q_REQUIRED_RESULT QString name() const;
111
112 /**
113 Sets the email address for this person to @p email.
114
115 @param email is the email address for this person.
116
117 @see email()
118 */
119 void setEmail(const QString &email);
120
121 /**
122 Returns the email address for this person.
123 @return A QString containing the person's email address.
124 @see setEmail()
125 */
126 Q_REQUIRED_RESULT QString email() const;
127
128 /**
129 Returns true if person's email address is valid.
130 Simple email validity check, test that there:
131 * is at least one @
132 * is at least one character in the local part
133 * is at least one dot in the domain part
134 * is at least four characters in the domain (assuming that no-one has an address at the tld,
135 that the tld is at least 2 chars)
136
137 @param email is the email address to validate
138 */
139 Q_REQUIRED_RESULT static bool isValidEmail(const QString &email);
140
141 /**
142 Compares this with @p person for equality.
143
144 @param person is the person to compare.
145 */
146 bool operator==(const Person &person) const;
147
148 /**
149 Compares this with @p person for non-equality.
150
151 @param person is the person to compare.
152 */
153 bool operator!=(const Person &person) const;
154
155 /**
156 Sets this person equal to @p person.
157
158 @param person is the person to copy.
159 */
160 Person &operator=(const Person &person);
161
162private:
163 //@cond PRIVATE
164 class Private;
166 //@endcond
167
168 friend KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &s, const KCalendarCore::Person &person);
169 friend KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &s, KCalendarCore::Person &person);
170};
171
172/**
173 Serializes the @p person object into the @p stream.
174*/
175KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &stream, const KCalendarCore::Person &person);
176
177/**
178 Initializes the @p person object from the @p stream.
179*/
180KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &stream, KCalendarCore::Person &person);
181
182/**
183 Return a hash value for a Person argument.
184 @param key is a Person.
185*/
186KCALENDARCORE_EXPORT size_t qHash(const KCalendarCore::Person &key, size_t seed = 0);
187
188}
189
190//@cond PRIVATE
191Q_DECLARE_TYPEINFO(KCalendarCore::Person, Q_RELOCATABLE_TYPE);
192Q_DECLARE_METATYPE(KCalendarCore::Person)
193//@endcond
194
195#endif
Represents a person, by name and email address.
Definition person.h:38
QList< Person > List
List of persons.
Definition person.h:49
virtual ~Person()
Destroys a person.
friend KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &s, const KCalendarCore::Person &person)
Serializes the person object into the stream.
friend KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &s, KCalendarCore::Person &person)
Initializes the person object from the stream.
Namespace for all KCalendarCore types.
Definition alarm.h:37
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
Alarm deserializer.
Definition alarm.cpp:833
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
Alarm serializer.
Definition alarm.cpp:820
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:39:07 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.