summaryrefslogtreecommitdiffabout
path: root/kaddressbook/phoneeditwidget.cpp
Unidiff
Diffstat (limited to 'kaddressbook/phoneeditwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/phoneeditwidget.cpp80
1 files changed, 58 insertions, 22 deletions
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp
index 997fc05..9e7e221 100644
--- a/kaddressbook/phoneeditwidget.cpp
+++ b/kaddressbook/phoneeditwidget.cpp
@@ -1,294 +1,330 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
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 <qlabel.h> 25#include <qlabel.h>
26#include <qtooltip.h> 26#include <qtooltip.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qcheckbox.h> 28#include <qcheckbox.h>
29#include <qstring.h> 29#include <qstring.h>
30#include <qlistbox.h> 30#include <qlistbox.h>
31#include <qlistview.h> 31#include <qlistview.h>
32#include <qbuttongroup.h> 32#include <qbuttongroup.h>
33#include <qhbox.h> 33#include <qhbox.h>
34#include <qcursor.h>
34 35
35#include <kbuttonbox.h> 36#include <kbuttonbox.h>
36#include <klistview.h> 37#include <klistview.h>
37#include <kapplication.h> 38#include <kapplication.h>
38#include <qapplication.h> 39#include <qapplication.h>
39#include <kconfig.h> 40#include <kconfig.h>
40#include <klineedit.h> 41#include <klineedit.h>
41#include <kcombobox.h> 42#include <kcombobox.h>
42#include <klocale.h> 43#include <klocale.h>
43#include <kdebug.h> 44#include <kdebug.h>
44#include <kglobal.h> 45#include <kglobal.h>
45#include <kiconloader.h> 46#include <kiconloader.h>
46 47
47#include <kabc/phonenumber.h> 48#include <kabc/phonenumber.h>
48 49
49#include "typecombo.h" 50#include "typecombo.h"
50 51
51#include "phoneeditwidget.h" 52#include "phoneeditwidget.h"
52 53
53PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) 54PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name )
54 : QScrollView(parent,name) 55 : QWidget(parent,name)
55{ 56{
56 setFrameStyle ( QFrame::Panel | QFrame::Plain ); 57 QGridLayout* gridLayout = new QGridLayout ( this, 2,2 );
57 setLineWidth ( 1 ); 58
58 setMidLineWidth ( 1 ); 59 QLabel *temp = new QLabel( "", this );
59 mw = new QWidget ( viewport() ); 60 temp->setAlignment( Qt::AlignCenter );
60 addChild(mw); 61 temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
61 setResizePolicy( AutoOneFit ); 62 gridLayout->addWidget( temp, 1, 0 );
63 QPushButton *addBut = new QPushButton ( "add", this );
64 addBut->setPixmap ( SmallIcon("plus"));
65 addBut->setMaximumSize( addBut->sizeHint().height(),addBut->sizeHint().height() );
66 connect(addBut,SIGNAL(clicked ()),SLOT(addNumber()));
67 gridLayout->addWidget( addBut, 0, 0 );
68
69 sv = new QScrollView( this );
70 sv->setFrameStyle ( QFrame::Panel | QFrame::Plain );
71 sv->setLineWidth ( 1 );
72 sv->setMidLineWidth ( 1 );
73 mw = new QWidget ( sv->viewport() );
74 sv->addChild(mw);
75 sv->setResizePolicy( QScrollView::AutoOneFit );
62 mainLayout = new QVBoxLayout ( mw ); 76 mainLayout = new QVBoxLayout ( mw );
63 mainLayout->setMargin( 2 ); 77 mainLayout->setMargin( 2 );
64 mainLayout->setSpacing( 2 ); 78 mainLayout->setSpacing( 2 );
65 QWidget* hb = new QWidget ( mw ); 79 gridLayout->addMultiCellWidget( sv, 0, 1, 1,1 );
66 mainLayout->add( hb );
67 QHBoxLayout* hbLayout = new QHBoxLayout ( hb );
68 QPushButton *addBut = new QPushButton ( "add", hb );
69 hbLayout->add( addBut );
70 addBut->setPixmap ( SmallIcon("plus"));
71 addBut->setMaximumSize( addBut->sizeHint().height(),addBut->sizeHint().height() );
72 connect(addBut,SIGNAL(clicked()),SLOT(addNumber()));
73 //QLabel * temp = new QLabel( i18n("Phone Type"), hb );
74 QLabel *temp = new QLabel( i18n("Phone Number"),hb );
75 temp->setAlignment( Qt::AlignCenter );
76 temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
77 hbLayout->add( temp );
78 setDefaults(); 80 setDefaults();
79 mTypeNumberEditList.setAutoDelete( true ); 81 mTypeNumberEditList.setAutoDelete( true );
82 mPopup = new QPopupMenu( this );
83 QStringList list = PhoneNumber::supportedTypeListNames();
84 mPopupCount = list.count();
85 int i = 0;
86 while ( i < mPopupCount ) {
87 mPopup->insertItem( list[ i ], i );
88 ++i;
89 }
90 connect(mPopup,SIGNAL(activated(int)),this,SLOT(addNumberInt( int)));
91
80} 92}
81 93
82PhoneEditWidget::~PhoneEditWidget() 94PhoneEditWidget::~PhoneEditWidget()
83{ 95{
84} 96}
85void PhoneEditWidget::setDefaults() 97void PhoneEditWidget::setDefaults()
86{ 98{
87 mTypeNumberEditList.clear(); 99 mTypeNumberEditList.clear();
88 PhoneTypeNumberEdit* edit = appendEditCombo(); 100 PhoneTypeNumberEdit* edit = appendEditCombo();
89 KABC::PhoneNumber phoneNumber; 101 KABC::PhoneNumber phoneNumber;
90 phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref ); 102 phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref );
91 edit->setPhoneNumber( phoneNumber ); 103 edit->setPhoneNumber( phoneNumber );
92 edit = appendEditCombo(); 104 edit = appendEditCombo();
93 phoneNumber.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref ); 105 phoneNumber.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref );
94 edit->setPhoneNumber( phoneNumber ); 106 edit->setPhoneNumber( phoneNumber );
95 edit = appendEditCombo(); 107 edit = appendEditCombo();
96 phoneNumber.setType( KABC::PhoneNumber::Cell ); 108 phoneNumber.setType( KABC::PhoneNumber::Cell );
97 edit->setPhoneNumber( phoneNumber ); 109 edit->setPhoneNumber( phoneNumber );
98 110
99} 111}
112void PhoneEditWidget::addNumberInt( int index )
113{
114 PhoneTypeNumberEdit* edit = appendEditCombo();
115 KABC::PhoneNumber phoneNumber;
116 phoneNumber.setType( PhoneNumber::supportedTypeList()[index] );
117 edit->setPhoneNumber( phoneNumber );
118 //verticalScrollBar()->setValue( 1024);
119 QTimer::singleShot( 0, this, SLOT ( bottomVisible() ) );
120}
121void PhoneEditWidget::bottomVisible()
122{
123 sv->setContentsPos ( 0, 1024 );
124}
100void PhoneEditWidget::addNumber() 125void PhoneEditWidget::addNumber()
101{ 126{
102 127 int i = 0;
128 while ( i < mPopupCount ) {
129 mPopup->setItemEnabled( i, true );
130 ++i;
131 }
132 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first();
133 while ( edit ) {
134 if ( edit->currentType() < mPopupCount -1 )
135 mPopup->setItemEnabled( edit->currentType(), false );
136 edit = mTypeNumberEditList.next();
137 }
138 mPopup->popup( QCursor::pos() );
103} 139}
104PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo() 140PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo()
105{ 141{
106 PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw ); 142 PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw );
107 connect ( edit, SIGNAL ( typeChange( int , int) ), this, SIGNAL ( typeChange( int , int)) ); 143 connect ( edit, SIGNAL ( typeChange( int , int) ), this, SIGNAL ( typeChange( int , int)) );
108 connect ( edit, SIGNAL ( modified() ), this, SIGNAL ( modified() ) ); 144 connect ( edit, SIGNAL ( modified() ), this, SIGNAL ( modified() ) );
109 connect ( edit, SIGNAL ( deleteMe( PhoneTypeNumberEdit* ) ), this, SLOT ( deleteEdit( PhoneTypeNumberEdit*) ) ); 145 connect ( edit, SIGNAL ( deleteMe( PhoneTypeNumberEdit* ) ), this, SLOT ( deleteEdit( PhoneTypeNumberEdit*) ) );
110 connect ( this, SIGNAL ( typeChange( int , int)), edit, SLOT ( typeExternalChanged( int, int)) ); 146 connect ( this, SIGNAL ( typeChange( int , int)), edit, SLOT ( typeExternalChanged( int, int)) );
111 147
112 mainLayout->add( edit ); 148 mainLayout->add( edit );
113 mTypeNumberEditList.append( edit ); 149 mTypeNumberEditList.append( edit );
114 return edit; 150 return edit;
115} 151}
116 152
117void PhoneEditWidget::deleteEdit( PhoneTypeNumberEdit* ew ) 153void PhoneEditWidget::deleteEdit( PhoneTypeNumberEdit* ew )
118{ 154{
119 mPendingDelete = ew; 155 mPendingDelete = ew;
120 QTimer::singleShot( 0, this, SLOT ( pendingDelete() ) ); 156 QTimer::singleShot( 0, this, SLOT ( pendingDelete() ) );
121} 157}
122void PhoneEditWidget::pendingDelete() 158void PhoneEditWidget::pendingDelete()
123{ 159{
124 mTypeNumberEditList.removeRef( mPendingDelete ); 160 mTypeNumberEditList.removeRef( mPendingDelete );
125 emit modified(); 161 emit modified();
126} 162}
127 163
128void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li ) 164void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li )
129{ 165{
130 if ( li.isEmpty() ) { 166 if ( li.isEmpty() ) {
131 setDefaults(); 167 setDefaults();
132 return; 168 return;
133 } 169 }
134 mTypeNumberEditList.clear(); 170 mTypeNumberEditList.clear();
135 KABC::PhoneNumber::List::Iterator it; 171 KABC::PhoneNumber::List::Iterator it;
136 KABC::PhoneNumber::List list = li; 172 KABC::PhoneNumber::List list = li;
137 PhoneTypeNumberEdit* edit = 0;//mTypeNumberEditList.first(); 173 PhoneTypeNumberEdit* edit = 0;//mTypeNumberEditList.first();
138 for ( it = list.begin(); it != list.end(); ++it ) { 174 for ( it = list.begin(); it != list.end(); ++it ) {
139 if ( edit ) { 175 if ( edit ) {
140 edit->setPhoneNumber( (*it ) ); 176 edit->setPhoneNumber( (*it ) );
141 edit = mTypeNumberEditList.next(); 177 edit = mTypeNumberEditList.next();
142 } else { 178 } else {
143 PhoneTypeNumberEdit* editNew = appendEditCombo(); 179 PhoneTypeNumberEdit* editNew = appendEditCombo();
144 editNew->setPhoneNumber( (*it ) ); 180 editNew->setPhoneNumber( (*it ) );
145 } 181 }
146 } 182 }
147 while ( edit ) { 183 while ( edit ) {
148 edit->hide(); 184 edit->hide();
149 edit = mTypeNumberEditList.next(); 185 edit = mTypeNumberEditList.next();
150 } 186 }
151} 187}
152KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() 188KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers()
153{ 189{
154 KABC::PhoneNumber::List retList; 190 KABC::PhoneNumber::List retList;
155 191
156 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); 192 PhoneTypeNumberEdit* edit = mTypeNumberEditList.first();
157 while ( edit ) { 193 while ( edit ) {
158 if ( edit->isValid() ) { 194 if ( edit->isValid() ) {
159 retList.append( edit->phoneNumber()); 195 retList.append( edit->phoneNumber());
160 } 196 }
161 edit = mTypeNumberEditList.next(); 197 edit = mTypeNumberEditList.next();
162 198
163 } 199 }
164 return retList; 200 return retList;
165} 201}
166 202
167#if 0 203#if 0
168PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) 204PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name )
169 : QWidget( parent, name ) 205 : QWidget( parent, name )
170{ 206{
171 QGridLayout *layout = new QGridLayout( this, 4, 1 ); 207 QGridLayout *layout = new QGridLayout( this, 4, 1 );
172//US layout->setSpacing( KDialog::spacingHint() ); 208//US layout->setSpacing( KDialog::spacingHint() );
173 layout->setSpacing( KDialogBase::spacingHintSmall() ); 209 layout->setSpacing( KDialogBase::spacingHintSmall() );
174 210
175 211
176 212
177 QLabel* label = new QLabel( this ); 213 QLabel* label = new QLabel( this );
178//US loadIcon call is ambiguous. Add one more parameter 214//US loadIcon call is ambiguous. Add one more parameter
179//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); 215//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) );
180 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); 216 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
181 label->setAlignment( AlignCenter ); 217 label->setAlignment( AlignCenter );
182//US layout->addMultiCellWidget( label, 0, 1, 3, 3 ); 218//US layout->addMultiCellWidget( label, 0, 1, 3, 3 );
183 layout->addWidget( label, 0, 0 ); 219 layout->addWidget( label, 0, 0 );
184 220
185 QPushButton *editButton = new QPushButton( i18n( "Edit Phone Numbers..." ), 221 QPushButton *editButton = new QPushButton( i18n( "Edit Phone Numbers..." ),
186 this ); 222 this );
187 if ( QApplication::desktop()->width() < 640 ) 223 if ( QApplication::desktop()->width() < 640 )
188 layout->addWidget( editButton, 0, 1 ); 224 layout->addWidget( editButton, 0, 1 );
189 else 225 else
190 layout->addMultiCellWidget( editButton, 0, 0, 1, 3); 226 layout->addMultiCellWidget( editButton, 0, 0, 1, 3);
191 227
192 mPrefCombo = new PhoneTypeCombo( mPhoneList, this ); 228 mPrefCombo = new PhoneTypeCombo( mPhoneList, this );
193 mPrefEdit = new KLineEdit( this ); 229 mPrefEdit = new KLineEdit( this );
194 //mPrefEdit->setMinimumWidth( int(mPrefEdit->sizeHint().width() * 1.5) ); 230 //mPrefEdit->setMinimumWidth( int(mPrefEdit->sizeHint().width() * 1.5) );
195 mPrefCombo->setLineEdit( mPrefEdit ); 231 mPrefCombo->setLineEdit( mPrefEdit );
196 layout->addWidget( mPrefCombo, 1, 0 ); 232 layout->addWidget( mPrefCombo, 1, 0 );
197 layout->addWidget( mPrefEdit, 1, 1 ); 233 layout->addWidget( mPrefEdit, 1, 1 );
198 int x = 1, y = 2; 234 int x = 1, y = 2;
199 if ( QApplication::desktop()->width() < 640 ) { 235 if ( QApplication::desktop()->width() < 640 ) {
200 ++x; 236 ++x;
201 y = 0; 237 y = 0;
202 } 238 }
203 mSecondCombo = new PhoneTypeCombo( mPhoneList, this ); 239 mSecondCombo = new PhoneTypeCombo( mPhoneList, this );
204 mSecondEdit = new KLineEdit( this ); 240 mSecondEdit = new KLineEdit( this );
205 mSecondCombo->setLineEdit( mSecondEdit ); 241 mSecondCombo->setLineEdit( mSecondEdit );
206 layout->addWidget( mSecondCombo, x, y++ ); 242 layout->addWidget( mSecondCombo, x, y++ );
207 layout->addWidget( mSecondEdit, x, y++ ); 243 layout->addWidget( mSecondEdit, x, y++ );
208 244
209 y = 0; 245 y = 0;
210 ++x; 246 ++x;
211 mThirdCombo = new PhoneTypeCombo( mPhoneList, this ); 247 mThirdCombo = new PhoneTypeCombo( mPhoneList, this );
212 mThirdEdit = new KLineEdit( this ); 248 mThirdEdit = new KLineEdit( this );
213 mThirdCombo->setLineEdit( mThirdEdit ); 249 mThirdCombo->setLineEdit( mThirdEdit );
214 layout->addWidget( mThirdCombo, x, y++ ); 250 layout->addWidget( mThirdCombo, x, y++ );
215 layout->addWidget( mThirdEdit, x, y++ ); 251 layout->addWidget( mThirdEdit, x, y++ );
216 if ( QApplication::desktop()->width() < 640 ) { 252 if ( QApplication::desktop()->width() < 640 ) {
217 ++x; 253 ++x;
218 y = 0; 254 y = 0;
219 } 255 }
220 mFourthCombo = new PhoneTypeCombo( mPhoneList, this ); 256 mFourthCombo = new PhoneTypeCombo( mPhoneList, this );
221 mFourthEdit = new KLineEdit( this ); 257 mFourthEdit = new KLineEdit( this );
222 mFourthCombo->setLineEdit( mFourthEdit ); 258 mFourthCombo->setLineEdit( mFourthEdit );
223 layout->addWidget( mFourthCombo, x, y++ ); 259 layout->addWidget( mFourthCombo, x, y++ );
224 layout->addWidget( mFourthEdit, x, y++ ); 260 layout->addWidget( mFourthEdit, x, y++ );
225 261
226 // Four numbers don't fit in the current dialog 262 // Four numbers don't fit in the current dialog
227 if ( QApplication::desktop()->width() < 640 ) { 263 if ( QApplication::desktop()->width() < 640 ) {
228 mFourthCombo->hide(); 264 mFourthCombo->hide();
229 mFourthEdit->hide(); 265 mFourthEdit->hide();
230 } else { 266 } else {
231 QFontMetrics fm ( font () ) ; 267 QFontMetrics fm ( font () ) ;
232 int wid = fm.width( "Messenger" ) +60; 268 int wid = fm.width( "Messenger" ) +60;
233 mPrefCombo->setMaximumWidth( wid ); 269 mPrefCombo->setMaximumWidth( wid );
234 mSecondCombo->setMaximumWidth( wid ); 270 mSecondCombo->setMaximumWidth( wid );
235 mThirdCombo->setMaximumWidth( wid ); 271 mThirdCombo->setMaximumWidth( wid );
236 mFourthCombo->setMaximumWidth( wid ); 272 mFourthCombo->setMaximumWidth( wid );
237 } 273 }
238 274
239 275
240 connect( mPrefEdit, SIGNAL( textChanged( const QString& ) ), 276 connect( mPrefEdit, SIGNAL( textChanged( const QString& ) ),
241 SLOT( slotPrefEditChanged() ) ); 277 SLOT( slotPrefEditChanged() ) );
242 connect( mSecondEdit, SIGNAL( textChanged( const QString& ) ), 278 connect( mSecondEdit, SIGNAL( textChanged( const QString& ) ),
243 SLOT( slotSecondEditChanged() ) ); 279 SLOT( slotSecondEditChanged() ) );
244 connect( mThirdEdit, SIGNAL( textChanged( const QString& ) ), 280 connect( mThirdEdit, SIGNAL( textChanged( const QString& ) ),
245 SLOT( slotThirdEditChanged() ) ); 281 SLOT( slotThirdEditChanged() ) );
246 connect( mFourthEdit, SIGNAL( textChanged( const QString& ) ), 282 connect( mFourthEdit, SIGNAL( textChanged( const QString& ) ),
247 SLOT( slotFourthEditChanged() ) ); 283 SLOT( slotFourthEditChanged() ) );
248 284
249 connect( editButton, SIGNAL( clicked() ), SLOT( edit() ) ); 285 connect( editButton, SIGNAL( clicked() ), SLOT( edit() ) );
250 286
251 connect( mPrefCombo, SIGNAL( activated( int ) ), 287 connect( mPrefCombo, SIGNAL( activated( int ) ),
252 SLOT( updatePrefEdit() ) ); 288 SLOT( updatePrefEdit() ) );
253 connect( mSecondCombo, SIGNAL( activated( int ) ), 289 connect( mSecondCombo, SIGNAL( activated( int ) ),
254 SLOT( updateSecondEdit() ) ); 290 SLOT( updateSecondEdit() ) );
255 connect( mThirdCombo, SIGNAL( activated( int ) ), 291 connect( mThirdCombo, SIGNAL( activated( int ) ),
256 SLOT( updateThirdEdit() ) ); 292 SLOT( updateThirdEdit() ) );
257 connect( mFourthCombo, SIGNAL( activated( int ) ), 293 connect( mFourthCombo, SIGNAL( activated( int ) ),
258 SLOT( updateFourthEdit() ) ); 294 SLOT( updateFourthEdit() ) );
259} 295}
260 296
261PhoneEditWidget::~PhoneEditWidget() 297PhoneEditWidget::~PhoneEditWidget()
262{ 298{
263} 299}
264 300
265void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &list ) 301void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &list )
266{ 302{
267 mPhoneList.clear(); 303 mPhoneList.clear();
268 304
269 // Insert types for existing numbers. 305 // Insert types for existing numbers.
270 mPrefCombo->insertTypeList( list ); 306 mPrefCombo->insertTypeList( list );
271 307
272 QValueList<int> defaultTypes; 308 QValueList<int> defaultTypes;
273 defaultTypes << KABC::PhoneNumber::Home; 309 defaultTypes << KABC::PhoneNumber::Home;
274 defaultTypes << KABC::PhoneNumber::Work; 310 defaultTypes << KABC::PhoneNumber::Work;
275 defaultTypes << KABC::PhoneNumber::Cell; 311 defaultTypes << KABC::PhoneNumber::Cell;
276 defaultTypes << ( KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax ); 312 defaultTypes << ( KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax );
277 defaultTypes << ( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax ); 313 defaultTypes << ( KABC::PhoneNumber::Home | KABC::PhoneNumber::Fax );
278 314
279 // Insert default types. 315 // Insert default types.
280 // Doing this for mPrefCombo is enough because the list is shared by all 316 // Doing this for mPrefCombo is enough because the list is shared by all
281 // combos. 317 // combos.
282 QValueList<int>::ConstIterator it; 318 QValueList<int>::ConstIterator it;
283 for( it = defaultTypes.begin(); it != defaultTypes.end(); ++it ) { 319 for( it = defaultTypes.begin(); it != defaultTypes.end(); ++it ) {
284 if ( !mPrefCombo->hasType( *it ) ) 320 if ( !mPrefCombo->hasType( *it ) )
285 mPrefCombo->insertType( list, *it, PhoneNumber( "", *it ) ); 321 mPrefCombo->insertType( list, *it, PhoneNumber( "", *it ) );
286 } 322 }
287 323
288 updateCombos(); 324 updateCombos();
289 325
290 mPrefCombo->selectType( defaultTypes[ 0 ] ); 326 mPrefCombo->selectType( defaultTypes[ 0 ] );
291 mSecondCombo->selectType( defaultTypes[ 1 ] ); 327 mSecondCombo->selectType( defaultTypes[ 1 ] );
292 mThirdCombo->selectType( defaultTypes[ 2 ] ); 328 mThirdCombo->selectType( defaultTypes[ 2 ] );
293 mFourthCombo->selectType( defaultTypes[ 3 ] ); 329 mFourthCombo->selectType( defaultTypes[ 3 ] );
294 330