-rw-r--r-- | kaddressbook/imagewidget.cpp | 25 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 28 | ||||
-rw-r--r-- | kaddressbook/xxportselectdialog.cpp | 48 | ||||
-rw-r--r-- | kaddressbook/xxportselectdialog.h | 1 |
4 files changed, 75 insertions, 27 deletions
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp index 9ee4eac..1e9743c 100644 --- a/kaddressbook/imagewidget.cpp +++ b/kaddressbook/imagewidget.cpp @@ -1,307 +1,306 @@ /* This file is part of KAddressBook. Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <kabc/picture.h> #ifndef KAB_EMBEDDED #include <kaccelmanager.h> #include <kio/netaccess.h> #include <kimageio.h> #endif //KAB_EMBEDDED #include <kdebug.h> #include <kdialog.h> #include <kiconloader.h> #include <klocale.h> #include <kurlrequester.h> #include <kurl.h> #include <qcheckbox.h> #include <qgroupbox.h> #include <qlabel.h> #include <qlayout.h> #include <qpixmap.h> #include <qpushbutton.h> #include <qapplication.h> #include "imagewidget.h" ImageWidget::ImageWidget( QWidget *parent, const char *name ) : QWidget( parent, name ) { QGridLayout *topLayout = new QGridLayout( this, 2, 1, KDialog::marginHint(), KDialog::spacingHint() ); QGroupBox *photoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Photo" ), this ); - QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 4, 2, + QGridLayout *boxLayout = new QGridLayout( photoBox->layout(), 3, 2, KDialog::spacingHint() ); boxLayout->setRowStretch( 2, 1 ); mPhotoLabel = new QLabel( photoBox ); int fac = 9; if ( QApplication::desktop()->width() > 320 ) fac = 6; mPhotoLabel->setFixedSize( 50*9/fac, 70*9/fac ); mPhotoLabel->setScaledContents( true ); mPhotoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); boxLayout->addMultiCellWidget( mPhotoLabel, 0, 3, 0, 0 ); mPhotoUrl = new KURLRequester( photoBox ); #ifndef KAB_EMBEDDED mPhotoUrl->setFilter( KImageIO::pattern() ); #else //KAB_EMBEDDED //US qDebug("ImageWidget::ImageWidget KImageIO not defined. Does this harm ???"); #endif //KAB_EMBEDDED boxLayout->addWidget( mPhotoUrl, 0, 1 ); - - mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), photoBox ); + QHBox *hb1 = new QHBox ( photoBox ); + mUsePhotoUrl = new QCheckBox( i18n( "Store as URL" ), hb1 ); mUsePhotoUrl->setEnabled( false ); - boxLayout->addWidget( mUsePhotoUrl, 1, 1 ); + boxLayout->addWidget( hb1, 1, 1 ); - QPushButton * pb = new QPushButton( i18n( "Remove" ), photoBox ); + QPushButton * pb = new QPushButton( i18n( "Remove" ), hb1 ); connect( pb, SIGNAL( clicked() ),this, SLOT( removePhoto() ) ); - boxLayout->addWidget( pb, 2, 1 ); - boxLayout->addWidget( new QLabel( photoBox ), 3, 1 ); + boxLayout->addWidget( new QLabel( photoBox ), 2, 1 ); topLayout->addWidget( photoBox, 0, 0 ); QGroupBox *logoBox = new QGroupBox( 0, Qt::Vertical, i18n( "Logo" ), this ); - boxLayout = new QGridLayout( logoBox->layout(), 4, 2, KDialog::spacingHint() ); + boxLayout = new QGridLayout( logoBox->layout(), 3, 2, KDialog::spacingHint() ); boxLayout->setRowStretch( 2, 1 ); mLogoLabel = new QLabel( logoBox ); mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac ); mLogoLabel->setScaledContents( true ); mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken ); boxLayout->addMultiCellWidget( mLogoLabel, 0, 3, 0, 0 ); mLogoUrl = new KURLRequester( logoBox ); #ifndef KAB_EMBEDDED mLogoUrl->setFilter( KImageIO::pattern() ); #else //KAB_EMBEDDED //US qDebug("ImageWidget::ImageWidget KImageIO not defined 2"); #endif //KAB_EMBEDDED boxLayout->addWidget( mLogoUrl, 0, 1 ); - mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), logoBox ); + QHBox *hb2 = new QHBox ( logoBox ); + mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), hb2 ); mUseLogoUrl->setEnabled( false ); - boxLayout->addWidget( mUseLogoUrl, 1, 1 ); + boxLayout->addWidget( hb2, 1, 1 ); - pb = new QPushButton( i18n( "Remove" ), logoBox ); + pb = new QPushButton( i18n( "Remove" ), hb2 ); connect( pb, SIGNAL( clicked() ),this, SLOT( removeLogo() ) ); - boxLayout->addWidget( pb, 2, 1 ); - boxLayout->addWidget( new QLabel( logoBox ), 3, 1 ); + boxLayout->addWidget( new QLabel( logoBox ), 2, 1 ); topLayout->addWidget( logoBox, 1, 0 ); connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ), SIGNAL( changed() ) ); connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), SLOT( loadPhoto() ) ); connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), SIGNAL( changed() ) ); connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ), SLOT( updateGUI() ) ); connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ), SIGNAL( changed() ) ); connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ), SIGNAL( changed() ) ); connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), SLOT( loadLogo() ) ); connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), SIGNAL( changed() ) ); connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ), SLOT( updateGUI() ) ); connect( mUseLogoUrl, SIGNAL( toggled( bool ) ), SIGNAL( changed() ) ); #ifndef KAB_EMBEDDED KAcceleratorManager::manage( this ); #endif //KAB_EMBEDDED } ImageWidget::~ImageWidget() { } void ImageWidget::setPhoto( const KABC::Picture &photo ) { bool blocked = signalsBlocked(); blockSignals( true ); if ( photo.isIntern() ) { //US //US mPhotoLabel->setPixmap( photo.data() ); if (photo.data().isNull() != true) { QPixmap pm; pm.convertFromImage(photo.data()); mPhotoLabel->setPixmap( pm ); } mUsePhotoUrl->setChecked( false ); } else { mPhotoUrl->setURL( photo.url() ); if ( !photo.url().isEmpty() ) mUsePhotoUrl->setChecked( true ); loadPhoto(); } blockSignals( blocked ); } KABC::Picture ImageWidget::photo() const { KABC::Picture photo; if ( mUsePhotoUrl->isChecked() ) photo.setUrl( mPhotoUrl->url() ); else { QPixmap *px = mPhotoLabel->pixmap(); if ( px ) { #ifndef KAB_EMBEDDED if ( px->height() > px->width() ) photo.setData( px->convertToImage().scaleHeight( 140 ) ); else photo.setData( px->convertToImage().scaleWidth( 100 ) ); #else //KAB_EMBEDDED //US add teh nullcheck if (px->isNull() != true ) photo.setData( px->convertToImage() ); #endif //KAB_EMBEDDED photo.setType( "PNG" ); } } return photo; } void ImageWidget::setLogo( const KABC::Picture &logo ) { bool blocked = signalsBlocked(); blockSignals( true ); if ( logo.isIntern() ) { //US //US mLogoLabel->setPixmap( logo.data() ); if (logo.data().isNull() != true) { QPixmap pm; pm.convertFromImage(logo.data()); mLogoLabel->setPixmap( pm ); } mUseLogoUrl->setChecked( false ); } else { mLogoUrl->setURL( logo.url() ); if ( !logo.url().isEmpty() ) mUseLogoUrl->setChecked( true ); loadLogo(); } blockSignals( blocked ); } KABC::Picture ImageWidget::logo() const { KABC::Picture logo; if ( mUseLogoUrl->isChecked() ) logo.setUrl( mLogoUrl->url() ); else { QPixmap *px = mLogoLabel->pixmap(); if ( px ) { #ifndef KAB_EMBEDDED if ( px->height() > px->width() ) logo.setData( px->convertToImage().scaleHeight( 140 ) ); else logo.setData( px->convertToImage().scaleWidth( 100 ) ); #else //KAB_EMBEDDED logo.setData( px->convertToImage() ); #endif //KAB_EMBEDDED logo.setType( "PNG" ); } } return logo; } void ImageWidget::removePhoto() { setPhoto(KABC::Picture() ); } void ImageWidget::removeLogo() { setLogo(KABC::Picture() ); } void ImageWidget::loadPhoto() { mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) ); } void ImageWidget::loadLogo() { mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) ); } void ImageWidget::updateGUI() { KURLRequester *ptr = (KURLRequester*)sender(); if ( ptr == mPhotoUrl ) mUsePhotoUrl->setEnabled( true ); else if ( ptr == mLogoUrl ) mUseLogoUrl->setEnabled( true ); } QPixmap ImageWidget::loadPixmap( const KURL &url ) { QString tempFile; QPixmap pixmap; if ( url.isEmpty() ) return pixmap; if ( url.isLocalFile() ) pixmap = QPixmap( url.path() ); else { #ifndef KAB_EMBEDDED if ( KIO::NetAccess::download( url, tempFile ) ) { pixmap = QPixmap( tempFile ); KIO::NetAccess::removeTempFile( tempFile ); } #else //KAB_EMBEDDED qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed"); #endif //KAB_EMBEDDED } return pixmap; diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 9526f23..d393660 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -36,385 +36,386 @@ $Id$ #include <qtimer.h> #include <qlabel.h> #include <qregexp.h> #include <qlineedit.h> #include <qcheckbox.h> #include <qpushbutton.h> #include <qprogressbar.h> #include <libkdepim/phoneaccess.h> #ifndef KAB_EMBEDDED #include <qclipboard.h> #include <qdir.h> #include <qfile.h> #include <qapplicaton.h> #include <qprogressbar.h> #include <qlayout.h> #include <qregexp.h> #include <qvbox.h> #include <kabc/addresseelist.h> #include <kabc/errorhandler.h> #include <kabc/resource.h> #include <kabc/vcardconverter.h> #include <kapplication.h> #include <kactionclasses.h> #include <kcmultidialog.h> #include <kdebug.h> #include <kdeversion.h> #include <kkeydialog.h> #include <kmessagebox.h> #include <kprinter.h> #include <kprotocolinfo.h> #include <kresources/selectdialog.h> #include <kstandarddirs.h> #include <ktempfile.h> #include <kxmlguiclient.h> #include <kaboutdata.h> #include <libkdepim/categoryselectdialog.h> #include "addresseeutil.h" #include "addresseeeditordialog.h" #include "extensionmanager.h" #include "kstdaction.h" #include "kaddressbookservice.h" #include "ldapsearchdialog.h" #include "printing/printingwizard.h" #else // KAB_EMBEDDED #include <kapplication.h> #include "KDGanttMinimizeSplitter.h" #include "kaddressbookmain.h" #include "kactioncollection.h" #include "addresseedialog.h" //US #include <addresseeview.h> #include <qapp.h> #include <qmenubar.h> //#include <qtoolbar.h> #include <qmessagebox.h> #include <kdebug.h> #include <kiconloader.h> // needed for SmallIcon #include <kresources/kcmkresources.h> #include <ktoolbar.h> //#include <qlabel.h> #ifndef DESKTOP_VERSION #include <qpe/ir.h> #include <qpe/qpemenubar.h> #include <qtopia/qcopenvelope_qws.h> #else #include <qmenubar.h> #endif #endif // KAB_EMBEDDED #include "kcmconfigs/kcmkabconfig.h" #include "kcmconfigs/kcmkdepimconfig.h" #include "kpimglobalprefs.h" #include "externalapphandler.h" #include "xxportselectdialog.h" #include <kresources/selectdialog.h> #include <kmessagebox.h> #include <picture.h> #include <resource.h> //US#include <qsplitter.h> #include <qmap.h> #include <qdir.h> #include <qfile.h> #include <qvbox.h> #include <qlayout.h> #include <qclipboard.h> #include <qtextstream.h> #include <qradiobutton.h> #include <qbuttongroup.h> #include <libkdepim/categoryselectdialog.h> #include <libkdepim/categoryeditdialog.h> #include <kabc/vcardconverter.h> #include "addresseeutil.h" #include "undocmds.h" #include "addresseeeditordialog.h" #include "viewmanager.h" #include "details/detailsviewcontainer.h" #include "kabprefs.h" #include "xxportmanager.h" #include "incsearchwidget.h" #include "jumpbuttonbar.h" #include "extensionmanager.h" #include "addresseeconfig.h" #include "nameeditdialog.h" #include <kcmultidialog.h> #ifdef _WIN32_ #include "kaimportoldialog.h" #else #include <unistd.h> #endif // sync includes #include <libkdepim/ksyncprofile.h> #include <libkdepim/ksyncprefsdialog.h> class KABCatPrefs : public QDialog { public: KABCatPrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Manage new Categories") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); lay->addWidget( lab ); QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); lay->addWidget( format ); format->setExclusive ( true ) ; addCatBut = new QRadioButton(i18n("Add to category list"), format ); new QRadioButton(i18n("Remove from addressees"), format ); addCatBut->setChecked( true ); QPushButton * ok = new QPushButton( i18n("OK"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); resize( 200, 200 ); } bool addCat() { return addCatBut->isChecked(); } private: QRadioButton* addCatBut; }; class KABFormatPrefs : public QDialog { public: KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Set formatted name") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); lay->addWidget( lab ); QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); lay->addWidget( format ); format->setExclusive ( true ) ; simple = new QRadioButton(i18n("Simple: James Bond"), format ); full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); company = new QRadioButton(i18n("Organization: MI6"), format ); simple->setChecked( true ); setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); lay->addWidget( setCompany ); QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); - resize( 200, 200 ); + //resize( 200, 200 ); + } public: QRadioButton* simple, *full, *reverse, *company; QCheckBox* setCompany; }; class KAex2phonePrefs : public QDialog { public: KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Export to phone options") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QLabel *lab; lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); lab->setAlignment (AlignHCenter ); QHBox* temphb; temphb = new QHBox( this ); new QLabel( i18n("I/O device: "), temphb ); mPhoneDevice = new QLineEdit( temphb); lay->addWidget( temphb ); temphb = new QHBox( this ); new QLabel( i18n("Connection: "), temphb ); mPhoneConnection = new QLineEdit( temphb); lay->addWidget( temphb ); temphb = new QHBox( this ); new QLabel( i18n("Model(opt.): "), temphb ); mPhoneModel = new QLineEdit( temphb); lay->addWidget( temphb ); // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); // lay->addWidget( mWriteToSim ); lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); lab->setAlignment (AlignHCenter); QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); resize( 220, 240 ); } public: QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; QCheckBox* mWriteToSim; }; bool pasteWithNewUid = true; #ifdef KAB_EMBEDDED KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ mReadWrite( readWrite ), mModified( false ), mMainWindow(client) #else //KAB_EMBEDDED KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), mReadWrite( readWrite ), mModified( false ) #endif //KAB_EMBEDDED { // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); // syncManager->setBlockSave(false); mMiniSplitter = 0; mExtensionBarSplitter = 0; mIsPart = !parent->inherits( "KAddressBookMain" ); mAddressBook = KABC::StdAddressBook::self(); KABC::StdAddressBook::setAutomaticSave( false ); #ifndef KAB_EMBEDDED mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); #endif //KAB_EMBEDDED connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), SLOT( addressBookChanged() ) ); #if 0 // LP moved to addressbook init method mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, "X-Department", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, "X-Profession", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, "X-AssistantsName", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, "X-ManagersName", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, "X-SpousesName", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, "X-Office", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, "X-IMAddress", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, "X-Anniversary", "KADDRESSBOOK" ); //US added this field to become compatible with Opie/qtopia addressbook // values can be "female" or "male" or "". An empty field represents undefined. mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, "X-Gender", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, "X-Children", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, "X-FreeBusyUrl", "KADDRESSBOOK" ); #endif initGUI(); mIncSearchWidget->setFocus(); connect( mViewManager, SIGNAL( selected( const QString& ) ), SLOT( setContactSelected( const QString& ) ) ); connect( mViewManager, SIGNAL( executed( const QString& ) ), SLOT( executeContact( const QString& ) ) ); connect( mViewManager, SIGNAL( deleteRequest( ) ), SLOT( deleteContacts( ) ) ); connect( mViewManager, SIGNAL( modified() ), SLOT( setModified() ) ); connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); connect( mXXPortManager, SIGNAL( modified() ), SLOT( setModified() ) ); connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), SLOT( incrementalSearch( const QString& ) ) ); connect( mIncSearchWidget, SIGNAL( fieldChanged() ), mJumpButtonBar, SLOT( recreateButtons() ) ); connect( mDetails, SIGNAL( sendEmail( const QString& ) ), SLOT( sendMail( const QString& ) ) ); connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 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&))); connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); #ifndef KAB_EMBEDDED connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), mXXPortManager, SLOT( importVCard( const KURL& ) ) ); connect( mDetails, SIGNAL( browse( const QString& ) ), SLOT( browse( const QString& ) ) ); mAddressBookService = new KAddressBookService( this ); #endif //KAB_EMBEDDED mMessageTimer = new QTimer( this ); connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); mEditorDialog = 0; createAddresseeEditorDialog( this ); setModified( false ); mBRdisabled = false; #ifndef DESKTOP_VERSION infrared = 0; #endif //toggleBeamReceive( ); //mMainWindow->toolBar()->show(); // we have a toolbar repainting error on the Zaurus when starting KA/Pi QTimer::singleShot( 10, this , SLOT ( updateToolBar())); } void KABCore::updateToolBar() { static int iii = 0; ++iii; mMainWindow->toolBar()->repaintMe(); if ( iii < 3 ) QTimer::singleShot( 10, this , SLOT ( updateToolBar())); } KABCore::~KABCore() { // save(); //saveSettings(); //KABPrefs::instance()->writeConfig(); delete AddresseeConfig::instance(); mAddressBook = 0; KABC::StdAddressBook::close(); delete syncManager; @@ -1184,385 +1185,386 @@ bool KABCore::modified() const return mModified; } void KABCore::contactModified( const KABC::Addressee &addr ) { addrModified( addr ); } void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) { Command *command = 0; QString uid; // check if it exists already KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); if ( origAddr.isEmpty() ) command = new PwNewCommand( mAddressBook, addr ); else { command = new PwEditCommand( mAddressBook, origAddr, addr ); uid = addr.uid(); } UndoStack::instance()->push( command ); RedoStack::instance()->clear(); if ( updateDetails ) mDetails->setAddressee( addr ); setModified( true ); } void KABCore::newContact() { QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); QPtrList<KRES::Resource> kresResources; QPtrListIterator<KABC::Resource> it( kabcResources ); KABC::Resource *resource; while ( ( resource = it.current() ) != 0 ) { ++it; if ( !resource->readOnly() ) { KRES::Resource *res = static_cast<KRES::Resource*>( resource ); if ( res ) kresResources.append( res ); } } KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); resource = static_cast<KABC::Resource*>( res ); if ( resource ) { KABC::Addressee addr; addr.setResource( resource ); mEditorDialog->setAddressee( addr ); KApplication::execDialog ( mEditorDialog ); } else return; // mEditorDict.insert( dialog->addressee().uid(), dialog ); } void KABCore::addEmail( QString aStr ) { #ifndef KAB_EMBEDDED QString fullName, email; KABC::Addressee::parseEmailAddress( aStr, fullName, email ); // Try to lookup the addressee matching the email address bool found = false; QStringList emailList; KABC::AddressBook::Iterator it; for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { emailList = (*it).emails(); if ( emailList.contains( email ) > 0 ) { found = true; (*it).setNameFromString( fullName ); editContact( (*it).uid() ); } } if ( !found ) { KABC::Addressee addr; addr.setNameFromString( fullName ); addr.insertEmail( email, true ); mAddressBook->insertAddressee( addr ); mViewManager->refreshView( addr.uid() ); editContact( addr.uid() ); } #else //KAB_EMBEDDED qDebug("KABCore::addEmail finsih method"); #endif //KAB_EMBEDDED } void KABCore::importVCard( const KURL &url, bool showPreview ) { mXXPortManager->importVCard( url, showPreview ); } void KABCore::importFromOL() { #ifdef _WIN32_ KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); idgl->exec(); KABC::Addressee::List list = idgl->getAddressList(); if ( list.count() > 0 ) { KABC::Addressee::List listNew; KABC::Addressee::List listExisting; KABC::Addressee::List::Iterator it; KABC::AddressBook::Iterator iter; for ( it = list.begin(); it != list.end(); ++it ) { if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) listNew.append( (*it) ); else listExisting.append( (*it) ); } if ( listExisting.count() > 0 ) KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); if ( listNew.count() > 0 ) { pasteWithNewUid = false; pasteContacts( listNew ); pasteWithNewUid = true; } } delete idgl; #endif } void KABCore::importVCard( const QString &vCard, bool showPreview ) { mXXPortManager->importVCard( vCard, showPreview ); } //US added a second method without defaultparameter void KABCore::editContact2() { editContact( QString::null ); } void KABCore::editContact( const QString &uid ) { if ( mExtensionManager->isQuickEditVisible() ) return; // First, locate the contact entry QString localUID = uid; if ( localUID.isNull() ) { QStringList uidList = mViewManager->selectedUids(); if ( uidList.count() > 0 ) localUID = *( uidList.at( 0 ) ); } KABC::Addressee addr = mAddressBook->findByUid( localUID ); if ( !addr.isEmpty() ) { mEditorDialog->setAddressee( addr ); KApplication::execDialog ( mEditorDialog ); } } /** Shows or edits the detail view for the given uid. If the uid is QString::null, the method will try to find a selected addressee in the view. */ void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) { if ( mMultipleViewsAtOnce ) { editContact( uid ); } else { setDetailsVisible( true ); mActionDetails->setChecked(true); } } void KABCore::save() { if (syncManager->blockSave()) return; if ( !mModified ) return; syncManager->setBlockSave(true); QString text = i18n( "There was an error while attempting to save\n the " "address book. Please check that some \nother application is " "not using it. " ); - message(i18n("Saving addressbook ... ")); + message(i18n("Saving ... please wait! ")); + qApp->processEvents(); #ifndef KAB_EMBEDDED KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); if ( !b || !b->save() ) { KMessageBox::error( this, text, i18n( "Unable to Save" ) ); } #else //KAB_EMBEDDED KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); if ( !b || !b->save() ) { QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); } #endif //KAB_EMBEDDED message(i18n("Addressbook saved!")); setModified( false ); syncManager->setBlockSave(false); } void KABCore::undo() { UndoStack::instance()->undo(); // Refresh the view mViewManager->refreshView(); } void KABCore::redo() { RedoStack::instance()->redo(); // Refresh the view mViewManager->refreshView(); } void KABCore::setJumpButtonBarVisible( bool visible ) { if (mMultipleViewsAtOnce) { if ( visible ) mJumpButtonBar->show(); else mJumpButtonBar->hide(); } else { // show the jumpbar only if "the details are hidden" == "viewmanager are shown" if (mViewManager->isVisible()) { if ( visible ) mJumpButtonBar->show(); else mJumpButtonBar->hide(); } else { mJumpButtonBar->hide(); } } } void KABCore::setDetailsToState() { setDetailsVisible( mActionDetails->isChecked() ); } void KABCore::setDetailsToggle() { mActionDetails->setChecked( !mActionDetails->isChecked() ); setDetailsToState(); } void KABCore::setDetailsVisible( bool visible ) { if (visible && mDetails->isHidden()) { KABC::Addressee::List addrList = mViewManager->selectedAddressees(); if ( addrList.count() > 0 ) mDetails->setAddressee( addrList[ 0 ] ); } // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between // the listview and the detailview. We do that by changing the splitbar size. if (mMultipleViewsAtOnce) { if ( visible ) mDetails->show(); else mDetails->hide(); } else { if ( visible ) { mViewManager->hide(); mDetails->show(); mIncSearchWidget->setFocus(); } else { mViewManager->show(); mDetails->hide(); mViewManager->setFocusAV(); } setJumpButtonBarVisible( !visible ); } } void KABCore::extensionChanged( int id ) { //change the details view only for non desktop systems #ifndef DESKTOP_VERSION if (id == 0) { //the user disabled the extension. if (mMultipleViewsAtOnce) { // enable detailsview again setDetailsVisible( true ); mActionDetails->setChecked( true ); } else { //go back to the listview setDetailsVisible( false ); mActionDetails->setChecked( false ); mActionDetails->setEnabled(true); } } else { //the user enabled the extension. setDetailsVisible( false ); mActionDetails->setChecked( false ); if (!mMultipleViewsAtOnce) { mActionDetails->setEnabled(false); } mExtensionManager->setSelectionChanged(); } #endif// DESKTOP_VERSION } void KABCore::extensionModified( const KABC::Addressee::List &list ) { if ( list.count() != 0 ) { KABC::Addressee::List::ConstIterator it; for ( it = list.begin(); it != list.end(); ++it ) mAddressBook->insertAddressee( *it ); if ( list.count() > 1 ) setModified(); else setModifiedWOrefresh(); } if ( list.count() == 0 ) mViewManager->refreshView(); else mViewManager->refreshView( list[ 0 ].uid() ); } QString KABCore::getNameByPhone( const QString &phone ) { #ifndef KAB_EMBEDDED QRegExp r( "[/*/-/ ]" ); QString localPhone( phone ); bool found = false; QString ownerName = ""; KABC::AddressBook::Iterator iter; KABC::PhoneNumber::List::Iterator phoneIter; KABC::PhoneNumber::List phoneList; for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { phoneList = (*iter).phoneNumbers(); for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); ++phoneIter) { // Get rid of separator chars so just the numbers are compared. if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { ownerName = (*iter).formattedName(); found = true; } } @@ -2174,409 +2176,415 @@ void KABCore::addActionsManually() mActionQuit->plug( fileMenu ); #ifdef _WIN32_ mActionImportOL->plug( ImportMenu ); #endif // edit menu mActionUndo->plug( editMenu ); mActionRedo->plug( editMenu ); editMenu->insertSeparator(); mActionCut->plug( editMenu ); mActionCopy->plug( editMenu ); mActionPaste->plug( editMenu ); mActionDelete->plug( editMenu ); editMenu->insertSeparator(); mActionSelectAll->plug( editMenu ); mActionSetFormattedName->plug( changeMenu ); mActionRemoveVoice->plug( changeMenu ); // settings menu //US special menuentry to configure the addressbook resources. On KDE // you do that through the control center !!! mActionConfigResources->plug( settingsMenu ); settingsMenu->insertSeparator(); mActionConfigKAddressbook->plug( settingsMenu ); if ( mIsPart ) { //US not implemented yet //mActionConfigShortcuts->plug( settingsMenu ); //mActionConfigureToolbars->plug( settingsMenu ); } else { //US not implemented yet //mActionKeyBindings->plug( settingsMenu ); } settingsMenu->insertSeparator(); mActionJumpBar->plug( settingsMenu ); mActionDetails->plug( settingsMenu ); //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) mActionDetails->plug( tb ); settingsMenu->insertSeparator(); #ifndef DESKTOP_VERSION if ( Ir::supported() ) mActionBR->plug(settingsMenu ); #endif settingsMenu->insertSeparator(); mActionWhoAmI->plug( settingsMenu ); mActionEditCategories->plug( settingsMenu ); mActionEditCategories->plug( changeMenu ); mActionCategories->plug( changeMenu ); mActionManageCategories->plug( changeMenu ); mActionCategories->plug( settingsMenu ); mActionManageCategories->plug( settingsMenu ); mActionWN->plug( helpMenu ); mActionSyncHowto->plug( helpMenu ); mActionKdeSyncHowto->plug( helpMenu ); mActionMultiSyncHowto->plug( helpMenu ); mActionFaq->plug( helpMenu ); mActionLicence->plug( helpMenu ); mActionAboutKAddressbook->plug( helpMenu ); if (KGlobal::getDesktopSize() > KGlobal::Small ) { mActionSave->plug( tb ); mViewManager->getFilterAction()->plug ( tb); //LR hide filteraction on started in 480x640 if (QApplication::desktop()->width() == 480 ) { mViewManager->getFilterAction()->setComboWidth( 0 ); } mActionUndo->plug( tb ); mActionDelete->plug( tb ); mActionRedo->plug( tb ); } else { mActionSave->plug( tb ); tb->enableMoving(false); } //mActionQuit->plug ( tb ); // tb->insertWidget(-1, 0, mIncSearchWidget, 6); //US link the searchwidget first to this. // The real linkage to the toolbar happens later. //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); //US tb->insertItem( mIncSearchWidget ); /*US mIncSearchWidget = new IncSearchWidget( tb ); connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), SLOT( incrementalSearch( const QString& ) ) ); mJumpButtonBar = new JumpButtonBar( this, this ); //US topLayout->addWidget( mJumpButtonBar ); this->layout()->add( mJumpButtonBar ); */ #endif //KAB_EMBEDDED mActionExport2phone->plug( ExportMenu ); connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); syncManager->fillSyncMenu(); } void KABCore::showLicence() { KApplication::showLicence(); } void KABCore::manageCategories( ) { KABCatPrefs* cp = new KABCatPrefs(); cp->show(); int w =cp->sizeHint().width() ; int h = cp->sizeHint().height() ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); if ( !cp->exec() ) { delete cp; return; } int count = 0; message( i18n("Please wait, processing categories...")); if ( cp->addCat() ) { KABC::AddressBook::Iterator it; QStringList catList = KABPrefs::instance()->mCustomCategories; for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { QStringList catIncList = (*it).categories(); int i; for( i = 0; i< catIncList.count(); ++i ) { if ( !catList.contains (catIncList[i])) { catList.append( catIncList[i] ); //qDebug("add cat %s ", catIncList[i].latin1()); ++count; } } } catList.sort(); KABPrefs::instance()->mCustomCategories = catList; KABPrefs::instance()->writeConfig(); message(QString::number( count )+ i18n(" categories added to list! ")); } else { QStringList catList = KABPrefs::instance()->mCustomCategories; QStringList catIncList; QStringList newCatList; KABC::AddressBook::Iterator it; for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { QStringList catIncList = (*it).categories(); int i; if ( catIncList.count() ) { newCatList.clear(); for( i = 0; i< catIncList.count(); ++i ) { if ( catList.contains (catIncList[i])) { newCatList.append( catIncList[i] ); } } newCatList.sort(); (*it).setCategories( newCatList ); mAddressBook->insertAddressee( (*it) ); } } setModified( true ); mViewManager->refreshView(); message( i18n("Removing categories done!")); } delete cp; } void KABCore::removeVoice() { if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) return; KABC::Addressee::List list; XXPortSelectDialog dlg( this, false, this ); if ( dlg.exec() ) list = dlg.contacts(); else return; KABC::Addressee::List::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { if ( (*it).removeVoice() ) addrModified((*it), false ); } } void KABCore::setFormattedName() { KABFormatPrefs setpref; if ( !setpref.exec() ) { return; } - KABC::Addressee::List list; XXPortSelectDialog dlg( this, false, this ); - if ( dlg.exec() ) - list = dlg.contacts(); - else + if ( !dlg.exec() ) return; - KABC::Addressee::List::Iterator it; - for ( it = list.begin(); it != list.end(); ++it ) { + mAddressBook->setUntagged(); + dlg.tagSelected(); + int count = 0; + KABC::AddressBook::Iterator it; + for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { + if ( (*it).tagged() ) { + message(i18n("Changing contact #%1").arg( ++count ) ); + qApp->processEvents(); QString fName; if ( setpref.simple->isChecked() ) fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); else if ( setpref.full->isChecked() ) fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); else if ( setpref.reverse->isChecked() ) fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); else fName = (*it).organization(); if ( setpref.setCompany->isChecked() ) if ( fName.isEmpty() || fName =="," ) fName = (*it).organization(); (*it).setFormattedName( fName ); - addrModified((*it),false ); } + } + message(i18n("Refreshing view...") ); + mViewManager->refreshView( "" ); Addressee add; mDetails->setAddressee( add ); + message(i18n("Setting formatted name completed!") ); } void KABCore::clipboardDataChanged() { if ( mReadWrite ) mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); } void KABCore::updateActionMenu() { UndoStack *undo = UndoStack::instance(); RedoStack *redo = RedoStack::instance(); if ( undo->isEmpty() ) mActionUndo->setText( i18n( "Undo" ) ); else mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); mActionUndo->setEnabled( !undo->isEmpty() ); if ( !redo->top() ) mActionRedo->setText( i18n( "Redo" ) ); else mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); mActionRedo->setEnabled( !redo->isEmpty() ); } void KABCore::configureKeyBindings() { #ifndef KAB_EMBEDDED KKeyDialog::configure( actionCollection(), true ); #else //KAB_EMBEDDED qDebug("KABCore::configureKeyBindings() not implemented"); #endif //KAB_EMBEDDED } #ifdef KAB_EMBEDDED void KABCore::configureResources() { KRES::KCMKResources dlg( this, "" , 0 ); if ( !dlg.exec() ) return; KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); } #endif //KAB_EMBEDDED /* this method will be called through the QCop interface from Ko/Pi to select addresses * for the attendees list of an event. */ void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) { QStringList nameList; QStringList emailList; QStringList uidList; KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); uint i=0; for (i=0; i < list.count(); i++) { nameList.append(list[i].realName()); emailList.append(list[i].preferredEmail()); uidList.append(list[i].uid()); } bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); } /* this method will be called through the QCop interface from Ko/Pi to select birthdays * to put them into the calendar. */ void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) { // qDebug("KABCore::requestForBirthdayList"); QStringList birthdayList; QStringList anniversaryList; QStringList realNameList; QStringList preferredEmailList; QStringList assembledNameList; QStringList uidList; KABC::AddressBook::Iterator it; int count = 0; for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { ++count; } QProgressBar bar(count,0 ); int w = 300; if ( QApplication::desktop()->width() < 320 ) w = 220; int h = bar.sizeHint().height() ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); bar.show(); bar.setCaption (i18n("Collecting birthdays - close to abort!") ); qApp->processEvents(); QDate bday; QString anni; QString formattedbday; for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { if ( ! bar.isVisible() ) return; bar.setProgress( count++ ); qApp->processEvents(); bday = (*it).birthday().date(); anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); if ( bday.isValid() || !anni.isEmpty()) { if (bday.isValid()) formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); else formattedbday = "NOTVALID"; if (anni.isEmpty()) anni = "INVALID"; birthdayList.append(formattedbday); anniversaryList.append(anni); //should be ISODate realNameList.append((*it).realName()); preferredEmailList.append((*it).preferredEmail()); assembledNameList.append((*it).assembledName()); uidList.append((*it).uid()); //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); } } bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); } /* this method will be called through the QCop interface from other apps to show details of a contact. */ void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) { //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); QString foundUid = QString::null; if ( ! uid.isEmpty() ) { Addressee adrr = mAddressBook->findByUid( uid ); if ( !adrr.isEmpty() ) { foundUid = uid; } if ( email == "sendbacklist" ) { //qDebug("ssssssssssssssssssssssend "); QStringList nameList; QStringList emailList; QStringList uidList; nameList.append(adrr.realName()); emailList = adrr.emails(); uidList.append( adrr.preferredEmail()); bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); return; } } if ( email == "sendbacklist" ) return; if (foundUid.isEmpty()) { //find the uid of the person first Addressee::List namelist; Addressee::List emaillist; if (!name.isEmpty()) namelist = mAddressBook->findByName( name ); if (!email.isEmpty()) emaillist = mAddressBook->findByEmail( email ); //qDebug("count %d %d ", namelist.count(),emaillist.count() ); //check if we have a match in Namelist and Emaillist if ((namelist.count() == 0) && (emaillist.count() > 0)) { foundUid = emaillist[0].uid(); } else if ((namelist.count() > 0) && (emaillist.count() == 0)) foundUid = namelist[0].uid(); else { for (int i = 0; i < namelist.count(); i++) { for (int j = 0; j < emaillist.count(); j++) @@ -3017,260 +3025,260 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo if ( !skipIncidence ) { inL = local->findByUid( uid ); if ( !inL.resource() || inL.resource()->includeInSync() ) { inR = remote->findByUid( uid ); if ( inR.isEmpty() ){ if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { // no conflict ********** add or delete local if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); local->removeAddressee( inL ); ++deletedAddresseeL; } else { if ( ! syncManager->mWriteBackExistingOnly ) { inL.removeID(mCurrentSyncDevice ); ++addedAddresseeR; inL.setRevision( modifiedCalendar ); local->insertAddressee( inL, false ); inR = inL; inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); inR.setResource( 0 ); remote->insertAddressee( inR, false ); } } } else { if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { //qDebug("data %s ", inL.revision().toString().latin1()); // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); local->removeAddressee( inL ); ++deletedAddresseeL; } else { if ( ! syncManager->mWriteBackExistingOnly ) { ++addedAddresseeR; inL.setRevision( modifiedCalendar ); local->insertAddressee( inL, false ); inR = inL; inR.setIDStr( ":" ); inR.setResource( 0 ); remote->insertAddressee( inR, false ); } } } } else { ++filteredOUT; } } } } ++incCounter; } el.clear(); syncManager->hideProgressBar(); mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); // get rid of micro seconds QTime t = mLastAddressbookSync.time(); mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); addresseeLSync.setRevision( mLastAddressbookSync ); addresseeRSync.setRevision( mLastAddressbookSync ); addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); addresseeRSync.setNote( "" ) ; addresseeLSync.setNote( "" ); if ( mGlobalSyncMode == SYNC_MODE_NORMAL) remote->insertAddressee( addresseeRSync, false ); local->insertAddressee( addresseeLSync, false ); QString mes; mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); qDebug( mes ); mes = i18n("Local addressbook changed!\n") +mes; if ( syncManager->mShowSyncSummary ) { if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, i18n("KA/Pi Synchronization"),i18n("Write back"))) { qDebug("cancelled "); return false; } } return syncOK; } //this is a overwritten callbackmethods from the syncinterface bool KABCore::sync(KSyncManager* manager, QString filename, int mode) { //pending prepare addresseeview for output //pending detect, if remote file has REV field. if not switch to external sync mGlobalSyncMode = SYNC_MODE_NORMAL; if ( manager != syncManager ) qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); AddressBook abLocal(filename,"syncContact"); bool syncOK = false; if ( abLocal.load() ) { qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); bool external = false; bool isXML = false; if ( filename.right(4) == ".xml") { mGlobalSyncMode = SYNC_MODE_EXTERNAL; isXML = true; abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); } else { external = !manager->mIsKapiFile; if ( external ) { qDebug("Setting vcf mode to external "); mGlobalSyncMode = SYNC_MODE_EXTERNAL; AddressBook::Iterator it; for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { (*it).setID( mCurrentSyncDevice, (*it).uid() ); (*it).computeCsum( mCurrentSyncDevice ); } } } //AddressBook::Iterator it; //QStringList vcards; //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { // qDebug("Name %s ", (*it).familyName().latin1()); //} syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); if ( syncOK ) { if ( syncManager->mWriteBackFile ) { if ( external ) abLocal.removeSyncAddressees( !isXML); qDebug("Saving remote AB "); if ( ! abLocal.saveAB()) qDebug("Error writing back AB to file "); if ( external ) { // afterwrite processing abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); } } } setModified(); } abLocal.removeResources(); if ( syncOK ) mViewManager->refreshView(); return syncOK; } void KABCore::removeSyncInfo( QString syncProfile) { qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); mAddressBook->removeSyncInfo( syncProfile ); setModified(); } //this is a overwritten callbackmethods from the syncinterface bool KABCore::syncExternal(KSyncManager* manager, QString resource) { if ( resource == "phone" ) return syncPhone(); disableBR( true ); if ( manager != syncManager ) qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); AddressBook abLocal( resource,"syncContact"); bool syncOK = false; if ( abLocal.load() ) { qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); mGlobalSyncMode = SYNC_MODE_EXTERNAL; abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); if ( syncOK ) { if ( syncManager->mWriteBackFile ) { abLocal.removeSyncAddressees( false ); abLocal.saveAB(); abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); } } else message( i18n("Sync cancelled or failed.") ); setModified(); } abLocal.removeResources(); if ( syncOK ) mViewManager->refreshView(); disableBR( false ); return syncOK; } void KABCore::message( QString m ) { topLevelWidget()->setCaption( m ); - mMessageTimer->start( 15000, true ); + mMessageTimer->start( 20000, true ); } bool KABCore::syncPhone() { QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); QString fileName = getPhoneFile(); if ( !PhoneAccess::readFromPhone( fileName) ) { message(i18n("Phone access failed!")); return false; } AddressBook abLocal( fileName,"syncContact"); bool syncOK = false; { abLocal.importFromFile( fileName ); qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); mGlobalSyncMode = SYNC_MODE_EXTERNAL; abLocal.preparePhoneSync( mCurrentSyncDevice, true ); abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); if ( syncOK ) { if ( syncManager->mWriteBackFile ) { abLocal.removeSyncAddressees( true ); abLocal.saveABphone( fileName ); abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); } } setModified(); } abLocal.removeResources(); if ( syncOK ) mViewManager->refreshView(); return syncOK; } void KABCore::getFile( bool success ) { if ( ! success ) { message( i18n("Error receiving file. Nothing changed!") ); return; } int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); if ( count ) setModified( true ); message( i18n("Pi-Sync successful!") ); mViewManager->refreshView(); } void KABCore::syncFileRequest() { if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { syncManager->slotSyncMenu( 999 ); } mAddressBook->export2File( sentSyncFile() ); } QString KABCore::sentSyncFile() { #ifdef DESKTOP_VERSION return locateLocal( "tmp", "copysyncab.vcf" ); #else return QString( "/tmp/copysyncab.vcf" ); #endif } void KABCore::setCaptionBack() { mMessageTimer->stop(); topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); } diff --git a/kaddressbook/xxportselectdialog.cpp b/kaddressbook/xxportselectdialog.cpp index 6282453..e7bc8c0 100644 --- a/kaddressbook/xxportselectdialog.cpp +++ b/kaddressbook/xxportselectdialog.cpp @@ -1,294 +1,334 @@ /* This file is part of KAddressBook. Copyright (c) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk> Tobias Koenig <tokoe@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include <kabc/addressbook.h> #include <kapplication.h> #include <kcombobox.h> #include <klocale.h> #include <kglobal.h> #include <qapplication.h> #include <qbuttongroup.h> #include <qcombobox.h> #include <qheader.h> #include <qlabel.h> #include <qlayout.h> #include <qlistview.h> #include <qpushbutton.h> #include <qradiobutton.h> #include <qstringlist.h> #include <qwhatsthis.h> #include "kabcore.h" #include "kabprefs.h" #include "xxportselectdialog.h" XXPortSelectDialog::XXPortSelectDialog( KABCore *core, bool sort, QWidget* parent, const char* name ) - : KDialogBase( Plain, i18n( "Choose which contacts to select" ), Help | Ok | Cancel, + : KDialogBase( Plain, i18n( "Choose contact selection" ), Help | Ok | Cancel, Ok, parent, name, true, true ), mCore( core ), mUseSorting( sort ) { initGUI(); connect( mFiltersCombo, SIGNAL( activated( int ) ), SLOT( filterChanged( int ) ) ); connect( mCategoriesView, SIGNAL( clicked( QListViewItem* ) ), SLOT( categoryClicked( QListViewItem* ) ) ); // setup filters #ifndef KAB_EMBEDDED mFilters = Filter::restore( kapp->config(), "Filter" ); Filter::List::iterator filterIt; #else //KAB_EMBEDDED mFilters = Filter::restore( KGlobal::config(), "Filter" ); Filter::List::Iterator filterIt; #endif //KAB_EMBEDDED QStringList filters; for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) filters.append( (*filterIt).name() ); mFiltersCombo->insertStringList( filters ); mUseFilters->setEnabled( filters.count() > 0 ); // setup categories QStringList categories = KABPrefs::instance()->mCustomCategories; QStringList::Iterator it; for ( it = categories.begin(); it != categories.end(); ++it ) new QCheckListItem( mCategoriesView, *it, QCheckListItem::CheckBox ); mUseCategories->setEnabled( categories.count() > 0 ); int count = mCore->selectedUIDs().count(); mUseSelection->setEnabled( count != 0 ); mUseSelection->setChecked( count > 1 ); mSortTypeCombo->insertItem( i18n( "Ascending" ) ); mSortTypeCombo->insertItem( i18n( "Descending" ) ); mFields = mCore->addressBook()->fields( KABC::Field::All ); KABC::Field::List::Iterator fieldIt; for ( fieldIt = mFields.begin(); fieldIt != mFields.end(); ++fieldIt ) mFieldCombo->insertItem( (*fieldIt)->label() ); } QStringList XXPortSelectDialog::uids() { QStringList uidlist; KABC::AddresseeList list = contacts(); KABC::Addressee::List::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) uidlist.append((*it).uid()); return uidlist; } -KABC::AddresseeList XXPortSelectDialog::contacts() +void XXPortSelectDialog::tagSelected() { + if ( mUseSelection->isChecked() ) { + QStringList selection = mCore->selectedUIDs(); + KABC::AddressBook::Iterator it; + for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { + if ( selection.findIndex((*it).uid()) >= 0 ) + (*it).setTagged( true ); + } + } else if ( mUseFilters->isChecked() ) { + // find contacts that can pass selected filter + Filter::List::Iterator filterIt; + for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) + if ( (*filterIt).name() == mFiltersCombo->currentText() ) + break; + KABC::AddressBook::Iterator it; + for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { + if ( (*filterIt).filterAddressee( *it ) ) + (*it).setTagged( true ); + } + } else if ( mUseCategories->isChecked() ) { + QStringList categorieList = categories(); + KABC::AddressBook::Iterator it; + for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { + QStringList tmp( (*it).categories() ); + QStringList::Iterator tmpIt; + for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt ) + if ( categorieList.contains( *tmpIt ) ) { + (*it).setTagged( true ); + break; + } + } + } else { + // create a string list of all entries: + KABC::AddressBook::Iterator it; + for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) + (*it).setTagged( true ); + } +} +KABC::AddresseeList XXPortSelectDialog::contacts() +{ KABC::AddresseeList list; if ( mUseSelection->isChecked() ) { QStringList::Iterator it; + QStringList selection = mCore->selectedUIDs(); for ( it = selection.begin(); it != selection.end(); ++it ) { KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); if ( !addr.isEmpty() ) list.append( addr ); } } else if ( mUseFilters->isChecked() ) { // find contacts that can pass selected filter Filter::List::Iterator filterIt; for ( filterIt = mFilters.begin(); filterIt != mFilters.end(); ++filterIt ) if ( (*filterIt).name() == mFiltersCombo->currentText() ) break; KABC::AddressBook::Iterator it; for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { if ( (*filterIt).filterAddressee( *it ) ) list.append( *it ); } } else if ( mUseCategories->isChecked() ) { QStringList categorieList = categories(); KABC::AddressBook::Iterator it; for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) { QStringList tmp( (*it).categories() ); QStringList::Iterator tmpIt; for ( tmpIt = tmp.begin(); tmpIt != tmp.end(); ++tmpIt ) if ( categorieList.contains( *tmpIt ) ) { list.append( *it ); break; } } } else { // create a string list of all entries: KABC::AddressBook::Iterator it; for ( it = mCore->addressBook()->begin(); it != mCore->addressBook()->end(); ++it ) list.append( *it ); } if ( mUseSorting ) { list.setReverseSorting( mSortTypeCombo->currentItem() == 1 ); uint pos = mFieldCombo->currentItem(); if ( pos < mFields.count() ) list.sortByField( mFields[ pos ] ); } return list; } QStringList XXPortSelectDialog::categories() const { QStringList list; QListViewItemIterator it( mCategoriesView ); for ( ; it.current(); ++it ) { QCheckListItem* qcli = static_cast<QCheckListItem*>(it.current()); if ( qcli->isOn() ) list.append( it.current()->text( 0 ) ); } return list; } void XXPortSelectDialog::filterChanged( int ) { mUseFilters->setChecked( true ); } void XXPortSelectDialog::categoryClicked( QListViewItem *i ) { QCheckListItem *qcli = static_cast<QCheckListItem*>( i ); if ( qcli->isOn() ) mUseCategories->setChecked( true ); } void XXPortSelectDialog::slotHelp() { #ifndef KAB_EMBEDDED kapp->invokeHelp( "import-and-export" ); #else //KAB_EMBEDDED qDebug("XXPortSelectDialog::slotHelp is not implemented yet"); #endif //KAB_EMBEDDED } void XXPortSelectDialog::initGUI() { QFrame *page = plainPage(); QVBoxLayout *topLayout = new QVBoxLayout( page, KDialog::marginHint(), KDialog::spacingHint() ); QLabel *label = new QLabel( i18n( "Which contacts do you want to select?" ), page ); topLayout->addWidget( label ); mButtonGroup = new QButtonGroup( i18n( "Contact Selection" ), page ); mButtonGroup->setColumnLayout( 0, Qt::Vertical ); mButtonGroup->layout()->setSpacing( KDialog::spacingHint() ); mButtonGroup->layout()->setMargin( KDialog::marginHint() ); QGridLayout *groupLayout = new QGridLayout( mButtonGroup->layout() ); groupLayout->setAlignment( Qt::AlignTop ); mUseWholeBook = new QRadioButton( i18n( "&All" ), mButtonGroup ); mUseWholeBook->setChecked( true ); QWhatsThis::add( mUseWholeBook, i18n( "Select the entire address book" ) ); groupLayout->addWidget( mUseWholeBook, 0, 0 ); mUseSelection = new QRadioButton( i18n( "&Selected" ), mButtonGroup ); QWhatsThis::add( mUseSelection, i18n( "Only contacts selected in KAddressBook.\n" "This option is disabled if no contacts are selected." ) ); groupLayout->addWidget( mUseSelection, 1, 0 ); mUseFilters = new QRadioButton( i18n( "By matching &filter" ), mButtonGroup ); QWhatsThis::add( mUseFilters, i18n( "Only contacts matching the selected filter.\n" "This option is disabled if you haven't defined any filters" ) ); groupLayout->addWidget( mUseFilters, 2, 0 ); mUseCategories = new QRadioButton( i18n( "By Cate&gories" ), mButtonGroup ); QWhatsThis::add( mUseCategories, i18n( "Only contacts who are members of a category that is checked on the list to the left.\n" "This option is disabled if you have no categories." ) ); groupLayout->addWidget( mUseCategories, 3, 0 ); mFiltersCombo = new QComboBox( false, mButtonGroup ); QWhatsThis::add( mFiltersCombo, i18n( "Select a filter to decide which contacts to select." ) ); groupLayout->addWidget( mFiltersCombo, 2, 1 ); mCategoriesView = new QListView( mButtonGroup ); mCategoriesView->addColumn( "" ); mCategoriesView->header()->hide(); QWhatsThis::add( mCategoriesView, i18n( "Check the categories whose members you want to select." ) ); groupLayout->addWidget( mCategoriesView, 3, 1 ); - // if (QApplication::desktop()->height() == 480 ) - // mCategoriesView->setMaximumHeight( 240 ); + if (QApplication::desktop()->height() == 480 ) + mCategoriesView->setMaximumHeight( 240 ); topLayout->addWidget( mButtonGroup ); QButtonGroup *sortingGroup = new QButtonGroup( i18n( "Sorting" ), page ); sortingGroup->setColumnLayout( 0, Qt::Vertical ); QGridLayout *sortLayout = new QGridLayout( sortingGroup->layout(), 2, 2, KDialog::spacingHint() ); sortLayout->setAlignment( Qt::AlignTop ); label = new QLabel( i18n( "Criterion:" ), sortingGroup ); sortLayout->addWidget( label, 0, 0 ); #ifndef KAB_EMBEDDED mFieldCombo = new KComboBox( false, sortingGroup ); #else //KAB_EMBEDDED //US Combobox is not editable anyway mFieldCombo = new KComboBox( sortingGroup ); #endif //KAB_EMBEDDED sortLayout->addWidget( mFieldCombo, 0, 1 ); label = new QLabel( i18n( "Order:" ), sortingGroup ); sortLayout->addWidget( label, 1, 0 ); #ifndef KAB_EMBEDDED mSortTypeCombo = new KComboBox( false, sortingGroup ); #else //KAB_EMBEDDED //US Combobox is not editable anyway mSortTypeCombo = new KComboBox( sortingGroup ); #endif //KAB_EMBEDDED sortLayout->addWidget( mSortTypeCombo, 1, 1 ); topLayout->addWidget( sortingGroup ); if ( !mUseSorting ) sortingGroup->hide(); #ifndef DESKTOP_VERSION hideButtons(); #endif } #ifndef KAB_EMBEDDED #include "xxportselectdialog.moc" #endif //KAB_EMBEDDED diff --git a/kaddressbook/xxportselectdialog.h b/kaddressbook/xxportselectdialog.h index 3bb696f..28b1fef 100644 --- a/kaddressbook/xxportselectdialog.h +++ b/kaddressbook/xxportselectdialog.h @@ -1,82 +1,83 @@ /* This file is part of KAddressBook. Copyright (c) 2002 Anders Lund <anders.lund@lund.tdcadsl.dk> Tobias Koenig <tokoe@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef XXPORTSELECTDIALOG_H #define XXPORTSELECTDIALOG_H #include <kabc/addresseelist.h> #include <kabc/field.h> #include <kdialogbase.h> #include "filter.h" class QButtonGroup; class QComboBox; class QListView; class QListViewItem; class QRadioButton; class KABCore; class KComboBox; class XXPortSelectDialog : public KDialogBase { Q_OBJECT public: XXPortSelectDialog( KABCore *core, bool sort, QWidget* parent, const char* name = 0 ); KABC::AddresseeList contacts(); + void tagSelected(); QStringList uids(); private slots: void filterChanged( int ); void categoryClicked( QListViewItem * i ); protected slots: void slotHelp(); private: void initGUI(); QStringList categories() const; QButtonGroup* mButtonGroup; QRadioButton* mUseCategories; QRadioButton* mUseFilters; QRadioButton* mUseWholeBook; QRadioButton* mUseSelection; QComboBox* mFiltersCombo; QListView* mCategoriesView; KComboBox *mFieldCombo; KComboBox *mSortTypeCombo; KABCore *mCore; KABC::AddresseeList mAddresseeList; Filter::List mFilters; KABC::Field::List mFields; bool mUseSorting; }; #endif |