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