summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-07-13 15:00:05 (UTC)
committer ulf69 <ulf69>2004-07-13 15:00:05 (UTC)
commit65848bf858dae95799ec8ed883c23faa48ff8566 (patch) (unidiff)
tree74835d0d68caa5570b344b8494281786d00e57d5
parenteb1ab908047072aa4fb224ab7da6e147d4dcf1e0 (diff)
downloadkdepimpi-65848bf858dae95799ec8ed883c23faa48ff8566.zip
kdepimpi-65848bf858dae95799ec8ed883c23faa48ff8566.tar.gz
kdepimpi-65848bf858dae95799ec8ed883c23faa48ff8566.tar.bz2
changed output of gender field. Now it can have the values "male", "female" or ""
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/converter/opie/opieconverter.cpp13
-rw-r--r--kaddressbook/kabcore.cpp3
2 files changed, 12 insertions, 4 deletions
diff --git a/kabc/converter/opie/opieconverter.cpp b/kabc/converter/opie/opieconverter.cpp
index 0b6a55e..46e14dd 100644
--- a/kabc/converter/opie/opieconverter.cpp
+++ b/kabc/converter/opie/opieconverter.cpp
@@ -1,348 +1,355 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28//US 28//US
29#include "kglobal.h" 29#include "kglobal.h"
30 30
31 31
32#include "opieconverter.h" 32#include "opieconverter.h"
33 33
34#include <qpe/categories.h> 34#include <qpe/categories.h>
35#include <qpe/categoryselect.h> 35#include <qpe/categoryselect.h>
36 36
37 37
38using namespace KABC; 38using namespace KABC;
39 39
40OpieConverter::OpieConverter() : catDB(0) 40OpieConverter::OpieConverter() : catDB(0)
41{ 41{
42} 42}
43 43
44OpieConverter::~OpieConverter() 44OpieConverter::~OpieConverter()
45{ 45{
46 deinit(); 46 deinit();
47} 47}
48 48
49bool OpieConverter::init() 49bool OpieConverter::init()
50{ 50{
51 catDB = new Categories(); 51 catDB = new Categories();
52 if (catDB) 52 if (catDB)
53 { 53 {
54 catDB->load( categoryFileName() ); 54 catDB->load( categoryFileName() );
55 return true; 55 return true;
56 } 56 }
57 else 57 else
58 { 58 {
59 return false; 59 return false;
60 } 60 }
61 61
62} 62}
63 63
64void OpieConverter::deinit() 64void OpieConverter::deinit()
65{ 65{
66 if (catDB) 66 if (catDB)
67 { 67 {
68 delete catDB; 68 delete catDB;
69 catDB = 0; 69 catDB = 0;
70 } 70 }
71} 71}
72 72
73bool OpieConverter::opieToAddressee( const OContact &contact, Addressee &addr ) 73bool OpieConverter::opieToAddressee( const OContact &contact, Addressee &addr )
74{ 74{
75 // name 75 // name
76 addr.setFormattedName(contact.fileAs()); 76 addr.setFormattedName(contact.fileAs());
77 addr.setFamilyName( contact.lastName() ); 77 addr.setFamilyName( contact.lastName() );
78 addr.setGivenName( contact.firstName() ); 78 addr.setGivenName( contact.firstName() );
79 addr.setAdditionalName( contact.middleName() ); 79 addr.setAdditionalName( contact.middleName() );
80 addr.setPrefix( contact.title() ); 80 addr.setPrefix( contact.title() );
81 addr.setSuffix( contact.suffix() ); 81 addr.setSuffix( contact.suffix() );
82 82
83 83
84 // email 84 // email
85 QStringList emails = contact.emailList(); 85 QStringList emails = contact.emailList();
86 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 86 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
87 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); 87 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) );
88 } 88 }
89 89
90 if (!contact.defaultEmail().isEmpty()) 90 if (!contact.defaultEmail().isEmpty())
91 addr.insertEmail(contact.defaultEmail(), true); 91 addr.insertEmail(contact.defaultEmail(), true);
92 92
93 // home 93 // home
94 if ((!contact.homeStreet().isEmpty()) || 94 if ((!contact.homeStreet().isEmpty()) ||
95 (!contact.homeCity().isEmpty()) || 95 (!contact.homeCity().isEmpty()) ||
96 (!contact.homeState().isEmpty()) || 96 (!contact.homeState().isEmpty()) ||
97 (!contact.homeZip().isEmpty()) || 97 (!contact.homeZip().isEmpty()) ||
98 (!contact.homeCountry().isEmpty())) 98 (!contact.homeCountry().isEmpty()))
99 { 99 {
100 Address homeaddress; 100 Address homeaddress;
101 homeaddress.setType(Address::Home); 101 homeaddress.setType(Address::Home);
102//US homeaddress.setPostOfficeBox( "" ); 102//US homeaddress.setPostOfficeBox( "" );
103//US homeaddress.setExtended( "" ); 103//US homeaddress.setExtended( "" );
104 homeaddress.setStreet( contact.homeStreet() ); 104 homeaddress.setStreet( contact.homeStreet() );
105 homeaddress.setLocality( contact.homeCity() ); 105 homeaddress.setLocality( contact.homeCity() );
106 homeaddress.setRegion( contact.homeState() ); 106 homeaddress.setRegion( contact.homeState() );
107 homeaddress.setPostalCode( contact.homeZip() ); 107 homeaddress.setPostalCode( contact.homeZip() );
108 homeaddress.setCountry( contact.homeCountry() ); 108 homeaddress.setCountry( contact.homeCountry() );
109 109
110 addr.insertAddress( homeaddress ); 110 addr.insertAddress( homeaddress );
111 } 111 }
112 112
113 if (!contact.homePhone().isEmpty()) 113 if (!contact.homePhone().isEmpty())
114 { 114 {
115 PhoneNumber homephone; 115 PhoneNumber homephone;
116 homephone.setType( PhoneNumber::Home ); 116 homephone.setType( PhoneNumber::Home );
117 homephone.setNumber( contact.homePhone() ); 117 homephone.setNumber( contact.homePhone() );
118 addr.insertPhoneNumber( homephone ); 118 addr.insertPhoneNumber( homephone );
119 } 119 }
120 120
121 if (!contact.homeFax().isEmpty()) 121 if (!contact.homeFax().isEmpty())
122 { 122 {
123 PhoneNumber homefax; 123 PhoneNumber homefax;
124 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); 124 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax );
125 homefax.setNumber( contact.homeFax() ); 125 homefax.setNumber( contact.homeFax() );
126 addr.insertPhoneNumber( homefax ); 126 addr.insertPhoneNumber( homefax );
127 } 127 }
128 128
129 if (!contact.homeMobile().isEmpty()) 129 if (!contact.homeMobile().isEmpty())
130 { 130 {
131 PhoneNumber homemobile; 131 PhoneNumber homemobile;
132 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); 132 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell );
133 homemobile.setNumber( contact.homeMobile() ); 133 homemobile.setNumber( contact.homeMobile() );
134 addr.insertPhoneNumber( homemobile ); 134 addr.insertPhoneNumber( homemobile );
135 } 135 }
136 136
137 addr.setUrl( contact.homeWebpage() ); 137 addr.setUrl( contact.homeWebpage() );
138 138
139 139
140 // business 140 // business
141 if ((!contact.businessStreet().isEmpty()) || 141 if ((!contact.businessStreet().isEmpty()) ||
142 (!contact.businessCity().isEmpty()) || 142 (!contact.businessCity().isEmpty()) ||
143 (!contact.businessState().isEmpty()) || 143 (!contact.businessState().isEmpty()) ||
144 (!contact.businessZip().isEmpty()) || 144 (!contact.businessZip().isEmpty()) ||
145 (!contact.businessCountry().isEmpty())) 145 (!contact.businessCountry().isEmpty()))
146 { 146 {
147 Address businessaddress; 147 Address businessaddress;
148 businessaddress.setType(Address::Work); 148 businessaddress.setType(Address::Work);
149//US businessaddress.setPostOfficeBox( "" ); 149//US businessaddress.setPostOfficeBox( "" );
150//US businessaddress.setExtended( "" ); 150//US businessaddress.setExtended( "" );
151 businessaddress.setStreet( contact.businessStreet() ); 151 businessaddress.setStreet( contact.businessStreet() );
152 businessaddress.setLocality( contact.businessCity() ); 152 businessaddress.setLocality( contact.businessCity() );
153 businessaddress.setRegion( contact.businessState() ); 153 businessaddress.setRegion( contact.businessState() );
154 businessaddress.setPostalCode( contact.businessZip() ); 154 businessaddress.setPostalCode( contact.businessZip() );
155 businessaddress.setCountry( contact.businessCountry() ); 155 businessaddress.setCountry( contact.businessCountry() );
156 156
157 addr.insertAddress( businessaddress ); 157 addr.insertAddress( businessaddress );
158 } 158 }
159 159
160 160
161 if (!contact.businessPhone().isEmpty()) 161 if (!contact.businessPhone().isEmpty())
162 { 162 {
163 PhoneNumber businessphone; 163 PhoneNumber businessphone;
164 businessphone.setType( PhoneNumber::Work ); 164 businessphone.setType( PhoneNumber::Work );
165 businessphone.setNumber( contact.businessPhone() ); 165 businessphone.setNumber( contact.businessPhone() );
166 addr.insertPhoneNumber( businessphone ); 166 addr.insertPhoneNumber( businessphone );
167 } 167 }
168 168
169 if (!contact.businessFax().isEmpty()) 169 if (!contact.businessFax().isEmpty())
170 { 170 {
171 PhoneNumber businessfax; 171 PhoneNumber businessfax;
172 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); 172 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax );
173 businessfax.setNumber( contact.businessFax() ); 173 businessfax.setNumber( contact.businessFax() );
174 addr.insertPhoneNumber( businessfax ); 174 addr.insertPhoneNumber( businessfax );
175 } 175 }
176 176
177 if (!contact.businessMobile().isEmpty()) 177 if (!contact.businessMobile().isEmpty())
178 { 178 {
179 PhoneNumber businessmobile; 179 PhoneNumber businessmobile;
180 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); 180 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell );
181 businessmobile.setNumber( contact.businessMobile() ); 181 businessmobile.setNumber( contact.businessMobile() );
182 addr.insertPhoneNumber( businessmobile ); 182 addr.insertPhoneNumber( businessmobile );
183 } 183 }
184 184
185 if (!contact.businessPager().isEmpty()) 185 if (!contact.businessPager().isEmpty())
186 { 186 {
187 PhoneNumber businesspager; 187 PhoneNumber businesspager;
188 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); 188 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager );
189 businesspager.setNumber( contact.businessPager() ); 189 businesspager.setNumber( contact.businessPager() );
190 addr.insertPhoneNumber( businesspager ); 190 addr.insertPhoneNumber( businesspager );
191 } 191 }
192 192
193 addr.setRole( contact.jobTitle() ); //? 193 addr.setRole( contact.jobTitle() ); //?
194 addr.setOrganization( contact.company() ); 194 addr.setOrganization( contact.company() );
195 addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() ); 195 addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() );
196 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() ); 196 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() );
197 addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() ); 197 addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() );
198 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() ); 198 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() );
199 addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() ); 199 addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() );
200 200
201 //personal 201 //personal
202 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); 202 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() );
203 addr.insertCustom( "KADDRESSBOOK", "X-Gender", contact.gender() ); 203 if (contact.gender() == 1)
204 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female" );
205 else if (contact.gender() == 2)
206 addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male" );
204 207
205 if (contact.anniversary().isValid()) { 208 if (contact.anniversary().isValid()) {
206 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); 209 QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate);
207//US 210//US
208 qDebug("OpieConverter::opieToAddressee found:%s", dt.latin1()); 211 qDebug("OpieConverter::opieToAddressee found:%s", dt.latin1());
209 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 212 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
210 } 213 }
211 214
212 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); 215 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() );
213 if (contact.birthday().isValid()) 216 if (contact.birthday().isValid())
214 addr.setBirthday( contact.birthday() ); 217 addr.setBirthday( contact.birthday() );
215 218
216 addr.setNickName( contact.nickname() ); 219 addr.setNickName( contact.nickname() );
217 220
218 // others 221 // others
219 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. 222 //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available.
220 QString notes = contact.notes(); 223 QString notes = contact.notes();
221 notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; 224 notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n";
222 225
223 addr.setNote( contact.notes() ); 226 addr.setNote( contact.notes() );
224 227
225 228
226 229
227//US QString groups() const { return find( Qtopia::Groups ); } 230//US QString groups() const { return find( Qtopia::Groups ); }
228//US QStringList groupList() const; 231//US QStringList groupList() const;
229 232
230 233
231 QStringList cats = contact.categoryNames("Contacts"); 234 QStringList cats = contact.categoryNames("Contacts");
232 addr.setCategories( cats ); 235 addr.setCategories( cats );
233// for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { 236// for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
234// qDebug("Cat: %s", (*it).latin1()); 237// qDebug("Cat: %s", (*it).latin1());
235// } 238// }
236 239
237 240
238 return true; 241 return true;
239} 242}
240 243
241bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact ) 244bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact )
242{ 245{
243 // name 246 // name
244 contact.setLastName(addr.familyName()); 247 contact.setLastName(addr.familyName());
245 contact.setFirstName(addr.givenName()); 248 contact.setFirstName(addr.givenName());
246 contact.setMiddleName(addr.additionalName()); 249 contact.setMiddleName(addr.additionalName());
247 contact.setTitle(addr.prefix()); 250 contact.setTitle(addr.prefix());
248 contact.setSuffix(addr.suffix()); 251 contact.setSuffix(addr.suffix());
249 contact.setFileAs(); 252 contact.setFileAs();
250 253
251 254
252 // email 255 // email
253 QStringList emails = addr.emails(); 256 QStringList emails = addr.emails();
254 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 257 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
255 contact.insertEmail(*it); 258 contact.insertEmail(*it);
256 } 259 }
257 contact.setDefaultEmail( addr.preferredEmail() ); 260 contact.setDefaultEmail( addr.preferredEmail() );
258 261
259 262
260 // home 263 // home
261 const Address homeaddress = addr.address(Address::Home); 264 const Address homeaddress = addr.address(Address::Home);
262 if (!homeaddress.isEmpty()) { 265 if (!homeaddress.isEmpty()) {
263 contact.setHomeStreet(homeaddress.street()); 266 contact.setHomeStreet(homeaddress.street());
264 contact.setHomeCity(homeaddress.locality()); 267 contact.setHomeCity(homeaddress.locality());
265 contact.setHomeState(homeaddress.region()); 268 contact.setHomeState(homeaddress.region());
266 contact.setHomeZip(homeaddress.postalCode()); 269 contact.setHomeZip(homeaddress.postalCode());
267 contact.setHomeCountry(homeaddress.country()); 270 contact.setHomeCountry(homeaddress.country());
268 } 271 }
269 272
270 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); 273 PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home );
271 if (!homephone.number().isEmpty()) 274 if (!homephone.number().isEmpty())
272 contact.setHomePhone(homephone.number()); 275 contact.setHomePhone(homephone.number());
273 276
274 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); 277 PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax );
275 if (!homefax.number().isEmpty()) 278 if (!homefax.number().isEmpty())
276 contact.setHomeFax(homefax.number()); 279 contact.setHomeFax(homefax.number());
277 280
278 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); 281 PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell );
279 if (!homemobile.number().isEmpty()) 282 if (!homemobile.number().isEmpty())
280 contact.setHomeMobile(homemobile.number()); 283 contact.setHomeMobile(homemobile.number());
281 284
282 contact.setHomeWebpage(addr.url().url()); 285 contact.setHomeWebpage(addr.url().url());
283 286
284 287
285 // business 288 // business
286 const Address businessaddress = addr.address(Address::Work); 289 const Address businessaddress = addr.address(Address::Work);
287 if (!businessaddress.isEmpty()) { 290 if (!businessaddress.isEmpty()) {
288 contact.setBusinessStreet(businessaddress.street()); 291 contact.setBusinessStreet(businessaddress.street());
289 contact.setBusinessCity(businessaddress.locality()); 292 contact.setBusinessCity(businessaddress.locality());
290 contact.setBusinessState(businessaddress.region()); 293 contact.setBusinessState(businessaddress.region());
291 contact.setBusinessZip(businessaddress.postalCode()); 294 contact.setBusinessZip(businessaddress.postalCode());
292 contact.setBusinessCountry(businessaddress.country()); 295 contact.setBusinessCountry(businessaddress.country());
293 } 296 }
294 297
295 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); 298 PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work );
296 if (!businessphone.number().isEmpty()) 299 if (!businessphone.number().isEmpty())
297 contact.setBusinessPhone(businessphone.number()); 300 contact.setBusinessPhone(businessphone.number());
298 301
299 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); 302 PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax );
300 if (!businessfax.number().isEmpty()) 303 if (!businessfax.number().isEmpty())
301 contact.setBusinessFax(businessfax.number()); 304 contact.setBusinessFax(businessfax.number());
302 305
303 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); 306 PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell );
304 if (!businessmobile.number().isEmpty()) 307 if (!businessmobile.number().isEmpty())
305 contact.setBusinessMobile(businessmobile.number()); 308 contact.setBusinessMobile(businessmobile.number());
306 309
307 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); 310 PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager );
308 if (!businesspager.number().isEmpty()) 311 if (!businesspager.number().isEmpty())
309 contact.setBusinessPager(businesspager.number()); 312 contact.setBusinessPager(businesspager.number());
310 313
311 contact.setJobTitle(addr.role()); 314 contact.setJobTitle(addr.role());
312 contact.setCompany(addr.organization()); 315 contact.setCompany(addr.organization());
313 316
314 contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" )); 317 contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" ));
315 contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); 318 contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" ));
316 contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" )); 319 contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" ));
317 contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" )); 320 contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" ));
318 contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" )); 321 contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" ));
319 322
320 //personal 323 //personal
321 contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" )); 324 contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" ));
322 contact.setGender(addr.custom( "KADDRESSBOOK", "X-Gender" )); 325 QString gend = addr.custom( "KADDRESSBOOK", "X-Gender" );
323 326 if (gend == "female")
327 contact.setGender("1");
328 else if (gend == "male")
329 contact.setGender("2");
330
324 QDate dt = KGlobal::locale()->readDate( 331 QDate dt = KGlobal::locale()->readDate(
325 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate 332 addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate
326 contact.setAnniversary( dt ); 333 contact.setAnniversary( dt );
327 334
328 contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" )); 335 contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" ));
329 336
330 contact.setBirthday(addr.birthday().date()); 337 contact.setBirthday(addr.birthday().date());
331 contact.setNickname(addr.nickName()); 338 contact.setNickname(addr.nickName());
332 339
333 // other 340 // other
334 contact.setNotes(addr.note()); 341 contact.setNotes(addr.note());
335 342
336//US QString groups() const { return find( Qtopia::Groups ); } 343//US QString groups() const { return find( Qtopia::Groups ); }
337//US QStringList groupList() const; 344//US QStringList groupList() const;
338 345
339 QStringList cats = addr.categories(); 346 QStringList cats = addr.categories();
340 347
341 QArray<int> iar; 348 QArray<int> iar;
342 if ( !cats.isEmpty() ) { 349 if ( !cats.isEmpty() ) {
343 QArray<int> iar = catDB->ids("contact", cats); 350 QArray<int> iar = catDB->ids("contact", cats);
344 contact.setCategories(iar); 351 contact.setCategories(iar);
345 } 352 }
346 353
347 return true; 354 return true;
348} 355}
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 1a34e4d..8daca33 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,1676 +1,1677 @@
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#include "kabcore.h" 24#include "kabcore.h"
25 25
26#include <stdaddressbook.h> 26#include <stdaddressbook.h>
27#include <klocale.h> 27#include <klocale.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#include <qclipboard.h> 30#include <qclipboard.h>
31#include <qdir.h> 31#include <qdir.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qapplicaton.h> 33#include <qapplicaton.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qregexp.h> 35#include <qregexp.h>
36#include <qvbox.h> 36#include <qvbox.h>
37#include <kabc/addresseelist.h> 37#include <kabc/addresseelist.h>
38#include <kabc/errorhandler.h> 38#include <kabc/errorhandler.h>
39#include <kabc/resource.h> 39#include <kabc/resource.h>
40#include <kabc/vcardconverter.h> 40#include <kabc/vcardconverter.h>
41#include <kapplication.h> 41#include <kapplication.h>
42#include <kactionclasses.h> 42#include <kactionclasses.h>
43#include <kcmultidialog.h> 43#include <kcmultidialog.h>
44#include <kdebug.h> 44#include <kdebug.h>
45#include <kdeversion.h> 45#include <kdeversion.h>
46#include <kkeydialog.h> 46#include <kkeydialog.h>
47#include <kmessagebox.h> 47#include <kmessagebox.h>
48#include <kprinter.h> 48#include <kprinter.h>
49#include <kprotocolinfo.h> 49#include <kprotocolinfo.h>
50#include <kresources/selectdialog.h> 50#include <kresources/selectdialog.h>
51#include <kstandarddirs.h> 51#include <kstandarddirs.h>
52#include <ktempfile.h> 52#include <ktempfile.h>
53#include <kxmlguiclient.h> 53#include <kxmlguiclient.h>
54#include <kaboutdata.h> 54#include <kaboutdata.h>
55#include <libkdepim/categoryselectdialog.h> 55#include <libkdepim/categoryselectdialog.h>
56 56
57#include "addresseeutil.h" 57#include "addresseeutil.h"
58#include "addresseeeditordialog.h" 58#include "addresseeeditordialog.h"
59#include "extensionmanager.h" 59#include "extensionmanager.h"
60#include "kstdaction.h" 60#include "kstdaction.h"
61#include "kaddressbookservice.h" 61#include "kaddressbookservice.h"
62#include "ldapsearchdialog.h" 62#include "ldapsearchdialog.h"
63#include "printing/printingwizard.h" 63#include "printing/printingwizard.h"
64#else // KAB_EMBEDDED 64#else // KAB_EMBEDDED
65 65
66#include <kapplication.h> 66#include <kapplication.h>
67#include "KDGanttMinimizeSplitter.h" 67#include "KDGanttMinimizeSplitter.h"
68#include "kaddressbookmain.h" 68#include "kaddressbookmain.h"
69#include "kactioncollection.h" 69#include "kactioncollection.h"
70#include <qapp.h> 70#include <qapp.h>
71#include <qmenubar.h> 71#include <qmenubar.h>
72//#include <qtoolbar.h> 72//#include <qtoolbar.h>
73#include <qmessagebox.h> 73#include <qmessagebox.h>
74#include <kdebug.h> 74#include <kdebug.h>
75#include <kiconloader.h> // needed for SmallIcon 75#include <kiconloader.h> // needed for SmallIcon
76#include <kresources/kcmkresources.h> 76#include <kresources/kcmkresources.h>
77#include <ktoolbar.h> 77#include <ktoolbar.h>
78 78
79#include <kcmkabconfig.h> 79#include <kcmkabconfig.h>
80 80
81//US#include <qpe/resource.h> // needed for Resource::loadPixmap 81//US#include <qpe/resource.h> // needed for Resource::loadPixmap
82//#include <qlabel.h> 82//#include <qlabel.h>
83#endif // KAB_EMBEDDED 83#endif // KAB_EMBEDDED
84#include <kcmkabconfig.h> 84#include <kcmkabconfig.h>
85 85
86 86
87#include <kresources/selectdialog.h> 87#include <kresources/selectdialog.h>
88#include <kmessagebox.h> 88#include <kmessagebox.h>
89 89
90#include <picture.h> 90#include <picture.h>
91#include <resource.h> 91#include <resource.h>
92 92
93//US#include <qsplitter.h> 93//US#include <qsplitter.h>
94#include <qvbox.h> 94#include <qvbox.h>
95#include <qlayout.h> 95#include <qlayout.h>
96#include <qclipboard.h> 96#include <qclipboard.h>
97 97
98#include <libkdepim/categoryselectdialog.h> 98#include <libkdepim/categoryselectdialog.h>
99 99
100#include "addresseeutil.h" 100#include "addresseeutil.h"
101#include "undocmds.h" 101#include "undocmds.h"
102#include "addresseeeditordialog.h" 102#include "addresseeeditordialog.h"
103#include "viewmanager.h" 103#include "viewmanager.h"
104#include "details/detailsviewcontainer.h" 104#include "details/detailsviewcontainer.h"
105#include "kabprefs.h" 105#include "kabprefs.h"
106#include "xxportmanager.h" 106#include "xxportmanager.h"
107#include "incsearchwidget.h" 107#include "incsearchwidget.h"
108#include "jumpbuttonbar.h" 108#include "jumpbuttonbar.h"
109#include "extensionmanager.h" 109#include "extensionmanager.h"
110#include "addresseeconfig.h" 110#include "addresseeconfig.h"
111#include <kcmultidialog.h> 111#include <kcmultidialog.h>
112 112
113#ifdef _WIN32_ 113#ifdef _WIN32_
114 114
115#include "kaimportoldialog.h" 115#include "kaimportoldialog.h"
116#endif 116#endif
117 117
118bool pasteWithNewUid = true; 118bool pasteWithNewUid = true;
119 119
120#ifdef KAB_EMBEDDED 120#ifdef KAB_EMBEDDED
121KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 121KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
122 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 122 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
123 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 123 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
124 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 124 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
125#else //KAB_EMBEDDED 125#else //KAB_EMBEDDED
126KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 126KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
127 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 127 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
128 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 128 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
129 mReadWrite( readWrite ), mModified( false ) 129 mReadWrite( readWrite ), mModified( false )
130#endif //KAB_EMBEDDED 130#endif //KAB_EMBEDDED
131{ 131{
132#ifdef KAB_EMBEDDED 132#ifdef KAB_EMBEDDED
133 //US we define here our own global actioncollection. 133 //US we define here our own global actioncollection.
134 //mActionCollection = new KActionCollection(this); 134 //mActionCollection = new KActionCollection(this);
135#endif //KAB_EMBEDDED 135#endif //KAB_EMBEDDED
136 mExtensionBarSplitter = 0; 136 mExtensionBarSplitter = 0;
137 mIsPart = !parent->inherits( "KAddressBookMain" ); 137 mIsPart = !parent->inherits( "KAddressBookMain" );
138 138
139 mAddressBook = KABC::StdAddressBook::self(); 139 mAddressBook = KABC::StdAddressBook::self();
140 KABC::StdAddressBook::setAutomaticSave( false ); 140 KABC::StdAddressBook::setAutomaticSave( false );
141 141
142#ifndef KAB_EMBEDDED 142#ifndef KAB_EMBEDDED
143 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 143 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
144#endif //KAB_EMBEDDED 144#endif //KAB_EMBEDDED
145 145
146 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 146 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
147 SLOT( addressBookChanged() ) ); 147 SLOT( addressBookChanged() ) );
148 148
149 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 149 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
150 "X-Department", "KADDRESSBOOK" ); 150 "X-Department", "KADDRESSBOOK" );
151 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 151 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
152 "X-Profession", "KADDRESSBOOK" ); 152 "X-Profession", "KADDRESSBOOK" );
153 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 153 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
154 "X-AssistantsName", "KADDRESSBOOK" ); 154 "X-AssistantsName", "KADDRESSBOOK" );
155 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 155 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
156 "X-ManagersName", "KADDRESSBOOK" ); 156 "X-ManagersName", "KADDRESSBOOK" );
157 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 157 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
158 "X-SpousesName", "KADDRESSBOOK" ); 158 "X-SpousesName", "KADDRESSBOOK" );
159 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 159 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
160 "X-Office", "KADDRESSBOOK" ); 160 "X-Office", "KADDRESSBOOK" );
161 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 161 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
162 "X-IMAddress", "KADDRESSBOOK" ); 162 "X-IMAddress", "KADDRESSBOOK" );
163 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 163 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
164 "X-Anniversary", "KADDRESSBOOK" ); 164 "X-Anniversary", "KADDRESSBOOK" );
165 165
166//US added this field to become compatible with Opie addressbook 166 //US added this field to become compatible with Opie/qtopia addressbook
167 // values can be "female" or "male" or "". An empty field represents undefined.
167 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 168 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
168 "X-Gender", "KADDRESSBOOK" ); 169 "X-Gender", "KADDRESSBOOK" );
169 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 170 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
170 "X-Children", "KADDRESSBOOK" ); 171 "X-Children", "KADDRESSBOOK" );
171 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 172 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
172 "X-FreeBusyUrl", "KADDRESSBOOK" ); 173 "X-FreeBusyUrl", "KADDRESSBOOK" );
173 174
174 initGUI(); 175 initGUI();
175 176
176 mIncSearchWidget->setFocus(); 177 mIncSearchWidget->setFocus();
177 178
178 179
179 connect( mViewManager, SIGNAL( selected( const QString& ) ), 180 connect( mViewManager, SIGNAL( selected( const QString& ) ),
180 SLOT( setContactSelected( const QString& ) ) ); 181 SLOT( setContactSelected( const QString& ) ) );
181 connect( mViewManager, SIGNAL( executed( const QString& ) ), 182 connect( mViewManager, SIGNAL( executed( const QString& ) ),
182 SLOT( editContact( const QString& ) ) ); 183 SLOT( editContact( const QString& ) ) );
183 connect( mViewManager, SIGNAL( deleteRequest( ) ), 184 connect( mViewManager, SIGNAL( deleteRequest( ) ),
184 SLOT( deleteContacts( ) ) ); 185 SLOT( deleteContacts( ) ) );
185 connect( mViewManager, SIGNAL( modified() ), 186 connect( mViewManager, SIGNAL( modified() ),
186 SLOT( setModified() ) ); 187 SLOT( setModified() ) );
187 188
188 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 189 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
189 190
190 connect( mXXPortManager, SIGNAL( modified() ), 191 connect( mXXPortManager, SIGNAL( modified() ),
191 SLOT( setModified() ) ); 192 SLOT( setModified() ) );
192 193
193 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 194 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
194 SLOT( incrementalSearch( const QString& ) ) ); 195 SLOT( incrementalSearch( const QString& ) ) );
195 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 196 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
196 mJumpButtonBar, SLOT( recreateButtons() ) ); 197 mJumpButtonBar, SLOT( recreateButtons() ) );
197 198
198#ifndef KAB_EMBEDDED 199#ifndef KAB_EMBEDDED
199 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 200 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
200 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 201 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
201 202
202 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 203 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
203 SLOT( sendMail( const QString& ) ) ); 204 SLOT( sendMail( const QString& ) ) );
204 connect( mDetails, SIGNAL( browse( const QString& ) ), 205 connect( mDetails, SIGNAL( browse( const QString& ) ),
205 SLOT( browse( const QString& ) ) ); 206 SLOT( browse( const QString& ) ) );
206 207
207 mAddressBookService = new KAddressBookService( this ); 208 mAddressBookService = new KAddressBookService( this );
208 209
209#endif //KAB_EMBEDDED 210#endif //KAB_EMBEDDED
210 mEditorDialog = 0; 211 mEditorDialog = 0;
211 createAddresseeEditorDialog( this ); 212 createAddresseeEditorDialog( this );
212 setModified( false ); 213 setModified( false );
213} 214}
214 215
215KABCore::~KABCore() 216KABCore::~KABCore()
216{ 217{
217 // save(); 218 // save();
218 //saveSettings(); 219 //saveSettings();
219 //KABPrefs::instance()->writeConfig(); 220 //KABPrefs::instance()->writeConfig();
220 delete AddresseeConfig::instance(); 221 delete AddresseeConfig::instance();
221 mAddressBook = 0; 222 mAddressBook = 0;
222 KABC::StdAddressBook::close(); 223 KABC::StdAddressBook::close();
223 224
224#ifdef KAB_EMBEDDED 225#ifdef KAB_EMBEDDED
225 //US we define here our own global actioncollection. 226 //US we define here our own global actioncollection.
226 // delete mActionCollection; 227 // delete mActionCollection;
227#endif //KAB_EMBEDDED 228#endif //KAB_EMBEDDED
228 229
229} 230}
230 231
231void KABCore::restoreSettings() 232void KABCore::restoreSettings()
232{ 233{
233 bool state = KABPrefs::instance()->mJumpButtonBarVisible; 234 bool state = KABPrefs::instance()->mJumpButtonBarVisible;
234 235
235 mActionJumpBar->setChecked( state ); 236 mActionJumpBar->setChecked( state );
236 setJumpButtonBarVisible( state ); 237 setJumpButtonBarVisible( state );
237 238
238 state = KABPrefs::instance()->mDetailsPageVisible; 239 state = KABPrefs::instance()->mDetailsPageVisible;
239 240
240 mActionDetails->setChecked( state ); 241 mActionDetails->setChecked( state );
241 setDetailsVisible( state ); 242 setDetailsVisible( state );
242 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 243 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
243 if ( splitterSize.count() == 0 ) { 244 if ( splitterSize.count() == 0 ) {
244 splitterSize.append( width() / 2 ); 245 splitterSize.append( width() / 2 );
245 splitterSize.append( width() / 2 ); 246 splitterSize.append( width() / 2 );
246 } 247 }
247 mMiniSplitter->setSizes( splitterSize ); 248 mMiniSplitter->setSizes( splitterSize );
248 if ( mExtensionBarSplitter ) { 249 if ( mExtensionBarSplitter ) {
249 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 250 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
250 if ( splitterSize.count() == 0 ) { 251 if ( splitterSize.count() == 0 ) {
251 splitterSize.append( width() / 2 ); 252 splitterSize.append( width() / 2 );
252 splitterSize.append( width() / 2 ); 253 splitterSize.append( width() / 2 );
253 } 254 }
254 mExtensionBarSplitter->setSizes( splitterSize ); 255 mExtensionBarSplitter->setSizes( splitterSize );
255 256
256 } 257 }
257#ifndef KAB_EMBEDDED 258#ifndef KAB_EMBEDDED
258 QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; 259 QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter;
259 if ( splitterSize.count() == 0 ) { 260 if ( splitterSize.count() == 0 ) {
260 splitterSize.append( width() / 2 ); 261 splitterSize.append( width() / 2 );
261 splitterSize.append( width() / 2 ); 262 splitterSize.append( width() / 2 );
262 } 263 }
263 mExtensionBarSplitter->setSizes( splitterSize ); 264 mExtensionBarSplitter->setSizes( splitterSize );
264 265
265 splitterSize = KABPrefs::instance()->mDetailsSplitter; 266 splitterSize = KABPrefs::instance()->mDetailsSplitter;
266 if ( splitterSize.count() == 0 ) { 267 if ( splitterSize.count() == 0 ) {
267 splitterSize.append( height() / 2 ); 268 splitterSize.append( height() / 2 );
268 splitterSize.append( height() / 2 ); 269 splitterSize.append( height() / 2 );
269 } 270 }
270 mDetailsSplitter->setSizes( splitterSize ); 271 mDetailsSplitter->setSizes( splitterSize );
271 272
272 mExtensionManager->restoreSettings(); 273 mExtensionManager->restoreSettings();
273 274
274#endif //KAB_EMBEDDED 275#endif //KAB_EMBEDDED
275 276
276 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 277 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
277 278
278 mViewManager->restoreSettings(); 279 mViewManager->restoreSettings();
279 mExtensionManager->restoreSettings(); 280 mExtensionManager->restoreSettings();
280} 281}
281 282
282void KABCore::saveSettings() 283void KABCore::saveSettings()
283{ 284{
284 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 285 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
285 if ( mExtensionBarSplitter ) 286 if ( mExtensionBarSplitter )
286 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 287 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
287 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 288 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
288 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 289 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
289#ifndef KAB_EMBEDDED 290#ifndef KAB_EMBEDDED
290 291
291 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 292 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
292 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 293 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
293#endif //KAB_EMBEDDED 294#endif //KAB_EMBEDDED
294 mExtensionManager->saveSettings(); 295 mExtensionManager->saveSettings();
295 mViewManager->saveSettings(); 296 mViewManager->saveSettings();
296 297
297 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 298 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
298 299
299} 300}
300 301
301KABC::AddressBook *KABCore::addressBook() const 302KABC::AddressBook *KABCore::addressBook() const
302{ 303{
303 return mAddressBook; 304 return mAddressBook;
304} 305}
305 306
306KConfig *KABCore::config() 307KConfig *KABCore::config()
307{ 308{
308#ifndef KAB_EMBEDDED 309#ifndef KAB_EMBEDDED
309 return KABPrefs::instance()->config(); 310 return KABPrefs::instance()->config();
310#else //KAB_EMBEDDED 311#else //KAB_EMBEDDED
311 return KABPrefs::instance()->getConfig(); 312 return KABPrefs::instance()->getConfig();
312#endif //KAB_EMBEDDED 313#endif //KAB_EMBEDDED
313} 314}
314 315
315KActionCollection *KABCore::actionCollection() const 316KActionCollection *KABCore::actionCollection() const
316{ 317{
317 return mGUIClient->actionCollection(); 318 return mGUIClient->actionCollection();
318} 319}
319 320
320KABC::Field *KABCore::currentSearchField() const 321KABC::Field *KABCore::currentSearchField() const
321{ 322{
322 if (mIncSearchWidget) 323 if (mIncSearchWidget)
323 return mIncSearchWidget->currentField(); 324 return mIncSearchWidget->currentField();
324 else 325 else
325 return 0; 326 return 0;
326} 327}
327 328
328QStringList KABCore::selectedUIDs() const 329QStringList KABCore::selectedUIDs() const
329{ 330{
330 return mViewManager->selectedUids(); 331 return mViewManager->selectedUids();
331} 332}
332 333
333KABC::Resource *KABCore::requestResource( QWidget *parent ) 334KABC::Resource *KABCore::requestResource( QWidget *parent )
334{ 335{
335 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 336 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
336 337
337 QPtrList<KRES::Resource> kresResources; 338 QPtrList<KRES::Resource> kresResources;
338 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 339 QPtrListIterator<KABC::Resource> resIt( kabcResources );
339 KABC::Resource *resource; 340 KABC::Resource *resource;
340 while ( ( resource = resIt.current() ) != 0 ) { 341 while ( ( resource = resIt.current() ) != 0 ) {
341 ++resIt; 342 ++resIt;
342 if ( !resource->readOnly() ) { 343 if ( !resource->readOnly() ) {
343 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 344 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
344 if ( res ) 345 if ( res )
345 kresResources.append( res ); 346 kresResources.append( res );
346 } 347 }
347 } 348 }
348 349
349 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 350 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
350 return static_cast<KABC::Resource*>( res ); 351 return static_cast<KABC::Resource*>( res );
351} 352}
352 353
353#ifndef KAB_EMBEDDED 354#ifndef KAB_EMBEDDED
354KAboutData *KABCore::createAboutData() 355KAboutData *KABCore::createAboutData()
355#else //KAB_EMBEDDED 356#else //KAB_EMBEDDED
356void KABCore::createAboutData() 357void KABCore::createAboutData()
357#endif //KAB_EMBEDDED 358#endif //KAB_EMBEDDED
358{ 359{
359#ifndef KAB_EMBEDDED 360#ifndef KAB_EMBEDDED
360 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 361 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
361 "3.1", I18N_NOOP( "The KDE Address Book" ), 362 "3.1", I18N_NOOP( "The KDE Address Book" ),
362 KAboutData::License_GPL_V2, 363 KAboutData::License_GPL_V2,
363 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 364 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
364 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 365 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
365 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 366 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
366 about->addAuthor( "Cornelius Schumacher", 367 about->addAuthor( "Cornelius Schumacher",
367 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 368 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
368 "schumacher@kde.org" ); 369 "schumacher@kde.org" );
369 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 370 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
370 "mpilone@slac.com" ); 371 "mpilone@slac.com" );
371 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 372 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
372 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 373 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
373 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 374 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
374 "michel@klaralvdalens-datakonsult.se" ); 375 "michel@klaralvdalens-datakonsult.se" );
375 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 376 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
376 "hansen@kde.org" ); 377 "hansen@kde.org" );
377 378
378 return about; 379 return about;
379#endif //KAB_EMBEDDED 380#endif //KAB_EMBEDDED
380 381
381 QString version; 382 QString version;
382#include <../version> 383#include <../version>
383 QMessageBox::about( this, "About KAddressbook/Pi", 384 QMessageBox::about( this, "About KAddressbook/Pi",
384 "KAddressbook/Platform-independent\n" 385 "KAddressbook/Platform-independent\n"
385 "(KA/Pi) " +version + " - " + 386 "(KA/Pi) " +version + " - " +
386#ifdef DESKTOP_VERSION 387#ifdef DESKTOP_VERSION
387 "Desktop Edition\n" 388 "Desktop Edition\n"
388#else 389#else
389 "PDA-Edition\n" 390 "PDA-Edition\n"
390 "for: Zaurus 5500 / 7x0 / 8x0\n" 391 "for: Zaurus 5500 / 7x0 / 8x0\n"
391#endif 392#endif
392 393
393 "(c) 2004 Ulf Schenk\n" 394 "(c) 2004 Ulf Schenk\n"
394 "(c) 1997-2003, The KDE PIM Team\n" 395 "(c) 1997-2003, The KDE PIM Team\n"
395 "Tobias Koenig Current maintainer tokoe@kde.org\n" 396 "Tobias Koenig Current maintainer tokoe@kde.org\n"
396 "Don Sanders Original author\n" 397 "Don Sanders Original author\n"
397 "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" 398 "Cornelius Schumacher Co-maintainer schumacher@kde.org\n"
398 "Mike Pilone GUI and framework redesign mpilone@slac.com\n" 399 "Mike Pilone GUI and framework redesign mpilone@slac.com\n"
399 "Greg Stern DCOP interface\n" 400 "Greg Stern DCOP interface\n"
400 "Mark Westcot Contact pinning\n" 401 "Mark Westcot Contact pinning\n"
401 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 402 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
402 "Steffen Hansen LDAP Lookup hansen@kde.org\n" 403 "Steffen Hansen LDAP Lookup hansen@kde.org\n"
403#ifdef _WIN32_ 404#ifdef _WIN32_
404 "(c) 2004 Lutz Rogowski Import from OL rogowski@kde.org\n" 405 "(c) 2004 Lutz Rogowski Import from OL rogowski@kde.org\n"
405#endif 406#endif
406 ); 407 );
407} 408}
408 409
409void KABCore::setContactSelected( const QString &uid ) 410void KABCore::setContactSelected( const QString &uid )
410{ 411{
411 KABC::Addressee addr = mAddressBook->findByUid( uid ); 412 KABC::Addressee addr = mAddressBook->findByUid( uid );
412 if ( !mDetails->isHidden() ) 413 if ( !mDetails->isHidden() )
413 mDetails->setAddressee( addr ); 414 mDetails->setAddressee( addr );
414 415
415 if ( !addr.isEmpty() ) { 416 if ( !addr.isEmpty() ) {
416 emit contactSelected( addr.formattedName() ); 417 emit contactSelected( addr.formattedName() );
417 KABC::Picture pic = addr.photo(); 418 KABC::Picture pic = addr.photo();
418 if ( pic.isIntern() ) { 419 if ( pic.isIntern() ) {
419//US emit contactSelected( pic.data() ); 420//US emit contactSelected( pic.data() );
420//US instead use: 421//US instead use:
421 QPixmap px; 422 QPixmap px;
422 if (pic.data().isNull() != true) 423 if (pic.data().isNull() != true)
423 { 424 {
424 px.convertFromImage(pic.data()); 425 px.convertFromImage(pic.data());
425 } 426 }
426 427
427 emit contactSelected( px ); 428 emit contactSelected( px );
428 } 429 }
429 } 430 }
430 431
431 432
432 mExtensionManager->setSelectionChanged(); 433 mExtensionManager->setSelectionChanged();
433 434
434 // update the actions 435 // update the actions
435 bool selected = !uid.isEmpty(); 436 bool selected = !uid.isEmpty();
436 437
437 if ( mReadWrite ) { 438 if ( mReadWrite ) {
438 mActionCut->setEnabled( selected ); 439 mActionCut->setEnabled( selected );
439 mActionPaste->setEnabled( selected ); 440 mActionPaste->setEnabled( selected );
440 } 441 }
441 442
442 mActionCopy->setEnabled( selected ); 443 mActionCopy->setEnabled( selected );
443 mActionDelete->setEnabled( selected ); 444 mActionDelete->setEnabled( selected );
444 mActionEditAddressee->setEnabled( selected ); 445 mActionEditAddressee->setEnabled( selected );
445 mActionMail->setEnabled( selected ); 446 mActionMail->setEnabled( selected );
446 mActionMailVCard->setEnabled( selected ); 447 mActionMailVCard->setEnabled( selected );
447 mActionWhoAmI->setEnabled( selected ); 448 mActionWhoAmI->setEnabled( selected );
448 mActionCategories->setEnabled( selected ); 449 mActionCategories->setEnabled( selected );
449} 450}
450 451
451void KABCore::sendMail() 452void KABCore::sendMail()
452{ 453{
453#ifndef KAB_EMBEDDED 454#ifndef KAB_EMBEDDED
454 sendMail( mViewManager->selectedEmails().join( ", " ) ); 455 sendMail( mViewManager->selectedEmails().join( ", " ) );
455#else //KAB_EMBEDDED 456#else //KAB_EMBEDDED
456 qDebug("KABCore::sendMail() ust be fixed"); 457 qDebug("KABCore::sendMail() ust be fixed");
457#endif //KAB_EMBEDDED 458#endif //KAB_EMBEDDED
458} 459}
459 460
460void KABCore::sendMail( const QString& email ) 461void KABCore::sendMail( const QString& email )
461{ 462{
462#ifndef KAB_EMBEDDED 463#ifndef KAB_EMBEDDED
463 kapp->invokeMailer( email, "" ); 464 kapp->invokeMailer( email, "" );
464#else //KAB_EMBEDDED 465#else //KAB_EMBEDDED
465 qDebug("KABCore::sendMail(const QString& email) ust be fixed"); 466 qDebug("KABCore::sendMail(const QString& email) ust be fixed");
466#endif //KAB_EMBEDDED 467#endif //KAB_EMBEDDED
467} 468}
468 469
469void KABCore::mailVCard() 470void KABCore::mailVCard()
470{ 471{
471#ifndef KAB_EMBEDDED 472#ifndef KAB_EMBEDDED
472 QStringList uids = mViewManager->selectedUids(); 473 QStringList uids = mViewManager->selectedUids();
473 if ( !uids.isEmpty() ) 474 if ( !uids.isEmpty() )
474 mailVCard( uids ); 475 mailVCard( uids );
475#else //KAB_EMBEDDED 476#else //KAB_EMBEDDED
476 qDebug("KABCore::mailVCard() must be fixed"); 477 qDebug("KABCore::mailVCard() must be fixed");
477#endif //KAB_EMBEDDED 478#endif //KAB_EMBEDDED
478} 479}
479 480
480void KABCore::mailVCard( const QStringList& uids ) 481void KABCore::mailVCard( const QStringList& uids )
481{ 482{
482#ifndef KAB_EMBEDDED 483#ifndef KAB_EMBEDDED
483 QStringList urls; 484 QStringList urls;
484 485
485 // Create a temp dir, so that we can put the files in it with proper names 486 // Create a temp dir, so that we can put the files in it with proper names
486 KTempFile tempDir; 487 KTempFile tempDir;
487 if ( tempDir.status() != 0 ) { 488 if ( tempDir.status() != 0 ) {
488 kdWarning() << strerror( tempDir.status() ) << endl; 489 kdWarning() << strerror( tempDir.status() ) << endl;
489 return; 490 return;
490 } 491 }
491 492
492 QString dirName = tempDir.name(); 493 QString dirName = tempDir.name();
493 tempDir.unlink(); 494 tempDir.unlink();
494 QDir().mkdir( dirName, true ); 495 QDir().mkdir( dirName, true );
495 496
496 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 497 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
497 KABC::Addressee a = mAddressBook->findByUid( *it ); 498 KABC::Addressee a = mAddressBook->findByUid( *it );
498 499
499 if ( a.isEmpty() ) 500 if ( a.isEmpty() )
500 continue; 501 continue;
501 502
502 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 503 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
503 504
504 QString fileName = dirName + "/" + name; 505 QString fileName = dirName + "/" + name;
505 506
506 QFile outFile(fileName); 507 QFile outFile(fileName);
507 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 508 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
508 KABC::VCardConverter converter; 509 KABC::VCardConverter converter;
509 QString vcard; 510 QString vcard;
510 511
511 converter.addresseeToVCard( a, vcard ); 512 converter.addresseeToVCard( a, vcard );
512 513
513 QTextStream t( &outFile ); // use a text stream 514 QTextStream t( &outFile ); // use a text stream
514 t.setEncoding( QTextStream::UnicodeUTF8 ); 515 t.setEncoding( QTextStream::UnicodeUTF8 );
515 t << vcard; 516 t << vcard;
516 517
517 outFile.close(); 518 outFile.close();
518 519
519 urls.append( fileName ); 520 urls.append( fileName );
520 } 521 }
521 } 522 }
522 523
523 kapp->invokeMailer( QString::null, QString::null, QString::null, 524 kapp->invokeMailer( QString::null, QString::null, QString::null,
524 QString::null, // subject 525 QString::null, // subject
525 QString::null, // body 526 QString::null, // body
526 QString::null, 527 QString::null,
527 urls ); // attachments 528 urls ); // attachments
528#else //KAB_EMBEDDED 529#else //KAB_EMBEDDED
529 qDebug("KABCore::mailVCard( must be fixed"); 530 qDebug("KABCore::mailVCard( must be fixed");
530#endif //KAB_EMBEDDED 531#endif //KAB_EMBEDDED
531 532
532} 533}
533 534
534void KABCore::browse( const QString& url ) 535void KABCore::browse( const QString& url )
535{ 536{
536#ifndef KAB_EMBEDDED 537#ifndef KAB_EMBEDDED
537 kapp->invokeBrowser( url ); 538 kapp->invokeBrowser( url );
538#else //KAB_EMBEDDED 539#else //KAB_EMBEDDED
539 qDebug("KABCore::browse must be fixed"); 540 qDebug("KABCore::browse must be fixed");
540#endif //KAB_EMBEDDED 541#endif //KAB_EMBEDDED
541} 542}
542 543
543void KABCore::selectAllContacts() 544void KABCore::selectAllContacts()
544{ 545{
545 mViewManager->setSelected( QString::null, true ); 546 mViewManager->setSelected( QString::null, true );
546} 547}
547 548
548void KABCore::deleteContacts() 549void KABCore::deleteContacts()
549{ 550{
550 QStringList uidList = mViewManager->selectedUids(); 551 QStringList uidList = mViewManager->selectedUids();
551 deleteContacts( uidList ); 552 deleteContacts( uidList );
552} 553}
553 554
554void KABCore::deleteContacts( const QStringList &uids ) 555void KABCore::deleteContacts( const QStringList &uids )
555{ 556{
556 if ( uids.count() > 0 ) { 557 if ( uids.count() > 0 ) {
557 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 558 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
558 UndoStack::instance()->push( command ); 559 UndoStack::instance()->push( command );
559 RedoStack::instance()->clear(); 560 RedoStack::instance()->clear();
560 561
561 // now if we deleted anything, refresh 562 // now if we deleted anything, refresh
562 setContactSelected( QString::null ); 563 setContactSelected( QString::null );
563 setModified( true ); 564 setModified( true );
564 } 565 }
565} 566}
566 567
567void KABCore::copyContacts() 568void KABCore::copyContacts()
568{ 569{
569 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 570 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
570 571
571 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 572 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
572 573
573 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 574 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
574 575
575 QClipboard *cb = QApplication::clipboard(); 576 QClipboard *cb = QApplication::clipboard();
576 cb->setText( clipText ); 577 cb->setText( clipText );
577} 578}
578 579
579void KABCore::cutContacts() 580void KABCore::cutContacts()
580{ 581{
581 QStringList uidList = mViewManager->selectedUids(); 582 QStringList uidList = mViewManager->selectedUids();
582 583
583//US if ( uidList.size() > 0 ) { 584//US if ( uidList.size() > 0 ) {
584 if ( uidList.count() > 0 ) { 585 if ( uidList.count() > 0 ) {
585 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 586 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
586 UndoStack::instance()->push( command ); 587 UndoStack::instance()->push( command );
587 RedoStack::instance()->clear(); 588 RedoStack::instance()->clear();
588 589
589 setModified( true ); 590 setModified( true );
590 } 591 }
591} 592}
592 593
593void KABCore::pasteContacts() 594void KABCore::pasteContacts()
594{ 595{
595 QClipboard *cb = QApplication::clipboard(); 596 QClipboard *cb = QApplication::clipboard();
596 597
597 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 598 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
598 599
599 pasteContacts( list ); 600 pasteContacts( list );
600} 601}
601 602
602void KABCore::pasteContacts( KABC::Addressee::List &list ) 603void KABCore::pasteContacts( KABC::Addressee::List &list )
603{ 604{
604 KABC::Resource *resource = requestResource( this ); 605 KABC::Resource *resource = requestResource( this );
605 KABC::Addressee::List::Iterator it; 606 KABC::Addressee::List::Iterator it;
606 for ( it = list.begin(); it != list.end(); ++it ) 607 for ( it = list.begin(); it != list.end(); ++it )
607 (*it).setResource( resource ); 608 (*it).setResource( resource );
608 609
609 PwPasteCommand *command = new PwPasteCommand( this, list ); 610 PwPasteCommand *command = new PwPasteCommand( this, list );
610 UndoStack::instance()->push( command ); 611 UndoStack::instance()->push( command );
611 RedoStack::instance()->clear(); 612 RedoStack::instance()->clear();
612 613
613 setModified( true ); 614 setModified( true );
614} 615}
615 616
616void KABCore::setWhoAmI() 617void KABCore::setWhoAmI()
617{ 618{
618 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 619 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
619 620
620 if ( addrList.count() > 1 ) { 621 if ( addrList.count() > 1 ) {
621 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 622 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
622 return; 623 return;
623 } 624 }
624 625
625 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 626 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
626 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 627 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
627 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 628 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
628} 629}
629 630
630void KABCore::setCategories() 631void KABCore::setCategories()
631{ 632{
632 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 633 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
633 if ( !dlg.exec() ) 634 if ( !dlg.exec() )
634 return; 635 return;
635 636
636 bool merge = false; 637 bool merge = false;
637 QString msg = i18n( "Merge with existing categories?" ); 638 QString msg = i18n( "Merge with existing categories?" );
638 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 639 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
639 merge = true; 640 merge = true;
640 641
641 QStringList categories = dlg.selectedCategories(); 642 QStringList categories = dlg.selectedCategories();
642 643
643 QStringList uids = mViewManager->selectedUids(); 644 QStringList uids = mViewManager->selectedUids();
644 QStringList::Iterator it; 645 QStringList::Iterator it;
645 for ( it = uids.begin(); it != uids.end(); ++it ) { 646 for ( it = uids.begin(); it != uids.end(); ++it ) {
646 KABC::Addressee addr = mAddressBook->findByUid( *it ); 647 KABC::Addressee addr = mAddressBook->findByUid( *it );
647 if ( !addr.isEmpty() ) { 648 if ( !addr.isEmpty() ) {
648 if ( !merge ) 649 if ( !merge )
649 addr.setCategories( categories ); 650 addr.setCategories( categories );
650 else { 651 else {
651 QStringList addrCategories = addr.categories(); 652 QStringList addrCategories = addr.categories();
652 QStringList::Iterator catIt; 653 QStringList::Iterator catIt;
653 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 654 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
654 if ( !addrCategories.contains( *catIt ) ) 655 if ( !addrCategories.contains( *catIt ) )
655 addrCategories.append( *catIt ); 656 addrCategories.append( *catIt );
656 } 657 }
657 addr.setCategories( addrCategories ); 658 addr.setCategories( addrCategories );
658 } 659 }
659 660
660 mAddressBook->insertAddressee( addr ); 661 mAddressBook->insertAddressee( addr );
661 } 662 }
662 } 663 }
663 664
664 if ( uids.count() > 0 ) 665 if ( uids.count() > 0 )
665 setModified( true ); 666 setModified( true );
666} 667}
667 668
668void KABCore::setSearchFields( const KABC::Field::List &fields ) 669void KABCore::setSearchFields( const KABC::Field::List &fields )
669{ 670{
670 mIncSearchWidget->setFields( fields ); 671 mIncSearchWidget->setFields( fields );
671} 672}
672 673
673void KABCore::incrementalSearch( const QString& text ) 674void KABCore::incrementalSearch( const QString& text )
674{ 675{
675 mViewManager->setSelected( QString::null, false ); 676 mViewManager->setSelected( QString::null, false );
676 677
677 if ( !text.isEmpty() ) { 678 if ( !text.isEmpty() ) {
678 KABC::Field *field = mIncSearchWidget->currentField(); 679 KABC::Field *field = mIncSearchWidget->currentField();
679 680
680 QString pattern = text.lower(); 681 QString pattern = text.lower();
681 682
682#if 1 //KDE_VERSION >= 319 683#if 1 //KDE_VERSION >= 319
683 KABC::AddresseeList list( mAddressBook->allAddressees() ); 684 KABC::AddresseeList list( mAddressBook->allAddressees() );
684 if ( field ) { 685 if ( field ) {
685 list.sortByField( field ); 686 list.sortByField( field );
686 KABC::AddresseeList::Iterator it; 687 KABC::AddresseeList::Iterator it;
687 for ( it = list.begin(); it != list.end(); ++it ) { 688 for ( it = list.begin(); it != list.end(); ++it ) {
688 if ( field->value( *it ).lower().startsWith( pattern ) ) { 689 if ( field->value( *it ).lower().startsWith( pattern ) ) {
689 mViewManager->setSelected( (*it).uid(), true ); 690 mViewManager->setSelected( (*it).uid(), true );
690 return; 691 return;
691 } 692 }
692 } 693 }
693 } else { 694 } else {
694 KABC::AddresseeList::Iterator it; 695 KABC::AddresseeList::Iterator it;
695 for ( it = list.begin(); it != list.end(); ++it ) { 696 for ( it = list.begin(); it != list.end(); ++it ) {
696 KABC::Field::List fieldList = mIncSearchWidget->fields(); 697 KABC::Field::List fieldList = mIncSearchWidget->fields();
697 KABC::Field::List::ConstIterator fieldIt; 698 KABC::Field::List::ConstIterator fieldIt;
698 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 699 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
699 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 700 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
700 mViewManager->setSelected( (*it).uid(), true ); 701 mViewManager->setSelected( (*it).uid(), true );
701 return; 702 return;
702 } 703 }
703 } 704 }
704 } 705 }
705 } 706 }
706#else 707#else
707 KABC::AddressBook::Iterator it; 708 KABC::AddressBook::Iterator it;
708 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 709 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
709 if ( field ) { 710 if ( field ) {
710 if ( field->value( *it ).lower().startsWith( pattern ) ) { 711 if ( field->value( *it ).lower().startsWith( pattern ) ) {
711 mViewManager->setSelected( (*it).uid(), true ); 712 mViewManager->setSelected( (*it).uid(), true );
712 return; 713 return;
713 } 714 }
714 } else { 715 } else {
715 KABC::Field::List fieldList = mIncSearchWidget->fields(); 716 KABC::Field::List fieldList = mIncSearchWidget->fields();
716 KABC::Field::List::ConstIterator fieldIt; 717 KABC::Field::List::ConstIterator fieldIt;
717 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 718 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
718 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 719 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
719 mViewManager->setSelected( (*it).uid(), true ); 720 mViewManager->setSelected( (*it).uid(), true );
720 return; 721 return;
721 } 722 }
722 } 723 }
723 } 724 }
724 } 725 }
725#endif 726#endif
726 } 727 }
727} 728}
728 729
729void KABCore::setModified() 730void KABCore::setModified()
730{ 731{
731 setModified( true ); 732 setModified( true );
732} 733}
733 734
734void KABCore::setModifiedWOrefresh() 735void KABCore::setModifiedWOrefresh()
735{ 736{
736 // qDebug("KABCore::setModifiedWOrefresh() "); 737 // qDebug("KABCore::setModifiedWOrefresh() ");
737 mModified = true; 738 mModified = true;
738 mActionSave->setEnabled( mModified ); 739 mActionSave->setEnabled( mModified );
739#ifdef DESKTOP_VERSION 740#ifdef DESKTOP_VERSION
740 mDetails->refreshView(); 741 mDetails->refreshView();
741#endif 742#endif
742 743
743} 744}
744void KABCore::setModified( bool modified ) 745void KABCore::setModified( bool modified )
745{ 746{
746 mModified = modified; 747 mModified = modified;
747 mActionSave->setEnabled( mModified ); 748 mActionSave->setEnabled( mModified );
748 749
749 if ( modified ) 750 if ( modified )
750 mJumpButtonBar->recreateButtons(); 751 mJumpButtonBar->recreateButtons();
751 752
752 mViewManager->refreshView(); 753 mViewManager->refreshView();
753 mDetails->refreshView(); 754 mDetails->refreshView();
754 755
755} 756}
756 757
757bool KABCore::modified() const 758bool KABCore::modified() const
758{ 759{
759 return mModified; 760 return mModified;
760} 761}
761 762
762void KABCore::contactModified( const KABC::Addressee &addr ) 763void KABCore::contactModified( const KABC::Addressee &addr )
763{ 764{
764 765
765 Command *command = 0; 766 Command *command = 0;
766 QString uid; 767 QString uid;
767 768
768 // check if it exists already 769 // check if it exists already
769 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 770 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
770 if ( origAddr.isEmpty() ) 771 if ( origAddr.isEmpty() )
771 command = new PwNewCommand( mAddressBook, addr ); 772 command = new PwNewCommand( mAddressBook, addr );
772 else { 773 else {
773 command = new PwEditCommand( mAddressBook, origAddr, addr ); 774 command = new PwEditCommand( mAddressBook, origAddr, addr );
774 uid = addr.uid(); 775 uid = addr.uid();
775 } 776 }
776 777
777 UndoStack::instance()->push( command ); 778 UndoStack::instance()->push( command );
778 RedoStack::instance()->clear(); 779 RedoStack::instance()->clear();
779 780
780 setModified( true ); 781 setModified( true );
781} 782}
782 783
783void KABCore::newContact() 784void KABCore::newContact()
784{ 785{
785 786
786 787
787 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 788 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
788 789
789 QPtrList<KRES::Resource> kresResources; 790 QPtrList<KRES::Resource> kresResources;
790 QPtrListIterator<KABC::Resource> it( kabcResources ); 791 QPtrListIterator<KABC::Resource> it( kabcResources );
791 KABC::Resource *resource; 792 KABC::Resource *resource;
792 while ( ( resource = it.current() ) != 0 ) { 793 while ( ( resource = it.current() ) != 0 ) {
793 ++it; 794 ++it;
794 if ( !resource->readOnly() ) { 795 if ( !resource->readOnly() ) {
795 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 796 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
796 if ( res ) 797 if ( res )
797 kresResources.append( res ); 798 kresResources.append( res );
798 } 799 }
799 } 800 }
800 801
801 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 802 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
802 resource = static_cast<KABC::Resource*>( res ); 803 resource = static_cast<KABC::Resource*>( res );
803 804
804 if ( resource ) { 805 if ( resource ) {
805 KABC::Addressee addr; 806 KABC::Addressee addr;
806 addr.setResource( resource ); 807 addr.setResource( resource );
807 mEditorDialog->setAddressee( addr ); 808 mEditorDialog->setAddressee( addr );
808 KApplication::execDialog ( mEditorDialog ); 809 KApplication::execDialog ( mEditorDialog );
809 810
810 } else 811 } else
811 return; 812 return;
812 813
813 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 814 // mEditorDict.insert( dialog->addressee().uid(), dialog );
814 815
815 816
816} 817}
817 818
818void KABCore::addEmail( QString aStr ) 819void KABCore::addEmail( QString aStr )
819{ 820{
820#ifndef KAB_EMBEDDED 821#ifndef KAB_EMBEDDED
821 QString fullName, email; 822 QString fullName, email;
822 823
823 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 824 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
824 825
825 // Try to lookup the addressee matching the email address 826 // Try to lookup the addressee matching the email address
826 bool found = false; 827 bool found = false;
827 QStringList emailList; 828 QStringList emailList;
828 KABC::AddressBook::Iterator it; 829 KABC::AddressBook::Iterator it;
829 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 830 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
830 emailList = (*it).emails(); 831 emailList = (*it).emails();
831 if ( emailList.contains( email ) > 0 ) { 832 if ( emailList.contains( email ) > 0 ) {
832 found = true; 833 found = true;
833 (*it).setNameFromString( fullName ); 834 (*it).setNameFromString( fullName );
834 editContact( (*it).uid() ); 835 editContact( (*it).uid() );
835 } 836 }
836 } 837 }
837 838
838 if ( !found ) { 839 if ( !found ) {
839 KABC::Addressee addr; 840 KABC::Addressee addr;
840 addr.setNameFromString( fullName ); 841 addr.setNameFromString( fullName );
841 addr.insertEmail( email, true ); 842 addr.insertEmail( email, true );
842 843
843 mAddressBook->insertAddressee( addr ); 844 mAddressBook->insertAddressee( addr );
844 mViewManager->refreshView( addr.uid() ); 845 mViewManager->refreshView( addr.uid() );
845 editContact( addr.uid() ); 846 editContact( addr.uid() );
846 } 847 }
847#else //KAB_EMBEDDED 848#else //KAB_EMBEDDED
848 qDebug("KABCore::addEmail finsih method"); 849 qDebug("KABCore::addEmail finsih method");
849#endif //KAB_EMBEDDED 850#endif //KAB_EMBEDDED
850} 851}
851 852
852void KABCore::importVCard( const KURL &url, bool showPreview ) 853void KABCore::importVCard( const KURL &url, bool showPreview )
853{ 854{
854 mXXPortManager->importVCard( url, showPreview ); 855 mXXPortManager->importVCard( url, showPreview );
855} 856}
856void KABCore::importFromOL() 857void KABCore::importFromOL()
857{ 858{
858#ifdef _WIN32_ 859#ifdef _WIN32_
859 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 860 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
860 idgl->exec(); 861 idgl->exec();
861 KABC::Addressee::List list = idgl->getAddressList(); 862 KABC::Addressee::List list = idgl->getAddressList();
862 if ( list.count() > 0 ) { 863 if ( list.count() > 0 ) {
863 KABC::Addressee::List listNew; 864 KABC::Addressee::List listNew;
864 KABC::Addressee::List listExisting; 865 KABC::Addressee::List listExisting;
865 KABC::Addressee::List::Iterator it; 866 KABC::Addressee::List::Iterator it;
866 KABC::AddressBook::Iterator iter; 867 KABC::AddressBook::Iterator iter;
867 for ( it = list.begin(); it != list.end(); ++it ) { 868 for ( it = list.begin(); it != list.end(); ++it ) {
868 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 869 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
869 listNew.append( (*it) ); 870 listNew.append( (*it) );
870 else 871 else
871 listExisting.append( (*it) ); 872 listExisting.append( (*it) );
872 } 873 }
873 if ( listExisting.count() > 0 ) 874 if ( listExisting.count() > 0 )
874 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 875 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
875 if ( listNew.count() > 0 ) { 876 if ( listNew.count() > 0 ) {
876 pasteWithNewUid = false; 877 pasteWithNewUid = false;
877 pasteContacts( listNew ); 878 pasteContacts( listNew );
878 pasteWithNewUid = true; 879 pasteWithNewUid = true;
879 } 880 }
880 } 881 }
881 delete idgl; 882 delete idgl;
882#endif 883#endif
883} 884}
884 885
885void KABCore::importVCard( const QString &vCard, bool showPreview ) 886void KABCore::importVCard( const QString &vCard, bool showPreview )
886{ 887{
887 mXXPortManager->importVCard( vCard, showPreview ); 888 mXXPortManager->importVCard( vCard, showPreview );
888} 889}
889 890
890//US added a second method without defaultparameter 891//US added a second method without defaultparameter
891void KABCore::editContact2() { 892void KABCore::editContact2() {
892 editContact( QString::null ); 893 editContact( QString::null );
893} 894}
894 895
895void KABCore::editContact( const QString &uid ) 896void KABCore::editContact( const QString &uid )
896{ 897{
897 898
898 if ( mExtensionManager->isQuickEditVisible() ) 899 if ( mExtensionManager->isQuickEditVisible() )
899 return; 900 return;
900 901
901 // First, locate the contact entry 902 // First, locate the contact entry
902 QString localUID = uid; 903 QString localUID = uid;
903 if ( localUID.isNull() ) { 904 if ( localUID.isNull() ) {
904 QStringList uidList = mViewManager->selectedUids(); 905 QStringList uidList = mViewManager->selectedUids();
905 if ( uidList.count() > 0 ) 906 if ( uidList.count() > 0 )
906 localUID = *( uidList.at( 0 ) ); 907 localUID = *( uidList.at( 0 ) );
907 } 908 }
908 909
909 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 910 KABC::Addressee addr = mAddressBook->findByUid( localUID );
910 if ( !addr.isEmpty() ) { 911 if ( !addr.isEmpty() ) {
911 mEditorDialog->setAddressee( addr ); 912 mEditorDialog->setAddressee( addr );
912 KApplication::execDialog ( mEditorDialog ); 913 KApplication::execDialog ( mEditorDialog );
913 } 914 }
914} 915}
915 916
916void KABCore::save() 917void KABCore::save()
917{ 918{
918 if ( !mModified ) 919 if ( !mModified )
919 return; 920 return;
920 QString text = i18n( "There was an error while attempting to save\n the " 921 QString text = i18n( "There was an error while attempting to save\n the "
921 "address book. Please check that some \nother application is " 922 "address book. Please check that some \nother application is "
922 "not using it. " ); 923 "not using it. " );
923 statusMessage(i18n("Saving addressbook ... ")); 924 statusMessage(i18n("Saving addressbook ... "));
924#ifndef KAB_EMBEDDED 925#ifndef KAB_EMBEDDED
925 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 926 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
926 if ( !b || !b->save() ) { 927 if ( !b || !b->save() ) {
927 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 928 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
928 } 929 }
929#else //KAB_EMBEDDED 930#else //KAB_EMBEDDED
930 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 931 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
931 if ( !b || !b->save() ) { 932 if ( !b || !b->save() ) {
932 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 933 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
933 } 934 }
934#endif //KAB_EMBEDDED 935#endif //KAB_EMBEDDED
935 936
936 statusMessage(i18n("Addressbook saved!")); 937 statusMessage(i18n("Addressbook saved!"));
937 setModified( false ); 938 setModified( false );
938} 939}
939 940
940void KABCore::statusMessage(QString mess , int time ) 941void KABCore::statusMessage(QString mess , int time )
941{ 942{
942 //topLevelWidget()->setCaption( mess ); 943 //topLevelWidget()->setCaption( mess );
943 // pending setting timer to revome message 944 // pending setting timer to revome message
944} 945}
945void KABCore::undo() 946void KABCore::undo()
946{ 947{
947 UndoStack::instance()->undo(); 948 UndoStack::instance()->undo();
948 949
949 // Refresh the view 950 // Refresh the view
950 mViewManager->refreshView(); 951 mViewManager->refreshView();
951} 952}
952 953
953void KABCore::redo() 954void KABCore::redo()
954{ 955{
955 RedoStack::instance()->redo(); 956 RedoStack::instance()->redo();
956 957
957 // Refresh the view 958 // Refresh the view
958 mViewManager->refreshView(); 959 mViewManager->refreshView();
959} 960}
960 961
961void KABCore::setJumpButtonBarVisible( bool visible ) 962void KABCore::setJumpButtonBarVisible( bool visible )
962{ 963{
963 if ( visible ) 964 if ( visible )
964 mJumpButtonBar->show(); 965 mJumpButtonBar->show();
965 else 966 else
966 mJumpButtonBar->hide(); 967 mJumpButtonBar->hide();
967} 968}
968void KABCore::setDetailsToState() 969void KABCore::setDetailsToState()
969{ 970{
970 setDetailsVisible( mActionDetails->isChecked() ); 971 setDetailsVisible( mActionDetails->isChecked() );
971} 972}
972 973
973void KABCore::setDetailsVisible( bool visible ) 974void KABCore::setDetailsVisible( bool visible )
974{ 975{
975 if ( visible ) 976 if ( visible )
976 mDetails->show(); 977 mDetails->show();
977 else 978 else
978 mDetails->hide(); 979 mDetails->hide();
979} 980}
980 981
981void KABCore::extensionModified( const KABC::Addressee::List &list ) 982void KABCore::extensionModified( const KABC::Addressee::List &list )
982{ 983{
983 984
984 if ( list.count() != 0 ) { 985 if ( list.count() != 0 ) {
985 KABC::Addressee::List::ConstIterator it; 986 KABC::Addressee::List::ConstIterator it;
986 for ( it = list.begin(); it != list.end(); ++it ) 987 for ( it = list.begin(); it != list.end(); ++it )
987 mAddressBook->insertAddressee( *it ); 988 mAddressBook->insertAddressee( *it );
988 if ( list.count() > 1 ) 989 if ( list.count() > 1 )
989 setModified(); 990 setModified();
990 else 991 else
991 setModifiedWOrefresh(); 992 setModifiedWOrefresh();
992 } 993 }
993 if ( list.count() == 0 ) 994 if ( list.count() == 0 )
994 mViewManager->refreshView(); 995 mViewManager->refreshView();
995 else 996 else
996 mViewManager->refreshView( list[ 0 ].uid() ); 997 mViewManager->refreshView( list[ 0 ].uid() );
997 998
998 999
999 1000
1000} 1001}
1001 1002
1002QString KABCore::getNameByPhone( const QString &phone ) 1003QString KABCore::getNameByPhone( const QString &phone )
1003{ 1004{
1004#ifndef KAB_EMBEDDED 1005#ifndef KAB_EMBEDDED
1005 QRegExp r( "[/*/-/ ]" ); 1006 QRegExp r( "[/*/-/ ]" );
1006 QString localPhone( phone ); 1007 QString localPhone( phone );
1007 1008
1008 bool found = false; 1009 bool found = false;
1009 QString ownerName = ""; 1010 QString ownerName = "";
1010 KABC::AddressBook::Iterator iter; 1011 KABC::AddressBook::Iterator iter;
1011 KABC::PhoneNumber::List::Iterator phoneIter; 1012 KABC::PhoneNumber::List::Iterator phoneIter;
1012 KABC::PhoneNumber::List phoneList; 1013 KABC::PhoneNumber::List phoneList;
1013 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1014 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1014 phoneList = (*iter).phoneNumbers(); 1015 phoneList = (*iter).phoneNumbers();
1015 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1016 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1016 ++phoneIter) { 1017 ++phoneIter) {
1017 // Get rid of separator chars so just the numbers are compared. 1018 // Get rid of separator chars so just the numbers are compared.
1018 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1019 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1019 ownerName = (*iter).formattedName(); 1020 ownerName = (*iter).formattedName();
1020 found = true; 1021 found = true;
1021 } 1022 }
1022 } 1023 }
1023 } 1024 }
1024 1025
1025 return ownerName; 1026 return ownerName;
1026#else //KAB_EMBEDDED 1027#else //KAB_EMBEDDED
1027 qDebug("KABCore::getNameByPhone finsih method"); 1028 qDebug("KABCore::getNameByPhone finsih method");
1028 return ""; 1029 return "";
1029#endif //KAB_EMBEDDED 1030#endif //KAB_EMBEDDED
1030 1031
1031} 1032}
1032 1033
1033void KABCore::openConfigDialog() 1034void KABCore::openConfigDialog()
1034{ 1035{
1035 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1036 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1036 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1037 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1037 ConfigureDialog->addModule(kabcfg ); 1038 ConfigureDialog->addModule(kabcfg );
1038 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1039 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1039 this, SLOT( configurationChanged() ) ); 1040 this, SLOT( configurationChanged() ) );
1040 connect( ConfigureDialog, SIGNAL( okClicked() ), 1041 connect( ConfigureDialog, SIGNAL( okClicked() ),
1041 this, SLOT( configurationChanged() ) ); 1042 this, SLOT( configurationChanged() ) );
1042 saveSettings(); 1043 saveSettings();
1043 ConfigureDialog->showMaximized(); 1044 ConfigureDialog->showMaximized();
1044 if ( ConfigureDialog->exec() ) 1045 if ( ConfigureDialog->exec() )
1045 KMessageBox::information( this, i18n("If you configured \nExtensions,\nplease restart!\n") ); 1046 KMessageBox::information( this, i18n("If you configured \nExtensions,\nplease restart!\n") );
1046 delete ConfigureDialog; 1047 delete ConfigureDialog;
1047} 1048}
1048 1049
1049void KABCore::openLDAPDialog() 1050void KABCore::openLDAPDialog()
1050{ 1051{
1051#ifndef KAB_EMBEDDED 1052#ifndef KAB_EMBEDDED
1052 if ( !mLdapSearchDialog ) { 1053 if ( !mLdapSearchDialog ) {
1053 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1054 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1054 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1055 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1055 SLOT( refreshView() ) ); 1056 SLOT( refreshView() ) );
1056 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1057 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1057 SLOT( setModified() ) ); 1058 SLOT( setModified() ) );
1058 } else 1059 } else
1059 mLdapSearchDialog->restoreSettings(); 1060 mLdapSearchDialog->restoreSettings();
1060 1061
1061 if ( mLdapSearchDialog->isOK() ) 1062 if ( mLdapSearchDialog->isOK() )
1062 mLdapSearchDialog->exec(); 1063 mLdapSearchDialog->exec();
1063#else //KAB_EMBEDDED 1064#else //KAB_EMBEDDED
1064 qDebug("KABCore::openLDAPDialog() finsih method"); 1065 qDebug("KABCore::openLDAPDialog() finsih method");
1065#endif //KAB_EMBEDDED 1066#endif //KAB_EMBEDDED
1066} 1067}
1067 1068
1068void KABCore::print() 1069void KABCore::print()
1069{ 1070{
1070#ifndef KAB_EMBEDDED 1071#ifndef KAB_EMBEDDED
1071 KPrinter printer; 1072 KPrinter printer;
1072 if ( !printer.setup( this ) ) 1073 if ( !printer.setup( this ) )
1073 return; 1074 return;
1074 1075
1075 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1076 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1076 mViewManager->selectedUids(), this ); 1077 mViewManager->selectedUids(), this );
1077 1078
1078 wizard.exec(); 1079 wizard.exec();
1079#else //KAB_EMBEDDED 1080#else //KAB_EMBEDDED
1080 qDebug("KABCore::print() finsih method"); 1081 qDebug("KABCore::print() finsih method");
1081#endif //KAB_EMBEDDED 1082#endif //KAB_EMBEDDED
1082 1083
1083} 1084}
1084 1085
1085 1086
1086void KABCore::addGUIClient( KXMLGUIClient *client ) 1087void KABCore::addGUIClient( KXMLGUIClient *client )
1087{ 1088{
1088 if ( mGUIClient ) 1089 if ( mGUIClient )
1089 mGUIClient->insertChildClient( client ); 1090 mGUIClient->insertChildClient( client );
1090 else 1091 else
1091 KMessageBox::error( this, "no KXMLGUICLient"); 1092 KMessageBox::error( this, "no KXMLGUICLient");
1092} 1093}
1093 1094
1094 1095
1095void KABCore::configurationChanged() 1096void KABCore::configurationChanged()
1096{ 1097{
1097 mExtensionManager->reconfigure(); 1098 mExtensionManager->reconfigure();
1098} 1099}
1099 1100
1100void KABCore::addressBookChanged() 1101void KABCore::addressBookChanged()
1101{ 1102{
1102#ifndef KAB_EMBEDDED 1103#ifndef KAB_EMBEDDED
1103 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1104 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1104 while ( it.current() ) { 1105 while ( it.current() ) {
1105 if ( it.current()->dirty() ) { 1106 if ( it.current()->dirty() ) {
1106 QString text = i18n( "Data has been changed externally. Unsaved " 1107 QString text = i18n( "Data has been changed externally. Unsaved "
1107 "changes will be lost." ); 1108 "changes will be lost." );
1108 KMessageBox::information( this, text ); 1109 KMessageBox::information( this, text );
1109 } 1110 }
1110 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1111 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1111 ++it; 1112 ++it;
1112 } 1113 }
1113 1114
1114 mViewManager->refreshView(); 1115 mViewManager->refreshView();
1115#else //KAB_EMBEDDED 1116#else //KAB_EMBEDDED
1116 qDebug("KABCore::addressBookChanged() finsih method"); 1117 qDebug("KABCore::addressBookChanged() finsih method");
1117#endif //KAB_EMBEDDED 1118#endif //KAB_EMBEDDED
1118} 1119}
1119 1120
1120AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1121AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1121 const char *name ) 1122 const char *name )
1122{ 1123{
1123 1124
1124 if ( mEditorDialog == 0 ) { 1125 if ( mEditorDialog == 0 ) {
1125 mEditorDialog = new AddresseeEditorDialog( this, parent, 1126 mEditorDialog = new AddresseeEditorDialog( this, parent,
1126 name ? name : "editorDialog" ); 1127 name ? name : "editorDialog" );
1127 1128
1128 1129
1129 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1130 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1130 SLOT( contactModified( const KABC::Addressee& ) ) ); 1131 SLOT( contactModified( const KABC::Addressee& ) ) );
1131 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1132 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1132 // SLOT( slotEditorDestroyed( const QString& ) ) ); 1133 // SLOT( slotEditorDestroyed( const QString& ) ) );
1133 } 1134 }
1134 1135
1135 return mEditorDialog; 1136 return mEditorDialog;
1136} 1137}
1137 1138
1138void KABCore::slotEditorDestroyed( const QString &uid ) 1139void KABCore::slotEditorDestroyed( const QString &uid )
1139{ 1140{
1140 qDebug("KABCore::slotEditorDestroyed called. maybe a problem! "); 1141 qDebug("KABCore::slotEditorDestroyed called. maybe a problem! ");
1141 //mEditorDict.remove( uid ); 1142 //mEditorDict.remove( uid );
1142} 1143}
1143 1144
1144void KABCore::initGUI() 1145void KABCore::initGUI()
1145{ 1146{
1146#ifndef KAB_EMBEDDED 1147#ifndef KAB_EMBEDDED
1147 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1148 QHBoxLayout *topLayout = new QHBoxLayout( this );
1148 topLayout->setSpacing( KDialogBase::spacingHint() ); 1149 topLayout->setSpacing( KDialogBase::spacingHint() );
1149 1150
1150 mExtensionBarSplitter = new QSplitter( this ); 1151 mExtensionBarSplitter = new QSplitter( this );
1151 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1152 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1152 1153
1153 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1154 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1154 1155
1155 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1156 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1156 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1157 mIncSearchWidget = new IncSearchWidget( viewSpace );
1157 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1158 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1158 SLOT( incrementalSearch( const QString& ) ) ); 1159 SLOT( incrementalSearch( const QString& ) ) );
1159 1160
1160 mViewManager = new ViewManager( this, viewSpace ); 1161 mViewManager = new ViewManager( this, viewSpace );
1161 viewSpace->setStretchFactor( mViewManager, 1 ); 1162 viewSpace->setStretchFactor( mViewManager, 1 );
1162 1163
1163 mDetails = new ViewContainer( mDetailsSplitter ); 1164 mDetails = new ViewContainer( mDetailsSplitter );
1164 1165
1165 mJumpButtonBar = new JumpButtonBar( this, this ); 1166 mJumpButtonBar = new JumpButtonBar( this, this );
1166 1167
1167 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1168 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1168 1169
1169 topLayout->addWidget( mExtensionBarSplitter ); 1170 topLayout->addWidget( mExtensionBarSplitter );
1170 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1171 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1171 topLayout->addWidget( mJumpButtonBar ); 1172 topLayout->addWidget( mJumpButtonBar );
1172 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1173 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1173 1174
1174 mXXPortManager = new XXPortManager( this, this ); 1175 mXXPortManager = new XXPortManager( this, this );
1175 1176
1176#else //KAB_EMBEDDED 1177#else //KAB_EMBEDDED
1177 //US initialize viewMenu before settingup viewmanager. 1178 //US initialize viewMenu before settingup viewmanager.
1178 // Viewmanager needs this menu to plugin submenues. 1179 // Viewmanager needs this menu to plugin submenues.
1179 viewMenu = new QPopupMenu( this ); 1180 viewMenu = new QPopupMenu( this );
1180 settingsMenu = new QPopupMenu( this ); 1181 settingsMenu = new QPopupMenu( this );
1181 //filterMenu = new QPopupMenu( this ); 1182 //filterMenu = new QPopupMenu( this );
1182 ImportMenu = new QPopupMenu( this ); 1183 ImportMenu = new QPopupMenu( this );
1183 ExportMenu = new QPopupMenu( this ); 1184 ExportMenu = new QPopupMenu( this );
1184 1185
1185 changeMenu= new QPopupMenu( this ); 1186 changeMenu= new QPopupMenu( this );
1186 1187
1187//US since we have no splitter for the embedded system, setup 1188//US since we have no splitter for the embedded system, setup
1188// a layout with two frames. One left and one right. 1189// a layout with two frames. One left and one right.
1189 1190
1190 QBoxLayout *topLayout; 1191 QBoxLayout *topLayout;
1191 1192
1192 // = new QHBoxLayout( this ); 1193 // = new QHBoxLayout( this );
1193// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1194// QBoxLayout *topLayout = (QBoxLayout*)layout();
1194 1195
1195// QWidget *mainBox = new QWidget( this ); 1196// QWidget *mainBox = new QWidget( this );
1196// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1197// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1197 1198
1198#ifdef DESKTOP_VERSION 1199#ifdef DESKTOP_VERSION
1199 topLayout = new QHBoxLayout( this ); 1200 topLayout = new QHBoxLayout( this );
1200 1201
1201 1202
1202 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1203 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1203 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1204 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1204 1205
1205 topLayout->addWidget(mMiniSplitter ); 1206 topLayout->addWidget(mMiniSplitter );
1206 1207
1207 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1208 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1208 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1209 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1209 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1210 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1210 mDetails = new ViewContainer( mMiniSplitter ); 1211 mDetails = new ViewContainer( mMiniSplitter );
1211 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1212 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1212#else 1213#else
1213 if ( QApplication::desktop()->width() > 480 ) { 1214 if ( QApplication::desktop()->width() > 480 ) {
1214 topLayout = new QHBoxLayout( this ); 1215 topLayout = new QHBoxLayout( this );
1215 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1216 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1216 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1217 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1217 } else { 1218 } else {
1218 1219
1219 topLayout = new QHBoxLayout( this ); 1220 topLayout = new QHBoxLayout( this );
1220 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1221 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1221 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1222 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1222 } 1223 }
1223 1224
1224 topLayout->addWidget(mMiniSplitter ); 1225 topLayout->addWidget(mMiniSplitter );
1225 mViewManager = new ViewManager( this, mMiniSplitter ); 1226 mViewManager = new ViewManager( this, mMiniSplitter );
1226 mDetails = new ViewContainer( mMiniSplitter ); 1227 mDetails = new ViewContainer( mMiniSplitter );
1227 1228
1228 1229
1229 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1230 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1230#endif 1231#endif
1231 //eh->hide(); 1232 //eh->hide();
1232 // topLayout->addWidget(mExtensionManager ); 1233 // topLayout->addWidget(mExtensionManager );
1233 1234
1234 1235
1235/*US 1236/*US
1236#ifndef KAB_NOSPLITTER 1237#ifndef KAB_NOSPLITTER
1237 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1238 QHBoxLayout *topLayout = new QHBoxLayout( this );
1238//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1239//US topLayout->setSpacing( KDialogBase::spacingHint() );
1239 topLayout->setSpacing( 10 ); 1240 topLayout->setSpacing( 10 );
1240 1241
1241 mDetailsSplitter = new QSplitter( this ); 1242 mDetailsSplitter = new QSplitter( this );
1242 1243
1243 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1244 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1244 1245
1245 mViewManager = new ViewManager( this, viewSpace ); 1246 mViewManager = new ViewManager( this, viewSpace );
1246 viewSpace->setStretchFactor( mViewManager, 1 ); 1247 viewSpace->setStretchFactor( mViewManager, 1 );
1247 1248
1248 mDetails = new ViewContainer( mDetailsSplitter ); 1249 mDetails = new ViewContainer( mDetailsSplitter );
1249 1250
1250 topLayout->addWidget( mDetailsSplitter ); 1251 topLayout->addWidget( mDetailsSplitter );
1251 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1252 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1252#else //KAB_NOSPLITTER 1253#else //KAB_NOSPLITTER
1253 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1254 QHBoxLayout *topLayout = new QHBoxLayout( this );
1254//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1255//US topLayout->setSpacing( KDialogBase::spacingHint() );
1255 topLayout->setSpacing( 10 ); 1256 topLayout->setSpacing( 10 );
1256 1257
1257// mDetailsSplitter = new QSplitter( this ); 1258// mDetailsSplitter = new QSplitter( this );
1258 1259
1259 QVBox *viewSpace = new QVBox( this ); 1260 QVBox *viewSpace = new QVBox( this );
1260 1261
1261 mViewManager = new ViewManager( this, viewSpace ); 1262 mViewManager = new ViewManager( this, viewSpace );
1262 viewSpace->setStretchFactor( mViewManager, 1 ); 1263 viewSpace->setStretchFactor( mViewManager, 1 );
1263 1264
1264 mDetails = new ViewContainer( this ); 1265 mDetails = new ViewContainer( this );
1265 1266
1266 topLayout->addWidget( viewSpace ); 1267 topLayout->addWidget( viewSpace );
1267// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1268// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1268 topLayout->addWidget( mDetails ); 1269 topLayout->addWidget( mDetails );
1269#endif //KAB_NOSPLITTER 1270#endif //KAB_NOSPLITTER
1270*/ 1271*/
1271 1272
1272 1273
1273#endif //KAB_EMBEDDED 1274#endif //KAB_EMBEDDED
1274 initActions(); 1275 initActions();
1275 1276
1276#ifdef KAB_EMBEDDED 1277#ifdef KAB_EMBEDDED
1277 addActionsManually(); 1278 addActionsManually();
1278 //US make sure the export and import menues are initialized before creating the xxPortManager. 1279 //US make sure the export and import menues are initialized before creating the xxPortManager.
1279 mXXPortManager = new XXPortManager( this, this ); 1280 mXXPortManager = new XXPortManager( this, this );
1280 1281
1281 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1282 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1282 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1283 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1283 // mActionQuit->plug ( mMainWindow->toolBar()); 1284 // mActionQuit->plug ( mMainWindow->toolBar());
1284 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1285 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1285 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1286 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1286 // mIncSearchWidget->hide(); 1287 // mIncSearchWidget->hide();
1287 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1288 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1288 SLOT( incrementalSearch( const QString& ) ) ); 1289 SLOT( incrementalSearch( const QString& ) ) );
1289 1290
1290 1291
1291 mJumpButtonBar = new JumpButtonBar( this, this ); 1292 mJumpButtonBar = new JumpButtonBar( this, this );
1292 1293
1293 topLayout->addWidget( mJumpButtonBar ); 1294 topLayout->addWidget( mJumpButtonBar );
1294//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1295//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1295 1296
1296// mMainWindow->getIconToolBar()->raise(); 1297// mMainWindow->getIconToolBar()->raise();
1297 1298
1298#endif //KAB_EMBEDDED 1299#endif //KAB_EMBEDDED
1299 1300
1300} 1301}
1301void KABCore::initActions() 1302void KABCore::initActions()
1302{ 1303{
1303//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1304//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1304 1305
1305#ifndef KAB_EMBEDDED 1306#ifndef KAB_EMBEDDED
1306 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1307 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1307 SLOT( clipboardDataChanged() ) ); 1308 SLOT( clipboardDataChanged() ) );
1308#endif //KAB_EMBEDDED 1309#endif //KAB_EMBEDDED
1309 1310
1310 // file menu 1311 // file menu
1311 if ( mIsPart ) { 1312 if ( mIsPart ) {
1312 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1313 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1313 SLOT( sendMail() ), actionCollection(), 1314 SLOT( sendMail() ), actionCollection(),
1314 "kaddressbook_mail" ); 1315 "kaddressbook_mail" );
1315 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1316 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1316 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1317 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1317 1318
1318 } else { 1319 } else {
1319 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1320 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1320 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1321 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1321 } 1322 }
1322 1323
1323 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1324 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1324 SLOT( save() ), actionCollection(), "file_sync" ); 1325 SLOT( save() ), actionCollection(), "file_sync" );
1325 1326
1326 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1327 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1327 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1328 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1328 1329
1329 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1330 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1330 this, SLOT( mailVCard() ), 1331 this, SLOT( mailVCard() ),
1331 actionCollection(), "file_mail_vcard"); 1332 actionCollection(), "file_mail_vcard");
1332 1333
1333 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1334 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1334 this, SLOT( editContact2() ), 1335 this, SLOT( editContact2() ),
1335 actionCollection(), "file_properties" ); 1336 actionCollection(), "file_properties" );
1336 1337
1337#ifdef KAB_EMBEDDED 1338#ifdef KAB_EMBEDDED
1338 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1339 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1339 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1340 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1340 mMainWindow, SLOT( exit() ), 1341 mMainWindow, SLOT( exit() ),
1341 actionCollection(), "quit" ); 1342 actionCollection(), "quit" );
1342#endif //KAB_EMBEDDED 1343#endif //KAB_EMBEDDED
1343 1344
1344 // edit menu 1345 // edit menu
1345 if ( mIsPart ) { 1346 if ( mIsPart ) {
1346 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1347 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1347 SLOT( copyContacts() ), actionCollection(), 1348 SLOT( copyContacts() ), actionCollection(),
1348 "kaddressbook_copy" ); 1349 "kaddressbook_copy" );
1349 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1350 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1350 SLOT( cutContacts() ), actionCollection(), 1351 SLOT( cutContacts() ), actionCollection(),
1351 "kaddressbook_cut" ); 1352 "kaddressbook_cut" );
1352 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1353 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1353 SLOT( pasteContacts() ), actionCollection(), 1354 SLOT( pasteContacts() ), actionCollection(),
1354 "kaddressbook_paste" ); 1355 "kaddressbook_paste" );
1355 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1356 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1356 SLOT( selectAllContacts() ), actionCollection(), 1357 SLOT( selectAllContacts() ), actionCollection(),
1357 "kaddressbook_select_all" ); 1358 "kaddressbook_select_all" );
1358 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1359 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1359 SLOT( undo() ), actionCollection(), 1360 SLOT( undo() ), actionCollection(),
1360 "kaddressbook_undo" ); 1361 "kaddressbook_undo" );
1361 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1362 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1362 this, SLOT( redo() ), actionCollection(), 1363 this, SLOT( redo() ), actionCollection(),
1363 "kaddressbook_redo" ); 1364 "kaddressbook_redo" );
1364 } else { 1365 } else {
1365 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1366 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1366 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1367 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1367 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1368 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1368 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1369 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1369 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1370 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1370 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1371 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1371 } 1372 }
1372 1373
1373 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1374 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1374 Key_Delete, this, SLOT( deleteContacts() ), 1375 Key_Delete, this, SLOT( deleteContacts() ),
1375 actionCollection(), "edit_delete" ); 1376 actionCollection(), "edit_delete" );
1376 1377
1377 mActionUndo->setEnabled( false ); 1378 mActionUndo->setEnabled( false );
1378 mActionRedo->setEnabled( false ); 1379 mActionRedo->setEnabled( false );
1379 1380
1380 // settings menu 1381 // settings menu
1381#ifdef KAB_EMBEDDED 1382#ifdef KAB_EMBEDDED
1382//US special menuentry to configure the addressbook resources. On KDE 1383//US special menuentry to configure the addressbook resources. On KDE
1383// you do that through the control center !!! 1384// you do that through the control center !!!
1384 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1385 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1385 SLOT( configureResources() ), actionCollection(), 1386 SLOT( configureResources() ), actionCollection(),
1386 "kaddressbook_configure_resources" ); 1387 "kaddressbook_configure_resources" );
1387#endif //KAB_EMBEDDED 1388#endif //KAB_EMBEDDED
1388 1389
1389 if ( mIsPart ) { 1390 if ( mIsPart ) {
1390 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1391 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1391 SLOT( openConfigDialog() ), actionCollection(), 1392 SLOT( openConfigDialog() ), actionCollection(),
1392 "kaddressbook_configure" ); 1393 "kaddressbook_configure" );
1393 1394
1394 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1395 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1395 this, SLOT( configureKeyBindings() ), actionCollection(), 1396 this, SLOT( configureKeyBindings() ), actionCollection(),
1396 "kaddressbook_configure_shortcuts" ); 1397 "kaddressbook_configure_shortcuts" );
1397#ifdef KAB_EMBEDDED 1398#ifdef KAB_EMBEDDED
1398 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1399 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1399 mActionConfigureToolbars->setEnabled( false ); 1400 mActionConfigureToolbars->setEnabled( false );
1400#endif //KAB_EMBEDDED 1401#endif //KAB_EMBEDDED
1401 1402
1402 } else { 1403 } else {
1403 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1404 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1404 1405
1405 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1406 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1406 } 1407 }
1407 1408
1408 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1409 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1409 actionCollection(), "options_show_jump_bar" ); 1410 actionCollection(), "options_show_jump_bar" );
1410 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1411 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1411 1412
1412 mActionDetails = new KToggleAction( i18n( "Show Details" ), 0, 0, 1413 mActionDetails = new KToggleAction( i18n( "Show Details" ), 0, 0,
1413 actionCollection(), "options_show_details" ); 1414 actionCollection(), "options_show_details" );
1414 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1415 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1415 1416
1416 // misc 1417 // misc
1417 // only enable LDAP lookup if we can handle the protocol 1418 // only enable LDAP lookup if we can handle the protocol
1418#ifndef KAB_EMBEDDED 1419#ifndef KAB_EMBEDDED
1419 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1420 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1420 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1421 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1421 this, SLOT( openLDAPDialog() ), actionCollection(), 1422 this, SLOT( openLDAPDialog() ), actionCollection(),
1422 "ldap_lookup" ); 1423 "ldap_lookup" );
1423 } 1424 }
1424#else //KAB_EMBEDDED 1425#else //KAB_EMBEDDED
1425 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1426 //qDebug("KABCore::initActions() LDAP has to be implemented");
1426#endif //KAB_EMBEDDED 1427#endif //KAB_EMBEDDED
1427 1428
1428 1429
1429 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1430 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1430 SLOT( setWhoAmI() ), actionCollection(), 1431 SLOT( setWhoAmI() ), actionCollection(),
1431 "set_personal" ); 1432 "set_personal" );
1432 1433
1433 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1434 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1434 SLOT( setCategories() ), actionCollection(), 1435 SLOT( setCategories() ), actionCollection(),
1435 "edit_set_categories" ); 1436 "edit_set_categories" );
1436 1437
1437 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1438 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1438 SLOT( removeVoice() ), actionCollection(), 1439 SLOT( removeVoice() ), actionCollection(),
1439 "remove_voice" ); 1440 "remove_voice" );
1440 mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, 1441 mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this,
1441 SLOT( importFromOL() ), actionCollection(), 1442 SLOT( importFromOL() ), actionCollection(),
1442 "import_OL" ); 1443 "import_OL" );
1443#ifdef KAB_EMBEDDED 1444#ifdef KAB_EMBEDDED
1444 1445
1445 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1446 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1446 this, SLOT( createAboutData() ), actionCollection(), 1447 this, SLOT( createAboutData() ), actionCollection(),
1447 "kaddressbook_about_data" ); 1448 "kaddressbook_about_data" );
1448#endif //KAB_EMBEDDED 1449#endif //KAB_EMBEDDED
1449 1450
1450 clipboardDataChanged(); 1451 clipboardDataChanged();
1451 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1452 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1452 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1453 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1453} 1454}
1454 1455
1455//US we need this function, to plug all actions into the correct menues. 1456//US we need this function, to plug all actions into the correct menues.
1456// KDE uses a XML format to plug the actions, but we work her without this overhead. 1457// KDE uses a XML format to plug the actions, but we work her without this overhead.
1457void KABCore::addActionsManually() 1458void KABCore::addActionsManually()
1458{ 1459{
1459//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1460//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1460 1461
1461#ifdef KAB_EMBEDDED 1462#ifdef KAB_EMBEDDED
1462 QPopupMenu *fileMenu = new QPopupMenu( this ); 1463 QPopupMenu *fileMenu = new QPopupMenu( this );
1463 QPopupMenu *editMenu = new QPopupMenu( this ); 1464 QPopupMenu *editMenu = new QPopupMenu( this );
1464 QPopupMenu *helpMenu = new QPopupMenu( this ); 1465 QPopupMenu *helpMenu = new QPopupMenu( this );
1465 1466
1466 KToolBar* tb = mMainWindow->toolBar(); 1467 KToolBar* tb = mMainWindow->toolBar();
1467 1468
1468#ifdef DESKTOP_VERSION 1469#ifdef DESKTOP_VERSION
1469 QMenuBar* mb = mMainWindow->menuBar(); 1470 QMenuBar* mb = mMainWindow->menuBar();
1470 1471
1471 //US setup menubar. 1472 //US setup menubar.
1472 //Disable the following block if you do not want to have a menubar. 1473 //Disable the following block if you do not want to have a menubar.
1473 mb->insertItem( "&File", fileMenu ); 1474 mb->insertItem( "&File", fileMenu );
1474 mb->insertItem( "&Edit", editMenu ); 1475 mb->insertItem( "&Edit", editMenu );
1475 mb->insertItem( "&View", viewMenu ); 1476 mb->insertItem( "&View", viewMenu );
1476 mb->insertItem( "&Settings", settingsMenu ); 1477 mb->insertItem( "&Settings", settingsMenu );
1477 mb->insertItem( "&Change selected", changeMenu ); 1478 mb->insertItem( "&Change selected", changeMenu );
1478 mb->insertItem( "&Help", helpMenu ); 1479 mb->insertItem( "&Help", helpMenu );
1479 mIncSearchWidget = new IncSearchWidget( tb ); 1480 mIncSearchWidget = new IncSearchWidget( tb );
1480 // tb->insertWidget(-1, 0, mIncSearchWidget); 1481 // tb->insertWidget(-1, 0, mIncSearchWidget);
1481 1482
1482#else 1483#else
1483 //US setup toolbar 1484 //US setup toolbar
1484 QMenuBar *menuBarTB = new QMenuBar( tb ); 1485 QMenuBar *menuBarTB = new QMenuBar( tb );
1485 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1486 QPopupMenu *popupBarTB = new QPopupMenu( this );
1486 menuBarTB->insertItem( "ME", popupBarTB); 1487 menuBarTB->insertItem( "ME", popupBarTB);
1487 tb->insertWidget(-1, 0, menuBarTB); 1488 tb->insertWidget(-1, 0, menuBarTB);
1488 mIncSearchWidget = new IncSearchWidget( tb ); 1489 mIncSearchWidget = new IncSearchWidget( tb );
1489 1490
1490 tb->enableMoving(false); 1491 tb->enableMoving(false);
1491 popupBarTB->insertItem( "&File", fileMenu ); 1492 popupBarTB->insertItem( "&File", fileMenu );
1492 popupBarTB->insertItem( "&Edit", editMenu ); 1493 popupBarTB->insertItem( "&Edit", editMenu );
1493 popupBarTB->insertItem( "&View", viewMenu ); 1494 popupBarTB->insertItem( "&View", viewMenu );
1494 popupBarTB->insertItem( "&Settings", settingsMenu ); 1495 popupBarTB->insertItem( "&Settings", settingsMenu );
1495 mViewManager->getFilterAction()->plug ( popupBarTB); 1496 mViewManager->getFilterAction()->plug ( popupBarTB);
1496 popupBarTB->insertItem( "&Change selected", changeMenu ); 1497 popupBarTB->insertItem( "&Change selected", changeMenu );
1497 popupBarTB->insertItem( "&Help", helpMenu ); 1498 popupBarTB->insertItem( "&Help", helpMenu );
1498 if (QApplication::desktop()->width() > 320 ) { 1499 if (QApplication::desktop()->width() > 320 ) {
1499 // mViewManager->getFilterAction()->plug ( tb); 1500 // mViewManager->getFilterAction()->plug ( tb);
1500 } 1501 }
1501#endif 1502#endif
1502 // mActionQuit->plug ( mMainWindow->toolBar()); 1503 // mActionQuit->plug ( mMainWindow->toolBar());
1503 1504
1504 1505
1505 1506
1506 //US Now connect the actions with the menue entries. 1507 //US Now connect the actions with the menue entries.
1507 mActionPrint->plug( fileMenu ); 1508 mActionPrint->plug( fileMenu );
1508 mActionMail->plug( fileMenu ); 1509 mActionMail->plug( fileMenu );
1509 fileMenu->insertSeparator(); 1510 fileMenu->insertSeparator();
1510 1511
1511 mActionNewContact->plug( fileMenu ); 1512 mActionNewContact->plug( fileMenu );
1512 mActionNewContact->plug( tb ); 1513 mActionNewContact->plug( tb );
1513 1514
1514 mActionEditAddressee->plug( fileMenu ); 1515 mActionEditAddressee->plug( fileMenu );
1515 fileMenu->insertSeparator(); 1516 fileMenu->insertSeparator();
1516 mActionSave->plug( fileMenu ); 1517 mActionSave->plug( fileMenu );
1517 fileMenu->insertItem( "&Import", ImportMenu ); 1518 fileMenu->insertItem( "&Import", ImportMenu );
1518 fileMenu->insertItem( "&Emport", ExportMenu ); 1519 fileMenu->insertItem( "&Emport", ExportMenu );
1519 fileMenu->insertSeparator(); 1520 fileMenu->insertSeparator();
1520 mActionMailVCard->plug( fileMenu ); 1521 mActionMailVCard->plug( fileMenu );
1521 fileMenu->insertSeparator(); 1522 fileMenu->insertSeparator();
1522 mActionQuit->plug( fileMenu ); 1523 mActionQuit->plug( fileMenu );
1523#ifdef _WIN32_ 1524#ifdef _WIN32_
1524 mActionImportOL->plug( ImportMenu ); 1525 mActionImportOL->plug( ImportMenu );
1525#endif 1526#endif
1526 // edit menu 1527 // edit menu
1527 mActionUndo->plug( editMenu ); 1528 mActionUndo->plug( editMenu );
1528 mActionRedo->plug( editMenu ); 1529 mActionRedo->plug( editMenu );
1529 editMenu->insertSeparator(); 1530 editMenu->insertSeparator();
1530 mActionCut->plug( editMenu ); 1531 mActionCut->plug( editMenu );
1531 mActionCopy->plug( editMenu ); 1532 mActionCopy->plug( editMenu );
1532 mActionPaste->plug( editMenu ); 1533 mActionPaste->plug( editMenu );
1533 mActionDelete->plug( editMenu ); 1534 mActionDelete->plug( editMenu );
1534 editMenu->insertSeparator(); 1535 editMenu->insertSeparator();
1535 mActionSelectAll->plug( editMenu ); 1536 mActionSelectAll->plug( editMenu );
1536 1537
1537 mActionRemoveVoice->plug( changeMenu ); 1538 mActionRemoveVoice->plug( changeMenu );
1538 // settings menu 1539 // settings menu
1539//US special menuentry to configure the addressbook resources. On KDE 1540//US special menuentry to configure the addressbook resources. On KDE
1540// you do that through the control center !!! 1541// you do that through the control center !!!
1541 mActionConfigResources->plug( settingsMenu ); 1542 mActionConfigResources->plug( settingsMenu );
1542 settingsMenu->insertSeparator(); 1543 settingsMenu->insertSeparator();
1543 1544
1544 mActionConfigKAddressbook->plug( settingsMenu ); 1545 mActionConfigKAddressbook->plug( settingsMenu );
1545 1546
1546 if ( mIsPart ) { 1547 if ( mIsPart ) {
1547 mActionConfigShortcuts->plug( settingsMenu ); 1548 mActionConfigShortcuts->plug( settingsMenu );
1548 mActionConfigureToolbars->plug( settingsMenu ); 1549 mActionConfigureToolbars->plug( settingsMenu );
1549 1550
1550 } else { 1551 } else {
1551 mActionKeyBindings->plug( settingsMenu ); 1552 mActionKeyBindings->plug( settingsMenu );
1552 } 1553 }
1553 1554
1554 settingsMenu->insertSeparator(); 1555 settingsMenu->insertSeparator();
1555 1556
1556 mActionJumpBar->plug( settingsMenu ); 1557 mActionJumpBar->plug( settingsMenu );
1557 mActionDetails->plug( settingsMenu ); 1558 mActionDetails->plug( settingsMenu );
1558 settingsMenu->insertSeparator(); 1559 settingsMenu->insertSeparator();
1559 1560
1560 mActionWhoAmI->plug( settingsMenu ); 1561 mActionWhoAmI->plug( settingsMenu );
1561 mActionCategories->plug( settingsMenu ); 1562 mActionCategories->plug( settingsMenu );
1562 1563
1563 mActionAboutKAddressbook->plug( helpMenu ); 1564 mActionAboutKAddressbook->plug( helpMenu );
1564 1565
1565 1566
1566 if (QApplication::desktop()->width() > 320 ) { 1567 if (QApplication::desktop()->width() > 320 ) {
1567 1568
1568 mActionEditAddressee->plug( tb ); 1569 mActionEditAddressee->plug( tb );
1569 mActionSave->plug( tb ); 1570 mActionSave->plug( tb );
1570 mViewManager->getFilterAction()->plug ( tb); 1571 mViewManager->getFilterAction()->plug ( tb);
1571 if (QApplication::desktop()->width() > 480 ) { 1572 if (QApplication::desktop()->width() > 480 ) {
1572 mActionUndo->plug( tb ); 1573 mActionUndo->plug( tb );
1573 mActionDelete->plug( tb ); 1574 mActionDelete->plug( tb );
1574 mActionRedo->plug( tb ); 1575 mActionRedo->plug( tb );
1575 } 1576 }
1576 } 1577 }
1577 //mActionQuit->plug ( tb ); 1578 //mActionQuit->plug ( tb );
1578 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 1579 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
1579 1580
1580 //US link the searchwidget first to this. 1581 //US link the searchwidget first to this.
1581 // The real linkage to the toolbar happens later. 1582 // The real linkage to the toolbar happens later.
1582//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 1583//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
1583//US tb->insertItem( mIncSearchWidget ); 1584//US tb->insertItem( mIncSearchWidget );
1584/*US 1585/*US
1585 mIncSearchWidget = new IncSearchWidget( tb ); 1586 mIncSearchWidget = new IncSearchWidget( tb );
1586 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1587 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1587 SLOT( incrementalSearch( const QString& ) ) ); 1588 SLOT( incrementalSearch( const QString& ) ) );
1588 1589
1589 mJumpButtonBar = new JumpButtonBar( this, this ); 1590 mJumpButtonBar = new JumpButtonBar( this, this );
1590 1591
1591//US topLayout->addWidget( mJumpButtonBar ); 1592//US topLayout->addWidget( mJumpButtonBar );
1592 this->layout()->add( mJumpButtonBar ); 1593 this->layout()->add( mJumpButtonBar );
1593*/ 1594*/
1594 1595
1595#endif //KAB_EMBEDDED 1596#endif //KAB_EMBEDDED
1596} 1597}
1597void KABCore::removeVoice() 1598void KABCore::removeVoice()
1598{ 1599{
1599 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 ) 1600 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 )
1600 return; 1601 return;
1601 KABC::Addressee::List list = mViewManager->selectedAddressees(); 1602 KABC::Addressee::List list = mViewManager->selectedAddressees();
1602 KABC::Addressee::List::Iterator it; 1603 KABC::Addressee::List::Iterator it;
1603 for ( it = list.begin(); it != list.end(); ++it ) { 1604 for ( it = list.begin(); it != list.end(); ++it ) {
1604 PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); 1605 PhoneNumber::List phoneNumbers = (*it).phoneNumbers();
1605 PhoneNumber::List::Iterator phoneIt; 1606 PhoneNumber::List::Iterator phoneIt;
1606 bool found = false; 1607 bool found = false;
1607 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { 1608 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
1608 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 1609 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
1609 if ((*phoneIt).type() - PhoneNumber::Voice ) { 1610 if ((*phoneIt).type() - PhoneNumber::Voice ) {
1610 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 1611 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
1611 (*it).insertPhoneNumber( (*phoneIt) ); 1612 (*it).insertPhoneNumber( (*phoneIt) );
1612 found = true; 1613 found = true;
1613 } 1614 }
1614 } 1615 }
1615 1616
1616 } 1617 }
1617 if ( found ) 1618 if ( found )
1618 contactModified((*it) ); 1619 contactModified((*it) );
1619 } 1620 }
1620} 1621}
1621 1622
1622 1623
1623 1624
1624void KABCore::clipboardDataChanged() 1625void KABCore::clipboardDataChanged()
1625{ 1626{
1626 1627
1627 if ( mReadWrite ) 1628 if ( mReadWrite )
1628 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 1629 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
1629 1630
1630} 1631}
1631 1632
1632void KABCore::updateActionMenu() 1633void KABCore::updateActionMenu()
1633{ 1634{
1634 UndoStack *undo = UndoStack::instance(); 1635 UndoStack *undo = UndoStack::instance();
1635 RedoStack *redo = RedoStack::instance(); 1636 RedoStack *redo = RedoStack::instance();
1636 1637
1637 if ( undo->isEmpty() ) 1638 if ( undo->isEmpty() )
1638 mActionUndo->setText( i18n( "Undo" ) ); 1639 mActionUndo->setText( i18n( "Undo" ) );
1639 else 1640 else
1640 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 1641 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
1641 1642
1642 mActionUndo->setEnabled( !undo->isEmpty() ); 1643 mActionUndo->setEnabled( !undo->isEmpty() );
1643 1644
1644 if ( !redo->top() ) 1645 if ( !redo->top() )
1645 mActionRedo->setText( i18n( "Redo" ) ); 1646 mActionRedo->setText( i18n( "Redo" ) );
1646 else 1647 else
1647 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 1648 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
1648 1649
1649 mActionRedo->setEnabled( !redo->isEmpty() ); 1650 mActionRedo->setEnabled( !redo->isEmpty() );
1650} 1651}
1651 1652
1652void KABCore::configureKeyBindings() 1653void KABCore::configureKeyBindings()
1653{ 1654{
1654#ifndef KAB_EMBEDDED 1655#ifndef KAB_EMBEDDED
1655 KKeyDialog::configure( actionCollection(), true ); 1656 KKeyDialog::configure( actionCollection(), true );
1656#else //KAB_EMBEDDED 1657#else //KAB_EMBEDDED
1657 qDebug("KABCore::configureKeyBindings() not implemented"); 1658 qDebug("KABCore::configureKeyBindings() not implemented");
1658#endif //KAB_EMBEDDED 1659#endif //KAB_EMBEDDED
1659} 1660}
1660 1661
1661#ifdef KAB_EMBEDDED 1662#ifdef KAB_EMBEDDED
1662void KABCore::configureResources() 1663void KABCore::configureResources()
1663{ 1664{
1664 KRES::KCMKResources dlg( this, "" , 0 ); 1665 KRES::KCMKResources dlg( this, "" , 0 );
1665 1666
1666 if ( !dlg.exec() ) 1667 if ( !dlg.exec() )
1667 return; 1668 return;
1668 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 1669 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
1669} 1670}
1670#endif //KAB_EMBEDDED 1671#endif //KAB_EMBEDDED
1671 1672
1672 1673
1673 1674
1674#ifndef KAB_EMBEDDED 1675#ifndef KAB_EMBEDDED
1675#include "kabcore.moc" 1676#include "kabcore.moc"
1676#endif //KAB_EMBEDDED 1677#endif //KAB_EMBEDDED