-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 | 3 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 81 | ||||
-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, 106 insertions, 20 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 @@ -8,16 +8,21 @@ Fixed a bug in sorting start date for recurring events in list view. 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. (They are not changed in KDE itself, of course). diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp index 3397e06..c6993e9 100644 --- a/kaddressbook/addresseeeditorwidget.cpp +++ b/kaddressbook/addresseeeditorwidget.cpp @@ -976,21 +976,21 @@ void AddresseeEditorWidget::load() 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; @@ -1180,16 +1180,18 @@ bool AddresseeEditorWidget::dirty() 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 { diff --git a/kaddressbook/extensionmanager.cpp b/kaddressbook/extensionmanager.cpp index 98561dc..efbdf17 100644 --- a/kaddressbook/extensionmanager.cpp +++ b/kaddressbook/extensionmanager.cpp @@ -53,16 +53,17 @@ ExtensionManager::ExtensionManager( KABCore *core, QWidget *parent, 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() { @@ -153,17 +154,17 @@ void ExtensionManager::createExtensionWidgets() 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() ); @@ -175,24 +176,24 @@ void ExtensionManager::createExtensionWidgets() 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 ) { diff --git a/kaddressbook/filter.cpp b/kaddressbook/filter.cpp index b0d04ca..39d2ae4 100644 --- a/kaddressbook/filter.cpp +++ b/kaddressbook/filter.cpp @@ -175,27 +175,28 @@ Filter::List Filter::restore( KConfig *config, QString baseGroup ) { KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); f.restore( config ); } list.append( f ); } + 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 @@ -146,16 +146,17 @@ $Id$ #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 @@ -191,16 +192,51 @@ class KABCatPrefs : public QDialog 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 ) { @@ -1143,31 +1179,37 @@ void KABCore::setModified( bool modified ) 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() { @@ -1991,16 +2033,19 @@ void KABCore::initActions() "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(), @@ -2131,16 +2176,17 @@ void KABCore::addActionsManually() 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 ); @@ -2297,21 +2343,52 @@ void KABCore::removeVoice() 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() ); } diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 85ffbdb..0d5891e 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -273,16 +273,17 @@ class KABCore : public QWidget, public KSyncInterface */ 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(); @@ -368,16 +369,17 @@ class KABCore : public QWidget, public KSyncInterface 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(); @@ -472,16 +474,17 @@ class KABCore : public QWidget, public KSyncInterface 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; diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp index db123da..a2095d4 100644 --- a/kaddressbook/kabprefs.cpp +++ b/kaddressbook/kabprefs.cpp @@ -55,17 +55,17 @@ KABPrefs::KABPrefs() 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 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 @@ -213,31 +213,26 @@ 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 @@ -220,32 +220,34 @@ int NameEditDialog::formattedNameType() const 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 ); } |