-rw-r--r-- | kaddressbook/addresseeeditorwidget.cpp | 21 | ||||
-rw-r--r-- | kaddressbook/phoneeditwidget.cpp | 8 | ||||
-rw-r--r-- | kaddressbook/phoneeditwidget.h | 112 |
3 files changed, 18 insertions, 123 deletions
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp index 966efa5..c4083a9 100644 --- a/kaddressbook/addresseeeditorwidget.cpp +++ b/kaddressbook/addresseeeditorwidget.cpp | |||
@@ -1,1394 +1,1399 @@ | |||
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 <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qhbox.h> | 25 | #include <qhbox.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qlistbox.h> | 28 | #include <qlistbox.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qtabwidget.h> | 30 | #include <qtabwidget.h> |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | 32 | ||
33 | #ifndef KAB_EMBEDDED | 33 | #ifndef KAB_EMBEDDED |
34 | #include <qtextedit.h> | 34 | #include <qtextedit.h> |
35 | 35 | ||
36 | #include <kaccelmanager.h> | 36 | #include <kaccelmanager.h> |
37 | #include "keywidget.h" | 37 | #include "keywidget.h" |
38 | #include "soundwidget.h" | 38 | #include "soundwidget.h" |
39 | 39 | ||
40 | #else //KAB_EMBEDDED | 40 | #else //KAB_EMBEDDED |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #endif //KAB_EMBEDDED | 42 | #endif //KAB_EMBEDDED |
43 | 43 | ||
44 | 44 | ||
45 | #include "keywidget.h" | 45 | #include "keywidget.h" |
46 | #include "geowidget.h" | 46 | #include "geowidget.h" |
47 | #include "imagewidget.h" | 47 | #include "imagewidget.h" |
48 | #include "nameeditdialog.h" | 48 | #include "nameeditdialog.h" |
49 | #include "phoneeditwidget.h" | 49 | #include "phoneeditwidget.h" |
50 | #include "secrecywidget.h" | 50 | #include "secrecywidget.h" |
51 | 51 | ||
52 | 52 | ||
53 | #include <qtoolbutton.h> | 53 | #include <qtoolbutton.h> |
54 | #include <qtooltip.h> | 54 | #include <qtooltip.h> |
55 | 55 | ||
56 | #include <kapplication.h> | 56 | #include <kapplication.h> |
57 | #include <kconfig.h> | 57 | #include <kconfig.h> |
58 | #include <kcombobox.h> | 58 | #include <kcombobox.h> |
59 | #include <kdebug.h> | 59 | #include <kdebug.h> |
60 | #include <kdialogbase.h> | 60 | #include <kdialogbase.h> |
61 | #include <kglobal.h> | 61 | #include <kglobal.h> |
62 | #include <kiconloader.h> | 62 | #include <kiconloader.h> |
63 | #include <klineedit.h> | 63 | #include <klineedit.h> |
64 | #include <klocale.h> | 64 | #include <klocale.h> |
65 | #include <kmessagebox.h> | 65 | #include <kmessagebox.h> |
66 | #include <kseparator.h> | 66 | #include <kseparator.h> |
67 | #include <ksqueezedtextlabel.h> | 67 | #include <ksqueezedtextlabel.h> |
68 | 68 | ||
69 | #include <libkdepim/categoryeditdialog.h> | 69 | #include <libkdepim/categoryeditdialog.h> |
70 | #include <libkdepim/categoryselectdialog.h> | 70 | #include <libkdepim/categoryselectdialog.h> |
71 | 71 | ||
72 | #include <libkdepim/kdateedit.h> | 72 | #include <libkdepim/kdateedit.h> |
73 | 73 | ||
74 | #include "addresseditwidget.h" | 74 | #include "addresseditwidget.h" |
75 | #include "emaileditwidget.h" | 75 | #include "emaileditwidget.h" |
76 | #include "kabcore.h" | 76 | #include "kabcore.h" |
77 | #include "kabprefs.h" | 77 | #include "kabprefs.h" |
78 | 78 | ||
79 | #include "addresseeeditorwidget.h" | 79 | #include "addresseeeditorwidget.h" |
80 | 80 | ||
81 | 81 | ||
82 | 82 | ||
83 | AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension, | 83 | AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension, |
84 | QWidget *parent, const char *name ) | 84 | QWidget *parent, const char *name ) |
85 | : ExtensionWidget( core, parent, name ), mIsExtension( isExtension ), | 85 | : ExtensionWidget( core, parent, name ), mIsExtension( isExtension ), |
86 | mBlockSignals( false ) | 86 | mBlockSignals( false ) |
87 | { | 87 | { |
88 | 88 | ||
89 | mAConfig = AddresseeConfig::instance(); | 89 | mAConfig = AddresseeConfig::instance(); |
90 | 90 | ||
91 | mFormattedNameType = NameEditDialog::CustomName; | 91 | mFormattedNameType = NameEditDialog::CustomName; |
92 | initGUI(); | 92 | initGUI(); |
93 | mCategoryDialog = 0; | 93 | mCategoryDialog = 0; |
94 | mCategoryEditDialog = 0; | 94 | mCategoryEditDialog = 0; |
95 | 95 | ||
96 | // Load the empty addressee as defaults | 96 | // Load the empty addressee as defaults |
97 | load(); | 97 | load(); |
98 | 98 | ||
99 | mDirty = false; | 99 | mDirty = false; |
100 | } | 100 | } |
101 | 101 | ||
102 | AddresseeEditorWidget::~AddresseeEditorWidget() | 102 | AddresseeEditorWidget::~AddresseeEditorWidget() |
103 | { | 103 | { |
104 | kdDebug(5720) << "~AddresseeEditorWidget()" << endl; | 104 | kdDebug(5720) << "~AddresseeEditorWidget()" << endl; |
105 | } | 105 | } |
106 | 106 | ||
107 | void AddresseeEditorWidget::contactsSelectionChanged() | 107 | void AddresseeEditorWidget::contactsSelectionChanged() |
108 | { | 108 | { |
109 | KABC::Addressee::List list = selectedContacts(); | 109 | KABC::Addressee::List list = selectedContacts(); |
110 | 110 | ||
111 | mAddressee = list[ 0 ]; | 111 | mAddressee = list[ 0 ]; |
112 | load(); | 112 | load(); |
113 | } | 113 | } |
114 | 114 | ||
115 | void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr ) | 115 | void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr ) |
116 | { | 116 | { |
117 | mAddressee = addr; | 117 | mAddressee = addr; |
118 | load(); | 118 | load(); |
119 | } | 119 | } |
120 | 120 | ||
121 | const KABC::Addressee &AddresseeEditorWidget::addressee() | 121 | const KABC::Addressee &AddresseeEditorWidget::addressee() |
122 | { | 122 | { |
123 | return mAddressee; | 123 | return mAddressee; |
124 | } | 124 | } |
125 | 125 | ||
126 | void AddresseeEditorWidget::textChanged( const QString& ) | 126 | void AddresseeEditorWidget::textChanged( const QString& ) |
127 | { | 127 | { |
128 | emitModified(); | 128 | emitModified(); |
129 | } | 129 | } |
130 | 130 | ||
131 | void AddresseeEditorWidget::initGUI() | 131 | void AddresseeEditorWidget::initGUI() |
132 | { | 132 | { |
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 | bool horLayout = false; | 157 | bool horLayout = false; |
158 | int maxCol = 1; | 158 | int maxCol = 1; |
159 | if ( QApplication::desktop()->width() == 640 || QApplication::desktop()->width() == 320 ) { | 159 | if ( QApplication::desktop()->width() == 640 || QApplication::desktop()->width() == 320 ) { |
160 | horLayout = true; | 160 | horLayout = true; |
161 | maxCol = 3; | 161 | maxCol = 3; |
162 | } | 162 | } |
163 | QGridLayout *layout = new QGridLayout( tab1, 8-maxCol, maxCol ); | 163 | QGridLayout *layout = new QGridLayout( tab1, 7-maxCol, maxCol ); |
164 | 164 | ||
165 | layout->setMargin( KDialogBase::marginHintSmall() ); | 165 | layout->setMargin( KDialogBase::marginHintSmall() ); |
166 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 166 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
167 | 167 | ||
168 | QLabel *label; | 168 | QLabel *label; |
169 | KSeparator* bar; | 169 | KSeparator* bar; |
170 | QPushButton *button; | 170 | QPushButton *button; |
171 | 171 | ||
172 | ////////////////////////////////// | 172 | ////////////////////////////////// |
173 | // Upper left group (person info) | 173 | // Upper left group (person info) |
174 | 174 | ||
175 | // Person icon | 175 | // Person icon |
176 | /* LR | 176 | /* LR |
177 | label = new QLabel( tab1 ); | 177 | label = new QLabel( tab1 ); |
178 | //US ambiguous call. Add one more parameter | 178 | //US ambiguous call. Add one more parameter |
179 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); | 179 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); |
180 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); | 180 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); |
181 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); | 181 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); |
182 | */ | 182 | */ |
183 | // First name | 183 | // First name |
184 | button = new QPushButton( i18n( "Name..." ), tab1 ); | 184 | button = new QPushButton( i18n( "Name..." ), tab1 ); |
185 | //US QToolTip::add( button, i18n( "Edit the contact's name" ) ); | 185 | //US QToolTip::add( button, i18n( "Edit the contact's name" ) ); |
186 | mNameEdit = new KLineEdit( tab1, "mNameEdit" ); | 186 | mNameEdit = new KLineEdit( tab1, "mNameEdit" ); |
187 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), | 187 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), |
188 | SLOT( nameTextChanged( const QString& ) ) ); | 188 | SLOT( nameTextChanged( const QString& ) ) ); |
189 | connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) ); | 189 | connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) ); |
190 | 190 | ||
191 | mNameLabel = new KSqueezedTextLabel( tab1 ); | 191 | mNameLabel = new KSqueezedTextLabel( tab1 ); |
192 | mNameLabel->hide(); | 192 | mNameLabel->hide(); |
193 | 193 | ||
194 | layout->addWidget( button, 0, 0 ); | 194 | layout->addWidget( button, 0, 0 ); |
195 | layout->addWidget( mNameEdit, 0, 1 ); | 195 | layout->addWidget( mNameEdit, 0, 1 ); |
196 | layout->addWidget( mNameLabel, 0, 1 ); | 196 | layout->addWidget( mNameLabel, 0, 1 ); |
197 | 197 | ||
198 | button = new QPushButton( i18n( "Role:" ), tab1 ); | 198 | button = new QPushButton( i18n( "Role:" ), tab1 ); |
199 | connect( button, SIGNAL( clicked() ), SLOT( setRole2FN() ) ); | 199 | connect( button, SIGNAL( clicked() ), SLOT( setRole2FN() ) ); |
200 | //label = new QLabel( i18n( "Role:" ), tab1 ); | 200 | //label = new QLabel( i18n( "Role:" ), tab1 ); |
201 | mRoleEdit = new KLineEdit( tab1 ); | 201 | mRoleEdit = new KLineEdit( tab1 ); |
202 | connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ), | 202 | connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ), |
203 | SLOT( textChanged( const QString& ) ) ); | 203 | SLOT( textChanged( const QString& ) ) ); |
204 | //label->setBuddy( mRoleEdit ); | 204 | //label->setBuddy( mRoleEdit ); |
205 | layout->addWidget( button, 1, 0 ); | 205 | if ( horLayout ) { |
206 | layout->addWidget( mRoleEdit, 1, 1 ); | 206 | layout->addWidget( button, 0, 2 ); |
207 | 207 | layout->addWidget( mRoleEdit, 0, 3 ); | |
208 | |||
209 | } else { | ||
210 | layout->addWidget( button, 1, 0 ); | ||
211 | layout->addWidget( mRoleEdit, 1, 1 ); | ||
212 | } | ||
208 | // Organization | 213 | // Organization |
209 | button = new QPushButton( i18n( "Organization:" ), tab1 ); | 214 | button = new QPushButton( i18n( "Organization:" ), tab1 ); |
210 | connect( button, SIGNAL( clicked() ), SLOT( setCompany2FN() ) ); | 215 | connect( button, SIGNAL( clicked() ), SLOT( setCompany2FN() ) ); |
211 | //label = new QLabel( i18n( "Organization:" ), tab1 ); | 216 | //label = new QLabel( i18n( "Organization:" ), tab1 ); |
212 | mOrgEdit = new KLineEdit( tab1 ); | 217 | mOrgEdit = new KLineEdit( tab1 ); |
213 | //label->setBuddy( mOrgEdit ); | 218 | //label->setBuddy( mOrgEdit ); |
214 | connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ), | 219 | connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ), |
215 | SLOT( textChanged( const QString& ) ) ); | 220 | SLOT( textChanged( const QString& ) ) ); |
216 | if ( horLayout ) { | 221 | if ( horLayout ) { |
217 | layout->addWidget( button, 1, 2 ); | 222 | layout->addWidget( button, 1, 2 ); |
218 | layout->addWidget( mOrgEdit, 1, 3 ); | 223 | layout->addWidget( mOrgEdit, 1, 3 ); |
219 | 224 | ||
220 | } else { | 225 | } else { |
221 | layout->addWidget( button, 2, 0 ); | 226 | layout->addWidget( button, 2, 0 ); |
222 | layout->addWidget( mOrgEdit, 2, 1 ); | 227 | layout->addWidget( mOrgEdit, 2, 1 ); |
223 | } | 228 | } |
224 | 229 | ||
225 | // File as (formatted name) | 230 | // File as (formatted name) |
226 | label = new QLabel( i18n( "Format.n.:" ), tab1 ); | 231 | label = new QLabel( i18n( "Format.n.:" ), tab1 ); |
227 | mFormattedNameLabel = new KSqueezedTextLabel( tab1 ); | 232 | mFormattedNameLabel = new KSqueezedTextLabel( tab1 ); |
228 | if ( horLayout ) { | 233 | if ( horLayout ) { |
229 | layout->addWidget( label, 0,2 ); | 234 | layout->addWidget( label, 1,0 ); |
230 | layout->addWidget( mFormattedNameLabel, 0, 3 ); | 235 | layout->addWidget( mFormattedNameLabel, 1, 1 ); |
231 | } else { | 236 | } else { |
232 | layout->addWidget( label, 3, 0 ); | 237 | layout->addWidget( label, 3, 0 ); |
233 | layout->addWidget( mFormattedNameLabel, 3, 1 ); | 238 | layout->addWidget( mFormattedNameLabel, 3, 1 ); |
234 | } | 239 | } |
235 | /* LR | 240 | /* LR |
236 | // Left hand separator. This separator doesn't go all the way | 241 | // Left hand separator. This separator doesn't go all the way |
237 | // across so the dialog still flows from top to bottom | 242 | // across so the dialog still flows from top to bottom |
238 | bar = new KSeparator( KSeparator::HLine, tab1 ); | 243 | bar = new KSeparator( KSeparator::HLine, tab1 ); |
239 | layout->addMultiCellWidget( bar, 4, 4, 0, 2 ); | 244 | layout->addMultiCellWidget( bar, 4, 4, 0, 2 ); |
240 | */ | 245 | */ |
241 | ////////////////////////////////////// | 246 | ////////////////////////////////////// |
242 | 247 | ||
243 | /* LR | 248 | /* LR |
244 | // Phone numbers (upper right) | 249 | // Phone numbers (upper right) |
245 | label = new QLabel( tab1 ); | 250 | label = new QLabel( tab1 ); |
246 | //US loadIcon call is ambiguous. Add one more parameter | 251 | //US loadIcon call is ambiguous. Add one more parameter |
247 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); | 252 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); |
248 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); | 253 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); |
249 | //US layout->addMultiCellWidget( label, 0, 1, 3, 3 ); | 254 | //US layout->addMultiCellWidget( label, 0, 1, 3, 3 ); |
250 | layout->addMultiCellWidget( label, 5, 6, 0, 0 ); | 255 | layout->addMultiCellWidget( label, 5, 6, 0, 0 ); |
251 | */ | 256 | */ |
252 | mPhoneEditWidget = new PhoneEditWidget( tab1 ); | 257 | mPhoneEditWidget = new PhoneEditWidget( tab1 ); |
253 | connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); | 258 | connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); |
254 | //US layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 ); | 259 | //US layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 ); |
255 | int iii; | 260 | int iii; |
256 | #ifndef DESKTOP_VERSION | 261 | #ifndef DESKTOP_VERSION |
257 | iii = 7; | 262 | iii = 7; |
258 | #else | 263 | #else |
259 | iii = 8; | 264 | iii = 8; |
260 | #endif | 265 | #endif |
261 | layout->addMultiCellWidget( mPhoneEditWidget, 4, iii, 0, maxCol ); | 266 | layout->addMultiCellWidget( mPhoneEditWidget, 5-maxCol, 5-maxCol+4, 0, maxCol ); |
262 | ++iii; | 267 | iii = 6-maxCol+4; |
263 | /* LR | 268 | /* LR |
264 | bar = new KSeparator( KSeparator::HLine, tab1 ); | 269 | bar = new KSeparator( KSeparator::HLine, tab1 ); |
265 | //US layout->addMultiCellWidget( bar, 4, 4, 3, 6 ); | 270 | //US layout->addMultiCellWidget( bar, 4, 4, 3, 6 ); |
266 | layout->addMultiCellWidget( bar, 9, 9, 0, 2 ); | 271 | layout->addMultiCellWidget( bar, 9, 9, 0, 2 ); |
267 | */ | 272 | */ |
268 | /*US | 273 | /*US |
269 | ////////////////////////////////////// | 274 | ////////////////////////////////////// |
270 | // Addresses (lower left) | 275 | // Addresses (lower left) |
271 | label = new QLabel( tab1 ); | 276 | label = new QLabel( tab1 ); |
272 | //US loadIcon call is ambiguous. Add one more parameter | 277 | //US loadIcon call is ambiguous. Add one more parameter |
273 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) ); | 278 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) ); |
274 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) ); | 279 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) ); |
275 | layout->addMultiCellWidget( label, 5, 6, 0, 0 ); | 280 | layout->addMultiCellWidget( label, 5, 6, 0, 0 ); |
276 | 281 | ||
277 | mAddressEditWidget = new AddressEditWidget( tab1 ); | 282 | mAddressEditWidget = new AddressEditWidget( tab1 ); |
278 | connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); | 283 | connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); |
279 | layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 ); | 284 | layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 ); |
280 | 285 | ||
281 | ////////////////////////////////////// | 286 | ////////////////////////////////////// |
282 | // Email / Web (lower right) | 287 | // Email / Web (lower right) |
283 | label = new QLabel( tab1 ); | 288 | label = new QLabel( tab1 ); |
284 | //US loadIcon call is ambiguous. Add one more parameter | 289 | //US loadIcon call is ambiguous. Add one more parameter |
285 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) ); | 290 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) ); |
286 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) ); | 291 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) ); |
287 | layout->addMultiCellWidget( label, 5, 6, 3, 3 ); | 292 | layout->addMultiCellWidget( label, 5, 6, 3, 3 ); |
288 | 293 | ||
289 | mEmailWidget = new EmailEditWidget( tab1 ); | 294 | mEmailWidget = new EmailEditWidget( tab1 ); |
290 | connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); | 295 | connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); |
291 | layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 ); | 296 | layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 ); |
292 | 297 | ||
293 | // add the separator | 298 | // add the separator |
294 | bar = new KSeparator( KSeparator::HLine, tab1 ); | 299 | bar = new KSeparator( KSeparator::HLine, tab1 ); |
295 | layout->addMultiCellWidget( bar, 7, 7, 3, 6 ); | 300 | layout->addMultiCellWidget( bar, 7, 7, 3, 6 ); |
296 | 301 | ||
297 | label = new QLabel( tab1 ); | 302 | label = new QLabel( tab1 ); |
298 | //US loadIcon call is ambiguous. Add one more parameter | 303 | //US loadIcon call is ambiguous. Add one more parameter |
299 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) ); | 304 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) ); |
300 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) ); | 305 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) ); |
301 | layout->addMultiCellWidget( label, 8, 9, 3, 3 ); | 306 | layout->addMultiCellWidget( label, 8, 9, 3, 3 ); |
302 | 307 | ||
303 | label = new QLabel( i18n( "URL:" ), tab1 ); | 308 | label = new QLabel( i18n( "URL:" ), tab1 ); |
304 | mURLEdit = new KLineEdit( tab1 ); | 309 | mURLEdit = new KLineEdit( tab1 ); |
305 | connect( mURLEdit, SIGNAL( textChanged( const QString& ) ), | 310 | connect( mURLEdit, SIGNAL( textChanged( const QString& ) ), |
306 | SLOT( textChanged( const QString& ) ) ); | 311 | SLOT( textChanged( const QString& ) ) ); |
307 | label->setBuddy( mURLEdit ); | 312 | label->setBuddy( mURLEdit ); |
308 | layout->addWidget( label, 8, 4 ); | 313 | layout->addWidget( label, 8, 4 ); |
309 | layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 ); | 314 | layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 ); |
310 | 315 | ||
311 | label = new QLabel( i18n( "&IM address:" ), tab1 ); | 316 | label = new QLabel( i18n( "&IM address:" ), tab1 ); |
312 | mIMAddressEdit = new KLineEdit( tab1 ); | 317 | mIMAddressEdit = new KLineEdit( tab1 ); |
313 | connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ), | 318 | connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ), |
314 | SLOT( textChanged( const QString& ) ) ); | 319 | SLOT( textChanged( const QString& ) ) ); |
315 | label->setBuddy( mIMAddressEdit ); | 320 | label->setBuddy( mIMAddressEdit ); |
316 | layout->addWidget( label, 9, 4 ); | 321 | layout->addWidget( label, 9, 4 ); |
317 | layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 ); | 322 | layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 ); |
318 | 323 | ||
319 | layout->addColSpacing( 6, 50 ); | 324 | layout->addColSpacing( 6, 50 ); |
320 | 325 | ||
321 | bar = new KSeparator( KSeparator::HLine, tab1 ); | 326 | bar = new KSeparator( KSeparator::HLine, tab1 ); |
322 | layout->addMultiCellWidget( bar, 10, 10, 0, 6 ); | 327 | layout->addMultiCellWidget( bar, 10, 10, 0, 6 ); |
323 | */ | 328 | */ |
324 | /////////////////////////////////////// | 329 | /////////////////////////////////////// |
325 | QHBox *categoryBox = new QHBox( tab1 ,"cato"); | 330 | QHBox *categoryBox = new QHBox( tab1 ,"cato"); |
326 | categoryBox->setSpacing( KDialogBase::spacingHint() ); | 331 | categoryBox->setSpacing( KDialogBase::spacingHint() ); |
327 | categoryBox->setMargin( KDialogBase::marginHintSmall() ); | 332 | categoryBox->setMargin( KDialogBase::marginHintSmall() ); |
328 | 333 | ||
329 | // Categories | 334 | // Categories |
330 | button = new QPushButton( i18n( "Categories" ), categoryBox ); | 335 | button = new QPushButton( i18n( "Categories" ), categoryBox ); |
331 | connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) ); | 336 | connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) ); |
332 | 337 | ||
333 | mCategoryEdit = new KLineEdit( categoryBox ); | 338 | mCategoryEdit = new KLineEdit( categoryBox ); |
334 | mCategoryEdit->setReadOnly( true ); | 339 | mCategoryEdit->setReadOnly( true ); |
335 | connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ), | 340 | connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ), |
336 | SLOT( textChanged( const QString& ) ) ); | 341 | SLOT( textChanged( const QString& ) ) ); |
337 | 342 | ||
338 | mSecrecyWidget = new SecrecyWidget( categoryBox ); | 343 | mSecrecyWidget = new SecrecyWidget( categoryBox ); |
339 | connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 344 | connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
340 | 345 | ||
341 | //US layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); | 346 | //US layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); |
342 | layout->addMultiCellWidget( categoryBox, iii, iii, 0, maxCol ); | 347 | layout->addMultiCellWidget( categoryBox, iii, iii, 0, maxCol ); |
343 | 348 | ||
344 | // Build the layout and add to the tab widget | 349 | // Build the layout and add to the tab widget |
345 | layout->activate(); // required | 350 | layout->activate(); // required |
346 | 351 | ||
347 | mTabWidget->addTab( tab1, i18n( "&General" ) ); | 352 | mTabWidget->addTab( tab1, i18n( "&General" ) ); |
348 | } | 353 | } |
349 | 354 | ||
350 | void AddresseeEditorWidget::setRole2FN() | 355 | void AddresseeEditorWidget::setRole2FN() |
351 | { | 356 | { |
352 | if ( mRoleEdit->text().isEmpty() ) return; | 357 | if ( mRoleEdit->text().isEmpty() ) return; |
353 | mFormattedNameType = NameEditDialog::CustomName; | 358 | mFormattedNameType = NameEditDialog::CustomName; |
354 | mAddressee.setFormattedName( mRoleEdit->text() ); | 359 | mAddressee.setFormattedName( mRoleEdit->text() ); |
355 | mFormattedNameLabel->setText( mRoleEdit->text() ); | 360 | mFormattedNameLabel->setText( mRoleEdit->text() ); |
356 | mDirty = true; | 361 | mDirty = true; |
357 | } | 362 | } |
358 | void AddresseeEditorWidget::setCompany2FN() | 363 | void AddresseeEditorWidget::setCompany2FN() |
359 | { | 364 | { |
360 | if ( mOrgEdit->text().isEmpty() ) return; | 365 | if ( mOrgEdit->text().isEmpty() ) return; |
361 | mFormattedNameType = NameEditDialog::CustomName; | 366 | mFormattedNameType = NameEditDialog::CustomName; |
362 | mAddressee.setFormattedName( mOrgEdit->text() ); | 367 | mAddressee.setFormattedName( mOrgEdit->text() ); |
363 | mFormattedNameLabel->setText( mOrgEdit->text() ); | 368 | mFormattedNameLabel->setText( mOrgEdit->text() ); |
364 | mDirty = true; | 369 | mDirty = true; |
365 | } | 370 | } |
366 | 371 | ||
367 | void AddresseeEditorWidget::setupTab1_1() | 372 | void AddresseeEditorWidget::setupTab1_1() |
368 | { | 373 | { |
369 | // This is the Address tab | 374 | // This is the Address tab |
370 | QWidget *tab1_1 = new QWidget( mTabWidget ); | 375 | QWidget *tab1_1 = new QWidget( mTabWidget ); |
371 | 376 | ||
372 | //US QGridLayout *layout = new QGridLayout( tab1_1, 11, 7 ); | 377 | //US QGridLayout *layout = new QGridLayout( tab1_1, 11, 7 ); |
373 | QGridLayout *layout = new QGridLayout( tab1_1, 7, 2 ); | 378 | QGridLayout *layout = new QGridLayout( tab1_1, 7, 2 ); |
374 | layout->setMargin( KDialogBase::marginHintSmall() ); | 379 | layout->setMargin( KDialogBase::marginHintSmall() ); |
375 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 380 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
376 | 381 | ||
377 | QLabel *label; | 382 | QLabel *label; |
378 | KSeparator* bar; | 383 | KSeparator* bar; |
379 | QPushButton *button; | 384 | QPushButton *button; |
380 | 385 | ||
381 | /*US | 386 | /*US |
382 | ////////////////////////////////// | 387 | ////////////////////////////////// |
383 | // Upper left group (person info) | 388 | // Upper left group (person info) |
384 | 389 | ||
385 | // Person icon | 390 | // Person icon |
386 | label = new QLabel( tab1 ); | 391 | label = new QLabel( tab1 ); |
387 | //US ambiguous call. Add one more parameter | 392 | //US ambiguous call. Add one more parameter |
388 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); | 393 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); |
389 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); | 394 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); |
390 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); | 395 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); |
391 | 396 | ||
392 | // First name | 397 | // First name |
393 | button = new QPushButton( i18n( "Name..." ), tab1 ); | 398 | button = new QPushButton( i18n( "Name..." ), tab1 ); |
394 | QToolTip::add( button, i18n( "Edit the contact's name" ) ); | 399 | QToolTip::add( button, i18n( "Edit the contact's name" ) ); |
395 | mNameEdit = new KLineEdit( tab1, "mNameEdit" ); | 400 | mNameEdit = new KLineEdit( tab1, "mNameEdit" ); |
396 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), | 401 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), |
397 | SLOT( nameTextChanged( const QString& ) ) ); | 402 | SLOT( nameTextChanged( const QString& ) ) ); |
398 | connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) ); | 403 | connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) ); |
399 | 404 | ||
400 | #ifndef KAB_EMBEDDED | 405 | #ifndef KAB_EMBEDDED |
401 | mNameLabel = new KSqueezedTextLabel( tab1 ); | 406 | mNameLabel = new KSqueezedTextLabel( tab1 ); |
402 | mNameLabel->hide(); | 407 | mNameLabel->hide(); |
403 | #else //KAB_EMBEDDED | 408 | #else //KAB_EMBEDDED |
404 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); | 409 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); |
405 | #endif //KAB_EMBEDDED | 410 | #endif //KAB_EMBEDDED |
406 | 411 | ||
407 | layout->addWidget( button, 0, 1 ); | 412 | layout->addWidget( button, 0, 1 ); |
408 | layout->addWidget( mNameEdit, 0, 2 ); | 413 | layout->addWidget( mNameEdit, 0, 2 ); |
409 | 414 | ||
410 | #ifndef KAB_EMBEDDED | 415 | #ifndef KAB_EMBEDDED |
411 | layout->addWidget( mNameLabel, 0, 2 ); | 416 | layout->addWidget( mNameLabel, 0, 2 ); |
412 | #else //KAB_EMBEDDED | 417 | #else //KAB_EMBEDDED |
413 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); | 418 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); |
414 | #endif //KAB_EMBEDDED | 419 | #endif //KAB_EMBEDDED |
415 | 420 | ||
416 | label = new QLabel( i18n( "Role:" ), tab1 ); | 421 | label = new QLabel( i18n( "Role:" ), tab1 ); |
417 | mRoleEdit = new KLineEdit( tab1 ); | 422 | mRoleEdit = new KLineEdit( tab1 ); |
418 | connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ), | 423 | connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ), |
419 | SLOT( textChanged( const QString& ) ) ); | 424 | SLOT( textChanged( const QString& ) ) ); |
420 | label->setBuddy( mRoleEdit ); | 425 | label->setBuddy( mRoleEdit ); |
421 | layout->addWidget( label, 1, 1 ); | 426 | layout->addWidget( label, 1, 1 ); |
422 | layout->addWidget( mRoleEdit, 1, 2 ); | 427 | layout->addWidget( mRoleEdit, 1, 2 ); |
423 | 428 | ||
424 | // Organization | 429 | // Organization |
425 | label = new QLabel( i18n( "Organization:" ), tab1 ); | 430 | label = new QLabel( i18n( "Organization:" ), tab1 ); |
426 | mOrgEdit = new KLineEdit( tab1 ); | 431 | mOrgEdit = new KLineEdit( tab1 ); |
427 | label->setBuddy( mOrgEdit ); | 432 | label->setBuddy( mOrgEdit ); |
428 | connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ), | 433 | connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ), |
429 | SLOT( textChanged( const QString& ) ) ); | 434 | SLOT( textChanged( const QString& ) ) ); |
430 | layout->addWidget( label, 2, 1 ); | 435 | layout->addWidget( label, 2, 1 ); |
431 | layout->addWidget( mOrgEdit, 2, 2 ); | 436 | layout->addWidget( mOrgEdit, 2, 2 ); |
432 | 437 | ||
433 | // File as (formatted name) | 438 | // File as (formatted name) |
434 | label = new QLabel( i18n( "Formatted name:" ), tab1 ); | 439 | label = new QLabel( i18n( "Formatted name:" ), tab1 ); |
435 | #ifndef KAB_EMBEDDED | 440 | #ifndef KAB_EMBEDDED |
436 | mFormattedNameLabel = new KSqueezedTextLabel( tab1 ); | 441 | mFormattedNameLabel = new KSqueezedTextLabel( tab1 ); |
437 | #else //KAB_EMBEDDED | 442 | #else //KAB_EMBEDDED |
438 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); | 443 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); |
439 | #endif //KAB_EMBEDDED | 444 | #endif //KAB_EMBEDDED |
440 | layout->addWidget( label, 3, 1 ); | 445 | layout->addWidget( label, 3, 1 ); |
441 | #ifndef KAB_EMBEDDED | 446 | #ifndef KAB_EMBEDDED |
442 | layout->addWidget( mFormattedNameLabel, 3, 2 ); | 447 | layout->addWidget( mFormattedNameLabel, 3, 2 ); |
443 | #else //KAB_EMBEDDED | 448 | #else //KAB_EMBEDDED |
444 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); | 449 | qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); |
445 | #endif //KAB_EMBEDDED | 450 | #endif //KAB_EMBEDDED |
446 | 451 | ||
447 | // Left hand separator. This separator doesn't go all the way | 452 | // Left hand separator. This separator doesn't go all the way |
448 | // across so the dialog still flows from top to bottom | 453 | // across so the dialog still flows from top to bottom |
449 | bar = new KSeparator( KSeparator::HLine, tab1 ); | 454 | bar = new KSeparator( KSeparator::HLine, tab1 ); |
450 | layout->addMultiCellWidget( bar, 4, 4, 0, 2 ); | 455 | layout->addMultiCellWidget( bar, 4, 4, 0, 2 ); |
451 | 456 | ||
452 | ////////////////////////////////////// | 457 | ////////////////////////////////////// |
453 | // Phone numbers (upper right) | 458 | // Phone numbers (upper right) |
454 | label = new QLabel( tab1 ); | 459 | label = new QLabel( tab1 ); |
455 | //US loadIcon call is ambiguous. Add one more parameter | 460 | //US loadIcon call is ambiguous. Add one more parameter |
456 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); | 461 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); |
457 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); | 462 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); |
458 | layout->addMultiCellWidget( label, 0, 1, 3, 3 ); | 463 | layout->addMultiCellWidget( label, 0, 1, 3, 3 ); |
459 | 464 | ||
460 | mPhoneEditWidget = new PhoneEditWidget( tab1 ); | 465 | mPhoneEditWidget = new PhoneEditWidget( tab1 ); |
461 | connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); | 466 | connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); |
462 | layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 ); | 467 | layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 ); |
463 | 468 | ||
464 | bar = new KSeparator( KSeparator::HLine, tab1 ); | 469 | bar = new KSeparator( KSeparator::HLine, tab1 ); |
465 | layout->addMultiCellWidget( bar, 4, 4, 3, 6 ); | 470 | layout->addMultiCellWidget( bar, 4, 4, 3, 6 ); |
466 | */ | 471 | */ |
467 | ////////////////////////////////////// | 472 | ////////////////////////////////////// |
468 | // Addresses (lower left) | 473 | // Addresses (lower left) |
469 | /* LR | 474 | /* LR |
470 | label = new QLabel( tab1_1 ); | 475 | label = new QLabel( tab1_1 ); |
471 | //US loadIcon call is ambiguous. Add one more parameter | 476 | //US loadIcon call is ambiguous. Add one more parameter |
472 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) ); | 477 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) ); |
473 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) ); | 478 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) ); |
474 | //US layout->addMultiCellWidget( label, 5, 6, 0, 0 ); | 479 | //US layout->addMultiCellWidget( label, 5, 6, 0, 0 ); |
475 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); | 480 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); |
476 | */ | 481 | */ |
477 | 482 | ||
478 | mAddressEditWidget = new AddressEditWidget( tab1_1 ); | 483 | mAddressEditWidget = new AddressEditWidget( tab1_1 ); |
479 | connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); | 484 | connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); |
480 | //US layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 ); | 485 | //US layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 ); |
481 | layout->addMultiCellWidget( mAddressEditWidget, 0, 4, 0, 1 ); | 486 | layout->addMultiCellWidget( mAddressEditWidget, 0, 4, 0, 1 ); |
482 | 487 | ||
483 | //US | 488 | //US |
484 | /* LR | 489 | /* LR |
485 | bar = new KSeparator( KSeparator::HLine, tab1_1 ); | 490 | bar = new KSeparator( KSeparator::HLine, tab1_1 ); |
486 | layout->addMultiCellWidget( bar, 5, 5, 0, 3 ); | 491 | layout->addMultiCellWidget( bar, 5, 5, 0, 3 ); |
487 | */ | 492 | */ |
488 | 493 | ||
489 | ////////////////////////////////////// | 494 | ////////////////////////////////////// |
490 | // Email / Web (lower right) | 495 | // Email / Web (lower right) |
491 | /* LR | 496 | /* LR |
492 | label = new QLabel( tab1_1 ); | 497 | label = new QLabel( tab1_1 ); |
493 | //US loadIcon call is ambiguous. Add one more parameter | 498 | //US loadIcon call is ambiguous. Add one more parameter |
494 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) ); | 499 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) ); |
495 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) ); | 500 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) ); |
496 | //US layout->addMultiCellWidget( label, 5, 6, 3, 3 ); | 501 | //US layout->addMultiCellWidget( label, 5, 6, 3, 3 ); |
497 | layout->addMultiCellWidget( label, 6, 7, 0, 0 ); | 502 | layout->addMultiCellWidget( label, 6, 7, 0, 0 ); |
498 | */ | 503 | */ |
499 | mEmailWidget = new EmailEditWidget( tab1_1 ); | 504 | mEmailWidget = new EmailEditWidget( tab1_1 ); |
500 | connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); | 505 | connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); |
501 | //US layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 ); | 506 | //US layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 ); |
502 | layout->addMultiCellWidget( mEmailWidget, 5, 6, 0, 1 ); | 507 | layout->addMultiCellWidget( mEmailWidget, 5, 6, 0, 1 ); |
503 | 508 | ||
504 | /* LR | 509 | /* LR |
505 | // add the separator | 510 | // add the separator |
506 | bar = new KSeparator( KSeparator::HLine, tab1_1 ); | 511 | bar = new KSeparator( KSeparator::HLine, tab1_1 ); |
507 | //US layout->addMultiCellWidget( bar, 7, 7, 3, 6 ); | 512 | //US layout->addMultiCellWidget( bar, 7, 7, 3, 6 ); |
508 | layout->addMultiCellWidget( bar, 8, 8, 0, 3 ); | 513 | layout->addMultiCellWidget( bar, 8, 8, 0, 3 ); |
509 | 514 | ||
510 | label = new QLabel( tab1_1 ); | 515 | label = new QLabel( tab1_1 ); |
511 | //US loadIcon call is ambiguous. Add one more parameter | 516 | //US loadIcon call is ambiguous. Add one more parameter |
512 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) ); | 517 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) ); |
513 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) ); | 518 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) ); |
514 | //US layout->addMultiCellWidget( label, 8, 9, 3, 3 ); | 519 | //US layout->addMultiCellWidget( label, 8, 9, 3, 3 ); |
515 | layout->addMultiCellWidget( label, 9, 10, 0, 0 ); | 520 | layout->addMultiCellWidget( label, 9, 10, 0, 0 ); |
516 | */ | 521 | */ |
517 | label = new QLabel( i18n( "URL:" ), tab1_1 ); | 522 | label = new QLabel( i18n( "URL:" ), tab1_1 ); |
518 | mURLEdit = new KLineEdit( tab1_1 ); | 523 | mURLEdit = new KLineEdit( tab1_1 ); |
519 | connect( mURLEdit, SIGNAL( textChanged( const QString& ) ), | 524 | connect( mURLEdit, SIGNAL( textChanged( const QString& ) ), |
520 | SLOT( textChanged( const QString& ) ) ); | 525 | SLOT( textChanged( const QString& ) ) ); |
521 | label->setBuddy( mURLEdit ); | 526 | label->setBuddy( mURLEdit ); |
522 | //US layout->addWidget( label, 8, 4 ); | 527 | //US layout->addWidget( label, 8, 4 ); |
523 | layout->addWidget( label, 7,0 ); | 528 | layout->addWidget( label, 7,0 ); |
524 | //US layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 ); | 529 | //US layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 ); |
525 | layout->addWidget( mURLEdit, 7, 1); | 530 | layout->addWidget( mURLEdit, 7, 1); |
526 | 531 | ||
527 | label = new QLabel( i18n( "&IM address:" ), tab1_1 ); | 532 | label = new QLabel( i18n( "&IM address:" ), tab1_1 ); |
528 | mIMAddressEdit = new KLineEdit( tab1_1 ); | 533 | mIMAddressEdit = new KLineEdit( tab1_1 ); |
529 | connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ), | 534 | connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ), |
530 | SLOT( textChanged( const QString& ) ) ); | 535 | SLOT( textChanged( const QString& ) ) ); |
531 | label->setBuddy( mIMAddressEdit ); | 536 | label->setBuddy( mIMAddressEdit ); |
532 | //US layout->addWidget( label, 9, 4 ); | 537 | //US layout->addWidget( label, 9, 4 ); |
533 | layout->addWidget( label, 8, 0 ); | 538 | layout->addWidget( label, 8, 0 ); |
534 | //US layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 ); | 539 | //US layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 ); |
535 | layout->addWidget( mIMAddressEdit, 8,1 ); | 540 | layout->addWidget( mIMAddressEdit, 8,1 ); |
536 | 541 | ||
537 | //US layout->addColSpacing( 6, 50 ); | 542 | //US layout->addColSpacing( 6, 50 ); |
538 | 543 | ||
539 | //US bar = new KSeparator( KSeparator::HLine, tab1_1 ); | 544 | //US bar = new KSeparator( KSeparator::HLine, tab1_1 ); |
540 | //US layout->addMultiCellWidget( bar, 10, 10, 0, 6 ); | 545 | //US layout->addMultiCellWidget( bar, 10, 10, 0, 6 ); |
541 | 546 | ||
542 | /*US | 547 | /*US |
543 | /////////////////////////////////////// | 548 | /////////////////////////////////////// |
544 | QHBox *categoryBox = new QHBox( tab1 ); | 549 | QHBox *categoryBox = new QHBox( tab1 ); |
545 | categoryBox->setSpacing( KDialogBase::spacingHintSmall() ); | 550 | categoryBox->setSpacing( KDialogBase::spacingHintSmall() ); |
546 | 551 | ||
547 | // Categories | 552 | // Categories |
548 | button = new QPushButton( i18n( "Categories" ), categoryBox ); | 553 | button = new QPushButton( i18n( "Categories" ), categoryBox ); |
549 | connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) ); | 554 | connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) ); |
550 | 555 | ||
551 | mCategoryEdit = new KLineEdit( categoryBox ); | 556 | mCategoryEdit = new KLineEdit( categoryBox ); |
552 | mCategoryEdit->setReadOnly( true ); | 557 | mCategoryEdit->setReadOnly( true ); |
553 | connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ), | 558 | connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ), |
554 | SLOT( textChanged( const QString& ) ) ); | 559 | SLOT( textChanged( const QString& ) ) ); |
555 | 560 | ||
556 | mSecrecyWidget = new SecrecyWidget( categoryBox ); | 561 | mSecrecyWidget = new SecrecyWidget( categoryBox ); |
557 | connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 562 | connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
558 | 563 | ||
559 | layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); | 564 | layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); |
560 | */ | 565 | */ |
561 | // Build the layout and add to the tab widget | 566 | // Build the layout and add to the tab widget |
562 | layout->activate(); // required | 567 | layout->activate(); // required |
563 | 568 | ||
564 | mTabWidget->addTab( tab1_1, i18n( "&Address" ) ); | 569 | mTabWidget->addTab( tab1_1, i18n( "&Address" ) ); |
565 | } | 570 | } |
566 | 571 | ||
567 | 572 | ||
568 | 573 | ||
569 | void AddresseeEditorWidget::setupTab2() | 574 | void AddresseeEditorWidget::setupTab2() |
570 | { | 575 | { |
571 | // This is the Details tab | 576 | // This is the Details tab |
572 | QWidget *tab2 = new QWidget( mTabWidget ); | 577 | QWidget *tab2 = new QWidget( mTabWidget ); |
573 | 578 | ||
574 | QGridLayout *layout = new QGridLayout( tab2, 8, 3 ); | 579 | QGridLayout *layout = new QGridLayout( tab2, 8, 3 ); |
575 | layout->setMargin( KDialogBase::marginHintSmall() ); | 580 | layout->setMargin( KDialogBase::marginHintSmall() ); |
576 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 581 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
577 | 582 | ||
578 | QLabel *label; | 583 | QLabel *label; |
579 | KSeparator* bar; | 584 | KSeparator* bar; |
580 | 585 | ||
581 | /////////////////////// | 586 | /////////////////////// |
582 | // Office info | 587 | // Office info |
583 | 588 | ||
584 | // Department | 589 | // Department |
585 | label = new QLabel( tab2 ); | 590 | label = new QLabel( tab2 ); |
586 | //US loadIcon call is ambiguous. Add one more parameter | 591 | //US loadIcon call is ambiguous. Add one more parameter |
587 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); | 592 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); |
588 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); | 593 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); |
589 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); | 594 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); |
590 | 595 | ||
591 | label = new QLabel( i18n( "Department:" ), tab2 ); | 596 | label = new QLabel( i18n( "Department:" ), tab2 ); |
592 | layout->addWidget( label, 0, 1 ); | 597 | layout->addWidget( label, 0, 1 ); |
593 | mDepartmentEdit = new KLineEdit( tab2 ); | 598 | mDepartmentEdit = new KLineEdit( tab2 ); |
594 | connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), | 599 | connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), |
595 | SLOT( textChanged( const QString& ) ) ); | 600 | SLOT( textChanged( const QString& ) ) ); |
596 | label->setBuddy( mDepartmentEdit ); | 601 | label->setBuddy( mDepartmentEdit ); |
597 | layout->addWidget( mDepartmentEdit, 0, 2 ); | 602 | layout->addWidget( mDepartmentEdit, 0, 2 ); |
598 | 603 | ||
599 | label = new QLabel( i18n( "Office:" ), tab2 ); | 604 | label = new QLabel( i18n( "Office:" ), tab2 ); |
600 | layout->addWidget( label, 1, 1 ); | 605 | layout->addWidget( label, 1, 1 ); |
601 | mOfficeEdit = new KLineEdit( tab2 ); | 606 | mOfficeEdit = new KLineEdit( tab2 ); |
602 | connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ), | 607 | connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ), |
603 | SLOT( textChanged( const QString& ) ) ); | 608 | SLOT( textChanged( const QString& ) ) ); |
604 | label->setBuddy( mOfficeEdit ); | 609 | label->setBuddy( mOfficeEdit ); |
605 | layout->addWidget( mOfficeEdit, 1, 2 ); | 610 | layout->addWidget( mOfficeEdit, 1, 2 ); |
606 | 611 | ||
607 | label = new QLabel( i18n( "Profession:" ), tab2 ); | 612 | label = new QLabel( i18n( "Profession:" ), tab2 ); |
608 | layout->addWidget( label, 2, 1 ); | 613 | layout->addWidget( label, 2, 1 ); |
609 | mProfessionEdit = new KLineEdit( tab2 ); | 614 | mProfessionEdit = new KLineEdit( tab2 ); |
610 | connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ), | 615 | connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ), |
611 | SLOT( textChanged( const QString& ) ) ); | 616 | SLOT( textChanged( const QString& ) ) ); |
612 | label->setBuddy( mProfessionEdit ); | 617 | label->setBuddy( mProfessionEdit ); |
613 | layout->addWidget( mProfessionEdit, 2, 2 ); | 618 | layout->addWidget( mProfessionEdit, 2, 2 ); |
614 | 619 | ||
615 | label = new QLabel( i18n( "Manager\'s name:" ), tab2 ); | 620 | label = new QLabel( i18n( "Manager\'s name:" ), tab2 ); |
616 | //US layout->addWidget( label, 0, 3 ); | 621 | //US layout->addWidget( label, 0, 3 ); |
617 | layout->addWidget( label, 3, 1 ); | 622 | layout->addWidget( label, 3, 1 ); |
618 | mManagerEdit = new KLineEdit( tab2 ); | 623 | mManagerEdit = new KLineEdit( tab2 ); |
619 | connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ), | 624 | connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ), |
620 | SLOT( textChanged( const QString& ) ) ); | 625 | SLOT( textChanged( const QString& ) ) ); |
621 | label->setBuddy( mManagerEdit ); | 626 | label->setBuddy( mManagerEdit ); |
622 | //US layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 ); | 627 | //US layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 ); |
623 | layout->addWidget( mManagerEdit, 3, 2 ); | 628 | layout->addWidget( mManagerEdit, 3, 2 ); |
624 | 629 | ||
625 | label = new QLabel( i18n( "Assistant's name:" ), tab2 ); | 630 | label = new QLabel( i18n( "Assistant's name:" ), tab2 ); |
626 | //US layout->addWidget( label, 1, 3 ); | 631 | //US layout->addWidget( label, 1, 3 ); |
627 | layout->addWidget( label, 4, 1 ); | 632 | layout->addWidget( label, 4, 1 ); |
628 | mAssistantEdit = new KLineEdit( tab2 ); | 633 | mAssistantEdit = new KLineEdit( tab2 ); |
629 | connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ), | 634 | connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ), |
630 | SLOT( textChanged( const QString& ) ) ); | 635 | SLOT( textChanged( const QString& ) ) ); |
631 | label->setBuddy( mAssistantEdit ); | 636 | label->setBuddy( mAssistantEdit ); |
632 | //US layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 ); | 637 | //US layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 ); |
633 | layout->addWidget( mAssistantEdit, 4, 2 ); | 638 | layout->addWidget( mAssistantEdit, 4, 2 ); |
634 | 639 | ||
635 | bar = new KSeparator( KSeparator::HLine, tab2 ); | 640 | bar = new KSeparator( KSeparator::HLine, tab2 ); |
636 | //US layout->addMultiCellWidget( bar, 3, 3, 0, 5 ); | 641 | //US layout->addMultiCellWidget( bar, 3, 3, 0, 5 ); |
637 | layout->addMultiCellWidget( bar, 5, 5, 0, 2 ); | 642 | layout->addMultiCellWidget( bar, 5, 5, 0, 2 ); |
638 | 643 | ||
639 | ///////////////////////////////////////////////// | 644 | ///////////////////////////////////////////////// |
640 | // Personal info | 645 | // Personal info |
641 | 646 | ||
642 | //label = new QLabel( tab2 ); | 647 | //label = new QLabel( tab2 ); |
643 | //US loadIcon call is ambiguous. Add one more parameter | 648 | //US loadIcon call is ambiguous. Add one more parameter |
644 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); | 649 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); |
645 | //label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); | 650 | //label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); |
646 | //US layout->addMultiCellWidget( label, 4, 5, 0, 0 ); | 651 | //US layout->addMultiCellWidget( label, 4, 5, 0, 0 ); |
647 | //layout->addMultiCellWidget( label, 6, 7, 0, 0 ); | 652 | //layout->addMultiCellWidget( label, 6, 7, 0, 0 ); |
648 | 653 | ||
649 | 654 | ||
650 | int iii = 6; | 655 | int iii = 6; |
651 | 656 | ||
652 | if ( QApplication::desktop()->width() == 640 ) { | 657 | if ( QApplication::desktop()->width() == 640 ) { |
653 | QHBox * nbox = new QHBox ( tab2 ); | 658 | QHBox * nbox = new QHBox ( tab2 ); |
654 | label = new QLabel( i18n( "Nick name:" )+" ", nbox ); | 659 | label = new QLabel( i18n( "Nick name:" )+" ", nbox ); |
655 | mNicknameEdit = new KLineEdit( nbox ); | 660 | mNicknameEdit = new KLineEdit( nbox ); |
656 | connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), | 661 | connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), |
657 | SLOT( textChanged( const QString& ) ) ); | 662 | SLOT( textChanged( const QString& ) ) ); |
658 | label->setBuddy( mNicknameEdit ); | 663 | label->setBuddy( mNicknameEdit ); |
659 | 664 | ||
660 | label = new QLabel( " "+i18n( "Spouse's name:" )+" ", nbox ); | 665 | label = new QLabel( " "+i18n( "Spouse's name:" )+" ", nbox ); |
661 | mSpouseEdit = new KLineEdit( nbox ); | 666 | mSpouseEdit = new KLineEdit( nbox ); |
662 | connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), | 667 | connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), |
663 | SLOT( textChanged( const QString& ) ) ); | 668 | SLOT( textChanged( const QString& ) ) ); |
664 | label->setBuddy( mSpouseEdit ); | 669 | label->setBuddy( mSpouseEdit ); |
665 | layout->addMultiCellWidget( nbox, iii, iii, 1, 2 ); | 670 | layout->addMultiCellWidget( nbox, iii, iii, 1, 2 ); |
666 | ++iii; | 671 | ++iii; |
667 | 672 | ||
668 | } else { | 673 | } else { |
669 | label = new QLabel( i18n( "Nick name:" ), tab2 ); | 674 | label = new QLabel( i18n( "Nick name:" ), tab2 ); |
670 | layout->addWidget( label, iii, 1 ); | 675 | layout->addWidget( label, iii, 1 ); |
671 | mNicknameEdit = new KLineEdit( tab2 ); | 676 | mNicknameEdit = new KLineEdit( tab2 ); |
672 | connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), | 677 | connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), |
673 | SLOT( textChanged( const QString& ) ) ); | 678 | SLOT( textChanged( const QString& ) ) ); |
674 | label->setBuddy( mNicknameEdit ); | 679 | label->setBuddy( mNicknameEdit ); |
675 | layout->addWidget( mNicknameEdit, iii, 2 ); | 680 | layout->addWidget( mNicknameEdit, iii, 2 ); |
676 | ++iii; | 681 | ++iii; |
677 | 682 | ||
678 | label = new QLabel( i18n( "Spouse's name:" ), tab2 ); | 683 | label = new QLabel( i18n( "Spouse's name:" ), tab2 ); |
679 | layout->addWidget( label, iii, 1 ); | 684 | layout->addWidget( label, iii, 1 ); |
680 | mSpouseEdit = new KLineEdit( tab2 ); | 685 | mSpouseEdit = new KLineEdit( tab2 ); |
681 | connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), | 686 | connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), |
682 | SLOT( textChanged( const QString& ) ) ); | 687 | SLOT( textChanged( const QString& ) ) ); |
683 | label->setBuddy( mSpouseEdit ); | 688 | label->setBuddy( mSpouseEdit ); |
684 | layout->addWidget( mSpouseEdit, iii, 2 ); | 689 | layout->addWidget( mSpouseEdit, iii, 2 ); |
685 | ++iii; | 690 | ++iii; |
686 | } | 691 | } |
687 | 692 | ||
688 | label = new QLabel( i18n( "Children's names:" ), tab2 ); | 693 | label = new QLabel( i18n( "Children's names:" ), tab2 ); |
689 | layout->addWidget( label, iii, 1 ); | 694 | layout->addWidget( label, iii, 1 ); |
690 | mChildEdit = new KLineEdit( tab2 ); | 695 | mChildEdit = new KLineEdit( tab2 ); |
691 | connect( mChildEdit, SIGNAL( textChanged( const QString& ) ), | 696 | connect( mChildEdit, SIGNAL( textChanged( const QString& ) ), |
692 | SLOT( textChanged( const QString& ) ) ); | 697 | SLOT( textChanged( const QString& ) ) ); |
693 | label->setBuddy( mChildEdit ); | 698 | label->setBuddy( mChildEdit ); |
694 | layout->addWidget( mChildEdit, iii, 2 ); | 699 | layout->addWidget( mChildEdit, iii, 2 ); |
695 | ++iii; | 700 | ++iii; |
696 | if ( QApplication::desktop()->width() == 640 ) { | 701 | if ( QApplication::desktop()->width() == 640 ) { |
697 | QHBox * nbox = new QHBox ( tab2 ); | 702 | QHBox * nbox = new QHBox ( tab2 ); |
698 | label = new QLabel( i18n( "Birthday:" )+" ", nbox ); | 703 | label = new QLabel( i18n( "Birthday:" )+" ", nbox ); |
699 | mBirthdayPicker = new KDateEdit( nbox ); | 704 | mBirthdayPicker = new KDateEdit( nbox ); |
700 | //mBirthdayPicker->toggleDateFormat(); | 705 | //mBirthdayPicker->toggleDateFormat(); |
701 | mBirthdayPicker->setHandleInvalid( true ); | 706 | mBirthdayPicker->setHandleInvalid( true ); |
702 | connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), | 707 | connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), |
703 | SLOT( dateChanged( QDate ) ) ); | 708 | SLOT( dateChanged( QDate ) ) ); |
704 | 709 | ||
705 | label->setBuddy( mBirthdayPicker ); | 710 | label->setBuddy( mBirthdayPicker ); |
706 | 711 | ||
707 | label = new QLabel( " "+i18n( "Anniversary:" )+" ", nbox ); | 712 | label = new QLabel( " "+i18n( "Anniversary:" )+" ", nbox ); |
708 | mAnniversaryPicker = new KDateEdit( nbox ); | 713 | mAnniversaryPicker = new KDateEdit( nbox ); |
709 | mAnniversaryPicker->setHandleInvalid( true ); | 714 | mAnniversaryPicker->setHandleInvalid( true ); |
710 | connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), | 715 | connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), |
711 | SLOT( dateChanged( QDate ) ) ); | 716 | SLOT( dateChanged( QDate ) ) ); |
712 | 717 | ||
713 | label->setBuddy( mAnniversaryPicker ); | 718 | label->setBuddy( mAnniversaryPicker ); |
714 | layout->addMultiCellWidget( nbox, iii, iii, 1, 2 ); | 719 | layout->addMultiCellWidget( nbox, iii, iii, 1, 2 ); |
715 | ++iii; | 720 | ++iii; |
716 | 721 | ||
717 | } else { | 722 | } else { |
718 | 723 | ||
719 | label = new QLabel( i18n( "Birthday:" ), tab2 ); | 724 | label = new QLabel( i18n( "Birthday:" ), tab2 ); |
720 | layout->addWidget( label, iii, 1 ); | 725 | layout->addWidget( label, iii, 1 ); |
721 | mBirthdayPicker = new KDateEdit( tab2 ); | 726 | mBirthdayPicker = new KDateEdit( tab2 ); |
722 | //mBirthdayPicker->toggleDateFormat(); | 727 | //mBirthdayPicker->toggleDateFormat(); |
723 | mBirthdayPicker->setHandleInvalid( true ); | 728 | mBirthdayPicker->setHandleInvalid( true ); |
724 | connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), | 729 | connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), |
725 | SLOT( dateChanged( QDate ) ) ); | 730 | SLOT( dateChanged( QDate ) ) ); |
726 | 731 | ||
727 | label->setBuddy( mBirthdayPicker ); | 732 | label->setBuddy( mBirthdayPicker ); |
728 | layout->addWidget( mBirthdayPicker, iii, 2 ); | 733 | layout->addWidget( mBirthdayPicker, iii, 2 ); |
729 | ++iii; | 734 | ++iii; |
730 | 735 | ||
731 | label = new QLabel( i18n( "Anniversary:" ), tab2 ); | 736 | label = new QLabel( i18n( "Anniversary:" ), tab2 ); |
732 | layout->addWidget( label, iii, 1 ); | 737 | layout->addWidget( label, iii, 1 ); |
733 | mAnniversaryPicker = new KDateEdit( tab2 ); | 738 | mAnniversaryPicker = new KDateEdit( tab2 ); |
734 | mAnniversaryPicker->setHandleInvalid( true ); | 739 | mAnniversaryPicker->setHandleInvalid( true ); |
735 | connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), | 740 | connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), |
736 | SLOT( dateChanged( QDate ) ) ); | 741 | SLOT( dateChanged( QDate ) ) ); |
737 | 742 | ||
738 | label->setBuddy( mAnniversaryPicker ); | 743 | label->setBuddy( mAnniversaryPicker ); |
739 | layout->addWidget( mAnniversaryPicker, iii, 2 ); | 744 | layout->addWidget( mAnniversaryPicker, iii, 2 ); |
740 | ++iii; | 745 | ++iii; |
741 | 746 | ||
742 | } | 747 | } |
743 | 748 | ||
744 | label = new QLabel( i18n( "Gender:" ), tab2 ); | 749 | label = new QLabel( i18n( "Gender:" ), tab2 ); |
745 | layout->addWidget( label, iii, 1 ); | 750 | layout->addWidget( label, iii, 1 ); |
746 | mGenderBox = new QComboBox ( tab2 ); | 751 | mGenderBox = new QComboBox ( tab2 ); |
747 | mGenderBox->insertItem ( i18n( "ALIEN (undefined)" )); | 752 | mGenderBox->insertItem ( i18n( "ALIEN (undefined)" )); |
748 | mGenderBox->insertItem ( i18n( "female" )); | 753 | mGenderBox->insertItem ( i18n( "female" )); |
749 | mGenderBox->insertItem ( i18n( "male" )); | 754 | mGenderBox->insertItem ( i18n( "male" )); |
750 | connect( mGenderBox, SIGNAL( activated ( const QString & ) ), | 755 | connect( mGenderBox, SIGNAL( activated ( const QString & ) ), |
751 | SLOT( textChanged( const QString& ) ) ); | 756 | SLOT( textChanged( const QString& ) ) ); |
752 | label->setBuddy( mGenderBox ); | 757 | label->setBuddy( mGenderBox ); |
753 | layout->addWidget( mGenderBox, iii, 2 ); | 758 | layout->addWidget( mGenderBox, iii, 2 ); |
754 | ++iii; | 759 | ++iii; |
755 | // Build the layout and add to the tab widget | 760 | // Build the layout and add to the tab widget |
756 | layout->activate(); // required | 761 | layout->activate(); // required |
757 | 762 | ||
758 | mTabWidget->addTab( tab2, i18n( "&Details" ) ); | 763 | mTabWidget->addTab( tab2, i18n( "&Details" ) ); |
759 | } | 764 | } |
760 | 765 | ||
761 | void AddresseeEditorWidget::setupTab2_1() | 766 | void AddresseeEditorWidget::setupTab2_1() |
762 | { | 767 | { |
763 | // This is the Details tab | 768 | // This is the Details tab |
764 | QWidget *tab2_2 = new QWidget( mTabWidget ); | 769 | QWidget *tab2_2 = new QWidget( mTabWidget ); |
765 | 770 | ||
766 | QGridLayout *layout = new QGridLayout( tab2_2, 1, 2 ); | 771 | QGridLayout *layout = new QGridLayout( tab2_2, 1, 2 ); |
767 | layout->setMargin( KDialogBase::marginHintSmall() ); | 772 | layout->setMargin( KDialogBase::marginHintSmall() ); |
768 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 773 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
769 | 774 | ||
770 | QLabel *label; | 775 | QLabel *label; |
771 | KSeparator* bar; | 776 | KSeparator* bar; |
772 | 777 | ||
773 | /*US | 778 | /*US |
774 | /////////////////////// | 779 | /////////////////////// |
775 | // Office info | 780 | // Office info |
776 | 781 | ||
777 | // Department | 782 | // Department |
778 | label = new QLabel( tab2 ); | 783 | label = new QLabel( tab2 ); |
779 | //US loadIcon call is ambiguous. Add one more parameter | 784 | //US loadIcon call is ambiguous. Add one more parameter |
780 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); | 785 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); |
781 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); | 786 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); |
782 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); | 787 | layout->addMultiCellWidget( label, 0, 1, 0, 0 ); |
783 | 788 | ||
784 | label = new QLabel( i18n( "Department:" ), tab2 ); | 789 | label = new QLabel( i18n( "Department:" ), tab2 ); |
785 | layout->addWidget( label, 0, 1 ); | 790 | layout->addWidget( label, 0, 1 ); |
786 | mDepartmentEdit = new KLineEdit( tab2 ); | 791 | mDepartmentEdit = new KLineEdit( tab2 ); |
787 | connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), | 792 | connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), |
788 | SLOT( textChanged( const QString& ) ) ); | 793 | SLOT( textChanged( const QString& ) ) ); |
789 | label->setBuddy( mDepartmentEdit ); | 794 | label->setBuddy( mDepartmentEdit ); |
790 | layout->addWidget( mDepartmentEdit, 0, 2 ); | 795 | layout->addWidget( mDepartmentEdit, 0, 2 ); |
791 | 796 | ||
792 | label = new QLabel( i18n( "Office:" ), tab2 ); | 797 | label = new QLabel( i18n( "Office:" ), tab2 ); |
793 | layout->addWidget( label, 1, 1 ); | 798 | layout->addWidget( label, 1, 1 ); |
794 | mOfficeEdit = new KLineEdit( tab2 ); | 799 | mOfficeEdit = new KLineEdit( tab2 ); |
795 | connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ), | 800 | connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ), |
796 | SLOT( textChanged( const QString& ) ) ); | 801 | SLOT( textChanged( const QString& ) ) ); |
797 | label->setBuddy( mOfficeEdit ); | 802 | label->setBuddy( mOfficeEdit ); |
798 | layout->addWidget( mOfficeEdit, 1, 2 ); | 803 | layout->addWidget( mOfficeEdit, 1, 2 ); |
799 | 804 | ||
800 | label = new QLabel( i18n( "Profession:" ), tab2 ); | 805 | label = new QLabel( i18n( "Profession:" ), tab2 ); |
801 | layout->addWidget( label, 2, 1 ); | 806 | layout->addWidget( label, 2, 1 ); |
802 | mProfessionEdit = new KLineEdit( tab2 ); | 807 | mProfessionEdit = new KLineEdit( tab2 ); |
803 | connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ), | 808 | connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ), |
804 | SLOT( textChanged( const QString& ) ) ); | 809 | SLOT( textChanged( const QString& ) ) ); |
805 | label->setBuddy( mProfessionEdit ); | 810 | label->setBuddy( mProfessionEdit ); |
806 | layout->addWidget( mProfessionEdit, 2, 2 ); | 811 | layout->addWidget( mProfessionEdit, 2, 2 ); |
807 | 812 | ||
808 | label = new QLabel( i18n( "Manager\'s name:" ), tab2 ); | 813 | label = new QLabel( i18n( "Manager\'s name:" ), tab2 ); |
809 | layout->addWidget( label, 0, 3 ); | 814 | layout->addWidget( label, 0, 3 ); |
810 | mManagerEdit = new KLineEdit( tab2 ); | 815 | mManagerEdit = new KLineEdit( tab2 ); |
811 | connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ), | 816 | connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ), |
812 | SLOT( textChanged( const QString& ) ) ); | 817 | SLOT( textChanged( const QString& ) ) ); |
813 | label->setBuddy( mManagerEdit ); | 818 | label->setBuddy( mManagerEdit ); |
814 | layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 ); | 819 | layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 ); |
815 | 820 | ||
816 | label = new QLabel( i18n( "Assistant's name:" ), tab2 ); | 821 | label = new QLabel( i18n( "Assistant's name:" ), tab2 ); |
817 | layout->addWidget( label, 1, 3 ); | 822 | layout->addWidget( label, 1, 3 ); |
818 | mAssistantEdit = new KLineEdit( tab2 ); | 823 | mAssistantEdit = new KLineEdit( tab2 ); |
819 | connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ), | 824 | connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ), |
820 | SLOT( textChanged( const QString& ) ) ); | 825 | SLOT( textChanged( const QString& ) ) ); |
821 | label->setBuddy( mAssistantEdit ); | 826 | label->setBuddy( mAssistantEdit ); |
822 | layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 ); | 827 | layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 ); |
823 | 828 | ||
824 | bar = new KSeparator( KSeparator::HLine, tab2 ); | 829 | bar = new KSeparator( KSeparator::HLine, tab2 ); |
825 | layout->addMultiCellWidget( bar, 3, 3, 0, 5 ); | 830 | layout->addMultiCellWidget( bar, 3, 3, 0, 5 ); |
826 | 831 | ||
827 | ///////////////////////////////////////////////// | 832 | ///////////////////////////////////////////////// |
828 | // Personal info | 833 | // Personal info |
829 | 834 | ||
830 | label = new QLabel( tab2 ); | 835 | label = new QLabel( tab2 ); |
831 | //US loadIcon call is ambiguous. Add one more parameter | 836 | //US loadIcon call is ambiguous. Add one more parameter |
832 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); | 837 | //US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); |
833 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); | 838 | label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); |
834 | layout->addMultiCellWidget( label, 4, 5, 0, 0 ); | 839 | layout->addMultiCellWidget( label, 4, 5, 0, 0 ); |
835 | 840 | ||
836 | label = new QLabel( i18n( "Nick name:" ), tab2 ); | 841 | label = new QLabel( i18n( "Nick name:" ), tab2 ); |
837 | layout->addWidget( label, 4, 1 ); | 842 | layout->addWidget( label, 4, 1 ); |
838 | mNicknameEdit = new KLineEdit( tab2 ); | 843 | mNicknameEdit = new KLineEdit( tab2 ); |
839 | connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), | 844 | connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), |
840 | SLOT( textChanged( const QString& ) ) ); | 845 | SLOT( textChanged( const QString& ) ) ); |
841 | label->setBuddy( mNicknameEdit ); | 846 | label->setBuddy( mNicknameEdit ); |
842 | layout->addWidget( mNicknameEdit, 4, 2 ); | 847 | layout->addWidget( mNicknameEdit, 4, 2 ); |
843 | 848 | ||
844 | label = new QLabel( i18n( "Spouse's name:" ), tab2 ); | 849 | label = new QLabel( i18n( "Spouse's name:" ), tab2 ); |
845 | layout->addWidget( label, 5, 1 ); | 850 | layout->addWidget( label, 5, 1 ); |
846 | mSpouseEdit = new KLineEdit( tab2 ); | 851 | mSpouseEdit = new KLineEdit( tab2 ); |
847 | connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), | 852 | connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), |
848 | SLOT( textChanged( const QString& ) ) ); | 853 | SLOT( textChanged( const QString& ) ) ); |
849 | label->setBuddy( mSpouseEdit ); | 854 | label->setBuddy( mSpouseEdit ); |
850 | layout->addWidget( mSpouseEdit, 5, 2 ); | 855 | layout->addWidget( mSpouseEdit, 5, 2 ); |
851 | 856 | ||
852 | label = new QLabel( i18n( "Birthday:" ), tab2 ); | 857 | label = new QLabel( i18n( "Birthday:" ), tab2 ); |
853 | layout->addWidget( label, 4, 3 ); | 858 | layout->addWidget( label, 4, 3 ); |
854 | mBirthdayPicker = new KDateEdit( tab2 ); | 859 | mBirthdayPicker = new KDateEdit( tab2 ); |
855 | mBirthdayPicker->setHandleInvalid( true ); | 860 | mBirthdayPicker->setHandleInvalid( true ); |
856 | connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), | 861 | connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), |
857 | SLOT( dateChanged( QDate ) ) ); | 862 | SLOT( dateChanged( QDate ) ) ); |
858 | connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ), | 863 | connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ), |
859 | SLOT( invalidDate() ) ); | 864 | SLOT( invalidDate() ) ); |
860 | connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ), | 865 | connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ), |
861 | SLOT( emitModified() ) ); | 866 | SLOT( emitModified() ) ); |
862 | label->setBuddy( mBirthdayPicker ); | 867 | label->setBuddy( mBirthdayPicker ); |
863 | layout->addWidget( mBirthdayPicker, 4, 4 ); | 868 | layout->addWidget( mBirthdayPicker, 4, 4 ); |
864 | 869 | ||
865 | label = new QLabel( i18n( "Anniversary:" ), tab2 ); | 870 | label = new QLabel( i18n( "Anniversary:" ), tab2 ); |
866 | layout->addWidget( label, 5, 3 ); | 871 | layout->addWidget( label, 5, 3 ); |
867 | mAnniversaryPicker = new KDateEdit( tab2 ); | 872 | mAnniversaryPicker = new KDateEdit( tab2 ); |
868 | mAnniversaryPicker->setHandleInvalid( true ); | 873 | mAnniversaryPicker->setHandleInvalid( true ); |
869 | connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), | 874 | connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), |
870 | SLOT( dateChanged( QDate ) ) ); | 875 | SLOT( dateChanged( QDate ) ) ); |
871 | connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ), | 876 | connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ), |
872 | SLOT( invalidDate() ) ); | 877 | SLOT( invalidDate() ) ); |
873 | connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ), | 878 | connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ), |
874 | SLOT( emitModified() ) ); | 879 | SLOT( emitModified() ) ); |
875 | label->setBuddy( mAnniversaryPicker ); | 880 | label->setBuddy( mAnniversaryPicker ); |
876 | layout->addWidget( mAnniversaryPicker, 5, 4 ); | 881 | layout->addWidget( mAnniversaryPicker, 5, 4 ); |
877 | 882 | ||
878 | bar = new KSeparator( KSeparator::HLine, tab2 ); | 883 | bar = new KSeparator( KSeparator::HLine, tab2 ); |
879 | layout->addMultiCellWidget( bar, 6, 6, 0, 5 ); | 884 | layout->addMultiCellWidget( bar, 6, 6, 0, 5 ); |
880 | */ | 885 | */ |
881 | ////////////////////////////////////// | 886 | ////////////////////////////////////// |
882 | // Notes | 887 | // Notes |
883 | label = new QLabel( i18n( "Note:" ), tab2_2 ); | 888 | label = new QLabel( i18n( "Note:" ), tab2_2 ); |
884 | label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); | 889 | label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); |
885 | //US layout->addWidget( label, 7, 0 ); | 890 | //US layout->addWidget( label, 7, 0 ); |
886 | layout->addWidget( label, 0, 0 ); | 891 | layout->addWidget( label, 0, 0 ); |
887 | #ifndef KAB_EMBEDDED | 892 | #ifndef KAB_EMBEDDED |
888 | mNoteEdit = new QTextEdit( tab2_2 ); | 893 | mNoteEdit = new QTextEdit( tab2_2 ); |
889 | mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); | 894 | mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); |
890 | mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); | 895 | mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); |
891 | #else //KAB_EMBEDDED | 896 | #else //KAB_EMBEDDED |
892 | mNoteEdit = new QMultiLineEdit( tab2_2 ); | 897 | mNoteEdit = new QMultiLineEdit( tab2_2 ); |
893 | mNoteEdit->setWordWrap( QMultiLineEdit::WidgetWidth ); | 898 | mNoteEdit->setWordWrap( QMultiLineEdit::WidgetWidth ); |
894 | mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); | 899 | mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); |
895 | #endif //KAB_EMBEDDED | 900 | #endif //KAB_EMBEDDED |
896 | 901 | ||
897 | connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) ); | 902 | connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) ); |
898 | label->setBuddy( mNoteEdit ); | 903 | label->setBuddy( mNoteEdit ); |
899 | //US layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 ); | 904 | //US layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 ); |
900 | layout->addWidget( mNoteEdit, 1, 0); | 905 | layout->addWidget( mNoteEdit, 1, 0); |
901 | 906 | ||
902 | // Build the layout and add to the tab widget | 907 | // Build the layout and add to the tab widget |
903 | layout->activate(); // required | 908 | layout->activate(); // required |
904 | 909 | ||
905 | mTabWidget->addTab( tab2_2, i18n( "&Notes" ) ); | 910 | mTabWidget->addTab( tab2_2, i18n( "&Notes" ) ); |
906 | } | 911 | } |
907 | 912 | ||
908 | 913 | ||
909 | 914 | ||
910 | void AddresseeEditorWidget::setupTab3() | 915 | void AddresseeEditorWidget::setupTab3() |
911 | { | 916 | { |
912 | // This is the Misc tab | 917 | // This is the Misc tab |
913 | QWidget *tab3 = new QWidget( mTabWidget ); | 918 | QWidget *tab3 = new QWidget( mTabWidget ); |
914 | 919 | ||
915 | QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); | 920 | QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); |
916 | layout->setMargin( KDialogBase::marginHintSmall() ); | 921 | layout->setMargin( KDialogBase::marginHintSmall() ); |
917 | layout->setSpacing( KDialogBase::spacingHintSmall() ); | 922 | layout->setSpacing( KDialogBase::spacingHintSmall() ); |
918 | //US layout->setColStretch( 2, 1 ); | 923 | //US layout->setColStretch( 2, 1 ); |
919 | 924 | ||
920 | ////////////////////////////////////// | 925 | ////////////////////////////////////// |
921 | // Geo | 926 | // Geo |
922 | mGeoWidget = new GeoWidget( tab3 ); | 927 | mGeoWidget = new GeoWidget( tab3 ); |
923 | // mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); | 928 | // mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); |
924 | connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 929 | connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
925 | layout->addWidget( mGeoWidget, 0, 0 ); | 930 | layout->addWidget( mGeoWidget, 0, 0 ); |
926 | /*US | 931 | /*US |
927 | ////////////////////////////////////// | 932 | ////////////////////////////////////// |
928 | // Sound | 933 | // Sound |
929 | #ifndef KAB_EMBEDDED | 934 | #ifndef KAB_EMBEDDED |
930 | mSoundWidget = new SoundWidget( tab3 ); | 935 | mSoundWidget = new SoundWidget( tab3 ); |
931 | mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); | 936 | mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); |
932 | connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 937 | connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
933 | layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); | 938 | layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); |
934 | #else //KAB_EMBEDDED | 939 | #else //KAB_EMBEDDED |
935 | qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); | 940 | qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); |
936 | #endif //KAB_EMBEDDED | 941 | #endif //KAB_EMBEDDED |
937 | 942 | ||
938 | ////////////////////////////////////// | 943 | ////////////////////////////////////// |
939 | // Images | 944 | // Images |
940 | mImageWidget = new ImageWidget( tab3 ); | 945 | mImageWidget = new ImageWidget( tab3 ); |
941 | mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); | 946 | mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); |
942 | connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 947 | connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
943 | layout->addWidget( mImageWidget, 1, 0, Qt::AlignTop ); | 948 | layout->addWidget( mImageWidget, 1, 0, Qt::AlignTop ); |
944 | */ | 949 | */ |
945 | //US | 950 | //US |
946 | /* | 951 | /* |
947 | KSeparator* bar = new KSeparator( KSeparator::HLine, tab3 ); | 952 | KSeparator* bar = new KSeparator( KSeparator::HLine, tab3 ); |
948 | layout->addMultiCellWidget( bar, 1, 1, 0, 0 ); | 953 | layout->addMultiCellWidget( bar, 1, 1, 0, 0 ); |
949 | */ | 954 | */ |
950 | ////////////////////////////////////// | 955 | ////////////////////////////////////// |
951 | // Keys | 956 | // Keys |
952 | mKeyWidget = new KeyWidget( tab3 ); | 957 | mKeyWidget = new KeyWidget( tab3 ); |
953 | //mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); | 958 | //mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); |
954 | connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 959 | connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
955 | //US layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); | 960 | //US layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); |
956 | layout->addWidget( mKeyWidget, 1, 0 ); | 961 | layout->addWidget( mKeyWidget, 1, 0 ); |
957 | 962 | ||
958 | mTabWidget->addTab( tab3, i18n( "&Misc" ) ); | 963 | mTabWidget->addTab( tab3, i18n( "&Misc" ) ); |
959 | } | 964 | } |
960 | 965 | ||
961 | void AddresseeEditorWidget::setupTab3_1() | 966 | void AddresseeEditorWidget::setupTab3_1() |
962 | { | 967 | { |
963 | // This is the Misc tab | 968 | // This is the Misc tab |
964 | QWidget *tab3 = new QWidget( mTabWidget ); | 969 | QWidget *tab3 = new QWidget( mTabWidget ); |
965 | 970 | ||
966 | //US QGridLayout *layout = new QGridLayout( tab3, 2, 3 ); | 971 | //US QGridLayout *layout = new QGridLayout( tab3, 2, 3 ); |
967 | QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); | 972 | QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); |
968 | layout->setMargin( KDialogBase::marginHint() ); | 973 | layout->setMargin( KDialogBase::marginHint() ); |
969 | layout->setSpacing( KDialogBase::spacingHint() ); | 974 | layout->setSpacing( KDialogBase::spacingHint() ); |
970 | //US layout->setColStretch( 2, 1 ); | 975 | //US layout->setColStretch( 2, 1 ); |
971 | 976 | ||
972 | /*US | 977 | /*US |
973 | ////////////////////////////////////// | 978 | ////////////////////////////////////// |
974 | // Geo | 979 | // Geo |
975 | mGeoWidget = new GeoWidget( tab3 ); | 980 | mGeoWidget = new GeoWidget( tab3 ); |
976 | mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); | 981 | mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); |
977 | connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 982 | connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
978 | layout->addWidget( mGeoWidget, 0, 0, Qt::AlignTop ); | 983 | layout->addWidget( mGeoWidget, 0, 0, Qt::AlignTop ); |
979 | */ | 984 | */ |
980 | ////////////////////////////////////// | 985 | ////////////////////////////////////// |
981 | // Sound | 986 | // Sound |
982 | #ifndef KAB_EMBEDDED | 987 | #ifndef KAB_EMBEDDED |
983 | mSoundWidget = new SoundWidget( tab3 ); | 988 | mSoundWidget = new SoundWidget( tab3 ); |
984 | mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); | 989 | mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); |
985 | connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 990 | connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
986 | layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); | 991 | layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); |
987 | #else //KAB_EMBEDDED | 992 | #else //KAB_EMBEDDED |
988 | //US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); | 993 | //US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); |
989 | #endif //KAB_EMBEDDED | 994 | #endif //KAB_EMBEDDED |
990 | 995 | ||
991 | ////////////////////////////////////// | 996 | ////////////////////////////////////// |
992 | // Images | 997 | // Images |
993 | mImageWidget = new ImageWidget( tab3 ); | 998 | mImageWidget = new ImageWidget( tab3 ); |
994 | mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); | 999 | mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); |
995 | connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 1000 | connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
996 | layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop ); | 1001 | layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop ); |
997 | /*US | 1002 | /*US |
998 | ////////////////////////////////////// | 1003 | ////////////////////////////////////// |
999 | // Keys | 1004 | // Keys |
1000 | mKeyWidget = new KeyWidget( tab3 ); | 1005 | mKeyWidget = new KeyWidget( tab3 ); |
1001 | mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); | 1006 | mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); |
1002 | connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); | 1007 | connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); |
1003 | layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); | 1008 | layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); |
1004 | */ | 1009 | */ |
1005 | mTabWidget->addTab( tab3, i18n( "&Images" ) ); | 1010 | mTabWidget->addTab( tab3, i18n( "&Images" ) ); |
1006 | } | 1011 | } |
1007 | 1012 | ||
1008 | 1013 | ||
1009 | void AddresseeEditorWidget::load() | 1014 | void AddresseeEditorWidget::load() |
1010 | { | 1015 | { |
1011 | 1016 | ||
1012 | // Block signals in case anything tries to emit modified | 1017 | // Block signals in case anything tries to emit modified |
1013 | // CS: This doesn't seem to work. | 1018 | // CS: This doesn't seem to work. |
1014 | bool block = signalsBlocked(); | 1019 | bool block = signalsBlocked(); |
1015 | blockSignals( true ); | 1020 | blockSignals( true ); |
1016 | mBlockSignals = true; // used for internal signal blocking | 1021 | mBlockSignals = true; // used for internal signal blocking |
1017 | 1022 | ||
1018 | mNameEdit->setText( mAddressee.assembledName() ); | 1023 | mNameEdit->setText( mAddressee.assembledName() ); |
1019 | 1024 | ||
1020 | if ( mAddressee.formattedName().isEmpty() ) { | 1025 | if ( mAddressee.formattedName().isEmpty() ) { |
1021 | //US KConfig config( "kaddressbookrc" ); | 1026 | //US KConfig config( "kaddressbookrc" ); |
1022 | KConfig config( locateLocal("config", "kabcrc") ); | 1027 | KConfig config( locateLocal("config", "kabcrc") ); |
1023 | config.setGroup( "General" ); | 1028 | config.setGroup( "General" ); |
1024 | mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); | 1029 | mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); |
1025 | mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); | 1030 | mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); |
1026 | } else {; | 1031 | } else {; |
1027 | if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) ) | 1032 | if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) ) |
1028 | mFormattedNameType = NameEditDialog::SimpleName; | 1033 | mFormattedNameType = NameEditDialog::SimpleName; |
1029 | else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) ) | 1034 | else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) ) |
1030 | mFormattedNameType = NameEditDialog::FullName; | 1035 | mFormattedNameType = NameEditDialog::FullName; |
1031 | else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) ) | 1036 | else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) ) |
1032 | mFormattedNameType = NameEditDialog::ReverseName; | 1037 | mFormattedNameType = NameEditDialog::ReverseName; |
1033 | else | 1038 | else |
1034 | mFormattedNameType = NameEditDialog::CustomName; | 1039 | mFormattedNameType = NameEditDialog::CustomName; |
1035 | } | 1040 | } |
1036 | 1041 | ||
1037 | mFormattedNameLabel->setText( mAddressee.formattedName() ); | 1042 | mFormattedNameLabel->setText( mAddressee.formattedName() ); |
1038 | 1043 | ||
1039 | mAConfig->setUid( mAddressee.uid() ); | 1044 | mAConfig->setUid( mAddressee.uid() ); |
1040 | if ( mAConfig->automaticNameParsing() ) { | 1045 | if ( mAConfig->automaticNameParsing() ) { |
1041 | mNameLabel->hide(); | 1046 | mNameLabel->hide(); |
1042 | mNameEdit->show(); | 1047 | mNameEdit->show(); |
1043 | } else { | 1048 | } else { |
1044 | mNameEdit->hide(); | 1049 | mNameEdit->hide(); |
1045 | mNameLabel->setText( mNameEdit->text() ); | 1050 | mNameLabel->setText( mNameEdit->text() ); |
1046 | mNameLabel->show(); | 1051 | mNameLabel->show(); |
1047 | } | 1052 | } |
1048 | 1053 | ||
1049 | mRoleEdit->setText( mAddressee.role() ); | 1054 | mRoleEdit->setText( mAddressee.role() ); |
1050 | mOrgEdit->setText( mAddressee.organization() ); | 1055 | mOrgEdit->setText( mAddressee.organization() ); |
1051 | 1056 | ||
1052 | //US mURLEdit->setURL( mAddressee.url().url() ); | 1057 | //US mURLEdit->setURL( mAddressee.url().url() ); |
1053 | mURLEdit->setText( mAddressee.url().prettyURL() ); | 1058 | mURLEdit->setText( mAddressee.url().prettyURL() ); |
1054 | //US?? mURLEdit->home( false ); | 1059 | //US?? mURLEdit->home( false ); |
1055 | 1060 | ||
1056 | // mNoteEdit->setText( mAddressee.note() ); | 1061 | // mNoteEdit->setText( mAddressee.note() ); |
1057 | mNoteEdit->setText( mAddressee.note() ); | 1062 | mNoteEdit->setText( mAddressee.note() ); |
1058 | mEmailWidget->setEmails( mAddressee.emails() ); | 1063 | mEmailWidget->setEmails( mAddressee.emails() ); |
1059 | mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() ); | 1064 | mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() ); |
1060 | mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() ); | 1065 | mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() ); |
1061 | mBirthdayPicker->setDate( mAddressee.birthday().date() ); | 1066 | mBirthdayPicker->setDate( mAddressee.birthday().date() ); |
1062 | 1067 | ||
1063 | //US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom( | 1068 | //US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom( |
1064 | //US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) ); | 1069 | //US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) ); |
1065 | QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), | 1070 | QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), |
1066 | "%Y-%m-%d"); // = Qt::ISODate | 1071 | "%Y-%m-%d"); // = Qt::ISODate |
1067 | mAnniversaryPicker->setDate( dt ); | 1072 | mAnniversaryPicker->setDate( dt ); |
1068 | 1073 | ||
1069 | 1074 | ||
1070 | mNicknameEdit->setText( mAddressee.nickName() ); | 1075 | mNicknameEdit->setText( mAddressee.nickName() ); |
1071 | mCategoryEdit->setText( mAddressee.categories().join( "," ) ); | 1076 | mCategoryEdit->setText( mAddressee.categories().join( "," ) ); |
1072 | 1077 | ||
1073 | mGeoWidget->setGeo( mAddressee.geo() ); | 1078 | mGeoWidget->setGeo( mAddressee.geo() ); |
1074 | mImageWidget->setPhoto( mAddressee.photo() ); | 1079 | mImageWidget->setPhoto( mAddressee.photo() ); |
1075 | mImageWidget->setLogo( mAddressee.logo() ); | 1080 | mImageWidget->setLogo( mAddressee.logo() ); |
1076 | mKeyWidget->setKeys( mAddressee.keys() ); | 1081 | mKeyWidget->setKeys( mAddressee.keys() ); |
1077 | mSecrecyWidget->setSecrecy( mAddressee.secrecy() ); | 1082 | mSecrecyWidget->setSecrecy( mAddressee.secrecy() ); |
1078 | #ifndef KAB_EMBEDDED | 1083 | #ifndef KAB_EMBEDDED |
1079 | mSoundWidget->setSound( mAddressee.sound() ); | 1084 | mSoundWidget->setSound( mAddressee.sound() ); |
1080 | #else //KAB_EMBEDDED | 1085 | #else //KAB_EMBEDDED |
1081 | //US qDebug("AddresseeEditorWidget::load has to be changed 2"); | 1086 | //US qDebug("AddresseeEditorWidget::load has to be changed 2"); |
1082 | #endif //KAB_EMBEDDED | 1087 | #endif //KAB_EMBEDDED |
1083 | 1088 | ||
1084 | // Load customs | 1089 | // Load customs |
1085 | mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) ); | 1090 | mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) ); |
1086 | mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) ); | 1091 | mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) ); |
1087 | mChildEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Children" ) ); | 1092 | mChildEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Children" ) ); |
1088 | mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) ); | 1093 | mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) ); |
1089 | mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) ); | 1094 | mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) ); |
1090 | mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) ); | 1095 | mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) ); |
1091 | mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) ); | 1096 | mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) ); |
1092 | mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) ); | 1097 | mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) ); |
1093 | QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); | 1098 | QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); |
1094 | if ( gen == "female" ) | 1099 | if ( gen == "female" ) |
1095 | mGenderBox->setCurrentItem ( 1 ); | 1100 | mGenderBox->setCurrentItem ( 1 ); |
1096 | else if ( gen == "male" ) | 1101 | else if ( gen == "male" ) |
1097 | mGenderBox->setCurrentItem ( 2 ); | 1102 | mGenderBox->setCurrentItem ( 2 ); |
1098 | else | 1103 | else |
1099 | mGenderBox->setCurrentItem ( 0 ); | 1104 | mGenderBox->setCurrentItem ( 0 ); |
1100 | blockSignals( block ); | 1105 | blockSignals( block ); |
1101 | mBlockSignals = false; | 1106 | mBlockSignals = false; |
1102 | 1107 | ||
1103 | mDirty = false; | 1108 | mDirty = false; |
1104 | } | 1109 | } |
1105 | 1110 | ||
1106 | void AddresseeEditorWidget::save() | 1111 | void AddresseeEditorWidget::save() |
1107 | { | 1112 | { |
1108 | if ( !dirty() ) { | 1113 | if ( !dirty() ) { |
1109 | return; | 1114 | return; |
1110 | } | 1115 | } |
1111 | 1116 | ||
1112 | mAddressee.setRevision( QDateTime::currentDateTime() ); | 1117 | mAddressee.setRevision( QDateTime::currentDateTime() ); |
1113 | 1118 | ||
1114 | mAddressee.setRole( mRoleEdit->text() ); | 1119 | mAddressee.setRole( mRoleEdit->text() ); |
1115 | mAddressee.setOrganization( mOrgEdit->text() ); | 1120 | mAddressee.setOrganization( mOrgEdit->text() ); |
1116 | mAddressee.setUrl( KURL( mURLEdit->text() ) ); | 1121 | mAddressee.setUrl( KURL( mURLEdit->text() ) ); |
1117 | mAddressee.setNote( mNoteEdit->text() ); | 1122 | mAddressee.setNote( mNoteEdit->text() ); |
1118 | if ( mBirthdayPicker->inputIsValid() ) { | 1123 | if ( mBirthdayPicker->inputIsValid() ) { |
1119 | QDate da = mBirthdayPicker->date(); | 1124 | QDate da = mBirthdayPicker->date(); |
1120 | mAddressee.setBirthday( QDateTime( da ) ); | 1125 | mAddressee.setBirthday( QDateTime( da ) ); |
1121 | //qDebug("bday %s ",da.toString().latin1()); | 1126 | //qDebug("bday %s ",da.toString().latin1()); |
1122 | } | 1127 | } |
1123 | else { | 1128 | else { |
1124 | mAddressee.setBirthday( QDateTime() ); | 1129 | mAddressee.setBirthday( QDateTime() ); |
1125 | mBirthdayPicker->clear(); | 1130 | mBirthdayPicker->clear(); |
1126 | } | 1131 | } |
1127 | mAddressee.setNickName( mNicknameEdit->text() ); | 1132 | mAddressee.setNickName( mNicknameEdit->text() ); |
1128 | mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) ); | 1133 | mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) ); |
1129 | 1134 | ||
1130 | mAddressee.setGeo( mGeoWidget->geo() ); | 1135 | mAddressee.setGeo( mGeoWidget->geo() ); |
1131 | mAddressee.setPhoto( mImageWidget->photo() ); | 1136 | mAddressee.setPhoto( mImageWidget->photo() ); |
1132 | mAddressee.setLogo( mImageWidget->logo() ); | 1137 | mAddressee.setLogo( mImageWidget->logo() ); |
1133 | mAddressee.setKeys( mKeyWidget->keys() ); | 1138 | mAddressee.setKeys( mKeyWidget->keys() ); |
1134 | #ifndef KAB_EMBEDDED | 1139 | #ifndef KAB_EMBEDDED |
1135 | mAddressee.setSound( mSoundWidget->sound() ); | 1140 | mAddressee.setSound( mSoundWidget->sound() ); |
1136 | #else //KAB_EMBEDDED | 1141 | #else //KAB_EMBEDDED |
1137 | //US qDebug("AddresseeEditorWidget::save sound not supported"); | 1142 | //US qDebug("AddresseeEditorWidget::save sound not supported"); |
1138 | #endif //KAB_EMBEDDED | 1143 | #endif //KAB_EMBEDDED |
1139 | mAddressee.setSecrecy( mSecrecyWidget->secrecy() ); | 1144 | mAddressee.setSecrecy( mSecrecyWidget->secrecy() ); |
1140 | 1145 | ||
1141 | // save custom fields | 1146 | // save custom fields |
1142 | mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() ); | 1147 | mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() ); |
1143 | mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() ); | 1148 | mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() ); |
1144 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Children", mChildEdit->text() ); | 1149 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Children", mChildEdit->text() ); |
1145 | mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() ); | 1150 | mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() ); |
1146 | mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() ); | 1151 | mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() ); |
1147 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() ); | 1152 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() ); |
1148 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() ); | 1153 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() ); |
1149 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() ); | 1154 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() ); |
1150 | if ( mAnniversaryPicker->inputIsValid() ) { | 1155 | if ( mAnniversaryPicker->inputIsValid() ) { |
1151 | QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate); | 1156 | QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate); |
1152 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | 1157 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); |
1153 | } | 1158 | } |
1154 | else { | 1159 | else { |
1155 | mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" ); | 1160 | mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" ); |
1156 | mAnniversaryPicker->clear(); | 1161 | mAnniversaryPicker->clear(); |
1157 | } | 1162 | } |
1158 | int gen = mGenderBox->currentItem (); | 1163 | int gen = mGenderBox->currentItem (); |
1159 | if ( gen == 1 ) | 1164 | if ( gen == 1 ) |
1160 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); | 1165 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); |
1161 | else if ( gen == 2 ) | 1166 | else if ( gen == 2 ) |
1162 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); | 1167 | mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); |
1163 | else | 1168 | else |
1164 | mAddressee.removeCustom( "KADDRESSBOOK", "X-Gender" ); | 1169 | mAddressee.removeCustom( "KADDRESSBOOK", "X-Gender" ); |
1165 | 1170 | ||
1166 | // Save the email addresses | 1171 | // Save the email addresses |
1167 | QStringList emails = mAddressee.emails(); | 1172 | QStringList emails = mAddressee.emails(); |
1168 | QStringList::Iterator iter; | 1173 | QStringList::Iterator iter; |
1169 | for ( iter = emails.begin(); iter != emails.end(); ++iter ) | 1174 | for ( iter = emails.begin(); iter != emails.end(); ++iter ) |
1170 | mAddressee.removeEmail( *iter ); | 1175 | mAddressee.removeEmail( *iter ); |
1171 | 1176 | ||
1172 | emails = mEmailWidget->emails(); | 1177 | emails = mEmailWidget->emails(); |
1173 | bool first = true; | 1178 | bool first = true; |
1174 | for ( iter = emails.begin(); iter != emails.end(); ++iter ) { | 1179 | for ( iter = emails.begin(); iter != emails.end(); ++iter ) { |
1175 | mAddressee.insertEmail( *iter, first ); | 1180 | mAddressee.insertEmail( *iter, first ); |
1176 | first = false; | 1181 | first = false; |
1177 | } | 1182 | } |
1178 | 1183 | ||
1179 | // Save the phone numbers | 1184 | // Save the phone numbers |
1180 | KABC::PhoneNumber::List phoneNumbers; | 1185 | KABC::PhoneNumber::List phoneNumbers; |
1181 | KABC::PhoneNumber::List::Iterator phoneIter; | 1186 | KABC::PhoneNumber::List::Iterator phoneIter; |
1182 | phoneNumbers = mAddressee.phoneNumbers(); | 1187 | phoneNumbers = mAddressee.phoneNumbers(); |
1183 | for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); | 1188 | for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); |
1184 | ++phoneIter ) | 1189 | ++phoneIter ) |
1185 | mAddressee.removePhoneNumber( *phoneIter ); | 1190 | mAddressee.removePhoneNumber( *phoneIter ); |
1186 | 1191 | ||
1187 | phoneNumbers = mPhoneEditWidget->phoneNumbers(); | 1192 | phoneNumbers = mPhoneEditWidget->phoneNumbers(); |
1188 | for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); | 1193 | for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); |
1189 | ++phoneIter ) | 1194 | ++phoneIter ) |
1190 | mAddressee.insertPhoneNumber( *phoneIter ); | 1195 | mAddressee.insertPhoneNumber( *phoneIter ); |
1191 | mAddressee.makePhoneNumbersOLcompatible(); | 1196 | mAddressee.makePhoneNumbersOLcompatible(); |
1192 | // Save the addresses | 1197 | // Save the addresses |
1193 | KABC::Address::List addresses; | 1198 | KABC::Address::List addresses; |
1194 | KABC::Address::List::Iterator addressIter; | 1199 | KABC::Address::List::Iterator addressIter; |
1195 | addresses = mAddressee.addresses(); | 1200 | addresses = mAddressee.addresses(); |
1196 | for ( addressIter = addresses.begin(); addressIter != addresses.end(); | 1201 | for ( addressIter = addresses.begin(); addressIter != addresses.end(); |
1197 | ++addressIter ) | 1202 | ++addressIter ) |
1198 | mAddressee.removeAddress( *addressIter ); | 1203 | mAddressee.removeAddress( *addressIter ); |
1199 | 1204 | ||
1200 | addresses = mAddressEditWidget->addresses(); | 1205 | addresses = mAddressEditWidget->addresses(); |
1201 | for ( addressIter = addresses.begin(); addressIter != addresses.end(); | 1206 | for ( addressIter = addresses.begin(); addressIter != addresses.end(); |
1202 | ++addressIter ) | 1207 | ++addressIter ) |
1203 | mAddressee.insertAddress( *addressIter ); | 1208 | mAddressee.insertAddress( *addressIter ); |
1204 | mDirty = false; | 1209 | mDirty = false; |
1205 | } | 1210 | } |
1206 | 1211 | ||
1207 | bool AddresseeEditorWidget::dirty() | 1212 | bool AddresseeEditorWidget::dirty() |
1208 | { | 1213 | { |
1209 | 1214 | ||
1210 | if ( ! mDirty ) { | 1215 | if ( ! mDirty ) { |
1211 | if ( mBirthdayPicker->inputIsValid() ) { | 1216 | if ( mBirthdayPicker->inputIsValid() ) { |
1212 | QDate da = mBirthdayPicker->date(); | 1217 | QDate da = mBirthdayPicker->date(); |
1213 | if ( !(da == mAddressee.birthday().date())) | 1218 | if ( !(da == mAddressee.birthday().date())) |
1214 | mDirty = true; | 1219 | mDirty = true; |
1215 | } | 1220 | } |
1216 | else { | 1221 | else { |
1217 | mBirthdayPicker->clear(); | 1222 | mBirthdayPicker->clear(); |
1218 | } | 1223 | } |
1219 | if ( mAnniversaryPicker->inputIsValid() ) { | 1224 | if ( mAnniversaryPicker->inputIsValid() ) { |
1220 | QDate da = mAnniversaryPicker->date(); | 1225 | QDate da = mAnniversaryPicker->date(); |
1221 | if ( da != KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), | 1226 | if ( da != KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), |
1222 | "%Y-%m-%d")) | 1227 | "%Y-%m-%d")) |
1223 | mDirty = true; | 1228 | mDirty = true; |
1224 | } | 1229 | } |
1225 | else { | 1230 | else { |
1226 | mAnniversaryPicker->clear(); | 1231 | mAnniversaryPicker->clear(); |
1227 | } | 1232 | } |
1228 | } | 1233 | } |
1229 | return mDirty; | 1234 | return mDirty; |
1230 | } | 1235 | } |
1231 | 1236 | ||
1232 | void AddresseeEditorWidget::nameTextChanged( const QString &text ) | 1237 | void AddresseeEditorWidget::nameTextChanged( const QString &text ) |
1233 | { | 1238 | { |
1234 | if ( mBlockSignals ) | 1239 | if ( mBlockSignals ) |
1235 | return; | 1240 | return; |
1236 | // use the addressee class to parse the name for us | 1241 | // use the addressee class to parse the name for us |
1237 | mAConfig->setUid( mAddressee.uid() ); | 1242 | mAConfig->setUid( mAddressee.uid() ); |
1238 | if ( mAConfig->automaticNameParsing() ) { | 1243 | if ( mAConfig->automaticNameParsing() ) { |
1239 | if ( !mAddressee.formattedName().isEmpty() ) { | 1244 | if ( !mAddressee.formattedName().isEmpty() ) { |
1240 | QString fn = mAddressee.formattedName(); | 1245 | QString fn = mAddressee.formattedName(); |
1241 | mAddressee.setNameFromString( text ); | 1246 | mAddressee.setNameFromString( text ); |
1242 | mAddressee.setFormattedName( fn ); | 1247 | mAddressee.setFormattedName( fn ); |
1243 | } else { | 1248 | } else { |
1244 | // use extra addressee to avoid a formatted name assignment | 1249 | // use extra addressee to avoid a formatted name assignment |
1245 | Addressee addr; | 1250 | Addressee addr; |
1246 | addr.setNameFromString( text ); | 1251 | addr.setNameFromString( text ); |
1247 | mAddressee.setPrefix( addr.prefix() ); | 1252 | mAddressee.setPrefix( addr.prefix() ); |
1248 | mAddressee.setGivenName( addr.givenName() ); | 1253 | mAddressee.setGivenName( addr.givenName() ); |
1249 | mAddressee.setAdditionalName( addr.additionalName() ); | 1254 | mAddressee.setAdditionalName( addr.additionalName() ); |
1250 | mAddressee.setFamilyName( addr.familyName() ); | 1255 | mAddressee.setFamilyName( addr.familyName() ); |
1251 | mAddressee.setSuffix( addr.suffix() ); | 1256 | mAddressee.setSuffix( addr.suffix() ); |
1252 | } | 1257 | } |
1253 | } | 1258 | } |
1254 | nameBoxChanged(); | 1259 | nameBoxChanged(); |
1255 | 1260 | ||
1256 | 1261 | ||
1257 | emitModified(); | 1262 | emitModified(); |
1258 | } | 1263 | } |
1259 | 1264 | ||
1260 | void AddresseeEditorWidget::nameBoxChanged() | 1265 | void AddresseeEditorWidget::nameBoxChanged() |
1261 | { | 1266 | { |
1262 | KABC::Addressee addr; | 1267 | KABC::Addressee addr; |
1263 | mAConfig->setUid( mAddressee.uid() ); | 1268 | mAConfig->setUid( mAddressee.uid() ); |
1264 | if ( mAConfig->automaticNameParsing() ) { | 1269 | if ( mAConfig->automaticNameParsing() ) { |
1265 | addr.setNameFromString( mNameEdit->text() ); | 1270 | addr.setNameFromString( mNameEdit->text() ); |
1266 | mNameLabel->hide(); | 1271 | mNameLabel->hide(); |
1267 | mNameEdit->show(); | 1272 | mNameEdit->show(); |
1268 | } else { | 1273 | } else { |
1269 | addr = mAddressee; | 1274 | addr = mAddressee; |
1270 | mNameEdit->hide(); | 1275 | mNameEdit->hide(); |
1271 | mNameLabel->setText( mNameEdit->text() ); | 1276 | mNameLabel->setText( mNameEdit->text() ); |
1272 | mNameLabel->show(); | 1277 | mNameLabel->show(); |
1273 | } | 1278 | } |
1274 | 1279 | ||
1275 | if ( mFormattedNameType != NameEditDialog::CustomName ) { | 1280 | if ( mFormattedNameType != NameEditDialog::CustomName ) { |
1276 | mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); | 1281 | mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); |
1277 | mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); | 1282 | mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); |
1278 | } | 1283 | } |
1279 | } | 1284 | } |
1280 | 1285 | ||
1281 | void AddresseeEditorWidget::nameButtonClicked() | 1286 | void AddresseeEditorWidget::nameButtonClicked() |
1282 | { | 1287 | { |
1283 | // show the name dialog. | 1288 | // show the name dialog. |
1284 | NameEditDialog dialog( mAddressee, mFormattedNameType, this ); | 1289 | NameEditDialog dialog( mAddressee, mFormattedNameType, this ); |
1285 | 1290 | ||
1286 | if ( KApplication::execDialog( &dialog) ) { | 1291 | if ( KApplication::execDialog( &dialog) ) { |
1287 | if ( dialog.changed() ) { | 1292 | if ( dialog.changed() ) { |
1288 | mAddressee.setFamilyName( dialog.familyName() ); | 1293 | mAddressee.setFamilyName( dialog.familyName() ); |
1289 | mAddressee.setGivenName( dialog.givenName() ); | 1294 | mAddressee.setGivenName( dialog.givenName() ); |
1290 | mAddressee.setPrefix( dialog.prefix() ); | 1295 | mAddressee.setPrefix( dialog.prefix() ); |
1291 | mAddressee.setSuffix( dialog.suffix() ); | 1296 | mAddressee.setSuffix( dialog.suffix() ); |
1292 | mAddressee.setAdditionalName( dialog.additionalName() ); | 1297 | mAddressee.setAdditionalName( dialog.additionalName() ); |
1293 | mFormattedNameType = dialog.formattedNameType(); | 1298 | mFormattedNameType = dialog.formattedNameType(); |
1294 | if ( mFormattedNameType == NameEditDialog::CustomName ) { | 1299 | if ( mFormattedNameType == NameEditDialog::CustomName ) { |
1295 | mFormattedNameLabel->setText( dialog.customFormattedName() ); | 1300 | mFormattedNameLabel->setText( dialog.customFormattedName() ); |
1296 | mAddressee.setFormattedName( dialog.customFormattedName() ); | 1301 | mAddressee.setFormattedName( dialog.customFormattedName() ); |
1297 | } | 1302 | } |
1298 | // Update the name edit. | 1303 | // Update the name edit. |
1299 | bool block = mNameEdit->signalsBlocked(); | 1304 | bool block = mNameEdit->signalsBlocked(); |
1300 | mNameEdit->blockSignals( true ); | 1305 | mNameEdit->blockSignals( true ); |
1301 | mNameEdit->setText( mAddressee.assembledName() ); | 1306 | mNameEdit->setText( mAddressee.assembledName() ); |
1302 | mNameEdit->blockSignals( block ); | 1307 | mNameEdit->blockSignals( block ); |
1303 | 1308 | ||
1304 | // Update the combo box. | 1309 | // Update the combo box. |
1305 | nameBoxChanged(); | 1310 | nameBoxChanged(); |
1306 | 1311 | ||
1307 | emitModified(); | 1312 | emitModified(); |
1308 | } | 1313 | } |
1309 | } | 1314 | } |
1310 | } | 1315 | } |
1311 | 1316 | ||
1312 | void AddresseeEditorWidget::categoryButtonClicked() | 1317 | void AddresseeEditorWidget::categoryButtonClicked() |
1313 | { | 1318 | { |
1314 | // Show the category dialog | 1319 | // Show the category dialog |
1315 | if ( mCategoryDialog == 0 ) { | 1320 | if ( mCategoryDialog == 0 ) { |
1316 | mCategoryDialog = new KPIM::CategorySelectDialog( KABPrefs::instance(), this ); | 1321 | mCategoryDialog = new KPIM::CategorySelectDialog( KABPrefs::instance(), this ); |
1317 | connect( mCategoryDialog, SIGNAL( categoriesSelected( const QStringList& ) ), | 1322 | connect( mCategoryDialog, SIGNAL( categoriesSelected( const QStringList& ) ), |
1318 | SLOT(categoriesSelected( const QStringList& ) ) ); | 1323 | SLOT(categoriesSelected( const QStringList& ) ) ); |
1319 | connect( mCategoryDialog, SIGNAL( editCategories() ), SLOT( editCategories() ) ); | 1324 | connect( mCategoryDialog, SIGNAL( editCategories() ), SLOT( editCategories() ) ); |
1320 | } | 1325 | } |
1321 | 1326 | ||
1322 | mCategoryDialog->setCategories(); | 1327 | mCategoryDialog->setCategories(); |
1323 | mCategoryDialog->setSelected( QStringList::split( ",", mCategoryEdit->text() ) ); | 1328 | mCategoryDialog->setSelected( QStringList::split( ",", mCategoryEdit->text() ) ); |
1324 | mCategoryDialog->show(); | 1329 | mCategoryDialog->show(); |
1325 | mCategoryDialog->raise(); | 1330 | mCategoryDialog->raise(); |
1326 | } | 1331 | } |
1327 | 1332 | ||
1328 | void AddresseeEditorWidget::categoriesSelected( const QStringList &list ) | 1333 | void AddresseeEditorWidget::categoriesSelected( const QStringList &list ) |
1329 | { | 1334 | { |
1330 | mCategoryEdit->setText( list.join( "," ) ); | 1335 | mCategoryEdit->setText( list.join( "," ) ); |
1331 | } | 1336 | } |
1332 | 1337 | ||
1333 | void AddresseeEditorWidget::editCategories() | 1338 | void AddresseeEditorWidget::editCategories() |
1334 | { | 1339 | { |
1335 | if ( mCategoryEditDialog == 0 ) { | 1340 | if ( mCategoryEditDialog == 0 ) { |
1336 | mCategoryEditDialog = new KPIM::CategoryEditDialog( KABPrefs::instance(), this ); | 1341 | mCategoryEditDialog = new KPIM::CategoryEditDialog( KABPrefs::instance(), this ); |
1337 | connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ), | 1342 | connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ), |
1338 | SLOT( categoryButtonClicked() ) ); | 1343 | SLOT( categoryButtonClicked() ) ); |
1339 | } | 1344 | } |
1340 | 1345 | ||
1341 | mCategoryEditDialog->show(); | 1346 | mCategoryEditDialog->show(); |
1342 | mCategoryEditDialog->raise(); | 1347 | mCategoryEditDialog->raise(); |
1343 | } | 1348 | } |
1344 | 1349 | ||
1345 | void AddresseeEditorWidget::emitModified() | 1350 | void AddresseeEditorWidget::emitModified() |
1346 | { | 1351 | { |
1347 | mDirty = true; | 1352 | mDirty = true; |
1348 | 1353 | ||
1349 | KABC::Addressee::List list; | 1354 | KABC::Addressee::List list; |
1350 | 1355 | ||
1351 | if ( mIsExtension && !mBlockSignals ) { | 1356 | if ( mIsExtension && !mBlockSignals ) { |
1352 | save(); | 1357 | save(); |
1353 | list.append( mAddressee ); | 1358 | list.append( mAddressee ); |
1354 | } | 1359 | } |
1355 | 1360 | ||
1356 | emit modified( list ); | 1361 | emit modified( list ); |
1357 | } | 1362 | } |
1358 | 1363 | ||
1359 | void AddresseeEditorWidget::dateChanged( QDate ) | 1364 | void AddresseeEditorWidget::dateChanged( QDate ) |
1360 | { | 1365 | { |
1361 | emitModified(); | 1366 | emitModified(); |
1362 | } | 1367 | } |
1363 | 1368 | ||
1364 | //US invalid dates are handdled by the KDateEdit widget itself | 1369 | //US invalid dates are handdled by the KDateEdit widget itself |
1365 | void AddresseeEditorWidget::invalidDate() | 1370 | void AddresseeEditorWidget::invalidDate() |
1366 | { | 1371 | { |
1367 | KMessageBox::sorry( this, i18n( "You must specify a valid date" ) ); | 1372 | KMessageBox::sorry( this, i18n( "You must specify a valid date" ) ); |
1368 | } | 1373 | } |
1369 | 1374 | ||
1370 | 1375 | ||
1371 | void AddresseeEditorWidget::pageChanged( QWidget *wdg ) | 1376 | void AddresseeEditorWidget::pageChanged( QWidget *wdg ) |
1372 | { | 1377 | { |
1373 | #ifndef KAB_EMBEDDED | 1378 | #ifndef KAB_EMBEDDED |
1374 | if ( wdg ) | 1379 | if ( wdg ) |
1375 | KAcceleratorManager::manage( wdg ); | 1380 | KAcceleratorManager::manage( wdg ); |
1376 | #else //KAB_EMBEDDED | 1381 | #else //KAB_EMBEDDED |
1377 | //US | 1382 | //US |
1378 | #endif //KAB_EMBEDDED | 1383 | #endif //KAB_EMBEDDED |
1379 | 1384 | ||
1380 | } | 1385 | } |
1381 | 1386 | ||
1382 | QString AddresseeEditorWidget::title() const | 1387 | QString AddresseeEditorWidget::title() const |
1383 | { | 1388 | { |
1384 | return i18n( "Contact Editor" ); | 1389 | return i18n( "Contact Editor" ); |
1385 | } | 1390 | } |
1386 | 1391 | ||
1387 | QString AddresseeEditorWidget::identifier() const | 1392 | QString AddresseeEditorWidget::identifier() const |
1388 | { | 1393 | { |
1389 | return i18n( "contact_editor" ); | 1394 | return i18n( "contact_editor" ); |
1390 | } | 1395 | } |
1391 | 1396 | ||
1392 | #ifndef KAB_EMBEDDED | 1397 | #ifndef KAB_EMBEDDED |
1393 | #include "addresseeeditorwidget.moc" | 1398 | #include "addresseeeditorwidget.moc" |
1394 | #endif //KAB_EMBEDDED | 1399 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp index 7e2aec1..5639aa2 100644 --- a/kaddressbook/phoneeditwidget.cpp +++ b/kaddressbook/phoneeditwidget.cpp | |||
@@ -1,726 +1,728 @@ | |||
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. |
335 | QValueList<int>::ConstIterator it; | 337 | QValueList<int>::ConstIterator it; |
336 | for( it = defaultTypes.begin(); it != defaultTypes.end(); ++it ) { | 338 | for( it = defaultTypes.begin(); it != defaultTypes.end(); ++it ) { |
337 | if ( !mPrefCombo->hasType( *it ) ) | 339 | if ( !mPrefCombo->hasType( *it ) ) |
338 | mPrefCombo->insertType( list, *it, PhoneNumber( "", *it ) ); | 340 | mPrefCombo->insertType( list, *it, PhoneNumber( "", *it ) ); |
339 | } | 341 | } |
340 | 342 | ||
341 | updateCombos(); | 343 | updateCombos(); |
342 | 344 | ||
343 | mPrefCombo->selectType( defaultTypes[ 0 ] ); | 345 | mPrefCombo->selectType( defaultTypes[ 0 ] ); |
344 | mSecondCombo->selectType( defaultTypes[ 1 ] ); | 346 | mSecondCombo->selectType( defaultTypes[ 1 ] ); |
345 | mThirdCombo->selectType( defaultTypes[ 2 ] ); | 347 | mThirdCombo->selectType( defaultTypes[ 2 ] ); |
346 | mFourthCombo->selectType( defaultTypes[ 3 ] ); | 348 | mFourthCombo->selectType( defaultTypes[ 3 ] ); |
347 | 349 | ||
348 | updateLineEdits(); | 350 | updateLineEdits(); |
349 | } | 351 | } |
350 | 352 | ||
351 | void PhoneEditWidget::updateLineEdits() | 353 | void PhoneEditWidget::updateLineEdits() |
352 | { | 354 | { |
353 | updatePrefEdit(); | 355 | updatePrefEdit(); |
354 | updateSecondEdit(); | 356 | updateSecondEdit(); |
355 | updateThirdEdit(); | 357 | updateThirdEdit(); |
356 | updateFourthEdit(); | 358 | updateFourthEdit(); |
357 | } | 359 | } |
358 | 360 | ||
359 | void PhoneEditWidget::updateCombos() | 361 | void PhoneEditWidget::updateCombos() |
360 | { | 362 | { |
361 | mPrefCombo->updateTypes(); | 363 | mPrefCombo->updateTypes(); |
362 | mSecondCombo->updateTypes(); | 364 | mSecondCombo->updateTypes(); |
363 | mThirdCombo->updateTypes(); | 365 | mThirdCombo->updateTypes(); |
364 | mFourthCombo->updateTypes(); | 366 | mFourthCombo->updateTypes(); |
365 | } | 367 | } |
366 | 368 | ||
367 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() | 369 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() |
368 | { | 370 | { |
369 | KABC::PhoneNumber::List retList; | 371 | KABC::PhoneNumber::List retList; |
370 | 372 | ||
371 | KABC::PhoneNumber::List::Iterator it; | 373 | KABC::PhoneNumber::List::Iterator it; |
372 | for ( it = mPhoneList.begin(); it != mPhoneList.end(); ++it ) | 374 | for ( it = mPhoneList.begin(); it != mPhoneList.end(); ++it ) |
373 | if ( !(*it).number().isEmpty() ) | 375 | if ( !(*it).number().isEmpty() ) |
374 | retList.append( *it ); | 376 | retList.append( *it ); |
375 | 377 | ||
376 | return retList; | 378 | return retList; |
377 | } | 379 | } |
378 | 380 | ||
379 | void PhoneEditWidget::edit() | 381 | void PhoneEditWidget::edit() |
380 | { | 382 | { |
381 | PhoneEditDialog dlg( mPhoneList, this ); | 383 | PhoneEditDialog dlg( mPhoneList, this ); |
382 | 384 | ||
383 | if ( dlg.exec() ) { | 385 | if ( dlg.exec() ) { |
384 | if ( dlg.changed() ) { | 386 | if ( dlg.changed() ) { |
385 | KABC::PhoneNumber::List list = dlg.phoneNumbers(); | 387 | KABC::PhoneNumber::List list = dlg.phoneNumbers(); |
386 | setPhoneNumbers( list ); | 388 | setPhoneNumbers( list ); |
387 | updateCombos(); | 389 | updateCombos(); |
388 | updateLineEdits(); | 390 | updateLineEdits(); |
389 | emit modified(); | 391 | emit modified(); |
390 | } | 392 | } |
391 | } | 393 | } |
392 | } | 394 | } |
393 | 395 | ||
394 | void PhoneEditWidget::updatePrefEdit() | 396 | void PhoneEditWidget::updatePrefEdit() |
395 | { | 397 | { |
396 | updateEdit( mPrefCombo ); | 398 | updateEdit( mPrefCombo ); |
397 | } | 399 | } |
398 | 400 | ||
399 | void PhoneEditWidget::updateSecondEdit() | 401 | void PhoneEditWidget::updateSecondEdit() |
400 | { | 402 | { |
401 | updateEdit( mSecondCombo ); | 403 | updateEdit( mSecondCombo ); |
402 | } | 404 | } |
403 | 405 | ||
404 | void PhoneEditWidget::updateThirdEdit() | 406 | void PhoneEditWidget::updateThirdEdit() |
405 | { | 407 | { |
406 | updateEdit( mThirdCombo ); | 408 | updateEdit( mThirdCombo ); |
407 | } | 409 | } |
408 | 410 | ||
409 | void PhoneEditWidget::updateFourthEdit() | 411 | void PhoneEditWidget::updateFourthEdit() |
410 | { | 412 | { |
411 | updateEdit( mFourthCombo ); | 413 | updateEdit( mFourthCombo ); |
412 | } | 414 | } |
413 | 415 | ||
414 | void PhoneEditWidget::updateEdit( PhoneTypeCombo *combo ) | 416 | void PhoneEditWidget::updateEdit( PhoneTypeCombo *combo ) |
415 | { | 417 | { |
416 | QLineEdit *edit = combo->lineEdit(); | 418 | QLineEdit *edit = combo->lineEdit(); |
417 | if ( !edit ) | 419 | if ( !edit ) |
418 | return; | 420 | return; |
419 | 421 | ||
420 | #if 0 | 422 | #if 0 |
421 | if ( edit == mPrefEdit ) kdDebug(5720) << " prefEdit" << endl; | 423 | if ( edit == mPrefEdit ) kdDebug(5720) << " prefEdit" << endl; |
422 | if ( edit == mSecondEdit ) kdDebug(5720) << " secondEdit" << endl; | 424 | if ( edit == mSecondEdit ) kdDebug(5720) << " secondEdit" << endl; |
423 | if ( edit == mThirdEdit ) kdDebug(5720) << " thirdEdit" << endl; | 425 | if ( edit == mThirdEdit ) kdDebug(5720) << " thirdEdit" << endl; |
424 | if ( edit == mFourthEdit ) kdDebug(5720) << " fourthEdit" << endl; | 426 | if ( edit == mFourthEdit ) kdDebug(5720) << " fourthEdit" << endl; |
425 | #endif | 427 | #endif |
426 | 428 | ||
427 | PhoneNumber::List::Iterator it = combo->selectedElement(); | 429 | PhoneNumber::List::Iterator it = combo->selectedElement(); |
428 | if ( it != mPhoneList.end() ) { | 430 | if ( it != mPhoneList.end() ) { |
429 | edit->setText( (*it).number() ); | 431 | edit->setText( (*it).number() ); |
430 | } else { | 432 | } else { |
431 | kdDebug(5720) << "PhoneEditWidget::updateEdit(): no selected element" << endl; | 433 | kdDebug(5720) << "PhoneEditWidget::updateEdit(): no selected element" << endl; |
432 | } | 434 | } |
433 | } | 435 | } |
434 | 436 | ||
435 | void PhoneEditWidget::slotPrefEditChanged() | 437 | void PhoneEditWidget::slotPrefEditChanged() |
436 | { | 438 | { |
437 | updatePhoneNumber( mPrefCombo ); | 439 | updatePhoneNumber( mPrefCombo ); |
438 | } | 440 | } |
439 | 441 | ||
440 | void PhoneEditWidget::slotSecondEditChanged() | 442 | void PhoneEditWidget::slotSecondEditChanged() |
441 | { | 443 | { |
442 | updatePhoneNumber( mSecondCombo ); | 444 | updatePhoneNumber( mSecondCombo ); |
443 | } | 445 | } |
444 | 446 | ||
445 | void PhoneEditWidget::slotThirdEditChanged() | 447 | void PhoneEditWidget::slotThirdEditChanged() |
446 | { | 448 | { |
447 | updatePhoneNumber( mThirdCombo ); | 449 | updatePhoneNumber( mThirdCombo ); |
448 | } | 450 | } |
449 | 451 | ||
450 | void PhoneEditWidget::slotFourthEditChanged() | 452 | void PhoneEditWidget::slotFourthEditChanged() |
451 | { | 453 | { |
452 | updatePhoneNumber( mFourthCombo ); | 454 | updatePhoneNumber( mFourthCombo ); |
453 | } | 455 | } |
454 | 456 | ||
455 | void PhoneEditWidget::updatePhoneNumber( PhoneTypeCombo *combo ) | 457 | void PhoneEditWidget::updatePhoneNumber( PhoneTypeCombo *combo ) |
456 | { | 458 | { |
457 | QLineEdit *edit = combo->lineEdit(); | 459 | QLineEdit *edit = combo->lineEdit(); |
458 | if ( !edit ) return; | 460 | if ( !edit ) return; |
459 | 461 | ||
460 | PhoneNumber::List::Iterator it = combo->selectedElement(); | 462 | PhoneNumber::List::Iterator it = combo->selectedElement(); |
461 | if ( it != mPhoneList.end() ) { | 463 | if ( it != mPhoneList.end() ) { |
462 | (*it).setNumber( edit->text() ); | 464 | (*it).setNumber( edit->text() ); |
463 | } | 465 | } |
464 | 466 | ||
465 | updateOtherEdit( combo, mPrefCombo ); | 467 | updateOtherEdit( combo, mPrefCombo ); |
466 | updateOtherEdit( combo, mSecondCombo ); | 468 | updateOtherEdit( combo, mSecondCombo ); |
467 | updateOtherEdit( combo, mThirdCombo ); | 469 | updateOtherEdit( combo, mThirdCombo ); |
468 | updateOtherEdit( combo, mFourthCombo ); | 470 | updateOtherEdit( combo, mFourthCombo ); |
469 | 471 | ||
470 | emit modified(); | 472 | emit modified(); |
471 | } | 473 | } |
472 | 474 | ||
473 | void PhoneEditWidget::updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ) | 475 | void PhoneEditWidget::updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ) |
474 | { | 476 | { |
475 | if ( combo == otherCombo ) return; | 477 | if ( combo == otherCombo ) return; |
476 | 478 | ||
477 | if ( combo->currentItem() == otherCombo->currentItem() ) { | 479 | if ( combo->currentItem() == otherCombo->currentItem() ) { |
478 | updateEdit( otherCombo ); | 480 | updateEdit( otherCombo ); |
479 | } | 481 | } |
480 | } | 482 | } |
481 | 483 | ||
482 | /////////////////////////////////////////// | 484 | /////////////////////////////////////////// |
483 | // PhoneEditDialog | 485 | // PhoneEditDialog |
484 | 486 | ||
485 | class PhoneViewItem : public QListViewItem | 487 | class PhoneViewItem : public QListViewItem |
486 | { | 488 | { |
487 | public: | 489 | public: |
488 | PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ); | 490 | PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ); |
489 | 491 | ||
490 | void setPhoneNumber( const KABC::PhoneNumber &number ) | 492 | void setPhoneNumber( const KABC::PhoneNumber &number ) |
491 | { | 493 | { |
492 | mPhoneNumber = number; | 494 | mPhoneNumber = number; |
493 | makeText(); | 495 | makeText(); |
494 | } | 496 | } |
495 | 497 | ||
496 | QString key() { return mPhoneNumber.id(); } | 498 | QString key() { return mPhoneNumber.id(); } |
497 | QString country() { return ""; } | 499 | QString country() { return ""; } |
498 | QString region() { return ""; } | 500 | QString region() { return ""; } |
499 | QString number() { return ""; } | 501 | QString number() { return ""; } |
500 | 502 | ||
501 | KABC::PhoneNumber phoneNumber() { return mPhoneNumber; } | 503 | KABC::PhoneNumber phoneNumber() { return mPhoneNumber; } |
502 | 504 | ||
503 | private: | 505 | private: |
504 | void makeText(); | 506 | void makeText(); |
505 | 507 | ||
506 | KABC::PhoneNumber mPhoneNumber; | 508 | KABC::PhoneNumber mPhoneNumber; |
507 | }; | 509 | }; |
508 | 510 | ||
509 | PhoneViewItem::PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ) | 511 | PhoneViewItem::PhoneViewItem( QListView *parent, const KABC::PhoneNumber &number ) |
510 | : QListViewItem( parent ), mPhoneNumber( number ) | 512 | : QListViewItem( parent ), mPhoneNumber( number ) |
511 | { | 513 | { |
512 | #ifdef DESKTOP_VERSION | 514 | #ifdef DESKTOP_VERSION |
513 | setRenameEnabled ( 0, true ); | 515 | setRenameEnabled ( 0, true ); |
514 | #endif | 516 | #endif |
515 | makeText(); | 517 | makeText(); |
516 | } | 518 | } |
517 | 519 | ||
518 | void PhoneViewItem::makeText() | 520 | void PhoneViewItem::makeText() |
519 | { | 521 | { |
520 | /** | 522 | /** |
521 | * Will be used in future versions of kaddressbook/libkabc | 523 | * Will be used in future versions of kaddressbook/libkabc |
522 | 524 | ||
523 | setText( 0, mPhoneNumber.country() ); | 525 | setText( 0, mPhoneNumber.country() ); |
524 | setText( 1, mPhoneNumber.region() ); | 526 | setText( 1, mPhoneNumber.region() ); |
525 | setText( 2, mPhoneNumber.number() ); | 527 | setText( 2, mPhoneNumber.number() ); |
526 | setText( 3, mPhoneNumber.typeLabel() ); | 528 | setText( 3, mPhoneNumber.typeLabel() ); |
527 | */ | 529 | */ |
528 | 530 | ||
529 | setText( 0, mPhoneNumber.number() ); | 531 | setText( 0, mPhoneNumber.number() ); |
530 | setText( 1, mPhoneNumber.typeLabel() ); | 532 | setText( 1, mPhoneNumber.typeLabel() ); |
531 | } | 533 | } |
532 | 534 | ||
533 | PhoneEditDialog::PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name ) | 535 | PhoneEditDialog::PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name ) |
534 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Numbers" ), | 536 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Numbers" ), |
535 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, | 537 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, |
536 | parent, name, true) | 538 | parent, name, true) |
537 | { | 539 | { |
538 | mPhoneNumberList = list; | 540 | mPhoneNumberList = list; |
539 | 541 | ||
540 | QWidget *page = plainPage(); | 542 | QWidget *page = plainPage(); |
541 | 543 | ||
542 | QGridLayout *layout = new QGridLayout( page, 1, 2 ); | 544 | QGridLayout *layout = new QGridLayout( page, 1, 2 ); |
543 | layout->setSpacing( spacingHint() ); | 545 | layout->setSpacing( spacingHint() ); |
544 | 546 | ||
545 | mListView = new KListView( page ); | 547 | mListView = new KListView( page ); |
546 | mListView->setAllColumnsShowFocus( true ); | 548 | mListView->setAllColumnsShowFocus( true ); |
547 | mListView->addColumn( i18n( "Number" ) ); | 549 | mListView->addColumn( i18n( "Number" ) ); |
548 | mListView->addColumn( i18n( "Type" ) ); | 550 | mListView->addColumn( i18n( "Type" ) ); |
549 | 551 | ||
550 | KButtonBox *buttonBox = new KButtonBox( page, Vertical ); | 552 | KButtonBox *buttonBox = new KButtonBox( page, Vertical ); |
551 | 553 | ||
552 | buttonBox->addButton( i18n( "&Add..." ), this, SLOT( slotAddPhoneNumber() ) ); | 554 | buttonBox->addButton( i18n( "&Add..." ), this, SLOT( slotAddPhoneNumber() ) ); |
553 | mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( slotEditPhoneNumber() ) ); | 555 | mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( slotEditPhoneNumber() ) ); |
554 | mEditButton->setEnabled( false ); | 556 | mEditButton->setEnabled( false ); |
555 | mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( slotRemovePhoneNumber() ) ); | 557 | mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( slotRemovePhoneNumber() ) ); |
556 | mRemoveButton->setEnabled( false ); | 558 | mRemoveButton->setEnabled( false ); |
557 | buttonBox->layout(); | 559 | buttonBox->layout(); |
558 | 560 | ||
559 | layout->addWidget( mListView, 0, 0 ); | 561 | layout->addWidget( mListView, 0, 0 ); |
560 | layout->addWidget( buttonBox, 0, 1 ); | 562 | layout->addWidget( buttonBox, 0, 1 ); |
561 | 563 | ||
562 | connect( mListView, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged()) ); | 564 | connect( mListView, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged()) ); |
563 | connect( mListView, SIGNAL(doubleClicked( QListViewItem *, const QPoint &, int )), this, SLOT( slotEditPhoneNumber())); | 565 | connect( mListView, SIGNAL(doubleClicked( QListViewItem *, const QPoint &, int )), this, SLOT( slotEditPhoneNumber())); |
564 | 566 | ||
565 | KABC::PhoneNumber::List::Iterator it; | 567 | KABC::PhoneNumber::List::Iterator it; |
566 | for ( it = mPhoneNumberList.begin(); it != mPhoneNumberList.end(); ++it ) | 568 | for ( it = mPhoneNumberList.begin(); it != mPhoneNumberList.end(); ++it ) |
567 | new PhoneViewItem( mListView, *it ); | 569 | new PhoneViewItem( mListView, *it ); |
568 | if (QApplication::desktop()->width() < 480 ) | 570 | if (QApplication::desktop()->width() < 480 ) |
569 | showMaximized(); | 571 | showMaximized(); |
570 | else | 572 | else |
571 | resize( 400, 400 ); | 573 | resize( 400, 400 ); |
572 | mChanged = false; | 574 | mChanged = false; |
573 | } | 575 | } |
574 | 576 | ||
575 | PhoneEditDialog::~PhoneEditDialog() | 577 | PhoneEditDialog::~PhoneEditDialog() |
576 | { | 578 | { |
577 | qDebug("PhoneEditDialog::~PhoneEditDialog() "); | 579 | qDebug("PhoneEditDialog::~PhoneEditDialog() "); |
578 | } | 580 | } |
579 | 581 | ||
580 | void PhoneEditDialog::slotAddPhoneNumber() | 582 | void PhoneEditDialog::slotAddPhoneNumber() |
581 | { | 583 | { |
582 | KABC::PhoneNumber tmp( "", 0 ); | 584 | KABC::PhoneNumber tmp( "", 0 ); |
583 | PhoneTypeDialog dlg( tmp, this ); | 585 | PhoneTypeDialog dlg( tmp, this ); |
584 | 586 | ||
585 | if ( dlg.exec() ) { | 587 | if ( dlg.exec() ) { |
586 | QListViewItem* i = mListView->firstChild(); | 588 | QListViewItem* i = mListView->firstChild(); |
587 | KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); | 589 | KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); |
588 | bool insert = true; | 590 | bool insert = true; |
589 | while ( i ) { | 591 | while ( i ) { |
590 | PhoneViewItem* p = ( PhoneViewItem* ) i; | 592 | PhoneViewItem* p = ( PhoneViewItem* ) i; |
591 | KABC::PhoneNumber pn = p->phoneNumber(); | 593 | KABC::PhoneNumber pn = p->phoneNumber(); |
592 | if ( (pn.type() | KABC::PhoneNumber::Pref) == (phoneNumber.type() | KABC::PhoneNumber::Pref) ) { | 594 | if ( (pn.type() | KABC::PhoneNumber::Pref) == (phoneNumber.type() | KABC::PhoneNumber::Pref) ) { |
593 | if ( p->text(0).isEmpty()) { | 595 | if ( p->text(0).isEmpty()) { |
594 | p->setPhoneNumber( phoneNumber ); | 596 | p->setPhoneNumber( phoneNumber ); |
595 | mPhoneNumberList.remove( pn ); | 597 | mPhoneNumberList.remove( pn ); |
596 | mPhoneNumberList.append( phoneNumber ); | 598 | mPhoneNumberList.append( phoneNumber ); |
597 | insert = false; | 599 | insert = false; |
598 | break; | 600 | break; |
599 | } | 601 | } |
600 | } | 602 | } |
601 | i = i->nextSibling(); | 603 | i = i->nextSibling(); |
602 | } | 604 | } |
603 | if ( insert ) { | 605 | if ( insert ) { |
604 | mPhoneNumberList.append( phoneNumber ); | 606 | mPhoneNumberList.append( phoneNumber ); |
605 | new PhoneViewItem( mListView, phoneNumber ); | 607 | new PhoneViewItem( mListView, phoneNumber ); |
606 | } | 608 | } |
607 | mChanged = true; | 609 | mChanged = true; |
608 | } | 610 | } |
609 | } | 611 | } |
610 | 612 | ||
611 | void PhoneEditDialog::slotRemovePhoneNumber() | 613 | void PhoneEditDialog::slotRemovePhoneNumber() |
612 | { | 614 | { |
613 | PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); | 615 | PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); |
614 | if ( !item ) | 616 | if ( !item ) |
615 | return; | 617 | return; |
616 | 618 | ||
617 | mPhoneNumberList.remove( item->phoneNumber() ); | 619 | mPhoneNumberList.remove( item->phoneNumber() ); |
618 | QListViewItem *currItem = mListView->currentItem(); | 620 | QListViewItem *currItem = mListView->currentItem(); |
619 | mListView->takeItem( currItem ); | 621 | mListView->takeItem( currItem ); |
620 | delete currItem; | 622 | delete currItem; |
621 | 623 | ||
622 | mChanged = true; | 624 | mChanged = true; |
623 | } | 625 | } |
624 | 626 | ||
625 | void PhoneEditDialog::slotEditPhoneNumber() | 627 | void PhoneEditDialog::slotEditPhoneNumber() |
626 | { | 628 | { |
627 | PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); | 629 | PhoneViewItem *item = static_cast<PhoneViewItem*>( mListView->currentItem() ); |
628 | if ( !item ) | 630 | if ( !item ) |
629 | return; | 631 | return; |
630 | 632 | ||
631 | PhoneTypeDialog dlg( item->phoneNumber(), this ); | 633 | PhoneTypeDialog dlg( item->phoneNumber(), this ); |
632 | 634 | ||
633 | if ( dlg.exec() ) { | 635 | if ( dlg.exec() ) { |
634 | slotRemovePhoneNumber(); | 636 | slotRemovePhoneNumber(); |
635 | KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); | 637 | KABC::PhoneNumber phoneNumber = dlg.phoneNumber(); |
636 | mPhoneNumberList.append( phoneNumber ); | 638 | mPhoneNumberList.append( phoneNumber ); |
637 | new PhoneViewItem( mListView, phoneNumber ); | 639 | new PhoneViewItem( mListView, phoneNumber ); |
638 | 640 | ||
639 | mChanged = true; | 641 | mChanged = true; |
640 | } | 642 | } |
641 | } | 643 | } |
642 | 644 | ||
643 | void PhoneEditDialog::slotSelectionChanged() | 645 | void PhoneEditDialog::slotSelectionChanged() |
644 | { | 646 | { |
645 | bool state = ( mListView->currentItem() != 0 ); | 647 | bool state = ( mListView->currentItem() != 0 ); |
646 | 648 | ||
647 | mRemoveButton->setEnabled( state ); | 649 | mRemoveButton->setEnabled( state ); |
648 | mEditButton->setEnabled( state ); | 650 | mEditButton->setEnabled( state ); |
649 | } | 651 | } |
650 | 652 | ||
651 | const KABC::PhoneNumber::List &PhoneEditDialog::phoneNumbers() | 653 | const KABC::PhoneNumber::List &PhoneEditDialog::phoneNumbers() |
652 | { | 654 | { |
653 | return mPhoneNumberList; | 655 | return mPhoneNumberList; |
654 | } | 656 | } |
655 | 657 | ||
656 | bool PhoneEditDialog::changed() const | 658 | bool PhoneEditDialog::changed() const |
657 | { | 659 | { |
658 | return mChanged; | 660 | return mChanged; |
659 | } | 661 | } |
660 | 662 | ||
661 | /////////////////////////////////////////// | 663 | /////////////////////////////////////////// |
662 | // PhoneTypeDialog | 664 | // PhoneTypeDialog |
663 | PhoneTypeDialog::PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, | 665 | PhoneTypeDialog::PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, |
664 | QWidget *parent, const char *name) | 666 | QWidget *parent, const char *name) |
665 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Number" ), | 667 | : KDialogBase( KDialogBase::Plain, i18n( "Edit Phone Number" ), |
666 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, | 668 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, |
667 | parent, name, true), mPhoneNumber( phoneNumber ) | 669 | parent, name, true), mPhoneNumber( phoneNumber ) |
668 | { | 670 | { |
669 | QWidget *page = plainPage(); | 671 | QWidget *page = plainPage(); |
670 | QLabel *label = 0; | 672 | QLabel *label = 0; |
671 | QGridLayout *layout = new QGridLayout( page, 3, 2, marginHint(), spacingHint() ); | 673 | QGridLayout *layout = new QGridLayout( page, 3, 2, marginHint(), spacingHint() ); |
672 | 674 | ||
673 | label = new QLabel( i18n( "Number:" ), page ); | 675 | label = new QLabel( i18n( "Number:" ), page ); |
674 | layout->addWidget( label, 0, 0 ); | 676 | layout->addWidget( label, 0, 0 ); |
675 | mNumber = new KLineEdit( page ); | 677 | mNumber = new KLineEdit( page ); |
676 | layout->addWidget( mNumber, 0, 1 ); | 678 | layout->addWidget( mNumber, 0, 1 ); |
677 | 679 | ||
678 | mPreferredBox = new QCheckBox( i18n( "This is the preferred phone number" ), page ); | 680 | mPreferredBox = new QCheckBox( i18n( "This is the preferred phone number" ), page ); |
679 | layout->addMultiCellWidget( mPreferredBox, 1, 1, 0, 1 ); | 681 | layout->addMultiCellWidget( mPreferredBox, 1, 1, 0, 1 ); |
680 | 682 | ||
681 | mGroup = new QButtonGroup( 2, Horizontal, i18n( "Types" ), page ); | 683 | mGroup = new QButtonGroup( 2, Horizontal, i18n( "Types" ), page ); |
682 | layout->addMultiCellWidget( mGroup, 2, 2, 0, 1 ); | 684 | layout->addMultiCellWidget( mGroup, 2, 2, 0, 1 ); |
683 | 685 | ||
684 | // fill widgets | 686 | // fill widgets |
685 | mNumber->setText( mPhoneNumber.number() ); | 687 | mNumber->setText( mPhoneNumber.number() ); |
686 | 688 | ||
687 | mTypeList = KABC::PhoneNumber::typeList(); | 689 | mTypeList = KABC::PhoneNumber::typeList(); |
688 | mTypeList.remove( KABC::PhoneNumber::Pref ); | 690 | mTypeList.remove( KABC::PhoneNumber::Pref ); |
689 | 691 | ||
690 | KABC::PhoneNumber::TypeList::Iterator it; | 692 | KABC::PhoneNumber::TypeList::Iterator it; |
691 | for ( it = mTypeList.begin(); it != mTypeList.end(); ++it ) | 693 | for ( it = mTypeList.begin(); it != mTypeList.end(); ++it ) |
692 | new QCheckBox( KABC::PhoneNumber::typeLabel( *it ), mGroup ); | 694 | new QCheckBox( KABC::PhoneNumber::typeLabel( *it ), mGroup ); |
693 | 695 | ||
694 | for ( int i = 0; i < mGroup->count(); ++i ) { | 696 | for ( int i = 0; i < mGroup->count(); ++i ) { |
695 | int type = mPhoneNumber.type(); | 697 | int type = mPhoneNumber.type(); |
696 | QCheckBox *box = (QCheckBox*)mGroup->find( i ); | 698 | QCheckBox *box = (QCheckBox*)mGroup->find( i ); |
697 | box->setChecked( type & mTypeList[ i ] ); | 699 | box->setChecked( type & mTypeList[ i ] ); |
698 | } | 700 | } |
699 | 701 | ||
700 | mPreferredBox->setChecked( mPhoneNumber.type() & KABC::PhoneNumber::Pref ); | 702 | mPreferredBox->setChecked( mPhoneNumber.type() & KABC::PhoneNumber::Pref ); |
701 | mNumber->setFocus(); | 703 | mNumber->setFocus(); |
702 | mNumber->setSelection( 0, 1024); | 704 | mNumber->setSelection( 0, 1024); |
703 | } | 705 | } |
704 | 706 | ||
705 | KABC::PhoneNumber PhoneTypeDialog::phoneNumber() | 707 | KABC::PhoneNumber PhoneTypeDialog::phoneNumber() |
706 | { | 708 | { |
707 | mPhoneNumber.setNumber( mNumber->text() ); | 709 | mPhoneNumber.setNumber( mNumber->text() ); |
708 | 710 | ||
709 | int type = 0; | 711 | int type = 0; |
710 | for ( int i = 0; i < mGroup->count(); ++i ) { | 712 | for ( int i = 0; i < mGroup->count(); ++i ) { |
711 | QCheckBox *box = (QCheckBox*)mGroup->find( i ); | 713 | QCheckBox *box = (QCheckBox*)mGroup->find( i ); |
712 | if ( box->isChecked() ) | 714 | if ( box->isChecked() ) |
713 | type += mTypeList[ i ]; | 715 | type += mTypeList[ i ]; |
714 | } | 716 | } |
715 | 717 | ||
716 | if ( mPreferredBox->isChecked() ) | 718 | if ( mPreferredBox->isChecked() ) |
717 | mPhoneNumber.setType( type | KABC::PhoneNumber::Pref ); | 719 | mPhoneNumber.setType( type | KABC::PhoneNumber::Pref ); |
718 | else | 720 | else |
719 | mPhoneNumber.setType( type & ~KABC::PhoneNumber::Pref ); | 721 | mPhoneNumber.setType( type & ~KABC::PhoneNumber::Pref ); |
720 | 722 | ||
721 | return mPhoneNumber; | 723 | return mPhoneNumber; |
722 | } | 724 | } |
723 | #endif | 725 | #endif |
724 | #ifndef KAB_EMBEDDED | 726 | #ifndef KAB_EMBEDDED |
725 | #include "phoneeditwidget.moc" | 727 | #include "phoneeditwidget.moc" |
726 | #endif //KAB_EMBEDDED | 728 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/phoneeditwidget.h b/kaddressbook/phoneeditwidget.h index 0477b6c..fbf9fe7 100644 --- a/kaddressbook/phoneeditwidget.h +++ b/kaddressbook/phoneeditwidget.h | |||
@@ -1,295 +1,183 @@ | |||
1 | #ifndef PHONEEDITWIDGET_H | 1 | #ifndef PHONEEDITWIDGET_H |
2 | #define PHONEEDITWIDGET_H | 2 | #define PHONEEDITWIDGET_H |
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> | 27 | #include <kiconloader.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qpopupmenu.h> | 30 | #include <qpopupmenu.h> |
31 | 31 | ||
32 | #include <qptrlist.h> | 32 | #include <qptrlist.h> |
33 | #include <qscrollview.h> | 33 | #include <qscrollview.h> |
34 | 34 | ||
35 | #include "addresseeconfig.h" | 35 | #include "addresseeconfig.h" |
36 | #include "typecombo.h" | 36 | #include "typecombo.h" |
37 | 37 | ||
38 | class QButtonGroup; | 38 | class QButtonGroup; |
39 | class QCheckBox; | 39 | class QCheckBox; |
40 | class PhoneTypeNumberEdit; | 40 | class PhoneTypeNumberEdit; |
41 | 41 | ||
42 | #include <klineedit.h> | 42 | #include <klineedit.h> |
43 | #include <kcombobox.h> | 43 | #include <kcombobox.h> |
44 | #include <kabc/phonenumber.h> | 44 | #include <kabc/phonenumber.h> |
45 | 45 | ||
46 | typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo; | 46 | typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo; |
47 | 47 | ||
48 | /** | 48 | /** |
49 | Widget for editing phone numbers. | 49 | Widget for editing phone numbers. |
50 | */ | 50 | */ |
51 | class PhoneEditWidget : public QWidget | 51 | class PhoneEditWidget : public QWidget |
52 | { | 52 | { |
53 | Q_OBJECT | 53 | Q_OBJECT |
54 | 54 | ||
55 | public: | 55 | public: |
56 | PhoneEditWidget( QWidget *parent, const char *name = 0 ); | 56 | PhoneEditWidget( QWidget *parent, const char *name = 0 ); |
57 | ~PhoneEditWidget(); | 57 | ~PhoneEditWidget(); |
58 | 58 | ||
59 | void setPhoneNumbers( const KABC::PhoneNumber::List &list ); | 59 | void setPhoneNumbers( const KABC::PhoneNumber::List &list ); |
60 | KABC::PhoneNumber::List phoneNumbers(); | 60 | KABC::PhoneNumber::List phoneNumbers(); |
61 | 61 | ||
62 | // void updateTypeCombo( const KABC::PhoneNumber::List&, KComboBox* ); | 62 | // void updateTypeCombo( const KABC::PhoneNumber::List&, KComboBox* ); |
63 | //KABC::PhoneNumber currentPhoneNumber( KComboBox*, int ); | 63 | //KABC::PhoneNumber currentPhoneNumber( KComboBox*, int ); |
64 | 64 | ||
65 | signals: | 65 | signals: |
66 | void modified(); | 66 | void modified(); |
67 | void typeChange( int oldType, int newType ); | 67 | void typeChange( int oldType, int newType ); |
68 | 68 | ||
69 | private slots: | 69 | private slots: |
70 | void bottomVisible(); | 70 | void bottomVisible(); |
71 | void addNumberInt( int ); | 71 | void addNumberInt( int ); |
72 | void deleteEdit( PhoneTypeNumberEdit* ew ); | 72 | void deleteEdit( PhoneTypeNumberEdit* ew ); |
73 | void addNumber(); | 73 | void addNumber(); |
74 | void pendingDelete(); | 74 | void pendingDelete(); |
75 | protected: | 75 | protected: |
76 | 76 | ||
77 | private: | 77 | private: |
78 | QScrollView* sv; | 78 | QScrollView* sv; |
79 | QPopupMenu *mPopup; | 79 | QPopupMenu *mPopup; |
80 | int mPopupCount; | 80 | int mPopupCount; |
81 | PhoneTypeNumberEdit* mPendingDelete; | 81 | PhoneTypeNumberEdit* mPendingDelete; |
82 | void setDefaults(); | 82 | void setDefaults(); |
83 | PhoneTypeNumberEdit* appendEditCombo(); | 83 | PhoneTypeNumberEdit* appendEditCombo(); |
84 | QWidget* mw; | 84 | QWidget* mw; |
85 | QVBoxLayout* mainLayout; | 85 | QVBoxLayout* mainLayout; |
86 | QPtrList <PhoneTypeNumberEdit> mTypeNumberEditList; | 86 | QPtrList <PhoneTypeNumberEdit> mTypeNumberEditList; |
87 | 87 | ||
88 | KABC::PhoneNumber::List mPhoneList; | ||
89 | }; | 88 | }; |
90 | 89 | ||
91 | 90 | ||
92 | |||
93 | |||
94 | |||
95 | #if 0 | ||
96 | class PhoneEditWidget : public QWidget | ||
97 | { | ||
98 | Q___OBJECT | ||
99 | |||
100 | public: | ||
101 | PhoneEditWidget( QWidget *parent, const char *name = 0 ); | ||
102 | ~PhoneEditWidget(); | ||
103 | |||
104 | void setPhoneNumbers( const KABC::PhoneNumber::List &list ); | ||
105 | KABC::PhoneNumber::List phoneNumbers(); | ||
106 | |||
107 | void updateTypeCombo( const KABC::PhoneNumber::List&, KComboBox* ); | ||
108 | KABC::PhoneNumber currentPhoneNumber( KComboBox*, int ); | ||
109 | |||
110 | sig_nals: | ||
111 | void modified(); | ||
112 | void typeChange( int oldType, int newType ); | ||
113 | |||
114 | private sl_ots: | ||
115 | void edit(); | ||
116 | |||
117 | void updatePrefEdit(); | ||
118 | void updateSecondEdit(); | ||
119 | void updateThirdEdit(); | ||
120 | void updateFourthEdit(); | ||
121 | |||
122 | void slotPrefEditChanged(); | ||
123 | void slotSecondEditChanged(); | ||
124 | void slotThirdEditChanged(); | ||
125 | void slotFourthEditChanged(); | ||
126 | |||
127 | protected: | ||
128 | void updateLineEdits(); | ||
129 | void updateCombos(); | ||
130 | |||
131 | private: | ||
132 | QPtrList <PhoneTypeNumberEdit> mTypeNumberEditList; | ||
133 | void updateEdit( PhoneTypeCombo *combo ); | ||
134 | void updatePhoneNumber( PhoneTypeCombo *combo ); | ||
135 | void updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ); | ||
136 | |||
137 | PhoneTypeCombo *mPrefCombo; | ||
138 | PhoneTypeCombo *mSecondCombo; | ||
139 | PhoneTypeCombo *mThirdCombo; | ||
140 | PhoneTypeCombo *mFourthCombo; | ||
141 | |||
142 | KLineEdit *mPrefEdit; | ||
143 | KLineEdit *mSecondEdit; | ||
144 | KLineEdit *mThirdEdit; | ||
145 | KLineEdit *mFourthEdit; | ||
146 | |||
147 | KABC::PhoneNumber::List mPhoneList; | ||
148 | }; | ||
149 | |||
150 | /** | ||
151 | Dialog for editing lists of phonenumbers. | ||
152 | */ | ||
153 | class PhoneEditDialog : public KDialogBase | ||
154 | { | ||
155 | Q___OBJECT | ||
156 | |||
157 | public: | ||
158 | PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name = 0 ); | ||
159 | ~PhoneEditDialog(); | ||
160 | |||
161 | const KABC::PhoneNumber::List &phoneNumbers(); | ||
162 | bool changed() const; | ||
163 | |||
164 | protected s__lots: | ||
165 | void slotAddPhoneNumber(); | ||
166 | void slotRemovePhoneNumber(); | ||
167 | void slotEditPhoneNumber(); | ||
168 | void slotSelectionChanged(); | ||
169 | |||
170 | private: | ||
171 | KABC::PhoneNumber::List mPhoneNumberList; | ||
172 | KABC::PhoneNumber::TypeList mTypeList; | ||
173 | KComboBox *mTypeBox; | ||
174 | KListView *mListView; | ||
175 | |||
176 | QPushButton *mRemoveButton; | ||
177 | QPushButton *mEditButton; | ||
178 | |||
179 | bool mChanged; | ||
180 | }; | ||
181 | |||
182 | /** | ||
183 | Dialog for editing phone number types. | ||
184 | */ | ||
185 | class PhoneTypeDialog : public KDialogBase | ||
186 | { | ||
187 | Q___OBJECT | ||
188 | public: | ||
189 | PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, QWidget *parent, const char *name = 0 ); | ||
190 | |||
191 | KABC::PhoneNumber phoneNumber(); | ||
192 | |||
193 | private: | ||
194 | KABC::PhoneNumber mPhoneNumber; | ||
195 | KABC::PhoneNumber::TypeList mTypeList; | ||
196 | |||
197 | QButtonGroup *mGroup; | ||
198 | QCheckBox *mPreferredBox; | ||
199 | KLineEdit *mNumber; | ||
200 | }; | ||
201 | #endif | ||
202 | |||
203 | class PhoneTypeNumberEdit : public QWidget | 91 | class PhoneTypeNumberEdit : public QWidget |
204 | { | 92 | { |
205 | Q_OBJECT | 93 | Q_OBJECT |
206 | public: | 94 | public: |
207 | PhoneTypeNumberEdit( QWidget *parent, const char *name = 0 ) :QWidget( parent ) | 95 | PhoneTypeNumberEdit( QWidget *parent, const char *name = 0 ) :QWidget( parent ) |
208 | { | 96 | { |
209 | QHBoxLayout * lay = new QHBoxLayout( this ); | 97 | QHBoxLayout * lay = new QHBoxLayout( this ); |
210 | lay->setSpacing( 2 ); | 98 | lay->setSpacing( 2 ); |
211 | lay->setMargin( 0 ); | 99 | lay->setMargin( 0 ); |
212 | mMinusButton = new QPushButton ( this ); | 100 | mMinusButton = new QPushButton ( this ); |
213 | mMinusButton->setPixmap ( SmallIcon("minus")); | 101 | mMinusButton->setPixmap ( SmallIcon("minus")); |
214 | mCombo = new KComboBox( this ); | 102 | mCombo = new KComboBox( this ); |
215 | mNumber = new KLineEdit( this ); | 103 | mNumber = new KLineEdit( this ); |
216 | mMinusButton->setMaximumHeight( mNumber->sizeHint().height() + 6); | 104 | mMinusButton->setMaximumHeight( mNumber->sizeHint().height() + 6); |
217 | lay->addWidget( mMinusButton ); | 105 | lay->addWidget( mMinusButton ); |
218 | lay->addWidget( mCombo ); | 106 | lay->addWidget( mCombo ); |
219 | lay->addWidget( mNumber ); | 107 | lay->addWidget( mNumber ); |
220 | connect( mMinusButton , SIGNAL ( clicked() ), this, SLOT ( deleteNumber() ) ); | 108 | connect( mMinusButton , SIGNAL ( clicked() ), this, SLOT ( deleteNumber() ) ); |
221 | connect( mCombo , SIGNAL ( activated ( int ) ), this, SLOT ( comboTypeChange( int ) ) ); | 109 | connect( mCombo , SIGNAL ( activated ( int ) ), this, SLOT ( comboTypeChange( int ) ) ); |
222 | connect( mNumber , SIGNAL ( textChanged ( const QString & ) ), | 110 | connect( mNumber , SIGNAL ( textChanged ( const QString & ) ), |
223 | this, SLOT ( textChanged ( const QString & ) ) ); | 111 | this, SLOT ( textChanged ( const QString & ) ) ); |
224 | mCombo->insertStringList( PhoneNumber::supportedTypeListNames() ); | 112 | mCombo->insertStringList( PhoneNumber::supportedTypeListNames() ); |
225 | } | 113 | } |
226 | ~PhoneTypeNumberEdit() { | 114 | ~PhoneTypeNumberEdit() { |
227 | // qDebug("~PhoneTypeNumberEdit() "); | 115 | // qDebug("~PhoneTypeNumberEdit() "); |
228 | } | 116 | } |
229 | void setPhoneNumber( const KABC::PhoneNumber &phoneNumber ) | 117 | void setPhoneNumber( const KABC::PhoneNumber &phoneNumber ) |
230 | { | 118 | { |
231 | mPhoneNumber = phoneNumber; | 119 | mPhoneNumber = phoneNumber; |
232 | int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); | 120 | int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); |
233 | mCombo->setCurrentItem( index ); | 121 | mCombo->setCurrentItem( index ); |
234 | mNumber->setText( mPhoneNumber.number() ); | 122 | mNumber->setText( mPhoneNumber.number() ); |
235 | show(); | 123 | show(); |
236 | mNumber->setFocus(); | 124 | mNumber->setFocus(); |
237 | } | 125 | } |
238 | KABC::PhoneNumber phoneNumber() | 126 | KABC::PhoneNumber phoneNumber() |
239 | { | 127 | { |
240 | mPhoneNumber.setNumber( mNumber->text() ); | 128 | mPhoneNumber.setNumber( mNumber->text() ); |
241 | int index = mCombo->currentItem(); | 129 | int index = mCombo->currentItem(); |
242 | mPhoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); | 130 | mPhoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); |
243 | return mPhoneNumber; | 131 | return mPhoneNumber; |
244 | } | 132 | } |
245 | bool isValid() | 133 | bool isValid() |
246 | { | 134 | { |
247 | if ( mNumber->text().isEmpty() )return false; | 135 | if ( mNumber->text().isEmpty() )return false; |
248 | return true; | 136 | return true; |
249 | } | 137 | } |
250 | int currentType() | 138 | int currentType() |
251 | { | 139 | { |
252 | return mCombo->currentItem(); | 140 | return mCombo->currentItem(); |
253 | } | 141 | } |
254 | private slots: | 142 | private slots: |
255 | void typeExternalChanged( int oldType, int newType ) | 143 | void typeExternalChanged( int oldType, int newType ) |
256 | { | 144 | { |
257 | if ( mPhoneNumber.type() == newType ) { | 145 | if ( mPhoneNumber.type() == newType ) { |
258 | mPhoneNumber.setType(oldType); | 146 | mPhoneNumber.setType(oldType); |
259 | int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); | 147 | int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); |
260 | mCombo->setCurrentItem( index ); | 148 | mCombo->setCurrentItem( index ); |
261 | } | 149 | } |
262 | } | 150 | } |
263 | void deleteNumber() | 151 | void deleteNumber() |
264 | { | 152 | { |
265 | emit deleteMe( this ); | 153 | emit deleteMe( this ); |
266 | } | 154 | } |
267 | void comboTypeChange( int index ) | 155 | void comboTypeChange( int index ) |
268 | { | 156 | { |
269 | int old = mPhoneNumber.type(); | 157 | int old = mPhoneNumber.type(); |
270 | int newT = PhoneNumber::supportedTypeList()[index]; | 158 | int newT = PhoneNumber::supportedTypeList()[index]; |
271 | if ( old != newT ) { | 159 | if ( old != newT ) { |
272 | emit modified(); | 160 | emit modified(); |
273 | if ( newT != PhoneNumber::Voice ) | 161 | if ( newT != PhoneNumber::Voice ) |
274 | emit typeChange ( old, newT ); | 162 | emit typeChange ( old, newT ); |
275 | mPhoneNumber.setType(newT ); | 163 | mPhoneNumber.setType(newT ); |
276 | } | 164 | } |
277 | 165 | ||
278 | } | 166 | } |
279 | void textChanged ( const QString & ) | 167 | void textChanged ( const QString & ) |
280 | { | 168 | { |
281 | emit modified(); | 169 | emit modified(); |
282 | } | 170 | } |
283 | signals: | 171 | signals: |
284 | void typeChange( int oldType, int newType ); | 172 | void typeChange( int oldType, int newType ); |
285 | void modified(); | 173 | void modified(); |
286 | void deleteMe( PhoneTypeNumberEdit* ); | 174 | void deleteMe( PhoneTypeNumberEdit* ); |
287 | 175 | ||
288 | private: | 176 | private: |
289 | KABC::PhoneNumber mPhoneNumber; | 177 | KABC::PhoneNumber mPhoneNumber; |
290 | QPushButton* mMinusButton; | 178 | QPushButton* mMinusButton; |
291 | KComboBox *mCombo; | 179 | KComboBox *mCombo; |
292 | KLineEdit *mNumber; | 180 | KLineEdit *mNumber; |
293 | }; | 181 | }; |
294 | 182 | ||
295 | #endif | 183 | #endif |