author | zautrix <zautrix> | 2005-10-29 11:44:55 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-10-29 11:44:55 (UTC) |
commit | 9e4a837905ba2634cc5c451fec8821404c04da30 (patch) (unidiff) | |
tree | e90a6cf9849fb7a781e0293e846f0dc646b7079c /kaddressbook | |
parent | 126ae577622d43e17d8aeb1e66cafd9d16298cd2 (diff) | |
download | kdepimpi-9e4a837905ba2634cc5c451fec8821404c04da30.zip kdepimpi-9e4a837905ba2634cc5c451fec8821404c04da30.tar.gz kdepimpi-9e4a837905ba2634cc5c451fec8821404c04da30.tar.bz2 |
fixxx
-rw-r--r-- | kaddressbook/phoneeditwidget.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kaddressbook/phoneeditwidget.h b/kaddressbook/phoneeditwidget.h index fbf9fe7..f61087b 100644 --- a/kaddressbook/phoneeditwidget.h +++ b/kaddressbook/phoneeditwidget.h | |||
@@ -1,183 +1,185 @@ | |||
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 | }; | 88 | }; |
89 | 89 | ||
90 | 90 | ||
91 | class PhoneTypeNumberEdit : public QWidget | 91 | class PhoneTypeNumberEdit : public QWidget |
92 | { | 92 | { |
93 | Q_OBJECT | 93 | Q_OBJECT |
94 | public: | 94 | public: |
95 | PhoneTypeNumberEdit( QWidget *parent, const char *name = 0 ) :QWidget( parent ) | 95 | PhoneTypeNumberEdit( QWidget *parent, const char *name = 0 ) :QWidget( parent ) |
96 | { | 96 | { |
97 | QHBoxLayout * lay = new QHBoxLayout( this ); | 97 | QHBoxLayout * lay = new QHBoxLayout( this ); |
98 | lay->setSpacing( 2 ); | 98 | lay->setSpacing( 2 ); |
99 | lay->setMargin( 0 ); | 99 | lay->setMargin( 0 ); |
100 | mMinusButton = new QPushButton ( this ); | 100 | mMinusButton = new QPushButton ( this ); |
101 | mMinusButton->setPixmap ( SmallIcon("minus")); | 101 | mMinusButton->setPixmap ( SmallIcon("minus")); |
102 | mCombo = new KComboBox( this ); | 102 | mCombo = new KComboBox( this ); |
103 | if ( QApplication::desktop()->width() <= 640 ) | ||
104 | mCombo->setSizeLimit ( 6 ); | ||
103 | mNumber = new KLineEdit( this ); | 105 | mNumber = new KLineEdit( this ); |
104 | mMinusButton->setMaximumHeight( mNumber->sizeHint().height() + 6); | 106 | mMinusButton->setMaximumHeight( mNumber->sizeHint().height() + 6); |
105 | lay->addWidget( mMinusButton ); | 107 | lay->addWidget( mMinusButton ); |
106 | lay->addWidget( mCombo ); | 108 | lay->addWidget( mCombo ); |
107 | lay->addWidget( mNumber ); | 109 | lay->addWidget( mNumber ); |
108 | connect( mMinusButton , SIGNAL ( clicked() ), this, SLOT ( deleteNumber() ) ); | 110 | connect( mMinusButton , SIGNAL ( clicked() ), this, SLOT ( deleteNumber() ) ); |
109 | connect( mCombo , SIGNAL ( activated ( int ) ), this, SLOT ( comboTypeChange( int ) ) ); | 111 | connect( mCombo , SIGNAL ( activated ( int ) ), this, SLOT ( comboTypeChange( int ) ) ); |
110 | connect( mNumber , SIGNAL ( textChanged ( const QString & ) ), | 112 | connect( mNumber , SIGNAL ( textChanged ( const QString & ) ), |
111 | this, SLOT ( textChanged ( const QString & ) ) ); | 113 | this, SLOT ( textChanged ( const QString & ) ) ); |
112 | mCombo->insertStringList( PhoneNumber::supportedTypeListNames() ); | 114 | mCombo->insertStringList( PhoneNumber::supportedTypeListNames() ); |
113 | } | 115 | } |
114 | ~PhoneTypeNumberEdit() { | 116 | ~PhoneTypeNumberEdit() { |
115 | // qDebug("~PhoneTypeNumberEdit() "); | 117 | // qDebug("~PhoneTypeNumberEdit() "); |
116 | } | 118 | } |
117 | void setPhoneNumber( const KABC::PhoneNumber &phoneNumber ) | 119 | void setPhoneNumber( const KABC::PhoneNumber &phoneNumber ) |
118 | { | 120 | { |
119 | mPhoneNumber = phoneNumber; | 121 | mPhoneNumber = phoneNumber; |
120 | int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); | 122 | int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); |
121 | mCombo->setCurrentItem( index ); | 123 | mCombo->setCurrentItem( index ); |
122 | mNumber->setText( mPhoneNumber.number() ); | 124 | mNumber->setText( mPhoneNumber.number() ); |
123 | show(); | 125 | show(); |
124 | mNumber->setFocus(); | 126 | mNumber->setFocus(); |
125 | } | 127 | } |
126 | KABC::PhoneNumber phoneNumber() | 128 | KABC::PhoneNumber phoneNumber() |
127 | { | 129 | { |
128 | mPhoneNumber.setNumber( mNumber->text() ); | 130 | mPhoneNumber.setNumber( mNumber->text() ); |
129 | int index = mCombo->currentItem(); | 131 | int index = mCombo->currentItem(); |
130 | mPhoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); | 132 | mPhoneNumber.setType( PhoneNumber::supportedTypeList()[index] ); |
131 | return mPhoneNumber; | 133 | return mPhoneNumber; |
132 | } | 134 | } |
133 | bool isValid() | 135 | bool isValid() |
134 | { | 136 | { |
135 | if ( mNumber->text().isEmpty() )return false; | 137 | if ( mNumber->text().isEmpty() )return false; |
136 | return true; | 138 | return true; |
137 | } | 139 | } |
138 | int currentType() | 140 | int currentType() |
139 | { | 141 | { |
140 | return mCombo->currentItem(); | 142 | return mCombo->currentItem(); |
141 | } | 143 | } |
142 | private slots: | 144 | private slots: |
143 | void typeExternalChanged( int oldType, int newType ) | 145 | void typeExternalChanged( int oldType, int newType ) |
144 | { | 146 | { |
145 | if ( mPhoneNumber.type() == newType ) { | 147 | if ( mPhoneNumber.type() == newType ) { |
146 | mPhoneNumber.setType(oldType); | 148 | mPhoneNumber.setType(oldType); |
147 | int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); | 149 | int index = PhoneNumber::typeListIndex4Type( mPhoneNumber.type() ); |
148 | mCombo->setCurrentItem( index ); | 150 | mCombo->setCurrentItem( index ); |
149 | } | 151 | } |
150 | } | 152 | } |
151 | void deleteNumber() | 153 | void deleteNumber() |
152 | { | 154 | { |
153 | emit deleteMe( this ); | 155 | emit deleteMe( this ); |
154 | } | 156 | } |
155 | void comboTypeChange( int index ) | 157 | void comboTypeChange( int index ) |
156 | { | 158 | { |
157 | int old = mPhoneNumber.type(); | 159 | int old = mPhoneNumber.type(); |
158 | int newT = PhoneNumber::supportedTypeList()[index]; | 160 | int newT = PhoneNumber::supportedTypeList()[index]; |
159 | if ( old != newT ) { | 161 | if ( old != newT ) { |
160 | emit modified(); | 162 | emit modified(); |
161 | if ( newT != PhoneNumber::Voice ) | 163 | if ( newT != PhoneNumber::Voice ) |
162 | emit typeChange ( old, newT ); | 164 | emit typeChange ( old, newT ); |
163 | mPhoneNumber.setType(newT ); | 165 | mPhoneNumber.setType(newT ); |
164 | } | 166 | } |
165 | 167 | ||
166 | } | 168 | } |
167 | void textChanged ( const QString & ) | 169 | void textChanged ( const QString & ) |
168 | { | 170 | { |
169 | emit modified(); | 171 | emit modified(); |
170 | } | 172 | } |
171 | signals: | 173 | signals: |
172 | void typeChange( int oldType, int newType ); | 174 | void typeChange( int oldType, int newType ); |
173 | void modified(); | 175 | void modified(); |
174 | void deleteMe( PhoneTypeNumberEdit* ); | 176 | void deleteMe( PhoneTypeNumberEdit* ); |
175 | 177 | ||
176 | private: | 178 | private: |
177 | KABC::PhoneNumber mPhoneNumber; | 179 | KABC::PhoneNumber mPhoneNumber; |
178 | QPushButton* mMinusButton; | 180 | QPushButton* mMinusButton; |
179 | KComboBox *mCombo; | 181 | KComboBox *mCombo; |
180 | KLineEdit *mNumber; | 182 | KLineEdit *mNumber; |
181 | }; | 183 | }; |
182 | 184 | ||
183 | #endif | 185 | #endif |