summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-29 21:05:07 (UTC)
committer zautrix <zautrix>2004-10-29 21:05:07 (UTC)
commit3c0edb4b4c4a77b334331749dfde776911c3a3a0 (patch) (unidiff)
tree89de7078a1a062c19b2f13ededd49f471c362abf
parenta7e2fe5bb10af47a239b8b014a210568cc79287a (diff)
downloadkdepimpi-3c0edb4b4c4a77b334331749dfde776911c3a3a0.zip
kdepimpi-3c0edb4b4c4a77b334331749dfde776911c3a3a0.tar.gz
kdepimpi-3c0edb4b4c4a77b334331749dfde776911c3a3a0.tar.bz2
KO WN view fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp3
-rw-r--r--kabc/phonenumber.cpp31
-rw-r--r--kabc/plugins/ldap/ldapE.pro2
-rw-r--r--korganizer/kowhatsnextview.cpp42
-rw-r--r--korganizer/kowhatsnextview.h2
5 files changed, 38 insertions, 42 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 028d3bb..eec0f1f 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,2132 +1,2133 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h> 35#include <kidmanager.h>
36//US 36//US
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40//US #include "resource.h" 40//US #include "resource.h"
41#include "addressee.h" 41#include "addressee.h"
42 42
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46static bool matchBinaryPatternA( int value, int pattern ); 46static bool matchBinaryPatternA( int value, int pattern );
47static bool matchBinaryPatternP( int value, int pattern ); 47static bool matchBinaryPatternP( int value, int pattern );
48 48
49struct Addressee::AddresseeData : public KShared 49struct Addressee::AddresseeData : public KShared
50{ 50{
51 QString uid; 51 QString uid;
52 QString name; 52 QString name;
53 QString formattedName; 53 QString formattedName;
54 QString familyName; 54 QString familyName;
55 QString givenName; 55 QString givenName;
56 QString additionalName; 56 QString additionalName;
57 QString prefix; 57 QString prefix;
58 QString suffix; 58 QString suffix;
59 QString nickName; 59 QString nickName;
60 QDateTime birthday; 60 QDateTime birthday;
61 QString mailer; 61 QString mailer;
62 TimeZone timeZone; 62 TimeZone timeZone;
63 Geo geo; 63 Geo geo;
64 QString title; 64 QString title;
65 QString role; 65 QString role;
66 QString organization; 66 QString organization;
67 QString note; 67 QString note;
68 QString productId; 68 QString productId;
69 QDateTime revision; 69 QDateTime revision;
70 QString sortString; 70 QString sortString;
71 QString externalUID; 71 QString externalUID;
72 QString originalExternalUID; 72 QString originalExternalUID;
73 KURL url; 73 KURL url;
74 Secrecy secrecy; 74 Secrecy secrecy;
75 Picture logo; 75 Picture logo;
76 Picture photo; 76 Picture photo;
77 Sound sound; 77 Sound sound;
78 Agent agent; 78 Agent agent;
79 QString mExternalId; 79 QString mExternalId;
80 PhoneNumber::List phoneNumbers; 80 PhoneNumber::List phoneNumbers;
81 Address::List addresses; 81 Address::List addresses;
82 Key::List keys; 82 Key::List keys;
83 QStringList emails; 83 QStringList emails;
84 QStringList categories; 84 QStringList categories;
85 QStringList custom; 85 QStringList custom;
86 int mTempSyncStat; 86 int mTempSyncStat;
87 Resource *resource; 87 Resource *resource;
88 88
89 bool empty :1; 89 bool empty :1;
90 bool changed :1; 90 bool changed :1;
91 bool tagged :1; 91 bool tagged :1;
92}; 92};
93 93
94Addressee::Addressee() 94Addressee::Addressee()
95{ 95{
96 mData = new AddresseeData; 96 mData = new AddresseeData;
97 mData->empty = true; 97 mData->empty = true;
98 mData->changed = false; 98 mData->changed = false;
99 mData->resource = 0; 99 mData->resource = 0;
100 mData->mExternalId = ":"; 100 mData->mExternalId = ":";
101 mData->revision = QDateTime ( QDate( 2003,1,1)); 101 mData->revision = QDateTime ( QDate( 2003,1,1));
102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 102 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
103} 103}
104 104
105Addressee::~Addressee() 105Addressee::~Addressee()
106{ 106{
107} 107}
108 108
109Addressee::Addressee( const Addressee &a ) 109Addressee::Addressee( const Addressee &a )
110{ 110{
111 mData = a.mData; 111 mData = a.mData;
112} 112}
113 113
114Addressee &Addressee::operator=( const Addressee &a ) 114Addressee &Addressee::operator=( const Addressee &a )
115{ 115{
116 mData = a.mData; 116 mData = a.mData;
117 return (*this); 117 return (*this);
118} 118}
119 119
120Addressee Addressee::copy() 120Addressee Addressee::copy()
121{ 121{
122 Addressee a; 122 Addressee a;
123 *(a.mData) = *mData; 123 *(a.mData) = *mData;
124 return a; 124 return a;
125} 125}
126 126
127void Addressee::detach() 127void Addressee::detach()
128{ 128{
129 if ( mData.count() == 1 ) return; 129 if ( mData.count() == 1 ) return;
130 *this = copy(); 130 *this = copy();
131} 131}
132 132
133bool Addressee::operator==( const Addressee &a ) const 133bool Addressee::operator==( const Addressee &a ) const
134{ 134{
135 if ( uid() != a.uid() ) return false; 135 if ( uid() != a.uid() ) return false;
136 if ( mData->name != a.mData->name ) return false; 136 if ( mData->name != a.mData->name ) return false;
137 if ( mData->formattedName != a.mData->formattedName ) return false; 137 if ( mData->formattedName != a.mData->formattedName ) return false;
138 if ( mData->familyName != a.mData->familyName ) return false; 138 if ( mData->familyName != a.mData->familyName ) return false;
139 if ( mData->givenName != a.mData->givenName ) return false; 139 if ( mData->givenName != a.mData->givenName ) return false;
140 if ( mData->additionalName != a.mData->additionalName ) return false; 140 if ( mData->additionalName != a.mData->additionalName ) return false;
141 if ( mData->prefix != a.mData->prefix ) return false; 141 if ( mData->prefix != a.mData->prefix ) return false;
142 if ( mData->suffix != a.mData->suffix ) return false; 142 if ( mData->suffix != a.mData->suffix ) return false;
143 if ( mData->nickName != a.mData->nickName ) return false; 143 if ( mData->nickName != a.mData->nickName ) return false;
144 if ( mData->birthday != a.mData->birthday ) return false; 144 if ( mData->birthday != a.mData->birthday ) return false;
145 if ( mData->mailer != a.mData->mailer ) return false; 145 if ( mData->mailer != a.mData->mailer ) return false;
146 if ( mData->timeZone != a.mData->timeZone ) return false; 146 if ( mData->timeZone != a.mData->timeZone ) return false;
147 if ( mData->geo != a.mData->geo ) return false; 147 if ( mData->geo != a.mData->geo ) return false;
148 if ( mData->title != a.mData->title ) return false; 148 if ( mData->title != a.mData->title ) return false;
149 if ( mData->role != a.mData->role ) return false; 149 if ( mData->role != a.mData->role ) return false;
150 if ( mData->organization != a.mData->organization ) return false; 150 if ( mData->organization != a.mData->organization ) return false;
151 if ( mData->note != a.mData->note ) return false; 151 if ( mData->note != a.mData->note ) return false;
152 if ( mData->productId != a.mData->productId ) return false; 152 if ( mData->productId != a.mData->productId ) return false;
153 //if ( mData->revision != a.mData->revision ) return false; 153 //if ( mData->revision != a.mData->revision ) return false;
154 if ( mData->sortString != a.mData->sortString ) return false; 154 if ( mData->sortString != a.mData->sortString ) return false;
155 if ( mData->secrecy != a.mData->secrecy ) return false; 155 if ( mData->secrecy != a.mData->secrecy ) return false;
156 if ( mData->logo != a.mData->logo ) return false; 156 if ( mData->logo != a.mData->logo ) return false;
157 if ( mData->photo != a.mData->photo ) return false; 157 if ( mData->photo != a.mData->photo ) return false;
158 if ( mData->sound != a.mData->sound ) return false; 158 if ( mData->sound != a.mData->sound ) return false;
159 if ( mData->agent != a.mData->agent ) return false; 159 if ( mData->agent != a.mData->agent ) return false;
160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 160 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
161 ( mData->url != a.mData->url ) ) return false; 161 ( mData->url != a.mData->url ) ) return false;
162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 162 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
163 if ( mData->addresses != a.mData->addresses ) return false; 163 if ( mData->addresses != a.mData->addresses ) return false;
164 if ( mData->keys != a.mData->keys ) return false; 164 if ( mData->keys != a.mData->keys ) return false;
165 if ( mData->emails != a.mData->emails ) return false; 165 if ( mData->emails != a.mData->emails ) return false;
166 if ( mData->categories != a.mData->categories ) return false; 166 if ( mData->categories != a.mData->categories ) return false;
167 if ( mData->custom != a.mData->custom ) return false; 167 if ( mData->custom != a.mData->custom ) return false;
168 168
169 return true; 169 return true;
170} 170}
171 171
172bool Addressee::operator!=( const Addressee &a ) const 172bool Addressee::operator!=( const Addressee &a ) const
173{ 173{
174 return !( a == *this ); 174 return !( a == *this );
175} 175}
176 176
177bool Addressee::isEmpty() const 177bool Addressee::isEmpty() const
178{ 178{
179 return mData->empty; 179 return mData->empty;
180} 180}
181ulong Addressee::getCsum4List( const QStringList & attList) 181ulong Addressee::getCsum4List( const QStringList & attList)
182{ 182{
183 int max = attList.count(); 183 int max = attList.count();
184 ulong cSum = 0; 184 ulong cSum = 0;
185 int j,k,i; 185 int j,k,i;
186 int add; 186 int add;
187 for ( i = 0; i < max ; ++i ) { 187 for ( i = 0; i < max ; ++i ) {
188 QString s = attList[i]; 188 QString s = attList[i];
189 if ( ! s.isEmpty() ){ 189 if ( ! s.isEmpty() ){
190 j = s.length(); 190 j = s.length();
191 for ( k = 0; k < j; ++k ) { 191 for ( k = 0; k < j; ++k ) {
192 int mul = k +1; 192 int mul = k +1;
193 add = s[k].unicode (); 193 add = s[k].unicode ();
194 if ( k < 16 ) 194 if ( k < 16 )
195 mul = mul * mul; 195 mul = mul * mul;
196 int ii = i+1; 196 int ii = i+1;
197 add = add * mul *ii*ii*ii; 197 add = add * mul *ii*ii*ii;
198 cSum += add; 198 cSum += add;
199 } 199 }
200 } 200 }
201 201
202 } 202 }
203 //QString dump = attList.join(","); 203 //QString dump = attList.join(",");
204 //qDebug("csum: %d %s", cSum,dump.latin1()); 204 //qDebug("csum: %d %s", cSum,dump.latin1());
205 205
206 return cSum; 206 return cSum;
207 207
208} 208}
209void Addressee::computeCsum(const QString &dev) 209void Addressee::computeCsum(const QString &dev)
210{ 210{
211 QStringList l; 211 QStringList l;
212 //if ( !mData->name.isEmpty() ) l.append(mData->name); 212 //if ( !mData->name.isEmpty() ) l.append(mData->name);
213 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 213 //if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
216 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName ); 216 if ( !mData->additionalName.isEmpty() ) l.append( mData->additionalName );
217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
224 if ( !mData->title .isEmpty() ) l.append( mData->title ); 224 if ( !mData->title .isEmpty() ) l.append( mData->title );
225 if ( !mData->role.isEmpty() ) l.append( mData->role ); 225 if ( !mData->role.isEmpty() ) l.append( mData->role );
226 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 226 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
227 if ( !mData->note.isEmpty() ) l.append( mData->note ); 227 if ( !mData->note.isEmpty() ) l.append( mData->note );
228 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 228 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
231 // if ( !mData->logo.isEmpty() ) l.append( ); 231 // if ( !mData->logo.isEmpty() ) l.append( );
232 //if ( !mData->photo.isEmpty() ) l.append( ); 232 //if ( !mData->photo.isEmpty() ) l.append( );
233 //if ( !mData->sound.isEmpty() ) l.append( ); 233 //if ( !mData->sound.isEmpty() ) l.append( );
234 //if ( !mData->agent.isEmpty() ) l.append( ); 234 //if ( !mData->agent.isEmpty() ) l.append( );
235 if ( mData->url.isValid() ) 235 if ( mData->url.isValid() )
236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); 236 if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() );
237 KABC::PhoneNumber::List phoneNumbers; 237 KABC::PhoneNumber::List phoneNumbers;
238 KABC::PhoneNumber::List::Iterator phoneIter; 238 KABC::PhoneNumber::List::Iterator phoneIter;
239 239
240 QStringList t; 240 QStringList t;
241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 241 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
242 ++phoneIter ) 242 ++phoneIter )
243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 243 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
244 t.sort(); 244 t.sort();
245 uint iii; 245 uint iii;
246 for ( iii = 0; iii < t.count(); ++iii) 246 for ( iii = 0; iii < t.count(); ++iii)
247 l.append( t[iii] ); 247 l.append( t[iii] );
248 t = mData->emails; 248 t = mData->emails;
249 t.sort(); 249 t.sort();
250 for ( iii = 0; iii < t.count(); ++iii) 250 for ( iii = 0; iii < t.count(); ++iii)
251 l.append( t[iii] ); 251 l.append( t[iii] );
252 t = mData->categories; 252 t = mData->categories;
253 t.sort(); 253 t.sort();
254 for ( iii = 0; iii < t.count(); ++iii) 254 for ( iii = 0; iii < t.count(); ++iii)
255 l.append( t[iii] ); 255 l.append( t[iii] );
256 t = mData->custom; 256 t = mData->custom;
257 t.sort(); 257 t.sort();
258 for ( iii = 0; iii < t.count(); ++iii) 258 for ( iii = 0; iii < t.count(); ++iii)
259 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) { 259 if ( t[iii].left( 25 ) != "KADDRESSBOOK-X-ExternalID" ) {
260 int find = t[iii].find (':')+1; 260 int find = t[iii].find (':')+1;
261 //qDebug("lennnn %d %d ", find, t[iii].length()); 261 //qDebug("lennnn %d %d ", find, t[iii].length());
262 if ( find < t[iii].length()) 262 if ( find < t[iii].length())
263 l.append( t[iii] ); 263 l.append( t[iii] );
264 264
265 } 265 }
266 KABC::Address::List::Iterator addressIter; 266 KABC::Address::List::Iterator addressIter;
267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
268 ++addressIter ) { 268 ++addressIter ) {
269 t = (*addressIter).asList(); 269 t = (*addressIter).asList();
270 t.sort(); 270 t.sort();
271 for ( iii = 0; iii < t.count(); ++iii) 271 for ( iii = 0; iii < t.count(); ++iii)
272 l.append( t[iii] ); 272 l.append( t[iii] );
273 } 273 }
274 uint cs = getCsum4List(l); 274 uint cs = getCsum4List(l);
275#if 0 275#if 0
276 for ( iii = 0; iii < l.count(); ++iii) 276 for ( iii = 0; iii < l.count(); ++iii)
277 qDebug("%d***%s***",iii,l[iii].latin1()); 277 qDebug("%d***%s***",iii,l[iii].latin1());
278 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 278 qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
279#endif 279#endif
280 setCsum( dev, QString::number (cs )); 280 setCsum( dev, QString::number (cs ));
281} 281}
282 282
283void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) 283void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false)
284{ 284{
285 285
286 detach(); 286 detach();
287 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 287 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
288 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 288 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
289 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 289 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
290 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 290 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
291 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 291 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
292 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 292 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
293 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 293 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
294 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 294 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
295 if ( !mData->birthday.isValid() ) 295 if ( !mData->birthday.isValid() )
296 if ( ad.mData->birthday.isValid()) 296 if ( ad.mData->birthday.isValid())
297 mData->birthday = ad.mData->birthday; 297 mData->birthday = ad.mData->birthday;
298 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 298 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
299 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 299 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
300 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 300 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
301 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 301 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
302 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 302 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
303 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 303 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
304 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 304 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
305 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 305 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
306 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 306 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
307 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 307 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
308 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 308 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
309 QStringList t; 309 QStringList t;
310 QStringList tAD; 310 QStringList tAD;
311 uint iii; 311 uint iii;
312 312
313 // ********** phone numbers 313 // ********** phone numbers
314 PhoneNumber::List phoneAD = ad.phoneNumbers(); 314 PhoneNumber::List phoneAD = ad.phoneNumbers();
315 PhoneNumber::List::Iterator phoneItAD; 315 PhoneNumber::List::Iterator phoneItAD;
316 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { 316 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
317 bool found = false; 317 bool found = false;
318 PhoneNumber::List::Iterator it; 318 PhoneNumber::List::Iterator it;
319 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 319 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
320 if ( ( *phoneItAD ).contains( (*it) ) ) { 320 if ( ( *phoneItAD ).contains( (*it) ) ) {
321 found = true; 321 found = true;
322 (*it).setType( ( *phoneItAD ).type() ); 322 (*it).setType( ( *phoneItAD ).type() );
323 (*it).setNumber( ( *phoneItAD ).number() ); 323 (*it).setNumber( ( *phoneItAD ).number() );
324 break; 324 break;
325 } 325 }
326 } 326 }
327 if ( isSubSet && ! found ) 327 // if ( isSubSet && ! found )
328 if ( ! found ) // LR try this one...
328 mData->phoneNumbers.append( *phoneItAD ); 329 mData->phoneNumbers.append( *phoneItAD );
329 } 330 }
330 if ( isSubSet ) { 331 if ( isSubSet ) {
331 // ************* emails; 332 // ************* emails;
332 t = mData->emails; 333 t = mData->emails;
333 tAD = ad.mData->emails; 334 tAD = ad.mData->emails;
334 for ( iii = 0; iii < tAD.count(); ++iii) 335 for ( iii = 0; iii < tAD.count(); ++iii)
335 if ( !t.contains(tAD[iii] ) ) 336 if ( !t.contains(tAD[iii] ) )
336 mData->emails.append( tAD[iii] ); 337 mData->emails.append( tAD[iii] );
337 } 338 }
338 339
339 // ************* categories; 340 // ************* categories;
340 t = mData->categories; 341 t = mData->categories;
341 tAD = ad.mData->categories; 342 tAD = ad.mData->categories;
342 for ( iii = 0; iii < tAD.count(); ++iii) 343 for ( iii = 0; iii < tAD.count(); ++iii)
343 if ( !t.contains(tAD[iii] ) ) 344 if ( !t.contains(tAD[iii] ) )
344 mData->categories.append( tAD[iii] ); 345 mData->categories.append( tAD[iii] );
345 QStringList::ConstIterator it; 346 QStringList::ConstIterator it;
346 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { 347 for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) {
347 QString qualifiedName = (*it).left( (*it).find( ":" )); 348 QString qualifiedName = (*it).left( (*it).find( ":" ));
348 bool found = false; 349 bool found = false;
349 QStringList::ConstIterator itL; 350 QStringList::ConstIterator itL;
350 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 351 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
351 if ( (*itL).startsWith( qualifiedName ) ) { 352 if ( (*itL).startsWith( qualifiedName ) ) {
352 found = true; 353 found = true;
353 break; 354 break;
354 } 355 }
355 } 356 }
356 if ( ! found ) { 357 if ( ! found ) {
357 mData->custom.append( *it ); 358 mData->custom.append( *it );
358 } 359 }
359 } 360 }
360 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; 361 if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo;
361 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; 362 if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo;
362 if ( !mData->sound.isIntern() ) { 363 if ( !mData->sound.isIntern() ) {
363 if ( mData->sound.url().isEmpty() ) { 364 if ( mData->sound.url().isEmpty() ) {
364 mData->sound = ad.mData->sound; 365 mData->sound = ad.mData->sound;
365 } 366 }
366 } 367 }
367 if ( !mData->agent.isIntern() ) { 368 if ( !mData->agent.isIntern() ) {
368 if ( mData->agent.url().isEmpty() ) { 369 if ( mData->agent.url().isEmpty() ) {
369 mData->agent = ad.mData->agent; 370 mData->agent = ad.mData->agent;
370 } 371 }
371 } 372 }
372 { 373 {
373 Key::List::Iterator itA; 374 Key::List::Iterator itA;
374 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { 375 for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) {
375 bool found = false; 376 bool found = false;
376 Key::List::Iterator it; 377 Key::List::Iterator it;
377 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 378 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
378 if ( (*it) == (*itA)) { 379 if ( (*it) == (*itA)) {
379 found = true; 380 found = true;
380 break; 381 break;
381 382
382 } 383 }
383 } 384 }
384 if ( ! found ) { 385 if ( ! found ) {
385 mData->keys.append( *itA ); 386 mData->keys.append( *itA );
386 } 387 }
387 } 388 }
388 } 389 }
389 KABC::Address::List::Iterator addressIterA; 390 KABC::Address::List::Iterator addressIterA;
390 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { 391 for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) {
391 bool found = false; 392 bool found = false;
392 KABC::Address::List::Iterator addressIter; 393 KABC::Address::List::Iterator addressIter;
393 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 394 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
394 ++addressIter ) { 395 ++addressIter ) {
395 if ( (*addressIter) == (*addressIterA)) { 396 if ( (*addressIter) == (*addressIterA)) {
396 found = true; 397 found = true;
397 (*addressIter).setType( (*addressIterA).type() ); 398 (*addressIter).setType( (*addressIterA).type() );
398 break; 399 break;
399 } 400 }
400 401
401 } 402 }
402 if ( isSubSet && ! found ) { 403 if ( isSubSet && ! found ) {
403 mData->addresses.append( *addressIterA ); 404 mData->addresses.append( *addressIterA );
404 } 405 }
405 } 406 }
406 //qDebug("merge contact %s ", ad.uid().latin1()); 407 //qDebug("merge contact %s ", ad.uid().latin1());
407 setUid( ad.uid() ); 408 setUid( ad.uid() );
408 setRevision( ad.revision() ); 409 setRevision( ad.revision() );
409} 410}
410 411
411bool Addressee::removeVoice() 412bool Addressee::removeVoice()
412{ 413{
413 PhoneNumber::List phoneN = phoneNumbers(); 414 PhoneNumber::List phoneN = phoneNumbers();
414 PhoneNumber::List::Iterator phoneIt; 415 PhoneNumber::List::Iterator phoneIt;
415 bool found = false; 416 bool found = false;
416 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 417 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
417 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 418 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
418 if ((*phoneIt).type() - PhoneNumber::Voice ) { 419 if ((*phoneIt).type() - PhoneNumber::Voice ) {
419 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 420 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
420 insertPhoneNumber( (*phoneIt) ); 421 insertPhoneNumber( (*phoneIt) );
421 found = true; 422 found = true;
422 } 423 }
423 } 424 }
424 425
425 } 426 }
426 return found; 427 return found;
427} 428}
428 429
429bool Addressee::containsAdr(const Addressee& ad ) 430bool Addressee::containsAdr(const Addressee& ad )
430{ 431{
431 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; 432 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
432 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; 433 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
433 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; 434 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
434 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; 435 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
435 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; 436 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
436 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; 437 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
437 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; 438 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
438 439
439 // compare phone numbers 440 // compare phone numbers
440 PhoneNumber::List phoneN = ad.phoneNumbers(); 441 PhoneNumber::List phoneN = ad.phoneNumbers();
441 PhoneNumber::List::Iterator phoneIt; 442 PhoneNumber::List::Iterator phoneIt;
442 bool found = false; 443 bool found = false;
443 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 444 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
444 bool found = false; 445 bool found = false;
445 PhoneNumber::List phoneL = ad.phoneNumbers(); 446 PhoneNumber::List phoneL = ad.phoneNumbers();
446 PhoneNumber::List::Iterator phoneItL; 447 PhoneNumber::List::Iterator phoneItL;
447 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 448 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
448 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 449 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
449 found = true; 450 found = true;
450 break; 451 break;
451 } 452 }
452 } 453 }
453 if ( ! found ) 454 if ( ! found )
454 return false; 455 return false;
455 } 456 }
456 return true; 457 return true;
457 458
458} 459}
459void Addressee::simplifyAddresses() 460void Addressee::simplifyAddresses()
460{ 461{
461 462
462 463
463 Address::List list; 464 Address::List list;
464 Address::List::Iterator it; 465 Address::List::Iterator it;
465 Address::List::Iterator it2; 466 Address::List::Iterator it2;
466 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 467 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
467 it2 = it; 468 it2 = it;
468 ++it2; 469 ++it2;
469 for( ; it2 != mData->addresses.end(); ++it2 ) { 470 for( ; it2 != mData->addresses.end(); ++it2 ) {
470 if ( (*it) == (*it2) ) { 471 if ( (*it) == (*it2) ) {
471 list.append( *it ); 472 list.append( *it );
472 break; 473 break;
473 } 474 }
474 } 475 }
475 } 476 }
476 for( it = list.begin(); it != list.end(); ++it ) { 477 for( it = list.begin(); it != list.end(); ++it ) {
477 removeAddress( (*it) ); 478 removeAddress( (*it) );
478 } 479 }
479 480
480 list.clear(); 481 list.clear();
481 int max = 2; 482 int max = 2;
482 if ( mData->url.isValid() ) 483 if ( mData->url.isValid() )
483 max = 1; 484 max = 1;
484 if ( mData->addresses.count() <= max ) return ; 485 if ( mData->addresses.count() <= max ) return ;
485 int count = 0; 486 int count = 0;
486 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 487 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
487 if ( count >= max ) 488 if ( count >= max )
488 list.append( *it ); 489 list.append( *it );
489 ++count; 490 ++count;
490 } 491 }
491 for( it = list.begin(); it != list.end(); ++it ) { 492 for( it = list.begin(); it != list.end(); ++it ) {
492 removeAddress( (*it) ); 493 removeAddress( (*it) );
493 } 494 }
494} 495}
495 496
496// removes all emails but the first 497// removes all emails but the first
497// needed by phone sync 498// needed by phone sync
498void Addressee::simplifyEmails() 499void Addressee::simplifyEmails()
499{ 500{
500 if ( mData->emails.count() == 0 ) return ; 501 if ( mData->emails.count() == 0 ) return ;
501 QString email = mData->emails.first(); 502 QString email = mData->emails.first();
502 detach(); 503 detach();
503 mData->emails.clear(); 504 mData->emails.clear();
504 mData->emails.append( email ); 505 mData->emails.append( email );
505} 506}
506 507
507void Addressee::simplifyPhoneNumbers() 508void Addressee::simplifyPhoneNumbers()
508{ 509{
509 int max = 4; 510 int max = 4;
510 int inList = mData->phoneNumbers.count(); 511 int inList = mData->phoneNumbers.count();
511 KABC::PhoneNumber::List removeNumbers; 512 KABC::PhoneNumber::List removeNumbers;
512 KABC::PhoneNumber::List::Iterator phoneIter; 513 KABC::PhoneNumber::List::Iterator phoneIter;
513 if ( inList > max ) { 514 if ( inList > max ) {
514 // delete non-preferred numbers 515 // delete non-preferred numbers
515 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 516 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
516 ++phoneIter ) { 517 ++phoneIter ) {
517 if ( inList > max ) { 518 if ( inList > max ) {
518 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { 519 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) {
519 removeNumbers.append( ( *phoneIter ) ); 520 removeNumbers.append( ( *phoneIter ) );
520 --inList; 521 --inList;
521 } 522 }
522 } else 523 } else
523 break; 524 break;
524 } 525 }
525 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 526 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
526 ++phoneIter ) { 527 ++phoneIter ) {
527 removePhoneNumber(( *phoneIter )); 528 removePhoneNumber(( *phoneIter ));
528 } 529 }
529 // delete preferred numbers 530 // delete preferred numbers
530 if ( inList > max ) { 531 if ( inList > max ) {
531 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 532 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
532 ++phoneIter ) { 533 ++phoneIter ) {
533 if ( inList > max ) { 534 if ( inList > max ) {
534 removeNumbers.append( ( *phoneIter ) ); 535 removeNumbers.append( ( *phoneIter ) );
535 --inList; 536 --inList;
536 } else 537 } else
537 break; 538 break;
538 } 539 }
539 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 540 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
540 ++phoneIter ) { 541 ++phoneIter ) {
541 removePhoneNumber(( *phoneIter )); 542 removePhoneNumber(( *phoneIter ));
542 } 543 }
543 } 544 }
544 } 545 }
545 // remove non-numeric characters 546 // remove non-numeric characters
546 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 547 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
547 ++phoneIter ) { 548 ++phoneIter ) {
548 if ( ! ( *phoneIter ).simplifyNumber() ) 549 if ( ! ( *phoneIter ).simplifyNumber() )
549 removeNumbers.append( ( *phoneIter ) ); 550 removeNumbers.append( ( *phoneIter ) );
550 } 551 }
551 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 552 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
552 ++phoneIter ) { 553 ++phoneIter ) {
553 removePhoneNumber(( *phoneIter )); 554 removePhoneNumber(( *phoneIter ));
554 } 555 }
555} 556}
556void Addressee::simplifyPhoneNumberTypes() 557void Addressee::simplifyPhoneNumberTypes()
557{ 558{
558 KABC::PhoneNumber::List::Iterator phoneIter; 559 KABC::PhoneNumber::List::Iterator phoneIter;
559 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 560 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
560 ++phoneIter ) 561 ++phoneIter )
561 ( *phoneIter ).simplifyType(); 562 ( *phoneIter ).simplifyType();
562} 563}
563void Addressee::removeID(const QString &prof) 564void Addressee::removeID(const QString &prof)
564{ 565{
565 detach(); 566 detach();
566 if ( prof.isEmpty() ) 567 if ( prof.isEmpty() )
567 mData->mExternalId = ":"; 568 mData->mExternalId = ":";
568 else 569 else
569 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 570 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
570 571
571} 572}
572void Addressee::setID( const QString & prof , const QString & id ) 573void Addressee::setID( const QString & prof , const QString & id )
573{ 574{
574 detach(); 575 detach();
575 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 576 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
576 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 577 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
577} 578}
578void Addressee::setTempSyncStat( int id ) 579void Addressee::setTempSyncStat( int id )
579{ 580{
580 if ( mData->mTempSyncStat == id ) return; 581 if ( mData->mTempSyncStat == id ) return;
581 detach(); 582 detach();
582 mData->mTempSyncStat = id; 583 mData->mTempSyncStat = id;
583} 584}
584int Addressee::tempSyncStat() const 585int Addressee::tempSyncStat() const
585{ 586{
586 return mData->mTempSyncStat; 587 return mData->mTempSyncStat;
587} 588}
588 589
589QString Addressee::getID( const QString & prof) 590QString Addressee::getID( const QString & prof)
590{ 591{
591 return KIdManager::getId ( mData->mExternalId, prof ); 592 return KIdManager::getId ( mData->mExternalId, prof );
592} 593}
593 594
594void Addressee::setCsum( const QString & prof , const QString & id ) 595void Addressee::setCsum( const QString & prof , const QString & id )
595{ 596{
596 detach(); 597 detach();
597 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 598 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
598 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 599 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
599 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 600 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
600} 601}
601 602
602QString Addressee::getCsum( const QString & prof) 603QString Addressee::getCsum( const QString & prof)
603{ 604{
604 return KIdManager::getCsum ( mData->mExternalId, prof ); 605 return KIdManager::getCsum ( mData->mExternalId, prof );
605} 606}
606 607
607void Addressee::setIDStr( const QString & s ) 608void Addressee::setIDStr( const QString & s )
608{ 609{
609 detach(); 610 detach();
610 mData->mExternalId = s; 611 mData->mExternalId = s;
611} 612}
612 613
613QString Addressee::IDStr() const 614QString Addressee::IDStr() const
614{ 615{
615 return mData->mExternalId; 616 return mData->mExternalId;
616} 617}
617 618
618void Addressee::setExternalUID( const QString &id ) 619void Addressee::setExternalUID( const QString &id )
619{ 620{
620 if ( id == mData->externalUID ) return; 621 if ( id == mData->externalUID ) return;
621 detach(); 622 detach();
622 mData->empty = false; 623 mData->empty = false;
623 mData->externalUID = id; 624 mData->externalUID = id;
624} 625}
625 626
626QString Addressee::externalUID() const 627QString Addressee::externalUID() const
627{ 628{
628 return mData->externalUID; 629 return mData->externalUID;
629} 630}
630void Addressee::setOriginalExternalUID( const QString &id ) 631void Addressee::setOriginalExternalUID( const QString &id )
631{ 632{
632 if ( id == mData->originalExternalUID ) return; 633 if ( id == mData->originalExternalUID ) return;
633 detach(); 634 detach();
634 mData->empty = false; 635 mData->empty = false;
635 //qDebug("*******Set orig uid %s ", id.latin1()); 636 //qDebug("*******Set orig uid %s ", id.latin1());
636 mData->originalExternalUID = id; 637 mData->originalExternalUID = id;
637} 638}
638 639
639QString Addressee::originalExternalUID() const 640QString Addressee::originalExternalUID() const
640{ 641{
641 return mData->originalExternalUID; 642 return mData->originalExternalUID;
642} 643}
643 644
644void Addressee::setUid( const QString &id ) 645void Addressee::setUid( const QString &id )
645{ 646{
646 if ( id == mData->uid ) return; 647 if ( id == mData->uid ) return;
647 detach(); 648 detach();
648 //qDebug("****setuid %s ", id.latin1()); 649 //qDebug("****setuid %s ", id.latin1());
649 mData->empty = false; 650 mData->empty = false;
650 mData->uid = id; 651 mData->uid = id;
651} 652}
652 653
653QString Addressee::uid() const 654QString Addressee::uid() const
654{ 655{
655 if ( mData->uid.isEmpty() ) 656 if ( mData->uid.isEmpty() )
656 mData->uid = KApplication::randomString( 10 ); 657 mData->uid = KApplication::randomString( 10 );
657 658
658 return mData->uid; 659 return mData->uid;
659} 660}
660 661
661QString Addressee::uidLabel() 662QString Addressee::uidLabel()
662{ 663{
663 return i18n("Unique Identifier"); 664 return i18n("Unique Identifier");
664} 665}
665 666
666void Addressee::setName( const QString &name ) 667void Addressee::setName( const QString &name )
667{ 668{
668 if ( name == mData->name ) return; 669 if ( name == mData->name ) return;
669 detach(); 670 detach();
670 mData->empty = false; 671 mData->empty = false;
671 mData->name = name; 672 mData->name = name;
672} 673}
673 674
674QString Addressee::name() const 675QString Addressee::name() const
675{ 676{
676 return mData->name; 677 return mData->name;
677} 678}
678 679
679QString Addressee::nameLabel() 680QString Addressee::nameLabel()
680{ 681{
681 return i18n("Name"); 682 return i18n("Name");
682} 683}
683 684
684 685
685void Addressee::setFormattedName( const QString &formattedName ) 686void Addressee::setFormattedName( const QString &formattedName )
686{ 687{
687 if ( formattedName == mData->formattedName ) return; 688 if ( formattedName == mData->formattedName ) return;
688 detach(); 689 detach();
689 mData->empty = false; 690 mData->empty = false;
690 mData->formattedName = formattedName; 691 mData->formattedName = formattedName;
691} 692}
692 693
693QString Addressee::formattedName() const 694QString Addressee::formattedName() const
694{ 695{
695 return mData->formattedName; 696 return mData->formattedName;
696} 697}
697 698
698QString Addressee::formattedNameLabel() 699QString Addressee::formattedNameLabel()
699{ 700{
700 return i18n("Formatted Name"); 701 return i18n("Formatted Name");
701} 702}
702 703
703 704
704void Addressee::setFamilyName( const QString &familyName ) 705void Addressee::setFamilyName( const QString &familyName )
705{ 706{
706 if ( familyName == mData->familyName ) return; 707 if ( familyName == mData->familyName ) return;
707 detach(); 708 detach();
708 mData->empty = false; 709 mData->empty = false;
709 mData->familyName = familyName; 710 mData->familyName = familyName;
710} 711}
711 712
712QString Addressee::familyName() const 713QString Addressee::familyName() const
713{ 714{
714 return mData->familyName; 715 return mData->familyName;
715} 716}
716 717
717QString Addressee::familyNameLabel() 718QString Addressee::familyNameLabel()
718{ 719{
719 return i18n("Family Name"); 720 return i18n("Family Name");
720} 721}
721 722
722 723
723void Addressee::setGivenName( const QString &givenName ) 724void Addressee::setGivenName( const QString &givenName )
724{ 725{
725 if ( givenName == mData->givenName ) return; 726 if ( givenName == mData->givenName ) return;
726 detach(); 727 detach();
727 mData->empty = false; 728 mData->empty = false;
728 mData->givenName = givenName; 729 mData->givenName = givenName;
729} 730}
730 731
731QString Addressee::givenName() const 732QString Addressee::givenName() const
732{ 733{
733 return mData->givenName; 734 return mData->givenName;
734} 735}
735 736
736QString Addressee::givenNameLabel() 737QString Addressee::givenNameLabel()
737{ 738{
738 return i18n("Given Name"); 739 return i18n("Given Name");
739} 740}
740 741
741 742
742void Addressee::setAdditionalName( const QString &additionalName ) 743void Addressee::setAdditionalName( const QString &additionalName )
743{ 744{
744 if ( additionalName == mData->additionalName ) return; 745 if ( additionalName == mData->additionalName ) return;
745 detach(); 746 detach();
746 mData->empty = false; 747 mData->empty = false;
747 mData->additionalName = additionalName; 748 mData->additionalName = additionalName;
748} 749}
749 750
750QString Addressee::additionalName() const 751QString Addressee::additionalName() const
751{ 752{
752 return mData->additionalName; 753 return mData->additionalName;
753} 754}
754 755
755QString Addressee::additionalNameLabel() 756QString Addressee::additionalNameLabel()
756{ 757{
757 return i18n("Additional Names"); 758 return i18n("Additional Names");
758} 759}
759 760
760 761
761void Addressee::setPrefix( const QString &prefix ) 762void Addressee::setPrefix( const QString &prefix )
762{ 763{
763 if ( prefix == mData->prefix ) return; 764 if ( prefix == mData->prefix ) return;
764 detach(); 765 detach();
765 mData->empty = false; 766 mData->empty = false;
766 mData->prefix = prefix; 767 mData->prefix = prefix;
767} 768}
768 769
769QString Addressee::prefix() const 770QString Addressee::prefix() const
770{ 771{
771 return mData->prefix; 772 return mData->prefix;
772} 773}
773 774
774QString Addressee::prefixLabel() 775QString Addressee::prefixLabel()
775{ 776{
776 return i18n("Honorific Prefixes"); 777 return i18n("Honorific Prefixes");
777} 778}
778 779
779 780
780void Addressee::setSuffix( const QString &suffix ) 781void Addressee::setSuffix( const QString &suffix )
781{ 782{
782 if ( suffix == mData->suffix ) return; 783 if ( suffix == mData->suffix ) return;
783 detach(); 784 detach();
784 mData->empty = false; 785 mData->empty = false;
785 mData->suffix = suffix; 786 mData->suffix = suffix;
786} 787}
787 788
788QString Addressee::suffix() const 789QString Addressee::suffix() const
789{ 790{
790 return mData->suffix; 791 return mData->suffix;
791} 792}
792 793
793QString Addressee::suffixLabel() 794QString Addressee::suffixLabel()
794{ 795{
795 return i18n("Honorific Suffixes"); 796 return i18n("Honorific Suffixes");
796} 797}
797 798
798 799
799void Addressee::setNickName( const QString &nickName ) 800void Addressee::setNickName( const QString &nickName )
800{ 801{
801 if ( nickName == mData->nickName ) return; 802 if ( nickName == mData->nickName ) return;
802 detach(); 803 detach();
803 mData->empty = false; 804 mData->empty = false;
804 mData->nickName = nickName; 805 mData->nickName = nickName;
805} 806}
806 807
807QString Addressee::nickName() const 808QString Addressee::nickName() const
808{ 809{
809 return mData->nickName; 810 return mData->nickName;
810} 811}
811 812
812QString Addressee::nickNameLabel() 813QString Addressee::nickNameLabel()
813{ 814{
814 return i18n("Nick Name"); 815 return i18n("Nick Name");
815} 816}
816 817
817 818
818void Addressee::setBirthday( const QDateTime &birthday ) 819void Addressee::setBirthday( const QDateTime &birthday )
819{ 820{
820 if ( birthday == mData->birthday ) return; 821 if ( birthday == mData->birthday ) return;
821 detach(); 822 detach();
822 mData->empty = false; 823 mData->empty = false;
823 mData->birthday = birthday; 824 mData->birthday = birthday;
824} 825}
825 826
826QDateTime Addressee::birthday() const 827QDateTime Addressee::birthday() const
827{ 828{
828 return mData->birthday; 829 return mData->birthday;
829} 830}
830 831
831QString Addressee::birthdayLabel() 832QString Addressee::birthdayLabel()
832{ 833{
833 return i18n("Birthday"); 834 return i18n("Birthday");
834} 835}
835 836
836 837
837QString Addressee::homeAddressStreetLabel() 838QString Addressee::homeAddressStreetLabel()
838{ 839{
839 return i18n("Home Address Street"); 840 return i18n("Home Address Street");
840} 841}
841 842
842 843
843QString Addressee::homeAddressLocalityLabel() 844QString Addressee::homeAddressLocalityLabel()
844{ 845{
845 return i18n("Home Address Locality"); 846 return i18n("Home Address Locality");
846} 847}
847 848
848 849
849QString Addressee::homeAddressRegionLabel() 850QString Addressee::homeAddressRegionLabel()
850{ 851{
851 return i18n("Home Address Region"); 852 return i18n("Home Address Region");
852} 853}
853 854
854 855
855QString Addressee::homeAddressPostalCodeLabel() 856QString Addressee::homeAddressPostalCodeLabel()
856{ 857{
857 return i18n("Home Address Postal Code"); 858 return i18n("Home Address Postal Code");
858} 859}
859 860
860 861
861QString Addressee::homeAddressCountryLabel() 862QString Addressee::homeAddressCountryLabel()
862{ 863{
863 return i18n("Home Address Country"); 864 return i18n("Home Address Country");
864} 865}
865 866
866 867
867QString Addressee::homeAddressLabelLabel() 868QString Addressee::homeAddressLabelLabel()
868{ 869{
869 return i18n("Home Address Label"); 870 return i18n("Home Address Label");
870} 871}
871 872
872 873
873QString Addressee::businessAddressStreetLabel() 874QString Addressee::businessAddressStreetLabel()
874{ 875{
875 return i18n("Business Address Street"); 876 return i18n("Business Address Street");
876} 877}
877 878
878 879
879QString Addressee::businessAddressLocalityLabel() 880QString Addressee::businessAddressLocalityLabel()
880{ 881{
881 return i18n("Business Address Locality"); 882 return i18n("Business Address Locality");
882} 883}
883 884
884 885
885QString Addressee::businessAddressRegionLabel() 886QString Addressee::businessAddressRegionLabel()
886{ 887{
887 return i18n("Business Address Region"); 888 return i18n("Business Address Region");
888} 889}
889 890
890 891
891QString Addressee::businessAddressPostalCodeLabel() 892QString Addressee::businessAddressPostalCodeLabel()
892{ 893{
893 return i18n("Business Address Postal Code"); 894 return i18n("Business Address Postal Code");
894} 895}
895 896
896 897
897QString Addressee::businessAddressCountryLabel() 898QString Addressee::businessAddressCountryLabel()
898{ 899{
899 return i18n("Business Address Country"); 900 return i18n("Business Address Country");
900} 901}
901 902
902 903
903QString Addressee::businessAddressLabelLabel() 904QString Addressee::businessAddressLabelLabel()
904{ 905{
905 return i18n("Business Address Label"); 906 return i18n("Business Address Label");
906} 907}
907 908
908 909
909QString Addressee::homePhoneLabel() 910QString Addressee::homePhoneLabel()
910{ 911{
911 return i18n("Home Phone"); 912 return i18n("Home Phone");
912} 913}
913 914
914 915
915QString Addressee::businessPhoneLabel() 916QString Addressee::businessPhoneLabel()
916{ 917{
917 return i18n("Business Phone"); 918 return i18n("Business Phone");
918} 919}
919 920
920 921
921QString Addressee::mobilePhoneLabel() 922QString Addressee::mobilePhoneLabel()
922{ 923{
923 return i18n("Mobile Phone"); 924 return i18n("Mobile Phone");
924} 925}
925 926
926 927
927QString Addressee::homeFaxLabel() 928QString Addressee::homeFaxLabel()
928{ 929{
929 return i18n("Home Fax"); 930 return i18n("Home Fax");
930} 931}
931 932
932 933
933QString Addressee::businessFaxLabel() 934QString Addressee::businessFaxLabel()
934{ 935{
935 return i18n("Business Fax"); 936 return i18n("Business Fax");
936} 937}
937 938
938 939
939QString Addressee::carPhoneLabel() 940QString Addressee::carPhoneLabel()
940{ 941{
941 return i18n("Car Phone"); 942 return i18n("Car Phone");
942} 943}
943 944
944 945
945QString Addressee::isdnLabel() 946QString Addressee::isdnLabel()
946{ 947{
947 return i18n("ISDN"); 948 return i18n("ISDN");
948} 949}
949 950
950 951
951QString Addressee::pagerLabel() 952QString Addressee::pagerLabel()
952{ 953{
953 return i18n("Pager"); 954 return i18n("Pager");
954} 955}
955 956
956QString Addressee::sipLabel() 957QString Addressee::sipLabel()
957{ 958{
958 return i18n("SIP"); 959 return i18n("SIP");
959} 960}
960 961
961QString Addressee::emailLabel() 962QString Addressee::emailLabel()
962{ 963{
963 return i18n("Email Address"); 964 return i18n("Email Address");
964} 965}
965 966
966 967
967void Addressee::setMailer( const QString &mailer ) 968void Addressee::setMailer( const QString &mailer )
968{ 969{
969 if ( mailer == mData->mailer ) return; 970 if ( mailer == mData->mailer ) return;
970 detach(); 971 detach();
971 mData->empty = false; 972 mData->empty = false;
972 mData->mailer = mailer; 973 mData->mailer = mailer;
973} 974}
974 975
975QString Addressee::mailer() const 976QString Addressee::mailer() const
976{ 977{
977 return mData->mailer; 978 return mData->mailer;
978} 979}
979 980
980QString Addressee::mailerLabel() 981QString Addressee::mailerLabel()
981{ 982{
982 return i18n("Mail Client"); 983 return i18n("Mail Client");
983} 984}
984 985
985 986
986void Addressee::setTimeZone( const TimeZone &timeZone ) 987void Addressee::setTimeZone( const TimeZone &timeZone )
987{ 988{
988 if ( timeZone == mData->timeZone ) return; 989 if ( timeZone == mData->timeZone ) return;
989 detach(); 990 detach();
990 mData->empty = false; 991 mData->empty = false;
991 mData->timeZone = timeZone; 992 mData->timeZone = timeZone;
992} 993}
993 994
994TimeZone Addressee::timeZone() const 995TimeZone Addressee::timeZone() const
995{ 996{
996 return mData->timeZone; 997 return mData->timeZone;
997} 998}
998 999
999QString Addressee::timeZoneLabel() 1000QString Addressee::timeZoneLabel()
1000{ 1001{
1001 return i18n("Time Zone"); 1002 return i18n("Time Zone");
1002} 1003}
1003 1004
1004 1005
1005void Addressee::setGeo( const Geo &geo ) 1006void Addressee::setGeo( const Geo &geo )
1006{ 1007{
1007 if ( geo == mData->geo ) return; 1008 if ( geo == mData->geo ) return;
1008 detach(); 1009 detach();
1009 mData->empty = false; 1010 mData->empty = false;
1010 mData->geo = geo; 1011 mData->geo = geo;
1011} 1012}
1012 1013
1013Geo Addressee::geo() const 1014Geo Addressee::geo() const
1014{ 1015{
1015 return mData->geo; 1016 return mData->geo;
1016} 1017}
1017 1018
1018QString Addressee::geoLabel() 1019QString Addressee::geoLabel()
1019{ 1020{
1020 return i18n("Geographic Position"); 1021 return i18n("Geographic Position");
1021} 1022}
1022 1023
1023 1024
1024void Addressee::setTitle( const QString &title ) 1025void Addressee::setTitle( const QString &title )
1025{ 1026{
1026 if ( title == mData->title ) return; 1027 if ( title == mData->title ) return;
1027 detach(); 1028 detach();
1028 mData->empty = false; 1029 mData->empty = false;
1029 mData->title = title; 1030 mData->title = title;
1030} 1031}
1031 1032
1032QString Addressee::title() const 1033QString Addressee::title() const
1033{ 1034{
1034 return mData->title; 1035 return mData->title;
1035} 1036}
1036 1037
1037QString Addressee::titleLabel() 1038QString Addressee::titleLabel()
1038{ 1039{
1039 return i18n("Title"); 1040 return i18n("Title");
1040} 1041}
1041 1042
1042 1043
1043void Addressee::setRole( const QString &role ) 1044void Addressee::setRole( const QString &role )
1044{ 1045{
1045 if ( role == mData->role ) return; 1046 if ( role == mData->role ) return;
1046 detach(); 1047 detach();
1047 mData->empty = false; 1048 mData->empty = false;
1048 mData->role = role; 1049 mData->role = role;
1049} 1050}
1050 1051
1051QString Addressee::role() const 1052QString Addressee::role() const
1052{ 1053{
1053 return mData->role; 1054 return mData->role;
1054} 1055}
1055 1056
1056QString Addressee::roleLabel() 1057QString Addressee::roleLabel()
1057{ 1058{
1058 return i18n("Role"); 1059 return i18n("Role");
1059} 1060}
1060 1061
1061 1062
1062void Addressee::setOrganization( const QString &organization ) 1063void Addressee::setOrganization( const QString &organization )
1063{ 1064{
1064 if ( organization == mData->organization ) return; 1065 if ( organization == mData->organization ) return;
1065 detach(); 1066 detach();
1066 mData->empty = false; 1067 mData->empty = false;
1067 mData->organization = organization; 1068 mData->organization = organization;
1068} 1069}
1069 1070
1070QString Addressee::organization() const 1071QString Addressee::organization() const
1071{ 1072{
1072 return mData->organization; 1073 return mData->organization;
1073} 1074}
1074 1075
1075QString Addressee::organizationLabel() 1076QString Addressee::organizationLabel()
1076{ 1077{
1077 return i18n("Organization"); 1078 return i18n("Organization");
1078} 1079}
1079 1080
1080 1081
1081void Addressee::setNote( const QString &note ) 1082void Addressee::setNote( const QString &note )
1082{ 1083{
1083 if ( note == mData->note ) return; 1084 if ( note == mData->note ) return;
1084 detach(); 1085 detach();
1085 mData->empty = false; 1086 mData->empty = false;
1086 mData->note = note; 1087 mData->note = note;
1087} 1088}
1088 1089
1089QString Addressee::note() const 1090QString Addressee::note() const
1090{ 1091{
1091 return mData->note; 1092 return mData->note;
1092} 1093}
1093 1094
1094QString Addressee::noteLabel() 1095QString Addressee::noteLabel()
1095{ 1096{
1096 return i18n("Note"); 1097 return i18n("Note");
1097} 1098}
1098 1099
1099 1100
1100void Addressee::setProductId( const QString &productId ) 1101void Addressee::setProductId( const QString &productId )
1101{ 1102{
1102 if ( productId == mData->productId ) return; 1103 if ( productId == mData->productId ) return;
1103 detach(); 1104 detach();
1104 mData->empty = false; 1105 mData->empty = false;
1105 mData->productId = productId; 1106 mData->productId = productId;
1106} 1107}
1107 1108
1108QString Addressee::productId() const 1109QString Addressee::productId() const
1109{ 1110{
1110 return mData->productId; 1111 return mData->productId;
1111} 1112}
1112 1113
1113QString Addressee::productIdLabel() 1114QString Addressee::productIdLabel()
1114{ 1115{
1115 return i18n("Product Identifier"); 1116 return i18n("Product Identifier");
1116} 1117}
1117 1118
1118 1119
1119void Addressee::setRevision( const QDateTime &revision ) 1120void Addressee::setRevision( const QDateTime &revision )
1120{ 1121{
1121 if ( revision == mData->revision ) return; 1122 if ( revision == mData->revision ) return;
1122 detach(); 1123 detach();
1123 mData->empty = false; 1124 mData->empty = false;
1124 mData->revision = QDateTime( revision.date(), 1125 mData->revision = QDateTime( revision.date(),
1125 QTime (revision.time().hour(), 1126 QTime (revision.time().hour(),
1126 revision.time().minute(), 1127 revision.time().minute(),
1127 revision.time().second())); 1128 revision.time().second()));
1128} 1129}
1129 1130
1130QDateTime Addressee::revision() const 1131QDateTime Addressee::revision() const
1131{ 1132{
1132 return mData->revision; 1133 return mData->revision;
1133} 1134}
1134 1135
1135QString Addressee::revisionLabel() 1136QString Addressee::revisionLabel()
1136{ 1137{
1137 return i18n("Revision Date"); 1138 return i18n("Revision Date");
1138} 1139}
1139 1140
1140 1141
1141void Addressee::setSortString( const QString &sortString ) 1142void Addressee::setSortString( const QString &sortString )
1142{ 1143{
1143 if ( sortString == mData->sortString ) return; 1144 if ( sortString == mData->sortString ) return;
1144 detach(); 1145 detach();
1145 mData->empty = false; 1146 mData->empty = false;
1146 mData->sortString = sortString; 1147 mData->sortString = sortString;
1147} 1148}
1148 1149
1149QString Addressee::sortString() const 1150QString Addressee::sortString() const
1150{ 1151{
1151 return mData->sortString; 1152 return mData->sortString;
1152} 1153}
1153 1154
1154QString Addressee::sortStringLabel() 1155QString Addressee::sortStringLabel()
1155{ 1156{
1156 return i18n("Sort String"); 1157 return i18n("Sort String");
1157} 1158}
1158 1159
1159 1160
1160void Addressee::setUrl( const KURL &url ) 1161void Addressee::setUrl( const KURL &url )
1161{ 1162{
1162 if ( url == mData->url ) return; 1163 if ( url == mData->url ) return;
1163 detach(); 1164 detach();
1164 mData->empty = false; 1165 mData->empty = false;
1165 mData->url = url; 1166 mData->url = url;
1166} 1167}
1167 1168
1168KURL Addressee::url() const 1169KURL Addressee::url() const
1169{ 1170{
1170 return mData->url; 1171 return mData->url;
1171} 1172}
1172 1173
1173QString Addressee::urlLabel() 1174QString Addressee::urlLabel()
1174{ 1175{
1175 return i18n("URL"); 1176 return i18n("URL");
1176} 1177}
1177 1178
1178 1179
1179void Addressee::setSecrecy( const Secrecy &secrecy ) 1180void Addressee::setSecrecy( const Secrecy &secrecy )
1180{ 1181{
1181 if ( secrecy == mData->secrecy ) return; 1182 if ( secrecy == mData->secrecy ) return;
1182 detach(); 1183 detach();
1183 mData->empty = false; 1184 mData->empty = false;
1184 mData->secrecy = secrecy; 1185 mData->secrecy = secrecy;
1185} 1186}
1186 1187
1187Secrecy Addressee::secrecy() const 1188Secrecy Addressee::secrecy() const
1188{ 1189{
1189 return mData->secrecy; 1190 return mData->secrecy;
1190} 1191}
1191 1192
1192QString Addressee::secrecyLabel() 1193QString Addressee::secrecyLabel()
1193{ 1194{
1194 return i18n("Security Class"); 1195 return i18n("Security Class");
1195} 1196}
1196 1197
1197 1198
1198void Addressee::setLogo( const Picture &logo ) 1199void Addressee::setLogo( const Picture &logo )
1199{ 1200{
1200 if ( logo == mData->logo ) return; 1201 if ( logo == mData->logo ) return;
1201 detach(); 1202 detach();
1202 mData->empty = false; 1203 mData->empty = false;
1203 mData->logo = logo; 1204 mData->logo = logo;
1204} 1205}
1205 1206
1206Picture Addressee::logo() const 1207Picture Addressee::logo() const
1207{ 1208{
1208 return mData->logo; 1209 return mData->logo;
1209} 1210}
1210 1211
1211QString Addressee::logoLabel() 1212QString Addressee::logoLabel()
1212{ 1213{
1213 return i18n("Logo"); 1214 return i18n("Logo");
1214} 1215}
1215 1216
1216 1217
1217void Addressee::setPhoto( const Picture &photo ) 1218void Addressee::setPhoto( const Picture &photo )
1218{ 1219{
1219 if ( photo == mData->photo ) return; 1220 if ( photo == mData->photo ) return;
1220 detach(); 1221 detach();
1221 mData->empty = false; 1222 mData->empty = false;
1222 mData->photo = photo; 1223 mData->photo = photo;
1223} 1224}
1224 1225
1225Picture Addressee::photo() const 1226Picture Addressee::photo() const
1226{ 1227{
1227 return mData->photo; 1228 return mData->photo;
1228} 1229}
1229 1230
1230QString Addressee::photoLabel() 1231QString Addressee::photoLabel()
1231{ 1232{
1232 return i18n("Photo"); 1233 return i18n("Photo");
1233} 1234}
1234 1235
1235 1236
1236void Addressee::setSound( const Sound &sound ) 1237void Addressee::setSound( const Sound &sound )
1237{ 1238{
1238 if ( sound == mData->sound ) return; 1239 if ( sound == mData->sound ) return;
1239 detach(); 1240 detach();
1240 mData->empty = false; 1241 mData->empty = false;
1241 mData->sound = sound; 1242 mData->sound = sound;
1242} 1243}
1243 1244
1244Sound Addressee::sound() const 1245Sound Addressee::sound() const
1245{ 1246{
1246 return mData->sound; 1247 return mData->sound;
1247} 1248}
1248 1249
1249QString Addressee::soundLabel() 1250QString Addressee::soundLabel()
1250{ 1251{
1251 return i18n("Sound"); 1252 return i18n("Sound");
1252} 1253}
1253 1254
1254 1255
1255void Addressee::setAgent( const Agent &agent ) 1256void Addressee::setAgent( const Agent &agent )
1256{ 1257{
1257 if ( agent == mData->agent ) return; 1258 if ( agent == mData->agent ) return;
1258 detach(); 1259 detach();
1259 mData->empty = false; 1260 mData->empty = false;
1260 mData->agent = agent; 1261 mData->agent = agent;
1261} 1262}
1262 1263
1263Agent Addressee::agent() const 1264Agent Addressee::agent() const
1264{ 1265{
1265 return mData->agent; 1266 return mData->agent;
1266} 1267}
1267 1268
1268QString Addressee::agentLabel() 1269QString Addressee::agentLabel()
1269{ 1270{
1270 return i18n("Agent"); 1271 return i18n("Agent");
1271} 1272}
1272 1273
1273 1274
1274 1275
1275void Addressee::setNameFromString( const QString &str ) 1276void Addressee::setNameFromString( const QString &str )
1276{ 1277{
1277 setFormattedName( str ); 1278 setFormattedName( str );
1278 setName( str ); 1279 setName( str );
1279 1280
1280 static bool first = true; 1281 static bool first = true;
1281 static QStringList titles; 1282 static QStringList titles;
1282 static QStringList suffixes; 1283 static QStringList suffixes;
1283 static QStringList prefixes; 1284 static QStringList prefixes;
1284 1285
1285 if ( first ) { 1286 if ( first ) {
1286 first = false; 1287 first = false;
1287 titles += i18n( "Dr." ); 1288 titles += i18n( "Dr." );
1288 titles += i18n( "Miss" ); 1289 titles += i18n( "Miss" );
1289 titles += i18n( "Mr." ); 1290 titles += i18n( "Mr." );
1290 titles += i18n( "Mrs." ); 1291 titles += i18n( "Mrs." );
1291 titles += i18n( "Ms." ); 1292 titles += i18n( "Ms." );
1292 titles += i18n( "Prof." ); 1293 titles += i18n( "Prof." );
1293 1294
1294 suffixes += i18n( "I" ); 1295 suffixes += i18n( "I" );
1295 suffixes += i18n( "II" ); 1296 suffixes += i18n( "II" );
1296 suffixes += i18n( "III" ); 1297 suffixes += i18n( "III" );
1297 suffixes += i18n( "Jr." ); 1298 suffixes += i18n( "Jr." );
1298 suffixes += i18n( "Sr." ); 1299 suffixes += i18n( "Sr." );
1299 1300
1300 prefixes += "van"; 1301 prefixes += "van";
1301 prefixes += "von"; 1302 prefixes += "von";
1302 prefixes += "de"; 1303 prefixes += "de";
1303 1304
1304 KConfig config( locateLocal( "config", "kabcrc") ); 1305 KConfig config( locateLocal( "config", "kabcrc") );
1305 config.setGroup( "General" ); 1306 config.setGroup( "General" );
1306 titles += config.readListEntry( "Prefixes" ); 1307 titles += config.readListEntry( "Prefixes" );
1307 titles.remove( "" ); 1308 titles.remove( "" );
1308 prefixes += config.readListEntry( "Inclusions" ); 1309 prefixes += config.readListEntry( "Inclusions" );
1309 prefixes.remove( "" ); 1310 prefixes.remove( "" );
1310 suffixes += config.readListEntry( "Suffixes" ); 1311 suffixes += config.readListEntry( "Suffixes" );
1311 suffixes.remove( "" ); 1312 suffixes.remove( "" );
1312 } 1313 }
1313 1314
1314 // clear all name parts 1315 // clear all name parts
1315 setPrefix( "" ); 1316 setPrefix( "" );
1316 setGivenName( "" ); 1317 setGivenName( "" );
1317 setAdditionalName( "" ); 1318 setAdditionalName( "" );
1318 setFamilyName( "" ); 1319 setFamilyName( "" );
1319 setSuffix( "" ); 1320 setSuffix( "" );
1320 1321
1321 if ( str.isEmpty() ) 1322 if ( str.isEmpty() )
1322 return; 1323 return;
1323 1324
1324 int i = str.find(','); 1325 int i = str.find(',');
1325 if( i < 0 ) { 1326 if( i < 0 ) {
1326 QStringList parts = QStringList::split( " ", str ); 1327 QStringList parts = QStringList::split( " ", str );
1327 int leftOffset = 0; 1328 int leftOffset = 0;
1328 int rightOffset = parts.count() - 1; 1329 int rightOffset = parts.count() - 1;
1329 1330
1330 QString suffix; 1331 QString suffix;
1331 while ( rightOffset >= 0 ) { 1332 while ( rightOffset >= 0 ) {
1332 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1333 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1333 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1334 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1334 rightOffset--; 1335 rightOffset--;
1335 } else 1336 } else
1336 break; 1337 break;
1337 } 1338 }
1338 setSuffix( suffix ); 1339 setSuffix( suffix );
1339 1340
1340 if ( rightOffset < 0 ) 1341 if ( rightOffset < 0 )
1341 return; 1342 return;
1342 1343
1343 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1344 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1344 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1345 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1345 rightOffset--; 1346 rightOffset--;
1346 } else 1347 } else
1347 setFamilyName( parts[ rightOffset ] ); 1348 setFamilyName( parts[ rightOffset ] );
1348 1349
1349 QString prefix; 1350 QString prefix;
1350 while ( leftOffset < rightOffset ) { 1351 while ( leftOffset < rightOffset ) {
1351 if ( titles.contains( parts[ leftOffset ] ) ) { 1352 if ( titles.contains( parts[ leftOffset ] ) ) {
1352 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1353 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1353 leftOffset++; 1354 leftOffset++;
1354 } else 1355 } else
1355 break; 1356 break;
1356 } 1357 }
1357 setPrefix( prefix ); 1358 setPrefix( prefix );
1358 1359
1359 if ( leftOffset < rightOffset ) { 1360 if ( leftOffset < rightOffset ) {
1360 setGivenName( parts[ leftOffset ] ); 1361 setGivenName( parts[ leftOffset ] );
1361 leftOffset++; 1362 leftOffset++;
1362 } 1363 }
1363 1364
1364 QString additionalName; 1365 QString additionalName;
1365 while ( leftOffset < rightOffset ) { 1366 while ( leftOffset < rightOffset ) {
1366 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1367 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1367 leftOffset++; 1368 leftOffset++;
1368 } 1369 }
1369 setAdditionalName( additionalName ); 1370 setAdditionalName( additionalName );
1370 } else { 1371 } else {
1371 QString part1 = str.left( i ); 1372 QString part1 = str.left( i );
1372 QString part2 = str.mid( i + 1 ); 1373 QString part2 = str.mid( i + 1 );
1373 1374
1374 QStringList parts = QStringList::split( " ", part1 ); 1375 QStringList parts = QStringList::split( " ", part1 );
1375 int leftOffset = 0; 1376 int leftOffset = 0;
1376 int rightOffset = parts.count() - 1; 1377 int rightOffset = parts.count() - 1;
1377 1378
1378 QString suffix; 1379 QString suffix;
1379 while ( rightOffset >= 0 ) { 1380 while ( rightOffset >= 0 ) {
1380 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1381 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1381 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1382 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1382 rightOffset--; 1383 rightOffset--;
1383 } else 1384 } else
1384 break; 1385 break;
1385 } 1386 }
1386 setSuffix( suffix ); 1387 setSuffix( suffix );
1387 1388
1388 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1389 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1389 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1390 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1390 rightOffset--; 1391 rightOffset--;
1391 } else 1392 } else
1392 setFamilyName( parts[ rightOffset ] ); 1393 setFamilyName( parts[ rightOffset ] );
1393 1394
1394 QString prefix; 1395 QString prefix;
1395 while ( leftOffset < rightOffset ) { 1396 while ( leftOffset < rightOffset ) {
1396 if ( titles.contains( parts[ leftOffset ] ) ) { 1397 if ( titles.contains( parts[ leftOffset ] ) ) {
1397 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1398 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1398 leftOffset++; 1399 leftOffset++;
1399 } else 1400 } else
1400 break; 1401 break;
1401 } 1402 }
1402 1403
1403 parts = QStringList::split( " ", part2 ); 1404 parts = QStringList::split( " ", part2 );
1404 1405
1405 leftOffset = 0; 1406 leftOffset = 0;
1406 rightOffset = parts.count(); 1407 rightOffset = parts.count();
1407 1408
1408 while ( leftOffset < rightOffset ) { 1409 while ( leftOffset < rightOffset ) {
1409 if ( titles.contains( parts[ leftOffset ] ) ) { 1410 if ( titles.contains( parts[ leftOffset ] ) ) {
1410 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1411 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1411 leftOffset++; 1412 leftOffset++;
1412 } else 1413 } else
1413 break; 1414 break;
1414 } 1415 }
1415 setPrefix( prefix ); 1416 setPrefix( prefix );
1416 1417
1417 if ( leftOffset < rightOffset ) { 1418 if ( leftOffset < rightOffset ) {
1418 setGivenName( parts[ leftOffset ] ); 1419 setGivenName( parts[ leftOffset ] );
1419 leftOffset++; 1420 leftOffset++;
1420 } 1421 }
1421 1422
1422 QString additionalName; 1423 QString additionalName;
1423 while ( leftOffset < rightOffset ) { 1424 while ( leftOffset < rightOffset ) {
1424 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1425 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1425 leftOffset++; 1426 leftOffset++;
1426 } 1427 }
1427 setAdditionalName( additionalName ); 1428 setAdditionalName( additionalName );
1428 } 1429 }
1429} 1430}
1430 1431
1431QString Addressee::realName() const 1432QString Addressee::realName() const
1432{ 1433{
1433 if ( !formattedName().isEmpty() ) 1434 if ( !formattedName().isEmpty() )
1434 return formattedName(); 1435 return formattedName();
1435 1436
1436 QString n = assembledName(); 1437 QString n = assembledName();
1437 1438
1438 if ( n.isEmpty() ) 1439 if ( n.isEmpty() )
1439 n = name(); 1440 n = name();
1440 1441
1441 return n; 1442 return n;
1442} 1443}
1443 1444
1444QString Addressee::assembledName() const 1445QString Addressee::assembledName() const
1445{ 1446{
1446 QString name = prefix() + " " + givenName() + " " + additionalName() + " " + 1447 QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
1447 familyName() + " " + suffix(); 1448 familyName() + " " + suffix();
1448 1449
1449 return name.simplifyWhiteSpace(); 1450 return name.simplifyWhiteSpace();
1450} 1451}
1451 1452
1452QString Addressee::fullEmail( const QString &email ) const 1453QString Addressee::fullEmail( const QString &email ) const
1453{ 1454{
1454 QString e; 1455 QString e;
1455 if ( email.isNull() ) { 1456 if ( email.isNull() ) {
1456 e = preferredEmail(); 1457 e = preferredEmail();
1457 } else { 1458 } else {
1458 e = email; 1459 e = email;
1459 } 1460 }
1460 if ( e.isEmpty() ) return QString::null; 1461 if ( e.isEmpty() ) return QString::null;
1461 1462
1462 QString text; 1463 QString text;
1463 if ( realName().isEmpty() ) 1464 if ( realName().isEmpty() )
1464 text = e; 1465 text = e;
1465 else 1466 else
1466 text = assembledName() + " <" + e + ">"; 1467 text = assembledName() + " <" + e + ">";
1467 1468
1468 return text; 1469 return text;
1469} 1470}
1470 1471
1471void Addressee::insertEmail( const QString &email, bool preferred ) 1472void Addressee::insertEmail( const QString &email, bool preferred )
1472{ 1473{
1473 detach(); 1474 detach();
1474 1475
1475 QStringList::Iterator it = mData->emails.find( email ); 1476 QStringList::Iterator it = mData->emails.find( email );
1476 1477
1477 if ( it != mData->emails.end() ) { 1478 if ( it != mData->emails.end() ) {
1478 if ( !preferred || it == mData->emails.begin() ) return; 1479 if ( !preferred || it == mData->emails.begin() ) return;
1479 mData->emails.remove( it ); 1480 mData->emails.remove( it );
1480 mData->emails.prepend( email ); 1481 mData->emails.prepend( email );
1481 } else { 1482 } else {
1482 if ( preferred ) { 1483 if ( preferred ) {
1483 mData->emails.prepend( email ); 1484 mData->emails.prepend( email );
1484 } else { 1485 } else {
1485 mData->emails.append( email ); 1486 mData->emails.append( email );
1486 } 1487 }
1487 } 1488 }
1488} 1489}
1489 1490
1490void Addressee::removeEmail( const QString &email ) 1491void Addressee::removeEmail( const QString &email )
1491{ 1492{
1492 detach(); 1493 detach();
1493 1494
1494 QStringList::Iterator it = mData->emails.find( email ); 1495 QStringList::Iterator it = mData->emails.find( email );
1495 if ( it == mData->emails.end() ) return; 1496 if ( it == mData->emails.end() ) return;
1496 1497
1497 mData->emails.remove( it ); 1498 mData->emails.remove( it );
1498} 1499}
1499 1500
1500QString Addressee::preferredEmail() const 1501QString Addressee::preferredEmail() const
1501{ 1502{
1502 if ( mData->emails.count() == 0 ) return QString::null; 1503 if ( mData->emails.count() == 0 ) return QString::null;
1503 else return mData->emails.first(); 1504 else return mData->emails.first();
1504} 1505}
1505 1506
1506QStringList Addressee::emails() const 1507QStringList Addressee::emails() const
1507{ 1508{
1508 return mData->emails; 1509 return mData->emails;
1509} 1510}
1510void Addressee::setEmails( const QStringList& emails ) { 1511void Addressee::setEmails( const QStringList& emails ) {
1511 detach(); 1512 detach();
1512 mData->emails = emails; 1513 mData->emails = emails;
1513} 1514}
1514void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1515void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1515{ 1516{
1516 detach(); 1517 detach();
1517 mData->empty = false; 1518 mData->empty = false;
1518 1519
1519 PhoneNumber::List::Iterator it; 1520 PhoneNumber::List::Iterator it;
1520 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1521 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1521 if ( (*it).id() == phoneNumber.id() ) { 1522 if ( (*it).id() == phoneNumber.id() ) {
1522 *it = phoneNumber; 1523 *it = phoneNumber;
1523 return; 1524 return;
1524 } 1525 }
1525 } 1526 }
1526 mData->phoneNumbers.append( phoneNumber ); 1527 mData->phoneNumbers.append( phoneNumber );
1527} 1528}
1528 1529
1529void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1530void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1530{ 1531{
1531 detach(); 1532 detach();
1532 1533
1533 PhoneNumber::List::Iterator it; 1534 PhoneNumber::List::Iterator it;
1534 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1535 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1535 if ( (*it).id() == phoneNumber.id() ) { 1536 if ( (*it).id() == phoneNumber.id() ) {
1536 mData->phoneNumbers.remove( it ); 1537 mData->phoneNumbers.remove( it );
1537 return; 1538 return;
1538 } 1539 }
1539 } 1540 }
1540} 1541}
1541 1542
1542PhoneNumber Addressee::phoneNumber( int type ) const 1543PhoneNumber Addressee::phoneNumber( int type ) const
1543{ 1544{
1544 PhoneNumber phoneNumber( "", type ); 1545 PhoneNumber phoneNumber( "", type );
1545 PhoneNumber::List::ConstIterator it; 1546 PhoneNumber::List::ConstIterator it;
1546 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1547 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1547 if ( matchBinaryPatternP( (*it).type(), type ) ) { 1548 if ( matchBinaryPatternP( (*it).type(), type ) ) {
1548 if ( (*it).type() & PhoneNumber::Pref ) 1549 if ( (*it).type() & PhoneNumber::Pref )
1549 return (*it); 1550 return (*it);
1550 else if ( phoneNumber.number().isEmpty() ) 1551 else if ( phoneNumber.number().isEmpty() )
1551 phoneNumber = (*it); 1552 phoneNumber = (*it);
1552 } 1553 }
1553 } 1554 }
1554 1555
1555 return phoneNumber; 1556 return phoneNumber;
1556} 1557}
1557 1558
1558PhoneNumber::List Addressee::phoneNumbers() const 1559PhoneNumber::List Addressee::phoneNumbers() const
1559{ 1560{
1560 return mData->phoneNumbers; 1561 return mData->phoneNumbers;
1561} 1562}
1562 1563
1563PhoneNumber::List Addressee::phoneNumbers( int type ) const 1564PhoneNumber::List Addressee::phoneNumbers( int type ) const
1564{ 1565{
1565 PhoneNumber::List list; 1566 PhoneNumber::List list;
1566 1567
1567 PhoneNumber::List::ConstIterator it; 1568 PhoneNumber::List::ConstIterator it;
1568 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1569 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1569 if ( matchBinaryPattern( (*it).type(), type ) ) { 1570 if ( matchBinaryPattern( (*it).type(), type ) ) {
1570 list.append( *it ); 1571 list.append( *it );
1571 } 1572 }
1572 } 1573 }
1573 return list; 1574 return list;
1574} 1575}
1575 1576
1576PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1577PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1577{ 1578{
1578 PhoneNumber::List::ConstIterator it; 1579 PhoneNumber::List::ConstIterator it;
1579 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1580 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1580 if ( (*it).id() == id ) { 1581 if ( (*it).id() == id ) {
1581 return *it; 1582 return *it;
1582 } 1583 }
1583 } 1584 }
1584 return PhoneNumber(); 1585 return PhoneNumber();
1585} 1586}
1586 1587
1587void Addressee::insertKey( const Key &key ) 1588void Addressee::insertKey( const Key &key )
1588{ 1589{
1589 detach(); 1590 detach();
1590 mData->empty = false; 1591 mData->empty = false;
1591 1592
1592 Key::List::Iterator it; 1593 Key::List::Iterator it;
1593 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1594 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1594 if ( (*it).id() == key.id() ) { 1595 if ( (*it).id() == key.id() ) {
1595 *it = key; 1596 *it = key;
1596 return; 1597 return;
1597 } 1598 }
1598 } 1599 }
1599 mData->keys.append( key ); 1600 mData->keys.append( key );
1600} 1601}
1601 1602
1602void Addressee::removeKey( const Key &key ) 1603void Addressee::removeKey( const Key &key )
1603{ 1604{
1604 detach(); 1605 detach();
1605 1606
1606 Key::List::Iterator it; 1607 Key::List::Iterator it;
1607 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1608 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1608 if ( (*it).id() == key.id() ) { 1609 if ( (*it).id() == key.id() ) {
1609 mData->keys.remove( key ); 1610 mData->keys.remove( key );
1610 return; 1611 return;
1611 } 1612 }
1612 } 1613 }
1613} 1614}
1614 1615
1615Key Addressee::key( int type, QString customTypeString ) const 1616Key Addressee::key( int type, QString customTypeString ) const
1616{ 1617{
1617 Key::List::ConstIterator it; 1618 Key::List::ConstIterator it;
1618 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1619 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1619 if ( (*it).type() == type ) { 1620 if ( (*it).type() == type ) {
1620 if ( type == Key::Custom ) { 1621 if ( type == Key::Custom ) {
1621 if ( customTypeString.isEmpty() ) { 1622 if ( customTypeString.isEmpty() ) {
1622 return *it; 1623 return *it;
1623 } else { 1624 } else {
1624 if ( (*it).customTypeString() == customTypeString ) 1625 if ( (*it).customTypeString() == customTypeString )
1625 return (*it); 1626 return (*it);
1626 } 1627 }
1627 } else { 1628 } else {
1628 return *it; 1629 return *it;
1629 } 1630 }
1630 } 1631 }
1631 } 1632 }
1632 return Key( QString(), type ); 1633 return Key( QString(), type );
1633} 1634}
1634void Addressee::setKeys( const Key::List& list ) { 1635void Addressee::setKeys( const Key::List& list ) {
1635 detach(); 1636 detach();
1636 mData->keys = list; 1637 mData->keys = list;
1637} 1638}
1638 1639
1639Key::List Addressee::keys() const 1640Key::List Addressee::keys() const
1640{ 1641{
1641 return mData->keys; 1642 return mData->keys;
1642} 1643}
1643 1644
1644Key::List Addressee::keys( int type, QString customTypeString ) const 1645Key::List Addressee::keys( int type, QString customTypeString ) const
1645{ 1646{
1646 Key::List list; 1647 Key::List list;
1647 1648
1648 Key::List::ConstIterator it; 1649 Key::List::ConstIterator it;
1649 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1650 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1650 if ( (*it).type() == type ) { 1651 if ( (*it).type() == type ) {
1651 if ( type == Key::Custom ) { 1652 if ( type == Key::Custom ) {
1652 if ( customTypeString.isEmpty() ) { 1653 if ( customTypeString.isEmpty() ) {
1653 list.append(*it); 1654 list.append(*it);
1654 } else { 1655 } else {
1655 if ( (*it).customTypeString() == customTypeString ) 1656 if ( (*it).customTypeString() == customTypeString )
1656 list.append(*it); 1657 list.append(*it);
1657 } 1658 }
1658 } else { 1659 } else {
1659 list.append(*it); 1660 list.append(*it);
1660 } 1661 }
1661 } 1662 }
1662 } 1663 }
1663 return list; 1664 return list;
1664} 1665}
1665 1666
1666Key Addressee::findKey( const QString &id ) const 1667Key Addressee::findKey( const QString &id ) const
1667{ 1668{
1668 Key::List::ConstIterator it; 1669 Key::List::ConstIterator it;
1669 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1670 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1670 if ( (*it).id() == id ) { 1671 if ( (*it).id() == id ) {
1671 return *it; 1672 return *it;
1672 } 1673 }
1673 } 1674 }
1674 return Key(); 1675 return Key();
1675} 1676}
1676 1677
1677QString Addressee::asString() const 1678QString Addressee::asString() const
1678{ 1679{
1679 return "Smith, agent Smith..."; 1680 return "Smith, agent Smith...";
1680} 1681}
1681 1682
1682void Addressee::dump() const 1683void Addressee::dump() const
1683{ 1684{
1684 return; 1685 return;
1685 kdDebug(5700) << "Addressee {" << endl; 1686 kdDebug(5700) << "Addressee {" << endl;
1686 1687
1687 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1688 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1688 1689
1689 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1690 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1690 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1691 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1691 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1692 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1692 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1693 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1693 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1694 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1694 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1695 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1695 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1696 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
1696 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; 1697 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
1697 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; 1698 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
1698 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; 1699 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
1699 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; 1700 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
1700 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; 1701 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
1701 kdDebug(5700) << " Title: '" << title() << "'" << endl; 1702 kdDebug(5700) << " Title: '" << title() << "'" << endl;
1702 kdDebug(5700) << " Role: '" << role() << "'" << endl; 1703 kdDebug(5700) << " Role: '" << role() << "'" << endl;
1703 kdDebug(5700) << " Organization: '" << organization() << "'" << endl; 1704 kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
1704 kdDebug(5700) << " Note: '" << note() << "'" << endl; 1705 kdDebug(5700) << " Note: '" << note() << "'" << endl;
1705 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; 1706 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
1706 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; 1707 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
1707 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; 1708 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
1708 kdDebug(5700) << " Url: '" << url().url() << "'" << endl; 1709 kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
1709 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; 1710 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
1710 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; 1711 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
1711 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; 1712 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
1712 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; 1713 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
1713 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; 1714 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
1714 1715
1715 kdDebug(5700) << " Emails {" << endl; 1716 kdDebug(5700) << " Emails {" << endl;
1716 QStringList e = emails(); 1717 QStringList e = emails();
1717 QStringList::ConstIterator it; 1718 QStringList::ConstIterator it;
1718 for( it = e.begin(); it != e.end(); ++it ) { 1719 for( it = e.begin(); it != e.end(); ++it ) {
1719 kdDebug(5700) << " " << (*it) << endl; 1720 kdDebug(5700) << " " << (*it) << endl;
1720 } 1721 }
1721 kdDebug(5700) << " }" << endl; 1722 kdDebug(5700) << " }" << endl;
1722 1723
1723 kdDebug(5700) << " PhoneNumbers {" << endl; 1724 kdDebug(5700) << " PhoneNumbers {" << endl;
1724 PhoneNumber::List p = phoneNumbers(); 1725 PhoneNumber::List p = phoneNumbers();
1725 PhoneNumber::List::ConstIterator it2; 1726 PhoneNumber::List::ConstIterator it2;
1726 for( it2 = p.begin(); it2 != p.end(); ++it2 ) { 1727 for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1727 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; 1728 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
1728 } 1729 }
1729 kdDebug(5700) << " }" << endl; 1730 kdDebug(5700) << " }" << endl;
1730 1731
1731 Address::List a = addresses(); 1732 Address::List a = addresses();
1732 Address::List::ConstIterator it3; 1733 Address::List::ConstIterator it3;
1733 for( it3 = a.begin(); it3 != a.end(); ++it3 ) { 1734 for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1734 (*it3).dump(); 1735 (*it3).dump();
1735 } 1736 }
1736 1737
1737 kdDebug(5700) << " Keys {" << endl; 1738 kdDebug(5700) << " Keys {" << endl;
1738 Key::List k = keys(); 1739 Key::List k = keys();
1739 Key::List::ConstIterator it4; 1740 Key::List::ConstIterator it4;
1740 for( it4 = k.begin(); it4 != k.end(); ++it4 ) { 1741 for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1741 kdDebug(5700) << " Type: " << int((*it4).type()) << 1742 kdDebug(5700) << " Type: " << int((*it4).type()) <<
1742 " Key: " << (*it4).textData() << 1743 " Key: " << (*it4).textData() <<
1743 " CustomString: " << (*it4).customTypeString() << endl; 1744 " CustomString: " << (*it4).customTypeString() << endl;
1744 } 1745 }
1745 kdDebug(5700) << " }" << endl; 1746 kdDebug(5700) << " }" << endl;
1746 1747
1747 kdDebug(5700) << "}" << endl; 1748 kdDebug(5700) << "}" << endl;
1748} 1749}
1749 1750
1750 1751
1751void Addressee::insertAddress( const Address &address ) 1752void Addressee::insertAddress( const Address &address )
1752{ 1753{
1753 detach(); 1754 detach();
1754 mData->empty = false; 1755 mData->empty = false;
1755 1756
1756 Address::List::Iterator it; 1757 Address::List::Iterator it;
1757 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1758 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1758 if ( (*it).id() == address.id() ) { 1759 if ( (*it).id() == address.id() ) {
1759 *it = address; 1760 *it = address;
1760 return; 1761 return;
1761 } 1762 }
1762 } 1763 }
1763 mData->addresses.append( address ); 1764 mData->addresses.append( address );
1764} 1765}
1765 1766
1766void Addressee::removeAddress( const Address &address ) 1767void Addressee::removeAddress( const Address &address )
1767{ 1768{
1768 detach(); 1769 detach();
1769 1770
1770 Address::List::Iterator it; 1771 Address::List::Iterator it;
1771 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1772 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1772 if ( (*it).id() == address.id() ) { 1773 if ( (*it).id() == address.id() ) {
1773 mData->addresses.remove( it ); 1774 mData->addresses.remove( it );
1774 return; 1775 return;
1775 } 1776 }
1776 } 1777 }
1777} 1778}
1778 1779
1779Address Addressee::address( int type ) const 1780Address Addressee::address( int type ) const
1780{ 1781{
1781 Address address( type ); 1782 Address address( type );
1782 Address::List::ConstIterator it; 1783 Address::List::ConstIterator it;
1783 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1784 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1784 if ( matchBinaryPatternA( (*it).type(), type ) ) { 1785 if ( matchBinaryPatternA( (*it).type(), type ) ) {
1785 if ( (*it).type() & Address::Pref ) 1786 if ( (*it).type() & Address::Pref )
1786 return (*it); 1787 return (*it);
1787 else if ( address.isEmpty() ) 1788 else if ( address.isEmpty() )
1788 address = (*it); 1789 address = (*it);
1789 } 1790 }
1790 } 1791 }
1791 1792
1792 return address; 1793 return address;
1793} 1794}
1794 1795
1795Address::List Addressee::addresses() const 1796Address::List Addressee::addresses() const
1796{ 1797{
1797 return mData->addresses; 1798 return mData->addresses;
1798} 1799}
1799 1800
1800Address::List Addressee::addresses( int type ) const 1801Address::List Addressee::addresses( int type ) const
1801{ 1802{
1802 Address::List list; 1803 Address::List list;
1803 1804
1804 Address::List::ConstIterator it; 1805 Address::List::ConstIterator it;
1805 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1806 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1806 if ( matchBinaryPattern( (*it).type(), type ) ) { 1807 if ( matchBinaryPattern( (*it).type(), type ) ) {
1807 list.append( *it ); 1808 list.append( *it );
1808 } 1809 }
1809 } 1810 }
1810 1811
1811 return list; 1812 return list;
1812} 1813}
1813 1814
1814Address Addressee::findAddress( const QString &id ) const 1815Address Addressee::findAddress( const QString &id ) const
1815{ 1816{
1816 Address::List::ConstIterator it; 1817 Address::List::ConstIterator it;
1817 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1818 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1818 if ( (*it).id() == id ) { 1819 if ( (*it).id() == id ) {
1819 return *it; 1820 return *it;
1820 } 1821 }
1821 } 1822 }
1822 return Address(); 1823 return Address();
1823} 1824}
1824 1825
1825void Addressee::insertCategory( const QString &c ) 1826void Addressee::insertCategory( const QString &c )
1826{ 1827{
1827 detach(); 1828 detach();
1828 mData->empty = false; 1829 mData->empty = false;
1829 1830
1830 if ( mData->categories.contains( c ) ) return; 1831 if ( mData->categories.contains( c ) ) return;
1831 1832
1832 mData->categories.append( c ); 1833 mData->categories.append( c );
1833} 1834}
1834 1835
1835void Addressee::removeCategory( const QString &c ) 1836void Addressee::removeCategory( const QString &c )
1836{ 1837{
1837 detach(); 1838 detach();
1838 1839
1839 QStringList::Iterator it = mData->categories.find( c ); 1840 QStringList::Iterator it = mData->categories.find( c );
1840 if ( it == mData->categories.end() ) return; 1841 if ( it == mData->categories.end() ) return;
1841 1842
1842 mData->categories.remove( it ); 1843 mData->categories.remove( it );
1843} 1844}
1844 1845
1845bool Addressee::hasCategory( const QString &c ) const 1846bool Addressee::hasCategory( const QString &c ) const
1846{ 1847{
1847 return ( mData->categories.contains( c ) ); 1848 return ( mData->categories.contains( c ) );
1848} 1849}
1849 1850
1850void Addressee::setCategories( const QStringList &c ) 1851void Addressee::setCategories( const QStringList &c )
1851{ 1852{
1852 detach(); 1853 detach();
1853 mData->empty = false; 1854 mData->empty = false;
1854 1855
1855 mData->categories = c; 1856 mData->categories = c;
1856} 1857}
1857 1858
1858QStringList Addressee::categories() const 1859QStringList Addressee::categories() const
1859{ 1860{
1860 return mData->categories; 1861 return mData->categories;
1861} 1862}
1862 1863
1863void Addressee::insertCustom( const QString &app, const QString &name, 1864void Addressee::insertCustom( const QString &app, const QString &name,
1864 const QString &value ) 1865 const QString &value )
1865{ 1866{
1866 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; 1867 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return;
1867 1868
1868 detach(); 1869 detach();
1869 mData->empty = false; 1870 mData->empty = false;
1870 1871
1871 QString qualifiedName = app + "-" + name + ":"; 1872 QString qualifiedName = app + "-" + name + ":";
1872 1873
1873 QStringList::Iterator it; 1874 QStringList::Iterator it;
1874 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1875 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1875 if ( (*it).startsWith( qualifiedName ) ) { 1876 if ( (*it).startsWith( qualifiedName ) ) {
1876 (*it) = qualifiedName + value; 1877 (*it) = qualifiedName + value;
1877 return; 1878 return;
1878 } 1879 }
1879 } 1880 }
1880 mData->custom.append( qualifiedName + value ); 1881 mData->custom.append( qualifiedName + value );
1881} 1882}
1882 1883
1883void Addressee::removeCustom( const QString &app, const QString &name) 1884void Addressee::removeCustom( const QString &app, const QString &name)
1884{ 1885{
1885 detach(); 1886 detach();
1886 1887
1887 QString qualifiedName = app + "-" + name + ":"; 1888 QString qualifiedName = app + "-" + name + ":";
1888 1889
1889 QStringList::Iterator it; 1890 QStringList::Iterator it;
1890 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1891 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1891 if ( (*it).startsWith( qualifiedName ) ) { 1892 if ( (*it).startsWith( qualifiedName ) ) {
1892 mData->custom.remove( it ); 1893 mData->custom.remove( it );
1893 return; 1894 return;
1894 } 1895 }
1895 } 1896 }
1896} 1897}
1897 1898
1898QString Addressee::custom( const QString &app, const QString &name ) const 1899QString Addressee::custom( const QString &app, const QString &name ) const
1899{ 1900{
1900 QString qualifiedName = app + "-" + name + ":"; 1901 QString qualifiedName = app + "-" + name + ":";
1901 QString value; 1902 QString value;
1902 1903
1903 QStringList::ConstIterator it; 1904 QStringList::ConstIterator it;
1904 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1905 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1905 if ( (*it).startsWith( qualifiedName ) ) { 1906 if ( (*it).startsWith( qualifiedName ) ) {
1906 value = (*it).mid( (*it).find( ":" ) + 1 ); 1907 value = (*it).mid( (*it).find( ":" ) + 1 );
1907 break; 1908 break;
1908 } 1909 }
1909 } 1910 }
1910 1911
1911 return value; 1912 return value;
1912} 1913}
1913 1914
1914void Addressee::setCustoms( const QStringList &l ) 1915void Addressee::setCustoms( const QStringList &l )
1915{ 1916{
1916 detach(); 1917 detach();
1917 mData->empty = false; 1918 mData->empty = false;
1918 1919
1919 mData->custom = l; 1920 mData->custom = l;
1920} 1921}
1921 1922
1922QStringList Addressee::customs() const 1923QStringList Addressee::customs() const
1923{ 1924{
1924 return mData->custom; 1925 return mData->custom;
1925} 1926}
1926 1927
1927void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, 1928void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
1928 QString &email) 1929 QString &email)
1929{ 1930{
1930 int startPos, endPos, len; 1931 int startPos, endPos, len;
1931 QString partA, partB, result; 1932 QString partA, partB, result;
1932 char endCh = '>'; 1933 char endCh = '>';
1933 1934
1934 startPos = rawEmail.find('<'); 1935 startPos = rawEmail.find('<');
1935 if (startPos < 0) 1936 if (startPos < 0)
1936 { 1937 {
1937 startPos = rawEmail.find('('); 1938 startPos = rawEmail.find('(');
1938 endCh = ')'; 1939 endCh = ')';
1939 } 1940 }
1940 if (startPos < 0) 1941 if (startPos < 0)
1941 { 1942 {
1942 // We couldn't find any separators, so we assume the whole string 1943 // We couldn't find any separators, so we assume the whole string
1943 // is the email address 1944 // is the email address
1944 email = rawEmail; 1945 email = rawEmail;
1945 fullName = ""; 1946 fullName = "";
1946 } 1947 }
1947 else 1948 else
1948 { 1949 {
1949 // We have a start position, try to find an end 1950 // We have a start position, try to find an end
1950 endPos = rawEmail.find(endCh, startPos+1); 1951 endPos = rawEmail.find(endCh, startPos+1);
1951 1952
1952 if (endPos < 0) 1953 if (endPos < 0)
1953 { 1954 {
1954 // We couldn't find the end of the email address. We can only 1955 // We couldn't find the end of the email address. We can only
1955 // assume the entire string is the email address. 1956 // assume the entire string is the email address.
1956 email = rawEmail; 1957 email = rawEmail;
1957 fullName = ""; 1958 fullName = "";
1958 } 1959 }
1959 else 1960 else
1960 { 1961 {
1961 // We have a start and end to the email address 1962 // We have a start and end to the email address
1962 1963
1963 // Grab the name part 1964 // Grab the name part
1964 fullName = rawEmail.left(startPos).stripWhiteSpace(); 1965 fullName = rawEmail.left(startPos).stripWhiteSpace();
1965 1966
1966 // grab the email part 1967 // grab the email part
1967 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); 1968 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
1968 1969
1969 // Check that we do not have any extra characters on the end of the 1970 // Check that we do not have any extra characters on the end of the
1970 // strings 1971 // strings
1971 len = fullName.length(); 1972 len = fullName.length();
1972 if (fullName[0]=='"' && fullName[len-1]=='"') 1973 if (fullName[0]=='"' && fullName[len-1]=='"')
1973 fullName = fullName.mid(1, len-2); 1974 fullName = fullName.mid(1, len-2);
1974 else if (fullName[0]=='<' && fullName[len-1]=='>') 1975 else if (fullName[0]=='<' && fullName[len-1]=='>')
1975 fullName = fullName.mid(1, len-2); 1976 fullName = fullName.mid(1, len-2);
1976 else if (fullName[0]=='(' && fullName[len-1]==')') 1977 else if (fullName[0]=='(' && fullName[len-1]==')')
1977 fullName = fullName.mid(1, len-2); 1978 fullName = fullName.mid(1, len-2);
1978 } 1979 }
1979 } 1980 }
1980} 1981}
1981 1982
1982void Addressee::setResource( Resource *resource ) 1983void Addressee::setResource( Resource *resource )
1983{ 1984{
1984 detach(); 1985 detach();
1985 mData->resource = resource; 1986 mData->resource = resource;
1986} 1987}
1987 1988
1988Resource *Addressee::resource() const 1989Resource *Addressee::resource() const
1989{ 1990{
1990 return mData->resource; 1991 return mData->resource;
1991} 1992}
1992 1993
1993//US 1994//US
1994QString Addressee::resourceLabel() 1995QString Addressee::resourceLabel()
1995{ 1996{
1996 return i18n("Resource"); 1997 return i18n("Resource");
1997} 1998}
1998 1999
1999void Addressee::setChanged( bool value ) 2000void Addressee::setChanged( bool value )
2000{ 2001{
2001 detach(); 2002 detach();
2002 mData->changed = value; 2003 mData->changed = value;
2003} 2004}
2004 2005
2005bool Addressee::changed() const 2006bool Addressee::changed() const
2006{ 2007{
2007 return mData->changed; 2008 return mData->changed;
2008} 2009}
2009 2010
2010void Addressee::setTagged( bool value ) 2011void Addressee::setTagged( bool value )
2011{ 2012{
2012 detach(); 2013 detach();
2013 mData->tagged = value; 2014 mData->tagged = value;
2014} 2015}
2015 2016
2016bool Addressee::tagged() const 2017bool Addressee::tagged() const
2017{ 2018{
2018 return mData->tagged; 2019 return mData->tagged;
2019} 2020}
2020 2021
2021QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) 2022QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
2022{ 2023{
2023 if (!a.mData) return s; 2024 if (!a.mData) return s;
2024 2025
2025 s << a.uid(); 2026 s << a.uid();
2026 2027
2027 s << a.mData->name; 2028 s << a.mData->name;
2028 s << a.mData->formattedName; 2029 s << a.mData->formattedName;
2029 s << a.mData->familyName; 2030 s << a.mData->familyName;
2030 s << a.mData->givenName; 2031 s << a.mData->givenName;
2031 s << a.mData->additionalName; 2032 s << a.mData->additionalName;
2032 s << a.mData->prefix; 2033 s << a.mData->prefix;
2033 s << a.mData->suffix; 2034 s << a.mData->suffix;
2034 s << a.mData->nickName; 2035 s << a.mData->nickName;
2035 s << a.mData->birthday; 2036 s << a.mData->birthday;
2036 s << a.mData->mailer; 2037 s << a.mData->mailer;
2037 s << a.mData->timeZone; 2038 s << a.mData->timeZone;
2038 s << a.mData->geo; 2039 s << a.mData->geo;
2039 s << a.mData->title; 2040 s << a.mData->title;
2040 s << a.mData->role; 2041 s << a.mData->role;
2041 s << a.mData->organization; 2042 s << a.mData->organization;
2042 s << a.mData->note; 2043 s << a.mData->note;
2043 s << a.mData->productId; 2044 s << a.mData->productId;
2044 s << a.mData->revision; 2045 s << a.mData->revision;
2045 s << a.mData->sortString; 2046 s << a.mData->sortString;
2046 s << a.mData->url; 2047 s << a.mData->url;
2047 s << a.mData->secrecy; 2048 s << a.mData->secrecy;
2048 s << a.mData->logo; 2049 s << a.mData->logo;
2049 s << a.mData->photo; 2050 s << a.mData->photo;
2050 s << a.mData->sound; 2051 s << a.mData->sound;
2051 s << a.mData->agent; 2052 s << a.mData->agent;
2052 s << a.mData->phoneNumbers; 2053 s << a.mData->phoneNumbers;
2053 s << a.mData->addresses; 2054 s << a.mData->addresses;
2054 s << a.mData->emails; 2055 s << a.mData->emails;
2055 s << a.mData->categories; 2056 s << a.mData->categories;
2056 s << a.mData->custom; 2057 s << a.mData->custom;
2057 s << a.mData->keys; 2058 s << a.mData->keys;
2058 return s; 2059 return s;
2059} 2060}
2060 2061
2061QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) 2062QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
2062{ 2063{
2063 if (!a.mData) return s; 2064 if (!a.mData) return s;
2064 2065
2065 s >> a.mData->uid; 2066 s >> a.mData->uid;
2066 2067
2067 s >> a.mData->name; 2068 s >> a.mData->name;
2068 s >> a.mData->formattedName; 2069 s >> a.mData->formattedName;
2069 s >> a.mData->familyName; 2070 s >> a.mData->familyName;
2070 s >> a.mData->givenName; 2071 s >> a.mData->givenName;
2071 s >> a.mData->additionalName; 2072 s >> a.mData->additionalName;
2072 s >> a.mData->prefix; 2073 s >> a.mData->prefix;
2073 s >> a.mData->suffix; 2074 s >> a.mData->suffix;
2074 s >> a.mData->nickName; 2075 s >> a.mData->nickName;
2075 s >> a.mData->birthday; 2076 s >> a.mData->birthday;
2076 s >> a.mData->mailer; 2077 s >> a.mData->mailer;
2077 s >> a.mData->timeZone; 2078 s >> a.mData->timeZone;
2078 s >> a.mData->geo; 2079 s >> a.mData->geo;
2079 s >> a.mData->title; 2080 s >> a.mData->title;
2080 s >> a.mData->role; 2081 s >> a.mData->role;
2081 s >> a.mData->organization; 2082 s >> a.mData->organization;
2082 s >> a.mData->note; 2083 s >> a.mData->note;
2083 s >> a.mData->productId; 2084 s >> a.mData->productId;
2084 s >> a.mData->revision; 2085 s >> a.mData->revision;
2085 s >> a.mData->sortString; 2086 s >> a.mData->sortString;
2086 s >> a.mData->url; 2087 s >> a.mData->url;
2087 s >> a.mData->secrecy; 2088 s >> a.mData->secrecy;
2088 s >> a.mData->logo; 2089 s >> a.mData->logo;
2089 s >> a.mData->photo; 2090 s >> a.mData->photo;
2090 s >> a.mData->sound; 2091 s >> a.mData->sound;
2091 s >> a.mData->agent; 2092 s >> a.mData->agent;
2092 s >> a.mData->phoneNumbers; 2093 s >> a.mData->phoneNumbers;
2093 s >> a.mData->addresses; 2094 s >> a.mData->addresses;
2094 s >> a.mData->emails; 2095 s >> a.mData->emails;
2095 s >> a.mData->categories; 2096 s >> a.mData->categories;
2096 s >> a.mData->custom; 2097 s >> a.mData->custom;
2097 s >> a.mData->keys; 2098 s >> a.mData->keys;
2098 2099
2099 a.mData->empty = false; 2100 a.mData->empty = false;
2100 2101
2101 return s; 2102 return s;
2102} 2103}
2103bool matchBinaryPattern( int value, int pattern ) 2104bool matchBinaryPattern( int value, int pattern )
2104{ 2105{
2105 /** 2106 /**
2106 We want to match all telephonnumbers/addresses which have the bits in the 2107 We want to match all telephonnumbers/addresses which have the bits in the
2107 pattern set. More are allowed. 2108 pattern set. More are allowed.
2108 if pattern == 0 we have a special handling, then we want only those with 2109 if pattern == 0 we have a special handling, then we want only those with
2109 exactly no bit set. 2110 exactly no bit set.
2110 */ 2111 */
2111 if ( pattern == 0 ) 2112 if ( pattern == 0 )
2112 return ( value == 0 ); 2113 return ( value == 0 );
2113 else 2114 else
2114 return ( pattern == ( pattern & value ) ); 2115 return ( pattern == ( pattern & value ) );
2115} 2116}
2116 2117
2117bool matchBinaryPatternP( int value, int pattern ) 2118bool matchBinaryPatternP( int value, int pattern )
2118{ 2119{
2119 2120
2120 if ( pattern == 0 ) 2121 if ( pattern == 0 )
2121 return ( value == 0 ); 2122 return ( value == 0 );
2122 else 2123 else
2123 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); 2124 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) );
2124} 2125}
2125bool matchBinaryPatternA( int value, int pattern ) 2126bool matchBinaryPatternA( int value, int pattern )
2126{ 2127{
2127 2128
2128 if ( pattern == 0 ) 2129 if ( pattern == 0 )
2129 return ( value == 0 ); 2130 return ( value == 0 );
2130 else 2131 else
2131 return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); 2132 return ( (pattern | Address::Pref) == ( value | Address::Pref ) );
2132} 2133}
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp
index 3d82553..abb3b3b 100644
--- a/kabc/phonenumber.cpp
+++ b/kabc/phonenumber.cpp
@@ -1,245 +1,240 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
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/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <kapplication.h> 28#include <kapplication.h>
29#include <klocale.h> 29#include <klocale.h>
30 30
31#include "phonenumber.h" 31#include "phonenumber.h"
32 32
33using namespace KABC; 33using namespace KABC;
34 34
35PhoneNumber::PhoneNumber() : 35PhoneNumber::PhoneNumber() :
36 mType( Home ) 36 mType( Home )
37{ 37{
38 init(); 38 init();
39} 39}
40 40
41PhoneNumber::PhoneNumber( const QString &number, int type ) : 41PhoneNumber::PhoneNumber( const QString &number, int type ) :
42 mType( type ), mNumber( number ) 42 mType( type ), mNumber( number )
43{ 43{
44 init(); 44 init();
45} 45}
46 46
47PhoneNumber::~PhoneNumber() 47PhoneNumber::~PhoneNumber()
48{ 48{
49} 49}
50 50
51void PhoneNumber::init() 51void PhoneNumber::init()
52{ 52{
53 mId = KApplication::randomString( 8 ); 53 mId = KApplication::randomString( 8 );
54} 54}
55 55
56bool PhoneNumber::operator==( const PhoneNumber &p ) const 56bool PhoneNumber::operator==( const PhoneNumber &p ) const
57{ 57{
58 if ( mNumber != p.mNumber ) return false; 58 if ( mNumber != p.mNumber ) return false;
59 if ( mType != p.mType ) return false; 59 if ( mType != p.mType ) return false;
60 60
61 return true; 61 return true;
62} 62}
63 63
64bool PhoneNumber::operator!=( const PhoneNumber &p ) const 64bool PhoneNumber::operator!=( const PhoneNumber &p ) const
65{ 65{
66 return !( p == *this ); 66 return !( p == *this );
67} 67}
68 68
69bool PhoneNumber::simplifyNumber() 69bool PhoneNumber::simplifyNumber()
70{ 70{
71 QString Number; 71 QString Number;
72 int i; 72 int i;
73 Number = mNumber.stripWhiteSpace (); 73 Number = mNumber.stripWhiteSpace ();
74 mNumber = ""; 74 mNumber = "";
75 for ( i = 0; i < Number.length(); ++i) { 75 for ( i = 0; i < Number.length(); ++i) {
76 if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) 76 if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' )
77 mNumber += Number.at(i); 77 mNumber += Number.at(i);
78 } 78 }
79 return ( mNumber.length() > 0 ); 79 return ( mNumber.length() > 0 );
80} 80}
81// make cellphone compatible 81// make cellphone compatible
82void PhoneNumber::simplifyType() 82void PhoneNumber::simplifyType()
83{ 83{
84 if ( mType & Fax ) mType = Fax; 84 if ( mType & Fax ) mType = Fax;
85 else if ( mType & Cell ) mType = Cell; 85 else if ( mType & Cell ) mType = Cell;
86 else if ( mType & Work ) mType = Work ; 86 else if ( mType & Work ) mType = Work ;
87 else if ( mType & Home ) mType = Home; 87 else if ( mType & Home ) mType = Home;
88 else mType = Pref; 88 else mType = Pref;
89} 89}
90bool PhoneNumber::contains( const PhoneNumber &p ) 90bool PhoneNumber::contains( const PhoneNumber &p )
91{ 91{
92 QString Number; 92 PhoneNumber myself;
93 QString Num; 93 PhoneNumber other;
94 uint i; 94 myself = *this;
95 Number = mNumber.stripWhiteSpace (); 95 other = p;
96 Num = ""; 96 myself.simplifyNumber();
97 for ( i = 0; i < Number.length(); ++i) { 97 other.simplifyNumber();
98 if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) 98 if ( myself.number() != other.number ())
99 Num += Number.at(i); 99 return false;
100 } 100 myself.simplifyType();
101 QString NumberR; 101 other.simplifyType();
102 QString NumR; 102 if ( myself.type() == other.type())
103 NumberR = p.mNumber.stripWhiteSpace (); 103 return true;
104 NumR = ""; 104 return false;
105 for ( i = 0; i < NumberR.length(); ++i) {
106 if ( NumberR.at(i).isDigit() || NumberR.at(i) == '+'|| NumberR.at(i) == '*'|| NumberR.at(i) == '#' )
107 NumR += NumberR.at(i);
108 }
109 return (Num == NumR);
110} 105}
111 106
112void PhoneNumber::setId( const QString &id ) 107void PhoneNumber::setId( const QString &id )
113{ 108{
114 mId = id; 109 mId = id;
115} 110}
116 111
117QString PhoneNumber::id() const 112QString PhoneNumber::id() const
118{ 113{
119 return mId; 114 return mId;
120} 115}
121 116
122void PhoneNumber::setNumber( const QString &number ) 117void PhoneNumber::setNumber( const QString &number )
123{ 118{
124 mNumber = number; 119 mNumber = number;
125} 120}
126 121
127QString PhoneNumber::number() const 122QString PhoneNumber::number() const
128{ 123{
129 return mNumber; 124 return mNumber;
130} 125}
131 126
132void PhoneNumber::setType( int type ) 127void PhoneNumber::setType( int type )
133{ 128{
134 mType = type; 129 mType = type;
135} 130}
136 131
137int PhoneNumber::type() const 132int PhoneNumber::type() const
138{ 133{
139 return mType; 134 return mType;
140} 135}
141 136
142QString PhoneNumber::typeLabel() const 137QString PhoneNumber::typeLabel() const
143{ 138{
144 QString label; 139 QString label;
145 bool first = true; 140 bool first = true;
146 141
147 TypeList list = typeList(); 142 TypeList list = typeList();
148 143
149 TypeList::Iterator it; 144 TypeList::Iterator it;
150 for ( it = list.begin(); it != list.end(); ++it ) { 145 for ( it = list.begin(); it != list.end(); ++it ) {
151 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { 146 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) {
152 label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); 147 label.append( ( first ? "" : "/" ) + typeLabel( *it ) );
153 if ( first ) 148 if ( first )
154 first = false; 149 first = false;
155 } 150 }
156 } 151 }
157 152
158 return label; 153 return label;
159} 154}
160 155
161QString PhoneNumber::label() const 156QString PhoneNumber::label() const
162{ 157{
163 return typeLabel( type() ); 158 return typeLabel( type() );
164} 159}
165 160
166PhoneNumber::TypeList PhoneNumber::typeList() 161PhoneNumber::TypeList PhoneNumber::typeList()
167{ 162{
168 TypeList list; 163 TypeList list;
169 164
170 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video 165 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video
171 << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip; 166 << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip;
172 167
173 return list; 168 return list;
174} 169}
175 170
176QString PhoneNumber::label( int type ) 171QString PhoneNumber::label( int type )
177{ 172{
178 return typeLabel( type ); 173 return typeLabel( type );
179} 174}
180 175
181QString PhoneNumber::typeLabel( int type ) 176QString PhoneNumber::typeLabel( int type )
182{ 177{
183 QString typeString; 178 QString typeString;
184 179
185 if ((type & Home) == Home) 180 if ((type & Home) == Home)
186 typeString += i18n("Home"); 181 typeString += i18n("Home");
187 else if ((type & Work) == Work) 182 else if ((type & Work) == Work)
188 typeString += i18n("Work"); 183 typeString += i18n("Work");
189 184
190 if (!typeString.isEmpty()) 185 if (!typeString.isEmpty())
191 typeString += " "; 186 typeString += " ";
192 187
193 if ((type & Cell) == Cell) 188 if ((type & Cell) == Cell)
194 typeString += i18n("Mobile"); 189 typeString += i18n("Mobile");
195 else if ((type & Fax) == Fax) 190 else if ((type & Fax) == Fax)
196 typeString += i18n("Fax"); 191 typeString += i18n("Fax");
197 else if ((type & Msg) == Msg) 192 else if ((type & Msg) == Msg)
198 typeString += i18n("Messenger"); 193 typeString += i18n("Messenger");
199 else if ((type & Voice) == Voice) { 194 else if ((type & Voice) == Voice) {
200// add nothing in case of the Voice flag 195// add nothing in case of the Voice flag
201// typeString += i18n("Voice"); 196// typeString += i18n("Voice");
202 } 197 }
203 else if ((type & Video) == Video) 198 else if ((type & Video) == Video)
204 typeString += i18n("Video"); 199 typeString += i18n("Video");
205 else if ((type & Bbs) == Bbs) 200 else if ((type & Bbs) == Bbs)
206 typeString += i18n("Mailbox"); 201 typeString += i18n("Mailbox");
207 else if ((type & Modem) == Modem) 202 else if ((type & Modem) == Modem)
208 typeString += i18n("Modem"); 203 typeString += i18n("Modem");
209 else if ((type & Car) == Car) 204 else if ((type & Car) == Car)
210 typeString += i18n("Car"); 205 typeString += i18n("Car");
211 else if ((type & Isdn) == Isdn) 206 else if ((type & Isdn) == Isdn)
212 typeString += i18n("ISDN"); 207 typeString += i18n("ISDN");
213 else if ((type & Pcs) == Pcs) 208 else if ((type & Pcs) == Pcs)
214 typeString += i18n("PCS"); 209 typeString += i18n("PCS");
215 else if ((type & Pager) == Pager) 210 else if ((type & Pager) == Pager)
216 typeString += i18n("Pager"); 211 typeString += i18n("Pager");
217 else if ((type & Sip) == Sip) 212 else if ((type & Sip) == Sip)
218 typeString += i18n("SIP"); 213 typeString += i18n("SIP");
219 214
220 // add the prefered flag 215 // add the prefered flag
221 if (!typeString.isEmpty()) 216 if (!typeString.isEmpty())
222 typeString += " "; 217 typeString += " ";
223 /* 218 /*
224 if ((type & Pref) == Pref) 219 if ((type & Pref) == Pref)
225 typeString += i18n("(p)"); 220 typeString += i18n("(p)");
226 */ 221 */
227 //if we still have no match, return "other" 222 //if we still have no match, return "other"
228 if (typeString.isEmpty()) 223 if (typeString.isEmpty())
229 return i18n("Other"); 224 return i18n("Other");
230 225
231 226
232 return typeString; 227 return typeString;
233} 228}
234 229
235QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) 230QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone )
236{ 231{
237 return s << phone.mId << phone.mType << phone.mNumber; 232 return s << phone.mId << phone.mType << phone.mNumber;
238} 233}
239 234
240QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) 235QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone )
241{ 236{
242 s >> phone.mId >> phone.mType >> phone.mNumber; 237 s >> phone.mId >> phone.mType >> phone.mNumber;
243 238
244 return s; 239 return s;
245} 240}
diff --git a/kabc/plugins/ldap/ldapE.pro b/kabc/plugins/ldap/ldapE.pro
index df3c94c..57b6f84 100644
--- a/kabc/plugins/ldap/ldapE.pro
+++ b/kabc/plugins/ldap/ldapE.pro
@@ -1,21 +1,21 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3#release debug 3#release debug
4 4
5TARGET = microkabc_ldap 5TARGET = microkabc_ldap
6INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include 6INCLUDEPATH += $(KDEPIMDIR)/kabc $(KDEPIMDIR)/microkde $(KDEPIMDIR)/microkde/kdecore $(KDEPIMDIR)/microkde/kio/kfile $(KDEPIMDIR)/microkde/kresources $(KDEPIMDIR)/qtcompat $(QPEDIR)/include
7OBJECTS_DIR = obj/$(PLATFORM) 7OBJECTS_DIR = obj/$(PLATFORM)
8MOC_DIR = moc/$(PLATFORM) 8MOC_DIR = moc/$(PLATFORM)
9DESTDIR = $(QPEDIR)/lib 9DESTDIR = $(QPEDIR)/lib
10LIBS += -lmicrokde -lkamicrokabc 10LIBS += -lmicrokde -lmicrokabc
11LIBS += -L$(QPEDIR)/lib 11LIBS += -L$(QPEDIR)/lib
12 12
13INTERFACES = \ 13INTERFACES = \
14 14
15HEADERS = \ 15HEADERS = \
16 resourceldap.h \ 16 resourceldap.h \
17 resourceldapconfig.h 17 resourceldapconfig.h
18 18
19SOURCES = \ 19SOURCES = \
20 resourceldap.cpp \ 20 resourceldap.cpp \
21 resourceldapconfig.cpp 21 resourceldapconfig.cpp
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index aa33588..2f7409d 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -1,706 +1,706 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qlayout.h> 20#include <qlayout.h>
21#include <qtextbrowser.h> 21#include <qtextbrowser.h>
22#include <qtextcodec.h> 22#include <qtextcodec.h>
23#include <qfileinfo.h> 23#include <qfileinfo.h>
24#include <qlabel.h> 24#include <qlabel.h>
25 25
26#include <qapplication.h> 26#include <qapplication.h>
27 27
28#include <kglobal.h> 28#include <kglobal.h>
29#include <klocale.h> 29#include <klocale.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include <kiconloader.h> 31#include <kiconloader.h>
32#include <kmessagebox.h> 32#include <kmessagebox.h>
33 33
34#include <libkcal/calendar.h> 34#include <libkcal/calendar.h>
35 35
36#ifndef KORG_NOPRINTER 36#ifndef KORG_NOPRINTER
37#include "calprinter.h" 37#include "calprinter.h"
38#endif 38#endif
39#include "koglobals.h" 39#include "koglobals.h"
40#include "koprefs.h" 40#include "koprefs.h"
41#include "koeventviewerdialog.h" 41#include "koeventviewerdialog.h"
42#include <qstylesheet.h> 42#include <qstylesheet.h>
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44using namespace KOrg; 44using namespace KOrg;
45 45
46void WhatsNextTextBrowser::setSource(const QString& n) 46void WhatsNextTextBrowser::setSource(const QString& n)
47{ 47{
48 48
49 if (n.startsWith("event:")) { 49 if (n.startsWith("event:")) {
50 emit showIncidence(n); 50 emit showIncidence(n);
51 return; 51 return;
52 } else if (n.startsWith("todo:")) { 52 } else if (n.startsWith("todo:")) {
53 emit showIncidence(n); 53 emit showIncidence(n);
54 return; 54 return;
55 } else { 55 } else {
56 QTextBrowser::setSource(n); 56 QTextBrowser::setSource(n);
57 } 57 }
58} 58}
59 59
60KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, 60KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent,
61 const char *name) 61 const char *name)
62 : KOrg::BaseView(calendar, parent, name) 62 : KOrg::BaseView(calendar, parent, name)
63{ 63{
64 // mDateLabel = 64 // mDateLabel =
65 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); 65 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this);
66 // mDateLabel->setMargin(2); 66 // mDateLabel->setMargin(2);
67 // mDateLabel->setAlignment(AlignCenter); 67 // mDateLabel->setAlignment(AlignCenter);
68 setFont( KOPrefs::instance()->mWhatsNextFont ); 68 setFont( KOPrefs::instance()->mWhatsNextFont );
69 mView = new WhatsNextTextBrowser(this); 69 mView = new WhatsNextTextBrowser(this);
70 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); 70 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &)));
71 QStyleSheet* stsh = mView->styleSheet(); 71 QStyleSheet* stsh = mView->styleSheet();
72 QStyleSheetItem * style ; 72 QStyleSheetItem * style ;
73 style = stsh->item ("a" );
74 if ( style ) {
75 style->setMargin(QStyleSheetItem::MarginAll,0);
76 }
77 style = stsh->item ("h2" ); 73 style = stsh->item ("h2" );
78 if ( style ) { 74 if ( style ) {
79 style->setMargin(QStyleSheetItem::MarginAll,0); 75 style->setMargin(QStyleSheetItem::MarginAll,0);
80 } 76 }
81 style = stsh->item ("h3" ); 77 style = stsh->item ("h3" );
82 if ( style ) { 78 if ( style ) {
83 style->setMargin(QStyleSheetItem::MarginAll,0); 79 style->setMargin(QStyleSheetItem::MarginAll,0);
84 } 80 }
85 style = stsh->item ("table" );
86 if ( style ) {
87 style->setMargin(QStyleSheetItem::MarginAll,0);
88 }
89 mEventViewer = 0; 81 mEventViewer = 0;
90 82
91 QBoxLayout *topLayout = new QVBoxLayout(this); 83 QBoxLayout *topLayout = new QVBoxLayout(this);
92 // topLayout->addWidget(mDateLabel); 84 // topLayout->addWidget(mDateLabel);
93 topLayout->addWidget(mView); 85 topLayout->addWidget(mView);
94 mTimer = new QTimer( this ); 86 mTimer = new QTimer( this );
95 connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); 87 connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView()));
96 88
97 connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); 89 connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
98 connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); 90 connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
99} 91}
100 92
101KOWhatsNextView::~KOWhatsNextView() 93KOWhatsNextView::~KOWhatsNextView()
102{ 94{
103} 95}
104 96
105int KOWhatsNextView::maxDatesHint() 97int KOWhatsNextView::maxDatesHint()
106{ 98{
107 return 0; 99 return 0;
108} 100}
109 101
110int KOWhatsNextView::currentDateCount() 102int KOWhatsNextView::currentDateCount()
111{ 103{
112 return 0; 104 return 0;
113} 105}
114 106
115QPtrList<Incidence> KOWhatsNextView::selectedIncidences() 107QPtrList<Incidence> KOWhatsNextView::selectedIncidences()
116{ 108{
117 QPtrList<Incidence> eventList; 109 QPtrList<Incidence> eventList;
118 110
119 return eventList; 111 return eventList;
120} 112}
121 113
122 114
123void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, 115void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd,
124 const QDate &td) 116 const QDate &td)
125{ 117{
126#ifndef KORG_NOPRINTER 118#ifndef KORG_NOPRINTER
127 calPrinter->preview(CalPrinter::Day, fd, td); 119 calPrinter->preview(CalPrinter::Day, fd, td);
128#endif 120#endif
129} 121}
130void KOWhatsNextView::updateConfig() 122void KOWhatsNextView::updateConfig()
131{ 123{
132 setFont( KOPrefs::instance()->mWhatsNextFont ); 124 setFont( KOPrefs::instance()->mWhatsNextFont );
133 updateView(); 125 updateView();
134 126
135} 127}
136void KOWhatsNextView::showEvent ( QShowEvent * e ) 128void KOWhatsNextView::showEvent ( QShowEvent * e )
137{ 129{
138 //qDebug("KOWhatsNextView::showEvent "); 130 //qDebug("KOWhatsNextView::showEvent ");
139 restartTimer(); 131 restartTimer();
140 QWidget::showEvent ( e ); 132 QWidget::showEvent ( e );
141} 133}
142void KOWhatsNextView::hideEvent ( QHideEvent * e) 134void KOWhatsNextView::hideEvent ( QHideEvent * e)
143{ 135{
144 //qDebug(" KOWhatsNextView::hideEvent"); 136 //qDebug(" KOWhatsNextView::hideEvent");
145 mTimer->stop(); 137 mTimer->stop();
146 QWidget::hideEvent ( e ); 138 QWidget::hideEvent ( e );
147} 139}
148void KOWhatsNextView::restartTimer() 140void KOWhatsNextView::restartTimer()
149{ 141{
150 //qDebug("KOWhatsNextView::restartTimer() "); 142 //qDebug("KOWhatsNextView::restartTimer() ");
151 mTimer->start( 300000 ); 143 mTimer->start( 300000 );
152 //mTimer->start( 5000 ); 144 //mTimer->start( 5000 );
153} 145}
154void KOWhatsNextView::updateView() 146void KOWhatsNextView::updateView()
155{ 147{
156 if ( mTimer->isActive() ) 148 if ( mTimer->isActive() )
157 restartTimer(); 149 restartTimer();
158 //qDebug("KOWhatsNextView::updateView() "); 150 //qDebug("KOWhatsNextView::updateView() ");
159 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); 151 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate()));
160 KIconLoader kil("korganizer"); 152 KIconLoader kil("korganizer");
161 QString ipath;// = new QString(); 153 QString ipath;// = new QString();
162 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); 154 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath);
163 //<big><big><strong>" + date + "</strong></big></big>\n"; 155 //<big><big><strong>" + date + "</strong></big></big>\n";
164 mText = "<qt><table width=\"100%\">\n"; 156 mText = "<table width=\"100%\">\n";
165 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 157 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
166#ifdef DESKTOP_VERSION 158#ifdef DESKTOP_VERSION
167 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; 159 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>";
168#else 160#else
169 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 161 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
170#endif 162#endif
171 // mText += "<img src=\""; 163 // mText += "<img src=\"";
172 // mText += ipath; 164 // mText += ipath;
173 // mText += "\">"; 165 // mText += "\">";
174 mEventDate = QDate::currentDate(); 166 mEventDate = QDate::currentDate();
175#ifdef DESKTOP_VERSION 167#ifdef DESKTOP_VERSION
176 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; 168 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>";
177#else 169#else
178 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; 170 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>";
179#endif 171#endif
180 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 172 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
181 int iii; 173 int iii;
182 mTodos.clear(); 174 mTodos.clear();
183 QPtrList<Event> events; 175 QPtrList<Event> events;
184 QPtrList<Todo> todos = calendar()->todos(); 176 QPtrList<Todo> todos = calendar()->todos();
185 Todo * todo; 177 Todo * todo;
186 //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; 178 //mText += "<h2>" + i18n("Events: ") + "</h2>\n";
187 int daysToShow = KOPrefs::instance()->mWhatsNextDays ; 179 int daysToShow = KOPrefs::instance()->mWhatsNextDays ;
188 bool itemAdded = false; 180 bool itemAdded = false;
189 for ( iii = 0; iii < daysToShow; ++iii ) { 181 for ( iii = 0; iii < daysToShow; ++iii ) {
190 QString date; 182 QString date;
191 itemAdded = false; 183 itemAdded = false;
192 events = calendar()->events( mEventDate, true ); 184 events = calendar()->events( mEventDate, true );
193 185
194 if ( iii == 0 ) { // today !!! 186 if ( iii == 0 ) { // today !!!
195 todo = todos.first(); 187 todo = todos.first();
196 while(todo) { 188 while(todo) {
197 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { 189 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) {
198 if ( ! itemAdded ) { 190 if ( ! itemAdded ) {
199 appendDay ( iii, mEventDate ); 191 appendDay ( iii, mEventDate );
200 itemAdded = true; 192 itemAdded = true;
201 193
202 } 194 }
203 appendEvent(todo); 195 appendEvent(todo);
204 } 196 }
205 todo = todos.next(); 197 todo = todos.next();
206 } 198 }
207 } 199 }
208 200
209 201
210 if (events.count() > 0) { 202 if (events.count() > 0) {
211 // mText += "<p></p>"; 203 // mText += "<p></p>";
212 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 204 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
213 // mText += "<h2>"; 205 // mText += "<h2>";
214 //mText += " <img src=\""; 206 //mText += " <img src=\"";
215 //mText += ipath; 207 //mText += ipath;
216 //mText += "\">"; 208 //mText += "\">";
217 if ( ! itemAdded ) { 209 if ( ! itemAdded ) {
218 appendDay ( iii, mEventDate ); 210 appendDay ( iii, mEventDate );
219 itemAdded = true;
220 211
221 } 212 }
213 // for first day (iii == 0)
214 // we may have syncevents, or events in the past, which maybe should nor be diaplayed
215 // for that reason we cannot append <table> in appendDay () for iii == 0
216 // we must append it in the first successful call of appendEvent()
222 Event *ev = events.first(); 217 Event *ev = events.first();
223 while(ev) { 218 while(ev) {
224 //qDebug("+++++event append %s", ev->summary().latin1()); 219 //qDebug("+++++event append %s", ev->summary().latin1());
225 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { 220 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) {
226 appendEvent(ev, false , iii!= 0 ); 221 if ( appendEvent(ev, false , iii!= 0,!itemAdded ) )
222 itemAdded = true;
227 } 223 }
228 ev = events.next(); 224 ev = events.next();
229 } 225 }
230 226
231 //mText += "</table>\n"; 227 //mText += "</table>\n";
232 } 228 }
233 229
234 todo = todos.first(); 230 todo = todos.first();
235 while(todo) { 231 while(todo) {
236 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { 232 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) {
237 if ( ! itemAdded ) { 233 if ( ! itemAdded ) {
238 appendDay ( iii, mEventDate ); 234 appendDay ( iii, mEventDate );
239 itemAdded = true; 235 itemAdded = true;
240 } 236 }
241 appendEvent(todo); 237 appendEvent(todo);
242 } 238 }
243 todo = todos.next(); 239 todo = todos.next();
244 } 240 }
245 if ( !itemAdded && iii == 0 ) { 241 if ( !itemAdded && iii == 0 ) {
246 // appendDay ( iii, mEventDate ); 242 // appendDay ( iii, mEventDate );
247 //mText += "<table>"; 243 //mText += "<table>";
248 // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; 244 // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n";
249 mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do. ") +"</em></font></h3>\n"; 245 mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do. ") +"</em></font></h3>\n";
250 //mText +="</table>"; 246 //mText +="</table>";
251 } 247 }
252 if ( itemAdded ) 248 if ( itemAdded )
253 mText += "</table>\n"; 249 mText += "</table>\n";
254 mEventDate = mEventDate.addDays( 1 ); 250 mEventDate = mEventDate.addDays( 1 );
255 } 251 }
256 252
257 int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; 253 int topmostPrios = KOPrefs::instance()->mWhatsNextPrios;
258 if (todos.count() > 0 && topmostPrios > 0 ) { 254 if (todos.count() > 0 && topmostPrios > 0 ) {
259 // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 255 // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
260 // mText += "<h2>"; 256 // mText += "<h2>";
261 //<img src=\""; 257 //<img src=\"";
262 // mText += ipath; 258 // mText += ipath;
263 // mText += "\">"; 259 // mText += "\">";
264 // mText += i18n("Overdue To-Do:") + "</h2>\n"; 260 // mText += i18n("Overdue To-Do:") + "</h2>\n";
265 261
266 //mText += "<ul>\n"; 262 //mText += "<ul>\n";
267 bool gotone = false; 263 bool gotone = false;
268 int priority = 1; 264 int priority = 1;
269 int priosFound = 0; 265 int priosFound = 0;
270#ifdef DESKTOP_VERSION 266#ifdef DESKTOP_VERSION
271 mText +="<p></p>"; 267 mText +="<p></p>";
272#endif 268#endif
273 269
274 mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; 270 mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n";
275 mText += "<ul>\n"; 271 mText += "<ul>\n";
276 while (!gotone && priority<6) { 272 while (!gotone && priority<6) {
277 todo = todos.first(); 273 todo = todos.first();
278 while(todo) { 274 while(todo) {
279 if (!todo->isCompleted() && (todo->priority() == priority) ) { 275 if (!todo->isCompleted() && (todo->priority() == priority) ) {
280 if ( appendTodo(todo) ) 276 if ( appendTodo(todo) )
281 gotone = true; 277 gotone = true;
282 } 278 }
283 todo = todos.next(); 279 todo = todos.next();
284 } 280 }
285 if ( gotone ) { 281 if ( gotone ) {
286 gotone = false; 282 gotone = false;
287 ++priosFound; 283 ++priosFound;
288 if ( priosFound == topmostPrios ) 284 if ( priosFound == topmostPrios )
289 break; 285 break;
290 } 286 }
291 priority++; 287 priority++;
292 // kdDebug() << "adding the todos..." << endl; 288 // kdDebug() << "adding the todos..." << endl;
293 } 289 }
294 mText += "</ul>\n"; 290 mText += "</ul>\n";
295 } 291 }
296 292
297 int replys = 0; 293 int replys = 0;
298 events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); 294 events = calendar()->events(QDate::currentDate(), QDate(2975,12,6));
299 if (events.count() > 0) { 295 if (events.count() > 0) {
300 Event *ev = events.first(); 296 Event *ev = events.first();
301 while(ev) { 297 while(ev) {
302 Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 298 Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
303 if (me!=0) { 299 if (me!=0) {
304 if (me->status()==Attendee::NeedsAction && me->RSVP()) { 300 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
305 if (replys == 0) { 301 if (replys == 0) {
306 mText += "<p></p>"; 302 mText += "<p></p>";
307 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 303 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
308 //mText += "<h2>"; 304 //mText += "<h2>";
309 //<img src=\""; 305 //<img src=\"";
310 // mText += ipath; 306 // mText += ipath;
311 // mText += "\">"; 307 // mText += "\">";
312 //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; 308 //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n";
313 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; 309 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n";
314 mText += "<table>\n"; 310 mText += "<table>\n";
315 } 311 }
316 replys++; 312 replys++;
317 appendEvent(ev,true); 313 appendEvent(ev,true);
318 } 314 }
319 } 315 }
320 ev = events.next(); 316 ev = events.next();
321 } 317 }
322 } 318 }
323 todos = calendar()->todos(); 319 todos = calendar()->todos();
324 if (todos.count() > 0) { 320 if (todos.count() > 0) {
325 Todo *to = todos.first(); 321 Todo *to = todos.first();
326 while(to) { 322 while(to) {
327 if ( !to->isCompleted() ){ 323 if ( !to->isCompleted() ){
328 Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 324 Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
329 if (me!=0) { 325 if (me!=0) {
330 if (me->status()==Attendee::NeedsAction && me->RSVP()) { 326 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
331 if (replys == 0) { 327 if (replys == 0) {
332 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; 328 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n";
333 mText += "<table>\n"; 329 mText += "<table>\n";
334 } 330 }
335 replys++; 331 replys++;
336 appendEvent(to, true); 332 appendEvent(to, true);
337 } 333 }
338 } 334 }
339 } 335 }
340 to = todos.next(); 336 to = todos.next();
341 } 337 }
342 } 338 }
343 if (replys > 0 ) mText += "</table>\n"; 339 if (replys > 0 ) mText += "</table>\n";
344 340
345 341
346 mText += "</td></tr>\n</table></qt>\n"; 342 mText += "</td></tr>\n</table>\n";
347 343
348 mView->setText(mText); 344 mView->setText(mText);
349 mView->setFocus(); 345 mView->setFocus();
350 346
351 // QPixmap bPix = SmallIcon( "back" ); 347 // QPixmap bPix = SmallIcon( "back" );
352 // qDebug("xxxxxxxxxxxxxxxxxxxxx "); 348 // qDebug("xxxxxxxxxxxxxxxxxxxxx ");
353 // QWidget* test = new QWidget(); 349 // QWidget* test = new QWidget();
354 // test->setBackgroundMode(FixedPixmap ); 350 // test->setBackgroundMode(FixedPixmap );
355 // test->setBackgroundPixmap ( bPix ); 351 // test->setBackgroundPixmap ( bPix );
356 // test->resize( 300, 400 ); 352 // test->resize( 300, 400 );
357 // test->show(); 353 // test->show();
358 // mView->setBackgroundMode(FixedPixmap ); 354 // mView->setBackgroundMode(FixedPixmap );
359 // mView->setBackgroundPixmap ( bPix ); 355 // mView->setBackgroundPixmap ( bPix );
360 // qDebug("%s ",mText.latin1()); 356 qDebug("%s ",mText.latin1());
361} 357}
362 358
363void KOWhatsNextView::appendDay( int i, QDate eventDate ) 359void KOWhatsNextView::appendDay( int i, QDate eventDate )
364{ 360{
365 QString date; 361 QString date;
366 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); 362 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer);
367 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { 363 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) {
368 if ( i == 0 ) { 364 if ( i == 0 ) {
369 mText += "<table>\n"; 365 //mText += "<table>\n";
370 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; 366 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>";
371 } 367 }
372 else if ( i == 1 ) 368 else if ( i == 1 )
373 date = "<em><font color=\"#000080\">" + day + "</font></em>" ; 369 date = "<em><font color=\"#000080\">" + day + "</font></em>" ;
374 else date = "<em><font color=\"#000080\">" + day + "</font></em>"; 370 else date = "<em><font color=\"#000080\">" + day + "</font></em>";
375 mText += "<h2>" + date + "</h2>\n"; 371 mText += "<h2>" + date + "</h2>\n";
376 //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 372 //mText += "<big><big><strong>" + date + "</strong></big></big>\n";
377 mText += "<table>\n"; 373 mText += "<table>\n";
378 374
379 375
380 376
381 } else { 377 } else {
382 if ( i == 0 ) { 378 if ( i == 0 ) {
383 mText += "<table>\n"; 379 //mText += "<table>\n";
384 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; 380 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>";
385 } 381 }
386 382
387#ifdef DESKTOP_VERSION 383#ifdef DESKTOP_VERSION
388 else if ( i == 1 ) { 384 else if ( i == 1 ) {
389 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; 385 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ;
390 } 386 }
391 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; 387 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>";
392#else 388#else
393 else if ( i == 1 ) { 389 else if ( i == 1 ) {
394 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; 390 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ;
395 } 391 }
396 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; 392 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>";
397 393
398#endif 394#endif
399 mText += "<h2>" + date + "</h2>\n"; 395 mText += "<h2>" + date + "</h2>\n";
400 //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 396 //mText += "<big><big><strong>" + date + "</strong></big></big>\n";
401 mText += "<table>\n"; 397 mText += "<table>\n";
402 } 398 }
403} 399}
404 400
405 401
406void KOWhatsNextView::showDates(const QDate &, const QDate &) 402void KOWhatsNextView::showDates(const QDate &, const QDate &)
407{ 403{
408 updateView(); 404 updateView();
409} 405}
410 406
411void KOWhatsNextView::showEvents(QPtrList<Event>) 407void KOWhatsNextView::showEvents(QPtrList<Event>)
412{ 408{
413} 409}
414 410
415void KOWhatsNextView::changeEventDisplay(Event *, int action) 411void KOWhatsNextView::changeEventDisplay(Event *, int action)
416{ 412{
417 switch(action) { 413 switch(action) {
418 case KOGlobals::EVENTADDED: 414 case KOGlobals::EVENTADDED:
419 updateView(); 415 updateView();
420 break; 416 break;
421 case KOGlobals::EVENTEDITED: 417 case KOGlobals::EVENTEDITED:
422 updateView(); 418 updateView();
423 break; 419 break;
424 case KOGlobals::EVENTDELETED: 420 case KOGlobals::EVENTDELETED:
425 updateView(); 421 updateView();
426 break; 422 break;
427 default: 423 default:
428 updateView(); 424 updateView();
429 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; 425 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl;
430 } 426 }
431} 427}
432 428
433void KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed ) 429bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable )
434{ 430{
435 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) 431 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") )
436 return; 432 return false;
437 QDateTime cdt = QDateTime::currentDateTime(); 433 QDateTime cdt = QDateTime::currentDateTime();
438 QDateTime noc; 434 QDateTime noc;
439 QString tempText; 435 QString tempText;
436 if ( appendTable && !notRed ) {
437 tempText = "<table>";
438 }
440 bool ok = true; 439 bool ok = true;
441 if ( reply ) { 440 if ( reply ) {
442 noc = ev->getNextOccurence( cdt, &ok ); 441 noc = ev->getNextOccurence( cdt, &ok );
443 if (! ok && ev->type() == "Event") 442 if (! ok && ev->type() == "Event")
444 return; 443 return false;
445 } 444 }
446 tempText += "<tr><td><b>"; 445 tempText += "<tr><td><b>";
447 if (ev->type()=="Event") { 446 if (ev->type()=="Event") {
448 if (reply) { 447 if (reply) {
449 if (!ev->doesFloat()) 448 if (!ev->doesFloat())
450 tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; 449 tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": ";
451 else 450 else
452 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 451 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
453 452
454 } else { 453 } else {
455 if (!ev->doesFloat()) { 454 if (!ev->doesFloat()) {
456 Event *event = static_cast<Event *>(ev); 455 Event *event = static_cast<Event *>(ev);
457 QDateTime st,end; 456 QDateTime st,end;
458 if ( event->recurrence()->doesRecur() ) { 457 if ( event->recurrence()->doesRecur() ) {
459 QDate recDate= mEventDate; 458 QDate recDate= mEventDate;
460 int days = event->dtStart().date().daysTo (event->dtEnd().date() ); 459 int days = event->dtStart().date().daysTo (event->dtEnd().date() );
461 while ( ! event->recursOn( recDate ) ) { 460 while ( ! event->recursOn( recDate ) ) {
462 recDate = recDate.addDays( -1 ); 461 recDate = recDate.addDays( -1 );
463 462
464 } 463 }
465 st = QDateTime ( recDate, event->dtStart().time() ); 464 st = QDateTime ( recDate, event->dtStart().time() );
466 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); 465 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() );
467 } 466 }
468 else { 467 else {
469 st = event->dtStart(); 468 st = event->dtStart();
470 end = event->dtEnd(); 469 end = event->dtEnd();
471 } 470 }
472 471
473 472
474 QString dateText; 473 QString dateText;
475 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); 474 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() );
476 if ( st.date() < mEventDate ) 475 if ( st.date() < mEventDate )
477 dateText = "++:++-"; 476 dateText = "++:++-";
478 else 477 else
479 dateText = event->dtStartTimeStr() + "-"; 478 dateText = event->dtStartTimeStr() + "-";
480 if ( end.date() > mEventDate ) 479 if ( end.date() > mEventDate )
481 dateText += "++:++"; 480 dateText += "++:++";
482 else 481 else
483 dateText += event->dtEndTimeStr(); 482 dateText += event->dtEndTimeStr();
484 if ( notRed ) 483 if ( notRed )
485 tempText += dateText; 484 tempText += dateText;
486 else { 485 else {
487 if ( end < cdt ) { 486 if ( end < cdt ) {
488 if ( !KOPrefs::instance()->mWNViewShowsPast ) 487 if ( !KOPrefs::instance()->mWNViewShowsPast )
489 return; 488 return false;
490 tempText += "<font color=\"#F00000\">" + dateText + "</font>"; 489 tempText += "<font color=\"#F00000\">" + dateText + "</font>";
491 } 490 }
492 else if ( st < cdt ) 491 else if ( st < cdt )
493 tempText += "<font color=\"#008000\">" + dateText + "</font>"; 492 tempText += "<font color=\"#008000\">" + dateText + "</font>";
494 else 493 else
495 tempText += dateText; 494 tempText += dateText;
496 495
497 } 496 }
498 497
499 } else { 498 } else {
500 tempText += i18n("Allday:"); 499 tempText += i18n("Allday:");
501 500
502 } 501 }
503 } 502 }
504 } else { 503 } else {
505 mTodos.append( ev ); 504 mTodos.append( ev );
506 tempText += i18n("ToDo:"); 505 tempText += i18n("ToDo:");
507 if (reply) { 506 if (reply) {
508 tempText += " "; 507 tempText += " ";
509 if ( noc != cdt ) { 508 if ( noc != cdt ) {
510 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 509 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
511 } 510 }
512 } else { 511 } else {
513 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { 512 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) {
514 // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 513 // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
515 QString dfs = KGlobal::locale()->dateFormatShort(); 514 QString dfs = KGlobal::locale()->dateFormatShort();
516 KGlobal::locale()->setDateFormatShort("%d.%b"); 515 KGlobal::locale()->setDateFormatShort("%d.%b");
517 tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; 516 tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>";
518 KGlobal::locale()->setDateFormatShort(dfs); 517 KGlobal::locale()->setDateFormatShort(dfs);
519 } else { 518 } else {
520 if (!ev->doesFloat() ) 519 if (!ev->doesFloat() )
521 if( ( (Todo*)ev)->dtDue() < cdt ) { 520 if( ( (Todo*)ev)->dtDue() < cdt ) {
522 tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; 521 tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>";
523 522
524 523
525 } else 524 } else
526 tempText +=((Todo*)ev)->dtDueTimeStr(); 525 tempText +=((Todo*)ev)->dtDueTimeStr();
527 mTodos.append( ev ); 526 mTodos.append( ev );
528 } 527 }
529 } 528 }
530 } 529 }
531 tempText += "</b></td><td>"; 530 tempText += "</b></td><td>";
532 bool needClose = false; 531 bool needClose = false;
533 if ( ev->cancelled() ) { 532 if ( ev->cancelled() ) {
534 tempText += "<font color=\"#F00000\">[c"; 533 tempText += "<font color=\"#F00000\">[c";
535 needClose =true; 534 needClose =true;
536 535
537 } 536 }
538 if ( ev->isAlarmEnabled() ) { 537 if ( ev->isAlarmEnabled() ) {
539 if ( !needClose) 538 if ( !needClose)
540 tempText +="["; 539 tempText +="[";
541 tempText += "a"; 540 tempText += "a";
542 needClose =true; 541 needClose =true;
543 542
544 } 543 }
545 if ( ev->description().length() > 0 ) { 544 if ( ev->description().length() > 0 ) {
546 if ( !needClose) 545 if ( !needClose)
547 tempText +="["; 546 tempText +="[";
548 tempText += "i"; 547 tempText += "i";
549 needClose =true; 548 needClose =true;
550 } 549 }
551 if ( ev->recurrence()->doesRecur() ) { 550 if ( ev->recurrence()->doesRecur() ) {
552 if ( !needClose) 551 if ( !needClose)
553 tempText +="["; 552 tempText +="[";
554 tempText += "r"; 553 tempText += "r";
555 needClose =true; 554 needClose =true;
556 } 555 }
557 if ( needClose ) { 556 if ( needClose ) {
558 tempText += "] "; 557 tempText += "] ";
559 } 558 }
560 if ( ev->cancelled() ) 559 if ( ev->cancelled() )
561 tempText += "</font>"; 560 tempText += "</font>";
562 tempText += "<a "; 561 tempText += "<a ";
563 if (ev->type()=="Event") tempText += "href=\"event:"; 562 if (ev->type()=="Event") tempText += "href=\"event:";
564 if (ev->type()=="Todo") tempText += "href=\"todo:"; 563 if (ev->type()=="Todo") tempText += "href=\"todo:";
565 tempText += ev->uid() + "\">"; 564 tempText += ev->uid() + "\">";
566 if ( ev->summary().length() > 0 ) 565 if ( ev->summary().length() > 0 )
567 tempText += ev->summary(); 566 tempText += ev->summary();
568 else 567 else
569 tempText += i18n("-no summary-"); 568 tempText += i18n("-no summary-");
570 tempText += "</a>"; 569 tempText += "</a>";
571 if ( KOPrefs::instance()->mWNViewShowLocation ) 570 if ( KOPrefs::instance()->mWNViewShowLocation )
572 if ( !ev->location().isEmpty() ) 571 if ( !ev->location().isEmpty() )
573 tempText += " ("+ev->location() +")"; 572 tempText += " ("+ev->location() +")";
574 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) 573 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents)
575 tempText += " ["+ev->relatedTo()->summary() +"]"; 574 tempText += " ["+ev->relatedTo()->summary() +"]";
576 tempText += "</td></tr>\n"; 575 tempText += "</td></tr>\n";
577 mText += tempText; 576 mText += tempText;
577 return true;
578} 578}
579 579
580bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) 580bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub )
581{ 581{
582 if ( mTodos.find( ev ) != mTodos.end() ) return false; 582 if ( mTodos.find( ev ) != mTodos.end() ) return false;
583 583
584 mTodos.append( ev ); 584 mTodos.append( ev );
585 if ( !isSub ) 585 if ( !isSub )
586 mText += "<p>"; 586 mText += "<p>";
587 else 587 else
588 mText += "<li>"; 588 mText += "<li>";
589 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; 589 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] ";
590 590
591 591
592 mText += ind; 592 mText += ind;
593 bool needClose = false; 593 bool needClose = false;
594 if ( ev->cancelled() ) { 594 if ( ev->cancelled() ) {
595 mText += "<font color=\"#F00000\">[c"; 595 mText += "<font color=\"#F00000\">[c";
596 needClose =true; 596 needClose =true;
597 597
598 } 598 }
599 if ( ev->isAlarmEnabled() ) { 599 if ( ev->isAlarmEnabled() ) {
600 if ( !needClose) 600 if ( !needClose)
601 mText +="["; 601 mText +="[";
602 mText += "a"; 602 mText += "a";
603 needClose =true; 603 needClose =true;
604 604
605 } 605 }
606 606
607 if ( ev->description().length() > 0 ) { 607 if ( ev->description().length() > 0 ) {
608 if ( !needClose) 608 if ( !needClose)
609 mText +="["; 609 mText +="[";
610 mText += "i"; 610 mText += "i";
611 needClose =true; 611 needClose =true;
612 } 612 }
613 // if ( ev->recurrence()->doesRecur() ) { 613 // if ( ev->recurrence()->doesRecur() ) {
614 // if ( !needClose) 614 // if ( !needClose)
615 // mText +="("; 615 // mText +="(";
616 // mText += "r"; 616 // mText += "r";
617 // needClose =true; 617 // needClose =true;
618 // } 618 // }
619 if ( needClose ) 619 if ( needClose )
620 mText += "] "; 620 mText += "] ";
621 if ( ev->cancelled() ) 621 if ( ev->cancelled() )
622 mText += "</font>"; 622 mText += "</font>";
623 mText += "<a href=\"todo:" + ev->uid() + "\">"; 623 mText += "<a href=\"todo:" + ev->uid() + "\">";
624 mText += ev->summary(); 624 mText += ev->summary();
625 mText += "</a>"; 625 mText += "</a>";
626 if ( ((Todo*)ev)->hasDueDate () ) { 626 if ( ((Todo*)ev)->hasDueDate () ) {
627 QString year = ""; 627 QString year = "";
628 int ye = ((Todo*)ev)->dtDue().date().year(); 628 int ye = ((Todo*)ev)->dtDue().date().year();
629 if ( QDateTime::currentDateTime().date().year() != ye ) 629 if ( QDateTime::currentDateTime().date().year() != ye )
630 year = QString::number( ye ); 630 year = QString::number( ye );
631 QString dfs = KGlobal::locale()->dateFormatShort(); 631 QString dfs = KGlobal::locale()->dateFormatShort();
632 KGlobal::locale()->setDateFormatShort("%d.%b"); 632 KGlobal::locale()->setDateFormatShort("%d.%b");
633 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; 633 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>";
634 KGlobal::locale()->setDateFormatShort(dfs); 634 KGlobal::locale()->setDateFormatShort(dfs);
635 } 635 }
636 if ( KOPrefs::instance()->mWNViewShowLocation ) 636 if ( KOPrefs::instance()->mWNViewShowLocation )
637 if ( !ev->location().isEmpty() ) 637 if ( !ev->location().isEmpty() )
638 mText += " ("+ev->location() +")"; 638 mText += " ("+ev->location() +")";
639 if ( !isSub ) { 639 if ( !isSub ) {
640 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) 640 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents)
641 mText += " ["+ev->relatedTo()->summary() +"]"; 641 mText += " ["+ev->relatedTo()->summary() +"]";
642 mText += "</p>\n"; 642 mText += "</p>\n";
643 } 643 }
644 else { 644 else {
645 ind += "-"; 645 ind += "-";
646 mText += "</li>\n"; 646 mText += "</li>\n";
647 } 647 }
648 QPtrList<Incidence> Relations = ev->relations(); 648 QPtrList<Incidence> Relations = ev->relations();
649 Incidence *to; 649 Incidence *to;
650 for (to=Relations.first();to;to=Relations.next()) { 650 for (to=Relations.first();to;to=Relations.next()) {
651 if (!((Todo*)to)->isCompleted()) 651 if (!((Todo*)to)->isCompleted())
652 appendTodo( to, ind , true ); 652 appendTodo( to, ind , true );
653 } 653 }
654 654
655 return true; 655 return true;
656} 656}
657 657
658/* 658/*
659 void KOWhatsNextView::createEventViewer() 659 void KOWhatsNextView::createEventViewer()
660 { 660 {
661 if (!mEventViewer) { 661 if (!mEventViewer) {
662 662
663 mEventViewer = new KOEventViewerDialog(this); 663 mEventViewer = new KOEventViewerDialog(this);
664 } 664 }
665 } 665 }
666*/ 666*/
667void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) 667void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v )
668{ 668{
669 mEventViewer = v; 669 mEventViewer = v;
670} 670}
671 671
672// TODO: Create this function in CalendarView and remove it from here 672// TODO: Create this function in CalendarView and remove it from here
673void KOWhatsNextView::showIncidence(const QString &uid) 673void KOWhatsNextView::showIncidence(const QString &uid)
674{ 674{
675 if ( !mEventViewer ) { 675 if ( !mEventViewer ) {
676 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); 676 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set ");
677 return; 677 return;
678 } 678 }
679 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; 679 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl;
680 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); 680 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1());
681 if (uid.startsWith("event:")) { 681 if (uid.startsWith("event:")) {
682#ifdef DESKTOP_VERSION 682#ifdef DESKTOP_VERSION
683 Event *event = calendar()->event(uid.mid(8)); 683 Event *event = calendar()->event(uid.mid(8));
684#else 684#else
685 Event *event = calendar()->event(uid.mid(6)); 685 Event *event = calendar()->event(uid.mid(6));
686#endif 686#endif
687 //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); 687 //qDebug("event %d uid %s ", event, uid.mid(6).latin1());
688 if (!event) return; 688 if (!event) return;
689 //createEventViewer(); 689 //createEventViewer();
690 mEventViewer->setEvent(event); 690 mEventViewer->setEvent(event);
691 } else if (uid.startsWith("todo:")) { 691 } else if (uid.startsWith("todo:")) {
692#ifdef DESKTOP_VERSION 692#ifdef DESKTOP_VERSION
693 Todo *todo = calendar()->todo(uid.mid(7)); 693 Todo *todo = calendar()->todo(uid.mid(7));
694#else 694#else
695 Todo *todo = calendar()->todo(uid.mid(5)); 695 Todo *todo = calendar()->todo(uid.mid(5));
696#endif 696#endif
697 if (!todo) return; 697 if (!todo) return;
698 //createEventViewer(); 698 //createEventViewer();
699 mEventViewer->setTodo(todo); 699 mEventViewer->setTodo(todo);
700 } else { 700 } else {
701 return; 701 return;
702 702
703 } 703 }
704 mEventViewer->showMe(); 704 mEventViewer->showMe();
705 mEventViewer->raise(); 705 mEventViewer->raise();
706} 706}
diff --git a/korganizer/kowhatsnextview.h b/korganizer/kowhatsnextview.h
index 1118bdd..9049268 100644
--- a/korganizer/kowhatsnextview.h
+++ b/korganizer/kowhatsnextview.h
@@ -1,96 +1,96 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19#ifndef KOWHATSNEXTVIEW_H 19#ifndef KOWHATSNEXTVIEW_H
20#define KOWHATSNEXTVIEW_H 20#define KOWHATSNEXTVIEW_H
21 21
22#include <qtextbrowser.h> 22#include <qtextbrowser.h>
23#include <qtimer.h> 23#include <qtimer.h>
24 24
25#include <korganizer/baseview.h> 25#include <korganizer/baseview.h>
26 26
27class QListView; 27class QListView;
28class QLabel; 28class QLabel;
29 29
30class KOEventViewerDialog; 30class KOEventViewerDialog;
31 31
32class WhatsNextTextBrowser : public QTextBrowser { 32class WhatsNextTextBrowser : public QTextBrowser {
33 Q_OBJECT 33 Q_OBJECT
34 public: 34 public:
35 WhatsNextTextBrowser(QWidget *parent) : QTextBrowser(parent) {} 35 WhatsNextTextBrowser(QWidget *parent) : QTextBrowser(parent) {}
36 36
37 void setSource(const QString &); 37 void setSource(const QString &);
38 38
39 signals: 39 signals:
40 void showIncidence(const QString &uid); 40 void showIncidence(const QString &uid);
41}; 41};
42 42
43 43
44/** 44/**
45 This class provides a view of the next events and todos 45 This class provides a view of the next events and todos
46*/ 46*/
47class KOWhatsNextView : public KOrg::BaseView 47class KOWhatsNextView : public KOrg::BaseView
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 KOWhatsNextView(Calendar *calendar, QWidget *parent = 0, 51 KOWhatsNextView(Calendar *calendar, QWidget *parent = 0,
52 const char *name = 0); 52 const char *name = 0);
53 ~KOWhatsNextView(); 53 ~KOWhatsNextView();
54 54
55 virtual int maxDatesHint(); 55 virtual int maxDatesHint();
56 virtual int currentDateCount(); 56 virtual int currentDateCount();
57 void setEventViewer(KOEventViewerDialog* v ); 57 void setEventViewer(KOEventViewerDialog* v );
58 virtual QPtrList<Incidence> selectedIncidences(); 58 virtual QPtrList<Incidence> selectedIncidences();
59 DateList selectedDates() 59 DateList selectedDates()
60 {DateList q; 60 {DateList q;
61 return q;} 61 return q;}
62 virtual void printPreview(CalPrinter *calPrinter, 62 virtual void printPreview(CalPrinter *calPrinter,
63 const QDate &, const QDate &); 63 const QDate &, const QDate &);
64 64
65 public slots: 65 public slots:
66 virtual void updateView(); 66 virtual void updateView();
67 virtual void showDates(const QDate &start, const QDate &end); 67 virtual void showDates(const QDate &start, const QDate &end);
68 virtual void showEvents(QPtrList<Event> eventList); 68 virtual void showEvents(QPtrList<Event> eventList);
69 void updateConfig(); 69 void updateConfig();
70 void changeEventDisplay(Event *, int); 70 void changeEventDisplay(Event *, int);
71 71
72 protected: 72 protected:
73 void appendEvent(Incidence *, bool reply=false, bool notRed = true); 73 bool appendEvent(Incidence *, bool reply=false, bool notRed = true, bool appendTable = false);
74 bool appendTodo(Incidence *, QString ind = "", bool isSub = false ); 74 bool appendTodo(Incidence *, QString ind = "", bool isSub = false );
75 void appendDay( int i, QDate date ); 75 void appendDay( int i, QDate date );
76 QDate mEventDate; 76 QDate mEventDate;
77 virtual void showEvent ( QShowEvent * ); 77 virtual void showEvent ( QShowEvent * );
78 virtual void hideEvent ( QHideEvent * ); 78 virtual void hideEvent ( QHideEvent * );
79 79
80 private slots: 80 private slots:
81 void showIncidence(const QString &); 81 void showIncidence(const QString &);
82 void restartTimer(); 82 void restartTimer();
83 83
84 84
85 private: 85 private:
86 //void createEventViewer(); 86 //void createEventViewer();
87 QTimer* mTimer; 87 QTimer* mTimer;
88 QTextBrowser *mView; 88 QTextBrowser *mView;
89 QString mText; 89 QString mText;
90 // QLabel *mDateLabel; 90 // QLabel *mDateLabel;
91 KOEventViewerDialog *mEventViewer; 91 KOEventViewerDialog *mEventViewer;
92 92
93 QValueList<Incidence *> mTodos; 93 QValueList<Incidence *> mTodos;
94}; 94};
95 95
96#endif 96#endif