summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Side-by-side diff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp81
1 files changed, 79 insertions, 2 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index e14e579..c6288fa 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -142,24 +142,25 @@ $Id$
#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>
@@ -187,24 +188,59 @@ class KABCatPrefs : public QDialog
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 );
@@ -1139,39 +1175,45 @@ void KABCore::setModified( bool modified )
mViewManager->refreshView();
}
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 );
@@ -1987,24 +2029,27 @@ void KABCore::initActions()
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(),
@@ -2127,24 +2172,25 @@ void KABCore::addActionsManually()
#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 );
@@ -2293,29 +2339,60 @@ 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();