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