author | zautrix <zautrix> | 2005-10-28 12:10:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-28 12:10:35 (UTC) |
commit | cee83f70d8e4a6945f4456c55ab1b280d3425f0f (patch) (unidiff) | |
tree | 1b317655a344f1a3640ef2561d61075e0feddd64 | |
parent | b27cb619bb9005ad4345d38bbee3b1c3d0eda1b2 (diff) | |
download | kdepimpi-cee83f70d8e4a6945f4456c55ab1b280d3425f0f.zip kdepimpi-cee83f70d8e4a6945f4456c55ab1b280d3425f0f.tar.gz kdepimpi-cee83f70d8e4a6945f4456c55ab1b280d3425f0f.tar.bz2 |
commit
-rw-r--r-- | kaddressbook/phoneeditwidget.cpp | 37 | ||||
-rw-r--r-- | kaddressbook/phoneeditwidget.h | 18 |
2 files changed, 31 insertions, 24 deletions
diff --git a/kaddressbook/phoneeditwidget.cpp b/kaddressbook/phoneeditwidget.cpp index b20275d..997fc05 100644 --- a/kaddressbook/phoneeditwidget.cpp +++ b/kaddressbook/phoneeditwidget.cpp | |||
@@ -75,10 +75,8 @@ PhoneEditWidget::PhoneEditWidget( QWidget *parent, const char *name ) | |||
75 | temp->setAlignment( Qt::AlignCenter ); | 75 | temp->setAlignment( Qt::AlignCenter ); |
76 | temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); | 76 | temp->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); |
77 | hbLayout->add( temp ); | 77 | hbLayout->add( temp ); |
78 | appendEditCombo(); | ||
79 | appendEditCombo(); | ||
80 | appendEditCombo(); | ||
81 | setDefaults(); | 78 | setDefaults(); |
79 | mTypeNumberEditList.setAutoDelete( true ); | ||
82 | } | 80 | } |
83 | 81 | ||
84 | PhoneEditWidget::~PhoneEditWidget() | 82 | PhoneEditWidget::~PhoneEditWidget() |
@@ -86,21 +84,18 @@ PhoneEditWidget::~PhoneEditWidget() | |||
86 | } | 84 | } |
87 | void PhoneEditWidget::setDefaults() | 85 | void PhoneEditWidget::setDefaults() |
88 | { | 86 | { |
89 | PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); | 87 | mTypeNumberEditList.clear(); |
88 | PhoneTypeNumberEdit* edit = appendEditCombo(); | ||
90 | KABC::PhoneNumber phoneNumber; | 89 | KABC::PhoneNumber phoneNumber; |
91 | phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref ); | 90 | phoneNumber.setType( KABC::PhoneNumber::Home | KABC::PhoneNumber::Pref ); |
92 | edit->setPhoneNumber( phoneNumber ); | 91 | edit->setPhoneNumber( phoneNumber ); |
93 | edit = mTypeNumberEditList.next(); | 92 | edit = appendEditCombo(); |
94 | phoneNumber.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref ); | 93 | phoneNumber.setType( KABC::PhoneNumber::Work | KABC::PhoneNumber::Pref ); |
95 | edit->setPhoneNumber( phoneNumber ); | 94 | edit->setPhoneNumber( phoneNumber ); |
96 | edit = mTypeNumberEditList.next(); | 95 | edit = appendEditCombo(); |
97 | phoneNumber.setType( KABC::PhoneNumber::Cell ); | 96 | phoneNumber.setType( KABC::PhoneNumber::Cell ); |
98 | edit->setPhoneNumber( phoneNumber ); | 97 | edit->setPhoneNumber( phoneNumber ); |
99 | edit = mTypeNumberEditList.next(); | 98 | |
100 | while ( edit ) { | ||
101 | edit->hide(); | ||
102 | edit = mTypeNumberEditList.next(); | ||
103 | } | ||
104 | } | 99 | } |
105 | void PhoneEditWidget::addNumber() | 100 | void PhoneEditWidget::addNumber() |
106 | { | 101 | { |
@@ -111,6 +106,7 @@ PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo() | |||
111 | PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw ); | 106 | PhoneTypeNumberEdit* edit = new PhoneTypeNumberEdit( mw ); |
112 | connect ( edit, SIGNAL ( typeChange( int , int) ), this, SIGNAL ( typeChange( int , int)) ); | 107 | connect ( edit, SIGNAL ( typeChange( int , int) ), this, SIGNAL ( typeChange( int , int)) ); |
113 | connect ( edit, SIGNAL ( modified() ), this, SIGNAL ( modified() ) ); | 108 | connect ( edit, SIGNAL ( modified() ), this, SIGNAL ( modified() ) ); |
109 | connect ( edit, SIGNAL ( deleteMe( PhoneTypeNumberEdit* ) ), this, SLOT ( deleteEdit( PhoneTypeNumberEdit*) ) ); | ||
114 | connect ( this, SIGNAL ( typeChange( int , int)), edit, SLOT ( typeExternalChanged( int, int)) ); | 110 | connect ( this, SIGNAL ( typeChange( int , int)), edit, SLOT ( typeExternalChanged( int, int)) ); |
115 | 111 | ||
116 | mainLayout->add( edit ); | 112 | mainLayout->add( edit ); |
@@ -118,15 +114,27 @@ PhoneTypeNumberEdit* PhoneEditWidget::appendEditCombo() | |||
118 | return edit; | 114 | return edit; |
119 | } | 115 | } |
120 | 116 | ||
117 | void PhoneEditWidget::deleteEdit( PhoneTypeNumberEdit* ew ) | ||
118 | { | ||
119 | mPendingDelete = ew; | ||
120 | QTimer::singleShot( 0, this, SLOT ( pendingDelete() ) ); | ||
121 | } | ||
122 | void PhoneEditWidget::pendingDelete() | ||
123 | { | ||
124 | mTypeNumberEditList.removeRef( mPendingDelete ); | ||
125 | emit modified(); | ||
126 | } | ||
127 | |||
121 | void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li ) | 128 | void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li ) |
122 | { | 129 | { |
123 | if ( li.isEmpty() ) { | 130 | if ( li.isEmpty() ) { |
124 | setDefaults(); | 131 | setDefaults(); |
125 | return; | 132 | return; |
126 | } | 133 | } |
134 | mTypeNumberEditList.clear(); | ||
127 | KABC::PhoneNumber::List::Iterator it; | 135 | KABC::PhoneNumber::List::Iterator it; |
128 | KABC::PhoneNumber::List list = li; | 136 | KABC::PhoneNumber::List list = li; |
129 | PhoneTypeNumberEdit* edit = mTypeNumberEditList.first(); | 137 | PhoneTypeNumberEdit* edit = 0;//mTypeNumberEditList.first(); |
130 | for ( it = list.begin(); it != list.end(); ++it ) { | 138 | for ( it = list.begin(); it != list.end(); ++it ) { |
131 | if ( edit ) { | 139 | if ( edit ) { |
132 | edit->setPhoneNumber( (*it ) ); | 140 | edit->setPhoneNumber( (*it ) ); |
@@ -140,8 +148,6 @@ void PhoneEditWidget::setPhoneNumbers( const KABC::PhoneNumber::List &li ) | |||
140 | edit->hide(); | 148 | edit->hide(); |
141 | edit = mTypeNumberEditList.next(); | 149 | edit = mTypeNumberEditList.next(); |
142 | } | 150 | } |
143 | //mainLayout->invalidate (); | ||
144 | mw->update(); | ||
145 | } | 151 | } |
146 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() | 152 | KABC::PhoneNumber::List PhoneEditWidget::phoneNumbers() |
147 | { | 153 | { |
@@ -515,6 +521,7 @@ PhoneEditDialog::PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget * | |||
515 | 521 | ||
516 | PhoneEditDialog::~PhoneEditDialog() | 522 | PhoneEditDialog::~PhoneEditDialog() |
517 | { | 523 | { |
524 | qDebug("PhoneEditDialog::~PhoneEditDialog() "); | ||
518 | } | 525 | } |
519 | 526 | ||
520 | void PhoneEditDialog::slotAddPhoneNumber() | 527 | void PhoneEditDialog::slotAddPhoneNumber() |
diff --git a/kaddressbook/phoneeditwidget.h b/kaddressbook/phoneeditwidget.h index 6a514ed..c730c7b 100644 --- a/kaddressbook/phoneeditwidget.h +++ b/kaddressbook/phoneeditwidget.h | |||
@@ -66,10 +66,13 @@ class PhoneEditWidget : public QScrollView | |||
66 | void typeChange( int oldType, int newType ); | 66 | void typeChange( int oldType, int newType ); |
67 | 67 | ||
68 | private slots: | 68 | private slots: |
69 | void addNumber(); | 69 | void deleteEdit( PhoneTypeNumberEdit* ew ); |
70 | void addNumber(); | ||
71 | void pendingDelete(); | ||
70 | protected: | 72 | protected: |
71 | 73 | ||
72 | private: | 74 | private: |
75 | PhoneTypeNumberEdit* mPendingDelete; | ||
73 | void setDefaults(); | 76 | void setDefaults(); |
74 | PhoneTypeNumberEdit* appendEditCombo(); | 77 | PhoneTypeNumberEdit* appendEditCombo(); |
75 | QWidget* mw; | 78 | QWidget* mw; |
@@ -212,16 +215,16 @@ public: | |||
212 | connect( mNumber , SIGNAL ( textChanged ( const QString & ) ), | 215 | connect( mNumber , SIGNAL ( textChanged ( const QString & ) ), |
213 | this, SLOT ( textChanged ( const QString & ) ) ); | 216 | this, SLOT ( textChanged ( const QString & ) ) ); |
214 | mCombo->insertStringList( PhoneNumber::supportedTypeListNames() ); | 217 | mCombo->insertStringList( PhoneNumber::supportedTypeListNames() ); |
215 | mIsValid = true; | ||
216 | } | 218 | } |
217 | 219 | ~PhoneTypeNumberEdit() { | |
220 | // qDebug("~PhoneTypeNumberEdit() "); | ||
221 | } | ||
218 | void setPhoneNumber( const KABC::PhoneNumber &phoneNumber ) | 222 | void setPhoneNumber( const KABC::PhoneNumber &phoneNumber ) |
219 | { | 223 | { |
220 | mPhoneNumber = phoneNumber; | 224 | mPhoneNumber = phoneNumber; |
221 | int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); | 225 | int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); |
222 | mCombo->setCurrentItem( index ); | 226 | mCombo->setCurrentItem( index ); |
223 | mNumber->setText( mPhoneNumber.number() ); | 227 | mNumber->setText( mPhoneNumber.number() ); |
224 | mIsValid = true; | ||
225 | show(); | 228 | show(); |
226 | 229 | ||
227 | } | 230 | } |
@@ -234,7 +237,6 @@ public: | |||
234 | } | 237 | } |
235 | bool isValid() | 238 | bool isValid() |
236 | { | 239 | { |
237 | if ( !mIsValid ) return false; | ||
238 | if ( mNumber->text().isEmpty() )return false; | 240 | if ( mNumber->text().isEmpty() )return false; |
239 | return true; | 241 | return true; |
240 | } | 242 | } |
@@ -249,9 +251,7 @@ public: | |||
249 | } | 251 | } |
250 | void deleteNumber() | 252 | void deleteNumber() |
251 | { | 253 | { |
252 | emit modified(); | 254 | emit deleteMe( this ); |
253 | hide(); | ||
254 | mIsValid = false; | ||
255 | } | 255 | } |
256 | void comboTypeChange( int index ) | 256 | void comboTypeChange( int index ) |
257 | { | 257 | { |
@@ -275,9 +275,9 @@ public: | |||
275 | signals: | 275 | signals: |
276 | void typeChange( int oldType, int newType ); | 276 | void typeChange( int oldType, int newType ); |
277 | void modified(); | 277 | void modified(); |
278 | void deleteMe( PhoneTypeNumberEdit* ); | ||
278 | 279 | ||
279 | private: | 280 | private: |
280 | bool mIsValid; | ||
281 | KABC::PhoneNumber mPhoneNumber; | 281 | KABC::PhoneNumber mPhoneNumber; |
282 | QPushButton* mMinusButton; | 282 | QPushButton* mMinusButton; |
283 | KComboBox *mCombo; | 283 | KComboBox *mCombo; |