-rw-r--r-- | kaddressbook/addresseeeditorwidget.cpp | 6 | ||||
-rw-r--r-- | kaddressbook/extensionmanager.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/filter.cpp | 21 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 87 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 3 | ||||
-rw-r--r-- | kaddressbook/kabprefs.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/addresseewidget.cpp | 11 | ||||
-rw-r--r-- | kaddressbook/nameeditdialog.cpp | 8 |
8 files changed, 113 insertions, 32 deletions
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp index 3397e06..c6993e9 100644 --- a/kaddressbook/addresseeeditorwidget.cpp +++ b/kaddressbook/addresseeeditorwidget.cpp @@ -952,69 +952,69 @@ void AddresseeEditorWidget::setupTab3_1() ////////////////////////////////////// // Images mImageWidget = new ImageWidget( tab3 ); mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop ); /*US ////////////////////////////////////// // Keys mKeyWidget = new KeyWidget( tab3 ); mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); */ mTabWidget->addTab( tab3, i18n( "&Images" ) ); } void AddresseeEditorWidget::load() { // Block signals in case anything tries to emit modified // CS: This doesn't seem to work. bool block = signalsBlocked(); blockSignals( true ); mBlockSignals = true; // used for internal signal blocking mNameEdit->setText( mAddressee.assembledName() ); if ( mAddressee.formattedName().isEmpty() ) { //US KConfig config( "kaddressbookrc" ); - KConfig config( locateLocal("config", "kaddressbookrc") ); + KConfig config( locateLocal("config", "kabcrc") ); config.setGroup( "General" ); mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); - } else { + } else {; if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) ) mFormattedNameType = NameEditDialog::SimpleName; else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) ) mFormattedNameType = NameEditDialog::FullName; else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) ) mFormattedNameType = NameEditDialog::ReverseName; else mFormattedNameType = NameEditDialog::CustomName; } mFormattedNameLabel->setText( mAddressee.formattedName() ); mRoleEdit->setText( mAddressee.role() ); mOrgEdit->setText( mAddressee.organization() ); //US mURLEdit->setURL( mAddressee.url().url() ); mURLEdit->setText( mAddressee.url().prettyURL() ); //US?? mURLEdit->home( false ); // mNoteEdit->setText( mAddressee.note() ); mNoteEdit->setText( mAddressee.note() ); mEmailWidget->setEmails( mAddressee.emails() ); mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() ); mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() ); mBirthdayPicker->setDate( mAddressee.birthday().date() ); //US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom( //US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) ); QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate mAnniversaryPicker->setDate( dt ); @@ -1156,64 +1156,66 @@ void AddresseeEditorWidget::save() ++addressIter ) mAddressee.insertAddress( *addressIter ); mDirty = false; } bool AddresseeEditorWidget::dirty() { if ( ! mDirty ) { if ( mBirthdayPicker->inputIsValid() ) { QDate da = mBirthdayPicker->date(); if ( !(da == mAddressee.birthday().date())) mDirty = true; } else { mBirthdayPicker->clear(); } if ( mAnniversaryPicker->inputIsValid() ) { QDate da = mAnniversaryPicker->date(); if ( da != KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d")) mDirty = true; } else { mAnniversaryPicker->clear(); } } return mDirty; } void AddresseeEditorWidget::nameTextChanged( const QString &text ) { + if ( mBlockSignals ) + return; // use the addressee class to parse the name for us mAConfig->setUid( mAddressee.uid() ); if ( mAConfig->automaticNameParsing() ) { if ( !mAddressee.formattedName().isEmpty() ) { QString fn = mAddressee.formattedName(); mAddressee.setNameFromString( text ); mAddressee.setFormattedName( fn ); } else { // use extra addressee to avoid a formatted name assignment Addressee addr; addr.setNameFromString( text ); mAddressee.setPrefix( addr.prefix() ); mAddressee.setGivenName( addr.givenName() ); mAddressee.setAdditionalName( addr.additionalName() ); mAddressee.setFamilyName( addr.familyName() ); mAddressee.setSuffix( addr.suffix() ); } } nameBoxChanged(); emitModified(); } void AddresseeEditorWidget::nameBoxChanged() { KABC::Addressee addr; mAConfig->setUid( mAddressee.uid() ); if ( mAConfig->automaticNameParsing() ) { addr.setNameFromString( mNameEdit->text() ); mNameLabel->hide(); mNameEdit->show(); diff --git a/kaddressbook/extensionmanager.cpp b/kaddressbook/extensionmanager.cpp index 98561dc..efbdf17 100644 --- a/kaddressbook/extensionmanager.cpp +++ b/kaddressbook/extensionmanager.cpp @@ -29,64 +29,65 @@ #ifndef KAB_EMBEDDED #include <ktrader.h> #else //KAB_EMBEDDED #include <features/mergewidget.h> #include <features/distributionlistwidget.h> #endif //KAB_EMBEDDED #include "addresseeeditorwidget.h" #include "kabcore.h" #include "kabprefs.h" #include "extensionmanager.h" ExtensionManager::ExtensionManager( KABCore *core, QWidget *parent, const char *name ) : QScrollView( parent, name ), mCore( core ), mCurrentExtensionWidget( 0 ) { #ifdef KAB_EMBEDDED //US QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); QWidget *settingsmenu = (QWidget*)mCore->getSettingsMenu(); #endif //KAB_EMBEDDED mActionExtensions = new KSelectAction( i18n( "Show Extension Bar" ), 0, mCore->actionCollection(), "options_show_extensions" ); mActionExtensions->plug( settingsmenu ); connect( mActionExtensions, SIGNAL( activated( int ) ), SLOT( setActiveExtension( int ) ) ); mWidgetBox = new QWidget( viewport() ); + new QHBoxLayout (mWidgetBox ); addChild( mWidgetBox ); setResizePolicy(AutoOneFit); createExtensionWidgets(); hide(); } ExtensionManager::~ExtensionManager() { } void ExtensionManager::restoreSettings() { mActionExtensions->setCurrentItem( KABPrefs::instance()->mCurrentExtension ); int i = 1; mCurrentExtensionWidget = mExtensionWidgetList.at( i-1 ); while ( mCurrentExtensionWidget ) { if( i != KABPrefs::instance()->mCurrentExtension ) mCurrentExtensionWidget->hide(); mCurrentExtensionWidget = mExtensionWidgetList.at( ++i-1 ); } setActiveExtension( mActionExtensions->currentItem() ); } void ExtensionManager::saveSettings() { KABPrefs::instance()->mCurrentExtension = mActionExtensions->currentItem(); } void ExtensionManager::reconfigure() { saveSettings(); @@ -129,94 +130,94 @@ void ExtensionManager::setActiveExtension( int id ) #endif //KAB_EMBEDDED show(); mWidgetBox->show(); mCurrentExtensionWidget->show(); } else { hide(); mCurrentExtensionWidget = 0; #ifndef DESKTOP_VERSION //US our screen is so small, that we better hide the detailscreen, just in case. //US mCore->setDetailsToState( ); #endif //KAB_EMBEDDED } } emit changedActiveExtension( id ); } void ExtensionManager::createExtensionWidgets() { // clear extension widget list mExtensionWidgetList.setAutoDelete( true ); QPtrListIterator<ExtensionWidget> wdgIt( mExtensionWidgetList ); ExtensionWidget *wdg = 0; while ( ( wdg = wdgIt.current() ) != 0 ) mExtensionWidgetList.remove( wdg ); mExtensionWidgetList.setAutoDelete( false ); QStringList extensionNames( i18n( "None" ) ); // add addressee editor as default - QHBoxLayout *hbl = new QHBoxLayout (mWidgetBox ); + QHBoxLayout *hbl = (QHBoxLayout *) mWidgetBox->layout();; wdg = new AddresseeEditorWidget( mCore, true, mWidgetBox ); hbl->addWidget( wdg ); //wdg->hide(); connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ), SIGNAL( modified( const KABC::Addressee::List& ) ) ); mExtensionWidgetList.append( wdg ); extensionNames.append( wdg->title() ); // load the other extensions QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; #ifndef KAB_EMBEDDED KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); KTrader::OfferList::ConstIterator it; for ( it = plugins.begin(); it != plugins.end(); ++it ) { if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) continue; KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); if ( !factory ) { - kdDebug(5720) << "ExtensionManager::loadExtensions(): Factory creation failed" << endl; + //kdDebug(5720) << "ExtensionManager::loadExtensions(): Factory creation failed" << endl; continue; } ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); if ( !extensionFactory ) { - kdDebug(5720) << "ExtensionManager::loadExtensions(): Cast failed" << endl; + //kdDebug(5720) << "ExtensionManager::loadExtensions(): Cast failed" << endl; continue; } if ( !activeExtensions.contains( extensionFactory->identifier() ) ) continue; wdg = extensionFactory->extension( mCore, this ); if ( wdg ) { //wdg->hide(); connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ), SIGNAL( modified( const KABC::Addressee::List& ) ) ); mExtensionWidgetList.append( wdg ); extensionNames.append( wdg->title() ); } } #else //KAB_EMBEDDED //load Mergefactory/extension ExtensionFactory *extensionFactory = new MergeFactory(); if ( activeExtensions.contains( extensionFactory->identifier() ) ) { wdg = extensionFactory->extension( mCore, mWidgetBox ); if ( wdg ) { hbl->addWidget( wdg ); //wdg->hide(); connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ), SIGNAL( modified( const KABC::Addressee::List& ) ) ); mExtensionWidgetList.append( wdg ); extensionNames.append( wdg->title() ); } } //load DistributionListfactory/extension diff --git a/kaddressbook/filter.cpp b/kaddressbook/filter.cpp index b0d04ca..39d2ae4 100644 --- a/kaddressbook/filter.cpp +++ b/kaddressbook/filter.cpp @@ -151,55 +151,56 @@ void Filter::save( KConfig *config, QString baseGroup, Filter::List &list ) (*iter).save( config ); index++; } } KConfigGroupSaver s( config, baseGroup ); config->writeEntry( "Count", index ); } Filter::List Filter::restore( KConfig *config, QString baseGroup ) { Filter::List list; int count = 0; Filter f; { KConfigGroupSaver s( config, baseGroup ); count = config->readNumEntry( "Count", 0 ); } for ( int i = 0; i < count; i++ ) { { KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); f.restore( config ); } list.append( f ); } - QStringList cats = KABPrefs::instance()->mCustomCategories; - for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { - Filter filter; - filter.mName = *it; - filter.mEnabled = true; - filter.mCategoryList = *it; - filter.mMatchRule = Matching; - filter.mInternal = true; - list.append( filter ); + if ( list.isEmpty()) { + QStringList cats = KABPrefs::instance()->mCustomCategories; + for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { + Filter filter; + filter.mName = *it; + filter.mEnabled = true; + filter.mCategoryList = *it; + filter.mMatchRule = Matching; + filter.mInternal = true; + list.append( filter ); + } } - return list; } void Filter::setMatchRule( MatchRule rule ) { mMatchRule = rule; } Filter::MatchRule Filter::matchRule() const { return mMatchRule; } diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index e14e579..c6288fa 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -122,109 +122,145 @@ $Id$ #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 ); + } +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 ); @@ -1117,82 +1153,88 @@ void KABCore::incrementalSearch( const QString& text ) } void KABCore::setModified() { setModified( true ); } void KABCore::setModifiedWOrefresh() { // qDebug("KABCore::setModifiedWOrefresh() "); mModified = true; mActionSave->setEnabled( mModified ); } void KABCore::setModified( bool modified ) { mModified = modified; mActionSave->setEnabled( mModified ); if ( modified ) mJumpButtonBar->recreateButtons(); mViewManager->refreshView(); } bool KABCore::modified() const { return mModified; } -void KABCore::contactModified( const KABC::Addressee &addr ) +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(); - mDetails->setAddressee( addr ); + 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; @@ -1512,65 +1554,65 @@ QString KABCore::getNameByPhone( const QString &phone ) 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; } } } return ownerName; #else //KAB_EMBEDDED qDebug("KABCore::getNameByPhone finsih method"); return ""; #endif //KAB_EMBEDDED } void KABCore::openConfigDialog() { KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); ConfigureDialog->addModule(kabcfg ); KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); ConfigureDialog->addModule(kdelibcfg ); connect( ConfigureDialog, SIGNAL( applyClicked() ), - this, SLOT( configurationChanged() ) ); + this, SLOT( configurationChanged() ) ); connect( ConfigureDialog, SIGNAL( okClicked() ), this, SLOT( configurationChanged() ) ); saveSettings(); #ifndef DESKTOP_VERSION ConfigureDialog->showMaximized(); #endif if ( ConfigureDialog->exec() ) KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); delete ConfigureDialog; } void KABCore::openLDAPDialog() { #ifndef KAB_EMBEDDED if ( !mLdapSearchDialog ) { mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, SLOT( refreshView() ) ); connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, SLOT( setModified() ) ); } else mLdapSearchDialog->restoreSettings(); if ( mLdapSearchDialog->isOK() ) mLdapSearchDialog->exec(); #else //KAB_EMBEDDED qDebug("KABCore::openLDAPDialog() finsih method"); #endif //KAB_EMBEDDED } void KABCore::print() { @@ -1967,64 +2009,67 @@ void KABCore::initActions() SLOT( toggleBeamReceive() ), actionCollection(), "kaddressbook_beam_rec" ); // misc // only enable LDAP lookup if we can handle the protocol #ifndef KAB_EMBEDDED if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, this, SLOT( openLDAPDialog() ), actionCollection(), "ldap_lookup" ); } #else //KAB_EMBEDDED //qDebug("KABCore::initActions() LDAP has to be implemented"); #endif //KAB_EMBEDDED mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, SLOT( setWhoAmI() ), actionCollection(), "set_personal" ); mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, SLOT( setCategories() ), actionCollection(), "edit_set_categories" ); mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, SLOT( editCategories() ), actionCollection(), "edit__categories" ); mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, SLOT( removeVoice() ), actionCollection(), "remove_voice" ); + mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, + SLOT( setFormattedName() ), actionCollection(), + "set_formatted" ); mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, SLOT( manageCategories() ), actionCollection(), "remove_voice" ); mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, SLOT( importFromOL() ), actionCollection(), "import_OL" ); #ifdef KAB_EMBEDDED mActionLicence = new KAction( i18n( "Licence" ), 0, this, SLOT( showLicence() ), actionCollection(), "licence_about_data" ); mActionFaq = new KAction( i18n( "Faq" ), 0, this, SLOT( faq() ), actionCollection(), "faq_about_data" ); mActionWN = new KAction( i18n( "What's New?" ), 0, this, SLOT( whatsnew() ), actionCollection(), "wn" ); mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, this, SLOT( synchowto() ), actionCollection(), "sync" ); mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, this, SLOT( kdesynchowto() ), actionCollection(), "kdesync" ); mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, this, SLOT( multisynchowto() ), actionCollection(), "multisync" ); mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, this, SLOT( createAboutData() ), actionCollection(), "kaddressbook_about_data" ); @@ -2107,64 +2152,65 @@ void KABCore::addActionsManually() fileMenu->insertSeparator(); mActionSave->plug( fileMenu ); fileMenu->insertItem( "&Import", ImportMenu ); fileMenu->insertItem( "&Export", ExportMenu ); fileMenu->insertItem( i18n("&Change"), changeMenu ); #ifndef DESKTOP_VERSION if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); #endif fileMenu->insertSeparator(); mActionMailVCard->plug( fileMenu ); #ifndef DESKTOP_VERSION if ( Ir::supported() ) mActionBR->plug( beamMenu ); if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); if ( Ir::supported() ) mActionBeam->plug( beamMenu ); #endif fileMenu->insertSeparator(); 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 ); @@ -2273,69 +2319,100 @@ void KABCore::manageCategories( ) 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() ) - contactModified((*it) ); + 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 + return; + KABC::Addressee::List::Iterator it; + for ( it = list.begin(); it != list.end(); ++it ) { + 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 ); + } + Addressee add; + mDetails->setAddressee( add ); +} 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 diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 85ffbdb..0d5891e 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -249,64 +249,65 @@ class KABCore : public QWidget, public KSyncInterface void setSearchFields( const KABC::Field::List &fields ); /** Search with the current search field for a contact, that matches the given text, and selects it in the view. */ void incrementalSearch( const QString& text ); /** Marks the address book as modified. */ void setModified(); /** Marks the address book as modified without refreshing the view. */ void setModifiedWOrefresh(); /** Marks the address book as modified concerning the argument. */ void setModified( bool modified ); /** Returns whether the address book is modified. */ bool modified() const; /** Called whenever an contact is modified in the contact editor dialog or the quick edit. */ void contactModified( const KABC::Addressee &addr ); + void addrModified( const KABC::Addressee &addr, bool updateDetails = true ); /** DCOP METHODS. */ void addEmail( QString addr ); void importVCard( const KURL& url, bool showPreview ); void importVCard( const QString& vCard, bool showPreview ); void newContact(); QString getNameByPhone( const QString& phone ); /** END DCOP METHODS */ /** Saves the contents of the AddressBook back to disk. */ void save(); /** Undos the last command using the undo stack. */ void undo(); /** Redos the last command that was undone, using the redo stack. */ void redo(); /** Shows the edit dialog for the given uid. If the uid is QString::null, the method will try to find a selected addressee in the view. */ @@ -344,64 +345,65 @@ class KABCore : public QWidget, public KSyncInterface void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); signals: void contactSelected( const QString &name ); void contactSelected( const QPixmap &pixmap ); public slots: void recieve(QString cmsg ); void getFile( bool success ); void syncFileRequest(); void setDetailsVisible( bool visible ); void setDetailsToState(); void saveSettings(); private slots: void updateToolBar(); void updateMainWindow(); void receive( const QCString& cmsg, const QByteArray& data ); void toggleBeamReceive( ); void disableBR(bool); void setJumpButtonBarVisible( bool visible ); void setCaptionBack(); void importFromOL(); void extensionModified( const KABC::Addressee::List &list ); void extensionChanged( int id ); void clipboardDataChanged(); void updateActionMenu(); void configureKeyBindings(); void removeVoice(); + void setFormattedName(); #ifdef KAB_EMBEDDED void configureResources(); #endif //KAB_EMBEDDED void slotEditorDestroyed( const QString &uid ); void configurationChanged(); void addressBookChanged(); private: void resizeEvent(QResizeEvent* e ); bool mBRdisabled; #ifndef DESKTOP_VERSION QCopChannel* infrared; #endif QTimer *mMessageTimer; void initGUI(); void initActions(); QString getPhoneFile(); AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, const char *name = 0 ); KXMLGUIClient *mGUIClient; KABC::AddressBook *mAddressBook; ViewManager *mViewManager; // QSplitter *mDetailsSplitter; KDGanttMinimizeSplitter *mExtensionBarSplitter; ViewContainer *mDetails; KDGanttMinimizeSplitter* mMiniSplitter; XXPortManager *mXXPortManager; @@ -448,64 +450,65 @@ class KABCore : public QWidget, public KSyncInterface //US settings menu KAction *mActionConfigResources; KAction *mActionConfigKAddressbook; KAction *mActionConfigShortcuts; KAction *mActionConfigureToolbars; KAction *mActionKeyBindings; KToggleAction *mActionJumpBar; KToggleAction *mActionDetails; KAction *mActionWhoAmI; KAction *mActionCategories; KAction *mActionEditCategories; KAction *mActionManageCategories; KAction *mActionAboutKAddressbook; KAction *mActionLicence; KAction *mActionFaq; KAction *mActionWN; KAction *mActionSyncHowto; KAction *mActionKdeSyncHowto; KAction *mActionMultiSyncHowto; KAction *mActionDeleteView; QPopupMenu *viewMenu; QPopupMenu *filterMenu; QPopupMenu *settingsMenu; QPopupMenu *changeMenu; QPopupMenu *beamMenu; //US QAction *mActionSave; QPopupMenu *ImportMenu; QPopupMenu *ExportMenu; //LR additional methods KAction *mActionRemoveVoice; + KAction *mActionSetFormattedName; KAction * mActionImportOL; #ifndef KAB_EMBEDDED KAddressBookService *mAddressBookService; #endif //KAB_EMBEDDED class KABCorePrivate; KABCorePrivate *d; //US bool mBlockSaveFlag; #ifdef KAB_EMBEDDED KAddressBookMain *mMainWindow; // should be the same like mGUIClient #endif //KAB_EMBEDDED //this are the overwritten callbackmethods from the syncinterface virtual bool sync(KSyncManager* manager, QString filename, int mode); virtual bool syncExternal(KSyncManager* manager, QString resource); virtual void removeSyncInfo( QString syncProfile); bool syncPhone(); void message( QString m ); // LR ******************************* // sync stuff! QString sentSyncFile(); QPopupMenu *syncMenu; KSyncManager* syncManager; int mGlobalSyncMode; bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); KABC::Addressee getLastSyncAddressee(); QDateTime mLastAddressbookSync; int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); // ********************* diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp index db123da..a2095d4 100644 --- a/kaddressbook/kabprefs.cpp +++ b/kaddressbook/kabprefs.cpp @@ -31,65 +31,65 @@ #include <stdlib.h> #include <libkdepim/kpimglobalprefs.h> #include <kconfig.h> #include <klocale.h> #include <kstaticdeleter.h> //US#include <kdebug.h> // defines kdDebug() #include "kabprefs.h" #ifdef DESKTOP_VERSION #include <qapplication.h> #endif KABPrefs *KABPrefs::sInstance = 0; static KStaticDeleter<KABPrefs> staticDeleterAB; KABPrefs::KABPrefs() : KPimPrefs("kaddressbookrc") { mDetailsFont = QFont("helvetica",12); KPrefs::setCurrentGroup( "Views" ); addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); KPrefs::setCurrentGroup( "General" ); addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); #ifdef KAB_EMBEDDED addItemBool("AskForQuit",&mAskForQuit,true); addItemBool("ToolBarHor",&mToolBarHor, true ); addItemBool("ToolBarUp",&mToolBarUp, false ); - addItemBool("SearchWithReturn",&mSearchWithReturn, true ); + addItemBool("SearchWithReturn",&mSearchWithReturn, false ); addItemFont("DetailsFont",&mDetailsFont); #endif //KAB_EMBEDDED KPrefs::setCurrentGroup( "MainWindow" ); bool m_visible = false; #ifdef DESKTOP_VERSION m_visible = true; #endif addItemBool( "FullMenuBarVisible", &mFullMenuBarVisible, m_visible ); addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); addItemIntList( "DetailsSplitter", &mDetailsSplitter ); addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); KPrefs::setCurrentGroup( "Extensions_General" ); QStringList defaultExtensions; defaultExtensions << "merge"; defaultExtensions << "distribution_list_editor"; addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); KPrefs::setCurrentGroup( "Views" ); QString defaultView = i18n( "Default Table View" ); addItemString( "CurrentView", &mCurrentView, defaultView ); addItemStringList( "ViewNames", &mViewNames, defaultView ); KPrefs::setCurrentGroup( "Filters" ); addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); diff --git a/kaddressbook/kcmconfigs/addresseewidget.cpp b/kaddressbook/kcmconfigs/addresseewidget.cpp index eb5bdd9..168d39e 100644 --- a/kaddressbook/kcmconfigs/addresseewidget.cpp +++ b/kaddressbook/kcmconfigs/addresseewidget.cpp @@ -189,55 +189,50 @@ AddresseeWidget::AddresseeWidget( QWidget *parent, const char *name ) } else { layout = new QGridLayout( this, 2, 3, KDialog::marginHint(), KDialog::spacingHint() ); layout->addWidget( mPrefix, 0, 0 ); layout->addWidget( mInclusion, 0, 1 ); layout->addWidget( mSuffix, 0, 2 ); layout->addWidget( label, 1, 0 ); layout->addMultiCellWidget( mFormattedNameCombo, 1, 1, 1, 2 ); } connect( mPrefix, SIGNAL( modified() ), SIGNAL( modified() ) ); connect( mInclusion, SIGNAL( modified() ), SIGNAL( modified() ) ); connect( mSuffix, SIGNAL( modified() ), SIGNAL( modified() ) ); connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SIGNAL( modified() ) ); } AddresseeWidget::~AddresseeWidget() { } void AddresseeWidget::restoreSettings() { KConfig config( locateLocal("config", "kabcrc") ); config.setGroup( "General" ); mPrefix->setNameParts( config.readListEntry( "Prefixes" ) ); mInclusion->setNameParts( config.readListEntry( "Inclusions" ) ); mSuffix->setNameParts( config.readListEntry( "Suffixes" ) ); - - KConfig cfg( locateLocal("config","kaddressbookrc") ); - cfg.setGroup( "General" ); - mFormattedNameCombo->setCurrentItem( cfg.readNumEntry( "FormattedNameType", 1 ) ); + mFormattedNameCombo->setCurrentItem( config.readNumEntry( "FormattedNameType", 1 ) ); } void AddresseeWidget::saveSettings() { + qDebug("AddresseeWidget::saveSettings() "); KConfig config( locateLocal("config","kabcrc") ); config.setGroup( "General" ); config.writeEntry( "Prefixes", mPrefix->nameParts() ); config.writeEntry( "Inclusions", mInclusion->nameParts() ); config.writeEntry( "Suffixes", mSuffix->nameParts() ); - - KConfig cfg( locateLocal("config","kaddressbookrc") ); - cfg.setGroup( "General" ); - cfg.writeEntry( "FormattedNameType", mFormattedNameCombo->currentItem() ); + config.writeEntry( "FormattedNameType", mFormattedNameCombo->currentItem() ); } #ifndef KAB_EMBEDDED #include "addresseewidget.moc" #endif //KAB_EMBEDDED diff --git a/kaddressbook/nameeditdialog.cpp b/kaddressbook/nameeditdialog.cpp index 8213c2b..f5dba0f 100644 --- a/kaddressbook/nameeditdialog.cpp +++ b/kaddressbook/nameeditdialog.cpp @@ -196,80 +196,82 @@ QString NameEditDialog::givenName() const QString NameEditDialog::prefix() const { return mPrefixCombo->currentText(); } QString NameEditDialog::suffix() const { return mSuffixCombo->currentText(); } QString NameEditDialog::additionalName() const { return mAdditionalNameEdit->text(); } QString NameEditDialog::customFormattedName() const { return mFormattedNameEdit->text(); } int NameEditDialog::formattedNameType() const { return mFormattedNameCombo->currentItem(); } bool NameEditDialog::changed() const { return mChanged; } QString NameEditDialog::formattedName( const KABC::Addressee &addr, int type ) { + QString retval; switch ( type ) { case SimpleName: - return addr.givenName() + " " + addr.familyName(); + retval = addr.givenName() + " " + addr.familyName(); break; case FullName: - return addr.prefix() + " " + addr.givenName() + " " + + retval =addr.prefix() + " " + addr.givenName() + " " + addr.additionalName() + " " + addr.familyName() + " " + addr.suffix(); break; case ReverseName: - return addr.familyName() + ", " + addr.givenName(); + retval = addr.familyName() + ", " + addr.givenName(); break; default: return ""; break; } + return retval.stripWhiteSpace (); } void NameEditDialog::parseBoxChanged( bool value ) { //AddresseeConfig::instance()->setUid( addr.uid() ); AddresseeConfig::instance()->setAutomaticNameParsing( value ); } void NameEditDialog::typeChanged( int pos ) { mFormattedNameEdit->setEnabled( pos == 0 ); } void NameEditDialog::modified() { mChanged = true; } void NameEditDialog::updateTypeCombo() { KABC::Addressee addr; addr.setPrefix( mPrefixCombo->currentText() ); addr.setGivenName( mGivenNameEdit->text() ); addr.setAdditionalName( mAdditionalNameEdit->text() ); addr.setFamilyName( mFamilyNameEdit->text() ); addr.setSuffix( mSuffixCombo->currentText() ); int pos = mFormattedNameCombo->currentItem(); mFormattedNameCombo->clear(); mFormattedNameCombo->insertItem( i18n( "Custom" ) ); mFormattedNameCombo->insertItem( formattedName( addr, SimpleName ) ); |