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