summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp9
1 files changed, 0 insertions, 9 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 9ef97c9..ea103a9 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,1893 +1,1884 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118 118
119 119
120#include <kresources/selectdialog.h> 120#include <kresources/selectdialog.h>
121#include <kmessagebox.h> 121#include <kmessagebox.h>
122 122
123#include <picture.h> 123#include <picture.h>
124#include <resource.h> 124#include <resource.h>
125 125
126//US#include <qsplitter.h> 126//US#include <qsplitter.h>
127#include <qmap.h> 127#include <qmap.h>
128#include <qdir.h> 128#include <qdir.h>
129#include <qfile.h> 129#include <qfile.h>
130#include <qvbox.h> 130#include <qvbox.h>
131#include <qlayout.h> 131#include <qlayout.h>
132#include <qclipboard.h> 132#include <qclipboard.h>
133#include <qtextstream.h> 133#include <qtextstream.h>
134 134
135#include <libkdepim/categoryselectdialog.h> 135#include <libkdepim/categoryselectdialog.h>
136#include <kabc/vcardconverter.h> 136#include <kabc/vcardconverter.h>
137 137
138 138
139#include "addresseeutil.h" 139#include "addresseeutil.h"
140#include "undocmds.h" 140#include "undocmds.h"
141#include "addresseeeditordialog.h" 141#include "addresseeeditordialog.h"
142#include "viewmanager.h" 142#include "viewmanager.h"
143#include "details/detailsviewcontainer.h" 143#include "details/detailsviewcontainer.h"
144#include "kabprefs.h" 144#include "kabprefs.h"
145#include "xxportmanager.h" 145#include "xxportmanager.h"
146#include "incsearchwidget.h" 146#include "incsearchwidget.h"
147#include "jumpbuttonbar.h" 147#include "jumpbuttonbar.h"
148#include "extensionmanager.h" 148#include "extensionmanager.h"
149#include "addresseeconfig.h" 149#include "addresseeconfig.h"
150#include <kcmultidialog.h> 150#include <kcmultidialog.h>
151 151
152#ifdef _WIN32_ 152#ifdef _WIN32_
153 153
154#include "kaimportoldialog.h" 154#include "kaimportoldialog.h"
155#else 155#else
156#include <unistd.h> 156#include <unistd.h>
157#endif 157#endif
158// sync includes 158// sync includes
159#include <libkdepim/ksyncprofile.h> 159#include <libkdepim/ksyncprofile.h>
160#include <libkdepim/ksyncprefsdialog.h> 160#include <libkdepim/ksyncprefsdialog.h>
161 161
162class KAex2phonePrefs : public QDialog 162class KAex2phonePrefs : public QDialog
163{ 163{
164 public: 164 public:
165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
166 QDialog( parent, name, true ) 166 QDialog( parent, name, true )
167 { 167 {
168 setCaption( i18n("Export to phone options") ); 168 setCaption( i18n("Export to phone options") );
169 QVBoxLayout* lay = new QVBoxLayout( this ); 169 QVBoxLayout* lay = new QVBoxLayout( this );
170 lay->setSpacing( 3 ); 170 lay->setSpacing( 3 );
171 lay->setMargin( 3 ); 171 lay->setMargin( 3 );
172 QLabel *lab; 172 QLabel *lab;
173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
174 lab->setAlignment (AlignHCenter ); 174 lab->setAlignment (AlignHCenter );
175 QHBox* temphb; 175 QHBox* temphb;
176 temphb = new QHBox( this ); 176 temphb = new QHBox( this );
177 new QLabel( i18n("I/O device: "), temphb ); 177 new QLabel( i18n("I/O device: "), temphb );
178 mPhoneDevice = new QLineEdit( temphb); 178 mPhoneDevice = new QLineEdit( temphb);
179 lay->addWidget( temphb ); 179 lay->addWidget( temphb );
180 temphb = new QHBox( this ); 180 temphb = new QHBox( this );
181 new QLabel( i18n("Connection: "), temphb ); 181 new QLabel( i18n("Connection: "), temphb );
182 mPhoneConnection = new QLineEdit( temphb); 182 mPhoneConnection = new QLineEdit( temphb);
183 lay->addWidget( temphb ); 183 lay->addWidget( temphb );
184 temphb = new QHBox( this ); 184 temphb = new QHBox( this );
185 new QLabel( i18n("Model(opt.): "), temphb ); 185 new QLabel( i18n("Model(opt.): "), temphb );
186 mPhoneModel = new QLineEdit( temphb); 186 mPhoneModel = new QLineEdit( temphb);
187 lay->addWidget( temphb ); 187 lay->addWidget( temphb );
188 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 188 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
189 // lay->addWidget( mWriteToSim ); 189 // lay->addWidget( mWriteToSim );
190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
191 lab->setAlignment (AlignHCenter ); 191 lab->setAlignment (AlignHCenter );
192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
193 lay->addWidget( ok ); 193 lay->addWidget( ok );
194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
195 lay->addWidget( cancel ); 195 lay->addWidget( cancel );
196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
198 resize( 220, 240 ); 198 resize( 220, 240 );
199 199
200 } 200 }
201 201
202public: 202public:
203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
204 QCheckBox* mWriteToSim; 204 QCheckBox* mWriteToSim;
205}; 205};
206 206
207 207
208bool pasteWithNewUid = true; 208bool pasteWithNewUid = true;
209 209
210#ifdef KAB_EMBEDDED 210#ifdef KAB_EMBEDDED
211KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 211KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
212 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 212 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
213 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 213 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
214 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 214 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
215#else //KAB_EMBEDDED 215#else //KAB_EMBEDDED
216KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 216KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
217 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 217 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
218 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 218 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
219 mReadWrite( readWrite ), mModified( false ) 219 mReadWrite( readWrite ), mModified( false )
220#endif //KAB_EMBEDDED 220#endif //KAB_EMBEDDED
221{ 221{
222 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 222 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
223 // syncManager->setBlockSave(false); 223 // syncManager->setBlockSave(false);
224 mExtensionBarSplitter = 0; 224 mExtensionBarSplitter = 0;
225 mIsPart = !parent->inherits( "KAddressBookMain" ); 225 mIsPart = !parent->inherits( "KAddressBookMain" );
226 mAddressBook = KABC::StdAddressBook::self(); 226 mAddressBook = KABC::StdAddressBook::self();
227 KABC::StdAddressBook::setAutomaticSave( false ); 227 KABC::StdAddressBook::setAutomaticSave( false );
228 228
229#ifndef KAB_EMBEDDED 229#ifndef KAB_EMBEDDED
230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 232
233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
234 SLOT( addressBookChanged() ) ); 234 SLOT( addressBookChanged() ) );
235 235
236#if 0 236#if 0
237 // LP moved to addressbook init method 237 // LP moved to addressbook init method
238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
239 "X-Department", "KADDRESSBOOK" ); 239 "X-Department", "KADDRESSBOOK" );
240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
241 "X-Profession", "KADDRESSBOOK" ); 241 "X-Profession", "KADDRESSBOOK" );
242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
243 "X-AssistantsName", "KADDRESSBOOK" ); 243 "X-AssistantsName", "KADDRESSBOOK" );
244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
245 "X-ManagersName", "KADDRESSBOOK" ); 245 "X-ManagersName", "KADDRESSBOOK" );
246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
247 "X-SpousesName", "KADDRESSBOOK" ); 247 "X-SpousesName", "KADDRESSBOOK" );
248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
249 "X-Office", "KADDRESSBOOK" ); 249 "X-Office", "KADDRESSBOOK" );
250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
251 "X-IMAddress", "KADDRESSBOOK" ); 251 "X-IMAddress", "KADDRESSBOOK" );
252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
253 "X-Anniversary", "KADDRESSBOOK" ); 253 "X-Anniversary", "KADDRESSBOOK" );
254 254
255 //US added this field to become compatible with Opie/qtopia addressbook 255 //US added this field to become compatible with Opie/qtopia addressbook
256 // values can be "female" or "male" or "". An empty field represents undefined. 256 // values can be "female" or "male" or "". An empty field represents undefined.
257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
258 "X-Gender", "KADDRESSBOOK" ); 258 "X-Gender", "KADDRESSBOOK" );
259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
260 "X-Children", "KADDRESSBOOK" ); 260 "X-Children", "KADDRESSBOOK" );
261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
262 "X-FreeBusyUrl", "KADDRESSBOOK" ); 262 "X-FreeBusyUrl", "KADDRESSBOOK" );
263#endif 263#endif
264 initGUI(); 264 initGUI();
265 265
266 mIncSearchWidget->setFocus(); 266 mIncSearchWidget->setFocus();
267 267
268 268
269 connect( mViewManager, SIGNAL( selected( const QString& ) ), 269 connect( mViewManager, SIGNAL( selected( const QString& ) ),
270 SLOT( setContactSelected( const QString& ) ) ); 270 SLOT( setContactSelected( const QString& ) ) );
271 connect( mViewManager, SIGNAL( executed( const QString& ) ), 271 connect( mViewManager, SIGNAL( executed( const QString& ) ),
272 SLOT( executeContact( const QString& ) ) ); 272 SLOT( executeContact( const QString& ) ) );
273 273
274 connect( mViewManager, SIGNAL( deleteRequest( ) ), 274 connect( mViewManager, SIGNAL( deleteRequest( ) ),
275 SLOT( deleteContacts( ) ) ); 275 SLOT( deleteContacts( ) ) );
276 connect( mViewManager, SIGNAL( modified() ), 276 connect( mViewManager, SIGNAL( modified() ),
277 SLOT( setModified() ) ); 277 SLOT( setModified() ) );
278 278
279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
281 281
282 connect( mXXPortManager, SIGNAL( modified() ), 282 connect( mXXPortManager, SIGNAL( modified() ),
283 SLOT( setModified() ) ); 283 SLOT( setModified() ) );
284 284
285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
286 SLOT( incrementalSearch( const QString& ) ) ); 286 SLOT( incrementalSearch( const QString& ) ) );
287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
288 mJumpButtonBar, SLOT( recreateButtons() ) ); 288 mJumpButtonBar, SLOT( recreateButtons() ) );
289 289
290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
291 SLOT( sendMail( const QString& ) ) ); 291 SLOT( sendMail( const QString& ) ) );
292 292
293 293
294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
297 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 297 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
298 298
299 299
300#ifndef KAB_EMBEDDED 300#ifndef KAB_EMBEDDED
301 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 301 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
302 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 302 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
303 303
304 connect( mDetails, SIGNAL( browse( const QString& ) ), 304 connect( mDetails, SIGNAL( browse( const QString& ) ),
305 SLOT( browse( const QString& ) ) ); 305 SLOT( browse( const QString& ) ) );
306 306
307 307
308 mAddressBookService = new KAddressBookService( this ); 308 mAddressBookService = new KAddressBookService( this );
309 309
310#endif //KAB_EMBEDDED 310#endif //KAB_EMBEDDED
311 311
312 mMessageTimer = new QTimer( this ); 312 mMessageTimer = new QTimer( this );
313 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 313 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
314 mEditorDialog = 0; 314 mEditorDialog = 0;
315 createAddresseeEditorDialog( this ); 315 createAddresseeEditorDialog( this );
316 setModified( false ); 316 setModified( false );
317 mBRdisabled = false; 317 mBRdisabled = false;
318#ifndef DESKTOP_VERSION 318#ifndef DESKTOP_VERSION
319 infrared = 0; 319 infrared = 0;
320#endif 320#endif
321 //toggleBeamReceive( ); 321 //toggleBeamReceive( );
322} 322}
323 323
324KABCore::~KABCore() 324KABCore::~KABCore()
325{ 325{
326 // save(); 326 // save();
327 //saveSettings(); 327 //saveSettings();
328 //KABPrefs::instance()->writeConfig(); 328 //KABPrefs::instance()->writeConfig();
329 delete AddresseeConfig::instance(); 329 delete AddresseeConfig::instance();
330 mAddressBook = 0; 330 mAddressBook = 0;
331 KABC::StdAddressBook::close(); 331 KABC::StdAddressBook::close();
332 332
333 delete syncManager; 333 delete syncManager;
334#ifndef DESKTOP_VERSION 334#ifndef DESKTOP_VERSION
335 if ( infrared ) 335 if ( infrared )
336 delete infrared; 336 delete infrared;
337#endif 337#endif
338} 338}
339void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 339void KABCore::receive( const QCString& cmsg, const QByteArray& data )
340{ 340{
341 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 341 qDebug("KA: QCOP message received: %s ", cmsg.data() );
342 if ( cmsg == "setDocument(QString)" ) { 342 if ( cmsg == "setDocument(QString)" ) {
343 QDataStream stream( data, IO_ReadOnly ); 343 QDataStream stream( data, IO_ReadOnly );
344 QString fileName; 344 QString fileName;
345 stream >> fileName; 345 stream >> fileName;
346 recieve( fileName ); 346 recieve( fileName );
347 return; 347 return;
348 } 348 }
349 else if ( cmsg == "nextView()" )
350 {
351 //toggle between details/ no details
352 bool b = !mActionDetails->isChecked();
353 setDetailsVisible( b );
354 mActionDetails->setChecked( b );
355 }
356
357
358} 349}
359void KABCore::toggleBeamReceive( ) 350void KABCore::toggleBeamReceive( )
360{ 351{
361 if ( mBRdisabled ) 352 if ( mBRdisabled )
362 return; 353 return;
363#ifndef DESKTOP_VERSION 354#ifndef DESKTOP_VERSION
364 if ( infrared ) { 355 if ( infrared ) {
365 qDebug("AB disable BeamReceive "); 356 qDebug("AB disable BeamReceive ");
366 delete infrared; 357 delete infrared;
367 infrared = 0; 358 infrared = 0;
368 mActionBR->setChecked(false); 359 mActionBR->setChecked(false);
369 return; 360 return;
370 } 361 }
371 qDebug("AB enable BeamReceive "); 362 qDebug("AB enable BeamReceive ");
372 mActionBR->setChecked(true); 363 mActionBR->setChecked(true);
373 364
374 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 365 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
375 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 366 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
376#endif 367#endif
377} 368}
378 369
379 370
380void KABCore::disableBR(bool b) 371void KABCore::disableBR(bool b)
381{ 372{
382#ifndef DESKTOP_VERSION 373#ifndef DESKTOP_VERSION
383 if ( b ) { 374 if ( b ) {
384 if ( infrared ) { 375 if ( infrared ) {
385 toggleBeamReceive( ); 376 toggleBeamReceive( );
386 } 377 }
387 mBRdisabled = true; 378 mBRdisabled = true;
388 } else { 379 } else {
389 if ( mBRdisabled ) { 380 if ( mBRdisabled ) {
390 mBRdisabled = false; 381 mBRdisabled = false;
391 //toggleBeamReceive( ); 382 //toggleBeamReceive( );
392 } 383 }
393 } 384 }
394#endif 385#endif
395 386
396} 387}
397void KABCore::recieve( QString fn ) 388void KABCore::recieve( QString fn )
398{ 389{
399 //qDebug("KABCore::recieve "); 390 //qDebug("KABCore::recieve ");
400 int count = mAddressBook->importFromFile( fn, true ); 391 int count = mAddressBook->importFromFile( fn, true );
401 if ( count ) 392 if ( count )
402 setModified( true ); 393 setModified( true );
403 mViewManager->refreshView(); 394 mViewManager->refreshView();
404 message(i18n("%1 contact(s) received!").arg( count )); 395 message(i18n("%1 contact(s) received!").arg( count ));
405 topLevelWidget()->showMaximized(); 396 topLevelWidget()->showMaximized();
406 topLevelWidget()->raise(); 397 topLevelWidget()->raise();
407} 398}
408void KABCore::restoreSettings() 399void KABCore::restoreSettings()
409{ 400{
410 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 401 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
411 402
412 bool state; 403 bool state;
413 404
414 if (mMultipleViewsAtOnce) 405 if (mMultipleViewsAtOnce)
415 state = KABPrefs::instance()->mDetailsPageVisible; 406 state = KABPrefs::instance()->mDetailsPageVisible;
416 else 407 else
417 state = false; 408 state = false;
418 409
419 mActionDetails->setChecked( state ); 410 mActionDetails->setChecked( state );
420 setDetailsVisible( state ); 411 setDetailsVisible( state );
421 412
422 state = KABPrefs::instance()->mJumpButtonBarVisible; 413 state = KABPrefs::instance()->mJumpButtonBarVisible;
423 414
424 mActionJumpBar->setChecked( state ); 415 mActionJumpBar->setChecked( state );
425 setJumpButtonBarVisible( state ); 416 setJumpButtonBarVisible( state );
426/*US 417/*US
427 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 418 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
428 if ( splitterSize.count() == 0 ) { 419 if ( splitterSize.count() == 0 ) {
429 splitterSize.append( width() / 2 ); 420 splitterSize.append( width() / 2 );
430 splitterSize.append( width() / 2 ); 421 splitterSize.append( width() / 2 );
431 } 422 }
432 mMiniSplitter->setSizes( splitterSize ); 423 mMiniSplitter->setSizes( splitterSize );
433 if ( mExtensionBarSplitter ) { 424 if ( mExtensionBarSplitter ) {
434 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 425 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
435 if ( splitterSize.count() == 0 ) { 426 if ( splitterSize.count() == 0 ) {
436 splitterSize.append( width() / 2 ); 427 splitterSize.append( width() / 2 );
437 splitterSize.append( width() / 2 ); 428 splitterSize.append( width() / 2 );
438 } 429 }
439 mExtensionBarSplitter->setSizes( splitterSize ); 430 mExtensionBarSplitter->setSizes( splitterSize );
440 431
441 } 432 }
442*/ 433*/
443 mViewManager->restoreSettings(); 434 mViewManager->restoreSettings();
444 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 435 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
445 mExtensionManager->restoreSettings(); 436 mExtensionManager->restoreSettings();
446#ifdef DESKTOP_VERSION 437#ifdef DESKTOP_VERSION
447 int wid = width(); 438 int wid = width();
448 if ( wid < 10 ) 439 if ( wid < 10 )
449 wid = 400; 440 wid = 400;
450#else 441#else
451 int wid = QApplication::desktop()->width(); 442 int wid = QApplication::desktop()->width();
452 if ( wid < 640 ) 443 if ( wid < 640 )
453 wid = QApplication::desktop()->height(); 444 wid = QApplication::desktop()->height();
454#endif 445#endif
455 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 446 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
456 if ( true /*splitterSize.count() == 0*/ ) { 447 if ( true /*splitterSize.count() == 0*/ ) {
457 splitterSize.append( wid / 2 ); 448 splitterSize.append( wid / 2 );
458 splitterSize.append( wid / 2 ); 449 splitterSize.append( wid / 2 );
459 } 450 }
460 mMiniSplitter->setSizes( splitterSize ); 451 mMiniSplitter->setSizes( splitterSize );
461 if ( mExtensionBarSplitter ) { 452 if ( mExtensionBarSplitter ) {
462 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 453 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
463 if ( true /*splitterSize.count() == 0*/ ) { 454 if ( true /*splitterSize.count() == 0*/ ) {
464 splitterSize.append( wid / 2 ); 455 splitterSize.append( wid / 2 );
465 splitterSize.append( wid / 2 ); 456 splitterSize.append( wid / 2 );
466 } 457 }
467 mExtensionBarSplitter->setSizes( splitterSize ); 458 mExtensionBarSplitter->setSizes( splitterSize );
468 459
469 } 460 }
470 461
471 462
472} 463}
473 464
474void KABCore::saveSettings() 465void KABCore::saveSettings()
475{ 466{
476 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 467 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
477 if ( mExtensionBarSplitter ) 468 if ( mExtensionBarSplitter )
478 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 469 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
479 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 470 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
480 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 471 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
481#ifndef KAB_EMBEDDED 472#ifndef KAB_EMBEDDED
482 473
483 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 474 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
484 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 475 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
485#endif //KAB_EMBEDDED 476#endif //KAB_EMBEDDED
486 mExtensionManager->saveSettings(); 477 mExtensionManager->saveSettings();
487 mViewManager->saveSettings(); 478 mViewManager->saveSettings();
488 479
489 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 480 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
490} 481}
491 482
492KABC::AddressBook *KABCore::addressBook() const 483KABC::AddressBook *KABCore::addressBook() const
493{ 484{
494 return mAddressBook; 485 return mAddressBook;
495} 486}
496 487
497KConfig *KABCore::config() 488KConfig *KABCore::config()
498{ 489{
499#ifndef KAB_EMBEDDED 490#ifndef KAB_EMBEDDED
500 return KABPrefs::instance()->config(); 491 return KABPrefs::instance()->config();
501#else //KAB_EMBEDDED 492#else //KAB_EMBEDDED
502 return KABPrefs::instance()->getConfig(); 493 return KABPrefs::instance()->getConfig();
503#endif //KAB_EMBEDDED 494#endif //KAB_EMBEDDED
504} 495}
505 496
506KActionCollection *KABCore::actionCollection() const 497KActionCollection *KABCore::actionCollection() const
507{ 498{
508 return mGUIClient->actionCollection(); 499 return mGUIClient->actionCollection();
509} 500}
510 501
511KABC::Field *KABCore::currentSearchField() const 502KABC::Field *KABCore::currentSearchField() const
512{ 503{
513 if (mIncSearchWidget) 504 if (mIncSearchWidget)
514 return mIncSearchWidget->currentField(); 505 return mIncSearchWidget->currentField();
515 else 506 else
516 return 0; 507 return 0;
517} 508}
518 509
519QStringList KABCore::selectedUIDs() const 510QStringList KABCore::selectedUIDs() const
520{ 511{
521 return mViewManager->selectedUids(); 512 return mViewManager->selectedUids();
522} 513}
523 514
524KABC::Resource *KABCore::requestResource( QWidget *parent ) 515KABC::Resource *KABCore::requestResource( QWidget *parent )
525{ 516{
526 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 517 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
527 518
528 QPtrList<KRES::Resource> kresResources; 519 QPtrList<KRES::Resource> kresResources;
529 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 520 QPtrListIterator<KABC::Resource> resIt( kabcResources );
530 KABC::Resource *resource; 521 KABC::Resource *resource;
531 while ( ( resource = resIt.current() ) != 0 ) { 522 while ( ( resource = resIt.current() ) != 0 ) {
532 ++resIt; 523 ++resIt;
533 if ( !resource->readOnly() ) { 524 if ( !resource->readOnly() ) {
534 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 525 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
535 if ( res ) 526 if ( res )
536 kresResources.append( res ); 527 kresResources.append( res );
537 } 528 }
538 } 529 }
539 530
540 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 531 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
541 return static_cast<KABC::Resource*>( res ); 532 return static_cast<KABC::Resource*>( res );
542} 533}
543 534
544#ifndef KAB_EMBEDDED 535#ifndef KAB_EMBEDDED
545KAboutData *KABCore::createAboutData() 536KAboutData *KABCore::createAboutData()
546#else //KAB_EMBEDDED 537#else //KAB_EMBEDDED
547void KABCore::createAboutData() 538void KABCore::createAboutData()
548#endif //KAB_EMBEDDED 539#endif //KAB_EMBEDDED
549{ 540{
550#ifndef KAB_EMBEDDED 541#ifndef KAB_EMBEDDED
551 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 542 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
552 "3.1", I18N_NOOP( "The KDE Address Book" ), 543 "3.1", I18N_NOOP( "The KDE Address Book" ),
553 KAboutData::License_GPL_V2, 544 KAboutData::License_GPL_V2,
554 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 545 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
555 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 546 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
556 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 547 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
557 about->addAuthor( "Cornelius Schumacher", 548 about->addAuthor( "Cornelius Schumacher",
558 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 549 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
559 "schumacher@kde.org" ); 550 "schumacher@kde.org" );
560 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 551 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
561 "mpilone@slac.com" ); 552 "mpilone@slac.com" );
562 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 553 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
563 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 554 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
564 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 555 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
565 "michel@klaralvdalens-datakonsult.se" ); 556 "michel@klaralvdalens-datakonsult.se" );
566 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 557 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
567 "hansen@kde.org" ); 558 "hansen@kde.org" );
568 559
569 return about; 560 return about;
570#endif //KAB_EMBEDDED 561#endif //KAB_EMBEDDED
571 562
572 QString version; 563 QString version;
573#include <../version> 564#include <../version>
574 QMessageBox::about( this, "About KAddressbook/Pi", 565 QMessageBox::about( this, "About KAddressbook/Pi",
575 "KAddressbook/Platform-independent\n" 566 "KAddressbook/Platform-independent\n"
576 "(KA/Pi) " +version + " - " + 567 "(KA/Pi) " +version + " - " +
577#ifdef DESKTOP_VERSION 568#ifdef DESKTOP_VERSION
578 "Desktop Edition\n" 569 "Desktop Edition\n"
579#else 570#else
580 "PDA-Edition\n" 571 "PDA-Edition\n"
581 "for: Zaurus 5500 / 7x0 / 8x0\n" 572 "for: Zaurus 5500 / 7x0 / 8x0\n"
582#endif 573#endif
583 574
584 "(c) 2004 Ulf Schenk\n" 575 "(c) 2004 Ulf Schenk\n"
585 "(c) 2004 Lutz Rogowski\n" 576 "(c) 2004 Lutz Rogowski\n"
586 "(c) 1997-2003, The KDE PIM Team\n" 577 "(c) 1997-2003, The KDE PIM Team\n"
587 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 578 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
588 "Don Sanders Original author\n" 579 "Don Sanders Original author\n"
589 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 580 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
590 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 581 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
591 "Greg Stern DCOP interface\n" 582 "Greg Stern DCOP interface\n"
592 "Mark Westcot Contact pinning\n" 583 "Mark Westcot Contact pinning\n"
593 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 584 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
594 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 585 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
595#ifdef _WIN32_ 586#ifdef _WIN32_
596 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 587 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
597#endif 588#endif
598 ); 589 );
599} 590}
600 591
601void KABCore::setContactSelected( const QString &uid ) 592void KABCore::setContactSelected( const QString &uid )
602{ 593{
603 KABC::Addressee addr = mAddressBook->findByUid( uid ); 594 KABC::Addressee addr = mAddressBook->findByUid( uid );
604 if ( !mDetails->isHidden() ) 595 if ( !mDetails->isHidden() )
605 mDetails->setAddressee( addr ); 596 mDetails->setAddressee( addr );
606 597
607 if ( !addr.isEmpty() ) { 598 if ( !addr.isEmpty() ) {
608 emit contactSelected( addr.formattedName() ); 599 emit contactSelected( addr.formattedName() );
609 KABC::Picture pic = addr.photo(); 600 KABC::Picture pic = addr.photo();
610 if ( pic.isIntern() ) { 601 if ( pic.isIntern() ) {
611//US emit contactSelected( pic.data() ); 602//US emit contactSelected( pic.data() );
612//US instead use: 603//US instead use:
613 QPixmap px; 604 QPixmap px;
614 if (pic.data().isNull() != true) 605 if (pic.data().isNull() != true)
615 { 606 {
616 px.convertFromImage(pic.data()); 607 px.convertFromImage(pic.data());
617 } 608 }
618 609
619 emit contactSelected( px ); 610 emit contactSelected( px );
620 } 611 }
621 } 612 }
622 613
623 614
624 mExtensionManager->setSelectionChanged(); 615 mExtensionManager->setSelectionChanged();
625 616
626 // update the actions 617 // update the actions
627 bool selected = !uid.isEmpty(); 618 bool selected = !uid.isEmpty();
628 619
629 if ( mReadWrite ) { 620 if ( mReadWrite ) {
630 mActionCut->setEnabled( selected ); 621 mActionCut->setEnabled( selected );
631 mActionPaste->setEnabled( selected ); 622 mActionPaste->setEnabled( selected );
632 } 623 }
633 624
634 mActionCopy->setEnabled( selected ); 625 mActionCopy->setEnabled( selected );
635 mActionDelete->setEnabled( selected ); 626 mActionDelete->setEnabled( selected );
636 mActionEditAddressee->setEnabled( selected ); 627 mActionEditAddressee->setEnabled( selected );
637 mActionMail->setEnabled( selected ); 628 mActionMail->setEnabled( selected );
638 mActionMailVCard->setEnabled( selected ); 629 mActionMailVCard->setEnabled( selected );
639 //if (mActionBeam) 630 //if (mActionBeam)
640 //mActionBeam->setEnabled( selected ); 631 //mActionBeam->setEnabled( selected );
641 632
642 if (mActionBeamVCard) 633 if (mActionBeamVCard)
643 mActionBeamVCard->setEnabled( selected ); 634 mActionBeamVCard->setEnabled( selected );
644 635
645 mActionExport2phone->setEnabled( selected ); 636 mActionExport2phone->setEnabled( selected );
646 mActionWhoAmI->setEnabled( selected ); 637 mActionWhoAmI->setEnabled( selected );
647 mActionCategories->setEnabled( selected ); 638 mActionCategories->setEnabled( selected );
648} 639}
649 640
650void KABCore::sendMail() 641void KABCore::sendMail()
651{ 642{
652 sendMail( mViewManager->selectedEmails().join( ", " ) ); 643 sendMail( mViewManager->selectedEmails().join( ", " ) );
653} 644}
654 645
655void KABCore::sendMail( const QString& emaillist ) 646void KABCore::sendMail( const QString& emaillist )
656{ 647{
657 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 648 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
658 if (emaillist.contains(",") > 0) 649 if (emaillist.contains(",") > 0)
659 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 650 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
660 else 651 else
661 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 652 ExternalAppHandler::instance()->mailToOneContact( emaillist );
662} 653}
663 654
664 655
665 656
666void KABCore::mailVCard() 657void KABCore::mailVCard()
667{ 658{
668 QStringList uids = mViewManager->selectedUids(); 659 QStringList uids = mViewManager->selectedUids();
669 if ( !uids.isEmpty() ) 660 if ( !uids.isEmpty() )
670 mailVCard( uids ); 661 mailVCard( uids );
671} 662}
672 663
673void KABCore::mailVCard( const QStringList& uids ) 664void KABCore::mailVCard( const QStringList& uids )
674{ 665{
675 QStringList urls; 666 QStringList urls;
676 667
677// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 668// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
678 669
679 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 670 QString dirName = "/tmp/" + KApplication::randomString( 8 );
680 671
681 672
682 673
683 QDir().mkdir( dirName, true ); 674 QDir().mkdir( dirName, true );
684 675
685 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 676 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
686 KABC::Addressee a = mAddressBook->findByUid( *it ); 677 KABC::Addressee a = mAddressBook->findByUid( *it );
687 678
688 if ( a.isEmpty() ) 679 if ( a.isEmpty() )
689 continue; 680 continue;
690 681
691 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 682 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
692 683
693 QString fileName = dirName + "/" + name; 684 QString fileName = dirName + "/" + name;
694 685
695 QFile outFile(fileName); 686 QFile outFile(fileName);
696 687
697 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 688 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
698 KABC::VCardConverter converter; 689 KABC::VCardConverter converter;
699 QString vcard; 690 QString vcard;
700 691
701 converter.addresseeToVCard( a, vcard ); 692 converter.addresseeToVCard( a, vcard );
702 693
703 QTextStream t( &outFile ); // use a text stream 694 QTextStream t( &outFile ); // use a text stream
704 t.setEncoding( QTextStream::UnicodeUTF8 ); 695 t.setEncoding( QTextStream::UnicodeUTF8 );
705 t << vcard; 696 t << vcard;
706 697
707 outFile.close(); 698 outFile.close();
708 699
709 urls.append( fileName ); 700 urls.append( fileName );
710 } 701 }
711 } 702 }
712 703
713 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 704 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
714 705
715 706
716/*US 707/*US
717 kapp->invokeMailer( QString::null, QString::null, QString::null, 708 kapp->invokeMailer( QString::null, QString::null, QString::null,
718 QString::null, // subject 709 QString::null, // subject
719 QString::null, // body 710 QString::null, // body
720 QString::null, 711 QString::null,
721 urls ); // attachments 712 urls ); // attachments
722*/ 713*/
723 714
724} 715}
725 716
726/** 717/**
727 Beams the "WhoAmI contact. 718 Beams the "WhoAmI contact.
728*/ 719*/
729void KABCore::beamMySelf() 720void KABCore::beamMySelf()
730{ 721{
731 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 722 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
732 if (!a.isEmpty()) 723 if (!a.isEmpty())
733 { 724 {
734 QStringList uids; 725 QStringList uids;
735 uids << a.uid(); 726 uids << a.uid();
736 727
737 beamVCard(uids); 728 beamVCard(uids);
738 } else { 729 } else {
739 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 730 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
740 731
741 732
742 } 733 }
743} 734}
744 735
745void KABCore::export2phone() 736void KABCore::export2phone()
746{ 737{
747 738
748 KAex2phonePrefs ex2phone; 739 KAex2phonePrefs ex2phone;
749 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 740 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
750 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 741 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
751 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 742 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
752 743
753 if ( !ex2phone.exec() ) { 744 if ( !ex2phone.exec() ) {
754 return; 745 return;
755 } 746 }
756 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 747 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
757 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 748 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
758 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 749 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
759 750
760 751
761 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 752 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
762 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 753 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
763 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 754 KPimGlobalPrefs::instance()->mEx2PhoneModel );
764 755
765 QStringList uids = mViewManager->selectedUids(); 756 QStringList uids = mViewManager->selectedUids();
766 if ( uids.isEmpty() ) 757 if ( uids.isEmpty() )
767 return; 758 return;
768 759
769 QString fileName = getPhoneFile(); 760 QString fileName = getPhoneFile();
770 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 761 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
771 return; 762 return;
772 763
773 message(i18n("Exporting to phone...")); 764 message(i18n("Exporting to phone..."));
774 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 765 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
775 766
776} 767}
777QString KABCore::getPhoneFile() 768QString KABCore::getPhoneFile()
778{ 769{
779#ifdef DESKTOP_VERSION 770#ifdef DESKTOP_VERSION
780 return locateLocal("tmp", "phonefile.vcf"); 771 return locateLocal("tmp", "phonefile.vcf");
781#else 772#else
782 return "/tmp/phonefile.vcf"; 773 return "/tmp/phonefile.vcf";
783#endif 774#endif
784 775
785} 776}
786void KABCore::writeToPhone( ) 777void KABCore::writeToPhone( )
787{ 778{
788 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 779 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
789 message(i18n("Export to phone finished!")); 780 message(i18n("Export to phone finished!"));
790 else 781 else
791 qDebug(i18n("Error exporting to phone")); 782 qDebug(i18n("Error exporting to phone"));
792} 783}
793void KABCore::beamVCard() 784void KABCore::beamVCard()
794{ 785{
795 QStringList uids = mViewManager->selectedUids(); 786 QStringList uids = mViewManager->selectedUids();
796 if ( !uids.isEmpty() ) 787 if ( !uids.isEmpty() )
797 beamVCard( uids ); 788 beamVCard( uids );
798} 789}
799 790
800 791
801void KABCore::beamVCard(const QStringList& uids) 792void KABCore::beamVCard(const QStringList& uids)
802{ 793{
803 794
804 // LR: we should use the /tmp dir on the Zaurus, 795 // LR: we should use the /tmp dir on the Zaurus,
805 // because: /tmp = RAM, (HOME)/kdepim = flash memory 796 // because: /tmp = RAM, (HOME)/kdepim = flash memory
806 797
807#ifdef DESKTOP_VERSION 798#ifdef DESKTOP_VERSION
808 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 799 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
809#else 800#else
810 QString fileName = "/tmp/kapibeamfile.vcf"; 801 QString fileName = "/tmp/kapibeamfile.vcf";
811#endif 802#endif
812 803
813 KABC::VCardConverter converter; 804 KABC::VCardConverter converter;
814 QString description; 805 QString description;
815 QString datastream; 806 QString datastream;
816 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 807 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
817 KABC::Addressee a = mAddressBook->findByUid( *it ); 808 KABC::Addressee a = mAddressBook->findByUid( *it );
818 809
819 if ( a.isEmpty() ) 810 if ( a.isEmpty() )
820 continue; 811 continue;
821 812
822 if (description.isEmpty()) 813 if (description.isEmpty())
823 description = a.formattedName(); 814 description = a.formattedName();
824 815
825 QString vcard; 816 QString vcard;
826 converter.addresseeToVCard( a, vcard ); 817 converter.addresseeToVCard( a, vcard );
827 int start = 0; 818 int start = 0;
828 int next; 819 int next;
829 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 820 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
830 int semi = vcard.find(";", next); 821 int semi = vcard.find(";", next);
831 int dopp = vcard.find(":", next); 822 int dopp = vcard.find(":", next);
832 int sep; 823 int sep;
833 if ( semi < dopp && semi >= 0 ) 824 if ( semi < dopp && semi >= 0 )
834 sep = semi ; 825 sep = semi ;
835 else 826 else
836 sep = dopp; 827 sep = dopp;
837 datastream +=vcard.mid( start, next - start); 828 datastream +=vcard.mid( start, next - start);
838 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 829 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
839 start = sep; 830 start = sep;
840 } 831 }
841 datastream += vcard.mid( start,vcard.length() ); 832 datastream += vcard.mid( start,vcard.length() );
842 } 833 }
843#ifndef DESKTOP_VERSION 834#ifndef DESKTOP_VERSION
844 QFile outFile(fileName); 835 QFile outFile(fileName);
845 if ( outFile.open(IO_WriteOnly) ) { 836 if ( outFile.open(IO_WriteOnly) ) {
846 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 837 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
847 QTextStream t( &outFile ); // use a text stream 838 QTextStream t( &outFile ); // use a text stream
848 //t.setEncoding( QTextStream::UnicodeUTF8 ); 839 //t.setEncoding( QTextStream::UnicodeUTF8 );
849 t.setEncoding( QTextStream::Latin1 ); 840 t.setEncoding( QTextStream::Latin1 );
850 t <<datastream.latin1(); 841 t <<datastream.latin1();
851 outFile.close(); 842 outFile.close();
852 Ir *ir = new Ir( this ); 843 Ir *ir = new Ir( this );
853 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 844 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
854 ir->send( fileName, description, "text/x-vCard" ); 845 ir->send( fileName, description, "text/x-vCard" );
855 } else { 846 } else {
856 qDebug("Error open temp beam file "); 847 qDebug("Error open temp beam file ");
857 return; 848 return;
858 } 849 }
859#endif 850#endif
860 851
861} 852}
862 853
863void KABCore::beamDone( Ir *ir ) 854void KABCore::beamDone( Ir *ir )
864{ 855{
865#ifndef DESKTOP_VERSION 856#ifndef DESKTOP_VERSION
866 delete ir; 857 delete ir;
867#endif 858#endif
868 topLevelWidget()->raise(); 859 topLevelWidget()->raise();
869 message( i18n("Beaming finished!") ); 860 message( i18n("Beaming finished!") );
870} 861}
871 862
872 863
873void KABCore::browse( const QString& url ) 864void KABCore::browse( const QString& url )
874{ 865{
875#ifndef KAB_EMBEDDED 866#ifndef KAB_EMBEDDED
876 kapp->invokeBrowser( url ); 867 kapp->invokeBrowser( url );
877#else //KAB_EMBEDDED 868#else //KAB_EMBEDDED
878 qDebug("KABCore::browse must be fixed"); 869 qDebug("KABCore::browse must be fixed");
879#endif //KAB_EMBEDDED 870#endif //KAB_EMBEDDED
880} 871}
881 872
882void KABCore::selectAllContacts() 873void KABCore::selectAllContacts()
883{ 874{
884 mViewManager->setSelected( QString::null, true ); 875 mViewManager->setSelected( QString::null, true );
885} 876}
886 877
887void KABCore::deleteContacts() 878void KABCore::deleteContacts()
888{ 879{
889 QStringList uidList = mViewManager->selectedUids(); 880 QStringList uidList = mViewManager->selectedUids();
890 deleteContacts( uidList ); 881 deleteContacts( uidList );
891} 882}
892 883
893void KABCore::deleteContacts( const QStringList &uids ) 884void KABCore::deleteContacts( const QStringList &uids )
894{ 885{
895 if ( uids.count() > 0 ) { 886 if ( uids.count() > 0 ) {
896 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 887 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
897 UndoStack::instance()->push( command ); 888 UndoStack::instance()->push( command );
898 RedoStack::instance()->clear(); 889 RedoStack::instance()->clear();
899 890
900 // now if we deleted anything, refresh 891 // now if we deleted anything, refresh
901 setContactSelected( QString::null ); 892 setContactSelected( QString::null );
902 setModified( true ); 893 setModified( true );
903 } 894 }
904} 895}
905 896
906void KABCore::copyContacts() 897void KABCore::copyContacts()
907{ 898{
908 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 899 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
909 900
910 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 901 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
911 902
912 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 903 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
913 904
914 QClipboard *cb = QApplication::clipboard(); 905 QClipboard *cb = QApplication::clipboard();
915 cb->setText( clipText ); 906 cb->setText( clipText );
916} 907}
917 908
918void KABCore::cutContacts() 909void KABCore::cutContacts()
919{ 910{
920 QStringList uidList = mViewManager->selectedUids(); 911 QStringList uidList = mViewManager->selectedUids();
921 912
922//US if ( uidList.size() > 0 ) { 913//US if ( uidList.size() > 0 ) {
923 if ( uidList.count() > 0 ) { 914 if ( uidList.count() > 0 ) {
924 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 915 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
925 UndoStack::instance()->push( command ); 916 UndoStack::instance()->push( command );
926 RedoStack::instance()->clear(); 917 RedoStack::instance()->clear();
927 918
928 setModified( true ); 919 setModified( true );
929 } 920 }
930} 921}
931 922
932void KABCore::pasteContacts() 923void KABCore::pasteContacts()
933{ 924{
934 QClipboard *cb = QApplication::clipboard(); 925 QClipboard *cb = QApplication::clipboard();
935 926
936 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 927 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
937 928
938 pasteContacts( list ); 929 pasteContacts( list );
939} 930}
940 931
941void KABCore::pasteContacts( KABC::Addressee::List &list ) 932void KABCore::pasteContacts( KABC::Addressee::List &list )
942{ 933{
943 KABC::Resource *resource = requestResource( this ); 934 KABC::Resource *resource = requestResource( this );
944 KABC::Addressee::List::Iterator it; 935 KABC::Addressee::List::Iterator it;
945 for ( it = list.begin(); it != list.end(); ++it ) 936 for ( it = list.begin(); it != list.end(); ++it )
946 (*it).setResource( resource ); 937 (*it).setResource( resource );
947 938
948 PwPasteCommand *command = new PwPasteCommand( this, list ); 939 PwPasteCommand *command = new PwPasteCommand( this, list );
949 UndoStack::instance()->push( command ); 940 UndoStack::instance()->push( command );
950 RedoStack::instance()->clear(); 941 RedoStack::instance()->clear();
951 942
952 setModified( true ); 943 setModified( true );
953} 944}
954 945
955void KABCore::setWhoAmI() 946void KABCore::setWhoAmI()
956{ 947{
957 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 948 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
958 949
959 if ( addrList.count() > 1 ) { 950 if ( addrList.count() > 1 ) {
960 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 951 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
961 return; 952 return;
962 } 953 }
963 954
964 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 955 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
965 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 956 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
966 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 957 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
967} 958}
968 959
969void KABCore::setCategories() 960void KABCore::setCategories()
970{ 961{
971 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 962 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
972 if ( !dlg.exec() ) 963 if ( !dlg.exec() )
973 return; 964 return;
974 965
975 bool merge = false; 966 bool merge = false;
976 QString msg = i18n( "Merge with existing categories?" ); 967 QString msg = i18n( "Merge with existing categories?" );
977 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 968 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
978 merge = true; 969 merge = true;
979 970
980 QStringList categories = dlg.selectedCategories(); 971 QStringList categories = dlg.selectedCategories();
981 972
982 QStringList uids = mViewManager->selectedUids(); 973 QStringList uids = mViewManager->selectedUids();
983 QStringList::Iterator it; 974 QStringList::Iterator it;
984 for ( it = uids.begin(); it != uids.end(); ++it ) { 975 for ( it = uids.begin(); it != uids.end(); ++it ) {
985 KABC::Addressee addr = mAddressBook->findByUid( *it ); 976 KABC::Addressee addr = mAddressBook->findByUid( *it );
986 if ( !addr.isEmpty() ) { 977 if ( !addr.isEmpty() ) {
987 if ( !merge ) 978 if ( !merge )
988 addr.setCategories( categories ); 979 addr.setCategories( categories );
989 else { 980 else {
990 QStringList addrCategories = addr.categories(); 981 QStringList addrCategories = addr.categories();
991 QStringList::Iterator catIt; 982 QStringList::Iterator catIt;
992 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 983 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
993 if ( !addrCategories.contains( *catIt ) ) 984 if ( !addrCategories.contains( *catIt ) )
994 addrCategories.append( *catIt ); 985 addrCategories.append( *catIt );
995 } 986 }
996 addr.setCategories( addrCategories ); 987 addr.setCategories( addrCategories );
997 } 988 }
998 989
999 mAddressBook->insertAddressee( addr ); 990 mAddressBook->insertAddressee( addr );
1000 } 991 }
1001 } 992 }
1002 993
1003 if ( uids.count() > 0 ) 994 if ( uids.count() > 0 )
1004 setModified( true ); 995 setModified( true );
1005} 996}
1006 997
1007void KABCore::setSearchFields( const KABC::Field::List &fields ) 998void KABCore::setSearchFields( const KABC::Field::List &fields )
1008{ 999{
1009 mIncSearchWidget->setFields( fields ); 1000 mIncSearchWidget->setFields( fields );
1010} 1001}
1011 1002
1012void KABCore::incrementalSearch( const QString& text ) 1003void KABCore::incrementalSearch( const QString& text )
1013{ 1004{
1014 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1005 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1015} 1006}
1016 1007
1017void KABCore::setModified() 1008void KABCore::setModified()
1018{ 1009{
1019 setModified( true ); 1010 setModified( true );
1020} 1011}
1021 1012
1022void KABCore::setModifiedWOrefresh() 1013void KABCore::setModifiedWOrefresh()
1023{ 1014{
1024 // qDebug("KABCore::setModifiedWOrefresh() "); 1015 // qDebug("KABCore::setModifiedWOrefresh() ");
1025 mModified = true; 1016 mModified = true;
1026 mActionSave->setEnabled( mModified ); 1017 mActionSave->setEnabled( mModified );
1027#ifdef DESKTOP_VERSION 1018#ifdef DESKTOP_VERSION
1028 mDetails->refreshView(); 1019 mDetails->refreshView();
1029#endif 1020#endif
1030 1021
1031} 1022}
1032void KABCore::setModified( bool modified ) 1023void KABCore::setModified( bool modified )
1033{ 1024{
1034 mModified = modified; 1025 mModified = modified;
1035 mActionSave->setEnabled( mModified ); 1026 mActionSave->setEnabled( mModified );
1036 1027
1037 if ( modified ) 1028 if ( modified )
1038 mJumpButtonBar->recreateButtons(); 1029 mJumpButtonBar->recreateButtons();
1039 1030
1040 mViewManager->refreshView(); 1031 mViewManager->refreshView();
1041 mDetails->refreshView(); 1032 mDetails->refreshView();
1042 1033
1043} 1034}
1044 1035
1045bool KABCore::modified() const 1036bool KABCore::modified() const
1046{ 1037{
1047 return mModified; 1038 return mModified;
1048} 1039}
1049 1040
1050void KABCore::contactModified( const KABC::Addressee &addr ) 1041void KABCore::contactModified( const KABC::Addressee &addr )
1051{ 1042{
1052 1043
1053 Command *command = 0; 1044 Command *command = 0;
1054 QString uid; 1045 QString uid;
1055 1046
1056 // check if it exists already 1047 // check if it exists already
1057 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1048 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1058 if ( origAddr.isEmpty() ) 1049 if ( origAddr.isEmpty() )
1059 command = new PwNewCommand( mAddressBook, addr ); 1050 command = new PwNewCommand( mAddressBook, addr );
1060 else { 1051 else {
1061 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1052 command = new PwEditCommand( mAddressBook, origAddr, addr );
1062 uid = addr.uid(); 1053 uid = addr.uid();
1063 } 1054 }
1064 1055
1065 UndoStack::instance()->push( command ); 1056 UndoStack::instance()->push( command );
1066 RedoStack::instance()->clear(); 1057 RedoStack::instance()->clear();
1067 1058
1068 setModified( true ); 1059 setModified( true );
1069} 1060}
1070 1061
1071void KABCore::newContact() 1062void KABCore::newContact()
1072{ 1063{
1073 1064
1074 1065
1075 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1066 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1076 1067
1077 QPtrList<KRES::Resource> kresResources; 1068 QPtrList<KRES::Resource> kresResources;
1078 QPtrListIterator<KABC::Resource> it( kabcResources ); 1069 QPtrListIterator<KABC::Resource> it( kabcResources );
1079 KABC::Resource *resource; 1070 KABC::Resource *resource;
1080 while ( ( resource = it.current() ) != 0 ) { 1071 while ( ( resource = it.current() ) != 0 ) {
1081 ++it; 1072 ++it;
1082 if ( !resource->readOnly() ) { 1073 if ( !resource->readOnly() ) {
1083 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1074 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1084 if ( res ) 1075 if ( res )
1085 kresResources.append( res ); 1076 kresResources.append( res );
1086 } 1077 }
1087 } 1078 }
1088 1079
1089 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1080 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1090 resource = static_cast<KABC::Resource*>( res ); 1081 resource = static_cast<KABC::Resource*>( res );
1091 1082
1092 if ( resource ) { 1083 if ( resource ) {
1093 KABC::Addressee addr; 1084 KABC::Addressee addr;
1094 addr.setResource( resource ); 1085 addr.setResource( resource );
1095 mEditorDialog->setAddressee( addr ); 1086 mEditorDialog->setAddressee( addr );
1096 KApplication::execDialog ( mEditorDialog ); 1087 KApplication::execDialog ( mEditorDialog );
1097 1088
1098 } else 1089 } else
1099 return; 1090 return;
1100 1091
1101 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1092 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1102 1093
1103 1094
1104} 1095}
1105 1096
1106void KABCore::addEmail( QString aStr ) 1097void KABCore::addEmail( QString aStr )
1107{ 1098{
1108#ifndef KAB_EMBEDDED 1099#ifndef KAB_EMBEDDED
1109 QString fullName, email; 1100 QString fullName, email;
1110 1101
1111 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1102 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1112 1103
1113 // Try to lookup the addressee matching the email address 1104 // Try to lookup the addressee matching the email address
1114 bool found = false; 1105 bool found = false;
1115 QStringList emailList; 1106 QStringList emailList;
1116 KABC::AddressBook::Iterator it; 1107 KABC::AddressBook::Iterator it;
1117 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1108 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1118 emailList = (*it).emails(); 1109 emailList = (*it).emails();
1119 if ( emailList.contains( email ) > 0 ) { 1110 if ( emailList.contains( email ) > 0 ) {
1120 found = true; 1111 found = true;
1121 (*it).setNameFromString( fullName ); 1112 (*it).setNameFromString( fullName );
1122 editContact( (*it).uid() ); 1113 editContact( (*it).uid() );
1123 } 1114 }
1124 } 1115 }
1125 1116
1126 if ( !found ) { 1117 if ( !found ) {
1127 KABC::Addressee addr; 1118 KABC::Addressee addr;
1128 addr.setNameFromString( fullName ); 1119 addr.setNameFromString( fullName );
1129 addr.insertEmail( email, true ); 1120 addr.insertEmail( email, true );
1130 1121
1131 mAddressBook->insertAddressee( addr ); 1122 mAddressBook->insertAddressee( addr );
1132 mViewManager->refreshView( addr.uid() ); 1123 mViewManager->refreshView( addr.uid() );
1133 editContact( addr.uid() ); 1124 editContact( addr.uid() );
1134 } 1125 }
1135#else //KAB_EMBEDDED 1126#else //KAB_EMBEDDED
1136 qDebug("KABCore::addEmail finsih method"); 1127 qDebug("KABCore::addEmail finsih method");
1137#endif //KAB_EMBEDDED 1128#endif //KAB_EMBEDDED
1138} 1129}
1139 1130
1140void KABCore::importVCard( const KURL &url, bool showPreview ) 1131void KABCore::importVCard( const KURL &url, bool showPreview )
1141{ 1132{
1142 mXXPortManager->importVCard( url, showPreview ); 1133 mXXPortManager->importVCard( url, showPreview );
1143} 1134}
1144void KABCore::importFromOL() 1135void KABCore::importFromOL()
1145{ 1136{
1146#ifdef _WIN32_ 1137#ifdef _WIN32_
1147 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1138 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1148 idgl->exec(); 1139 idgl->exec();
1149 KABC::Addressee::List list = idgl->getAddressList(); 1140 KABC::Addressee::List list = idgl->getAddressList();
1150 if ( list.count() > 0 ) { 1141 if ( list.count() > 0 ) {
1151 KABC::Addressee::List listNew; 1142 KABC::Addressee::List listNew;
1152 KABC::Addressee::List listExisting; 1143 KABC::Addressee::List listExisting;
1153 KABC::Addressee::List::Iterator it; 1144 KABC::Addressee::List::Iterator it;
1154 KABC::AddressBook::Iterator iter; 1145 KABC::AddressBook::Iterator iter;
1155 for ( it = list.begin(); it != list.end(); ++it ) { 1146 for ( it = list.begin(); it != list.end(); ++it ) {
1156 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1147 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1157 listNew.append( (*it) ); 1148 listNew.append( (*it) );
1158 else 1149 else
1159 listExisting.append( (*it) ); 1150 listExisting.append( (*it) );
1160 } 1151 }
1161 if ( listExisting.count() > 0 ) 1152 if ( listExisting.count() > 0 )
1162 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1153 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1163 if ( listNew.count() > 0 ) { 1154 if ( listNew.count() > 0 ) {
1164 pasteWithNewUid = false; 1155 pasteWithNewUid = false;
1165 pasteContacts( listNew ); 1156 pasteContacts( listNew );
1166 pasteWithNewUid = true; 1157 pasteWithNewUid = true;
1167 } 1158 }
1168 } 1159 }
1169 delete idgl; 1160 delete idgl;
1170#endif 1161#endif
1171} 1162}
1172 1163
1173void KABCore::importVCard( const QString &vCard, bool showPreview ) 1164void KABCore::importVCard( const QString &vCard, bool showPreview )
1174{ 1165{
1175 mXXPortManager->importVCard( vCard, showPreview ); 1166 mXXPortManager->importVCard( vCard, showPreview );
1176} 1167}
1177 1168
1178//US added a second method without defaultparameter 1169//US added a second method without defaultparameter
1179void KABCore::editContact2() { 1170void KABCore::editContact2() {
1180 editContact( QString::null ); 1171 editContact( QString::null );
1181} 1172}
1182 1173
1183void KABCore::editContact( const QString &uid ) 1174void KABCore::editContact( const QString &uid )
1184{ 1175{
1185 1176
1186 if ( mExtensionManager->isQuickEditVisible() ) 1177 if ( mExtensionManager->isQuickEditVisible() )
1187 return; 1178 return;
1188 1179
1189 // First, locate the contact entry 1180 // First, locate the contact entry
1190 QString localUID = uid; 1181 QString localUID = uid;
1191 if ( localUID.isNull() ) { 1182 if ( localUID.isNull() ) {
1192 QStringList uidList = mViewManager->selectedUids(); 1183 QStringList uidList = mViewManager->selectedUids();
1193 if ( uidList.count() > 0 ) 1184 if ( uidList.count() > 0 )
1194 localUID = *( uidList.at( 0 ) ); 1185 localUID = *( uidList.at( 0 ) );
1195 } 1186 }
1196 1187
1197 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1188 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1198 if ( !addr.isEmpty() ) { 1189 if ( !addr.isEmpty() ) {
1199 mEditorDialog->setAddressee( addr ); 1190 mEditorDialog->setAddressee( addr );
1200 KApplication::execDialog ( mEditorDialog ); 1191 KApplication::execDialog ( mEditorDialog );
1201 } 1192 }
1202} 1193}
1203 1194
1204/** 1195/**
1205 Shows or edits the detail view for the given uid. If the uid is QString::null, 1196 Shows or edits the detail view for the given uid. If the uid is QString::null,
1206 the method will try to find a selected addressee in the view. 1197 the method will try to find a selected addressee in the view.
1207 */ 1198 */
1208void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1199void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1209{ 1200{
1210 if ( mMultipleViewsAtOnce ) 1201 if ( mMultipleViewsAtOnce )
1211 { 1202 {
1212 editContact( uid ); 1203 editContact( uid );
1213 } 1204 }
1214 else 1205 else
1215 { 1206 {
1216 setDetailsVisible( true ); 1207 setDetailsVisible( true );
1217 mActionDetails->setChecked(true); 1208 mActionDetails->setChecked(true);
1218 } 1209 }
1219 1210
1220} 1211}
1221 1212
1222void KABCore::save() 1213void KABCore::save()
1223{ 1214{
1224 if (syncManager->blockSave()) 1215 if (syncManager->blockSave())
1225 return; 1216 return;
1226 if ( !mModified ) 1217 if ( !mModified )
1227 return; 1218 return;
1228 1219
1229 syncManager->setBlockSave(true); 1220 syncManager->setBlockSave(true);
1230 QString text = i18n( "There was an error while attempting to save\n the " 1221 QString text = i18n( "There was an error while attempting to save\n the "
1231 "address book. Please check that some \nother application is " 1222 "address book. Please check that some \nother application is "
1232 "not using it. " ); 1223 "not using it. " );
1233 message(i18n("Saving addressbook ... ")); 1224 message(i18n("Saving addressbook ... "));
1234#ifndef KAB_EMBEDDED 1225#ifndef KAB_EMBEDDED
1235 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1226 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1236 if ( !b || !b->save() ) { 1227 if ( !b || !b->save() ) {
1237 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1228 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1238 } 1229 }
1239#else //KAB_EMBEDDED 1230#else //KAB_EMBEDDED
1240 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1231 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1241 if ( !b || !b->save() ) { 1232 if ( !b || !b->save() ) {
1242 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1233 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1243 } 1234 }
1244#endif //KAB_EMBEDDED 1235#endif //KAB_EMBEDDED
1245 1236
1246 message(i18n("Addressbook saved!")); 1237 message(i18n("Addressbook saved!"));
1247 setModified( false ); 1238 setModified( false );
1248 syncManager->setBlockSave(false); 1239 syncManager->setBlockSave(false);
1249} 1240}
1250 1241
1251 1242
1252void KABCore::undo() 1243void KABCore::undo()
1253{ 1244{
1254 UndoStack::instance()->undo(); 1245 UndoStack::instance()->undo();
1255 1246
1256 // Refresh the view 1247 // Refresh the view
1257 mViewManager->refreshView(); 1248 mViewManager->refreshView();
1258} 1249}
1259 1250
1260void KABCore::redo() 1251void KABCore::redo()
1261{ 1252{
1262 RedoStack::instance()->redo(); 1253 RedoStack::instance()->redo();
1263 1254
1264 // Refresh the view 1255 // Refresh the view
1265 mViewManager->refreshView(); 1256 mViewManager->refreshView();
1266} 1257}
1267 1258
1268void KABCore::setJumpButtonBarVisible( bool visible ) 1259void KABCore::setJumpButtonBarVisible( bool visible )
1269{ 1260{
1270 if (mMultipleViewsAtOnce) 1261 if (mMultipleViewsAtOnce)
1271 { 1262 {
1272 if ( visible ) 1263 if ( visible )
1273 mJumpButtonBar->show(); 1264 mJumpButtonBar->show();
1274 else 1265 else
1275 mJumpButtonBar->hide(); 1266 mJumpButtonBar->hide();
1276 } 1267 }
1277 else 1268 else
1278 { 1269 {
1279 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1270 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1280 if (mViewManager->isVisible()) 1271 if (mViewManager->isVisible())
1281 { 1272 {
1282 if ( visible ) 1273 if ( visible )
1283 mJumpButtonBar->show(); 1274 mJumpButtonBar->show();
1284 else 1275 else
1285 mJumpButtonBar->hide(); 1276 mJumpButtonBar->hide();
1286 } 1277 }
1287 else 1278 else
1288 { 1279 {
1289 mJumpButtonBar->hide(); 1280 mJumpButtonBar->hide();
1290 } 1281 }
1291 } 1282 }
1292} 1283}
1293 1284
1294 1285
1295void KABCore::setDetailsToState() 1286void KABCore::setDetailsToState()
1296{ 1287{
1297 setDetailsVisible( mActionDetails->isChecked() ); 1288 setDetailsVisible( mActionDetails->isChecked() );
1298} 1289}
1299void KABCore::setDetailsToggle() 1290void KABCore::setDetailsToggle()
1300{ 1291{
1301 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1292 mActionDetails->setChecked( !mActionDetails->isChecked() );
1302 setDetailsToState(); 1293 setDetailsToState();
1303} 1294}
1304 1295
1305 1296
1306 1297
1307void KABCore::setDetailsVisible( bool visible ) 1298void KABCore::setDetailsVisible( bool visible )
1308{ 1299{
1309 if (visible && mDetails->isHidden()) 1300 if (visible && mDetails->isHidden())
1310 { 1301 {
1311 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1302 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1312 if ( addrList.count() > 0 ) 1303 if ( addrList.count() > 0 )
1313 mDetails->setAddressee( addrList[ 0 ] ); 1304 mDetails->setAddressee( addrList[ 0 ] );
1314 } 1305 }
1315 1306
1316 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1307 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1317 // the listview and the detailview. We do that by changing the splitbar size. 1308 // the listview and the detailview. We do that by changing the splitbar size.
1318 if (mMultipleViewsAtOnce) 1309 if (mMultipleViewsAtOnce)
1319 { 1310 {
1320 if ( visible ) 1311 if ( visible )
1321 mDetails->show(); 1312 mDetails->show();
1322 else 1313 else
1323 mDetails->hide(); 1314 mDetails->hide();
1324 } 1315 }
1325 else 1316 else
1326 { 1317 {
1327 if ( visible ) { 1318 if ( visible ) {
1328 mViewManager->hide(); 1319 mViewManager->hide();
1329 mDetails->show(); 1320 mDetails->show();
1330 mIncSearchWidget->setFocus(); 1321 mIncSearchWidget->setFocus();
1331 } 1322 }
1332 else { 1323 else {
1333 mViewManager->show(); 1324 mViewManager->show();
1334 mDetails->hide(); 1325 mDetails->hide();
1335 mViewManager->setFocusAV(); 1326 mViewManager->setFocusAV();
1336 } 1327 }
1337 setJumpButtonBarVisible( !visible ); 1328 setJumpButtonBarVisible( !visible );
1338 } 1329 }
1339 1330
1340} 1331}
1341 1332
1342void KABCore::extensionChanged( int id ) 1333void KABCore::extensionChanged( int id )
1343{ 1334{
1344 //change the details view only for non desktop systems 1335 //change the details view only for non desktop systems
1345#ifndef DESKTOP_VERSION 1336#ifndef DESKTOP_VERSION
1346 1337
1347 if (id == 0) 1338 if (id == 0)
1348 { 1339 {
1349 //the user disabled the extension. 1340 //the user disabled the extension.
1350 1341
1351 if (mMultipleViewsAtOnce) 1342 if (mMultipleViewsAtOnce)
1352 { // enable detailsview again 1343 { // enable detailsview again
1353 setDetailsVisible( true ); 1344 setDetailsVisible( true );
1354 mActionDetails->setChecked( true ); 1345 mActionDetails->setChecked( true );
1355 } 1346 }
1356 else 1347 else
1357 { //go back to the listview 1348 { //go back to the listview
1358 setDetailsVisible( false ); 1349 setDetailsVisible( false );
1359 mActionDetails->setChecked( false ); 1350 mActionDetails->setChecked( false );
1360 mActionDetails->setEnabled(true); 1351 mActionDetails->setEnabled(true);
1361 } 1352 }
1362 1353
1363 } 1354 }
1364 else 1355 else
1365 { 1356 {
1366 //the user enabled the extension. 1357 //the user enabled the extension.
1367 setDetailsVisible( false ); 1358 setDetailsVisible( false );
1368 mActionDetails->setChecked( false ); 1359 mActionDetails->setChecked( false );
1369 1360
1370 if (!mMultipleViewsAtOnce) 1361 if (!mMultipleViewsAtOnce)
1371 { 1362 {
1372 mActionDetails->setEnabled(false); 1363 mActionDetails->setEnabled(false);
1373 } 1364 }
1374 1365
1375 mExtensionManager->setSelectionChanged(); 1366 mExtensionManager->setSelectionChanged();
1376 1367
1377 } 1368 }
1378 1369
1379#endif// DESKTOP_VERSION 1370#endif// DESKTOP_VERSION
1380 1371
1381} 1372}
1382 1373
1383 1374
1384void KABCore::extensionModified( const KABC::Addressee::List &list ) 1375void KABCore::extensionModified( const KABC::Addressee::List &list )
1385{ 1376{
1386 1377
1387 if ( list.count() != 0 ) { 1378 if ( list.count() != 0 ) {
1388 KABC::Addressee::List::ConstIterator it; 1379 KABC::Addressee::List::ConstIterator it;
1389 for ( it = list.begin(); it != list.end(); ++it ) 1380 for ( it = list.begin(); it != list.end(); ++it )
1390 mAddressBook->insertAddressee( *it ); 1381 mAddressBook->insertAddressee( *it );
1391 if ( list.count() > 1 ) 1382 if ( list.count() > 1 )
1392 setModified(); 1383 setModified();
1393 else 1384 else
1394 setModifiedWOrefresh(); 1385 setModifiedWOrefresh();
1395 } 1386 }
1396 if ( list.count() == 0 ) 1387 if ( list.count() == 0 )
1397 mViewManager->refreshView(); 1388 mViewManager->refreshView();
1398 else 1389 else
1399 mViewManager->refreshView( list[ 0 ].uid() ); 1390 mViewManager->refreshView( list[ 0 ].uid() );
1400 1391
1401 1392
1402 1393
1403} 1394}
1404 1395
1405QString KABCore::getNameByPhone( const QString &phone ) 1396QString KABCore::getNameByPhone( const QString &phone )
1406{ 1397{
1407#ifndef KAB_EMBEDDED 1398#ifndef KAB_EMBEDDED
1408 QRegExp r( "[/*/-/ ]" ); 1399 QRegExp r( "[/*/-/ ]" );
1409 QString localPhone( phone ); 1400 QString localPhone( phone );
1410 1401
1411 bool found = false; 1402 bool found = false;
1412 QString ownerName = ""; 1403 QString ownerName = "";
1413 KABC::AddressBook::Iterator iter; 1404 KABC::AddressBook::Iterator iter;
1414 KABC::PhoneNumber::List::Iterator phoneIter; 1405 KABC::PhoneNumber::List::Iterator phoneIter;
1415 KABC::PhoneNumber::List phoneList; 1406 KABC::PhoneNumber::List phoneList;
1416 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1407 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1417 phoneList = (*iter).phoneNumbers(); 1408 phoneList = (*iter).phoneNumbers();
1418 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1409 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1419 ++phoneIter) { 1410 ++phoneIter) {
1420 // Get rid of separator chars so just the numbers are compared. 1411 // Get rid of separator chars so just the numbers are compared.
1421 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1412 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1422 ownerName = (*iter).formattedName(); 1413 ownerName = (*iter).formattedName();
1423 found = true; 1414 found = true;
1424 } 1415 }
1425 } 1416 }
1426 } 1417 }
1427 1418
1428 return ownerName; 1419 return ownerName;
1429#else //KAB_EMBEDDED 1420#else //KAB_EMBEDDED
1430 qDebug("KABCore::getNameByPhone finsih method"); 1421 qDebug("KABCore::getNameByPhone finsih method");
1431 return ""; 1422 return "";
1432#endif //KAB_EMBEDDED 1423#endif //KAB_EMBEDDED
1433 1424
1434} 1425}
1435 1426
1436void KABCore::openConfigDialog() 1427void KABCore::openConfigDialog()
1437{ 1428{
1438 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1429 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1439 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1430 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1440 ConfigureDialog->addModule(kabcfg ); 1431 ConfigureDialog->addModule(kabcfg );
1441 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1432 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1442 ConfigureDialog->addModule(kdelibcfg ); 1433 ConfigureDialog->addModule(kdelibcfg );
1443 1434
1444 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1435 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1445 this, SLOT( configurationChanged() ) ); 1436 this, SLOT( configurationChanged() ) );
1446 connect( ConfigureDialog, SIGNAL( okClicked() ), 1437 connect( ConfigureDialog, SIGNAL( okClicked() ),
1447 this, SLOT( configurationChanged() ) ); 1438 this, SLOT( configurationChanged() ) );
1448 saveSettings(); 1439 saveSettings();
1449#ifndef DESKTOP_VERSION 1440#ifndef DESKTOP_VERSION
1450 ConfigureDialog->showMaximized(); 1441 ConfigureDialog->showMaximized();
1451#endif 1442#endif
1452 if ( ConfigureDialog->exec() ) 1443 if ( ConfigureDialog->exec() )
1453 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1444 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1454 delete ConfigureDialog; 1445 delete ConfigureDialog;
1455} 1446}
1456 1447
1457void KABCore::openLDAPDialog() 1448void KABCore::openLDAPDialog()
1458{ 1449{
1459#ifndef KAB_EMBEDDED 1450#ifndef KAB_EMBEDDED
1460 if ( !mLdapSearchDialog ) { 1451 if ( !mLdapSearchDialog ) {
1461 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1452 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1462 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1453 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1463 SLOT( refreshView() ) ); 1454 SLOT( refreshView() ) );
1464 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1455 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1465 SLOT( setModified() ) ); 1456 SLOT( setModified() ) );
1466 } else 1457 } else
1467 mLdapSearchDialog->restoreSettings(); 1458 mLdapSearchDialog->restoreSettings();
1468 1459
1469 if ( mLdapSearchDialog->isOK() ) 1460 if ( mLdapSearchDialog->isOK() )
1470 mLdapSearchDialog->exec(); 1461 mLdapSearchDialog->exec();
1471#else //KAB_EMBEDDED 1462#else //KAB_EMBEDDED
1472 qDebug("KABCore::openLDAPDialog() finsih method"); 1463 qDebug("KABCore::openLDAPDialog() finsih method");
1473#endif //KAB_EMBEDDED 1464#endif //KAB_EMBEDDED
1474} 1465}
1475 1466
1476void KABCore::print() 1467void KABCore::print()
1477{ 1468{
1478#ifndef KAB_EMBEDDED 1469#ifndef KAB_EMBEDDED
1479 KPrinter printer; 1470 KPrinter printer;
1480 if ( !printer.setup( this ) ) 1471 if ( !printer.setup( this ) )
1481 return; 1472 return;
1482 1473
1483 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1474 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1484 mViewManager->selectedUids(), this ); 1475 mViewManager->selectedUids(), this );
1485 1476
1486 wizard.exec(); 1477 wizard.exec();
1487#else //KAB_EMBEDDED 1478#else //KAB_EMBEDDED
1488 qDebug("KABCore::print() finsih method"); 1479 qDebug("KABCore::print() finsih method");
1489#endif //KAB_EMBEDDED 1480#endif //KAB_EMBEDDED
1490 1481
1491} 1482}
1492 1483
1493 1484
1494void KABCore::addGUIClient( KXMLGUIClient *client ) 1485void KABCore::addGUIClient( KXMLGUIClient *client )
1495{ 1486{
1496 if ( mGUIClient ) 1487 if ( mGUIClient )
1497 mGUIClient->insertChildClient( client ); 1488 mGUIClient->insertChildClient( client );
1498 else 1489 else
1499 KMessageBox::error( this, "no KXMLGUICLient"); 1490 KMessageBox::error( this, "no KXMLGUICLient");
1500} 1491}
1501 1492
1502 1493
1503void KABCore::configurationChanged() 1494void KABCore::configurationChanged()
1504{ 1495{
1505 mExtensionManager->reconfigure(); 1496 mExtensionManager->reconfigure();
1506} 1497}
1507 1498
1508void KABCore::addressBookChanged() 1499void KABCore::addressBookChanged()
1509{ 1500{
1510/*US 1501/*US
1511 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1502 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1512 while ( it.current() ) { 1503 while ( it.current() ) {
1513 if ( it.current()->dirty() ) { 1504 if ( it.current()->dirty() ) {
1514 QString text = i18n( "Data has been changed externally. Unsaved " 1505 QString text = i18n( "Data has been changed externally. Unsaved "
1515 "changes will be lost." ); 1506 "changes will be lost." );
1516 KMessageBox::information( this, text ); 1507 KMessageBox::information( this, text );
1517 } 1508 }
1518 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1509 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1519 ++it; 1510 ++it;
1520 } 1511 }
1521*/ 1512*/
1522 if (mEditorDialog) 1513 if (mEditorDialog)
1523 { 1514 {
1524 if (mEditorDialog->dirty()) 1515 if (mEditorDialog->dirty())
1525 { 1516 {
1526 QString text = i18n( "Data has been changed externally. Unsaved " 1517 QString text = i18n( "Data has been changed externally. Unsaved "
1527 "changes will be lost." ); 1518 "changes will be lost." );
1528 KMessageBox::information( this, text ); 1519 KMessageBox::information( this, text );
1529 } 1520 }
1530 QString currentuid = mEditorDialog->addressee().uid(); 1521 QString currentuid = mEditorDialog->addressee().uid();
1531 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1522 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1532 } 1523 }
1533 mViewManager->refreshView(); 1524 mViewManager->refreshView();
1534// mDetails->refreshView(); 1525// mDetails->refreshView();
1535 1526
1536 1527
1537} 1528}
1538 1529
1539AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1530AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1540 const char *name ) 1531 const char *name )
1541{ 1532{
1542 1533
1543 if ( mEditorDialog == 0 ) { 1534 if ( mEditorDialog == 0 ) {
1544 mEditorDialog = new AddresseeEditorDialog( this, parent, 1535 mEditorDialog = new AddresseeEditorDialog( this, parent,
1545 name ? name : "editorDialog" ); 1536 name ? name : "editorDialog" );
1546 1537
1547 1538
1548 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1539 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1549 SLOT( contactModified( const KABC::Addressee& ) ) ); 1540 SLOT( contactModified( const KABC::Addressee& ) ) );
1550 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1541 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1551 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1542 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1552 } 1543 }
1553 1544
1554 return mEditorDialog; 1545 return mEditorDialog;
1555} 1546}
1556 1547
1557void KABCore::slotEditorDestroyed( const QString &uid ) 1548void KABCore::slotEditorDestroyed( const QString &uid )
1558{ 1549{
1559 //mEditorDict.remove( uid ); 1550 //mEditorDict.remove( uid );
1560} 1551}
1561 1552
1562void KABCore::initGUI() 1553void KABCore::initGUI()
1563{ 1554{
1564#ifndef KAB_EMBEDDED 1555#ifndef KAB_EMBEDDED
1565 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1556 QHBoxLayout *topLayout = new QHBoxLayout( this );
1566 topLayout->setSpacing( KDialogBase::spacingHint() ); 1557 topLayout->setSpacing( KDialogBase::spacingHint() );
1567 1558
1568 mExtensionBarSplitter = new QSplitter( this ); 1559 mExtensionBarSplitter = new QSplitter( this );
1569 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1560 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1570 1561
1571 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1562 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1572 1563
1573 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1564 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1574 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1565 mIncSearchWidget = new IncSearchWidget( viewSpace );
1575 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1566 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1576 SLOT( incrementalSearch( const QString& ) ) ); 1567 SLOT( incrementalSearch( const QString& ) ) );
1577 1568
1578 mViewManager = new ViewManager( this, viewSpace ); 1569 mViewManager = new ViewManager( this, viewSpace );
1579 viewSpace->setStretchFactor( mViewManager, 1 ); 1570 viewSpace->setStretchFactor( mViewManager, 1 );
1580 1571
1581 mDetails = new ViewContainer( mDetailsSplitter ); 1572 mDetails = new ViewContainer( mDetailsSplitter );
1582 1573
1583 mJumpButtonBar = new JumpButtonBar( this, this ); 1574 mJumpButtonBar = new JumpButtonBar( this, this );
1584 1575
1585 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1576 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1586 1577
1587 topLayout->addWidget( mExtensionBarSplitter ); 1578 topLayout->addWidget( mExtensionBarSplitter );
1588 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1579 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1589 topLayout->addWidget( mJumpButtonBar ); 1580 topLayout->addWidget( mJumpButtonBar );
1590 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1581 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1591 1582
1592 mXXPortManager = new XXPortManager( this, this ); 1583 mXXPortManager = new XXPortManager( this, this );
1593 1584
1594#else //KAB_EMBEDDED 1585#else //KAB_EMBEDDED
1595 //US initialize viewMenu before settingup viewmanager. 1586 //US initialize viewMenu before settingup viewmanager.
1596 // Viewmanager needs this menu to plugin submenues. 1587 // Viewmanager needs this menu to plugin submenues.
1597 viewMenu = new QPopupMenu( this ); 1588 viewMenu = new QPopupMenu( this );
1598 settingsMenu = new QPopupMenu( this ); 1589 settingsMenu = new QPopupMenu( this );
1599 //filterMenu = new QPopupMenu( this ); 1590 //filterMenu = new QPopupMenu( this );
1600 ImportMenu = new QPopupMenu( this ); 1591 ImportMenu = new QPopupMenu( this );
1601 ExportMenu = new QPopupMenu( this ); 1592 ExportMenu = new QPopupMenu( this );
1602 syncMenu = new QPopupMenu( this ); 1593 syncMenu = new QPopupMenu( this );
1603 changeMenu= new QPopupMenu( this ); 1594 changeMenu= new QPopupMenu( this );
1604 1595
1605//US since we have no splitter for the embedded system, setup 1596//US since we have no splitter for the embedded system, setup
1606// a layout with two frames. One left and one right. 1597// a layout with two frames. One left and one right.
1607 1598
1608 QBoxLayout *topLayout; 1599 QBoxLayout *topLayout;
1609 1600
1610 // = new QHBoxLayout( this ); 1601 // = new QHBoxLayout( this );
1611// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1602// QBoxLayout *topLayout = (QBoxLayout*)layout();
1612 1603
1613// QWidget *mainBox = new QWidget( this ); 1604// QWidget *mainBox = new QWidget( this );
1614// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1605// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1615 1606
1616#ifdef DESKTOP_VERSION 1607#ifdef DESKTOP_VERSION
1617 topLayout = new QHBoxLayout( this ); 1608 topLayout = new QHBoxLayout( this );
1618 1609
1619 1610
1620 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1611 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1621 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1612 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1622 1613
1623 topLayout->addWidget(mMiniSplitter ); 1614 topLayout->addWidget(mMiniSplitter );
1624 1615
1625 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1616 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1626 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1617 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1627 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1618 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1628 mDetails = new ViewContainer( mMiniSplitter ); 1619 mDetails = new ViewContainer( mMiniSplitter );
1629 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1620 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1630#else 1621#else
1631 if ( QApplication::desktop()->width() > 480 ) { 1622 if ( QApplication::desktop()->width() > 480 ) {
1632 topLayout = new QHBoxLayout( this ); 1623 topLayout = new QHBoxLayout( this );
1633 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1624 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1634 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1625 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1635 } else { 1626 } else {
1636 1627
1637 topLayout = new QHBoxLayout( this ); 1628 topLayout = new QHBoxLayout( this );
1638 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1629 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1639 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1630 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1640 } 1631 }
1641 1632
1642 topLayout->addWidget(mMiniSplitter ); 1633 topLayout->addWidget(mMiniSplitter );
1643 mViewManager = new ViewManager( this, mMiniSplitter ); 1634 mViewManager = new ViewManager( this, mMiniSplitter );
1644 mDetails = new ViewContainer( mMiniSplitter ); 1635 mDetails = new ViewContainer( mMiniSplitter );
1645 1636
1646 1637
1647 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1638 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1648#endif 1639#endif
1649 //eh->hide(); 1640 //eh->hide();
1650 // topLayout->addWidget(mExtensionManager ); 1641 // topLayout->addWidget(mExtensionManager );
1651 1642
1652 1643
1653/*US 1644/*US
1654#ifndef KAB_NOSPLITTER 1645#ifndef KAB_NOSPLITTER
1655 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1646 QHBoxLayout *topLayout = new QHBoxLayout( this );
1656//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1647//US topLayout->setSpacing( KDialogBase::spacingHint() );
1657 topLayout->setSpacing( 10 ); 1648 topLayout->setSpacing( 10 );
1658 1649
1659 mDetailsSplitter = new QSplitter( this ); 1650 mDetailsSplitter = new QSplitter( this );
1660 1651
1661 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1652 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1662 1653
1663 mViewManager = new ViewManager( this, viewSpace ); 1654 mViewManager = new ViewManager( this, viewSpace );
1664 viewSpace->setStretchFactor( mViewManager, 1 ); 1655 viewSpace->setStretchFactor( mViewManager, 1 );
1665 1656
1666 mDetails = new ViewContainer( mDetailsSplitter ); 1657 mDetails = new ViewContainer( mDetailsSplitter );
1667 1658
1668 topLayout->addWidget( mDetailsSplitter ); 1659 topLayout->addWidget( mDetailsSplitter );
1669 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1660 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1670#else //KAB_NOSPLITTER 1661#else //KAB_NOSPLITTER
1671 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1662 QHBoxLayout *topLayout = new QHBoxLayout( this );
1672//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1663//US topLayout->setSpacing( KDialogBase::spacingHint() );
1673 topLayout->setSpacing( 10 ); 1664 topLayout->setSpacing( 10 );
1674 1665
1675// mDetailsSplitter = new QSplitter( this ); 1666// mDetailsSplitter = new QSplitter( this );
1676 1667
1677 QVBox *viewSpace = new QVBox( this ); 1668 QVBox *viewSpace = new QVBox( this );
1678 1669
1679 mViewManager = new ViewManager( this, viewSpace ); 1670 mViewManager = new ViewManager( this, viewSpace );
1680 viewSpace->setStretchFactor( mViewManager, 1 ); 1671 viewSpace->setStretchFactor( mViewManager, 1 );
1681 1672
1682 mDetails = new ViewContainer( this ); 1673 mDetails = new ViewContainer( this );
1683 1674
1684 topLayout->addWidget( viewSpace ); 1675 topLayout->addWidget( viewSpace );
1685// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1676// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1686 topLayout->addWidget( mDetails ); 1677 topLayout->addWidget( mDetails );
1687#endif //KAB_NOSPLITTER 1678#endif //KAB_NOSPLITTER
1688*/ 1679*/
1689 1680
1690 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1681 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1691 syncManager->setBlockSave(false); 1682 syncManager->setBlockSave(false);
1692 1683
1693 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1684 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1694 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1685 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1695 syncManager->setDefaultFileName( sentSyncFile()); 1686 syncManager->setDefaultFileName( sentSyncFile());
1696 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1687 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1697 1688
1698#endif //KAB_EMBEDDED 1689#endif //KAB_EMBEDDED
1699 initActions(); 1690 initActions();
1700 1691
1701#ifdef KAB_EMBEDDED 1692#ifdef KAB_EMBEDDED
1702 addActionsManually(); 1693 addActionsManually();
1703 //US make sure the export and import menues are initialized before creating the xxPortManager. 1694 //US make sure the export and import menues are initialized before creating the xxPortManager.
1704 mXXPortManager = new XXPortManager( this, this ); 1695 mXXPortManager = new XXPortManager( this, this );
1705 1696
1706 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1697 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1707 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1698 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1708 // mActionQuit->plug ( mMainWindow->toolBar()); 1699 // mActionQuit->plug ( mMainWindow->toolBar());
1709 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1700 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1710 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1701 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1711 // mIncSearchWidget->hide(); 1702 // mIncSearchWidget->hide();
1712 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1703 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1713 SLOT( incrementalSearch( const QString& ) ) ); 1704 SLOT( incrementalSearch( const QString& ) ) );
1714 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1705 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1715 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1706 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1716 1707
1717 mJumpButtonBar = new JumpButtonBar( this, this ); 1708 mJumpButtonBar = new JumpButtonBar( this, this );
1718 1709
1719 topLayout->addWidget( mJumpButtonBar ); 1710 topLayout->addWidget( mJumpButtonBar );
1720//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1711//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1721 1712
1722// mMainWindow->getIconToolBar()->raise(); 1713// mMainWindow->getIconToolBar()->raise();
1723 1714
1724#endif //KAB_EMBEDDED 1715#endif //KAB_EMBEDDED
1725 1716
1726} 1717}
1727void KABCore::initActions() 1718void KABCore::initActions()
1728{ 1719{
1729//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1720//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1730 1721
1731#ifndef KAB_EMBEDDED 1722#ifndef KAB_EMBEDDED
1732 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1723 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1733 SLOT( clipboardDataChanged() ) ); 1724 SLOT( clipboardDataChanged() ) );
1734#endif //KAB_EMBEDDED 1725#endif //KAB_EMBEDDED
1735 1726
1736 // file menu 1727 // file menu
1737 if ( mIsPart ) { 1728 if ( mIsPart ) {
1738 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1729 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1739 SLOT( sendMail() ), actionCollection(), 1730 SLOT( sendMail() ), actionCollection(),
1740 "kaddressbook_mail" ); 1731 "kaddressbook_mail" );
1741 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1732 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1742 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1733 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1743 1734
1744 } else { 1735 } else {
1745 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1736 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1746 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1737 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1747 } 1738 }
1748 1739
1749 1740
1750 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1741 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1751 SLOT( save() ), actionCollection(), "file_sync" ); 1742 SLOT( save() ), actionCollection(), "file_sync" );
1752 1743
1753 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1744 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1754 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1745 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1755 1746
1756 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1747 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1757 this, SLOT( mailVCard() ), 1748 this, SLOT( mailVCard() ),
1758 actionCollection(), "file_mail_vcard"); 1749 actionCollection(), "file_mail_vcard");
1759 1750
1760 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, 1751 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this,
1761 SLOT( export2phone() ), actionCollection(), 1752 SLOT( export2phone() ), actionCollection(),
1762 "kaddressbook_ex2phone" ); 1753 "kaddressbook_ex2phone" );
1763 1754
1764 mActionBeamVCard = 0; 1755 mActionBeamVCard = 0;
1765 mActionBeam = 0; 1756 mActionBeam = 0;
1766 1757
1767#ifndef DESKTOP_VERSION 1758#ifndef DESKTOP_VERSION
1768 if ( Ir::supported() ) { 1759 if ( Ir::supported() ) {
1769 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1760 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1770 SLOT( beamVCard() ), actionCollection(), 1761 SLOT( beamVCard() ), actionCollection(),
1771 "kaddressbook_beam_vcard" ); 1762 "kaddressbook_beam_vcard" );
1772 1763
1773 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1764 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1774 SLOT( beamMySelf() ), actionCollection(), 1765 SLOT( beamMySelf() ), actionCollection(),
1775 "kaddressbook_beam_myself" ); 1766 "kaddressbook_beam_myself" );
1776 } 1767 }
1777#endif 1768#endif
1778 1769
1779 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1770 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1780 this, SLOT( editContact2() ), 1771 this, SLOT( editContact2() ),
1781 actionCollection(), "file_properties" ); 1772 actionCollection(), "file_properties" );
1782 1773
1783#ifdef KAB_EMBEDDED 1774#ifdef KAB_EMBEDDED
1784 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1775 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1785 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1776 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1786 mMainWindow, SLOT( exit() ), 1777 mMainWindow, SLOT( exit() ),
1787 actionCollection(), "quit" ); 1778 actionCollection(), "quit" );
1788#endif //KAB_EMBEDDED 1779#endif //KAB_EMBEDDED
1789 1780
1790 // edit menu 1781 // edit menu
1791 if ( mIsPart ) { 1782 if ( mIsPart ) {
1792 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1783 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1793 SLOT( copyContacts() ), actionCollection(), 1784 SLOT( copyContacts() ), actionCollection(),
1794 "kaddressbook_copy" ); 1785 "kaddressbook_copy" );
1795 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1786 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1796 SLOT( cutContacts() ), actionCollection(), 1787 SLOT( cutContacts() ), actionCollection(),
1797 "kaddressbook_cut" ); 1788 "kaddressbook_cut" );
1798 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1789 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1799 SLOT( pasteContacts() ), actionCollection(), 1790 SLOT( pasteContacts() ), actionCollection(),
1800 "kaddressbook_paste" ); 1791 "kaddressbook_paste" );
1801 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1792 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1802 SLOT( selectAllContacts() ), actionCollection(), 1793 SLOT( selectAllContacts() ), actionCollection(),
1803 "kaddressbook_select_all" ); 1794 "kaddressbook_select_all" );
1804 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1795 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1805 SLOT( undo() ), actionCollection(), 1796 SLOT( undo() ), actionCollection(),
1806 "kaddressbook_undo" ); 1797 "kaddressbook_undo" );
1807 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1798 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1808 this, SLOT( redo() ), actionCollection(), 1799 this, SLOT( redo() ), actionCollection(),
1809 "kaddressbook_redo" ); 1800 "kaddressbook_redo" );
1810 } else { 1801 } else {
1811 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1802 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1812 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1803 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1813 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1804 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1814 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1805 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1815 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1806 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1816 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1807 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1817 } 1808 }
1818 1809
1819 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1810 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1820 Key_Delete, this, SLOT( deleteContacts() ), 1811 Key_Delete, this, SLOT( deleteContacts() ),
1821 actionCollection(), "edit_delete" ); 1812 actionCollection(), "edit_delete" );
1822 1813
1823 mActionUndo->setEnabled( false ); 1814 mActionUndo->setEnabled( false );
1824 mActionRedo->setEnabled( false ); 1815 mActionRedo->setEnabled( false );
1825 1816
1826 // settings menu 1817 // settings menu
1827#ifdef KAB_EMBEDDED 1818#ifdef KAB_EMBEDDED
1828//US special menuentry to configure the addressbook resources. On KDE 1819//US special menuentry to configure the addressbook resources. On KDE
1829// you do that through the control center !!! 1820// you do that through the control center !!!
1830 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1821 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1831 SLOT( configureResources() ), actionCollection(), 1822 SLOT( configureResources() ), actionCollection(),
1832 "kaddressbook_configure_resources" ); 1823 "kaddressbook_configure_resources" );
1833#endif //KAB_EMBEDDED 1824#endif //KAB_EMBEDDED
1834 1825
1835 if ( mIsPart ) { 1826 if ( mIsPart ) {
1836 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1827 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1837 SLOT( openConfigDialog() ), actionCollection(), 1828 SLOT( openConfigDialog() ), actionCollection(),
1838 "kaddressbook_configure" ); 1829 "kaddressbook_configure" );
1839 1830
1840 //US not implemented yet 1831 //US not implemented yet
1841 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1832 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1842 // this, SLOT( configureKeyBindings() ), actionCollection(), 1833 // this, SLOT( configureKeyBindings() ), actionCollection(),
1843 // "kaddressbook_configure_shortcuts" ); 1834 // "kaddressbook_configure_shortcuts" );
1844#ifdef KAB_EMBEDDED 1835#ifdef KAB_EMBEDDED
1845 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1836 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1846 mActionConfigureToolbars->setEnabled( false ); 1837 mActionConfigureToolbars->setEnabled( false );
1847#endif //KAB_EMBEDDED 1838#endif //KAB_EMBEDDED
1848 1839
1849 } else { 1840 } else {
1850 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1841 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1851 1842
1852 //US not implemented yet 1843 //US not implemented yet
1853 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1844 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1854 } 1845 }
1855 1846
1856 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1847 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1857 actionCollection(), "options_show_jump_bar" ); 1848 actionCollection(), "options_show_jump_bar" );
1858 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1849 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1859 1850
1860 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1851 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1861 actionCollection(), "options_show_details" ); 1852 actionCollection(), "options_show_details" );
1862 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1853 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1863 1854
1864 1855
1865 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 1856 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
1866 SLOT( toggleBeamReceive() ), actionCollection(), 1857 SLOT( toggleBeamReceive() ), actionCollection(),
1867 "kaddressbook_beam_rec" ); 1858 "kaddressbook_beam_rec" );
1868 1859
1869 1860
1870 // misc 1861 // misc
1871 // only enable LDAP lookup if we can handle the protocol 1862 // only enable LDAP lookup if we can handle the protocol
1872#ifndef KAB_EMBEDDED 1863#ifndef KAB_EMBEDDED
1873 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1864 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1874 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1865 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1875 this, SLOT( openLDAPDialog() ), actionCollection(), 1866 this, SLOT( openLDAPDialog() ), actionCollection(),
1876 "ldap_lookup" ); 1867 "ldap_lookup" );
1877 } 1868 }
1878#else //KAB_EMBEDDED 1869#else //KAB_EMBEDDED
1879 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1870 //qDebug("KABCore::initActions() LDAP has to be implemented");
1880#endif //KAB_EMBEDDED 1871#endif //KAB_EMBEDDED
1881 1872
1882 1873
1883 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1874 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1884 SLOT( setWhoAmI() ), actionCollection(), 1875 SLOT( setWhoAmI() ), actionCollection(),
1885 "set_personal" ); 1876 "set_personal" );
1886 1877
1887 1878
1888 1879
1889 1880
1890 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1881 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1891 SLOT( setCategories() ), actionCollection(), 1882 SLOT( setCategories() ), actionCollection(),
1892 "edit_set_categories" ); 1883 "edit_set_categories" );
1893 1884