summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2004-10-08 23:38:07 (UTC)
committer zautrix <zautrix>2004-10-08 23:38:07 (UTC)
commit07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861 (patch) (unidiff)
tree03d0e5d20e607e035e17fcdabd6bce789069f41e /kaddressbook
parent44169895703beb3e8b1551a313d2d341bf742905 (diff)
downloadkdepimpi-07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861.zip
kdepimpi-07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861.tar.gz
kdepimpi-07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861.tar.bz2
some bugfixes
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp8
-rw-r--r--kaddressbook/kabprefs.cpp3
2 files changed, 7 insertions, 4 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 939296f..9b059d3 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -129,768 +129,770 @@ $Id$
129#include <qfile.h> 129#include <qfile.h>
130#include <qvbox.h> 130#include <qvbox.h>
131#include <qlayout.h> 131#include <qlayout.h>
132#include <qclipboard.h> 132#include <qclipboard.h>
133#include <qtextstream.h> 133#include <qtextstream.h>
134 134
135#include <libkdepim/categoryselectdialog.h> 135#include <libkdepim/categoryselectdialog.h>
136#include <kabc/vcardconverter.h> 136#include <kabc/vcardconverter.h>
137 137
138 138
139#include "addresseeutil.h" 139#include "addresseeutil.h"
140#include "undocmds.h" 140#include "undocmds.h"
141#include "addresseeeditordialog.h" 141#include "addresseeeditordialog.h"
142#include "viewmanager.h" 142#include "viewmanager.h"
143#include "details/detailsviewcontainer.h" 143#include "details/detailsviewcontainer.h"
144#include "kabprefs.h" 144#include "kabprefs.h"
145#include "xxportmanager.h" 145#include "xxportmanager.h"
146#include "incsearchwidget.h" 146#include "incsearchwidget.h"
147#include "jumpbuttonbar.h" 147#include "jumpbuttonbar.h"
148#include "extensionmanager.h" 148#include "extensionmanager.h"
149#include "addresseeconfig.h" 149#include "addresseeconfig.h"
150#include <kcmultidialog.h> 150#include <kcmultidialog.h>
151 151
152#ifdef _WIN32_ 152#ifdef _WIN32_
153 153
154#include "kaimportoldialog.h" 154#include "kaimportoldialog.h"
155#else 155#else
156#include <unistd.h> 156#include <unistd.h>
157#endif 157#endif
158// sync includes 158// sync includes
159#include <libkdepim/ksyncprofile.h> 159#include <libkdepim/ksyncprofile.h>
160#include <libkdepim/ksyncprefsdialog.h> 160#include <libkdepim/ksyncprefsdialog.h>
161 161
162class KAex2phonePrefs : public QDialog 162class KAex2phonePrefs : public QDialog
163{ 163{
164 public: 164 public:
165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
166 QDialog( parent, name, true ) 166 QDialog( parent, name, true )
167 { 167 {
168 setCaption( i18n("Export to phone options") ); 168 setCaption( i18n("Export to phone options") );
169 QVBoxLayout* lay = new QVBoxLayout( this ); 169 QVBoxLayout* lay = new QVBoxLayout( this );
170 lay->setSpacing( 3 ); 170 lay->setSpacing( 3 );
171 lay->setMargin( 3 ); 171 lay->setMargin( 3 );
172 QLabel *lab; 172 QLabel *lab;
173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
174 lab->setAlignment (AlignHCenter ); 174 lab->setAlignment (AlignHCenter );
175 QHBox* temphb; 175 QHBox* temphb;
176 temphb = new QHBox( this ); 176 temphb = new QHBox( this );
177 new QLabel( i18n("I/O device: "), temphb ); 177 new QLabel( i18n("I/O device: "), temphb );
178 mPhoneDevice = new QLineEdit( temphb); 178 mPhoneDevice = new QLineEdit( temphb);
179 lay->addWidget( temphb ); 179 lay->addWidget( temphb );
180 temphb = new QHBox( this ); 180 temphb = new QHBox( this );
181 new QLabel( i18n("Connection: "), temphb ); 181 new QLabel( i18n("Connection: "), temphb );
182 mPhoneConnection = new QLineEdit( temphb); 182 mPhoneConnection = new QLineEdit( temphb);
183 lay->addWidget( temphb ); 183 lay->addWidget( temphb );
184 temphb = new QHBox( this ); 184 temphb = new QHBox( this );
185 new QLabel( i18n("Model(opt.): "), temphb ); 185 new QLabel( i18n("Model(opt.): "), temphb );
186 mPhoneModel = new QLineEdit( temphb); 186 mPhoneModel = new QLineEdit( temphb);
187 lay->addWidget( temphb ); 187 lay->addWidget( temphb );
188 mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 188 mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
189 lay->addWidget( mWriteToSim ); 189 lay->addWidget( mWriteToSim );
190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
191 lab->setAlignment (AlignHCenter ); 191 lab->setAlignment (AlignHCenter );
192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
193 lay->addWidget( ok ); 193 lay->addWidget( ok );
194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
195 lay->addWidget( cancel ); 195 lay->addWidget( cancel );
196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
198 resize( 220, 240 ); 198 resize( 220, 240 );
199 199
200 } 200 }
201 201
202public: 202public:
203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
204 QCheckBox* mWriteToSim; 204 QCheckBox* mWriteToSim;
205}; 205};
206 206
207bool pasteWithNewUid = true; 207bool pasteWithNewUid = true;
208 208
209#ifdef KAB_EMBEDDED 209#ifdef KAB_EMBEDDED
210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
214#else //KAB_EMBEDDED 214#else //KAB_EMBEDDED
215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
218 mReadWrite( readWrite ), mModified( false ) 218 mReadWrite( readWrite ), mModified( false )
219#endif //KAB_EMBEDDED 219#endif //KAB_EMBEDDED
220{ 220{
221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
222 // syncManager->setBlockSave(false); 222 // syncManager->setBlockSave(false);
223 mExtensionBarSplitter = 0; 223 mExtensionBarSplitter = 0;
224 mIsPart = !parent->inherits( "KAddressBookMain" ); 224 mIsPart = !parent->inherits( "KAddressBookMain" );
225 225
226 mAddressBook = KABC::StdAddressBook::self(); 226 mAddressBook = KABC::StdAddressBook::self();
227 KABC::StdAddressBook::setAutomaticSave( false ); 227 KABC::StdAddressBook::setAutomaticSave( false );
228 228
229#ifndef KAB_EMBEDDED 229#ifndef KAB_EMBEDDED
230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 232
233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
234 SLOT( addressBookChanged() ) ); 234 SLOT( addressBookChanged() ) );
235 235
236#if 0 236#if 0
237 // LP moved to addressbook init method 237 // LP moved to addressbook init method
238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
239 "X-Department", "KADDRESSBOOK" ); 239 "X-Department", "KADDRESSBOOK" );
240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
241 "X-Profession", "KADDRESSBOOK" ); 241 "X-Profession", "KADDRESSBOOK" );
242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
243 "X-AssistantsName", "KADDRESSBOOK" ); 243 "X-AssistantsName", "KADDRESSBOOK" );
244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
245 "X-ManagersName", "KADDRESSBOOK" ); 245 "X-ManagersName", "KADDRESSBOOK" );
246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
247 "X-SpousesName", "KADDRESSBOOK" ); 247 "X-SpousesName", "KADDRESSBOOK" );
248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
249 "X-Office", "KADDRESSBOOK" ); 249 "X-Office", "KADDRESSBOOK" );
250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
251 "X-IMAddress", "KADDRESSBOOK" ); 251 "X-IMAddress", "KADDRESSBOOK" );
252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
253 "X-Anniversary", "KADDRESSBOOK" ); 253 "X-Anniversary", "KADDRESSBOOK" );
254 254
255 //US added this field to become compatible with Opie/qtopia addressbook 255 //US added this field to become compatible with Opie/qtopia addressbook
256 // values can be "female" or "male" or "". An empty field represents undefined. 256 // values can be "female" or "male" or "". An empty field represents undefined.
257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
258 "X-Gender", "KADDRESSBOOK" ); 258 "X-Gender", "KADDRESSBOOK" );
259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
260 "X-Children", "KADDRESSBOOK" ); 260 "X-Children", "KADDRESSBOOK" );
261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
262 "X-FreeBusyUrl", "KADDRESSBOOK" ); 262 "X-FreeBusyUrl", "KADDRESSBOOK" );
263#endif 263#endif
264 initGUI(); 264 initGUI();
265 265
266 mIncSearchWidget->setFocus(); 266 mIncSearchWidget->setFocus();
267 267
268 268
269 connect( mViewManager, SIGNAL( selected( const QString& ) ), 269 connect( mViewManager, SIGNAL( selected( const QString& ) ),
270 SLOT( setContactSelected( const QString& ) ) ); 270 SLOT( setContactSelected( const QString& ) ) );
271 connect( mViewManager, SIGNAL( executed( const QString& ) ), 271 connect( mViewManager, SIGNAL( executed( const QString& ) ),
272 SLOT( executeContact( const QString& ) ) ); 272 SLOT( executeContact( const QString& ) ) );
273 273
274 connect( mViewManager, SIGNAL( deleteRequest( ) ), 274 connect( mViewManager, SIGNAL( deleteRequest( ) ),
275 SLOT( deleteContacts( ) ) ); 275 SLOT( deleteContacts( ) ) );
276 connect( mViewManager, SIGNAL( modified() ), 276 connect( mViewManager, SIGNAL( modified() ),
277 SLOT( setModified() ) ); 277 SLOT( setModified() ) );
278 278
279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
281 281
282 connect( mXXPortManager, SIGNAL( modified() ), 282 connect( mXXPortManager, SIGNAL( modified() ),
283 SLOT( setModified() ) ); 283 SLOT( setModified() ) );
284 284
285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
286 SLOT( incrementalSearch( const QString& ) ) ); 286 SLOT( incrementalSearch( const QString& ) ) );
287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
288 mJumpButtonBar, SLOT( recreateButtons() ) ); 288 mJumpButtonBar, SLOT( recreateButtons() ) );
289 289
290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
291 SLOT( sendMail( const QString& ) ) ); 291 SLOT( sendMail( const QString& ) ) );
292 292
293 293
294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
297 297
298 298
299#ifndef KAB_EMBEDDED 299#ifndef KAB_EMBEDDED
300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
301 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 301 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
302 302
303 connect( mDetails, SIGNAL( browse( const QString& ) ), 303 connect( mDetails, SIGNAL( browse( const QString& ) ),
304 SLOT( browse( const QString& ) ) ); 304 SLOT( browse( const QString& ) ) );
305 305
306 306
307 mAddressBookService = new KAddressBookService( this ); 307 mAddressBookService = new KAddressBookService( this );
308 308
309#endif //KAB_EMBEDDED 309#endif //KAB_EMBEDDED
310 mEditorDialog = 0; 310 mEditorDialog = 0;
311 createAddresseeEditorDialog( this ); 311 createAddresseeEditorDialog( this );
312 setModified( false ); 312 setModified( false );
313} 313}
314 314
315KABCore::~KABCore() 315KABCore::~KABCore()
316{ 316{
317 // save(); 317 // save();
318 //saveSettings(); 318 //saveSettings();
319 //KABPrefs::instance()->writeConfig(); 319 //KABPrefs::instance()->writeConfig();
320 delete AddresseeConfig::instance(); 320 delete AddresseeConfig::instance();
321 mAddressBook = 0; 321 mAddressBook = 0;
322 KABC::StdAddressBook::close(); 322 KABC::StdAddressBook::close();
323
324 delete syncManager;
323 325
324 delete syncManager;
325} 326}
326 327
327void KABCore::restoreSettings() 328void KABCore::restoreSettings()
328{ 329{
329 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 330 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
330 331
331 bool state; 332 bool state;
332 333
333 if (mMultipleViewsAtOnce) 334 if (mMultipleViewsAtOnce)
334 state = KABPrefs::instance()->mDetailsPageVisible; 335 state = KABPrefs::instance()->mDetailsPageVisible;
335 else 336 else
336 state = false; 337 state = false;
337 338
338 mActionDetails->setChecked( state ); 339 mActionDetails->setChecked( state );
339 setDetailsVisible( state ); 340 setDetailsVisible( state );
340 341
341 state = KABPrefs::instance()->mJumpButtonBarVisible; 342 state = KABPrefs::instance()->mJumpButtonBarVisible;
342 343
343 mActionJumpBar->setChecked( state ); 344 mActionJumpBar->setChecked( state );
344 setJumpButtonBarVisible( state ); 345 setJumpButtonBarVisible( state );
345/*US 346/*US
346 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 347 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
347 if ( splitterSize.count() == 0 ) { 348 if ( splitterSize.count() == 0 ) {
348 splitterSize.append( width() / 2 ); 349 splitterSize.append( width() / 2 );
349 splitterSize.append( width() / 2 ); 350 splitterSize.append( width() / 2 );
350 } 351 }
351 mMiniSplitter->setSizes( splitterSize ); 352 mMiniSplitter->setSizes( splitterSize );
352 if ( mExtensionBarSplitter ) { 353 if ( mExtensionBarSplitter ) {
353 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 354 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
354 if ( splitterSize.count() == 0 ) { 355 if ( splitterSize.count() == 0 ) {
355 splitterSize.append( width() / 2 ); 356 splitterSize.append( width() / 2 );
356 splitterSize.append( width() / 2 ); 357 splitterSize.append( width() / 2 );
357 } 358 }
358 mExtensionBarSplitter->setSizes( splitterSize ); 359 mExtensionBarSplitter->setSizes( splitterSize );
359 360
360 } 361 }
361*/ 362*/
362 mViewManager->restoreSettings(); 363 mViewManager->restoreSettings();
363 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 364 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
364 mExtensionManager->restoreSettings(); 365 mExtensionManager->restoreSettings();
365#ifdef DESKTOP_VERSION 366#ifdef DESKTOP_VERSION
366 int wid = width(); 367 int wid = width();
367 if ( wid < 10 ) 368 if ( wid < 10 )
368 wid = 400; 369 wid = 400;
369#else 370#else
370 int wid = QApplication::desktop()->width(); 371 int wid = QApplication::desktop()->width();
371 if ( wid < 640 ) 372 if ( wid < 640 )
372 wid = QApplication::desktop()->height(); 373 wid = QApplication::desktop()->height();
373#endif 374#endif
374 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 375 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
375 if ( true /*splitterSize.count() == 0*/ ) { 376 if ( true /*splitterSize.count() == 0*/ ) {
376 splitterSize.append( wid / 2 ); 377 splitterSize.append( wid / 2 );
377 splitterSize.append( wid / 2 ); 378 splitterSize.append( wid / 2 );
378 } 379 }
379 mMiniSplitter->setSizes( splitterSize ); 380 mMiniSplitter->setSizes( splitterSize );
380 if ( mExtensionBarSplitter ) { 381 if ( mExtensionBarSplitter ) {
381 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 382 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
382 if ( true /*splitterSize.count() == 0*/ ) { 383 if ( true /*splitterSize.count() == 0*/ ) {
383 splitterSize.append( wid / 2 ); 384 splitterSize.append( wid / 2 );
384 splitterSize.append( wid / 2 ); 385 splitterSize.append( wid / 2 );
385 } 386 }
386 mExtensionBarSplitter->setSizes( splitterSize ); 387 mExtensionBarSplitter->setSizes( splitterSize );
387 388
388 } 389 }
389 390
390 391
391} 392}
392 393
393void KABCore::saveSettings() 394void KABCore::saveSettings()
394{ 395{
395 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 396 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
396 if ( mExtensionBarSplitter ) 397 if ( mExtensionBarSplitter )
397 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 398 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
398 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 399 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
399 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 400 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
400#ifndef KAB_EMBEDDED 401#ifndef KAB_EMBEDDED
401 402
402 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 403 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
403 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 404 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
404#endif //KAB_EMBEDDED 405#endif //KAB_EMBEDDED
405 mExtensionManager->saveSettings(); 406 mExtensionManager->saveSettings();
406 mViewManager->saveSettings(); 407 mViewManager->saveSettings();
407 408
408 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 409 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
409} 410}
410 411
411KABC::AddressBook *KABCore::addressBook() const 412KABC::AddressBook *KABCore::addressBook() const
412{ 413{
413 return mAddressBook; 414 return mAddressBook;
414} 415}
415 416
416KConfig *KABCore::config() 417KConfig *KABCore::config()
417{ 418{
418#ifndef KAB_EMBEDDED 419#ifndef KAB_EMBEDDED
419 return KABPrefs::instance()->config(); 420 return KABPrefs::instance()->config();
420#else //KAB_EMBEDDED 421#else //KAB_EMBEDDED
421 return KABPrefs::instance()->getConfig(); 422 return KABPrefs::instance()->getConfig();
422#endif //KAB_EMBEDDED 423#endif //KAB_EMBEDDED
423} 424}
424 425
425KActionCollection *KABCore::actionCollection() const 426KActionCollection *KABCore::actionCollection() const
426{ 427{
427 return mGUIClient->actionCollection(); 428 return mGUIClient->actionCollection();
428} 429}
429 430
430KABC::Field *KABCore::currentSearchField() const 431KABC::Field *KABCore::currentSearchField() const
431{ 432{
432 if (mIncSearchWidget) 433 if (mIncSearchWidget)
433 return mIncSearchWidget->currentField(); 434 return mIncSearchWidget->currentField();
434 else 435 else
435 return 0; 436 return 0;
436} 437}
437 438
438QStringList KABCore::selectedUIDs() const 439QStringList KABCore::selectedUIDs() const
439{ 440{
440 return mViewManager->selectedUids(); 441 return mViewManager->selectedUids();
441} 442}
442 443
443KABC::Resource *KABCore::requestResource( QWidget *parent ) 444KABC::Resource *KABCore::requestResource( QWidget *parent )
444{ 445{
445 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 446 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
446 447
447 QPtrList<KRES::Resource> kresResources; 448 QPtrList<KRES::Resource> kresResources;
448 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 449 QPtrListIterator<KABC::Resource> resIt( kabcResources );
449 KABC::Resource *resource; 450 KABC::Resource *resource;
450 while ( ( resource = resIt.current() ) != 0 ) { 451 while ( ( resource = resIt.current() ) != 0 ) {
451 ++resIt; 452 ++resIt;
452 if ( !resource->readOnly() ) { 453 if ( !resource->readOnly() ) {
453 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 454 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
454 if ( res ) 455 if ( res )
455 kresResources.append( res ); 456 kresResources.append( res );
456 } 457 }
457 } 458 }
458 459
459 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 460 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
460 return static_cast<KABC::Resource*>( res ); 461 return static_cast<KABC::Resource*>( res );
461} 462}
462 463
463#ifndef KAB_EMBEDDED 464#ifndef KAB_EMBEDDED
464KAboutData *KABCore::createAboutData() 465KAboutData *KABCore::createAboutData()
465#else //KAB_EMBEDDED 466#else //KAB_EMBEDDED
466void KABCore::createAboutData() 467void KABCore::createAboutData()
467#endif //KAB_EMBEDDED 468#endif //KAB_EMBEDDED
468{ 469{
469#ifndef KAB_EMBEDDED 470#ifndef KAB_EMBEDDED
470 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 471 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
471 "3.1", I18N_NOOP( "The KDE Address Book" ), 472 "3.1", I18N_NOOP( "The KDE Address Book" ),
472 KAboutData::License_GPL_V2, 473 KAboutData::License_GPL_V2,
473 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 474 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
474 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 475 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
475 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 476 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
476 about->addAuthor( "Cornelius Schumacher", 477 about->addAuthor( "Cornelius Schumacher",
477 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 478 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
478 "schumacher@kde.org" ); 479 "schumacher@kde.org" );
479 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 480 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
480 "mpilone@slac.com" ); 481 "mpilone@slac.com" );
481 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 482 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
482 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 483 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
483 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 484 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
484 "michel@klaralvdalens-datakonsult.se" ); 485 "michel@klaralvdalens-datakonsult.se" );
485 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 486 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
486 "hansen@kde.org" ); 487 "hansen@kde.org" );
487 488
488 return about; 489 return about;
489#endif //KAB_EMBEDDED 490#endif //KAB_EMBEDDED
490 491
491 QString version; 492 QString version;
492#include <../version> 493#include <../version>
493 QMessageBox::about( this, "About KAddressbook/Pi", 494 QMessageBox::about( this, "About KAddressbook/Pi",
494 "KAddressbook/Platform-independent\n" 495 "KAddressbook/Platform-independent\n"
495 "(KA/Pi) " +version + " - " + 496 "(KA/Pi) " +version + " - " +
496#ifdef DESKTOP_VERSION 497#ifdef DESKTOP_VERSION
497 "Desktop Edition\n" 498 "Desktop Edition\n"
498#else 499#else
499 "PDA-Edition\n" 500 "PDA-Edition\n"
500 "for: Zaurus 5500 / 7x0 / 8x0\n" 501 "for: Zaurus 5500 / 7x0 / 8x0\n"
501#endif 502#endif
502 503
503 "(c) 2004 Ulf Schenk\n" 504 "(c) 2004 Ulf Schenk\n"
504 "(c) 2004 Lutz Rogowski\n" 505 "(c) 2004 Lutz Rogowski\n"
505 "(c) 1997-2003, The KDE PIM Team\n" 506 "(c) 1997-2003, The KDE PIM Team\n"
506 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 507 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
507 "Don Sanders Original author\n" 508 "Don Sanders Original author\n"
508 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 509 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
509 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 510 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
510 "Greg Stern DCOP interface\n" 511 "Greg Stern DCOP interface\n"
511 "Mark Westcot Contact pinning\n" 512 "Mark Westcot Contact pinning\n"
512 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 513 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
513 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 514 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
514#ifdef _WIN32_ 515#ifdef _WIN32_
515 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 516 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
516#endif 517#endif
517 ); 518 );
518} 519}
519 520
520void KABCore::setContactSelected( const QString &uid ) 521void KABCore::setContactSelected( const QString &uid )
521{ 522{
522 KABC::Addressee addr = mAddressBook->findByUid( uid ); 523 KABC::Addressee addr = mAddressBook->findByUid( uid );
523 if ( !mDetails->isHidden() ) 524 if ( !mDetails->isHidden() )
524 mDetails->setAddressee( addr ); 525 mDetails->setAddressee( addr );
525 526
526 if ( !addr.isEmpty() ) { 527 if ( !addr.isEmpty() ) {
527 emit contactSelected( addr.formattedName() ); 528 emit contactSelected( addr.formattedName() );
528 KABC::Picture pic = addr.photo(); 529 KABC::Picture pic = addr.photo();
529 if ( pic.isIntern() ) { 530 if ( pic.isIntern() ) {
530//US emit contactSelected( pic.data() ); 531//US emit contactSelected( pic.data() );
531//US instead use: 532//US instead use:
532 QPixmap px; 533 QPixmap px;
533 if (pic.data().isNull() != true) 534 if (pic.data().isNull() != true)
534 { 535 {
535 px.convertFromImage(pic.data()); 536 px.convertFromImage(pic.data());
536 } 537 }
537 538
538 emit contactSelected( px ); 539 emit contactSelected( px );
539 } 540 }
540 } 541 }
541 542
542 543
543 mExtensionManager->setSelectionChanged(); 544 mExtensionManager->setSelectionChanged();
544 545
545 // update the actions 546 // update the actions
546 bool selected = !uid.isEmpty(); 547 bool selected = !uid.isEmpty();
547 548
548 if ( mReadWrite ) { 549 if ( mReadWrite ) {
549 mActionCut->setEnabled( selected ); 550 mActionCut->setEnabled( selected );
550 mActionPaste->setEnabled( selected ); 551 mActionPaste->setEnabled( selected );
551 } 552 }
552 553
553 mActionCopy->setEnabled( selected ); 554 mActionCopy->setEnabled( selected );
554 mActionDelete->setEnabled( selected ); 555 mActionDelete->setEnabled( selected );
555 mActionEditAddressee->setEnabled( selected ); 556 mActionEditAddressee->setEnabled( selected );
556 mActionMail->setEnabled( selected ); 557 mActionMail->setEnabled( selected );
557 mActionMailVCard->setEnabled( selected ); 558 mActionMailVCard->setEnabled( selected );
558 //if (mActionBeam) 559 //if (mActionBeam)
559 //mActionBeam->setEnabled( selected ); 560 //mActionBeam->setEnabled( selected );
560 561
561 if (mActionBeamVCard) 562 if (mActionBeamVCard)
562 mActionBeamVCard->setEnabled( selected ); 563 mActionBeamVCard->setEnabled( selected );
563 564
564 mActionExport2phone->setEnabled( selected ); 565 mActionExport2phone->setEnabled( selected );
565 mActionWhoAmI->setEnabled( selected ); 566 mActionWhoAmI->setEnabled( selected );
566 mActionCategories->setEnabled( selected ); 567 mActionCategories->setEnabled( selected );
567} 568}
568 569
569void KABCore::sendMail() 570void KABCore::sendMail()
570{ 571{
571 sendMail( mViewManager->selectedEmails().join( ", " ) ); 572 sendMail( mViewManager->selectedEmails().join( ", " ) );
572} 573}
573 574
574void KABCore::sendMail( const QString& emaillist ) 575void KABCore::sendMail( const QString& emaillist )
575{ 576{
576 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 577 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
577 if (emaillist.contains(",") > 0) 578 if (emaillist.contains(",") > 0)
578 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 579 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
579 else 580 else
580 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 581 ExternalAppHandler::instance()->mailToOneContact( emaillist );
581} 582}
582 583
583 584
584 585
585void KABCore::mailVCard() 586void KABCore::mailVCard()
586{ 587{
587 QStringList uids = mViewManager->selectedUids(); 588 QStringList uids = mViewManager->selectedUids();
588 if ( !uids.isEmpty() ) 589 if ( !uids.isEmpty() )
589 mailVCard( uids ); 590 mailVCard( uids );
590} 591}
591 592
592void KABCore::mailVCard( const QStringList& uids ) 593void KABCore::mailVCard( const QStringList& uids )
593{ 594{
594 QStringList urls; 595 QStringList urls;
595 596
596// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 597// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
597 598
598 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 599 QString dirName = "/tmp/" + KApplication::randomString( 8 );
599 600
600 601
601 602
602 QDir().mkdir( dirName, true ); 603 QDir().mkdir( dirName, true );
603 604
604 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 605 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
605 KABC::Addressee a = mAddressBook->findByUid( *it ); 606 KABC::Addressee a = mAddressBook->findByUid( *it );
606 607
607 if ( a.isEmpty() ) 608 if ( a.isEmpty() )
608 continue; 609 continue;
609 610
610 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 611 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
611 612
612 QString fileName = dirName + "/" + name; 613 QString fileName = dirName + "/" + name;
613 614
614 QFile outFile(fileName); 615 QFile outFile(fileName);
615 616
616 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 617 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
617 KABC::VCardConverter converter; 618 KABC::VCardConverter converter;
618 QString vcard; 619 QString vcard;
619 620
620 converter.addresseeToVCard( a, vcard ); 621 converter.addresseeToVCard( a, vcard );
621 622
622 QTextStream t( &outFile ); // use a text stream 623 QTextStream t( &outFile ); // use a text stream
623 t.setEncoding( QTextStream::UnicodeUTF8 ); 624 t.setEncoding( QTextStream::UnicodeUTF8 );
624 t << vcard; 625 t << vcard;
625 626
626 outFile.close(); 627 outFile.close();
627 628
628 urls.append( fileName ); 629 urls.append( fileName );
629 } 630 }
630 } 631 }
631 632
632 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 633 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
633 634
634 635
635/*US 636/*US
636 kapp->invokeMailer( QString::null, QString::null, QString::null, 637 kapp->invokeMailer( QString::null, QString::null, QString::null,
637 QString::null, // subject 638 QString::null, // subject
638 QString::null, // body 639 QString::null, // body
639 QString::null, 640 QString::null,
640 urls ); // attachments 641 urls ); // attachments
641*/ 642*/
642 643
643} 644}
644 645
645/** 646/**
646 Beams the "WhoAmI contact. 647 Beams the "WhoAmI contact.
647*/ 648*/
648void KABCore::beamMySelf() 649void KABCore::beamMySelf()
649{ 650{
650 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 651 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
651 if (!a.isEmpty()) 652 if (!a.isEmpty())
652 { 653 {
653 QStringList uids; 654 QStringList uids;
654 uids << a.uid(); 655 uids << a.uid();
655 656
656 beamVCard(uids); 657 beamVCard(uids);
657 } else { 658 } else {
658 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 659 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
659 660
660 661
661 } 662 }
662} 663}
663 664
664void KABCore::export2phone() 665void KABCore::export2phone()
665{ 666{
666 667
667 KAex2phonePrefs ex2phone; 668 KAex2phonePrefs ex2phone;
668 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 669 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
669 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 670 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
670 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 671 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
671 672
672 if ( !ex2phone.exec() ) { 673 if ( !ex2phone.exec() ) {
673 return; 674 return;
674 } 675 }
675 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 676 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
676 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 677 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
677 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 678 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
678 679
679 680
680 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 681 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
681 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 682 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
682 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 683 KPimGlobalPrefs::instance()->mEx2PhoneModel );
683 684
684 QStringList uids = mViewManager->selectedUids(); 685 QStringList uids = mViewManager->selectedUids();
685 if ( uids.isEmpty() ) 686 if ( uids.isEmpty() )
686 return; 687 return;
687 688
688#ifdef _WIN32_ 689#ifdef _WIN32_
689 QString fileName = locateLocal("tmp", "tempfile.vcf"); 690 QString fileName = locateLocal("tmp", "tempfile.vcf");
690#else 691#else
691 QString fileName = "/tmp/kdepimtemp.vcf"; 692 QString fileName = "/tmp/kdepimtemp.vcf";
692#endif 693#endif
693 694
694 KABC::VCardConverter converter; 695 KABC::VCardConverter converter;
695 QString description; 696 QString description;
696 QString datastream; 697 QString datastream;
697 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 698 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
698 KABC::Addressee a = mAddressBook->findByUid( *it ); 699 KABC::Addressee a = mAddressBook->findByUid( *it );
699 700
700 if ( a.isEmpty() ) 701 if ( a.isEmpty() )
701 continue; 702 continue;
702 a.simplifyEmails(); 703 a.simplifyEmails();
703 a.simplifyPhoneNumbers(); 704 a.simplifyPhoneNumbers();
704 a.simplifyPhoneNumberTypes(); 705 a.simplifyPhoneNumberTypes();
706 a.simplifyAddresses();
705 707
706 if (description.isEmpty()) 708 if (description.isEmpty())
707 description = a.formattedName(); 709 description = a.formattedName();
708 QString vcard; 710 QString vcard;
709 QString vcardnew; 711 QString vcardnew;
710 converter.addresseeToVCard( a, vcard ); 712 converter.addresseeToVCard( a, vcard );
711 int start = 0; 713 int start = 0;
712 int next; 714 int next;
713 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 715 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
714 int semi = vcard.find(";", next); 716 int semi = vcard.find(";", next);
715 int dopp = vcard.find(":", next); 717 int dopp = vcard.find(":", next);
716 int sep; 718 int sep;
717 if ( semi < dopp && semi >= 0 ) 719 if ( semi < dopp && semi >= 0 )
718 sep = semi ; 720 sep = semi ;
719 else 721 else
720 sep = dopp; 722 sep = dopp;
721 vcardnew +=vcard.mid( start, next - start); 723 vcardnew +=vcard.mid( start, next - start);
722 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); 724 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
723 start = sep; 725 start = sep;
724 } 726 }
725 vcardnew += vcard.mid( start,vcard.length() ); 727 vcardnew += vcard.mid( start,vcard.length() );
726 vcard = ""; 728 vcard = "";
727 start = 0; 729 start = 0;
728 while ( (next = vcardnew.find("ADR", start) )>= 0 ) { 730 while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
729 int sep = vcardnew.find(":", next); 731 int sep = vcardnew.find(":", next);
730 vcard +=vcardnew.mid( start, next - start+3); 732 vcard +=vcardnew.mid( start, next - start+3);
731 start = sep; 733 start = sep;
732 } 734 }
733 vcard += vcardnew.mid( start,vcardnew.length() ); 735 vcard += vcardnew.mid( start,vcardnew.length() );
734 vcard.replace ( QRegExp(";;;") , "" ); 736 vcard.replace ( QRegExp(";;;") , "" );
735 vcard.replace ( QRegExp(";;") , "" ); 737 vcard.replace ( QRegExp(";;") , "" );
736 datastream += vcard; 738 datastream += vcard;
737 739
738 } 740 }
739 QFile outFile(fileName); 741 QFile outFile(fileName);
740 if ( outFile.open(IO_WriteOnly) ) { 742 if ( outFile.open(IO_WriteOnly) ) {
741 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 743 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
742 QTextStream t( &outFile ); // use a text stream 744 QTextStream t( &outFile ); // use a text stream
743 t.setEncoding( QTextStream::UnicodeUTF8 ); 745 t.setEncoding( QTextStream::UnicodeUTF8 );
744 t <<datastream; 746 t <<datastream;
745 outFile.close(); 747 outFile.close();
746 if ( PhoneAccess::writeToPhone( fileName ) ) 748 if ( PhoneAccess::writeToPhone( fileName ) )
747 qDebug("Export okay "); 749 qDebug("Export okay ");
748 else 750 else
749 qDebug("Error export contacts "); 751 qDebug("Error export contacts ");
750 752
751 } else { 753 } else {
752 qDebug("Error open temp file "); 754 qDebug("Error open temp file ");
753 return; 755 return;
754 } 756 }
755 757
756 758
757#if 0 759#if 0
758 760
759 setCaption( i18n("Writing to phone...")); 761 setCaption( i18n("Writing to phone..."));
760 if ( PhoneFormat::writeToPhone( cal ) ) 762 if ( PhoneFormat::writeToPhone( cal ) )
761 setCaption( i18n("Export to phone successful!")); 763 setCaption( i18n("Export to phone successful!"));
762 else 764 else
763 setCaption( i18n("Error exporting to phone!")); 765 setCaption( i18n("Error exporting to phone!"));
764#endif 766#endif
765 767
766 768
767} 769}
768void KABCore::beamVCard() 770void KABCore::beamVCard()
769{ 771{
770 QStringList uids = mViewManager->selectedUids(); 772 QStringList uids = mViewManager->selectedUids();
771 if ( !uids.isEmpty() ) 773 if ( !uids.isEmpty() )
772 beamVCard( uids ); 774 beamVCard( uids );
773} 775}
774 776
775 777
776void KABCore::beamVCard(const QStringList& uids) 778void KABCore::beamVCard(const QStringList& uids)
777{ 779{
778/*US 780/*US
779 QString beamFilename; 781 QString beamFilename;
780 Opie::OPimContact c; 782 Opie::OPimContact c;
781 if ( actionPersonal->isOn() ) { 783 if ( actionPersonal->isOn() ) {
782 beamFilename = addressbookPersonalVCardName(); 784 beamFilename = addressbookPersonalVCardName();
783 if ( !QFile::exists( beamFilename ) ) 785 if ( !QFile::exists( beamFilename ) )
784 return; // can't beam a non-existent file 786 return; // can't beam a non-existent file
785 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 787 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
786 beamFilename ); 788 beamFilename );
787 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 789 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
788 Opie::OPimContactAccess::List allList = access->allRecords(); 790 Opie::OPimContactAccess::List allList = access->allRecords();
789 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 791 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
790 c = *it; 792 c = *it;
791 793
792 delete access; 794 delete access;
793 } else { 795 } else {
794 unlink( beamfile ); // delete if exists 796 unlink( beamfile ); // delete if exists
795 mkdir("/tmp/obex/", 0755); 797 mkdir("/tmp/obex/", 0755);
796 c = m_abView -> currentEntry(); 798 c = m_abView -> currentEntry();
797 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 799 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
798 beamfile ); 800 beamfile );
799 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 801 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
800 access->add( c ); 802 access->add( c );
801 access->save(); 803 access->save();
802 delete access; 804 delete access;
803 805
804 beamFilename = beamfile; 806 beamFilename = beamfile;
805 } 807 }
806 808
807 owarn << "Beaming: " << beamFilename << oendl; 809 owarn << "Beaming: " << beamFilename << oendl;
808*/ 810*/
809 811
810#if 0 812#if 0
811 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 813 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
812 814
813 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 815 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
814 816
815 QString name = "contact.vcf"; 817 QString name = "contact.vcf";
816 818
817 QString fileName = dirName + "/" + name; 819 QString fileName = dirName + "/" + name;
818#endif 820#endif
819 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 821 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
820 // 822 //
821 QString fileName = "/tmp/kapibeamfile.vcf"; 823 QString fileName = "/tmp/kapibeamfile.vcf";
822 824
823 825
824 //QDir().mkdir( dirName, true ); 826 //QDir().mkdir( dirName, true );
825 827
826 828
827 KABC::VCardConverter converter; 829 KABC::VCardConverter converter;
828 QString description; 830 QString description;
829 QString datastream; 831 QString datastream;
830 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 832 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
831 KABC::Addressee a = mAddressBook->findByUid( *it ); 833 KABC::Addressee a = mAddressBook->findByUid( *it );
832 834
833 if ( a.isEmpty() ) 835 if ( a.isEmpty() )
834 continue; 836 continue;
835 837
836 if (description.isEmpty()) 838 if (description.isEmpty())
837 description = a.formattedName(); 839 description = a.formattedName();
838 840
839 QString vcard; 841 QString vcard;
840 converter.addresseeToVCard( a, vcard ); 842 converter.addresseeToVCard( a, vcard );
841 int start = 0; 843 int start = 0;
842 int next; 844 int next;
843 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 845 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
844 int semi = vcard.find(";", next); 846 int semi = vcard.find(";", next);
845 int dopp = vcard.find(":", next); 847 int dopp = vcard.find(":", next);
846 int sep; 848 int sep;
847 if ( semi < dopp && semi >= 0 ) 849 if ( semi < dopp && semi >= 0 )
848 sep = semi ; 850 sep = semi ;
849 else 851 else
850 sep = dopp; 852 sep = dopp;
851 datastream +=vcard.mid( start, next - start); 853 datastream +=vcard.mid( start, next - start);
852 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 854 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
853 start = sep; 855 start = sep;
854 } 856 }
855 datastream += vcard.mid( start,vcard.length() ); 857 datastream += vcard.mid( start,vcard.length() );
856 } 858 }
857#ifndef DESKTOP_VERSION 859#ifndef DESKTOP_VERSION
858 QFile outFile(fileName); 860 QFile outFile(fileName);
859 if ( outFile.open(IO_WriteOnly) ) { 861 if ( outFile.open(IO_WriteOnly) ) {
860 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 862 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
861 QTextStream t( &outFile ); // use a text stream 863 QTextStream t( &outFile ); // use a text stream
862 t.setEncoding( QTextStream::UnicodeUTF8 ); 864 t.setEncoding( QTextStream::UnicodeUTF8 );
863 t <<datastream; 865 t <<datastream;
864 outFile.close(); 866 outFile.close();
865 Ir *ir = new Ir( this ); 867 Ir *ir = new Ir( this );
866 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 868 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
867 ir->send( fileName, description, "text/x-vCard" ); 869 ir->send( fileName, description, "text/x-vCard" );
868 } else { 870 } else {
869 qDebug("Error open temp beam file "); 871 qDebug("Error open temp beam file ");
870 return; 872 return;
871 } 873 }
872#endif 874#endif
873 875
874} 876}
875 877
876void KABCore::beamDone( Ir *ir ) 878void KABCore::beamDone( Ir *ir )
877{ 879{
878#ifndef DESKTOP_VERSION 880#ifndef DESKTOP_VERSION
879 delete ir; 881 delete ir;
880#endif 882#endif
881} 883}
882 884
883 885
884void KABCore::browse( const QString& url ) 886void KABCore::browse( const QString& url )
885{ 887{
886#ifndef KAB_EMBEDDED 888#ifndef KAB_EMBEDDED
887 kapp->invokeBrowser( url ); 889 kapp->invokeBrowser( url );
888#else //KAB_EMBEDDED 890#else //KAB_EMBEDDED
889 qDebug("KABCore::browse must be fixed"); 891 qDebug("KABCore::browse must be fixed");
890#endif //KAB_EMBEDDED 892#endif //KAB_EMBEDDED
891} 893}
892 894
893void KABCore::selectAllContacts() 895void KABCore::selectAllContacts()
894{ 896{
895 mViewManager->setSelected( QString::null, true ); 897 mViewManager->setSelected( QString::null, true );
896} 898}
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp
index 552c933..dded2bf 100644
--- a/kaddressbook/kabprefs.cpp
+++ b/kaddressbook/kabprefs.cpp
@@ -1,132 +1,133 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
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//US#ifdef KAB_EMBEDDED 24//US#ifdef KAB_EMBEDDED
25//#include <qstring.h> 25//#include <qstring.h>
26//#endif //KAB_EMBEDDED 26//#endif //KAB_EMBEDDED
27 27
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30#include <klocale.h> 30#include <klocale.h>
31#include <kstaticdeleter.h> 31#include <kstaticdeleter.h>
32//US#include <kdebug.h> // defines kdDebug() 32//US#include <kdebug.h> // defines kdDebug()
33 33
34#include "kabprefs.h" 34#include "kabprefs.h"
35 35
36KABPrefs *KABPrefs::sInstance = 0; 36KABPrefs *KABPrefs::sInstance = 0;
37static KStaticDeleter<KABPrefs> staticDeleter; 37static KStaticDeleter<KABPrefs> staticDeleter;
38 38
39KABPrefs::KABPrefs() 39KABPrefs::KABPrefs()
40 : KPimPrefs("kaddressbookrc") 40 : KPimPrefs("kaddressbookrc")
41{ 41{
42 KPrefs::setCurrentGroup( "Views" ); 42 KPrefs::setCurrentGroup( "Views" );
43 addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); 43 addItemBool( "HonorSingleClick", &mHonorSingleClick, false );
44 44
45 KPrefs::setCurrentGroup( "General" ); 45 KPrefs::setCurrentGroup( "General" );
46 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); 46 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true );
47 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); 47 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 );
48 48
49#ifdef KAB_EMBEDDED 49#ifdef KAB_EMBEDDED
50 addItemBool("AskForQuit",&mAskForQuit,true); 50 addItemBool("AskForQuit",&mAskForQuit,true);
51 addItemBool("ToolBarHor",&mToolBarHor, true ); 51 addItemBool("ToolBarHor",&mToolBarHor, true );
52 addItemBool("ToolBarUp",&mToolBarUp, false ); 52 addItemBool("ToolBarUp",&mToolBarUp, false );
53 addItemBool("SearchWithReturn",&mSearchWithReturn, true ); 53 addItemBool("SearchWithReturn",&mSearchWithReturn, true );
54 54
55 55
56#endif //KAB_EMBEDDED 56#endif //KAB_EMBEDDED
57 57
58 KPrefs::setCurrentGroup( "MainWindow" ); 58 KPrefs::setCurrentGroup( "MainWindow" );
59 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); 59 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false );
60 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); 60 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true );
61 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); 61 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter );
62 addItemIntList( "DetailsSplitter", &mDetailsSplitter ); 62 addItemIntList( "DetailsSplitter", &mDetailsSplitter );
63 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); 63 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true );
64 64
65 65
66 KPrefs::setCurrentGroup( "Extensions_General" ); 66 KPrefs::setCurrentGroup( "Extensions_General" );
67 QStringList defaultExtensions; 67 QStringList defaultExtensions;
68 defaultExtensions << "merge"; 68 defaultExtensions << "merge";
69 defaultExtensions << "distribution_list_editor"; 69 defaultExtensions << "distribution_list_editor";
70 addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); 70 addItemInt( "CurrentExtension", &mCurrentExtension, 0 );
71 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); 71 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions );
72 72
73 KPrefs::setCurrentGroup( "Views" ); 73 KPrefs::setCurrentGroup( "Views" );
74 QString defaultView = i18n( "Default Table View" ); 74 QString defaultView = i18n( "Default Table View" );
75 addItemString( "CurrentView", &mCurrentView, defaultView ); 75 addItemString( "CurrentView", &mCurrentView, defaultView );
76 addItemStringList( "ViewNames", &mViewNames, defaultView ); 76 addItemStringList( "ViewNames", &mViewNames, defaultView );
77 77
78 KPrefs::setCurrentGroup( "Filters" ); 78 KPrefs::setCurrentGroup( "Filters" );
79 addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); 79 addItemInt( "CurrentFilter", &mCurrentFilter, 0 );
80 80
81} 81}
82 82
83KABPrefs::~KABPrefs() 83KABPrefs::~KABPrefs()
84{ 84{
85 //qDebug("KABPrefs::~KABPrefs() ");
85} 86}
86 87
87KABPrefs *KABPrefs::instance() 88KABPrefs *KABPrefs::instance()
88{ 89{
89 if ( !sInstance ) { 90 if ( !sInstance ) {
90#ifdef KAB_EMBEDDED 91#ifdef KAB_EMBEDDED
91 sInstance = staticDeleter.setObject( new KABPrefs() ); 92 sInstance = staticDeleter.setObject( new KABPrefs() );
92#else //KAB_EMBEDDED 93#else //KAB_EMBEDDED
93 //US the following line has changed ???. Why 94 //US the following line has changed ???. Why
94 staticDeleter.setObject( sInstance, new KABPrefs() ); 95 staticDeleter.setObject( sInstance, new KABPrefs() );
95#endif //KAB_EMBEDDED 96#endif //KAB_EMBEDDED
96 sInstance->readConfig(); 97 sInstance->readConfig();
97 } 98 }
98 99
99 return sInstance; 100 return sInstance;
100} 101}
101 102
102void KABPrefs::setCategoryDefaults() 103void KABPrefs::setCategoryDefaults()
103{ 104{
104 mCustomCategories.clear(); 105 mCustomCategories.clear();
105 106
106 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) 107 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" )
107 << i18n( "Customer" ) << i18n( "Friend" ); 108 << i18n( "Customer" ) << i18n( "Friend" );
108} 109}
109 110
110 // US introduce a nonconst way to return the config object. 111 // US introduce a nonconst way to return the config object.
111KConfig* KABPrefs::getConfig() 112KConfig* KABPrefs::getConfig()
112{ 113{
113 return config(); 114 return config();
114} 115}
115 116
116 117
117/*US 118/*US
118void KABPrefs::usrSetDefaults() 119void KABPrefs::usrSetDefaults()
119{ 120{
120 KPimPrefs::usrSetDefaults(); 121 KPimPrefs::usrSetDefaults();
121} 122}
122 123
123void KABPrefs::usrReadConfig() 124void KABPrefs::usrReadConfig()
124{ 125{
125 KPimPrefs::usrReadConfig(); 126 KPimPrefs::usrReadConfig();
126} 127}
127 128
128void KABPrefs::usrWriteConfig() 129void KABPrefs::usrWriteConfig()
129{ 130{
130 KPimPrefs::usrWriteConfig(); 131 KPimPrefs::usrWriteConfig();
131} 132}
132*/ 133*/