author | zautrix <zautrix> | 2005-10-28 08:57:25 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-28 08:57:25 (UTC) |
commit | f284eafbe4274cb97ec25f375544b924ae04ac09 (patch) (unidiff) | |
tree | bc754eac9882740463a447099944cbb590bad7f6 /kaddressbook/phoneeditwidget.h | |
parent | d934f3fe2a62f6a696992335124c4434cd77d990 (diff) | |
download | kdepimpi-f284eafbe4274cb97ec25f375544b924ae04ac09.zip kdepimpi-f284eafbe4274cb97ec25f375544b924ae04ac09.tar.gz kdepimpi-f284eafbe4274cb97ec25f375544b924ae04ac09.tar.bz2 |
cimmit
Diffstat (limited to 'kaddressbook/phoneeditwidget.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/phoneeditwidget.h | 79 |
1 files changed, 77 insertions, 2 deletions
diff --git a/kaddressbook/phoneeditwidget.h b/kaddressbook/phoneeditwidget.h index 7fe4bc0..0241cf0 100644 --- a/kaddressbook/phoneeditwidget.h +++ b/kaddressbook/phoneeditwidget.h | |||
@@ -1,147 +1,222 @@ | |||
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> | ||
28 | #include <qpushbutton.h> | ||
29 | #include <qlayout.h> | ||
30 | |||
27 | 31 | ||
28 | #include "addresseeconfig.h" | 32 | #include "addresseeconfig.h" |
29 | #include "typecombo.h" | 33 | #include "typecombo.h" |
30 | 34 | ||
31 | class QButtonGroup; | 35 | class QButtonGroup; |
32 | class QCheckBox; | 36 | class QCheckBox; |
33 | 37 | ||
38 | #include <klineedit.h> | ||
39 | #include <kcombobox.h> | ||
34 | class KListView; | 40 | class KListView; |
35 | class KLineEdit; | ||
36 | class KComboBox; | ||
37 | 41 | ||
38 | typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo; | 42 | typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo; |
39 | 43 | ||
40 | /** | 44 | /** |
41 | Widget for editing phone numbers. | 45 | Widget for editing phone numbers. |
42 | */ | 46 | */ |
43 | class PhoneEditWidget : public QWidget | 47 | class PhoneEditWidget : public QWidget |
44 | { | 48 | { |
45 | Q_OBJECT | 49 | Q_OBJECT |
46 | 50 | ||
47 | public: | 51 | public: |
48 | PhoneEditWidget( QWidget *parent, const char *name = 0 ); | 52 | PhoneEditWidget( QWidget *parent, const char *name = 0 ); |
49 | ~PhoneEditWidget(); | 53 | ~PhoneEditWidget(); |
50 | 54 | ||
51 | void setPhoneNumbers( const KABC::PhoneNumber::List &list ); | 55 | void setPhoneNumbers( const KABC::PhoneNumber::List &list ); |
52 | KABC::PhoneNumber::List phoneNumbers(); | 56 | KABC::PhoneNumber::List phoneNumbers(); |
53 | 57 | ||
54 | void updateTypeCombo( const KABC::PhoneNumber::List&, KComboBox* ); | 58 | void updateTypeCombo( const KABC::PhoneNumber::List&, KComboBox* ); |
55 | KABC::PhoneNumber currentPhoneNumber( KComboBox*, int ); | 59 | KABC::PhoneNumber currentPhoneNumber( KComboBox*, int ); |
56 | 60 | ||
57 | signals: | 61 | signals: |
58 | void modified(); | 62 | void modified(); |
59 | 63 | ||
60 | private slots: | 64 | private slots: |
61 | void edit(); | 65 | void edit(); |
62 | 66 | ||
63 | void updatePrefEdit(); | 67 | void updatePrefEdit(); |
64 | void updateSecondEdit(); | 68 | void updateSecondEdit(); |
65 | void updateThirdEdit(); | 69 | void updateThirdEdit(); |
66 | void updateFourthEdit(); | 70 | void updateFourthEdit(); |
67 | 71 | ||
68 | void slotPrefEditChanged(); | 72 | void slotPrefEditChanged(); |
69 | void slotSecondEditChanged(); | 73 | void slotSecondEditChanged(); |
70 | void slotThirdEditChanged(); | 74 | void slotThirdEditChanged(); |
71 | void slotFourthEditChanged(); | 75 | void slotFourthEditChanged(); |
72 | 76 | ||
73 | protected: | 77 | protected: |
74 | void updateLineEdits(); | 78 | void updateLineEdits(); |
75 | void updateCombos(); | 79 | void updateCombos(); |
76 | 80 | ||
77 | private: | 81 | private: |
78 | void updateEdit( PhoneTypeCombo *combo ); | 82 | void updateEdit( PhoneTypeCombo *combo ); |
79 | void updatePhoneNumber( PhoneTypeCombo *combo ); | 83 | void updatePhoneNumber( PhoneTypeCombo *combo ); |
80 | void updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ); | 84 | void updateOtherEdit( PhoneTypeCombo *combo, PhoneTypeCombo *otherCombo ); |
81 | 85 | ||
82 | PhoneTypeCombo *mPrefCombo; | 86 | PhoneTypeCombo *mPrefCombo; |
83 | PhoneTypeCombo *mSecondCombo; | 87 | PhoneTypeCombo *mSecondCombo; |
84 | PhoneTypeCombo *mThirdCombo; | 88 | PhoneTypeCombo *mThirdCombo; |
85 | PhoneTypeCombo *mFourthCombo; | 89 | PhoneTypeCombo *mFourthCombo; |
86 | 90 | ||
87 | KLineEdit *mPrefEdit; | 91 | KLineEdit *mPrefEdit; |
88 | KLineEdit *mSecondEdit; | 92 | KLineEdit *mSecondEdit; |
89 | KLineEdit *mThirdEdit; | 93 | KLineEdit *mThirdEdit; |
90 | KLineEdit *mFourthEdit; | 94 | KLineEdit *mFourthEdit; |
91 | 95 | ||
92 | KABC::PhoneNumber::List mPhoneList; | 96 | KABC::PhoneNumber::List mPhoneList; |
93 | }; | 97 | }; |
94 | 98 | ||
95 | /** | 99 | /** |
96 | Dialog for editing lists of phonenumbers. | 100 | Dialog for editing lists of phonenumbers. |
97 | */ | 101 | */ |
98 | class PhoneEditDialog : public KDialogBase | 102 | class PhoneEditDialog : public KDialogBase |
99 | { | 103 | { |
100 | Q_OBJECT | 104 | Q_OBJECT |
101 | 105 | ||
102 | public: | 106 | public: |
103 | PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name = 0 ); | 107 | PhoneEditDialog( const KABC::PhoneNumber::List &list, QWidget *parent, const char *name = 0 ); |
104 | ~PhoneEditDialog(); | 108 | ~PhoneEditDialog(); |
105 | 109 | ||
106 | const KABC::PhoneNumber::List &phoneNumbers(); | 110 | const KABC::PhoneNumber::List &phoneNumbers(); |
107 | bool changed() const; | 111 | bool changed() const; |
108 | 112 | ||
109 | protected slots: | 113 | protected slots: |
110 | void slotAddPhoneNumber(); | 114 | void slotAddPhoneNumber(); |
111 | void slotRemovePhoneNumber(); | 115 | void slotRemovePhoneNumber(); |
112 | void slotEditPhoneNumber(); | 116 | void slotEditPhoneNumber(); |
113 | void slotSelectionChanged(); | 117 | void slotSelectionChanged(); |
114 | 118 | ||
115 | private: | 119 | private: |
116 | KABC::PhoneNumber::List mPhoneNumberList; | 120 | KABC::PhoneNumber::List mPhoneNumberList; |
117 | KABC::PhoneNumber::TypeList mTypeList; | 121 | KABC::PhoneNumber::TypeList mTypeList; |
118 | KComboBox *mTypeBox; | 122 | KComboBox *mTypeBox; |
119 | KListView *mListView; | 123 | KListView *mListView; |
120 | 124 | ||
121 | QPushButton *mRemoveButton; | 125 | QPushButton *mRemoveButton; |
122 | QPushButton *mEditButton; | 126 | QPushButton *mEditButton; |
123 | 127 | ||
124 | bool mChanged; | 128 | bool mChanged; |
125 | }; | 129 | }; |
126 | 130 | ||
127 | /** | 131 | /** |
128 | Dialog for editing phone number types. | 132 | Dialog for editing phone number types. |
129 | */ | 133 | */ |
130 | class PhoneTypeDialog : public KDialogBase | 134 | class PhoneTypeDialog : public KDialogBase |
131 | { | 135 | { |
132 | Q_OBJECT | 136 | Q_OBJECT |
133 | public: | 137 | public: |
134 | PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, QWidget *parent, const char *name = 0 ); | 138 | PhoneTypeDialog( const KABC::PhoneNumber &phoneNumber, QWidget *parent, const char *name = 0 ); |
135 | 139 | ||
136 | KABC::PhoneNumber phoneNumber(); | 140 | KABC::PhoneNumber phoneNumber(); |
137 | 141 | ||
138 | private: | 142 | private: |
139 | KABC::PhoneNumber mPhoneNumber; | 143 | KABC::PhoneNumber mPhoneNumber; |
140 | KABC::PhoneNumber::TypeList mTypeList; | 144 | KABC::PhoneNumber::TypeList mTypeList; |
141 | 145 | ||
142 | QButtonGroup *mGroup; | 146 | QButtonGroup *mGroup; |
143 | QCheckBox *mPreferredBox; | 147 | QCheckBox *mPreferredBox; |
144 | KLineEdit *mNumber; | 148 | KLineEdit *mNumber; |
145 | }; | 149 | }; |
150 | class PhoneTypeNumberEdit : public QWidget | ||
151 | { | ||
152 | Q_OBJECT | ||
153 | public: | ||
154 | PhoneTypeNumberEdit( QWidget *parent, const char *name = 0 ) | ||
155 | { | ||
156 | QHBoxLayout * lay = new QHBoxLayout( this ); | ||
157 | lay->setSpacing( KDialogBase::spacingHintSmall() ); | ||
158 | lay->setMargin( KDialogBase::marginHintSmall() ); | ||
159 | mMinusButton = new QPushButton ( this ); | ||
160 | mMinusButton->setPixmap ( SmallIcon("minus")); | ||
161 | mCombo = new KComboBox( this ); | ||
162 | mNumber = new KLineEdit( this ); | ||
163 | lay->addWidget( mMinusButton ); | ||
164 | lay->addWidget( mCombo ); | ||
165 | lay->addWidget( mNumber ); | ||
166 | connect( mMinusButton , SIGNAL ( clicked() ), this, SLOT ( deleteNumber() ) ); | ||
167 | connect( mCombo , SIGNAL ( activated ( int ) ), this, SLOT ( comboTypeChange( int ) ) ); | ||
168 | mCombo->insertStringList( PhoneNumber::supportedTypeListNames() ); | ||
169 | } | ||
170 | |||
171 | void setPhoneNumber( const KABC::PhoneNumber &phoneNumber ) | ||
172 | { | ||
173 | mPhoneNumber = phoneNumber; | ||
174 | int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); | ||
175 | mCombo->setCurrentItem( index ); | ||
176 | mNumber->setText( mPhoneNumber.number() ); | ||
177 | show(); | ||
178 | |||
179 | } | ||
180 | KABC::PhoneNumber phoneNumber() | ||
181 | { | ||
182 | mPhoneNumber.setNumber( mNumber->text() ); | ||
183 | int index = mCombo->currentItem(); | ||
184 | mPhoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); | ||
185 | return mPhoneNumber; | ||
186 | |||
187 | } | ||
188 | private slots: | ||
189 | void typeExternalChanged( int oldType, int newType ) | ||
190 | { | ||
191 | if ( mPhoneNumber.type() == newType ) { | ||
192 | mPhoneNumber.setType(oldType); | ||
193 | int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); | ||
194 | mCombo->setCurrentItem( index ); | ||
195 | } | ||
196 | |||
197 | } | ||
198 | void deleteNumber() | ||
199 | { | ||
200 | hide(); | ||
201 | } | ||
202 | void comboTypeChange( int index ) | ||
203 | { | ||
204 | int old = mPhoneNumber.type(); | ||
205 | int newT = PhoneNumber::supportedTypeList()[index]; | ||
206 | if ( old != newT ) { | ||
207 | mPhoneNumber.setType(newT ); | ||
208 | emit typeChange ( old, newT ); | ||
209 | } | ||
210 | |||
211 | } | ||
212 | signals: | ||
213 | void typeChange( int oldType, int newType ); | ||
214 | |||
215 | private: | ||
216 | KABC::PhoneNumber mPhoneNumber; | ||
217 | QPushButton* mMinusButton; | ||
218 | KComboBox *mCombo; | ||
219 | KLineEdit *mNumber; | ||
220 | }; | ||
146 | 221 | ||
147 | #endif | 222 | #endif |