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 | |||
@@ -11,42 +11,46 @@ | |||
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(); |
@@ -130,18 +134,89 @@ class PhoneEditDialog : public KDialogBase | |||
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 |