summaryrefslogtreecommitdiffabout
path: root/kaddressbook/phoneeditwidget.h
Unidiff
Diffstat (limited to 'kaddressbook/phoneeditwidget.h') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/phoneeditwidget.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/kaddressbook/phoneeditwidget.h b/kaddressbook/phoneeditwidget.h
index 6a514ed..c730c7b 100644
--- a/kaddressbook/phoneeditwidget.h
+++ b/kaddressbook/phoneeditwidget.h
@@ -1,287 +1,287 @@
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 30
31#include <qptrlist.h> 31#include <qptrlist.h>
32#include <qscrollview.h> 32#include <qscrollview.h>
33 33
34#include "addresseeconfig.h" 34#include "addresseeconfig.h"
35#include "typecombo.h" 35#include "typecombo.h"
36 36
37class QButtonGroup; 37class QButtonGroup;
38class QCheckBox; 38class QCheckBox;
39class PhoneTypeNumberEdit; 39class PhoneTypeNumberEdit;
40 40
41#include <klineedit.h> 41#include <klineedit.h>
42#include <kcombobox.h> 42#include <kcombobox.h>
43#include <kabc/phonenumber.h> 43#include <kabc/phonenumber.h>
44 44
45typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo; 45typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo;
46 46
47/** 47/**
48 Widget for editing phone numbers. 48 Widget for editing phone numbers.
49*/ 49*/
50class PhoneEditWidget : public QScrollView 50class PhoneEditWidget : public QScrollView
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
54 public: 54 public:
55 PhoneEditWidget( QWidget *parent, const char *name = 0 ); 55 PhoneEditWidget( QWidget *parent, const char *name = 0 );
56 ~PhoneEditWidget(); 56 ~PhoneEditWidget();
57 57
58 void setPhoneNumbers( const KABC::PhoneNumber::List &list ); 58 void setPhoneNumbers( const KABC::PhoneNumber::List &list );
59 KABC::PhoneNumber::List phoneNumbers(); 59 KABC::PhoneNumber::List phoneNumbers();
60 60
61 // void updateTypeCombo( const KABC::PhoneNumber::List&, KComboBox* ); 61 // void updateTypeCombo( const KABC::PhoneNumber::List&, KComboBox* );
62 //KABC::PhoneNumber currentPhoneNumber( KComboBox*, int ); 62 //KABC::PhoneNumber currentPhoneNumber( KComboBox*, int );
63 63
64 signals: 64 signals:
65 void modified(); 65 void modified();
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;
76 QVBoxLayout* mainLayout; 79 QVBoxLayout* mainLayout;
77 QPtrList <PhoneTypeNumberEdit> mTypeNumberEditList; 80 QPtrList <PhoneTypeNumberEdit> mTypeNumberEditList;
78 81
79 KABC::PhoneNumber::List mPhoneList; 82 KABC::PhoneNumber::List mPhoneList;
80}; 83};
81 84
82 85
83 86
84 87
85 88
86#if 0 89#if 0
87class PhoneEditWidget : public QWidget 90class PhoneEditWidget : public QWidget
88{ 91{
89 Q___OBJECT 92 Q___OBJECT
90 93
91 public: 94 public:
92 PhoneEditWidget( QWidget *parent, const char *name = 0 ); 95 PhoneEditWidget( QWidget *parent, const char *name = 0 );
93 ~PhoneEditWidget(); 96 ~PhoneEditWidget();
94 97
95 void setPhoneNumbers( const KABC::PhoneNumber::List &list ); 98 void setPhoneNumbers( const KABC::PhoneNumber::List &list );
96 KABC::PhoneNumber::List phoneNumbers(); 99 KABC::PhoneNumber::List phoneNumbers();
97 100
98 void updateTypeCombo( const KABC::PhoneNumber::List&, KComboBox* ); 101 void updateTypeCombo( const KABC::PhoneNumber::List&, KComboBox* );
99 KABC::PhoneNumber currentPhoneNumber( KComboBox*, int ); 102 KABC::PhoneNumber currentPhoneNumber( KComboBox*, int );
100 103
101 sig_nals: 104 sig_nals:
102 void modified(); 105 void modified();
103 void typeChange( int oldType, int newType ); 106 void typeChange( int oldType, int newType );
104 107
105 private sl_ots: 108 private sl_ots:
106 void edit(); 109 void edit();
107 110
108 void updatePrefEdit(); 111 void updatePrefEdit();
109 void updateSecondEdit(); 112 void updateSecondEdit();
110 void updateThirdEdit(); 113 void updateThirdEdit();
111 void updateFourthEdit(); 114 void updateFourthEdit();
112 115
113 void slotPrefEditChanged(); 116 void slotPrefEditChanged();
114 void slotSecondEditChanged(); 117 void slotSecondEditChanged();
115 void slotThirdEditChanged(); 118 void slotThirdEditChanged();
116 void slotFourthEditChanged(); 119 void slotFourthEditChanged();
117 120
118 protected: 121 protected:
119 void updateLineEdits(); 122 void updateLineEdits();
120 void updateCombos(); 123 void updateCombos();
121 124
122 private: 125 private:
123 QPtrList <PhoneTypeNumberEdit> mTypeNumberEditList; 126 QPtrList <PhoneTypeNumberEdit> mTypeNumberEditList;
124 void updateEdit( PhoneTypeCombo *combo ); 127 void updateEdit( PhoneTypeCombo *combo );
125 void updatePhoneNumber( PhoneTypeCombo *combo ); 128 void updatePhoneNumber( PhoneTypeCombo *combo );
126 void updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ); 129 void updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo );
127 130
128 PhoneTypeCombo *mPrefCombo; 131 PhoneTypeCombo *mPrefCombo;
129 PhoneTypeCombo *mSecondCombo; 132 PhoneTypeCombo *mSecondCombo;
130 PhoneTypeCombo *mThirdCombo; 133 PhoneTypeCombo *mThirdCombo;
131 PhoneTypeCombo *mFourthCombo; 134 PhoneTypeCombo *mFourthCombo;
132 135
133 KLineEdit *mPrefEdit; 136 KLineEdit *mPrefEdit;
134 KLineEdit *mSecondEdit; 137 KLineEdit *mSecondEdit;
135 KLineEdit *mThirdEdit; 138 KLineEdit *mThirdEdit;
136 KLineEdit *mFourthEdit; 139 KLineEdit *mFourthEdit;
137 140
138 KABC::PhoneNumber::List mPhoneList; 141 KABC::PhoneNumber::List mPhoneList;
139}; 142};
140 143
141/** 144/**
142 Dialog for editing lists of phonenumbers. 145 Dialog for editing lists of phonenumbers.
143*/ 146*/
144class PhoneEditDialog : public KDialogBase 147class PhoneEditDialog : public KDialogBase
145{ 148{
146 Q___OBJECT 149 Q___OBJECT
147 150
148 public: 151 public:
149 PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name = 0 ); 152 PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name = 0 );
150 ~PhoneEditDialog(); 153 ~PhoneEditDialog();
151 154
152 const KABC::PhoneNumber::List &phoneNumbers(); 155 const KABC::PhoneNumber::List &phoneNumbers();
153 bool changed() const; 156 bool changed() const;
154 157
155 protected s__lots: 158 protected s__lots:
156 void slotAddPhoneNumber(); 159 void slotAddPhoneNumber();
157 void slotRemovePhoneNumber(); 160 void slotRemovePhoneNumber();
158 void slotEditPhoneNumber(); 161 void slotEditPhoneNumber();
159 void slotSelectionChanged(); 162 void slotSelectionChanged();
160 163
161 private: 164 private:
162 KABC::PhoneNumber::List mPhoneNumberList; 165 KABC::PhoneNumber::List mPhoneNumberList;
163 KABC::PhoneNumber::TypeList mTypeList; 166 KABC::PhoneNumber::TypeList mTypeList;
164 KComboBox *mTypeBox; 167 KComboBox *mTypeBox;
165 KListView *mListView; 168 KListView *mListView;
166 169
167 QPushButton *mRemoveButton; 170 QPushButton *mRemoveButton;
168 QPushButton *mEditButton; 171 QPushButton *mEditButton;
169 172
170 bool mChanged; 173 bool mChanged;
171}; 174};
172 175
173/** 176/**
174 Dialog for editing phone number types. 177 Dialog for editing phone number types.
175*/ 178*/
176class PhoneTypeDialog : public KDialogBase 179class PhoneTypeDialog : public KDialogBase
177{ 180{
178 Q___OBJECT 181 Q___OBJECT
179public: 182public:
180 PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, QWidget *parent, const char *name = 0 ); 183 PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, QWidget *parent, const char *name = 0 );
181 184
182 KABC::PhoneNumber phoneNumber(); 185 KABC::PhoneNumber phoneNumber();
183 186
184private: 187private:
185 KABC::PhoneNumber mPhoneNumber; 188 KABC::PhoneNumber mPhoneNumber;
186 KABC::PhoneNumber::TypeList mTypeList; 189 KABC::PhoneNumber::TypeList mTypeList;
187 190
188 QButtonGroup *mGroup; 191 QButtonGroup *mGroup;
189 QCheckBox *mPreferredBox; 192 QCheckBox *mPreferredBox;
190 KLineEdit *mNumber; 193 KLineEdit *mNumber;
191}; 194};
192#endif 195#endif
193 196
194class PhoneTypeNumberEdit : public QWidget 197class PhoneTypeNumberEdit : public QWidget
195{ 198{
196 Q_OBJECT 199 Q_OBJECT
197public: 200public:
198 PhoneTypeNumberEdit( QWidget *parent, const char *name = 0 ) :QWidget( parent ) 201 PhoneTypeNumberEdit( QWidget *parent, const char *name = 0 ) :QWidget( parent )
199 { 202 {
200 QHBoxLayout * lay = new QHBoxLayout( this ); 203 QHBoxLayout * lay = new QHBoxLayout( this );
201 lay->setSpacing( KDialogBase::spacingHintSmall() ); 204 lay->setSpacing( KDialogBase::spacingHintSmall() );
202 lay->setMargin( KDialogBase::marginHintSmall() ); 205 lay->setMargin( KDialogBase::marginHintSmall() );
203 mMinusButton = new QPushButton ( this ); 206 mMinusButton = new QPushButton ( this );
204 mMinusButton->setPixmap ( SmallIcon("minus")); 207 mMinusButton->setPixmap ( SmallIcon("minus"));
205 mCombo = new KComboBox( this ); 208 mCombo = new KComboBox( this );
206 mNumber = new KLineEdit( this ); 209 mNumber = new KLineEdit( this );
207 lay->addWidget( mMinusButton ); 210 lay->addWidget( mMinusButton );
208 lay->addWidget( mCombo ); 211 lay->addWidget( mCombo );
209 lay->addWidget( mNumber ); 212 lay->addWidget( mNumber );
210 connect( mMinusButton , SIGNAL ( clicked() ), this, SLOT ( deleteNumber() ) ); 213 connect( mMinusButton , SIGNAL ( clicked() ), this, SLOT ( deleteNumber() ) );
211 connect( mCombo , SIGNAL ( activated ( int ) ), this, SLOT ( comboTypeChange( int ) ) ); 214 connect( mCombo , SIGNAL ( activated ( int ) ), this, SLOT ( comboTypeChange( int ) ) );
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 }
228 KABC::PhoneNumber phoneNumber() 231 KABC::PhoneNumber phoneNumber()
229 { 232 {
230 mPhoneNumber.setNumber( mNumber->text() ); 233 mPhoneNumber.setNumber( mNumber->text() );
231 int index = mCombo->currentItem(); 234 int index = mCombo->currentItem();
232 mPhoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); 235 mPhoneNumber.setType( PhoneNumber::supportedTypeList()[index] );
233 return mPhoneNumber; 236 return mPhoneNumber;
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 }
241 private slots: 243 private slots:
242 void typeExternalChanged( int oldType, int newType ) 244 void typeExternalChanged( int oldType, int newType )
243 { 245 {
244 if ( mPhoneNumber.type() == newType ) { 246 if ( mPhoneNumber.type() == newType ) {
245 mPhoneNumber.setType(oldType); 247 mPhoneNumber.setType(oldType);
246 int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); 248 int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() );
247 mCombo->setCurrentItem( index ); 249 mCombo->setCurrentItem( index );
248 } 250 }
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 {
258 int old = mPhoneNumber.type(); 258 int old = mPhoneNumber.type();
259 int newT = PhoneNumber::supportedTypeList()[index]; 259 int newT = PhoneNumber::supportedTypeList()[index];
260 if ( old != newT ) { 260 if ( old != newT ) {
261 emit modified(); 261 emit modified();
262 emit typeChange ( old, newT ); 262 emit typeChange ( old, newT );
263 mPhoneNumber.setType(newT ); 263 mPhoneNumber.setType(newT );
264 } 264 }
265 265
266 } 266 }
267 int currentType() 267 int currentType()
268 { 268 {
269 return mCombo->currentItem(); 269 return mCombo->currentItem();
270 } 270 }
271 void textChanged ( const QString & ) 271 void textChanged ( const QString & )
272 { 272 {
273 emit modified(); 273 emit modified();
274 } 274 }
275 signals: 275 signals:
276void typeChange( int oldType, int newType ); 276void typeChange( int oldType, int newType );
277 void modified(); 277 void modified();
278 void deleteMe( PhoneTypeNumberEdit* );
278 279
279private: 280private:
280 bool mIsValid;
281 KABC::PhoneNumber mPhoneNumber; 281 KABC::PhoneNumber mPhoneNumber;
282 QPushButton* mMinusButton; 282 QPushButton* mMinusButton;
283 KComboBox *mCombo; 283 KComboBox *mCombo;
284 KLineEdit *mNumber; 284 KLineEdit *mNumber;
285}; 285};
286 286
287#endif 287#endif