-rw-r--r-- | bin/kdepim/WhatsNew.txt | 5 | ||||
-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 |
9 files changed, 118 insertions, 32 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index ff87423..5be1d28 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt @@ -10,12 +10,17 @@ KA/Pi: All fields search does now actually search all the (possible) fields, not only those listed in the contact list. Made is possible to inline a picture in a vcard on the Z. This was only possible on the desktop, now is it possible on the Z as well. Fixed of missing save settings after filter configuration. Made saving of addressbook much faster. +Fixed extension widget layout problem. +Fixed saving of default formatted name settings. +Fixed formatted name handling in edit dialog. +Added an option for changing formatted names of many contacts +(menu: File - Change - Set formatted name). QWhatsThis was not working on the Z ( only black rectangle was shown). This is Fixed. KDE-Sync: Now readonly KDE resources are synced as well. diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp index 3397e06..c6993e9 100644 --- a/kaddressbook/addresseeeditorwidget.cpp +++ b/kaddressbook/addresseeeditorwidget.cpp @@ -978,17 +978,17 @@ void AddresseeEditorWidget::load() 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; @@ -1182,12 +1182,14 @@ bool AddresseeEditorWidget::dirty() } 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 ); diff --git a/kaddressbook/extensionmanager.cpp b/kaddressbook/extensionmanager.cpp index 98561dc..efbdf17 100644 --- a/kaddressbook/extensionmanager.cpp +++ b/kaddressbook/extensionmanager.cpp @@ -55,12 +55,13 @@ ExtensionManager::ExtensionManager( KABCore *core, QWidget *parent, mActionExtensions->plug( settingsmenu ); connect( mActionExtensions, SIGNAL( activated( int ) ), SLOT( setActiveExtension( int ) ) ); mWidgetBox = new QWidget( viewport() ); + new QHBoxLayout (mWidgetBox ); addChild( mWidgetBox ); setResizePolicy(AutoOneFit); createExtensionWidgets(); hide(); } @@ -155,13 +156,13 @@ void ExtensionManager::createExtensionWidgets() 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& ) ) ); @@ -177,20 +178,20 @@ void ExtensionManager::createExtensionWidgets() 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; diff --git a/kaddressbook/filter.cpp b/kaddressbook/filter.cpp index b0d04ca..39d2ae4 100644 --- a/kaddressbook/filter.cpp +++ b/kaddressbook/filter.cpp @@ -177,23 +177,24 @@ Filter::List Filter::restore( KConfig *config, QString baseGroup ) 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; diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index e14e579..c6288fa 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -148,12 +148,13 @@ $Id$ #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 @@ -193,12 +194,47 @@ class KABCatPrefs : public QDialog 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 ) : @@ -1143,13 +1179,18 @@ void KABCore::setModified( bool modified ) 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 @@ -1160,13 +1201,14 @@ void KABCore::contactModified( const KABC::Addressee &addr ) 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() { @@ -1538,13 +1580,13 @@ void KABCore::openConfigDialog() 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 @@ -1993,12 +2035,15 @@ void KABCore::initActions() 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" ); @@ -2133,12 +2178,13 @@ void KABCore::addActionsManually() 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(); @@ -2299,17 +2345,48 @@ void KABCore::removeVoice() 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() ); diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 85ffbdb..0d5891e 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -275,12 +275,13 @@ class KABCore : public QWidget, public KSyncInterface /** 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 ); @@ -370,12 +371,13 @@ class KABCore : public QWidget, public KSyncInterface 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(); @@ -474,12 +476,13 @@ class KABCore : public QWidget, public KSyncInterface 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 diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp index db123da..a2095d4 100644 --- a/kaddressbook/kabprefs.cpp +++ b/kaddressbook/kabprefs.cpp @@ -57,13 +57,13 @@ KABPrefs::KABPrefs() 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" ); 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 @@ -215,29 +215,24 @@ 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 @@ -222,28 +222,30 @@ 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 ); |