Diffstat (limited to 'kaddressbook/features/mergewidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kaddressbook/features/mergewidget.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/kaddressbook/features/mergewidget.cpp b/kaddressbook/features/mergewidget.cpp index 2476e42..1becc2f 100644 --- a/kaddressbook/features/mergewidget.cpp +++ b/kaddressbook/features/mergewidget.cpp @@ -1,129 +1,131 @@ /* This file is part of KAddressBook. Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qlayout.h> #include <qpushbutton.h> +//Added by qt3to4: +#include <Q3GridLayout> #ifndef KAB_EMBEDDED #include <kaccelmanager.h> #endif //KAB_EMBEDDED #include <kdebug.h> #include <klistview.h> #include <klocale.h> #include <kglobal.h> #include <kmessagebox.h> #include <kabc/addressbook.h> #include "kabcore.h" #include "mergewidget.h" #ifndef KAB_EMBEDDED class MergeFactory : public ExtensionFactory { public: ExtensionWidget *extension( KABCore *core, QWidget *parent, const char *name ) { return new MergeWidget( core, parent, name ); } QString identifier() const { return "merge"; } }; extern "C" { void *init_libkaddrbk_merge() { return ( new MergeFactory ); } } #endif //KAB_EMBEDDED -class ContactItem : public QListViewItem +class ContactItem : public Q3ListViewItem { public: ContactItem( KListView *parent, const KABC::Addressee &addressee ) - : QListViewItem( parent ), mAddressee( addressee ) + : Q3ListViewItem( parent ), mAddressee( addressee ) { KABC::Field::List fieldList = KABC::Field::defaultFields(); KABC::Field::List::ConstIterator it; int i = 0; for ( it = fieldList.begin(); it != fieldList.end(); ++it ) setText( i++, (*it)->value( mAddressee ) ); } KABC::Addressee addressee() const { return mAddressee; } private: KABC::Addressee mAddressee; }; MergeWidget::MergeWidget( KABCore *core, QWidget *parent, const char *name ) : ExtensionWidget( core, parent, name ), mBlockUpdate( false ) { #ifdef KAB_EMBEDDED if (KGlobal::getOrientation() == KGlobal::Portrait) parent->setMaximumSize( KGlobal::getDesktopWidth() , 180); #endif //KAB_EMBEDDED - QGridLayout *topLayout = new QGridLayout( this, 3, 2, KDialog::marginHint(), + Q3GridLayout *topLayout = new Q3GridLayout( this, 3, 2, KDialog::marginHint(), KDialog::spacingHint() ); mContactView = new KListView( this ); KABC::Field::List fieldList = KABC::Field::defaultFields(); KABC::Field::List::ConstIterator it; for ( it = fieldList.begin(); it != fieldList.end(); ++it ) mContactView->addColumn( (*it)->label() ); mContactView->setEnabled( false ); mContactView->setAllColumnsShowFocus( true ); topLayout->addMultiCellWidget( mContactView, 0, 2, 0, 0 ); connect( mContactView, SIGNAL( selectionChanged() ), SLOT( selectionContactViewChanged() ) ); mMergeAndRemoveButton = new QPushButton( i18n( "Merge and Remove" ), this ); mMergeAndRemoveButton->setEnabled( false ); topLayout->addWidget( mMergeAndRemoveButton, 0, 1 ); connect( mMergeAndRemoveButton, SIGNAL( clicked() ), SLOT( mergeAndRemove() ) ); mMergeButton = new QPushButton( i18n( "Merge" ), this ); mMergeButton->setEnabled( false ); topLayout->addWidget( mMergeButton, 1, 1 ); connect( mMergeButton, SIGNAL( clicked() ), SLOT( merge() ) ); #ifndef KAB_EMBEDDED KAcceleratorManager::manage( this ); #endif //KAB_EMBEDDED } MergeWidget::~MergeWidget() @@ -185,65 +187,65 @@ void MergeWidget::updateView() new ContactItem( mContactView, *it ); } QString MergeWidget::title() const { return i18n( "Merge Contacts Editor" ); } QString MergeWidget::identifier() const { return "merge"; } void MergeWidget::mergeAndRemove() { #ifndef KAB_EMBEDDED ContactItem *item = dynamic_cast<ContactItem*>( mContactView->currentItem() ); #else //KAB_EMBEDDED ContactItem *item = (ContactItem*)( mContactView->currentItem() ); #endif //KAB_EMBEDDED if ( !item ) return; QString oldUID = item->addressee().uid(); doMerge( item->addressee() ); KABC::Addressee::List retval; retval << mMasterAddressee; emit modified( retval ); mBlockUpdate = true; - core()->deleteContacts( oldUID ); + core()->deleteContacts( QStringList(oldUID) ); core()->setContactSelected( mMasterAddressee.uid() ); mBlockUpdate = false; updateView(); } void MergeWidget::merge() { #ifndef KAB_EMBEDDED ContactItem *item = dynamic_cast<ContactItem*>( mContactView->currentItem() ); #else //KAB_EMBEDDED ContactItem *item = (ContactItem*)( mContactView->currentItem() ); #endif //KAB_EMBEDDED if ( !item ) return; doMerge( item->addressee() ); KABC::Addressee::List retval; retval << mMasterAddressee; emit modified( retval ); mBlockUpdate = true; core()->setContactSelected( mMasterAddressee.uid() ); mBlockUpdate = false; updateView(); } void MergeWidget::doMerge( const KABC::Addressee &addr ) { // ADR + LABEL @@ -340,35 +342,35 @@ void MergeWidget::doMerge( const KABC::Addressee &addr ) // TEL KABC::PhoneNumber::List phones = addr.phoneNumbers(); KABC::PhoneNumber::List masterPhones = mMasterAddressee.phoneNumbers(); KABC::PhoneNumber::List::ConstIterator phoneIt; for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) if ( !masterPhones.contains( *it ) ) mMasterAddressee.insertPhoneNumber( *it ); // TITLE if ( mMasterAddressee.title().isEmpty() && !addr.title().isEmpty() ) mMasterAddressee.setTitle( addr.title() ); // TZ if ( !mMasterAddressee.timeZone().isValid() && addr.timeZone().isValid() ) mMasterAddressee.setTimeZone( addr.timeZone() ); // UID // ignore UID // URL if ( mMasterAddressee.url().isEmpty() && !addr.url().isEmpty() ) mMasterAddressee.setUrl( addr.url() ); // X- QStringList customs = addr.customs(); QStringList masterCustoms = mMasterAddressee.customs(); QStringList newCustoms( masterCustoms ); for ( it = customs.begin(); it != customs.end(); ++it ) if ( !masterCustoms.contains( *it ) ) newCustoms.append( *it ); mMasterAddressee.setCustoms( newCustoms ); } -#ifndef KAB_EMBEDDED -#include "mergewidget.moc" +#ifndef KAB_EMBEDDED_ +#include "moc_mergewidget.cpp" #endif //KAB_EMBEDDED |