summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/phoneeditwidget.cpp4
-rw-r--r--kaddressbook/phoneeditwidget.h5
2 files changed, 5 insertions, 4 deletions
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp
index d895ea1..f52cedb 100644
--- a/kaddressbook/phoneeditwidget.cpp
+++ b/kaddressbook/phoneeditwidget.cpp
@@ -46,66 +46,66 @@
46#include <kglobal.h> 46#include <kglobal.h>
47#include <kiconloader.h> 47#include <kiconloader.h>
48 48
49#include <kabc/phonenumber.h> 49#include <kabc/phonenumber.h>
50 50
51#include "typecombo.h" 51#include "typecombo.h"
52 52
53#include "phoneeditwidget.h" 53#include "phoneeditwidget.h"
54 54
55PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) 55PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name )
56 : QWidget(parent,name) 56 : QWidget(parent,name)
57{ 57{
58 QGridLayout* gridLayout = new QGridLayout ( this, 2,2 ); 58 QGridLayout* gridLayout = new QGridLayout ( this, 2,2 );
59 59
60 QLabel *temp = new QLabel( "", this ); 60 QLabel *temp = new QLabel( "", this );
61 temp->setAlignment( Qt::AlignCenter ); 61 temp->setAlignment( Qt::AlignCenter );
62 temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); 62 temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
63 gridLayout->addWidget( temp, 1, 0 ); 63 gridLayout->addWidget( temp, 1, 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 gridLayout->addWidget( addBut, 0, 0 ); 68 gridLayout->addWidget( addBut, 0, 0 );
69 69
70 sv = new QScrollView( this ); 70 sv = new QScrollView( this );
71 sv->setFrameStyle ( QFrame::Panel | QFrame::Plain ); 71 sv->setFrameStyle ( QFrame::Panel | QFrame::Plain );
72 sv->setLineWidth ( 1 ); 72 sv->setLineWidth ( 1 );
73 sv->setMidLineWidth ( 1 ); 73 sv->setMidLineWidth ( 1 );
74 mw = new QWidget ( sv->viewport() ); 74 mw = new QWidget ( sv->viewport() );
75 sv->addChild(mw); 75 sv->addChild(mw);
76 sv->setResizePolicy( QScrollView::AutoOneFit ); 76 sv->setResizePolicy( QScrollView::AutoOneFit );
77 mainLayout = new QVBoxLayout ( mw ); 77 mainLayout = new QVBoxLayout ( mw );
78 mainLayout->setMargin( 2 ); 78 mainLayout->setMargin( 0 );
79 mainLayout->setSpacing( 2 ); 79 mainLayout->setSpacing( 0 );
80 gridLayout->addMultiCellWidget( sv, 0, 1, 1,1 ); 80 gridLayout->addMultiCellWidget( sv, 0, 1, 1,1 );
81 setDefaults(); 81 setDefaults();
82 mTypeNumberEditList.setAutoDelete( true ); 82 mTypeNumberEditList.setAutoDelete( true );
83 mPopup = new QPopupMenu( this ); 83 mPopup = new QPopupMenu( this );
84 QStringList list = PhoneNumber::supportedTypeListNames(); 84 QStringList list = PhoneNumber::supportedTypeListNames();
85 mPopupCount = list.count(); 85 mPopupCount = list.count();
86 int i = 0; 86 int i = 0;
87 while ( i < mPopupCount ) { 87 while ( i < mPopupCount ) {
88 mPopup->insertItem( list[ i ], i ); 88 mPopup->insertItem( list[ i ], i );
89 ++i; 89 ++i;
90 } 90 }
91 connect(mPopup,SIGNAL(activated(int)),this,SLOT(addNumberInt( int))); 91 connect(mPopup,SIGNAL(activated(int)),this,SLOT(addNumberInt( int)));
92 92
93} 93}
94 94
95PhoneEditWidget::~PhoneEditWidget() 95PhoneEditWidget::~PhoneEditWidget()
96{ 96{
97} 97}
98void PhoneEditWidget::setDefaults() 98void PhoneEditWidget::setDefaults()
99{ 99{
100 mTypeNumberEditList.clear(); 100 mTypeNumberEditList.clear();
101 PhoneTypeNumberEdit* edit = appendEditCombo(); 101 PhoneTypeNumberEdit* edit = appendEditCombo();
102 KABC::PhoneNumber phoneNumber; 102 KABC::PhoneNumber phoneNumber;
103 phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref ); 103 phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref );
104 edit->setPhoneNumber( phoneNumber ); 104 edit->setPhoneNumber( phoneNumber );
105 edit = appendEditCombo(); 105 edit = appendEditCombo();
106 phoneNumber.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref ); 106 phoneNumber.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref );
107 edit->setPhoneNumber( phoneNumber ); 107 edit->setPhoneNumber( phoneNumber );
108 edit = appendEditCombo(); 108 edit = appendEditCombo();
109 phoneNumber.setType( KABC::PhoneNumber::Cell ); 109 phoneNumber.setType( KABC::PhoneNumber::Cell );
110 edit->setPhoneNumber( phoneNumber ); 110 edit->setPhoneNumber( phoneNumber );
111 111
diff --git a/kaddressbook/phoneeditwidget.h b/kaddressbook/phoneeditwidget.h
index df5aff9..0477b6c 100644
--- a/kaddressbook/phoneeditwidget.h
+++ b/kaddressbook/phoneeditwidget.h
@@ -178,70 +178,71 @@ class PhoneEditDialog : public KDialogBase
178 178
179 bool mChanged; 179 bool mChanged;
180}; 180};
181 181
182/** 182/**
183 Dialog for editing phone number types. 183 Dialog for editing phone number types.
184*/ 184*/
185class PhoneTypeDialog : public KDialogBase 185class PhoneTypeDialog : public KDialogBase
186{ 186{
187 Q___OBJECT 187 Q___OBJECT
188public: 188public:
189 PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, QWidget *parent, const char *name = 0 ); 189 PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, QWidget *parent, const char *name = 0 );
190 190
191 KABC::PhoneNumber phoneNumber(); 191 KABC::PhoneNumber phoneNumber();
192 192
193private: 193private:
194 KABC::PhoneNumber mPhoneNumber; 194 KABC::PhoneNumber mPhoneNumber;
195 KABC::PhoneNumber::TypeList mTypeList; 195 KABC::PhoneNumber::TypeList mTypeList;
196 196
197 QButtonGroup *mGroup; 197 QButtonGroup *mGroup;
198 QCheckBox *mPreferredBox; 198 QCheckBox *mPreferredBox;
199 KLineEdit *mNumber; 199 KLineEdit *mNumber;
200}; 200};
201#endif 201#endif
202 202
203class PhoneTypeNumberEdit : public QWidget 203class PhoneTypeNumberEdit : public QWidget
204{ 204{
205 Q_OBJECT 205 Q_OBJECT
206public: 206public:
207 PhoneTypeNumberEdit( QWidget *parent, const char *name = 0 ) :QWidget( parent ) 207 PhoneTypeNumberEdit( QWidget *parent, const char *name = 0 ) :QWidget( parent )
208 { 208 {
209 QHBoxLayout * lay = new QHBoxLayout( this ); 209 QHBoxLayout * lay = new QHBoxLayout( this );
210 lay->setSpacing( KDialogBase::spacingHintSmall() ); 210 lay->setSpacing( 2 );
211 lay->setMargin( KDialogBase::marginHintSmall() ); 211 lay->setMargin( 0 );
212 mMinusButton = new QPushButton ( this ); 212 mMinusButton = new QPushButton ( this );
213 mMinusButton->setPixmap ( SmallIcon("minus")); 213 mMinusButton->setPixmap ( SmallIcon("minus"));
214 mCombo = new KComboBox( this ); 214 mCombo = new KComboBox( this );
215 mNumber = new KLineEdit( this ); 215 mNumber = new KLineEdit( this );
216 mMinusButton->setMaximumHeight( mNumber->sizeHint().height() + 6);
216 lay->addWidget( mMinusButton ); 217 lay->addWidget( mMinusButton );
217 lay->addWidget( mCombo ); 218 lay->addWidget( mCombo );
218 lay->addWidget( mNumber ); 219 lay->addWidget( mNumber );
219 connect( mMinusButton , SIGNAL ( clicked() ), this, SLOT ( deleteNumber() ) ); 220 connect( mMinusButton , SIGNAL ( clicked() ), this, SLOT ( deleteNumber() ) );
220 connect( mCombo , SIGNAL ( activated ( int ) ), this, SLOT ( comboTypeChange( int ) ) ); 221 connect( mCombo , SIGNAL ( activated ( int ) ), this, SLOT ( comboTypeChange( int ) ) );
221 connect( mNumber , SIGNAL ( textChanged ( const QString & ) ), 222 connect( mNumber , SIGNAL ( textChanged ( const QString & ) ),
222 this, SLOT ( textChanged ( const QString & ) ) ); 223 this, SLOT ( textChanged ( const QString & ) ) );
223 mCombo->insertStringList( PhoneNumber::supportedTypeListNames() ); 224 mCombo->insertStringList( PhoneNumber::supportedTypeListNames() );
224 } 225 }
225 ~PhoneTypeNumberEdit() { 226 ~PhoneTypeNumberEdit() {
226 // qDebug("~PhoneTypeNumberEdit() "); 227 // qDebug("~PhoneTypeNumberEdit() ");
227 } 228 }
228 void setPhoneNumber( const KABC::PhoneNumber &phoneNumber ) 229 void setPhoneNumber( const KABC::PhoneNumber &phoneNumber )
229 { 230 {
230 mPhoneNumber = phoneNumber; 231 mPhoneNumber = phoneNumber;
231 int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); 232 int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() );
232 mCombo->setCurrentItem( index ); 233 mCombo->setCurrentItem( index );
233 mNumber->setText( mPhoneNumber.number() ); 234 mNumber->setText( mPhoneNumber.number() );
234 show(); 235 show();
235 mNumber->setFocus(); 236 mNumber->setFocus();
236 } 237 }
237 KABC::PhoneNumber phoneNumber() 238 KABC::PhoneNumber phoneNumber()
238 { 239 {
239 mPhoneNumber.setNumber( mNumber->text() ); 240 mPhoneNumber.setNumber( mNumber->text() );
240 int index = mCombo->currentItem(); 241 int index = mCombo->currentItem();
241 mPhoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); 242 mPhoneNumber.setType( PhoneNumber::supportedTypeList()[index] );
242 return mPhoneNumber; 243 return mPhoneNumber;
243 } 244 }
244 bool isValid() 245 bool isValid()
245 { 246 {
246 if ( mNumber->text().isEmpty() )return false; 247 if ( mNumber->text().isEmpty() )return false;
247 return true; 248 return true;