author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kaddressbook/viewconfigurefieldspage.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-p1.zip kdepimpi-p1.tar.gz kdepimpi-p1.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'kaddressbook/viewconfigurefieldspage.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/viewconfigurefieldspage.cpp | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/kaddressbook/viewconfigurefieldspage.cpp b/kaddressbook/viewconfigurefieldspage.cpp index 5daae1a..7366a0b 100644 --- a/kaddressbook/viewconfigurefieldspage.cpp +++ b/kaddressbook/viewconfigurefieldspage.cpp | |||
@@ -27,38 +27,42 @@ | |||
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 <qapplication.h> |
39 | #include <QDesktopWidget> | ||
39 | #include <qlabel.h> | 40 | #include <qlabel.h> |
40 | #include <qlistbox.h> | 41 | #include <q3listbox.h> |
41 | #include <qlayout.h> | 42 | #include <qlayout.h> |
43 | //Added by qt3to4: | ||
44 | #include <Q3GridLayout> | ||
45 | #include <Q3BoxLayout> | ||
42 | 46 | ||
43 | #include "viewconfigurefieldspage.h" | 47 | #include "viewconfigurefieldspage.h" |
44 | 48 | ||
45 | class FieldItem : public QListBoxText | 49 | class FieldItem : public Q3ListBoxText |
46 | { | 50 | { |
47 | public: | 51 | public: |
48 | FieldItem( QListBox *parent, KABC::Field *field ) | 52 | FieldItem( Q3ListBox *parent, KABC::Field *field ) |
49 | : QListBoxText( parent, field->label() ), mField( field ) {} | 53 | : Q3ListBoxText( parent, field->label() ), mField( field ) {} |
50 | 54 | ||
51 | FieldItem( QListBox *parent, KABC::Field *field, int index ) | 55 | FieldItem( Q3ListBox *parent, KABC::Field *field, int index ) |
52 | : QListBoxText( parent, field->label(), parent->item( index ) ), | 56 | : Q3ListBoxText( parent, field->label(), parent->item( index ) ), |
53 | mField( field ) {} | 57 | mField( field ) {} |
54 | 58 | ||
55 | KABC::Field *field() { return mField; } | 59 | KABC::Field *field() { return mField; } |
56 | 60 | ||
57 | private: | 61 | private: |
58 | KABC::Field *mField; | 62 | KABC::Field *mField; |
59 | }; | 63 | }; |
60 | 64 | ||
61 | 65 | ||
62 | ViewConfigureFieldsPage::ViewConfigureFieldsPage( KABC::AddressBook *ab, | 66 | ViewConfigureFieldsPage::ViewConfigureFieldsPage( KABC::AddressBook *ab, |
63 | QWidget *parent, | 67 | QWidget *parent, |
64 | const char *name ) | 68 | const char *name ) |
@@ -97,25 +101,25 @@ void ViewConfigureFieldsPage::slotShowFields( int index ) | |||
97 | { | 101 | { |
98 | int currentPos = mUnSelectedBox->currentItem(); | 102 | int currentPos = mUnSelectedBox->currentItem(); |
99 | mUnSelectedBox->clear(); | 103 | mUnSelectedBox->clear(); |
100 | 104 | ||
101 | int category; | 105 | int category; |
102 | if ( index == 0 ) category = KABC::Field::All; | 106 | if ( index == 0 ) category = KABC::Field::All; |
103 | else category = 1 << ( index - 1 ); | 107 | else category = 1 << ( index - 1 ); |
104 | 108 | ||
105 | KABC::Field::List allFields = mAddressBook->fields( category ); | 109 | KABC::Field::List allFields = mAddressBook->fields( category ); |
106 | 110 | ||
107 | KABC::Field::List::ConstIterator it; | 111 | KABC::Field::List::ConstIterator it; |
108 | for ( it = allFields.begin(); it != allFields.end(); ++it ) { | 112 | for ( it = allFields.begin(); it != allFields.end(); ++it ) { |
109 | QListBoxItem *item = mSelectedBox->firstItem(); | 113 | Q3ListBoxItem *item = mSelectedBox->firstItem(); |
110 | while( item ) { | 114 | while( item ) { |
111 | FieldItem *fieldItem = static_cast<FieldItem *>( item ); | 115 | FieldItem *fieldItem = static_cast<FieldItem *>( item ); |
112 | if ( (*it)->equals( fieldItem->field() ) ) | 116 | if ( (*it)->equals( fieldItem->field() ) ) |
113 | break; | 117 | break; |
114 | item = item->next(); | 118 | item = item->next(); |
115 | } | 119 | } |
116 | 120 | ||
117 | if ( !item ) | 121 | if ( !item ) |
118 | new FieldItem( mUnSelectedBox, *it ); | 122 | new FieldItem( mUnSelectedBox, *it ); |
119 | } | 123 | } |
120 | 124 | ||
121 | mUnSelectedBox->sort(); | 125 | mUnSelectedBox->sort(); |
@@ -180,59 +184,59 @@ void ViewConfigureFieldsPage::slotButtonsEnabled() | |||
180 | //US QListBoxItem::isSelected()) is not available in QT 2.x. Use selected instead. | 184 | //US QListBoxItem::isSelected()) is not available in QT 2.x. Use selected instead. |
181 | if ( mSelectedBox->item( i )->selected() ) { | 185 | if ( mSelectedBox->item( i )->selected() ) { |
182 | state = true; | 186 | state = true; |
183 | break; | 187 | break; |
184 | } | 188 | } |
185 | mRemoveButton->setEnabled( state ); | 189 | mRemoveButton->setEnabled( state ); |
186 | } | 190 | } |
187 | 191 | ||
188 | void ViewConfigureFieldsPage::slotMoveUp() | 192 | void ViewConfigureFieldsPage::slotMoveUp() |
189 | { | 193 | { |
190 | int i = mSelectedBox->currentItem(); | 194 | int i = mSelectedBox->currentItem(); |
191 | if ( i > 0 ) { | 195 | if ( i > 0 ) { |
192 | QListBoxItem *item = mSelectedBox->item( i ); | 196 | Q3ListBoxItem *item = mSelectedBox->item( i ); |
193 | mSelectedBox->takeItem( item ); | 197 | mSelectedBox->takeItem( item ); |
194 | mSelectedBox->insertItem( item, i - 1 ); | 198 | mSelectedBox->insertItem( item, i - 1 ); |
195 | mSelectedBox->setCurrentItem( item ); | 199 | mSelectedBox->setCurrentItem( item ); |
196 | mSelectedBox->setSelected( i - 1, true ); | 200 | mSelectedBox->setSelected( i - 1, true ); |
197 | } | 201 | } |
198 | } | 202 | } |
199 | 203 | ||
200 | void ViewConfigureFieldsPage::slotMoveDown() | 204 | void ViewConfigureFieldsPage::slotMoveDown() |
201 | { | 205 | { |
202 | int i = mSelectedBox->currentItem(); | 206 | int i = mSelectedBox->currentItem(); |
203 | if ( i > -1 && i < (int)mSelectedBox->count() - 1 ) { | 207 | if ( i > -1 && i < (int)mSelectedBox->count() - 1 ) { |
204 | QListBoxItem *item = mSelectedBox->item( i ); | 208 | Q3ListBoxItem *item = mSelectedBox->item( i ); |
205 | mSelectedBox->takeItem( item ); | 209 | mSelectedBox->takeItem( item ); |
206 | mSelectedBox->insertItem( item, i + 1 ); | 210 | mSelectedBox->insertItem( item, i + 1 ); |
207 | mSelectedBox->setCurrentItem( item ); | 211 | mSelectedBox->setCurrentItem( item ); |
208 | mSelectedBox->setSelected( i + 1, true ); | 212 | mSelectedBox->setSelected( i + 1, true ); |
209 | } | 213 | } |
210 | } | 214 | } |
211 | 215 | ||
212 | void ViewConfigureFieldsPage::initGUI() | 216 | void ViewConfigureFieldsPage::initGUI() |
213 | { | 217 | { |
214 | //US change the orientation dependent on the following flag | 218 | //US change the orientation dependent on the following flag |
215 | // right the flag is set only staticly. | 219 | // right the flag is set only staticly. |
216 | // 0 = 640x480 ; 1 = 240x320 | 220 | // 0 = 640x480 ; 1 = 240x320 |
217 | bool orientation = 1; | 221 | bool orientation = 1; |
218 | 222 | ||
219 | 223 | ||
220 | setCaption( i18n("Select Fields to Display") ); | 224 | setCaption( i18n("Select Fields to Display") ); |
221 | 225 | ||
222 | QGridLayout *gl = 0; | 226 | Q3GridLayout *gl = 0; |
223 | if (orientation == 0) | 227 | if (orientation == 0) |
224 | gl = new QGridLayout( this , 6, 4, 0, KDialog::spacingHint() ); | 228 | gl = new Q3GridLayout( this , 6, 4, 0, KDialog::spacingHint() ); |
225 | else | 229 | else |
226 | gl = new QGridLayout( this , 4, 6, 0, KDialog::spacingHint() ); | 230 | gl = new Q3GridLayout( this , 4, 6, 0, KDialog::spacingHint() ); |
227 | 231 | ||
228 | #ifndef KAB_EMBEDDED | 232 | #ifndef KAB_EMBEDDED |
229 | mCategoryCombo = new KComboBox( false, this ); | 233 | mCategoryCombo = new KComboBox( false, this ); |
230 | #else //KAB_EMBEDDED | 234 | #else //KAB_EMBEDDED |
231 | mCategoryCombo = new QComboBox( false, this ); | 235 | mCategoryCombo = new QComboBox( false, this ); |
232 | #endif //KAB_EMBEDDED | 236 | #endif //KAB_EMBEDDED |
233 | if ( QApplication::desktop()->width() < 320 ) | 237 | if ( QApplication::desktop()->width() < 320 ) |
234 | mCategoryCombo->setMaximumWidth( 70 ); | 238 | mCategoryCombo->setMaximumWidth( 70 ); |
235 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::All ) ); | 239 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::All ) ); |
236 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Frequent ) ); | 240 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Frequent ) ); |
237 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Address ) ); | 241 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Address ) ); |
238 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Email ) ); | 242 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Email ) ); |
@@ -240,50 +244,50 @@ void ViewConfigureFieldsPage::initGUI() | |||
240 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Organization ) ); | 244 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Organization ) ); |
241 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::CustomCategory ) ); | 245 | mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::CustomCategory ) ); |
242 | connect( mCategoryCombo, SIGNAL( activated(int) ), SLOT( slotShowFields(int) ) ); | 246 | connect( mCategoryCombo, SIGNAL( activated(int) ), SLOT( slotShowFields(int) ) ); |
243 | gl->addWidget( mCategoryCombo, 0, 0 ); | 247 | gl->addWidget( mCategoryCombo, 0, 0 ); |
244 | 248 | ||
245 | QLabel *label = new QLabel( i18n( "&Selected\nfields:" ), this ); | 249 | QLabel *label = new QLabel( i18n( "&Selected\nfields:" ), this ); |
246 | if (orientation == 0) | 250 | if (orientation == 0) |
247 | gl->addWidget( label, 0, 2 ); | 251 | gl->addWidget( label, 0, 2 ); |
248 | else | 252 | else |
249 | gl->addWidget( label, 2, 0 ); | 253 | gl->addWidget( label, 2, 0 ); |
250 | 254 | ||
251 | 255 | ||
252 | mUnSelectedBox = new QListBox( this ); | 256 | mUnSelectedBox = new Q3ListBox( this ); |
253 | mUnSelectedBox->setSelectionMode( QListBox::Extended ); | 257 | mUnSelectedBox->setSelectionMode( Q3ListBox::Extended ); |
254 | mUnSelectedBox->setMinimumHeight( 80 ); | 258 | mUnSelectedBox->setMinimumHeight( 80 ); |
255 | if (orientation == 0) | 259 | if (orientation == 0) |
256 | gl->addWidget( mUnSelectedBox, 1, 0 ); | 260 | gl->addWidget( mUnSelectedBox, 1, 0 ); |
257 | else | 261 | else |
258 | gl->addWidget( mUnSelectedBox, 0, 1 ); | 262 | gl->addWidget( mUnSelectedBox, 0, 1 ); |
259 | 263 | ||
260 | mSelectedBox = new QListBox( this ); | 264 | mSelectedBox = new Q3ListBox( this ); |
261 | //if ( QApplication::desktop()->width() < 320 ) { | 265 | //if ( QApplication::desktop()->width() < 320 ) { |
262 | // mUnSelectedBox->setMaximumWidth( 134 ); | 266 | // mUnSelectedBox->setMaximumWidth( 134 ); |
263 | // mSelectedBox->setMaximumWidth( 134 ); | 267 | // mSelectedBox->setMaximumWidth( 134 ); |
264 | //} | 268 | //} |
265 | mSelectedBox->setSelectionMode( QListBox::Extended ); | 269 | mSelectedBox->setSelectionMode( Q3ListBox::Extended ); |
266 | mSelectedBox->setMinimumHeight( 80 ); | 270 | mSelectedBox->setMinimumHeight( 80 ); |
267 | label->setBuddy( mSelectedBox ); | 271 | label->setBuddy( mSelectedBox ); |
268 | if (orientation == 0) | 272 | if (orientation == 0) |
269 | gl->addWidget( mSelectedBox, 1, 2 ); | 273 | gl->addWidget( mSelectedBox, 1, 2 ); |
270 | else | 274 | else |
271 | gl->addWidget( mSelectedBox, 2, 1 ); | 275 | gl->addWidget( mSelectedBox, 2, 1 ); |
272 | 276 | ||
273 | QBoxLayout *vb1 = 0; | 277 | Q3BoxLayout *vb1 = 0; |
274 | if (orientation == 0) | 278 | if (orientation == 0) |
275 | vb1 = new QBoxLayout( QBoxLayout::TopToBottom, KDialog::spacingHint() ); | 279 | vb1 = new Q3BoxLayout( Q3BoxLayout::TopToBottom, KDialog::spacingHint() ); |
276 | else | 280 | else |
277 | vb1 = new QBoxLayout( QBoxLayout::LeftToRight, KDialog::spacingHint() ); | 281 | vb1 = new Q3BoxLayout( Q3BoxLayout::LeftToRight, KDialog::spacingHint() ); |
278 | 282 | ||
279 | vb1->addStretch(); | 283 | vb1->addStretch(); |
280 | 284 | ||
281 | mAddButton = new QToolButton( this ); | 285 | mAddButton = new QToolButton( this ); |
282 | if (orientation == 0) | 286 | if (orientation == 0) |
283 | mAddButton->setIconSet( SmallIconSet( "1rightarrow" ) ); | 287 | mAddButton->setIconSet( SmallIconSet( "1rightarrow" ) ); |
284 | else | 288 | else |
285 | mAddButton->setIconSet( SmallIconSet( "1downarrow" ) ); | 289 | mAddButton->setIconSet( SmallIconSet( "1downarrow" ) ); |
286 | connect( mAddButton, SIGNAL( clicked() ), SLOT( slotSelect() ) ); | 290 | connect( mAddButton, SIGNAL( clicked() ), SLOT( slotSelect() ) ); |
287 | vb1->addWidget( mAddButton ); | 291 | vb1->addWidget( mAddButton ); |
288 | 292 | ||
289 | mRemoveButton = new QToolButton( this ); | 293 | mRemoveButton = new QToolButton( this ); |
@@ -292,29 +296,29 @@ void ViewConfigureFieldsPage::initGUI() | |||
292 | else | 296 | else |
293 | mRemoveButton->setIconSet( SmallIconSet( "1uparrow" ) ); | 297 | mRemoveButton->setIconSet( SmallIconSet( "1uparrow" ) ); |
294 | 298 | ||
295 | connect( mRemoveButton, SIGNAL( clicked() ), SLOT( slotUnSelect() ) ); | 299 | connect( mRemoveButton, SIGNAL( clicked() ), SLOT( slotUnSelect() ) ); |
296 | vb1->addWidget( mRemoveButton ); | 300 | vb1->addWidget( mRemoveButton ); |
297 | 301 | ||
298 | vb1->addStretch(); | 302 | vb1->addStretch(); |
299 | if (orientation == 0) | 303 | if (orientation == 0) |
300 | gl->addLayout( vb1, 1, 1 ); | 304 | gl->addLayout( vb1, 1, 1 ); |
301 | else | 305 | else |
302 | gl->addLayout( vb1, 1, 1 ); | 306 | gl->addLayout( vb1, 1, 1 ); |
303 | 307 | ||
304 | QBoxLayout *vb2 = 0; | 308 | Q3BoxLayout *vb2 = 0; |
305 | if (orientation == 0) | 309 | if (orientation == 0) |
306 | vb2 = new QBoxLayout( QBoxLayout::TopToBottom, KDialog::spacingHint() ); | 310 | vb2 = new Q3BoxLayout( Q3BoxLayout::TopToBottom, KDialog::spacingHint() ); |
307 | else | 311 | else |
308 | vb2 = new QBoxLayout( QBoxLayout::LeftToRight, KDialog::spacingHint() ); | 312 | vb2 = new Q3BoxLayout( Q3BoxLayout::LeftToRight, KDialog::spacingHint() ); |
309 | 313 | ||
310 | vb2->addStretch(); | 314 | vb2->addStretch(); |
311 | 315 | ||
312 | mUpButton = new QToolButton( this ); | 316 | mUpButton = new QToolButton( this ); |
313 | mUpButton->setIconSet( SmallIconSet( "1uparrow" ) ); | 317 | mUpButton->setIconSet( SmallIconSet( "1uparrow" ) ); |
314 | connect( mUpButton, SIGNAL( clicked() ), SLOT( slotMoveUp() ) ); | 318 | connect( mUpButton, SIGNAL( clicked() ), SLOT( slotMoveUp() ) ); |
315 | vb2->addWidget( mUpButton ); | 319 | vb2->addWidget( mUpButton ); |
316 | 320 | ||
317 | mDownButton = new QToolButton( this ); | 321 | mDownButton = new QToolButton( this ); |
318 | mDownButton->setIconSet( SmallIconSet( "1downarrow" ) ); | 322 | mDownButton->setIconSet( SmallIconSet( "1downarrow" ) ); |
319 | connect( mDownButton, SIGNAL( clicked() ), SLOT( slotMoveDown() ) ); | 323 | connect( mDownButton, SIGNAL( clicked() ), SLOT( slotMoveDown() ) ); |
320 | vb2->addWidget( mDownButton ); | 324 | vb2->addWidget( mDownButton ); |
@@ -331,21 +335,21 @@ void ViewConfigureFieldsPage::initGUI() | |||
331 | // get the maxItemWidth we need to not truncate the view | 335 | // get the maxItemWidth we need to not truncate the view |
332 | slotShowFields( 0 ); | 336 | slotShowFields( 0 ); |
333 | 337 | ||
334 | //sizeHint = sizeHint.expandedTo( mSelectedBox->sizeHint() ); | 338 | //sizeHint = sizeHint.expandedTo( mSelectedBox->sizeHint() ); |
335 | //sizeHint.setWidth( mUnSelectedBox->maxItemWidth() ); | 339 | //sizeHint.setWidth( mUnSelectedBox->maxItemWidth() ); |
336 | // mUnSelectedBox->setMinimumSize( sizeHint ); | 340 | // mUnSelectedBox->setMinimumSize( sizeHint ); |
337 | //mSelectedBox->setMinimumSize( sizeHint ); | 341 | //mSelectedBox->setMinimumSize( sizeHint ); |
338 | 342 | ||
339 | gl->activate(); | 343 | gl->activate(); |
340 | 344 | ||
341 | connect( mUnSelectedBox, SIGNAL( selectionChanged() ), SLOT( slotButtonsEnabled() ) ); | 345 | connect( mUnSelectedBox, SIGNAL( selectionChanged() ), SLOT( slotButtonsEnabled() ) ); |
342 | connect( mSelectedBox, SIGNAL( selectionChanged() ), SLOT( slotButtonsEnabled() ) ); | 346 | connect( mSelectedBox, SIGNAL( selectionChanged() ), SLOT( slotButtonsEnabled() ) ); |
343 | connect( mSelectedBox, SIGNAL( currentChanged( QListBoxItem * ) ), SLOT( slotButtonsEnabled() ) ); | 347 | connect( mSelectedBox, SIGNAL( currentChanged( Q3ListBoxItem * ) ), SLOT( slotButtonsEnabled() ) ); |
344 | 348 | ||
345 | slotButtonsEnabled(); | 349 | slotButtonsEnabled(); |
346 | } | 350 | } |
347 | 351 | ||
348 | 352 | ||
349 | #ifndef KAB_EMBEDDED | 353 | #ifndef KAB_EMBEDDED_ |
350 | #include "viewconfigurefieldspage.moc" | 354 | #include "moc_viewconfigurefieldspage.cpp" |
351 | #endif //KAB_EMBEDDED | 355 | #endif //KAB_EMBEDDED |