summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2005-08-23 20:09:28 (UTC)
committer zautrix <zautrix>2005-08-23 20:09:28 (UTC)
commit6f5464760f5fb1e4c13027464cfe4943b85d29a0 (patch) (unidiff)
tree3c074b7e313d965516b60b9ba97fe27a7ee774a1 /kaddressbook
parent13a736b71dec27ef7ffef06b91f34d220d89cce6 (diff)
downloadkdepimpi-6f5464760f5fb1e4c13027464cfe4943b85d29a0.zip
kdepimpi-6f5464760f5fb1e4c13027464cfe4943b85d29a0.tar.gz
kdepimpi-6f5464760f5fb1e4c13027464cfe4943b85d29a0.tar.bz2
fixx
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp6
-rw-r--r--kaddressbook/kaddressbookmain.cpp2
2 files changed, 4 insertions, 4 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 77321aa..af12f2b 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,1453 +1,1453 @@
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 Async a special exception, permission is given to link this program 19 Async a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99#include <kprefsdialog.h> 99#include <kprefsdialog.h>
100 100
101 101
102//#include <qlabel.h> 102//#include <qlabel.h>
103 103
104 104
105#ifndef DESKTOP_VERSION 105#ifndef DESKTOP_VERSION
106#include <qpe/ir.h> 106#include <qpe/ir.h>
107#include <qpe/qpemenubar.h> 107#include <qpe/qpemenubar.h>
108#include <qtopia/qcopenvelope_qws.h> 108#include <qtopia/qcopenvelope_qws.h>
109#else 109#else
110 110
111#include <qmenubar.h> 111#include <qmenubar.h>
112#endif 112#endif
113 113
114#endif // KAB_EMBEDDED 114#endif // KAB_EMBEDDED
115#include "kcmconfigs/kcmkabconfig.h" 115#include "kcmconfigs/kcmkabconfig.h"
116#include "kcmconfigs/kcmkdepimconfig.h" 116#include "kcmconfigs/kcmkdepimconfig.h"
117#include "kpimglobalprefs.h" 117#include "kpimglobalprefs.h"
118#include "externalapphandler.h" 118#include "externalapphandler.h"
119#include "xxportselectdialog.h" 119#include "xxportselectdialog.h"
120 120
121 121
122#include <kresources/selectdialog.h> 122#include <kresources/selectdialog.h>
123#include <kmessagebox.h> 123#include <kmessagebox.h>
124 124
125#include <picture.h> 125#include <picture.h>
126#include <resource.h> 126#include <resource.h>
127 127
128//US#include <qsplitter.h> 128//US#include <qsplitter.h>
129#include <qmap.h> 129#include <qmap.h>
130#include <qdir.h> 130#include <qdir.h>
131#include <qfile.h> 131#include <qfile.h>
132#include <qvbox.h> 132#include <qvbox.h>
133#include <qlayout.h> 133#include <qlayout.h>
134#include <qclipboard.h> 134#include <qclipboard.h>
135#include <qtextstream.h> 135#include <qtextstream.h>
136#include <qradiobutton.h> 136#include <qradiobutton.h>
137#include <qbuttongroup.h> 137#include <qbuttongroup.h>
138 138
139#include <libkdepim/categoryselectdialog.h> 139#include <libkdepim/categoryselectdialog.h>
140#include <libkdepim/categoryeditdialog.h> 140#include <libkdepim/categoryeditdialog.h>
141#include <kabc/vcardconverter.h> 141#include <kabc/vcardconverter.h>
142 142
143 143
144#include "addresseeutil.h" 144#include "addresseeutil.h"
145#include "undocmds.h" 145#include "undocmds.h"
146#include "addresseeeditordialog.h" 146#include "addresseeeditordialog.h"
147#include "viewmanager.h" 147#include "viewmanager.h"
148#include "details/detailsviewcontainer.h" 148#include "details/detailsviewcontainer.h"
149#include "kabprefs.h" 149#include "kabprefs.h"
150#include "xxportmanager.h" 150#include "xxportmanager.h"
151#include "incsearchwidget.h" 151#include "incsearchwidget.h"
152#include "jumpbuttonbar.h" 152#include "jumpbuttonbar.h"
153#include "extensionmanager.h" 153#include "extensionmanager.h"
154#include "addresseeconfig.h" 154#include "addresseeconfig.h"
155#include "nameeditdialog.h" 155#include "nameeditdialog.h"
156#include <kcmultidialog.h> 156#include <kcmultidialog.h>
157 157
158#ifdef _WIN32_ 158#ifdef _WIN32_
159#ifdef _OL_IMPORT_ 159#ifdef _OL_IMPORT_
160#include "kaimportoldialog.h" 160#include "kaimportoldialog.h"
161#endif 161#endif
162#else 162#else
163#include <unistd.h> 163#include <unistd.h>
164#endif 164#endif
165// sync includes 165// sync includes
166#include <libkdepim/ksyncprofile.h> 166#include <libkdepim/ksyncprofile.h>
167#include <libkdepim/ksyncprefsdialog.h> 167#include <libkdepim/ksyncprefsdialog.h>
168 168
169 169
170class KABCatPrefs : public QDialog 170class KABCatPrefs : public QDialog
171{ 171{
172 public: 172 public:
173 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 173 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
174 QDialog( parent, name, true ) 174 QDialog( parent, name, true )
175 { 175 {
176 setCaption( i18n("Manage new Categories") ); 176 setCaption( i18n("Manage new Categories") );
177 QVBoxLayout* lay = new QVBoxLayout( this ); 177 QVBoxLayout* lay = new QVBoxLayout( this );
178 lay->setSpacing( 3 ); 178 lay->setSpacing( 3 );
179 lay->setMargin( 3 ); 179 lay->setMargin( 3 );
180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
181 lay->addWidget( lab ); 181 lay->addWidget( lab );
182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
183 lay->addWidget( format ); 183 lay->addWidget( format );
184 format->setExclusive ( true ) ; 184 format->setExclusive ( true ) ;
185 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 185 addCatBut = new QRadioButton(i18n("Add to category list"), format );
186 new QRadioButton(i18n("Remove from addressees"), format ); 186 new QRadioButton(i18n("Remove from addressees"), format );
187 addCatBut->setChecked( true ); 187 addCatBut->setChecked( true );
188 QPushButton * ok = new QPushButton( i18n("OK"), this ); 188 QPushButton * ok = new QPushButton( i18n("OK"), this );
189 lay->addWidget( ok ); 189 lay->addWidget( ok );
190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
191 lay->addWidget( cancel ); 191 lay->addWidget( cancel );
192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
194 resize( 200, 200 ); 194 resize( 200, 200 );
195 } 195 }
196 196
197 bool addCat() { return addCatBut->isChecked(); } 197 bool addCat() { return addCatBut->isChecked(); }
198private: 198private:
199 QRadioButton* addCatBut; 199 QRadioButton* addCatBut;
200}; 200};
201 201
202class KABFormatPrefs : public QDialog 202class KABFormatPrefs : public QDialog
203{ 203{
204 public: 204 public:
205 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : 205 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) :
206 QDialog( parent, name, true ) 206 QDialog( parent, name, true )
207 { 207 {
208 setCaption( i18n("Set formatted name") ); 208 setCaption( i18n("Set formatted name") );
209 QVBoxLayout* lay = new QVBoxLayout( this ); 209 QVBoxLayout* lay = new QVBoxLayout( this );
210 lay->setSpacing( 3 ); 210 lay->setSpacing( 3 );
211 lay->setMargin( 3 ); 211 lay->setMargin( 3 );
212 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); 212 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
213 lay->addWidget( lab ); 213 lay->addWidget( lab );
214 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); 214 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this );
215 lay->addWidget( format ); 215 lay->addWidget( format );
216 format->setExclusive ( true ) ; 216 format->setExclusive ( true ) ;
217 simple = new QRadioButton(i18n("Simple: James Bond"), format ); 217 simple = new QRadioButton(i18n("Simple: James Bond"), format );
218 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); 218 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
219 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); 219 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
220 company = new QRadioButton(i18n("Organization: MI6"), format ); 220 company = new QRadioButton(i18n("Organization: MI6"), format );
221 simple->setChecked( true ); 221 simple->setChecked( true );
222 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); 222 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
223 lay->addWidget( setCompany ); 223 lay->addWidget( setCompany );
224 QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); 224 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
225 lay->addWidget( ok ); 225 lay->addWidget( ok );
226 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 226 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
227 lay->addWidget( cancel ); 227 lay->addWidget( cancel );
228 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 228 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
229 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 229 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
230 //resize( 200, 200 ); 230 //resize( 200, 200 );
231 231
232 } 232 }
233public: 233public:
234 QRadioButton* simple, *full, *reverse, *company; 234 QRadioButton* simple, *full, *reverse, *company;
235 QCheckBox* setCompany; 235 QCheckBox* setCompany;
236}; 236};
237 237
238 238
239 239
240class KAex2phonePrefs : public QDialog 240class KAex2phonePrefs : public QDialog
241{ 241{
242 public: 242 public:
243 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 243 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
244 QDialog( parent, name, true ) 244 QDialog( parent, name, true )
245 { 245 {
246 setCaption( i18n("Export to phone options") ); 246 setCaption( i18n("Export to phone options") );
247 QVBoxLayout* lay = new QVBoxLayout( this ); 247 QVBoxLayout* lay = new QVBoxLayout( this );
248 lay->setSpacing( 3 ); 248 lay->setSpacing( 3 );
249 lay->setMargin( 3 ); 249 lay->setMargin( 3 );
250 QLabel *lab; 250 QLabel *lab;
251 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 251 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
252 lab->setAlignment (AlignHCenter ); 252 lab->setAlignment (AlignHCenter );
253 QHBox* temphb; 253 QHBox* temphb;
254 temphb = new QHBox( this ); 254 temphb = new QHBox( this );
255 new QLabel( i18n("I/O device: "), temphb ); 255 new QLabel( i18n("I/O device: "), temphb );
256 mPhoneDevice = new QLineEdit( temphb); 256 mPhoneDevice = new QLineEdit( temphb);
257 lay->addWidget( temphb ); 257 lay->addWidget( temphb );
258 temphb = new QHBox( this ); 258 temphb = new QHBox( this );
259 new QLabel( i18n("Connection: "), temphb ); 259 new QLabel( i18n("Connection: "), temphb );
260 mPhoneConnection = new QLineEdit( temphb); 260 mPhoneConnection = new QLineEdit( temphb);
261 lay->addWidget( temphb ); 261 lay->addWidget( temphb );
262 temphb = new QHBox( this ); 262 temphb = new QHBox( this );
263 new QLabel( i18n("Model(opt.): "), temphb ); 263 new QLabel( i18n("Model(opt.): "), temphb );
264 mPhoneModel = new QLineEdit( temphb); 264 mPhoneModel = new QLineEdit( temphb);
265 lay->addWidget( temphb ); 265 lay->addWidget( temphb );
266 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 266 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
267 // lay->addWidget( mWriteToSim ); 267 // lay->addWidget( mWriteToSim );
268 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 268 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
269 lab->setAlignment (AlignHCenter); 269 lab->setAlignment (AlignHCenter);
270 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 270 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
271 lay->addWidget( ok ); 271 lay->addWidget( ok );
272 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 272 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
273 lay->addWidget( cancel ); 273 lay->addWidget( cancel );
274 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 274 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
275 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 275 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
276 resize( 220, 240 ); 276 resize( 220, 240 );
277 277
278 } 278 }
279 279
280public: 280public:
281 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 281 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
282 QCheckBox* mWriteToSim; 282 QCheckBox* mWriteToSim;
283}; 283};
284 284
285 285
286bool pasteWithNewUid = true; 286bool pasteWithNewUid = true;
287 287
288#ifdef KAB_EMBEDDED 288#ifdef KAB_EMBEDDED
289KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 289KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
290 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 290 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
291 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 291 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
292 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 292 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
293#else //KAB_EMBEDDED 293#else //KAB_EMBEDDED
294KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 294KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
295 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 295 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
296 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 296 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
297 mReadWrite( readWrite ), mModified( false ) 297 mReadWrite( readWrite ), mModified( false )
298#endif //KAB_EMBEDDED 298#endif //KAB_EMBEDDED
299{ 299{
300 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 300 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
301 // syncManager->setBlockSave(false); 301 // syncManager->setBlockSave(false);
302 mIncSearchWidget = 0; 302 mIncSearchWidget = 0;
303 mMiniSplitter = 0; 303 mMiniSplitter = 0;
304 mExtensionBarSplitter = 0; 304 mExtensionBarSplitter = 0;
305 mIsPart = !parent->inherits( "KAddressBookMain" ); 305 mIsPart = !parent->inherits( "KAddressBookMain" );
306 mAddressBook = KABC::StdAddressBook::selfNoLoad(); 306 mAddressBook = KABC::StdAddressBook::selfNoLoad();
307 KABC::StdAddressBook::setAutomaticSave( false ); 307 KABC::StdAddressBook::setAutomaticSave( false );
308 308
309#ifndef KAB_EMBEDDED 309#ifndef KAB_EMBEDDED
310 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 310 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
311#endif //KAB_EMBEDDED 311#endif //KAB_EMBEDDED
312 312
313 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 313 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
314 SLOT( addressBookChanged() ) ); 314 SLOT( addressBookChanged() ) );
315 315
316#if 0 316#if 0
317 // LR moved to addressbook init method 317 // LR moved to addressbook init method
318 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 318 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
319 "X-Department", "KADDRESSBOOK" ); 319 "X-Department", "KADDRESSBOOK" );
320 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 320 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
321 "X-Profession", "KADDRESSBOOK" ); 321 "X-Profession", "KADDRESSBOOK" );
322 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 322 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
323 "X-AssistantsName", "KADDRESSBOOK" ); 323 "X-AssistantsName", "KADDRESSBOOK" );
324 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 324 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
325 "X-ManagersName", "KADDRESSBOOK" ); 325 "X-ManagersName", "KADDRESSBOOK" );
326 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 326 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
327 "X-SpousesName", "KADDRESSBOOK" ); 327 "X-SpousesName", "KADDRESSBOOK" );
328 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 328 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
329 "X-Office", "KADDRESSBOOK" ); 329 "X-Office", "KADDRESSBOOK" );
330 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 330 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
331 "X-IMAddress", "KADDRESSBOOK" ); 331 "X-IMAddress", "KADDRESSBOOK" );
332 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 332 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
333 "X-Anniversary", "KADDRESSBOOK" ); 333 "X-Anniversary", "KADDRESSBOOK" );
334 334
335 //US added this field to become compatible with Opie/qtopia addressbook 335 //US added this field to become compatible with Opie/qtopia addressbook
336 // values can be "female" or "male" or "". An empty field represents undefined. 336 // values can be "female" or "male" or "". An empty field represents undefined.
337 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 337 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
338 "X-Gender", "KADDRESSBOOK" ); 338 "X-Gender", "KADDRESSBOOK" );
339 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 339 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
340 "X-Children", "KADDRESSBOOK" ); 340 "X-Children", "KADDRESSBOOK" );
341 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 341 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
342 "X-FreeBusyUrl", "KADDRESSBOOK" ); 342 "X-FreeBusyUrl", "KADDRESSBOOK" );
343#endif 343#endif
344 initGUI(); 344 initGUI();
345 345
346 mIncSearchWidget->setFocus(); 346 mIncSearchWidget->setFocus();
347 347
348 348
349 connect( mViewManager, SIGNAL( selected( const QString& ) ), 349 connect( mViewManager, SIGNAL( selected( const QString& ) ),
350 SLOT( setContactSelected( const QString& ) ) ); 350 SLOT( setContactSelected( const QString& ) ) );
351 connect( mViewManager, SIGNAL( executed( const QString& ) ), 351 connect( mViewManager, SIGNAL( executed( const QString& ) ),
352 SLOT( executeContact( const QString& ) ) ); 352 SLOT( executeContact( const QString& ) ) );
353 353
354 connect( mViewManager, SIGNAL( deleteRequest( ) ), 354 connect( mViewManager, SIGNAL( deleteRequest( ) ),
355 SLOT( deleteContacts( ) ) ); 355 SLOT( deleteContacts( ) ) );
356 connect( mViewManager, SIGNAL( modified() ), 356 connect( mViewManager, SIGNAL( modified() ),
357 SLOT( setModified() ) ); 357 SLOT( setModified() ) );
358 358
359 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 359 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
360 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 360 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
361 361
362 connect( mXXPortManager, SIGNAL( modified() ), 362 connect( mXXPortManager, SIGNAL( modified() ),
363 SLOT( setModified() ) ); 363 SLOT( setModified() ) );
364 364
365 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 365 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
366 SLOT( incrementalSearchJump( const QString& ) ) ); 366 SLOT( incrementalSearchJump( const QString& ) ) );
367 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 367 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
368 mJumpButtonBar, SLOT( recreateButtons() ) ); 368 mJumpButtonBar, SLOT( recreateButtons() ) );
369 369
370 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 370 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
371 SLOT( sendMail( const QString& ) ) ); 371 SLOT( sendMail( const QString& ) ) );
372 372
373 373
374 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 374 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
375 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 375 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
376 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 376 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
377 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 377 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
378 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync())); 378 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync()));
379 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); 379 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog()));
380 380
381 381
382#ifndef KAB_EMBEDDED 382#ifndef KAB_EMBEDDED
383 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 383 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
384 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 384 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
385 385
386 connect( mDetails, SIGNAL( browse( const QString& ) ), 386 connect( mDetails, SIGNAL( browse( const QString& ) ),
387 SLOT( browse( const QString& ) ) ); 387 SLOT( browse( const QString& ) ) );
388 388
389 389
390 mAddressBookService = new KAddressBookService( this ); 390 mAddressBookService = new KAddressBookService( this );
391 391
392#endif //KAB_EMBEDDED 392#endif //KAB_EMBEDDED
393 393
394 mMessageTimer = new QTimer( this ); 394 mMessageTimer = new QTimer( this );
395 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 395 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
396 mEditorDialog = 0; 396 mEditorDialog = 0;
397 createAddresseeEditorDialog( this ); 397 createAddresseeEditorDialog( this );
398 setModified( false ); 398 setModified( false );
399 mBRdisabled = false; 399 mBRdisabled = false;
400#ifndef DESKTOP_VERSION 400#ifndef DESKTOP_VERSION
401 infrared = 0; 401 infrared = 0;
402#endif 402#endif
403 //toggleBeamReceive( ); 403 //toggleBeamReceive( );
404 mMainWindow->toolBar()->show(); 404 mMainWindow->toolBar()->show();
405 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 405 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
406 //QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 406 //QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
407 QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() )); 407 QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() ));
408} 408}
409void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data ) 409void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data )
410{ 410{
411 qDebug("KO: QCOP start message received: %s ", cmsg.data() ); 411 //qDebug("KO: QCOP start message received: %s ", cmsg.data() );
412 mCStringMess = cmsg; 412 mCStringMess = cmsg;
413 mByteData = data; 413 mByteData = data;
414} 414}
415 415
416void KABCore::loadDataAfterStart() 416void KABCore::loadDataAfterStart()
417{ 417{
418 qDebug("KABCore::loadDataAfterStart() "); 418 //qDebug("KABCore::loadDataAfterStart() ");
419 ((StdAddressBook*)mAddressBook)->init( true ); 419 ((StdAddressBook*)mAddressBook)->init( true );
420 mViewManager->refreshView(); 420 mViewManager->refreshView();
421 421
422#ifndef DESKTOP_VERSION 422#ifndef DESKTOP_VERSION
423 disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & ))); 423 disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & )));
424 424
425 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 425 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
426 if ( !mCStringMess.isEmpty() ) 426 if ( !mCStringMess.isEmpty() )
427 ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData ); 427 ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData );
428#endif 428#endif
429 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 429 // QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
430 setCaptionBack(); 430 setCaptionBack();
431} 431}
432void KABCore::updateToolBar() 432void KABCore::updateToolBar()
433{ 433{
434 static int iii = 0; 434 static int iii = 0;
435 ++iii; 435 ++iii;
436 mMainWindow->toolBar()->repaintMe(); 436 mMainWindow->toolBar()->repaintMe();
437 if ( iii < 4 ) 437 if ( iii < 4 )
438 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); 438 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar()));
439} 439}
440KABCore::~KABCore() 440KABCore::~KABCore()
441{ 441{
442 // save(); 442 // save();
443 //saveSettings(); 443 //saveSettings();
444 //KABPrefs::instance()->writeConfig(); 444 //KABPrefs::instance()->writeConfig();
445 delete AddresseeConfig::instance(); 445 delete AddresseeConfig::instance();
446 mAddressBook = 0; 446 mAddressBook = 0;
447 KABC::StdAddressBook::close(); 447 KABC::StdAddressBook::close();
448 448
449 delete syncManager; 449 delete syncManager;
450#ifndef DESKTOP_VERSION 450#ifndef DESKTOP_VERSION
451 if ( infrared ) 451 if ( infrared )
452 delete infrared; 452 delete infrared;
453#endif 453#endif
454} 454}
455void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 455void KABCore::receive( const QCString& cmsg, const QByteArray& data )
456{ 456{
457 //qDebug("KA: QCOP message received: %s ", cmsg.data() ); 457 //qDebug("KA: QCOP message received: %s ", cmsg.data() );
458 if ( cmsg == "setDocument(QString)" ) { 458 if ( cmsg == "setDocument(QString)" ) {
459 QDataStream stream( data, IO_ReadOnly ); 459 QDataStream stream( data, IO_ReadOnly );
460 QString fileName; 460 QString fileName;
461 stream >> fileName; 461 stream >> fileName;
462 recieve( fileName ); 462 recieve( fileName );
463 return; 463 return;
464 } 464 }
465} 465}
466void KABCore::toggleBeamReceive( ) 466void KABCore::toggleBeamReceive( )
467{ 467{
468 if ( mBRdisabled ) 468 if ( mBRdisabled )
469 return; 469 return;
470#ifndef DESKTOP_VERSION 470#ifndef DESKTOP_VERSION
471 if ( infrared ) { 471 if ( infrared ) {
472 qDebug("KA: AB disable BeamReceive "); 472 qDebug("KA: AB disable BeamReceive ");
473 delete infrared; 473 delete infrared;
474 infrared = 0; 474 infrared = 0;
475 mActionBR->setChecked(false); 475 mActionBR->setChecked(false);
476 return; 476 return;
477 } 477 }
478 qDebug("KA: AB enable BeamReceive "); 478 qDebug("KA: AB enable BeamReceive ");
479 mActionBR->setChecked(true); 479 mActionBR->setChecked(true);
480 480
481 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 481 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
482 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 482 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
483#endif 483#endif
484} 484}
485 485
486 486
487void KABCore::disableBR(bool b) 487void KABCore::disableBR(bool b)
488{ 488{
489#ifndef DESKTOP_VERSION 489#ifndef DESKTOP_VERSION
490 if ( b ) { 490 if ( b ) {
491 if ( infrared ) { 491 if ( infrared ) {
492 toggleBeamReceive( ); 492 toggleBeamReceive( );
493 } 493 }
494 mBRdisabled = true; 494 mBRdisabled = true;
495 } else { 495 } else {
496 if ( mBRdisabled ) { 496 if ( mBRdisabled ) {
497 mBRdisabled = false; 497 mBRdisabled = false;
498 //toggleBeamReceive( ); 498 //toggleBeamReceive( );
499 } 499 }
500 } 500 }
501#endif 501#endif
502 502
503} 503}
504void KABCore::recieve( QString fn ) 504void KABCore::recieve( QString fn )
505{ 505{
506 //qDebug("KABCore::recieve "); 506 //qDebug("KABCore::recieve ");
507 int count = mAddressBook->importFromFile( fn, true ); 507 int count = mAddressBook->importFromFile( fn, true );
508 if ( count ) 508 if ( count )
509 setModified( true ); 509 setModified( true );
510 mViewManager->refreshView(); 510 mViewManager->refreshView();
511 message(i18n("%1 contact(s) received!").arg( count )); 511 message(i18n("%1 contact(s) received!").arg( count ));
512 topLevelWidget()->showMaximized(); 512 topLevelWidget()->showMaximized();
513 topLevelWidget()->raise(); 513 topLevelWidget()->raise();
514} 514}
515void KABCore::restoreSettings() 515void KABCore::restoreSettings()
516{ 516{
517 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 517 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
518 518
519 bool state; 519 bool state;
520 520
521 if (mMultipleViewsAtOnce) 521 if (mMultipleViewsAtOnce)
522 state = KABPrefs::instance()->mDetailsPageVisible; 522 state = KABPrefs::instance()->mDetailsPageVisible;
523 else 523 else
524 state = false; 524 state = false;
525 525
526 mActionDetails->setChecked( state ); 526 mActionDetails->setChecked( state );
527 setDetailsVisible( state ); 527 setDetailsVisible( state );
528 528
529 state = KABPrefs::instance()->mJumpButtonBarVisible; 529 state = KABPrefs::instance()->mJumpButtonBarVisible;
530 530
531 mActionJumpBar->setChecked( state ); 531 mActionJumpBar->setChecked( state );
532 setJumpButtonBarVisible( state ); 532 setJumpButtonBarVisible( state );
533/*US 533/*US
534 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 534 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
535 if ( splitterSize.count() == 0 ) { 535 if ( splitterSize.count() == 0 ) {
536 splitterSize.append( width() / 2 ); 536 splitterSize.append( width() / 2 );
537 splitterSize.append( width() / 2 ); 537 splitterSize.append( width() / 2 );
538 } 538 }
539 mMiniSplitter->setSizes( splitterSize ); 539 mMiniSplitter->setSizes( splitterSize );
540 if ( mExtensionBarSplitter ) { 540 if ( mExtensionBarSplitter ) {
541 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 541 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
542 if ( splitterSize.count() == 0 ) { 542 if ( splitterSize.count() == 0 ) {
543 splitterSize.append( width() / 2 ); 543 splitterSize.append( width() / 2 );
544 splitterSize.append( width() / 2 ); 544 splitterSize.append( width() / 2 );
545 } 545 }
546 mExtensionBarSplitter->setSizes( splitterSize ); 546 mExtensionBarSplitter->setSizes( splitterSize );
547 547
548 } 548 }
549*/ 549*/
550 mViewManager->restoreSettings(); 550 mViewManager->restoreSettings();
551 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 551 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
552 mExtensionManager->restoreSettings(); 552 mExtensionManager->restoreSettings();
553#ifdef DESKTOP_VERSION 553#ifdef DESKTOP_VERSION
554 int wid = width(); 554 int wid = width();
555 if ( wid < 10 ) 555 if ( wid < 10 )
556 wid = 400; 556 wid = 400;
557#else 557#else
558 int wid = QApplication::desktop()->width(); 558 int wid = QApplication::desktop()->width();
559 if ( wid < 640 ) 559 if ( wid < 640 )
560 wid = QApplication::desktop()->height(); 560 wid = QApplication::desktop()->height();
561#endif 561#endif
562 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 562 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
563 if ( true /*splitterSize.count() == 0*/ ) { 563 if ( true /*splitterSize.count() == 0*/ ) {
564 splitterSize.append( wid / 2 ); 564 splitterSize.append( wid / 2 );
565 splitterSize.append( wid / 2 ); 565 splitterSize.append( wid / 2 );
566 } 566 }
567 mMiniSplitter->setSizes( splitterSize ); 567 mMiniSplitter->setSizes( splitterSize );
568 if ( mExtensionBarSplitter ) { 568 if ( mExtensionBarSplitter ) {
569 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 569 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
570 if ( true /*splitterSize.count() == 0*/ ) { 570 if ( true /*splitterSize.count() == 0*/ ) {
571 splitterSize.append( wid / 2 ); 571 splitterSize.append( wid / 2 );
572 splitterSize.append( wid / 2 ); 572 splitterSize.append( wid / 2 );
573 } 573 }
574 mExtensionBarSplitter->setSizes( splitterSize ); 574 mExtensionBarSplitter->setSizes( splitterSize );
575 575
576 } 576 }
577#ifdef DESKTOP_VERSION 577#ifdef DESKTOP_VERSION
578 KConfig *config = KABPrefs::instance()->getConfig(); 578 KConfig *config = KABPrefs::instance()->getConfig();
579 config->setGroup("WidgetLayout"); 579 config->setGroup("WidgetLayout");
580 QStringList list; 580 QStringList list;
581 list = config->readListEntry("MainLayout"); 581 list = config->readListEntry("MainLayout");
582 int x,y,w,h; 582 int x,y,w,h;
583 if ( ! list.isEmpty() ) { 583 if ( ! list.isEmpty() ) {
584 x = list[0].toInt(); 584 x = list[0].toInt();
585 y = list[1].toInt(); 585 y = list[1].toInt();
586 w = list[2].toInt(); 586 w = list[2].toInt();
587 h = list[3].toInt(); 587 h = list[3].toInt();
588 KApplication::testCoords( &x,&y,&w,&h ); 588 KApplication::testCoords( &x,&y,&w,&h );
589 topLevelWidget()->setGeometry(x,y,w,h); 589 topLevelWidget()->setGeometry(x,y,w,h);
590 590
591 } else { 591 } else {
592 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 592 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
593 } 593 }
594#endif 594#endif
595} 595}
596 596
597void KABCore::saveSettings() 597void KABCore::saveSettings()
598{ 598{
599 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 599 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
600 if ( mExtensionBarSplitter ) 600 if ( mExtensionBarSplitter )
601 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 601 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
602 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 602 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
603 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 603 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
604#ifndef KAB_EMBEDDED 604#ifndef KAB_EMBEDDED
605 605
606 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 606 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
607 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 607 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
608#endif //KAB_EMBEDDED 608#endif //KAB_EMBEDDED
609 mExtensionManager->saveSettings(); 609 mExtensionManager->saveSettings();
610 mViewManager->saveSettings(); 610 mViewManager->saveSettings();
611 611
612 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 612 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
613 613
614 KABPrefs::instance()->writeConfig(); 614 KABPrefs::instance()->writeConfig();
615 qDebug("KA: KABCore::saveSettings() "); 615 qDebug("KA: KABCore::saveSettings() ");
616} 616}
617 617
618KABC::AddressBook *KABCore::addressBook() const 618KABC::AddressBook *KABCore::addressBook() const
619{ 619{
620 return mAddressBook; 620 return mAddressBook;
621} 621}
622 622
623KConfig *KABCore::config() 623KConfig *KABCore::config()
624{ 624{
625#ifndef KAB_EMBEDDED 625#ifndef KAB_EMBEDDED
626 return KABPrefs::instance()->config(); 626 return KABPrefs::instance()->config();
627#else //KAB_EMBEDDED 627#else //KAB_EMBEDDED
628 return KABPrefs::instance()->getConfig(); 628 return KABPrefs::instance()->getConfig();
629#endif //KAB_EMBEDDED 629#endif //KAB_EMBEDDED
630} 630}
631 631
632KActionCollection *KABCore::actionCollection() const 632KActionCollection *KABCore::actionCollection() const
633{ 633{
634 return mGUIClient->actionCollection(); 634 return mGUIClient->actionCollection();
635} 635}
636 636
637KABC::Field *KABCore::currentSearchField() const 637KABC::Field *KABCore::currentSearchField() const
638{ 638{
639 if (mIncSearchWidget) 639 if (mIncSearchWidget)
640 return mIncSearchWidget->currentField(); 640 return mIncSearchWidget->currentField();
641 else 641 else
642 return 0; 642 return 0;
643} 643}
644 644
645QStringList KABCore::selectedUIDs() const 645QStringList KABCore::selectedUIDs() const
646{ 646{
647 return mViewManager->selectedUids(); 647 return mViewManager->selectedUids();
648} 648}
649 649
650KABC::Resource *KABCore::requestResource( QWidget *parent ) 650KABC::Resource *KABCore::requestResource( QWidget *parent )
651{ 651{
652 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 652 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
653 653
654 QPtrList<KRES::Resource> kresResources; 654 QPtrList<KRES::Resource> kresResources;
655 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 655 QPtrListIterator<KABC::Resource> resIt( kabcResources );
656 KABC::Resource *resource; 656 KABC::Resource *resource;
657 while ( ( resource = resIt.current() ) != 0 ) { 657 while ( ( resource = resIt.current() ) != 0 ) {
658 ++resIt; 658 ++resIt;
659 if ( !resource->readOnly() ) { 659 if ( !resource->readOnly() ) {
660 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 660 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
661 if ( res ) 661 if ( res )
662 kresResources.append( res ); 662 kresResources.append( res );
663 } 663 }
664 } 664 }
665 665
666 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 666 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
667 return static_cast<KABC::Resource*>( res ); 667 return static_cast<KABC::Resource*>( res );
668} 668}
669 669
670#ifndef KAB_EMBEDDED 670#ifndef KAB_EMBEDDED
671KAboutData *KABCore::createAboutData() 671KAboutData *KABCore::createAboutData()
672#else //KAB_EMBEDDED 672#else //KAB_EMBEDDED
673void KABCore::createAboutData() 673void KABCore::createAboutData()
674#endif //KAB_EMBEDDED 674#endif //KAB_EMBEDDED
675{ 675{
676 676
677 677
678 QString version; 678 QString version;
679#include <../version> 679#include <../version>
680 QMessageBox::about( this, "About KAddressbook/Pi", 680 QMessageBox::about( this, "About KAddressbook/Pi",
681 "KAddressbook/Platform-independent\n" 681 "KAddressbook/Platform-independent\n"
682 "(KA/Pi) " +version + " - " + 682 "(KA/Pi) " +version + " - " +
683#ifdef DESKTOP_VERSION 683#ifdef DESKTOP_VERSION
684 "Desktop Edition\n" 684 "Desktop Edition\n"
685#else 685#else
686 "PDA-Edition\n" 686 "PDA-Edition\n"
687 "for: Zaurus 5500 / 7x0 / 8x0\n" 687 "for: Zaurus 5500 / 7x0 / 8x0\n"
688#endif 688#endif
689 689
690 "(c) 2004 Ulf Schenk\n" 690 "(c) 2004 Ulf Schenk\n"
691 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" 691 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n"
692 "(c) 1997-2003, The KDE PIM Team\n" 692 "(c) 1997-2003, The KDE PIM Team\n"
693 "Tobias Koenig Maintainer\n" 693 "Tobias Koenig Maintainer\n"
694 "Don Sanders Original author\n" 694 "Don Sanders Original author\n"
695 "Cornelius Schumacher Co-maintainer\n" 695 "Cornelius Schumacher Co-maintainer\n"
696 "Mike Pilone GUI and framework redesign\n" 696 "Mike Pilone GUI and framework redesign\n"
697 "Greg Stern DCOP interface\n" 697 "Greg Stern DCOP interface\n"
698 "Mark Westcot Contact pinning\n" 698 "Mark Westcot Contact pinning\n"
699 "Michel Boyer de la Giroday LDAP Lookup\n" 699 "Michel Boyer de la Giroday LDAP Lookup\n"
700 "Steffen Hansen LDAP Lookup" 700 "Steffen Hansen LDAP Lookup"
701#ifdef _WIN32_ 701#ifdef _WIN32_
702 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 702 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
703#endif 703#endif
704 ); 704 );
705} 705}
706 706
707void KABCore::setContactSelected( const QString &uid ) 707void KABCore::setContactSelected( const QString &uid )
708{ 708{
709 KABC::Addressee addr = mAddressBook->findByUid( uid ); 709 KABC::Addressee addr = mAddressBook->findByUid( uid );
710 if ( !mDetails->isHidden() ) 710 if ( !mDetails->isHidden() )
711 mDetails->setAddressee( addr ); 711 mDetails->setAddressee( addr );
712 712
713 if ( !addr.isEmpty() ) { 713 if ( !addr.isEmpty() ) {
714 emit contactSelected( addr.formattedName() ); 714 emit contactSelected( addr.formattedName() );
715 KABC::Picture pic = addr.photo(); 715 KABC::Picture pic = addr.photo();
716 if ( pic.isIntern() ) { 716 if ( pic.isIntern() ) {
717//US emit contactSelected( pic.data() ); 717//US emit contactSelected( pic.data() );
718//US instead use: 718//US instead use:
719 QPixmap px; 719 QPixmap px;
720 if (pic.data().isNull() != true) 720 if (pic.data().isNull() != true)
721 { 721 {
722 px.convertFromImage(pic.data()); 722 px.convertFromImage(pic.data());
723 } 723 }
724 724
725 emit contactSelected( px ); 725 emit contactSelected( px );
726 } 726 }
727 } 727 }
728 728
729 729
730 mExtensionManager->setSelectionChanged(); 730 mExtensionManager->setSelectionChanged();
731 731
732 // update the actions 732 // update the actions
733 bool selected = !uid.isEmpty(); 733 bool selected = !uid.isEmpty();
734 734
735 if ( mReadWrite ) { 735 if ( mReadWrite ) {
736 mActionCut->setEnabled( selected ); 736 mActionCut->setEnabled( selected );
737 mActionPaste->setEnabled( selected ); 737 mActionPaste->setEnabled( selected );
738 } 738 }
739 739
740 mActionCopy->setEnabled( selected ); 740 mActionCopy->setEnabled( selected );
741 mActionDelete->setEnabled( selected ); 741 mActionDelete->setEnabled( selected );
742 mActionEditAddressee->setEnabled( selected ); 742 mActionEditAddressee->setEnabled( selected );
743 mActionMail->setEnabled( selected ); 743 mActionMail->setEnabled( selected );
744 mActionMailVCard->setEnabled( selected ); 744 mActionMailVCard->setEnabled( selected );
745 //if (mActionBeam) 745 //if (mActionBeam)
746 //mActionBeam->setEnabled( selected ); 746 //mActionBeam->setEnabled( selected );
747 mActionWhoAmI->setEnabled( selected ); 747 mActionWhoAmI->setEnabled( selected );
748} 748}
749 749
750void KABCore::sendMail() 750void KABCore::sendMail()
751{ 751{
752 sendMail( mViewManager->selectedEmails().join( ", " ) ); 752 sendMail( mViewManager->selectedEmails().join( ", " ) );
753} 753}
754 754
755void KABCore::sendMail( const QString& emaillist ) 755void KABCore::sendMail( const QString& emaillist )
756{ 756{
757 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 757 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
758 if (emaillist.contains(",") > 0) 758 if (emaillist.contains(",") > 0)
759 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 759 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
760 else 760 else
761 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 761 ExternalAppHandler::instance()->mailToOneContact( emaillist );
762} 762}
763 763
764 764
765 765
766void KABCore::mailVCard() 766void KABCore::mailVCard()
767{ 767{
768 QStringList uids = mViewManager->selectedUids(); 768 QStringList uids = mViewManager->selectedUids();
769 if ( !uids.isEmpty() ) 769 if ( !uids.isEmpty() )
770 mailVCard( uids ); 770 mailVCard( uids );
771} 771}
772 772
773void KABCore::mailVCard( const QStringList& uids ) 773void KABCore::mailVCard( const QStringList& uids )
774{ 774{
775 QStringList urls; 775 QStringList urls;
776 776
777// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 777// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
778 778
779 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 779 QString dirName = "/tmp/" + KApplication::randomString( 8 );
780 780
781 781
782 782
783 QDir().mkdir( dirName, true ); 783 QDir().mkdir( dirName, true );
784 784
785 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 785 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
786 KABC::Addressee a = mAddressBook->findByUid( *it ); 786 KABC::Addressee a = mAddressBook->findByUid( *it );
787 787
788 if ( a.isEmpty() ) 788 if ( a.isEmpty() )
789 continue; 789 continue;
790 790
791 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 791 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
792 792
793 QString fileName = dirName + "/" + name; 793 QString fileName = dirName + "/" + name;
794 794
795 QFile outFile(fileName); 795 QFile outFile(fileName);
796 796
797 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 797 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
798 KABC::VCardConverter converter; 798 KABC::VCardConverter converter;
799 QString vcard; 799 QString vcard;
800 800
801 converter.addresseeToVCard( a, vcard ); 801 converter.addresseeToVCard( a, vcard );
802 802
803 QTextStream t( &outFile ); // use a text stream 803 QTextStream t( &outFile ); // use a text stream
804 t.setEncoding( QTextStream::UnicodeUTF8 ); 804 t.setEncoding( QTextStream::UnicodeUTF8 );
805 t << vcard; 805 t << vcard;
806 806
807 outFile.close(); 807 outFile.close();
808 808
809 urls.append( fileName ); 809 urls.append( fileName );
810 } 810 }
811 } 811 }
812 812
813 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 813 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
814 814
815 815
816/*US 816/*US
817 kapp->invokeMailer( QString::null, QString::null, QString::null, 817 kapp->invokeMailer( QString::null, QString::null, QString::null,
818 QString::null, // subject 818 QString::null, // subject
819 QString::null, // body 819 QString::null, // body
820 QString::null, 820 QString::null,
821 urls ); // attachments 821 urls ); // attachments
822*/ 822*/
823 823
824} 824}
825 825
826/** 826/**
827 Beams the "WhoAmI contact. 827 Beams the "WhoAmI contact.
828*/ 828*/
829void KABCore::beamMySelf() 829void KABCore::beamMySelf()
830{ 830{
831 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 831 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
832 if (!a.isEmpty()) 832 if (!a.isEmpty())
833 { 833 {
834 QStringList uids; 834 QStringList uids;
835 uids << a.uid(); 835 uids << a.uid();
836 836
837 beamVCard(uids); 837 beamVCard(uids);
838 } else { 838 } else {
839 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 839 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
840 840
841 841
842 } 842 }
843} 843}
844void KABCore::updateMainWindow() 844void KABCore::updateMainWindow()
845{ 845{
846 mMainWindow->showMaximized(); 846 mMainWindow->showMaximized();
847 mMainWindow->update(); 847 mMainWindow->update();
848} 848}
849void KABCore::resizeEvent(QResizeEvent* e ) 849void KABCore::resizeEvent(QResizeEvent* e )
850{ 850{
851 if ( !mMiniSplitter ) 851 if ( !mMiniSplitter )
852 return; 852 return;
853 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); 853 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
854 if ( e->oldSize().width() != e->size().width() ) 854 if ( e->oldSize().width() != e->size().width() )
855 if ( QApplication::desktop()->width() >= 480 ) { 855 if ( QApplication::desktop()->width() >= 480 ) {
856 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 856 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
857 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 857 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
858 mMiniSplitter->setOrientation( Qt::Horizontal); 858 mMiniSplitter->setOrientation( Qt::Horizontal);
859 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 859 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
860 } 860 }
861 if ( QApplication::desktop()->width() <= 640 ) { 861 if ( QApplication::desktop()->width() <= 640 ) {
862 mMainWindow->showMinimized(); 862 mMainWindow->showMinimized();
863 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 863 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
864 mViewManager->getFilterAction()->setComboWidth( 150 ); 864 mViewManager->getFilterAction()->setComboWidth( 150 );
865 if ( mIncSearchWidget ) 865 if ( mIncSearchWidget )
866 mIncSearchWidget->setSize(); 866 mIncSearchWidget->setSize();
867 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 867 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
868 } 868 }
869 869
870 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 870 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
871 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 871 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
872 mMiniSplitter->setOrientation( Qt::Vertical ); 872 mMiniSplitter->setOrientation( Qt::Vertical );
873 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 873 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
874 } 874 }
875 if ( QApplication::desktop()->width() <= 640 ) { 875 if ( QApplication::desktop()->width() <= 640 ) {
876 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 876 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
877 mMainWindow->showMinimized(); 877 mMainWindow->showMinimized();
878 if ( KABPrefs::instance()->mHideSearchOnSwitch ) { 878 if ( KABPrefs::instance()->mHideSearchOnSwitch ) {
879 if ( mIncSearchWidget ) { 879 if ( mIncSearchWidget ) {
880 mIncSearchWidget->setSize(); 880 mIncSearchWidget->setSize();
881 } 881 }
882 } else { 882 } else {
883 mViewManager->getFilterAction()->setComboWidth( 0 ); 883 mViewManager->getFilterAction()->setComboWidth( 0 );
884 } 884 }
885 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 885 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
886 } 886 }
887 } 887 }
888 } 888 }
889 QWidget::resizeEvent( e ); 889 QWidget::resizeEvent( e );
890 890
891} 891}
892void KABCore::export2phone() 892void KABCore::export2phone()
893{ 893{
894 894
895 QStringList uids; 895 QStringList uids;
896 XXPortSelectDialog dlg( this, false, this ); 896 XXPortSelectDialog dlg( this, false, this );
897 if ( dlg.exec() ) 897 if ( dlg.exec() )
898 uids = dlg.uids(); 898 uids = dlg.uids();
899 else 899 else
900 return; 900 return;
901 if ( uids.isEmpty() ) 901 if ( uids.isEmpty() )
902 return; 902 return;
903 // qDebug("count %d ", uids.count()); 903 // qDebug("count %d ", uids.count());
904 904
905 KAex2phonePrefs ex2phone; 905 KAex2phonePrefs ex2phone;
906 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 906 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
907 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 907 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
908 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 908 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
909 909
910 if ( !ex2phone.exec() ) { 910 if ( !ex2phone.exec() ) {
911 return; 911 return;
912 } 912 }
913 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 913 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
914 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 914 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
915 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 915 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
916 916
917 917
918 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 918 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
919 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 919 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
920 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 920 KPimGlobalPrefs::instance()->mEx2PhoneModel );
921 921
922 QString fileName = getPhoneFile(); 922 QString fileName = getPhoneFile();
923 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 923 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
924 return; 924 return;
925 925
926 message(i18n("Exporting to phone...")); 926 message(i18n("Exporting to phone..."));
927 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 927 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
928 928
929} 929}
930QString KABCore::getPhoneFile() 930QString KABCore::getPhoneFile()
931{ 931{
932#ifdef DESKTOP_VERSION 932#ifdef DESKTOP_VERSION
933 return locateLocal("tmp", "phonefile.vcf"); 933 return locateLocal("tmp", "phonefile.vcf");
934#else 934#else
935 return "/tmp/phonefile.vcf"; 935 return "/tmp/phonefile.vcf";
936#endif 936#endif
937 937
938} 938}
939void KABCore::writeToPhone( ) 939void KABCore::writeToPhone( )
940{ 940{
941 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 941 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
942 message(i18n("Export to phone finished!")); 942 message(i18n("Export to phone finished!"));
943 else 943 else
944 qDebug(i18n("KA: Error exporting to phone")); 944 qDebug(i18n("KA: Error exporting to phone"));
945} 945}
946void KABCore::beamVCard() 946void KABCore::beamVCard()
947{ 947{
948 QStringList uids; 948 QStringList uids;
949 XXPortSelectDialog dlg( this, false, this ); 949 XXPortSelectDialog dlg( this, false, this );
950 if ( dlg.exec() ) 950 if ( dlg.exec() )
951 uids = dlg.uids(); 951 uids = dlg.uids();
952 else 952 else
953 return; 953 return;
954 if ( uids.isEmpty() ) 954 if ( uids.isEmpty() )
955 return; 955 return;
956 beamVCard( uids ); 956 beamVCard( uids );
957} 957}
958 958
959 959
960void KABCore::beamVCard(const QStringList& uids) 960void KABCore::beamVCard(const QStringList& uids)
961{ 961{
962 962
963 // LR: we should use the /tmp dir on the Zaurus, 963 // LR: we should use the /tmp dir on the Zaurus,
964 // because: /tmp = RAM, (HOME)/kdepim = flash memory 964 // because: /tmp = RAM, (HOME)/kdepim = flash memory
965 965
966#ifdef DESKTOP_VERSION 966#ifdef DESKTOP_VERSION
967 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 967 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
968#else 968#else
969 QString fileName = "/tmp/kapibeamfile.vcf"; 969 QString fileName = "/tmp/kapibeamfile.vcf";
970#endif 970#endif
971 971
972 KABC::VCardConverter converter; 972 KABC::VCardConverter converter;
973 QString description; 973 QString description;
974 QString datastream; 974 QString datastream;
975 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 975 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
976 KABC::Addressee a = mAddressBook->findByUid( *it ); 976 KABC::Addressee a = mAddressBook->findByUid( *it );
977 977
978 if ( a.isEmpty() ) 978 if ( a.isEmpty() )
979 continue; 979 continue;
980 980
981 if (description.isEmpty()) 981 if (description.isEmpty())
982 description = a.formattedName(); 982 description = a.formattedName();
983 983
984 QString vcard; 984 QString vcard;
985 converter.addresseeToVCard( a, vcard ); 985 converter.addresseeToVCard( a, vcard );
986 int start = 0; 986 int start = 0;
987 int next; 987 int next;
988 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 988 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
989 int semi = vcard.find(";", next); 989 int semi = vcard.find(";", next);
990 int dopp = vcard.find(":", next); 990 int dopp = vcard.find(":", next);
991 int sep; 991 int sep;
992 if ( semi < dopp && semi >= 0 ) 992 if ( semi < dopp && semi >= 0 )
993 sep = semi ; 993 sep = semi ;
994 else 994 else
995 sep = dopp; 995 sep = dopp;
996 datastream +=vcard.mid( start, next - start); 996 datastream +=vcard.mid( start, next - start);
997 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 997 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
998 start = sep; 998 start = sep;
999 } 999 }
1000 datastream += vcard.mid( start,vcard.length() ); 1000 datastream += vcard.mid( start,vcard.length() );
1001 } 1001 }
1002#ifndef DESKTOP_VERSION 1002#ifndef DESKTOP_VERSION
1003 QFile outFile(fileName); 1003 QFile outFile(fileName);
1004 if ( outFile.open(IO_WriteOnly) ) { 1004 if ( outFile.open(IO_WriteOnly) ) {
1005 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 1005 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
1006 QTextStream t( &outFile ); // use a text stream 1006 QTextStream t( &outFile ); // use a text stream
1007 //t.setEncoding( QTextStream::UnicodeUTF8 ); 1007 //t.setEncoding( QTextStream::UnicodeUTF8 );
1008 t.setEncoding( QTextStream::Latin1 ); 1008 t.setEncoding( QTextStream::Latin1 );
1009 t <<datastream.latin1(); 1009 t <<datastream.latin1();
1010 outFile.close(); 1010 outFile.close();
1011 Ir *ir = new Ir( this ); 1011 Ir *ir = new Ir( this );
1012 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 1012 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
1013 ir->send( fileName, description, "text/x-vCard" ); 1013 ir->send( fileName, description, "text/x-vCard" );
1014 } else { 1014 } else {
1015 qDebug("KA: Error open temp beam file "); 1015 qDebug("KA: Error open temp beam file ");
1016 return; 1016 return;
1017 } 1017 }
1018#endif 1018#endif
1019 1019
1020} 1020}
1021 1021
1022void KABCore::beamDone( Ir *ir ) 1022void KABCore::beamDone( Ir *ir )
1023{ 1023{
1024#ifndef DESKTOP_VERSION 1024#ifndef DESKTOP_VERSION
1025 delete ir; 1025 delete ir;
1026#endif 1026#endif
1027 topLevelWidget()->raise(); 1027 topLevelWidget()->raise();
1028 message( i18n("Beaming finished!") ); 1028 message( i18n("Beaming finished!") );
1029} 1029}
1030 1030
1031 1031
1032void KABCore::browse( const QString& url ) 1032void KABCore::browse( const QString& url )
1033{ 1033{
1034#ifndef KAB_EMBEDDED 1034#ifndef KAB_EMBEDDED
1035 kapp->invokeBrowser( url ); 1035 kapp->invokeBrowser( url );
1036#else //KAB_EMBEDDED 1036#else //KAB_EMBEDDED
1037 qDebug("KABCore::browse must be fixed"); 1037 qDebug("KABCore::browse must be fixed");
1038#endif //KAB_EMBEDDED 1038#endif //KAB_EMBEDDED
1039} 1039}
1040 1040
1041void KABCore::selectAllContacts() 1041void KABCore::selectAllContacts()
1042{ 1042{
1043 mViewManager->setSelected( QString::null, true ); 1043 mViewManager->setSelected( QString::null, true );
1044} 1044}
1045 1045
1046void KABCore::deleteContacts() 1046void KABCore::deleteContacts()
1047{ 1047{
1048 QStringList uidList = mViewManager->selectedUids(); 1048 QStringList uidList = mViewManager->selectedUids();
1049 deleteContacts( uidList ); 1049 deleteContacts( uidList );
1050} 1050}
1051 1051
1052void KABCore::deleteContacts( const QStringList &uids ) 1052void KABCore::deleteContacts( const QStringList &uids )
1053{ 1053{
1054 1054
1055 if ( uids.count() > 0 ) { 1055 if ( uids.count() > 0 ) {
1056 1056
1057 if ( KABPrefs::instance()->mAskForDelete ) { 1057 if ( KABPrefs::instance()->mAskForDelete ) {
1058 int count = uids.count(); 1058 int count = uids.count();
1059 if ( count > 5 ) count = 5; 1059 if ( count > 5 ) count = 5;
1060 QString cNames; 1060 QString cNames;
1061 int i; 1061 int i;
1062 for ( i = 0; i < count ; ++i ) { 1062 for ( i = 0; i < count ; ++i ) {
1063 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n"; 1063 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n";
1064 } 1064 }
1065 if ( uids.count() > 5 ) 1065 if ( uids.count() > 5 )
1066 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 ); 1066 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 );
1067 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ; 1067 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ;
1068 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes ) 1068 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes )
1069 return; 1069 return;
1070 } 1070 }
1071 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1071 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1072 UndoStack::instance()->push( command ); 1072 UndoStack::instance()->push( command );
1073 RedoStack::instance()->clear(); 1073 RedoStack::instance()->clear();
1074 1074
1075 // now if we deleted anything, refresh 1075 // now if we deleted anything, refresh
1076 setContactSelected( QString::null ); 1076 setContactSelected( QString::null );
1077 setModified( true ); 1077 setModified( true );
1078 } 1078 }
1079} 1079}
1080 1080
1081void KABCore::copyContacts() 1081void KABCore::copyContacts()
1082{ 1082{
1083 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1083 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1084 1084
1085 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1085 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1086 1086
1087 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1087 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1088 1088
1089 QClipboard *cb = QApplication::clipboard(); 1089 QClipboard *cb = QApplication::clipboard();
1090 cb->setText( clipText ); 1090 cb->setText( clipText );
1091} 1091}
1092 1092
1093void KABCore::cutContacts() 1093void KABCore::cutContacts()
1094{ 1094{
1095 QStringList uidList = mViewManager->selectedUids(); 1095 QStringList uidList = mViewManager->selectedUids();
1096 1096
1097//US if ( uidList.size() > 0 ) { 1097//US if ( uidList.size() > 0 ) {
1098 if ( uidList.count() > 0 ) { 1098 if ( uidList.count() > 0 ) {
1099 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1099 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1100 UndoStack::instance()->push( command ); 1100 UndoStack::instance()->push( command );
1101 RedoStack::instance()->clear(); 1101 RedoStack::instance()->clear();
1102 1102
1103 setModified( true ); 1103 setModified( true );
1104 } 1104 }
1105} 1105}
1106 1106
1107void KABCore::pasteContacts() 1107void KABCore::pasteContacts()
1108{ 1108{
1109 QClipboard *cb = QApplication::clipboard(); 1109 QClipboard *cb = QApplication::clipboard();
1110 1110
1111 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1111 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1112 1112
1113 pasteContacts( list ); 1113 pasteContacts( list );
1114} 1114}
1115 1115
1116void KABCore::pasteContacts( KABC::Addressee::List &list ) 1116void KABCore::pasteContacts( KABC::Addressee::List &list )
1117{ 1117{
1118 KABC::Resource *resource = requestResource( this ); 1118 KABC::Resource *resource = requestResource( this );
1119 KABC::Addressee::List::Iterator it; 1119 KABC::Addressee::List::Iterator it;
1120 for ( it = list.begin(); it != list.end(); ++it ) 1120 for ( it = list.begin(); it != list.end(); ++it )
1121 (*it).setResource( resource ); 1121 (*it).setResource( resource );
1122 1122
1123 PwPasteCommand *command = new PwPasteCommand( this, list ); 1123 PwPasteCommand *command = new PwPasteCommand( this, list );
1124 UndoStack::instance()->push( command ); 1124 UndoStack::instance()->push( command );
1125 RedoStack::instance()->clear(); 1125 RedoStack::instance()->clear();
1126 1126
1127 setModified( true ); 1127 setModified( true );
1128} 1128}
1129 1129
1130void KABCore::setWhoAmI() 1130void KABCore::setWhoAmI()
1131{ 1131{
1132 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1132 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1133 1133
1134 if ( addrList.count() > 1 ) { 1134 if ( addrList.count() > 1 ) {
1135 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1135 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1136 return; 1136 return;
1137 } 1137 }
1138 1138
1139 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1139 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1140 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes ) 1140 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes )
1141 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1141 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1142} 1142}
1143void KABCore::editCategories() 1143void KABCore::editCategories()
1144{ 1144{
1145 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1145 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1146 dlg.exec(); 1146 dlg.exec();
1147} 1147}
1148void KABCore::setCategories() 1148void KABCore::setCategories()
1149{ 1149{
1150 1150
1151 QStringList uids; 1151 QStringList uids;
1152 XXPortSelectDialog dlgx( this, false, this ); 1152 XXPortSelectDialog dlgx( this, false, this );
1153 if ( dlgx.exec() ) 1153 if ( dlgx.exec() )
1154 uids = dlgx.uids(); 1154 uids = dlgx.uids();
1155 else 1155 else
1156 return; 1156 return;
1157 if ( uids.isEmpty() ) 1157 if ( uids.isEmpty() )
1158 return; 1158 return;
1159 // qDebug("count %d ", uids.count()); 1159 // qDebug("count %d ", uids.count());
1160 1160
1161 1161
1162 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1162 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1163 if ( !dlg.exec() ) { 1163 if ( !dlg.exec() ) {
1164 message( i18n("Setting categories cancelled") ); 1164 message( i18n("Setting categories cancelled") );
1165 return; 1165 return;
1166 } 1166 }
1167 bool merge = false; 1167 bool merge = false;
1168 QString msg = i18n( "Merge with existing categories?" ); 1168 QString msg = i18n( "Merge with existing categories?" );
1169 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1169 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1170 merge = true; 1170 merge = true;
1171 1171
1172 message( i18n("Setting categories ... please wait!") ); 1172 message( i18n("Setting categories ... please wait!") );
1173 QStringList categories = dlg.selectedCategories(); 1173 QStringList categories = dlg.selectedCategories();
1174 1174
1175 //QStringList uids = mViewManager->selectedUids(); 1175 //QStringList uids = mViewManager->selectedUids();
1176 QStringList::Iterator it; 1176 QStringList::Iterator it;
1177 for ( it = uids.begin(); it != uids.end(); ++it ) { 1177 for ( it = uids.begin(); it != uids.end(); ++it ) {
1178 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1178 KABC::Addressee addr = mAddressBook->findByUid( *it );
1179 if ( !addr.isEmpty() ) { 1179 if ( !addr.isEmpty() ) {
1180 if ( !merge ) 1180 if ( !merge )
1181 addr.setCategories( categories ); 1181 addr.setCategories( categories );
1182 else { 1182 else {
1183 QStringList addrCategories = addr.categories(); 1183 QStringList addrCategories = addr.categories();
1184 QStringList::Iterator catIt; 1184 QStringList::Iterator catIt;
1185 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1185 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1186 if ( !addrCategories.contains( *catIt ) ) 1186 if ( !addrCategories.contains( *catIt ) )
1187 addrCategories.append( *catIt ); 1187 addrCategories.append( *catIt );
1188 } 1188 }
1189 addr.setCategories( addrCategories ); 1189 addr.setCategories( addrCategories );
1190 } 1190 }
1191 mAddressBook->insertAddressee( addr ); 1191 mAddressBook->insertAddressee( addr );
1192 } 1192 }
1193 } 1193 }
1194 1194
1195 if ( uids.count() > 0 ) 1195 if ( uids.count() > 0 )
1196 setModified( true ); 1196 setModified( true );
1197 message( i18n("Setting categories completed!") ); 1197 message( i18n("Setting categories completed!") );
1198} 1198}
1199 1199
1200void KABCore::setSearchFields( const KABC::Field::List &fields ) 1200void KABCore::setSearchFields( const KABC::Field::List &fields )
1201{ 1201{
1202 mIncSearchWidget->setFields( fields ); 1202 mIncSearchWidget->setFields( fields );
1203} 1203}
1204 1204
1205void KABCore::incrementalSearch( const QString& text ) 1205void KABCore::incrementalSearch( const QString& text )
1206{ 1206{
1207 QString stext; 1207 QString stext;
1208 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { 1208 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) {
1209 stext = "*" + text; 1209 stext = "*" + text;
1210 } else { 1210 } else {
1211 stext = text; 1211 stext = text;
1212 } 1212 }
1213 mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); 1213 mViewManager->doSearch( stext, mIncSearchWidget->currentField() );
1214} 1214}
1215void KABCore::incrementalSearchJump( const QString& text ) 1215void KABCore::incrementalSearchJump( const QString& text )
1216{ 1216{
1217 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1217 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1218} 1218}
1219 1219
1220void KABCore::setModified() 1220void KABCore::setModified()
1221{ 1221{
1222 setModified( true ); 1222 setModified( true );
1223} 1223}
1224 1224
1225void KABCore::setModifiedWOrefresh() 1225void KABCore::setModifiedWOrefresh()
1226{ 1226{
1227 // qDebug("KABCore::setModifiedWOrefresh() "); 1227 // qDebug("KABCore::setModifiedWOrefresh() ");
1228 mModified = true; 1228 mModified = true;
1229 mActionSave->setEnabled( mModified ); 1229 mActionSave->setEnabled( mModified );
1230 1230
1231 1231
1232} 1232}
1233void KABCore::setModified( bool modified ) 1233void KABCore::setModified( bool modified )
1234{ 1234{
1235 mModified = modified; 1235 mModified = modified;
1236 mActionSave->setEnabled( mModified ); 1236 mActionSave->setEnabled( mModified );
1237 1237
1238 if ( modified ) 1238 if ( modified )
1239 mJumpButtonBar->recreateButtons(); 1239 mJumpButtonBar->recreateButtons();
1240 1240
1241 mViewManager->refreshView(); 1241 mViewManager->refreshView();
1242 1242
1243} 1243}
1244 1244
1245bool KABCore::modified() const 1245bool KABCore::modified() const
1246{ 1246{
1247 return mModified; 1247 return mModified;
1248} 1248}
1249 1249
1250void KABCore::contactModified( const KABC::Addressee &addr ) 1250void KABCore::contactModified( const KABC::Addressee &addr )
1251{ 1251{
1252 addrModified( addr ); 1252 addrModified( addr );
1253#if 0 // debug only 1253#if 0 // debug only
1254 KABC::Addressee ad = addr; 1254 KABC::Addressee ad = addr;
1255 ad.computeCsum( "123"); 1255 ad.computeCsum( "123");
1256#endif 1256#endif
1257} 1257}
1258 1258
1259void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1259void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1260{ 1260{
1261 1261
1262 Command *command = 0; 1262 Command *command = 0;
1263 QString uid; 1263 QString uid;
1264 1264
1265 // check if it exists already 1265 // check if it exists already
1266 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1266 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1267 if ( origAddr.isEmpty() ) 1267 if ( origAddr.isEmpty() )
1268 command = new PwNewCommand( mAddressBook, addr ); 1268 command = new PwNewCommand( mAddressBook, addr );
1269 else { 1269 else {
1270 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1270 command = new PwEditCommand( mAddressBook, origAddr, addr );
1271 uid = addr.uid(); 1271 uid = addr.uid();
1272 } 1272 }
1273 1273
1274 UndoStack::instance()->push( command ); 1274 UndoStack::instance()->push( command );
1275 RedoStack::instance()->clear(); 1275 RedoStack::instance()->clear();
1276 if ( updateDetails ) 1276 if ( updateDetails )
1277 mDetails->setAddressee( addr ); 1277 mDetails->setAddressee( addr );
1278 setModified( true ); 1278 setModified( true );
1279} 1279}
1280 1280
1281void KABCore::newContact() 1281void KABCore::newContact()
1282{ 1282{
1283 1283
1284 1284
1285 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1285 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1286 1286
1287 QPtrList<KRES::Resource> kresResources; 1287 QPtrList<KRES::Resource> kresResources;
1288 QPtrListIterator<KABC::Resource> it( kabcResources ); 1288 QPtrListIterator<KABC::Resource> it( kabcResources );
1289 KABC::Resource *resource; 1289 KABC::Resource *resource;
1290 while ( ( resource = it.current() ) != 0 ) { 1290 while ( ( resource = it.current() ) != 0 ) {
1291 ++it; 1291 ++it;
1292 if ( !resource->readOnly() ) { 1292 if ( !resource->readOnly() ) {
1293 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1293 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1294 if ( res ) 1294 if ( res )
1295 kresResources.append( res ); 1295 kresResources.append( res );
1296 } 1296 }
1297 } 1297 }
1298 1298
1299 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1299 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1300 resource = static_cast<KABC::Resource*>( res ); 1300 resource = static_cast<KABC::Resource*>( res );
1301 1301
1302 if ( resource ) { 1302 if ( resource ) {
1303 KABC::Addressee addr; 1303 KABC::Addressee addr;
1304 addr.setResource( resource ); 1304 addr.setResource( resource );
1305 mEditorDialog->setAddressee( addr ); 1305 mEditorDialog->setAddressee( addr );
1306 mEditorDialog->setCaption( i18n("Edit new contact")); 1306 mEditorDialog->setCaption( i18n("Edit new contact"));
1307 KApplication::execDialog ( mEditorDialog ); 1307 KApplication::execDialog ( mEditorDialog );
1308 1308
1309 } else 1309 } else
1310 return; 1310 return;
1311 1311
1312 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1312 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1313 1313
1314 1314
1315} 1315}
1316 1316
1317void KABCore::addEmail( QString aStr ) 1317void KABCore::addEmail( QString aStr )
1318{ 1318{
1319#ifndef KAB_EMBEDDED 1319#ifndef KAB_EMBEDDED
1320 QString fullName, email; 1320 QString fullName, email;
1321 1321
1322 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1322 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1323 1323
1324 // Try to lookup the addressee matching the email address 1324 // Try to lookup the addressee matching the email address
1325 bool found = false; 1325 bool found = false;
1326 QStringList emailList; 1326 QStringList emailList;
1327 KABC::AddressBook::Iterator it; 1327 KABC::AddressBook::Iterator it;
1328 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1328 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1329 emailList = (*it).emails(); 1329 emailList = (*it).emails();
1330 if ( emailList.contains( email ) > 0 ) { 1330 if ( emailList.contains( email ) > 0 ) {
1331 found = true; 1331 found = true;
1332 (*it).setNameFromString( fullName ); 1332 (*it).setNameFromString( fullName );
1333 editContact( (*it).uid() ); 1333 editContact( (*it).uid() );
1334 } 1334 }
1335 } 1335 }
1336 1336
1337 if ( !found ) { 1337 if ( !found ) {
1338 KABC::Addressee addr; 1338 KABC::Addressee addr;
1339 addr.setNameFromString( fullName ); 1339 addr.setNameFromString( fullName );
1340 addr.insertEmail( email, true ); 1340 addr.insertEmail( email, true );
1341 1341
1342 mAddressBook->insertAddressee( addr ); 1342 mAddressBook->insertAddressee( addr );
1343 mViewManager->refreshView( addr.uid() ); 1343 mViewManager->refreshView( addr.uid() );
1344 editContact( addr.uid() ); 1344 editContact( addr.uid() );
1345 } 1345 }
1346#else //KAB_EMBEDDED 1346#else //KAB_EMBEDDED
1347 qDebug("KABCore::addEmail finsih method"); 1347 qDebug("KABCore::addEmail finsih method");
1348#endif //KAB_EMBEDDED 1348#endif //KAB_EMBEDDED
1349} 1349}
1350 1350
1351void KABCore::importVCard( const KURL &url, bool showPreview ) 1351void KABCore::importVCard( const KURL &url, bool showPreview )
1352{ 1352{
1353 mXXPortManager->importVCard( url, showPreview ); 1353 mXXPortManager->importVCard( url, showPreview );
1354} 1354}
1355void KABCore::importFromOL() 1355void KABCore::importFromOL()
1356{ 1356{
1357#ifdef _OL_IMPORT_ 1357#ifdef _OL_IMPORT_
1358 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1358 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1359 idgl->exec(); 1359 idgl->exec();
1360 KABC::Addressee::List list = idgl->getAddressList(); 1360 KABC::Addressee::List list = idgl->getAddressList();
1361 if ( list.count() > 0 ) { 1361 if ( list.count() > 0 ) {
1362 KABC::Addressee::List listNew; 1362 KABC::Addressee::List listNew;
1363 KABC::Addressee::List listExisting; 1363 KABC::Addressee::List listExisting;
1364 KABC::Addressee::List::Iterator it; 1364 KABC::Addressee::List::Iterator it;
1365 KABC::AddressBook::Iterator iter; 1365 KABC::AddressBook::Iterator iter;
1366 for ( it = list.begin(); it != list.end(); ++it ) { 1366 for ( it = list.begin(); it != list.end(); ++it ) {
1367 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1367 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1368 listNew.append( (*it) ); 1368 listNew.append( (*it) );
1369 else 1369 else
1370 listExisting.append( (*it) ); 1370 listExisting.append( (*it) );
1371 } 1371 }
1372 if ( listExisting.count() > 0 ) 1372 if ( listExisting.count() > 0 )
1373 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1373 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1374 if ( listNew.count() > 0 ) { 1374 if ( listNew.count() > 0 ) {
1375 pasteWithNewUid = false; 1375 pasteWithNewUid = false;
1376 pasteContacts( listNew ); 1376 pasteContacts( listNew );
1377 pasteWithNewUid = true; 1377 pasteWithNewUid = true;
1378 } 1378 }
1379 } 1379 }
1380 delete idgl; 1380 delete idgl;
1381#endif 1381#endif
1382} 1382}
1383 1383
1384void KABCore::importVCard( const QString &vCard, bool showPreview ) 1384void KABCore::importVCard( const QString &vCard, bool showPreview )
1385{ 1385{
1386 mXXPortManager->importVCard( vCard, showPreview ); 1386 mXXPortManager->importVCard( vCard, showPreview );
1387} 1387}
1388 1388
1389//US added a second method without defaultparameter 1389//US added a second method without defaultparameter
1390void KABCore::editContact2() { 1390void KABCore::editContact2() {
1391 editContact( QString::null ); 1391 editContact( QString::null );
1392} 1392}
1393 1393
1394void KABCore::editContact( const QString &uid ) 1394void KABCore::editContact( const QString &uid )
1395{ 1395{
1396 1396
1397 if ( mExtensionManager->isQuickEditVisible() ) 1397 if ( mExtensionManager->isQuickEditVisible() )
1398 return; 1398 return;
1399 1399
1400 // First, locate the contact entry 1400 // First, locate the contact entry
1401 QString localUID = uid; 1401 QString localUID = uid;
1402 if ( localUID.isNull() ) { 1402 if ( localUID.isNull() ) {
1403 QStringList uidList = mViewManager->selectedUids(); 1403 QStringList uidList = mViewManager->selectedUids();
1404 if ( uidList.count() > 0 ) 1404 if ( uidList.count() > 0 )
1405 localUID = *( uidList.at( 0 ) ); 1405 localUID = *( uidList.at( 0 ) );
1406 } 1406 }
1407 1407
1408 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1408 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1409 if ( !addr.isEmpty() ) { 1409 if ( !addr.isEmpty() ) {
1410 mEditorDialog->setAddressee( addr ); 1410 mEditorDialog->setAddressee( addr );
1411 KApplication::execDialog ( mEditorDialog ); 1411 KApplication::execDialog ( mEditorDialog );
1412 } 1412 }
1413} 1413}
1414 1414
1415/** 1415/**
1416 Shows or edits the detail view for the given uid. If the uid is QString::null, 1416 Shows or edits the detail view for the given uid. If the uid is QString::null,
1417 the method will try to find a selected addressee in the view. 1417 the method will try to find a selected addressee in the view.
1418 */ 1418 */
1419void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1419void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1420{ 1420{
1421 if ( mMultipleViewsAtOnce ) 1421 if ( mMultipleViewsAtOnce )
1422 { 1422 {
1423 editContact( uid ); 1423 editContact( uid );
1424 } 1424 }
1425 else 1425 else
1426 { 1426 {
1427 setDetailsVisible( true ); 1427 setDetailsVisible( true );
1428 mActionDetails->setChecked(true); 1428 mActionDetails->setChecked(true);
1429 } 1429 }
1430 1430
1431} 1431}
1432 1432
1433void KABCore::save() 1433void KABCore::save()
1434{ 1434{
1435 if (syncManager->blockSave()) 1435 if (syncManager->blockSave())
1436 return; 1436 return;
1437 if ( !mModified ) 1437 if ( !mModified )
1438 return; 1438 return;
1439 1439
1440 syncManager->setBlockSave(true); 1440 syncManager->setBlockSave(true);
1441 QString text = i18n( "There was an error while attempting to save\n the " 1441 QString text = i18n( "There was an error while attempting to save\n the "
1442 "address book. Please check that some \nother application is " 1442 "address book. Please check that some \nother application is "
1443 "not using it. " ); 1443 "not using it. " );
1444 message(i18n("Saving ... please wait! "), false); 1444 message(i18n("Saving ... please wait! "), false);
1445 //qApp->processEvents(); 1445 //qApp->processEvents();
1446#ifndef KAB_EMBEDDED 1446#ifndef KAB_EMBEDDED
1447 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1447 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1448 if ( !b || !b->save() ) { 1448 if ( !b || !b->save() ) {
1449 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1449 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1450 } 1450 }
1451#else //KAB_EMBEDDED 1451#else //KAB_EMBEDDED
1452 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1452 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1453 if ( !b || !b->save() ) { 1453 if ( !b || !b->save() ) {
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp
index 8fe3ee0..c417226 100644
--- a/kaddressbook/kaddressbookmain.cpp
+++ b/kaddressbook/kaddressbookmain.cpp
@@ -1,241 +1,241 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 1999 Don Sanders <dsanders@kde.org> 3 Copyright (c) 1999 Don Sanders <dsanders@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#ifdef KAB_EMBEDDED 24#ifdef KAB_EMBEDDED
25#include "kabprefs.h" 25#include "kabprefs.h"
26#include <kglobal.h> 26#include <kglobal.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qtoolbar.h> 28#include <qtoolbar.h>
29#include <qapplication.h> 29#include <qapplication.h>
30#else //KAB_EMBEDDED 30#else //KAB_EMBEDDED
31#include <kedittoolbar.h> 31#include <kedittoolbar.h>
32#include <kkeydialog.h> 32#include <kkeydialog.h>
33#include <kmessagebox.h> 33#include <kmessagebox.h>
34#include <kstatusbar.h> 34#include <kstatusbar.h>
35#endif //KAB_EMBEDDED 35#endif //KAB_EMBEDDED
36#include <klocale.h> 36#include <klocale.h>
37 37
38#include "kabcore.h" 38#include "kabcore.h"
39#include "kaddressbookmain.h" 39#include "kaddressbookmain.h"
40#include "kactioncollection.h" 40#include "kactioncollection.h"
41 41
42#ifdef KAB_EMBEDDED 42#ifdef KAB_EMBEDDED
43KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" ) 43KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "abmain" )
44#else //KAB_EMBEDDED 44#else //KAB_EMBEDDED
45//MOC_SKIP_BEGIN 45//MOC_SKIP_BEGIN
46KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) 46KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 )
47//MOC_SKIP_END 47//MOC_SKIP_END
48#endif //KAB_EMBEDDED 48#endif //KAB_EMBEDDED
49{ 49{
50 setIcon(SmallIcon( "ka24" ) ); 50 setIcon(SmallIcon( "ka24" ) );
51#if 0 51#if 0
52 //US for embedded systems, create the toolbar before we initiate KABCore. 52 //US for embedded systems, create the toolbar before we initiate KABCore.
53 // KABCore will fill the toolbar with menues and icons 53 // KABCore will fill the toolbar with menues and icons
54 QMainWindow::ToolBarDock tbd; 54 QMainWindow::ToolBarDock tbd;
55 tbd = Top; 55 tbd = Top;
56 iconToolBar = new QToolBar( this ); 56 iconToolBar = new QToolBar( this );
57 addToolBar (iconToolBar , tbd ); 57 addToolBar (iconToolBar , tbd );
58 iconToolBar->setHorizontalStretchable(true); 58 iconToolBar->setHorizontalStretchable(true);
59//US iconToolBar->setWidth(300); 59//US iconToolBar->setWidth(300);
60#endif // 0 60#endif // 0
61 61
62 mCore = new KABCore( this, true, this ); 62 mCore = new KABCore( this, true, this );
63 63
64#ifdef KAB_EMBEDDED 64#ifdef KAB_EMBEDDED
65 setCaption( i18n( "KAddressbook/Pi" ) ); 65 setCaption( i18n( "KAddressbook/Pi" ) );
66#else //KAB_EMBEDDED 66#else //KAB_EMBEDDED
67 setCaption( i18n( "Address Book Browser" ) ); 67 setCaption( i18n( "Address Book Browser" ) );
68#endif //KAB_EMBEDDED 68#endif //KAB_EMBEDDED
69 69
70 //mCore->restoreSettings(); 70 //mCore->restoreSettings();
71 71
72 initActions(); 72 initActions();
73 73
74 setCentralWidget( mCore ); 74 setCentralWidget( mCore );
75 75
76//US statusBar()->show(); 76//US statusBar()->show();
77 77
78#ifndef KAB_EMBEDDED 78#ifndef KAB_EMBEDDED
79 setStandardToolBarMenuEnabled(true); 79 setStandardToolBarMenuEnabled(true);
80 80
81 createGUI( "kaddressbookui.rc", false ); 81 createGUI( "kaddressbookui.rc", false );
82 82
83 83
84#endif //KAB_EMBEDDED 84#endif //KAB_EMBEDDED
85 setAutoSaveSettings(); 85 setAutoSaveSettings();
86 mCore->restoreSettings(); 86 mCore->restoreSettings();
87#ifndef DESKTOP_VERSION 87#ifndef DESKTOP_VERSION
88 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), mCore, SLOT (receiveStart ( const QCString &, const QByteArray & ))); 88 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), mCore, SLOT (receiveStart ( const QCString &, const QByteArray & )));
89#endif 89#endif
90} 90}
91 91
92KAddressBookMain::~KAddressBookMain() 92KAddressBookMain::~KAddressBookMain()
93{ 93{
94 // mCore->saveSettings(); 94 // mCore->saveSettings();
95} 95}
96 96
97void KAddressBookMain::showMinimized () 97void KAddressBookMain::showMinimized ()
98{ 98{
99 QWidget::showMinimized () ; 99 QWidget::showMinimized () ;
100} 100}
101void KAddressBookMain::addEmail( QString addr ) 101void KAddressBookMain::addEmail( QString addr )
102{ 102{
103 mCore->addEmail( addr ); 103 mCore->addEmail( addr );
104} 104}
105 105
106#ifndef KAB_EMBEDDED 106#ifndef KAB_EMBEDDED
107ASYNC KAddressBookMain::showContactEditor( QString uid ) 107ASYNC KAddressBookMain::showContactEditor( QString uid )
108{ 108{
109 mCore->editContact( uid ); 109 mCore->editContact( uid );
110} 110}
111#endif //KAB_EMBEDDED 111#endif //KAB_EMBEDDED
112void KAddressBookMain::newContact() 112void KAddressBookMain::newContact()
113{ 113{
114 mCore->newContact(); 114 mCore->newContact();
115} 115}
116 116
117QString KAddressBookMain::getNameByPhone( QString phone ) 117QString KAddressBookMain::getNameByPhone( QString phone )
118{ 118{
119 return mCore->getNameByPhone( phone ); 119 return mCore->getNameByPhone( phone );
120} 120}
121 121
122void KAddressBookMain::save() 122void KAddressBookMain::save()
123{ 123{
124 mCore->save(); 124 mCore->save();
125} 125}
126 126
127void KAddressBookMain::exit() 127void KAddressBookMain::exit()
128{ 128{
129 close( ); 129 close( );
130} 130}
131 131
132void KAddressBookMain::saveProperties( KConfig* ) 132void KAddressBookMain::saveProperties( KConfig* )
133{ 133{
134} 134}
135 135
136void KAddressBookMain::readProperties( KConfig* ) 136void KAddressBookMain::readProperties( KConfig* )
137{ 137{
138} 138}
139 139
140void KAddressBookMain::initActions() 140void KAddressBookMain::initActions()
141{ 141{
142#ifndef KAB_EMBEDDED 142#ifndef KAB_EMBEDDED
143 KStdAction::quit( this, SLOT( close() ), actionCollection() ); 143 KStdAction::quit( this, SLOT( close() ), actionCollection() );
144 KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); 144 KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() );
145#else //KAB_EMBEDDED 145#else //KAB_EMBEDDED
146 //US: transfered the setup of the actions into KABCore 146 //US: transfered the setup of the actions into KABCore
147#endif //KAB_EMBEDDED 147#endif //KAB_EMBEDDED
148 148
149 149
150} 150}
151 151
152//US new method to setup menues and toolbars on embedded systems 152//US new method to setup menues and toolbars on embedded systems
153#ifdef KAB_EMBEDDED 153#ifdef KAB_EMBEDDED
154/* 154/*
155QToolBar * KAddressBookMain::getIconToolBar() 155QToolBar * KAddressBookMain::getIconToolBar()
156{ 156{
157 return iconToolBar; 157 return iconToolBar;
158} 158}
159*/ 159*/
160 160
161void KAddressBookMain::createGUI() 161void KAddressBookMain::createGUI()
162{ 162{
163 163
164 164
165 165
166} 166}
167#endif //KAB_EMBEDDED 167#endif //KAB_EMBEDDED
168 168
169void KAddressBookMain::configureToolbars() 169void KAddressBookMain::configureToolbars()
170{ 170{
171#ifndef KAB_EMBEDDED 171#ifndef KAB_EMBEDDED
172 saveMainWindowSettings( KGlobal::config(), "MainWindow" ); 172 saveMainWindowSettings( KGlobal::config(), "MainWindow" );
173 173
174 KEditToolbar dlg( factory() ); 174 KEditToolbar dlg( factory() );
175 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); 175 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) );
176 176
177 dlg.exec(); 177 dlg.exec();
178#else //KAB_EMBEDDED 178#else //KAB_EMBEDDED
179 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); 179 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" );
180#endif //KAB_EMBEDDED 180#endif //KAB_EMBEDDED
181} 181}
182 182
183void KAddressBookMain::slotNewToolbarConfig() 183void KAddressBookMain::slotNewToolbarConfig()
184{ 184{
185#ifndef KAB_EMBEDDED 185#ifndef KAB_EMBEDDED
186 applyMainWindowSettings( KGlobal::config(), "MainWindow" ); 186 applyMainWindowSettings( KGlobal::config(), "MainWindow" );
187#else //KAB_EMBEDDED 187#else //KAB_EMBEDDED
188 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); 188 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" );
189#endif //KAB_EMBEDDED 189#endif //KAB_EMBEDDED
190} 190}
191 191
192void KAddressBookMain::configureKeys() 192void KAddressBookMain::configureKeys()
193{ 193{
194#ifndef KAB_EMBEDDED 194#ifndef KAB_EMBEDDED
195 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); 195 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this );
196#else //KAB_EMBEDDED 196#else //KAB_EMBEDDED
197 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); 197 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" );
198#endif //KAB_EMBEDDED 198#endif //KAB_EMBEDDED
199} 199}
200 200
201void KAddressBookMain::closeEvent( QCloseEvent* ce ) 201void KAddressBookMain::closeEvent( QCloseEvent* ce )
202{ 202{
203 bool mModified = mCore->modified(); 203 bool mModified = mCore->modified();
204 bool mAskForQuit = KABPrefs::instance()->mAskForQuit; 204 bool mAskForQuit = KABPrefs::instance()->mAskForQuit;
205 205
206 QString mess = i18n( "Close KA/Pi?"); 206 QString mess = i18n( "Close KA/Pi?");
207 if ( mModified == true ) 207 if ( mModified == true )
208 mess += i18n( "\nChanges will be saved!"); 208 mess += i18n( "\nChanges will be saved!");
209 else 209 else
210 mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); 210 mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!");
211 211
212 bool mQuit = true; 212 bool mQuit = true;
213 213
214 214
215 if (mAskForQuit) 215 if (mAskForQuit)
216 { 216 {
217 217
218 int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); 218 int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 );
219 if (res == 0) 219 if (res == 0)
220 mQuit = true; 220 mQuit = true;
221 else 221 else
222 mQuit = false; 222 mQuit = false;
223 } 223 }
224 224
225 if (mQuit == false) 225 if (mQuit == false)
226 return; 226 return;
227 227
228 if (mModified == true) 228 if (mModified == true)
229 { 229 {
230 save(); 230 save();
231 mCore->saveSettings(); 231 mCore->saveSettings();
232 //KABPrefs::instance()->writeConfig(); 232 //KABPrefs::instance()->writeConfig();
233 } 233 }
234 234
235 ce->accept(); 235 ce->accept();
236} 236}
237 237
238#ifndef KAB_EMBEDDED 238#ifndef KAB_EMBEDDED
239#include "kaddressbookmain.moc" 239#include "kaddressbookmain.moc"
240#endif //KAB_EMBEDDED 240#endif //KAB_EMBEDDED
241 241