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