summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
authorzautrix <zautrix>2005-01-14 19:02:53 (UTC)
committer zautrix <zautrix>2005-01-14 19:02:53 (UTC)
commit620f8de219ee34c209960f02c8296c0568dd5d8b (patch) (side-by-side diff)
tree772170b3b9ceaf8c204e2bdd9cbb333427de30cd /kaddressbook/kabcore.cpp
parent61c95ce0295f1397db6499c5b468a9fb3d32a0f4 (diff)
downloadkdepimpi-620f8de219ee34c209960f02c8296c0568dd5d8b.zip
kdepimpi-620f8de219ee34c209960f02c8296c0568dd5d8b.tar.gz
kdepimpi-620f8de219ee34c209960f02c8296c0568dd5d8b.tar.bz2
formatted name fixes
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp87
1 files changed, 82 insertions, 5 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index e14e579..c6288fa 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -151,6 +151,7 @@ $Id$
#include "jumpbuttonbar.h"
#include "extensionmanager.h"
#include "addresseeconfig.h"
+#include "nameeditdialog.h"
#include <kcmultidialog.h>
#ifdef _WIN32_
@@ -196,6 +197,41 @@ 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
@@ -1146,7 +1182,12 @@ 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;
@@ -1163,7 +1204,8 @@ void KABCore::contactModified( const KABC::Addressee &addr )
UndoStack::instance()->push( command );
RedoStack::instance()->clear();
- mDetails->setAddressee( addr );
+ if ( updateDetails )
+ mDetails->setAddressee( addr );
setModified( true );
}
@@ -1541,7 +1583,7 @@ void KABCore::openConfigDialog()
ConfigureDialog->addModule(kdelibcfg );
connect( ConfigureDialog, SIGNAL( applyClicked() ),
- this, SLOT( configurationChanged() ) );
+ this, SLOT( configurationChanged() ) );
connect( ConfigureDialog, SIGNAL( okClicked() ),
this, SLOT( configurationChanged() ) );
saveSettings();
@@ -1996,6 +2038,9 @@ void KABCore::initActions()
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(),
@@ -2136,6 +2181,7 @@ void KABCore::addActionsManually()
editMenu->insertSeparator();
mActionSelectAll->plug( editMenu );
+ mActionSetFormattedName->plug( changeMenu );
mActionRemoveVoice->plug( changeMenu );
// settings menu
//US special menuentry to configure the addressbook resources. On KDE
@@ -2302,11 +2348,42 @@ void KABCore::removeVoice()
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()
{