Diffstat (limited to 'kaddressbook/nameeditdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/nameeditdialog.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/kaddressbook/nameeditdialog.cpp b/kaddressbook/nameeditdialog.cpp index 199f3d6..96822d8 100644 --- a/kaddressbook/nameeditdialog.cpp +++ b/kaddressbook/nameeditdialog.cpp | |||
@@ -1,108 +1,110 @@ | |||
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 <qlistbox.h> | 26 | #include <q3listbox.h> |
27 | #include <qlistview.h> | 27 | #include <q3listview.h> |
28 | #include <qtooltip.h> | 28 | #include <qtooltip.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qcheckbox.h> | 30 | #include <qcheckbox.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | //Added by qt3to4: | ||
33 | #include <Q3GridLayout> | ||
32 | 34 | ||
33 | #ifndef KAB_EMBEDDED | 35 | #ifndef KAB_EMBEDDED |
34 | #include <kaccelmanager.h> | 36 | #include <kaccelmanager.h> |
35 | #else //KAB_EMBEDDED | 37 | #else //KAB_EMBEDDED |
36 | #include <kstandarddirs.h> | 38 | #include <kstandarddirs.h> |
37 | #endif //KAB_EMBEDDED | 39 | #endif //KAB_EMBEDDED |
38 | 40 | ||
39 | #include <kapplication.h> | 41 | #include <kapplication.h> |
40 | #include <kbuttonbox.h> | 42 | #include <kbuttonbox.h> |
41 | #include <kconfig.h> | 43 | #include <kconfig.h> |
42 | #include <klineedit.h> | 44 | #include <klineedit.h> |
43 | #include <klistview.h> | 45 | #include <klistview.h> |
44 | #include <kcombobox.h> | 46 | #include <kcombobox.h> |
45 | #include <klocale.h> | 47 | #include <klocale.h> |
46 | #include <kglobal.h> | 48 | #include <kglobal.h> |
47 | #include <kdebug.h> | 49 | #include <kdebug.h> |
48 | #include <kiconloader.h> | 50 | #include <kiconloader.h> |
49 | #include <kmessagebox.h> | 51 | #include <kmessagebox.h> |
50 | 52 | ||
51 | #include "nameeditdialog.h" | 53 | #include "nameeditdialog.h" |
52 | 54 | ||
53 | NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type, | 55 | NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type, |
54 | QWidget *parent, const char *name ) | 56 | QWidget *parent, const char *name ) |
55 | : KDialogBase( Plain, i18n( "Edit Contact Name" ), Help | Ok | Cancel, | 57 | : KDialogBase( Plain, i18n( "Edit Contact Name" ), Help | Ok | Cancel, |
56 | Ok, parent, name, true ) | 58 | Ok, parent, name, true ) |
57 | { | 59 | { |
58 | 60 | ||
59 | QWidget *page = plainPage(); | 61 | QWidget *page = plainPage(); |
60 | QGridLayout *layout = new QGridLayout( page, 5, 3 ); | 62 | Q3GridLayout *layout = new Q3GridLayout( page, 5, 3 ); |
61 | layout->setSpacing( spacingHint() ); | 63 | layout->setSpacing( spacingHint() ); |
62 | layout->addColSpacing( 2, 100 ); | 64 | layout->addColSpacing( 2, 100 ); |
63 | QLabel *label; | 65 | QLabel *label; |
64 | 66 | ||
65 | label = new QLabel( i18n( "Honorific prefixes:" ), page ); | 67 | label = new QLabel( i18n( "Honorific prefixes:" ), page ); |
66 | layout->addWidget( label, 0, 0 ); | 68 | layout->addWidget( label, 0, 0 ); |
67 | mPrefixCombo = new KComboBox( page ); | 69 | mPrefixCombo = new KComboBox( page ); |
68 | mPrefixCombo->setDuplicatesEnabled( false ); | 70 | mPrefixCombo->setDuplicatesEnabled( false ); |
69 | mPrefixCombo->setEditable( true ); | 71 | mPrefixCombo->setEditable( true ); |
70 | label->setBuddy( mPrefixCombo ); | 72 | label->setBuddy( mPrefixCombo ); |
71 | layout->addMultiCellWidget( mPrefixCombo, 0, 0, 1, 2 ); | 73 | layout->addMultiCellWidget( mPrefixCombo, 0, 0, 1, 2 ); |
72 | 74 | ||
73 | label = new QLabel( i18n( "Given name:" ), page ); | 75 | label = new QLabel( i18n( "Given name:" ), page ); |
74 | layout->addWidget( label, 1, 0 ); | 76 | layout->addWidget( label, 1, 0 ); |
75 | mGivenNameEdit = new KLineEdit( page ); | 77 | mGivenNameEdit = new KLineEdit( page ); |
76 | label->setBuddy( mGivenNameEdit ); | 78 | label->setBuddy( mGivenNameEdit ); |
77 | layout->addMultiCellWidget( mGivenNameEdit, 1, 1, 1, 2 ); | 79 | layout->addMultiCellWidget( mGivenNameEdit, 1, 1, 1, 2 ); |
78 | 80 | ||
79 | label = new QLabel( i18n( "Additional names:" ), page ); | 81 | label = new QLabel( i18n( "Additional names:" ), page ); |
80 | layout->addWidget( label, 2, 0 ); | 82 | layout->addWidget( label, 2, 0 ); |
81 | mAdditionalNameEdit = new KLineEdit( page ); | 83 | mAdditionalNameEdit = new KLineEdit( page ); |
82 | label->setBuddy( mAdditionalNameEdit ); | 84 | label->setBuddy( mAdditionalNameEdit ); |
83 | layout->addMultiCellWidget( mAdditionalNameEdit, 2, 2, 1, 2 ); | 85 | layout->addMultiCellWidget( mAdditionalNameEdit, 2, 2, 1, 2 ); |
84 | 86 | ||
85 | label = new QLabel( i18n( "Family names:" ), page ); | 87 | label = new QLabel( i18n( "Family names:" ), page ); |
86 | layout->addWidget( label, 3, 0 ); | 88 | layout->addWidget( label, 3, 0 ); |
87 | mFamilyNameEdit = new KLineEdit( page ); | 89 | mFamilyNameEdit = new KLineEdit( page ); |
88 | label->setBuddy( mFamilyNameEdit ); | 90 | label->setBuddy( mFamilyNameEdit ); |
89 | layout->addMultiCellWidget( mFamilyNameEdit, 3, 3, 1, 2 ); | 91 | layout->addMultiCellWidget( mFamilyNameEdit, 3, 3, 1, 2 ); |
90 | 92 | ||
91 | label = new QLabel( i18n( "Honorific suffixes:" ), page ); | 93 | label = new QLabel( i18n( "Honorific suffixes:" ), page ); |
92 | layout->addWidget( label, 4, 0 ); | 94 | layout->addWidget( label, 4, 0 ); |
93 | mSuffixCombo = new KComboBox( page ); | 95 | mSuffixCombo = new KComboBox( page ); |
94 | mSuffixCombo->setDuplicatesEnabled( false ); | 96 | mSuffixCombo->setDuplicatesEnabled( false ); |
95 | mSuffixCombo->setEditable( true ); | 97 | mSuffixCombo->setEditable( true ); |
96 | label->setBuddy( mSuffixCombo ); | 98 | label->setBuddy( mSuffixCombo ); |
97 | layout->addMultiCellWidget( mSuffixCombo, 4, 4, 1, 2 ); | 99 | layout->addMultiCellWidget( mSuffixCombo, 4, 4, 1, 2 ); |
98 | 100 | ||
99 | mFormattedNameCombo = new KComboBox( page ); | 101 | mFormattedNameCombo = new KComboBox( page ); |
100 | mFormattedNameCombo->setMaximumWidth(100); | 102 | mFormattedNameCombo->setMaximumWidth(100); |
101 | 103 | ||
102 | layout->addMultiCellWidget( mFormattedNameCombo, 5, 5, 0, 0 ); | 104 | layout->addMultiCellWidget( mFormattedNameCombo, 5, 5, 0, 0 ); |
103 | connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( typeChanged( int ) ) ); | 105 | connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( typeChanged( int ) ) ); |
104 | 106 | ||
105 | mFormattedNameEdit = new KLineEdit( page ); | 107 | mFormattedNameEdit = new KLineEdit( page ); |
106 | mFormattedNameEdit->setEnabled( type == CustomName ); | 108 | mFormattedNameEdit->setEnabled( type == CustomName ); |
107 | layout->addMultiCellWidget( mFormattedNameEdit, 5, 5, 1, 2 ); | 109 | layout->addMultiCellWidget( mFormattedNameEdit, 5, 5, 1, 2 ); |
108 | 110 | ||
@@ -250,51 +252,51 @@ QString NameEditDialog::formattedName( const KABC::Addressee &addr, int type ) | |||
250 | return retval.stripWhiteSpace (); | 252 | return retval.stripWhiteSpace (); |
251 | } | 253 | } |
252 | 254 | ||
253 | void NameEditDialog::parseBoxChanged( bool value ) | 255 | void NameEditDialog::parseBoxChanged( bool value ) |
254 | { | 256 | { |
255 | //AddresseeConfig::instance()->setUid( addr.uid() ); | 257 | //AddresseeConfig::instance()->setUid( addr.uid() ); |
256 | AddresseeConfig::instance()->setAutomaticNameParsing( value ); | 258 | AddresseeConfig::instance()->setAutomaticNameParsing( value ); |
257 | } | 259 | } |
258 | 260 | ||
259 | void NameEditDialog::typeChanged( int pos ) | 261 | void NameEditDialog::typeChanged( int pos ) |
260 | { | 262 | { |
261 | mFormattedNameEdit->setEnabled( pos == 0 ); | 263 | mFormattedNameEdit->setEnabled( pos == 0 ); |
262 | } | 264 | } |
263 | 265 | ||
264 | void NameEditDialog::modified() | 266 | void NameEditDialog::modified() |
265 | { | 267 | { |
266 | mChanged = true; | 268 | mChanged = true; |
267 | } | 269 | } |
268 | 270 | ||
269 | void NameEditDialog::updateTypeCombo() | 271 | void NameEditDialog::updateTypeCombo() |
270 | { | 272 | { |
271 | KABC::Addressee addr; | 273 | KABC::Addressee addr; |
272 | addr.setPrefix( mPrefixCombo->currentText() ); | 274 | addr.setPrefix( mPrefixCombo->currentText() ); |
273 | addr.setGivenName( mGivenNameEdit->text() ); | 275 | addr.setGivenName( mGivenNameEdit->text() ); |
274 | addr.setAdditionalName( mAdditionalNameEdit->text() ); | 276 | addr.setAdditionalName( mAdditionalNameEdit->text() ); |
275 | addr.setFamilyName( mFamilyNameEdit->text() ); | 277 | addr.setFamilyName( mFamilyNameEdit->text() ); |
276 | addr.setSuffix( mSuffixCombo->currentText() ); | 278 | addr.setSuffix( mSuffixCombo->currentText() ); |
277 | 279 | ||
278 | int pos = mFormattedNameCombo->currentItem(); | 280 | int pos = mFormattedNameCombo->currentItem(); |
279 | 281 | ||
280 | mFormattedNameCombo->clear(); | 282 | mFormattedNameCombo->clear(); |
281 | mFormattedNameCombo->insertItem( i18n( "Custom" ) ); | 283 | mFormattedNameCombo->insertItem( i18n( "Custom" ) ); |
282 | mFormattedNameCombo->insertItem( formattedName( addr, SimpleName ) ); | 284 | mFormattedNameCombo->insertItem( formattedName( addr, SimpleName ) ); |
283 | mFormattedNameCombo->insertItem( formattedName( addr, FullName ) ); | 285 | mFormattedNameCombo->insertItem( formattedName( addr, FullName ) ); |
284 | mFormattedNameCombo->insertItem( formattedName( addr, ReverseName ) ); | 286 | mFormattedNameCombo->insertItem( formattedName( addr, ReverseName ) ); |
285 | 287 | ||
286 | mFormattedNameCombo->setCurrentItem( pos ); | 288 | mFormattedNameCombo->setCurrentItem( pos ); |
287 | } | 289 | } |
288 | 290 | ||
289 | void NameEditDialog::slotHelp() | 291 | void NameEditDialog::slotHelp() |
290 | { | 292 | { |
291 | #ifndef KAB_EMBEDDED | 293 | #ifndef KAB_EMBEDDED |
292 | kapp->invokeHelp( "managing-contacts-automatic-nameparsing" ); | 294 | kapp->invokeHelp( "managing-contacts-automatic-nameparsing" ); |
293 | #else //KAB_EMBEDDED | 295 | #else //KAB_EMBEDDED |
294 | qDebug("NameEditDialog::slotHelp Help is not supported yet"); | 296 | qDebug("NameEditDialog::slotHelp Help is not supported yet"); |
295 | #endif //KAB_EMBEDDED | 297 | #endif //KAB_EMBEDDED |
296 | } | 298 | } |
297 | 299 | ||
298 | #ifndef KAB_EMBEDDED | 300 | #ifndef KAB_EMBEDDED_ |
299 | #include "nameeditdialog.moc" | 301 | #include "moc_nameeditdialog.cpp" |
300 | #endif //KAB_EMBEDDED | 302 | #endif //KAB_EMBEDDED |