author | zautrix <zautrix> | 2005-10-28 16:38:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-28 16:38:18 (UTC) |
commit | d6eb485cf2ff7a14918f51a5b21b5306f9908fdb (patch) (unidiff) | |
tree | 6382df41981bad0d38a384868cfacc04c7b4a149 /kaddressbook/phoneeditwidget.h | |
parent | 869e4921d8b052c376b2769de44674a8c2d68221 (diff) | |
download | kdepimpi-d6eb485cf2ff7a14918f51a5b21b5306f9908fdb.zip kdepimpi-d6eb485cf2ff7a14918f51a5b21b5306f9908fdb.tar.gz kdepimpi-d6eb485cf2ff7a14918f51a5b21b5306f9908fdb.tar.bz2 |
fixx
Diffstat (limited to 'kaddressbook/phoneeditwidget.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/phoneeditwidget.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/kaddressbook/phoneeditwidget.h b/kaddressbook/phoneeditwidget.h index df5aff9..0477b6c 100644 --- a/kaddressbook/phoneeditwidget.h +++ b/kaddressbook/phoneeditwidget.h | |||
@@ -1,294 +1,295 @@ | |||
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; | 88 | KABC::PhoneNumber::List mPhoneList; |
89 | }; | 89 | }; |
90 | 90 | ||
91 | 91 | ||
92 | 92 | ||
93 | 93 | ||
94 | 94 | ||
95 | #if 0 | 95 | #if 0 |
96 | class PhoneEditWidget : public QWidget | 96 | class PhoneEditWidget : public QWidget |
97 | { | 97 | { |
98 | Q___OBJECT | 98 | Q___OBJECT |
99 | 99 | ||
100 | public: | 100 | public: |
101 | PhoneEditWidget( QWidget *parent, const char *name = 0 ); | 101 | PhoneEditWidget( QWidget *parent, const char *name = 0 ); |
102 | ~PhoneEditWidget(); | 102 | ~PhoneEditWidget(); |
103 | 103 | ||
104 | void setPhoneNumbers( const KABC::PhoneNumber::List &list ); | 104 | void setPhoneNumbers( const KABC::PhoneNumber::List &list ); |
105 | KABC::PhoneNumber::List phoneNumbers(); | 105 | KABC::PhoneNumber::List phoneNumbers(); |
106 | 106 | ||
107 | void updateTypeCombo( const KABC::PhoneNumber::List&, KComboBox* ); | 107 | void updateTypeCombo( const KABC::PhoneNumber::List&, KComboBox* ); |
108 | KABC::PhoneNumber currentPhoneNumber( KComboBox*, int ); | 108 | KABC::PhoneNumber currentPhoneNumber( KComboBox*, int ); |
109 | 109 | ||
110 | sig_nals: | 110 | sig_nals: |
111 | void modified(); | 111 | void modified(); |
112 | void typeChange( int oldType, int newType ); | 112 | void typeChange( int oldType, int newType ); |
113 | 113 | ||
114 | private sl_ots: | 114 | private sl_ots: |
115 | void edit(); | 115 | void edit(); |
116 | 116 | ||
117 | void updatePrefEdit(); | 117 | void updatePrefEdit(); |
118 | void updateSecondEdit(); | 118 | void updateSecondEdit(); |
119 | void updateThirdEdit(); | 119 | void updateThirdEdit(); |
120 | void updateFourthEdit(); | 120 | void updateFourthEdit(); |
121 | 121 | ||
122 | void slotPrefEditChanged(); | 122 | void slotPrefEditChanged(); |
123 | void slotSecondEditChanged(); | 123 | void slotSecondEditChanged(); |
124 | void slotThirdEditChanged(); | 124 | void slotThirdEditChanged(); |
125 | void slotFourthEditChanged(); | 125 | void slotFourthEditChanged(); |
126 | 126 | ||
127 | protected: | 127 | protected: |
128 | void updateLineEdits(); | 128 | void updateLineEdits(); |
129 | void updateCombos(); | 129 | void updateCombos(); |
130 | 130 | ||
131 | private: | 131 | private: |
132 | QPtrList <PhoneTypeNumberEdit> mTypeNumberEditList; | 132 | QPtrList <PhoneTypeNumberEdit> mTypeNumberEditList; |
133 | void updateEdit( PhoneTypeCombo *combo ); | 133 | void updateEdit( PhoneTypeCombo *combo ); |
134 | void updatePhoneNumber( PhoneTypeCombo *combo ); | 134 | void updatePhoneNumber( PhoneTypeCombo *combo ); |
135 | void updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ); | 135 | void updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ); |
136 | 136 | ||
137 | PhoneTypeCombo *mPrefCombo; | 137 | PhoneTypeCombo *mPrefCombo; |
138 | PhoneTypeCombo *mSecondCombo; | 138 | PhoneTypeCombo *mSecondCombo; |
139 | PhoneTypeCombo *mThirdCombo; | 139 | PhoneTypeCombo *mThirdCombo; |
140 | PhoneTypeCombo *mFourthCombo; | 140 | PhoneTypeCombo *mFourthCombo; |
141 | 141 | ||
142 | KLineEdit *mPrefEdit; | 142 | KLineEdit *mPrefEdit; |
143 | KLineEdit *mSecondEdit; | 143 | KLineEdit *mSecondEdit; |
144 | KLineEdit *mThirdEdit; | 144 | KLineEdit *mThirdEdit; |
145 | KLineEdit *mFourthEdit; | 145 | KLineEdit *mFourthEdit; |
146 | 146 | ||
147 | KABC::PhoneNumber::List mPhoneList; | 147 | KABC::PhoneNumber::List mPhoneList; |
148 | }; | 148 | }; |
149 | 149 | ||
150 | /** | 150 | /** |
151 | Dialog for editing lists of phonenumbers. | 151 | Dialog for editing lists of phonenumbers. |
152 | */ | 152 | */ |
153 | class PhoneEditDialog : public KDialogBase | 153 | class PhoneEditDialog : public KDialogBase |
154 | { | 154 | { |
155 | Q___OBJECT | 155 | Q___OBJECT |
156 | 156 | ||
157 | public: | 157 | public: |
158 | PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name = 0 ); | 158 | PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name = 0 ); |
159 | ~PhoneEditDialog(); | 159 | ~PhoneEditDialog(); |
160 | 160 | ||
161 | const KABC::PhoneNumber::List &phoneNumbers(); | 161 | const KABC::PhoneNumber::List &phoneNumbers(); |
162 | bool changed() const; | 162 | bool changed() const; |
163 | 163 | ||
164 | protected s__lots: | 164 | protected s__lots: |
165 | void slotAddPhoneNumber(); | 165 | void slotAddPhoneNumber(); |
166 | void slotRemovePhoneNumber(); | 166 | void slotRemovePhoneNumber(); |
167 | void slotEditPhoneNumber(); | 167 | void slotEditPhoneNumber(); |
168 | void slotSelectionChanged(); | 168 | void slotSelectionChanged(); |
169 | 169 | ||
170 | private: | 170 | private: |
171 | KABC::PhoneNumber::List mPhoneNumberList; | 171 | KABC::PhoneNumber::List mPhoneNumberList; |
172 | KABC::PhoneNumber::TypeList mTypeList; | 172 | KABC::PhoneNumber::TypeList mTypeList; |
173 | KComboBox *mTypeBox; | 173 | KComboBox *mTypeBox; |
174 | KListView *mListView; | 174 | KListView *mListView; |
175 | 175 | ||
176 | QPushButton *mRemoveButton; | 176 | QPushButton *mRemoveButton; |
177 | QPushButton *mEditButton; | 177 | QPushButton *mEditButton; |
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 | */ |
185 | class PhoneTypeDialog : public KDialogBase | 185 | class PhoneTypeDialog : public KDialogBase |
186 | { | 186 | { |
187 | Q___OBJECT | 187 | Q___OBJECT |
188 | public: | 188 | public: |
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 | ||
193 | private: | 193 | private: |
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 | ||
203 | class PhoneTypeNumberEdit : public QWidget | 203 | class PhoneTypeNumberEdit : public QWidget |
204 | { | 204 | { |
205 | Q_OBJECT | 205 | Q_OBJECT |
206 | public: | 206 | public: |
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; |
248 | } | 249 | } |
249 | int currentType() | 250 | int currentType() |
250 | { | 251 | { |
251 | return mCombo->currentItem(); | 252 | return mCombo->currentItem(); |
252 | } | 253 | } |
253 | private slots: | 254 | private slots: |
254 | void typeExternalChanged( int oldType, int newType ) | 255 | void typeExternalChanged( int oldType, int newType ) |
255 | { | 256 | { |
256 | if ( mPhoneNumber.type() == newType ) { | 257 | if ( mPhoneNumber.type() == newType ) { |
257 | mPhoneNumber.setType(oldType); | 258 | mPhoneNumber.setType(oldType); |
258 | int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); | 259 | int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); |
259 | mCombo->setCurrentItem( index ); | 260 | mCombo->setCurrentItem( index ); |
260 | } | 261 | } |
261 | } | 262 | } |
262 | void deleteNumber() | 263 | void deleteNumber() |
263 | { | 264 | { |
264 | emit deleteMe( this ); | 265 | emit deleteMe( this ); |
265 | } | 266 | } |
266 | void comboTypeChange( int index ) | 267 | void comboTypeChange( int index ) |
267 | { | 268 | { |
268 | int old = mPhoneNumber.type(); | 269 | int old = mPhoneNumber.type(); |
269 | int newT = PhoneNumber::supportedTypeList()[index]; | 270 | int newT = PhoneNumber::supportedTypeList()[index]; |
270 | if ( old != newT ) { | 271 | if ( old != newT ) { |
271 | emit modified(); | 272 | emit modified(); |
272 | if ( newT != PhoneNumber::Voice ) | 273 | if ( newT != PhoneNumber::Voice ) |
273 | emit typeChange ( old, newT ); | 274 | emit typeChange ( old, newT ); |
274 | mPhoneNumber.setType(newT ); | 275 | mPhoneNumber.setType(newT ); |
275 | } | 276 | } |
276 | 277 | ||
277 | } | 278 | } |
278 | void textChanged ( const QString & ) | 279 | void textChanged ( const QString & ) |
279 | { | 280 | { |
280 | emit modified(); | 281 | emit modified(); |
281 | } | 282 | } |
282 | signals: | 283 | signals: |
283 | void typeChange( int oldType, int newType ); | 284 | void typeChange( int oldType, int newType ); |
284 | void modified(); | 285 | void modified(); |
285 | void deleteMe( PhoneTypeNumberEdit* ); | 286 | void deleteMe( PhoneTypeNumberEdit* ); |
286 | 287 | ||
287 | private: | 288 | private: |
288 | KABC::PhoneNumber mPhoneNumber; | 289 | KABC::PhoneNumber mPhoneNumber; |
289 | QPushButton* mMinusButton; | 290 | QPushButton* mMinusButton; |
290 | KComboBox *mCombo; | 291 | KComboBox *mCombo; |
291 | KLineEdit *mNumber; | 292 | KLineEdit *mNumber; |
292 | }; | 293 | }; |
293 | 294 | ||
294 | #endif | 295 | #endif |