summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-29 23:13:22 (UTC)
committer zautrix <zautrix>2004-10-29 23:13:22 (UTC)
commitda80b510e4643fa3f78cf3f97af108e87097583d (patch) (unidiff)
tree01c328362a6bf1898853ba26fd5d48eb5cff1e27
parentaafa695508796e86e9f267633ea5e6965d876031 (diff)
downloadkdepimpi-da80b510e4643fa3f78cf3f97af108e87097583d.zip
kdepimpi-da80b510e4643fa3f78cf3f97af108e87097583d.tar.gz
kdepimpi-da80b510e4643fa3f78cf3f97af108e87097583d.tar.bz2
added better category handling to kapi
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp4
-rw-r--r--kabc/addressee.h2
-rw-r--r--kabc/field.cpp6
-rw-r--r--kaddressbook/kabcore.cpp54
-rw-r--r--kaddressbook/kabcore.h5
5 files changed, 68 insertions, 3 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index eec0f1f..3ce733d 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,2133 +1,2137 @@
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 if ( ! found ) // LR try this one...
329 mData->phoneNumbers.append( *phoneItAD ); 329 mData->phoneNumbers.append( *phoneItAD );
330 } 330 }
331 if ( isSubSet ) { 331 if ( isSubSet ) {
332 // ************* emails; 332 // ************* emails;
333 t = mData->emails; 333 t = mData->emails;
334 tAD = ad.mData->emails; 334 tAD = ad.mData->emails;
335 for ( iii = 0; iii < tAD.count(); ++iii) 335 for ( iii = 0; iii < tAD.count(); ++iii)
336 if ( !t.contains(tAD[iii] ) ) 336 if ( !t.contains(tAD[iii] ) )
337 mData->emails.append( tAD[iii] ); 337 mData->emails.append( tAD[iii] );
338 } 338 }
339 339
340 // ************* categories; 340 // ************* categories;
341 t = mData->categories; 341 t = mData->categories;
342 tAD = ad.mData->categories; 342 tAD = ad.mData->categories;
343 for ( iii = 0; iii < tAD.count(); ++iii) 343 for ( iii = 0; iii < tAD.count(); ++iii)
344 if ( !t.contains(tAD[iii] ) ) 344 if ( !t.contains(tAD[iii] ) )
345 mData->categories.append( tAD[iii] ); 345 mData->categories.append( tAD[iii] );
346 QStringList::ConstIterator it; 346 QStringList::ConstIterator it;
347 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 ) {
348 QString qualifiedName = (*it).left( (*it).find( ":" )); 348 QString qualifiedName = (*it).left( (*it).find( ":" ));
349 bool found = false; 349 bool found = false;
350 QStringList::ConstIterator itL; 350 QStringList::ConstIterator itL;
351 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { 351 for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) {
352 if ( (*itL).startsWith( qualifiedName ) ) { 352 if ( (*itL).startsWith( qualifiedName ) ) {
353 found = true; 353 found = true;
354 break; 354 break;
355 } 355 }
356 } 356 }
357 if ( ! found ) { 357 if ( ! found ) {
358 mData->custom.append( *it ); 358 mData->custom.append( *it );
359 } 359 }
360 } 360 }
361 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;
362 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;
363 if ( !mData->sound.isIntern() ) { 363 if ( !mData->sound.isIntern() ) {
364 if ( mData->sound.url().isEmpty() ) { 364 if ( mData->sound.url().isEmpty() ) {
365 mData->sound = ad.mData->sound; 365 mData->sound = ad.mData->sound;
366 } 366 }
367 } 367 }
368 if ( !mData->agent.isIntern() ) { 368 if ( !mData->agent.isIntern() ) {
369 if ( mData->agent.url().isEmpty() ) { 369 if ( mData->agent.url().isEmpty() ) {
370 mData->agent = ad.mData->agent; 370 mData->agent = ad.mData->agent;
371 } 371 }
372 } 372 }
373 { 373 {
374 Key::List::Iterator itA; 374 Key::List::Iterator itA;
375 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 ) {
376 bool found = false; 376 bool found = false;
377 Key::List::Iterator it; 377 Key::List::Iterator it;
378 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 378 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
379 if ( (*it) == (*itA)) { 379 if ( (*it) == (*itA)) {
380 found = true; 380 found = true;
381 break; 381 break;
382 382
383 } 383 }
384 } 384 }
385 if ( ! found ) { 385 if ( ! found ) {
386 mData->keys.append( *itA ); 386 mData->keys.append( *itA );
387 } 387 }
388 } 388 }
389 } 389 }
390 KABC::Address::List::Iterator addressIterA; 390 KABC::Address::List::Iterator addressIterA;
391 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 ) {
392 bool found = false; 392 bool found = false;
393 KABC::Address::List::Iterator addressIter; 393 KABC::Address::List::Iterator addressIter;
394 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 394 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
395 ++addressIter ) { 395 ++addressIter ) {
396 if ( (*addressIter) == (*addressIterA)) { 396 if ( (*addressIter) == (*addressIterA)) {
397 found = true; 397 found = true;
398 (*addressIter).setType( (*addressIterA).type() ); 398 (*addressIter).setType( (*addressIterA).type() );
399 break; 399 break;
400 } 400 }
401 401
402 } 402 }
403 if ( isSubSet && ! found ) { 403 if ( isSubSet && ! found ) {
404 mData->addresses.append( *addressIterA ); 404 mData->addresses.append( *addressIterA );
405 } 405 }
406 } 406 }
407 //qDebug("merge contact %s ", ad.uid().latin1()); 407 //qDebug("merge contact %s ", ad.uid().latin1());
408 setUid( ad.uid() ); 408 setUid( ad.uid() );
409 setRevision( ad.revision() ); 409 setRevision( ad.revision() );
410} 410}
411 411
412bool Addressee::removeVoice() 412bool Addressee::removeVoice()
413{ 413{
414 PhoneNumber::List phoneN = phoneNumbers(); 414 PhoneNumber::List phoneN = phoneNumbers();
415 PhoneNumber::List::Iterator phoneIt; 415 PhoneNumber::List::Iterator phoneIt;
416 bool found = false; 416 bool found = false;
417 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 417 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
418 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 418 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
419 if ((*phoneIt).type() - PhoneNumber::Voice ) { 419 if ((*phoneIt).type() - PhoneNumber::Voice ) {
420 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 420 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
421 insertPhoneNumber( (*phoneIt) ); 421 insertPhoneNumber( (*phoneIt) );
422 found = true; 422 found = true;
423 } 423 }
424 } 424 }
425 425
426 } 426 }
427 return found; 427 return found;
428} 428}
429 429
430bool Addressee::containsAdr(const Addressee& ad ) 430bool Addressee::containsAdr(const Addressee& ad )
431{ 431{
432 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;
433 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;
434 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 ;
435 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 ;
436 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 ;
437 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 ;
438 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 ;
439 439
440 // compare phone numbers 440 // compare phone numbers
441 PhoneNumber::List phoneN = ad.phoneNumbers(); 441 PhoneNumber::List phoneN = ad.phoneNumbers();
442 PhoneNumber::List::Iterator phoneIt; 442 PhoneNumber::List::Iterator phoneIt;
443 bool found = false; 443 bool found = false;
444 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 444 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
445 bool found = false; 445 bool found = false;
446 PhoneNumber::List phoneL = ad.phoneNumbers(); 446 PhoneNumber::List phoneL = ad.phoneNumbers();
447 PhoneNumber::List::Iterator phoneItL; 447 PhoneNumber::List::Iterator phoneItL;
448 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { 448 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
449 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { 449 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
450 found = true; 450 found = true;
451 break; 451 break;
452 } 452 }
453 } 453 }
454 if ( ! found ) 454 if ( ! found )
455 return false; 455 return false;
456 } 456 }
457 return true; 457 return true;
458 458
459} 459}
460void Addressee::simplifyAddresses() 460void Addressee::simplifyAddresses()
461{ 461{
462 462
463 463
464 Address::List list; 464 Address::List list;
465 Address::List::Iterator it; 465 Address::List::Iterator it;
466 Address::List::Iterator it2; 466 Address::List::Iterator it2;
467 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 467 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
468 it2 = it; 468 it2 = it;
469 ++it2; 469 ++it2;
470 for( ; it2 != mData->addresses.end(); ++it2 ) { 470 for( ; it2 != mData->addresses.end(); ++it2 ) {
471 if ( (*it) == (*it2) ) { 471 if ( (*it) == (*it2) ) {
472 list.append( *it ); 472 list.append( *it );
473 break; 473 break;
474 } 474 }
475 } 475 }
476 } 476 }
477 for( it = list.begin(); it != list.end(); ++it ) { 477 for( it = list.begin(); it != list.end(); ++it ) {
478 removeAddress( (*it) ); 478 removeAddress( (*it) );
479 } 479 }
480 480
481 list.clear(); 481 list.clear();
482 int max = 2; 482 int max = 2;
483 if ( mData->url.isValid() ) 483 if ( mData->url.isValid() )
484 max = 1; 484 max = 1;
485 if ( mData->addresses.count() <= max ) return ; 485 if ( mData->addresses.count() <= max ) return ;
486 int count = 0; 486 int count = 0;
487 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 487 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
488 if ( count >= max ) 488 if ( count >= max )
489 list.append( *it ); 489 list.append( *it );
490 ++count; 490 ++count;
491 } 491 }
492 for( it = list.begin(); it != list.end(); ++it ) { 492 for( it = list.begin(); it != list.end(); ++it ) {
493 removeAddress( (*it) ); 493 removeAddress( (*it) );
494 } 494 }
495} 495}
496 496
497// removes all emails but the first 497// removes all emails but the first
498// needed by phone sync 498// needed by phone sync
499void Addressee::simplifyEmails() 499void Addressee::simplifyEmails()
500{ 500{
501 if ( mData->emails.count() == 0 ) return ; 501 if ( mData->emails.count() == 0 ) return ;
502 QString email = mData->emails.first(); 502 QString email = mData->emails.first();
503 detach(); 503 detach();
504 mData->emails.clear(); 504 mData->emails.clear();
505 mData->emails.append( email ); 505 mData->emails.append( email );
506} 506}
507 507
508void Addressee::simplifyPhoneNumbers() 508void Addressee::simplifyPhoneNumbers()
509{ 509{
510 int max = 4; 510 int max = 4;
511 int inList = mData->phoneNumbers.count(); 511 int inList = mData->phoneNumbers.count();
512 KABC::PhoneNumber::List removeNumbers; 512 KABC::PhoneNumber::List removeNumbers;
513 KABC::PhoneNumber::List::Iterator phoneIter; 513 KABC::PhoneNumber::List::Iterator phoneIter;
514 if ( inList > max ) { 514 if ( inList > max ) {
515 // delete non-preferred numbers 515 // delete non-preferred numbers
516 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 516 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
517 ++phoneIter ) { 517 ++phoneIter ) {
518 if ( inList > max ) { 518 if ( inList > max ) {
519 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { 519 if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) {
520 removeNumbers.append( ( *phoneIter ) ); 520 removeNumbers.append( ( *phoneIter ) );
521 --inList; 521 --inList;
522 } 522 }
523 } else 523 } else
524 break; 524 break;
525 } 525 }
526 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 526 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
527 ++phoneIter ) { 527 ++phoneIter ) {
528 removePhoneNumber(( *phoneIter )); 528 removePhoneNumber(( *phoneIter ));
529 } 529 }
530 // delete preferred numbers 530 // delete preferred numbers
531 if ( inList > max ) { 531 if ( inList > max ) {
532 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 532 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
533 ++phoneIter ) { 533 ++phoneIter ) {
534 if ( inList > max ) { 534 if ( inList > max ) {
535 removeNumbers.append( ( *phoneIter ) ); 535 removeNumbers.append( ( *phoneIter ) );
536 --inList; 536 --inList;
537 } else 537 } else
538 break; 538 break;
539 } 539 }
540 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 540 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
541 ++phoneIter ) { 541 ++phoneIter ) {
542 removePhoneNumber(( *phoneIter )); 542 removePhoneNumber(( *phoneIter ));
543 } 543 }
544 } 544 }
545 } 545 }
546 // remove non-numeric characters 546 // remove non-numeric characters
547 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 547 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
548 ++phoneIter ) { 548 ++phoneIter ) {
549 if ( ! ( *phoneIter ).simplifyNumber() ) 549 if ( ! ( *phoneIter ).simplifyNumber() )
550 removeNumbers.append( ( *phoneIter ) ); 550 removeNumbers.append( ( *phoneIter ) );
551 } 551 }
552 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 552 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
553 ++phoneIter ) { 553 ++phoneIter ) {
554 removePhoneNumber(( *phoneIter )); 554 removePhoneNumber(( *phoneIter ));
555 } 555 }
556} 556}
557void Addressee::simplifyPhoneNumberTypes() 557void Addressee::simplifyPhoneNumberTypes()
558{ 558{
559 KABC::PhoneNumber::List::Iterator phoneIter; 559 KABC::PhoneNumber::List::Iterator phoneIter;
560 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 560 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
561 ++phoneIter ) 561 ++phoneIter )
562 ( *phoneIter ).simplifyType(); 562 ( *phoneIter ).simplifyType();
563} 563}
564void Addressee::removeID(const QString &prof) 564void Addressee::removeID(const QString &prof)
565{ 565{
566 detach(); 566 detach();
567 if ( prof.isEmpty() ) 567 if ( prof.isEmpty() )
568 mData->mExternalId = ":"; 568 mData->mExternalId = ":";
569 else 569 else
570 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 570 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
571 571
572} 572}
573void Addressee::setID( const QString & prof , const QString & id ) 573void Addressee::setID( const QString & prof , const QString & id )
574{ 574{
575 detach(); 575 detach();
576 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 576 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
577 //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() );
578} 578}
579void Addressee::setTempSyncStat( int id ) 579void Addressee::setTempSyncStat( int id )
580{ 580{
581 if ( mData->mTempSyncStat == id ) return; 581 if ( mData->mTempSyncStat == id ) return;
582 detach(); 582 detach();
583 mData->mTempSyncStat = id; 583 mData->mTempSyncStat = id;
584} 584}
585int Addressee::tempSyncStat() const 585int Addressee::tempSyncStat() const
586{ 586{
587 return mData->mTempSyncStat; 587 return mData->mTempSyncStat;
588} 588}
589 589
590QString Addressee::getID( const QString & prof) 590QString Addressee::getID( const QString & prof)
591{ 591{
592 return KIdManager::getId ( mData->mExternalId, prof ); 592 return KIdManager::getId ( mData->mExternalId, prof );
593} 593}
594 594
595void Addressee::setCsum( const QString & prof , const QString & id ) 595void Addressee::setCsum( const QString & prof , const QString & id )
596{ 596{
597 detach(); 597 detach();
598 //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() );
599 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 599 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
600 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 600 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
601} 601}
602 602
603QString Addressee::getCsum( const QString & prof) 603QString Addressee::getCsum( const QString & prof)
604{ 604{
605 return KIdManager::getCsum ( mData->mExternalId, prof ); 605 return KIdManager::getCsum ( mData->mExternalId, prof );
606} 606}
607 607
608void Addressee::setIDStr( const QString & s ) 608void Addressee::setIDStr( const QString & s )
609{ 609{
610 detach(); 610 detach();
611 mData->mExternalId = s; 611 mData->mExternalId = s;
612} 612}
613 613
614QString Addressee::IDStr() const 614QString Addressee::IDStr() const
615{ 615{
616 return mData->mExternalId; 616 return mData->mExternalId;
617} 617}
618 618
619void Addressee::setExternalUID( const QString &id ) 619void Addressee::setExternalUID( const QString &id )
620{ 620{
621 if ( id == mData->externalUID ) return; 621 if ( id == mData->externalUID ) return;
622 detach(); 622 detach();
623 mData->empty = false; 623 mData->empty = false;
624 mData->externalUID = id; 624 mData->externalUID = id;
625} 625}
626 626
627QString Addressee::externalUID() const 627QString Addressee::externalUID() const
628{ 628{
629 return mData->externalUID; 629 return mData->externalUID;
630} 630}
631void Addressee::setOriginalExternalUID( const QString &id ) 631void Addressee::setOriginalExternalUID( const QString &id )
632{ 632{
633 if ( id == mData->originalExternalUID ) return; 633 if ( id == mData->originalExternalUID ) return;
634 detach(); 634 detach();
635 mData->empty = false; 635 mData->empty = false;
636 //qDebug("*******Set orig uid %s ", id.latin1()); 636 //qDebug("*******Set orig uid %s ", id.latin1());
637 mData->originalExternalUID = id; 637 mData->originalExternalUID = id;
638} 638}
639 639
640QString Addressee::originalExternalUID() const 640QString Addressee::originalExternalUID() const
641{ 641{
642 return mData->originalExternalUID; 642 return mData->originalExternalUID;
643} 643}
644 644
645void Addressee::setUid( const QString &id ) 645void Addressee::setUid( const QString &id )
646{ 646{
647 if ( id == mData->uid ) return; 647 if ( id == mData->uid ) return;
648 detach(); 648 detach();
649 //qDebug("****setuid %s ", id.latin1()); 649 //qDebug("****setuid %s ", id.latin1());
650 mData->empty = false; 650 mData->empty = false;
651 mData->uid = id; 651 mData->uid = id;
652} 652}
653 653
654QString Addressee::uid() const 654QString Addressee::uid() const
655{ 655{
656 if ( mData->uid.isEmpty() ) 656 if ( mData->uid.isEmpty() )
657 mData->uid = KApplication::randomString( 10 ); 657 mData->uid = KApplication::randomString( 10 );
658 658
659 return mData->uid; 659 return mData->uid;
660} 660}
661 661
662QString Addressee::uidLabel() 662QString Addressee::uidLabel()
663{ 663{
664 return i18n("Unique Identifier"); 664 return i18n("Unique Identifier");
665} 665}
666 666
667void Addressee::setName( const QString &name ) 667void Addressee::setName( const QString &name )
668{ 668{
669 if ( name == mData->name ) return; 669 if ( name == mData->name ) return;
670 detach(); 670 detach();
671 mData->empty = false; 671 mData->empty = false;
672 mData->name = name; 672 mData->name = name;
673} 673}
674 674
675QString Addressee::name() const 675QString Addressee::name() const
676{ 676{
677 return mData->name; 677 return mData->name;
678} 678}
679 679
680QString Addressee::nameLabel() 680QString Addressee::nameLabel()
681{ 681{
682 return i18n("Name"); 682 return i18n("Name");
683} 683}
684 684
685 685
686void Addressee::setFormattedName( const QString &formattedName ) 686void Addressee::setFormattedName( const QString &formattedName )
687{ 687{
688 if ( formattedName == mData->formattedName ) return; 688 if ( formattedName == mData->formattedName ) return;
689 detach(); 689 detach();
690 mData->empty = false; 690 mData->empty = false;
691 mData->formattedName = formattedName; 691 mData->formattedName = formattedName;
692} 692}
693 693
694QString Addressee::formattedName() const 694QString Addressee::formattedName() const
695{ 695{
696 return mData->formattedName; 696 return mData->formattedName;
697} 697}
698 698
699QString Addressee::formattedNameLabel() 699QString Addressee::formattedNameLabel()
700{ 700{
701 return i18n("Formatted Name"); 701 return i18n("Formatted Name");
702} 702}
703 703
704 704
705void Addressee::setFamilyName( const QString &familyName ) 705void Addressee::setFamilyName( const QString &familyName )
706{ 706{
707 if ( familyName == mData->familyName ) return; 707 if ( familyName == mData->familyName ) return;
708 detach(); 708 detach();
709 mData->empty = false; 709 mData->empty = false;
710 mData->familyName = familyName; 710 mData->familyName = familyName;
711} 711}
712 712
713QString Addressee::familyName() const 713QString Addressee::familyName() const
714{ 714{
715 return mData->familyName; 715 return mData->familyName;
716} 716}
717 717
718QString Addressee::familyNameLabel() 718QString Addressee::familyNameLabel()
719{ 719{
720 return i18n("Family Name"); 720 return i18n("Family Name");
721} 721}
722 722
723 723
724void Addressee::setGivenName( const QString &givenName ) 724void Addressee::setGivenName( const QString &givenName )
725{ 725{
726 if ( givenName == mData->givenName ) return; 726 if ( givenName == mData->givenName ) return;
727 detach(); 727 detach();
728 mData->empty = false; 728 mData->empty = false;
729 mData->givenName = givenName; 729 mData->givenName = givenName;
730} 730}
731 731
732QString Addressee::givenName() const 732QString Addressee::givenName() const
733{ 733{
734 return mData->givenName; 734 return mData->givenName;
735} 735}
736 736
737QString Addressee::givenNameLabel() 737QString Addressee::givenNameLabel()
738{ 738{
739 return i18n("Given Name"); 739 return i18n("Given Name");
740} 740}
741 741
742 742
743void Addressee::setAdditionalName( const QString &additionalName ) 743void Addressee::setAdditionalName( const QString &additionalName )
744{ 744{
745 if ( additionalName == mData->additionalName ) return; 745 if ( additionalName == mData->additionalName ) return;
746 detach(); 746 detach();
747 mData->empty = false; 747 mData->empty = false;
748 mData->additionalName = additionalName; 748 mData->additionalName = additionalName;
749} 749}
750 750
751QString Addressee::additionalName() const 751QString Addressee::additionalName() const
752{ 752{
753 return mData->additionalName; 753 return mData->additionalName;
754} 754}
755 755
756QString Addressee::additionalNameLabel() 756QString Addressee::additionalNameLabel()
757{ 757{
758 return i18n("Additional Names"); 758 return i18n("Additional Names");
759} 759}
760 760
761 761
762void Addressee::setPrefix( const QString &prefix ) 762void Addressee::setPrefix( const QString &prefix )
763{ 763{
764 if ( prefix == mData->prefix ) return; 764 if ( prefix == mData->prefix ) return;
765 detach(); 765 detach();
766 mData->empty = false; 766 mData->empty = false;
767 mData->prefix = prefix; 767 mData->prefix = prefix;
768} 768}
769 769
770QString Addressee::prefix() const 770QString Addressee::prefix() const
771{ 771{
772 return mData->prefix; 772 return mData->prefix;
773} 773}
774 774
775QString Addressee::prefixLabel() 775QString Addressee::prefixLabel()
776{ 776{
777 return i18n("Honorific Prefixes"); 777 return i18n("Honorific Prefixes");
778} 778}
779 779
780 780
781void Addressee::setSuffix( const QString &suffix ) 781void Addressee::setSuffix( const QString &suffix )
782{ 782{
783 if ( suffix == mData->suffix ) return; 783 if ( suffix == mData->suffix ) return;
784 detach(); 784 detach();
785 mData->empty = false; 785 mData->empty = false;
786 mData->suffix = suffix; 786 mData->suffix = suffix;
787} 787}
788 788
789QString Addressee::suffix() const 789QString Addressee::suffix() const
790{ 790{
791 return mData->suffix; 791 return mData->suffix;
792} 792}
793 793
794QString Addressee::suffixLabel() 794QString Addressee::suffixLabel()
795{ 795{
796 return i18n("Honorific Suffixes"); 796 return i18n("Honorific Suffixes");
797} 797}
798 798
799 799
800void Addressee::setNickName( const QString &nickName ) 800void Addressee::setNickName( const QString &nickName )
801{ 801{
802 if ( nickName == mData->nickName ) return; 802 if ( nickName == mData->nickName ) return;
803 detach(); 803 detach();
804 mData->empty = false; 804 mData->empty = false;
805 mData->nickName = nickName; 805 mData->nickName = nickName;
806} 806}
807 807
808QString Addressee::nickName() const 808QString Addressee::nickName() const
809{ 809{
810 return mData->nickName; 810 return mData->nickName;
811} 811}
812 812
813QString Addressee::nickNameLabel() 813QString Addressee::nickNameLabel()
814{ 814{
815 return i18n("Nick Name"); 815 return i18n("Nick Name");
816} 816}
817 817
818 818
819void Addressee::setBirthday( const QDateTime &birthday ) 819void Addressee::setBirthday( const QDateTime &birthday )
820{ 820{
821 if ( birthday == mData->birthday ) return; 821 if ( birthday == mData->birthday ) return;
822 detach(); 822 detach();
823 mData->empty = false; 823 mData->empty = false;
824 mData->birthday = birthday; 824 mData->birthday = birthday;
825} 825}
826 826
827QDateTime Addressee::birthday() const 827QDateTime Addressee::birthday() const
828{ 828{
829 return mData->birthday; 829 return mData->birthday;
830} 830}
831 831
832QString Addressee::birthdayLabel() 832QString Addressee::birthdayLabel()
833{ 833{
834 return i18n("Birthday"); 834 return i18n("Birthday");
835} 835}
836 836
837 837
838QString Addressee::homeAddressStreetLabel() 838QString Addressee::homeAddressStreetLabel()
839{ 839{
840 return i18n("Home Address Street"); 840 return i18n("Home Address Street");
841} 841}
842 842
843 843
844QString Addressee::homeAddressLocalityLabel() 844QString Addressee::homeAddressLocalityLabel()
845{ 845{
846 return i18n("Home Address Locality"); 846 return i18n("Home Address Locality");
847} 847}
848 848
849 849
850QString Addressee::homeAddressRegionLabel() 850QString Addressee::homeAddressRegionLabel()
851{ 851{
852 return i18n("Home Address Region"); 852 return i18n("Home Address Region");
853} 853}
854 854
855 855
856QString Addressee::homeAddressPostalCodeLabel() 856QString Addressee::homeAddressPostalCodeLabel()
857{ 857{
858 return i18n("Home Address Postal Code"); 858 return i18n("Home Address Postal Code");
859} 859}
860 860
861 861
862QString Addressee::homeAddressCountryLabel() 862QString Addressee::homeAddressCountryLabel()
863{ 863{
864 return i18n("Home Address Country"); 864 return i18n("Home Address Country");
865} 865}
866 866
867 867
868QString Addressee::homeAddressLabelLabel() 868QString Addressee::homeAddressLabelLabel()
869{ 869{
870 return i18n("Home Address Label"); 870 return i18n("Home Address Label");
871} 871}
872 872
873 873
874QString Addressee::businessAddressStreetLabel() 874QString Addressee::businessAddressStreetLabel()
875{ 875{
876 return i18n("Business Address Street"); 876 return i18n("Business Address Street");
877} 877}
878 878
879 879
880QString Addressee::businessAddressLocalityLabel() 880QString Addressee::businessAddressLocalityLabel()
881{ 881{
882 return i18n("Business Address Locality"); 882 return i18n("Business Address Locality");
883} 883}
884 884
885 885
886QString Addressee::businessAddressRegionLabel() 886QString Addressee::businessAddressRegionLabel()
887{ 887{
888 return i18n("Business Address Region"); 888 return i18n("Business Address Region");
889} 889}
890 890
891 891
892QString Addressee::businessAddressPostalCodeLabel() 892QString Addressee::businessAddressPostalCodeLabel()
893{ 893{
894 return i18n("Business Address Postal Code"); 894 return i18n("Business Address Postal Code");
895} 895}
896 896
897 897
898QString Addressee::businessAddressCountryLabel() 898QString Addressee::businessAddressCountryLabel()
899{ 899{
900 return i18n("Business Address Country"); 900 return i18n("Business Address Country");
901} 901}
902 902
903 903
904QString Addressee::businessAddressLabelLabel() 904QString Addressee::businessAddressLabelLabel()
905{ 905{
906 return i18n("Business Address Label"); 906 return i18n("Business Address Label");
907} 907}
908 908
909 909
910QString Addressee::homePhoneLabel() 910QString Addressee::homePhoneLabel()
911{ 911{
912 return i18n("Home Phone"); 912 return i18n("Home Phone");
913} 913}
914 914
915 915
916QString Addressee::businessPhoneLabel() 916QString Addressee::businessPhoneLabel()
917{ 917{
918 return i18n("Business Phone"); 918 return i18n("Business Phone");
919} 919}
920 920
921 921
922QString Addressee::mobilePhoneLabel() 922QString Addressee::mobilePhoneLabel()
923{ 923{
924 return i18n("Mobile Phone"); 924 return i18n("Mobile Phone");
925} 925}
926 926
927 927
928QString Addressee::homeFaxLabel() 928QString Addressee::homeFaxLabel()
929{ 929{
930 return i18n("Home Fax"); 930 return i18n("Home Fax");
931} 931}
932 932
933 933
934QString Addressee::businessFaxLabel() 934QString Addressee::businessFaxLabel()
935{ 935{
936 return i18n("Business Fax"); 936 return i18n("Business Fax");
937} 937}
938 938
939 939
940QString Addressee::carPhoneLabel() 940QString Addressee::carPhoneLabel()
941{ 941{
942 return i18n("Car Phone"); 942 return i18n("Car Phone");
943} 943}
944 944
945 945
946QString Addressee::isdnLabel() 946QString Addressee::isdnLabel()
947{ 947{
948 return i18n("ISDN"); 948 return i18n("ISDN");
949} 949}
950 950
951 951
952QString Addressee::pagerLabel() 952QString Addressee::pagerLabel()
953{ 953{
954 return i18n("Pager"); 954 return i18n("Pager");
955} 955}
956 956
957QString Addressee::sipLabel() 957QString Addressee::sipLabel()
958{ 958{
959 return i18n("SIP"); 959 return i18n("SIP");
960} 960}
961 961
962QString Addressee::emailLabel() 962QString Addressee::emailLabel()
963{ 963{
964 return i18n("Email Address"); 964 return i18n("Email Address");
965} 965}
966 966
967 967
968void Addressee::setMailer( const QString &mailer ) 968void Addressee::setMailer( const QString &mailer )
969{ 969{
970 if ( mailer == mData->mailer ) return; 970 if ( mailer == mData->mailer ) return;
971 detach(); 971 detach();
972 mData->empty = false; 972 mData->empty = false;
973 mData->mailer = mailer; 973 mData->mailer = mailer;
974} 974}
975 975
976QString Addressee::mailer() const 976QString Addressee::mailer() const
977{ 977{
978 return mData->mailer; 978 return mData->mailer;
979} 979}
980 980
981QString Addressee::mailerLabel() 981QString Addressee::mailerLabel()
982{ 982{
983 return i18n("Mail Client"); 983 return i18n("Mail Client");
984} 984}
985 985
986 986
987void Addressee::setTimeZone( const TimeZone &timeZone ) 987void Addressee::setTimeZone( const TimeZone &timeZone )
988{ 988{
989 if ( timeZone == mData->timeZone ) return; 989 if ( timeZone == mData->timeZone ) return;
990 detach(); 990 detach();
991 mData->empty = false; 991 mData->empty = false;
992 mData->timeZone = timeZone; 992 mData->timeZone = timeZone;
993} 993}
994 994
995TimeZone Addressee::timeZone() const 995TimeZone Addressee::timeZone() const
996{ 996{
997 return mData->timeZone; 997 return mData->timeZone;
998} 998}
999 999
1000QString Addressee::timeZoneLabel() 1000QString Addressee::timeZoneLabel()
1001{ 1001{
1002 return i18n("Time Zone"); 1002 return i18n("Time Zone");
1003} 1003}
1004 1004
1005 1005
1006void Addressee::setGeo( const Geo &geo ) 1006void Addressee::setGeo( const Geo &geo )
1007{ 1007{
1008 if ( geo == mData->geo ) return; 1008 if ( geo == mData->geo ) return;
1009 detach(); 1009 detach();
1010 mData->empty = false; 1010 mData->empty = false;
1011 mData->geo = geo; 1011 mData->geo = geo;
1012} 1012}
1013 1013
1014Geo Addressee::geo() const 1014Geo Addressee::geo() const
1015{ 1015{
1016 return mData->geo; 1016 return mData->geo;
1017} 1017}
1018 1018
1019QString Addressee::geoLabel() 1019QString Addressee::geoLabel()
1020{ 1020{
1021 return i18n("Geographic Position"); 1021 return i18n("Geographic Position");
1022} 1022}
1023 1023
1024 1024
1025void Addressee::setTitle( const QString &title ) 1025void Addressee::setTitle( const QString &title )
1026{ 1026{
1027 if ( title == mData->title ) return; 1027 if ( title == mData->title ) return;
1028 detach(); 1028 detach();
1029 mData->empty = false; 1029 mData->empty = false;
1030 mData->title = title; 1030 mData->title = title;
1031} 1031}
1032 1032
1033QString Addressee::title() const 1033QString Addressee::title() const
1034{ 1034{
1035 return mData->title; 1035 return mData->title;
1036} 1036}
1037 1037
1038QString Addressee::titleLabel() 1038QString Addressee::titleLabel()
1039{ 1039{
1040 return i18n("Title"); 1040 return i18n("Title");
1041} 1041}
1042 1042
1043 1043
1044void Addressee::setRole( const QString &role ) 1044void Addressee::setRole( const QString &role )
1045{ 1045{
1046 if ( role == mData->role ) return; 1046 if ( role == mData->role ) return;
1047 detach(); 1047 detach();
1048 mData->empty = false; 1048 mData->empty = false;
1049 mData->role = role; 1049 mData->role = role;
1050} 1050}
1051 1051
1052QString Addressee::role() const 1052QString Addressee::role() const
1053{ 1053{
1054 return mData->role; 1054 return mData->role;
1055} 1055}
1056 1056
1057QString Addressee::roleLabel() 1057QString Addressee::roleLabel()
1058{ 1058{
1059 return i18n("Role"); 1059 return i18n("Role");
1060} 1060}
1061 1061
1062 1062
1063void Addressee::setOrganization( const QString &organization ) 1063void Addressee::setOrganization( const QString &organization )
1064{ 1064{
1065 if ( organization == mData->organization ) return; 1065 if ( organization == mData->organization ) return;
1066 detach(); 1066 detach();
1067 mData->empty = false; 1067 mData->empty = false;
1068 mData->organization = organization; 1068 mData->organization = organization;
1069} 1069}
1070 1070
1071QString Addressee::organization() const 1071QString Addressee::organization() const
1072{ 1072{
1073 return mData->organization; 1073 return mData->organization;
1074} 1074}
1075 1075
1076QString Addressee::organizationLabel() 1076QString Addressee::organizationLabel()
1077{ 1077{
1078 return i18n("Organization"); 1078 return i18n("Organization");
1079} 1079}
1080 1080
1081 1081
1082void Addressee::setNote( const QString &note ) 1082void Addressee::setNote( const QString &note )
1083{ 1083{
1084 if ( note == mData->note ) return; 1084 if ( note == mData->note ) return;
1085 detach(); 1085 detach();
1086 mData->empty = false; 1086 mData->empty = false;
1087 mData->note = note; 1087 mData->note = note;
1088} 1088}
1089 1089
1090QString Addressee::note() const 1090QString Addressee::note() const
1091{ 1091{
1092 return mData->note; 1092 return mData->note;
1093} 1093}
1094 1094
1095QString Addressee::noteLabel() 1095QString Addressee::noteLabel()
1096{ 1096{
1097 return i18n("Note"); 1097 return i18n("Note");
1098} 1098}
1099 1099
1100 1100
1101void Addressee::setProductId( const QString &productId ) 1101void Addressee::setProductId( const QString &productId )
1102{ 1102{
1103 if ( productId == mData->productId ) return; 1103 if ( productId == mData->productId ) return;
1104 detach(); 1104 detach();
1105 mData->empty = false; 1105 mData->empty = false;
1106 mData->productId = productId; 1106 mData->productId = productId;
1107} 1107}
1108 1108
1109QString Addressee::productId() const 1109QString Addressee::productId() const
1110{ 1110{
1111 return mData->productId; 1111 return mData->productId;
1112} 1112}
1113 1113
1114QString Addressee::productIdLabel() 1114QString Addressee::productIdLabel()
1115{ 1115{
1116 return i18n("Product Identifier"); 1116 return i18n("Product Identifier");
1117} 1117}
1118 1118
1119 1119
1120void Addressee::setRevision( const QDateTime &revision ) 1120void Addressee::setRevision( const QDateTime &revision )
1121{ 1121{
1122 if ( revision == mData->revision ) return; 1122 if ( revision == mData->revision ) return;
1123 detach(); 1123 detach();
1124 mData->empty = false; 1124 mData->empty = false;
1125 mData->revision = QDateTime( revision.date(), 1125 mData->revision = QDateTime( revision.date(),
1126 QTime (revision.time().hour(), 1126 QTime (revision.time().hour(),
1127 revision.time().minute(), 1127 revision.time().minute(),
1128 revision.time().second())); 1128 revision.time().second()));
1129} 1129}
1130 1130
1131QDateTime Addressee::revision() const 1131QDateTime Addressee::revision() const
1132{ 1132{
1133 return mData->revision; 1133 return mData->revision;
1134} 1134}
1135 1135
1136QString Addressee::revisionLabel() 1136QString Addressee::revisionLabel()
1137{ 1137{
1138 return i18n("Revision Date"); 1138 return i18n("Revision Date");
1139} 1139}
1140 1140
1141 1141
1142void Addressee::setSortString( const QString &sortString ) 1142void Addressee::setSortString( const QString &sortString )
1143{ 1143{
1144 if ( sortString == mData->sortString ) return; 1144 if ( sortString == mData->sortString ) return;
1145 detach(); 1145 detach();
1146 mData->empty = false; 1146 mData->empty = false;
1147 mData->sortString = sortString; 1147 mData->sortString = sortString;
1148} 1148}
1149 1149
1150QString Addressee::sortString() const 1150QString Addressee::sortString() const
1151{ 1151{
1152 return mData->sortString; 1152 return mData->sortString;
1153} 1153}
1154 1154
1155QString Addressee::sortStringLabel() 1155QString Addressee::sortStringLabel()
1156{ 1156{
1157 return i18n("Sort String"); 1157 return i18n("Sort String");
1158} 1158}
1159 1159
1160 1160
1161void Addressee::setUrl( const KURL &url ) 1161void Addressee::setUrl( const KURL &url )
1162{ 1162{
1163 if ( url == mData->url ) return; 1163 if ( url == mData->url ) return;
1164 detach(); 1164 detach();
1165 mData->empty = false; 1165 mData->empty = false;
1166 mData->url = url; 1166 mData->url = url;
1167} 1167}
1168 1168
1169KURL Addressee::url() const 1169KURL Addressee::url() const
1170{ 1170{
1171 return mData->url; 1171 return mData->url;
1172} 1172}
1173 1173
1174QString Addressee::urlLabel() 1174QString Addressee::urlLabel()
1175{ 1175{
1176 return i18n("URL"); 1176 return i18n("URL");
1177} 1177}
1178 1178
1179 1179
1180void Addressee::setSecrecy( const Secrecy &secrecy ) 1180void Addressee::setSecrecy( const Secrecy &secrecy )
1181{ 1181{
1182 if ( secrecy == mData->secrecy ) return; 1182 if ( secrecy == mData->secrecy ) return;
1183 detach(); 1183 detach();
1184 mData->empty = false; 1184 mData->empty = false;
1185 mData->secrecy = secrecy; 1185 mData->secrecy = secrecy;
1186} 1186}
1187 1187
1188Secrecy Addressee::secrecy() const 1188Secrecy Addressee::secrecy() const
1189{ 1189{
1190 return mData->secrecy; 1190 return mData->secrecy;
1191} 1191}
1192 1192
1193QString Addressee::secrecyLabel() 1193QString Addressee::secrecyLabel()
1194{ 1194{
1195 return i18n("Security Class"); 1195 return i18n("Security Class");
1196} 1196}
1197 1197
1198 1198
1199void Addressee::setLogo( const Picture &logo ) 1199void Addressee::setLogo( const Picture &logo )
1200{ 1200{
1201 if ( logo == mData->logo ) return; 1201 if ( logo == mData->logo ) return;
1202 detach(); 1202 detach();
1203 mData->empty = false; 1203 mData->empty = false;
1204 mData->logo = logo; 1204 mData->logo = logo;
1205} 1205}
1206 1206
1207Picture Addressee::logo() const 1207Picture Addressee::logo() const
1208{ 1208{
1209 return mData->logo; 1209 return mData->logo;
1210} 1210}
1211 1211
1212QString Addressee::logoLabel() 1212QString Addressee::logoLabel()
1213{ 1213{
1214 return i18n("Logo"); 1214 return i18n("Logo");
1215} 1215}
1216 1216
1217 1217
1218void Addressee::setPhoto( const Picture &photo ) 1218void Addressee::setPhoto( const Picture &photo )
1219{ 1219{
1220 if ( photo == mData->photo ) return; 1220 if ( photo == mData->photo ) return;
1221 detach(); 1221 detach();
1222 mData->empty = false; 1222 mData->empty = false;
1223 mData->photo = photo; 1223 mData->photo = photo;
1224} 1224}
1225 1225
1226Picture Addressee::photo() const 1226Picture Addressee::photo() const
1227{ 1227{
1228 return mData->photo; 1228 return mData->photo;
1229} 1229}
1230 1230
1231QString Addressee::photoLabel() 1231QString Addressee::photoLabel()
1232{ 1232{
1233 return i18n("Photo"); 1233 return i18n("Photo");
1234} 1234}
1235 1235
1236 1236
1237void Addressee::setSound( const Sound &sound ) 1237void Addressee::setSound( const Sound &sound )
1238{ 1238{
1239 if ( sound == mData->sound ) return; 1239 if ( sound == mData->sound ) return;
1240 detach(); 1240 detach();
1241 mData->empty = false; 1241 mData->empty = false;
1242 mData->sound = sound; 1242 mData->sound = sound;
1243} 1243}
1244 1244
1245Sound Addressee::sound() const 1245Sound Addressee::sound() const
1246{ 1246{
1247 return mData->sound; 1247 return mData->sound;
1248} 1248}
1249 1249
1250QString Addressee::soundLabel() 1250QString Addressee::soundLabel()
1251{ 1251{
1252 return i18n("Sound"); 1252 return i18n("Sound");
1253} 1253}
1254 1254
1255 1255
1256void Addressee::setAgent( const Agent &agent ) 1256void Addressee::setAgent( const Agent &agent )
1257{ 1257{
1258 if ( agent == mData->agent ) return; 1258 if ( agent == mData->agent ) return;
1259 detach(); 1259 detach();
1260 mData->empty = false; 1260 mData->empty = false;
1261 mData->agent = agent; 1261 mData->agent = agent;
1262} 1262}
1263 1263
1264Agent Addressee::agent() const 1264Agent Addressee::agent() const
1265{ 1265{
1266 return mData->agent; 1266 return mData->agent;
1267} 1267}
1268 1268
1269QString Addressee::agentLabel() 1269QString Addressee::agentLabel()
1270{ 1270{
1271 return i18n("Agent"); 1271 return i18n("Agent");
1272} 1272}
1273 1273
1274 1274
1275 1275
1276void Addressee::setNameFromString( const QString &str ) 1276void Addressee::setNameFromString( const QString &str )
1277{ 1277{
1278 setFormattedName( str ); 1278 setFormattedName( str );
1279 setName( str ); 1279 setName( str );
1280 1280
1281 static bool first = true; 1281 static bool first = true;
1282 static QStringList titles; 1282 static QStringList titles;
1283 static QStringList suffixes; 1283 static QStringList suffixes;
1284 static QStringList prefixes; 1284 static QStringList prefixes;
1285 1285
1286 if ( first ) { 1286 if ( first ) {
1287 first = false; 1287 first = false;
1288 titles += i18n( "Dr." ); 1288 titles += i18n( "Dr." );
1289 titles += i18n( "Miss" ); 1289 titles += i18n( "Miss" );
1290 titles += i18n( "Mr." ); 1290 titles += i18n( "Mr." );
1291 titles += i18n( "Mrs." ); 1291 titles += i18n( "Mrs." );
1292 titles += i18n( "Ms." ); 1292 titles += i18n( "Ms." );
1293 titles += i18n( "Prof." ); 1293 titles += i18n( "Prof." );
1294 1294
1295 suffixes += i18n( "I" ); 1295 suffixes += i18n( "I" );
1296 suffixes += i18n( "II" ); 1296 suffixes += i18n( "II" );
1297 suffixes += i18n( "III" ); 1297 suffixes += i18n( "III" );
1298 suffixes += i18n( "Jr." ); 1298 suffixes += i18n( "Jr." );
1299 suffixes += i18n( "Sr." ); 1299 suffixes += i18n( "Sr." );
1300 1300
1301 prefixes += "van"; 1301 prefixes += "van";
1302 prefixes += "von"; 1302 prefixes += "von";
1303 prefixes += "de"; 1303 prefixes += "de";
1304 1304
1305 KConfig config( locateLocal( "config", "kabcrc") ); 1305 KConfig config( locateLocal( "config", "kabcrc") );
1306 config.setGroup( "General" ); 1306 config.setGroup( "General" );
1307 titles += config.readListEntry( "Prefixes" ); 1307 titles += config.readListEntry( "Prefixes" );
1308 titles.remove( "" ); 1308 titles.remove( "" );
1309 prefixes += config.readListEntry( "Inclusions" ); 1309 prefixes += config.readListEntry( "Inclusions" );
1310 prefixes.remove( "" ); 1310 prefixes.remove( "" );
1311 suffixes += config.readListEntry( "Suffixes" ); 1311 suffixes += config.readListEntry( "Suffixes" );
1312 suffixes.remove( "" ); 1312 suffixes.remove( "" );
1313 } 1313 }
1314 1314
1315 // clear all name parts 1315 // clear all name parts
1316 setPrefix( "" ); 1316 setPrefix( "" );
1317 setGivenName( "" ); 1317 setGivenName( "" );
1318 setAdditionalName( "" ); 1318 setAdditionalName( "" );
1319 setFamilyName( "" ); 1319 setFamilyName( "" );
1320 setSuffix( "" ); 1320 setSuffix( "" );
1321 1321
1322 if ( str.isEmpty() ) 1322 if ( str.isEmpty() )
1323 return; 1323 return;
1324 1324
1325 int i = str.find(','); 1325 int i = str.find(',');
1326 if( i < 0 ) { 1326 if( i < 0 ) {
1327 QStringList parts = QStringList::split( " ", str ); 1327 QStringList parts = QStringList::split( " ", str );
1328 int leftOffset = 0; 1328 int leftOffset = 0;
1329 int rightOffset = parts.count() - 1; 1329 int rightOffset = parts.count() - 1;
1330 1330
1331 QString suffix; 1331 QString suffix;
1332 while ( rightOffset >= 0 ) { 1332 while ( rightOffset >= 0 ) {
1333 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1333 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1334 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1334 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1335 rightOffset--; 1335 rightOffset--;
1336 } else 1336 } else
1337 break; 1337 break;
1338 } 1338 }
1339 setSuffix( suffix ); 1339 setSuffix( suffix );
1340 1340
1341 if ( rightOffset < 0 ) 1341 if ( rightOffset < 0 )
1342 return; 1342 return;
1343 1343
1344 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1344 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1345 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1345 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1346 rightOffset--; 1346 rightOffset--;
1347 } else 1347 } else
1348 setFamilyName( parts[ rightOffset ] ); 1348 setFamilyName( parts[ rightOffset ] );
1349 1349
1350 QString prefix; 1350 QString prefix;
1351 while ( leftOffset < rightOffset ) { 1351 while ( leftOffset < rightOffset ) {
1352 if ( titles.contains( parts[ leftOffset ] ) ) { 1352 if ( titles.contains( parts[ leftOffset ] ) ) {
1353 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1353 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1354 leftOffset++; 1354 leftOffset++;
1355 } else 1355 } else
1356 break; 1356 break;
1357 } 1357 }
1358 setPrefix( prefix ); 1358 setPrefix( prefix );
1359 1359
1360 if ( leftOffset < rightOffset ) { 1360 if ( leftOffset < rightOffset ) {
1361 setGivenName( parts[ leftOffset ] ); 1361 setGivenName( parts[ leftOffset ] );
1362 leftOffset++; 1362 leftOffset++;
1363 } 1363 }
1364 1364
1365 QString additionalName; 1365 QString additionalName;
1366 while ( leftOffset < rightOffset ) { 1366 while ( leftOffset < rightOffset ) {
1367 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1367 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1368 leftOffset++; 1368 leftOffset++;
1369 } 1369 }
1370 setAdditionalName( additionalName ); 1370 setAdditionalName( additionalName );
1371 } else { 1371 } else {
1372 QString part1 = str.left( i ); 1372 QString part1 = str.left( i );
1373 QString part2 = str.mid( i + 1 ); 1373 QString part2 = str.mid( i + 1 );
1374 1374
1375 QStringList parts = QStringList::split( " ", part1 ); 1375 QStringList parts = QStringList::split( " ", part1 );
1376 int leftOffset = 0; 1376 int leftOffset = 0;
1377 int rightOffset = parts.count() - 1; 1377 int rightOffset = parts.count() - 1;
1378 1378
1379 QString suffix; 1379 QString suffix;
1380 while ( rightOffset >= 0 ) { 1380 while ( rightOffset >= 0 ) {
1381 if ( suffixes.contains( parts[ rightOffset ] ) ) { 1381 if ( suffixes.contains( parts[ rightOffset ] ) ) {
1382 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); 1382 suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
1383 rightOffset--; 1383 rightOffset--;
1384 } else 1384 } else
1385 break; 1385 break;
1386 } 1386 }
1387 setSuffix( suffix ); 1387 setSuffix( suffix );
1388 1388
1389 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { 1389 if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
1390 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); 1390 setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
1391 rightOffset--; 1391 rightOffset--;
1392 } else 1392 } else
1393 setFamilyName( parts[ rightOffset ] ); 1393 setFamilyName( parts[ rightOffset ] );
1394 1394
1395 QString prefix; 1395 QString prefix;
1396 while ( leftOffset < rightOffset ) { 1396 while ( leftOffset < rightOffset ) {
1397 if ( titles.contains( parts[ leftOffset ] ) ) { 1397 if ( titles.contains( parts[ leftOffset ] ) ) {
1398 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1398 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1399 leftOffset++; 1399 leftOffset++;
1400 } else 1400 } else
1401 break; 1401 break;
1402 } 1402 }
1403 1403
1404 parts = QStringList::split( " ", part2 ); 1404 parts = QStringList::split( " ", part2 );
1405 1405
1406 leftOffset = 0; 1406 leftOffset = 0;
1407 rightOffset = parts.count(); 1407 rightOffset = parts.count();
1408 1408
1409 while ( leftOffset < rightOffset ) { 1409 while ( leftOffset < rightOffset ) {
1410 if ( titles.contains( parts[ leftOffset ] ) ) { 1410 if ( titles.contains( parts[ leftOffset ] ) ) {
1411 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1411 prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1412 leftOffset++; 1412 leftOffset++;
1413 } else 1413 } else
1414 break; 1414 break;
1415 } 1415 }
1416 setPrefix( prefix ); 1416 setPrefix( prefix );
1417 1417
1418 if ( leftOffset < rightOffset ) { 1418 if ( leftOffset < rightOffset ) {
1419 setGivenName( parts[ leftOffset ] ); 1419 setGivenName( parts[ leftOffset ] );
1420 leftOffset++; 1420 leftOffset++;
1421 } 1421 }
1422 1422
1423 QString additionalName; 1423 QString additionalName;
1424 while ( leftOffset < rightOffset ) { 1424 while ( leftOffset < rightOffset ) {
1425 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); 1425 additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
1426 leftOffset++; 1426 leftOffset++;
1427 } 1427 }
1428 setAdditionalName( additionalName ); 1428 setAdditionalName( additionalName );
1429 } 1429 }
1430} 1430}
1431 1431
1432QString Addressee::realName() const 1432QString Addressee::realName() const
1433{ 1433{
1434 if ( !formattedName().isEmpty() ) 1434 if ( !formattedName().isEmpty() )
1435 return formattedName(); 1435 return formattedName();
1436 1436
1437 QString n = assembledName(); 1437 QString n = assembledName();
1438 1438
1439 if ( n.isEmpty() ) 1439 if ( n.isEmpty() )
1440 n = name(); 1440 n = name();
1441 1441
1442 return n; 1442 return n;
1443} 1443}
1444 1444
1445QString Addressee::assembledName() const 1445QString Addressee::assembledName() const
1446{ 1446{
1447 QString name = prefix() + " " + givenName() + " " + additionalName() + " " + 1447 QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
1448 familyName() + " " + suffix(); 1448 familyName() + " " + suffix();
1449 1449
1450 return name.simplifyWhiteSpace(); 1450 return name.simplifyWhiteSpace();
1451} 1451}
1452 1452
1453QString Addressee::fullEmail( const QString &email ) const 1453QString Addressee::fullEmail( const QString &email ) const
1454{ 1454{
1455 QString e; 1455 QString e;
1456 if ( email.isNull() ) { 1456 if ( email.isNull() ) {
1457 e = preferredEmail(); 1457 e = preferredEmail();
1458 } else { 1458 } else {
1459 e = email; 1459 e = email;
1460 } 1460 }
1461 if ( e.isEmpty() ) return QString::null; 1461 if ( e.isEmpty() ) return QString::null;
1462 1462
1463 QString text; 1463 QString text;
1464 if ( realName().isEmpty() ) 1464 if ( realName().isEmpty() )
1465 text = e; 1465 text = e;
1466 else 1466 else
1467 text = assembledName() + " <" + e + ">"; 1467 text = assembledName() + " <" + e + ">";
1468 1468
1469 return text; 1469 return text;
1470} 1470}
1471 1471
1472void Addressee::insertEmail( const QString &email, bool preferred ) 1472void Addressee::insertEmail( const QString &email, bool preferred )
1473{ 1473{
1474 detach(); 1474 detach();
1475 1475
1476 QStringList::Iterator it = mData->emails.find( email ); 1476 QStringList::Iterator it = mData->emails.find( email );
1477 1477
1478 if ( it != mData->emails.end() ) { 1478 if ( it != mData->emails.end() ) {
1479 if ( !preferred || it == mData->emails.begin() ) return; 1479 if ( !preferred || it == mData->emails.begin() ) return;
1480 mData->emails.remove( it ); 1480 mData->emails.remove( it );
1481 mData->emails.prepend( email ); 1481 mData->emails.prepend( email );
1482 } else { 1482 } else {
1483 if ( preferred ) { 1483 if ( preferred ) {
1484 mData->emails.prepend( email ); 1484 mData->emails.prepend( email );
1485 } else { 1485 } else {
1486 mData->emails.append( email ); 1486 mData->emails.append( email );
1487 } 1487 }
1488 } 1488 }
1489} 1489}
1490 1490
1491void Addressee::removeEmail( const QString &email ) 1491void Addressee::removeEmail( const QString &email )
1492{ 1492{
1493 detach(); 1493 detach();
1494 1494
1495 QStringList::Iterator it = mData->emails.find( email ); 1495 QStringList::Iterator it = mData->emails.find( email );
1496 if ( it == mData->emails.end() ) return; 1496 if ( it == mData->emails.end() ) return;
1497 1497
1498 mData->emails.remove( it ); 1498 mData->emails.remove( it );
1499} 1499}
1500 1500
1501QString Addressee::preferredEmail() const 1501QString Addressee::preferredEmail() const
1502{ 1502{
1503 if ( mData->emails.count() == 0 ) return QString::null; 1503 if ( mData->emails.count() == 0 ) return QString::null;
1504 else return mData->emails.first(); 1504 else return mData->emails.first();
1505} 1505}
1506 1506
1507QStringList Addressee::emails() const 1507QStringList Addressee::emails() const
1508{ 1508{
1509 return mData->emails; 1509 return mData->emails;
1510} 1510}
1511void Addressee::setEmails( const QStringList& emails ) { 1511void Addressee::setEmails( const QStringList& emails ) {
1512 detach(); 1512 detach();
1513 mData->emails = emails; 1513 mData->emails = emails;
1514} 1514}
1515void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) 1515void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
1516{ 1516{
1517 detach(); 1517 detach();
1518 mData->empty = false; 1518 mData->empty = false;
1519 1519
1520 PhoneNumber::List::Iterator it; 1520 PhoneNumber::List::Iterator it;
1521 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1521 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1522 if ( (*it).id() == phoneNumber.id() ) { 1522 if ( (*it).id() == phoneNumber.id() ) {
1523 *it = phoneNumber; 1523 *it = phoneNumber;
1524 return; 1524 return;
1525 } 1525 }
1526 } 1526 }
1527 mData->phoneNumbers.append( phoneNumber ); 1527 mData->phoneNumbers.append( phoneNumber );
1528} 1528}
1529 1529
1530void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) 1530void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
1531{ 1531{
1532 detach(); 1532 detach();
1533 1533
1534 PhoneNumber::List::Iterator it; 1534 PhoneNumber::List::Iterator it;
1535 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1535 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1536 if ( (*it).id() == phoneNumber.id() ) { 1536 if ( (*it).id() == phoneNumber.id() ) {
1537 mData->phoneNumbers.remove( it ); 1537 mData->phoneNumbers.remove( it );
1538 return; 1538 return;
1539 } 1539 }
1540 } 1540 }
1541} 1541}
1542 1542
1543PhoneNumber Addressee::phoneNumber( int type ) const 1543PhoneNumber Addressee::phoneNumber( int type ) const
1544{ 1544{
1545 PhoneNumber phoneNumber( "", type ); 1545 PhoneNumber phoneNumber( "", type );
1546 PhoneNumber::List::ConstIterator it; 1546 PhoneNumber::List::ConstIterator it;
1547 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1547 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1548 if ( matchBinaryPatternP( (*it).type(), type ) ) { 1548 if ( matchBinaryPatternP( (*it).type(), type ) ) {
1549 if ( (*it).type() & PhoneNumber::Pref ) 1549 if ( (*it).type() & PhoneNumber::Pref )
1550 return (*it); 1550 return (*it);
1551 else if ( phoneNumber.number().isEmpty() ) 1551 else if ( phoneNumber.number().isEmpty() )
1552 phoneNumber = (*it); 1552 phoneNumber = (*it);
1553 } 1553 }
1554 } 1554 }
1555 1555
1556 return phoneNumber; 1556 return phoneNumber;
1557} 1557}
1558 1558
1559PhoneNumber::List Addressee::phoneNumbers() const 1559PhoneNumber::List Addressee::phoneNumbers() const
1560{ 1560{
1561 return mData->phoneNumbers; 1561 return mData->phoneNumbers;
1562} 1562}
1563 1563
1564PhoneNumber::List Addressee::phoneNumbers( int type ) const 1564PhoneNumber::List Addressee::phoneNumbers( int type ) const
1565{ 1565{
1566 PhoneNumber::List list; 1566 PhoneNumber::List list;
1567 1567
1568 PhoneNumber::List::ConstIterator it; 1568 PhoneNumber::List::ConstIterator it;
1569 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1569 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1570 if ( matchBinaryPattern( (*it).type(), type ) ) { 1570 if ( matchBinaryPattern( (*it).type(), type ) ) {
1571 list.append( *it ); 1571 list.append( *it );
1572 } 1572 }
1573 } 1573 }
1574 return list; 1574 return list;
1575} 1575}
1576 1576
1577PhoneNumber Addressee::findPhoneNumber( const QString &id ) const 1577PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
1578{ 1578{
1579 PhoneNumber::List::ConstIterator it; 1579 PhoneNumber::List::ConstIterator it;
1580 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { 1580 for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
1581 if ( (*it).id() == id ) { 1581 if ( (*it).id() == id ) {
1582 return *it; 1582 return *it;
1583 } 1583 }
1584 } 1584 }
1585 return PhoneNumber(); 1585 return PhoneNumber();
1586} 1586}
1587 1587
1588void Addressee::insertKey( const Key &key ) 1588void Addressee::insertKey( const Key &key )
1589{ 1589{
1590 detach(); 1590 detach();
1591 mData->empty = false; 1591 mData->empty = false;
1592 1592
1593 Key::List::Iterator it; 1593 Key::List::Iterator it;
1594 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1594 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1595 if ( (*it).id() == key.id() ) { 1595 if ( (*it).id() == key.id() ) {
1596 *it = key; 1596 *it = key;
1597 return; 1597 return;
1598 } 1598 }
1599 } 1599 }
1600 mData->keys.append( key ); 1600 mData->keys.append( key );
1601} 1601}
1602 1602
1603void Addressee::removeKey( const Key &key ) 1603void Addressee::removeKey( const Key &key )
1604{ 1604{
1605 detach(); 1605 detach();
1606 1606
1607 Key::List::Iterator it; 1607 Key::List::Iterator it;
1608 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1608 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1609 if ( (*it).id() == key.id() ) { 1609 if ( (*it).id() == key.id() ) {
1610 mData->keys.remove( key ); 1610 mData->keys.remove( key );
1611 return; 1611 return;
1612 } 1612 }
1613 } 1613 }
1614} 1614}
1615 1615
1616Key Addressee::key( int type, QString customTypeString ) const 1616Key Addressee::key( int type, QString customTypeString ) const
1617{ 1617{
1618 Key::List::ConstIterator it; 1618 Key::List::ConstIterator it;
1619 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1619 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1620 if ( (*it).type() == type ) { 1620 if ( (*it).type() == type ) {
1621 if ( type == Key::Custom ) { 1621 if ( type == Key::Custom ) {
1622 if ( customTypeString.isEmpty() ) { 1622 if ( customTypeString.isEmpty() ) {
1623 return *it; 1623 return *it;
1624 } else { 1624 } else {
1625 if ( (*it).customTypeString() == customTypeString ) 1625 if ( (*it).customTypeString() == customTypeString )
1626 return (*it); 1626 return (*it);
1627 } 1627 }
1628 } else { 1628 } else {
1629 return *it; 1629 return *it;
1630 } 1630 }
1631 } 1631 }
1632 } 1632 }
1633 return Key( QString(), type ); 1633 return Key( QString(), type );
1634} 1634}
1635void Addressee::setKeys( const Key::List& list ) { 1635void Addressee::setKeys( const Key::List& list ) {
1636 detach(); 1636 detach();
1637 mData->keys = list; 1637 mData->keys = list;
1638} 1638}
1639 1639
1640Key::List Addressee::keys() const 1640Key::List Addressee::keys() const
1641{ 1641{
1642 return mData->keys; 1642 return mData->keys;
1643} 1643}
1644 1644
1645Key::List Addressee::keys( int type, QString customTypeString ) const 1645Key::List Addressee::keys( int type, QString customTypeString ) const
1646{ 1646{
1647 Key::List list; 1647 Key::List list;
1648 1648
1649 Key::List::ConstIterator it; 1649 Key::List::ConstIterator it;
1650 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1650 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1651 if ( (*it).type() == type ) { 1651 if ( (*it).type() == type ) {
1652 if ( type == Key::Custom ) { 1652 if ( type == Key::Custom ) {
1653 if ( customTypeString.isEmpty() ) { 1653 if ( customTypeString.isEmpty() ) {
1654 list.append(*it); 1654 list.append(*it);
1655 } else { 1655 } else {
1656 if ( (*it).customTypeString() == customTypeString ) 1656 if ( (*it).customTypeString() == customTypeString )
1657 list.append(*it); 1657 list.append(*it);
1658 } 1658 }
1659 } else { 1659 } else {
1660 list.append(*it); 1660 list.append(*it);
1661 } 1661 }
1662 } 1662 }
1663 } 1663 }
1664 return list; 1664 return list;
1665} 1665}
1666 1666
1667Key Addressee::findKey( const QString &id ) const 1667Key Addressee::findKey( const QString &id ) const
1668{ 1668{
1669 Key::List::ConstIterator it; 1669 Key::List::ConstIterator it;
1670 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { 1670 for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
1671 if ( (*it).id() == id ) { 1671 if ( (*it).id() == id ) {
1672 return *it; 1672 return *it;
1673 } 1673 }
1674 } 1674 }
1675 return Key(); 1675 return Key();
1676} 1676}
1677 1677
1678QString Addressee::asString() const 1678QString Addressee::asString() const
1679{ 1679{
1680 return "Smith, agent Smith..."; 1680 return "Smith, agent Smith...";
1681} 1681}
1682 1682
1683void Addressee::dump() const 1683void Addressee::dump() const
1684{ 1684{
1685 return; 1685 return;
1686 kdDebug(5700) << "Addressee {" << endl; 1686 kdDebug(5700) << "Addressee {" << endl;
1687 1687
1688 kdDebug(5700) << " Uid: '" << uid() << "'" << endl; 1688 kdDebug(5700) << " Uid: '" << uid() << "'" << endl;
1689 1689
1690 kdDebug(5700) << " Name: '" << name() << "'" << endl; 1690 kdDebug(5700) << " Name: '" << name() << "'" << endl;
1691 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; 1691 kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl;
1692 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; 1692 kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl;
1693 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; 1693 kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl;
1694 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; 1694 kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl;
1695 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; 1695 kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl;
1696 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; 1696 kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl;
1697 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; 1697 kdDebug(5700) << " NickName: '" << nickName() << "'" << endl;
1698 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; 1698 kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl;
1699 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; 1699 kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl;
1700 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; 1700 kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl;
1701 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; 1701 kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl;
1702 kdDebug(5700) << " Title: '" << title() << "'" << endl; 1702 kdDebug(5700) << " Title: '" << title() << "'" << endl;
1703 kdDebug(5700) << " Role: '" << role() << "'" << endl; 1703 kdDebug(5700) << " Role: '" << role() << "'" << endl;
1704 kdDebug(5700) << " Organization: '" << organization() << "'" << endl; 1704 kdDebug(5700) << " Organization: '" << organization() << "'" << endl;
1705 kdDebug(5700) << " Note: '" << note() << "'" << endl; 1705 kdDebug(5700) << " Note: '" << note() << "'" << endl;
1706 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; 1706 kdDebug(5700) << " ProductId: '" << productId() << "'" << endl;
1707 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; 1707 kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl;
1708 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; 1708 kdDebug(5700) << " SortString: '" << sortString() << "'" << endl;
1709 kdDebug(5700) << " Url: '" << url().url() << "'" << endl; 1709 kdDebug(5700) << " Url: '" << url().url() << "'" << endl;
1710 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; 1710 kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl;
1711 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; 1711 kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl;
1712 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; 1712 kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl;
1713 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; 1713 kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl;
1714 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; 1714 kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl;
1715 1715
1716 kdDebug(5700) << " Emails {" << endl; 1716 kdDebug(5700) << " Emails {" << endl;
1717 QStringList e = emails(); 1717 QStringList e = emails();
1718 QStringList::ConstIterator it; 1718 QStringList::ConstIterator it;
1719 for( it = e.begin(); it != e.end(); ++it ) { 1719 for( it = e.begin(); it != e.end(); ++it ) {
1720 kdDebug(5700) << " " << (*it) << endl; 1720 kdDebug(5700) << " " << (*it) << endl;
1721 } 1721 }
1722 kdDebug(5700) << " }" << endl; 1722 kdDebug(5700) << " }" << endl;
1723 1723
1724 kdDebug(5700) << " PhoneNumbers {" << endl; 1724 kdDebug(5700) << " PhoneNumbers {" << endl;
1725 PhoneNumber::List p = phoneNumbers(); 1725 PhoneNumber::List p = phoneNumbers();
1726 PhoneNumber::List::ConstIterator it2; 1726 PhoneNumber::List::ConstIterator it2;
1727 for( it2 = p.begin(); it2 != p.end(); ++it2 ) { 1727 for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
1728 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; 1728 kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
1729 } 1729 }
1730 kdDebug(5700) << " }" << endl; 1730 kdDebug(5700) << " }" << endl;
1731 1731
1732 Address::List a = addresses(); 1732 Address::List a = addresses();
1733 Address::List::ConstIterator it3; 1733 Address::List::ConstIterator it3;
1734 for( it3 = a.begin(); it3 != a.end(); ++it3 ) { 1734 for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
1735 (*it3).dump(); 1735 (*it3).dump();
1736 } 1736 }
1737 1737
1738 kdDebug(5700) << " Keys {" << endl; 1738 kdDebug(5700) << " Keys {" << endl;
1739 Key::List k = keys(); 1739 Key::List k = keys();
1740 Key::List::ConstIterator it4; 1740 Key::List::ConstIterator it4;
1741 for( it4 = k.begin(); it4 != k.end(); ++it4 ) { 1741 for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
1742 kdDebug(5700) << " Type: " << int((*it4).type()) << 1742 kdDebug(5700) << " Type: " << int((*it4).type()) <<
1743 " Key: " << (*it4).textData() << 1743 " Key: " << (*it4).textData() <<
1744 " CustomString: " << (*it4).customTypeString() << endl; 1744 " CustomString: " << (*it4).customTypeString() << endl;
1745 } 1745 }
1746 kdDebug(5700) << " }" << endl; 1746 kdDebug(5700) << " }" << endl;
1747 1747
1748 kdDebug(5700) << "}" << endl; 1748 kdDebug(5700) << "}" << endl;
1749} 1749}
1750 1750
1751 1751
1752void Addressee::insertAddress( const Address &address ) 1752void Addressee::insertAddress( const Address &address )
1753{ 1753{
1754 detach(); 1754 detach();
1755 mData->empty = false; 1755 mData->empty = false;
1756 1756
1757 Address::List::Iterator it; 1757 Address::List::Iterator it;
1758 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1758 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1759 if ( (*it).id() == address.id() ) { 1759 if ( (*it).id() == address.id() ) {
1760 *it = address; 1760 *it = address;
1761 return; 1761 return;
1762 } 1762 }
1763 } 1763 }
1764 mData->addresses.append( address ); 1764 mData->addresses.append( address );
1765} 1765}
1766 1766
1767void Addressee::removeAddress( const Address &address ) 1767void Addressee::removeAddress( const Address &address )
1768{ 1768{
1769 detach(); 1769 detach();
1770 1770
1771 Address::List::Iterator it; 1771 Address::List::Iterator it;
1772 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1772 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1773 if ( (*it).id() == address.id() ) { 1773 if ( (*it).id() == address.id() ) {
1774 mData->addresses.remove( it ); 1774 mData->addresses.remove( it );
1775 return; 1775 return;
1776 } 1776 }
1777 } 1777 }
1778} 1778}
1779 1779
1780Address Addressee::address( int type ) const 1780Address Addressee::address( int type ) const
1781{ 1781{
1782 Address address( type ); 1782 Address address( type );
1783 Address::List::ConstIterator it; 1783 Address::List::ConstIterator it;
1784 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1784 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1785 if ( matchBinaryPatternA( (*it).type(), type ) ) { 1785 if ( matchBinaryPatternA( (*it).type(), type ) ) {
1786 if ( (*it).type() & Address::Pref ) 1786 if ( (*it).type() & Address::Pref )
1787 return (*it); 1787 return (*it);
1788 else if ( address.isEmpty() ) 1788 else if ( address.isEmpty() )
1789 address = (*it); 1789 address = (*it);
1790 } 1790 }
1791 } 1791 }
1792 1792
1793 return address; 1793 return address;
1794} 1794}
1795 1795
1796Address::List Addressee::addresses() const 1796Address::List Addressee::addresses() const
1797{ 1797{
1798 return mData->addresses; 1798 return mData->addresses;
1799} 1799}
1800 1800
1801Address::List Addressee::addresses( int type ) const 1801Address::List Addressee::addresses( int type ) const
1802{ 1802{
1803 Address::List list; 1803 Address::List list;
1804 1804
1805 Address::List::ConstIterator it; 1805 Address::List::ConstIterator it;
1806 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1806 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1807 if ( matchBinaryPattern( (*it).type(), type ) ) { 1807 if ( matchBinaryPattern( (*it).type(), type ) ) {
1808 list.append( *it ); 1808 list.append( *it );
1809 } 1809 }
1810 } 1810 }
1811 1811
1812 return list; 1812 return list;
1813} 1813}
1814 1814
1815Address Addressee::findAddress( const QString &id ) const 1815Address Addressee::findAddress( const QString &id ) const
1816{ 1816{
1817 Address::List::ConstIterator it; 1817 Address::List::ConstIterator it;
1818 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 1818 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
1819 if ( (*it).id() == id ) { 1819 if ( (*it).id() == id ) {
1820 return *it; 1820 return *it;
1821 } 1821 }
1822 } 1822 }
1823 return Address(); 1823 return Address();
1824} 1824}
1825 1825
1826void Addressee::insertCategory( const QString &c ) 1826void Addressee::insertCategory( const QString &c )
1827{ 1827{
1828 detach(); 1828 detach();
1829 mData->empty = false; 1829 mData->empty = false;
1830 1830
1831 if ( mData->categories.contains( c ) ) return; 1831 if ( mData->categories.contains( c ) ) return;
1832 1832
1833 mData->categories.append( c ); 1833 mData->categories.append( c );
1834} 1834}
1835 1835
1836void Addressee::removeCategory( const QString &c ) 1836void Addressee::removeCategory( const QString &c )
1837{ 1837{
1838 detach(); 1838 detach();
1839 1839
1840 QStringList::Iterator it = mData->categories.find( c ); 1840 QStringList::Iterator it = mData->categories.find( c );
1841 if ( it == mData->categories.end() ) return; 1841 if ( it == mData->categories.end() ) return;
1842 1842
1843 mData->categories.remove( it ); 1843 mData->categories.remove( it );
1844} 1844}
1845 1845
1846bool Addressee::hasCategory( const QString &c ) const 1846bool Addressee::hasCategory( const QString &c ) const
1847{ 1847{
1848 return ( mData->categories.contains( c ) ); 1848 return ( mData->categories.contains( c ) );
1849} 1849}
1850 1850
1851void Addressee::setCategories( const QStringList &c ) 1851void Addressee::setCategories( const QStringList &c )
1852{ 1852{
1853 detach(); 1853 detach();
1854 mData->empty = false; 1854 mData->empty = false;
1855 1855
1856 mData->categories = c; 1856 mData->categories = c;
1857} 1857}
1858 1858
1859QStringList Addressee::categories() const 1859QStringList Addressee::categories() const
1860{ 1860{
1861 return mData->categories; 1861 return mData->categories;
1862} 1862}
1863 1863
1864void Addressee::insertCustom( const QString &app, const QString &name, 1864void Addressee::insertCustom( const QString &app, const QString &name,
1865 const QString &value ) 1865 const QString &value )
1866{ 1866{
1867 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; 1867 if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return;
1868 1868
1869 detach(); 1869 detach();
1870 mData->empty = false; 1870 mData->empty = false;
1871 1871
1872 QString qualifiedName = app + "-" + name + ":"; 1872 QString qualifiedName = app + "-" + name + ":";
1873 1873
1874 QStringList::Iterator it; 1874 QStringList::Iterator it;
1875 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1875 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1876 if ( (*it).startsWith( qualifiedName ) ) { 1876 if ( (*it).startsWith( qualifiedName ) ) {
1877 (*it) = qualifiedName + value; 1877 (*it) = qualifiedName + value;
1878 return; 1878 return;
1879 } 1879 }
1880 } 1880 }
1881 mData->custom.append( qualifiedName + value ); 1881 mData->custom.append( qualifiedName + value );
1882} 1882}
1883 1883
1884void Addressee::removeCustom( const QString &app, const QString &name) 1884void Addressee::removeCustom( const QString &app, const QString &name)
1885{ 1885{
1886 detach(); 1886 detach();
1887 1887
1888 QString qualifiedName = app + "-" + name + ":"; 1888 QString qualifiedName = app + "-" + name + ":";
1889 1889
1890 QStringList::Iterator it; 1890 QStringList::Iterator it;
1891 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1891 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1892 if ( (*it).startsWith( qualifiedName ) ) { 1892 if ( (*it).startsWith( qualifiedName ) ) {
1893 mData->custom.remove( it ); 1893 mData->custom.remove( it );
1894 return; 1894 return;
1895 } 1895 }
1896 } 1896 }
1897} 1897}
1898 1898
1899QString Addressee::custom( const QString &app, const QString &name ) const 1899QString Addressee::custom( const QString &app, const QString &name ) const
1900{ 1900{
1901 QString qualifiedName = app + "-" + name + ":"; 1901 QString qualifiedName = app + "-" + name + ":";
1902 QString value; 1902 QString value;
1903 1903
1904 QStringList::ConstIterator it; 1904 QStringList::ConstIterator it;
1905 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { 1905 for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
1906 if ( (*it).startsWith( qualifiedName ) ) { 1906 if ( (*it).startsWith( qualifiedName ) ) {
1907 value = (*it).mid( (*it).find( ":" ) + 1 ); 1907 value = (*it).mid( (*it).find( ":" ) + 1 );
1908 break; 1908 break;
1909 } 1909 }
1910 } 1910 }
1911 1911
1912 return value; 1912 return value;
1913} 1913}
1914 1914
1915void Addressee::setCustoms( const QStringList &l ) 1915void Addressee::setCustoms( const QStringList &l )
1916{ 1916{
1917 detach(); 1917 detach();
1918 mData->empty = false; 1918 mData->empty = false;
1919 1919
1920 mData->custom = l; 1920 mData->custom = l;
1921} 1921}
1922 1922
1923QStringList Addressee::customs() const 1923QStringList Addressee::customs() const
1924{ 1924{
1925 return mData->custom; 1925 return mData->custom;
1926} 1926}
1927 1927
1928void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, 1928void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
1929 QString &email) 1929 QString &email)
1930{ 1930{
1931 int startPos, endPos, len; 1931 int startPos, endPos, len;
1932 QString partA, partB, result; 1932 QString partA, partB, result;
1933 char endCh = '>'; 1933 char endCh = '>';
1934 1934
1935 startPos = rawEmail.find('<'); 1935 startPos = rawEmail.find('<');
1936 if (startPos < 0) 1936 if (startPos < 0)
1937 { 1937 {
1938 startPos = rawEmail.find('('); 1938 startPos = rawEmail.find('(');
1939 endCh = ')'; 1939 endCh = ')';
1940 } 1940 }
1941 if (startPos < 0) 1941 if (startPos < 0)
1942 { 1942 {
1943 // 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
1944 // is the email address 1944 // is the email address
1945 email = rawEmail; 1945 email = rawEmail;
1946 fullName = ""; 1946 fullName = "";
1947 } 1947 }
1948 else 1948 else
1949 { 1949 {
1950 // We have a start position, try to find an end 1950 // We have a start position, try to find an end
1951 endPos = rawEmail.find(endCh, startPos+1); 1951 endPos = rawEmail.find(endCh, startPos+1);
1952 1952
1953 if (endPos < 0) 1953 if (endPos < 0)
1954 { 1954 {
1955 // 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
1956 // assume the entire string is the email address. 1956 // assume the entire string is the email address.
1957 email = rawEmail; 1957 email = rawEmail;
1958 fullName = ""; 1958 fullName = "";
1959 } 1959 }
1960 else 1960 else
1961 { 1961 {
1962 // We have a start and end to the email address 1962 // We have a start and end to the email address
1963 1963
1964 // Grab the name part 1964 // Grab the name part
1965 fullName = rawEmail.left(startPos).stripWhiteSpace(); 1965 fullName = rawEmail.left(startPos).stripWhiteSpace();
1966 1966
1967 // grab the email part 1967 // grab the email part
1968 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); 1968 email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
1969 1969
1970 // 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
1971 // strings 1971 // strings
1972 len = fullName.length(); 1972 len = fullName.length();
1973 if (fullName[0]=='"' && fullName[len-1]=='"') 1973 if (fullName[0]=='"' && fullName[len-1]=='"')
1974 fullName = fullName.mid(1, len-2); 1974 fullName = fullName.mid(1, len-2);
1975 else if (fullName[0]=='<' && fullName[len-1]=='>') 1975 else if (fullName[0]=='<' && fullName[len-1]=='>')
1976 fullName = fullName.mid(1, len-2); 1976 fullName = fullName.mid(1, len-2);
1977 else if (fullName[0]=='(' && fullName[len-1]==')') 1977 else if (fullName[0]=='(' && fullName[len-1]==')')
1978 fullName = fullName.mid(1, len-2); 1978 fullName = fullName.mid(1, len-2);
1979 } 1979 }
1980 } 1980 }
1981} 1981}
1982 1982
1983void Addressee::setResource( Resource *resource ) 1983void Addressee::setResource( Resource *resource )
1984{ 1984{
1985 detach(); 1985 detach();
1986 mData->resource = resource; 1986 mData->resource = resource;
1987} 1987}
1988 1988
1989Resource *Addressee::resource() const 1989Resource *Addressee::resource() const
1990{ 1990{
1991 return mData->resource; 1991 return mData->resource;
1992} 1992}
1993 1993
1994//US 1994//US
1995QString Addressee::resourceLabel() 1995QString Addressee::resourceLabel()
1996{ 1996{
1997 return i18n("Resource"); 1997 return i18n("Resource");
1998} 1998}
1999QString Addressee::categoryLabel()
2000{
2001 return i18n("Category");
2002}
1999 2003
2000void Addressee::setChanged( bool value ) 2004void Addressee::setChanged( bool value )
2001{ 2005{
2002 detach(); 2006 detach();
2003 mData->changed = value; 2007 mData->changed = value;
2004} 2008}
2005 2009
2006bool Addressee::changed() const 2010bool Addressee::changed() const
2007{ 2011{
2008 return mData->changed; 2012 return mData->changed;
2009} 2013}
2010 2014
2011void Addressee::setTagged( bool value ) 2015void Addressee::setTagged( bool value )
2012{ 2016{
2013 detach(); 2017 detach();
2014 mData->tagged = value; 2018 mData->tagged = value;
2015} 2019}
2016 2020
2017bool Addressee::tagged() const 2021bool Addressee::tagged() const
2018{ 2022{
2019 return mData->tagged; 2023 return mData->tagged;
2020} 2024}
2021 2025
2022QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) 2026QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
2023{ 2027{
2024 if (!a.mData) return s; 2028 if (!a.mData) return s;
2025 2029
2026 s << a.uid(); 2030 s << a.uid();
2027 2031
2028 s << a.mData->name; 2032 s << a.mData->name;
2029 s << a.mData->formattedName; 2033 s << a.mData->formattedName;
2030 s << a.mData->familyName; 2034 s << a.mData->familyName;
2031 s << a.mData->givenName; 2035 s << a.mData->givenName;
2032 s << a.mData->additionalName; 2036 s << a.mData->additionalName;
2033 s << a.mData->prefix; 2037 s << a.mData->prefix;
2034 s << a.mData->suffix; 2038 s << a.mData->suffix;
2035 s << a.mData->nickName; 2039 s << a.mData->nickName;
2036 s << a.mData->birthday; 2040 s << a.mData->birthday;
2037 s << a.mData->mailer; 2041 s << a.mData->mailer;
2038 s << a.mData->timeZone; 2042 s << a.mData->timeZone;
2039 s << a.mData->geo; 2043 s << a.mData->geo;
2040 s << a.mData->title; 2044 s << a.mData->title;
2041 s << a.mData->role; 2045 s << a.mData->role;
2042 s << a.mData->organization; 2046 s << a.mData->organization;
2043 s << a.mData->note; 2047 s << a.mData->note;
2044 s << a.mData->productId; 2048 s << a.mData->productId;
2045 s << a.mData->revision; 2049 s << a.mData->revision;
2046 s << a.mData->sortString; 2050 s << a.mData->sortString;
2047 s << a.mData->url; 2051 s << a.mData->url;
2048 s << a.mData->secrecy; 2052 s << a.mData->secrecy;
2049 s << a.mData->logo; 2053 s << a.mData->logo;
2050 s << a.mData->photo; 2054 s << a.mData->photo;
2051 s << a.mData->sound; 2055 s << a.mData->sound;
2052 s << a.mData->agent; 2056 s << a.mData->agent;
2053 s << a.mData->phoneNumbers; 2057 s << a.mData->phoneNumbers;
2054 s << a.mData->addresses; 2058 s << a.mData->addresses;
2055 s << a.mData->emails; 2059 s << a.mData->emails;
2056 s << a.mData->categories; 2060 s << a.mData->categories;
2057 s << a.mData->custom; 2061 s << a.mData->custom;
2058 s << a.mData->keys; 2062 s << a.mData->keys;
2059 return s; 2063 return s;
2060} 2064}
2061 2065
2062QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) 2066QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
2063{ 2067{
2064 if (!a.mData) return s; 2068 if (!a.mData) return s;
2065 2069
2066 s >> a.mData->uid; 2070 s >> a.mData->uid;
2067 2071
2068 s >> a.mData->name; 2072 s >> a.mData->name;
2069 s >> a.mData->formattedName; 2073 s >> a.mData->formattedName;
2070 s >> a.mData->familyName; 2074 s >> a.mData->familyName;
2071 s >> a.mData->givenName; 2075 s >> a.mData->givenName;
2072 s >> a.mData->additionalName; 2076 s >> a.mData->additionalName;
2073 s >> a.mData->prefix; 2077 s >> a.mData->prefix;
2074 s >> a.mData->suffix; 2078 s >> a.mData->suffix;
2075 s >> a.mData->nickName; 2079 s >> a.mData->nickName;
2076 s >> a.mData->birthday; 2080 s >> a.mData->birthday;
2077 s >> a.mData->mailer; 2081 s >> a.mData->mailer;
2078 s >> a.mData->timeZone; 2082 s >> a.mData->timeZone;
2079 s >> a.mData->geo; 2083 s >> a.mData->geo;
2080 s >> a.mData->title; 2084 s >> a.mData->title;
2081 s >> a.mData->role; 2085 s >> a.mData->role;
2082 s >> a.mData->organization; 2086 s >> a.mData->organization;
2083 s >> a.mData->note; 2087 s >> a.mData->note;
2084 s >> a.mData->productId; 2088 s >> a.mData->productId;
2085 s >> a.mData->revision; 2089 s >> a.mData->revision;
2086 s >> a.mData->sortString; 2090 s >> a.mData->sortString;
2087 s >> a.mData->url; 2091 s >> a.mData->url;
2088 s >> a.mData->secrecy; 2092 s >> a.mData->secrecy;
2089 s >> a.mData->logo; 2093 s >> a.mData->logo;
2090 s >> a.mData->photo; 2094 s >> a.mData->photo;
2091 s >> a.mData->sound; 2095 s >> a.mData->sound;
2092 s >> a.mData->agent; 2096 s >> a.mData->agent;
2093 s >> a.mData->phoneNumbers; 2097 s >> a.mData->phoneNumbers;
2094 s >> a.mData->addresses; 2098 s >> a.mData->addresses;
2095 s >> a.mData->emails; 2099 s >> a.mData->emails;
2096 s >> a.mData->categories; 2100 s >> a.mData->categories;
2097 s >> a.mData->custom; 2101 s >> a.mData->custom;
2098 s >> a.mData->keys; 2102 s >> a.mData->keys;
2099 2103
2100 a.mData->empty = false; 2104 a.mData->empty = false;
2101 2105
2102 return s; 2106 return s;
2103} 2107}
2104bool matchBinaryPattern( int value, int pattern ) 2108bool matchBinaryPattern( int value, int pattern )
2105{ 2109{
2106 /** 2110 /**
2107 We want to match all telephonnumbers/addresses which have the bits in the 2111 We want to match all telephonnumbers/addresses which have the bits in the
2108 pattern set. More are allowed. 2112 pattern set. More are allowed.
2109 if pattern == 0 we have a special handling, then we want only those with 2113 if pattern == 0 we have a special handling, then we want only those with
2110 exactly no bit set. 2114 exactly no bit set.
2111 */ 2115 */
2112 if ( pattern == 0 ) 2116 if ( pattern == 0 )
2113 return ( value == 0 ); 2117 return ( value == 0 );
2114 else 2118 else
2115 return ( pattern == ( pattern & value ) ); 2119 return ( pattern == ( pattern & value ) );
2116} 2120}
2117 2121
2118bool matchBinaryPatternP( int value, int pattern ) 2122bool matchBinaryPatternP( int value, int pattern )
2119{ 2123{
2120 2124
2121 if ( pattern == 0 ) 2125 if ( pattern == 0 )
2122 return ( value == 0 ); 2126 return ( value == 0 );
2123 else 2127 else
2124 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); 2128 return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) );
2125} 2129}
2126bool matchBinaryPatternA( int value, int pattern ) 2130bool matchBinaryPatternA( int value, int pattern )
2127{ 2131{
2128 2132
2129 if ( pattern == 0 ) 2133 if ( pattern == 0 )
2130 return ( value == 0 ); 2134 return ( value == 0 );
2131 else 2135 else
2132 return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); 2136 return ( (pattern | Address::Pref) == ( value | Address::Pref ) );
2133} 2137}
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 2c81c1a..08d2f56 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -1,853 +1,853 @@
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#ifndef KABC_ADDRESSEE_H 29#ifndef KABC_ADDRESSEE_H
30#define KABC_ADDRESSEE_H 30#define KABC_ADDRESSEE_H
31 31
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qstringlist.h> 34#include <qstringlist.h>
35#include <qvaluelist.h> 35#include <qvaluelist.h>
36 36
37#include <ksharedptr.h> 37#include <ksharedptr.h>
38#include <kurl.h> 38#include <kurl.h>
39 39
40#include "address.h" 40#include "address.h"
41#include "agent.h" 41#include "agent.h"
42#include "geo.h" 42#include "geo.h"
43#include "key.h" 43#include "key.h"
44#include "phonenumber.h" 44#include "phonenumber.h"
45#include "picture.h" 45#include "picture.h"
46#include "secrecy.h" 46#include "secrecy.h"
47#include "sound.h" 47#include "sound.h"
48#include "timezone.h" 48#include "timezone.h"
49 49
50namespace KABC { 50namespace KABC {
51 51
52class Resource; 52class Resource;
53 53
54/** 54/**
55 @short address book entry 55 @short address book entry
56 56
57 This class represents an entry in the address book. 57 This class represents an entry in the address book.
58 58
59 The data of this class is implicitly shared. You can pass this class by value. 59 The data of this class is implicitly shared. You can pass this class by value.
60 60
61 If you need the name of a field for presenting it to the user you should use 61 If you need the name of a field for presenting it to the user you should use
62 the functions ending in Label(). They return a translated string which can be 62 the functions ending in Label(). They return a translated string which can be
63 used as label for the corresponding field. 63 used as label for the corresponding field.
64 64
65 About the name fields: 65 About the name fields:
66 66
67 givenName() is the first name and familyName() the last name. In some 67 givenName() is the first name and familyName() the last name. In some
68 countries the family name comes first, that's the reason for the 68 countries the family name comes first, that's the reason for the
69 naming. formattedName() is the full name with the correct formatting. 69 naming. formattedName() is the full name with the correct formatting.
70 It is used as an override, when the correct formatting can't be generated 70 It is used as an override, when the correct formatting can't be generated
71 from the other name fields automatically. 71 from the other name fields automatically.
72 72
73 realName() returns a fully formatted name(). It uses formattedName, if set, 73 realName() returns a fully formatted name(). It uses formattedName, if set,
74 otherwise it constucts the name from the name fields. As fallback, if 74 otherwise it constucts the name from the name fields. As fallback, if
75 nothing else is set it uses name(). 75 nothing else is set it uses name().
76 76
77 name() is the NAME type of RFC2426. It can be used as internal name for the 77 name() is the NAME type of RFC2426. It can be used as internal name for the
78 data enty, but shouldn't be used for displaying the data to the user. 78 data enty, but shouldn't be used for displaying the data to the user.
79 */ 79 */
80class Addressee 80class Addressee
81{ 81{
82 friend QDataStream &operator<<( QDataStream &, const Addressee & ); 82 friend QDataStream &operator<<( QDataStream &, const Addressee & );
83 friend QDataStream &operator>>( QDataStream &, Addressee & ); 83 friend QDataStream &operator>>( QDataStream &, Addressee & );
84 84
85 public: 85 public:
86 typedef QValueList<Addressee> List; 86 typedef QValueList<Addressee> List;
87 87
88 /** 88 /**
89 Construct an empty address book entry. 89 Construct an empty address book entry.
90 */ 90 */
91 Addressee(); 91 Addressee();
92 ~Addressee(); 92 ~Addressee();
93 93
94 Addressee( const Addressee & ); 94 Addressee( const Addressee & );
95 Addressee &operator=( const Addressee & ); 95 Addressee &operator=( const Addressee & );
96 96
97 bool operator==( const Addressee & ) const; 97 bool operator==( const Addressee & ) const;
98 bool operator!=( const Addressee & ) const; 98 bool operator!=( const Addressee & ) const;
99 // sync stuff 99 // sync stuff
100 void setTempSyncStat(int id); 100 void setTempSyncStat(int id);
101 int tempSyncStat() const; 101 int tempSyncStat() const;
102 void setIDStr( const QString & ); 102 void setIDStr( const QString & );
103 QString IDStr() const; 103 QString IDStr() const;
104 void setID( const QString &, const QString & ); 104 void setID( const QString &, const QString & );
105 QString getID( const QString & ); 105 QString getID( const QString & );
106 void setCsum( const QString &, const QString & ); 106 void setCsum( const QString &, const QString & );
107 QString getCsum( const QString & ); 107 QString getCsum( const QString & );
108 void removeID(const QString &); 108 void removeID(const QString &);
109 void computeCsum(const QString &dev); 109 void computeCsum(const QString &dev);
110 ulong getCsum4List( const QStringList & attList); 110 ulong getCsum4List( const QStringList & attList);
111 /** 111 /**
112 Return, if the address book entry is empty. 112 Return, if the address book entry is empty.
113 */ 113 */
114 bool isEmpty() const; 114 bool isEmpty() const;
115 void setExternalUID( const QString &id ); 115 void setExternalUID( const QString &id );
116 QString externalUID() const; 116 QString externalUID() const;
117 void setOriginalExternalUID( const QString &id ); 117 void setOriginalExternalUID( const QString &id );
118 QString originalExternalUID() const; 118 QString originalExternalUID() const;
119 void mergeContact( const Addressee& ad, bool isSubSet ); 119 void mergeContact( const Addressee& ad, bool isSubSet );
120 void simplifyEmails(); 120 void simplifyEmails();
121 void simplifyAddresses(); 121 void simplifyAddresses();
122 void simplifyPhoneNumbers(); 122 void simplifyPhoneNumbers();
123 void simplifyPhoneNumberTypes(); 123 void simplifyPhoneNumberTypes();
124 bool removeVoice(); 124 bool removeVoice();
125 bool containsAdr(const Addressee& addr ); 125 bool containsAdr(const Addressee& addr );
126 126
127 /** 127 /**
128 Set unique identifier. 128 Set unique identifier.
129 */ 129 */
130 void setUid( const QString &uid ); 130 void setUid( const QString &uid );
131 /** 131 /**
132 Return unique identifier. 132 Return unique identifier.
133 */ 133 */
134 QString uid() const; 134 QString uid() const;
135 /** 135 /**
136 Return translated label for uid field. 136 Return translated label for uid field.
137 */ 137 */
138 static QString uidLabel(); 138 static QString uidLabel();
139 139
140 /** 140 /**
141 Set name. 141 Set name.
142 */ 142 */
143 void setName( const QString &name ); 143 void setName( const QString &name );
144 /** 144 /**
145 Return name. 145 Return name.
146 */ 146 */
147 QString name() const; 147 QString name() const;
148 /** 148 /**
149 Return translated label for name field. 149 Return translated label for name field.
150 */ 150 */
151 static QString nameLabel(); 151 static QString nameLabel();
152 152
153 /** 153 /**
154 Set formatted name. 154 Set formatted name.
155 */ 155 */
156 void setFormattedName( const QString &formattedName ); 156 void setFormattedName( const QString &formattedName );
157 /** 157 /**
158 Return formatted name. 158 Return formatted name.
159 */ 159 */
160 QString formattedName() const; 160 QString formattedName() const;
161 /** 161 /**
162 Return translated label for formattedName field. 162 Return translated label for formattedName field.
163 */ 163 */
164 static QString formattedNameLabel(); 164 static QString formattedNameLabel();
165 165
166 /** 166 /**
167 Set family name. 167 Set family name.
168 */ 168 */
169 void setFamilyName( const QString &familyName ); 169 void setFamilyName( const QString &familyName );
170 /** 170 /**
171 Return family name. 171 Return family name.
172 */ 172 */
173 QString familyName() const; 173 QString familyName() const;
174 /** 174 /**
175 Return translated label for familyName field. 175 Return translated label for familyName field.
176 */ 176 */
177 static QString familyNameLabel(); 177 static QString familyNameLabel();
178 178
179 /** 179 /**
180 Set given name. 180 Set given name.
181 */ 181 */
182 void setGivenName( const QString &givenName ); 182 void setGivenName( const QString &givenName );
183 /** 183 /**
184 Return given name. 184 Return given name.
185 */ 185 */
186 QString givenName() const; 186 QString givenName() const;
187 /** 187 /**
188 Return translated label for givenName field. 188 Return translated label for givenName field.
189 */ 189 */
190 static QString givenNameLabel(); 190 static QString givenNameLabel();
191 191
192 /** 192 /**
193 Set additional names. 193 Set additional names.
194 */ 194 */
195 void setAdditionalName( const QString &additionalName ); 195 void setAdditionalName( const QString &additionalName );
196 /** 196 /**
197 Return additional names. 197 Return additional names.
198 */ 198 */
199 QString additionalName() const; 199 QString additionalName() const;
200 /** 200 /**
201 Return translated label for additionalName field. 201 Return translated label for additionalName field.
202 */ 202 */
203 static QString additionalNameLabel(); 203 static QString additionalNameLabel();
204 204
205 /** 205 /**
206 Set honorific prefixes. 206 Set honorific prefixes.
207 */ 207 */
208 void setPrefix( const QString &prefix ); 208 void setPrefix( const QString &prefix );
209 /** 209 /**
210 Return honorific prefixes. 210 Return honorific prefixes.
211 */ 211 */
212 QString prefix() const; 212 QString prefix() const;
213 /** 213 /**
214 Return translated label for prefix field. 214 Return translated label for prefix field.
215 */ 215 */
216 static QString prefixLabel(); 216 static QString prefixLabel();
217 217
218 /** 218 /**
219 Set honorific suffixes. 219 Set honorific suffixes.
220 */ 220 */
221 void setSuffix( const QString &suffix ); 221 void setSuffix( const QString &suffix );
222 /** 222 /**
223 Return honorific suffixes. 223 Return honorific suffixes.
224 */ 224 */
225 QString suffix() const; 225 QString suffix() const;
226 /** 226 /**
227 Return translated label for suffix field. 227 Return translated label for suffix field.
228 */ 228 */
229 static QString suffixLabel(); 229 static QString suffixLabel();
230 230
231 /** 231 /**
232 Set nick name. 232 Set nick name.
233 */ 233 */
234 void setNickName( const QString &nickName ); 234 void setNickName( const QString &nickName );
235 /** 235 /**
236 Return nick name. 236 Return nick name.
237 */ 237 */
238 QString nickName() const; 238 QString nickName() const;
239 /** 239 /**
240 Return translated label for nickName field. 240 Return translated label for nickName field.
241 */ 241 */
242 static QString nickNameLabel(); 242 static QString nickNameLabel();
243 243
244 /** 244 /**
245 Set birthday. 245 Set birthday.
246 */ 246 */
247 void setBirthday( const QDateTime &birthday ); 247 void setBirthday( const QDateTime &birthday );
248 /** 248 /**
249 Return birthday. 249 Return birthday.
250 */ 250 */
251 QDateTime birthday() const; 251 QDateTime birthday() const;
252 /** 252 /**
253 Return translated label for birthday field. 253 Return translated label for birthday field.
254 */ 254 */
255 static QString birthdayLabel(); 255 static QString birthdayLabel();
256 256
257 /** 257 /**
258 Return translated label for homeAddressStreet field. 258 Return translated label for homeAddressStreet field.
259 */ 259 */
260 static QString homeAddressStreetLabel(); 260 static QString homeAddressStreetLabel();
261 261
262 /** 262 /**
263 Return translated label for homeAddressLocality field. 263 Return translated label for homeAddressLocality field.
264 */ 264 */
265 static QString homeAddressLocalityLabel(); 265 static QString homeAddressLocalityLabel();
266 266
267 /** 267 /**
268 Return translated label for homeAddressRegion field. 268 Return translated label for homeAddressRegion field.
269 */ 269 */
270 static QString homeAddressRegionLabel(); 270 static QString homeAddressRegionLabel();
271 271
272 /** 272 /**
273 Return translated label for homeAddressPostalCode field. 273 Return translated label for homeAddressPostalCode field.
274 */ 274 */
275 static QString homeAddressPostalCodeLabel(); 275 static QString homeAddressPostalCodeLabel();
276 276
277 /** 277 /**
278 Return translated label for homeAddressCountry field. 278 Return translated label for homeAddressCountry field.
279 */ 279 */
280 static QString homeAddressCountryLabel(); 280 static QString homeAddressCountryLabel();
281 281
282 /** 282 /**
283 Return translated label for homeAddressLabel field. 283 Return translated label for homeAddressLabel field.
284 */ 284 */
285 static QString homeAddressLabelLabel(); 285 static QString homeAddressLabelLabel();
286 286
287 /** 287 /**
288 Return translated label for businessAddressStreet field. 288 Return translated label for businessAddressStreet field.
289 */ 289 */
290 static QString businessAddressStreetLabel(); 290 static QString businessAddressStreetLabel();
291 291
292 /** 292 /**
293 Return translated label for businessAddressLocality field. 293 Return translated label for businessAddressLocality field.
294 */ 294 */
295 static QString businessAddressLocalityLabel(); 295 static QString businessAddressLocalityLabel();
296 296
297 /** 297 /**
298 Return translated label for businessAddressRegion field. 298 Return translated label for businessAddressRegion field.
299 */ 299 */
300 static QString businessAddressRegionLabel(); 300 static QString businessAddressRegionLabel();
301 301
302 /** 302 /**
303 Return translated label for businessAddressPostalCode field. 303 Return translated label for businessAddressPostalCode field.
304 */ 304 */
305 static QString businessAddressPostalCodeLabel(); 305 static QString businessAddressPostalCodeLabel();
306 306
307 /** 307 /**
308 Return translated label for businessAddressCountry field. 308 Return translated label for businessAddressCountry field.
309 */ 309 */
310 static QString businessAddressCountryLabel(); 310 static QString businessAddressCountryLabel();
311 311
312 /** 312 /**
313 Return translated label for businessAddressLabel field. 313 Return translated label for businessAddressLabel field.
314 */ 314 */
315 static QString businessAddressLabelLabel(); 315 static QString businessAddressLabelLabel();
316 316
317 /** 317 /**
318 Return translated label for homePhone field. 318 Return translated label for homePhone field.
319 */ 319 */
320 static QString homePhoneLabel(); 320 static QString homePhoneLabel();
321 321
322 /** 322 /**
323 Return translated label for businessPhone field. 323 Return translated label for businessPhone field.
324 */ 324 */
325 static QString businessPhoneLabel(); 325 static QString businessPhoneLabel();
326 326
327 /** 327 /**
328 Return translated label for mobilePhone field. 328 Return translated label for mobilePhone field.
329 */ 329 */
330 static QString mobilePhoneLabel(); 330 static QString mobilePhoneLabel();
331 331
332 /** 332 /**
333 Return translated label for homeFax field. 333 Return translated label for homeFax field.
334 */ 334 */
335 static QString homeFaxLabel(); 335 static QString homeFaxLabel();
336 336
337 /** 337 /**
338 Return translated label for businessFax field. 338 Return translated label for businessFax field.
339 */ 339 */
340 static QString businessFaxLabel(); 340 static QString businessFaxLabel();
341 341
342 /** 342 /**
343 Return translated label for carPhone field. 343 Return translated label for carPhone field.
344 */ 344 */
345 static QString carPhoneLabel(); 345 static QString carPhoneLabel();
346 346
347 /** 347 /**
348 Return translated label for isdn field. 348 Return translated label for isdn field.
349 */ 349 */
350 static QString isdnLabel(); 350 static QString isdnLabel();
351 351
352 /** 352 /**
353 Return translated label for pager field. 353 Return translated label for pager field.
354 */ 354 */
355 static QString pagerLabel(); 355 static QString pagerLabel();
356 356
357 /** 357 /**
358 Return translated label for sip field. 358 Return translated label for sip field.
359 */ 359 */
360 static QString sipLabel(); 360 static QString sipLabel();
361 361
362 /** 362 /**
363 Return translated label for email field. 363 Return translated label for email field.
364 */ 364 */
365 static QString emailLabel(); 365 static QString emailLabel();
366 366
367 /** 367 /**
368 Set mail client. 368 Set mail client.
369 */ 369 */
370 void setMailer( const QString &mailer ); 370 void setMailer( const QString &mailer );
371 /** 371 /**
372 Return mail client. 372 Return mail client.
373 */ 373 */
374 QString mailer() const; 374 QString mailer() const;
375 /** 375 /**
376 Return translated label for mailer field. 376 Return translated label for mailer field.
377 */ 377 */
378 static QString mailerLabel(); 378 static QString mailerLabel();
379 379
380 /** 380 /**
381 Set time zone. 381 Set time zone.
382 */ 382 */
383 void setTimeZone( const TimeZone &timeZone ); 383 void setTimeZone( const TimeZone &timeZone );
384 /** 384 /**
385 Return time zone. 385 Return time zone.
386 */ 386 */
387 TimeZone timeZone() const; 387 TimeZone timeZone() const;
388 /** 388 /**
389 Return translated label for timeZone field. 389 Return translated label for timeZone field.
390 */ 390 */
391 static QString timeZoneLabel(); 391 static QString timeZoneLabel();
392 392
393 /** 393 /**
394 Set geographic position. 394 Set geographic position.
395 */ 395 */
396 void setGeo( const Geo &geo ); 396 void setGeo( const Geo &geo );
397 /** 397 /**
398 Return geographic position. 398 Return geographic position.
399 */ 399 */
400 Geo geo() const; 400 Geo geo() const;
401 /** 401 /**
402 Return translated label for geo field. 402 Return translated label for geo field.
403 */ 403 */
404 static QString geoLabel(); 404 static QString geoLabel();
405 405
406 /** 406 /**
407 Set title. 407 Set title.
408 */ 408 */
409 void setTitle( const QString &title ); 409 void setTitle( const QString &title );
410 /** 410 /**
411 Return title. 411 Return title.
412 */ 412 */
413 QString title() const; 413 QString title() const;
414 /** 414 /**
415 Return translated label for title field. 415 Return translated label for title field.
416 */ 416 */
417 static QString titleLabel(); 417 static QString titleLabel();
418 418
419 /** 419 /**
420 Set role. 420 Set role.
421 */ 421 */
422 void setRole( const QString &role ); 422 void setRole( const QString &role );
423 /** 423 /**
424 Return role. 424 Return role.
425 */ 425 */
426 QString role() const; 426 QString role() const;
427 /** 427 /**
428 Return translated label for role field. 428 Return translated label for role field.
429 */ 429 */
430 static QString roleLabel(); 430 static QString roleLabel();
431 431
432 /** 432 /**
433 Set organization. 433 Set organization.
434 */ 434 */
435 void setOrganization( const QString &organization ); 435 void setOrganization( const QString &organization );
436 /** 436 /**
437 Return organization. 437 Return organization.
438 */ 438 */
439 QString organization() const; 439 QString organization() const;
440 /** 440 /**
441 Return translated label for organization field. 441 Return translated label for organization field.
442 */ 442 */
443 static QString organizationLabel(); 443 static QString organizationLabel();
444 444
445 /** 445 /**
446 Set note. 446 Set note.
447 */ 447 */
448 void setNote( const QString &note ); 448 void setNote( const QString &note );
449 /** 449 /**
450 Return note. 450 Return note.
451 */ 451 */
452 QString note() const; 452 QString note() const;
453 /** 453 /**
454 Return translated label for note field. 454 Return translated label for note field.
455 */ 455 */
456 static QString noteLabel(); 456 static QString noteLabel();
457 457
458 /** 458 /**
459 Set product identifier. 459 Set product identifier.
460 */ 460 */
461 void setProductId( const QString &productId ); 461 void setProductId( const QString &productId );
462 /** 462 /**
463 Return product identifier. 463 Return product identifier.
464 */ 464 */
465 QString productId() const; 465 QString productId() const;
466 /** 466 /**
467 Return translated label for productId field. 467 Return translated label for productId field.
468 */ 468 */
469 static QString productIdLabel(); 469 static QString productIdLabel();
470 470
471 /** 471 /**
472 Set revision date. 472 Set revision date.
473 */ 473 */
474 void setRevision( const QDateTime &revision ); 474 void setRevision( const QDateTime &revision );
475 /** 475 /**
476 Return revision date. 476 Return revision date.
477 */ 477 */
478 QDateTime revision() const; 478 QDateTime revision() const;
479 /** 479 /**
480 Return translated label for revision field. 480 Return translated label for revision field.
481 */ 481 */
482 static QString revisionLabel(); 482 static QString revisionLabel();
483 483
484 /** 484 /**
485 Set sort string. 485 Set sort string.
486 */ 486 */
487 void setSortString( const QString &sortString ); 487 void setSortString( const QString &sortString );
488 /** 488 /**
489 Return sort string. 489 Return sort string.
490 */ 490 */
491 QString sortString() const; 491 QString sortString() const;
492 /** 492 /**
493 Return translated label for sortString field. 493 Return translated label for sortString field.
494 */ 494 */
495 static QString sortStringLabel(); 495 static QString sortStringLabel();
496 496
497 /** 497 /**
498 Set URL. 498 Set URL.
499 */ 499 */
500 void setUrl( const KURL &url ); 500 void setUrl( const KURL &url );
501 /** 501 /**
502 Return URL. 502 Return URL.
503 */ 503 */
504 KURL url() const; 504 KURL url() const;
505 /** 505 /**
506 Return translated label for url field. 506 Return translated label for url field.
507 */ 507 */
508 static QString urlLabel(); 508 static QString urlLabel();
509 509
510 /** 510 /**
511 Set security class. 511 Set security class.
512 */ 512 */
513 void setSecrecy( const Secrecy &secrecy ); 513 void setSecrecy( const Secrecy &secrecy );
514 /** 514 /**
515 Return security class. 515 Return security class.
516 */ 516 */
517 Secrecy secrecy() const; 517 Secrecy secrecy() const;
518 /** 518 /**
519 Return translated label for secrecy field. 519 Return translated label for secrecy field.
520 */ 520 */
521 static QString secrecyLabel(); 521 static QString secrecyLabel();
522 522
523 /** 523 /**
524 Set logo. 524 Set logo.
525 */ 525 */
526 void setLogo( const Picture &logo ); 526 void setLogo( const Picture &logo );
527 /** 527 /**
528 Return logo. 528 Return logo.
529 */ 529 */
530 Picture logo() const; 530 Picture logo() const;
531 /** 531 /**
532 Return translated label for logo field. 532 Return translated label for logo field.
533 */ 533 */
534 static QString logoLabel(); 534 static QString logoLabel();
535 535
536 /** 536 /**
537 Set photo. 537 Set photo.
538 */ 538 */
539 void setPhoto( const Picture &photo ); 539 void setPhoto( const Picture &photo );
540 /** 540 /**
541 Return photo. 541 Return photo.
542 */ 542 */
543 Picture photo() const; 543 Picture photo() const;
544 /** 544 /**
545 Return translated label for photo field. 545 Return translated label for photo field.
546 */ 546 */
547 static QString photoLabel(); 547 static QString photoLabel();
548 548
549 /** 549 /**
550 Set sound. 550 Set sound.
551 */ 551 */
552 void setSound( const Sound &sound ); 552 void setSound( const Sound &sound );
553 /** 553 /**
554 Return sound. 554 Return sound.
555 */ 555 */
556 Sound sound() const; 556 Sound sound() const;
557 /** 557 /**
558 Return translated label for sound field. 558 Return translated label for sound field.
559 */ 559 */
560 static QString soundLabel(); 560 static QString soundLabel();
561 561
562 /** 562 /**
563 Set agent. 563 Set agent.
564 */ 564 */
565 void setAgent( const Agent &agent ); 565 void setAgent( const Agent &agent );
566 /** 566 /**
567 Return agent. 567 Return agent.
568 */ 568 */
569 Agent agent() const; 569 Agent agent() const;
570 /** 570 /**
571 Return translated label for agent field. 571 Return translated label for agent field.
572 */ 572 */
573 static QString agentLabel(); 573 static QString agentLabel();
574 574
575 /** 575 /**
576 Set name fields by parsing the given string and trying to associate the 576 Set name fields by parsing the given string and trying to associate the
577 parts of the string with according fields. This function should probably 577 parts of the string with according fields. This function should probably
578 be a bit more clever. 578 be a bit more clever.
579 */ 579 */
580 void setNameFromString( const QString & ); 580 void setNameFromString( const QString & );
581 581
582 /** 582 /**
583 Return the name of the addressee. This is calculated from all the name 583 Return the name of the addressee. This is calculated from all the name
584 fields. 584 fields.
585 */ 585 */
586 QString realName() const; 586 QString realName() const;
587 587
588 /** 588 /**
589 Return the name that consists of all name parts. 589 Return the name that consists of all name parts.
590 */ 590 */
591 QString assembledName() const; 591 QString assembledName() const;
592 592
593 /** 593 /**
594 Return email address including real name. 594 Return email address including real name.
595 595
596 @param email Email address to be used to construct the full email string. 596 @param email Email address to be used to construct the full email string.
597 If this is QString::null the preferred email address is used. 597 If this is QString::null the preferred email address is used.
598 */ 598 */
599 QString fullEmail( const QString &email=QString::null ) const; 599 QString fullEmail( const QString &email=QString::null ) const;
600 600
601 /** 601 /**
602 Insert an email address. If the email address already exists in this 602 Insert an email address. If the email address already exists in this
603 addressee it is not duplicated. 603 addressee it is not duplicated.
604 604
605 @param email Email address 605 @param email Email address
606 @param preferred Set to true, if this is the preferred email address of 606 @param preferred Set to true, if this is the preferred email address of
607 the addressee. 607 the addressee.
608 */ 608 */
609 void insertEmail( const QString &email, bool preferred=false ); 609 void insertEmail( const QString &email, bool preferred=false );
610 610
611 /** 611 /**
612 Remove email address. If the email address doesn't exist, nothing happens. 612 Remove email address. If the email address doesn't exist, nothing happens.
613 */ 613 */
614 void removeEmail( const QString &email ); 614 void removeEmail( const QString &email );
615 615
616 /** 616 /**
617 Return preferred email address. This is the first email address or the 617 Return preferred email address. This is the first email address or the
618 last one added with @ref insertEmail() with a set preferred parameter. 618 last one added with @ref insertEmail() with a set preferred parameter.
619 */ 619 */
620 QString preferredEmail() const; 620 QString preferredEmail() const;
621 621
622 /** 622 /**
623 Return list of all email addresses. 623 Return list of all email addresses.
624 */ 624 */
625 QStringList emails() const; 625 QStringList emails() const;
626 626
627 /** 627 /**
628 Set the emails to @param. 628 Set the emails to @param.
629 The first email address gets the preferred one! 629 The first email address gets the preferred one!
630 @param list The list of email addresses. 630 @param list The list of email addresses.
631 */ 631 */
632 void setEmails( const QStringList& list); 632 void setEmails( const QStringList& list);
633 633
634 /** 634 /**
635 Insert a phone number. If a phone number with the same id already exists 635 Insert a phone number. If a phone number with the same id already exists
636 in this addressee it is not duplicated. 636 in this addressee it is not duplicated.
637 */ 637 */
638 void insertPhoneNumber( const PhoneNumber &phoneNumber ); 638 void insertPhoneNumber( const PhoneNumber &phoneNumber );
639 639
640 /** 640 /**
641 Remove phone number. If no phone number with the given id exists for this 641 Remove phone number. If no phone number with the given id exists for this
642 addresse nothing happens. 642 addresse nothing happens.
643 */ 643 */
644 void removePhoneNumber( const PhoneNumber &phoneNumber ); 644 void removePhoneNumber( const PhoneNumber &phoneNumber );
645 645
646 /** 646 /**
647 Return phone number, which matches the given type. 647 Return phone number, which matches the given type.
648 */ 648 */
649 PhoneNumber phoneNumber( int type ) const; 649 PhoneNumber phoneNumber( int type ) const;
650 650
651 /** 651 /**
652 Return list of all phone numbers. 652 Return list of all phone numbers.
653 */ 653 */
654 PhoneNumber::List phoneNumbers() const; 654 PhoneNumber::List phoneNumbers() const;
655 655
656 /** 656 /**
657 Return list of phone numbers with a special type. 657 Return list of phone numbers with a special type.
658 */ 658 */
659 PhoneNumber::List phoneNumbers( int type ) const; 659 PhoneNumber::List phoneNumbers( int type ) const;
660 660
661 /** 661 /**
662 Return phone number with the given id. 662 Return phone number with the given id.
663 */ 663 */
664 PhoneNumber findPhoneNumber( const QString &id ) const; 664 PhoneNumber findPhoneNumber( const QString &id ) const;
665 665
666 /** 666 /**
667 Insert a key. If a key with the same id already exists 667 Insert a key. If a key with the same id already exists
668 in this addressee it is not duplicated. 668 in this addressee it is not duplicated.
669 */ 669 */
670 void insertKey( const Key &key ); 670 void insertKey( const Key &key );
671 671
672 /** 672 /**
673 Remove a key. If no key with the given id exists for this 673 Remove a key. If no key with the given id exists for this
674 addresse nothing happens. 674 addresse nothing happens.
675 */ 675 */
676 void removeKey( const Key &key ); 676 void removeKey( const Key &key );
677 677
678 /** 678 /**
679 Return key, which matches the given type. 679 Return key, which matches the given type.
680 If @p type == Key::Custom you can specify a string 680 If @p type == Key::Custom you can specify a string
681 that should match. If you leave the string empty, the first 681 that should match. If you leave the string empty, the first
682 key with a custom value is returned. 682 key with a custom value is returned.
683 */ 683 */
684 Key key( int type, QString customTypeString = QString::null ) const; 684 Key key( int type, QString customTypeString = QString::null ) const;
685 685
686 /** 686 /**
687 Return list of all keys. 687 Return list of all keys.
688 */ 688 */
689 Key::List keys() const; 689 Key::List keys() const;
690 690
691 /** 691 /**
692 Set the list of keys 692 Set the list of keys
693 @param keys The keys to be set. 693 @param keys The keys to be set.
694 */ 694 */
695 void setKeys( const Key::List& keys); 695 void setKeys( const Key::List& keys);
696 696
697 /** 697 /**
698 Return list of keys with a special type. 698 Return list of keys with a special type.
699 If @p type == Key::Custom you can specify a string 699 If @p type == Key::Custom you can specify a string
700 that should match. If you leave the string empty, all custom 700 that should match. If you leave the string empty, all custom
701 keys will be returned. 701 keys will be returned.
702 */ 702 */
703 Key::List keys( int type, QString customTypeString = QString::null ) const; 703 Key::List keys( int type, QString customTypeString = QString::null ) const;
704 704
705 /** 705 /**
706 Return key with the given id. 706 Return key with the given id.
707 */ 707 */
708 Key findKey( const QString &id ) const; 708 Key findKey( const QString &id ) const;
709 709
710 /** 710 /**
711 Insert an address. If an address with the same id already exists 711 Insert an address. If an address with the same id already exists
712 in this addressee it is not duplicated. 712 in this addressee it is not duplicated.
713 */ 713 */
714 void insertAddress( const Address &address ); 714 void insertAddress( const Address &address );
715 715
716 /** 716 /**
717 Remove address. If no address with the given id exists for this 717 Remove address. If no address with the given id exists for this
718 addresse nothing happens. 718 addresse nothing happens.
719 */ 719 */
720 void removeAddress( const Address &address ); 720 void removeAddress( const Address &address );
721 721
722 /** 722 /**
723 Return address, which matches the given type. 723 Return address, which matches the given type.
724 */ 724 */
725 Address address( int type ) const; 725 Address address( int type ) const;
726 726
727 /** 727 /**
728 Return list of all addresses. 728 Return list of all addresses.
729 */ 729 */
730 Address::List addresses() const; 730 Address::List addresses() const;
731 731
732 /** 732 /**
733 Return list of addresses with a special type. 733 Return list of addresses with a special type.
734 */ 734 */
735 Address::List addresses( int type ) const; 735 Address::List addresses( int type ) const;
736 736
737 /** 737 /**
738 Return address with the given id. 738 Return address with the given id.
739 */ 739 */
740 Address findAddress( const QString &id ) const; 740 Address findAddress( const QString &id ) const;
741 741
742 /** 742 /**
743 Insert category. If the category already exists it is not duplicated. 743 Insert category. If the category already exists it is not duplicated.
744 */ 744 */
745 void insertCategory( const QString & ); 745 void insertCategory( const QString & );
746 746
747 /** 747 /**
748 Remove category. 748 Remove category.
749 */ 749 */
750 void removeCategory( const QString & ); 750 void removeCategory( const QString & );
751 751
752 /** 752 /**
753 Return, if addressee has the given category. 753 Return, if addressee has the given category.
754 */ 754 */
755 bool hasCategory( const QString & ) const; 755 bool hasCategory( const QString & ) const;
756 756
757 /** 757 /**
758 Set categories to given value. 758 Set categories to given value.
759 */ 759 */
760 void setCategories( const QStringList & ); 760 void setCategories( const QStringList & );
761 761
762 /** 762 /**
763 Return list of all set categories. 763 Return list of all set categories.
764 */ 764 */
765 QStringList categories() const; 765 QStringList categories() const;
766 766
767 /** 767 /**
768 Insert custom entry. The entry is identified by the name of the inserting 768 Insert custom entry. The entry is identified by the name of the inserting
769 application and a unique name. If an entry with the given app and name 769 application and a unique name. If an entry with the given app and name
770 already exists its value is replaced with the new given value. 770 already exists its value is replaced with the new given value.
771 */ 771 */
772 void insertCustom( const QString &app, const QString &name, 772 void insertCustom( const QString &app, const QString &name,
773 const QString &value ); 773 const QString &value );
774 774
775 /** 775 /**
776 Remove custom entry. 776 Remove custom entry.
777 */ 777 */
778 void removeCustom( const QString &app, const QString &name ); 778 void removeCustom( const QString &app, const QString &name );
779 779
780 /** 780 /**
781 Return value of custom entry, identified by app and entry name. 781 Return value of custom entry, identified by app and entry name.
782 */ 782 */
783 QString custom( const QString &app, const QString &name ) const; 783 QString custom( const QString &app, const QString &name ) const;
784 784
785 /** 785 /**
786 Set all custom entries. 786 Set all custom entries.
787 */ 787 */
788 void setCustoms( const QStringList & ); 788 void setCustoms( const QStringList & );
789 789
790 /** 790 /**
791 Return list of all custom entries. 791 Return list of all custom entries.
792 */ 792 */
793 QStringList customs() const; 793 QStringList customs() const;
794 794
795 /** 795 /**
796 Parse full email address. The result is given back in fullName and email. 796 Parse full email address. The result is given back in fullName and email.
797 */ 797 */
798 static void parseEmailAddress( const QString &rawEmail, QString &fullName, 798 static void parseEmailAddress( const QString &rawEmail, QString &fullName,
799 QString &email ); 799 QString &email );
800 800
801 /** 801 /**
802 Debug output. 802 Debug output.
803 */ 803 */
804 void dump() const; 804 void dump() const;
805 805
806 /** 806 /**
807 Returns string representation of the addressee. 807 Returns string representation of the addressee.
808 */ 808 */
809 QString asString() const; 809 QString asString() const;
810 810
811 /** 811 /**
812 Set resource where the addressee is from. 812 Set resource where the addressee is from.
813 */ 813 */
814 void setResource( Resource *resource ); 814 void setResource( Resource *resource );
815 815
816 /** 816 /**
817 Return pointer to resource. 817 Return pointer to resource.
818 */ 818 */
819 Resource *resource() const; 819 Resource *resource() const;
820 820
821 /** 821 /**
822 Return resourcelabel. 822 Return resourcelabel.
823 */ 823 */
824 //US 824 //US
825 static QString resourceLabel(); 825 static QString resourceLabel();
826 826 static QString categoryLabel();
827 /** 827 /**
828 Mark addressee as changed. 828 Mark addressee as changed.
829 */ 829 */
830 void setChanged( bool value ); 830 void setChanged( bool value );
831 831
832 /** 832 /**
833 Return whether the addressee is changed. 833 Return whether the addressee is changed.
834 */ 834 */
835 bool changed() const; 835 bool changed() const;
836 836
837 void setTagged( bool value ); 837 void setTagged( bool value );
838 bool tagged() const; 838 bool tagged() const;
839 839
840 private: 840 private:
841 Addressee copy(); 841 Addressee copy();
842 void detach(); 842 void detach();
843 843
844 struct AddresseeData; 844 struct AddresseeData;
845 mutable KSharedPtr<AddresseeData> mData; 845 mutable KSharedPtr<AddresseeData> mData;
846}; 846};
847 847
848QDataStream &operator<<( QDataStream &, const Addressee & ); 848QDataStream &operator<<( QDataStream &, const Addressee & );
849QDataStream &operator>>( QDataStream &, Addressee & ); 849QDataStream &operator>>( QDataStream &, Addressee & );
850 850
851} 851}
852 852
853#endif 853#endif
diff --git a/kabc/field.cpp b/kabc/field.cpp
index d95cd19..89d0b77 100644
--- a/kabc/field.cpp
+++ b/kabc/field.cpp
@@ -1,572 +1,578 @@
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) 2002 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2002 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 <klocale.h> 29#include <klocale.h>
30#include <kconfig.h> 30#include <kconfig.h>
31#include <kconfigbase.h> 31#include <kconfigbase.h>
32#include <kglobal.h> 32#include <kglobal.h>
33 33
34#include "field.h" 34#include "field.h"
35#include "resource.h" 35#include "resource.h"
36 36
37using namespace KABC; 37using namespace KABC;
38 38
39class Field::FieldImpl 39class Field::FieldImpl
40{ 40{
41 public: 41 public:
42 FieldImpl( int fieldId, int category = 0, 42 FieldImpl( int fieldId, int category = 0,
43 const QString &label = QString::null, 43 const QString &label = QString::null,
44 const QString &key = QString::null, 44 const QString &key = QString::null,
45 const QString &app = QString::null ) 45 const QString &app = QString::null )
46 : mFieldId( fieldId ), mCategory( category ), mLabel( label ), 46 : mFieldId( fieldId ), mCategory( category ), mLabel( label ),
47 mKey( key ), mApp( app ) {} 47 mKey( key ), mApp( app ) {}
48 48
49 enum FieldId 49 enum FieldId
50 { 50 {
51 CustomField, 51 CustomField,
52 FormattedName, 52 FormattedName,
53 FamilyName, 53 FamilyName,
54 GivenName, 54 GivenName,
55 AdditionalName, 55 AdditionalName,
56 Prefix, 56 Prefix,
57 Suffix, 57 Suffix,
58 NickName, 58 NickName,
59 Birthday, 59 Birthday,
60 Category,
60 HomeAddressStreet, 61 HomeAddressStreet,
61 HomeAddressLocality, 62 HomeAddressLocality,
62 HomeAddressRegion, 63 HomeAddressRegion,
63 HomeAddressPostalCode, 64 HomeAddressPostalCode,
64 HomeAddressCountry, 65 HomeAddressCountry,
65 HomeAddressLabel, 66 HomeAddressLabel,
66 BusinessAddressStreet, 67 BusinessAddressStreet,
67 BusinessAddressLocality, 68 BusinessAddressLocality,
68 BusinessAddressRegion, 69 BusinessAddressRegion,
69 BusinessAddressPostalCode, 70 BusinessAddressPostalCode,
70 BusinessAddressCountry, 71 BusinessAddressCountry,
71 BusinessAddressLabel, 72 BusinessAddressLabel,
72 HomePhone, 73 HomePhone,
73 BusinessPhone, 74 BusinessPhone,
74 MobilePhone, 75 MobilePhone,
75 HomeFax, 76 HomeFax,
76 BusinessFax, 77 BusinessFax,
77 CarPhone, 78 CarPhone,
78 Isdn, 79 Isdn,
79 Pager, 80 Pager,
80 Email, 81 Email,
81 Mailer, 82 Mailer,
82 Title, 83 Title,
83 Role, 84 Role,
84 Organization, 85 Organization,
85 Note, 86 Note,
86 Url, 87 Url,
87 Resource, 88 Resource,
88 Sip 89 Sip
89 }; 90 };
90 91
91 int fieldId() { return mFieldId; } 92 int fieldId() { return mFieldId; }
92 int category() { return mCategory; } 93 int category() { return mCategory; }
93 94
94 QString label() { return mLabel; } 95 QString label() { return mLabel; }
95 QString key() { return mKey; } 96 QString key() { return mKey; }
96 QString app() { return mApp; } 97 QString app() { return mApp; }
97 98
98 private: 99 private:
99 int mFieldId; 100 int mFieldId;
100 int mCategory; 101 int mCategory;
101 102
102 QString mLabel; 103 QString mLabel;
103 QString mKey; 104 QString mKey;
104 QString mApp; 105 QString mApp;
105}; 106};
106 107
107 108
108Field::List Field::mAllFields; 109Field::List Field::mAllFields;
109Field::List Field::mDefaultFields; 110Field::List Field::mDefaultFields;
110Field::List Field::mCustomFields; 111Field::List Field::mCustomFields;
111 112
112 113
113Field::Field( FieldImpl *impl ) 114Field::Field( FieldImpl *impl )
114{ 115{
115 mImpl = impl; 116 mImpl = impl;
116} 117}
117 118
118Field::~Field() 119Field::~Field()
119{ 120{
120 delete mImpl; 121 delete mImpl;
121} 122}
122 123
123QString Field::label() 124QString Field::label()
124{ 125{
125 switch ( mImpl->fieldId() ) { 126 switch ( mImpl->fieldId() ) {
126 case FieldImpl::FormattedName: 127 case FieldImpl::FormattedName:
127 return Addressee::formattedNameLabel(); 128 return Addressee::formattedNameLabel();
128 case FieldImpl::FamilyName: 129 case FieldImpl::FamilyName:
129 return Addressee::familyNameLabel(); 130 return Addressee::familyNameLabel();
130 case FieldImpl::GivenName: 131 case FieldImpl::GivenName:
131 return Addressee::givenNameLabel(); 132 return Addressee::givenNameLabel();
132 case FieldImpl::AdditionalName: 133 case FieldImpl::AdditionalName:
133 return Addressee::additionalNameLabel(); 134 return Addressee::additionalNameLabel();
134 case FieldImpl::Prefix: 135 case FieldImpl::Prefix:
135 return Addressee::prefixLabel(); 136 return Addressee::prefixLabel();
136 case FieldImpl::Suffix: 137 case FieldImpl::Suffix:
137 return Addressee::suffixLabel(); 138 return Addressee::suffixLabel();
138 case FieldImpl::NickName: 139 case FieldImpl::NickName:
139 return Addressee::nickNameLabel(); 140 return Addressee::nickNameLabel();
140 case FieldImpl::Birthday: 141 case FieldImpl::Birthday:
141 return Addressee::birthdayLabel(); 142 return Addressee::birthdayLabel();
142 case FieldImpl::HomeAddressStreet: 143 case FieldImpl::HomeAddressStreet:
143 return Addressee::homeAddressStreetLabel(); 144 return Addressee::homeAddressStreetLabel();
144 case FieldImpl::HomeAddressLocality: 145 case FieldImpl::HomeAddressLocality:
145 return Addressee::homeAddressLocalityLabel(); 146 return Addressee::homeAddressLocalityLabel();
146 case FieldImpl::HomeAddressRegion: 147 case FieldImpl::HomeAddressRegion:
147 return Addressee::homeAddressRegionLabel(); 148 return Addressee::homeAddressRegionLabel();
148 case FieldImpl::HomeAddressPostalCode: 149 case FieldImpl::HomeAddressPostalCode:
149 return Addressee::homeAddressPostalCodeLabel(); 150 return Addressee::homeAddressPostalCodeLabel();
150 case FieldImpl::HomeAddressCountry: 151 case FieldImpl::HomeAddressCountry:
151 return Addressee::homeAddressCountryLabel(); 152 return Addressee::homeAddressCountryLabel();
152 case FieldImpl::HomeAddressLabel: 153 case FieldImpl::HomeAddressLabel:
153 return Addressee::homeAddressLabelLabel(); 154 return Addressee::homeAddressLabelLabel();
154 case FieldImpl::BusinessAddressStreet: 155 case FieldImpl::BusinessAddressStreet:
155 return Addressee::businessAddressStreetLabel(); 156 return Addressee::businessAddressStreetLabel();
156 case FieldImpl::BusinessAddressLocality: 157 case FieldImpl::BusinessAddressLocality:
157 return Addressee::businessAddressLocalityLabel(); 158 return Addressee::businessAddressLocalityLabel();
158 case FieldImpl::BusinessAddressRegion: 159 case FieldImpl::BusinessAddressRegion:
159 return Addressee::businessAddressRegionLabel(); 160 return Addressee::businessAddressRegionLabel();
160 case FieldImpl::BusinessAddressPostalCode: 161 case FieldImpl::BusinessAddressPostalCode:
161 return Addressee::businessAddressPostalCodeLabel(); 162 return Addressee::businessAddressPostalCodeLabel();
162 case FieldImpl::BusinessAddressCountry: 163 case FieldImpl::BusinessAddressCountry:
163 return Addressee::businessAddressCountryLabel(); 164 return Addressee::businessAddressCountryLabel();
164 case FieldImpl::BusinessAddressLabel: 165 case FieldImpl::BusinessAddressLabel:
165 return Addressee::businessAddressLabelLabel(); 166 return Addressee::businessAddressLabelLabel();
166 case FieldImpl::HomePhone: 167 case FieldImpl::HomePhone:
167 return Addressee::homePhoneLabel(); 168 return Addressee::homePhoneLabel();
168 case FieldImpl::BusinessPhone: 169 case FieldImpl::BusinessPhone:
169 return Addressee::businessPhoneLabel(); 170 return Addressee::businessPhoneLabel();
170 case FieldImpl::MobilePhone: 171 case FieldImpl::MobilePhone:
171 return Addressee::mobilePhoneLabel(); 172 return Addressee::mobilePhoneLabel();
172 case FieldImpl::HomeFax: 173 case FieldImpl::HomeFax:
173 return Addressee::homeFaxLabel(); 174 return Addressee::homeFaxLabel();
174 case FieldImpl::BusinessFax: 175 case FieldImpl::BusinessFax:
175 return Addressee::businessFaxLabel(); 176 return Addressee::businessFaxLabel();
176 case FieldImpl::CarPhone: 177 case FieldImpl::CarPhone:
177 return Addressee::carPhoneLabel(); 178 return Addressee::carPhoneLabel();
178 case FieldImpl::Isdn: 179 case FieldImpl::Isdn:
179 return Addressee::isdnLabel(); 180 return Addressee::isdnLabel();
180 case FieldImpl::Pager: 181 case FieldImpl::Pager:
181 return Addressee::pagerLabel(); 182 return Addressee::pagerLabel();
182 case FieldImpl::Email: 183 case FieldImpl::Email:
183 return Addressee::emailLabel(); 184 return Addressee::emailLabel();
184 case FieldImpl::Mailer: 185 case FieldImpl::Mailer:
185 return Addressee::mailerLabel(); 186 return Addressee::mailerLabel();
186 case FieldImpl::Title: 187 case FieldImpl::Title:
187 return Addressee::titleLabel(); 188 return Addressee::titleLabel();
188 case FieldImpl::Role: 189 case FieldImpl::Role:
189 return Addressee::roleLabel(); 190 return Addressee::roleLabel();
190 case FieldImpl::Organization: 191 case FieldImpl::Organization:
191 return Addressee::organizationLabel(); 192 return Addressee::organizationLabel();
192 case FieldImpl::Note: 193 case FieldImpl::Note:
193 return Addressee::noteLabel(); 194 return Addressee::noteLabel();
194 case FieldImpl::Url: 195 case FieldImpl::Url:
195 return Addressee::urlLabel(); 196 return Addressee::urlLabel();
196 case FieldImpl::Resource: 197 case FieldImpl::Resource:
197 return Addressee::resourceLabel(); 198 return Addressee::resourceLabel();
199 case FieldImpl::Category:
200 return Addressee::categoryLabel();
198 case FieldImpl::Sip: 201 case FieldImpl::Sip:
199 return Addressee::sipLabel(); 202 return Addressee::sipLabel();
200 case FieldImpl::CustomField: 203 case FieldImpl::CustomField:
201 return mImpl->label(); 204 return mImpl->label();
202 default: 205 default:
203 return i18n("Unknown Field"); 206 return i18n("Unknown Field");
204 } 207 }
205} 208}
206 209
207int Field::category() 210int Field::category()
208{ 211{
209 return mImpl->category(); 212 return mImpl->category();
210} 213}
211 214
212QString Field::categoryLabel( int category ) 215QString Field::categoryLabel( int category )
213{ 216{
214 switch ( category ) { 217 switch ( category ) {
215 case All: 218 case All:
216 return i18n("All"); 219 return i18n("All");
217 case Frequent: 220 case Frequent:
218 return i18n("Frequent"); 221 return i18n("Frequent");
219 case Address: 222 case Address:
220 return i18n("Address"); 223 return i18n("Address");
221 case Email: 224 case Email:
222 return i18n("Email"); 225 return i18n("Email");
223 case Personal: 226 case Personal:
224 return i18n("Personal"); 227 return i18n("Personal");
225 case Organization: 228 case Organization:
226 return i18n("Organization"); 229 return i18n("Organization");
227 case CustomCategory: 230 case CustomCategory:
228 return i18n("Custom"); 231 return i18n("Custom");
229 default: 232 default:
230 return i18n("Undefined"); 233 return i18n("Undefined");
231 } 234 }
232} 235}
233 236
234QString Field::value( const KABC::Addressee &a ) 237QString Field::value( const KABC::Addressee &a )
235{ 238{
236 switch ( mImpl->fieldId() ) { 239 switch ( mImpl->fieldId() ) {
237 case FieldImpl::FormattedName: 240 case FieldImpl::FormattedName:
238 return a.formattedName(); 241 return a.formattedName();
239 case FieldImpl::FamilyName: 242 case FieldImpl::FamilyName:
240 return a.familyName(); 243 return a.familyName();
241 case FieldImpl::GivenName: 244 case FieldImpl::GivenName:
242 return a.givenName(); 245 return a.givenName();
243 case FieldImpl::AdditionalName: 246 case FieldImpl::AdditionalName:
244 return a.additionalName(); 247 return a.additionalName();
245 case FieldImpl::Prefix: 248 case FieldImpl::Prefix:
246 return a.prefix(); 249 return a.prefix();
247 case FieldImpl::Suffix: 250 case FieldImpl::Suffix:
248 return a.suffix(); 251 return a.suffix();
249 case FieldImpl::NickName: 252 case FieldImpl::NickName:
250 return a.nickName(); 253 return a.nickName();
251 case FieldImpl::Mailer: 254 case FieldImpl::Mailer:
252 return a.mailer(); 255 return a.mailer();
253 case FieldImpl::Title: 256 case FieldImpl::Title:
254 return a.title(); 257 return a.title();
255 case FieldImpl::Role: 258 case FieldImpl::Role:
256 return a.role(); 259 return a.role();
257 case FieldImpl::Organization: 260 case FieldImpl::Organization:
258 return a.organization(); 261 return a.organization();
259 case FieldImpl::Note: 262 case FieldImpl::Note:
260 return a.note(); 263 return a.note();
261 case FieldImpl::Email: 264 case FieldImpl::Email:
262 return a.preferredEmail(); 265 return a.preferredEmail();
263 case FieldImpl::Birthday: 266 case FieldImpl::Birthday:
264 if ( a.birthday().isValid() ) { 267 if ( a.birthday().isValid() ) {
265//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate ); 268//the generated code had the following format: return a.birthday().date().toString( Qt::ISODate );
266// But Qt::IsoDate was not specified. 269// But Qt::IsoDate was not specified.
267// QString _oldFormat = KGlobal::locale()->dateFormat(); 270// QString _oldFormat = KGlobal::locale()->dateFormat();
268// KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate 271// KGlobal::locale()->setDateFormat("%Y-%m-%d"); // = Qt::ISODate
269 QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate); 272 QString dt = KGlobal::locale()->formatDate(a.birthday().date(), false, KLocale::ISODate);
270// KGlobal::locale()->setDateFormat(_oldFormat); 273// KGlobal::locale()->setDateFormat(_oldFormat);
271 return dt; 274 return dt;
272 } 275 }
273 else 276 else
274 return QString::null; 277 return QString::null;
275 case FieldImpl::Url: 278 case FieldImpl::Url:
276 return a.url().prettyURL(); 279 return a.url().prettyURL();
277//US 280//US
278 case FieldImpl::Resource: 281 case FieldImpl::Resource:
279 return a.resource()->resourceName(); 282 return a.resource()->resourceName();
283 case FieldImpl::Category:
284 return a.categories().join(",");
280 case FieldImpl::HomePhone: 285 case FieldImpl::HomePhone:
281 return a.phoneNumber( PhoneNumber::Home ).number(); 286 return a.phoneNumber( PhoneNumber::Home ).number();
282 case FieldImpl::BusinessPhone: 287 case FieldImpl::BusinessPhone:
283 return a.phoneNumber( PhoneNumber::Work ).number(); 288 return a.phoneNumber( PhoneNumber::Work ).number();
284 case FieldImpl::MobilePhone: 289 case FieldImpl::MobilePhone:
285 return a.phoneNumber( PhoneNumber::Cell ).number(); 290 return a.phoneNumber( PhoneNumber::Cell ).number();
286 case FieldImpl::HomeFax: 291 case FieldImpl::HomeFax:
287 return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number(); 292 return a.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ).number();
288 case FieldImpl::BusinessFax: 293 case FieldImpl::BusinessFax:
289 return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number(); 294 return a.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ).number();
290 case FieldImpl::CarPhone: 295 case FieldImpl::CarPhone:
291 return a.phoneNumber( PhoneNumber::Car ).number(); 296 return a.phoneNumber( PhoneNumber::Car ).number();
292 case FieldImpl::Isdn: 297 case FieldImpl::Isdn:
293 return a.phoneNumber( PhoneNumber::Isdn ).number(); 298 return a.phoneNumber( PhoneNumber::Isdn ).number();
294 case FieldImpl::Pager: 299 case FieldImpl::Pager:
295 return a.phoneNumber( PhoneNumber::Pager ).number(); 300 return a.phoneNumber( PhoneNumber::Pager ).number();
296 case FieldImpl::Sip: 301 case FieldImpl::Sip:
297 return a.phoneNumber( PhoneNumber::Sip ).number(); 302 return a.phoneNumber( PhoneNumber::Sip ).number();
298 case FieldImpl::HomeAddressStreet: 303 case FieldImpl::HomeAddressStreet:
299 return a.address( Address::Home ).street(); 304 return a.address( Address::Home ).street();
300 case FieldImpl::HomeAddressLocality: 305 case FieldImpl::HomeAddressLocality:
301 return a.address( Address::Home ).locality(); 306 return a.address( Address::Home ).locality();
302 case FieldImpl::HomeAddressRegion: 307 case FieldImpl::HomeAddressRegion:
303 return a.address( Address::Home ).region(); 308 return a.address( Address::Home ).region();
304 case FieldImpl::HomeAddressPostalCode: 309 case FieldImpl::HomeAddressPostalCode:
305 return a.address( Address::Home ).postalCode(); 310 return a.address( Address::Home ).postalCode();
306 case FieldImpl::HomeAddressCountry: 311 case FieldImpl::HomeAddressCountry:
307 return a.address( Address::Home ).country(); 312 return a.address( Address::Home ).country();
308 case FieldImpl::BusinessAddressStreet: 313 case FieldImpl::BusinessAddressStreet:
309 return a.address( Address::Work ).street(); 314 return a.address( Address::Work ).street();
310 case FieldImpl::BusinessAddressLocality: 315 case FieldImpl::BusinessAddressLocality:
311 return a.address( Address::Work ).locality(); 316 return a.address( Address::Work ).locality();
312 case FieldImpl::BusinessAddressRegion: 317 case FieldImpl::BusinessAddressRegion:
313 return a.address( Address::Work ).region(); 318 return a.address( Address::Work ).region();
314 case FieldImpl::BusinessAddressPostalCode: 319 case FieldImpl::BusinessAddressPostalCode:
315 return a.address( Address::Work ).postalCode(); 320 return a.address( Address::Work ).postalCode();
316 case FieldImpl::BusinessAddressCountry: 321 case FieldImpl::BusinessAddressCountry:
317 return a.address( Address::Work ).country(); 322 return a.address( Address::Work ).country();
318 case FieldImpl::CustomField: 323 case FieldImpl::CustomField:
319 return a.custom( mImpl->app(), mImpl->key() ); 324 return a.custom( mImpl->app(), mImpl->key() );
320 default: 325 default:
321 return QString::null; 326 return QString::null;
322 } 327 }
323} 328}
324 329
325bool Field::setValue( KABC::Addressee &a, const QString &value ) 330bool Field::setValue( KABC::Addressee &a, const QString &value )
326{ 331{
327 switch ( mImpl->fieldId() ) { 332 switch ( mImpl->fieldId() ) {
328 case FieldImpl::FormattedName: 333 case FieldImpl::FormattedName:
329 a.setFormattedName( value ); 334 a.setFormattedName( value );
330 return true; 335 return true;
331 case FieldImpl::FamilyName: 336 case FieldImpl::FamilyName:
332 a.setFamilyName( value ); 337 a.setFamilyName( value );
333 return true; 338 return true;
334 case FieldImpl::GivenName: 339 case FieldImpl::GivenName:
335 a.setGivenName( value ); 340 a.setGivenName( value );
336 return true; 341 return true;
337 case FieldImpl::AdditionalName: 342 case FieldImpl::AdditionalName:
338 a.setAdditionalName( value ); 343 a.setAdditionalName( value );
339 return true; 344 return true;
340 case FieldImpl::Prefix: 345 case FieldImpl::Prefix:
341 a.setPrefix( value ); 346 a.setPrefix( value );
342 return true; 347 return true;
343 case FieldImpl::Suffix: 348 case FieldImpl::Suffix:
344 a.setSuffix( value ); 349 a.setSuffix( value );
345 return true; 350 return true;
346 case FieldImpl::NickName: 351 case FieldImpl::NickName:
347 a.setNickName( value ); 352 a.setNickName( value );
348 return true; 353 return true;
349 case FieldImpl::Mailer: 354 case FieldImpl::Mailer:
350 a.setMailer( value ); 355 a.setMailer( value );
351 return true; 356 return true;
352 case FieldImpl::Title: 357 case FieldImpl::Title:
353 a.setTitle( value ); 358 a.setTitle( value );
354 return true; 359 return true;
355 case FieldImpl::Role: 360 case FieldImpl::Role:
356 a.setRole( value ); 361 a.setRole( value );
357 return true; 362 return true;
358 case FieldImpl::Organization: 363 case FieldImpl::Organization:
359 a.setOrganization( value ); 364 a.setOrganization( value );
360 return true; 365 return true;
361 case FieldImpl::Note: 366 case FieldImpl::Note:
362 a.setNote( value ); 367 a.setNote( value );
363 return true; 368 return true;
364 case FieldImpl::Birthday: 369 case FieldImpl::Birthday:
365//US 370//US
366//the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); 371//the generated code had the following format: return a.setBirthday( QDate::fromString( value, Qt::ISODate ) );
367// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? 372// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ?
368 { 373 {
369 QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate 374 QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate
370 a.setBirthday(dt); 375 a.setBirthday(dt);
371 } 376 }
372 return true; 377 return true;
373 case FieldImpl::CustomField: 378 case FieldImpl::CustomField:
374 a.insertCustom( mImpl->app(), mImpl->key(), value ); 379 a.insertCustom( mImpl->app(), mImpl->key(), value );
375//US never copy the resourcename back to the adressee. 380//US never copy the resourcename back to the adressee.
376 case FieldImpl::Resource: 381 case FieldImpl::Resource:
377 default: 382 default:
378 return false; 383 return false;
379 } 384 }
380} 385}
381 386
382bool Field::isCustom() 387bool Field::isCustom()
383{ 388{
384 return mImpl->fieldId() == FieldImpl::CustomField; 389 return mImpl->fieldId() == FieldImpl::CustomField;
385} 390}
386 391
387Field::List Field::allFields() 392Field::List Field::allFields()
388{ 393{
389 if ( mAllFields.isEmpty() ) { 394 if ( mAllFields.isEmpty() ) {
390 createField( FieldImpl::FormattedName, Frequent ); 395 createField( FieldImpl::FormattedName, Frequent );
391 createField( FieldImpl::FamilyName, Frequent ); 396 createField( FieldImpl::FamilyName, Frequent );
392 createField( FieldImpl::GivenName, Frequent ); 397 createField( FieldImpl::GivenName, Frequent );
393 createField( FieldImpl::AdditionalName ); 398 createField( FieldImpl::AdditionalName );
394 createField( FieldImpl::Prefix ); 399 createField( FieldImpl::Prefix );
395 createField( FieldImpl::Suffix ); 400 createField( FieldImpl::Suffix );
396 createField( FieldImpl::NickName, Personal ); 401 createField( FieldImpl::NickName, Personal );
397 createField( FieldImpl::Birthday, Personal ); 402 createField( FieldImpl::Birthday, Personal );
403 createField( FieldImpl::Category );
398 createField( FieldImpl::HomeAddressStreet, Address|Personal ); 404 createField( FieldImpl::HomeAddressStreet, Address|Personal );
399 createField( FieldImpl::HomeAddressLocality, Address|Personal ); 405 createField( FieldImpl::HomeAddressLocality, Address|Personal );
400 createField( FieldImpl::HomeAddressRegion, Address|Personal ); 406 createField( FieldImpl::HomeAddressRegion, Address|Personal );
401 createField( FieldImpl::HomeAddressPostalCode, Address|Personal ); 407 createField( FieldImpl::HomeAddressPostalCode, Address|Personal );
402 createField( FieldImpl::HomeAddressCountry, Address|Personal ); 408 createField( FieldImpl::HomeAddressCountry, Address|Personal );
403 createField( FieldImpl::HomeAddressLabel, Address|Personal ); 409 createField( FieldImpl::HomeAddressLabel, Address|Personal );
404 createField( FieldImpl::BusinessAddressStreet, Address|Organization ); 410 createField( FieldImpl::BusinessAddressStreet, Address|Organization );
405 createField( FieldImpl::BusinessAddressLocality, Address|Organization ); 411 createField( FieldImpl::BusinessAddressLocality, Address|Organization );
406 createField( FieldImpl::BusinessAddressRegion, Address|Organization ); 412 createField( FieldImpl::BusinessAddressRegion, Address|Organization );
407 createField( FieldImpl::BusinessAddressPostalCode, Address|Organization ); 413 createField( FieldImpl::BusinessAddressPostalCode, Address|Organization );
408 createField( FieldImpl::BusinessAddressCountry, Address|Organization ); 414 createField( FieldImpl::BusinessAddressCountry, Address|Organization );
409 createField( FieldImpl::BusinessAddressLabel, Address|Organization ); 415 createField( FieldImpl::BusinessAddressLabel, Address|Organization );
410 createField( FieldImpl::HomePhone, Personal|Frequent ); 416 createField( FieldImpl::HomePhone, Personal|Frequent );
411 createField( FieldImpl::BusinessPhone, Organization|Frequent ); 417 createField( FieldImpl::BusinessPhone, Organization|Frequent );
412 createField( FieldImpl::MobilePhone, Frequent ); 418 createField( FieldImpl::MobilePhone, Frequent );
413 createField( FieldImpl::HomeFax ); 419 createField( FieldImpl::HomeFax );
414 createField( FieldImpl::BusinessFax ); 420 createField( FieldImpl::BusinessFax );
415 createField( FieldImpl::CarPhone ); 421 createField( FieldImpl::CarPhone );
416 createField( FieldImpl::Isdn ); 422 createField( FieldImpl::Isdn );
417 createField( FieldImpl::Pager ); 423 createField( FieldImpl::Pager );
418 createField( FieldImpl::Email, Email|Frequent ); 424 createField( FieldImpl::Email, Email|Frequent );
419 createField( FieldImpl::Mailer, Email ); 425 createField( FieldImpl::Mailer, Email );
420 createField( FieldImpl::Title, Organization ); 426 createField( FieldImpl::Title, Organization );
421 createField( FieldImpl::Role, Organization ); 427 createField( FieldImpl::Role, Organization );
422 createField( FieldImpl::Organization, Organization ); 428 createField( FieldImpl::Organization, Organization );
423 createField( FieldImpl::Note ); 429 createField( FieldImpl::Note );
424 createField( FieldImpl::Url ); 430 createField( FieldImpl::Url );
425 createField( FieldImpl::Resource ); 431 createField( FieldImpl::Resource );
426 createField( FieldImpl::Sip ); 432 createField( FieldImpl::Sip );
427 } 433 }
428 434
429 return mAllFields; 435 return mAllFields;
430} 436}
431 437
432Field::List Field::defaultFields() 438Field::List Field::defaultFields()
433{ 439{
434 if ( mDefaultFields.isEmpty() ) { 440 if ( mDefaultFields.isEmpty() ) {
435 createDefaultField( FieldImpl::GivenName ); 441 createDefaultField( FieldImpl::GivenName );
436 createDefaultField( FieldImpl::FamilyName ); 442 createDefaultField( FieldImpl::FamilyName );
437 createDefaultField( FieldImpl::Email ); 443 createDefaultField( FieldImpl::Email );
438 } 444 }
439 445
440 return mDefaultFields; 446 return mDefaultFields;
441} 447}
442 448
443void Field::createField( int id, int category ) 449void Field::createField( int id, int category )
444{ 450{
445 mAllFields.append( new Field( new FieldImpl( id, category ) ) ); 451 mAllFields.append( new Field( new FieldImpl( id, category ) ) );
446} 452}
447 453
448void Field::createDefaultField( int id, int category ) 454void Field::createDefaultField( int id, int category )
449{ 455{
450 mDefaultFields.append( new Field( new FieldImpl( id, category ) ) ); 456 mDefaultFields.append( new Field( new FieldImpl( id, category ) ) );
451} 457}
452 458
453void Field::deleteFields() 459void Field::deleteFields()
454{ 460{
455 Field::List::ConstIterator it; 461 Field::List::ConstIterator it;
456 462
457 for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) { 463 for( it = mAllFields.begin(); it != mAllFields.end(); ++it ) {
458 delete (*it); 464 delete (*it);
459 } 465 }
460 mAllFields.clear(); 466 mAllFields.clear();
461 467
462 for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) { 468 for( it = mDefaultFields.begin(); it != mDefaultFields.end(); ++it ) {
463 delete (*it); 469 delete (*it);
464 } 470 }
465 mDefaultFields.clear(); 471 mDefaultFields.clear();
466 472
467 for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) { 473 for( it = mCustomFields.begin(); it != mCustomFields.end(); ++it ) {
468 delete (*it); 474 delete (*it);
469 } 475 }
470 mCustomFields.clear(); 476 mCustomFields.clear();
471} 477}
472 478
473void Field::saveFields( const QString &identifier, 479void Field::saveFields( const QString &identifier,
474 const Field::List &fields ) 480 const Field::List &fields )
475{ 481{
476 KConfig *cfg = KGlobal::config(); 482 KConfig *cfg = KGlobal::config();
477 KConfigGroupSaver( cfg, "KABCFields" ); 483 KConfigGroupSaver( cfg, "KABCFields" );
478 saveFields( cfg, identifier, fields ); 484 saveFields( cfg, identifier, fields );
479} 485}
480 486
481void Field::saveFields( KConfig *cfg, const QString &identifier, 487void Field::saveFields( KConfig *cfg, const QString &identifier,
482 const Field::List &fields ) 488 const Field::List &fields )
483{ 489{
484 QValueList<int> fieldIds; 490 QValueList<int> fieldIds;
485 491
486//US 492//US
487// qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1()); 493// qDebug("Field::saveFields to %s %s", cfg->getFileName().latin1(), identifier.latin1());
488 494
489 int custom = 0; 495 int custom = 0;
490 Field::List::ConstIterator it; 496 Field::List::ConstIterator it;
491 for( it = fields.begin(); it != fields.end(); ++it ) { 497 for( it = fields.begin(); it != fields.end(); ++it ) {
492//US 498//US
493// qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId()); 499// qDebug("Field::saveFields field:%i", (*it)->mImpl->fieldId());
494 500
495 fieldIds.append( (*it)->mImpl->fieldId() ); 501 fieldIds.append( (*it)->mImpl->fieldId() );
496 if( (*it)->isCustom() ) { 502 if( (*it)->isCustom() ) {
497 QStringList customEntry; 503 QStringList customEntry;
498 customEntry << (*it)->mImpl->label(); 504 customEntry << (*it)->mImpl->label();
499 customEntry << (*it)->mImpl->key(); 505 customEntry << (*it)->mImpl->key();
500 customEntry << (*it)->mImpl->app(); 506 customEntry << (*it)->mImpl->app();
501 cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" + 507 cfg->writeEntry( "KABC_CustomEntry_" + identifier + "_" +
502 QString::number( custom++ ), customEntry ); 508 QString::number( custom++ ), customEntry );
503 } 509 }
504 } 510 }
505 cfg->writeEntry( identifier, fieldIds ); 511 cfg->writeEntry( identifier, fieldIds );
506} 512}
507 513
508Field::List Field::restoreFields( const QString &identifier ) 514Field::List Field::restoreFields( const QString &identifier )
509{ 515{
510//US 516//US
511// qDebug("Field::restoreFields, identifier: %s", identifier.latin1()); 517// qDebug("Field::restoreFields, identifier: %s", identifier.latin1());
512 518
513 KConfig *cfg = KGlobal::config(); 519 KConfig *cfg = KGlobal::config();
514 KConfigGroupSaver( cfg, "KABCFields" ); 520 KConfigGroupSaver( cfg, "KABCFields" );
515 cfg->setGroup( "KABCFields" ); 521 cfg->setGroup( "KABCFields" );
516 522
517 Field::List l = restoreFields( cfg, identifier ); 523 Field::List l = restoreFields( cfg, identifier );
518 524
519 return l; 525 return l;
520} 526}
521 527
522Field::List Field::restoreFields( KConfig *cfg, const QString &identifier ) 528Field::List Field::restoreFields( KConfig *cfg, const QString &identifier )
523{ 529{
524 QValueList<int> fieldIds = cfg->readIntListEntry( identifier); 530 QValueList<int> fieldIds = cfg->readIntListEntry( identifier);
525//US 531//US
526// qDebug("Field::restoreFields from %s, identifier: %s", cfg->getFileName().latin1(), identifier.latin1()); 532// qDebug("Field::restoreFields from %s, identifier: %s", cfg->getFileName().latin1(), identifier.latin1());
527 533
528 Field::List fields; 534 Field::List fields;
529 535
530 int custom = 0; 536 int custom = 0;
531 QValueList<int>::ConstIterator it; 537 QValueList<int>::ConstIterator it;
532 for( it = fieldIds.begin(); it != fieldIds.end(); ++it ) { 538 for( it = fieldIds.begin(); it != fieldIds.end(); ++it ) {
533 FieldImpl *f = 0; 539 FieldImpl *f = 0;
534 if ( (*it) == FieldImpl::CustomField ) { 540 if ( (*it) == FieldImpl::CustomField ) {
535 QStringList customEntry = cfg->readListEntry( "KABC_CustomEntry_" + 541 QStringList customEntry = cfg->readListEntry( "KABC_CustomEntry_" +
536 identifier + "_" + 542 identifier + "_" +
537 QString::number( custom++ ) ); 543 QString::number( custom++ ) );
538 f = new FieldImpl( *it, CustomCategory, customEntry[ 0 ], 544 f = new FieldImpl( *it, CustomCategory, customEntry[ 0 ],
539 customEntry[ 1 ], customEntry[ 2 ] ); 545 customEntry[ 1 ], customEntry[ 2 ] );
540 } else { 546 } else {
541 f = new FieldImpl( *it ); 547 f = new FieldImpl( *it );
542 } 548 }
543 fields.append( new Field( f ) ); 549 fields.append( new Field( f ) );
544 } 550 }
545 551
546 return fields; 552 return fields;
547} 553}
548 554
549bool Field::equals( Field *field ) 555bool Field::equals( Field *field )
550{ 556{
551 bool sameId = ( mImpl->fieldId() == field->mImpl->fieldId() ); 557 bool sameId = ( mImpl->fieldId() == field->mImpl->fieldId() );
552 558
553 if ( !sameId ) return false; 559 if ( !sameId ) return false;
554 560
555 if ( mImpl->fieldId() != FieldImpl::CustomField ) return true; 561 if ( mImpl->fieldId() != FieldImpl::CustomField ) return true;
556 562
557 return mImpl->key() == field->mImpl->key(); 563 return mImpl->key() == field->mImpl->key();
558} 564}
559 565
560Field *Field::createCustomField( const QString &label, int category, 566Field *Field::createCustomField( const QString &label, int category,
561 const QString &key, const QString &app ) 567 const QString &key, const QString &app )
562{ 568{
563 Field *field = new Field( new FieldImpl( FieldImpl::CustomField, 569 Field *field = new Field( new FieldImpl( FieldImpl::CustomField,
564 category | CustomCategory, 570 category | CustomCategory,
565 label, key, app ) ); 571 label, key, app ) );
566//US 572//US
567// qDebug("Field::createCustomField label %s", label.latin1() ); 573// qDebug("Field::createCustomField label %s", label.latin1() );
568 574
569 mCustomFields.append( field ); 575 mCustomFields.append( field );
570 576
571 return field; 577 return field;
572} 578}
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index e6bdde9..2c2f1a0 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,2975 +1,3025 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118 118
119 119
120#include <kresources/selectdialog.h> 120#include <kresources/selectdialog.h>
121#include <kmessagebox.h> 121#include <kmessagebox.h>
122 122
123#include <picture.h> 123#include <picture.h>
124#include <resource.h> 124#include <resource.h>
125 125
126//US#include <qsplitter.h> 126//US#include <qsplitter.h>
127#include <qmap.h> 127#include <qmap.h>
128#include <qdir.h> 128#include <qdir.h>
129#include <qfile.h> 129#include <qfile.h>
130#include <qvbox.h> 130#include <qvbox.h>
131#include <qlayout.h> 131#include <qlayout.h>
132#include <qclipboard.h> 132#include <qclipboard.h>
133#include <qtextstream.h> 133#include <qtextstream.h>
134 134
135#include <libkdepim/categoryselectdialog.h> 135#include <libkdepim/categoryselectdialog.h>
136#include <kabc/vcardconverter.h> 136#include <kabc/vcardconverter.h>
137 137
138 138
139#include "addresseeutil.h" 139#include "addresseeutil.h"
140#include "undocmds.h" 140#include "undocmds.h"
141#include "addresseeeditordialog.h" 141#include "addresseeeditordialog.h"
142#include "viewmanager.h" 142#include "viewmanager.h"
143#include "details/detailsviewcontainer.h" 143#include "details/detailsviewcontainer.h"
144#include "kabprefs.h" 144#include "kabprefs.h"
145#include "xxportmanager.h" 145#include "xxportmanager.h"
146#include "incsearchwidget.h" 146#include "incsearchwidget.h"
147#include "jumpbuttonbar.h" 147#include "jumpbuttonbar.h"
148#include "extensionmanager.h" 148#include "extensionmanager.h"
149#include "addresseeconfig.h" 149#include "addresseeconfig.h"
150#include <kcmultidialog.h> 150#include <kcmultidialog.h>
151 151
152#ifdef _WIN32_ 152#ifdef _WIN32_
153 153
154#include "kaimportoldialog.h" 154#include "kaimportoldialog.h"
155#else 155#else
156#include <unistd.h> 156#include <unistd.h>
157#endif 157#endif
158// sync includes 158// sync includes
159#include <libkdepim/ksyncprofile.h> 159#include <libkdepim/ksyncprofile.h>
160#include <libkdepim/ksyncprefsdialog.h> 160#include <libkdepim/ksyncprefsdialog.h>
161 161
162class KAex2phonePrefs : public QDialog 162class KAex2phonePrefs : public QDialog
163{ 163{
164 public: 164 public:
165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
166 QDialog( parent, name, true ) 166 QDialog( parent, name, true )
167 { 167 {
168 setCaption( i18n("Export to phone options") ); 168 setCaption( i18n("Export to phone options") );
169 QVBoxLayout* lay = new QVBoxLayout( this ); 169 QVBoxLayout* lay = new QVBoxLayout( this );
170 lay->setSpacing( 3 ); 170 lay->setSpacing( 3 );
171 lay->setMargin( 3 ); 171 lay->setMargin( 3 );
172 QLabel *lab; 172 QLabel *lab;
173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
174 lab->setAlignment (AlignHCenter ); 174 lab->setAlignment (AlignHCenter );
175 QHBox* temphb; 175 QHBox* temphb;
176 temphb = new QHBox( this ); 176 temphb = new QHBox( this );
177 new QLabel( i18n("I/O device: "), temphb ); 177 new QLabel( i18n("I/O device: "), temphb );
178 mPhoneDevice = new QLineEdit( temphb); 178 mPhoneDevice = new QLineEdit( temphb);
179 lay->addWidget( temphb ); 179 lay->addWidget( temphb );
180 temphb = new QHBox( this ); 180 temphb = new QHBox( this );
181 new QLabel( i18n("Connection: "), temphb ); 181 new QLabel( i18n("Connection: "), temphb );
182 mPhoneConnection = new QLineEdit( temphb); 182 mPhoneConnection = new QLineEdit( temphb);
183 lay->addWidget( temphb ); 183 lay->addWidget( temphb );
184 temphb = new QHBox( this ); 184 temphb = new QHBox( this );
185 new QLabel( i18n("Model(opt.): "), temphb ); 185 new QLabel( i18n("Model(opt.): "), temphb );
186 mPhoneModel = new QLineEdit( temphb); 186 mPhoneModel = new QLineEdit( temphb);
187 lay->addWidget( temphb ); 187 lay->addWidget( temphb );
188 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 188 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
189 // lay->addWidget( mWriteToSim ); 189 // lay->addWidget( mWriteToSim );
190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
191 lab->setAlignment (AlignHCenter ); 191 lab->setAlignment (AlignHCenter );
192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
193 lay->addWidget( ok ); 193 lay->addWidget( ok );
194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
195 lay->addWidget( cancel ); 195 lay->addWidget( cancel );
196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
198 resize( 220, 240 ); 198 resize( 220, 240 );
199 199
200 } 200 }
201 201
202public: 202public:
203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
204 QCheckBox* mWriteToSim; 204 QCheckBox* mWriteToSim;
205}; 205};
206 206
207 207
208bool pasteWithNewUid = true; 208bool pasteWithNewUid = true;
209 209
210#ifdef KAB_EMBEDDED 210#ifdef KAB_EMBEDDED
211KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 211KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
212 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 212 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
213 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 213 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
214 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 214 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
215#else //KAB_EMBEDDED 215#else //KAB_EMBEDDED
216KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 216KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
217 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 217 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
218 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 218 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
219 mReadWrite( readWrite ), mModified( false ) 219 mReadWrite( readWrite ), mModified( false )
220#endif //KAB_EMBEDDED 220#endif //KAB_EMBEDDED
221{ 221{
222 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 222 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
223 // syncManager->setBlockSave(false); 223 // syncManager->setBlockSave(false);
224 mExtensionBarSplitter = 0; 224 mExtensionBarSplitter = 0;
225 mIsPart = !parent->inherits( "KAddressBookMain" ); 225 mIsPart = !parent->inherits( "KAddressBookMain" );
226 mAddressBook = KABC::StdAddressBook::self(); 226 mAddressBook = KABC::StdAddressBook::self();
227 KABC::StdAddressBook::setAutomaticSave( false ); 227 KABC::StdAddressBook::setAutomaticSave( false );
228 228
229#ifndef KAB_EMBEDDED 229#ifndef KAB_EMBEDDED
230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 232
233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
234 SLOT( addressBookChanged() ) ); 234 SLOT( addressBookChanged() ) );
235 235
236#if 0 236#if 0
237 // LP moved to addressbook init method 237 // LP moved to addressbook init method
238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
239 "X-Department", "KADDRESSBOOK" ); 239 "X-Department", "KADDRESSBOOK" );
240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
241 "X-Profession", "KADDRESSBOOK" ); 241 "X-Profession", "KADDRESSBOOK" );
242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
243 "X-AssistantsName", "KADDRESSBOOK" ); 243 "X-AssistantsName", "KADDRESSBOOK" );
244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
245 "X-ManagersName", "KADDRESSBOOK" ); 245 "X-ManagersName", "KADDRESSBOOK" );
246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
247 "X-SpousesName", "KADDRESSBOOK" ); 247 "X-SpousesName", "KADDRESSBOOK" );
248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
249 "X-Office", "KADDRESSBOOK" ); 249 "X-Office", "KADDRESSBOOK" );
250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
251 "X-IMAddress", "KADDRESSBOOK" ); 251 "X-IMAddress", "KADDRESSBOOK" );
252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
253 "X-Anniversary", "KADDRESSBOOK" ); 253 "X-Anniversary", "KADDRESSBOOK" );
254 254
255 //US added this field to become compatible with Opie/qtopia addressbook 255 //US added this field to become compatible with Opie/qtopia addressbook
256 // values can be "female" or "male" or "". An empty field represents undefined. 256 // values can be "female" or "male" or "". An empty field represents undefined.
257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
258 "X-Gender", "KADDRESSBOOK" ); 258 "X-Gender", "KADDRESSBOOK" );
259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
260 "X-Children", "KADDRESSBOOK" ); 260 "X-Children", "KADDRESSBOOK" );
261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
262 "X-FreeBusyUrl", "KADDRESSBOOK" ); 262 "X-FreeBusyUrl", "KADDRESSBOOK" );
263#endif 263#endif
264 initGUI(); 264 initGUI();
265 265
266 mIncSearchWidget->setFocus(); 266 mIncSearchWidget->setFocus();
267 267
268 268
269 connect( mViewManager, SIGNAL( selected( const QString& ) ), 269 connect( mViewManager, SIGNAL( selected( const QString& ) ),
270 SLOT( setContactSelected( const QString& ) ) ); 270 SLOT( setContactSelected( const QString& ) ) );
271 connect( mViewManager, SIGNAL( executed( const QString& ) ), 271 connect( mViewManager, SIGNAL( executed( const QString& ) ),
272 SLOT( executeContact( const QString& ) ) ); 272 SLOT( executeContact( const QString& ) ) );
273 273
274 connect( mViewManager, SIGNAL( deleteRequest( ) ), 274 connect( mViewManager, SIGNAL( deleteRequest( ) ),
275 SLOT( deleteContacts( ) ) ); 275 SLOT( deleteContacts( ) ) );
276 connect( mViewManager, SIGNAL( modified() ), 276 connect( mViewManager, SIGNAL( modified() ),
277 SLOT( setModified() ) ); 277 SLOT( setModified() ) );
278 278
279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
281 281
282 connect( mXXPortManager, SIGNAL( modified() ), 282 connect( mXXPortManager, SIGNAL( modified() ),
283 SLOT( setModified() ) ); 283 SLOT( setModified() ) );
284 284
285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
286 SLOT( incrementalSearch( const QString& ) ) ); 286 SLOT( incrementalSearch( const QString& ) ) );
287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
288 mJumpButtonBar, SLOT( recreateButtons() ) ); 288 mJumpButtonBar, SLOT( recreateButtons() ) );
289 289
290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
291 SLOT( sendMail( const QString& ) ) ); 291 SLOT( sendMail( const QString& ) ) );
292 292
293 293
294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
297 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 297 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
298 298
299 299
300#ifndef KAB_EMBEDDED 300#ifndef KAB_EMBEDDED
301 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 301 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
302 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 302 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
303 303
304 connect( mDetails, SIGNAL( browse( const QString& ) ), 304 connect( mDetails, SIGNAL( browse( const QString& ) ),
305 SLOT( browse( const QString& ) ) ); 305 SLOT( browse( const QString& ) ) );
306 306
307 307
308 mAddressBookService = new KAddressBookService( this ); 308 mAddressBookService = new KAddressBookService( this );
309 309
310#endif //KAB_EMBEDDED 310#endif //KAB_EMBEDDED
311 311
312 mMessageTimer = new QTimer( this ); 312 mMessageTimer = new QTimer( this );
313 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 313 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
314 mEditorDialog = 0; 314 mEditorDialog = 0;
315 createAddresseeEditorDialog( this ); 315 createAddresseeEditorDialog( this );
316 setModified( false ); 316 setModified( false );
317 mBRdisabled = false; 317 mBRdisabled = false;
318#ifndef DESKTOP_VERSION 318#ifndef DESKTOP_VERSION
319 infrared = 0; 319 infrared = 0;
320#endif 320#endif
321 //toggleBeamReceive( ); 321 //toggleBeamReceive( );
322} 322}
323 323
324KABCore::~KABCore() 324KABCore::~KABCore()
325{ 325{
326 // save(); 326 // save();
327 //saveSettings(); 327 //saveSettings();
328 //KABPrefs::instance()->writeConfig(); 328 //KABPrefs::instance()->writeConfig();
329 delete AddresseeConfig::instance(); 329 delete AddresseeConfig::instance();
330 mAddressBook = 0; 330 mAddressBook = 0;
331 KABC::StdAddressBook::close(); 331 KABC::StdAddressBook::close();
332 332
333 delete syncManager; 333 delete syncManager;
334#ifndef DESKTOP_VERSION 334#ifndef DESKTOP_VERSION
335 if ( infrared ) 335 if ( infrared )
336 delete infrared; 336 delete infrared;
337#endif 337#endif
338} 338}
339void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 339void KABCore::receive( const QCString& cmsg, const QByteArray& data )
340{ 340{
341 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 341 qDebug("KA: QCOP message received: %s ", cmsg.data() );
342 if ( cmsg == "setDocument(QString)" ) { 342 if ( cmsg == "setDocument(QString)" ) {
343 QDataStream stream( data, IO_ReadOnly ); 343 QDataStream stream( data, IO_ReadOnly );
344 QString fileName; 344 QString fileName;
345 stream >> fileName; 345 stream >> fileName;
346 recieve( fileName ); 346 recieve( fileName );
347 return; 347 return;
348 } 348 }
349} 349}
350void KABCore::toggleBeamReceive( ) 350void KABCore::toggleBeamReceive( )
351{ 351{
352 if ( mBRdisabled ) 352 if ( mBRdisabled )
353 return; 353 return;
354#ifndef DESKTOP_VERSION 354#ifndef DESKTOP_VERSION
355 if ( infrared ) { 355 if ( infrared ) {
356 qDebug("AB disable BeamReceive "); 356 qDebug("AB disable BeamReceive ");
357 delete infrared; 357 delete infrared;
358 infrared = 0; 358 infrared = 0;
359 mActionBR->setChecked(false); 359 mActionBR->setChecked(false);
360 return; 360 return;
361 } 361 }
362 qDebug("AB enable BeamReceive "); 362 qDebug("AB enable BeamReceive ");
363 mActionBR->setChecked(true); 363 mActionBR->setChecked(true);
364 364
365 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 365 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
366 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 366 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
367#endif 367#endif
368} 368}
369 369
370 370
371void KABCore::disableBR(bool b) 371void KABCore::disableBR(bool b)
372{ 372{
373#ifndef DESKTOP_VERSION 373#ifndef DESKTOP_VERSION
374 if ( b ) { 374 if ( b ) {
375 if ( infrared ) { 375 if ( infrared ) {
376 toggleBeamReceive( ); 376 toggleBeamReceive( );
377 } 377 }
378 mBRdisabled = true; 378 mBRdisabled = true;
379 } else { 379 } else {
380 if ( mBRdisabled ) { 380 if ( mBRdisabled ) {
381 mBRdisabled = false; 381 mBRdisabled = false;
382 //toggleBeamReceive( ); 382 //toggleBeamReceive( );
383 } 383 }
384 } 384 }
385#endif 385#endif
386 386
387} 387}
388void KABCore::recieve( QString fn ) 388void KABCore::recieve( QString fn )
389{ 389{
390 //qDebug("KABCore::recieve "); 390 //qDebug("KABCore::recieve ");
391 int count = mAddressBook->importFromFile( fn, true ); 391 int count = mAddressBook->importFromFile( fn, true );
392 if ( count ) 392 if ( count )
393 setModified( true ); 393 setModified( true );
394 mViewManager->refreshView(); 394 mViewManager->refreshView();
395 message(i18n("%1 contact(s) received!").arg( count )); 395 message(i18n("%1 contact(s) received!").arg( count ));
396 topLevelWidget()->showMaximized(); 396 topLevelWidget()->showMaximized();
397 topLevelWidget()->raise(); 397 topLevelWidget()->raise();
398} 398}
399void KABCore::restoreSettings() 399void KABCore::restoreSettings()
400{ 400{
401 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 401 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
402 402
403 bool state; 403 bool state;
404 404
405 if (mMultipleViewsAtOnce) 405 if (mMultipleViewsAtOnce)
406 state = KABPrefs::instance()->mDetailsPageVisible; 406 state = KABPrefs::instance()->mDetailsPageVisible;
407 else 407 else
408 state = false; 408 state = false;
409 409
410 mActionDetails->setChecked( state ); 410 mActionDetails->setChecked( state );
411 setDetailsVisible( state ); 411 setDetailsVisible( state );
412 412
413 state = KABPrefs::instance()->mJumpButtonBarVisible; 413 state = KABPrefs::instance()->mJumpButtonBarVisible;
414 414
415 mActionJumpBar->setChecked( state ); 415 mActionJumpBar->setChecked( state );
416 setJumpButtonBarVisible( state ); 416 setJumpButtonBarVisible( state );
417/*US 417/*US
418 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 418 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
419 if ( splitterSize.count() == 0 ) { 419 if ( splitterSize.count() == 0 ) {
420 splitterSize.append( width() / 2 ); 420 splitterSize.append( width() / 2 );
421 splitterSize.append( width() / 2 ); 421 splitterSize.append( width() / 2 );
422 } 422 }
423 mMiniSplitter->setSizes( splitterSize ); 423 mMiniSplitter->setSizes( splitterSize );
424 if ( mExtensionBarSplitter ) { 424 if ( mExtensionBarSplitter ) {
425 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 425 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
426 if ( splitterSize.count() == 0 ) { 426 if ( splitterSize.count() == 0 ) {
427 splitterSize.append( width() / 2 ); 427 splitterSize.append( width() / 2 );
428 splitterSize.append( width() / 2 ); 428 splitterSize.append( width() / 2 );
429 } 429 }
430 mExtensionBarSplitter->setSizes( splitterSize ); 430 mExtensionBarSplitter->setSizes( splitterSize );
431 431
432 } 432 }
433*/ 433*/
434 mViewManager->restoreSettings(); 434 mViewManager->restoreSettings();
435 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 435 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
436 mExtensionManager->restoreSettings(); 436 mExtensionManager->restoreSettings();
437#ifdef DESKTOP_VERSION 437#ifdef DESKTOP_VERSION
438 int wid = width(); 438 int wid = width();
439 if ( wid < 10 ) 439 if ( wid < 10 )
440 wid = 400; 440 wid = 400;
441#else 441#else
442 int wid = QApplication::desktop()->width(); 442 int wid = QApplication::desktop()->width();
443 if ( wid < 640 ) 443 if ( wid < 640 )
444 wid = QApplication::desktop()->height(); 444 wid = QApplication::desktop()->height();
445#endif 445#endif
446 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 446 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
447 if ( true /*splitterSize.count() == 0*/ ) { 447 if ( true /*splitterSize.count() == 0*/ ) {
448 splitterSize.append( wid / 2 ); 448 splitterSize.append( wid / 2 );
449 splitterSize.append( wid / 2 ); 449 splitterSize.append( wid / 2 );
450 } 450 }
451 mMiniSplitter->setSizes( splitterSize ); 451 mMiniSplitter->setSizes( splitterSize );
452 if ( mExtensionBarSplitter ) { 452 if ( mExtensionBarSplitter ) {
453 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 453 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
454 if ( true /*splitterSize.count() == 0*/ ) { 454 if ( true /*splitterSize.count() == 0*/ ) {
455 splitterSize.append( wid / 2 ); 455 splitterSize.append( wid / 2 );
456 splitterSize.append( wid / 2 ); 456 splitterSize.append( wid / 2 );
457 } 457 }
458 mExtensionBarSplitter->setSizes( splitterSize ); 458 mExtensionBarSplitter->setSizes( splitterSize );
459 459
460 } 460 }
461 461
462 462
463} 463}
464 464
465void KABCore::saveSettings() 465void KABCore::saveSettings()
466{ 466{
467 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 467 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
468 if ( mExtensionBarSplitter ) 468 if ( mExtensionBarSplitter )
469 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 469 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
470 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 470 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
471 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 471 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
472#ifndef KAB_EMBEDDED 472#ifndef KAB_EMBEDDED
473 473
474 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 474 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
475 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 475 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
476#endif //KAB_EMBEDDED 476#endif //KAB_EMBEDDED
477 mExtensionManager->saveSettings(); 477 mExtensionManager->saveSettings();
478 mViewManager->saveSettings(); 478 mViewManager->saveSettings();
479 479
480 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 480 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
481} 481}
482 482
483KABC::AddressBook *KABCore::addressBook() const 483KABC::AddressBook *KABCore::addressBook() const
484{ 484{
485 return mAddressBook; 485 return mAddressBook;
486} 486}
487 487
488KConfig *KABCore::config() 488KConfig *KABCore::config()
489{ 489{
490#ifndef KAB_EMBEDDED 490#ifndef KAB_EMBEDDED
491 return KABPrefs::instance()->config(); 491 return KABPrefs::instance()->config();
492#else //KAB_EMBEDDED 492#else //KAB_EMBEDDED
493 return KABPrefs::instance()->getConfig(); 493 return KABPrefs::instance()->getConfig();
494#endif //KAB_EMBEDDED 494#endif //KAB_EMBEDDED
495} 495}
496 496
497KActionCollection *KABCore::actionCollection() const 497KActionCollection *KABCore::actionCollection() const
498{ 498{
499 return mGUIClient->actionCollection(); 499 return mGUIClient->actionCollection();
500} 500}
501 501
502KABC::Field *KABCore::currentSearchField() const 502KABC::Field *KABCore::currentSearchField() const
503{ 503{
504 if (mIncSearchWidget) 504 if (mIncSearchWidget)
505 return mIncSearchWidget->currentField(); 505 return mIncSearchWidget->currentField();
506 else 506 else
507 return 0; 507 return 0;
508} 508}
509 509
510QStringList KABCore::selectedUIDs() const 510QStringList KABCore::selectedUIDs() const
511{ 511{
512 return mViewManager->selectedUids(); 512 return mViewManager->selectedUids();
513} 513}
514 514
515KABC::Resource *KABCore::requestResource( QWidget *parent ) 515KABC::Resource *KABCore::requestResource( QWidget *parent )
516{ 516{
517 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 517 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
518 518
519 QPtrList<KRES::Resource> kresResources; 519 QPtrList<KRES::Resource> kresResources;
520 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 520 QPtrListIterator<KABC::Resource> resIt( kabcResources );
521 KABC::Resource *resource; 521 KABC::Resource *resource;
522 while ( ( resource = resIt.current() ) != 0 ) { 522 while ( ( resource = resIt.current() ) != 0 ) {
523 ++resIt; 523 ++resIt;
524 if ( !resource->readOnly() ) { 524 if ( !resource->readOnly() ) {
525 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 525 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
526 if ( res ) 526 if ( res )
527 kresResources.append( res ); 527 kresResources.append( res );
528 } 528 }
529 } 529 }
530 530
531 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 531 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
532 return static_cast<KABC::Resource*>( res ); 532 return static_cast<KABC::Resource*>( res );
533} 533}
534 534
535#ifndef KAB_EMBEDDED 535#ifndef KAB_EMBEDDED
536KAboutData *KABCore::createAboutData() 536KAboutData *KABCore::createAboutData()
537#else //KAB_EMBEDDED 537#else //KAB_EMBEDDED
538void KABCore::createAboutData() 538void KABCore::createAboutData()
539#endif //KAB_EMBEDDED 539#endif //KAB_EMBEDDED
540{ 540{
541#ifndef KAB_EMBEDDED 541#ifndef KAB_EMBEDDED
542 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 542 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
543 "3.1", I18N_NOOP( "The KDE Address Book" ), 543 "3.1", I18N_NOOP( "The KDE Address Book" ),
544 KAboutData::License_GPL_V2, 544 KAboutData::License_GPL_V2,
545 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 545 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
546 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 546 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
547 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 547 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
548 about->addAuthor( "Cornelius Schumacher", 548 about->addAuthor( "Cornelius Schumacher",
549 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 549 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
550 "schumacher@kde.org" ); 550 "schumacher@kde.org" );
551 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 551 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
552 "mpilone@slac.com" ); 552 "mpilone@slac.com" );
553 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 553 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
554 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 554 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
555 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 555 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
556 "michel@klaralvdalens-datakonsult.se" ); 556 "michel@klaralvdalens-datakonsult.se" );
557 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 557 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
558 "hansen@kde.org" ); 558 "hansen@kde.org" );
559 559
560 return about; 560 return about;
561#endif //KAB_EMBEDDED 561#endif //KAB_EMBEDDED
562 562
563 QString version; 563 QString version;
564#include <../version> 564#include <../version>
565 QMessageBox::about( this, "About KAddressbook/Pi", 565 QMessageBox::about( this, "About KAddressbook/Pi",
566 "KAddressbook/Platform-independent\n" 566 "KAddressbook/Platform-independent\n"
567 "(KA/Pi) " +version + " - " + 567 "(KA/Pi) " +version + " - " +
568#ifdef DESKTOP_VERSION 568#ifdef DESKTOP_VERSION
569 "Desktop Edition\n" 569 "Desktop Edition\n"
570#else 570#else
571 "PDA-Edition\n" 571 "PDA-Edition\n"
572 "for: Zaurus 5500 / 7x0 / 8x0\n" 572 "for: Zaurus 5500 / 7x0 / 8x0\n"
573#endif 573#endif
574 574
575 "(c) 2004 Ulf Schenk\n" 575 "(c) 2004 Ulf Schenk\n"
576 "(c) 2004 Lutz Rogowski\n" 576 "(c) 2004 Lutz Rogowski\n"
577 "(c) 1997-2003, The KDE PIM Team\n" 577 "(c) 1997-2003, The KDE PIM Team\n"
578 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 578 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
579 "Don Sanders Original author\n" 579 "Don Sanders Original author\n"
580 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 580 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
581 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 581 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
582 "Greg Stern DCOP interface\n" 582 "Greg Stern DCOP interface\n"
583 "Mark Westcot Contact pinning\n" 583 "Mark Westcot Contact pinning\n"
584 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 584 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
585 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 585 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
586#ifdef _WIN32_ 586#ifdef _WIN32_
587 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 587 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
588#endif 588#endif
589 ); 589 );
590} 590}
591 591
592void KABCore::setContactSelected( const QString &uid ) 592void KABCore::setContactSelected( const QString &uid )
593{ 593{
594 KABC::Addressee addr = mAddressBook->findByUid( uid ); 594 KABC::Addressee addr = mAddressBook->findByUid( uid );
595 if ( !mDetails->isHidden() ) 595 if ( !mDetails->isHidden() )
596 mDetails->setAddressee( addr ); 596 mDetails->setAddressee( addr );
597 597
598 if ( !addr.isEmpty() ) { 598 if ( !addr.isEmpty() ) {
599 emit contactSelected( addr.formattedName() ); 599 emit contactSelected( addr.formattedName() );
600 KABC::Picture pic = addr.photo(); 600 KABC::Picture pic = addr.photo();
601 if ( pic.isIntern() ) { 601 if ( pic.isIntern() ) {
602//US emit contactSelected( pic.data() ); 602//US emit contactSelected( pic.data() );
603//US instead use: 603//US instead use:
604 QPixmap px; 604 QPixmap px;
605 if (pic.data().isNull() != true) 605 if (pic.data().isNull() != true)
606 { 606 {
607 px.convertFromImage(pic.data()); 607 px.convertFromImage(pic.data());
608 } 608 }
609 609
610 emit contactSelected( px ); 610 emit contactSelected( px );
611 } 611 }
612 } 612 }
613 613
614 614
615 mExtensionManager->setSelectionChanged(); 615 mExtensionManager->setSelectionChanged();
616 616
617 // update the actions 617 // update the actions
618 bool selected = !uid.isEmpty(); 618 bool selected = !uid.isEmpty();
619 619
620 if ( mReadWrite ) { 620 if ( mReadWrite ) {
621 mActionCut->setEnabled( selected ); 621 mActionCut->setEnabled( selected );
622 mActionPaste->setEnabled( selected ); 622 mActionPaste->setEnabled( selected );
623 } 623 }
624 624
625 mActionCopy->setEnabled( selected ); 625 mActionCopy->setEnabled( selected );
626 mActionDelete->setEnabled( selected ); 626 mActionDelete->setEnabled( selected );
627 mActionEditAddressee->setEnabled( selected ); 627 mActionEditAddressee->setEnabled( selected );
628 mActionMail->setEnabled( selected ); 628 mActionMail->setEnabled( selected );
629 mActionMailVCard->setEnabled( selected ); 629 mActionMailVCard->setEnabled( selected );
630 //if (mActionBeam) 630 //if (mActionBeam)
631 //mActionBeam->setEnabled( selected ); 631 //mActionBeam->setEnabled( selected );
632 632
633 if (mActionBeamVCard) 633 if (mActionBeamVCard)
634 mActionBeamVCard->setEnabled( selected ); 634 mActionBeamVCard->setEnabled( selected );
635 635
636 mActionExport2phone->setEnabled( selected ); 636 mActionExport2phone->setEnabled( selected );
637 mActionWhoAmI->setEnabled( selected ); 637 mActionWhoAmI->setEnabled( selected );
638 mActionCategories->setEnabled( selected ); 638 mActionCategories->setEnabled( selected );
639} 639}
640 640
641void KABCore::sendMail() 641void KABCore::sendMail()
642{ 642{
643 sendMail( mViewManager->selectedEmails().join( ", " ) ); 643 sendMail( mViewManager->selectedEmails().join( ", " ) );
644} 644}
645 645
646void KABCore::sendMail( const QString& emaillist ) 646void KABCore::sendMail( const QString& emaillist )
647{ 647{
648 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 648 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
649 if (emaillist.contains(",") > 0) 649 if (emaillist.contains(",") > 0)
650 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 650 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
651 else 651 else
652 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 652 ExternalAppHandler::instance()->mailToOneContact( emaillist );
653} 653}
654 654
655 655
656 656
657void KABCore::mailVCard() 657void KABCore::mailVCard()
658{ 658{
659 QStringList uids = mViewManager->selectedUids(); 659 QStringList uids = mViewManager->selectedUids();
660 if ( !uids.isEmpty() ) 660 if ( !uids.isEmpty() )
661 mailVCard( uids ); 661 mailVCard( uids );
662} 662}
663 663
664void KABCore::mailVCard( const QStringList& uids ) 664void KABCore::mailVCard( const QStringList& uids )
665{ 665{
666 QStringList urls; 666 QStringList urls;
667 667
668// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 668// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
669 669
670 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 670 QString dirName = "/tmp/" + KApplication::randomString( 8 );
671 671
672 672
673 673
674 QDir().mkdir( dirName, true ); 674 QDir().mkdir( dirName, true );
675 675
676 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 676 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
677 KABC::Addressee a = mAddressBook->findByUid( *it ); 677 KABC::Addressee a = mAddressBook->findByUid( *it );
678 678
679 if ( a.isEmpty() ) 679 if ( a.isEmpty() )
680 continue; 680 continue;
681 681
682 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 682 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
683 683
684 QString fileName = dirName + "/" + name; 684 QString fileName = dirName + "/" + name;
685 685
686 QFile outFile(fileName); 686 QFile outFile(fileName);
687 687
688 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 688 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
689 KABC::VCardConverter converter; 689 KABC::VCardConverter converter;
690 QString vcard; 690 QString vcard;
691 691
692 converter.addresseeToVCard( a, vcard ); 692 converter.addresseeToVCard( a, vcard );
693 693
694 QTextStream t( &outFile ); // use a text stream 694 QTextStream t( &outFile ); // use a text stream
695 t.setEncoding( QTextStream::UnicodeUTF8 ); 695 t.setEncoding( QTextStream::UnicodeUTF8 );
696 t << vcard; 696 t << vcard;
697 697
698 outFile.close(); 698 outFile.close();
699 699
700 urls.append( fileName ); 700 urls.append( fileName );
701 } 701 }
702 } 702 }
703 703
704 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 704 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
705 705
706 706
707/*US 707/*US
708 kapp->invokeMailer( QString::null, QString::null, QString::null, 708 kapp->invokeMailer( QString::null, QString::null, QString::null,
709 QString::null, // subject 709 QString::null, // subject
710 QString::null, // body 710 QString::null, // body
711 QString::null, 711 QString::null,
712 urls ); // attachments 712 urls ); // attachments
713*/ 713*/
714 714
715} 715}
716 716
717/** 717/**
718 Beams the "WhoAmI contact. 718 Beams the "WhoAmI contact.
719*/ 719*/
720void KABCore::beamMySelf() 720void KABCore::beamMySelf()
721{ 721{
722 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 722 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
723 if (!a.isEmpty()) 723 if (!a.isEmpty())
724 { 724 {
725 QStringList uids; 725 QStringList uids;
726 uids << a.uid(); 726 uids << a.uid();
727 727
728 beamVCard(uids); 728 beamVCard(uids);
729 } else { 729 } else {
730 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 730 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
731 731
732 732
733 } 733 }
734} 734}
735 735
736void KABCore::export2phone() 736void KABCore::export2phone()
737{ 737{
738 738
739 KAex2phonePrefs ex2phone; 739 KAex2phonePrefs ex2phone;
740 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 740 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
741 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 741 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
742 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 742 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
743 743
744 if ( !ex2phone.exec() ) { 744 if ( !ex2phone.exec() ) {
745 return; 745 return;
746 } 746 }
747 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 747 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
748 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 748 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
749 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 749 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
750 750
751 751
752 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 752 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
753 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 753 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
754 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 754 KPimGlobalPrefs::instance()->mEx2PhoneModel );
755 755
756 QStringList uids = mViewManager->selectedUids(); 756 QStringList uids = mViewManager->selectedUids();
757 if ( uids.isEmpty() ) 757 if ( uids.isEmpty() )
758 return; 758 return;
759 759
760 QString fileName = getPhoneFile(); 760 QString fileName = getPhoneFile();
761 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 761 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
762 return; 762 return;
763 763
764 message(i18n("Exporting to phone...")); 764 message(i18n("Exporting to phone..."));
765 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 765 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
766 766
767} 767}
768QString KABCore::getPhoneFile() 768QString KABCore::getPhoneFile()
769{ 769{
770#ifdef DESKTOP_VERSION 770#ifdef DESKTOP_VERSION
771 return locateLocal("tmp", "phonefile.vcf"); 771 return locateLocal("tmp", "phonefile.vcf");
772#else 772#else
773 return "/tmp/phonefile.vcf"; 773 return "/tmp/phonefile.vcf";
774#endif 774#endif
775 775
776} 776}
777void KABCore::writeToPhone( ) 777void KABCore::writeToPhone( )
778{ 778{
779 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 779 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
780 message(i18n("Export to phone finished!")); 780 message(i18n("Export to phone finished!"));
781 else 781 else
782 qDebug(i18n("Error exporting to phone")); 782 qDebug(i18n("Error exporting to phone"));
783} 783}
784void KABCore::beamVCard() 784void KABCore::beamVCard()
785{ 785{
786 QStringList uids = mViewManager->selectedUids(); 786 QStringList uids = mViewManager->selectedUids();
787 if ( !uids.isEmpty() ) 787 if ( !uids.isEmpty() )
788 beamVCard( uids ); 788 beamVCard( uids );
789} 789}
790 790
791 791
792void KABCore::beamVCard(const QStringList& uids) 792void KABCore::beamVCard(const QStringList& uids)
793{ 793{
794 794
795 // LR: we should use the /tmp dir on the Zaurus, 795 // LR: we should use the /tmp dir on the Zaurus,
796 // because: /tmp = RAM, (HOME)/kdepim = flash memory 796 // because: /tmp = RAM, (HOME)/kdepim = flash memory
797 797
798#ifdef DESKTOP_VERSION 798#ifdef DESKTOP_VERSION
799 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 799 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
800#else 800#else
801 QString fileName = "/tmp/kapibeamfile.vcf"; 801 QString fileName = "/tmp/kapibeamfile.vcf";
802#endif 802#endif
803 803
804 KABC::VCardConverter converter; 804 KABC::VCardConverter converter;
805 QString description; 805 QString description;
806 QString datastream; 806 QString datastream;
807 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 807 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
808 KABC::Addressee a = mAddressBook->findByUid( *it ); 808 KABC::Addressee a = mAddressBook->findByUid( *it );
809 809
810 if ( a.isEmpty() ) 810 if ( a.isEmpty() )
811 continue; 811 continue;
812 812
813 if (description.isEmpty()) 813 if (description.isEmpty())
814 description = a.formattedName(); 814 description = a.formattedName();
815 815
816 QString vcard; 816 QString vcard;
817 converter.addresseeToVCard( a, vcard ); 817 converter.addresseeToVCard( a, vcard );
818 int start = 0; 818 int start = 0;
819 int next; 819 int next;
820 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 820 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
821 int semi = vcard.find(";", next); 821 int semi = vcard.find(";", next);
822 int dopp = vcard.find(":", next); 822 int dopp = vcard.find(":", next);
823 int sep; 823 int sep;
824 if ( semi < dopp && semi >= 0 ) 824 if ( semi < dopp && semi >= 0 )
825 sep = semi ; 825 sep = semi ;
826 else 826 else
827 sep = dopp; 827 sep = dopp;
828 datastream +=vcard.mid( start, next - start); 828 datastream +=vcard.mid( start, next - start);
829 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 829 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
830 start = sep; 830 start = sep;
831 } 831 }
832 datastream += vcard.mid( start,vcard.length() ); 832 datastream += vcard.mid( start,vcard.length() );
833 } 833 }
834#ifndef DESKTOP_VERSION 834#ifndef DESKTOP_VERSION
835 QFile outFile(fileName); 835 QFile outFile(fileName);
836 if ( outFile.open(IO_WriteOnly) ) { 836 if ( outFile.open(IO_WriteOnly) ) {
837 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 837 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
838 QTextStream t( &outFile ); // use a text stream 838 QTextStream t( &outFile ); // use a text stream
839 //t.setEncoding( QTextStream::UnicodeUTF8 ); 839 //t.setEncoding( QTextStream::UnicodeUTF8 );
840 t.setEncoding( QTextStream::Latin1 ); 840 t.setEncoding( QTextStream::Latin1 );
841 t <<datastream.latin1(); 841 t <<datastream.latin1();
842 outFile.close(); 842 outFile.close();
843 Ir *ir = new Ir( this ); 843 Ir *ir = new Ir( this );
844 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 844 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
845 ir->send( fileName, description, "text/x-vCard" ); 845 ir->send( fileName, description, "text/x-vCard" );
846 } else { 846 } else {
847 qDebug("Error open temp beam file "); 847 qDebug("Error open temp beam file ");
848 return; 848 return;
849 } 849 }
850#endif 850#endif
851 851
852} 852}
853 853
854void KABCore::beamDone( Ir *ir ) 854void KABCore::beamDone( Ir *ir )
855{ 855{
856#ifndef DESKTOP_VERSION 856#ifndef DESKTOP_VERSION
857 delete ir; 857 delete ir;
858#endif 858#endif
859 topLevelWidget()->raise(); 859 topLevelWidget()->raise();
860 message( i18n("Beaming finished!") ); 860 message( i18n("Beaming finished!") );
861} 861}
862 862
863 863
864void KABCore::browse( const QString& url ) 864void KABCore::browse( const QString& url )
865{ 865{
866#ifndef KAB_EMBEDDED 866#ifndef KAB_EMBEDDED
867 kapp->invokeBrowser( url ); 867 kapp->invokeBrowser( url );
868#else //KAB_EMBEDDED 868#else //KAB_EMBEDDED
869 qDebug("KABCore::browse must be fixed"); 869 qDebug("KABCore::browse must be fixed");
870#endif //KAB_EMBEDDED 870#endif //KAB_EMBEDDED
871} 871}
872 872
873void KABCore::selectAllContacts() 873void KABCore::selectAllContacts()
874{ 874{
875 mViewManager->setSelected( QString::null, true ); 875 mViewManager->setSelected( QString::null, true );
876} 876}
877 877
878void KABCore::deleteContacts() 878void KABCore::deleteContacts()
879{ 879{
880 QStringList uidList = mViewManager->selectedUids(); 880 QStringList uidList = mViewManager->selectedUids();
881 deleteContacts( uidList ); 881 deleteContacts( uidList );
882} 882}
883 883
884void KABCore::deleteContacts( const QStringList &uids ) 884void KABCore::deleteContacts( const QStringList &uids )
885{ 885{
886 if ( uids.count() > 0 ) { 886 if ( uids.count() > 0 ) {
887 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 887 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
888 UndoStack::instance()->push( command ); 888 UndoStack::instance()->push( command );
889 RedoStack::instance()->clear(); 889 RedoStack::instance()->clear();
890 890
891 // now if we deleted anything, refresh 891 // now if we deleted anything, refresh
892 setContactSelected( QString::null ); 892 setContactSelected( QString::null );
893 setModified( true ); 893 setModified( true );
894 } 894 }
895} 895}
896 896
897void KABCore::copyContacts() 897void KABCore::copyContacts()
898{ 898{
899 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 899 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
900 900
901 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 901 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
902 902
903 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 903 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
904 904
905 QClipboard *cb = QApplication::clipboard(); 905 QClipboard *cb = QApplication::clipboard();
906 cb->setText( clipText ); 906 cb->setText( clipText );
907} 907}
908 908
909void KABCore::cutContacts() 909void KABCore::cutContacts()
910{ 910{
911 QStringList uidList = mViewManager->selectedUids(); 911 QStringList uidList = mViewManager->selectedUids();
912 912
913//US if ( uidList.size() > 0 ) { 913//US if ( uidList.size() > 0 ) {
914 if ( uidList.count() > 0 ) { 914 if ( uidList.count() > 0 ) {
915 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 915 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
916 UndoStack::instance()->push( command ); 916 UndoStack::instance()->push( command );
917 RedoStack::instance()->clear(); 917 RedoStack::instance()->clear();
918 918
919 setModified( true ); 919 setModified( true );
920 } 920 }
921} 921}
922 922
923void KABCore::pasteContacts() 923void KABCore::pasteContacts()
924{ 924{
925 QClipboard *cb = QApplication::clipboard(); 925 QClipboard *cb = QApplication::clipboard();
926 926
927 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 927 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
928 928
929 pasteContacts( list ); 929 pasteContacts( list );
930} 930}
931 931
932void KABCore::pasteContacts( KABC::Addressee::List &list ) 932void KABCore::pasteContacts( KABC::Addressee::List &list )
933{ 933{
934 KABC::Resource *resource = requestResource( this ); 934 KABC::Resource *resource = requestResource( this );
935 KABC::Addressee::List::Iterator it; 935 KABC::Addressee::List::Iterator it;
936 for ( it = list.begin(); it != list.end(); ++it ) 936 for ( it = list.begin(); it != list.end(); ++it )
937 (*it).setResource( resource ); 937 (*it).setResource( resource );
938 938
939 PwPasteCommand *command = new PwPasteCommand( this, list ); 939 PwPasteCommand *command = new PwPasteCommand( this, list );
940 UndoStack::instance()->push( command ); 940 UndoStack::instance()->push( command );
941 RedoStack::instance()->clear(); 941 RedoStack::instance()->clear();
942 942
943 setModified( true ); 943 setModified( true );
944} 944}
945 945
946void KABCore::setWhoAmI() 946void KABCore::setWhoAmI()
947{ 947{
948 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 948 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
949 949
950 if ( addrList.count() > 1 ) { 950 if ( addrList.count() > 1 ) {
951 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 951 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
952 return; 952 return;
953 } 953 }
954 954
955 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 955 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
956 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 956 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
957 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 957 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
958} 958}
959 959
960void KABCore::setCategories() 960void KABCore::setCategories()
961{ 961{
962 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 962 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
963 if ( !dlg.exec() ) 963 if ( !dlg.exec() )
964 return; 964 return;
965 965
966 bool merge = false; 966 bool merge = false;
967 QString msg = i18n( "Merge with existing categories?" ); 967 QString msg = i18n( "Merge with existing categories?" );
968 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 968 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
969 merge = true; 969 merge = true;
970 970
971 QStringList categories = dlg.selectedCategories(); 971 QStringList categories = dlg.selectedCategories();
972 972
973 QStringList uids = mViewManager->selectedUids(); 973 QStringList uids = mViewManager->selectedUids();
974 QStringList::Iterator it; 974 QStringList::Iterator it;
975 for ( it = uids.begin(); it != uids.end(); ++it ) { 975 for ( it = uids.begin(); it != uids.end(); ++it ) {
976 KABC::Addressee addr = mAddressBook->findByUid( *it ); 976 KABC::Addressee addr = mAddressBook->findByUid( *it );
977 if ( !addr.isEmpty() ) { 977 if ( !addr.isEmpty() ) {
978 if ( !merge ) 978 if ( !merge )
979 addr.setCategories( categories ); 979 addr.setCategories( categories );
980 else { 980 else {
981 QStringList addrCategories = addr.categories(); 981 QStringList addrCategories = addr.categories();
982 QStringList::Iterator catIt; 982 QStringList::Iterator catIt;
983 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 983 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
984 if ( !addrCategories.contains( *catIt ) ) 984 if ( !addrCategories.contains( *catIt ) )
985 addrCategories.append( *catIt ); 985 addrCategories.append( *catIt );
986 } 986 }
987 addr.setCategories( addrCategories ); 987 addr.setCategories( addrCategories );
988 } 988 }
989 989
990 mAddressBook->insertAddressee( addr ); 990 mAddressBook->insertAddressee( addr );
991 } 991 }
992 } 992 }
993 993
994 if ( uids.count() > 0 ) 994 if ( uids.count() > 0 )
995 setModified( true ); 995 setModified( true );
996} 996}
997 997
998void KABCore::setSearchFields( const KABC::Field::List &fields ) 998void KABCore::setSearchFields( const KABC::Field::List &fields )
999{ 999{
1000 mIncSearchWidget->setFields( fields ); 1000 mIncSearchWidget->setFields( fields );
1001} 1001}
1002 1002
1003void KABCore::incrementalSearch( const QString& text ) 1003void KABCore::incrementalSearch( const QString& text )
1004{ 1004{
1005 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1005 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1006} 1006}
1007 1007
1008void KABCore::setModified() 1008void KABCore::setModified()
1009{ 1009{
1010 setModified( true ); 1010 setModified( true );
1011} 1011}
1012 1012
1013void KABCore::setModifiedWOrefresh() 1013void KABCore::setModifiedWOrefresh()
1014{ 1014{
1015 // qDebug("KABCore::setModifiedWOrefresh() "); 1015 // qDebug("KABCore::setModifiedWOrefresh() ");
1016 mModified = true; 1016 mModified = true;
1017 mActionSave->setEnabled( mModified ); 1017 mActionSave->setEnabled( mModified );
1018#ifdef DESKTOP_VERSION 1018#ifdef DESKTOP_VERSION
1019 mDetails->refreshView(); 1019 mDetails->refreshView();
1020#endif 1020#endif
1021 1021
1022} 1022}
1023void KABCore::setModified( bool modified ) 1023void KABCore::setModified( bool modified )
1024{ 1024{
1025 mModified = modified; 1025 mModified = modified;
1026 mActionSave->setEnabled( mModified ); 1026 mActionSave->setEnabled( mModified );
1027 1027
1028 if ( modified ) 1028 if ( modified )
1029 mJumpButtonBar->recreateButtons(); 1029 mJumpButtonBar->recreateButtons();
1030 1030
1031 mViewManager->refreshView(); 1031 mViewManager->refreshView();
1032 mDetails->refreshView(); 1032 mDetails->refreshView();
1033 1033
1034} 1034}
1035 1035
1036bool KABCore::modified() const 1036bool KABCore::modified() const
1037{ 1037{
1038 return mModified; 1038 return mModified;
1039} 1039}
1040 1040
1041void KABCore::contactModified( const KABC::Addressee &addr ) 1041void KABCore::contactModified( const KABC::Addressee &addr )
1042{ 1042{
1043 1043
1044 Command *command = 0; 1044 Command *command = 0;
1045 QString uid; 1045 QString uid;
1046 1046
1047 // check if it exists already 1047 // check if it exists already
1048 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1048 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1049 if ( origAddr.isEmpty() ) 1049 if ( origAddr.isEmpty() )
1050 command = new PwNewCommand( mAddressBook, addr ); 1050 command = new PwNewCommand( mAddressBook, addr );
1051 else { 1051 else {
1052 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1052 command = new PwEditCommand( mAddressBook, origAddr, addr );
1053 uid = addr.uid(); 1053 uid = addr.uid();
1054 } 1054 }
1055 1055
1056 UndoStack::instance()->push( command ); 1056 UndoStack::instance()->push( command );
1057 RedoStack::instance()->clear(); 1057 RedoStack::instance()->clear();
1058 1058
1059 setModified( true ); 1059 setModified( true );
1060} 1060}
1061 1061
1062void KABCore::newContact() 1062void KABCore::newContact()
1063{ 1063{
1064 1064
1065 1065
1066 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1066 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1067 1067
1068 QPtrList<KRES::Resource> kresResources; 1068 QPtrList<KRES::Resource> kresResources;
1069 QPtrListIterator<KABC::Resource> it( kabcResources ); 1069 QPtrListIterator<KABC::Resource> it( kabcResources );
1070 KABC::Resource *resource; 1070 KABC::Resource *resource;
1071 while ( ( resource = it.current() ) != 0 ) { 1071 while ( ( resource = it.current() ) != 0 ) {
1072 ++it; 1072 ++it;
1073 if ( !resource->readOnly() ) { 1073 if ( !resource->readOnly() ) {
1074 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1074 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1075 if ( res ) 1075 if ( res )
1076 kresResources.append( res ); 1076 kresResources.append( res );
1077 } 1077 }
1078 } 1078 }
1079 1079
1080 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1080 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1081 resource = static_cast<KABC::Resource*>( res ); 1081 resource = static_cast<KABC::Resource*>( res );
1082 1082
1083 if ( resource ) { 1083 if ( resource ) {
1084 KABC::Addressee addr; 1084 KABC::Addressee addr;
1085 addr.setResource( resource ); 1085 addr.setResource( resource );
1086 mEditorDialog->setAddressee( addr ); 1086 mEditorDialog->setAddressee( addr );
1087 KApplication::execDialog ( mEditorDialog ); 1087 KApplication::execDialog ( mEditorDialog );
1088 1088
1089 } else 1089 } else
1090 return; 1090 return;
1091 1091
1092 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1092 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1093 1093
1094 1094
1095} 1095}
1096 1096
1097void KABCore::addEmail( QString aStr ) 1097void KABCore::addEmail( QString aStr )
1098{ 1098{
1099#ifndef KAB_EMBEDDED 1099#ifndef KAB_EMBEDDED
1100 QString fullName, email; 1100 QString fullName, email;
1101 1101
1102 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1102 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1103 1103
1104 // Try to lookup the addressee matching the email address 1104 // Try to lookup the addressee matching the email address
1105 bool found = false; 1105 bool found = false;
1106 QStringList emailList; 1106 QStringList emailList;
1107 KABC::AddressBook::Iterator it; 1107 KABC::AddressBook::Iterator it;
1108 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1108 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1109 emailList = (*it).emails(); 1109 emailList = (*it).emails();
1110 if ( emailList.contains( email ) > 0 ) { 1110 if ( emailList.contains( email ) > 0 ) {
1111 found = true; 1111 found = true;
1112 (*it).setNameFromString( fullName ); 1112 (*it).setNameFromString( fullName );
1113 editContact( (*it).uid() ); 1113 editContact( (*it).uid() );
1114 } 1114 }
1115 } 1115 }
1116 1116
1117 if ( !found ) { 1117 if ( !found ) {
1118 KABC::Addressee addr; 1118 KABC::Addressee addr;
1119 addr.setNameFromString( fullName ); 1119 addr.setNameFromString( fullName );
1120 addr.insertEmail( email, true ); 1120 addr.insertEmail( email, true );
1121 1121
1122 mAddressBook->insertAddressee( addr ); 1122 mAddressBook->insertAddressee( addr );
1123 mViewManager->refreshView( addr.uid() ); 1123 mViewManager->refreshView( addr.uid() );
1124 editContact( addr.uid() ); 1124 editContact( addr.uid() );
1125 } 1125 }
1126#else //KAB_EMBEDDED 1126#else //KAB_EMBEDDED
1127 qDebug("KABCore::addEmail finsih method"); 1127 qDebug("KABCore::addEmail finsih method");
1128#endif //KAB_EMBEDDED 1128#endif //KAB_EMBEDDED
1129} 1129}
1130 1130
1131void KABCore::importVCard( const KURL &url, bool showPreview ) 1131void KABCore::importVCard( const KURL &url, bool showPreview )
1132{ 1132{
1133 mXXPortManager->importVCard( url, showPreview ); 1133 mXXPortManager->importVCard( url, showPreview );
1134} 1134}
1135void KABCore::importFromOL() 1135void KABCore::importFromOL()
1136{ 1136{
1137#ifdef _WIN32_ 1137#ifdef _WIN32_
1138 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1138 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1139 idgl->exec(); 1139 idgl->exec();
1140 KABC::Addressee::List list = idgl->getAddressList(); 1140 KABC::Addressee::List list = idgl->getAddressList();
1141 if ( list.count() > 0 ) { 1141 if ( list.count() > 0 ) {
1142 KABC::Addressee::List listNew; 1142 KABC::Addressee::List listNew;
1143 KABC::Addressee::List listExisting; 1143 KABC::Addressee::List listExisting;
1144 KABC::Addressee::List::Iterator it; 1144 KABC::Addressee::List::Iterator it;
1145 KABC::AddressBook::Iterator iter; 1145 KABC::AddressBook::Iterator iter;
1146 for ( it = list.begin(); it != list.end(); ++it ) { 1146 for ( it = list.begin(); it != list.end(); ++it ) {
1147 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1147 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1148 listNew.append( (*it) ); 1148 listNew.append( (*it) );
1149 else 1149 else
1150 listExisting.append( (*it) ); 1150 listExisting.append( (*it) );
1151 } 1151 }
1152 if ( listExisting.count() > 0 ) 1152 if ( listExisting.count() > 0 )
1153 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1153 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1154 if ( listNew.count() > 0 ) { 1154 if ( listNew.count() > 0 ) {
1155 pasteWithNewUid = false; 1155 pasteWithNewUid = false;
1156 pasteContacts( listNew ); 1156 pasteContacts( listNew );
1157 pasteWithNewUid = true; 1157 pasteWithNewUid = true;
1158 } 1158 }
1159 } 1159 }
1160 delete idgl; 1160 delete idgl;
1161#endif 1161#endif
1162} 1162}
1163 1163
1164void KABCore::importVCard( const QString &vCard, bool showPreview ) 1164void KABCore::importVCard( const QString &vCard, bool showPreview )
1165{ 1165{
1166 mXXPortManager->importVCard( vCard, showPreview ); 1166 mXXPortManager->importVCard( vCard, showPreview );
1167} 1167}
1168 1168
1169//US added a second method without defaultparameter 1169//US added a second method without defaultparameter
1170void KABCore::editContact2() { 1170void KABCore::editContact2() {
1171 editContact( QString::null ); 1171 editContact( QString::null );
1172} 1172}
1173 1173
1174void KABCore::editContact( const QString &uid ) 1174void KABCore::editContact( const QString &uid )
1175{ 1175{
1176 1176
1177 if ( mExtensionManager->isQuickEditVisible() ) 1177 if ( mExtensionManager->isQuickEditVisible() )
1178 return; 1178 return;
1179 1179
1180 // First, locate the contact entry 1180 // First, locate the contact entry
1181 QString localUID = uid; 1181 QString localUID = uid;
1182 if ( localUID.isNull() ) { 1182 if ( localUID.isNull() ) {
1183 QStringList uidList = mViewManager->selectedUids(); 1183 QStringList uidList = mViewManager->selectedUids();
1184 if ( uidList.count() > 0 ) 1184 if ( uidList.count() > 0 )
1185 localUID = *( uidList.at( 0 ) ); 1185 localUID = *( uidList.at( 0 ) );
1186 } 1186 }
1187 1187
1188 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1188 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1189 if ( !addr.isEmpty() ) { 1189 if ( !addr.isEmpty() ) {
1190 mEditorDialog->setAddressee( addr ); 1190 mEditorDialog->setAddressee( addr );
1191 KApplication::execDialog ( mEditorDialog ); 1191 KApplication::execDialog ( mEditorDialog );
1192 } 1192 }
1193} 1193}
1194 1194
1195/** 1195/**
1196 Shows or edits the detail view for the given uid. If the uid is QString::null, 1196 Shows or edits the detail view for the given uid. If the uid is QString::null,
1197 the method will try to find a selected addressee in the view. 1197 the method will try to find a selected addressee in the view.
1198 */ 1198 */
1199void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1199void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1200{ 1200{
1201 if ( mMultipleViewsAtOnce ) 1201 if ( mMultipleViewsAtOnce )
1202 { 1202 {
1203 editContact( uid ); 1203 editContact( uid );
1204 } 1204 }
1205 else 1205 else
1206 { 1206 {
1207 setDetailsVisible( true ); 1207 setDetailsVisible( true );
1208 mActionDetails->setChecked(true); 1208 mActionDetails->setChecked(true);
1209 } 1209 }
1210 1210
1211} 1211}
1212 1212
1213void KABCore::save() 1213void KABCore::save()
1214{ 1214{
1215 if (syncManager->blockSave()) 1215 if (syncManager->blockSave())
1216 return; 1216 return;
1217 if ( !mModified ) 1217 if ( !mModified )
1218 return; 1218 return;
1219 1219
1220 syncManager->setBlockSave(true); 1220 syncManager->setBlockSave(true);
1221 QString text = i18n( "There was an error while attempting to save\n the " 1221 QString text = i18n( "There was an error while attempting to save\n the "
1222 "address book. Please check that some \nother application is " 1222 "address book. Please check that some \nother application is "
1223 "not using it. " ); 1223 "not using it. " );
1224 message(i18n("Saving addressbook ... ")); 1224 message(i18n("Saving addressbook ... "));
1225#ifndef KAB_EMBEDDED 1225#ifndef KAB_EMBEDDED
1226 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1226 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1227 if ( !b || !b->save() ) { 1227 if ( !b || !b->save() ) {
1228 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1228 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1229 } 1229 }
1230#else //KAB_EMBEDDED 1230#else //KAB_EMBEDDED
1231 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1231 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1232 if ( !b || !b->save() ) { 1232 if ( !b || !b->save() ) {
1233 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1233 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1234 } 1234 }
1235#endif //KAB_EMBEDDED 1235#endif //KAB_EMBEDDED
1236 1236
1237 message(i18n("Addressbook saved!")); 1237 message(i18n("Addressbook saved!"));
1238 setModified( false ); 1238 setModified( false );
1239 syncManager->setBlockSave(false); 1239 syncManager->setBlockSave(false);
1240} 1240}
1241 1241
1242 1242
1243void KABCore::undo() 1243void KABCore::undo()
1244{ 1244{
1245 UndoStack::instance()->undo(); 1245 UndoStack::instance()->undo();
1246 1246
1247 // Refresh the view 1247 // Refresh the view
1248 mViewManager->refreshView(); 1248 mViewManager->refreshView();
1249} 1249}
1250 1250
1251void KABCore::redo() 1251void KABCore::redo()
1252{ 1252{
1253 RedoStack::instance()->redo(); 1253 RedoStack::instance()->redo();
1254 1254
1255 // Refresh the view 1255 // Refresh the view
1256 mViewManager->refreshView(); 1256 mViewManager->refreshView();
1257} 1257}
1258 1258
1259void KABCore::setJumpButtonBarVisible( bool visible ) 1259void KABCore::setJumpButtonBarVisible( bool visible )
1260{ 1260{
1261 if (mMultipleViewsAtOnce) 1261 if (mMultipleViewsAtOnce)
1262 { 1262 {
1263 if ( visible ) 1263 if ( visible )
1264 mJumpButtonBar->show(); 1264 mJumpButtonBar->show();
1265 else 1265 else
1266 mJumpButtonBar->hide(); 1266 mJumpButtonBar->hide();
1267 } 1267 }
1268 else 1268 else
1269 { 1269 {
1270 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1270 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1271 if (mViewManager->isVisible()) 1271 if (mViewManager->isVisible())
1272 { 1272 {
1273 if ( visible ) 1273 if ( visible )
1274 mJumpButtonBar->show(); 1274 mJumpButtonBar->show();
1275 else 1275 else
1276 mJumpButtonBar->hide(); 1276 mJumpButtonBar->hide();
1277 } 1277 }
1278 else 1278 else
1279 { 1279 {
1280 mJumpButtonBar->hide(); 1280 mJumpButtonBar->hide();
1281 } 1281 }
1282 } 1282 }
1283} 1283}
1284 1284
1285 1285
1286void KABCore::setDetailsToState() 1286void KABCore::setDetailsToState()
1287{ 1287{
1288 setDetailsVisible( mActionDetails->isChecked() ); 1288 setDetailsVisible( mActionDetails->isChecked() );
1289} 1289}
1290void KABCore::setDetailsToggle() 1290void KABCore::setDetailsToggle()
1291{ 1291{
1292 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1292 mActionDetails->setChecked( !mActionDetails->isChecked() );
1293 setDetailsToState(); 1293 setDetailsToState();
1294} 1294}
1295 1295
1296 1296
1297 1297
1298void KABCore::setDetailsVisible( bool visible ) 1298void KABCore::setDetailsVisible( bool visible )
1299{ 1299{
1300 if (visible && mDetails->isHidden()) 1300 if (visible && mDetails->isHidden())
1301 { 1301 {
1302 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1302 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1303 if ( addrList.count() > 0 ) 1303 if ( addrList.count() > 0 )
1304 mDetails->setAddressee( addrList[ 0 ] ); 1304 mDetails->setAddressee( addrList[ 0 ] );
1305 } 1305 }
1306 1306
1307 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1307 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1308 // the listview and the detailview. We do that by changing the splitbar size. 1308 // the listview and the detailview. We do that by changing the splitbar size.
1309 if (mMultipleViewsAtOnce) 1309 if (mMultipleViewsAtOnce)
1310 { 1310 {
1311 if ( visible ) 1311 if ( visible )
1312 mDetails->show(); 1312 mDetails->show();
1313 else 1313 else
1314 mDetails->hide(); 1314 mDetails->hide();
1315 } 1315 }
1316 else 1316 else
1317 { 1317 {
1318 if ( visible ) { 1318 if ( visible ) {
1319 mViewManager->hide(); 1319 mViewManager->hide();
1320 mDetails->show(); 1320 mDetails->show();
1321 mIncSearchWidget->setFocus(); 1321 mIncSearchWidget->setFocus();
1322 } 1322 }
1323 else { 1323 else {
1324 mViewManager->show(); 1324 mViewManager->show();
1325 mDetails->hide(); 1325 mDetails->hide();
1326 mViewManager->setFocusAV(); 1326 mViewManager->setFocusAV();
1327 } 1327 }
1328 setJumpButtonBarVisible( !visible ); 1328 setJumpButtonBarVisible( !visible );
1329 } 1329 }
1330 1330
1331} 1331}
1332 1332
1333void KABCore::extensionChanged( int id ) 1333void KABCore::extensionChanged( int id )
1334{ 1334{
1335 //change the details view only for non desktop systems 1335 //change the details view only for non desktop systems
1336#ifndef DESKTOP_VERSION 1336#ifndef DESKTOP_VERSION
1337 1337
1338 if (id == 0) 1338 if (id == 0)
1339 { 1339 {
1340 //the user disabled the extension. 1340 //the user disabled the extension.
1341 1341
1342 if (mMultipleViewsAtOnce) 1342 if (mMultipleViewsAtOnce)
1343 { // enable detailsview again 1343 { // enable detailsview again
1344 setDetailsVisible( true ); 1344 setDetailsVisible( true );
1345 mActionDetails->setChecked( true ); 1345 mActionDetails->setChecked( true );
1346 } 1346 }
1347 else 1347 else
1348 { //go back to the listview 1348 { //go back to the listview
1349 setDetailsVisible( false ); 1349 setDetailsVisible( false );
1350 mActionDetails->setChecked( false ); 1350 mActionDetails->setChecked( false );
1351 mActionDetails->setEnabled(true); 1351 mActionDetails->setEnabled(true);
1352 } 1352 }
1353 1353
1354 } 1354 }
1355 else 1355 else
1356 { 1356 {
1357 //the user enabled the extension. 1357 //the user enabled the extension.
1358 setDetailsVisible( false ); 1358 setDetailsVisible( false );
1359 mActionDetails->setChecked( false ); 1359 mActionDetails->setChecked( false );
1360 1360
1361 if (!mMultipleViewsAtOnce) 1361 if (!mMultipleViewsAtOnce)
1362 { 1362 {
1363 mActionDetails->setEnabled(false); 1363 mActionDetails->setEnabled(false);
1364 } 1364 }
1365 1365
1366 mExtensionManager->setSelectionChanged(); 1366 mExtensionManager->setSelectionChanged();
1367 1367
1368 } 1368 }
1369 1369
1370#endif// DESKTOP_VERSION 1370#endif// DESKTOP_VERSION
1371 1371
1372} 1372}
1373 1373
1374 1374
1375void KABCore::extensionModified( const KABC::Addressee::List &list ) 1375void KABCore::extensionModified( const KABC::Addressee::List &list )
1376{ 1376{
1377 1377
1378 if ( list.count() != 0 ) { 1378 if ( list.count() != 0 ) {
1379 KABC::Addressee::List::ConstIterator it; 1379 KABC::Addressee::List::ConstIterator it;
1380 for ( it = list.begin(); it != list.end(); ++it ) 1380 for ( it = list.begin(); it != list.end(); ++it )
1381 mAddressBook->insertAddressee( *it ); 1381 mAddressBook->insertAddressee( *it );
1382 if ( list.count() > 1 ) 1382 if ( list.count() > 1 )
1383 setModified(); 1383 setModified();
1384 else 1384 else
1385 setModifiedWOrefresh(); 1385 setModifiedWOrefresh();
1386 } 1386 }
1387 if ( list.count() == 0 ) 1387 if ( list.count() == 0 )
1388 mViewManager->refreshView(); 1388 mViewManager->refreshView();
1389 else 1389 else
1390 mViewManager->refreshView( list[ 0 ].uid() ); 1390 mViewManager->refreshView( list[ 0 ].uid() );
1391 1391
1392 1392
1393 1393
1394} 1394}
1395 1395
1396QString KABCore::getNameByPhone( const QString &phone ) 1396QString KABCore::getNameByPhone( const QString &phone )
1397{ 1397{
1398#ifndef KAB_EMBEDDED 1398#ifndef KAB_EMBEDDED
1399 QRegExp r( "[/*/-/ ]" ); 1399 QRegExp r( "[/*/-/ ]" );
1400 QString localPhone( phone ); 1400 QString localPhone( phone );
1401 1401
1402 bool found = false; 1402 bool found = false;
1403 QString ownerName = ""; 1403 QString ownerName = "";
1404 KABC::AddressBook::Iterator iter; 1404 KABC::AddressBook::Iterator iter;
1405 KABC::PhoneNumber::List::Iterator phoneIter; 1405 KABC::PhoneNumber::List::Iterator phoneIter;
1406 KABC::PhoneNumber::List phoneList; 1406 KABC::PhoneNumber::List phoneList;
1407 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1407 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1408 phoneList = (*iter).phoneNumbers(); 1408 phoneList = (*iter).phoneNumbers();
1409 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1409 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1410 ++phoneIter) { 1410 ++phoneIter) {
1411 // Get rid of separator chars so just the numbers are compared. 1411 // Get rid of separator chars so just the numbers are compared.
1412 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1412 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1413 ownerName = (*iter).formattedName(); 1413 ownerName = (*iter).formattedName();
1414 found = true; 1414 found = true;
1415 } 1415 }
1416 } 1416 }
1417 } 1417 }
1418 1418
1419 return ownerName; 1419 return ownerName;
1420#else //KAB_EMBEDDED 1420#else //KAB_EMBEDDED
1421 qDebug("KABCore::getNameByPhone finsih method"); 1421 qDebug("KABCore::getNameByPhone finsih method");
1422 return ""; 1422 return "";
1423#endif //KAB_EMBEDDED 1423#endif //KAB_EMBEDDED
1424 1424
1425} 1425}
1426 1426
1427void KABCore::openConfigDialog() 1427void KABCore::openConfigDialog()
1428{ 1428{
1429 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1429 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1430 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1430 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1431 ConfigureDialog->addModule(kabcfg ); 1431 ConfigureDialog->addModule(kabcfg );
1432 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1432 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1433 ConfigureDialog->addModule(kdelibcfg ); 1433 ConfigureDialog->addModule(kdelibcfg );
1434 1434
1435 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1435 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1436 this, SLOT( configurationChanged() ) ); 1436 this, SLOT( configurationChanged() ) );
1437 connect( ConfigureDialog, SIGNAL( okClicked() ), 1437 connect( ConfigureDialog, SIGNAL( okClicked() ),
1438 this, SLOT( configurationChanged() ) ); 1438 this, SLOT( configurationChanged() ) );
1439 saveSettings(); 1439 saveSettings();
1440#ifndef DESKTOP_VERSION 1440#ifndef DESKTOP_VERSION
1441 ConfigureDialog->showMaximized(); 1441 ConfigureDialog->showMaximized();
1442#endif 1442#endif
1443 if ( ConfigureDialog->exec() ) 1443 if ( ConfigureDialog->exec() )
1444 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1444 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1445 delete ConfigureDialog; 1445 delete ConfigureDialog;
1446} 1446}
1447 1447
1448void KABCore::openLDAPDialog() 1448void KABCore::openLDAPDialog()
1449{ 1449{
1450#ifndef KAB_EMBEDDED 1450#ifndef KAB_EMBEDDED
1451 if ( !mLdapSearchDialog ) { 1451 if ( !mLdapSearchDialog ) {
1452 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1452 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1453 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1453 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1454 SLOT( refreshView() ) ); 1454 SLOT( refreshView() ) );
1455 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1455 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1456 SLOT( setModified() ) ); 1456 SLOT( setModified() ) );
1457 } else 1457 } else
1458 mLdapSearchDialog->restoreSettings(); 1458 mLdapSearchDialog->restoreSettings();
1459 1459
1460 if ( mLdapSearchDialog->isOK() ) 1460 if ( mLdapSearchDialog->isOK() )
1461 mLdapSearchDialog->exec(); 1461 mLdapSearchDialog->exec();
1462#else //KAB_EMBEDDED 1462#else //KAB_EMBEDDED
1463 qDebug("KABCore::openLDAPDialog() finsih method"); 1463 qDebug("KABCore::openLDAPDialog() finsih method");
1464#endif //KAB_EMBEDDED 1464#endif //KAB_EMBEDDED
1465} 1465}
1466 1466
1467void KABCore::print() 1467void KABCore::print()
1468{ 1468{
1469#ifndef KAB_EMBEDDED 1469#ifndef KAB_EMBEDDED
1470 KPrinter printer; 1470 KPrinter printer;
1471 if ( !printer.setup( this ) ) 1471 if ( !printer.setup( this ) )
1472 return; 1472 return;
1473 1473
1474 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1474 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1475 mViewManager->selectedUids(), this ); 1475 mViewManager->selectedUids(), this );
1476 1476
1477 wizard.exec(); 1477 wizard.exec();
1478#else //KAB_EMBEDDED 1478#else //KAB_EMBEDDED
1479 qDebug("KABCore::print() finsih method"); 1479 qDebug("KABCore::print() finsih method");
1480#endif //KAB_EMBEDDED 1480#endif //KAB_EMBEDDED
1481 1481
1482} 1482}
1483 1483
1484 1484
1485void KABCore::addGUIClient( KXMLGUIClient *client ) 1485void KABCore::addGUIClient( KXMLGUIClient *client )
1486{ 1486{
1487 if ( mGUIClient ) 1487 if ( mGUIClient )
1488 mGUIClient->insertChildClient( client ); 1488 mGUIClient->insertChildClient( client );
1489 else 1489 else
1490 KMessageBox::error( this, "no KXMLGUICLient"); 1490 KMessageBox::error( this, "no KXMLGUICLient");
1491} 1491}
1492 1492
1493 1493
1494void KABCore::configurationChanged() 1494void KABCore::configurationChanged()
1495{ 1495{
1496 mExtensionManager->reconfigure(); 1496 mExtensionManager->reconfigure();
1497} 1497}
1498 1498
1499void KABCore::addressBookChanged() 1499void KABCore::addressBookChanged()
1500{ 1500{
1501/*US 1501/*US
1502 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1502 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1503 while ( it.current() ) { 1503 while ( it.current() ) {
1504 if ( it.current()->dirty() ) { 1504 if ( it.current()->dirty() ) {
1505 QString text = i18n( "Data has been changed externally. Unsaved " 1505 QString text = i18n( "Data has been changed externally. Unsaved "
1506 "changes will be lost." ); 1506 "changes will be lost." );
1507 KMessageBox::information( this, text ); 1507 KMessageBox::information( this, text );
1508 } 1508 }
1509 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1509 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1510 ++it; 1510 ++it;
1511 } 1511 }
1512*/ 1512*/
1513 if (mEditorDialog) 1513 if (mEditorDialog)
1514 { 1514 {
1515 if (mEditorDialog->dirty()) 1515 if (mEditorDialog->dirty())
1516 { 1516 {
1517 QString text = i18n( "Data has been changed externally. Unsaved " 1517 QString text = i18n( "Data has been changed externally. Unsaved "
1518 "changes will be lost." ); 1518 "changes will be lost." );
1519 KMessageBox::information( this, text ); 1519 KMessageBox::information( this, text );
1520 } 1520 }
1521 QString currentuid = mEditorDialog->addressee().uid(); 1521 QString currentuid = mEditorDialog->addressee().uid();
1522 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1522 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1523 } 1523 }
1524 mViewManager->refreshView(); 1524 mViewManager->refreshView();
1525// mDetails->refreshView(); 1525// mDetails->refreshView();
1526 1526
1527 1527
1528} 1528}
1529 1529
1530AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1530AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1531 const char *name ) 1531 const char *name )
1532{ 1532{
1533 1533
1534 if ( mEditorDialog == 0 ) { 1534 if ( mEditorDialog == 0 ) {
1535 mEditorDialog = new AddresseeEditorDialog( this, parent, 1535 mEditorDialog = new AddresseeEditorDialog( this, parent,
1536 name ? name : "editorDialog" ); 1536 name ? name : "editorDialog" );
1537 1537
1538 1538
1539 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1539 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1540 SLOT( contactModified( const KABC::Addressee& ) ) ); 1540 SLOT( contactModified( const KABC::Addressee& ) ) );
1541 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1541 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1542 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1542 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1543 } 1543 }
1544 1544
1545 return mEditorDialog; 1545 return mEditorDialog;
1546} 1546}
1547 1547
1548void KABCore::slotEditorDestroyed( const QString &uid ) 1548void KABCore::slotEditorDestroyed( const QString &uid )
1549{ 1549{
1550 //mEditorDict.remove( uid ); 1550 //mEditorDict.remove( uid );
1551} 1551}
1552 1552
1553void KABCore::initGUI() 1553void KABCore::initGUI()
1554{ 1554{
1555#ifndef KAB_EMBEDDED 1555#ifndef KAB_EMBEDDED
1556 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1556 QHBoxLayout *topLayout = new QHBoxLayout( this );
1557 topLayout->setSpacing( KDialogBase::spacingHint() ); 1557 topLayout->setSpacing( KDialogBase::spacingHint() );
1558 1558
1559 mExtensionBarSplitter = new QSplitter( this ); 1559 mExtensionBarSplitter = new QSplitter( this );
1560 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1560 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1561 1561
1562 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1562 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1563 1563
1564 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1564 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1565 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1565 mIncSearchWidget = new IncSearchWidget( viewSpace );
1566 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1566 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1567 SLOT( incrementalSearch( const QString& ) ) ); 1567 SLOT( incrementalSearch( const QString& ) ) );
1568 1568
1569 mViewManager = new ViewManager( this, viewSpace ); 1569 mViewManager = new ViewManager( this, viewSpace );
1570 viewSpace->setStretchFactor( mViewManager, 1 ); 1570 viewSpace->setStretchFactor( mViewManager, 1 );
1571 1571
1572 mDetails = new ViewContainer( mDetailsSplitter ); 1572 mDetails = new ViewContainer( mDetailsSplitter );
1573 1573
1574 mJumpButtonBar = new JumpButtonBar( this, this ); 1574 mJumpButtonBar = new JumpButtonBar( this, this );
1575 1575
1576 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1576 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1577 1577
1578 topLayout->addWidget( mExtensionBarSplitter ); 1578 topLayout->addWidget( mExtensionBarSplitter );
1579 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1579 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1580 topLayout->addWidget( mJumpButtonBar ); 1580 topLayout->addWidget( mJumpButtonBar );
1581 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1581 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1582 1582
1583 mXXPortManager = new XXPortManager( this, this ); 1583 mXXPortManager = new XXPortManager( this, this );
1584 1584
1585#else //KAB_EMBEDDED 1585#else //KAB_EMBEDDED
1586 //US initialize viewMenu before settingup viewmanager. 1586 //US initialize viewMenu before settingup viewmanager.
1587 // Viewmanager needs this menu to plugin submenues. 1587 // Viewmanager needs this menu to plugin submenues.
1588 viewMenu = new QPopupMenu( this ); 1588 viewMenu = new QPopupMenu( this );
1589 settingsMenu = new QPopupMenu( this ); 1589 settingsMenu = new QPopupMenu( this );
1590 //filterMenu = new QPopupMenu( this ); 1590 //filterMenu = new QPopupMenu( this );
1591 ImportMenu = new QPopupMenu( this ); 1591 ImportMenu = new QPopupMenu( this );
1592 ExportMenu = new QPopupMenu( this ); 1592 ExportMenu = new QPopupMenu( this );
1593 syncMenu = new QPopupMenu( this ); 1593 syncMenu = new QPopupMenu( this );
1594 changeMenu= new QPopupMenu( this ); 1594 changeMenu= new QPopupMenu( this );
1595 1595
1596//US since we have no splitter for the embedded system, setup 1596//US since we have no splitter for the embedded system, setup
1597// a layout with two frames. One left and one right. 1597// a layout with two frames. One left and one right.
1598 1598
1599 QBoxLayout *topLayout; 1599 QBoxLayout *topLayout;
1600 1600
1601 // = new QHBoxLayout( this ); 1601 // = new QHBoxLayout( this );
1602// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1602// QBoxLayout *topLayout = (QBoxLayout*)layout();
1603 1603
1604// QWidget *mainBox = new QWidget( this ); 1604// QWidget *mainBox = new QWidget( this );
1605// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1605// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1606 1606
1607#ifdef DESKTOP_VERSION 1607#ifdef DESKTOP_VERSION
1608 topLayout = new QHBoxLayout( this ); 1608 topLayout = new QHBoxLayout( this );
1609 1609
1610 1610
1611 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1611 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1612 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1612 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1613 1613
1614 topLayout->addWidget(mMiniSplitter ); 1614 topLayout->addWidget(mMiniSplitter );
1615 1615
1616 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1616 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1617 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1617 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1618 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1618 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1619 mDetails = new ViewContainer( mMiniSplitter ); 1619 mDetails = new ViewContainer( mMiniSplitter );
1620 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1620 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1621#else 1621#else
1622 if ( QApplication::desktop()->width() > 480 ) { 1622 if ( QApplication::desktop()->width() > 480 ) {
1623 topLayout = new QHBoxLayout( this ); 1623 topLayout = new QHBoxLayout( this );
1624 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1624 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1625 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1625 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1626 } else { 1626 } else {
1627 1627
1628 topLayout = new QHBoxLayout( this ); 1628 topLayout = new QHBoxLayout( this );
1629 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1629 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1630 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1630 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1631 } 1631 }
1632 1632
1633 topLayout->addWidget(mMiniSplitter ); 1633 topLayout->addWidget(mMiniSplitter );
1634 mViewManager = new ViewManager( this, mMiniSplitter ); 1634 mViewManager = new ViewManager( this, mMiniSplitter );
1635 mDetails = new ViewContainer( mMiniSplitter ); 1635 mDetails = new ViewContainer( mMiniSplitter );
1636 1636
1637 1637
1638 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1638 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1639#endif 1639#endif
1640 //eh->hide(); 1640 //eh->hide();
1641 // topLayout->addWidget(mExtensionManager ); 1641 // topLayout->addWidget(mExtensionManager );
1642 1642
1643 1643
1644/*US 1644/*US
1645#ifndef KAB_NOSPLITTER 1645#ifndef KAB_NOSPLITTER
1646 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1646 QHBoxLayout *topLayout = new QHBoxLayout( this );
1647//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1647//US topLayout->setSpacing( KDialogBase::spacingHint() );
1648 topLayout->setSpacing( 10 ); 1648 topLayout->setSpacing( 10 );
1649 1649
1650 mDetailsSplitter = new QSplitter( this ); 1650 mDetailsSplitter = new QSplitter( this );
1651 1651
1652 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1652 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1653 1653
1654 mViewManager = new ViewManager( this, viewSpace ); 1654 mViewManager = new ViewManager( this, viewSpace );
1655 viewSpace->setStretchFactor( mViewManager, 1 ); 1655 viewSpace->setStretchFactor( mViewManager, 1 );
1656 1656
1657 mDetails = new ViewContainer( mDetailsSplitter ); 1657 mDetails = new ViewContainer( mDetailsSplitter );
1658 1658
1659 topLayout->addWidget( mDetailsSplitter ); 1659 topLayout->addWidget( mDetailsSplitter );
1660 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1660 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1661#else //KAB_NOSPLITTER 1661#else //KAB_NOSPLITTER
1662 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1662 QHBoxLayout *topLayout = new QHBoxLayout( this );
1663//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1663//US topLayout->setSpacing( KDialogBase::spacingHint() );
1664 topLayout->setSpacing( 10 ); 1664 topLayout->setSpacing( 10 );
1665 1665
1666// mDetailsSplitter = new QSplitter( this ); 1666// mDetailsSplitter = new QSplitter( this );
1667 1667
1668 QVBox *viewSpace = new QVBox( this ); 1668 QVBox *viewSpace = new QVBox( this );
1669 1669
1670 mViewManager = new ViewManager( this, viewSpace ); 1670 mViewManager = new ViewManager( this, viewSpace );
1671 viewSpace->setStretchFactor( mViewManager, 1 ); 1671 viewSpace->setStretchFactor( mViewManager, 1 );
1672 1672
1673 mDetails = new ViewContainer( this ); 1673 mDetails = new ViewContainer( this );
1674 1674
1675 topLayout->addWidget( viewSpace ); 1675 topLayout->addWidget( viewSpace );
1676// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1676// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1677 topLayout->addWidget( mDetails ); 1677 topLayout->addWidget( mDetails );
1678#endif //KAB_NOSPLITTER 1678#endif //KAB_NOSPLITTER
1679*/ 1679*/
1680 1680
1681 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1681 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1682 syncManager->setBlockSave(false); 1682 syncManager->setBlockSave(false);
1683 1683
1684 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1684 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1685 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1685 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1686 syncManager->setDefaultFileName( sentSyncFile()); 1686 syncManager->setDefaultFileName( sentSyncFile());
1687 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1687 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1688 1688
1689#endif //KAB_EMBEDDED 1689#endif //KAB_EMBEDDED
1690 initActions(); 1690 initActions();
1691 1691
1692#ifdef KAB_EMBEDDED 1692#ifdef KAB_EMBEDDED
1693 addActionsManually(); 1693 addActionsManually();
1694 //US make sure the export and import menues are initialized before creating the xxPortManager. 1694 //US make sure the export and import menues are initialized before creating the xxPortManager.
1695 mXXPortManager = new XXPortManager( this, this ); 1695 mXXPortManager = new XXPortManager( this, this );
1696 1696
1697 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1697 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1698 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1698 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1699 // mActionQuit->plug ( mMainWindow->toolBar()); 1699 // mActionQuit->plug ( mMainWindow->toolBar());
1700 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1700 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1701 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1701 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1702 // mIncSearchWidget->hide(); 1702 // mIncSearchWidget->hide();
1703 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1703 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1704 SLOT( incrementalSearch( const QString& ) ) ); 1704 SLOT( incrementalSearch( const QString& ) ) );
1705 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1705 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1706 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1706 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1707 1707
1708 mJumpButtonBar = new JumpButtonBar( this, this ); 1708 mJumpButtonBar = new JumpButtonBar( this, this );
1709 1709
1710 topLayout->addWidget( mJumpButtonBar ); 1710 topLayout->addWidget( mJumpButtonBar );
1711//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1711//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1712 1712
1713// mMainWindow->getIconToolBar()->raise(); 1713// mMainWindow->getIconToolBar()->raise();
1714 1714
1715#endif //KAB_EMBEDDED 1715#endif //KAB_EMBEDDED
1716 1716
1717} 1717}
1718void KABCore::initActions() 1718void KABCore::initActions()
1719{ 1719{
1720//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1720//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1721 1721
1722#ifndef KAB_EMBEDDED 1722#ifndef KAB_EMBEDDED
1723 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1723 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1724 SLOT( clipboardDataChanged() ) ); 1724 SLOT( clipboardDataChanged() ) );
1725#endif //KAB_EMBEDDED 1725#endif //KAB_EMBEDDED
1726 1726
1727 // file menu 1727 // file menu
1728 if ( mIsPart ) { 1728 if ( mIsPart ) {
1729 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1729 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1730 SLOT( sendMail() ), actionCollection(), 1730 SLOT( sendMail() ), actionCollection(),
1731 "kaddressbook_mail" ); 1731 "kaddressbook_mail" );
1732 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1732 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1733 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1733 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1734 1734
1735 } else { 1735 } else {
1736 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1736 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1737 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1737 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1738 } 1738 }
1739 1739
1740 1740
1741 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1741 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1742 SLOT( save() ), actionCollection(), "file_sync" ); 1742 SLOT( save() ), actionCollection(), "file_sync" );
1743 1743
1744 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1744 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1745 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1745 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1746 1746
1747 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1747 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1748 this, SLOT( mailVCard() ), 1748 this, SLOT( mailVCard() ),
1749 actionCollection(), "file_mail_vcard"); 1749 actionCollection(), "file_mail_vcard");
1750 1750
1751 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, 1751 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this,
1752 SLOT( export2phone() ), actionCollection(), 1752 SLOT( export2phone() ), actionCollection(),
1753 "kaddressbook_ex2phone" ); 1753 "kaddressbook_ex2phone" );
1754 1754
1755 mActionBeamVCard = 0; 1755 mActionBeamVCard = 0;
1756 mActionBeam = 0; 1756 mActionBeam = 0;
1757 1757
1758#ifndef DESKTOP_VERSION 1758#ifndef DESKTOP_VERSION
1759 if ( Ir::supported() ) { 1759 if ( Ir::supported() ) {
1760 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1760 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1761 SLOT( beamVCard() ), actionCollection(), 1761 SLOT( beamVCard() ), actionCollection(),
1762 "kaddressbook_beam_vcard" ); 1762 "kaddressbook_beam_vcard" );
1763 1763
1764 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1764 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1765 SLOT( beamMySelf() ), actionCollection(), 1765 SLOT( beamMySelf() ), actionCollection(),
1766 "kaddressbook_beam_myself" ); 1766 "kaddressbook_beam_myself" );
1767 } 1767 }
1768#endif 1768#endif
1769 1769
1770 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1770 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1771 this, SLOT( editContact2() ), 1771 this, SLOT( editContact2() ),
1772 actionCollection(), "file_properties" ); 1772 actionCollection(), "file_properties" );
1773 1773
1774#ifdef KAB_EMBEDDED 1774#ifdef KAB_EMBEDDED
1775 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1775 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1776 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1776 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1777 mMainWindow, SLOT( exit() ), 1777 mMainWindow, SLOT( exit() ),
1778 actionCollection(), "quit" ); 1778 actionCollection(), "quit" );
1779#endif //KAB_EMBEDDED 1779#endif //KAB_EMBEDDED
1780 1780
1781 // edit menu 1781 // edit menu
1782 if ( mIsPart ) { 1782 if ( mIsPart ) {
1783 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1783 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1784 SLOT( copyContacts() ), actionCollection(), 1784 SLOT( copyContacts() ), actionCollection(),
1785 "kaddressbook_copy" ); 1785 "kaddressbook_copy" );
1786 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1786 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1787 SLOT( cutContacts() ), actionCollection(), 1787 SLOT( cutContacts() ), actionCollection(),
1788 "kaddressbook_cut" ); 1788 "kaddressbook_cut" );
1789 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1789 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1790 SLOT( pasteContacts() ), actionCollection(), 1790 SLOT( pasteContacts() ), actionCollection(),
1791 "kaddressbook_paste" ); 1791 "kaddressbook_paste" );
1792 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1792 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1793 SLOT( selectAllContacts() ), actionCollection(), 1793 SLOT( selectAllContacts() ), actionCollection(),
1794 "kaddressbook_select_all" ); 1794 "kaddressbook_select_all" );
1795 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1795 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1796 SLOT( undo() ), actionCollection(), 1796 SLOT( undo() ), actionCollection(),
1797 "kaddressbook_undo" ); 1797 "kaddressbook_undo" );
1798 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1798 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1799 this, SLOT( redo() ), actionCollection(), 1799 this, SLOT( redo() ), actionCollection(),
1800 "kaddressbook_redo" ); 1800 "kaddressbook_redo" );
1801 } else { 1801 } else {
1802 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1802 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1803 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1803 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1804 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1804 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1805 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1805 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1806 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1806 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1807 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1807 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1808 } 1808 }
1809 1809
1810 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1810 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1811 Key_Delete, this, SLOT( deleteContacts() ), 1811 Key_Delete, this, SLOT( deleteContacts() ),
1812 actionCollection(), "edit_delete" ); 1812 actionCollection(), "edit_delete" );
1813 1813
1814 mActionUndo->setEnabled( false ); 1814 mActionUndo->setEnabled( false );
1815 mActionRedo->setEnabled( false ); 1815 mActionRedo->setEnabled( false );
1816 1816
1817 // settings menu 1817 // settings menu
1818#ifdef KAB_EMBEDDED 1818#ifdef KAB_EMBEDDED
1819//US special menuentry to configure the addressbook resources. On KDE 1819//US special menuentry to configure the addressbook resources. On KDE
1820// you do that through the control center !!! 1820// you do that through the control center !!!
1821 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1821 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1822 SLOT( configureResources() ), actionCollection(), 1822 SLOT( configureResources() ), actionCollection(),
1823 "kaddressbook_configure_resources" ); 1823 "kaddressbook_configure_resources" );
1824#endif //KAB_EMBEDDED 1824#endif //KAB_EMBEDDED
1825 1825
1826 if ( mIsPart ) { 1826 if ( mIsPart ) {
1827 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1827 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1828 SLOT( openConfigDialog() ), actionCollection(), 1828 SLOT( openConfigDialog() ), actionCollection(),
1829 "kaddressbook_configure" ); 1829 "kaddressbook_configure" );
1830 1830
1831 //US not implemented yet 1831 //US not implemented yet
1832 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1832 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1833 // this, SLOT( configureKeyBindings() ), actionCollection(), 1833 // this, SLOT( configureKeyBindings() ), actionCollection(),
1834 // "kaddressbook_configure_shortcuts" ); 1834 // "kaddressbook_configure_shortcuts" );
1835#ifdef KAB_EMBEDDED 1835#ifdef KAB_EMBEDDED
1836 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1836 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1837 mActionConfigureToolbars->setEnabled( false ); 1837 mActionConfigureToolbars->setEnabled( false );
1838#endif //KAB_EMBEDDED 1838#endif //KAB_EMBEDDED
1839 1839
1840 } else { 1840 } else {
1841 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1841 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1842 1842
1843 //US not implemented yet 1843 //US not implemented yet
1844 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1844 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1845 } 1845 }
1846 1846
1847 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1847 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1848 actionCollection(), "options_show_jump_bar" ); 1848 actionCollection(), "options_show_jump_bar" );
1849 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1849 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1850 1850
1851 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1851 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1852 actionCollection(), "options_show_details" ); 1852 actionCollection(), "options_show_details" );
1853 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1853 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1854 1854
1855 1855
1856 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 1856 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
1857 SLOT( toggleBeamReceive() ), actionCollection(), 1857 SLOT( toggleBeamReceive() ), actionCollection(),
1858 "kaddressbook_beam_rec" ); 1858 "kaddressbook_beam_rec" );
1859 1859
1860 1860
1861 // misc 1861 // misc
1862 // only enable LDAP lookup if we can handle the protocol 1862 // only enable LDAP lookup if we can handle the protocol
1863#ifndef KAB_EMBEDDED 1863#ifndef KAB_EMBEDDED
1864 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1864 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1865 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1865 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1866 this, SLOT( openLDAPDialog() ), actionCollection(), 1866 this, SLOT( openLDAPDialog() ), actionCollection(),
1867 "ldap_lookup" ); 1867 "ldap_lookup" );
1868 } 1868 }
1869#else //KAB_EMBEDDED 1869#else //KAB_EMBEDDED
1870 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1870 //qDebug("KABCore::initActions() LDAP has to be implemented");
1871#endif //KAB_EMBEDDED 1871#endif //KAB_EMBEDDED
1872 1872
1873 1873
1874 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1874 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1875 SLOT( setWhoAmI() ), actionCollection(), 1875 SLOT( setWhoAmI() ), actionCollection(),
1876 "set_personal" ); 1876 "set_personal" );
1877 1877
1878 1878
1879
1880
1881 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1879 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1882 SLOT( setCategories() ), actionCollection(), 1880 SLOT( setCategories() ), actionCollection(),
1883 "edit_set_categories" ); 1881 "edit_set_categories" );
1884 1882
1885 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1883 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1886 SLOT( removeVoice() ), actionCollection(), 1884 SLOT( removeVoice() ), actionCollection(),
1887 "remove_voice" ); 1885 "remove_voice" );
1886
1887 mActionSetCat= new KAction( i18n( "Set categories..." ), 0, this,
1888 SLOT( setCat() ), actionCollection(),
1889 "remove_voice" );
1890
1891
1892 mActionAddCat= new KAction( i18n( "Add categories..." ), 0, this,
1893 SLOT( addCat() ), actionCollection(),
1894 "remove_voice" );
1895
1888 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1896 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1889 SLOT( importFromOL() ), actionCollection(), 1897 SLOT( importFromOL() ), actionCollection(),
1890 "import_OL" ); 1898 "import_OL" );
1891#ifdef KAB_EMBEDDED 1899#ifdef KAB_EMBEDDED
1892 mActionLicence = new KAction( i18n( "Licence" ), 0, 1900 mActionLicence = new KAction( i18n( "Licence" ), 0,
1893 this, SLOT( showLicence() ), actionCollection(), 1901 this, SLOT( showLicence() ), actionCollection(),
1894 "licence_about_data" ); 1902 "licence_about_data" );
1895 mActionFaq = new KAction( i18n( "Faq" ), 0, 1903 mActionFaq = new KAction( i18n( "Faq" ), 0,
1896 this, SLOT( faq() ), actionCollection(), 1904 this, SLOT( faq() ), actionCollection(),
1897 "faq_about_data" ); 1905 "faq_about_data" );
1898 mActionWN = new KAction( i18n( "What's New?" ), 0, 1906 mActionWN = new KAction( i18n( "What's New?" ), 0,
1899 this, SLOT( whatsnew() ), actionCollection(), 1907 this, SLOT( whatsnew() ), actionCollection(),
1900 "wn" ); 1908 "wn" );
1901 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 1909 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
1902 this, SLOT( synchowto() ), actionCollection(), 1910 this, SLOT( synchowto() ), actionCollection(),
1903 "sync" ); 1911 "sync" );
1904 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 1912 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
1905 this, SLOT( kdesynchowto() ), actionCollection(), 1913 this, SLOT( kdesynchowto() ), actionCollection(),
1906 "kdesync" ); 1914 "kdesync" );
1907 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 1915 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
1908 this, SLOT( multisynchowto() ), actionCollection(), 1916 this, SLOT( multisynchowto() ), actionCollection(),
1909 "multisync" ); 1917 "multisync" );
1910 1918
1911 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1919 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1912 this, SLOT( createAboutData() ), actionCollection(), 1920 this, SLOT( createAboutData() ), actionCollection(),
1913 "kaddressbook_about_data" ); 1921 "kaddressbook_about_data" );
1914#endif //KAB_EMBEDDED 1922#endif //KAB_EMBEDDED
1915 1923
1916 clipboardDataChanged(); 1924 clipboardDataChanged();
1917 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1925 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1918 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1926 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1919} 1927}
1920 1928
1921//US we need this function, to plug all actions into the correct menues. 1929//US we need this function, to plug all actions into the correct menues.
1922// KDE uses a XML format to plug the actions, but we work her without this overhead. 1930// KDE uses a XML format to plug the actions, but we work her without this overhead.
1923void KABCore::addActionsManually() 1931void KABCore::addActionsManually()
1924{ 1932{
1925//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1933//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1926 1934
1927#ifdef KAB_EMBEDDED 1935#ifdef KAB_EMBEDDED
1928 QPopupMenu *fileMenu = new QPopupMenu( this ); 1936 QPopupMenu *fileMenu = new QPopupMenu( this );
1929 QPopupMenu *editMenu = new QPopupMenu( this ); 1937 QPopupMenu *editMenu = new QPopupMenu( this );
1930 QPopupMenu *helpMenu = new QPopupMenu( this ); 1938 QPopupMenu *helpMenu = new QPopupMenu( this );
1931 1939
1932 KToolBar* tb = mMainWindow->toolBar(); 1940 KToolBar* tb = mMainWindow->toolBar();
1933 1941
1934#ifndef DESKTOP_VERSION 1942#ifndef DESKTOP_VERSION
1935 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 1943 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
1936#endif 1944#endif
1937 QMenuBar* mb = mMainWindow->menuBar(); 1945 QMenuBar* mb = mMainWindow->menuBar();
1938 1946
1939 //US setup menubar. 1947 //US setup menubar.
1940 //Disable the following block if you do not want to have a menubar. 1948 //Disable the following block if you do not want to have a menubar.
1941 mb->insertItem( "&File", fileMenu ); 1949 mb->insertItem( "&File", fileMenu );
1942 mb->insertItem( "&Edit", editMenu ); 1950 mb->insertItem( "&Edit", editMenu );
1943 mb->insertItem( "&View", viewMenu ); 1951 mb->insertItem( "&View", viewMenu );
1944 mb->insertItem( "&Settings", settingsMenu ); 1952 mb->insertItem( "&Settings", settingsMenu );
1945 mb->insertItem( i18n("Synchronize"), syncMenu ); 1953 mb->insertItem( i18n("Synchronize"), syncMenu );
1946 mb->insertItem( "&Change selected", changeMenu ); 1954 mb->insertItem( "&Change selected", changeMenu );
1947 mb->insertItem( "&Help", helpMenu ); 1955 mb->insertItem( "&Help", helpMenu );
1948 mIncSearchWidget = new IncSearchWidget( tb ); 1956 mIncSearchWidget = new IncSearchWidget( tb );
1949 // tb->insertWidget(-1, 0, mIncSearchWidget); 1957 // tb->insertWidget(-1, 0, mIncSearchWidget);
1950#ifndef DESKTOP_VERSION 1958#ifndef DESKTOP_VERSION
1951 } else { 1959 } else {
1952 //US setup toolbar 1960 //US setup toolbar
1953 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 1961 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1954 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1962 QPopupMenu *popupBarTB = new QPopupMenu( this );
1955 menuBarTB->insertItem( "ME", popupBarTB); 1963 menuBarTB->insertItem( "ME", popupBarTB);
1956 tb->insertWidget(-1, 0, menuBarTB); 1964 tb->insertWidget(-1, 0, menuBarTB);
1957 mIncSearchWidget = new IncSearchWidget( tb ); 1965 mIncSearchWidget = new IncSearchWidget( tb );
1958 1966
1959 tb->enableMoving(false); 1967 tb->enableMoving(false);
1960 popupBarTB->insertItem( "&File", fileMenu ); 1968 popupBarTB->insertItem( "&File", fileMenu );
1961 popupBarTB->insertItem( "&Edit", editMenu ); 1969 popupBarTB->insertItem( "&Edit", editMenu );
1962 popupBarTB->insertItem( "&View", viewMenu ); 1970 popupBarTB->insertItem( "&View", viewMenu );
1963 popupBarTB->insertItem( "&Settings", settingsMenu ); 1971 popupBarTB->insertItem( "&Settings", settingsMenu );
1964 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 1972 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
1965 mViewManager->getFilterAction()->plug ( popupBarTB); 1973 mViewManager->getFilterAction()->plug ( popupBarTB);
1966 popupBarTB->insertItem( "&Change selected", changeMenu ); 1974 popupBarTB->insertItem( "&Change selected", changeMenu );
1967 popupBarTB->insertItem( "&Help", helpMenu ); 1975 popupBarTB->insertItem( "&Help", helpMenu );
1968 if (QApplication::desktop()->width() > 320 ) { 1976 if (QApplication::desktop()->width() > 320 ) {
1969 // mViewManager->getFilterAction()->plug ( tb); 1977 // mViewManager->getFilterAction()->plug ( tb);
1970 } 1978 }
1971 } 1979 }
1972#endif 1980#endif
1973 // mActionQuit->plug ( mMainWindow->toolBar()); 1981 // mActionQuit->plug ( mMainWindow->toolBar());
1974 1982
1975 1983
1976 1984
1977 //US Now connect the actions with the menue entries. 1985 //US Now connect the actions with the menue entries.
1978 mActionPrint->plug( fileMenu ); 1986 mActionPrint->plug( fileMenu );
1979 mActionMail->plug( fileMenu ); 1987 mActionMail->plug( fileMenu );
1980 fileMenu->insertSeparator(); 1988 fileMenu->insertSeparator();
1981 1989
1982 mActionNewContact->plug( fileMenu ); 1990 mActionNewContact->plug( fileMenu );
1983 mActionNewContact->plug( tb ); 1991 mActionNewContact->plug( tb );
1984 1992
1985 mActionEditAddressee->plug( fileMenu ); 1993 mActionEditAddressee->plug( fileMenu );
1986 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1994 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1987 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1995 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1988 mActionEditAddressee->plug( tb ); 1996 mActionEditAddressee->plug( tb );
1989 1997
1990 fileMenu->insertSeparator(); 1998 fileMenu->insertSeparator();
1991 mActionSave->plug( fileMenu ); 1999 mActionSave->plug( fileMenu );
1992 fileMenu->insertItem( "&Import", ImportMenu ); 2000 fileMenu->insertItem( "&Import", ImportMenu );
1993 fileMenu->insertItem( "&Export", ExportMenu ); 2001 fileMenu->insertItem( "&Export", ExportMenu );
1994 fileMenu->insertSeparator(); 2002 fileMenu->insertSeparator();
1995 mActionMailVCard->plug( fileMenu ); 2003 mActionMailVCard->plug( fileMenu );
1996#ifndef DESKTOP_VERSION 2004#ifndef DESKTOP_VERSION
1997 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 2005 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1998 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 2006 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1999#endif 2007#endif
2000 fileMenu->insertSeparator(); 2008 fileMenu->insertSeparator();
2001 mActionQuit->plug( fileMenu ); 2009 mActionQuit->plug( fileMenu );
2002#ifdef _WIN32_ 2010#ifdef _WIN32_
2003 mActionImportOL->plug( ImportMenu ); 2011 mActionImportOL->plug( ImportMenu );
2004#endif 2012#endif
2005 // edit menu 2013 // edit menu
2006 mActionUndo->plug( editMenu ); 2014 mActionUndo->plug( editMenu );
2007 mActionRedo->plug( editMenu ); 2015 mActionRedo->plug( editMenu );
2008 editMenu->insertSeparator(); 2016 editMenu->insertSeparator();
2009 mActionCut->plug( editMenu ); 2017 mActionCut->plug( editMenu );
2010 mActionCopy->plug( editMenu ); 2018 mActionCopy->plug( editMenu );
2011 mActionPaste->plug( editMenu ); 2019 mActionPaste->plug( editMenu );
2012 mActionDelete->plug( editMenu ); 2020 mActionDelete->plug( editMenu );
2013 editMenu->insertSeparator(); 2021 editMenu->insertSeparator();
2014 mActionSelectAll->plug( editMenu ); 2022 mActionSelectAll->plug( editMenu );
2015 2023
2016 mActionRemoveVoice->plug( changeMenu ); 2024 mActionRemoveVoice->plug( changeMenu );
2025 mActionSetCat->plug( changeMenu );
2026 mActionAddCat->plug( changeMenu );
2017 // settings menu 2027 // settings menu
2018//US special menuentry to configure the addressbook resources. On KDE 2028//US special menuentry to configure the addressbook resources. On KDE
2019// you do that through the control center !!! 2029// you do that through the control center !!!
2020 mActionConfigResources->plug( settingsMenu ); 2030 mActionConfigResources->plug( settingsMenu );
2021 settingsMenu->insertSeparator(); 2031 settingsMenu->insertSeparator();
2022 2032
2023 mActionConfigKAddressbook->plug( settingsMenu ); 2033 mActionConfigKAddressbook->plug( settingsMenu );
2024 2034
2025 if ( mIsPart ) { 2035 if ( mIsPart ) {
2026 //US not implemented yet 2036 //US not implemented yet
2027 //mActionConfigShortcuts->plug( settingsMenu ); 2037 //mActionConfigShortcuts->plug( settingsMenu );
2028 //mActionConfigureToolbars->plug( settingsMenu ); 2038 //mActionConfigureToolbars->plug( settingsMenu );
2029 2039
2030 } else { 2040 } else {
2031 //US not implemented yet 2041 //US not implemented yet
2032 //mActionKeyBindings->plug( settingsMenu ); 2042 //mActionKeyBindings->plug( settingsMenu );
2033 } 2043 }
2034 2044
2035 settingsMenu->insertSeparator(); 2045 settingsMenu->insertSeparator();
2036 2046
2037 mActionJumpBar->plug( settingsMenu ); 2047 mActionJumpBar->plug( settingsMenu );
2038 mActionDetails->plug( settingsMenu ); 2048 mActionDetails->plug( settingsMenu );
2039 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2049 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2040 mActionDetails->plug( tb ); 2050 mActionDetails->plug( tb );
2041 settingsMenu->insertSeparator(); 2051 settingsMenu->insertSeparator();
2042 mActionBR->plug(settingsMenu ); 2052 mActionBR->plug(settingsMenu );
2043 settingsMenu->insertSeparator(); 2053 settingsMenu->insertSeparator();
2044 2054
2045 mActionWhoAmI->plug( settingsMenu ); 2055 mActionWhoAmI->plug( settingsMenu );
2046 mActionCategories->plug( settingsMenu ); 2056 mActionCategories->plug( settingsMenu );
2047 2057
2048 2058
2049 mActionWN->plug( helpMenu ); 2059 mActionWN->plug( helpMenu );
2050 mActionSyncHowto->plug( helpMenu ); 2060 mActionSyncHowto->plug( helpMenu );
2051 mActionKdeSyncHowto->plug( helpMenu ); 2061 mActionKdeSyncHowto->plug( helpMenu );
2052 mActionMultiSyncHowto->plug( helpMenu ); 2062 mActionMultiSyncHowto->plug( helpMenu );
2053 mActionFaq->plug( helpMenu ); 2063 mActionFaq->plug( helpMenu );
2054 mActionLicence->plug( helpMenu ); 2064 mActionLicence->plug( helpMenu );
2055 mActionAboutKAddressbook->plug( helpMenu ); 2065 mActionAboutKAddressbook->plug( helpMenu );
2056 2066
2057 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2067 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2058 2068
2059 mActionSave->plug( tb ); 2069 mActionSave->plug( tb );
2060 mViewManager->getFilterAction()->plug ( tb); 2070 mViewManager->getFilterAction()->plug ( tb);
2061 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2071 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2062 mActionUndo->plug( tb ); 2072 mActionUndo->plug( tb );
2063 mActionDelete->plug( tb ); 2073 mActionDelete->plug( tb );
2064 mActionRedo->plug( tb ); 2074 mActionRedo->plug( tb );
2065 } 2075 }
2066 } else { 2076 } else {
2067 mActionSave->plug( tb ); 2077 mActionSave->plug( tb );
2068 tb->enableMoving(false); 2078 tb->enableMoving(false);
2069 } 2079 }
2070 //mActionQuit->plug ( tb ); 2080 //mActionQuit->plug ( tb );
2071 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2081 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2072 2082
2073 //US link the searchwidget first to this. 2083 //US link the searchwidget first to this.
2074 // The real linkage to the toolbar happens later. 2084 // The real linkage to the toolbar happens later.
2075//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2085//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2076//US tb->insertItem( mIncSearchWidget ); 2086//US tb->insertItem( mIncSearchWidget );
2077/*US 2087/*US
2078 mIncSearchWidget = new IncSearchWidget( tb ); 2088 mIncSearchWidget = new IncSearchWidget( tb );
2079 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2089 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2080 SLOT( incrementalSearch( const QString& ) ) ); 2090 SLOT( incrementalSearch( const QString& ) ) );
2081 2091
2082 mJumpButtonBar = new JumpButtonBar( this, this ); 2092 mJumpButtonBar = new JumpButtonBar( this, this );
2083 2093
2084//US topLayout->addWidget( mJumpButtonBar ); 2094//US topLayout->addWidget( mJumpButtonBar );
2085 this->layout()->add( mJumpButtonBar ); 2095 this->layout()->add( mJumpButtonBar );
2086*/ 2096*/
2087 2097
2088#endif //KAB_EMBEDDED 2098#endif //KAB_EMBEDDED
2089 2099
2090 mActionExport2phone->plug( ExportMenu ); 2100 mActionExport2phone->plug( ExportMenu );
2091 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2101 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2092 syncManager->fillSyncMenu(); 2102 syncManager->fillSyncMenu();
2093 2103
2094} 2104}
2095void KABCore::showLicence() 2105void KABCore::showLicence()
2096{ 2106{
2097 KApplication::showLicence(); 2107 KApplication::showLicence();
2098} 2108}
2109void KABCore::setCat()
2110{
2111 setCategories( true );
2112}
2113void KABCore::addCat()
2114{
2115 setCategories( false );
2116}
2117void KABCore::setCategories( bool removeOld )
2118{
2119 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KABPrefs::instance(), 0 );
2120 if (! csd->exec()) {
2121 message( i18n("Setting categories cancelled") );
2122 delete csd;
2123 return;
2124 }
2125 message( i18n("Setting categories ... please wait!") );
2126 QStringList catList = csd->selectedCategories();
2127 delete csd;
2128 catList.sort();
2129 QStringList newList;
2130 KABC::Addressee::List list = mViewManager->selectedAddressees();
2131 KABC::Addressee::List::Iterator it;
2132 for ( it = list.begin(); it != list.end(); ++it ) {
2133 if ( removeOld ) {
2134 (*it).setCategories( catList );
2135 } else {
2136 newList = (*it).categories();
2137 int i;
2138 for( i = 0; i< catList.count(); ++i ) {
2139 if ( !newList.contains (catList[i]))
2140 newList.append( catList[i] );
2141 }
2142 newList.sort();
2143 (*it).setCategories( newList );
2144 }
2145 contactModified((*it) );
2146 }
2147 message( i18n("Setting categories completed!") );
2148}
2099void KABCore::removeVoice() 2149void KABCore::removeVoice()
2100{ 2150{
2101 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2151 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2102 return; 2152 return;
2103 KABC::Addressee::List list = mViewManager->selectedAddressees(); 2153 KABC::Addressee::List list = mViewManager->selectedAddressees();
2104 KABC::Addressee::List::Iterator it; 2154 KABC::Addressee::List::Iterator it;
2105 for ( it = list.begin(); it != list.end(); ++it ) { 2155 for ( it = list.begin(); it != list.end(); ++it ) {
2106 2156
2107 if ( (*it).removeVoice() ) 2157 if ( (*it).removeVoice() )
2108 contactModified((*it) ); 2158 contactModified((*it) );
2109 } 2159 }
2110} 2160}
2111 2161
2112 2162
2113 2163
2114void KABCore::clipboardDataChanged() 2164void KABCore::clipboardDataChanged()
2115{ 2165{
2116 2166
2117 if ( mReadWrite ) 2167 if ( mReadWrite )
2118 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2168 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2119 2169
2120} 2170}
2121 2171
2122void KABCore::updateActionMenu() 2172void KABCore::updateActionMenu()
2123{ 2173{
2124 UndoStack *undo = UndoStack::instance(); 2174 UndoStack *undo = UndoStack::instance();
2125 RedoStack *redo = RedoStack::instance(); 2175 RedoStack *redo = RedoStack::instance();
2126 2176
2127 if ( undo->isEmpty() ) 2177 if ( undo->isEmpty() )
2128 mActionUndo->setText( i18n( "Undo" ) ); 2178 mActionUndo->setText( i18n( "Undo" ) );
2129 else 2179 else
2130 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2180 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2131 2181
2132 mActionUndo->setEnabled( !undo->isEmpty() ); 2182 mActionUndo->setEnabled( !undo->isEmpty() );
2133 2183
2134 if ( !redo->top() ) 2184 if ( !redo->top() )
2135 mActionRedo->setText( i18n( "Redo" ) ); 2185 mActionRedo->setText( i18n( "Redo" ) );
2136 else 2186 else
2137 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2187 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2138 2188
2139 mActionRedo->setEnabled( !redo->isEmpty() ); 2189 mActionRedo->setEnabled( !redo->isEmpty() );
2140} 2190}
2141 2191
2142void KABCore::configureKeyBindings() 2192void KABCore::configureKeyBindings()
2143{ 2193{
2144#ifndef KAB_EMBEDDED 2194#ifndef KAB_EMBEDDED
2145 KKeyDialog::configure( actionCollection(), true ); 2195 KKeyDialog::configure( actionCollection(), true );
2146#else //KAB_EMBEDDED 2196#else //KAB_EMBEDDED
2147 qDebug("KABCore::configureKeyBindings() not implemented"); 2197 qDebug("KABCore::configureKeyBindings() not implemented");
2148#endif //KAB_EMBEDDED 2198#endif //KAB_EMBEDDED
2149} 2199}
2150 2200
2151#ifdef KAB_EMBEDDED 2201#ifdef KAB_EMBEDDED
2152void KABCore::configureResources() 2202void KABCore::configureResources()
2153{ 2203{
2154 KRES::KCMKResources dlg( this, "" , 0 ); 2204 KRES::KCMKResources dlg( this, "" , 0 );
2155 2205
2156 if ( !dlg.exec() ) 2206 if ( !dlg.exec() )
2157 return; 2207 return;
2158 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2208 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2159} 2209}
2160#endif //KAB_EMBEDDED 2210#endif //KAB_EMBEDDED
2161 2211
2162 2212
2163/* this method will be called through the QCop interface from Ko/Pi to select addresses 2213/* this method will be called through the QCop interface from Ko/Pi to select addresses
2164 * for the attendees list of an event. 2214 * for the attendees list of an event.
2165 */ 2215 */
2166void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2216void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2167{ 2217{
2168 QStringList nameList; 2218 QStringList nameList;
2169 QStringList emailList; 2219 QStringList emailList;
2170 QStringList uidList; 2220 QStringList uidList;
2171 2221
2172 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2222 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2173 uint i=0; 2223 uint i=0;
2174 for (i=0; i < list.count(); i++) 2224 for (i=0; i < list.count(); i++)
2175 { 2225 {
2176 nameList.append(list[i].realName()); 2226 nameList.append(list[i].realName());
2177 emailList.append(list[i].preferredEmail()); 2227 emailList.append(list[i].preferredEmail());
2178 uidList.append(list[i].uid()); 2228 uidList.append(list[i].uid());
2179 } 2229 }
2180 2230
2181 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2231 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2182 2232
2183} 2233}
2184 2234
2185/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2235/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2186 * to put them into the calendar. 2236 * to put them into the calendar.
2187 */ 2237 */
2188void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2238void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2189{ 2239{
2190 // qDebug("KABCore::requestForBirthdayList"); 2240 // qDebug("KABCore::requestForBirthdayList");
2191 QStringList birthdayList; 2241 QStringList birthdayList;
2192 QStringList anniversaryList; 2242 QStringList anniversaryList;
2193 QStringList realNameList; 2243 QStringList realNameList;
2194 QStringList preferredEmailList; 2244 QStringList preferredEmailList;
2195 QStringList assembledNameList; 2245 QStringList assembledNameList;
2196 QStringList uidList; 2246 QStringList uidList;
2197 2247
2198 KABC::AddressBook::Iterator it; 2248 KABC::AddressBook::Iterator it;
2199 2249
2200 int count = 0; 2250 int count = 0;
2201 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2251 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2202 ++count; 2252 ++count;
2203 } 2253 }
2204 QProgressBar bar(count,0 ); 2254 QProgressBar bar(count,0 );
2205 int w = 300; 2255 int w = 300;
2206 if ( QApplication::desktop()->width() < 320 ) 2256 if ( QApplication::desktop()->width() < 320 )
2207 w = 220; 2257 w = 220;
2208 int h = bar.sizeHint().height() ; 2258 int h = bar.sizeHint().height() ;
2209 int dw = QApplication::desktop()->width(); 2259 int dw = QApplication::desktop()->width();
2210 int dh = QApplication::desktop()->height(); 2260 int dh = QApplication::desktop()->height();
2211 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2261 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2212 bar.show(); 2262 bar.show();
2213 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2263 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2214 qApp->processEvents(); 2264 qApp->processEvents();
2215 2265
2216 QDate bday; 2266 QDate bday;
2217 QString anni; 2267 QString anni;
2218 QString formattedbday; 2268 QString formattedbday;
2219 2269
2220 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2270 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2221 { 2271 {
2222 if ( ! bar.isVisible() ) 2272 if ( ! bar.isVisible() )
2223 return; 2273 return;
2224 bar.setProgress( count++ ); 2274 bar.setProgress( count++ );
2225 qApp->processEvents(); 2275 qApp->processEvents();
2226 bday = (*it).birthday().date(); 2276 bday = (*it).birthday().date();
2227 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2277 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2228 2278
2229 if ( bday.isValid() || !anni.isEmpty()) 2279 if ( bday.isValid() || !anni.isEmpty())
2230 { 2280 {
2231 if (bday.isValid()) 2281 if (bday.isValid())
2232 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2282 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2233 else 2283 else
2234 formattedbday = "NOTVALID"; 2284 formattedbday = "NOTVALID";
2235 if (anni.isEmpty()) 2285 if (anni.isEmpty())
2236 anni = "INVALID"; 2286 anni = "INVALID";
2237 2287
2238 birthdayList.append(formattedbday); 2288 birthdayList.append(formattedbday);
2239 anniversaryList.append(anni); //should be ISODate 2289 anniversaryList.append(anni); //should be ISODate
2240 realNameList.append((*it).realName()); 2290 realNameList.append((*it).realName());
2241 preferredEmailList.append((*it).preferredEmail()); 2291 preferredEmailList.append((*it).preferredEmail());
2242 assembledNameList.append((*it).assembledName()); 2292 assembledNameList.append((*it).assembledName());
2243 uidList.append((*it).uid()); 2293 uidList.append((*it).uid());
2244 2294
2245 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2295 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2246 } 2296 }
2247 } 2297 }
2248 2298
2249 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2299 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2250 2300
2251} 2301}
2252 2302
2253/* this method will be called through the QCop interface from other apps to show details of a contact. 2303/* this method will be called through the QCop interface from other apps to show details of a contact.
2254 */ 2304 */
2255void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2305void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2256{ 2306{
2257 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2307 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2258 2308
2259 QString foundUid = QString::null; 2309 QString foundUid = QString::null;
2260 if ( ! uid.isEmpty() ) { 2310 if ( ! uid.isEmpty() ) {
2261 Addressee adrr = mAddressBook->findByUid( uid ); 2311 Addressee adrr = mAddressBook->findByUid( uid );
2262 if ( !adrr.isEmpty() ) { 2312 if ( !adrr.isEmpty() ) {
2263 foundUid = uid; 2313 foundUid = uid;
2264 } 2314 }
2265 if ( email == "sendbacklist" ) { 2315 if ( email == "sendbacklist" ) {
2266 //qDebug("ssssssssssssssssssssssend "); 2316 //qDebug("ssssssssssssssssssssssend ");
2267 QStringList nameList; 2317 QStringList nameList;
2268 QStringList emailList; 2318 QStringList emailList;
2269 QStringList uidList; 2319 QStringList uidList;
2270 nameList.append(adrr.realName()); 2320 nameList.append(adrr.realName());
2271 emailList = adrr.emails(); 2321 emailList = adrr.emails();
2272 uidList.append( adrr.preferredEmail()); 2322 uidList.append( adrr.preferredEmail());
2273 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2323 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2274 return; 2324 return;
2275 } 2325 }
2276 2326
2277 } 2327 }
2278 2328
2279 if ( email == "sendbacklist" ) 2329 if ( email == "sendbacklist" )
2280 return; 2330 return;
2281 if (foundUid.isEmpty()) 2331 if (foundUid.isEmpty())
2282 { 2332 {
2283 //find the uid of the person first 2333 //find the uid of the person first
2284 Addressee::List namelist; 2334 Addressee::List namelist;
2285 Addressee::List emaillist; 2335 Addressee::List emaillist;
2286 2336
2287 if (!name.isEmpty()) 2337 if (!name.isEmpty())
2288 namelist = mAddressBook->findByName( name ); 2338 namelist = mAddressBook->findByName( name );
2289 2339
2290 if (!email.isEmpty()) 2340 if (!email.isEmpty())
2291 emaillist = mAddressBook->findByEmail( email ); 2341 emaillist = mAddressBook->findByEmail( email );
2292 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2342 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2293 //check if we have a match in Namelist and Emaillist 2343 //check if we have a match in Namelist and Emaillist
2294 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2344 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2295 foundUid = emaillist[0].uid(); 2345 foundUid = emaillist[0].uid();
2296 } 2346 }
2297 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2347 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2298 foundUid = namelist[0].uid(); 2348 foundUid = namelist[0].uid();
2299 else 2349 else
2300 { 2350 {
2301 for (int i = 0; i < namelist.count(); i++) 2351 for (int i = 0; i < namelist.count(); i++)
2302 { 2352 {
2303 for (int j = 0; j < emaillist.count(); j++) 2353 for (int j = 0; j < emaillist.count(); j++)
2304 { 2354 {
2305 if (namelist[i] == emaillist[j]) 2355 if (namelist[i] == emaillist[j])
2306 { 2356 {
2307 foundUid = namelist[i].uid(); 2357 foundUid = namelist[i].uid();
2308 } 2358 }
2309 } 2359 }
2310 } 2360 }
2311 } 2361 }
2312 } 2362 }
2313 else 2363 else
2314 { 2364 {
2315 foundUid = uid; 2365 foundUid = uid;
2316 } 2366 }
2317 2367
2318 if (!foundUid.isEmpty()) 2368 if (!foundUid.isEmpty())
2319 { 2369 {
2320 2370
2321 // raise Ka/Pi if it is in the background 2371 // raise Ka/Pi if it is in the background
2322#ifndef DESKTOP_VERSION 2372#ifndef DESKTOP_VERSION
2323#ifndef KORG_NODCOP 2373#ifndef KORG_NODCOP
2324 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2374 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2325#endif 2375#endif
2326#endif 2376#endif
2327 2377
2328 mMainWindow->showMaximized(); 2378 mMainWindow->showMaximized();
2329 mMainWindow-> raise(); 2379 mMainWindow-> raise();
2330 2380
2331 mViewManager->setSelected( "", false); 2381 mViewManager->setSelected( "", false);
2332 mViewManager->refreshView( "" ); 2382 mViewManager->refreshView( "" );
2333 mViewManager->setSelected( foundUid, true ); 2383 mViewManager->setSelected( foundUid, true );
2334 mViewManager->refreshView( foundUid ); 2384 mViewManager->refreshView( foundUid );
2335 2385
2336 if ( !mMultipleViewsAtOnce ) 2386 if ( !mMultipleViewsAtOnce )
2337 { 2387 {
2338 setDetailsVisible( true ); 2388 setDetailsVisible( true );
2339 mActionDetails->setChecked(true); 2389 mActionDetails->setChecked(true);
2340 } 2390 }
2341 } 2391 }
2342} 2392}
2343 2393
2344void KABCore::whatsnew() 2394void KABCore::whatsnew()
2345{ 2395{
2346 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2396 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2347} 2397}
2348void KABCore::synchowto() 2398void KABCore::synchowto()
2349{ 2399{
2350 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2400 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2351} 2401}
2352void KABCore::kdesynchowto() 2402void KABCore::kdesynchowto()
2353{ 2403{
2354 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2404 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2355} 2405}
2356void KABCore::multisynchowto() 2406void KABCore::multisynchowto()
2357{ 2407{
2358 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2408 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2359} 2409}
2360void KABCore::faq() 2410void KABCore::faq()
2361{ 2411{
2362 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2412 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2363} 2413}
2364 2414
2365#include <libkcal/syncdefines.h> 2415#include <libkcal/syncdefines.h>
2366 2416
2367KABC::Addressee KABCore::getLastSyncAddressee() 2417KABC::Addressee KABCore::getLastSyncAddressee()
2368{ 2418{
2369 Addressee lse; 2419 Addressee lse;
2370 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2420 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2371 2421
2372 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2422 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2373 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2423 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2374 if (lse.isEmpty()) { 2424 if (lse.isEmpty()) {
2375 qDebug("Creating new last-syncAddressee "); 2425 qDebug("Creating new last-syncAddressee ");
2376 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2426 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2377 QString sum = ""; 2427 QString sum = "";
2378 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2428 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2379 sum = "E: "; 2429 sum = "E: ";
2380 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2430 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2381 lse.setRevision( mLastAddressbookSync ); 2431 lse.setRevision( mLastAddressbookSync );
2382 lse.setCategories( i18n("SyncEvent") ); 2432 lse.setCategories( i18n("SyncEvent") );
2383 mAddressBook->insertAddressee( lse ); 2433 mAddressBook->insertAddressee( lse );
2384 } 2434 }
2385 return lse; 2435 return lse;
2386} 2436}
2387int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2437int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2388{ 2438{
2389 2439
2390 //void setZaurusId(int id); 2440 //void setZaurusId(int id);
2391 // int zaurusId() const; 2441 // int zaurusId() const;
2392 // void setZaurusUid(int id); 2442 // void setZaurusUid(int id);
2393 // int zaurusUid() const; 2443 // int zaurusUid() const;
2394 // void setZaurusStat(int id); 2444 // void setZaurusStat(int id);
2395 // int zaurusStat() const; 2445 // int zaurusStat() const;
2396 // 0 equal 2446 // 0 equal
2397 // 1 take local 2447 // 1 take local
2398 // 2 take remote 2448 // 2 take remote
2399 // 3 cancel 2449 // 3 cancel
2400 QDateTime lastSync = mLastAddressbookSync; 2450 QDateTime lastSync = mLastAddressbookSync;
2401 QDateTime localMod = local->revision(); 2451 QDateTime localMod = local->revision();
2402 QDateTime remoteMod = remote->revision(); 2452 QDateTime remoteMod = remote->revision();
2403 2453
2404 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2454 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2405 2455
2406 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2456 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2407 bool remCh, locCh; 2457 bool remCh, locCh;
2408 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2458 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2409 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2459 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2410 locCh = ( localMod > mLastAddressbookSync ); 2460 locCh = ( localMod > mLastAddressbookSync );
2411 if ( !remCh && ! locCh ) { 2461 if ( !remCh && ! locCh ) {
2412 //qDebug("both not changed "); 2462 //qDebug("both not changed ");
2413 lastSync = localMod.addDays(1); 2463 lastSync = localMod.addDays(1);
2414 if ( mode <= SYNC_PREF_ASK ) 2464 if ( mode <= SYNC_PREF_ASK )
2415 return 0; 2465 return 0;
2416 } else { 2466 } else {
2417 if ( locCh ) { 2467 if ( locCh ) {
2418 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2468 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2419 lastSync = localMod.addDays( -1 ); 2469 lastSync = localMod.addDays( -1 );
2420 if ( !remCh ) 2470 if ( !remCh )
2421 remoteMod =( lastSync.addDays( -1 ) ); 2471 remoteMod =( lastSync.addDays( -1 ) );
2422 } else { 2472 } else {
2423 //qDebug(" not loc changed "); 2473 //qDebug(" not loc changed ");
2424 lastSync = localMod.addDays( 1 ); 2474 lastSync = localMod.addDays( 1 );
2425 if ( remCh ) { 2475 if ( remCh ) {
2426 //qDebug("rem changed "); 2476 //qDebug("rem changed ");
2427 remoteMod =( lastSync.addDays( 1 ) ); 2477 remoteMod =( lastSync.addDays( 1 ) );
2428 } 2478 }
2429 2479
2430 } 2480 }
2431 } 2481 }
2432 full = true; 2482 full = true;
2433 if ( mode < SYNC_PREF_ASK ) 2483 if ( mode < SYNC_PREF_ASK )
2434 mode = SYNC_PREF_ASK; 2484 mode = SYNC_PREF_ASK;
2435 } else { 2485 } else {
2436 if ( localMod == remoteMod ) 2486 if ( localMod == remoteMod )
2437 return 0; 2487 return 0;
2438 2488
2439 } 2489 }
2440 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2490 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2441 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2491 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2442 //full = true; //debug only 2492 //full = true; //debug only
2443 if ( full ) { 2493 if ( full ) {
2444 bool equ = ( (*local) == (*remote) ); 2494 bool equ = ( (*local) == (*remote) );
2445 if ( equ ) { 2495 if ( equ ) {
2446 //qDebug("equal "); 2496 //qDebug("equal ");
2447 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2497 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2448 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2498 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2449 } 2499 }
2450 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2500 if ( mode < SYNC_PREF_FORCE_LOCAL )
2451 return 0; 2501 return 0;
2452 2502
2453 }//else //debug only 2503 }//else //debug only
2454 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2504 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2455 } 2505 }
2456 int result; 2506 int result;
2457 bool localIsNew; 2507 bool localIsNew;
2458 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2508 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2459 2509
2460 if ( full && mode < SYNC_PREF_NEWEST ) 2510 if ( full && mode < SYNC_PREF_NEWEST )
2461 mode = SYNC_PREF_ASK; 2511 mode = SYNC_PREF_ASK;
2462 2512
2463 switch( mode ) { 2513 switch( mode ) {
2464 case SYNC_PREF_LOCAL: 2514 case SYNC_PREF_LOCAL:
2465 if ( lastSync > remoteMod ) 2515 if ( lastSync > remoteMod )
2466 return 1; 2516 return 1;
2467 if ( lastSync > localMod ) 2517 if ( lastSync > localMod )
2468 return 2; 2518 return 2;
2469 return 1; 2519 return 1;
2470 break; 2520 break;
2471 case SYNC_PREF_REMOTE: 2521 case SYNC_PREF_REMOTE:
2472 if ( lastSync > remoteMod ) 2522 if ( lastSync > remoteMod )
2473 return 1; 2523 return 1;
2474 if ( lastSync > localMod ) 2524 if ( lastSync > localMod )
2475 return 2; 2525 return 2;
2476 return 2; 2526 return 2;
2477 break; 2527 break;
2478 case SYNC_PREF_NEWEST: 2528 case SYNC_PREF_NEWEST:
2479 if ( localMod > remoteMod ) 2529 if ( localMod > remoteMod )
2480 return 1; 2530 return 1;
2481 else 2531 else
2482 return 2; 2532 return 2;
2483 break; 2533 break;
2484 case SYNC_PREF_ASK: 2534 case SYNC_PREF_ASK:
2485 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2535 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2486 if ( lastSync > remoteMod ) 2536 if ( lastSync > remoteMod )
2487 return 1; 2537 return 1;
2488 if ( lastSync > localMod ) 2538 if ( lastSync > localMod )
2489 return 2; 2539 return 2;
2490 localIsNew = localMod >= remoteMod; 2540 localIsNew = localMod >= remoteMod;
2491 //qDebug("conflict! ************************************** "); 2541 //qDebug("conflict! ************************************** ");
2492 { 2542 {
2493 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2543 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2494 result = acd.executeD(localIsNew); 2544 result = acd.executeD(localIsNew);
2495 return result; 2545 return result;
2496 } 2546 }
2497 break; 2547 break;
2498 case SYNC_PREF_FORCE_LOCAL: 2548 case SYNC_PREF_FORCE_LOCAL:
2499 return 1; 2549 return 1;
2500 break; 2550 break;
2501 case SYNC_PREF_FORCE_REMOTE: 2551 case SYNC_PREF_FORCE_REMOTE:
2502 return 2; 2552 return 2;
2503 break; 2553 break;
2504 2554
2505 default: 2555 default:
2506 // SYNC_PREF_TAKE_BOTH not implemented 2556 // SYNC_PREF_TAKE_BOTH not implemented
2507 break; 2557 break;
2508 } 2558 }
2509 return 0; 2559 return 0;
2510} 2560}
2511 2561
2512 2562
2513bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2563bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2514{ 2564{
2515 bool syncOK = true; 2565 bool syncOK = true;
2516 int addedAddressee = 0; 2566 int addedAddressee = 0;
2517 int addedAddresseeR = 0; 2567 int addedAddresseeR = 0;
2518 int deletedAddresseeR = 0; 2568 int deletedAddresseeR = 0;
2519 int deletedAddresseeL = 0; 2569 int deletedAddresseeL = 0;
2520 int changedLocal = 0; 2570 int changedLocal = 0;
2521 int changedRemote = 0; 2571 int changedRemote = 0;
2522 2572
2523 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2573 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2524 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2574 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2525 2575
2526 //QPtrList<Addressee> el = local->rawAddressees(); 2576 //QPtrList<Addressee> el = local->rawAddressees();
2527 Addressee addresseeR; 2577 Addressee addresseeR;
2528 QString uid; 2578 QString uid;
2529 int take; 2579 int take;
2530 Addressee addresseeL; 2580 Addressee addresseeL;
2531 Addressee addresseeRSync; 2581 Addressee addresseeRSync;
2532 Addressee addresseeLSync; 2582 Addressee addresseeLSync;
2533 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2583 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2534 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2584 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2535 bool fullDateRange = false; 2585 bool fullDateRange = false;
2536 local->resetTempSyncStat(); 2586 local->resetTempSyncStat();
2537 mLastAddressbookSync = QDateTime::currentDateTime(); 2587 mLastAddressbookSync = QDateTime::currentDateTime();
2538 if ( syncManager->syncWithDesktop() ) { 2588 if ( syncManager->syncWithDesktop() ) {
2539 // remote->removeSyncInfo( QString());//remove all info 2589 // remote->removeSyncInfo( QString());//remove all info
2540 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2590 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2541 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2591 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2542 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2592 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2543 } else { 2593 } else {
2544 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2594 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2545 } 2595 }
2546 } 2596 }
2547 QDateTime modifiedCalendar = mLastAddressbookSync; 2597 QDateTime modifiedCalendar = mLastAddressbookSync;
2548 addresseeLSync = getLastSyncAddressee(); 2598 addresseeLSync = getLastSyncAddressee();
2549 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2599 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2550 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2600 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2551 if ( !addresseeR.isEmpty() ) { 2601 if ( !addresseeR.isEmpty() ) {
2552 addresseeRSync = addresseeR; 2602 addresseeRSync = addresseeR;
2553 remote->removeAddressee(addresseeR ); 2603 remote->removeAddressee(addresseeR );
2554 2604
2555 } else { 2605 } else {
2556 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2606 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2557 addresseeRSync = addresseeLSync ; 2607 addresseeRSync = addresseeLSync ;
2558 } else { 2608 } else {
2559 //qDebug("FULLDATE 1"); 2609 //qDebug("FULLDATE 1");
2560 fullDateRange = true; 2610 fullDateRange = true;
2561 Addressee newAdd; 2611 Addressee newAdd;
2562 addresseeRSync = newAdd; 2612 addresseeRSync = newAdd;
2563 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2613 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2564 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2614 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2565 addresseeRSync.setRevision( mLastAddressbookSync ); 2615 addresseeRSync.setRevision( mLastAddressbookSync );
2566 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2616 addresseeRSync.setCategories( i18n("SyncAddressee") );
2567 } 2617 }
2568 } 2618 }
2569 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2619 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2570 // qDebug("FULLDATE 2"); 2620 // qDebug("FULLDATE 2");
2571 fullDateRange = true; 2621 fullDateRange = true;
2572 } 2622 }
2573 if ( ! fullDateRange ) { 2623 if ( ! fullDateRange ) {
2574 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2624 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2575 2625
2576 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2626 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2577 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2627 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2578 fullDateRange = true; 2628 fullDateRange = true;
2579 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2629 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2580 } 2630 }
2581 } 2631 }
2582 // fullDateRange = true; // debug only! 2632 // fullDateRange = true; // debug only!
2583 if ( fullDateRange ) 2633 if ( fullDateRange )
2584 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2634 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2585 else 2635 else
2586 mLastAddressbookSync = addresseeLSync.revision(); 2636 mLastAddressbookSync = addresseeLSync.revision();
2587 // for resyncing if own file has changed 2637 // for resyncing if own file has changed
2588 // PENDING fixme later when implemented 2638 // PENDING fixme later when implemented
2589#if 0 2639#if 0
2590 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2640 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2591 mLastAddressbookSync = loadedFileVersion; 2641 mLastAddressbookSync = loadedFileVersion;
2592 qDebug("setting mLastAddressbookSync "); 2642 qDebug("setting mLastAddressbookSync ");
2593 } 2643 }
2594#endif 2644#endif
2595 2645
2596 //qDebug("*************************** "); 2646 //qDebug("*************************** ");
2597 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2647 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2598 QStringList er = remote->uidList(); 2648 QStringList er = remote->uidList();
2599 Addressee inR ;//= er.first(); 2649 Addressee inR ;//= er.first();
2600 Addressee inL; 2650 Addressee inL;
2601 2651
2602 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2652 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2603 2653
2604 int modulo = (er.count()/10)+1; 2654 int modulo = (er.count()/10)+1;
2605 int incCounter = 0; 2655 int incCounter = 0;
2606 while ( incCounter < er.count()) { 2656 while ( incCounter < er.count()) {
2607 if (syncManager->isProgressBarCanceled()) 2657 if (syncManager->isProgressBarCanceled())
2608 return false; 2658 return false;
2609 if ( incCounter % modulo == 0 ) 2659 if ( incCounter % modulo == 0 )
2610 syncManager->showProgressBar(incCounter); 2660 syncManager->showProgressBar(incCounter);
2611 2661
2612 uid = er[ incCounter ]; 2662 uid = er[ incCounter ];
2613 bool skipIncidence = false; 2663 bool skipIncidence = false;
2614 if ( uid.left(19) == QString("last-syncAddressee-") ) 2664 if ( uid.left(19) == QString("last-syncAddressee-") )
2615 skipIncidence = true; 2665 skipIncidence = true;
2616 QString idS,OidS; 2666 QString idS,OidS;
2617 qApp->processEvents(); 2667 qApp->processEvents();
2618 if ( !skipIncidence ) { 2668 if ( !skipIncidence ) {
2619 inL = local->findByUid( uid ); 2669 inL = local->findByUid( uid );
2620 inR = remote->findByUid( uid ); 2670 inR = remote->findByUid( uid );
2621 //inL.setResource( 0 ); 2671 //inL.setResource( 0 );
2622 //inR.setResource( 0 ); 2672 //inR.setResource( 0 );
2623 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2673 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2624 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2674 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2625 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2675 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2626 //qDebug("take %d %s ", take, inL.summary().latin1()); 2676 //qDebug("take %d %s ", take, inL.summary().latin1());
2627 if ( take == 3 ) 2677 if ( take == 3 )
2628 return false; 2678 return false;
2629 if ( take == 1 ) {// take local ********************** 2679 if ( take == 1 ) {// take local **********************
2630 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2680 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2631 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2681 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2632 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2682 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2633 local->insertAddressee( inL, false ); 2683 local->insertAddressee( inL, false );
2634 idS = inR.externalUID(); 2684 idS = inR.externalUID();
2635 OidS = inR.originalExternalUID(); 2685 OidS = inR.originalExternalUID();
2636 } 2686 }
2637 else 2687 else
2638 idS = inR.IDStr(); 2688 idS = inR.IDStr();
2639 remote->removeAddressee( inR ); 2689 remote->removeAddressee( inR );
2640 inR = inL; 2690 inR = inL;
2641 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2691 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2642 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2692 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2643 inR.setOriginalExternalUID( OidS ); 2693 inR.setOriginalExternalUID( OidS );
2644 inR.setExternalUID( idS ); 2694 inR.setExternalUID( idS );
2645 if ( syncManager->syncWithDesktop() ) { 2695 if ( syncManager->syncWithDesktop() ) {
2646 inR.setIDStr("changed" ); 2696 inR.setIDStr("changed" );
2647 } 2697 }
2648 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2698 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2649 } else { 2699 } else {
2650 inR.setIDStr( idS ); 2700 inR.setIDStr( idS );
2651 } 2701 }
2652 inR.setResource( 0 ); 2702 inR.setResource( 0 );
2653 remote->insertAddressee( inR , false); 2703 remote->insertAddressee( inR , false);
2654 ++changedRemote; 2704 ++changedRemote;
2655 } else { // take == 2 take remote ********************** 2705 } else { // take == 2 take remote **********************
2656 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2706 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2657 if ( inR.revision().date().year() < 2004 ) 2707 if ( inR.revision().date().year() < 2004 )
2658 inR.setRevision( modifiedCalendar ); 2708 inR.setRevision( modifiedCalendar );
2659 } 2709 }
2660 idS = inL.IDStr(); 2710 idS = inL.IDStr();
2661 local->removeAddressee( inL ); 2711 local->removeAddressee( inL );
2662 inL = inR; 2712 inL = inR;
2663 inL.setIDStr( idS ); 2713 inL.setIDStr( idS );
2664 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2714 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2665 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2715 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2666 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2716 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2667 } 2717 }
2668 inL.setResource( 0 ); 2718 inL.setResource( 0 );
2669 local->insertAddressee( inL , false ); 2719 local->insertAddressee( inL , false );
2670 ++changedLocal; 2720 ++changedLocal;
2671 } 2721 }
2672 } 2722 }
2673 } 2723 }
2674 } else { // no conflict ********** add or delete remote 2724 } else { // no conflict ********** add or delete remote
2675 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2725 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2676 QString des = addresseeLSync.note(); 2726 QString des = addresseeLSync.note();
2677 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2727 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2678 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2728 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2679 remote->insertAddressee( inR, false ); 2729 remote->insertAddressee( inR, false );
2680 ++deletedAddresseeR; 2730 ++deletedAddresseeR;
2681 } else { 2731 } else {
2682 inR.setRevision( modifiedCalendar ); 2732 inR.setRevision( modifiedCalendar );
2683 remote->insertAddressee( inR, false ); 2733 remote->insertAddressee( inR, false );
2684 inL = inR; 2734 inL = inR;
2685 inL.setIDStr( ":" ); 2735 inL.setIDStr( ":" );
2686 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2736 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2687 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2737 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2688 inL.setResource( 0 ); 2738 inL.setResource( 0 );
2689 local->insertAddressee( inL , false); 2739 local->insertAddressee( inL , false);
2690 ++addedAddressee; 2740 ++addedAddressee;
2691 } 2741 }
2692 } else { 2742 } else {
2693 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2743 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2694 inR.setRevision( modifiedCalendar ); 2744 inR.setRevision( modifiedCalendar );
2695 remote->insertAddressee( inR, false ); 2745 remote->insertAddressee( inR, false );
2696 inR.setResource( 0 ); 2746 inR.setResource( 0 );
2697 local->insertAddressee( inR, false ); 2747 local->insertAddressee( inR, false );
2698 ++addedAddressee; 2748 ++addedAddressee;
2699 } else { 2749 } else {
2700 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2750 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2701 remote->removeAddressee( inR ); 2751 remote->removeAddressee( inR );
2702 ++deletedAddresseeR; 2752 ++deletedAddresseeR;
2703 } 2753 }
2704 } 2754 }
2705 } 2755 }
2706 } 2756 }
2707 ++incCounter; 2757 ++incCounter;
2708 } 2758 }
2709 er.clear(); 2759 er.clear();
2710 QStringList el = local->uidList(); 2760 QStringList el = local->uidList();
2711 modulo = (el.count()/10)+1; 2761 modulo = (el.count()/10)+1;
2712 2762
2713 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2763 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2714 incCounter = 0; 2764 incCounter = 0;
2715 while ( incCounter < el.count()) { 2765 while ( incCounter < el.count()) {
2716 qApp->processEvents(); 2766 qApp->processEvents();
2717 if (syncManager->isProgressBarCanceled()) 2767 if (syncManager->isProgressBarCanceled())
2718 return false; 2768 return false;
2719 if ( incCounter % modulo == 0 ) 2769 if ( incCounter % modulo == 0 )
2720 syncManager->showProgressBar(incCounter); 2770 syncManager->showProgressBar(incCounter);
2721 uid = el[ incCounter ]; 2771 uid = el[ incCounter ];
2722 bool skipIncidence = false; 2772 bool skipIncidence = false;
2723 if ( uid.left(19) == QString("last-syncAddressee-") ) 2773 if ( uid.left(19) == QString("last-syncAddressee-") )
2724 skipIncidence = true; 2774 skipIncidence = true;
2725 if ( !skipIncidence ) { 2775 if ( !skipIncidence ) {
2726 inL = local->findByUid( uid ); 2776 inL = local->findByUid( uid );
2727 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2777 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2728 inR = remote->findByUid( uid ); 2778 inR = remote->findByUid( uid );
2729 if ( inR.isEmpty() ) { // no conflict ********** add or delete local 2779 if ( inR.isEmpty() ) { // no conflict ********** add or delete local
2730 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2780 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2731 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2781 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2732 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2782 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2733 local->removeAddressee( inL ); 2783 local->removeAddressee( inL );
2734 ++deletedAddresseeL; 2784 ++deletedAddresseeL;
2735 } else { 2785 } else {
2736 if ( ! syncManager->mWriteBackExistingOnly ) { 2786 if ( ! syncManager->mWriteBackExistingOnly ) {
2737 inL.removeID(mCurrentSyncDevice ); 2787 inL.removeID(mCurrentSyncDevice );
2738 ++addedAddresseeR; 2788 ++addedAddresseeR;
2739 inL.setRevision( modifiedCalendar ); 2789 inL.setRevision( modifiedCalendar );
2740 local->insertAddressee( inL, false ); 2790 local->insertAddressee( inL, false );
2741 inR = inL; 2791 inR = inL;
2742 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2792 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2743 inR.setResource( 0 ); 2793 inR.setResource( 0 );
2744 remote->insertAddressee( inR, false ); 2794 remote->insertAddressee( inR, false );
2745 } 2795 }
2746 } 2796 }
2747 } else { 2797 } else {
2748 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2798 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2749 //qDebug("data %s ", inL.revision().toString().latin1()); 2799 //qDebug("data %s ", inL.revision().toString().latin1());
2750 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2800 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2751 local->removeAddressee( inL ); 2801 local->removeAddressee( inL );
2752 ++deletedAddresseeL; 2802 ++deletedAddresseeL;
2753 } else { 2803 } else {
2754 if ( ! syncManager->mWriteBackExistingOnly ) { 2804 if ( ! syncManager->mWriteBackExistingOnly ) {
2755 ++addedAddresseeR; 2805 ++addedAddresseeR;
2756 inL.setRevision( modifiedCalendar ); 2806 inL.setRevision( modifiedCalendar );
2757 local->insertAddressee( inL, false ); 2807 local->insertAddressee( inL, false );
2758 inR = inL; 2808 inR = inL;
2759 inR.setIDStr( ":" ); 2809 inR.setIDStr( ":" );
2760 inR.setResource( 0 ); 2810 inR.setResource( 0 );
2761 remote->insertAddressee( inR, false ); 2811 remote->insertAddressee( inR, false );
2762 } 2812 }
2763 } 2813 }
2764 } 2814 }
2765 } 2815 }
2766 } 2816 }
2767 } 2817 }
2768 ++incCounter; 2818 ++incCounter;
2769 } 2819 }
2770 el.clear(); 2820 el.clear();
2771 syncManager->hideProgressBar(); 2821 syncManager->hideProgressBar();
2772 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2822 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2773 // get rid of micro seconds 2823 // get rid of micro seconds
2774 QTime t = mLastAddressbookSync.time(); 2824 QTime t = mLastAddressbookSync.time();
2775 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2825 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2776 addresseeLSync.setRevision( mLastAddressbookSync ); 2826 addresseeLSync.setRevision( mLastAddressbookSync );
2777 addresseeRSync.setRevision( mLastAddressbookSync ); 2827 addresseeRSync.setRevision( mLastAddressbookSync );
2778 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2828 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2779 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2829 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2780 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2830 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2781 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2831 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2782 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2832 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2783 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2833 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2784 addresseeRSync.setNote( "" ) ; 2834 addresseeRSync.setNote( "" ) ;
2785 addresseeLSync.setNote( "" ); 2835 addresseeLSync.setNote( "" );
2786 2836
2787 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2837 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2788 remote->insertAddressee( addresseeRSync, false ); 2838 remote->insertAddressee( addresseeRSync, false );
2789 local->insertAddressee( addresseeLSync, false ); 2839 local->insertAddressee( addresseeLSync, false );
2790 QString mes; 2840 QString mes;
2791 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2841 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2792 qDebug( mes ); 2842 qDebug( mes );
2793 mes = i18n("Local addressbook changed!\n") +mes; 2843 mes = i18n("Local addressbook changed!\n") +mes;
2794 if ( syncManager->mShowSyncSummary ) { 2844 if ( syncManager->mShowSyncSummary ) {
2795 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 2845 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
2796 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 2846 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
2797 qDebug("cancelled "); 2847 qDebug("cancelled ");
2798 return false; 2848 return false;
2799 } 2849 }
2800 } 2850 }
2801 return syncOK; 2851 return syncOK;
2802} 2852}
2803 2853
2804 2854
2805//this is a overwritten callbackmethods from the syncinterface 2855//this is a overwritten callbackmethods from the syncinterface
2806bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2856bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2807{ 2857{
2808 2858
2809 //pending prepare addresseeview for output 2859 //pending prepare addresseeview for output
2810 //pending detect, if remote file has REV field. if not switch to external sync 2860 //pending detect, if remote file has REV field. if not switch to external sync
2811 mGlobalSyncMode = SYNC_MODE_NORMAL; 2861 mGlobalSyncMode = SYNC_MODE_NORMAL;
2812 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2862 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2813 2863
2814 AddressBook abLocal(filename,"syncContact"); 2864 AddressBook abLocal(filename,"syncContact");
2815 bool syncOK = false; 2865 bool syncOK = false;
2816 if ( abLocal.load() ) { 2866 if ( abLocal.load() ) {
2817 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2867 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2818 bool external = false; 2868 bool external = false;
2819 bool isXML = false; 2869 bool isXML = false;
2820 if ( filename.right(4) == ".xml") { 2870 if ( filename.right(4) == ".xml") {
2821 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2871 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2822 isXML = true; 2872 isXML = true;
2823 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2873 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2824 } else { 2874 } else {
2825 external = !manager->mIsKapiFile; 2875 external = !manager->mIsKapiFile;
2826 if ( external ) { 2876 if ( external ) {
2827 qDebug("Setting vcf mode to external "); 2877 qDebug("Setting vcf mode to external ");
2828 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2878 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2829 AddressBook::Iterator it; 2879 AddressBook::Iterator it;
2830 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2880 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2831 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2881 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2832 (*it).computeCsum( mCurrentSyncDevice ); 2882 (*it).computeCsum( mCurrentSyncDevice );
2833 } 2883 }
2834 } 2884 }
2835 } 2885 }
2836 //AddressBook::Iterator it; 2886 //AddressBook::Iterator it;
2837 //QStringList vcards; 2887 //QStringList vcards;
2838 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2888 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2839 // qDebug("Name %s ", (*it).familyName().latin1()); 2889 // qDebug("Name %s ", (*it).familyName().latin1());
2840 //} 2890 //}
2841 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2891 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2842 if ( syncOK ) { 2892 if ( syncOK ) {
2843 if ( syncManager->mWriteBackFile ) 2893 if ( syncManager->mWriteBackFile )
2844 { 2894 {
2845 if ( external ) 2895 if ( external )
2846 abLocal.removeSyncAddressees( !isXML); 2896 abLocal.removeSyncAddressees( !isXML);
2847 qDebug("Saving remote AB "); 2897 qDebug("Saving remote AB ");
2848 if ( ! abLocal.saveAB()) 2898 if ( ! abLocal.saveAB())
2849 qDebug("Error writing back AB to file "); 2899 qDebug("Error writing back AB to file ");
2850 if ( external ) { 2900 if ( external ) {
2851 // afterwrite processing 2901 // afterwrite processing
2852 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 2902 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
2853 } 2903 }
2854 } 2904 }
2855 } 2905 }
2856 setModified(); 2906 setModified();
2857 2907
2858 } 2908 }
2859 abLocal.removeResources(); 2909 abLocal.removeResources();
2860 if ( syncOK ) 2910 if ( syncOK )
2861 mViewManager->refreshView(); 2911 mViewManager->refreshView();
2862 return syncOK; 2912 return syncOK;
2863 2913
2864} 2914}
2865void KABCore::removeSyncInfo( QString syncProfile) 2915void KABCore::removeSyncInfo( QString syncProfile)
2866{ 2916{
2867 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 2917 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
2868 mAddressBook->removeSyncInfo( syncProfile ); 2918 mAddressBook->removeSyncInfo( syncProfile );
2869 setModified(); 2919 setModified();
2870} 2920}
2871 2921
2872 2922
2873//this is a overwritten callbackmethods from the syncinterface 2923//this is a overwritten callbackmethods from the syncinterface
2874bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2924bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2875{ 2925{
2876 if ( resource == "phone" ) 2926 if ( resource == "phone" )
2877 return syncPhone(); 2927 return syncPhone();
2878 disableBR( true ); 2928 disableBR( true );
2879 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2929 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2880 2930
2881 AddressBook abLocal( resource,"syncContact"); 2931 AddressBook abLocal( resource,"syncContact");
2882 bool syncOK = false; 2932 bool syncOK = false;
2883 if ( abLocal.load() ) { 2933 if ( abLocal.load() ) {
2884 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2934 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2885 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2935 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2886 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 2936 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
2887 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2937 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2888 if ( syncOK ) { 2938 if ( syncOK ) {
2889 if ( syncManager->mWriteBackFile ) { 2939 if ( syncManager->mWriteBackFile ) {
2890 abLocal.removeSyncAddressees( false ); 2940 abLocal.removeSyncAddressees( false );
2891 abLocal.saveAB(); 2941 abLocal.saveAB();
2892 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 2942 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
2893 } 2943 }
2894 } else 2944 } else
2895 message( i18n("Sync cancelled or failed.") ); 2945 message( i18n("Sync cancelled or failed.") );
2896 setModified(); 2946 setModified();
2897 } 2947 }
2898 abLocal.removeResources(); 2948 abLocal.removeResources();
2899 if ( syncOK ) 2949 if ( syncOK )
2900 mViewManager->refreshView(); 2950 mViewManager->refreshView();
2901 disableBR( false ); 2951 disableBR( false );
2902 return syncOK; 2952 return syncOK;
2903 2953
2904} 2954}
2905void KABCore::message( QString m ) 2955void KABCore::message( QString m )
2906{ 2956{
2907 topLevelWidget()->setCaption( m ); 2957 topLevelWidget()->setCaption( m );
2908 mMessageTimer->start( 15000, true ); 2958 mMessageTimer->start( 15000, true );
2909} 2959}
2910bool KABCore::syncPhone() 2960bool KABCore::syncPhone()
2911{ 2961{
2912 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2962 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2913 QString fileName = getPhoneFile(); 2963 QString fileName = getPhoneFile();
2914 if ( !PhoneAccess::readFromPhone( fileName) ) { 2964 if ( !PhoneAccess::readFromPhone( fileName) ) {
2915 message(i18n("Phone access failed!")); 2965 message(i18n("Phone access failed!"));
2916 return false; 2966 return false;
2917 } 2967 }
2918 AddressBook abLocal( fileName,"syncContact"); 2968 AddressBook abLocal( fileName,"syncContact");
2919 bool syncOK = false; 2969 bool syncOK = false;
2920 { 2970 {
2921 abLocal.importFromFile( fileName ); 2971 abLocal.importFromFile( fileName );
2922 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2972 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
2923 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2973 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2924 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 2974 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
2925 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2975 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2926 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2976 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2927 if ( syncOK ) { 2977 if ( syncOK ) {
2928 if ( syncManager->mWriteBackFile ) { 2978 if ( syncManager->mWriteBackFile ) {
2929 abLocal.removeSyncAddressees( true ); 2979 abLocal.removeSyncAddressees( true );
2930 abLocal.saveABphone( fileName ); 2980 abLocal.saveABphone( fileName );
2931 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 2981 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
2932 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 2982 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
2933 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 2983 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
2934 } 2984 }
2935 } 2985 }
2936 setModified(); 2986 setModified();
2937 } 2987 }
2938 abLocal.removeResources(); 2988 abLocal.removeResources();
2939 if ( syncOK ) 2989 if ( syncOK )
2940 mViewManager->refreshView(); 2990 mViewManager->refreshView();
2941 return syncOK; 2991 return syncOK;
2942} 2992}
2943void KABCore::getFile( bool success ) 2993void KABCore::getFile( bool success )
2944{ 2994{
2945 if ( ! success ) { 2995 if ( ! success ) {
2946 message( i18n("Error receiving file. Nothing changed!") ); 2996 message( i18n("Error receiving file. Nothing changed!") );
2947 return; 2997 return;
2948 } 2998 }
2949 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 2999 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
2950 if ( count ) 3000 if ( count )
2951 setModified( true ); 3001 setModified( true );
2952 message( i18n("Pi-Sync successful!") ); 3002 message( i18n("Pi-Sync successful!") );
2953 mViewManager->refreshView(); 3003 mViewManager->refreshView();
2954} 3004}
2955void KABCore::syncFileRequest() 3005void KABCore::syncFileRequest()
2956{ 3006{
2957 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3007 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
2958 syncManager->slotSyncMenu( 999 ); 3008 syncManager->slotSyncMenu( 999 );
2959 } 3009 }
2960 mAddressBook->export2File( sentSyncFile() ); 3010 mAddressBook->export2File( sentSyncFile() );
2961} 3011}
2962QString KABCore::sentSyncFile() 3012QString KABCore::sentSyncFile()
2963{ 3013{
2964#ifdef DESKTOP_VERSION 3014#ifdef DESKTOP_VERSION
2965 return locateLocal( "tmp", "copysyncab.vcf" ); 3015 return locateLocal( "tmp", "copysyncab.vcf" );
2966#else 3016#else
2967 return QString( "/tmp/copysyncab.vcf" ); 3017 return QString( "/tmp/copysyncab.vcf" );
2968#endif 3018#endif
2969} 3019}
2970 3020
2971void KABCore::setCaptionBack() 3021void KABCore::setCaptionBack()
2972{ 3022{
2973 mMessageTimer->stop(); 3023 mMessageTimer->stop();
2974 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3024 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2975} 3025}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index c01d598..1bdae5f 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,508 +1,513 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCORE_H 24#ifndef KABCORE_H
25#define KABCORE_H 25#define KABCORE_H
26 26
27#include <kabc/field.h> 27#include <kabc/field.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31#include <qdict.h> 31#include <qdict.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34#include <qwidget.h> 34#include <qwidget.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <ksyncmanager.h> 36#include <ksyncmanager.h>
37#ifndef DESKTOP_VERSION 37#ifndef DESKTOP_VERSION
38#include <qcopchannel_qws.h> 38#include <qcopchannel_qws.h>
39#endif 39#endif
40 40
41namespace KABC { 41namespace KABC {
42class AddressBook; 42class AddressBook;
43} 43}
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46class KAboutData; 46class KAboutData;
47class KConfig; 47class KConfig;
48 48
49class KAddressBookService; 49class KAddressBookService;
50class LDAPSearchDialog; 50class LDAPSearchDialog;
51#else //KAB_EMBEDDED 51#else //KAB_EMBEDDED
52class KAddressBookMain; 52class KAddressBookMain;
53//US class QAction; 53//US class QAction;
54#endif //KAB_EMBEDDED 54#endif //KAB_EMBEDDED
55class KCMultiDialog; 55class KCMultiDialog;
56class KXMLGUIClient; 56class KXMLGUIClient;
57class ExtensionManager; 57class ExtensionManager;
58class XXPortManager; 58class XXPortManager;
59class JumpButtonBar; 59class JumpButtonBar;
60class IncSearchWidget; 60class IncSearchWidget;
61class KDGanttMinimizeSplitter; 61class KDGanttMinimizeSplitter;
62class KAction; 62class KAction;
63class KActionCollection; 63class KActionCollection;
64class KToggleAction; 64class KToggleAction;
65class KSyncProfile; 65class KSyncProfile;
66 66
67class QAction; 67class QAction;
68class QMenuBar; 68class QMenuBar;
69class QSplitter; 69class QSplitter;
70class ViewContainer; 70class ViewContainer;
71class ViewManager; 71class ViewManager;
72class AddresseeEditorDialog; 72class AddresseeEditorDialog;
73class Ir; 73class Ir;
74 74
75class KABCore : public QWidget, public KSyncInterface 75class KABCore : public QWidget, public KSyncInterface
76{ 76{
77 Q_OBJECT 77 Q_OBJECT
78 78
79 public: 79 public:
80 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 80 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
81 81
82 82
83 ~KABCore(); 83 ~KABCore();
84 84
85 85
86#ifdef KAB_EMBEDDED 86#ifdef KAB_EMBEDDED
87 //US added functionality 87 //US added functionality
88 QPopupMenu* getViewMenu() {return viewMenu;} 88 QPopupMenu* getViewMenu() {return viewMenu;}
89 QPopupMenu* getFilterMenu() {return filterMenu;} 89 QPopupMenu* getFilterMenu() {return filterMenu;}
90 QPopupMenu* getSettingsMenu() {return settingsMenu;} 90 QPopupMenu* getSettingsMenu() {return settingsMenu;}
91 void addActionsManually(); 91 void addActionsManually();
92#endif //KAB_EMBEDDED 92#endif //KAB_EMBEDDED
93 /** 93 /**
94 Restores the global settings. 94 Restores the global settings.
95 */ 95 */
96 void restoreSettings(); 96 void restoreSettings();
97 97
98 /** 98 /**
99 Saves the global settings. 99 Saves the global settings.
100 */ 100 */
101 void saveSettings(); 101 void saveSettings();
102 102
103 /** 103 /**
104 Returns a pointer to the StdAddressBook of the application. 104 Returns a pointer to the StdAddressBook of the application.
105 */ 105 */
106 KABC::AddressBook *addressBook() const; 106 KABC::AddressBook *addressBook() const;
107 107
108 /** 108 /**
109 Returns a pointer to the KConfig object of the application. 109 Returns a pointer to the KConfig object of the application.
110 */ 110 */
111 static KConfig *config(); 111 static KConfig *config();
112 112
113 /** 113 /**
114 Returns a pointer to the global KActionCollection object. So 114 Returns a pointer to the global KActionCollection object. So
115 other classes can register their actions easily. 115 other classes can register their actions easily.
116 */ 116 */
117 KActionCollection *actionCollection() const; 117 KActionCollection *actionCollection() const;
118 118
119 /** 119 /**
120 Returns the current search field of the Incremental Search Widget. 120 Returns the current search field of the Incremental Search Widget.
121 */ 121 */
122 KABC::Field *currentSearchField() const; 122 KABC::Field *currentSearchField() const;
123 123
124 /** 124 /**
125 Returns the uid list of the currently selected contacts. 125 Returns the uid list of the currently selected contacts.
126 */ 126 */
127 QStringList selectedUIDs() const; 127 QStringList selectedUIDs() const;
128 128
129 /** 129 /**
130 Displays the ResourceSelectDialog and returns the selected 130 Displays the ResourceSelectDialog and returns the selected
131 resource or a null pointer if no resource was selected by 131 resource or a null pointer if no resource was selected by
132 the user. 132 the user.
133 */ 133 */
134 KABC::Resource *requestResource( QWidget *parent ); 134 KABC::Resource *requestResource( QWidget *parent );
135 135
136#ifndef KAB_EMBEDDED 136#ifndef KAB_EMBEDDED
137 static KAboutData *createAboutData(); 137 static KAboutData *createAboutData();
138#endif //KAB_EMBEDDED 138#endif //KAB_EMBEDDED
139 139
140#ifdef KAB_EMBEDDED 140#ifdef KAB_EMBEDDED
141 inline QPopupMenu* getImportMenu() { return ImportMenu;} 141 inline QPopupMenu* getImportMenu() { return ImportMenu;}
142 inline QPopupMenu* getExportMenu() { return ExportMenu;} 142 inline QPopupMenu* getExportMenu() { return ExportMenu;}
143#endif //KAB_EMBEDDED 143#endif //KAB_EMBEDDED
144 144
145 public slots: 145 public slots:
146#ifdef KAB_EMBEDDED 146#ifdef KAB_EMBEDDED
147 void createAboutData(); 147 void createAboutData();
148#endif //KAB_EMBEDDED 148#endif //KAB_EMBEDDED
149 void setDetailsToggle(); 149 void setDetailsToggle();
150 150
151 void showLicence(); 151 void showLicence();
152 void faq(); 152 void faq();
153 void whatsnew() ; 153 void whatsnew() ;
154 void synchowto() ; 154 void synchowto() ;
155 void multisynchowto() ; 155 void multisynchowto() ;
156 void kdesynchowto() ; 156 void kdesynchowto() ;
157 void writeToPhone(); 157 void writeToPhone();
158 158
159 /** 159 /**
160 Is called whenever a contact is selected in the view. 160 Is called whenever a contact is selected in the view.
161 */ 161 */
162 void setContactSelected( const QString &uid ); 162 void setContactSelected( const QString &uid );
163 163
164 /** 164 /**
165 Opens the preferred mail composer with all selected contacts as 165 Opens the preferred mail composer with all selected contacts as
166 arguments. 166 arguments.
167 */ 167 */
168 void sendMail(); 168 void sendMail();
169 169
170 /** 170 /**
171 Opens the preferred mail composer with the given contacts as 171 Opens the preferred mail composer with the given contacts as
172 arguments. 172 arguments.
173 */ 173 */
174 void sendMail( const QString& email ); 174 void sendMail( const QString& email );
175 175
176 176
177 void mailVCard(); 177 void mailVCard();
178 void mailVCard(const QStringList& uids); 178 void mailVCard(const QStringList& uids);
179 179
180 /** 180 /**
181 Beams the "WhoAmI contact. 181 Beams the "WhoAmI contact.
182 */ 182 */
183 void beamMySelf(); 183 void beamMySelf();
184 184
185 void beamVCard(); 185 void beamVCard();
186 void export2phone(); 186 void export2phone();
187 void beamVCard(const QStringList& uids); 187 void beamVCard(const QStringList& uids);
188 void beamDone( Ir *ir ); 188 void beamDone( Ir *ir );
189 189
190 190
191 /** 191 /**
192 Starts the preferred web browser with the given URL as argument. 192 Starts the preferred web browser with the given URL as argument.
193 */ 193 */
194 void browse( const QString& url ); 194 void browse( const QString& url );
195 195
196 /** 196 /**
197 Select all contacts in the view. 197 Select all contacts in the view.
198 */ 198 */
199 void selectAllContacts(); 199 void selectAllContacts();
200 200
201 /** 201 /**
202 Deletes all selected contacts from the address book. 202 Deletes all selected contacts from the address book.
203 */ 203 */
204 void deleteContacts(); 204 void deleteContacts();
205 205
206 /** 206 /**
207 Deletes given contacts from the address book. 207 Deletes given contacts from the address book.
208 208
209 @param uids The uids of the contacts, which shall be deleted. 209 @param uids The uids of the contacts, which shall be deleted.
210 */ 210 */
211 void deleteContacts( const QStringList &uids ); 211 void deleteContacts( const QStringList &uids );
212 212
213 /** 213 /**
214 Copys the selected contacts into clipboard for later pasting. 214 Copys the selected contacts into clipboard for later pasting.
215 */ 215 */
216 void copyContacts(); 216 void copyContacts();
217 217
218 /** 218 /**
219 Cuts the selected contacts and stores them for later pasting. 219 Cuts the selected contacts and stores them for later pasting.
220 */ 220 */
221 void cutContacts(); 221 void cutContacts();
222 222
223 /** 223 /**
224 Paste contacts from clipboard into the address book. 224 Paste contacts from clipboard into the address book.
225 */ 225 */
226 void pasteContacts(); 226 void pasteContacts();
227 227
228 /** 228 /**
229 Paste given contacts into the address book. 229 Paste given contacts into the address book.
230 230
231 @param list The list of addressee, which shall be pasted. 231 @param list The list of addressee, which shall be pasted.
232 */ 232 */
233 void pasteContacts( KABC::Addressee::List &list ); 233 void pasteContacts( KABC::Addressee::List &list );
234 234
235 /** 235 /**
236 Sets the whoAmI contact, that is used by many other programs to 236 Sets the whoAmI contact, that is used by many other programs to
237 get personal information about the current user. 237 get personal information about the current user.
238 */ 238 */
239 void setWhoAmI(); 239 void setWhoAmI();
240 240
241 /** 241 /**
242 Displays the category dialog and applies the result to all 242 Displays the category dialog and applies the result to all
243 selected contacts. 243 selected contacts.
244 */ 244 */
245 void setCategories(); 245 void setCategories();
246 246
247 /** 247 /**
248 Sets the field list of the Incremental Search Widget. 248 Sets the field list of the Incremental Search Widget.
249 */ 249 */
250 void setSearchFields( const KABC::Field::List &fields ); 250 void setSearchFields( const KABC::Field::List &fields );
251 251
252 /** 252 /**
253 Search with the current search field for a contact, that matches 253 Search with the current search field for a contact, that matches
254 the given text, and selects it in the view. 254 the given text, and selects it in the view.
255 */ 255 */
256 void incrementalSearch( const QString& text ); 256 void incrementalSearch( const QString& text );
257 257
258 /** 258 /**
259 Marks the address book as modified. 259 Marks the address book as modified.
260 */ 260 */
261 void setModified(); 261 void setModified();
262 /** 262 /**
263 Marks the address book as modified without refreshing the view. 263 Marks the address book as modified without refreshing the view.
264 */ 264 */
265 void setModifiedWOrefresh(); 265 void setModifiedWOrefresh();
266 266
267 /** 267 /**
268 Marks the address book as modified concerning the argument. 268 Marks the address book as modified concerning the argument.
269 */ 269 */
270 void setModified( bool modified ); 270 void setModified( bool modified );
271 271
272 /** 272 /**
273 Returns whether the address book is modified. 273 Returns whether the address book is modified.
274 */ 274 */
275 bool modified() const; 275 bool modified() const;
276 276
277 /** 277 /**
278 Called whenever an contact is modified in the contact editor 278 Called whenever an contact is modified in the contact editor
279 dialog or the quick edit. 279 dialog or the quick edit.
280 */ 280 */
281 void contactModified( const KABC::Addressee &addr ); 281 void contactModified( const KABC::Addressee &addr );
282 282
283 /** 283 /**
284 DCOP METHODS. 284 DCOP METHODS.
285 */ 285 */
286 void addEmail( QString addr ); 286 void addEmail( QString addr );
287 void importVCard( const KURL& url, bool showPreview ); 287 void importVCard( const KURL& url, bool showPreview );
288 void importVCard( const QString& vCard, bool showPreview ); 288 void importVCard( const QString& vCard, bool showPreview );
289 void newContact(); 289 void newContact();
290 QString getNameByPhone( const QString& phone ); 290 QString getNameByPhone( const QString& phone );
291 /** 291 /**
292 END DCOP METHODS 292 END DCOP METHODS
293 */ 293 */
294 294
295 /** 295 /**
296 Saves the contents of the AddressBook back to disk. 296 Saves the contents of the AddressBook back to disk.
297 */ 297 */
298 void save(); 298 void save();
299 299
300 /** 300 /**
301 Undos the last command using the undo stack. 301 Undos the last command using the undo stack.
302 */ 302 */
303 void undo(); 303 void undo();
304 304
305 /** 305 /**
306 Redos the last command that was undone, using the redo stack. 306 Redos the last command that was undone, using the redo stack.
307 */ 307 */
308 void redo(); 308 void redo();
309 309
310 /** 310 /**
311 Shows the edit dialog for the given uid. If the uid is QString::null, 311 Shows the edit dialog for the given uid. If the uid is QString::null,
312 the method will try to find a selected addressee in the view. 312 the method will try to find a selected addressee in the view.
313 */ 313 */
314 void editContact( const QString &uid /*US = QString::null*/ ); 314 void editContact( const QString &uid /*US = QString::null*/ );
315//US added a second method without defaultparameter 315//US added a second method without defaultparameter
316 void editContact2(); 316 void editContact2();
317 317
318 /** 318 /**
319 Shows or edits the detail view for the given uid. If the uid is QString::null, 319 Shows or edits the detail view for the given uid. If the uid is QString::null,
320 the method will try to find a selected addressee in the view. 320 the method will try to find a selected addressee in the view.
321 */ 321 */
322 void executeContact( const QString &uid /*US = QString::null*/ ); 322 void executeContact( const QString &uid /*US = QString::null*/ );
323 323
324 /** 324 /**
325 Launches the configuration dialog. 325 Launches the configuration dialog.
326 */ 326 */
327 void openConfigDialog(); 327 void openConfigDialog();
328 328
329 /** 329 /**
330 Launches the ldap search dialog. 330 Launches the ldap search dialog.
331 */ 331 */
332 void openLDAPDialog(); 332 void openLDAPDialog();
333 333
334 /** 334 /**
335 Creates a KAddressBookPrinter, which will display the print 335 Creates a KAddressBookPrinter, which will display the print
336 dialog and do the printing. 336 dialog and do the printing.
337 */ 337 */
338 void print(); 338 void print();
339 339
340 /** 340 /**
341 Registers a new GUI client, so plugins can register its actions. 341 Registers a new GUI client, so plugins can register its actions.
342 */ 342 */
343 void addGUIClient( KXMLGUIClient *client ); 343 void addGUIClient( KXMLGUIClient *client );
344 344
345 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 345 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
346 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 346 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
347 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 347 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
348 348
349 349
350 signals: 350 signals:
351 void contactSelected( const QString &name ); 351 void contactSelected( const QString &name );
352 void contactSelected( const QPixmap &pixmap ); 352 void contactSelected( const QPixmap &pixmap );
353 public slots: 353 public slots:
354 void recieve(QString cmsg ); 354 void recieve(QString cmsg );
355 void getFile( bool success ); 355 void getFile( bool success );
356 void syncFileRequest(); 356 void syncFileRequest();
357 void setDetailsVisible( bool visible ); 357 void setDetailsVisible( bool visible );
358 void setDetailsToState(); 358 void setDetailsToState();
359 // void slotSyncMenu( int ); 359 // void slotSyncMenu( int );
360 private slots: 360 private slots:
361 void receive( const QCString& cmsg, const QByteArray& data ); 361 void receive( const QCString& cmsg, const QByteArray& data );
362 void toggleBeamReceive( ); 362 void toggleBeamReceive( );
363 void disableBR(bool); 363 void disableBR(bool);
364 void setJumpButtonBarVisible( bool visible ); 364 void setJumpButtonBarVisible( bool visible );
365 void setCaptionBack(); 365 void setCaptionBack();
366 void importFromOL(); 366 void importFromOL();
367 void extensionModified( const KABC::Addressee::List &list ); 367 void extensionModified( const KABC::Addressee::List &list );
368 void extensionChanged( int id ); 368 void extensionChanged( int id );
369 void clipboardDataChanged(); 369 void clipboardDataChanged();
370 void updateActionMenu(); 370 void updateActionMenu();
371 void configureKeyBindings(); 371 void configureKeyBindings();
372 void removeVoice(); 372 void removeVoice();
373 void setCat();
374 void addCat();
375 void setCategories( bool removeOld );
373#ifdef KAB_EMBEDDED 376#ifdef KAB_EMBEDDED
374 void configureResources(); 377 void configureResources();
375#endif //KAB_EMBEDDED 378#endif //KAB_EMBEDDED
376 379
377 void slotEditorDestroyed( const QString &uid ); 380 void slotEditorDestroyed( const QString &uid );
378 void configurationChanged(); 381 void configurationChanged();
379 void addressBookChanged(); 382 void addressBookChanged();
380 383
381 private: 384 private:
382 bool mBRdisabled; 385 bool mBRdisabled;
383#ifndef DESKTOP_VERSION 386#ifndef DESKTOP_VERSION
384 QCopChannel* infrared; 387 QCopChannel* infrared;
385#endif 388#endif
386 QTimer *mMessageTimer; 389 QTimer *mMessageTimer;
387 void initGUI(); 390 void initGUI();
388 void initActions(); 391 void initActions();
389 QString getPhoneFile(); 392 QString getPhoneFile();
390 393
391 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 394 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
392 const char *name = 0 ); 395 const char *name = 0 );
393 396
394 KXMLGUIClient *mGUIClient; 397 KXMLGUIClient *mGUIClient;
395 398
396 KABC::AddressBook *mAddressBook; 399 KABC::AddressBook *mAddressBook;
397 400
398 ViewManager *mViewManager; 401 ViewManager *mViewManager;
399 // QSplitter *mDetailsSplitter; 402 // QSplitter *mDetailsSplitter;
400 KDGanttMinimizeSplitter *mExtensionBarSplitter; 403 KDGanttMinimizeSplitter *mExtensionBarSplitter;
401 ViewContainer *mDetails; 404 ViewContainer *mDetails;
402 KDGanttMinimizeSplitter* mMiniSplitter; 405 KDGanttMinimizeSplitter* mMiniSplitter;
403 XXPortManager *mXXPortManager; 406 XXPortManager *mXXPortManager;
404 JumpButtonBar *mJumpButtonBar; 407 JumpButtonBar *mJumpButtonBar;
405 IncSearchWidget *mIncSearchWidget; 408 IncSearchWidget *mIncSearchWidget;
406 ExtensionManager *mExtensionManager; 409 ExtensionManager *mExtensionManager;
407 410
408 KCMultiDialog *mConfigureDialog; 411 KCMultiDialog *mConfigureDialog;
409 412
410#ifndef KAB_EMBEDDED 413#ifndef KAB_EMBEDDED
411 LDAPSearchDialog *mLdapSearchDialog; 414 LDAPSearchDialog *mLdapSearchDialog;
412#endif //KAB_EMBEDDED 415#endif //KAB_EMBEDDED
413 // QDict<AddresseeEditorDialog> mEditorDict; 416 // QDict<AddresseeEditorDialog> mEditorDict;
414 AddresseeEditorDialog *mEditorDialog; 417 AddresseeEditorDialog *mEditorDialog;
415 bool mReadWrite; 418 bool mReadWrite;
416 bool mModified; 419 bool mModified;
417 bool mIsPart; 420 bool mIsPart;
418 bool mMultipleViewsAtOnce; 421 bool mMultipleViewsAtOnce;
419 422
420 423
421 //US file menu 424 //US file menu
422 KAction *mActionMail; 425 KAction *mActionMail;
423 KAction *mActionBeam; 426 KAction *mActionBeam;
424 KToggleAction *mActionBR; 427 KToggleAction *mActionBR;
425 KAction *mActionExport2phone; 428 KAction *mActionExport2phone;
426 KAction* mActionPrint; 429 KAction* mActionPrint;
427 KAction* mActionNewContact; 430 KAction* mActionNewContact;
428 KAction *mActionSave; 431 KAction *mActionSave;
429 KAction *mActionEditAddressee; 432 KAction *mActionEditAddressee;
430 KAction *mActionMailVCard; 433 KAction *mActionMailVCard;
431 KAction *mActionBeamVCard; 434 KAction *mActionBeamVCard;
432 435
433 KAction *mActionQuit; 436 KAction *mActionQuit;
434 437
435 //US edit menu 438 //US edit menu
436 KAction *mActionCopy; 439 KAction *mActionCopy;
437 KAction *mActionCut; 440 KAction *mActionCut;
438 KAction *mActionPaste; 441 KAction *mActionPaste;
439 KAction *mActionSelectAll; 442 KAction *mActionSelectAll;
440 KAction *mActionUndo; 443 KAction *mActionUndo;
441 KAction *mActionRedo; 444 KAction *mActionRedo;
442 KAction *mActionDelete; 445 KAction *mActionDelete;
443 446
444 //US settings menu 447 //US settings menu
445 KAction *mActionConfigResources; 448 KAction *mActionConfigResources;
446 KAction *mActionConfigKAddressbook; 449 KAction *mActionConfigKAddressbook;
447 KAction *mActionConfigShortcuts; 450 KAction *mActionConfigShortcuts;
448 KAction *mActionConfigureToolbars; 451 KAction *mActionConfigureToolbars;
449 KAction *mActionKeyBindings; 452 KAction *mActionKeyBindings;
450 KToggleAction *mActionJumpBar; 453 KToggleAction *mActionJumpBar;
451 KToggleAction *mActionDetails; 454 KToggleAction *mActionDetails;
452 KAction *mActionWhoAmI; 455 KAction *mActionWhoAmI;
453 KAction *mActionCategories; 456 KAction *mActionCategories;
454 KAction *mActionAboutKAddressbook; 457 KAction *mActionAboutKAddressbook;
455 KAction *mActionLicence; 458 KAction *mActionLicence;
456 KAction *mActionFaq; 459 KAction *mActionFaq;
457 KAction *mActionWN; 460 KAction *mActionWN;
458 KAction *mActionSyncHowto; 461 KAction *mActionSyncHowto;
459 KAction *mActionKdeSyncHowto; 462 KAction *mActionKdeSyncHowto;
460 KAction *mActionMultiSyncHowto; 463 KAction *mActionMultiSyncHowto;
461 464
462 KAction *mActionDeleteView; 465 KAction *mActionDeleteView;
463 466
464 QPopupMenu *viewMenu; 467 QPopupMenu *viewMenu;
465 QPopupMenu *filterMenu; 468 QPopupMenu *filterMenu;
466 QPopupMenu *settingsMenu; 469 QPopupMenu *settingsMenu;
467 QPopupMenu *changeMenu; 470 QPopupMenu *changeMenu;
468//US QAction *mActionSave; 471//US QAction *mActionSave;
469 QPopupMenu *ImportMenu; 472 QPopupMenu *ImportMenu;
470 QPopupMenu *ExportMenu; 473 QPopupMenu *ExportMenu;
471 //LR additional methods 474 //LR additional methods
472 KAction *mActionRemoveVoice; 475 KAction *mActionRemoveVoice;
476 KAction *mActionSetCat;
477 KAction *mActionAddCat;
473 KAction * mActionImportOL; 478 KAction * mActionImportOL;
474 479
475#ifndef KAB_EMBEDDED 480#ifndef KAB_EMBEDDED
476 KAddressBookService *mAddressBookService; 481 KAddressBookService *mAddressBookService;
477#endif //KAB_EMBEDDED 482#endif //KAB_EMBEDDED
478 483
479 class KABCorePrivate; 484 class KABCorePrivate;
480 KABCorePrivate *d; 485 KABCorePrivate *d;
481 //US bool mBlockSaveFlag; 486 //US bool mBlockSaveFlag;
482 487
483#ifdef KAB_EMBEDDED 488#ifdef KAB_EMBEDDED
484 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 489 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
485#endif //KAB_EMBEDDED 490#endif //KAB_EMBEDDED
486 491
487 //this are the overwritten callbackmethods from the syncinterface 492 //this are the overwritten callbackmethods from the syncinterface
488 virtual bool sync(KSyncManager* manager, QString filename, int mode); 493 virtual bool sync(KSyncManager* manager, QString filename, int mode);
489 virtual bool syncExternal(KSyncManager* manager, QString resource); 494 virtual bool syncExternal(KSyncManager* manager, QString resource);
490 virtual void removeSyncInfo( QString syncProfile); 495 virtual void removeSyncInfo( QString syncProfile);
491 bool syncPhone(); 496 bool syncPhone();
492 void message( QString m ); 497 void message( QString m );
493 498
494 // LR ******************************* 499 // LR *******************************
495 // sync stuff! 500 // sync stuff!
496 QString sentSyncFile(); 501 QString sentSyncFile();
497 QPopupMenu *syncMenu; 502 QPopupMenu *syncMenu;
498 KSyncManager* syncManager; 503 KSyncManager* syncManager;
499 int mGlobalSyncMode; 504 int mGlobalSyncMode;
500 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 505 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
501 KABC::Addressee getLastSyncAddressee(); 506 KABC::Addressee getLastSyncAddressee();
502 QDateTime mLastAddressbookSync; 507 QDateTime mLastAddressbookSync;
503 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 508 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
504 // ********************* 509 // *********************
505 510
506}; 511};
507 512
508#endif 513#endif