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 | |
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 | |||
@@ -39,128 +39,130 @@ 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 | } |