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