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