summaryrefslogtreecommitdiffabout
Unidiff
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,1372 +1,1381 @@
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}