summaryrefslogtreecommitdiffabout
path: root/kaddressbook/features/mergewidget.cpp
Unidiff
Diffstat (limited to 'kaddressbook/features/mergewidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/features/mergewidget.cpp14
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
@@ -14,24 +14,26 @@
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26//Added by qt3to4:
27#include <Q3GridLayout>
26 28
27#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
28#include <kaccelmanager.h> 30#include <kaccelmanager.h>
29#endif //KAB_EMBEDDED 31#endif //KAB_EMBEDDED
30 32
31#include <kdebug.h> 33#include <kdebug.h>
32#include <klistview.h> 34#include <klistview.h>
33#include <klocale.h> 35#include <klocale.h>
34#include <kglobal.h> 36#include <kglobal.h>
35#include <kmessagebox.h> 37#include <kmessagebox.h>
36 38
37#include <kabc/addressbook.h> 39#include <kabc/addressbook.h>
@@ -54,29 +56,29 @@ class MergeFactory : public ExtensionFactory
54 return "merge"; 56 return "merge";
55 } 57 }
56}; 58};
57 59
58extern "C" { 60extern "C" {
59 void *init_libkaddrbk_merge() 61 void *init_libkaddrbk_merge()
60 { 62 {
61 return ( new MergeFactory ); 63 return ( new MergeFactory );
62 } 64 }
63} 65}
64#endif //KAB_EMBEDDED 66#endif //KAB_EMBEDDED
65 67
66class ContactItem : public QListViewItem 68class ContactItem : public Q3ListViewItem
67{ 69{
68 public: 70 public:
69 ContactItem( KListView *parent, const KABC::Addressee &addressee ) 71 ContactItem( KListView *parent, const KABC::Addressee &addressee )
70 : QListViewItem( parent ), mAddressee( addressee ) 72 : Q3ListViewItem( parent ), mAddressee( addressee )
71 { 73 {
72 KABC::Field::List fieldList = KABC::Field::defaultFields(); 74 KABC::Field::List fieldList = KABC::Field::defaultFields();
73 KABC::Field::List::ConstIterator it; 75 KABC::Field::List::ConstIterator it;
74 76
75 int i = 0; 77 int i = 0;
76 for ( it = fieldList.begin(); it != fieldList.end(); ++it ) 78 for ( it = fieldList.begin(); it != fieldList.end(); ++it )
77 setText( i++, (*it)->value( mAddressee ) ); 79 setText( i++, (*it)->value( mAddressee ) );
78 } 80 }
79 81
80 KABC::Addressee addressee() const 82 KABC::Addressee addressee() const
81 { 83 {
82 return mAddressee; 84 return mAddressee;
@@ -85,25 +87,25 @@ class ContactItem : public QListViewItem
85 private: 87 private:
86 KABC::Addressee mAddressee; 88 KABC::Addressee mAddressee;
87}; 89};
88 90
89MergeWidget::MergeWidget( KABCore *core, QWidget *parent, const char *name ) 91MergeWidget::MergeWidget( KABCore *core, QWidget *parent, const char *name )
90 : ExtensionWidget( core, parent, name ), mBlockUpdate( false ) 92 : ExtensionWidget( core, parent, name ), mBlockUpdate( false )
91{ 93{
92#ifdef KAB_EMBEDDED 94#ifdef KAB_EMBEDDED
93 if (KGlobal::getOrientation() == KGlobal::Portrait) 95 if (KGlobal::getOrientation() == KGlobal::Portrait)
94 parent->setMaximumSize( KGlobal::getDesktopWidth() , 180); 96 parent->setMaximumSize( KGlobal::getDesktopWidth() , 180);
95#endif //KAB_EMBEDDED 97#endif //KAB_EMBEDDED
96 98
97 QGridLayout *topLayout = new QGridLayout( this, 3, 2, KDialog::marginHint(), 99 Q3GridLayout *topLayout = new Q3GridLayout( this, 3, 2, KDialog::marginHint(),
98 KDialog::spacingHint() ); 100 KDialog::spacingHint() );
99 101
100 mContactView = new KListView( this ); 102 mContactView = new KListView( this );
101 KABC::Field::List fieldList = KABC::Field::defaultFields(); 103 KABC::Field::List fieldList = KABC::Field::defaultFields();
102 KABC::Field::List::ConstIterator it; 104 KABC::Field::List::ConstIterator it;
103 105
104 for ( it = fieldList.begin(); it != fieldList.end(); ++it ) 106 for ( it = fieldList.begin(); it != fieldList.end(); ++it )
105 mContactView->addColumn( (*it)->label() ); 107 mContactView->addColumn( (*it)->label() );
106 108
107 mContactView->setEnabled( false ); 109 mContactView->setEnabled( false );
108 mContactView->setAllColumnsShowFocus( true ); 110 mContactView->setAllColumnsShowFocus( true );
109 topLayout->addMultiCellWidget( mContactView, 0, 2, 0, 0 ); 111 topLayout->addMultiCellWidget( mContactView, 0, 2, 0, 0 );
@@ -205,25 +207,25 @@ void MergeWidget::mergeAndRemove()
205 if ( !item ) 207 if ( !item )
206 return; 208 return;
207 209
208 QString oldUID = item->addressee().uid(); 210 QString oldUID = item->addressee().uid();
209 211
210 doMerge( item->addressee() ); 212 doMerge( item->addressee() );
211 213
212 KABC::Addressee::List retval; 214 KABC::Addressee::List retval;
213 retval << mMasterAddressee; 215 retval << mMasterAddressee;
214 emit modified( retval ); 216 emit modified( retval );
215 217
216 mBlockUpdate = true; 218 mBlockUpdate = true;
217 core()->deleteContacts( oldUID ); 219 core()->deleteContacts( QStringList(oldUID) );
218 core()->setContactSelected( mMasterAddressee.uid() ); 220 core()->setContactSelected( mMasterAddressee.uid() );
219 mBlockUpdate = false; 221 mBlockUpdate = false;
220 222
221 updateView(); 223 updateView();
222} 224}
223 225
224void MergeWidget::merge() 226void MergeWidget::merge()
225{ 227{
226#ifndef KAB_EMBEDDED 228#ifndef KAB_EMBEDDED
227 ContactItem *item = dynamic_cast<ContactItem*>( mContactView->currentItem() ); 229 ContactItem *item = dynamic_cast<ContactItem*>( mContactView->currentItem() );
228#else //KAB_EMBEDDED 230#else //KAB_EMBEDDED
229 ContactItem *item = (ContactItem*)( mContactView->currentItem() ); 231 ContactItem *item = (ContactItem*)( mContactView->currentItem() );
@@ -360,15 +362,15 @@ void MergeWidget::doMerge( const KABC::Addressee &addr )
360 mMasterAddressee.setUrl( addr.url() ); 362 mMasterAddressee.setUrl( addr.url() );
361 363
362 // X- 364 // X-
363 QStringList customs = addr.customs(); 365 QStringList customs = addr.customs();
364 QStringList masterCustoms = mMasterAddressee.customs(); 366 QStringList masterCustoms = mMasterAddressee.customs();
365 QStringList newCustoms( masterCustoms ); 367 QStringList newCustoms( masterCustoms );
366 for ( it = customs.begin(); it != customs.end(); ++it ) 368 for ( it = customs.begin(); it != customs.end(); ++it )
367 if ( !masterCustoms.contains( *it ) ) 369 if ( !masterCustoms.contains( *it ) )
368 newCustoms.append( *it ); 370 newCustoms.append( *it );
369 mMasterAddressee.setCustoms( newCustoms ); 371 mMasterAddressee.setCustoms( newCustoms );
370} 372}
371 373
372#ifndef KAB_EMBEDDED 374#ifndef KAB_EMBEDDED_
373#include "mergewidget.moc" 375#include "moc_mergewidget.cpp"
374#endif //KAB_EMBEDDED 376#endif //KAB_EMBEDDED