summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/addresseeeditorwidget.cpp21
-rw-r--r--kaddressbook/phoneeditwidget.cpp8
-rw-r--r--kaddressbook/phoneeditwidget.h112
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
@@ -99,228 +99,233 @@ AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension,
99 mDirty = false; 99 mDirty = false;
100} 100}
101 101
102AddresseeEditorWidget::~AddresseeEditorWidget() 102AddresseeEditorWidget::~AddresseeEditorWidget()
103{ 103{
104 kdDebug(5720) << "~AddresseeEditorWidget()" << endl; 104 kdDebug(5720) << "~AddresseeEditorWidget()" << endl;
105} 105}
106 106
107void AddresseeEditorWidget::contactsSelectionChanged() 107void 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
115void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr ) 115void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr )
116{ 116{
117 mAddressee = addr; 117 mAddressee = addr;
118 load(); 118 load();
119} 119}
120 120
121const KABC::Addressee &AddresseeEditorWidget::addressee() 121const KABC::Addressee &AddresseeEditorWidget::addressee()
122{ 122{
123 return mAddressee; 123 return mAddressee;
124} 124}
125 125
126void AddresseeEditorWidget::textChanged( const QString& ) 126void AddresseeEditorWidget::textChanged( const QString& )
127{ 127{
128 emitModified(); 128 emitModified();
129} 129}
130 130
131void AddresseeEditorWidget::initGUI() 131void 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
151void AddresseeEditorWidget::setupTab1() 151void 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() );
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp
index 7e2aec1..5639aa2 100644
--- a/kaddressbook/phoneeditwidget.cpp
+++ b/kaddressbook/phoneeditwidget.cpp
@@ -6,137 +6,139 @@
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
56PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) 56PhoneEditWidget::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
102PhoneEditWidget::~PhoneEditWidget() 104PhoneEditWidget::~PhoneEditWidget()
103{ 105{
104} 106}
105void PhoneEditWidget::setDefaults() 107void 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}
120void PhoneEditWidget::addNumberInt( int index ) 122void 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}
129void PhoneEditWidget::bottomVisible() 131void PhoneEditWidget::bottomVisible()
130{ 132{
131 sv->setContentsPos ( 0, 1024 ); 133 sv->setContentsPos ( 0, 1024 );
132} 134}
133void PhoneEditWidget::addNumber() 135void 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 )
diff --git a/kaddressbook/phoneeditwidget.h b/kaddressbook/phoneeditwidget.h
index 0477b6c..fbf9fe7 100644
--- a/kaddressbook/phoneeditwidget.h
+++ b/kaddressbook/phoneeditwidget.h
@@ -24,243 +24,131 @@
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
38class QButtonGroup; 38class QButtonGroup;
39class QCheckBox; 39class QCheckBox;
40class PhoneTypeNumberEdit; 40class 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
46typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo; 46typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo;
47 47
48/** 48/**
49 Widget for editing phone numbers. 49 Widget for editing phone numbers.
50*/ 50*/
51class PhoneEditWidget : public QWidget 51class 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
96class 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*/
153class 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*/
185class PhoneTypeDialog : public KDialogBase
186{
187 Q___OBJECT
188public:
189 PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, QWidget *parent, const char *name = 0 );
190
191 KABC::PhoneNumber phoneNumber();
192
193private:
194 KABC::PhoneNumber mPhoneNumber;
195 KABC::PhoneNumber::TypeList mTypeList;
196
197 QButtonGroup *mGroup;
198 QCheckBox *mPreferredBox;
199 KLineEdit *mNumber;
200};
201#endif
202
203class PhoneTypeNumberEdit : public QWidget 91class PhoneTypeNumberEdit : public QWidget
204{ 92{
205 Q_OBJECT 93 Q_OBJECT
206public: 94public:
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 }