author | zautrix <zautrix> | 2005-10-28 08:57:25 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-28 08:57:25 (UTC) |
commit | f284eafbe4274cb97ec25f375544b924ae04ac09 (patch) (unidiff) | |
tree | bc754eac9882740463a447099944cbb590bad7f6 /kaddressbook | |
parent | d934f3fe2a62f6a696992335124c4434cd77d990 (diff) | |
download | kdepimpi-f284eafbe4274cb97ec25f375544b924ae04ac09.zip kdepimpi-f284eafbe4274cb97ec25f375544b924ae04ac09.tar.gz kdepimpi-f284eafbe4274cb97ec25f375544b924ae04ac09.tar.bz2 |
cimmit
-rw-r--r-- | kaddressbook/addresseeeditorwidget.cpp | 34 | ||||
-rw-r--r-- | kaddressbook/phoneeditwidget.h | 79 |
2 files changed, 103 insertions, 10 deletions
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp index 310d628..9814cd5 100644 --- a/kaddressbook/addresseeeditorwidget.cpp +++ b/kaddressbook/addresseeeditorwidget.cpp | |||
@@ -133,49 +133,56 @@ void AddresseeEditorWidget::initGUI() | |||
133 | QVBoxLayout *layout = new QVBoxLayout( this ); | 133 | QVBoxLayout *layout = new QVBoxLayout( this ); |
134 | 134 | ||
135 | mTabWidget = new QTabWidget( this ); | 135 | mTabWidget = new QTabWidget( this ); |
136 | layout->addWidget( mTabWidget ); | 136 | layout->addWidget( mTabWidget ); |
137 | 137 | ||
138 | setupTab1(); | 138 | setupTab1(); |
139 | setupTab1_1(); | 139 | setupTab1_1(); |
140 | setupTab2(); | 140 | setupTab2(); |
141 | setupTab2_1(); | 141 | setupTab2_1(); |
142 | setupTab3(); | 142 | setupTab3(); |
143 | setupTab3_1(); | 143 | setupTab3_1(); |
144 | 144 | ||
145 | mNameEdit->setFocus(); | 145 | mNameEdit->setFocus(); |
146 | 146 | ||
147 | connect( mTabWidget, SIGNAL( currentChanged(QWidget*) ), | 147 | connect( mTabWidget, SIGNAL( currentChanged(QWidget*) ), |
148 | SLOT( pageChanged(QWidget*) ) ); | 148 | SLOT( pageChanged(QWidget*) ) ); |
149 | } | 149 | } |
150 | 150 | ||
151 | void AddresseeEditorWidget::setupTab1() | 151 | void AddresseeEditorWidget::setupTab1() |
152 | { | 152 | { |
153 | // This is the General tab | 153 | // This is the General tab |
154 | QWidget *tab1 = new QWidget( mTabWidget ); | 154 | QWidget *tab1 = new QWidget( mTabWidget ); |
155 | 155 | ||
156 | //US QGridLayout *layout = new QGridLayout( tab1, 11, 7 ); | 156 | //US QGridLayout *layout = new QGridLayout( tab1, 11, 7 ); |
157 | QGridLayout *layout = new QGridLayout( tab1, 7, 1 ); | 157 | bool horLayout = false; |
158 | int maxCol = 1; | ||
159 | if ( QApplication::desktop()->width() == 640 || QApplication::desktop()->width() == 320 ) { | ||
160 | horLayout = true; | ||
161 | maxCol = 3; | ||
162 | } | ||
163 | QGridLayout *layout = new QGridLayout( tab1, 8-maxCol, maxCol ); | ||
164 | |||
158 | layout->setMargin( KDialogBase::marginHintSmall() ); | 165 | layout->setMargin( KDialogBase::marginHintSmall() ); |
159 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 166 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
160 | 167 | ||
161 | QLabel *label; | 168 | QLabel *label; |
162 | KSeparator* bar; | 169 | KSeparator* bar; |
163 | QPushButton *button; | 170 | QPushButton *button; |
164 | 171 | ||
165 | ////////////////////////////////// | 172 | ////////////////////////////////// |
166 | // Upper left group (person info) | 173 | // Upper left group (person info) |
167 | 174 | ||
168 | // Person icon | 175 | // Person icon |
169 | /* LR | 176 | /* LR |
170 | label = new QLabel( tab1 ); | 177 | label = new QLabel( tab1 ); |
171 | //US ambiguous call. Add one more parameter | 178 | //US ambiguous call. Add one more parameter |
172 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); | 179 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); |
173 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); | 180 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); |
174 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); | 181 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); |
175 | */ | 182 | */ |
176 | // First name | 183 | // First name |
177 | button = new QPushButton( i18n( "Name..." ), tab1 ); | 184 | button = new QPushButton( i18n( "Name..." ), tab1 ); |
178 | //US QToolTip::add( button, i18n( "Edit the contact's name" ) ); | 185 | //US QToolTip::add( button, i18n( "Edit the contact's name" ) ); |
179 | mNameEdit = new KLineEdit( tab1, "mNameEdit" ); | 186 | mNameEdit = new KLineEdit( tab1, "mNameEdit" ); |
180 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), | 187 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), |
181 | SLOT( nameTextChanged( const QString& ) ) ); | 188 | SLOT( nameTextChanged( const QString& ) ) ); |
@@ -185,83 +192,94 @@ void AddresseeEditorWidget::setupTab1() | |||
185 | mNameLabel->hide(); | 192 | mNameLabel->hide(); |
186 | 193 | ||
187 | layout->addWidget( button, 0, 0 ); | 194 | layout->addWidget( button, 0, 0 ); |
188 | layout->addWidget( mNameEdit, 0, 1 ); | 195 | layout->addWidget( mNameEdit, 0, 1 ); |
189 | layout->addWidget( mNameLabel, 0, 1 ); | 196 | layout->addWidget( mNameLabel, 0, 1 ); |
190 | 197 | ||
191 | button = new QPushButton( i18n( "Role:" ), tab1 ); | 198 | button = new QPushButton( i18n( "Role:" ), tab1 ); |
192 | connect( button, SIGNAL( clicked() ), SLOT( setRole2FN() ) ); | 199 | connect( button, SIGNAL( clicked() ), SLOT( setRole2FN() ) ); |
193 | //label = new QLabel( i18n( "Role:" ), tab1 ); | 200 | //label = new QLabel( i18n( "Role:" ), tab1 ); |
194 | mRoleEdit = new KLineEdit( tab1 ); | 201 | mRoleEdit = new KLineEdit( tab1 ); |
195 | connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ), | 202 | connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ), |
196 | SLOT( textChanged( const QString& ) ) ); | 203 | SLOT( textChanged( const QString& ) ) ); |
197 | //label->setBuddy( mRoleEdit ); | 204 | //label->setBuddy( mRoleEdit ); |
198 | layout->addWidget( button, 1, 0 ); | 205 | layout->addWidget( button, 1, 0 ); |
199 | layout->addWidget( mRoleEdit, 1, 1 ); | 206 | layout->addWidget( mRoleEdit, 1, 1 ); |
200 | 207 | ||
201 | // Organization | 208 | // Organization |
202 | button = new QPushButton( i18n( "Organization:" ), tab1 ); | 209 | button = new QPushButton( i18n( "Organization:" ), tab1 ); |
203 | connect( button, SIGNAL( clicked() ), SLOT( setCompany2FN() ) ); | 210 | connect( button, SIGNAL( clicked() ), SLOT( setCompany2FN() ) ); |
204 | //label = new QLabel( i18n( "Organization:" ), tab1 ); | 211 | //label = new QLabel( i18n( "Organization:" ), tab1 ); |
205 | mOrgEdit = new KLineEdit( tab1 ); | 212 | mOrgEdit = new KLineEdit( tab1 ); |
206 | //label->setBuddy( mOrgEdit ); | 213 | //label->setBuddy( mOrgEdit ); |
207 | connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ), | 214 | connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ), |
208 | SLOT( textChanged( const QString& ) ) ); | 215 | SLOT( textChanged( const QString& ) ) ); |
209 | layout->addWidget( button, 2, 0 ); | 216 | if ( horLayout ) { |
210 | layout->addWidget( mOrgEdit, 2, 1 ); | 217 | layout->addWidget( button, 1, 2 ); |
218 | layout->addWidget( mOrgEdit, 1, 3 ); | ||
219 | |||
220 | } else { | ||
221 | layout->addWidget( button, 2, 0 ); | ||
222 | layout->addWidget( mOrgEdit, 2, 1 ); | ||
223 | } | ||
211 | 224 | ||
212 | // File as (formatted name) | 225 | // File as (formatted name) |
213 | label = new QLabel( i18n( "Formatted name:" ), tab1 ); | 226 | label = new QLabel( i18n( "Format.n.:" ), tab1 ); |
214 | mFormattedNameLabel = new KSqueezedTextLabel( tab1 ); | 227 | mFormattedNameLabel = new KSqueezedTextLabel( tab1 ); |
215 | layout->addWidget( label, 3, 0 ); | 228 | if ( horLayout ) { |
216 | layout->addWidget( mFormattedNameLabel, 3, 1 ); | 229 | layout->addWidget( label, 0,2 ); |
230 | layout->addWidget( mFormattedNameLabel, 0, 3 ); | ||
231 | } else { | ||
232 | layout->addWidget( label, 3, 0 ); | ||
233 | layout->addWidget( mFormattedNameLabel, 3, 1 ); | ||
234 | } | ||
217 | /* LR | 235 | /* LR |
218 | // Left hand separator. This separator doesn't go all the way | 236 | // Left hand separator. This separator doesn't go all the way |
219 | // across so the dialog still flows from top to bottom | 237 | // across so the dialog still flows from top to bottom |
220 | bar = new KSeparator( KSeparator::HLine, tab1 ); | 238 | bar = new KSeparator( KSeparator::HLine, tab1 ); |
221 | layout->addMultiCellWidget( bar, 4, 4, 0, 2 ); | 239 | layout->addMultiCellWidget( bar, 4, 4, 0, 2 ); |
222 | */ | 240 | */ |
223 | ////////////////////////////////////// | 241 | ////////////////////////////////////// |
224 | 242 | ||
225 | /* LR | 243 | /* LR |
226 | // Phone numbers (upper right) | 244 | // Phone numbers (upper right) |
227 | label = new QLabel( tab1 ); | 245 | label = new QLabel( tab1 ); |
228 | //US loadIcon call is ambiguous. Add one more parameter | 246 | //US loadIcon call is ambiguous. Add one more parameter |
229 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); | 247 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); |
230 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); | 248 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); |
231 | //US layout->addMultiCellWidget( label, 0, 1, 3, 3 ); | 249 | //US layout->addMultiCellWidget( label, 0, 1, 3, 3 ); |
232 | layout->addMultiCellWidget( label, 5, 6, 0, 0 ); | 250 | layout->addMultiCellWidget( label, 5, 6, 0, 0 ); |
233 | */ | 251 | */ |
234 | mPhoneEditWidget = new PhoneEditWidget( tab1 ); | 252 | mPhoneEditWidget = new PhoneEditWidget( tab1 ); |
235 | connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); | 253 | connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); |
236 | //US layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 ); | 254 | //US layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 ); |
237 | int iii; | 255 | int iii; |
238 | #ifndef DESKTOP_VERSION | 256 | #ifndef DESKTOP_VERSION |
239 | iii = 7; | 257 | iii = 7; |
240 | #else | 258 | #else |
241 | iii = 8; | 259 | iii = 8; |
242 | #endif | 260 | #endif |
243 | layout->addMultiCellWidget( mPhoneEditWidget, 4, iii, 0, 1 ); | 261 | layout->addMultiCellWidget( mPhoneEditWidget, 4, iii, 0, maxCol ); |
244 | ++iii; | 262 | ++iii; |
245 | /* LR | 263 | /* LR |
246 | bar = new KSeparator( KSeparator::HLine, tab1 ); | 264 | bar = new KSeparator( KSeparator::HLine, tab1 ); |
247 | //US layout->addMultiCellWidget( bar, 4, 4, 3, 6 ); | 265 | //US layout->addMultiCellWidget( bar, 4, 4, 3, 6 ); |
248 | layout->addMultiCellWidget( bar, 9, 9, 0, 2 ); | 266 | layout->addMultiCellWidget( bar, 9, 9, 0, 2 ); |
249 | */ | 267 | */ |
250 | /*US | 268 | /*US |
251 | ////////////////////////////////////// | 269 | ////////////////////////////////////// |
252 | // Addresses (lower left) | 270 | // Addresses (lower left) |
253 | label = new QLabel( tab1 ); | 271 | label = new QLabel( tab1 ); |
254 | //US loadIcon call is ambiguous. Add one more parameter | 272 | //US loadIcon call is ambiguous. Add one more parameter |
255 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) ); | 273 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) ); |
256 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) ); | 274 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) ); |
257 | layout->addMultiCellWidget( label, 5, 6, 0, 0 ); | 275 | layout->addMultiCellWidget( label, 5, 6, 0, 0 ); |
258 | 276 | ||
259 | mAddressEditWidget = new AddressEditWidget( tab1 ); | 277 | mAddressEditWidget = new AddressEditWidget( tab1 ); |
260 | connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); | 278 | connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); |
261 | layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 ); | 279 | layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 ); |
262 | 280 | ||
263 | ////////////////////////////////////// | 281 | ////////////////////////////////////// |
264 | // Email / Web (lower right) | 282 | // Email / Web (lower right) |
265 | label = new QLabel( tab1 ); | 283 | label = new QLabel( tab1 ); |
266 | //US loadIcon call is ambiguous. Add one more parameter | 284 | //US loadIcon call is ambiguous. Add one more parameter |
267 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) ); | 285 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) ); |
@@ -300,49 +318,49 @@ void AddresseeEditorWidget::setupTab1() | |||
300 | 318 | ||
301 | layout->addColSpacing( 6, 50 ); | 319 | layout->addColSpacing( 6, 50 ); |
302 | 320 | ||
303 | bar = new KSeparator( KSeparator::HLine, tab1 ); | 321 | bar = new KSeparator( KSeparator::HLine, tab1 ); |
304 | layout->addMultiCellWidget( bar, 10, 10, 0, 6 ); | 322 | layout->addMultiCellWidget( bar, 10, 10, 0, 6 ); |
305 | */ | 323 | */ |
306 | /////////////////////////////////////// | 324 | /////////////////////////////////////// |
307 | QHBox *categoryBox = new QHBox( tab1 ,"cato"); | 325 | QHBox *categoryBox = new QHBox( tab1 ,"cato"); |
308 | categoryBox->setSpacing( KDialogBase::spacingHint() ); | 326 | categoryBox->setSpacing( KDialogBase::spacingHint() ); |
309 | categoryBox->setMargin( KDialogBase::marginHintSmall() ); | 327 | categoryBox->setMargin( KDialogBase::marginHintSmall() ); |
310 | 328 | ||
311 | // Categories | 329 | // Categories |
312 | button = new QPushButton( i18n( "Categories" ), categoryBox ); | 330 | button = new QPushButton( i18n( "Categories" ), categoryBox ); |
313 | connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) ); | 331 | connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) ); |
314 | 332 | ||
315 | mCategoryEdit = new KLineEdit( categoryBox ); | 333 | mCategoryEdit = new KLineEdit( categoryBox ); |
316 | mCategoryEdit->setReadOnly( true ); | 334 | mCategoryEdit->setReadOnly( true ); |
317 | connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ), | 335 | connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ), |
318 | SLOT( textChanged( const QString& ) ) ); | 336 | SLOT( textChanged( const QString& ) ) ); |
319 | 337 | ||
320 | mSecrecyWidget = new SecrecyWidget( categoryBox ); | 338 | mSecrecyWidget = new SecrecyWidget( categoryBox ); |
321 | connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 339 | connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
322 | 340 | ||
323 | //US layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); | 341 | //US layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); |
324 | layout->addMultiCellWidget( categoryBox, iii, iii, 0, 1 ); | 342 | layout->addMultiCellWidget( categoryBox, iii, iii, 0, maxCol ); |
325 | 343 | ||
326 | // Build the layout and add to the tab widget | 344 | // Build the layout and add to the tab widget |
327 | layout->activate(); // required | 345 | layout->activate(); // required |
328 | 346 | ||
329 | mTabWidget->addTab( tab1, i18n( "&General" ) ); | 347 | mTabWidget->addTab( tab1, i18n( "&General" ) ); |
330 | } | 348 | } |
331 | 349 | ||
332 | void AddresseeEditorWidget::setRole2FN() | 350 | void AddresseeEditorWidget::setRole2FN() |
333 | { | 351 | { |
334 | if ( mRoleEdit->text().isEmpty() ) return; | 352 | if ( mRoleEdit->text().isEmpty() ) return; |
335 | mFormattedNameType = NameEditDialog::CustomName; | 353 | mFormattedNameType = NameEditDialog::CustomName; |
336 | mAddressee.setFormattedName( mRoleEdit->text() ); | 354 | mAddressee.setFormattedName( mRoleEdit->text() ); |
337 | mFormattedNameLabel->setText( mRoleEdit->text() ); | 355 | mFormattedNameLabel->setText( mRoleEdit->text() ); |
338 | mDirty = true; | 356 | mDirty = true; |
339 | } | 357 | } |
340 | void AddresseeEditorWidget::setCompany2FN() | 358 | void AddresseeEditorWidget::setCompany2FN() |
341 | { | 359 | { |
342 | if ( mOrgEdit->text().isEmpty() ) return; | 360 | if ( mOrgEdit->text().isEmpty() ) return; |
343 | mFormattedNameType = NameEditDialog::CustomName; | 361 | mFormattedNameType = NameEditDialog::CustomName; |
344 | mAddressee.setFormattedName( mOrgEdit->text() ); | 362 | mAddressee.setFormattedName( mOrgEdit->text() ); |
345 | mFormattedNameLabel->setText( mOrgEdit->text() ); | 363 | mFormattedNameLabel->setText( mOrgEdit->text() ); |
346 | mDirty = true; | 364 | mDirty = true; |
347 | } | 365 | } |
348 | 366 | ||
diff --git a/kaddressbook/phoneeditwidget.h b/kaddressbook/phoneeditwidget.h index 7fe4bc0..0241cf0 100644 --- a/kaddressbook/phoneeditwidget.h +++ b/kaddressbook/phoneeditwidget.h | |||
@@ -3,58 +3,62 @@ | |||
3 | /* | 3 | /* |
4 | This file is part of KAddressBook. | 4 | This file is part of KAddressBook. |
5 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 5 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <kdialogbase.h> | 26 | #include <kdialogbase.h> |
27 | #include <kiconloader.h> | ||
28 | #include <qpushbutton.h> | ||
29 | #include <qlayout.h> | ||
30 | |||
27 | 31 | ||
28 | #include "addresseeconfig.h" | 32 | #include "addresseeconfig.h" |
29 | #include "typecombo.h" | 33 | #include "typecombo.h" |
30 | 34 | ||
31 | class QButtonGroup; | 35 | class QButtonGroup; |
32 | class QCheckBox; | 36 | class QCheckBox; |
33 | 37 | ||
38 | #include <klineedit.h> | ||
39 | #include <kcombobox.h> | ||
34 | class KListView; | 40 | class KListView; |
35 | class KLineEdit; | ||
36 | class KComboBox; | ||
37 | 41 | ||
38 | typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo; | 42 | typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo; |
39 | 43 | ||
40 | /** | 44 | /** |
41 | Widget for editing phone numbers. | 45 | Widget for editing phone numbers. |
42 | */ | 46 | */ |
43 | class PhoneEditWidget : public QWidget | 47 | class PhoneEditWidget : public QWidget |
44 | { | 48 | { |
45 | Q_OBJECT | 49 | Q_OBJECT |
46 | 50 | ||
47 | public: | 51 | public: |
48 | PhoneEditWidget( QWidget *parent, const char *name = 0 ); | 52 | PhoneEditWidget( QWidget *parent, const char *name = 0 ); |
49 | ~PhoneEditWidget(); | 53 | ~PhoneEditWidget(); |
50 | 54 | ||
51 | void setPhoneNumbers( const KABC::PhoneNumber::List &list ); | 55 | void setPhoneNumbers( const KABC::PhoneNumber::List &list ); |
52 | KABC::PhoneNumber::List phoneNumbers(); | 56 | KABC::PhoneNumber::List phoneNumbers(); |
53 | 57 | ||
54 | void updateTypeCombo( const KABC::PhoneNumber::List&, KComboBox* ); | 58 | void updateTypeCombo( const KABC::PhoneNumber::List&, KComboBox* ); |
55 | KABC::PhoneNumber currentPhoneNumber( KComboBox*, int ); | 59 | KABC::PhoneNumber currentPhoneNumber( KComboBox*, int ); |
56 | 60 | ||
57 | signals: | 61 | signals: |
58 | void modified(); | 62 | void modified(); |
59 | 63 | ||
60 | private slots: | 64 | private slots: |
@@ -122,26 +126,97 @@ class PhoneEditDialog : public KDialogBase | |||
122 | QPushButton *mEditButton; | 126 | QPushButton *mEditButton; |
123 | 127 | ||
124 | bool mChanged; | 128 | bool mChanged; |
125 | }; | 129 | }; |
126 | 130 | ||
127 | /** | 131 | /** |
128 | Dialog for editing phone number types. | 132 | Dialog for editing phone number types. |
129 | */ | 133 | */ |
130 | class PhoneTypeDialog : public KDialogBase | 134 | class PhoneTypeDialog : public KDialogBase |
131 | { | 135 | { |
132 | Q_OBJECT | 136 | Q_OBJECT |
133 | public: | 137 | public: |
134 | PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, QWidget *parent, const char *name = 0 ); | 138 | PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, QWidget *parent, const char *name = 0 ); |
135 | 139 | ||
136 | KABC::PhoneNumber phoneNumber(); | 140 | KABC::PhoneNumber phoneNumber(); |
137 | 141 | ||
138 | private: | 142 | private: |
139 | KABC::PhoneNumber mPhoneNumber; | 143 | KABC::PhoneNumber mPhoneNumber; |
140 | KABC::PhoneNumber::TypeList mTypeList; | 144 | KABC::PhoneNumber::TypeList mTypeList; |
141 | 145 | ||
142 | QButtonGroup *mGroup; | 146 | QButtonGroup *mGroup; |
143 | QCheckBox *mPreferredBox; | 147 | QCheckBox *mPreferredBox; |
144 | KLineEdit *mNumber; | 148 | KLineEdit *mNumber; |
145 | }; | 149 | }; |
150 | class PhoneTypeNumberEdit : public QWidget | ||
151 | { | ||
152 | Q_OBJECT | ||
153 | public: | ||
154 | PhoneTypeNumberEdit( QWidget *parent, const char *name = 0 ) | ||
155 | { | ||
156 | QHBoxLayout * lay = new QHBoxLayout( this ); | ||
157 | lay->setSpacing( KDialogBase::spacingHintSmall() ); | ||
158 | lay->setMargin( KDialogBase::marginHintSmall() ); | ||
159 | mMinusButton = new QPushButton ( this ); | ||
160 | mMinusButton->setPixmap ( SmallIcon("minus")); | ||
161 | mCombo = new KComboBox( this ); | ||
162 | mNumber = new KLineEdit( this ); | ||
163 | lay->addWidget( mMinusButton ); | ||
164 | lay->addWidget( mCombo ); | ||
165 | lay->addWidget( mNumber ); | ||
166 | connect( mMinusButton , SIGNAL ( clicked() ), this, SLOT ( deleteNumber() ) ); | ||
167 | connect( mCombo , SIGNAL ( activated ( int ) ), this, SLOT ( comboTypeChange( int ) ) ); | ||
168 | mCombo->insertStringList( PhoneNumber::supportedTypeListNames() ); | ||
169 | } | ||
170 | |||
171 | void setPhoneNumber( const KABC::PhoneNumber &phoneNumber ) | ||
172 | { | ||
173 | mPhoneNumber = phoneNumber; | ||
174 | int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); | ||
175 | mCombo->setCurrentItem( index ); | ||
176 | mNumber->setText( mPhoneNumber.number() ); | ||
177 | show(); | ||
178 | |||
179 | } | ||
180 | KABC::PhoneNumber phoneNumber() | ||
181 | { | ||
182 | mPhoneNumber.setNumber( mNumber->text() ); | ||
183 | int index = mCombo->currentItem(); | ||
184 | mPhoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); | ||
185 | return mPhoneNumber; | ||
186 | |||
187 | } | ||
188 | private slots: | ||
189 | void typeExternalChanged( int oldType, int newType ) | ||
190 | { | ||
191 | if ( mPhoneNumber.type() == newType ) { | ||
192 | mPhoneNumber.setType(oldType); | ||
193 | int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); | ||
194 | mCombo->setCurrentItem( index ); | ||
195 | } | ||
196 | |||
197 | } | ||
198 | void deleteNumber() | ||
199 | { | ||
200 | hide(); | ||
201 | } | ||
202 | void comboTypeChange( int index ) | ||
203 | { | ||
204 | int old = mPhoneNumber.type(); | ||
205 | int newT = PhoneNumber::supportedTypeList()[index]; | ||
206 | if ( old != newT ) { | ||
207 | mPhoneNumber.setType(newT ); | ||
208 | emit typeChange ( old, newT ); | ||
209 | } | ||
210 | |||
211 | } | ||
212 | signals: | ||
213 | void typeChange( int oldType, int newType ); | ||
214 | |||
215 | private: | ||
216 | KABC::PhoneNumber mPhoneNumber; | ||
217 | QPushButton* mMinusButton; | ||
218 | KComboBox *mCombo; | ||
219 | KLineEdit *mNumber; | ||
220 | }; | ||
146 | 221 | ||
147 | #endif | 222 | #endif |