summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp107
-rw-r--r--kaddressbook/kabcore.h2
2 files changed, 106 insertions, 3 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 83027ac..9505a23 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -110,76 +110,114 @@ $Id$
#include <qmenubar.h>
#endif
#endif // KAB_EMBEDDED
#include "kcmconfigs/kcmkabconfig.h"
#include "kcmconfigs/kcmkdepimconfig.h"
#include "kpimglobalprefs.h"
#include "externalapphandler.h"
#include <kresources/selectdialog.h>
#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 <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 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 );
@@ -935,81 +973,84 @@ void KABCore::pasteContacts( KABC::Addressee::List &list )
KABC::Addressee::List::Iterator it;
for ( it = list.begin(); it != list.end(); ++it )
(*it).setResource( resource );
PwPasteCommand *command = new PwPasteCommand( this, list );
UndoStack::instance()->push( command );
RedoStack::instance()->clear();
setModified( true );
}
void KABCore::setWhoAmI()
{
KABC::Addressee::List addrList = mViewManager->selectedAddressees();
if ( addrList.count() > 1 ) {
KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
return;
}
QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
}
-
+void KABCore::editCategories()
+{
+ KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
+ dlg.exec();
+}
void KABCore::setCategories()
{
KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
if ( !dlg.exec() ) {
message( i18n("Setting categories cancelled") );
return;
}
bool merge = false;
QString msg = i18n( "Merge with existing categories?" );
if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
merge = true;
message( i18n("Setting categories ... please wait!") );
QStringList categories = dlg.selectedCategories();
QStringList uids = mViewManager->selectedUids();
QStringList::Iterator it;
for ( it = uids.begin(); it != uids.end(); ++it ) {
KABC::Addressee addr = mAddressBook->findByUid( *it );
if ( !addr.isEmpty() ) {
if ( !merge )
addr.setCategories( categories );
else {
QStringList addrCategories = addr.categories();
QStringList::Iterator catIt;
for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
if ( !addrCategories.contains( *catIt ) )
addrCategories.append( *catIt );
}
addr.setCategories( addrCategories );
}
-
mAddressBook->insertAddressee( addr );
}
}
if ( uids.count() > 0 )
setModified( true );
message( i18n("Setting categories completed!") );
}
void KABCore::setSearchFields( const KABC::Field::List &fields )
{
mIncSearchWidget->setFields( fields );
}
void KABCore::incrementalSearch( const QString& text )
{
mViewManager->doSearch( text, mIncSearchWidget->currentField() );
}
void KABCore::setModified()
{
setModified( true );
}
@@ -1861,48 +1902,51 @@ void KABCore::initActions()
"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" );
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,
@@ -2029,48 +2073,49 @@ void KABCore::addActionsManually()
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();
mActionBR->plug(settingsMenu );
settingsMenu->insertSeparator();
mActionWhoAmI->plug( settingsMenu );
+ mActionEditCategories->plug( settingsMenu );
mActionCategories->plug( settingsMenu );
mActionManageCategories->plug( settingsMenu );
mActionWN->plug( helpMenu );
mActionSyncHowto->plug( helpMenu );
mActionKdeSyncHowto->plug( helpMenu );
mActionMultiSyncHowto->plug( helpMenu );
mActionFaq->plug( helpMenu );
mActionLicence->plug( helpMenu );
mActionAboutKAddressbook->plug( helpMenu );
if (KGlobal::getDesktopSize() > KGlobal::Small ) {
mActionSave->plug( tb );
mViewManager->getFilterAction()->plug ( tb);
if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
mActionUndo->plug( tb );
mActionDelete->plug( tb );
mActionRedo->plug( tb );
}
} else {
mActionSave->plug( tb );
tb->enableMoving(false);
@@ -2086,49 +2131,105 @@ void KABCore::addActionsManually()
mIncSearchWidget = new IncSearchWidget( tb );
connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
SLOT( incrementalSearch( const QString& ) ) );
mJumpButtonBar = new JumpButtonBar( this, this );
//US topLayout->addWidget( mJumpButtonBar );
this->layout()->add( mJumpButtonBar );
*/
#endif //KAB_EMBEDDED
mActionExport2phone->plug( ExportMenu );
connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
syncManager->fillSyncMenu();
}
void KABCore::showLicence()
{
KApplication::showLicence();
}
void KABCore::manageCategories( )
{
-
+ KABCatPrefs* cp = new KABCatPrefs();
+ cp->show();
+ int w =cp->sizeHint().width() ;
+ int h = cp->sizeHint().height() ;
+ int dw = QApplication::desktop()->width();
+ int dh = QApplication::desktop()->height();
+ cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
+ if ( !cp->exec() ) {
+ delete cp;
+ return;
+ }
+ int count = 0;
+ message( i18n("Please wait, processing categories..."));
+ if ( cp->addCat() ) {
+ KABC::AddressBook::Iterator it;
+ QStringList catList = KABPrefs::instance()->mCustomCategories;
+ for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
+ QStringList catIncList = (*it).categories();
+ int i;
+ for( i = 0; i< catIncList.count(); ++i ) {
+ if ( !catList.contains (catIncList[i])) {
+ catList.append( catIncList[i] );
+ //qDebug("add cat %s ", catIncList[i].latin1());
+ ++count;
+ }
+ }
+ }
+ catList.sort();
+ KABPrefs::instance()->mCustomCategories = catList;
+ KABPrefs::instance()->writeConfig();
+ message(QString::number( count )+ i18n(" categories added to list! "));
+ } else {
+ QStringList catList = KABPrefs::instance()->mCustomCategories;
+ QStringList catIncList;
+ QStringList newCatList;
+ KABC::AddressBook::Iterator it;
+ for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
+ QStringList catIncList = (*it).categories();
+ 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();
+ mDetails->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 = mViewManager->selectedAddressees();
KABC::Addressee::List::Iterator it;
for ( it = list.begin(); it != list.end(); ++it ) {
if ( (*it).removeVoice() )
contactModified((*it) );
}
}
void KABCore::clipboardDataChanged()
{
if ( mReadWrite )
mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index bf5398b..d2ee45d 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -223,48 +223,49 @@ class KABCore : public QWidget, public KSyncInterface
/**
Paste contacts from clipboard into the address book.
*/
void pasteContacts();
/**
Paste given contacts into the address book.
@param list The list of addressee, which shall be pasted.
*/
void pasteContacts( KABC::Addressee::List &list );
/**
Sets the whoAmI contact, that is used by many other programs to
get personal information about the current user.
*/
void setWhoAmI();
/**
Displays the category dialog and applies the result to all
selected contacts.
*/
void setCategories();
void manageCategories();
+ void editCategories();
/**
Sets the field list of the Incremental Search Widget.
*/
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.
*/
@@ -431,48 +432,49 @@ class KABCore : public QWidget, public KSyncInterface
KAction *mActionMailVCard;
KAction *mActionBeamVCard;
KAction *mActionQuit;
//US edit menu
KAction *mActionCopy;
KAction *mActionCut;
KAction *mActionPaste;
KAction *mActionSelectAll;
KAction *mActionUndo;
KAction *mActionRedo;
KAction *mActionDelete;
//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;
//US QAction *mActionSave;
QPopupMenu *ImportMenu;
QPopupMenu *ExportMenu;
//LR additional methods
KAction *mActionRemoveVoice;
KAction * mActionImportOL;
#ifndef KAB_EMBEDDED
KAddressBookService *mAddressBookService;