author | zautrix <zautrix> | 2004-09-17 11:06:59 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-17 11:06:59 (UTC) |
commit | d7a6a271b48f0c79e1f3beca03bbc9c3f2a54050 (patch) (unidiff) | |
tree | 6bf244eed529e8141f7176ce9ec575ad4507bd7f /kaddressbook/viewconfigurefieldspage.cpp | |
parent | e8dac946bcd8c080b9abb74b45221ca0c5f268c7 (diff) | |
download | kdepimpi-d7a6a271b48f0c79e1f3beca03bbc9c3f2a54050.zip kdepimpi-d7a6a271b48f0c79e1f3beca03bbc9c3f2a54050.tar.gz kdepimpi-d7a6a271b48f0c79e1f3beca03bbc9c3f2a54050.tar.bz2 |
Fixed layout problem in modify view
Diffstat (limited to 'kaddressbook/viewconfigurefieldspage.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/viewconfigurefieldspage.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/kaddressbook/viewconfigurefieldspage.cpp b/kaddressbook/viewconfigurefieldspage.cpp index 2c827eb..5daae1a 100644 --- a/kaddressbook/viewconfigurefieldspage.cpp +++ b/kaddressbook/viewconfigurefieldspage.cpp | |||
@@ -1,345 +1,351 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef KAB_EMBEDDED | 24 | #ifndef KAB_EMBEDDED |
25 | #include <kcombobox.h> | 25 | #include <kcombobox.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <kdebug.h> | 27 | #include <kdebug.h> |
28 | 28 | ||
29 | #else //KAB_EMBEDDED | 29 | #else //KAB_EMBEDDED |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | #endif //KAB_EMBEDDED | 31 | #endif //KAB_EMBEDDED |
32 | 32 | ||
33 | #include <kiconloader.h> | 33 | #include <kiconloader.h> |
34 | #include <kdialog.h> | 34 | #include <kdialog.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | 36 | ||
37 | #include <qtoolbutton.h> | 37 | #include <qtoolbutton.h> |
38 | #include <qapplication.h> | ||
38 | #include <qlabel.h> | 39 | #include <qlabel.h> |
39 | #include <qlistbox.h> | 40 | #include <qlistbox.h> |
40 | #include <qlayout.h> | 41 | #include <qlayout.h> |
41 | 42 | ||
42 | #include "viewconfigurefieldspage.h" | 43 | #include "viewconfigurefieldspage.h" |
43 | 44 | ||
44 | class FieldItem : public QListBoxText | 45 | class FieldItem : public QListBoxText |
45 | { | 46 | { |
46 | public: | 47 | public: |
47 | FieldItem( QListBox *parent, KABC::Field *field ) | 48 | FieldItem( QListBox *parent, KABC::Field *field ) |
48 | : QListBoxText( parent, field->label() ), mField( field ) {} | 49 | : QListBoxText( parent, field->label() ), mField( field ) {} |
49 | 50 | ||
50 | FieldItem( QListBox *parent, KABC::Field *field, int index ) | 51 | FieldItem( QListBox *parent, KABC::Field *field, int index ) |
51 | : QListBoxText( parent, field->label(), parent->item( index ) ), | 52 | : QListBoxText( parent, field->label(), parent->item( index ) ), |
52 | mField( field ) {} | 53 | mField( field ) {} |
53 | 54 | ||
54 | KABC::Field *field() { return mField; } | 55 | KABC::Field *field() { return mField; } |
55 | 56 | ||
56 | private: | 57 | private: |
57 | KABC::Field *mField; | 58 | KABC::Field *mField; |
58 | }; | 59 | }; |
59 | 60 | ||
60 | 61 | ||
61 | ViewConfigureFieldsPage::ViewConfigureFieldsPage( KABC::AddressBook *ab, | 62 | ViewConfigureFieldsPage::ViewConfigureFieldsPage( KABC::AddressBook *ab, |
62 | QWidget *parent, | 63 | QWidget *parent, |
63 | const char *name ) | 64 | const char *name ) |
64 | : QWidget( parent, name ), mAddressBook( ab ) | 65 | : QWidget( parent, name ), mAddressBook( ab ) |
65 | { | 66 | { |
66 | initGUI(); | 67 | initGUI(); |
67 | } | 68 | } |
68 | 69 | ||
69 | void ViewConfigureFieldsPage::restoreSettings( KConfig *config ) | 70 | void ViewConfigureFieldsPage::restoreSettings( KConfig *config ) |
70 | { | 71 | { |
71 | KABC::Field::List fields = KABC::Field::restoreFields( config, "KABCFields" ); | 72 | KABC::Field::List fields = KABC::Field::restoreFields( config, "KABCFields" ); |
72 | 73 | ||
73 | if ( fields.isEmpty() ) | 74 | if ( fields.isEmpty() ) |
74 | fields = KABC::Field::defaultFields(); | 75 | fields = KABC::Field::defaultFields(); |
75 | 76 | ||
76 | KABC::Field::List::ConstIterator it; | 77 | KABC::Field::List::ConstIterator it; |
77 | for( it = fields.begin(); it != fields.end(); ++it ) | 78 | for( it = fields.begin(); it != fields.end(); ++it ) |
78 | new FieldItem( mSelectedBox, *it ); | 79 | new FieldItem( mSelectedBox, *it ); |
79 | 80 | ||
80 | slotShowFields( mCategoryCombo->currentItem() ); | 81 | slotShowFields( mCategoryCombo->currentItem() ); |
81 | } | 82 | } |
82 | 83 | ||
83 | void ViewConfigureFieldsPage::saveSettings( KConfig *config ) | 84 | void ViewConfigureFieldsPage::saveSettings( KConfig *config ) |
84 | { | 85 | { |
85 | KABC::Field::List fields; | 86 | KABC::Field::List fields; |
86 | 87 | ||
87 | for( uint i = 0; i < mSelectedBox->count(); ++i ) { | 88 | for( uint i = 0; i < mSelectedBox->count(); ++i ) { |
88 | FieldItem *fieldItem = static_cast<FieldItem *>( mSelectedBox->item( i ) ); | 89 | FieldItem *fieldItem = static_cast<FieldItem *>( mSelectedBox->item( i ) ); |
89 | fields.append( fieldItem->field() ); | 90 | fields.append( fieldItem->field() ); |
90 | } | 91 | } |
91 | 92 | ||
92 | KABC::Field::saveFields( config, "KABCFields", fields ); | 93 | KABC::Field::saveFields( config, "KABCFields", fields ); |
93 | } | 94 | } |
94 | 95 | ||
95 | void ViewConfigureFieldsPage::slotShowFields( int index ) | 96 | void ViewConfigureFieldsPage::slotShowFields( int index ) |
96 | { | 97 | { |
97 | int currentPos = mUnSelectedBox->currentItem(); | 98 | int currentPos = mUnSelectedBox->currentItem(); |
98 | mUnSelectedBox->clear(); | 99 | mUnSelectedBox->clear(); |
99 | 100 | ||
100 | int category; | 101 | int category; |
101 | if ( index == 0 ) category = KABC::Field::All; | 102 | if ( index == 0 ) category = KABC::Field::All; |
102 | else category = 1 << ( index - 1 ); | 103 | else category = 1 << ( index - 1 ); |
103 | 104 | ||
104 | KABC::Field::List allFields = mAddressBook->fields( category ); | 105 | KABC::Field::List allFields = mAddressBook->fields( category ); |
105 | 106 | ||
106 | KABC::Field::List::ConstIterator it; | 107 | KABC::Field::List::ConstIterator it; |
107 | for ( it = allFields.begin(); it != allFields.end(); ++it ) { | 108 | for ( it = allFields.begin(); it != allFields.end(); ++it ) { |
108 | QListBoxItem *item = mSelectedBox->firstItem(); | 109 | QListBoxItem *item = mSelectedBox->firstItem(); |
109 | while( item ) { | 110 | while( item ) { |
110 | FieldItem *fieldItem = static_cast<FieldItem *>( item ); | 111 | FieldItem *fieldItem = static_cast<FieldItem *>( item ); |
111 | if ( (*it)->equals( fieldItem->field() ) ) | 112 | if ( (*it)->equals( fieldItem->field() ) ) |
112 | break; | 113 | break; |
113 | item = item->next(); | 114 | item = item->next(); |
114 | } | 115 | } |
115 | 116 | ||
116 | if ( !item ) | 117 | if ( !item ) |
117 | new FieldItem( mUnSelectedBox, *it ); | 118 | new FieldItem( mUnSelectedBox, *it ); |
118 | } | 119 | } |
119 | 120 | ||
120 | mUnSelectedBox->sort(); | 121 | mUnSelectedBox->sort(); |
121 | mUnSelectedBox->setCurrentItem( currentPos ); | 122 | mUnSelectedBox->setCurrentItem( currentPos ); |
122 | } | 123 | } |
123 | 124 | ||
124 | void ViewConfigureFieldsPage::slotSelect() | 125 | void ViewConfigureFieldsPage::slotSelect() |
125 | { | 126 | { |
126 | // insert selected items in the unselected list to the selected list, | 127 | // insert selected items in the unselected list to the selected list, |
127 | // directoy under the current item if selected, or at the bottonm if | 128 | // directoy under the current item if selected, or at the bottonm if |
128 | // nothing is selected in the selected list | 129 | // nothing is selected in the selected list |
129 | int where = mSelectedBox->currentItem(); | 130 | int where = mSelectedBox->currentItem(); |
130 | //US QListBoxItem::isSelected()) is not available in QT 2.x. Use selected instead. | 131 | //US QListBoxItem::isSelected()) is not available in QT 2.x. Use selected instead. |
131 | if ( !(where > -1 && mSelectedBox->item( where )->selected()) ) | 132 | if ( !(where > -1 && mSelectedBox->item( where )->selected()) ) |
132 | where = mSelectedBox->count() - 1; | 133 | where = mSelectedBox->count() - 1; |
133 | 134 | ||
134 | for ( uint i = 0; i < mUnSelectedBox->count(); ++i ) | 135 | for ( uint i = 0; i < mUnSelectedBox->count(); ++i ) |
135 | if ( mUnSelectedBox->isSelected( mUnSelectedBox->item( i ) ) ) { | 136 | if ( mUnSelectedBox->isSelected( mUnSelectedBox->item( i ) ) ) { |
136 | FieldItem *fieldItem = static_cast<FieldItem *>( mUnSelectedBox->item( i ) ); | 137 | FieldItem *fieldItem = static_cast<FieldItem *>( mUnSelectedBox->item( i ) ); |
137 | new FieldItem( mSelectedBox, fieldItem->field(), where ); | 138 | new FieldItem( mSelectedBox, fieldItem->field(), where ); |
138 | where++; | 139 | where++; |
139 | } | 140 | } |
140 | 141 | ||
141 | slotShowFields( mCategoryCombo->currentItem() ); | 142 | slotShowFields( mCategoryCombo->currentItem() ); |
142 | } | 143 | } |
143 | 144 | ||
144 | void ViewConfigureFieldsPage::slotUnSelect() | 145 | void ViewConfigureFieldsPage::slotUnSelect() |
145 | { | 146 | { |
146 | for ( uint i = 0; i < mSelectedBox->count(); ++i ) | 147 | for ( uint i = 0; i < mSelectedBox->count(); ++i ) |
147 | if ( mSelectedBox->isSelected( mSelectedBox->item( i ) ) ) { | 148 | if ( mSelectedBox->isSelected( mSelectedBox->item( i ) ) ) { |
148 | mSelectedBox->removeItem( i ); | 149 | mSelectedBox->removeItem( i ); |
149 | --i; | 150 | --i; |
150 | } | 151 | } |
151 | 152 | ||
152 | slotShowFields( mCategoryCombo->currentItem() ); | 153 | slotShowFields( mCategoryCombo->currentItem() ); |
153 | } | 154 | } |
154 | 155 | ||
155 | void ViewConfigureFieldsPage::slotButtonsEnabled() | 156 | void ViewConfigureFieldsPage::slotButtonsEnabled() |
156 | { | 157 | { |
157 | bool state = false; | 158 | bool state = false; |
158 | // add button: enabled if any items are selected in the unselected list | 159 | // add button: enabled if any items are selected in the unselected list |
159 | for( uint i = 0; i < mUnSelectedBox->count(); ++i ) | 160 | for( uint i = 0; i < mUnSelectedBox->count(); ++i ) |
160 | //US QListBoxItem::isSelected()) is not available in QT 2.x. Use selected instead. | 161 | //US QListBoxItem::isSelected()) is not available in QT 2.x. Use selected instead. |
161 | if ( mUnSelectedBox->item( i )->selected() ) { | 162 | if ( mUnSelectedBox->item( i )->selected() ) { |
162 | state = true; | 163 | state = true; |
163 | break; | 164 | break; |
164 | } | 165 | } |
165 | mAddButton->setEnabled( state ); | 166 | mAddButton->setEnabled( state ); |
166 | 167 | ||
167 | int j = mSelectedBox->currentItem(); | 168 | int j = mSelectedBox->currentItem(); |
168 | state = ( j > -1 && mSelectedBox->isSelected( j ) ); | 169 | state = ( j > -1 && mSelectedBox->isSelected( j ) ); |
169 | 170 | ||
170 | // up button: enabled if there is a current item > 0 and that is selected | 171 | // up button: enabled if there is a current item > 0 and that is selected |
171 | mUpButton->setEnabled( ( j > 0 && state ) ); | 172 | mUpButton->setEnabled( ( j > 0 && state ) ); |
172 | 173 | ||
173 | // down button: enabled if there is a current item < count - 2 and that is selected | 174 | // down button: enabled if there is a current item < count - 2 and that is selected |
174 | mDownButton->setEnabled( ( j > -1 && j < (int)mSelectedBox->count() - 1 && state ) ); | 175 | mDownButton->setEnabled( ( j > -1 && j < (int)mSelectedBox->count() - 1 && state ) ); |
175 | 176 | ||
176 | // remove button: enabled if any items are selected in the selected list | 177 | // remove button: enabled if any items are selected in the selected list |
177 | state = false; | 178 | state = false; |
178 | for ( uint i = 0; i < mSelectedBox->count(); ++i ) | 179 | for ( uint i = 0; i < mSelectedBox->count(); ++i ) |
179 | //US QListBoxItem::isSelected()) is not available in QT 2.x. Use selected instead. | 180 | //US QListBoxItem::isSelected()) is not available in QT 2.x. Use selected instead. |
180 | if ( mSelectedBox->item( i )->selected() ) { | 181 | if ( mSelectedBox->item( i )->selected() ) { |
181 | state = true; | 182 | state = true; |
182 | break; | 183 | break; |
183 | } | 184 | } |
184 | mRemoveButton->setEnabled( state ); | 185 | mRemoveButton->setEnabled( state ); |
185 | } | 186 | } |
186 | 187 | ||
187 | void ViewConfigureFieldsPage::slotMoveUp() | 188 | void ViewConfigureFieldsPage::slotMoveUp() |
188 | { | 189 | { |
189 | int i = mSelectedBox->currentItem(); | 190 | int i = mSelectedBox->currentItem(); |
190 | if ( i > 0 ) { | 191 | if ( i > 0 ) { |
191 | QListBoxItem *item = mSelectedBox->item( i ); | 192 | QListBoxItem *item = mSelectedBox->item( i ); |
192 | mSelectedBox->takeItem( item ); | 193 | mSelectedBox->takeItem( item ); |
193 | mSelectedBox->insertItem( item, i - 1 ); | 194 | mSelectedBox->insertItem( item, i - 1 ); |
194 | mSelectedBox->setCurrentItem( item ); | 195 | mSelectedBox->setCurrentItem( item ); |
195 | mSelectedBox->setSelected( i - 1, true ); | 196 | mSelectedBox->setSelected( i - 1, true ); |
196 | } | 197 | } |
197 | } | 198 | } |
198 | 199 | ||
199 | void ViewConfigureFieldsPage::slotMoveDown() | 200 | void ViewConfigureFieldsPage::slotMoveDown() |
200 | { | 201 | { |
201 | int i = mSelectedBox->currentItem(); | 202 | int i = mSelectedBox->currentItem(); |
202 | if ( i > -1 && i < (int)mSelectedBox->count() - 1 ) { | 203 | if ( i > -1 && i < (int)mSelectedBox->count() - 1 ) { |
203 | QListBoxItem *item = mSelectedBox->item( i ); | 204 | QListBoxItem *item = mSelectedBox->item( i ); |
204 | mSelectedBox->takeItem( item ); | 205 | mSelectedBox->takeItem( item ); |
205 | mSelectedBox->insertItem( item, i + 1 ); | 206 | mSelectedBox->insertItem( item, i + 1 ); |
206 | mSelectedBox->setCurrentItem( item ); | 207 | mSelectedBox->setCurrentItem( item ); |
207 | mSelectedBox->setSelected( i + 1, true ); | 208 | mSelectedBox->setSelected( i + 1, true ); |
208 | } | 209 | } |
209 | } | 210 | } |
210 | 211 | ||
211 | void ViewConfigureFieldsPage::initGUI() | 212 | void ViewConfigureFieldsPage::initGUI() |
212 | { | 213 | { |
213 | //US change the orientation dependent on the following flag | 214 | //US change the orientation dependent on the following flag |
214 | // right the flag is set only staticly. | 215 | // right the flag is set only staticly. |
215 | // 0 = 640x480 ; 1 = 240x320 | 216 | // 0 = 640x480 ; 1 = 240x320 |
216 | bool orientation = 1; | 217 | bool orientation = 1; |
217 | 218 | ||
218 | 219 | ||
219 | setCaption( i18n("Select Fields to Display") ); | 220 | setCaption( i18n("Select Fields to Display") ); |
220 | 221 | ||
221 | QGridLayout *gl = 0; | 222 | QGridLayout *gl = 0; |
222 | |||
223 | if (orientation == 0) | 223 | if (orientation == 0) |
224 | gl = new QGridLayout( this , 6, 4, 0, KDialog::spacingHint() ); | 224 | gl = new QGridLayout( this , 6, 4, 0, KDialog::spacingHint() ); |
225 | else | 225 | else |
226 | gl = new QGridLayout( this , 4, 6, 0, KDialog::spacingHint() ); | 226 | gl = new QGridLayout( this , 4, 6, 0, KDialog::spacingHint() ); |
227 | 227 | ||
228 | #ifndef KAB_EMBEDDED | 228 | #ifndef KAB_EMBEDDED |
229 | mCategoryCombo = new KComboBox( false, this ); | 229 | mCategoryCombo = new KComboBox( false, this ); |
230 | #else //KAB_EMBEDDED | 230 | #else //KAB_EMBEDDED |
231 | mCategoryCombo = new QComboBox( false, this ); | 231 | mCategoryCombo = new QComboBox( false, this ); |
232 | #endif //KAB_EMBEDDED | 232 | #endif //KAB_EMBEDDED |
233 | 233 | if ( QApplication::desktop()->width() < 320 ) | |
234 | mCategoryCombo->setMaximumWidth( 70 ); | ||
234 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::All ) ); | 235 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::All ) ); |
235 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Frequent ) ); | 236 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Frequent ) ); |
236 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Address ) ); | 237 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Address ) ); |
237 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Email ) ); | 238 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Email ) ); |
238 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Personal ) ); | 239 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Personal ) ); |
239 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Organization ) ); | 240 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Organization ) ); |
240 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::CustomCategory ) ); | 241 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::CustomCategory ) ); |
241 | connect( mCategoryCombo, SIGNAL( activated(int) ), SLOT( slotShowFields(int) ) ); | 242 | connect( mCategoryCombo, SIGNAL( activated(int) ), SLOT( slotShowFields(int) ) ); |
242 | gl->addWidget( mCategoryCombo, 0, 0 ); | 243 | gl->addWidget( mCategoryCombo, 0, 0 ); |
243 | 244 | ||
244 | QLabel *label = new QLabel( i18n( "&Selected fields:" ), this ); | 245 | QLabel *label = new QLabel( i18n( "&Selected\nfields:" ), this ); |
245 | if (orientation == 0) | 246 | if (orientation == 0) |
246 | gl->addWidget( label, 0, 2 ); | 247 | gl->addWidget( label, 0, 2 ); |
247 | else | 248 | else |
248 | gl->addWidget( label, 2, 0 ); | 249 | gl->addWidget( label, 2, 0 ); |
249 | 250 | ||
250 | 251 | ||
251 | mUnSelectedBox = new QListBox( this ); | 252 | mUnSelectedBox = new QListBox( this ); |
252 | mUnSelectedBox->setSelectionMode( QListBox::Extended ); | 253 | mUnSelectedBox->setSelectionMode( QListBox::Extended ); |
253 | mUnSelectedBox->setMinimumHeight( 100 ); | 254 | mUnSelectedBox->setMinimumHeight( 80 ); |
254 | if (orientation == 0) | 255 | if (orientation == 0) |
255 | gl->addWidget( mUnSelectedBox, 1, 0 ); | 256 | gl->addWidget( mUnSelectedBox, 1, 0 ); |
256 | else | 257 | else |
257 | gl->addWidget( mUnSelectedBox, 0, 1 ); | 258 | gl->addWidget( mUnSelectedBox, 0, 1 ); |
258 | 259 | ||
259 | mSelectedBox = new QListBox( this ); | 260 | mSelectedBox = new QListBox( this ); |
261 | //if ( QApplication::desktop()->width() < 320 ) { | ||
262 | // mUnSelectedBox->setMaximumWidth( 134 ); | ||
263 | // mSelectedBox->setMaximumWidth( 134 ); | ||
264 | //} | ||
260 | mSelectedBox->setSelectionMode( QListBox::Extended ); | 265 | mSelectedBox->setSelectionMode( QListBox::Extended ); |
266 | mSelectedBox->setMinimumHeight( 80 ); | ||
261 | label->setBuddy( mSelectedBox ); | 267 | label->setBuddy( mSelectedBox ); |
262 | if (orientation == 0) | 268 | if (orientation == 0) |
263 | gl->addWidget( mSelectedBox, 1, 2 ); | 269 | gl->addWidget( mSelectedBox, 1, 2 ); |
264 | else | 270 | else |
265 | gl->addWidget( mSelectedBox, 2, 1 ); | 271 | gl->addWidget( mSelectedBox, 2, 1 ); |
266 | 272 | ||
267 | QBoxLayout *vb1 = 0; | 273 | QBoxLayout *vb1 = 0; |
268 | if (orientation == 0) | 274 | if (orientation == 0) |
269 | vb1 = new QBoxLayout( QBoxLayout::TopToBottom, KDialog::spacingHint() ); | 275 | vb1 = new QBoxLayout( QBoxLayout::TopToBottom, KDialog::spacingHint() ); |
270 | else | 276 | else |
271 | vb1 = new QBoxLayout( QBoxLayout::LeftToRight, KDialog::spacingHint() ); | 277 | vb1 = new QBoxLayout( QBoxLayout::LeftToRight, KDialog::spacingHint() ); |
272 | 278 | ||
273 | vb1->addStretch(); | 279 | vb1->addStretch(); |
274 | 280 | ||
275 | mAddButton = new QToolButton( this ); | 281 | mAddButton = new QToolButton( this ); |
276 | if (orientation == 0) | 282 | if (orientation == 0) |
277 | mAddButton->setIconSet( SmallIconSet( "1rightarrow" ) ); | 283 | mAddButton->setIconSet( SmallIconSet( "1rightarrow" ) ); |
278 | else | 284 | else |
279 | mAddButton->setIconSet( SmallIconSet( "1downarrow" ) ); | 285 | mAddButton->setIconSet( SmallIconSet( "1downarrow" ) ); |
280 | connect( mAddButton, SIGNAL( clicked() ), SLOT( slotSelect() ) ); | 286 | connect( mAddButton, SIGNAL( clicked() ), SLOT( slotSelect() ) ); |
281 | vb1->addWidget( mAddButton ); | 287 | vb1->addWidget( mAddButton ); |
282 | 288 | ||
283 | mRemoveButton = new QToolButton( this ); | 289 | mRemoveButton = new QToolButton( this ); |
284 | if (orientation == 0) | 290 | if (orientation == 0) |
285 | mRemoveButton->setIconSet( SmallIconSet( "1leftarrow" ) ); | 291 | mRemoveButton->setIconSet( SmallIconSet( "1leftarrow" ) ); |
286 | else | 292 | else |
287 | mRemoveButton->setIconSet( SmallIconSet( "1uparrow" ) ); | 293 | mRemoveButton->setIconSet( SmallIconSet( "1uparrow" ) ); |
288 | 294 | ||
289 | connect( mRemoveButton, SIGNAL( clicked() ), SLOT( slotUnSelect() ) ); | 295 | connect( mRemoveButton, SIGNAL( clicked() ), SLOT( slotUnSelect() ) ); |
290 | vb1->addWidget( mRemoveButton ); | 296 | vb1->addWidget( mRemoveButton ); |
291 | 297 | ||
292 | vb1->addStretch(); | 298 | vb1->addStretch(); |
293 | if (orientation == 0) | 299 | if (orientation == 0) |
294 | gl->addLayout( vb1, 1, 1 ); | 300 | gl->addLayout( vb1, 1, 1 ); |
295 | else | 301 | else |
296 | gl->addLayout( vb1, 1, 1 ); | 302 | gl->addLayout( vb1, 1, 1 ); |
297 | 303 | ||
298 | QBoxLayout *vb2 = 0; | 304 | QBoxLayout *vb2 = 0; |
299 | if (orientation == 0) | 305 | if (orientation == 0) |
300 | vb2 = new QBoxLayout( QBoxLayout::TopToBottom, KDialog::spacingHint() ); | 306 | vb2 = new QBoxLayout( QBoxLayout::TopToBottom, KDialog::spacingHint() ); |
301 | else | 307 | else |
302 | vb2 = new QBoxLayout( QBoxLayout::LeftToRight, KDialog::spacingHint() ); | 308 | vb2 = new QBoxLayout( QBoxLayout::LeftToRight, KDialog::spacingHint() ); |
303 | 309 | ||
304 | vb2->addStretch(); | 310 | vb2->addStretch(); |
305 | 311 | ||
306 | mUpButton = new QToolButton( this ); | 312 | mUpButton = new QToolButton( this ); |
307 | mUpButton->setIconSet( SmallIconSet( "1uparrow" ) ); | 313 | mUpButton->setIconSet( SmallIconSet( "1uparrow" ) ); |
308 | connect( mUpButton, SIGNAL( clicked() ), SLOT( slotMoveUp() ) ); | 314 | connect( mUpButton, SIGNAL( clicked() ), SLOT( slotMoveUp() ) ); |
309 | vb2->addWidget( mUpButton ); | 315 | vb2->addWidget( mUpButton ); |
310 | 316 | ||
311 | mDownButton = new QToolButton( this ); | 317 | mDownButton = new QToolButton( this ); |
312 | mDownButton->setIconSet( SmallIconSet( "1downarrow" ) ); | 318 | mDownButton->setIconSet( SmallIconSet( "1downarrow" ) ); |
313 | connect( mDownButton, SIGNAL( clicked() ), SLOT( slotMoveDown() ) ); | 319 | connect( mDownButton, SIGNAL( clicked() ), SLOT( slotMoveDown() ) ); |
314 | vb2->addWidget( mDownButton ); | 320 | vb2->addWidget( mDownButton ); |
315 | 321 | ||
316 | vb2->addStretch(); | 322 | vb2->addStretch(); |
317 | if (orientation == 0) | 323 | if (orientation == 0) |
318 | gl->addLayout( vb2, 1, 3 ); | 324 | gl->addLayout( vb2, 1, 3 ); |
319 | else | 325 | else |
320 | gl->addLayout( vb2, 3, 1 ); | 326 | gl->addLayout( vb2, 3, 1 ); |
321 | 327 | ||
322 | QSize sizeHint = mUnSelectedBox->sizeHint(); | 328 | QSize sizeHint = mUnSelectedBox->sizeHint(); |
323 | 329 | ||
324 | // make sure we fill the list with all items, so that we can | 330 | // make sure we fill the list with all items, so that we can |
325 | // get the maxItemWidth we need to not truncate the view | 331 | // get the maxItemWidth we need to not truncate the view |
326 | slotShowFields( 0 ); | 332 | slotShowFields( 0 ); |
327 | 333 | ||
328 | sizeHint = sizeHint.expandedTo( mSelectedBox->sizeHint() ); | 334 | //sizeHint = sizeHint.expandedTo( mSelectedBox->sizeHint() ); |
329 | sizeHint.setWidth( mUnSelectedBox->maxItemWidth() ); | 335 | //sizeHint.setWidth( mUnSelectedBox->maxItemWidth() ); |
330 | mUnSelectedBox->setMinimumSize( sizeHint ); | 336 | // mUnSelectedBox->setMinimumSize( sizeHint ); |
331 | mSelectedBox->setMinimumSize( sizeHint ); | 337 | //mSelectedBox->setMinimumSize( sizeHint ); |
332 | 338 | ||
333 | gl->activate(); | 339 | gl->activate(); |
334 | 340 | ||
335 | connect( mUnSelectedBox, SIGNAL( selectionChanged() ), SLOT( slotButtonsEnabled() ) ); | 341 | connect( mUnSelectedBox, SIGNAL( selectionChanged() ), SLOT( slotButtonsEnabled() ) ); |
336 | connect( mSelectedBox, SIGNAL( selectionChanged() ), SLOT( slotButtonsEnabled() ) ); | 342 | connect( mSelectedBox, SIGNAL( selectionChanged() ), SLOT( slotButtonsEnabled() ) ); |
337 | connect( mSelectedBox, SIGNAL( currentChanged( QListBoxItem * ) ), SLOT( slotButtonsEnabled() ) ); | 343 | connect( mSelectedBox, SIGNAL( currentChanged( QListBoxItem * ) ), SLOT( slotButtonsEnabled() ) ); |
338 | 344 | ||
339 | slotButtonsEnabled(); | 345 | slotButtonsEnabled(); |
340 | } | 346 | } |
341 | 347 | ||
342 | 348 | ||
343 | #ifndef KAB_EMBEDDED | 349 | #ifndef KAB_EMBEDDED |
344 | #include "viewconfigurefieldspage.moc" | 350 | #include "viewconfigurefieldspage.moc" |
345 | #endif //KAB_EMBEDDED | 351 | #endif //KAB_EMBEDDED |