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