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