author | zautrix <zautrix> | 2005-10-29 16:39:40 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-29 16:39:40 (UTC) |
commit | 898dbabef6d747447999add46201315d04f85f63 (patch) (unidiff) | |
tree | fb247cbbd99ca6918400547e16484a58a8ba1523 /libkcal | |
parent | 1360f8e3b5da58b561f868643d2d5f04b874cee7 (diff) | |
download | kdepimpi-898dbabef6d747447999add46201315d04f85f63.zip kdepimpi-898dbabef6d747447999add46201315d04f85f63.tar.gz kdepimpi-898dbabef6d747447999add46201315d04f85f63.tar.bz2 |
commit
-rw-r--r-- | libkcal/person.cpp | 8 | ||||
-rw-r--r-- | libkcal/person.h | 1 |
2 files changed, 8 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 | |||
@@ -28,49 +28,55 @@ using namespace KCal; | |||
28 | Person::Person( const QString &fullName ) | 28 | Person::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 | ||
39 | Person::Person( const QString &name, const QString &email ) | 39 | Person::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 | ||
46 | bool KCal::operator==( const Person& p1, const Person& p2 ) | 46 | bool 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 | 52 | QString 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 | } | ||
53 | QString Person::fullName() const | 59 | QString 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 | ||
65 | void Person::setName(const QString &name) | 71 | void Person::setName(const QString &name) |
66 | { | 72 | { |
67 | mName = name; | 73 | mName = name; |
68 | } | 74 | } |
69 | 75 | ||
70 | void Person::setEmail(const QString &email) | 76 | void 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 | } |
diff --git a/libkcal/person.h b/libkcal/person.h index c46c5f0..3cec153 100644 --- a/libkcal/person.h +++ b/libkcal/person.h | |||
@@ -14,37 +14,38 @@ | |||
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 | #ifndef KCAL_PERSON_H | 20 | #ifndef KCAL_PERSON_H |
21 | #define KCAL_PERSON_H | 21 | #define KCAL_PERSON_H |
22 | 22 | ||
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | 24 | ||
25 | namespace KCal { | 25 | namespace KCal { |
26 | 26 | ||
27 | class Person | 27 | class Person |
28 | { | 28 | { |
29 | public: | 29 | public: |
30 | Person() {} | 30 | Person() {} |
31 | Person( const QString &fullName ); | 31 | Person( const QString &fullName ); |
32 | Person( const QString &name, const QString &email ); | 32 | Person( const QString &name, const QString &email ); |
33 | 33 | ||
34 | QString fullName( ) const; | 34 | QString fullName( ) const; |
35 | 35 | ||
36 | void setName(const QString &); | 36 | void setName(const QString &); |
37 | QString name() const { return mName; } | 37 | QString name() const { return mName; } |
38 | QString realName() const; | ||
38 | 39 | ||
39 | void setEmail(const QString &); | 40 | void setEmail(const QString &); |
40 | QString email() const { return mEmail; } | 41 | QString email() const { return mEmail; } |
41 | 42 | ||
42 | private: | 43 | private: |
43 | QString mName; | 44 | QString mName; |
44 | QString mEmail; | 45 | QString mEmail; |
45 | }; | 46 | }; |
46 | 47 | ||
47 | bool operator==( const Person& p1, const Person& p2 ); | 48 | bool operator==( const Person& p1, const Person& p2 ); |
48 | } | 49 | } |
49 | 50 | ||
50 | #endif | 51 | #endif |