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 @@ #include <kdebug.h> #else //KAB_EMBEDDED #include <qcombobox.h> #endif //KAB_EMBEDDED #include <kiconloader.h> #include <kdialog.h> #include <klocale.h> #include <qtoolbutton.h> #include <qapplication.h> +#include <QDesktopWidget> #include <qlabel.h> -#include <qlistbox.h> +#include <q3listbox.h> #include <qlayout.h> +//Added by qt3to4: +#include <Q3GridLayout> +#include <Q3BoxLayout> #include "viewconfigurefieldspage.h" -class FieldItem : public QListBoxText +class FieldItem : public Q3ListBoxText { public: - FieldItem( QListBox *parent, KABC::Field *field ) - : QListBoxText( parent, field->label() ), mField( field ) {} + FieldItem( Q3ListBox *parent, KABC::Field *field ) + : Q3ListBoxText( parent, field->label() ), mField( field ) {} - FieldItem( QListBox *parent, KABC::Field *field, int index ) - : QListBoxText( parent, field->label(), parent->item( index ) ), + FieldItem( Q3ListBox *parent, KABC::Field *field, int index ) + : Q3ListBoxText( parent, field->label(), parent->item( index ) ), mField( field ) {} KABC::Field *field() { return mField; } private: KABC::Field *mField; }; ViewConfigureFieldsPage::ViewConfigureFieldsPage( KABC::AddressBook *ab, QWidget *parent, const char *name ) @@ -97,25 +101,25 @@ void ViewConfigureFieldsPage::slotShowFields( int index ) { int currentPos = mUnSelectedBox->currentItem(); mUnSelectedBox->clear(); int category; if ( index == 0 ) category = KABC::Field::All; else category = 1 << ( index - 1 ); KABC::Field::List allFields = mAddressBook->fields( category ); KABC::Field::List::ConstIterator it; for ( it = allFields.begin(); it != allFields.end(); ++it ) { - QListBoxItem *item = mSelectedBox->firstItem(); + Q3ListBoxItem *item = mSelectedBox->firstItem(); while( item ) { FieldItem *fieldItem = static_cast<FieldItem *>( item ); if ( (*it)->equals( fieldItem->field() ) ) break; item = item->next(); } if ( !item ) new FieldItem( mUnSelectedBox, *it ); } mUnSelectedBox->sort(); @@ -180,59 +184,59 @@ void ViewConfigureFieldsPage::slotButtonsEnabled() //US QListBoxItem::isSelected()) is not available in QT 2.x. Use selected instead. if ( mSelectedBox->item( i )->selected() ) { state = true; break; } mRemoveButton->setEnabled( state ); } void ViewConfigureFieldsPage::slotMoveUp() { int i = mSelectedBox->currentItem(); if ( i > 0 ) { - QListBoxItem *item = mSelectedBox->item( i ); + Q3ListBoxItem *item = mSelectedBox->item( i ); mSelectedBox->takeItem( item ); mSelectedBox->insertItem( item, i - 1 ); mSelectedBox->setCurrentItem( item ); mSelectedBox->setSelected( i - 1, true ); } } void ViewConfigureFieldsPage::slotMoveDown() { int i = mSelectedBox->currentItem(); if ( i > -1 && i < (int)mSelectedBox->count() - 1 ) { - QListBoxItem *item = mSelectedBox->item( i ); + Q3ListBoxItem *item = mSelectedBox->item( i ); mSelectedBox->takeItem( item ); mSelectedBox->insertItem( item, i + 1 ); mSelectedBox->setCurrentItem( item ); mSelectedBox->setSelected( i + 1, true ); } } void ViewConfigureFieldsPage::initGUI() { //US change the orientation dependent on the following flag // right the flag is set only staticly. // 0 = 640x480 ; 1 = 240x320 bool orientation = 1; setCaption( i18n("Select Fields to Display") ); - QGridLayout *gl = 0; + Q3GridLayout *gl = 0; if (orientation == 0) - gl = new QGridLayout( this , 6, 4, 0, KDialog::spacingHint() ); + gl = new Q3GridLayout( this , 6, 4, 0, KDialog::spacingHint() ); else - gl = new QGridLayout( this , 4, 6, 0, KDialog::spacingHint() ); + gl = new Q3GridLayout( this , 4, 6, 0, KDialog::spacingHint() ); #ifndef KAB_EMBEDDED mCategoryCombo = new KComboBox( false, this ); #else //KAB_EMBEDDED mCategoryCombo = new QComboBox( false, this ); #endif //KAB_EMBEDDED if ( QApplication::desktop()->width() < 320 ) mCategoryCombo->setMaximumWidth( 70 ); mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::All ) ); mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Frequent ) ); mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Address ) ); mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Email ) ); @@ -240,50 +244,50 @@ void ViewConfigureFieldsPage::initGUI() mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::Organization ) ); mCategoryCombo->insertItem( KABC::Field::categoryLabel( KABC::Field::CustomCategory ) ); connect( mCategoryCombo, SIGNAL( activated(int) ), SLOT( slotShowFields(int) ) ); gl->addWidget( mCategoryCombo, 0, 0 ); QLabel *label = new QLabel( i18n( "&Selected\nfields:" ), this ); if (orientation == 0) gl->addWidget( label, 0, 2 ); else gl->addWidget( label, 2, 0 ); - mUnSelectedBox = new QListBox( this ); - mUnSelectedBox->setSelectionMode( QListBox::Extended ); + mUnSelectedBox = new Q3ListBox( this ); + mUnSelectedBox->setSelectionMode( Q3ListBox::Extended ); mUnSelectedBox->setMinimumHeight( 80 ); if (orientation == 0) gl->addWidget( mUnSelectedBox, 1, 0 ); else gl->addWidget( mUnSelectedBox, 0, 1 ); - mSelectedBox = new QListBox( this ); + mSelectedBox = new Q3ListBox( this ); //if ( QApplication::desktop()->width() < 320 ) { // mUnSelectedBox->setMaximumWidth( 134 ); // mSelectedBox->setMaximumWidth( 134 ); //} - mSelectedBox->setSelectionMode( QListBox::Extended ); + mSelectedBox->setSelectionMode( Q3ListBox::Extended ); mSelectedBox->setMinimumHeight( 80 ); label->setBuddy( mSelectedBox ); if (orientation == 0) gl->addWidget( mSelectedBox, 1, 2 ); else gl->addWidget( mSelectedBox, 2, 1 ); - QBoxLayout *vb1 = 0; + Q3BoxLayout *vb1 = 0; if (orientation == 0) - vb1 = new QBoxLayout( QBoxLayout::TopToBottom, KDialog::spacingHint() ); + vb1 = new Q3BoxLayout( Q3BoxLayout::TopToBottom, KDialog::spacingHint() ); else - vb1 = new QBoxLayout( QBoxLayout::LeftToRight, KDialog::spacingHint() ); + vb1 = new Q3BoxLayout( Q3BoxLayout::LeftToRight, KDialog::spacingHint() ); vb1->addStretch(); mAddButton = new QToolButton( this ); if (orientation == 0) mAddButton->setIconSet( SmallIconSet( "1rightarrow" ) ); else mAddButton->setIconSet( SmallIconSet( "1downarrow" ) ); connect( mAddButton, SIGNAL( clicked() ), SLOT( slotSelect() ) ); vb1->addWidget( mAddButton ); mRemoveButton = new QToolButton( this ); @@ -292,29 +296,29 @@ void ViewConfigureFieldsPage::initGUI() else mRemoveButton->setIconSet( SmallIconSet( "1uparrow" ) ); connect( mRemoveButton, SIGNAL( clicked() ), SLOT( slotUnSelect() ) ); vb1->addWidget( mRemoveButton ); vb1->addStretch(); if (orientation == 0) gl->addLayout( vb1, 1, 1 ); else gl->addLayout( vb1, 1, 1 ); - QBoxLayout *vb2 = 0; + Q3BoxLayout *vb2 = 0; if (orientation == 0) - vb2 = new QBoxLayout( QBoxLayout::TopToBottom, KDialog::spacingHint() ); + vb2 = new Q3BoxLayout( Q3BoxLayout::TopToBottom, KDialog::spacingHint() ); else - vb2 = new QBoxLayout( QBoxLayout::LeftToRight, KDialog::spacingHint() ); + vb2 = new Q3BoxLayout( Q3BoxLayout::LeftToRight, KDialog::spacingHint() ); vb2->addStretch(); mUpButton = new QToolButton( this ); mUpButton->setIconSet( SmallIconSet( "1uparrow" ) ); connect( mUpButton, SIGNAL( clicked() ), SLOT( slotMoveUp() ) ); vb2->addWidget( mUpButton ); mDownButton = new QToolButton( this ); mDownButton->setIconSet( SmallIconSet( "1downarrow" ) ); connect( mDownButton, SIGNAL( clicked() ), SLOT( slotMoveDown() ) ); vb2->addWidget( mDownButton ); @@ -331,21 +335,21 @@ void ViewConfigureFieldsPage::initGUI() // get the maxItemWidth we need to not truncate the view slotShowFields( 0 ); //sizeHint = sizeHint.expandedTo( mSelectedBox->sizeHint() ); //sizeHint.setWidth( mUnSelectedBox->maxItemWidth() ); // mUnSelectedBox->setMinimumSize( sizeHint ); //mSelectedBox->setMinimumSize( sizeHint ); gl->activate(); connect( mUnSelectedBox, SIGNAL( selectionChanged() ), SLOT( slotButtonsEnabled() ) ); connect( mSelectedBox, SIGNAL( selectionChanged() ), SLOT( slotButtonsEnabled() ) ); - connect( mSelectedBox, SIGNAL( currentChanged( QListBoxItem * ) ), SLOT( slotButtonsEnabled() ) ); + connect( mSelectedBox, SIGNAL( currentChanged( Q3ListBoxItem * ) ), SLOT( slotButtonsEnabled() ) ); slotButtonsEnabled(); } -#ifndef KAB_EMBEDDED -#include "viewconfigurefieldspage.moc" +#ifndef KAB_EMBEDDED_ +#include "moc_viewconfigurefieldspage.cpp" #endif //KAB_EMBEDDED |