summaryrefslogtreecommitdiffabout
path: root/libkcal/person.cpp
Unidiff
Diffstat (limited to 'libkcal/person.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/person.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/libkcal/person.cpp b/libkcal/person.cpp
index aca28c2..858805d 100644
--- a/libkcal/person.cpp
+++ b/libkcal/person.cpp
@@ -4,74 +4,80 @@
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kdebug.h> 21#include <kdebug.h>
22#include <klocale.h> 22#include <klocale.h>
23 23
24#include "person.h" 24#include "person.h"
25 25
26using namespace KCal; 26using namespace KCal;
27 27
28Person::Person( const QString &fullName ) 28Person::Person( const QString &fullName )
29{ 29{
30 int emailPos = fullName.find( '<' ); 30 int emailPos = fullName.find( '<' );
31 if ( emailPos < 0 ) { 31 if ( emailPos < 0 ) {
32 setEmail(fullName); 32 setEmail(fullName);
33 } else { 33 } else {
34 setEmail(fullName.mid( emailPos + 1, fullName.length() - 1 )); 34 setEmail(fullName.mid( emailPos + 1, fullName.length() - 1 ));
35 setName(fullName.left( emailPos - 2 )); 35 setName(fullName.left( emailPos - 2 ));
36 } 36 }
37} 37}
38 38
39Person::Person( const QString &name, const QString &email ) 39Person::Person( const QString &name, const QString &email )
40{ 40{
41 setName(name); 41 setName(name);
42 setEmail(email); 42 setEmail(email);
43} 43}
44 44
45 45
46bool KCal::operator==( const Person& p1, const Person& p2 ) 46bool KCal::operator==( const Person& p1, const Person& p2 )
47{ 47{
48 return ( p1.name() == p2.name() && 48 return ( p1.name() == p2.name() &&
49 p1.email() == p2.email() ); 49 p1.email() == p2.email() );
50} 50}
51 51
52 52QString Person::realName() const
53{
54 int ccc = mName.find (',');
55 if ( ccc < 0 )
56 return mName;
57 return mName.mid( ccc+1 ).stripWhiteSpace() + " " + mName.left( ccc ).stripWhiteSpace();
58}
53QString Person::fullName() const 59QString Person::fullName() const
54{ 60{
55 if( mName.isEmpty() ) { 61 if( mName.isEmpty() ) {
56 return mEmail; 62 return mEmail;
57 } else { 63 } else {
58 if( mEmail.isEmpty() ) 64 if( mEmail.isEmpty() )
59 return mName; 65 return mName;
60 else 66 else
61 return mName + " <" + mEmail + ">"; 67 return mName + " <" + mEmail + ">";
62 } 68 }
63} 69}
64 70
65void Person::setName(const QString &name) 71void Person::setName(const QString &name)
66{ 72{
67 mName = name; 73 mName = name;
68} 74}
69 75
70void Person::setEmail(const QString &email) 76void Person::setEmail(const QString &email)
71{ 77{
72 if (email.left(7).lower() == "mailto:") { 78 if (email.left(7).lower() == "mailto:") {
73 mEmail = email.mid(7); 79 mEmail = email.mid(7);
74 } else { 80 } else {
75 mEmail = email; 81 mEmail = email;
76 } 82 }
77} 83}