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