summaryrefslogtreecommitdiffabout
path: root/kaddressbook/phoneeditwidget.h
Unidiff
Diffstat (limited to 'kaddressbook/phoneeditwidget.h') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/phoneeditwidget.h79
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
31class QButtonGroup; 35class QButtonGroup;
32class QCheckBox; 36class QCheckBox;
33 37
38#include <klineedit.h>
39#include <kcombobox.h>
34class KListView; 40class KListView;
35class KLineEdit;
36class KComboBox;
37 41
38typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo; 42typedef TypeCombo<KABC::PhoneNumber> PhoneTypeCombo;
39 43
40/** 44/**
41 Widget for editing phone numbers. 45 Widget for editing phone numbers.
42*/ 46*/
43class PhoneEditWidget : public QWidget 47class 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*/
98class PhoneEditDialog : public KDialogBase 102class 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*/
130class PhoneTypeDialog : public KDialogBase 134class PhoneTypeDialog : public KDialogBase
131{ 135{
132 Q_OBJECT 136 Q_OBJECT
133public: 137public:
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
138private: 142private:
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};
150class PhoneTypeNumberEdit : public QWidget
151{
152 Q_OBJECT
153public:
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:
213void typeChange( int oldType, int newType );
214
215private:
216 KABC::PhoneNumber mPhoneNumber;
217 QPushButton* mMinusButton;
218 KComboBox *mCombo;
219 KLineEdit *mNumber;
220};
146 221
147#endif 222#endif